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

  var focalStorage;
  return {
    setters: [function (_srcExternalFocalStorageJs) {
      focalStorage = _srcExternalFocalStorageJs.default;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_client_favorites_js = _recorder_._src_client_favorites_js || {};
      Object.defineProperty(_recorder_._src_client_favorites_js, 'removeMainDirectory', {
        get() {
          return removeMainDirectory;
        },

        set(thisIsVererySecretVariableName) {
          removeMainDirectory = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._src_client_favorites_js, 'toFullURL', {
        get() {
          return toFullURL;
        },

        set(thisIsVererySecretVariableName) {
          toFullURL = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._src_client_favorites_js, 'focalStorage', {
        get() {
          return focalStorage;
        },

        set(thisIsVererySecretVariableName) {
          focalStorage = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });


      const MAIN_DIRECTORY = lively4url + '/';
      Object.defineProperty(_recorder_._src_client_favorites_js, 'MAIN_DIRECTORY', {
        get() {
          return MAIN_DIRECTORY;
        },

        set(thisIsVererySecretVariableName) {
          MAIN_DIRECTORY = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const MATCH_MAIN_DIRECTORY = new RegExp('^' + MAIN_DIRECTORY, 'i');
      Object.defineProperty(_recorder_._src_client_favorites_js, 'MATCH_MAIN_DIRECTORY', {
        get() {
          return MATCH_MAIN_DIRECTORY;
        },

        set(thisIsVererySecretVariableName) {
          MATCH_MAIN_DIRECTORY = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const STORAGE_KEY = 'favorite-files';

      Object.defineProperty(_recorder_._src_client_favorites_js, 'STORAGE_KEY', {
        get() {
          return STORAGE_KEY;
        },

        set(thisIsVererySecretVariableName) {
          STORAGE_KEY = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      function toFullURL(url) {
        return new URL(url, MAIN_DIRECTORY).toString();
      }

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

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

        static async set(fullURLs) {
          const relativeURLs = fullURLs.map(removeMainDirectory);
          return focalStorage.setItem(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);

      Object.defineProperty(_recorder_._src_client_favorites_js, 'Favorites', {
        get() {
          return Favorites;
        },

        set(thisIsVererySecretVariableName) {
          _export('default', Favorites = thisIsVererySecretVariableName);

          return true;
        },

        enumerable: true,
        configurable: true
      });
    }
  };
});