251a24d41f3705079acc600c1a471416b9c976c448370302e55482353f455149.json raw

   1  {"ast":null,"code":"import _asyncToGenerator from \"/home/mleku/src/orly.dev/next/signer/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { inject } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { BrowserSyncFlow, IconButtonComponent, NavComponent, StartupService, StorageService } from '@common';\nimport browser from 'webextension-polyfill';\nimport { getNewStorageServiceConfig } from '../../common/data/get-new-storage-service-config';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/forms\";\nfunction VaultImportComponent_For_12_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"option\", 7)(1, \"span\");\n    i0.ɵɵtext(2);\n    i0.ɵɵelementEnd()();\n  }\n  if (rf & 2) {\n    const snapshot_r1 = ctx.$implicit;\n    i0.ɵɵproperty(\"ngValue\", snapshot_r1);\n    i0.ɵɵadvance(2);\n    i0.ɵɵtextInterpolate(snapshot_r1.fileName);\n  }\n}\nexport let VaultImportComponent = /*#__PURE__*/(() => {\n  class VaultImportComponent extends NavComponent {\n    snapshots = [];\n    selectedSnapshot;\n    syncText;\n    #storage = inject(StorageService);\n    #startup = inject(StartupService);\n    openOptionsPage() {\n      return _asyncToGenerator(function* () {\n        yield browser.runtime.openOptionsPage();\n      })();\n    }\n    ngOnInit() {\n      this.#loadData();\n    }\n    onClickImport() {\n      var _this = this;\n      return _asyncToGenerator(function* () {\n        if (!_this.selectedSnapshot) {\n          return;\n        }\n        try {\n          yield _this.#storage.deleteVault(true);\n          yield _this.#storage.importVault(_this.selectedSnapshot.data);\n          _this.#storage.isInitialized = false;\n          _this.#startup.startOver(getNewStorageServiceConfig());\n        } catch (error) {\n          console.log(error);\n          // TODO\n        }\n      })();\n    }\n    #loadData() {\n      var _this2 = this;\n      return _asyncToGenerator(function* () {\n        _this2.snapshots = (_this2.#storage.getSignerMetaHandler().signerMetaData?.vaultSnapshots ?? []).sortBy(x => x.fileName, 'desc');\n        const syncFlow = _this2.#storage.getSignerMetaHandler().signerMetaData?.syncFlow;\n        switch (syncFlow) {\n          case BrowserSyncFlow.BROWSER_SYNC:\n            _this2.syncText = 'MOZILLA FIREFOX';\n            break;\n          default:\n          case BrowserSyncFlow.NO_SYNC:\n            _this2.syncText = 'OFF';\n            break;\n        }\n      })();\n    }\n    static ɵfac = /*@__PURE__*/(() => {\n      let ɵVaultImportComponent_BaseFactory;\n      return function VaultImportComponent_Factory(__ngFactoryType__) {\n        return (ɵVaultImportComponent_BaseFactory || (ɵVaultImportComponent_BaseFactory = i0.ɵɵgetInheritedFactory(VaultImportComponent)))(__ngFactoryType__ || VaultImportComponent);\n      };\n    })();\n    static ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: VaultImportComponent,\n      selectors: [[\"app-vault-import\"]],\n      features: [i0.ɵɵInheritDefinitionFeature],\n      decls: 20,\n      vars: 3,\n      consts: [[1, \"custom-header\"], [\"icon\", \"chevron-left\", 1, \"button\", 3, \"click\"], [1, \"text\"], [1, \"sam-pl\", \"sam-pr\", \"sam-flex-column\", \"gap\"], [1, \"sam-text-muted\"], [\"href\", \"options.html\", \"target\", \"_blank\"], [1, \"form-select\", \"sam-text-sm\", 3, \"ngModelChange\", \"ngModel\"], [3, \"ngValue\"], [1, \"sam-text-muted\", 2, \"font-size\", \"12px\"], [1, \"sam-flex-grow\"], [1, \"import-button\", \"btn\", \"btn-primary\", 3, \"click\", \"disabled\"]],\n      template: function VaultImportComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          i0.ɵɵelementStart(0, \"div\", 0)(1, \"lib-icon-button\", 1);\n          i0.ɵɵlistener(\"click\", function VaultImportComponent_Template_lib_icon_button_click_1_listener() {\n            return ctx.navigateBack();\n          });\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(2, \"span\", 2);\n          i0.ɵɵtext(3, \"Import Vault \");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelementStart(4, \"div\", 3)(5, \"span\", 4);\n          i0.ɵɵtext(6, \" You can select any snapshot that you have previously imported on the \");\n          i0.ɵɵelementStart(7, \"a\", 5);\n          i0.ɵɵtext(8, \"options page\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵtext(9, \". \");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(10, \"select\", 6);\n          i0.ɵɵtwoWayListener(\"ngModelChange\", function VaultImportComponent_Template_select_ngModelChange_10_listener($event) {\n            i0.ɵɵtwoWayBindingSet(ctx.selectedSnapshot, $event) || (ctx.selectedSnapshot = $event);\n            return $event;\n          });\n          i0.ɵɵrepeaterCreate(11, VaultImportComponent_For_12_Template, 3, 2, \"option\", 7, i0.ɵɵrepeaterTrackByIdentity);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(13, \"span\", 8);\n          i0.ɵɵtext(14, \" Please note that your data will be imported regarding your current SYNC setting: \");\n          i0.ɵɵelementStart(15, \"b\");\n          i0.ɵɵtext(16);\n          i0.ɵɵelementEnd()()();\n          i0.ɵɵelement(17, \"div\", 9);\n          i0.ɵɵelementStart(18, \"button\", 10);\n          i0.ɵɵlistener(\"click\", function VaultImportComponent_Template_button_click_18_listener() {\n            return ctx.onClickImport();\n          });\n          i0.ɵɵtext(19, \" Import\\n\");\n          i0.ɵɵelementEnd();\n        }\n        if (rf & 2) {\n          i0.ɵɵadvance(10);\n          i0.ɵɵtwoWayProperty(\"ngModel\", ctx.selectedSnapshot);\n          i0.ɵɵadvance();\n          i0.ɵɵrepeater(ctx.snapshots);\n          i0.ɵɵadvance(5);\n          i0.ɵɵtextInterpolate(ctx.syncText);\n          i0.ɵɵadvance(2);\n          i0.ɵɵproperty(\"disabled\", !ctx.selectedSnapshot);\n        }\n      },\n      dependencies: [IconButtonComponent, FormsModule, i1.NgSelectOption, i1.ɵNgSelectMultipleOption, i1.SelectControlValueAccessor, i1.NgControlStatus, i1.NgModel],\n      styles: [\"[_nghost-%COMP%] {\\n  height: 100%;\\n  display: flex;\\n  flex-direction: column;\\n  overflow-y: auto;\\n  overflow-x: hidden;\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%] {\\n  padding-top: var(--size);\\n  padding-bottom: var(--size);\\n  display: grid;\\n  grid-template-columns: 1fr;\\n  grid-template-rows: auto;\\n  align-items: center;\\n  background: var(--background);\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%]   .button[_ngcontent-%COMP%] {\\n  grid-column-start: 1;\\n  grid-column-end: 2;\\n  grid-row-start: 1;\\n  grid-row-end: 2;\\n  justify-self: start;\\n  margin-left: 16px;\\n  z-index: 1;\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%]   .text[_ngcontent-%COMP%] {\\n  grid-column-start: 1;\\n  grid-column-end: 2;\\n  grid-row-start: 1;\\n  grid-row-end: 2;\\n  font-size: 20px;\\n  font-weight: 500;\\n  justify-self: center;\\n  height: 32px;\\n  overflow-x: hidden;\\n  white-space: nowrap;\\n  text-overflow: ellipsis;\\n  max-width: 70%;\\n}\\n[_nghost-%COMP%]   .import-button[_ngcontent-%COMP%] {\\n  margin: var(--size);\\n}\"]\n    });\n  }\n  return VaultImportComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}