public/be-assets/node_modules/@yaireo/tagify/dist/tagify.esm.js
/**
   * pre-proccess the tagsItems, which can be a complex tagsItems like an Array of Objects or a string comprised of multiple words
   * so each item should be iterated on and a tag created for.
   * @return {Array} [Array of Objects]
   */
pre-proccess the tagsItems, which can be a complex tagsItems like an Array of Objects or a string comprised of multiple words
so each item should be iterated on and a tag created for.
@return {Array} [Array of Objects]
pre - proccess the tagsItems which can be a complex tagsItems like an Array of Objects or a string comprised of multiple words so each item should be iterated on and a tag created for . @return { Array } [ Array of Objects ]
normalizeTags(tagsItems) {
    var _this$settings = this.settings,
        whitelist = _this$settings.whitelist,
        delimiters = _this$settings.delimiters,
        mode = _this$settings.mode,
        tagTextProp = _this$settings.tagTextProp;
        _this$settings.enforceWhitelist;
        var whitelistMatches = [],
        whitelistWithProps = whitelist ? whitelist[0] instanceof Object : false,
        isArray = tagsItems instanceof Array,
        mapStringToCollection = s => (s + "").split(delimiters).filter(n => n).map(v => ({
      [tagTextProp]: this.trim(v),
      value: this.trim(v)
    }));
    if (typeof tagsItems == 'number') tagsItems = tagsItems.toString(); 
    if (typeof tagsItems == 'string') {
      if (!tagsItems.trim()) return []; 
      tagsItems = mapStringToCollection(tagsItems);
    } 
    else if (isArray) {
      tagsItems = [].concat(...tagsItems.map(item => item.value ? item 
      : mapStringToCollection(item)));
    } 
    if (whitelistWithProps) {
      tagsItems.forEach(item => {
        var whitelistMatchesValues = whitelistMatches.map(a => a.value); 
        var filteredList = this.dropdown.filterListItems.call(this, item[tagTextProp], {
          exact: true
        });
        if (!this.settings.duplicates) 
          filteredList = filteredList.filter(filteredItem => !whitelistMatchesValues.includes(filteredItem.value)); 
        var matchObj = filteredList.length > 1 ? this.getWhitelistItem(item[tagTextProp], tagTextProp, filteredList) : filteredList[0];
        if (matchObj && matchObj instanceof Object) {
          whitelistMatches.push(matchObj); 
        } else if (mode != 'mix') {
          if (item.value == undefined) item.value = item[tagTextProp];
          whitelistMatches.push(item);
        }
      });
      if (whitelistMatches.length) tagsItems = whitelistMatches;
    }
    return tagsItems;
  }
normalizeTags ( tagsItems ) { var _this$settings = this . settings , whitelist = _this$settings . whitelist , delimiters = _this$settings . delimiters , mode = _this$settings . mode , tagTextProp = _this$settings . tagTextProp ; _this$settings . enforceWhitelist ; var whitelistMatches = [ ] , whitelistWithProps = whitelist ? whitelist [ 0 ] instanceof Object : false , isArray = tagsItems instanceof Array , mapStringToCollection = s => ( s + "" ) . split ( delimiters ) . filter ( n => n ) . map ( v => ( { [ tagTextProp ] : this . trim ( v ) , value : this . trim ( v ) } ) ) ; if ( typeof tagsItems == 'number' ) tagsItems = tagsItems . toString ( ) ; if ( typeof tagsItems == 'string' ) { if ( ! tagsItems . trim ( ) ) return [ ] ; tagsItems = mapStringToCollection ( tagsItems ) ; } else if ( isArray ) { tagsItems = [ ] . concat ( ... tagsItems . map ( item => item . value ? item : mapStringToCollection ( item ) ) ) ; } if ( whitelistWithProps ) { tagsItems . forEach ( item => { var whitelistMatchesValues = whitelistMatches . map ( a => a . value ) ; var filteredList = this . dropdown . filterListItems . call ( this , item [ tagTextProp ] , { exact : true } ) ; if ( ! this . settings . duplicates ) filteredList = filteredList . filter ( filteredItem => ! whitelistMatchesValues . includes ( filteredItem . value ) ) ; var matchObj = filteredList . length > 1 ? this . getWhitelistItem ( item [ tagTextProp ] , tagTextProp , filteredList ) : filteredList [ 0 ] ; if ( matchObj && matchObj instanceof Object ) { whitelistMatches . push ( matchObj ) ; } else if ( mode != 'mix' ) { if ( item . value == undefined ) item . value = item [ tagTextProp ] ; whitelistMatches . push ( item ) ; } } ) ; if ( whitelistMatches . length ) tagsItems = whitelistMatches ; } return tagsItems ; }
pre-proccess the tagsItems, which can be a complex tagsItems like an Array of Objects or a string comprised of multiple words
 so each item should be iterated on and a tag created for.
pre - proccess the tagsItems which can be a complex tagsItems like an Array of Objects or a string comprised of multiple words so each item should be iterated on and a tag created for .
// if the argument is a "simple" String, ex: "aaa, bbb, ccc" // go over each tag and add it (if there were multiple ones) // is is an Array of Strings, convert to an Array of Objects // flatten the 2D array // mapStringToCollection(item.value).map(newItem => ({...item,...newItem})) // search if the tag exists in the whitelist as an Object (has props), // to be able to use its properties // if suggestions are shown, they are already filtered, so it's easier to use them, // because the whitelist might also include items which have already been added // also filter out items which have already been matched in previous iterations // get the best match out of list of possible matches. // if there was a single item in the filtered list, use that one // set the Array (with the found Object) as the new value