System.register(['src/external/focalStorage.js'], function (_export, _context) {
  "use strict";

  var focalStorage;
  return {
    setters: [function (_srcExternalFocalStorageJs) {
      focalStorage = _srcExternalFocalStorageJs.default;
    }],
    execute: function () {
      _recorder_._src_client_favorites_js = _recorder_._src_client_favorites_js || {};
      _recorder_._src_client_favorites_js.removeMainDirectory = removeMainDirectory;
      _recorder_._src_client_favorites_js.toFullURL = toFullURL;
      _recorder_._src_client_favorites_js.focalStorage = focalStorage;


      const MAIN_DIRECTORY = lively4url + '/';
      _recorder_._src_client_favorites_js.MAIN_DIRECTORY = MAIN_DIRECTORY;
      const MATCH_MAIN_DIRECTORY = new RegExp('^' + _recorder_._src_client_favorites_js.MAIN_DIRECTORY, 'i');
      _recorder_._src_client_favorites_js.MATCH_MAIN_DIRECTORY = MATCH_MAIN_DIRECTORY;
      const STORAGE_KEY = 'favorite-files';

      _recorder_._src_client_favorites_js.STORAGE_KEY = STORAGE_KEY;
      function toFullURL(url) {
        return new URL(url, _recorder_._src_client_favorites_js.MAIN_DIRECTORY).toString();
      }

      function removeMainDirectory(fullURL) {
        return fullURL.replace(_recorder_._src_client_favorites_js.MATCH_MAIN_DIRECTORY, '');
      }

      class Favorites {
        static async get() {
          const urls = (await _recorder_._src_client_favorites_js.focalStorage.getItem(_recorder_._src_client_favorites_js.STORAGE_KEY)) || [];
          const fullURLs = urls.map(_recorder_._src_client_favorites_js.toFullURL);
          return fullURLs;
        }

        static async set(fullURLs) {
          const relativeURLs = fullURLs.map(_recorder_._src_client_favorites_js.removeMainDirectory);
          return _recorder_._src_client_favorites_js.focalStorage.setItem(_recorder_._src_client_favorites_js.STORAGE_KEY, relativeURLs);
        }

        static async has(fullURL) {
          return (await this.get()).includes(fullURL);
        }

        static async add(newFullURL) {
          const fullURLs = new Set((await this.get()));
          fullURLs.add(newFullURL);
          return this.set(Array.from(fullURLs));
        }

        static async remove(fullURL) {
          const fullURLs = new Set((await this.get()));
          fullURLs.delete(fullURL);
          return this.set(Array.from(fullURLs));
        }

        static async toggle(fullURL) {
          if (await this.has(fullURL)) {
            await this.remove(fullURL);
          } else {
            await this.add(fullURL);
          }
        }
      }

      _export('default', Favorites);

      _recorder_._src_client_favorites_js.Favorites = Favorites;
    }
  };
});