text: "use strict";
  /**
   * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
   *
   * @author Alexander Rose <alexander.rose@weirdbyte.de>
   */
  Object.defineProperty(exports, "__esModule", { value: true });
  var tslib_1 = require("tslib");
  var mol_plugin_ui_1 = require("../../mol-plugin-ui");
  var spec_1 = require("../../mol-plugin-ui/spec");
  var commands_1 = require("../../mol-plugin/commands");
  var assets_1 = require("../../mol-util/assets");
  require("./index.html");
  require('mol-plugin-ui/skin/light.scss');
  var Canvas3DPresets = {
      illustrative: {
          multiSample: {
              mode: 'temporal'
          },
          postprocessing: {
              occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
              outline: { name: 'on', params: { scale: 1, threshold: 0.1 } }
          },
          renderer: {
              style: { name: 'flat', params: {} }
          }
      },
      occlusion: {
          multiSample: {
              mode: 'temporal'
          },
          postprocessing: {
              occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
              outline: { name: 'off', params: {} }
          },
          renderer: {
              style: { name: 'matte', params: {} }
          }
      },
      standard: {
          multiSample: {
              mode: 'off'
          },
          postprocessing: {
              occlusion: { name: 'off', params: {} },
              outline: { name: 'off', params: {} }
          },
          renderer: {
              style: { name: 'matte', params: {} }
          }
      }
  };
  var LightingDemo = /** @class */ (function () {
      function LightingDemo() {
          this.radius = 5;
          this.bias = 1.1;
          this.preset = 'illustrative';
      }
      LightingDemo.prototype.init = function (target) {
          this.plugin = (0, mol_plugin_ui_1.createPlugin)(typeof target === 'string' ? document.getElementById(target) : target, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (0, spec_1.DefaultPluginUISpec)()), { layout: {
                  initial: {
                      isExpanded: false,
                      showControls: false
                  },
              }, components: {
                  controls: { left: 'none', right: 'none', top: 'none', bottom: 'none' }
              } }));
          this.setPreset('illustrative');
      };
      LightingDemo.prototype.setPreset = function (preset) {
          var _a;
          var props = Canvas3DPresets[preset];
          if (((_a = props.postprocessing.occlusion) === null || _a === void 0 ? void 0 : _a.name) === 'on') {
              props.postprocessing.occlusion.params.radius = this.radius;
              props.postprocessing.occlusion.params.bias = this.bias;
          }
          commands_1.PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, props), { multiSample: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, this.plugin.canvas3d.props.multiSample), props.multiSample), renderer: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, this.plugin.canvas3d.props.renderer), props.renderer), postprocessing: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, this.plugin.canvas3d.props.postprocessing), props.postprocessing) }) });
      };
      LightingDemo.prototype.load = function (_a, radius, bias) {
          var url = _a.url, _b = _a.format, format = _b === void 0 ? 'mmcif' : _b, _c = _a.isBinary, isBinary = _c === void 0 ? true : _c, _d = _a.assemblyId, assemblyId = _d === void 0 ? '' : _d;
          return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
              var data, trajectory, model, structure, polymer, ligand;
              return (0, tslib_1.__generator)(this, function (_e) {
                  switch (_e.label) {
                      case 0: return [4 /*yield*/, this.plugin.clear()];
                      case 1:
                          _e.sent();
                          return [4 /*yield*/, this.plugin.builders.data.download({ url: assets_1.Asset.Url(url), isBinary: isBinary }, { state: { isGhost: true } })];
                      case 2:
                          data = _e.sent();
                          return [4 /*yield*/, this.plugin.builders.structure.parseTrajectory(data, format)];
                      case 3:
                          trajectory = _e.sent();
                          return [4 /*yield*/, this.plugin.builders.structure.createModel(trajectory)];
                      case 4:
                          model = _e.sent();
                          return [4 /*yield*/, this.plugin.builders.structure.createStructure(model, assemblyId ? { name: 'assembly', params: { id: assemblyId } } : { name: 'model', params: {} })];
                      case 5:
                          structure = _e.sent();
                          return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentStatic(structure, 'polymer')];
                      case 6:
                          polymer = _e.sent();
                          if (!polymer) return [3 /*break*/, 8];
                          return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(polymer, { type: 'spacefill', color: 'illustrative' })];
                      case 7:
                          _e.sent();
                          _e.label = 8;
                      case 8: return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentStatic(structure, 'ligand')];
                      case 9:
                          ligand = _e.sent();
                          if (!ligand) return [3 /*break*/, 11];
                          return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(ligand, { type: 'ball-and-stick', color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } })];
                      case 10:
                          _e.sent();
                          _e.label = 11;
                      case 11:
                          this.radius = radius;
                          this.bias = bias;
                          this.setPreset(this.preset);
                          return [2 /*return*/];
                  }
              });
          });
      };
      return LightingDemo;
  }());
  window.LightingDemo = new LightingDemo();
  //# sourceMappingURL=index.js.map