"enable aexpr";

System.register(['active-expression-rewriting', 'src/components/halo/lively-halo-item.js', 'src/client/vivide/scripts/saving.js'], function (_export, _context) {
  "use strict";

  var _getAndCallMember, _setMember, _setLocal, _getLocal, _getGlobal, _getMember, _traceMember, HaloItem, getName, writeFile;

  return {
    setters: [function (_activeExpressionRewriting) {
      _getAndCallMember = _activeExpressionRewriting.getAndCallMember;
      _setMember = _activeExpressionRewriting.setMember;
      _setLocal = _activeExpressionRewriting.setLocal;
      _getLocal = _activeExpressionRewriting.getLocal;
      _getGlobal = _activeExpressionRewriting.getGlobal;
      _getMember = _activeExpressionRewriting.getMember;
      _traceMember = _activeExpressionRewriting.traceMember;
    }, function (_srcComponentsHaloLivelyHaloItemJs) {
      HaloItem = _srcComponentsHaloLivelyHaloItemJs.default;
    }, function (_srcClientVivideScriptsSavingJs) {
      getName = _srcClientVivideScriptsSavingJs.getName;
      writeFile = _srcClientVivideScriptsSavingJs.writeFile;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_components_halo_lively_halo_vivide_save_application_item_js = _recorder_._src_components_halo_lively_halo_vivide_save_application_item_js || {};
      let _scope = {
        isScope: true
      };
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'HaloItem', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'HaloItem', HaloItem) : void 0, HaloItem;
        },

        set(thisIsVererySecretVariableName) {
          let _scope2 = {
            isScope: true
          };
          HaloItem = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope2, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'HaloItem', HaloItem, {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 15,
              line: 3
            },
            start: {
              column: 7,
              line: 3
            },
            source: ''
          }) : void 0, HaloItem;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'writeFile', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'writeFile', writeFile) : void 0, writeFile;
        },

        set(thisIsVererySecretVariableName) {
          let _scope3 = {
            isScope: true
          };
          writeFile = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope3, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'writeFile', writeFile, {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 26,
              line: 4
            },
            start: {
              column: 17,
              line: 4
            },
            source: ''
          }) : void 0, writeFile;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'getName', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getName', getName) : void 0, getName;
        },

        set(thisIsVererySecretVariableName) {
          let _scope4 = {
            isScope: true
          };
          getName = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope4, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'getName', getName, {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 15,
              line: 4
            },
            start: {
              column: 8,
              line: 4
            },
            source: ''
          }) : void 0, getName;
          return true;
        },

        enumerable: true,
        configurable: true
      });


      const basePath = "src/client/vivide/scripts/applications/";

      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'basePath', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'basePath', basePath) : void 0, basePath;
        },

        set(thisIsVererySecretVariableName) {
          let _scope5 = {
            isScope: true
          };
          basePath = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope5, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'basePath', basePath, {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 14,
              line: 6
            },
            start: {
              column: 6,
              line: 6
            },
            source: ''
          }) : void 0, basePath;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      class LivelyHaloVivideSaveApplicationItem extends HaloItem {
        constructor(...args) {
          let _scope6 = {
            isScope: true
          };
          super(...(args === Object(args) ? self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'args', args) : void 0 : args, args));

          _setMember(this, '__classFilePath__', 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js', (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined));
        }

        async onClick(evt) {
          let _scope7 = {
            isScope: true
          };

          const saveTarget = _getMember((self.__expressionAnalysisMode__ ? _getGlobal('window') : void 0, window), 'that');
          const { name, description, url } = await (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getName', getName) : void 0, getName)((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), "application");
          if ((name === Object(name) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'name', name) : void 0 : name, name) === (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined)) {
            return;
          }_setMember(this, 'storedViews', [], {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 25,
              line: 14
            },
            start: {
              column: 4,
              line: 14
            },
            source: ''
          });
          // set the name on the saveTarget
          /*
          We have to save a multitude of things:
          inputData
          scriptSteps
          And for applications:
          input targets
          output targets
          */
          const stringToSave = (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'stringify') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).stringify((self.__expressionAnalysisMode__ ? _traceMember(this, 'createJSON') : void 0, this.createJSON((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), (name === Object(name) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'name', name) : void 0 : name, name), (description === Object(description) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'description', description) : void 0 : description, description)))));
          _setMember(this, 'storedViews', [], {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 25,
              line: 25
            },
            start: {
              column: 4,
              line: 25
            },
            source: ''
          });
          (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'writeFile', writeFile) : void 0, writeFile)((url === Object(url) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'url', url) : void 0 : url, url), (stringToSave === Object(stringToSave) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'stringToSave', stringToSave) : void 0 : stringToSave, stringToSave));
        }

        createJSON(saveTarget, name, description) {
          let _scope8 = {
            isScope: true
          };

          _getAndCallMember(_getMember(this, 'storedViews'), 'push', [_getMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'id')]);
          _setMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'applicationName', (name === Object(name) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'name', name) : void 0 : name, name), {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 37,
              line: 31
            },
            start: {
              column: 4,
              line: 31
            },
            source: ''
          });
          _setMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'description', (description === Object(description) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'description', description) : void 0 : description, description), {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 40,
              line: 32
            },
            start: {
              column: 4,
              line: 32
            },
            source: ''
          });
          const script = _getAndCallMember(_getMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'myCurrentScript'), 'toJSON', []);
          const inputSources = _getAndCallMember(_getAndCallMember(_getMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'inportSources'), 'filter', [i => {
            let _scope9 = {
              isScope: true
            };
            return !_getAndCallMember(_getMember(this, 'storedViews'), 'includes', [_getMember((i === Object(i) ? self.__expressionAnalysisMode__ ? _getLocal(_scope9, 'i', i) : void 0 : i, i), 'id')]);
          }]), 'map', [v => {
            let _scope10 = {
              isScope: true
            };

            return self.__expressionAnalysisMode__ ? _traceMember(this, 'createJSON') : void 0, this.createJSON((v === Object(v) ? self.__expressionAnalysisMode__ ? _getLocal(_scope10, 'v', v) : void 0 : v, v), (name === Object(name) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'name', name) : void 0 : name, name));
          }]);
          const outputs = _getAndCallMember(_getAndCallMember(_getMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'outportTargets'), 'filter', [i => {
            let _scope11 = {
              isScope: true
            };
            return !_getAndCallMember(_getMember(this, 'storedViews'), 'includes', [_getMember((i === Object(i) ? self.__expressionAnalysisMode__ ? _getLocal(_scope11, 'i', i) : void 0 : i, i), 'id')]);
          }]), 'map', [v => {
            let _scope12 = {
              isScope: true
            };

            return self.__expressionAnalysisMode__ ? _traceMember(this, 'createJSON') : void 0, this.createJSON((v === Object(v) ? self.__expressionAnalysisMode__ ? _getLocal(_scope12, 'v', v) : void 0 : v, v), (name === Object(name) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'name', name) : void 0 : name, name));
          }]);
          const inputs = _getMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'input');
          const stringToSave = { description, script, outputs, inputSources, inputs, widget: _getAndCallMember(_getMember(_getMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'widget'), 'tagName'), 'toLowerCase', []), id: _getMember((saveTarget === Object(saveTarget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'saveTarget', saveTarget) : void 0 : saveTarget, saveTarget), 'id') };
          return stringToSave === Object(stringToSave) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'stringToSave', stringToSave) : void 0 : stringToSave, stringToSave;
        }
      }

      _export('default', LivelyHaloVivideSaveApplicationItem);

      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      (self.__expressionAnalysisMode__ ? _getGlobal('Object') : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'LivelyHaloVivideSaveApplicationItem', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'LivelyHaloVivideSaveApplicationItem', LivelyHaloVivideSaveApplicationItem) : void 0, LivelyHaloVivideSaveApplicationItem;
        },

        set(thisIsVererySecretVariableName) {
          let _scope13 = {
            isScope: true
          };
          _export('default', LivelyHaloVivideSaveApplicationItem = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope13, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'LivelyHaloVivideSaveApplicationItem', LivelyHaloVivideSaveApplicationItem, {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/components/halo/lively-halo-vivide-save-application-item.js',
            end: {
              column: 56,
              line: 9
            },
            start: {
              column: 21,
              line: 9
            },
            source: ''
          }) : void 0, LivelyHaloVivideSaveApplicationItem;
          return true;
        },

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