{"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 { Router } from '@angular/router';\nimport { BrowserSyncFlow, StartupService, StorageService } from '@common';\nimport { getNewStorageServiceConfig } from '../../../common/data/get-new-storage-service-config';\nimport browser from 'webextension-polyfill';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/forms\";\nfunction HomeComponent_Conditional_14_For_2_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"option\", 13);\n    i0.ɵɵtext(1);\n    i0.ɵɵelementEnd();\n  }\n  if (rf & 2) {\n    const snapshot_r3 = ctx.$implicit;\n    i0.ɵɵproperty(\"ngValue\", snapshot_r3);\n    i0.ɵɵadvance();\n    i0.ɵɵtextInterpolate1(\" \", snapshot_r3.fileName, \" \");\n  }\n}\nfunction HomeComponent_Conditional_14_Template(rf, ctx) {\n  if (rf & 1) {\n    const _r1 = i0.ɵɵgetCurrentView();\n    i0.ɵɵelementStart(0, \"select\", 12);\n    i0.ɵɵtwoWayListener(\"ngModelChange\", function HomeComponent_Conditional_14_Template_select_ngModelChange_0_listener($event) {\n      i0.ɵɵrestoreView(_r1);\n      const ctx_r1 = i0.ɵɵnextContext();\n      i0.ɵɵtwoWayBindingSet(ctx_r1.selectedSnapshot, $event) || (ctx_r1.selectedSnapshot = $event);\n      return i0.ɵɵresetView($event);\n    });\n    i0.ɵɵrepeaterCreate(1, HomeComponent_Conditional_14_For_2_Template, 2, 2, \"option\", 13, i0.ɵɵrepeaterTrackByIdentity);\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(3, \"span\", 14);\n    i0.ɵɵtext(4, \" SYNC setting: \");\n    i0.ɵɵelementStart(5, \"b\");\n    i0.ɵɵtext(6);\n    i0.ɵɵelementEnd()();\n    i0.ɵɵelementStart(7, \"button\", 15);\n    i0.ɵɵlistener(\"click\", function HomeComponent_Conditional_14_Template_button_click_7_listener() {\n      i0.ɵɵrestoreView(_r1);\n      const ctx_r1 = i0.ɵɵnextContext();\n      return i0.ɵɵresetView(ctx_r1.onClickImport());\n    });\n    i0.ɵɵtext(8, \" Import selected vault \");\n    i0.ɵɵelementEnd();\n  }\n  if (rf & 2) {\n    const ctx_r1 = i0.ɵɵnextContext();\n    i0.ɵɵtwoWayProperty(\"ngModel\", ctx_r1.selectedSnapshot);\n    i0.ɵɵadvance();\n    i0.ɵɵrepeater(ctx_r1.snapshots);\n    i0.ɵɵadvance(5);\n    i0.ɵɵtextInterpolate(ctx_r1.syncText);\n    i0.ɵɵadvance();\n    i0.ɵɵproperty(\"disabled\", !ctx_r1.selectedSnapshot);\n  }\n}\nfunction HomeComponent_Conditional_15_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"span\", 10);\n    i0.ɵɵtext(1, \"No vault snapshots available\");\n    i0.ɵɵelementEnd();\n  }\n}\nexport let HomeComponent = /*#__PURE__*/(() => {\n  class HomeComponent {\n    router = inject(Router);\n    #storage = inject(StorageService);\n    #startup = inject(StartupService);\n    snapshots = [];\n    selectedSnapshot;\n    syncText = '';\n    ngOnInit() {\n      this.#loadData();\n    }\n    #loadData() {\n      var _this = this;\n      return _asyncToGenerator(function* () {\n        const data = yield browser.storage.local.get('vaultSnapshots');\n        _this.snapshots = (data.vaultSnapshots ?? []).sortBy(x => x.fileName, 'desc');\n        _this.selectedSnapshot = _this.snapshots[0];\n        const syncFlow = _this.#storage.getSignerMetaHandler().signerMetaData?.syncFlow;\n        _this.syncText = syncFlow === BrowserSyncFlow.BROWSER_SYNC ? 'MOZILLA FIREFOX' : 'OFF';\n      })();\n    }\n    onClickImport() {\n      var _this2 = this;\n      return _asyncToGenerator(function* () {\n        if (!_this2.selectedSnapshot) return;\n        try {\n          yield _this2.#storage.deleteVault(true);\n          yield _this2.#storage.importVault(_this2.selectedSnapshot.data);\n          _this2.#storage.isInitialized = false;\n          _this2.#startup.startOver(getNewStorageServiceConfig());\n        } catch (error) {\n          console.log(error);\n        }\n      })();\n    }\n    openOptionsPage() {\n      browser.runtime.openOptionsPage();\n    }\n    static ɵfac = function HomeComponent_Factory(__ngFactoryType__) {\n      return new (__ngFactoryType__ || HomeComponent)();\n    };\n    static ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: HomeComponent,\n      selectors: [[\"app-vault-create-home\"]],\n      decls: 18,\n      vars: 1,\n      consts: [[1, \"vertically-centered\"], [1, \"sam-flex-column\", \"center\"], [1, \"sam-flex-column\", \"gap\", 2, \"align-items\", \"center\"], [1, \"title\"], [1, \"logo-frame\"], [\"src\", \"logo.svg\", \"height\", \"120\", \"width\", \"120\", \"alt\", \"\"], [\"type\", \"button\", 1, \"sam-mt-2\", \"btn\", \"btn-primary\", 3, \"click\"], [1, \"sam-flex-row\", \"gap-h\"], [1, \"bi\", \"bi-plus-circle\", 2, \"height\", \"22px\"], [1, \"sam-text-muted\"], [1, \"sam-text-muted\", \"sam-text-sm\"], [\"type\", \"button\", 1, \"btn\", \"btn-secondary\", 3, \"click\"], [1, \"form-select\", \"sam-text-sm\", 3, \"ngModelChange\", \"ngModel\"], [3, \"ngValue\"], [1, \"sam-text-muted\", \"sync-note\"], [1, \"btn\", \"btn-primary\", 3, \"click\", \"disabled\"]],\n      template: function HomeComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          i0.ɵɵelementStart(0, \"div\", 0)(1, \"div\", 1)(2, \"div\", 2)(3, \"span\", 3);\n          i0.ɵɵtext(4, \"Smesh Signer\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(5, \"div\", 4);\n          i0.ɵɵelement(6, \"img\", 5);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(7, \"button\", 6);\n          i0.ɵɵlistener(\"click\", function HomeComponent_Template_button_click_7_listener() {\n            return ctx.router.navigateByUrl(\"/vault-create/new\");\n          });\n          i0.ɵɵelementStart(8, \"div\", 7);\n          i0.ɵɵelement(9, \"i\", 8);\n          i0.ɵɵelementStart(10, \"span\");\n          i0.ɵɵtext(11, \"Create a new vault\");\n          i0.ɵɵelementEnd()()();\n          i0.ɵɵelementStart(12, \"span\", 9);\n          i0.ɵɵtext(13, \"or\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵtemplate(14, HomeComponent_Conditional_14_Template, 9, 3)(15, HomeComponent_Conditional_15_Template, 2, 0, \"span\", 10);\n          i0.ɵɵelementStart(16, \"button\", 11);\n          i0.ɵɵlistener(\"click\", function HomeComponent_Template_button_click_16_listener() {\n            return ctx.openOptionsPage();\n          });\n          i0.ɵɵtext(17, \" Import vault snapshot \");\n          i0.ɵɵelementEnd()()()();\n        }\n        if (rf & 2) {\n          i0.ɵɵadvance(14);\n          i0.ɵɵconditional(ctx.snapshots.length > 0 ? 14 : 15);\n        }\n      },\n      dependencies: [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}\\n[_nghost-%COMP%]   .vertically-centered[_ngcontent-%COMP%] {\\n  height: 100%;\\n  display: flex;\\n  justify-content: center;\\n  align-items: center;\\n}\\n[_nghost-%COMP%]   .title[_ngcontent-%COMP%] {\\n  font-size: 20px;\\n  font-weight: 500;\\n  margin-bottom: var(--size);\\n}\\n[_nghost-%COMP%]   .sync-note[_ngcontent-%COMP%] {\\n  font-size: 12px;\\n  text-align: center;\\n}\\n[_nghost-%COMP%]   .link-btn[_ngcontent-%COMP%] {\\n  background: transparent;\\n  border: none;\\n  color: var(--muted-foreground);\\n  font-size: 0.8rem;\\n  cursor: pointer;\\n  padding: 4px 8px;\\n  margin-top: 4px;\\n}\\n[_nghost-%COMP%]   .link-btn[_ngcontent-%COMP%]:hover {\\n  color: var(--foreground);\\n  text-decoration: underline;\\n}\\n[_nghost-%COMP%]   .file-input[_ngcontent-%COMP%] {\\n  position: absolute;\\n  visibility: hidden;\\n}\"]\n    });\n  }\n  return HomeComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}