/* minified */ function e(e){var t=this;Object.keys(e).forEach((function(n){t[n]=e[n]})),t.endpoints=t.endpoints||[]}function t(e,t){"use strict";var n=this;t&&t.length?_.forEach(t,(function(t){n[t]=e[t]})):["currency","issuer","medianTime","number","version","powMin","dividend","membersCount","hash","identities","joiners","actives","leavers","revoked","excluded","certifications","transactions","unitbase"].forEach((function(t){n[t]=e[t]})),n.identitiesCount=n.identities?n.identities.length:0,n.joinersCount=n.joiners?n.joiners.length:0,n.activesCount=n.actives?n.actives.length:0,n.leaversCount=n.leavers?n.leavers.length:0,n.revokedCount=n.revoked?n.revoked.length:0,n.excludedCount=n.excluded?n.excluded.length:0,n.certificationsCount=n.certifications?n.certifications.length:0,n.transactionsCount=n.transactions?n.transactions.length:0,n.empty=n.isEmpty(),n.id=[n.number,n.hash].join("-")}function n(e){var t=e.split(":");if(t.length<3||!t[0].startsWith("WS2P"))throw Error("Invalid format: "+e);if("HEAD"==t[1]){if(t.length<4)throw Error("Invalid format: "+e);if(4==t.length)this.pubkey=t[2],this.buid=t[3];else if(t[2]>=1){var n=t[0];if(n.length>4){var i=this.regexp.WS2P_PREFIX.exec(n);if(!i)throw Error("Invalid format: "+e);var a=i[1];if(a){this.private={useTor:a.startsWith("T")};var o=a.substring(1);"A"==o?this.private.mode="all":"M"==o?this.private.mode="mixed":"S"==o&&(this.private.mode="strict")}var r=i[2];r&&(this.public={useTor:r.startsWith("T"),mode:"all"})}this.pubkey=t[3],this.buid=t[4],this.ws2pid=t[5],this.software=t[6],this.version=t[7],this.powPrefix=t[8]}}}function a(e,t){e.extensionPoint=t.extensions.points.current.get()}function o(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E,b,g,f,_,h){e.walletData=b.data,e.search={},e.login=b.isLogin(),e.auth=b.isAuth(),e.motion=m.motion.default,e.fullscreen=m.screen.fullscreen.isEnabled(),e.showHome=function(){return r.nextViewOptions({historyRoot:!0}),n.go("app.home").then(m.loading.hide)},e.createHelptipScope=function(n){if(n||!t.tour&&t.settings.helptip.enable&&!m.screen.isSmall()){var i=e.$new();return s("HelpTipCtrl",{$scope:i}),i}},e.startHelpTour=function(n,i){if(n&&n.defaultPrevented)return!1;if(t.tour=!0,!i)return r.clearHistory(),r.clearCache().then((function(){e.startHelpTour(null,!0)}));var a=e.createHelptipScope(!0);return a.startHelpTour().then((function(){a.$destroy(),delete t.tour})).catch((function(e){delete t.tour}))},e.disableHelpTour=function(e){e&&(e.preventDefault(),e.stopPropagation()),d.data.helptip&&d.data.helptip.enable&&(t.settings.helptip.enable=!1,d.store())},e.isLogin=function(){return e.login},e.loadWalletData=function(e){return console.warn("[app-controller] DEPRECATED - Please use csWallet.load() instead of $scope.loadWalletData()",new Error),((e=e||{}).wallet||b).loadData(e).then((function(e){if(!e)throw"CANCELLED";return e}))},e.loadWallet=function(t){if(console.warn("[app-controller] DEPRECATED - Please use csWallet.loginOrLoad() instead of $scope.loadWallet()",new Error),!c.isStarted())return c.ready().then((function(){return e.loadWallet(t)}));var n=(t=t||{}).wallet||b;return t.auth&&!n.isAuth()?n.auth(t).then((function(e){if(e)return e;throw"CANCELLED"})):n.isLogin()?n.isDataLoaded(t)?a.when(n.data):e.loadWalletData(t):n.login(t).then((function(e){if(e)return e;throw"CANCELLED"}))},e.loginAndGo=function(t,i){e.closeProfilePopover();var a=(i=i||{}).wallet||b;if(delete i.wallet,t=t||"app.view_wallet",a.isLogin())return n.go(t,i);if(_.httpsMode&&l.location&&"https:"!==l.location.protocol){var o=l.location.href,r=o.indexOf("#"),s=-1!=r?o.substr(0,r):o;if(o=(s="https"+s.substr(4))+n.href(t),!_.httpsModeDebug)return void(l.location.href=o);console.debug("[httpsMode] --- Should redirect to: "+o)}return a.login(i).then((function(){return n.go(t,i)})).then(m.loading.hide)},e.logout=function(t){var n=(t=t||{}).wallet||b;return!t.force&&e.profilePopover?e.profilePopover.hide().then((function(){return t.force=!0,e.logout(t)})):t.askConfirm?m.alert.confirm("CONFIRM.LOGOUT").then((function(n){if(n)return t.askConfirm=!1,e.logout(t)})):(m.loading.show(),n.logout().then((function(){if(i.isOpenLeft()&&i.toggleLeft(),n.isDefault())return r.clearHistory(),r.clearCache().then((function(){return e.showHome()}));m.loading.hide(10)})).catch(m.onError("ERROR.LOGOUT")))},e.doAuth=function(e){return(e&&e.wallet||b).auth().then(m.loading.hide)},e.isUserPubkey=function(e){return b.isUserPubkey(e)},b.api.data.on.login(e,(function(t,n){return e.login=!0,n?n.resolve():a.when()})),b.api.data.on.logout(e,(function(){e.login=!1})),b.api.data.on.auth(e,(function(t,n){return e.auth=!0,n?n.resolve():a.when()})),b.api.data.on.unauth(e,(function(){e.auth=!1})),e.showTransferModal=function(e){return f.showTransfer(e)},e.showAboutModal=function(){return f.showAbout()},e.showJoinModal=function(){return e.closeProfilePopover(),f.showJoin()},e.showSettings=function(){return e.closeProfilePopover(),n.go("app.settings")},e.showHelpModal=function(e){return f.showHelp(e)},e.showProfilePopover=function(t){return m.popover.show(t,{templateUrl:"templates/common/popover_profile.html",scope:e,autoremove:!0,afterShow:function(t){e.profilePopover=t,o((function(){m.ink({selector:"#profile-popover .ink, #profile-popover .ink-dark"})}),100)}})},e.closeProfilePopover=function(){e.profilePopover&&e.profilePopover.isShown()&&o((function(){e.profilePopover.hide()}))},e.showPeerInfoPopover=function(t){return m.popover.show(t,{templateUrl:"templates/network/popover_peer_info.html",autoremove:!0,scope:e.$new(!0)})},e.openLink=function(e,t,i){if(e.stopPropagation(),e.preventDefault(),t&&t.startsWith("@")){var a=t.substr(1);if(E.regexp.USER_ID.test(a))return n.go("app.wot_identity_uid",{uid:a}),!1}return(i=i||{}).onError=function(){return m.popover.copy(e,t)},h.uri.open(t,i),!1},e.showFab=function(e,t){m.motion.toggleOn({selector:"#"+e+".button-fab"},t)},e.hideFab=function(e,t){m.motion.toggleOff({selector:"#"+e+".button-fab"},t)},e.doMotion=function(t){return e.motion.show(t)},e.askFullscreen=function(){if(!e.fullscreen&&m.screen.isSmall()&&g.isWeb())return m.alert.confirm("CONFIRM.FULLSCREEN",void 0,{cancelText:"COMMON.BTN_NO",okText:"COMMON.BTN_YES"}).then((function(t){t&&e.toggleFullscreen()}))},e.toggleFullscreen=function(){e.fullscreen=!m.screen.fullscreen.isEnabled(),m.screen.fullscreen.toggleAll()},e.askFullscreen()}function r(e,t,n,i,a,o,r,s,l,c,d,u){e.loading=!0,e.locales=angular.copy(u.locales),e.smallscreen=r.screen.isSmall(),e.showInstallHelp=!1,e.enter=function(n,a){ionic.Platform.isIOS()&&window.StatusBar&&(StatusBar.overlaysWebView(!1),StatusBar.overlaysWebView(!0)),a&&a.stateParams&&a.stateParams.error?(e.error=a.stateParams.error,e.node=d.data.node,e.loading=!1,i.nextViewOptions({disableAnimate:!0,disableBack:!0,historyRoot:!0}),t.go("app.home",{error:void 0},{reload:!1,inherit:!0,notify:!1})):c.ready().then((function(){e.loading=!1,e.loadFeeds()})).catch((function(t){e.node=d.data.node,e.loading=!1,e.error=t}))},e.$on("$ionicView.enter",e.enter),e.reload=function(){e.loading=!0,delete e.error,n(e.enter,200)},e.loadFeeds=function(){var t=u.getFeedUrl();if(t&&"string"==typeof t){var n=s.feed&&s.feed.maxContentLength||650,i=Date.now();console.debug("[home] Loading feeds from {0}...".format(t)),o.get(t,{responseType:"json",cache:l.get(null,l.constants.LONG)}).success((function(t){console.debug("[home] Feeds loaded in {0}ms".format(Date.now()-i)),t&&t.items&&t.items.length&&(t.items=t.items.reduce((function(e,i){if(!i||!i.title&&!i.content_text&&!i.content_html)return e;if(i.date_published&&(i.time=moment.utc(i.date_published).unix()),i.content_html?i.content=i.content_html:i.content=(i.content_text||"").replace(/\n/g,"
"),-1!==n&&i.content&&i.content.length>n){var a=Math.max(i.content.lastIndexOf(" ",n),i.content.lastIndexOf("<",n));i.content=i.content.substr(0,a)+" (...)",i.truncated=!0}return i.author=i.author||t.author,e.concat(i)}),[]),e.feed=t)})).error((function(t,n){console.error("[home] Failed to load feeds."),e.feed=null}))}},e.doQuickFix=function(e){"settings"===e&&(i.nextViewOptions({historyRoot:!0}),t.go("app.settings"))},e.changeLanguage=function(t){a.use(t),e.hideLocalesPopover(),u.data.locale=_.findWhere(e.locales,{id:t}),u.store(),e.loadFeeds()},e.showLocalesPopover=function(t){r.popover.show(t,{templateUrl:"templates/common/popover_locales.html",scope:e,autoremove:!0,afterShow:function(t){e.localesPopover=t}})},e.hideLocalesPopover=function(){e.localesPopover&&(e.localesPopover.hide(),e.localesPopover=null)}}function s(e,t,n,i,a){angular.extend(this,n("HomeCtrl",{$scope:e})),e.showJoinModal=function(){return e.loading?t(e.showJoinModal,500):a.isLogin()||e.error?void 0:t(i.showJoin,300)},e.$on("$ionicView.enter",e.showJoinModal)}function l(e,t,n,i,a,o){e.formData={},e.slides={slider:null,options:{loop:!1,effect:"slide",speed:500}},e.loading=!0,e.load=function(){if(e.loading)return o.get().then((function(t){t&&(e.currency=t,e.formData.currency=t.name,e.loading=!1)})).catch(i.onError("ERROR.GET_CURRENCY_FAILED"))},e.$on("modal.shown",e.load),e.$on("$ionicSlides.sliderInitialized",(function(e,t){t.slider.lockSwipes()})),e.slidePrev=function(){e.slides.slider.unlockSwipes(),e.slides.slider.slidePrev(),e.slides.slider.lockSwipes()},e.slideNext=function(){e.slides.slider.unlockSwipes(),e.slides.slider.slideNext(),e.slides.slider.lockSwipes()},e.selectAccountTypeAndClose=function(t){if(a.demo)return i.alert.demo();e.formData.accountType=t,e.closeModal(e.formData)},e.doQuickFix=function(n){"settings"==n&&(e.closeModal(),t.go("app.settings"))},e.showHelpModal=function(e){n.showHelp({anchor:e})}}function c(e,t,n,i,a,o,r,s,l,c,d,u,p){var m;e.formData={pseudo:p.uid||"",pubkey:p.pubkey||void 0},e.slides={slider:null,options:{loop:!1,effect:"slide",speed:500,pager:!1,showPager:!1}},e.slideBehavior={},e.loading=!0,e.isLicenseRead=o.isIOS(),e.showUsername=!1,e.showPassword=!1,e.formData.computing=!1,e.smallscreen=r.screen.isSmall(),e.userIdPattern=u.constants.regexp.USER_ID,e.accountAvailable=!!p.pubkey,e.currency=p.currency,e.accountType=p.accountType||"member",e.load=function(){if(e.loading){if(!(m=p.walletId&&d.children.get(p.walletId)||p.pubkey&&d.children.getByPubkey(p.pubkey)||(!p.pubkey||d.isUserPubkey(p.pubkey))&&d))throw new Error("Cannot found the corresponding wallet, from parameters.pubkey or parameters.walletId");console.debug("[join] Starting join modal on wallet {0}".format(m.id)),"member"===e.accountType&&(e.licenseFileUrl=l.getLicenseUrl(),e.licenseFileUrl&&(".txt"!=e.licenseFileUrl.substring(e.licenseFileUrl.length-3)&&(e.licenseFileUrl=e.licenseFileUrl+".html"),e.isLicenseRead||a((function(){e.isLicenseRead||(e.isLicenseRead=!0)}),5e3))),e.slideBehavior=e.computeSlideBehavior(),e.loading=!1}},e.$on("modal.shown",e.load),e.$on("$ionicSlides.sliderInitialized",(function(e,t){t.slider.lockSwipes()})),e.slidePrev=function(){e.slides.slider.unlockSwipes(),e.slides.slider.slidePrev(),e.slides.slider.lockSwipes()},e.slideNext=function(){e.slides.slider.unlockSwipes(),e.slides.slider.slideNext(),e.slides.slider.lockSwipes()},e.showAccountPubkey=function(){if(p.pubkey&&p.pseudo===e.formData.pseudo)return e.formData.pubkey=p.pubkey,void(e.formData.computing=!1);e.formData.computing=!0,s.scryptKeypair(e.formData.username,e.formData.password).then((function(t){return e.formData.pubkey=s.util.encode_base58(t.signPk),e.checkAccountAvailable()})).then((function(){return a((function(){e.formData.computing=!1}),400)})).catch((function(t){e.formData.pubkey=void 0,e.formData.computing=!1,r.onError("ERROR.CRYPTO_UNKNOWN_ERROR")(t)}))},e.formDataChanged=function(){e.formData.computing=!1,e.formData.pubkey=null},e.getCurrentFormName=function(){var t=e.slides.slider.activeIndex;if("member"===e.accountType){if(t+=e.licenseFileUrl?0:1,0===(t+=p.pubkey&&t>=2?2:0))return"licenseForm";if(1===t)return"pseudoForm";if(2===t)return"saltForm";if(3===t)return"passwordForm";if(4===t)return"confirmForm"}else{if(0===t)return"saltForm";if(1===t)return"passwordForm";if(2===t)return"confirmForm"}},e.computeSlideBehavior=function(){var t=e.getCurrentFormName();return"licenseForm"===t?{hasPreviousButton:!1,hasNextButton:!1,hasAcceptButton:!0}:"pseudoForm"===t?{helpAnchor:"join-pseudo",hasPreviousButton:e.licenseFileUrl&&!0,hasNextButton:!0,focus:"pseudo"}:"saltForm"===t?{helpAnchor:"join-salt",hasPreviousButton:"member"===e.accountType,hasNextButton:!0,focus:"salt"}:"passwordForm"===t?{helpAnchor:"join-password",hasPreviousButton:!0,hasNextButton:!0,focus:"password"}:"confirmForm"===t?{hasPreviousButton:!0,hasNextButton:!1,hasSendButton:!0,helpAnchor:"join-pubkey"}:{hasPreviousButton:!1,hasNextButton:!0}},e.doNext=function(){var t=e.getCurrentFormName();if(t&&e[t]){if(e[t].$submitted=!0,!e[t].$valid)return;if("pseudoForm"===t&&e.uiAlreadyUsed)return;"passwordForm"===t&&e.showAccountPubkey()}e.slideNext(),e.slideBehavior=e.computeSlideBehavior()},e.doPrev=function(){e.slidePrev(),e.slideBehavior=e.computeSlideBehavior()},e.doNewAccount=function(n){if(!n){var o="member"===e.accountType?"ACCOUNT.NEW.CONFIRMATION_MEMBER_ACCOUNT":"ACCOUNT.NEW.CONFIRMATION_WALLET_ACCOUNT";return r.alert.confirm(o,void 0,{cssClass:"warning",okText:"member"==e.accountType?"COMMON.BTN_SEND":"COMMON.BTN_CONTINUE",okType:"button-assertive"}).then((function(t){t&&e.doNewAccount(!0)}))}var s=function(e){return function(t){throw parameter.uid?m.unauth().then((function(){r.onError(e)(t)})):m.logout().then((function(){r.onError(e)(t)})),new Error("CANCELLED")}};return r.loading.show(),m.login({auth:!0,isNew:!0,method:"SCRYPT_DEFAULT",expectedPubkey:e.formData.pubkey,showMethods:!1}).then((function(){if("member"===e.accountType){e.closeModal(),l.data.wallet=l.data.wallet||{},l.data.wallet.alertIfUnusedWallet=!1;var n=angular.isUndefined(p.uid)||angular.isUndefined(p.blockUid)||p.uid.toUpperCase()!==e.formData.pseudo.toUpperCase();return n||m.setSelf(p.uid,p.blockUid),(n?m.self(e.formData.pseudo,!1).catch(s("ERROR.SEND_IDENTITY_FAILED")):i.when()).then((function(){return m.membership.inside().catch((function(e){e&&e.ucode!=u.errorCodes.MEMBERSHIP_ALREADY_SEND||s("ERROR.SEND_MEMBERSHIP_IN_FAILED")(e)}))})).then((function(){return e.closeModal(),m.isDefault()?t.go("app.view_wallet"):t.go("app.view_wallet_by_id",{id:m.id})})).then((function(){return a((function(){return m.isDataLoaded({requirements:!0})&&r.loading.hide(),e.downloadRevocationRegistration()}),2e3)}))}e.closeModal(),m.isDefault()?t.go("app.view_wallet"):t.go("app.view_wallet_by_id",{id:m.id})})).catch((function(e){r.loading.hide(),"CANCELLED"!==e&&(e&&e.ucode!=u.errorCodes.MEMBERSHIP_ALREADY_SEND?console.error("[wallet] Node: already membership",e):r.alert.error("ERROR.UNKNOWN_ERROR"))}))},e.downloadRevocationRegistration=function(){return r.alert.confirm("DOWNLOAD.POPUP_REVOKE_MESSAGE","DOWNLOAD.POPUP_TITLE",{cssClass:"warning",okText:"COMMON.BTN_DOWNLOAD",okType:"button-assertive",cancelText:"COMMON.BTN_LATER"}).then((function(e){if(e)return m.downloadRevocation()}))},e.showHelpModal=function(e){c.showHelp({anchor:e})},e.startListenLicenseBottom=function(){var t=angular.element(document.querySelector(".modal #iframe-license"));if(!(t=t&&t.length?t[0]:void 0)||!t.contentWindow)return console.debug("[join] Waiting license frame to be load..."),a(e.startListenLicenseBottom,1e3);e.licenseBottomInterval=n((function(){var n=t.contentWindow.document.body.scrollTop;t.contentWindow.document.body.scrollHeight-t.contentWindow.document.body.clientHeight===n&&(e.isLicenseRead=!0,e.stopListenLicenseBottom())}),1e3)},e.stopListenLicenseBottom=function(){e.licenseBottomInterval&&(n.cancel(e.licenseBottomInterval),delete e.licenseBottomInterval)},e.$on("modal.hidden",e.stopListenLicenseBottom),e.checkUid=function(){if(!e.formData.pseudo||e.formData.pseudo.length<3)return e.formData.computing=!1,void delete e.uiAlreadyUsed;var t=e.formData.pseudo.toUpperCase();if(e.formData.computing=!0,p.uid&&t===p.uid.toUpperCase())return e.formData.computing=!1,void(e.uiAlreadyUsed=!1);u.wot.lookup({search:t}).then((function(n){e.uiAlreadyUsed=(n.results||[]).some((function(e){return(e.uids||[]).some((function(e){return e.uid.toUpperCase()===t}))})),e.formData.computing=!1})).catch((function(t){console.error(t),e.formData.computing=!1,e.uiAlreadyUsed=!1}))},e.$watch("formData.pseudo",e.checkUid,!0),e.checkAccountAvailable=function(){if(!p.pubkey)return delete e.accountAvailable,u.tx.sources({pubkey:e.formData.pubkey}).then((function(t){e.accountAvailable=!t||!t.sources.length})).catch((function(t){console.error(t),e.accountAvailable=!1}));e.accountAvailable=!0},e.identifierRecovery=function(){e.slides.slider.unlockSwipes();for(var t=0;t<2;t++)e.slides.slider.slidePrev();e.slides.slider.lockSwipes(),e.slideBehavior=e.computeSlideBehavior()}}function d(e,t,n,i){angular.extend(this,n("HomeCtrl",{$scope:e})),e.showLoginModal=function(){return e.loading?t(e.showLoginModal,500):i.isLogin()||e.error?void 0:t(i.login,300)},e.$on("$ionicView.enter",e.showLoginModal)}function u(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E){E=E||{},u.demo&&(E.method="PUBKEY"),e.computing=!1,e.pubkey=null,e.formData={},e.showPubkey=!1,e.showComputePubkeyButton=!1,e.autoComputePubkey=!1,e.pubkeyPattern="^(:?{0}|{1})$".format(c.constants.regexp.PUBKEY,c.constants.regexp.PUBKEY_WITH_CHECKSUM),e.isAuth=E.auth,e.okText=E.okText,e.title=E.title||(e.isAuth?"AUTH.TITLE":"LOGIN.TITLE"),e.showMethods=!angular.isDefined(E.showMethods)||E.showMethods,e.showNewAccountLink=!angular.isDefined(E.showNewAccountLink)||E.showNewAccountLink,e.expectedPubkey=E.expectedPubkey,e.expectedUid=E.uid,e.scryptParamsValues=_.keys(o.constants.SCRYPT_PARAMS).reduce((function(e,t){return e.concat({id:t,label:"LOGIN.SCRYPT."+t,params:o.constants.SCRYPT_PARAMS[t]})}),[{id:"USER",label:"LOGIN.SCRYPT.USER",params:{}}]),e.init=function(){s().then((function(){e.autoComputePubkey="a"===ionic.Platform.grade.toLowerCase()&&!l.screen.isSmall()})),e.formData.rememberMe=p.data.rememberMe,e.formData.keepAuthIdle=p.data.keepAuthIdle,e.formData.keepAuth=e.formData.keepAuthIdle==p.constants.KEEP_AUTH_IDLE_SESSION;var t=E.method||p.data.login&&p.data.login.method||"SCRYPT_DEFAULT",n=p.data.login&&p.data.login.params;(e.isAuth&&"PUBKEY"===t||"SCAN"===t||"default"===t)&&(t="SCRYPT_DEFAULT"),e.changeMethod(t,n)},e.enter=function(){l.loading.hide(),l.ink({selector:".modal-login .ink"})},e.$on("modal.shown",e.enter),e.leave=function(){e.formData={},e.computing=!1,e.pubkey=null,e.methods=[]},e.$on("modal.hide",e.leave),e.doLogin=function(n){var i=e.formData.method;if(e.form.$valid||"SCAN"===i){var a,s=e.formData.keepAuthIdle;if("SCRYPT_DEFAULT"===i||"SCRYPT_ADVANCED"===i){if(!e.formData.username||!e.formData.password)return;var d=e.formData.scrypt&&e.formData.scrypt.params;l.loading.show(),a=o.scryptKeypair(e.formData.username,e.formData.password,d).then((function(t){if(!t)return l.loading.hide(10);var n=o.util.encode_base58(t.signPk);return E.expectedPubkey&&E.expectedPubkey!=n?(e.pubkey=n,e.showPubkey=!0,e.pubkeyError=!0,l.loading.hide(10)):(e.pubkeyError=!1,{pubkey:n,keypair:t,params:e.formData.scrypt&&"SCRYPT_DEFAULT"!=e.formData.scrypt.id?d:void 0})})).catch(l.onError("ERROR.CRYPTO_UNKNOWN_ERROR"))}else if("FILE"===i){if(!e.formData.file||!e.formData.file.valid||!e.formData.file.pubkey)return;s=e.formData.keepAuth&&p.constants.KEEP_AUTH_IDLE_SESSION||s,a=l.loading.show().then((function(){return e.readKeyFile(e.formData.file,{withSecret:e.isAuth||e.formData.keepAuth})})).then((function(t){if(!t)return l.loading.hide(10);var n=o.util.encode_base58(t.signPk);return E.expectedPubkey&&E.expectedPubkey!=n?(e.formData.file.valid=!1,l.loading.hide(10)):(e.pubkeyError=!1,{pubkey:n,keypair:t})})).catch(l.onError("ERROR.AUTH_FILE_ERROR"))}else if("PUBKEY"===i){var u=e.formData.pubkey&&e.formData.pubkey.trim(),m=e.formData.uid&&e.formData.uid.trim()||void 0;if(!u)return;var b=c.regexp.PUBKEY.exec(u);if(b)a=l.loading.show().then((function(){return{pubkey:u,uid:m}}));else{if(!(b=c.regexp.PUBKEY_WITH_CHECKSUM.exec(u)))return e.showWotLookupModal(u);u=b[1],b[2]!=r.util.pkChecksum(u)?e.form.pubkey.$error={checksum:!0}:a=l.loading.show().then((function(){return{pubkey:u,uid:m}}))}}else if("SCAN"===i){if(!e.formData.pubkey||e.isAuth&&!e.formData.keypair)return;a=l.loading.show().then((function(){return{pubkey:e.formData.pubkey,keypair:e.formData.keypair}}))}if(a)return a.then((function(n){if(n){var a=!angular.equals(p.data.rememberMe,e.formData.rememberMe),o=!angular.equals(p.data.keepAuthIdle,s),r=!angular.equals(p.data.login&&p.data.login.method,i),c=!angular.equals(p.data.login&&p.data.login.params,n.params);return(a||o||r||c)&&(p.data.rememberMe=e.formData.rememberMe,p.data.keepAuthIdle=s,p.data.useLocalStorage=!!p.data.rememberMe||p.data.useLocalStorage,p.data.login=p.data.login||{},p.data.login.method=i,p.data.login.params=n.params,t(p.store,500)),E.success&&E.success(e.formData),E.silent&&l.loading.hide(),e.closeModal(n)}}));console.warn("[login] unknown method: ",i)}},e.onScryptFormChanged=function(){e.computing||(e.pubkey=null,e.pubkeyError=!1,e.showPubkey=!!e.formData.username&&!!e.formData.password,e.autoComputePubkey&&e.showPubkey?(e.computePubkey(),e.showComputePubkeyButton=!1):e.showComputePubkeyButton=!e.autoComputePubkey&&e.showPubkey)},e.$watch("formData.username + formData.password",e.onScryptFormChanged,!0),e.computePubkey=function(){return e.showComputePubkeyButton=!1,e.computing=!0,e.pubkey=null,t((function(){var t=e.formData.username,n=e.formData.password,i=e.formData.scrypt&&e.formData.scrypt.params;return o.scryptSignPk(t,n,i).then((function(i){if(t!==e.formData.username||n!==e.formData.password)return e.computePubkey();e.pubkey=o.util.encode_base58(i),e.expectedPubkey&&e.expectedPubkey!=e.pubkey&&(e.pubkeyError=!0),e.computing=!1})).catch((function(t){l.onError("ERROR.CRYPTO_UNKNOWN_ERROR")(t),e.computing=!1,e.autoComputePubkey=!1,e.onScryptFormChanged()}))}),100)},e.showJoinModal=function(){e.closeModal(),t((function(){d.showJoin()}),300)},e.showAccountSecurityModal=function(){e.closeModal(),t((function(){d.showAccountSecurity()}),300)},e.showHelpModal=function(e){return d.showHelp(e)},e.doScan=function(){if(!e.computing)return e.computing=!0,e.formData.pubkey=null,e.formData.keypair=null,m.barcode.scan().then((function(t){if(t)return e.isAuth?n.when(t):c.uri.parse(t).then((function(e){if(!e||!e.pubkey)throw{message:"ERROR.SCAN_UNKNOWN_FORMAT"};return e})).catch((function(e){return console.debug("[login] Error while parsing as URI: "+(e&&e.message||e)),t}))})).then((function(e){if(e)return e&&e.pubkey?e:r.keyfile.parseData(e,{silent:!0}).then((function(e){if(!e||!e.signPk||!e.signSk)throw{message:"ERROR.SCAN_UNKNOWN_FORMAT"};return{pubkey:o.base58.encode(e.signPk),keypair:e}})).catch(l.onError("ERROR.SCAN_UNKNOWN_FORMAT"))})).then((function(t){t&&t.pubkey&&(e.pubkeyError=e.expectedPubkey&&e.expectedPubkey!=t.pubkey,e.formData.pubkey=t.pubkey,e.formData.keypair=t.keypair)})).then((function(){e.computing=!1,l.loading.hide(10)})).catch((function(t){e.computing=!1,l.onError("ERROR.SCAN_FAILED")(t)}))},e.changeMethod=function(t,n){if(e.hideMethodsPopover(),"PUBKEY"!==t&&u.demo)return l.alert.demo();if(t&&t!==e.formData.method)if(console.debug("[login] method is: "+t),e.formData.method=t,e.formData.uid=null,e.form&&delete e.form.$submitted,"SCRYPT_DEFAULT"===t||"SCRYPT_ADVANCED"===t){var i;e.pubkey=null,n?(i=_.find(e.scryptParamsValues,(function(e){return e.params&&angular.equals(e.params,n)})))||((i=_.findWhere(e.scryptParamsValues,{id:"USER"})||{}).params=n):i=_.findWhere(e.scryptParamsValues,{id:"DEFAULT"}),e.changeScrypt(i),e.autoComputePubkey=e.autoComputePubkey&&"SCRYPT_DEFAULT"===t}else{if("SCAN"===t)return e.doScan();e.formData.username=null,e.formData.password=null,e.formData.pubkey=null,e.pubkey=null,e.computing=!1}},e.changeScrypt=function(t){e.formData.scrypt=angular.copy(t||{}),e.onScryptFormChanged()},e.readKeyFile=function(n,i){return(i=i||{}).password=i.password||e.formData.file.password||function(){return e.formData.file.password=void 0,d.showPassword({title:"ACCOUNT.SECURITY.KEYFILE.PASSWORD_POPUP.TITLE",subTitle:"ACCOUNT.SECURITY.KEYFILE.PASSWORD_POPUP.HELP",error:i.error,scope:e}).then((function(n){return e.formData.file.password=n,t((function(){return n}),150)}))},r.keyfile.read(e.formData.file,i).catch((function(t){if(e.formData.file.password=void 0,"CANCELLED"===t&&l.loading.hide(10),t&&t.ucode==r.errorCodes.BAD_PASSWORD)return e.readKeyFile(e.formData.file,{withSecret:i.withSecret,error:"ACCOUNT.SECURITY.KEYFILE.ERROR.BAD_PASSWORD"});throw t}))},e.onFileChanged=function(n){n&&n.fileData?(e.formData.file={name:n.fileData.name,size:n.fileData.size,content:n.fileContent},e.validatingFile=!0,t((function(){return console.debug("[login] key file changed: ",e.formData.file),e.validatingFile=!0,e.readKeyFile(e.formData.file,{withSecret:!1,password:e.formData.file.password}).then((function(t){t&&t.signPk?(e.formData.file.pubkey=o.util.encode_base58(t.signPk),e.formData.file.valid=!e.expectedPubkey||e.expectedPubkey===e.formData.file.pubkey,e.validatingFile=!1):(e.formData.file.valid=!1,e.formData.file.pubkey=void 0)})).catch((function(t){t&&"CANCELLED"===t?e.removeKeyFile():(e.validatingFile=!1,e.formData.file.valid=!1,e.formData.file.pubkey=void 0,l.onError("ERROR.AUTH_FILE_ERROR")(t))}))}))):e.validatingFile=!1},e.removeKeyFile=function(){e.formData.file=void 0},e.showWotLookupModal=function(n){return d.showWotLookup({q:n}).then((function(n){if(n&&n.pubkey)return e.formData.pubkey=n.pubkey,e.formData.uid=n.uid||void 0,t(e.doLogin,300)}))},e.showMethodsPopover=function(t){t.defaultPrevented||l.popover.show(t,{templateUrl:"templates/login/popover_methods.html",scope:e,autoremove:!0,afterShow:function(t){e.methodsPopover=t,l.ink({selector:".popover-login-methods .item"})}})},e.hideMethodsPopover=function(){e.methodsPopover&&(e.methodsPopover.hide(),e.methodsPopover=null)},e.init()}function p(e,t,n){var i=angular.copy(n);i.demo=!1,i.readonly=!1,angular.extend(this,t("LoginModalCtrl",{$scope:e,parameters:{auth:!0},csConfig:i})),e.setForm=function(t){e.form=t}}function m(e,t,n,i,a){e.$on("$ionicView.enter",(function(o){e.locale=a.data.locale.id,t.stateParams&&t.stateParams.anchor&&(e.anchor=t.stateParams.anchor,n((function(){i(t.stateParams.anchor)}),100))}))}function E(e,t,n,i,a){e.itemsClass={},e.locale=i.data.locale.id,(a=a||{})&&"string"==typeof a&&(a={anchor:a}),a.anchor&&(t((function(){n(a.anchor)}),100),e.itemsClass={},e.itemsClass[a.anchor]="selected",e.listClass="selection")}function b(e,t,n,i,a,o,r,s,l,c,d,u,p,m){e.tour=!1,e.continue=!0,e.executeStep=function(t,n,i){if((i=angular.isDefined(i)?i:0)>=n.length)return o.when(!0);var a=n[i];if("function"!=typeof a)throw new Error("[helptip] Invalid step at index {0} of '{1}' tour: step must be a function".format(i,t));var r=a();return"boolean"==typeof r&&(r=o.when(r)),r.then((function(a){return angular.isUndefined(a)?(e.continue=!1,i):a&&i!==n.length-1?e.executeStep(t,n,i+1):a?-1:i+1})).catch((function(n){return n&&"transition prevented"===n.message?console.error("ERROR: in help tour [{0}], in step [{1}] -> use large if exists, to prevent [transition prevented] error".format(t,i)):console.error("ERROR: in help tour [{0}], in step [{1}] : {2}".format(t,i,n)),e.continue=!1,i}))},e.showHelpTip=function(t,n){return(n=n||{}).bindings=n.bindings||{},n.bindings.value=n.bindings.value||"",n.bindings.hasNext=!angular.isDefined(n.bindings.hasNext)||n.bindings.hasNext,n.timeout=n.timeout||(p.enable?900:500),n.autoremove=!0,n.bindings.tour=e.tour,n.backdropClickToClose=!e.tour,s.popover.helptip(t,n)},e.showHelpModal=function(e){Modals.showHelp({anchor:e})},e.startHelpTour=function(){return e.tour=!0,e.continue=!0,console.debug("[help] Starting help tour... {demo: {0}, readonly: {1}, isLogin: {2}}".format(l.demo,l.readonly,m.isLogin())),(!l.readonly&&m.isLogin()?e.startWalletNoLoginTour(0,!0):o.when(!0)).then((function(t){return!!t&&(!(!l.readonly&&m.isLogin())||e.startWalletTour(0,!0).then((function(t){return!!t&&(c.data.helptip.wallet=t,c.store(),e.continue)})))})).then((function(t){return!!t&&(!(!l.readonly&&m.isLogin())||e.startWalletCertTour(0,!0).then((function(t){return!!t&&(c.data.helptip.walletCerts=t,c.store(),e.continue)})))})).then((function(t){return!!t&&(!(!l.readonly&&m.isLogin())||e.startTxTour(0,!0).then((function(t){return!!t&&(c.data.helptip.tx=t,c.store(),e.continue)})))})).then((function(t){return!!t&&(!(!l.readonly&&m.isLogin())||e.startWalletsTour(0,!0).then((function(t){return!!t&&(c.data.helptip.wallets=t,c.store(),e.continue)})))})).then((function(t){return!!t&&(!!l.readonly||e.startHeaderTour(0,!0))})).then((function(t){return!!t&&(!!l.readonly||e.startSettingsTour(0,!0))})).then((function(t){return!!t&&e.startWotLookupTour(0,!0).then((function(t){return!(!t||e.cancelled)&&(c.data.helptip.wotLookup=t,c.store(),e.continue)}))})).then((function(t){return!!t&&e.startWotTour(0,!0).then((function(t){return!(!t||e.cancelled)&&(c.data.helptip.wot=t,c.store(),e.continue)}))})).then((function(t){return!!t&&e.startWotCertTour(0,!0).then((function(t){return!!t&&(c.data.helptip.wotCerts=t,c.store(),e.continue)}))})).then((function(t){return!!t&&e.startCurrencyTour(0,!0).then((function(t){return!(!t||e.cancelled)&&(c.data.helptip.currency=t,c.store(),e.continue)}))})).then((function(t){return!!t&&e.startNetworkTour(0,!0).then((function(t){return!(!t||e.cancelled)&&(c.data.helptip.network=t,c.store(),e.continue)}))})).then((function(t){return!!t&&(!l.readonly||e.startSettingsTour(0,!0))})).then((function(t){return!!t&&e.finishTour()}))},e.startCurrencyTour=function(n,a){var o,u=[function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-currency",{bindings:{content:"HELP.TIP.MENU_BTN_CURRENCY",icon:{position:s.screen.isSmall()||l.readonly?"left":"bottom-left"}}})},function(){return i.isOpen()&&i.toggleLeft(!1),t.go(s.screen.isSmall()?"app.currency":"app.currency_lg").then((function(){return e.showHelpTip("helptip-currency-mass-member",{bindings:{content:"HELP.TIP.CURRENCY_MASS",icon:{position:"center"}}})}))},function(){return!c.data.useRelative||e.showHelpTip("helptip-currency-mass-member-unit",{bindings:{content:"HELP.TIP.CURRENCY_UNIT_RELATIVE",contentParams:o,icon:{position:s.screen.isSmall()?"right":"center"}}})},function(){return r("helptip-currency-rules-anchor"),e.showHelpTip("helptip-currency-rules",{bindings:{content:"HELP.TIP.CURRENCY_RULES",icon:{position:"center",glyph:"ion-information-circled"}}})},function(){return t.is("app.currency.tab_parameters")&&t.go("app.currency.tab_wot"),r("helptip-currency-newcomers-anchor"),e.showHelpTip("helptip-currency-newcomers",{bindings:{content:"HELP.TIP.CURRENCY_WOT",icon:{position:"center"},hasNext:a},timeout:1200,retry:2})}];return d.get().then((function(t){return o=t.parameters,e.executeStep("currency",u,n)}))},e.startNetworkTour=function(o,r){var u=function(){t.is("app.currency")&&a((function(){var e=n.document.querySelectorAll("ion-tabs .tabs a");e&&3===e.length&&angular.element(e[2]).triggerHandler("click")}),100)},p=[function(){return!!s.screen.isSmall()||(i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-network",{bindings:{content:"HELP.TIP.MENU_BTN_NETWORK",icon:{position:s.screen.isSmall()||l.readonly?"left":"bottom-left"}}}))},function(){return i.isOpen()&&i.toggleLeft(!1),t.go(s.screen.isSmall()?"app.currency.tab_network":"app.network").then((function(){return u(),e.showHelpTip("helptip-network-peers",{bindings:{content:"HELP.TIP.NETWORK_BLOCKCHAIN",icon:{position:"center",glyph:"ion-information-circled"}},timeout:1200})}))},function(){return u(),e.showHelpTip("helptip-network-peer-0",{bindings:{content:"HELP.TIP.NETWORK_PEERS",icon:{position:s.screen.isSmall()?void 0:"center"}},timeout:1e3,retry:20})},function(){return u(),e.showHelpTip("helptip-network-peer-0-block",{bindings:{content:"HELP.TIP.NETWORK_PEERS_BLOCK_NUMBER",icon:{position:s.screen.isSmall()?void 0:"center"}}})},function(){u();var t=c.data.locale.id;return e.showHelpTip("helptip-network-peers",{bindings:{content:"HELP.TIP.NETWORK_PEERS_PARTICIPATE",contentParams:{installDocUrl:l.helptip&&l.helptip.installDocUrl?l.helptip.installDocUrl[t]?l.helptip.installDocUrl[t]:l.helptip.installDocUrl:"http://duniter.org"},icon:{position:"center",glyph:"ion-information-circled"},hasNext:r}})}];return d.parameters().then((function(t){return e.executeStep("network",p,o)}))},e.startWotLookupTour=function(o,r){var c=[function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-wot",{bindings:{content:"HELP.TIP.MENU_BTN_WOT",icon:{position:s.screen.isSmall()||l.readonly?"left":"bottom-left"}},onError:"continue"})},function(){return i.isOpen()&&i.toggleLeft(!1),t.go(s.screen.isSmall()?"app.wot_lookup.tab_search":"app.wot_lookup_lg").then((function(){return e.showHelpTip("helptip-wot-search-text",{bindings:{content:s.screen.isSmall()?"HELP.TIP.WOT_SEARCH_TEXT_XS":"HELP.TIP.WOT_SEARCH_TEXT",icon:{position:"center"}}})}))},function(){return e.showHelpTip("helptip-wot-search-result-0",{bindings:{content:"HELP.TIP.WOT_SEARCH_RESULT",icon:{position:"center"}},timeout:700,retry:15})},function(){var t=n.document.getElementById("helptip-wot-search-result-0");return!t||(a((function(){angular.element(t).triggerHandler("click")})),e.showHelpTip("helptip-wot-view-certifications",{bindings:{content:"HELP.TIP.WOT_VIEW_CERTIFICATIONS",hasNext:r},timeout:2500}))}];return e.executeStep("wotLookup",c,o)},e.startWotTour=function(t,n){var i,a=[function(){return e.showHelpTip("helptip-wot-view-certifications",{bindings:{content:"HELP.TIP.WOT_VIEW_CERTIFICATIONS_COUNT",contentParams:i,icon:{position:"center",glyph:"ion-information-circled"}}})},function(){return e.showHelpTip("helptip-wot-view-certifications-count",{bindings:{content:"HELP.TIP.WOT_VIEW_CERTIFICATIONS_CLICK",icon:{position:"center"},hasNext:n}})}];return d.get().then((function(n){return(i=n.parameters).currentUD=n.currentUD,e.executeStep("wot",a,t)}))},e.startWotCertTour=function(i,r){if(l.readonly)return o.when(!0);var c=[function(){if(t.is("app.wot_identity")){var i=n.document.getElementById("helptip-wot-view-certifications");if(!i)return!0;a((function(){angular.element(i).triggerHandler("click")}))}return e.showHelpTip(s.screen.isSmall()?"fab-certify":"helptip-certs-certify",{bindings:{content:"HELP.TIP.WOT_VIEW_CERTIFY",icon:{position:s.screen.isSmall()?"bottom-right":"center"}},timeout:s.screen.isSmall()?2e3:1e3,retry:10})},function(){return e.showHelpTip(s.screen.isSmall()?"fab-certify":"helptip-certs-certify",{bindings:{content:"HELP.TIP.CERTIFY_RULES",icon:{position:"center",glyph:"ion-alert-circled"},hasNext:r}})}];return e.executeStep("certs",c,i)},e.startWalletNoLoginTour=function(t,n){if(m.isLogin())return o.when(!0);var a=[function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-account",{bindings:{content:"HELP.TIP.MENU_BTN_ACCOUNT",icon:{position:"left"},hasNext:n}})},function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-tx",{bindings:{content:"HELP.TIP.MENU_BTN_TX",icon:{position:"left"},hasNext:n}})},function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-wallets",{bindings:{content:"HELP.TIP.MENU_BTN_WALLETS",icon:{position:"left"},hasNext:n}})}];return e.executeStep("wallet-no-login",a,t)},e.startWalletTour=function(n,a){if(!m.isLogin())return o.when(!0);var l=m.data.isMember||m.data.requirements&&m.data.requirements.pendingMembership,c=[function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-account",{bindings:{content:m.data.isMember?"HELP.TIP.MENU_BTN_ACCOUNT_MEMBER":"HELP.TIP.MENU_BTN_ACCOUNT",icon:{position:"left"}}})},function(){return i.isOpen()&&i.toggleLeft(!1),t.go("app.view_wallet").then((function(){return e.showHelpTip(s.screen.isSmall()?"helptip-wallet-options-xs":"helptip-wallet-options",{bindings:{content:"HELP.TIP.WALLET_OPTIONS",icon:{position:s.screen.isSmall()?"right":"center"}},timeout:s.screen.isSmall()?2e3:1e3,retry:10})}))},function(){return r("helptip-wallet-pubkey"),e.showHelpTip("helptip-wallet-pubkey",{bindings:{content:"HELP.TIP.WALLET_PUBKEY",icon:{position:"center"},hasNext:!l&&a},timeout:s.screen.isSmall()?2e3:500,retry:10})},function(){return l?(r("helptip-wallet-certifications"),e.showHelpTip("helptip-wallet-certifications",{bindings:{content:s.screen.isSmall()?"HELP.TIP.WALLET_RECEIVED_CERTIFICATIONS":"HELP.TIP.WALLET_CERTIFICATIONS",icon:{position:"center"},hasNext:a},timeout:500,onError:"continue"})):a}];return c.length!=u.wallet.stepCount&&console.error("[help] Invalid value of 'csHelpConstants.wallet.stepCount'. Please update to {0}".format(c.length)),d.get().then((function(t){return t.parameters.currentUD=t.currentUD,e.executeStep("wallet",c,n)}))},e.startWalletCertTour=function(i,r){if(!m.isLogin())return o.when(!0);var l=!1,c=[function(){if(t.is("app.view_wallet")){var i=n.document.getElementById("helptip-wallet-certifications");if(!i)return l=!0,!0;a((function(){angular.element(i).triggerHandler("click")}))}return!s.screen.isSmall()||e.showHelpTip("helptip-received-certs",{bindings:{content:"HELP.TIP.WALLET_RECEIVED_CERTS"}})},function(){return!(!l&&s.screen.isSmall())||t.go("app.view_wallet").then((function(){return e.showHelpTip("helptip-wallet-given-certifications",{bindings:{content:"HELP.TIP.WALLET_GIVEN_CERTIFICATIONS",icon:{position:"center"}},timeout:500})}))},function(){if(l)return!0;if(t.is("app.view_wallet")){var i=n.document.getElementById("helptip-wallet-given-certifications");if(!i)return l=!0,!0;a((function(){angular.element(i).triggerHandler("click")}),500)}return e.showHelpTip(s.screen.isSmall()?"fab-select-certify":"helptip-certs-select-certify",{bindings:{content:"HELP.TIP.WALLET_CERTIFY",icon:{position:s.screen.isSmall()?"bottom-right":"center"}},timeout:s.screen.isSmall()?2e3:500,retry:10})},function(){return e.tour||l?r:e.showHelpTip("helptip-certs-stock",{bindings:{content:"HELP.TIP.CERTIFY_RULES",icon:{position:"center",glyph:"ion-alert-circled"},hasNext:r}})}];return d.parameters().then((function(t){return e.executeStep("certs",c,i)}))},e.startTxTour=function(n,a){if(!m.isLogin())return o.when(!0);var r,s=[function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-tx",{bindings:{content:"HELP.TIP.MENU_BTN_TX",icon:{position:"left"}}})},function(){return i.isOpen()&&i.toggleLeft(!1),t.go("app.view_wallet_tx").then((function(){return e.showHelpTip("helptip-wallet-balance",{bindings:{content:c.data.useRelative?"HELP.TIP.WALLET_BALANCE_RELATIVE":"HELP.TIP.WALLET_BALANCE",contentParams:r,icon:{position:"center"}},retry:20})}))},function(){return e.showHelpTip("helptip-wallet-balance",{bindings:{content:"HELP.TIP.WALLET_BALANCE_CHANGE_UNIT",contentParams:r,icon:{position:"center",glyph:"ion-information-circled"}}})}];return d.get().then((function(t){return(r=t.parameters).currentUD=t.currentUD,e.executeStep("tx",s,n)}))},e.startWalletsTour=function(t,n){var a=[function(){return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-wallets",{bindings:{content:"HELP.TIP.MENU_BTN_WALLETS",icon:{position:"left"},hasNext:n}})}];return e.executeStep("my-wallets",a,t)},e.startHeaderTour=function(r,c){if(s.screen.isSmall()||l.readonly)return o.when(!0);function d(){var e=n.document.querySelectorAll("#helptip-header-bar-btn-profile");return e&&e.length?_.find(e,(function(e){return e.offsetWidth>0})):null}var u=[function(){if(s.screen.isSmall())return!0;var n=d();return!n||e.showHelpTip(n,{bindings:{content:"HELP.TIP.HEADER_BAR_BTN_PROFILE",icon:{position:"right",style:t.is("app.home")?"margin-right: 60px":void 0}}})},function(){if(s.screen.isSmall())return i.toggleLeft(!0),e.showHelpTip("helptip-menu-btn-settings",{bindings:{content:"HELP.TIP.MENU_BTN_SETTINGS",icon:{position:"left"},hasNext:c},timeout:1e3});var t=d();return!t||(a((function(){angular.element(t).triggerHandler("click")})),e.showHelpTip("helptip-popover-profile-btn-settings",{bindings:{content:"HELP.TIP.MENU_BTN_SETTINGS",icon:{position:"center"},hasNext:c},timeout:1e3}).then((function(t){return e.closeProfilePopover(),t})))}];return e.executeStep("header",u,r)},e.startSettingsTour=function(n,a){var o,r=[function(){return!s.screen.isSmall()&&!l.readonly||(i.toggleLeft(!0),e.showHelpTip(s.screen.isSmall()?"helptip-menu-btn-settings":"menu-btn-settings",{bindings:{content:"HELP.TIP.MENU_BTN_SETTINGS",icon:{position:s.screen.isSmall()?"left":"bottom-left"}},timeout:1e3}))},function(){return i.isOpen()&&i.toggleLeft(!1),t.go("app.settings").then((function(){return e.showHelpTip("helptip-settings-btn-unit-relative",{bindings:{content:"HELP.TIP.SETTINGS_CHANGE_UNIT",contentParams:o,icon:s.screen.isSmall()?{position:"right",style:"margin-right: 60px"}:{position:"center"},hasNext:a},timeout:1e3})}))}];return d.parameters().then((function(t){return o=t,e.executeStep("settings",r,n)}))},e.finishTour=function(){return i.isOpen()&&i.toggleLeft(!1),m.isLogin()?t.go("app.view_wallet").then((function(){return e.showHelpTip("helptip-wallet-pubkey",{bindings:{content:"HELP.TIP.END_LOGIN",hasNext:!1},timeout:1200})})):o.all([e.showHome(),d.parameters().then((function(e){n=e}))]).then((function(){return e.showHelpTip("helptip-home-logo",{bindings:{content:l.readonly?"HELP.TIP.END_READONLY":"HELP.TIP.END_NOT_LOGIN",contentParams:n,hasNext:!1}})}));var n}}function g(e){e.$on("$ionicView.enter",(function(t,n){e.startHelpTour()}))}function f(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E,b,g,f){var h;e.loading=!0,e.settings=b.data,e.qrcodeId="qrcode-wallet-"+e.$id,e.toggleQRCode=!1,e.likeData={likes:{},abuses:{}},e.enter=function(t,n){if(e.loading=e.loading||n.stateParams&&n.stateParams.refresh,e.enableSelectWallet=g.children.count()>0,e.loading)return(h=n.stateParams&&n.stateParams.id?g.children.get(n.stateParams.id):g)?(e.isDefaultWallet=h.isDefault(),e.walletId=h.id,e.cleanLocationHref(n),e.load()):(c.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome());c.loading.hide(10),a(e.updateView,300)},e.$on("$ionicView.enter",e.enter),e.load=function(){if(h)return h.login().then((function(t){e.formData=t,e.loading=!1,e.updateView(),e.addListeners(),e.showQRCode(),h.isDefault()&&e.showHelpTip(),c.loading.hide(10)})).catch((function(t){"CANCELLED"!==t?c.onError("ERROR.LOAD_WALLET_DATA_ERROR")(t):e.showHome()}))},e.updateView=function(){e.motion.show({selector:"#wallet .item"}),e.$broadcast("$$rebind::rebind")},e.setRegisterForm=function(t){e.registerForm=t},e.onWalletLogout=function(){e.hideQRCode(),e.removeListeners(),delete e.formData,h=null,e.loading=!0},e.addListeners=function(){e.listeners=[h.api.data.on.logout(e,e.onWalletLogout),e.$watchCollection("formData.events",(function(t,n){!n||e.loading||angular.equals(t,n)||e.updateView()}))]},e.removeListeners=function(){_.forEach(e.listeners,(function(e){e()})),e.listeners=[]},e.showUidPopup=function(){return n((function(t,n){r(["ACCOUNT.NEW.TITLE","ACCOUNT.POPUP_REGISTER.TITLE","ACCOUNT.POPUP_REGISTER.HELP","COMMON.BTN_OK","COMMON.BTN_CANCEL"]).then((function(a){e.formData.newUid=e.formData.uid?""+e.formData.uid:"",i.show({templateUrl:"templates/wallet/popup_register.html",title:a["ACCOUNT.POPUP_REGISTER.TITLE"],subTitle:a["ACCOUNT.POPUP_REGISTER.HELP"],scope:e,buttons:[{text:a["COMMON.BTN_CANCEL"]},{text:a["COMMON.BTN_OK"],type:"button-positive",onTap:function(t){if(e.registerForm.$submitted=!0,e.registerForm.$valid&&e.formData.newUid)return e.formData.newUid;t.preventDefault()}}]}).then((function(i){if(!i)return delete e.formData.uid,c.loading.hide(),void n("CANCELLED");t(i)}))}))}))},e.self=function(){return e.hideActionsPopover(),e.showUidPopup().then((function(t){if(t)return c.loading.show(),h.self(t).then((function(){e.updateView(),c.loading.hide()})).catch((function(t){c.onError("ERROR.SEND_IDENTITY_FAILED")(t).then((function(){e.self()}))}))}))},e.doMembershipIn=function(t){return h.membership.inside().then((function(){e.updateView(),c.loading.hide()})).catch((function(n){if("CANCELLED"===n)throw n;if(n&&n.ucode!=m.errorCodes.MEMBERSHIP_ALREADY_SEND)return console.error("[wallet] Node: already membership",n),void c.loading.hide();if(!t||t<=2)return a((function(){return e.doMembershipIn((t||0)+1)}),1e3);throw n}))},e.membershipIn=function(t){if(e.hideActionsPopover(),h.isMember())return c.alert.info("INFO.NOT_NEED_MEMBERSHIP");var n=angular.isDefined(e.formData.blockUid)&&e.formData.uid||void 0;return u.showJoinMember({uid:n,blockUid:n&&e.formData.blockUid,pubkey:e.formData.pubkey}).catch((function(e){"CANCELLED"!==e&&(h.data.uid?c.onError("ERROR.SEND_MEMBERSHIP_IN_FAILED")(e):c.onError("ERROR.SEND_IDENTITY_FAILED")(e))}))},e.membershipOut=function(t,n){return e.hideActionsPopover(),t?n?(c.loading.show(),h.membership.out().then((function(){c.loading.hide(),c.toast.show("INFO.MEMBERSHIP_OUT_SENT")})).catch(c.onError("ERROR.SEND_MEMBERSHIP_OUT_FAILED"))):c.alert.confirm("CONFIRM.MEMBERSHIP_OUT_2","CONFIRM.POPUP_TITLE",{cssClass:"warning",okText:"COMMON.BTN_YES",okType:"button-assertive"}).then((function(t){t&&e.membershipOut(!0,!0)})):c.alert.confirm("CONFIRM.MEMBERSHIP_OUT","CONFIRM.POPUP_WARNING_TITLE",{cssClass:"warning",okText:"COMMON.BTN_YES",okType:"button-assertive"}).then((function(t){t&&e.membershipOut(!0)}))},e.doUpdate=function(t){return console.debug("[wallet] Refreshing data..."),(t?h.refreshData():c.loading.show().then(h.refreshData).then(c.loading.hide)).then(e.updateView).catch(c.onError("ERROR.REFRESH_WALLET_DATA"))},e.renewMembership=function(t){return h.isMember()||e.formData.requirements.wasMember?t||e.formData.requirements.needRenew?h.auth({minData:!0}).then((function(){return c.loading.hide(),c.alert.confirm("CONFIRM.RENEW_MEMBERSHIP")})).then((function(t){if(t)return c.loading.show(),e.doMembershipIn()})).catch((function(e){"CANCELLED"!==e&&(c.loading.hide(),c.alert.error(e))})):r("CONFIRM.NOT_NEED_RENEW_MEMBERSHIP",{membershipExpiresIn:e.formData.requirements.membershipExpiresIn}).then((function(e){return c.alert.confirm(e)})).then((function(t){if(t)return e.renewMembership(!0)})):c.alert.error("ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION")},e.fixIdentity=function(){if(e.formData.uid)return n.all([h.auth(),r("CONFIRM.FIX_IDENTITY",{uid:e.formData.uid})]).then((function(e){return c.alert.confirm(e[1])})).then((function(t){if(t)return c.loading.show(),e.formData.blockUid=null,e.formData.sigDate=null,h.self(e.formData.uid)})).then(e.doMembershipIn).catch((function(e){"CANCELLED"!==e&&(c.loading.hide(),c.alert.error(e))}))},e.fixMembership=function(){if(e.formData.uid)return h.isMember()?c.alert.info("INFO.NOT_NEED_MEMBERSHIP"):(e.hideActionsPopover(),h.auth({silent:!0}).then((function(){c.alert.confirm("CONFIRM.FIX_MEMBERSHIP")})).then((function(t){if(t)return c.loading.show(),e.formData.blockUid=null,e.formData.sigDate=null,h.self(e.formData.uid,!1)})).then(e.doMembershipIn).catch((function(e){"CANCELLED"!==e&&(c.loading.hide(),c.alert.error(e))})))},e.doQuickFix=function(t){"renew"===t?e.renewMembership():"membership"===t?e.membershipIn(!0):"fixMembership"===t?e.fixMembership(!1):"fixIdentity"===t&&e.fixIdentity()};var T=e.logout;e.logout=function(t){if(e.isDefaultWallet)return T(t)},e.startWalletTour=function(){return e.hideActionsPopover(),f.wallet.tour()},e.showHelpTip=function(){return f.wallet.helptip()},e.showQRCode=function(t){if(h&&e.qrcodeId){var n=angular.element(document.querySelector("#"+e.qrcodeId+" .content"));n?h.loadQrCode().then((function(i){n.html(i),c.motion.toggleOn({selector:"#"+e.qrcodeId},t||1100)})):console.error("[wallet-controller] Cannot found div #{0} for the QRCode. Skipping.".format(e.qrcodeId))}},e.hideQRCode=function(){e.qrcodeId&&angular.element(document.querySelector("#"+e.qrcodeId))&&c.motion.toggleOff({selector:"#"+e.qrcodeId})},e.showCertifications=function(){e.isDefaultWallet?o.go(c.screen.isSmall()?"app.wallet_cert":"app.wallet_cert_lg",{type:"received"}):o.go(c.screen.isSmall()?"app.wallet_cert_by_id":"app.wallet_cert_lg_by_id",{id:e.walletId,type:"received"})},e.showGivenCertifications=function(){e.isDefaultWallet?o.go(c.screen.isSmall()?"app.wallet_cert":"app.wallet_cert_lg",{type:"given"}):o.go(c.screen.isSmall()?"app.wallet_cert_by_id":"app.wallet_cert_lg_by_id",{id:e.walletId,type:"given"})},e.showTxHistory=function(){o.go(e.isDefaultWallet?"app.view_wallet_tx":"app.view_wallet_tx_by_id",{id:e.walletId})},e.showLicenseModal=function(){return d.show("templates/currency/modal_license.html","CurrencyLicenseModalCtrl")},e.showTransferModal=function(){if(e.formData.balance&&e.formData.balance>0||g.children.count())return u.showTransfer({wallet:h.id}).then((function(t){t&&(c.toast.show("INFO.TRANSFER_SENT"),e.$broadcast("$$rebind::balance"),e.motion.show({selector:".item-pending"}))}));c.alert.info("INFO.NOT_ENOUGH_CREDIT")},e.showSecurityModal=function(){return e.hideActionsPopover(),u.showAccountSecurity({wallet:h}).then((function(t){if(t)return"self"===t?e.self():"membershipIn"===t?e.membershipIn():void 0}))},e.showSelectIdentitiesModal=function(){return e.hideActionsPopover(),u.showSelectPubkeyIdentity({identities:[e.formData.requirements].concat(e.formData.requirements.alternatives)}).then((function(t){if(t&&t.uid)return e.loading=!0,h.setSelf(t.uid,t.blockUid).then((function(){e.loading=!1,e.updateView(),c.loading.hide()}))}))},e.showSelectWalletModal=function(){if(g.children.count())return u.showSelectWallet({parameters:{showDefault:!0,showBalance:!1,excludedWalletId:e.walletId}}).then((function(t){if(t&&(!h||t.id!==h.id))return e.removeListeners(),e.loading=!0,h=t,console.debug("[transfer] Using wallet {"+h.id+"}"),e.formData={},e.load()}))},e.showActionsPopover=function(t){c.popover.show(t,{templateUrl:"templates/wallet/popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.showSharePopover=function(n){e.hideActionsPopover();var i=e.formData.name||e.formData.uid||e.formData.pubkey,a=(E.shareBaseUrl||t.rootPath)+o.href("app.wot_identity",{pubkey:e.formData.pubkey,uid:e.formData.uid});c.screen.isSmall()&&(n=angular.element(document.querySelector("#wallet-share-anchor"))||n),c.popover.share(n,{bindings:{url:a,titleKey:"WOT.VIEW.POPOVER_SHARE_TITLE",titleValues:{title:i},postMessage:i}})},e.showSelectWalletPopover=function(t){return p.showSelectWallet(t,{parameters:{excludedWalletId:e.walletId}}).then((function(t){if(t&&t.id!==e.walletId)return t.isDefault()?o.go("app.view_wallet"):o.go("app.view_wallet_by_id",{id:t.id})}))},e.cleanLocationHref=function(e){e&&e.stateParams&&e.stateParams.refresh&&a((function(){var t=angular.copy(e.stateParams);delete t.refresh,delete t.id,l.search(t).replace()}),300)}}function h(e,t,n,i,a,o,r,s,l,c,d,u,p,m){var E;e.loading=!0,e.settings=d.data,e.listeners=[],e.qrcodeId="qrcode-wallet-tx-"+e.$id,e.enter=function(t,n){if(e.loading=e.loading||n.stateParams&&n.stateParams.refresh,e.enableSelectWallet=p.children.count()>0,e.loading)return(E=n.stateParams&&n.stateParams.id?p.children.get(n.stateParams.id):p)?(e.walletId=E.id,e.cleanLocationHref(n),e.load()):(o.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome());e.addListeners(),i(e.updateView,300)},e.$on("$ionicView.enter",e.enter),e.leave=function(){e.removeListeners()},e.$on("$ionicView.leave",e.leave),e.load=function(){if(!E)return $q.reject("Missing wallet");var t=E.isDataLoaded({minData:!0}),n={requirements:!t,minData:!t,sources:!0,tx:{enable:!0}};return E.login(n).then((function(t){return e.formData=t,e.loading=!1,e.updateView(),e.addListeners(),e.showFab("fab-transfer"),e.showQRCode(),E.isDefault()&&e.showHelpTip(),o.loading.hide(10)})).catch((function(t){"CANCELLED"!==t?(console.error(t),o.onError("ERROR.LOAD_WALLET_DATA_ERROR")(t)):e.showHome()}))},e.cleanLocationHref=function(e){e&&e.stateParams&&e.stateParams.refresh&&i((function(){var t=angular.copy(e.stateParams);delete t.refresh,delete t.id,a.search(t).replace()}),300)},e.updateView=function(){e.formData&&!e.loading&&(e.$broadcast("$$rebind::balance"),e.$broadcast("$$rebind::rebind"),e.motion.show({selector:".view-wallet-tx .item",ink:!1}))},e.downloadHistoryFile=function(t){(t=t||{}).fromTime=t.fromTime||-1;var n=e.formData.pubkey;m.downloadHistoryFile(n,t)},e.doUpdate=function(t){console.debug("[wallet] TX history reloading...");var n={sources:!0,tx:{enable:!0,fromTime:e.formData&&e.formData.tx&&e.formData.tx.fromTime||void 0},api:!1};return(t?E.refreshData(n):o.loading.show().then((function(){return E.refreshData(n)})).then(o.loading.hide)).then(e.updateView).catch(o.onError("ERROR.REFRESH_WALLET_DATA"))},e.showQRCode=function(t){if(E&&e.qrcodeId){var n=angular.element(document.querySelector("#"+e.qrcodeId+" .content"));n?E.loadQrCode().then((function(i){n.html(i),o.motion.toggleOn({selector:"#"+e.qrcodeId},t||1100)})):console.error("[wallet-controller] Cannot found div #{0} for the QRCode. Skipping.".format(e.qrcodeId))}},e.hideQRCode=function(){e.qrcodeId&&angular.element(document.querySelector("#"+e.qrcodeId))&&o.motion.toggleOff({selector:"#"+e.qrcodeId})},e.addListeners=function(){e.listeners=[E.api.data.on.balanceChanged(e,e.updateView),e.$watch("settings.useRelative",e.updateView,!0),e.$watch("settings.showUDHistory",(function(t,n){e.formData&&!e.loading&&t!==n&&e.doUpdate()}),!0)],e.settings.walletHistoryAutoRefresh&&e.listeners.push(u.api.data.on.newBlock(e,(function(t){e.loading||(console.debug("[wallet] Received new block. Will reload history."),i((function(){e.doUpdate(!0)}),500))})))},e.removeListeners=function(){_.forEach(e.listeners,(function(e){e()})),e.listeners=[]},e.showTransferModal=function(){if(e.formData.balance&&e.formData.balance>0||p.children.count())return r.showTransfer({wallet:E.id}).then((function(t){t&&(o.toast.show("INFO.TRANSFER_SENT"),e.$broadcast("$$rebind::balance"),e.motion.show({selector:".item-pending"}))}));o.alert.info("INFO.NOT_ENOUGH_CREDIT")},e.showHelpTip=function(e,t){},e.showTxErrors=function(t){return E.isDefault()?e.goState("app.view_wallet_tx_errors"):e.goState("app.view_wallet_tx_errors_by_id",{id:E.id})},e.showMoreTx=function(t){return t=t||e.formData.tx.fromTime-d.data.walletHistoryTimeSecond||c.date.now()-2*d.data.walletHistoryTimeSecond,o.loading.show(),E.refreshData({tx:{enable:!0,fromTime:t}}).then((function(){e.updateView(),o.loading.hide()})).catch((function(n){n.ucode==l.errorCodes.HTTP_LIMITATION?i((function(){return e.showMoreTx(t)}),2e3):o.onError("ERROR.REFRESH_WALLET_DATA")(n)}))},e.showSelectWalletModal=function(){if(p.children.count())return r.showSelectWallet({parameters:{showDefault:!0,showBalance:!1,excludedWalletId:e.walletId}}).then((function(t){if(t&&(!E||t.id!==E.id))return e.removeListeners(),e.loading=!0,E=t,console.debug("[transfer] Using wallet {"+E.id+"}"),e.formData={},e.load()}))},e.toUnlockUIArray=function(t,n,i){return n=n||0,!t.children||"AND"!=t.type&&"OR"!=t.type?{style:{"padding-left":n+"px"},operator:i,type:t.type,value:t.value}:t.children.reduce((function(i,a,o){return a.children&&o>0?(i=i.concat({style:{"padding-left":n+"px","padding-top":"10px","padding-bottom":"10px"},operator:t.type})).concat(e.toUnlockUIArray(a,n+10)):i.concat(e.toUnlockUIArray(a,n+10,o&&t.type))}),[])},e.showLockedOutputsPopover=function(t,n){t.lockedOutputs&&(e.popoverData=e.popoverData||{},e.popoverData.lockedOuputs=t.lockedOutputs.reduce((function(t,n){return t.concat({amount:n.amount,unlockFunctions:n.unlockFunctions,unlockConditions:e.toUnlockUIArray(n.unlockTree)})}),[]),o.popover.show(n,{templateUrl:"templates/wallet/tx_locked_outputs_popover.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}}))},e.hideLockedOutputsPopover=function(){e.lockedOutputsPopover&&(e.lockedOutputsPopover.hide(),e.popoverData&&delete e.popoverData.unlockConditions,e.lockedOutputsPopover=null)},e.showSelectWalletPopover=function(t){return s.showSelectWallet(t,{scope:e}).then((function(t){if(t&&t.id!==E.id)return t.isDefault()?e.goState("app.view_wallet_tx"):e.goState("app.view_wallet_tx_by_id",{id:t.id})}))},e.goState=function(t,i){return e.hideLockedOutputsPopover(),n.go(t,i)}}function T(e,t,n,i){var a;e.settings=n.data,e.loading=!0,e.formData={},e.$on("$ionicView.enter",(function(n,o){return(a=o.stateParams&&o.stateParams.id?i.children.get(o.stateParams.id):i)?e.load():(t.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome())})),e.load=function(){if(a)return a.login().then((function(n){e.formData=n,e.loading=!1,e.doMotion(),t.loading.hide()}))},e.doUpdate=function(n){return e.loading=!0,(n?a.refreshData():t.loading.show().then(i.refreshData).then(t.loading.hide)).then((function(){e.doMotion(),e.loading=!1})).catch((function(n){t.onError("ERROR.REFRESH_WALLET_DATA")(n),e.loading=!1}))},e.filterReceivedTx=function(e){return e.amount&&e.amount>0},e.filterSentTx=function(e){return e.amount&&e.amount<0},e.hasReceivedTx=function(){return e.formData.tx&&_(e.formData.tx.errors||[]).find(e.filterReceivedTx)&&!0},e.hasSentTx=function(){return e.formData.tx&&_(e.formData.tx.errors||[]).find(e.filterSentTx)&&!0}}function v(e,t,n,i,a,o){var r=o&&o.wallet||i;e.slides={slider:null,options:{loop:!1,effect:"slide",speed:500}},e.isLastSlide=!1,e.smallscreen=t.screen.isSmall(),e.recover={},e.isValidFile=!1,e.login=r.isLogin(),e.hasSelf=r.hasSelf(),e.needSelf=e.login&&r.data.requirements.needSelf,e.canRevoke=e.login&&e.hasSelf&&!r.data.requirements.revoked,e.needMembership=e.login&&r.data.requirements.needMembership,e.option=e.login?"saveID":"recoverID",e.formData={addQuestion:"",level:"4",questions:[]};for(var s=[],l=1;l<20;l++)s.push("ACCOUNT.SECURITY.QUESTION_"+l.toString());a(s).then((function(t){_.each(t,(function(t){e.formData.questions.push({value:t,checked:!1})}))})),e.$on("$ionicSlides.sliderInitialized",(function(e,t){t.slider.lockSwipes()})),e.slidePrev=function(){e.slides.slider.unlockSwipes(),e.slides.slider.slidePrev(),e.slides.slider.lockSwipes(),e.isLastSlide=!1},e.slideNext=function(){e.slides.slider.unlockSwipes(),e.slides.slider.slideNext(),e.slides.slider.lockSwipes(),e.isLastSlide=3===e.slides.slider.activeIndex&&("saveID"==e.option||"recoverID"==e.option)||2===e.slides.slider.activeIndex&&"revocation"==e.option},e.doNext=function(n){if(!n)switch(e.slides.slider.activeIndex){case 1:switch(e.option){case"saveID":n="questionsForm";break;case"recoverID":e.isValidFile?(e.slideNext(),e.hasContent=!1,e.fileData=""):t.alert.error("ERROR.NOT_VALID_SAVE_ID_FILE","ERROR.LOAD_FILE_FAILED")}break;case 2:switch(e.option){case"recoverID":n="recoverForm";break;case"saveID":n="answersForm"}}if(n){if(e[n].$submitted=!0,!e[n].$valid)return;switch(n){case"recoverForm":e.recoverId();break;case"answersForm":e.downloadSaveIDFile();break;default:e.slideNext()}}},e.selectOption=function(i,a){if(!a&&n.demo)return t.alert.demo();e.option=i,e.slideNext()},e.restore=function(){1===e.slides.slider.activeIndex&&"saveID"===e.option?(e.formData={addQuestion:"",level:"4",questions:[]},a(s).then((function(t){_.each(t,(function(t){e.formData.questions.push({value:t,checked:!1})}))}))):2===e.slides.slider.activeIndex&&"saveID"===e.option?_.each(e.formData.questions,(function(e){e.answer=void 0})):1===e.slides.slider.activeIndex&&"recoverID"===e.option?(e.hasContent=!1,e.recover={},e.fileData="",e.isValidFile=!1):2===e.slides.slider.activeIndex&&"recoverID"===e.option?_.each(e.recover.questions,(function(e){e.answer=void 0})):2===e.slides.slider.activeIndex&&"revocation"===e.option&&(e.isValidFile=!1,e.hasContent=!1,e.revocation=void 0)},e.onFileChanged=function(t){if(e.hasContent=angular.isDefined(t)&&""!==t,e.fileData=t.fileData?t.fileData:"",e.isValidFile=""!==e.fileData&&"text/plain"===e.fileData.type,e.isValidFile&&"recoverID"===e.option){e.content=t.fileContent.split("\n");var n=_.indexOf(e.content,"Questions: "),i=-1;_.each(e.content,(function(t,n){/^Issuer:/.test(t)?i=n:/^Crypted-Nonce:/.test(t)?e.recover.cypherNonce=t.split(" ")[1]:/^Crypted-Pubkey:/.test(t)?e.recover.cypherPubkey=t.split(" ")[1]:/^Crypted-Salt:/.test(t)?e.recover.cypherSalt=t.split(" ")[1]:/^Crypted-Pwd:/.test(t)&&(e.recover.cypherPwd=t.split(" ")[1])})),e.recover.questions=[];for(var a=n+1;a0?e.search.results:[],e.search.hasMore=!1,e.search.total=void 0,l.onError("ERROR.LOAD_NEWCOMERS_FAILED")(n)}))},e.doGetPending=function(t,n,i){t=t||0,(n=n||10)<10&&(n=10),e.hideActionsPopover(),e.search.loading=0===t,e.search.type="pending";var a=d.data.initPhase?b.all:b.pending;return t||i||e.updateLocationHref(),a(t,n).then((function(i){return"pending"==e.search.type&&(e.doDisplayResult(i&&i.hits,t,n,i&&i.total),e.search.hasMore=!d.data.initPhase&&e.search.hasMore,!0)})).catch((function(n){e.search.loading=!1,e.search.results=t>0?e.search.results:[],e.search.total=void 0,e.search.hasMore=!1,l.onError("ERROR.LOAD_PENDING_FAILED")(n)}))},e.doGetWallets=function(t,n,i){return t=t||0,(n=n||10)<10&&(n=10),e.hideActionsPopover(),e.search.loading=0===t,e.search.type="wallets",t||i||e.updateLocationHref(),E.children.all().then((function(i){if(!i||"wallets"!=e.search.type)return!1;var a=[E].concat(i).reduce((function(e,t,n){var i={id:n,pubkey:t.data.pubkey,uid:t.data.uid,name:t.data.localName||t.data.name,avatar:t.data.avatar};return e.concat(i)}),[]);return e.doDisplayResult(a,t,n,a.length),e.search.hasMore=!1,!0}))},e.showMore=function(){var t=e.search.results?e.search.results.length:0;return e.search.loadingMore=!0,("newcomers"==e.search.type?e.doGetNewcomers:e.doGetPending)(t).then((function(t){t&&(e.search.loadingMore=!1,e.$broadcast("scroll.infiniteScrollComplete"))})).catch((function(t){console.error(t),e.search.loadingMore=!1,e.search.hasMore=!1,e.$broadcast("scroll.infiniteScrollComplete")}))},e.select=function(e){var n=e.state;!n&&e.pubkey&&(n=E.isUserPubkey(e.pubkey)?"app.view_wallet":"app.wot_identity"),n&&(s.nextViewOptions({historyRoot:!1,disableAnimate:!1,expire:300}),t.go(n,e.stateParams||e))},e.next=function(){console.warn("Selected identities (should be override):",e.selection)},e.toggleCheck=function(t,n){var i=e.search.results[t];i.checked?e.addToSelection(i):e.removeSelection(i,n)},e.toggleSelect=function(e){e.selected=!e.selected},e.addToSelection=function(t){var n=angular.copy(t);n.name&&(n.name=n.name.replace("","").replace("","")),e.selection.push(n)},e.removeSelection=function(t,n){var i=_.findWhere(e.selection,{id:t.id});if(i&&e.selection.splice(e.selection.indexOf(i),1),!e.search.loading){var a=_.findWhere(e.search.results,{id:t.id});a&&a.checked&&(a.checked=!1)}},e.scanQrCode=function(){p.barcode.enable&&p.barcode.scan().then((function(t){t&&m.uri.parse(t).then((function(n){n.pubkey?e.search.text=n.pubkey:t.uid?e.search.text=n.uid:e.search.text=t,e.doSearch()}))})).catch(l.onError("ERROR.SCAN_FAILED"))},e.showHelpTip=function(t){if(e.isLogin()&&!((t=angular.isDefined(t)?t:u.data.helptip.wotLookup)<0)){0===t&&(t=1);var n=e.createHelptipScope();if(n)return n.startWotLookupTour(t,!1).then((function(e){n.$destroy(),u.data.helptip.wotLookup=e,u.store()}))}},e.doDisplayResult=function(t,n,i,a){t=t||[],e.allowMultiple&&t.length&&e.selection.length&&_.forEach(e.selection,(function(e){var n=_.findWhere(t,{id:e.id});n&&(n.checked=!0)})),e.search.results=n?e.search.results.concat(t):t||[],e.search.total=angular.isDefined(a)?a:void 0,e.search.loading=!1,e.search.hasMore=e.search.results.length>=n+i,e.smallscreen=l.screen.isSmall(),e.search.results.length&&t.length>0&&e.motion&&e.motion.show({selector:".lookupForm .list .item",ink:!0})},e.showActionsPopover=function(t){l.popover.show(t,{templateUrl:"templates/wot/lookup_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)}}function C(e,t,n,i,a){angular.extend(this,t("WotLookupCtrl",{$scope:e})),a=a||{},e.search.loading=!1,e.enableFilter=!!angular.isDefined(a.enableFilter)&&a.enableFilter,e.enableWallets=!!angular.isDefined(a.enableWallets)&&i.isLogin()&&i.children.count()&&a.enableWallets,e.allowMultiple=!!angular.isDefined(a.allowMultiple)&&a.allowMultiple,e.parameters=a,e.showResultLabel=!1,e.wotSearchTextId="wotSearchTextModal",e.allowMultiple&&a.selection&&(e.selection=a.selection);var o=e.enter;e.enter=function(t){e.parameters&&e.parameters.q&&(e.search.text=e.parameters.q,e.parameters.q.trim().length>2&&o(t))},e.$on("modal.shown",e.enter),e.cancel=function(){e.closeModal()},e.select=function(t){e.closeModal({pubkey:t.pubkey,uid:t.uid,name:t.name&&t.name.replace(/<\/?em>/gi,"")})},e.next=function(){e.closeModal(e.selection)},e.updateLocationHref=function(){},e.showHelpTip=function(){},n(e.wotSearchTextId)}function D(e,t,n,i,a,o,r,s,l,c,d,u,p){e.formData={hasSelf:!0},e.disableCertifyButton=!0,e.loading=!0,e.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!r.screen.isSmall()||t.enableBack})),e.load=function(t,n,i){return u.load(t,n,i).then((function(n){if(!n)return r.onError("ERROR.IDENTITY_NOT_FOUND")().then(e.showHome);e.formData=n;var i=p.isLogin();e.revoked=n.requirements&&(n.requirements.revoked||n.requirements.pendingRevocation),e.canCertify=n.hasSelf&&!e.revoked&&(!i||!p.isUserPubkey(t)||p.children.count()>0),e.canSelectAndCertify=n.hasSelf&&(p.isUserPubkey(t)||p.children.hasPubkey(t));var a=i&&_.find((n.received_cert||[]).concat(n.received_cert_pending||[]),(function(e){return e.pubkey===p.data.pubkey&&e.valid&&e.expiresIn>c.data.timeWarningExpire}));e.alreadyCertified=!(!e.canCertify||!i||p.children.count()>0||!a),e.disableCertifyButton=e.alreadyCertified||e.revoked,e.loading=!1})).catch((function(t){e.loading=!1,r.onError("ERROR.LOAD_IDENTITY_FAILED")(t)}))},e.doUpdate=function(t){t||(e.loading=!0,r.loading.show());var n={cache:!1,blockUid:e.formData.blockUid||void 0};return e.load(e.formData.pubkey,e.formData.uid,n).then(r.loading.hide)},e.certify=function(){return(p.children.count()?s.showSelectWallet({displayBalance:!1}):o.when(p)).then((function(t){if(t)return t.auth({minData:!0}).then((function(n){if(r.loading.hide(),d.data.initPhase||n.isMember)if(d.data.initPhase||e.formData.hasSelf)if(e.formData.requirements.expired)r.alert.error("ERROR.IDENTITY_EXPIRED");else{var a=_.find(e.formData.received_cert,(function(e){return e.pubkey===t.data.pubkey&&e.valid&&e.expiresIn>c.data.timeWarningExpire}));a?i("ERROR.IDENTITY_ALREADY_CERTIFY",a).then((function(e){r.alert.error(e,"ERROR.UNABLE_TO_CERTIFY_TITLE")})):(a=_.findWhere(e.formData.received_cert_pending,{pubkey:t.data.pubkey,valid:!0}))?i("ERROR.IDENTITY_ALREADY_CERTIFY_PENDING",a).then((function(e){r.alert.error(e,"ERROR.UNABLE_TO_CERTIFY_TITLE")})):r.alert.confirm("CONFIRM.CERTIFY_RULES","CONFIRM.POPUP_SECURITY_WARNING_TITLE",{cssClass:"warning",okText:"WOT.BTN_YES_CERTIFY",okType:"button-assertive"}).then((function(n){n&&(r.loading.show(),t.certify(e.formData.uid,e.formData.pubkey,e.formData.blockUid||e.formData.requirements&&e.formData.requirements.meta&&e.formData.requirements.meta.timestamp,e.formData.requirements&&e.formData.requirements.meta&&e.formData.requirements.meta.sig,e.formData.isMember,e.formData.wasMember).then((function(n){r.loading.hide(),n&&(e.prepareNewCert(t,n),e.alreadyCertified=!0,r.toast.show("INFO.CERTIFICATION_DONE"),e.formData.received_cert_pending.unshift(n),e.formData.requirements.pendingCertificationCount++,e.doMotion())})).catch(r.onError("ERROR.SEND_CERTIFICATION_FAILED")))}))}else r.alert.error("ERROR.IDENTITY_TO_CERTIFY_HAS_NO_SELF");else r.alert.error(n.requirements.needSelf?"ERROR.NEED_MEMBER_ACCOUNT_TO_CERTIFY":"ERROR.NEED_MEMBER_ACCOUNT_TO_CERTIFY_HAS_SELF")})).catch((function(e){"CANCELLED"!==e&&r.onError("ERROR.LOGIN_FAILED")(e)}))}))},e.selectAndCertify=function(){return(p.children.count()?s.showSelectWallet({displayBalance:!1}):o.when(p)).then((function(t){return t.auth({minData:!0}).then((function(e){if(d.data.initPhase||e.isMember)return r.loading.hide(),s.showWotLookup();r.alert.error(e.requirements.needSelf||e.requirements.needMembership?"ERROR.NEED_MEMBER_ACCOUNT_TO_CERTIFY":"ERROR.NEED_MEMBER_ACCOUNT_TO_CERTIFY_HAS_SELF")})).then((function(e){if(e&&e.pubkey){if(e.uid){r.loading.show();var t={cache:!1,blockUid:e.blockUid};return u.load(e.pubkey,e.uid,t)}r.alert.error("ERROR.IDENTITY_TO_CERTIFY_HAS_NO_SELF")}})).then((function(n){if(n)if(r.loading.hide(),n&&n.hasSelf)if(n.requirements.expired)r.alert.error("ERROR.IDENTITY_EXPIRED");else{var a=_.findWhere(n.received_cert,{pubkey:t.data.pubkey,valid:!0});a?i("ERROR.IDENTITY_ALREADY_CERTIFY",a).then((function(e){r.alert.error(e,"ERROR.UNABLE_TO_CERTIFY_TITLE")})):(a=_.findWhere(n.received_cert_pending,{pubkey:t.data.pubkey,valid:!0}))?i("ERROR.IDENTITY_ALREADY_CERTIFY_PENDING",a).then((function(e){r.alert.error(e,"ERROR.UNABLE_TO_CERTIFY_TITLE")})):i("CONFIRM.CERTIFY_RULES_TITLE_UID",{uid:n.uid}).then((function(e){return r.alert.confirm("CONFIRM.CERTIFY_RULES",e)})).then((function(i){i&&(r.loading.show(),t.certify(n.uid,n.pubkey,n.blockUid||n.requirements&&n.requirements.meta&&n.requirements.meta.timestamp,n.requirements&&n.requirements.meta&&n.requirements.meta.sig,n.isMember,n.wasMember).then((function(t){if(r.loading.hide(),t)return u.extendAll([t],"pubkey").then((function(){r.toast.show("INFO.CERTIFICATION_DONE"),e.formData.given_cert_pending.unshift(t),e.doMotion()}))})).catch(r.onError("ERROR.SEND_CERTIFICATION_FAILED")))}))}else r.alert.error("ERROR.IDENTITY_TO_CERTIFY_HAS_NO_SELF")})).catch((function(e){"CANCELLED"!==e&&r.onError("ERROR.LOAD_IDENTITY_FAILED")(e)}))}))},e.prepareNewCert=function(e,t){t.uid=e.data.uid,t.pubkey=e.data.pubkey,t.isMember=e.data.isMember,t.avatar=e.data.avatar,t.name=e.data.name},e.removeActionParamInLocationHref=function(e){if(e&&e.stateParams&&e.stateParams.action){var t=angular.copy(e.stateParams);t.action=null,a.nextViewOptions({disableAnimate:!0,disableBack:!1,historyRoot:!1}),n.go(e.stateName,t,{reload:!1,inherit:!0,notify:!1})}},e.doAction=function(t,n){if("certify"==t)return e.certify();"transfer"==t&&e.showTransferModal(n)},e.showCertifications=function(){var t=e.formData.requirements&&e.formData.requirements.alternatives&&e.formData.blockUid||void 0;r.screen.isSmall()?n.go("app.wot_cert",{pubkey:e.formData.pubkey,uid:e.formData.uid,type:"received",block:t}):n.go("app.wot_cert_lg",{pubkey:e.formData.pubkey,uid:e.formData.uid,block:t})},e.showGivenCertifications=function(){var t=e.formData.requirements&&e.formData.requirements.alternatives&&e.formData.blockUid||void 0;r.screen.isSmall()?n.go("app.wot_cert",{pubkey:e.formData.pubkey,uid:e.formData.uid,type:"given",block:t}):n.go("app.wot_cert_lg",{pubkey:e.formData.pubkey,uid:e.formData.uid,block:t})},e.showSharePopover=function(i){var a=e.formData.name||e.formData.uid||e.formData.pubkey,o=(l.shareBaseUrl||t.rootPath)+n.href("app.wot_identity",{pubkey:e.formData.pubkey,uid:e.formData.uid});r.screen.isSmall()&&(i=angular.element(document.querySelector("#wot-share-anchor-"+e.formData.pubkey))||i),r.popover.share(i,{bindings:{url:o,titleKey:"WOT.VIEW.POPOVER_SHARE_TITLE",titleValues:{title:a},postMessage:a}})}}function y(e,t,n,i,a,o,r,s){angular.extend(this,n("WotIdentityAbstractCtrl",{$scope:e})),e.motion=o.motion.fadeSlideInRight,e.qrcodeId="qrcode-wot-"+e.$id,e.options=e.options||{},e.options.like={kinds:["LIKE","ABUSE"],index:"user",type:"profile"},e.likeData={likes:{},abuses:{}},e.$on("$ionicView.enter",(function(t,n){var a=function(){e.doMotion(),n.stateParams&&n.stateParams.action&&(i((function(){e.doAction(n.stateParams.action.trim())}),100),e.removeActionParamInLocationHref(n),e.likeData.id=e.formData.pubkey),e.showQRCode()},r={cache:!0,blockUid:n.stateParams&&n.stateParams.block||void 0};if(n.stateParams&&n.stateParams.pubkey&&n.stateParams.pubkey.trim().length>0){if(e.loading)return e.load(n.stateParams.pubkey.trim(),n.stateParams.uid,r).then(a).catch(o.onError("ERROR.LOAD_IDENTITY_FAILED"))}else if(n.stateParams&&n.stateParams.uid&&n.stateParams.uid.trim().length>0){if(e.loading)return e.load(null,n.stateParams.uid,r).then(a)}else e.showHome()})),e.doMotion=function(){e.motion.show({selector:".view-identity .list .item"}),e.showFab("fab-transfer"),(e.canCertify&&!e.alreadyCertified||t.tour)&&e.showFab("fab-certify-"+e.formData.uid),e.$broadcast("$csExtension.motion")},e.doQuickFix=function(t){if("showSelectIdentities"===t)return e.showSelectIdentities()},e.showSelectIdentities=function(){if(e.formData.requirements&&e.formData.requirements.alternatives)return r.showSelectPubkeyIdentity({identities:[e.formData.requirements].concat(e.formData.requirements.alternatives)}).then((function(e){if(e&&e.pubkey)return a.go("app.wot_identity",{pubkey:e.pubkey,uid:e.uid,block:e.meta&&e.meta.timestamp||e.blockUid})}))},e.showQRCode=function(t){if(e.qrcodeId&&e.formData.pubkey){var n=angular.element(document.querySelector("#"+e.qrcodeId+" .content"));n?(console.debug("[wot-controller] Generating QR code for identity..."),i((function(){var i=o.qrcode.svg(e.formData.pubkey);n.html(i),o.motion.toggleOn({selector:"#"+e.qrcodeId},t||1100)}))):console.error("[wot-controller] Cannot found div #{0} for the QRCode. Skipping.".format(e.qrcodeId))}},e.hideQRCode=function(){e.qrcodeId&&angular.element(document.querySelector("#"+e.qrcodeId))&&o.motion.toggleOff({selector:"#"+e.qrcodeId})}}function P(e,t,n,i,a,o,r,s){e.formData={},e.loading=!0,e.motion=s.motion.fadeSlideInRight,e.$on("$ionicView.enter",(function(t,n){e.loading?(e.pubkey=n.stateParams.pubkey,e.uid=n.stateParams.uid,e.load()):e.updateView()})),e.load=function(t){return n.all([o.extend({pubkey:e.pubkey}),r.load(e.pubkey,t)]).then((function(t){e.formData=angular.merge(t[0],t[1]),e.loading=!1,e.updateView()}))},e.doUpdate=function(t){return console.debug("[wot] TX history reloading..."),e.formData={},(t?e.load():s.loading.show().then(e.load).then(s.loading.hide)).then(e.updateView).catch(s.onError("ERROR.IDENTITY_TX_FAILED"))},e.updateView=function(){e.$broadcast("$$rebind::balance"),e.$broadcast("$$rebind::rebind"),e.motion.show()},e.downloadHistoryFile=function(t){(t=t||{}).fromTime=t.fromTime||-1,r.downloadHistoryFile(e.pubkey,t)},e.showMoreTx=function(n){return n=n||e.formData.tx.fromTime-a.data.walletHistoryTimeSecond||moment().utc().unix()-2*a.data.walletHistoryTimeSecond,s.loading.show(),r.load(e.pubkey,n).then((function(t){angular.merge(e.formData,t),e.updateView(),s.loading.hide()})).catch((function(a){a.ucode==i.errorCodes.HTTP_LIMITATION?t((function(){return e.showMoreTx(n)}),2e3):s.onError("ERROR.IDENTITY_TX_FAILED")(a)}))}}function k(e,t,n,i,a,o){var r;angular.extend(this,n("WotIdentityAbstractCtrl",{$scope:e})),e.motions={receivedCertifications:angular.copy(o.motion.fadeSlideIn),givenCertifications:angular.copy(o.motion.fadeSlideInRight),avatar:angular.copy(o.motion.fadeIn)},e.motions.receivedCertifications.enable=!0,e.motions.givenCertifications.enable=!0,e.motions.avatar.enable=!0,e.$on("$ionicView.enter",(function(t,n){if(n.stateParams&&n.stateParams.type&&(e.motions.receivedCertifications.enable="given"!=n.stateParams.type,e.motions.givenCertifications.enable="given"==n.stateParams.type,e.motions.avatar.enable=!1),e.loading){var i={cache:!0,blockUid:n.stateParams&&n.stateParams.block||void 0};return n.stateParams&&n.stateParams.pubkey&&n.stateParams.pubkey.trim().length>0?e.load(n.stateParams.pubkey.trim(),n.stateParams.uid,i).then((function(){e.doMotion(),e.showHelpTip()})):(r=n.stateParams&&n.stateParams.id?a.children.get(n.stateParams.id):a)?r.isLogin()?e.load(r.data.pubkey,r.data.uid,i).then((function(){e.doMotion(),e.showHelpTip()})):e.showHome():(o.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome())}e.doMotion()})),e.$on("$ionicView.leave",(function(){e.loading=!0})),e.doUpdate=function(){var t={cache:!1,blockUid:e.formData.blockUid||void 0};return e.load(e.formData.pubkey,e.formData.uid,t).then((function(){e.doMotion(),e.showHelpTip()}))},e.doMotion=function(t){e.doMotionReceivedCertifications(0,t),e.motions.avatar.enable&&e.motions.avatar.show({selector:".col-avatar ."+e.motions.avatar.ionListClass}),e.doMotionGivenCertifications(e.motions.receivedCertifications.enable?100:10,t)},e.doMotionReceivedCertifications=function(n,i){e.motions.receivedCertifications.enable?(i||e.motions.receivedCertifications.show({selector:".list.certifications .item",timeout:n}),(e.canCertify&&!e.alreadyCertified||t.tour)&&e.showFab("fab-certify",n)):(e.canCertify||t.tour)&&e.hideFab("fab-certify",0)},e.doMotionGivenCertifications=function(n,i){e.motions.givenCertifications.enable?(i||e.motions.givenCertifications.show({selector:".list.given-certifications .item",timeout:n}),(e.canSelectAndCertify||t.tour)&&e.showFab("fab-select-certify")):(e.canSelectAndCertify||t.tour)&&e.hideFab("fab-select-certify",0)},e.showHelpTip=function(){if(e.isLogin()&&i.data.helptip.enable){var t=e.createHelptipScope();if(t){var n=a.isUserPubkey(e.formData.pubkey),o=n?i.data.helptip.walletCerts:i.data.helptip.wotCerts;if(!(o<0))return(n?t.startWalletCertTour(o,!1):t.startWotCertTour(o,!1)).then((function(e){t.$destroy(),n?i.data.helptip.walletCerts=e:i.data.helptip.wotCerts=e,i.store()}))}}}}function M(e,t,n,i){e.loading=!0,e.load=function(){return i&&i.identities?(e.identities=i.identities,e.pubkey=e.identities[0].pubkey,e.loading=!1,t.when()):(e.pubkey=i&&i.pubkey,pubkey?n.loadRequirements({pubkey:pubkey,uid:uid}).then((function(t){t&&t.requirements&&(e.identities=t.requirements,t.requirements.alternatives?e.identities=[t.requirements].concat(t.requirements.alternatives):e.identities=[t.requirements]),e.loading=!1})):t.reject("Missing parameters: [pubkey] or [identities]"))},e.$on("modal.shown",e.load)}function w(e,t,n,i,a,o,r,s,l,c,d,u,p){e.networkStarted=!1,e.ionItemClass="",e.expertMode=c.data.expertMode&&!s.screen.isSmall(),e.isHttps="https:"===a.location.protocol,e.search={text:"",loading:!0,type:void 0,results:[],endpoint:null,bma:void 0,ssl:void 0,ws2p:void 0,sort:void 0,asc:!0},e.compactMode=!0,e.listeners=[],e.helptipPrefix="helptip-network",e.enableLocationHref=!0,e.removeListeners=function(){e.listeners.length&&(console.debug("[network] Closing listeners"),_.forEach(e.listeners,(function(e){e()})),e.listeners=[])},e.enter=function(t,n){e.networkStarted||(e.networkStarted=!0,e.search.loading=!0,d.get().then((function(t){if(t){var i=r.node.same(t.node);e.node=i?r:r.instance(t.node.host,t.node.port),n&&n.stateParams&&(n.stateParams.type&&-1!=["mirror","member","offline"].indexOf(n.stateParams.type)&&(e.search.type=n.stateParams.type),n.stateParams.expert&&(e.expertMode="true"==n.stateParams.expert)),e.load()}})).catch((function(t){s.onError("ERROR.GET_CURRENCY_FAILED")(t),e.networkStarted=!1})))},e.$on("$ionicParentView.enter",e.enter),e.leave=function(){e.node!==r&&e.node.close(),e.networkStarted&&(e.removeListeners(),u.close(),e.networkStarted=!1,e.search.loading=!0)},e.$on("$ionicView.beforeLeave",e.leave),e.$on("$ionicParentView.beforeLeave",e.leave),e.$on("$destroy",e.leave),e.computeOptions=function(){return{filter:{member:!e.search.type||"member"===e.search.type,mirror:!e.search.type||"mirror"===e.search.type,endpoint:angular.isDefined(e.search.endpoint)?e.search.endpoint:null,bma:e.search.bma,ssl:e.search.ssl,ws2p:e.search.ws2p,online:!(e.search.type&&"offline"===e.search.type)},sort:{type:e.search.sort,asc:e.search.asc},expertMode:e.expertMode,timeout:l.timeout&&(e.expertMode?l.timeout/10:l.timeout/100)}},e.load=function(){e.search.loading&&(u.start(e.node,e.computeOptions()),e.refreshing=!1,e.listeners.push(u.api.data.on.changed(e,(function(t){e.refreshing||(e.refreshing=!0,p.extendAll(t.peers).then((function(){e.networkStarted&&e.updateView(t),e.refreshing=!1})))})))),e.showHelpTip()},e.updateView=function(t){console.debug("[peers] Updating UI"),e.$broadcast("$$rebind::rebind"),e.search.results=t.peers,e.search.memberPeersCount=t.memberPeersCount,e.search.loading=!e.networkStarted||u.isBusy(),e.loading||e.$broadcast("$$rebind::rebind"),e.motion&&e.search.results&&e.search.results.length>0&&e.motion.show({selector:".item-peer"})},e.refresh=function(){e.search.loading=!0,u.loadPeers()},e.sort=function(){e.search.loading=!0,e.refreshing=!0,u.sort(e.computeOptions()),e.updateView(u.data)},e.toggleSearchType=function(t){e.hideActionsPopover(),e.search.type===t||"none"===t?e.search.type=void 0:e.search.type=t,u.close(),e.search.loading=!0,e.load(),e.enableLocationHref&&n.search({type:e.search.type}).replace()},e.toggleSearchEndpoint=function(t){e.hideActionsPopover(),e.search.endpoint===t||null===t?e.search.endpoint=null:e.search.endpoint=t,e.sort()},e.toggleSort=function(t){e.search.sort!==t||e.search.asc?(e.search.asc=e.search.sort!==t||!e.search.asc,e.search.sort=t):(e.search.asc=void 0,e.search.sort=void 0),e.sort()},e.toggleCompactMode=function(){e.compactMode=!e.compactMode,e.$broadcast("$$rebind::rebind")},e.selectPeer=function(n){if(n.compacted&&e.compactMode)e.toggleCompactMode();else if(n.online&&n.hasBma()){var i={server:n.getServer()};n.isSsl()&&(i.ssl=!0),n.isTor()&&(i.tor=!0),t.go("app.view_peer",i)}},e.$on("csView.action.refresh",(function(t,n){"peers"===n&&e.refresh()})),e.$on("csView.action.showActionsPopover",(function(t,n){e.showActionsPopover(n)})),e.showActionsPopover=function(t){s.popover.show(t,{templateUrl:"templates/network/lookup_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.showEndpointsPopover=function(e,t,n){e.preventDefault(),e.stopPropagation();var i=t.getEndpoints(n);(i=(i||[]).reduce((function(e,i){var a=r.node.parseEndPoint(i)||r.node.parseEndPoint(i,n);return e.concat({label:"NETWORK.VIEW.NODE_ADDRESS",value:t.getServer(a)+(a&&a.path||"")})}),[])).length&&s.popover.show(e,{templateUrl:"templates/network/popover_endpoints.html",bindings:{titleKey:"NETWORK.VIEW.ENDPOINTS."+n,items:i}})},e.showWs2pPopover=function(e,t){return e.stopPropagation(),o("NETWORK.VIEW.PRIVATE_ACCESS").then((function(n){s.popover.show(e,{templateUrl:"templates/network/popover_endpoints.html",bindings:{titleKey:"NETWORK.VIEW.ENDPOINTS.WS2P",valueKey:"NETWORK.VIEW.NODE_ADDRESS",items:[{label:"NETWORK.VIEW.NODE_ADDRESS",value:t.bma.private?n:t.getServer()+(t.bma.path||"")},{label:"NETWORK.VIEW.WS2PID",value:t.bma.ws2pid},{label:"NETWORK.VIEW.POW_PREFIX",value:t.powPrefix}]}})}))},e.showHelpTip=function(t,n){if(t=angular.isDefined(t)?t:c.data.helptip.network,n=!!angular.isDefined(n)&&n,!(t<0)){var i=e.createHelptipScope();if(i)return i.tour=n,i.startNetworkTour(t,!1).then((function(e){i.$destroy(),n||(c.data.helptip.network=e,c.store())}))}}}function U(e,t,n){angular.extend(this,t("NetworkLookupCtrl",{$scope:e})),n=n||{},e.enableFilter=!angular.isDefined(n.enableFilter)||n.enableFilter,e.search.type=angular.isDefined(n.type)?n.type:e.search.type,e.search.endpoint=angular.isDefined(n.endpoint)?n.endpoint:e.search.endpoint,e.search.bma=angular.isDefined(n.bma)?n.bma:e.search.bma,e.search.ssl=angular.isDefined(n.ssl)?n.ssl:e.search.ssl,e.search.ws2p=angular.isDefined(n.ws2p)?n.ws2p:e.search.ws2p,e.expertMode=angular.isDefined(n.expertMode)?n.expertMode:e.expertMode,e.ionItemClass=n.ionItemClass||"item-border-large",e.enableLocationHref=!1,e.helptipPrefix="",e.selectPeer=function(t){e.closeModal(t)},e.$on("modal.hidden",(function(){e.leave()})),e.showHelpTip=function(){},e.enter()}function x(e,t){angular.extend(this,t("NetworkLookupCtrl",{$scope:e}));var n=n||{};e.enableFilter=!angular.isDefined(n.enableFilter)||n.enableFilter,e.search.type=angular.isDefined(n.type)?n.type:e.search.type,e.search.endpoint=angular.isDefined(n.endpoint)?n.endpoint:e.search.endpoint,e.expertMode=angular.isDefined(n.expertMode)?n.expertMode:e.expertMode,e.ionItemClass=n.ionItemClass||"item-border-large",e.helptipPrefix="",e.selectPeer=function(t){e.closePopover(t)},e.$on("popover.hidden",(function(){e.leave()})),e.showHelpTip=function(){},e.enter()}function B(e,t,n,i,a,o){e.loading=!0,e.formData={},e.load=function(){return console.debug("[peer-popover] Loading peer info..."),e.loading=!0,e.formData={},t.all([i.blockchain.current().then((function(t){e.formData.number=t.number,e.formData.medianTime=t.medianTime,e.formData.powMin=t.powMin,e.formData.useSsl=o.useSsl})).catch((function(){delete e.formData.number,delete e.formData.medianTime,delete e.formData.powMin,delete e.formData.useSsl})),o.node.summary().then((function(t){e.formData.version=t&&t.duniter&&t.duniter.version,e.formData.software=t&&t.duniter&&t.duniter.software})).catch((function(){delete e.formData.version,delete e.formData.software})),o.version.latest().then((function(t){e.formData.latestRelease=t})).catch((function(){delete e.formData.latestRelease}))]).then((function(){if(e.formData.latestRelease&&"duniter"==e.formData.software){var t=a.version.compare(e.formData.version,e.formData.latestRelease.version);e.formData.isPreRelease=t>0,e.formData.hasNewRelease=t<0}else e.formData.isPreRelease=!1,e.formData.hasNewRelease=!1;e.loading=!1,e.$broadcast("$$rebind::rebind")}))},i.api.data.on.newBlock(e,(function(t){e.loading||(console.debug("[peer info] Received new block. Reload content"),e.load())})),n.api.data.on.changed(e,(function(t){e.loading||(console.debug("[peer info] Peer settings changed. Reload content"),e.load())})),e.load()}function H(t,n,i,a,o,r,s){t.node={},t.loading=!0,t.isHttps="https:"===i.location.protocol,t.isReachable=!0,t.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!o.screen.isSmall()||t.enableBack})),t.$on("$ionicView.enter",(function(e,n){var i=!n.stateParams||!n.stateParams.server,a=n.stateParams&&n.stateParams.server||s.server,o=n.stateParams&&"true"==n.stateParams.ssl||!!i&&s.useSsl,r="true"==n.stateParams.tor||!!i&&s.useTor;return t.load(a,o,r).then((function(){return t.$broadcast("$csExtension.enter",e,n)})).then((function(){t.loading=!1})).catch((function(){t.loading=!1}))})),t.load=function(i,a,l){var c={server:i,host:i,useSsl:a,useTor:l},d=i.split(":");return 2===d.length&&(c.host=d[0],c.port=d[1]),angular.merge(t.node,l?s.lightInstance(c.host+".to",443,!0,6e4):s.lightInstance(c.host,c.port,c.useSsl),c),t.isReachable=!t.isHttps||a,t.isReachable?n.all([t.node.network.peering.self().then((function(e){t.node.pubkey=e.pubkey,t.node.currency=e.currency})).catch((function(e){console.error(e&&e.message||e)})),t.node.network.peers().then((function(n){var i=(n&&n.peers||[]).map((function(t){var n=new e(t);return n.online="UP"===t.status,n.buid=n.block,n.blockNumber=n.buid&&n.buid.split("-")[0],n.dns=n.getDns(),n.id=n.keyID(),n.server=n.getServer(),n}));return r.extendAll([t.node].concat(i)).then((function(){t.peers=_.sortBy(i,(function(e){var t=1;return t+=1e4*(e.online?1:0),t+=1e3*(e.hasMainConsensusBlock?1:0),-(t+=100*(e.uid?1:0))})),t.motion.show({selector:".item-peer"})}))})),t.node.blockchain.current().then((function(e){t.current=e}))]).catch((function(e){throw console.error(e&&e.message||e),o.onError(l?"PEER.VIEW.ERROR.LOADING_TOR_NODE_ERROR":"PEER.VIEW.ERROR.LOADING_NODE_ERROR")(e),e})):s.network.peers().then((function(n){var i=(n&&n.peers||[]).reduce((function(t,n){var i=new e(n);return(i.getEndpoints("BASIC_MERKLED_API")||[]).reduce((function(e,t){var n=s.node.parseEndPoint(t);return n.dns!==c.host&&n.ipv4!==c.host&&n.ipv6!==c.host||n.port!=c.port?e:(i.bma=n,e.concat(i))}),t)}),[]),a=i.length&&i[0];if(a)return t.node.pubkey=a.pubkey,t.node.currency=a.currency,r.extend(t.node);console.warn("Could not get peer from /network/peers")}))},t.selectPeer=function(e){if(e.online&&!e.isWs2p()){var t={server:e.getServer()};e.isSsl()&&(t.ssl=!0),e.isTor()&&(t.tor=!0),a.go("app.view_peer",t)}},t.openRawPeering=function(e){return t.openLink(e,t.node.url+"/network/peering")},t.openRawCurrentBlock=function(e){return t.openLink(e,t.node.url+"/blockchain/current")}}function F(e,t,n,i,a,o,r,s,l,c,d){e.formData={useRelative:!1,currency:"",M:0,MoverN:0,UD:0,cactual:0,c:0,dt:0,sigQty:0,sigStock:0,msWindow:0,msValidity:0,sigWindow:0,sigValidity:0,sigPeriod:0,medianTime:0,difficulty:0,Nprev:0,stepMax:0,sentries:0,xpercent:0,durationFromLastUD:0,blockUid:null,dtReeval:0,udReevalTime0:0,allRules:angular.isDefined(s.data.currency&&s.data.currency.allRules)?s.data.currency.allRules:s.data.expertMode,allWotRules:angular.isDefined(s.data.currency&&s.data.currency.allWotRules)?s.data.currency.allWotRules:s.data.expertMode,licenseUrl:s.getLicenseUrl()},e.loading=!0,e.screen=r.screen,e.enter=function(t,i){e.loading&&(e.formData.useRelative=s.data.useRelative,l.get().then(e.load).then((function(){e.isLogin()&&e.showHelpTip()})).catch(r.onError("ERROR.GET_CURRENCY_FAILED")),c.api.data.on.mainBlockChanged(e,(function(t){e.loading||e.formData.blockUid!==t.buid&&(console.debug("[currency] Updating parameters UI (new main block detected)"),n(e.load,1e3))}))),e.$broadcast("$csExtension.enter",i)},e.$on("$ionicView.enter",e.enter),e.load=function(){var n,i,a={},s=Date.now();return t.all([o.blockchain.parameters().then((function(e){a.currency=e.currency,a.c=e.c,a.dt=e.dt,a.sigQty=e.sigQty,a.sigStock=e.sigStock,a.msWindow=e.msWindow,a.msValidity=e.msValidity,a.sigWindow=e.sigWindow,a.sigValidity=e.sigValidity,a.sigPeriod=e.sigPeriod,a.stepMax=e.stepMax,a.xpercent=e.xpercent,a.avgGenTime=e.avgGenTime,a.dtReeval=e.dtReeval,a.udTime0=e.udTime0,a.udReevalTime0=e.udReevalTime0,a.dtReeval||(a.dtReeval=a.dt)})),l.blockchain.current().then((function(e){n=e.monetaryMass,a.N=e.membersCount,a.medianTime=e.medianTime,a.difficulty=e.powMin,a.blockUid=[e.number,e.hash].join("-")})).catch((function(e){if(e&&e.ucode==o.errorCodes.NO_CURRENT_BLOCK)return n=0,a.N=0,a.medianTime=moment().utc().unix(),a.difficulty=0,void(a.blockUid=null);throw e})),o.blockchain.stats.ud().then((function(e){if(e.result.blocks.length){var t=e.result.blocks[e.result.blocks.length-1];return o.blockchain.block({block:t}).then((function(e){a.currentUD=e.unitbase>0?e.dividend*Math.pow(10,e.unitbase):e.dividend,i=e.medianTime,a.Nprev=e.membersCount}))}return i=0,a.Nprev=0,o.blockchain.parameters().then((function(e){a.currentUD=e.ud0}))}))]).then((function(){var t=n-a.currentUD*a.Nprev,o=a.Nprev?t/a.Nprev:0;return a.cactual=o?100*a.currentUD/o:0,a.M=n,a.MoverN=a.Nprev?(t||n)/a.Nprev:0,a.UD=a.currentUD,a.durationFromLastUD=i?a.medianTime-i:0,a.sentries=Math.ceil(Math.pow(a.N,1/a.stepMax)),angular.extend(e.formData,a),console.debug("[currency] Parameters loaded in "+(Date.now()-s)+"ms"),e.loading=!1,e.$broadcast("$$rebind::rebind"),r.ink(),r.loading.hide()})).catch((function(t){e.loading=!1,r.onError("ERROR.LOAD_PEER_DATA_FAILED")(t)}))},e.refresh=function(){if(!e.loading)return e.loading=!0,r.loading.show(),e.load().then((function(){e.$broadcast("csView.action.refresh","currency")}))},e.refreshPeers=function(){return e.$broadcast("csView.action.refresh","peers"),t.when()},e.showExtendActionsPopover=function(t){e.$broadcast("csView.action.showActionsPopover",t)},e.onAllRulesChange=function(){s.data.currency=s.data.currency||{},s.data.currency.allRules!==e.formData.allRules&&(s.data.currency.allRules=e.formData.allRules,s.store())},e.$watch("formData.allRules",e.onAllRulesChange),e.onAllWotRulesChange=function(){s.data.currency=s.data.currency||{},s.data.currency.allWotRules!==e.formData.allWotRules&&(s.data.currency.allWotRules=e.formData.allWotRules,s.store())},e.$watch("formData.allWotRules",e.onAllWotRulesChange),e.startCurrencyTour=function(){return e.hideActionsPopover(),e.showHelpTip(0,!0)},e.showHelpTip=function(t,n){if(t=angular.isDefined(t)?t:s.data.helptip.currency,n=!!angular.isDefined(n)&&n,!(t<0)){var i=e.createHelptipScope(n);if(i)return i.tour=n,i.startCurrencyTour(t,!1).then((function(e){i.$destroy(),s.data.helptip.currency=e,s.store()}))}},e.showLicenseModal=function(){return d.show("templates/currency/modal_license.html","CurrencyLicenseModalCtrl")},e.showHelpModal=function(e){a.showHelp({anchor:e})},e.showActionsPopover=function(t){r.popover.show(t,{templateUrl:"templates/currency/popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)}}function W(e,t,n,i,a){e.loading=!0,e.load=function(){e.loading&&(e.licenseUrl=i.getLicenseUrl(),e.licenseUrl&&".txt"!=e.licenseUrl.substring(e.licenseUrl.length-3)&&(e.licenseUrlHtml=e.licenseUrl+".html",e.licenseUrl=e.licenseUrl+".txt"),e.loading=!1)},e.$on("modal.shown",e.load),e.downloadFile=function(){if(e.licenseUrl)return t.get(e.licenseUrl).success((function(e){var t=new Blob([e],{type:"text/plain; charset=utf-8"});a.saveAs(t,"license.txt")})).error((function(){n.onError("ERROR.GET_LICENSE_FILE_FAILED")()}))}}function V(e,t,n){angular.extend(this,t("TransferModalCtrl",{$scope:e,parameters:{}})),e.enter=function(t,i){return i&&i.stateParams&&e.setParameters(i.stateParams),e.load().then(n.loading.hide)},e.$on("$ionicView.enter",e.enter),e.setForm=function(t){e.form=t},e.closeModal=function(){return e.showHome()}}function G(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E){var b;e.convertedBalance=0,e.formData={destPub:null,amount:null,comment:null,useRelative:m.data.useRelative,useComment:!1,all:!1,restPub:null,restAmount:null,walletId:null},e.udAmount=null,e.minAmount=.01,e.commentPattern=s.regexp.COMMENT,e.currency=p.data.name,e.loading=!0,e.commentInputId="transferComment-"+e.$id,e.enableSelectWallet=!0,e.smallscreen=angular.isDefined(e.smallscreen)?e.smallscreen:l.screen.isSmall(),(e.smallscreen||r.enable)&&(e.digitKeyboardSettings=e.digitKeyboardSettings||r.keyboard.digit.settings.bindModel(e,"formData.amount",{decimal:!0,decimalSeparator:".",resizeContent:!1}),e.digitKeyboardVisible=!1),e.setParameters=function(t){t&&(t.pubkey&&(e.formData.destPub=t.pubkey),t.uid?(e.destUid=t.uid,e.destPub=""):(e.destUid="",e.destPub=t.pubkey),t.amount?(e.formData.amount=t.amount,e.formData.useRelative=!1):t.udAmount&&(e.formData.amount=t.udAmount,e.formData.useRelative=!0),t.comment&&(e.formData.useComment=!0,e.formData.comment=t.comment),t.restPub||t.all?(e.restUid="",e.restPub=t.restPub,e.formData.restPub=t.restPub,e.formData.all=!0):e.formData.all=!1,t.wallet&&"default"!==t.wallet?e.formData.walletId=t.wallet:e.formData.walletId=d.id)},e.setParameters(E),e.load=function(){return e.enableSelectWallet=d.children.count()>0,(b=e.enableSelectWallet&&(e.formData.walletId?d.children.get(e.formData.walletId):d)||d).isDefault()||console.debug("[transfer] Using wallet {"+b.id+"}"),b.login({sources:!0,silent:!0}).then((function(t){if(b&&!e.$$destroyed){if(e.walletData=t,e.formData.walletId=b.id,e.onUseRelativeChanged(),e.onAmountChanged(),e.$watch("walletData.balance",e.onAmountChanged,!0),e.$watch("formData.amount",e.onAmountChanged,!0),e.$watch("formData.useRelative",e.onUseRelativeChanged,!0),e.$watch("walletData.balance",e.onUseRelativeChanged,!0),l.ink({selector:".modal-transfer .ink"}),e.destPub&&!e.destUid)return u.extend({pubkey:e.destPub}).then((function(t){e.destUid=t&&(t.name||t.uid),e.destUid&&(e.destPub=""),e.loading=!1}));e.loading=!1}})).catch((function(t){if("CANCELLED"===t)return e.cancel();l.onError("ERROR.LOGIN_FAILED")(t)}))},e.$on("modal.shown",e.load),e.cancel=function(){e.closeModal(),b=null},e.onUseRelativeChanged=function(){e.currency=p.data.name,e.formData.useRelative?(e.convertedBalance=e.walletData.balance/p.data.currentUD,e.minAmount=.01/(p.data.currentUD/100)):(e.convertedBalance=e.walletData.balance/100,e.minAmount=.01),e.form&&!e.loading&&e.form.$setPristine(!0)},e.onAmountChanged=function(){if(!e.sending){var t=e.formData.amount;t&&"string"==typeof t&&(t=parseFloat(t.replace(new RegExp("[.,]"),".")));var n=!0;t&&te.convertedBalance?(e.form.$valid=!1,e.form.amount.$invalid=!0,e.form.amount.$error=e.form.amount.$error||{},e.form.amount.$error={max:!0}):e.form.amount&&e.form.amount.$error&&e.form.amount.$error.max&&delete e.form.amount.$error.max,e.form.$valid=n,e.form.amount&&(e.form.amount.$invalid=!n),n&&e.formData.all&&t?e.formData.useRelative?(e.formData.restAmount=e.walletData.balance-t*p.data.currentUD,e.formData.restAmount<.01&&(e.formData.restAmount=0)):e.formData.restAmount=e.walletData.balance-100*t:e.formData.restAmount=void 0}},e.doTransfer=function(){if(!e.loading&&(e.form.$submitted=!0,e.form.$valid&&e.formData.destPub&&e.formData.amount)){var n,a=e.formData.amount;if("string"==typeof a&&(a=parseFloat(a.replace(new RegExp("[.,]"),"."))),!e.sending)return e.sending=!0,t.all([b.auth({silent:!0}),p.currentUD().then((function(e){n=e})),e.hideDigitKeyboard(300)]).then(e.askTransferConfirm).then((function(t){if(t)return l.loading.show().then((function(){e.formData.useRelative?a*=n:a=100*a.toFixed(2);var t=e.formData.comment&&e.formData.comment.trim();return t&&!t.length&&(t=null),e.formData.all&&e.formData.restAmount>0?b.transferAll(e.formData.destPub,a,t,e.formData.useRelative,e.formData.restPub):b.transfer(e.formData.destPub,a,t,e.formData.useRelative)})).then((function(){return l.loading.hide(),e.closeModal(!0)})).then((function(t){return i((function(){e.sending=!1,l.toast.show("INFO.TRANSFER_SENT")}),500),t}));e.sending=!1})).catch((function(t){e.sending=!1,"CANCELLED"!==t&&l.onError("ERROR.SEND_TX_FAILED")(t)}))}},e.askTransferConfirm=function(){return n(["COMMON.UD","COMMON.EMPTY_PARENTHESIS"]).then((function(t){var i=e.formData.all&&e.formData.restAmount>0;return n(i?"CONFIRM.TRANSFER_ALL":"CONFIRM.TRANSFER",{from:e.walletData.isMember?e.walletData.uid:a("formatPubkey")(e.walletData.pubkey),to:e.destUid||e.destPub,amount:e.formData.amount,unit:e.formData.useRelative?t["COMMON.UD"]:a("abbreviate")(e.currency),comment:e.formData.comment&&0!==e.formData.comment.trim().length?e.formData.comment:t["COMMON.EMPTY_PARENTHESIS"],restAmount:i&&a("formatAmount")(e.formData.restAmount,{useRelative:e.formData.useRelative}),restTo:i&&(e.restUid||e.restPub)})})).then(l.alert.confirm)},e.addComment=function(){e.formData.useComment=!0,e.commentInputId&&i((function(){o(e.commentInputId)}),200)},e.showWotLookupModal=function(t){return t=t||"destPub",e.hideDigitKeyboard(0),c.showWotLookup({enableWallets:!0}).then((function(n){n&&("destPub"===t?(e.destUid=n.uid,e.destPub=n.uid?"":n.pubkey,e.formData.destPub=n.pubkey):"restPub"===t&&(e.restUid=n.uid,e.restPub=n.uid?"":n.pubkey,e.formData.restPub=n.pubkey))}))},e.showSelectWalletModal=function(){if(e.enableSelectWallet)return c.showSelectWallet({useRelative:e.formData.useRelative,showDefault:!0,showBalance:!0}).then((function(t){!t||b&&b.id===t.id||(b=t,e.walletData=b.data,console.debug("[transfer] Using wallet {"+b.id+"}"),e.onAmountChanged())}))},e.showUnitPopover=function(t){l.popover.show(t,{templateUrl:"templates/wallet/popover_unit.html",scope:e}).then((function(t){e.formData.useRelative=t}))},e.showDigitKeyboard=function(){if(e.digitKeyboardSettings&&!e.digitKeyboardVisible)return r.enable?(r.keyboard.close(),i((function(){e.digitKeyboardVisible=!0}),200)):(e.digitKeyboardVisible=!0,t.when())},e.hideDigitKeyboard=function(n){return e.digitKeyboardVisible?(e.digitKeyboardVisible=!1,i((function(){}),n||200)):t.when()}}function Y(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E,b){e.formData=angular.copy(E.data),e.popupData={},e.loading=!0,e.nodePopup={},e.bma=d,e.keepAuthIdleLabels={10:{labelKey:"SETTINGS.KEEP_AUTH_OPTION.SECONDS",labelParams:{value:10}},30:{labelKey:"SETTINGS.KEEP_AUTH_OPTION.SECONDS",labelParams:{value:30}},60:{labelKey:"SETTINGS.KEEP_AUTH_OPTION.MINUTE",labelParams:{value:1}},600:{labelKey:"SETTINGS.KEEP_AUTH_OPTION.MINUTES",labelParams:{value:10}},3600:{labelKey:"SETTINGS.KEEP_AUTH_OPTION.HOUR",labelParams:{value:1}},9999:{labelKey:"SETTINGS.KEEP_AUTH_OPTION.ALWAYS"}},e.keepAuthIdles=_.keys(e.keepAuthIdleLabels),e.blockValidityWindowLabels={0:{labelKey:"SETTINGS.BLOCK_VALIDITY_OPTION.NONE"},6:{labelKey:"SETTINGS.BLOCK_VALIDITY_OPTION.N",labelParams:{count:6,time:void 0}},12:{labelKey:"SETTINGS.BLOCK_VALIDITY_OPTION.N",labelParams:{count:12,time:void 0}},24:{labelKey:"SETTINGS.BLOCK_VALIDITY_OPTION.N",labelParams:{count:24,time:void 0}}},e.blockValidityWindows=_.keys(e.blockValidityWindowLabels),e.$on("$ionicView.enter",(function(){t.all([E.ready(),m.parameters().catch((function(e){})).then((function(t){var n=t&&t.avgGenTime;(!n||n<0)&&(console.warn("[settings] Could not not currency parameters. Using default G1 'avgGenTime' (300s)"),n=300),_.each(e.blockValidityWindows,(function(t){t>0&&(e.blockValidityWindowLabels[t].labelParams.time=n*t)}))}))]).then(e.load)})),e.setPopupForm=function(t){e.popupForm=t},e.load=function(){return e.loading=!0,e.locales=angular.copy(E.locales),angular.merge(e.formData,E.data),e.formData.locale=E.data.locale&&E.data.locale.id&&_.findWhere(e.locales,{id:E.data.locale.id})||_.findWhere(e.locales,{id:E.defaultSettings.locale.id}),o((function(){e.loading=!1,l.ink({selector:".item"}),e.showHelpTip()}),100)},e.reset=function(){e.actionsPopover&&e.actionsPopover.hide(),e.pendingSaving=!0,E.reset().then(b.restart).then((function(){e.load(),e.pendingSaving=!1}))},e.changeLanguage=function(e){r.use(e)},e.changeNode=function(t){var n=e.formData.node.port&&80!=e.formData.node.port&&443!=e.formData.node.port?e.formData.node.port:void 0;t=t||{host:e.formData.node.host,port:n,useSsl:angular.isDefined(e.formData.node.useSsl)?e.formData.node.useSsl:443==e.formData.node.port},e.showNodePopup(t).then((function(t){(t.host!==e.formData.node.host||t.port!==e.formData.node.port||t.useSsl!==e.formData.node.useSsl||e.formData.node.temporary)&&(l.loading.show(),d.isAlive(t).then((function(n){return n?(l.loading.hide(),angular.merge(e.formData.node,t),delete e.formData.node.temporary,d.stop(),d.copy(t),e.bma=d,b.restart(),i.clearCache()):(l.loading.hide(),l.alert.error("ERROR.INVALID_NODE_SUMMARY").then((function(){e.changeNode(t)})))})))}))},e.showNodeList=function(){var t=!!("true"===p.httpsMode||!0===p.httpsMode||"force"===p.httpsMode||n.location&&"https:"===n.location.protocol);return a._popupStack[0].responseDeferred.promise.close(),c.showNetworkLookup({enableFilter:!0,bma:!0,ssl:!!t||void 0}).then((function(e){if(e){var t=e.getBMA();return{host:t.dns?t.dns:e.hasValid4(t)?t.ipv4:t.ipv6,port:t.port||80,useSsl:t.useSsl||443==t.port}}})).then((function(t){e.changeNode(t)}))},e.showNodePopup=function(n){return t((function(t,i){e.popupData.newNode=n.port?[n.host,n.port].join(":"):n.host,e.popupData.useSsl=n.useSsl,e.popupForm&&e.popupForm.$setPristine(),r(["SETTINGS.POPUP_PEER.TITLE","COMMON.BTN_OK","COMMON.BTN_CANCEL"]).then((function(n){a.show({templateUrl:"templates/settings/popup_node.html",title:n["SETTINGS.POPUP_PEER.TITLE"],scope:e,buttons:[{text:n["COMMON.BTN_CANCEL"]},{text:n["COMMON.BTN_OK"],type:"button-positive",onTap:function(t){if(e.popupForm.$submitted=!0,e.popupForm.$valid&&e.popupForm.newNode)return{server:e.popupData.newNode,useSsl:e.popupData.useSsl};t.preventDefault()}}]}).then((function(e){if(e){var n=e.server.split(":");n[1]=n[1]?n[1]:80,t({host:n[0],port:n[1],useSsl:e.useSsl})}else l.loading.hide()}))}))}))},e.save=function(){return e.loading||e.pendingSaving?t.when():e.saving?(e.pendingSaving=!0,o((function(){return e.pendingSaving=!1,e.save() }),500)):(e.saving=!0,o((function(){return e.cleanupHelpTip(),E.apply(e.formData),E.store()}),100).then((function(){e.saving=!1})))},e.onDataChanged=function(n,i,a){return e.loading||e.pendingSaving?t.when():e.saving?(e.pendingSaving=!0,o((function(){return e.pendingSaving=!1,e.onDataChanged(n,i,a)}),500)):void(a!==e||angular.equals(n,i)||e.save())},e.$watch("formData",e.onDataChanged,!0),E.api.data.on.changed(e,(function(t){e.loading||e.saving||e.pendingSaving||!angular.equals(t.useLocalStorageEncryption,e.formData.useLocalStorageEncryption)&&(console.debug("[settings] Settings changed (outside the settings page). Reloading..."),e.load())})),e.getServer=function(){return e.formData.node&&e.formData.node.host?u.getServer(e.formData.node.host,e.formData.node.port):""},e.cleanupHelpTip=function(){if(e.formData.helptip.enable!==E.data.helptip.enable){var t=e.formData.helptip.enable;e.formData.helptip=angular.merge({},E.defaultSettings.helptip),e.formData.helptip.enable=t}},e.showActionsPopover=function(t){l.popover.show(t,{templateUrl:"templates/settings/popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.startSettingsTour=function(){return e.hideActionsPopover(),e.showHelpTip(0,!0)},e.showHelpTip=function(t,n){if((e.isLogin()||n)&&!((t=angular.isDefined(t)?t:E.data.helptip.settings)<0)){0===t&&(t=1);var i=e.createHelptipScope(n);if(i)return i.startSettingsTour(t,!1).then((function(e){i.$destroy(),E.data.helptip.settings=e,E.store()}))}}}function $(e,n,i,a,o,r,s,l,c,d,u){e.search={result:[],total:0,loading:!0,loadingMore:!1,hasMore:!1,type:"last"},e.node={},e.currency=!1,e.entered=!1,e.searchTextId=null,e.ionItemClass="item-border-large",e.defaultSizeLimit=s.screen.isSmall()?50:100,e.helptipPrefix="helptip-network",e.listeners=[],e.enter=function(t,a){if(e.entered)e.addListeners();else{if(a&&a.stateParams&&a.stateParams.q&&(e.search.text=a.stateParams.q,e.search.text&&e.search.text.trim().length&&(e.search.type="text")),a&&a.stateParams&&a.stateParams.server){var o="true"==a.stateParams.ssl,r="true"==a.stateParams.tor,d={server:a.stateParams.server,host:a.stateParams.server,useSsl:o,useTor:r},p=a.stateParams.server.split(":");if(2===p.length&&(d.host=p[0],d.port=p[1]),!l.node.same(d))return e.node=r?l.instance(d.host+".to",443,!0,6e5):l.instance(d.host,d.port,d.useSsl),e.node.blockchain.parameters().then((function(t){e.currency=t.currency,e.enter()}));e.node=l}if(!e.currency)return c.get().then((function(t){e.currency=t?t.name:null,e.node=t.node?t.node:l,e.currency?e.enter():s.alert.error("ERROR.GET_CURRENCY_FAILED")})).catch(s.onError("ERROR.GET_CURRENCY_FAILED"));e.compactMode=!angular.isDefined(e.compactMode)||e.compactMode,e.expertMode=angular.isDefined(e.expertMode)?e.expertMode:!s.screen.isSmall()&&u.data.expertMode,e.doSearch(),e.searchTextId&&n((function(){i(e.searchTextId)}),100),e.addListeners(),e.entered=!0,e.showHelpTip()}},e.$on("$ionicParentView.enter",e.enter),e.leave=function(){e.removeListeners()},e.$on("$ionicParentView.leave",e.leave),e.$on("$destroy",e.leave),e.doSearchLast=function(){return e.search.type="last",e.doSearch()},e.doSearch=function(n){var i;if(n=angular.isDefined(n)?n:0,e.search.loading=0===n,e.search.hasMore=!1,0===n)i=e.node.blockchain.current(!1).then((function(t){var n=t.number0&&e.search.results.length){var a=e.search.results[e.search.results.length-1];i=a.empty?a.day:void 0}_.forEach(t,(function(e,t){if(e.empty){var a=p(e.medianTime),o=0!==t||0!==n,r=!i||i==a;e.compacted=o&&r,i=a}else i=void 0}))}return d.extendAll(t,"issuer")},e.doDisplayResult=function(t,n,i){e.search.results=n?e.search.results.concat(t):t||[],e.search.hasMore=i&&e.search.results.length0&&n((function(){e.search.hasMore=!0}),500)}},e.toggleSort=function(t){e.search.sort!==t||e.search.asc?(e.search.asc=e.search.sort!==t||!e.search.asc,e.search.sort=t):(e.search.asc=void 0,e.search.sort=void 0),e.doSearch()},e.showHelpTip=function(){}}function K(e,n,i,a,o,r,s){e.loading=!0,e.formData={},e.compactMode=!0,e.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!a.screen.isSmall()||t.enableBack})),e.enter=function(t,n){if(e.loading){if(n&&(e.number=n.stateParams&&angular.isDefined(n.stateParams.number)?n.stateParams.number:"current",e.hash=n.stateParams&&n.stateParams.hash?n.stateParams.hash:void 0,n.stateParams&&n.stateParams.server)){var i="true"==n.stateParams.ssl,s="true"==n.stateParams.tor,l={server:n.stateParams.server,host:n.stateParams.server,useSsl:i,useTor:s},c=n.stateParams.server.split(":");if(2==c.length&&(l.host=c[0],l.port=c[1]),!o.node.same(l))return e.node=s?o.instance(l.host+".to",443,!0,6e5):o.instance(l.host,l.port,l.useSsl),e.node.blockchain.parameters().then((function(t){e.currency=t.currency,e.enter()}));e.node=o}e.currency&&e.node?e.load():r.get().then((function(t){t&&(e.currency=t.name,e.node=t.node,e.load())})).catch(a.onError("ERROR.GET_CURRENCY_FAILED"))}},e.$on("$ionicView.enter",e.enter),e.leave=function(){},e.$on("$ionicParentView.beforeLeave",e.leave),e.load=function(){if(e.number)return("current"==e.number?e.node.blockchain.current():e.node.blockchain.block({block:e.number})).then((function(n){var i=new t(n);if(i.parseData(),!i||!angular.isDefined(i.number)||!i.hash)return e.loading=!1,void a.alert.error("ERROR.GET_BLOCK_FAILED");if(e.hash&&i.hash!=e.hash)return e.loading=!1,void a.alert.error("ERROR.INVALID_BLOCK_HASH");var r=[];i.joiners.length&&(r=r.concat(i.joiners)),i.certifications.length&&(r=i.certifications.reduce((function(e,t){return t.to={pubkey:t.to},t.from={pubkey:t.from},e.concat(t.to,t.from)}),r),i.certifications=_.groupBy(i.certifications,(function(e){return e.to.pubkey}))),i.transactions.length&&(r=i.transactions.reduce((function(e,t){return t.issuers=t.issuers.reduce((function(e,t){return e.concat({pubkey:t})}),[]),_.forEach(t.outputs||[],(function(e){e.unlockCondition&&angular.merge(e,o.tx.parseUnlockCondition(e.unlockCondition))})),e.concat(t.issuers.concat(t.outputs||[]))}),r));var l={pubkey:i.issuer};return r.push(l),s.extendAll(r).then((function(){e.updateView({block:i,issuer:l})}))})).catch((function(t){e.loading=!1,a.onError("ERROR.GET_BLOCK_FAILED")(t)}))},e.updateView=function(t){e.formData=t.block,e.issuer=t.issuer,e.loading=!1},e.toggleCompactMode=function(){e.compactMode=!e.compactMode},e.toUnlockUIArray=function(t,n,i){return n=n||10,!t.children||"AND"!=t.type&&"OR"!=t.type?{style:{"padding-left":n+"px"},operator:i,type:t.type,value:t.value}:t.children.reduce((function(i,a,o){return a.children&&o>0?(i=i.concat({style:{"padding-left":n+"px","padding-top":"10px","padding-bottom":"10px"},operator:t.type})).concat(e.toUnlockUIArray(a,n+10)):i.concat(e.toUnlockUIArray(a,n+10,o&&t.type))}),[])},e.showUnlockConditionPopover=function(t,n){t.unlockTree&&(e.popoverData=e.popoverData||{},e.popoverData.unlockConditions=e.toUnlockUIArray(t.unlockTree),a.popover.show(n,{templateUrl:"templates/blockchain/unlock_condition_popover.html",scope:e,autoremove:!0,afterShow:function(t){e.unlockConditionPopover=t}}))},e.hideUnlockConditionsPopover=function(){e.unlockConditionPopover&&(e.unlockConditionPopover.hide(),e.unlockConditionPopover=null)},e.goState=function(t,n){e.hideUnlockConditionsPopover(),i.go(t,n)},e.openRawBlock=function(t){return e.openLink(t,e.node.url+"/blockchain/block/"+e.formData.number)},e.showHelpTip=function(e){}}function j(e,t){var n,i,a={user:"EVENT.USER.",page:"EVENT.PAGE."},o=this;if(e=e||{},o.id=e.id||""+Date.now(),o.type=e.type&&e.type.toLowerCase(),o.time=e.time,o.hash=e.hash,o.read=!!e.read_signature,o.message=e.code&&(e.reference&&a[e.reference.index]?a[e.reference.index]+e.code:"EVENT."+e.code)||e.message,o.params=e.params,t&&"function"==typeof t&&(o.markAsReadCallback=t),o.markAsRead=function(){o.markAsReadCallback&&o.markAsReadCallback(o)},e.code=e.code||"",e.code.startsWith("MEMBER_"))o.avatarIcon="ion-person",o.icon="ion-information-circled positive",o.state="app.view_wallet",o.medianTime=o.time;else if(e.code.startsWith("TX_"))o.avatarIcon="ion-card",o.icon="TX_SENT"===e.code?"ion-paper-airplane dark":"ion-archive balanced",o.medianTime=o.time,(n=e.params.length>0?e.params[0]:null)&&-1==n.indexOf(",")&&(o.pubkey=n),o.state="app.view_wallet_tx",o.stateParams={refresh:!0};else if(e.code.startsWith("CERT_"))o.avatarIcon="CERT_RECEIVED"===e.code?"ion-ribbon-b":"ion-ribbon-a",o.icon="CERT_RECEIVED"===e.code?"ion-ribbon-b balanced":"ion-ribbon-a gray",o.pubkey=e.params.length>0?e.params[0]:null,o.medianTime=o.time,o.state="app.wallet_cert",o.stateParams={type:"CERT_RECEIVED"===e.code?"received":"given"};else if(e.code.startsWith("MESSAGE_"))o.avatarIcon="ion-email",o.icon="ion-email dark",(n=e.params.length>0?e.params[0]:null)&&-1===n.indexOf(",")&&(o.pubkey=n),o.id=e.reference.id;else if(e.reference&&"user"===e.reference.index&&"profile"===e.reference.type)if(o.pubkey=e.params.length>0?e.params[0]:null,o.state="app.wot_identity",o.stateParams={pubkey:o.pubkey,uid:e.params&&e.params[3]},e.code.startsWith("LIKE_"))o.avatarIcon="ion-person",o.icon="ion-ios-heart positive";else if(e.code.startsWith("STAR_"))o.avatarIcon="ion-person",o.icon="ion-star gray";else if(e.code.startsWith("FOLLOW_"))o.avatarIcon="ion-person",o.icon="ion-ios-people gray";else if(e.code.startsWith("ABUSE_"))o.avatarIcon="ion-person",o.icon="ion-android-warning assertive";else if(e.code.startsWith("MODERATION_")){o.state="app.wot_identity",o.stateParams={pubkey:e.reference.id,uid:e.params&&e.params[3]},o.avatarIcon="ion-alert-circled",o.icon="ion-alert-circled energized";var r=e.params&&e.params[4]||0;"MODERATION_RECEIVED"===e.code&&5==r&&(o.message="EVENT.USER.DELETION_RECEIVED",o.icon="ion-trash-a assertive")}else o.icon="ion-person dark";else e.reference&&"page"===e.reference.index?(o.pubkey=e.params.length>0?e.params[0]:null,o.avatarIcon="ion-social-buffer",e.reference.anchor?(o.icon="ion-ios-chatbubble-outline dark",o.state="app.view_page_anchor",o.stateParams={id:e.reference.id,title:e.params[1],anchor:(i=e.reference.anchor,i?i.substr(0,4)+i.substr(i.length-4):"")}):(o.icon="ion-social-buffer dark",o.state="app.view_page",o.stateParams={id:e.reference.id,title:e.params[1]}),e.code.startsWith("LIKE_")?o.icon="ion-ios-heart positive":e.code.startsWith("FOLLOW_")?o.avatarIcon="ion-person":e.code.startsWith("ABUSE_")?o.icon="ion-alert-circled energized":e.code.startsWith("MODERATION_")&&(o.avatarIcon="ion-alert-circled",o.icon="ion-alert-circled energized","MODERATION_RECEIVED"===e.code&&5===e.level&&(o.message="EVENT.PAGE.DELETION_RECEIVED",o.icon="ion-trash-a assertive"))):"INFO"===e.type?(o.avatarIcon="ion-information",o.icon="ion-information-circled positive"):"WARN"===e.type?(o.avatarIcon="ion-alert-circled",o.icon="ion-alert-circled energized"):"ERROR"===e.type&&(o.avatarIcon="ion-close",o.icon="ion-close-circled assertive");return o}function z(e,t){var n=this;n.id=e,n.message=null,n.html=null,n.issuer=null,n.time=null,n.creationTime=null,n.reply_to=null,n.replyCount=0,n.parent=null,n.replies=[],n.onRemoveListeners=[],n.copy=function(e){n.message=e.message,n.html=e.html,n.issuer=e.issuer,n.time=e.time,n.creationTime=e.creationTime||n.time,n.id=e.id||n.id,n.reply_to=e.reply_to||n.reply_to,n.uid=e.uid||n.uid,n.name=e.name||n.name,n.avatarStyle=e.avatarStyle||n.avatarStyle,e.parent&&(n.parent=e.parent),e.replies&&n.setReplies(e.replies)},n.copyFromJson=function(e){n.message=e.message,n.issuer=e.issuer,n.time=e.time,n.creationTime=e.creationTime||n.time,n.reply_to=e.reply_to},n.addOnRemoveListener=function(e){e&&"function"==typeof e&&n.onRemoveListeners.push(e)},n.cleanAllListeners=function(){n.onRemoveListeners=[]},n.setReplies=function(e){n.removeAllReplies(),n.addReplies(e)},n.addReplies=function(e){e&&e.length&&(e=e.sort((function(e,t){return e.time-t.time})),_.forEach(e,(function(e){e.parent=n,n.replies.push(e)})),n.replyCount+=e.length)},n.containsReply=function(e){return-1!=n.replies.indexOf(e)},n.addReply=function(e){n.replyCount+=1,n.replies.push(e),n.replies=n.replies.sort((function(e,t){return e.time-t.time})),e.parent=n},n.removeAllReplies=function(){if(n.replyCount){var e=n.replies.splice(0,n.replies.length);n.replyCount=0,_.forEach(e,(function(e){e.remove()}))}},n.removeReply=function(e){var t=_.findIndex(n.replies,{id:e});-1!=t&&(n.replyCount--,delete n.replies.splice(t,1)[0].parent)},n.remove=function(){n.parent&&(n.parent.removeReply(n.id),delete n.parent),n.onRemoveListeners.length&&(_.forEach(n.onRemoveListeners,(function(e){e(n)})),n.issuer=null,n.message=null,n.cleanAllListeners())},t&&"object"==typeof t&&n.copyFromJson(t)}function q(e){if(e=e||{},this.type=e.type&&e.type.toLowerCase(),this.time=e.time,this.id=e.id,"certification"==this.type){if(this.comment=e.comment,this.icon="ion-ribbon-a",this.okText="WOT.BTN_CERTIFY",!e.content||-1==e.content.indexOf("-"))return console.error("[invitation] Empty content for invitation [{0}]".format(this.id)),this.message="INVITATION.ERROR.BAD_INVITATION_FORMAT",void(this.pubkey=e.issuer);var t=e.content.lastIndexOf("-");if(-1==t)return console.error("[invitation] Bad content format for invitation [{0}]: {1}".format(this.id,e.content)),this.message="INVITATION.ERROR.BAD_INVITATION_FORMAT",void(this.pubkey=e.issuer);var n={uid:e.content.substr(0,t),pubkey:e.content.substr(t+1)};this.state="app.wot_identity",this.stateParams={pubkey:n.pubkey,uid:n.uid,action:"certify"},n.pubkey==e.issuer?(this.pubkey=e.issuer,this.uid=n.uid,this.message="INVITATION.ASK_CERTIFICATION"):(this.issuer={pubkey:e.issuer},this.message="INVITATION.SUGGESTION_CERTIFICATION",this.pubkey=n.pubkey,this.uid=n.uid)}}function X(e){var t=this;Object.keys(e).forEach((function(n){t[n]=e[n]})),t.endpoints=t.endpoints||[]}function Q(e,t,n,i){e.selectNewPicture=function(t){if(i.enable)e.openPicturePopup();else{var n=angular.element(document.querySelector(t||"#pictureFile"));n&&n.length>0&&n[0].click()}},e.openPicturePopup=function(){i.camera.getPicture().then((function(t){e.pictures.push({src:"data:image/png;base64,"+t,isnew:!0})})).catch(t.onError("ERROR.TAKE_PICTURE_FAILED"))},e.onFileChanged=function(n){if(n&&n.file){t.loading.show();var i=n.file;return t.image.resizeFile(i).then((function(n){e.pictures.push({src:n,isnew:!0}),t.loading.hide(100)})).catch((function(e){console.error(e),t.loading.hide()}))}},e.removePicture=function(t){e.pictures.splice(t,1)},e.favoritePicture=function(t){if(t>0){var n=e.pictures[t];e.pictures.splice(t,1),e.pictures.splice(0,0,n)}},e.rotatePicture=function(n){var i=e.pictures[n];t.image.rotateSrc(i.src).then((function(e){i.src=e}))}}function J(e,t,n,i){e.loading=!0,e.allCategories=[],e.categories=[],this.searchText="",this.title=i&&i.title,e.afterLoad=function(i){e.categories=i,e.allCategories=i,e.loading=!1,n((function(){t.ink()}),10)},this.doSearch=function(){var t=this.searchText.toLowerCase().trim();t.length>1?(e.loading=!0,e.categories=e.allCategories.reduce((function(e,n){return n.parent&&-1!=n.name.toLowerCase().search(t)?e.concat(n):e}),[]),e.loading=!1):e.categories=e.allCategories},i&&i.categories?e.afterLoad(i.categories):i&&i.load&&i.load().then((function(t){e.afterLoad(t)}))}function Z(e,t,n,i,a,o,r){e.loading=!0,e.defaultCommentSize=5,e.formData={},e.comments={},e.$on("$recordView.enter",(function(t,n){e.loading?e.anchor=n&&n.stateParams.anchor:!e.loading&&e.id&&e.load(e.id,{animate:!1})})),e.$on("$recordView.load",(function(t,n,i){e.id=n||e.id,e.service=i||e.service,console.debug("[ES] [comment] Will use {"+i.index+"} service"),e.id&&e.load(e.id).then((function(){e.scrollToAnchor()}))})),e.load=function(t,n){return(n=n||{}).from=n.from||0,n.size=n.size||e.anchor&&-1,n.size=n.size||e.defaultCommentSize,n.animate=!angular.isDefined(n.animate)||n.animate,n.loadAvatarAllParent=!angular.isDefined(n.loadAvatarAllParent)||n.loadAvatarAllParent,e.loading=!0,e.service.load(t,n).then((function(i){!n.animate&&i.result.length&&_.forEach(i.result,(function(e){e.isnew=!0})),e.comments=i,e.comments.hasMore=i.total>i.result.length,e.loading=!1,e.service.changes.start(t,i,e),e.motion.show({selector:".comments .item",ink:!1})}))},e.$on("$recordView.beforeLeave",(function(){if(e.comments){if(!e.service)return void console.error("[comment] Comment controller has no service ! Unable to listen changes...");e.service.changes.stop(e.comments)}})),e.scrollToAnchor=function(){if(e.anchor){var t=document.getElementsByName(e.anchor);if(!t||!t.length)return a(e.scrollToAnchor,500);for(var n=0;n-1?e.selectLocation(e.locations[e.selectLocationIndex]):e.selectLocation(e.locations[0])},e.onArrowUpOrDown=function(t){e.locations&&(e.selectLocationIndex+=t,e.selectLocationIndex>=e.locations.length&&(e.selectLocationIndex=0),e.selectLocationIndex<0&&(e.selectLocationIndex=e.locations.length-1),_.forEach(e.locations||[],(function(t,n){t.selected=n==e.selectLocationIndex})))},e.onLocationChanged=function(){r||e.search.loading||(e.search.geoPoint=void 0,e.showDropdown())},e.showDropdown=function(){var t=e.search.location&&e.search.location.trim();if(!t||t.length<3)return e.hideDropdown(!0);var n=e.requestId&&e.requestId+1||1;return e.requestId=n,r=!0,a.point.searchByAddress(t).then((function(t){e.requestId==n&&(r=!1,e.locations=t||[],e.license=t&&t.length&&t[0].license)})).catch((function(t){throw e.hideDropdown(),t}))},e.hideDropdown=function(n){return n?(e.locations=void 0,e.selectLocationIndex=-1,e.license=void 0,void(r=!1)):t((function(){r||(e.locations=void 0,e.license=void 0,r=!1)}),500)},e.selectLocation=function(t,n){if(r=!0,t)if(e.search.geoPoint=e.search.geoPoint||{},e.search.geoPoint.lat=parseFloat(t.lat),e.search.geoPoint.lon=parseFloat(t.lon),n)e.search.geoPoint.exact=!0;else if(t&&t.address&&t.address.city){var i=[t.address.city];t.address.postcode&&i.push(t.address.postcode),t.address.country!=o&&i.push(t.address.country),e.search.location=i.join(", ")}e.hideDropdown(!0)},e.openSearchLocationModal=function(t){var i={text:(t=t||{text:e.search.location}).text||e.search.location};return n.show("plugins/es/templates/common/modal_location.html","ESSearchPositionModalCtrl",i,{focusFirstInput:!0}).then(e.selectLocation)}}function re(e,t,n,i,a){e.search={text:a.text||"",fallbackText:a.fallbackText||void 0,forceFallback:!!angular.isDefined(a.forceFallback)&&a.forceFallback,loading:!1,results:a.results||void 0},e.$on("modal.shown",(function(){e.doSearch(!0)})),e.doSearch=function(a){var o=e.search.text&&e.search.text.trim();if(!o)return t.when();e.search.loading=!0;var r=a&&e.search.fallbackText&&e.search.fallbackText.trim();return r=r&&r!=o?r:void 0,(a&&e.search.forceFallback&&e.search.results?t.when(e.search.results):i.point.searchByAddress(o)).then((function(e){return e&&e.length||!r?e:t.all([n("LOCATION.MODAL.ALTERNATIVE_RESULT_DIVIDER",{address:r}),i.point.searchByAddress(r)]).then((function(e){var t=e[0];return(e=e[1])&&e.length?[{name:t}].concat(e):e}))})).then((function(t){e.search.loading=!1,e.search.results=t||[],e.license=t&&t.length&&t[0].license})).catch((function(t){throw e.search.loading=!1,e.search.results=[],e.license=void 0,t}))}}function se(e,t,n){e.extensionPoint=n.extensions.points.current.get(),e.enable=t.isEnable(),t.api.state.on.changed(e,(function(t){e.enable=t,e.$broadcast("$$rebind::state")}))}function le(e,t,n,i,a){angular.extend(this,n("ESExtensionCtrl",{$scope:e})),e.showRegistryLookupView=function(){t.go(i.screen.isSmall()?"app.wot_lookup.tab_registry":"app.registry_lookup_lg")},e.showNotificationsPopover=function(t){return i.popover.show(t,{templateUrl:"plugins/es/templates/notification/popover_notification.html",scope:e,autoremove:!1,afterShow:function(e){var t=a.api.data.on.unauth(e.scope,(function(){e.scope.closePopover(),t()}))}})},e.showMessagesPopover=function(t){return a.isAuth()?i.popover.show(t,{templateUrl:"plugins/es/templates/message/popover_message.html",scope:e,autoremove:!1,afterShow:function(e){var t=a.api.data.on.unauth(e.scope,(function(){e.scope.closePopover(),t()}))}}):a.auth({minData:!0}).then((function(){return i.loading.hide(),e.showMessagesPopover(t)}))},e.showInvitationsPopover=function(t){return a.isAuth()?i.popover.show(t,{templateUrl:"plugins/es/templates/invitation/popover_invitation.html",scope:e,autoremove:!1,afterShow:function(e){var t=a.api.data.on.unauth(e.scope,(function(){e.scope.closePopover(),t()}))}}):a.auth().then((function(){return i.loading.hide(),e.showInvitationsPopover(t)}))}}function ce(e,t,n,i,a){e.updateView=function(){e.enable=a.isLogin()&&i.isEnable()},e.showEditUserProfile=function(){e.closeProfilePopover(),n.go("app.edit_profile")},i.api.state.on.changed(e,e.updateView),a.api.data.on.login(e,(function(n,a){return e.enable=i.isEnable(),a&&a.resolve()||t.when()})),a.api.data.on.logout(e,(function(){e.enable=!1})),e.updateView()}function de(e,t,n,i,a,o,r,s,l,c,d,u,p){e.hasWindowNotification=!!("Notification"in window),e.formData={},e.popupData={},e.loading=!0,e.enter=function(t,n){e.load()},e.$on("$ionicView.enter",e.enter),e.load=function(t){e.loading=!0;var n=e.formData.enable;e.formData=c.data.plugins&&c.data.plugins.es?angular.copy(c.data.plugins.es):{enable:!1,host:void 0,port:void 0},t&&n&&(e.formData.enable=n),e.isFallbackNode=e.formData.enable&&d.node.isFallback(),e.server=e.getServer(d),e.loading=!1},u.api.state.on.changed(e,(function(t){e.load(!0)})),e.setPopupForm=function(t){e.popupForm=t},e.changeEsNode=function(t){t=t||{host:e.formData.host,port:e.formData.port&&80!=e.formData.port&&443!=e.formData.port?e.formData.port:void 0,useSsl:angular.isDefined(e.formData.useSsl)?e.formData.useSsl:443==e.formData.port},e.showNodePopup(t).then((function(t){if(t.host!==e.formData.host||t.port!=e.formData.port||t.useSsl!=e.formData.useSsl){o.loading.show();var n=d.instance(t.host,t.port,t.useSsl);return n.isAlive().then((function(i){return i?(e.formData.host=n.host,e.formData.port=n.port,e.formData.useSsl=n.useSsl,d.copy(n)):(o.loading.hide(),o.alert.error("ERROR.INVALID_NODE_SUMMARY").then((function(){e.changeEsNode(t)})))})).then((function(){e.server=e.getServer(d),e.isFallbackNode=!1,o.loading.hide()}))}o.loading.hide()}))},e.showNodePopup=function(t){return n((function(n,r){var s=[t.host];t.port&&80!=t.port&&s.push(t.port),e.popupData.newNode=s.join(":"),e.popupData.useSsl=angular.isDefined(t.useSsl)?t.useSsl:443==t.port,e.popupForm&&e.popupForm.$setPristine(),i(["ES_SETTINGS.POPUP_PEER.TITLE","ES_SETTINGS.POPUP_PEER.HELP","COMMON.BTN_OK","COMMON.BTN_CANCEL"]).then((function(t){a.show({templateUrl:"templates/settings/popup_node.html",title:t["ES_SETTINGS.POPUP_PEER.TITLE"],subTitle:t["ES_SETTINGS.POPUP_PEER.HELP"],scope:e,buttons:[{text:t["COMMON.BTN_CANCEL"]},{text:t["COMMON.BTN_OK"],type:"button-positive",onTap:function(t){if(e.popupForm.$submitted=!0,e.popupForm.$valid&&e.popupForm.newNode)return{server:e.popupData.newNode,useSsl:e.popupData.useSsl};t.preventDefault()}}]}).then((function(e){if(e){var t=e.server.split(":");t[1]=t[1]?t[1]:e.useSsl?443:80,n({host:t[0],port:t[1],useSsl:e.useSsl})}else o.loading.hide()}))}))}))},e.showNodeList=function(){var n=!!("true"===l.httpsMode||!0===l.httpsMode||"force"===l.httpsMode||t.location&&"https:"===t.location.protocol);return a._popupStack[0].responseDeferred.promise.close(),p.showNetworkLookup({enableFilter:!0,endpoint:d.constants.ES_USER_API_ENDPOINT,ssl:!!n||void 0}).then((function(e){if(e){var t=(e.getEsEndpoints()||[]).reduce((function(e,t){var n=d.node.parseEndPoint(t);return n?e.concat(n):e}),[]);if(t.length){var n=t[0];return{host:n.dns?n.dns:e.hasValid4(n)?n.ipv4:n.ipv6,port:n.port||80,useSsl:n.useSsl||443==n.port}}}})).then((function(t){e.changeEsNode(t)}))},e.onFormChanged=function(){e.loading||(e.hasWindowNotification&&e.formData.notifications.emitHtml5!==("granted"===window.Notification.permission)?window.Notification.requestPermission((function(t){e.formData.notifications.emitHtml5="granted"===t,e.onFormChanged()})):(e.loading=!0,c.data.plugins=c.data.plugins||{},c.data.plugins.es=c.data.plugins.es?angular.merge(c.data.plugins.es,e.formData):e.formData,delete c.data.plugins.es.newNode,c.store().then((function(){e.loading=!1}))))},e.$watch("formData",e.onFormChanged,!0),e.getServer=function(t){if((t=t||e.formData).host)return s.getServer(t.host,t.port)}}function ue(e,t,n,i,a){angular.extend(this,t("ESExtensionCtrl",{$scope:e})),e.showProfileHelp=!1,e.showNewPageModal=function(e){var t=n.params&&n.params.id?i.children.get(n.params.id):i;if(t)return a.showNewPage({wallet:t});UIUtils.alert.error("ERROR.UNKNOWN_WALLET_ID")}}function pe(e,t,n,i,a){e.options=e.options||{},e.options.like=e.options.like||{index:"user",type:"profile",service:a.like},e.canEdit=!0,angular.extend(this,t("ESLikesCtrl",{$scope:e})),angular.extend(this,t("ESExtensionCtrl",{$scope:e})),e.$watch("formData.pubkey",(function(t){t&&e.loadLikes(t)}))}function me(e,t,n){angular.extend(this,t("ESExtensionCtrl",{$scope:e})),e.openRegistryLookup=function(){var t=e.search.text&&e.search.text.trim()||"",i=e.search.location&&e.search.location.trim()||"",a={q:t.length?t:void 0,location:i.length?i:void 0};n.go("app.wot_lookup.tab_registry",a)}}function Ee(e,t,n,i,a,o,r,s,l,c,d,u,p,m){e.options=e.options||{},e.options.like=e.options.like||{kinds:c.constants.KINDS,index:"user",type:"profile",service:p.like},e.smallscreen=angular.isDefined(e.smallscreen)?e.smallscreen:o.screen.isSmall(),angular.extend(this,i("ESLikesCtrl",{$scope:e})),angular.extend(this,i("ESExtensionCtrl",{$scope:e})),e.canCertify=!1,e.showNewMessageModal=function(t){return s.login({minData:!0,method:"default"}).then((function(){return o.loading.hide(),!(!t&&!e.formData.profile)||o.alert.confirm("MESSAGE.CONFIRM.USER_HAS_NO_PROFILE").then((function(e){if(e)return!0}))})).then((function(t){return!!t&&d.showMessageCompose({destPub:e.formData.pubkey,destUid:e.formData.name||e.formData.uid}).then((function(e){e&&o.toast.show("MESSAGE.INFO.MESSAGE_SENT")}))}))},e.showSuggestCertificationModal=function(){var t;return e.hideCertificationActionsPopover(),s.auth({minData:!0}).then((function(i){if(o.loading.hide(),i)return i.isMember?r.showWotLookup({allowMultiple:!0,enableFilter:!0,title:"WOT.SUGGEST_CERTIFICATIONS_MODAL.TITLE",help:"WOT.SUGGEST_CERTIFICATIONS_MODAL.HELP",okText:"COMMON.BTN_NEXT",okType:"button-positive"}).then((function(a){if(a&&a.length)return t=a,n.all([u.box.getKeypair(i.keypair),o.alert.confirm("WOT.CONFIRM.SUGGEST_CERTIFICATIONS",void 0,{okText:"COMMON.BTN_SEND"})]).then((function(a){if(a){var o=a[0];if(a[1]){var r=moment().utc().unix();return n.all(t.reduce((function(t,n){return t.concat(m.send({issuer:i.pubkey,recipient:e.formData.pubkey,time:r,content:[n.uid,n.pubkey].join("-")},o,"certification"))}),[]))}}})).then((function(){o.toast.show("INVITATION.INFO.INVITATION_SENT")})).catch(o.onError("INVITATION.ERROR.SEND_INVITATION_FAILED"))})):o.alert.error("ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION")}))},e.showAskCertificationModal=function(){var t;return e.hideCertificationActionsPopover(),(s.children.count()?r.showSelectWallet({displayBalance:!1}):n.when(s)).then((function(e){if(!e)throw"CANCELLED";return e.auth({minData:!0})})).then((function(e){if(o.loading.hide(),e)return e.isMember?r.showWotLookup({allowMultiple:!0,enableFilter:!1,title:"WOT.ASK_CERTIFICATIONS_MODAL.TITLE",help:"WOT.ASK_CERTIFICATIONS_MODAL.HELP",okText:"COMMON.BTN_NEXT",okType:"button-positive"}).then((function(i){if(i&&i.length)return t=i,n.all([u.box.getKeypair(e.keypair),o.alert.confirm("WOT.CONFIRM.ASK_CERTIFICATIONS",void 0,{okText:"COMMON.BTN_SEND"})]).then((function(i){var a=i&&i[0],r=i&&i[1];if(a&&r){var s=moment().utc().unix();return n.all(t.reduce((function(t,n){return t.concat(m.send({issuer:e.pubkey,recipient:n.pubkey,time:s,content:[e.uid,e.pubkey].join("-")},a,"certification"))}),[])).then((function(){o.toast.show("INVITATION.INFO.INVITATION_SENT")})).catch(o.onError("INVITATION.ERROR.SEND_INVITATION_FAILED"))}}))})):o.alert.error("ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION")}))},e.askCertification=function(){return e.hideCertificationActionsPopover(),(s.children.count()?r.showSelectWallet({displayBalance:!1}):n.when(s)).then((function(e){return e.auth({minData:!0})})).then((function(t){if(o.loading.hide(),t)return t.isMember?o.alert.confirm("WOT.CONFIRM.ASK_CERTIFICATION",void 0,{okText:"COMMON.BTN_SEND"}).then((function(n){if(n)return m.send({issuer:t.pubkey,recipient:e.formData.pubkey,content:[t.uid,t.pubkey].join("-")},{type:"certification",keypair:t.keypair}).then((function(){o.toast.show("INVITATION.INFO.INVITATION_SENT")})).catch(o.onError("INVITATION.ERROR.SEND_INVITATION_FAILED"))})):o.alert.error("ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION")}))},e.delete=function(t){if(!t){if(e.hideActionsPopover(),!e.formData.pubkey)return;return o.alert.confirm("PROFILE.CONFIRM.DELETE_BY_MODERATOR").then((function(t){if(t)return e.delete(t)}))}return o.loading.show().then((function(){return p.remove(e.formData.pubkey)})).then((function(){return e.doUpdate()})).then((function(){return a((function(){o.toast.show("DOCUMENT.INFO.REMOVED")}),800)})).catch(o.onError("PROFILE.ERROR.DELETE_PROFILE_FAILED"))},e.$watch("formData.pubkey",(function(t){t&&(e.loadLikes(t),e.canDelete=e.formData.profile&&s.isLogin()&&!0===s.data.moderator)})),e.showCertificationActionsPopover=function(t){o.popover.show(t,{templateUrl:"plugins/es/templates/wot/popover_certification_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.certificationActionsPopover=t}})},e.hideCertificationActionsPopover=function(){return e.certificationActionsPopover&&(e.certificationActionsPopover.hide(),e.certificationActionsPopover=null),!0},e.showActionsPopover=function(t){o.popover.show(t,{templateUrl:"plugins/es/templates/wot/view_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){return e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null),!0},"buttons-top-fab"===e.extensionPoint&&e.$on("$csExtension.motion",(function(t){e.formData.profile&&e.showFab("fab-compose-"+e.formData.pubkey)}))}function be(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E,b,g){angular.extend(this,a("ESLookupPositionCtrl",{$scope:e})),e.search={text:"",results:[],loading:!0,lastRecords:!0,type:null,category:null,location:null,advanced:null,issuer:null,geoDistance:isNaN(p.data.plugins.es.geoDistance)?20:p.data.plugins.es.geoDistance},e.searchTextId="registrySearchText",e.enableFilter=!0,e.smallscreen=angular.isDefined(e.smallscreen)?e.smallscreen:c.screen.isSmall(),e.options=angular.merge(e.options||{},{location:{show:!0,help:"REGISTRY.SEARCH.LOCATION_HELP"}}),e.enter=function(n,i){if(!e.entered||!e.search.results||0===e.search.results.length){if(!e.geoUnit)return r("LOCATION.DISTANCE_UNIT").then((function(t){return e.geoUnit=t,e.enter(n,i)}));var a=function(){e.searchTextId&&t(e.searchTextId),e.entered=!0,e.doSearch()};if(i.stateParams&&i.stateParams.q&&"string"==typeof i.stateParams.q&&(e.search.text=i.stateParams.q),i.stateParams&&i.stateParams.hash&&(e.search.text="#"+i.stateParams.hash),i.stateParams&&i.stateParams.location)e.search.location=i.stateParams.location,i.stateParams.lat&&i.stateParams.lon&&(e.search.geoPoint={lat:parseFloat(i.stateParams.lat),lon:parseFloat(i.stateParams.lon)}),i.stateParams.d&&(e.search.geoDistance=i.stateParams.d);else{var o=p.data.plugins.es.registry&&p.data.plugins.es.registry.defaultSearch;if(o&&(o.location?angular.merge(e.search,p.data.plugins.es.registry.defaultSearch):o=void 0),!o&&m.isLogin()&&m.data.profile){if(!m.isDataLoaded())return c.loading.show(),m.loadData().then((function(){return c.loading.hide(),e.enter(n,i)}));e.search.geoPoint=m.data.profile.geoPoint,e.search.location=m.data.profile.city||(m.data.profile.geoPoint?r.instant("LOCATION.PROFILE_POSITION"):void 0)}}i.stateParams&&(i.stateParams.type||i.stateParams.last)?i.stateParams.last||"last"==i.stateParams.type?(e.search.lastRecords=!0,e.search.type=void 0):e.search.type=i.stateParams.type:e.search.lastRecords=!1,i.stateParams&&i.stateParams.issuer&&(e.search.issuer=i.stateParams.issuer),i.stateParams&&i.stateParams.category?b.category.get({id:i.stateParams.category}).then((function(t){e.search.category=t,a()})).catch(c.onError("REGISTRY.ERROR.LOAD_CATEGORY_FAILED")):a()}e.showFab("fab-add-registry-record")},e.$on("$ionicView.enter",(function(t,n){return e.enter(t,n)})),e.leave=function(){var t=!1;p.data.plugins.es.registry=p.data.plugins.es.registry||{},p.data.plugins.es.registry.defaultSearch=p.data.plugins.es.registry.defaultSearch||{};var i=e.search.location&&e.search.location.trim(),a=p.data.plugins.es.registry.defaultSearch.location;a&&a===i||(p.data.plugins.es.registry.defaultSearch={location:i,geoPoint:i&&e.search.geoPoint?angular.copy(e.search.geoPoint):void 0},t=!0);var o=p.data.plugins.es.geoDistance;o&&o===e.search.geoDistance||(p.data.plugins.es.geoDistance=e.search.geoDistance,t=!0),t&&n((function(){p.store()}))},e.$on("$ionicView.leave",(function(){return e.leave()})),e.onGeoPointChanged=function(){e.search.loading||e.search.geoPoint&&e.search.geoPoint.lat&&e.search.geoPoint.lon&&!e.search.geoPoint.exact&&(e.doSearch(),e.updateLocationHref())},e.$watch("search.geoPoint",e.onGeoPointChanged,!0),e.resolveLocationPosition=function(){if(!e.search.loadingPosition)return e.search.loadingPosition=!0,e.searchPosition(e.search.location).then((function(t){if(!t)throw e.search.loading=!1,e.search.results=void 0,e.search.total=0,e.search.loadingPosition=!1,e.search.geoPoint=void 0,"CANCELLED";e.search.geoPoint=t,t.shortName&&!t.exact&&(e.search.location=t.shortName),e.search.loadingPosition=!1}))},e.doGetLastRecords=function(t){return e.hidePopovers(),e.search.text=void 0,e.doSearch(t)},e.doSearchText=function(){e.doSearch()},e.doSearch=function(t){if(e.search.loading=!t,e.search.location&&e.search.location.length>=3&&!e.search.geoPoint)return e.resolveLocationPosition().then((function(){return e.doSearch(t)}));var n=e.search.text&&e.search.text.trim()||"";e.search.lastRecords=!n||!n.length;var i=[],a=[];if(n&&n.length)if(u.regexp.PUBKEY.test(n))a.push({term:{pubkey:n}});else{var o=(n=n.toLowerCase())?g.util.parseTags(n):void 0;i.push({multi_match:{query:n,fields:["title","description","city","address"],type:"phrase_prefix"}}),i.push({match:{title:{query:n,boost:2}}}),i.push({prefix:{title:n}}),i.push({match:{description:n}}),i.push({nested:{path:"category",query:{bool:{filter:{match:{"category.name":n}}}}}}),o&&o.length&&a.push({terms:{tags:o}})}else e.search.issuer&&a.push({term:{issuer:e.search.issuer}});e.search.type&&a.push({term:{type:e.search.type}}),e.search.category&&a.push({nested:{path:"category",query:{bool:{filter:{term:{"category.id":e.search.category.id}}}}}});var r=e.search.location&&e.search.location.trim().toLowerCase();if(e.search.geoPoint&&e.search.geoPoint.lat&&e.search.geoPoint.lon)if(r&&r.length){var s=r.split(",")[0];a.push({or:[{and:[{not:{exists:{field:"geoPoint"}}},{match_phrase:{city:s}}]},{geo_distance:{distance:e.search.geoDistance+e.geoUnit,geoPoint:{lat:e.search.geoPoint.lat,lon:e.search.geoPoint.lon}}}]})}else a.push({geo_distance:{distance:e.search.geoDistance+e.geoUnit,geoPoint:{lat:e.search.geoPoint.lat,lon:e.search.geoPoint.lon}}});var l={highlight:{fields:{title:{},description:{},tags:{}}},from:t};return i.length>0&&(l.query=l.query||{bool:{}},l.query.bool.should=i,l.query.bool.minimum_should_match=1),a.length>0&&(l.query=l.query||{bool:{}},l.query.bool.filter=a),e.search.lastRecords&&(l.sort={creationTime:"desc"}),e.updateLocationHref(),e.doRequest(l)},e.doRequest=function(t){(t=t||{}).from=t.from||0,t.size=t.size||10,t.size<10&&(t.size=10),e.search.loading=0===t.from;var n=e.requestId&&e.requestId+1||1;return e.requestId=n,b.record.search(t).then((function(a){if(e.requestId==n){if(!a||!a.hits||!a.hits.length)return e.search.results=t.from>0?e.search.results:[],e.search.total=t.from>0?e.search.total:0,e.search.loading=!1,void(e.search.hasMore=!1);var o=i("formatSlug");_.forEach(a.hits,(function(e){e.urlTitle=o(e.title)})),t.from?e.search.results=e.search.results.concat(a.hits):(e.search.results=a.hits,e.search.total=a.total),e.search.hasMore=e.search.results.length0?e.search.results:[],e.search.total=t.from>0?e.search.total:0,e.search.hasMore=!1,c.onError("REGISTRY.ERROR.LOOKUP_RECORDS_FAILED")(n)}))},e.showMore=function(){var t=e.search.results?e.search.results.length:0;return e.search.loadingMore=!0,(e.search.lastRecords?e.doGetLastRecords:e.doSearch)(t).then((function(){e.search.loadingMore=!1,e.$broadcast("scroll.infiniteScrollComplete")})).catch((function(t){console.error(t),e.search.loadingMore=!1,e.search.hasMore=!1,e.$broadcast("scroll.infiniteScrollComplete")}))},e.removeType=function(){e.search.type=null,e.doSearch(),e.updateLocationHref()},e.removeCategory=function(){e.search.category=null,e.category=null,e.doSearch(),e.updateLocationHref()},e.removeLocation=function(){e.search.location=null,e.search.geoPoint=null,e.doSearch(),e.updateLocationHref()},e.updateLocationHref=function(t){t||n((function(){var t=e.search.text&&e.search.text.trim(),n=e.search.location&&e.search.location.trim(),i={location:n&&n.length?n:void 0,category:e.search.category?e.search.category.id:void 0,last:!!e.search.lastRecords||void 0,type:e.search.type?e.search.type:void 0,lat:e.search.geoPoint&&e.search.geoPoint.lat||void 0,lon:e.search.geoPoint&&e.search.geoPoint.lon||void 0,d:e.search.geoPoint&&e.search.geoDistance||void 0};t&&t.match(/^#\w+$/)?i.hash=t.substr(1):t&&t.length&&(i.q=t),o.search(i).replace()}))},e.onToggleAdvanced=function(){e.search.entered&&!e.search.lastRecords&&(e.doSearch(),e.updateLocationHref())},e.$watch("search.advanced",e.onToggleAdvanced,!0),e.toggleAdvanced=function(){e.search.advanced=!e.search.advanced,n(e.hidePopovers,200)},e.showRecordTypeModal=function(t){e.hidePopovers(),n((function(){t.isDefaultPrevented()||d.show("plugins/es/templates/registry/modal_record_type.html").then((function(t){t&&(e.search.type=t,e.doSearch(),e.updateLocationHref())}))}),350)},e.showCategoryModal=function(t){n((function(){t.isDefaultPrevented()||b.category.all().then((function(e){return d.show("plugins/es/templates/common/modal_category.html","ESCategoryModalCtrl as ctrl",{categories:e},{focusFirstInput:!0})})).then((function(t){t&&t.parent&&(e.search.category=t,e.doSearch(),e.updateLocationHref())}))}),350)},e.showNewPageModal=function(){return e.hidePopovers(),E.showNewPage()},e.showActionsPopover=function(t){c.popover.show(t,{templateUrl:"plugins/es/templates/registry/lookup_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.filtersPopover=null)},e.showFiltersPopover=function(t){c.popover.show(t,{templateUrl:"plugins/es/templates/registry/lookup_popover_filters.html",scope:e,autoremove:!0,afterShow:function(t){e.filtersPopover=t}})},e.hideFiltersPopover=function(){e.filtersPopover&&(e.filtersPopover.hide(),e.filtersPopover=null)},e.hidePopovers=function(){e.hideActionsPopover(),e.hideFiltersPopover()}}function ge(e,t,n,i,a,o){var r;angular.extend(this,t("ESRegistryLookupCtrl",{$scope:e})),e.searchTextId=void 0,e.enter=function(t,a){return e.entered?a.stateParams&&a.stateParams.refresh?n(e.doSearch,2e3):void 0:(r=a.stateParams&&a.stateParams.id?o.children.get(a.stateParams.id):o)?r.login({minData:!0}).then((function(t){i.loading.hide(),e.search.issuer=t.pubkey,e.search.advanced=!0,n(e.doSearch,100),e.showFab("fab-wallet-add-registry-record")})):(i.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome())},e.doUpdate=function(){if(r&&r.isLogin())return e.search.issuer=o.data.pubkey,e.search.advanced=!0,e.doSearch()},e.showNewPageModal=function(){return e.hidePopovers(),a.showNewPage({wallet:r})}}function fe(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E){e.formData={},e.id=null,e.category={},e.pictures=[],e.canEdit=!1,e.showTransfer=!1,e.loading=!0,e.motion=m.motion.fadeSlideIn,e.options=e.options||{},e.options.like={kinds:["LIKE","ABUSE"],index:"page",type:"record"},e.likeData={likes:{},abuses:{}},angular.extend(this,l("ESLikesCtrl",{$scope:e})),e.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!m.screen.isSmall()||t.enableBack})),e.$on("$ionicView.enter",(function(t,i){i.stateParams&&i.stateParams.id?((e.loading||i.stateParams.refresh)&&e.load(i.stateParams.id,i.stateParams.anchor),e.$broadcast("$recordView.enter",i)):n.go("app.wot_lookup.tab_registry")})),e.$on("$ionicView.beforeLeave",(function(t,n){e.$broadcast("$recordView.beforeLeave",n)})),e.load=function(t,o){return t=t||e.id,e.loading=!0,i.all([p.record.load(t).then((function(t){e.id=t.id,e.formData=t.record,e.canEdit=u.isUserPubkey(e.formData.issuer)||u.children.hasPubkey(e.formData.issuer),e.showTransfer=!e.canEdit&&e.formData.pubkey,e.issuer=t.issuer,e.avatar=e.formData.avatar,e.avatarStyle=e.formData.avatar&&{"background-image":'url("'+e.avatar.src+'")'},m.loading.hide(),e.loading=!1,e.motion.show({selector:".list > .item, .list > ng-if > .item"})})).catch((function(a){e.secondTry?(e.loading=!1,a&&404===a.ucode?(m.toast.show("REGISTRY.ERROR.RECORD_NOT_EXISTS"),n.go("app.wot_lookup.tab_registry")):m.onError("REGISTRY.ERROR.LOAD_RECORD_FAILED")(a)):(e.secondTry=!0,i((function(){e.load(t)}),100))})),p.record.picture.all({id:t}).then((function(t){e.pictures=t._source.pictures&&t._source.pictures.reduce((function(e,t){return e.concat(E.image.fromAttachment(t.file))}),[]),e.pictures.length>0&&e.motion.show({selector:".lazy-load .item.card-gallery",startVelocity:3e3})})).catch((function(){e.pictures=[]})),a((function(){return e.$broadcast("$recordView.load",t,p.record.comment)}))]).then((function(){e.motion.show({selector:".lazy-load .item",startVelocity:3e3}),o&&a((function(){c(o)}),1e3)}))},e.edit=function(){var t=u.isUserPubkey(e.formData.issuer)?u:u.children.getByPubkey(e.formData.issuer);if(t)return m.loading.show(),n.go("app.registry_edit_record",{id:e.id,wallet:t.id})},e.delete=function(){e.hideActionsPopover();var t,i=u.isUserPubkey(e.formData.issuer)?u:u.children.getByPubkey(e.formData.issuer);i&&s(["REGISTRY.VIEW.REMOVE_CONFIRMATION","REGISTRY.INFO.RECORD_REMOVED"]).then((function(e){return t=e,m.alert.confirm(e["REGISTRY.VIEW.REMOVE_CONFIRMATION"])})).then((function(a){a&&p.record.remove(e.id,{wallet:i}).then((function(){i.data.pages&&i.data.pages.count&&i.data.pages.count--,r.nextViewOptions({historyRoot:!0}),i.isDefault()?n.go("app.wallet_pages",{refresh:!0}):n.go("app.wallet_pages_by_id",{refresh:!0,id:i.id}),m.toast.show(t["REGISTRY.INFO.RECORD_REMOVED"])})).catch(m.onError("REGISTRY.ERROR.REMOVE_RECORD_FAILED"))}))},e.showActionsPopover=function(t){m.popover.show(t,{templateUrl:"plugins/es/templates/registry/view_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){return e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null),!0},e.showSharePopover=function(i){e.hideActionsPopover();var a=e.formData.title,o=(d.shareBaseUrl||t.rootPath)+n.href("app.view_page",{title:a,id:e.id});m.screen.isSmall()&&(i=angular.element(document.querySelector("#registry-share-anchor-"+e.id))||i),m.popover.share(i,{bindings:{url:o,titleKey:"REGISTRY.VIEW.POPOVER_SHARE_TITLE",titleValues:{title:a},time:e.formData.time,postMessage:a}})}}function _e(e,t,n,i,a,o,r,s,l,c,d,u,p,m){var E;angular.extend(this,s("ESPositionEditCtrl",{$scope:e})),e.formData={title:null,description:null,socials:[],geoPoint:null},e.loading=!0,e.dirty=!1,e.walletData=null,e.id=null,e.avatar=null,e.pictures=[],e.setForm=function(t){e.form=t},e.$on("$ionicView.enter",(function(t,n){if(e.loading)return(E=n.stateParams&&n.stateParams.wallet&&"default"!=n.stateParams.wallet?u.children.get(n.stateParams.wallet):u)?E.login({minData:!0}).then((function(t){e.walletData=t,n.stateParams&&n.stateParams.id?e.load(n.stateParams.id):n.stateParams&&n.stateParams.type&&e.updateView({record:{type:n.stateParams.type}}),o("registry-record-title")})):(c.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome())})),e.$on("$stateChangeStart",(function(t,i,o,r){if(e.dirty&&!e.saving&&(t.preventDefault(),!e.loading))return e.loading=!0,c.alert.confirm("CONFIRM.SAVE_BEFORE_LEAVE","CONFIRM.SAVE_BEFORE_LEAVE_TITLE",{cancelText:"COMMON.BTN_NO",okText:"COMMON.BTN_YES_SAVE"}).then((function(t){return e.loading=!1,t?(e.form.$submitted=!0,e.save(!1,!0).then((function(t){return t&&(e.dirty=!1),t}))):(e.dirty=!1,!0)})).then((function(e){e&&(a.nextViewOptions({historyRoot:!0}),n.go(i.name,o))})).catch((function(e){}))})),e.load=function(t){e.loading=!0,m.record.load(t,{raw:!0}).then((function(t){t&&t.record?e.updateView(t):e.updateView({record:{}})})).catch((function(t){c.loading.hide(10),e.loading=!1,c.onError("REGISTRY.ERROR.LOAD_RECORD_FAILED")(t)}))},e.updateView=function(n){e.formData=n.record||{},e.id=n.id,e.avatar=e.formData.avatar,e.avatar?(e.avatarStyle=e.avatar&&{"background-image":'url("'+e.avatar.src+'")'},e.avatarClass={}):(e.avatarStyle=void 0,e.avatarClass={},e.avatarClass["cion-page-"+e.formData.type]=!e.avatar),e.pictures=n.record&&n.record.pictures||[],delete n.record.pictures,e.motion.show({selector:".animate-ripple .item, .card-gallery",startVelocity:3e3}),c.loading.hide(),t((function(){e.loading=!1}),1e3)},e.onFormDataChanged=function(){e.loading||(e.dirty=!0)},e.$watch("formData",e.onFormDataChanged,!0),e.needCategory=function(){return e.formData.type&&("company"==e.formData.type||"shop"==e.formData.type)},e.save=function(o,s){return e.form.$submitted=!0,!e.saving&&e.form.$valid&&("shop"!==e.formData.type&&"company"!==e.formData.type||e.formData.category&&e.formData.category.id)?s?(e.saving=!0,console.debug("[ES] [page] Saving record..."),i.when().then((function(){var t=e.formData;return e.needCategory()||delete t.category,t.time=moment().utc().unix(),t.geoPoint&&t.geoPoint.lat&&t.geoPoint.lon?(t.geoPoint.lat=parseFloat(t.geoPoint.lat),t.geoPoint.lon=parseFloat(t.geoPoint.lon)):t.geoPoint=null,t.socials&&t.socials.length&&(t.socials=_.uniq(t.socials,!1,(function(e){return e.url}))),t.picturesCount=e.pictures.length,t.picturesCount>0?t.pictures=e.pictures.reduce((function(e,t){return e.concat({file:p.image.toAttachment(t)})}),[]):t.pictures=[],e.avatar&&e.avatar.src?c.image.resizeSrc(e.avatar.src,!0).then((function(e){return t.avatar=p.image.toAttachment({src:e}),t})):(t.avatar={_content:"",_content_type:""},t)})).then((function(t){return e.id?m.record.update(t,{id:e.id,wallet:E}):m.record.add(t,{wallet:E})})).then((function(t){return console.info("[ES] [page] Record successfully saved."),!e.id&&E.data.pages&&E.data.pages.count&&u.data.pages.count++,e.id=e.id||t,e.saving=!1,e.dirty=!1,o||r("REGISTRY.INFO.RECORD_SAVED").then((function(e){c.toast.show(e)})),a.clearCache(a.currentView().stateId),a.nextViewOptions({historyRoot:!0}),n.go("app.view_page",{id:e.id,refresh:!0})})).catch((function(t){e.saving=!1,c.onError("REGISTRY.ERROR.SAVE_RECORD_FAILED")(t)}))):(console.debug("[ES] [page] Waiting debounce end, before saving..."),t((function(){return e.save(o,!0)}),650)):i.reject()},e.openPicturePopup=function(){l.camera.getPicture().then((function(t){t&&e.pictures.push({src:"data:image/png;base64,"+t})})).catch(c.onError("ERROR.TAKE_PICTURE_FAILED"))},e.rotateAvatar=function(){if(e.avatar&&e.avatar.src&&!e.rotating)return e.rotating=!0,c.image.rotateSrc(e.avatar.src).then((function(t){e.avatar.src=t,e.avatarStyle={"background-image":'url("'+t+'")'},e.dirty=!0,e.rotating=!1})).catch((function(t){console.error(t),e.rotating=!1}))},e.fileChanged=function(t){return c.loading.show(),i((function(n,i){var a=t.target.files[0];c.image.resizeFile(a).then((function(t){e.pictures.push({src:t}),c.loading.hide(),n()}))}))},e.removePicture=function(t){e.pictures.splice(t,1)},e.favoritePicture=function(t){if(t>0){var n=e.pictures[t];e.pictures.splice(t,1),e.pictures.splice(0,0,n)}},e.cancel=function(){a.goBack()},e.showAvatarModal=function(){return l.camera.enable?l.camera.getPicture().then((function(t){t&&(e.avatar={src:"data:image/png;base64,"+t},e.avatarStyle={"background-image":'url("'+t+'")'},e.dirty=!0,e.avatarClass={})})).catch(c.onError("ERROR.TAKE_PICTURE_FAILED")):d.show("plugins/es/templates/common/modal_edit_avatar.html","ESAvatarModalCtrl",{}).then((function(t){t&&(e.avatar={src:t},e.avatarStyle={"background-image":'url("'+t+'")'},e.dirty=!0,e.avatarClass={})}))},e.showRecordTypeModal=function(){d.show("plugins/es/templates/registry/modal_record_type.html").then((function(t){t&&(e.formData.type=t,e.avatar||(e.avatarClass["cion-page-"+t]=!0))}))},e.showCategoryModal=function(t){m.category.all().then((function(e){return d.show("plugins/es/templates/common/modal_category.html","ESCategoryModalCtrl as ctrl",{categories:e},{focusFirstInput:!0})})).then((function(t){t&&t.parent&&(e.formData.category=t)}))}}function he(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E){var b;angular.extend(this,r("ESPositionEditCtrl",{$scope:e})),e.formData={title:null,description:null,socials:[],geoPoint:null},e.loading=!0,e.dirty=!1,e.walletData=null,e.avatar=null,e.existing=!1,e.socialData={url:null},e.socialReorder=!0,e.enter=function(t,n){return(b=n.stateParams&&n.stateParams.id?d.children.get(n.stateParams.id):d)?(e.walletId=b.id,b.auth({minData:!0}).then(e.load).catch((function(t){if("CANCELLED"==t)return c.loading.hide(10),void e.cancel();c.onError("PROFILE.ERROR.LOAD_PROFILE_FAILED")(t)}))):(c.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome())},e.$on("$ionicView.enter",e.enter),e.$on("$stateChangeStart",(function(t,n,a,o){if(e.dirty&&!e.saving&&(t.preventDefault(),!e.loading))return e.loading=!0,c.alert.confirm("CONFIRM.SAVE_BEFORE_LEAVE","CONFIRM.SAVE_BEFORE_LEAVE_TITLE",{cancelText:"COMMON.BTN_NO",okText:"COMMON.BTN_YES_SAVE"}).then((function(t){return e.loading=!1,t?(e.form.$submitted=!0,e.save(!1,!0).then((function(t){return t&&(e.dirty=!1),t}))):(e.dirty=!1,!0)})).then((function(e){e&&(s.nextViewOptions({historyRoot:!0}),i.go(n.name,a))})).catch((function(e){}))})),e.load=function(t){return e.loading=!0,p.get(t.pubkey,{raw:!0}).then((function(i){return i?(e.avatar=u.image.fromAttachment(i.source.avatar),e.existing=!0,e.updateView(t,i.source)):(e.avatar=void 0,e.existing=!1,e.updateView(t,{})),c.loading.hide(),n((function(){e.loading=!1}),1e3)})).then((function(){a("profile-name")})).catch(c.onError("PROFILE.ERROR.LOAD_PROFILE_FAILED"))},e.setForm=function(t){e.form=t},e.updateView=function(t,n){e.walletData=t,e.formData=n,n.avatar&&(e.avatarStyle={"background-image":'url("'+e.avatar.src+'")'}),e.motion.show()},e.onFormDataChanged=function(){e.loading||(e.dirty=!0)},e.$watch("formData",e.onFormDataChanged,!0),e.save=function(i,a){if(e.form.$invalid||!e.walletData||e.saving&&!a)return t.reject();if(!a)return e.saving=!0,n((function(){return e.save(i,!0)}),650);console.debug("[ES] [profile] Saving user profile...");var r=function(t){return function(n){e.saving=!1,c.onError(t)(n)}},s=function(t){t&&(e.walletData.name=t.title,e.avatar?e.walletData.avatar=e.avatar:delete e.walletData.avatar,e.walletData.profile=angular.copy(t),e.walletData.profile.descriptionHtml=u.util.parseAsHtml(t.description))},l=function(){if(!i)return o("PROFILE.INFO.PROFILE_SAVED").then((function(e){c.toast.show(e)}))},d=function(t){return t.socials&&t.socials.length&&(t.socials=_.uniq(t.socials,!1,(function(e){return e.url}))),t.position&&(t.position=null),t.geoPoint&&t.geoPoint.lat&&t.geoPoint.lon?(t.geoPoint.lat=parseFloat(t.geoPoint.lat),t.geoPoint.lon=parseFloat(t.geoPoint.lon)):t.geoPoint=null,e.existing?p.update(t,{id:e.walletData.pubkey,wallet:b}).then((function(){return console.info("[ES] Profile successfully updated."),e.saving=!1,e.dirty=!1,s(t),l(),!0})).catch(r("PROFILE.ERROR.SAVE_PROFILE_FAILED")):p.add(t,{wallet:b}).then((function(){return console.info("[ES] [profile] Successfully created."),e.existing=!0,e.saving=!1,e.dirty=!1,s(t),l(),!0})).catch(r("PROFILE.ERROR.SAVE_PROFILE_FAILED"))};return e.avatar&&e.avatar.src?c.image.resizeSrc(e.avatar.src,!0).then((function(t){return e.formData.avatar=u.image.toAttachment({src:t}),d(e.formData)})):(delete e.formData.avatar,d(e.formData))},e.saveAndClose=function(){return e.save().then((function(t){t&&e.close()}))},e.submitAndSaveAndClose=function(){e.form.$submitted=!0,e.saveAndClose()},e.cancel=function(){return e.dirty=!1,b.isDefault()?(s.nextViewOptions({historyRoot:!0}),i.go("app.view_wallet")):i.go("app.view_wallet_by_id",{id:b.id})},e.close=function(){return b.isDefault()?(s.nextViewOptions({historyRoot:!0}),i.go("app.view_wallet",{refresh:!0})):i.go("app.view_wallet_by_id",{refresh:!0,id:b.id})},e.showAvatarModal=function(){return E.camera.enable?E.camera.getPicture().then((function(t){t&&(e.avatar={src:"data:image/png;base64,"+t},e.avatarStyle={"background-image":'url("'+t+'")'},e.dirty=!0)})).catch(c.onError("ERROR.TAKE_PICTURE_FAILED")):m.show("plugins/es/templates/common/modal_edit_avatar.html","ESAvatarModalCtrl",{}).then((function(t){t&&(e.avatar={src:t},e.avatarStyle={"background-image":'url("'+t+'")'},e.dirty=!0)}))},e.rotateAvatar=function(){if(e.avatar&&e.avatar.src&&!e.rotating)return e.rotating=!0,c.image.rotateSrc(e.avatar.src).then((function(t){e.avatar.src=t,e.avatarStyle={"background-image":'url("'+t+'")'},e.dirty=!0,e.rotating=!1})).catch((function(t){console.error(t),e.rotating=!1}))},e.removeProfile=function(){return e.hideActionsPopover(),e.existing&&b.auth({minData:!0}).then((function(t){c.loading.hide(),c.alert.confirm("PROFILE.CONFIRM.DELETE",void 0,{okText:"COMMON.BTN_DELETE"}).then((function(i){if(i)return console.debug("[ES] [profile] Deleting user profile..."),p.remove(t.pubkey,{wallet:b}).then((function(){return b.isDefault()&&(t.name=null),t.profile=null,t.avatar=null,console.debug("[ES] [profile] Successfully deleted"),e.dirty=!1,e.close()})).then((function(){return n((function(){c.toast.show("PROFILE.INFO.PROFILE_REMOVED")}),750)})).catch(c.onError("PROFILE.ERROR.REMOVE_PROFILE_FAILED"))}))}))},e.showActionsPopover=function(t){c.popover.show(t,{templateUrl:"plugins/es/templates/user/edit_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)}}function Te(e,t,n,i,a,o,r,s,l,c){var d,u=!1;e.search={loading:!0,results:[],hasMore:!1,loadingMore:!1,limit:40,type:"last",text:null,options:{}},e.fabButtonNewMessageId=void 0,e.enter=function(t,n){if(e.search.loading){if(!(d=n.stateParams&&n.stateParams.id?r.children.get(n.stateParams.id):r))return l.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome();e.isDefaultWallet=d.isDefault(),e.walletId=d.id,d.auth({minData:!0}).then((function(){e.entered||(e.entered=!0,e.type=e.type||n.stateParams&&n.stateParams.type||"inbox",e.load()),e.fabButtonNewMessageId&&e.showFab(e.fabButtonNewMessageId)})).catch((function(t){"CANCELLED"===t&&(i.nextViewOptions({historyRoot:!0}),e.showHome())}))}else e.updateView()},e.$on("$ionicView.enter",e.enter),e.load=function(t,n,i){var a=angular.copy(e.search.options);return a.from=a.from||t||0,a.size=a.size||n||40,a.type=e.type,a.summary=!1,a.filter="text"==e.search.type&&e.search.text&&e.search.text.trim().length>0?e.search.text:void 0,a.wallet=d,e.search.loading=!i,c.load(a).then((function(t){a.from?t&&(e.search.results=e.search.results.concat(t)):e.search.results=t||[],l.loading.hide(),e.search.loading=!1,e.search.hasMore=e.search.results&&e.search.results.length>=e.search.limit,e.updateView()})).catch((function(t){e.search.loading=!1,a.from||(e.search.results=[]),e.search.hasMore=!1,l.onError("MESSAGE.ERROR.LOAD_MESSAGES_FAILED")(t)}))},e.updateView=function(){e.motion&&e.motion.ionListClass&&e.search.results.length&&e.motion.show({selector:".view-messages .list .item"}),e.$broadcast("$$rebind::rebind")},e.showMore=function(){e.search.limit=e.search.limit||40,e.search.limit+=40,e.search.limit<40&&(e.search.limit=40),e.search.loadingMore=!0,e.load(e.search.results.length,e.search.limit,!0).then((function(){e.search.loadingMore=!1,e.$broadcast("scroll.infiniteScrollComplete")}))},e.markAllAsRead=function(){e.hideActionsPopover(),e.search.results&&e.search.results.length&&l.alert.confirm("MESSAGE.CONFIRM.MARK_ALL_AS_READ").then((function(t){t&&c.markAllAsRead().then((function(){_.forEach(e.search.results,(function(e){e.read=!0}))})).catch(l.onError("MESSAGE.ERROR.MARK_ALL_AS_READ_FAILED"))}))},e.delete=function(t){var n=e.search.results[t];n&&l.alert.confirm("MESSAGE.CONFIRM.REMOVE").then((function(i){i&&c.remove(n.id,e.type,{walletId:e.walletId}).then((function(){e.search.results.splice(t,1),e.updateView(),l.toast.show("MESSAGE.INFO.MESSAGE_REMOVED")})).catch(l.onError("MESSAGE.ERROR.REMOVE_MESSAGE_FAILED"))}))},e.deleteAll=function(){e.hideActionsPopover(),e.search.results&&e.search.results.length&&l.alert.confirm("MESSAGE.CONFIRM.REMOVE_ALL").then((function(t){t&&c.removeAll(e.type,{walletId:e.walletId}).then((function(){e.search.results.splice(0,e.search.results.length),e.updateView(),l.toast.show("MESSAGE.INFO.All_MESSAGE_REMOVED")})).catch(l.onError("MESSAGE.ERROR.REMOVE_All_MESSAGES_FAILED"))}))},e.doSearchLast=function(){return e.search.type="last",e.search.loadingMore=!1,e.search.limit=40,e.load()},e.doSearch=function(){if(e.search.text&&!(e.search.text.length<3))return e.search.type="text",e.search.loadingMore=!1,e.search.results=[],e.search.limit=40,console.debug("[message] [{0}] Searching for: {1}".format(e.type,e.search.text)),e.load()},e.refresh=function(t){return u=!0,e.load(void 0,void 0,t).then((function(){u=!1})).catch((function(){u=!1}))},e.select=function(n,i){if(!(i.isDefaultPrevented()||e.search.loading||u))return o((function(){if(!u&&!i.isDefaultPrevented())return i.preventDefault(),"default"===e.walletId?t.go("app.user_view_message",{type:e.type,messageId:n.id}):t.go("app.user_view_message_by_id",{type:e.type,messageId:n.id,id:e.walletId})}),200)},e.showNewMessageModal=function(t){return d.login({minData:!0}).then((function(){return l.loading.hide(),(t=t||{}).wallet=e.walletId,s.showMessageCompose(t).then((function(e){e&&l.toast.show("MESSAGE.INFO.MESSAGE_SENT")}))}))},e.showReplyModal=function(t){var i=e.search.results[t];i&&n("MESSAGE.REPLY_TITLE_PREFIX").then((function(t){var n=i.content?i.content.replace(/^/g," > "):null;return n=(n=n?n.replace(/\n/g,"\n > "):null)?n+"\n":null,s.showMessageCompose({destPub:i.issuer,destUid:i.name||i.uid,title:t+i.title,content:n,isReply:!0,wallet:e.walletId})})).then((function(e){e&&l.toast.show("MESSAGE.INFO.MESSAGE_SENT")}))},e.showActionsPopover=function(t){l.popover.show(t,{templateUrl:"plugins/es/templates/message/lookup_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.onMessageDelete=function(t){var n=_.findIndex(e.search.results,(function(e){return e.id==t}));n&&e.search.results.splice(n,1),e.updateView()},c.api.data.on.delete(e,e.onMessageDelete),e.onNewOutboxMessage=function(t){if("outbox"===e.type)return e.search.loading=!0,o((function(){return c.get(t,e.type,{summary:!0,wallet:d})}),500).then((function(t){e.search.results.splice(0,0,t),e.search.loading=!1,e.updateView()})).catch((function(){e.loading=!1}))},c.api.data.on.sent(e,e.onNewOutboxMessage),e.onNewInboxMessage=function(t){if("inbox"===e.type&&e.entered&&d.isUserPubkey(t.issuer))return e.search.loading=!0,c.get(t.id,e.type,{summary:!0,wallet:d}).then((function(t){e.search.results.splice(0,0,t),e.search.loading=!1,e.updateView()})).catch((function(){e.search.loading=!1}))},c.api.data.on.new(e,e.onNewInboxMessage),e.onUnauth=function(){e.search.results=void 0,e.search.loading=!1,e.entered=!1},r.api.data.on.unauth(e,e.onUnauth)}function ve(e,t){angular.extend(this,t("ESMessageAbstractListCtrl",{$scope:e})),e.type="inbox",e.fabButtonNewMessageId="fab-add-message-record-inbox"}function Ie(e,t){angular.extend(this,t("ESMessageAbstractListCtrl",{$scope:e})),e.type="outbox",e.fabButtonNewMessageId="fab-add-message-record-outbox"}function Oe(e,t){angular.extend(this,t("ESMessageComposeModalCtrl",{$scope:e,parameters:{}})),e.enter=function(t,n){return n&&n.stateParams&&e.setParameters(n.stateParams),e.load().then(UIUtils.loading.hide)},e.$on("$ionicView.enter",e.enter),e.cancel=function(){e.sending=!1,e.showHome()},e.setForm=function(t){e.form=t},e.closeModal=function(){e.sending=!1,e.showHome()}}function Ne(e,t,n,i,a,o,r){var s;e.formData={title:null,content:null,destPub:null,walletId:null},e.destUid=null,e.destPub=null,e.isReply=!1,e.enableSelectWallet=!0,e.sending=!1,e.setParameters=function(t){t&&((t.pubkey||t.destPub)&&(e.formData.destPub=t.pubkey||t.destPub,t.uid||t.destUid?(e.destUid=t.uid||t.destUid,e.destPub=""):(e.destUid="",e.destPub=e.formData.destPub)),t.title&&(e.formData.title=t.title),t.content&&(e.formData.content=t.content),e.isReply=t.isReply||!1,t.wallet&&(e.formData.walletId=t.wallet))},e.setParameters(r),e.load=function(){return e.enableSelectWallet=i.children.count()>0,(s=e.enableSelectWallet&&(e.formData.walletId?i.children.get(e.formData.walletId):i)||i).isDefault()?console.debug("[message] Using default wallet"):console.debug("[message] Using {"+s.id+"} wallet"),s.login({minData:!0,silent:!0}).then((function(t){e.walletData=t})).catch((function(t){"CANCELLED"===t&&e.cancel()}))},e.$on("modal.shown",e.load),e.doSend=function(t){if(e.form.$submitted=!0,e.form.$valid){if(!(t||e.formData.content&&e.formData.content.trim().length))return n.alert.confirm("MESSAGE.COMPOSE.CONTENT_CONFIRMATION").then((function(t){t&&e.doSend(!0)}));e.sending=!0,n.loading.show();var i={issuer:s.data.pubkey,recipient:e.formData.destPub,title:e.formData.title,content:e.formData.content,time:moment().utc().unix()};o.send(i,{wallet:s}).then((function(t){e.id=t,n.loading.hide(),e.closeModal(t)})).catch((function(t){e.sending=!1,"CANCELLED"!==t?n.onError("MESSAGE.ERROR.SEND_MSG_FAILED")(t):n.loading.hide()}))}},e.cancel=function(){e.closeModal()},e.showWotLookupModal=function(){t.showWotLookup().then((function(t){t&&(t.uid?(e.destUid=t.uid,e.destPub=""):(e.destUid="",e.destPub=t.pubkey),e.destName=t.name||t.uid,e.formData.destPub=t.pubkey)}))},e.showSelectWalletModal=function(){if(e.enableSelectWallet)return t.showSelectWallet({showDefault:!0,showBalance:!1}).then((function(t){!t||s&&s.id===t.id||(s=t,e.walletData=s.data,console.debug("[message] Using {"+s.id+"} wallet"))}))}}function Re(e,t,n,i,a,o,r,s,l,c){var d;e.formData={},e.id=null,e.loading=!0,e.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!r.screen.isSmall()||t.enableBack})),e.enter=function(t,i){if(e.loading){if(!(d=i.stateParams&&i.stateParams.id?c.children.get(i.stateParams.id):c))return r.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome();e.isDefaultWallet=d.isDefault(),e.walletId=d.id;var a=i.stateParams&&i.stateParams.messageId;if(e.type=i.stateParams.type||"inbox",angular.isUndefined(a))return void e.goBack();d.auth({minData:!0}).then((function(){return e.load(a,e.type)})).then((function(t){r.loading.hide(),t&&(e.updateView(t),e.showFab("fab-view-message-reply"),t.read||n((function(){e.id===t.id&&l.markAsRead(t,{type:e.type,wallet:d}).then((function(){console.debug("[message] marked as read")})).catch(r.onError("MESSAGE.ERROR.MARK_AS_READ_FAILED"))}),2e3))}))}},e.$on("$ionicView.enter",e.enter),e.load=function(t,n){return n=n||"inbox",l.get(t,n,{wallet:d}).catch(r.onError("MESSAGE.ERROR.LOAD_MESSAGE_FAILED")).then((function(t){return t.valid?t:r.alert.error(e.isUserPubkey(t.recipient)?"MESSAGE.ERROR.NOT_AUTHENTICATED_MESSAGE":"MESSAGE.ERROR.USER_NOT_RECIPIENT","MESSAGE.ERROR.MESSAGE_NOT_READABLE").then((function(){e.goBack(!0)}))}))},e.updateView=function(t){e.loading=!1,e.id=t.id,e.formData=t,e.canDelete=!0,e.motion.show({selector:".view-message .list .item"})},e.delete=function(){e.actionsPopover&&e.actionsPopover.hide(),r.alert.confirm("MESSAGE.CONFIRM.REMOVE").then((function(t){if(t)return l.remove(e.id,e.type,{wallet:d}).then((function(){e.goBack(!0),r.toast.show("MESSAGE.INFO.MESSAGE_REMOVED")})).catch(r.onError("MESSAGE.ERROR.REMOVE_MESSAGE_FAILED"))}))},e.goBack=function(n){n&&a.clearCache(a.currentView().stateId),a.nextViewOptions({historyRoot:!0}),e.isDefaultWallet?e.type&&t.go("app.user_message.tab_"+e.type,{type:e.type}):e.type&&t.go("app.user_messages_by_id.tab_"+e.type,{type:e.type,id:e.walletId})},e.showActionsPopover=function(t){r.popover.show(t,{templateUrl:"plugins/es/templates/message/view_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.showReplyModal=function(){var t="inbox"===e.type?"issuer":"recipient";i("MESSAGE.REPLY_TITLE_PREFIX").then((function(n){var i=e.formData.content?e.formData.content.replace(/^/g," > "):null;return i=(i=i?i.replace(/\n/g,"\n > "):null)?i+"\n":null,s.showMessageCompose({destPub:e.formData[t],destUid:e.formData.name||e.formData.uid,title:n+e.formData.title,content:i,isReply:!0,walletId:d.id})})).then((function(e){e&&r.toast.show("MESSAGE.INFO.MESSAGE_SENT").then((function(){a.goBack()}))}))}}function Ae(e,t,n,i,a,o,r,s){var l;e.search={loading:!0,results:null,hasMore:!1,loadingMore:!1,limit:40},e.$on("popover.shown",(function(){e.search.loading&&((l=e.walletId&&i.children.get(e.walletId)||i).isDefault()&&(l.api.data.on.logout(e,e.resetData),o.api.data.on.new(e,e.onNewMessageNotification)),e.load())})),e.load=function(n,i){var a={};return a.from=n||0,a.size=i||40,o.notifications.load(a).then((function(t){e.search.results=n?e.search.results.concat(t):t,e.search.loading=!1,e.search.hasMore=e.search.results&&e.search.results.length>=e.search.limit,e.updateView()})).catch((function(i){e.search.loading=!1,n||(e.search.results=[]),e.search.hasMore=!1,t.onError("MESSAGE.ERROR.LOAD_NOTIFICATIONS_FAILED")(i)}))},e.updateView=function(){e.motion&&e.search.results&&e.search.results.length&&e.motion.show({selector:".popover-notification .item"})},e.showMore=function(){e.search.limit=e.search.limit||40,e.search.limit=2*e.search.limit,e.search.limit<40&&(e.search.limit=40),e.search.loadingMore=!0,e.load(e.search.results.length,e.search.limit).then((function(){e.search.loadingMore=!1,e.$broadcast("scroll.infiniteScrollComplete")}))},e.onNewMessageNotification=function(t){e.search.loading||e.search.loadingMore||l.isUserPubkey(t.issuer)&&(e.search.results.splice(0,0,t),e.updateView())},e.select=function(t){t.read||(t.read=!0),"default"===e.walletId?n.go("app.user_view_message",{messageId:t.id}):n.go("app.user_view_message_by_id",{messageId:t.id,id:e.walletId}),e.closePopover(t)},e.resetData=function(){e.search.loading||(console.debug("[ES] [messages] Resetting data (settings or account may have changed)"),e.search.hasMore=!1,e.search.results=[],e.search.loading=!0,delete e.search.limit)},e.showNewMessageModal=function(n){e.closePopover(),s((function(){(n=n||{}).walletId=l.id,r.showMessageCompose(n).then((function(e){e&&t.toast.show("MESSAGE.INFO.MESSAGE_SENT")}))}),500)},a.api.node.on.stop(e,e.resetData),a.api.node.on.start(e,e.load)}function Se(e,t,n,i,a,o,r,s){var l;e.preventSelect=!1,e.search={loading:!0,results:null,hasMore:!1,loadingMore:!1,limit:40,options:{codes:{excludes:s.constants.EXCLUDED_CODES}}},e.listeners=[],e.setWallet=function(e){l=e},e.$on("$ionicView.enter",(function(t,n){if(e.search.loading){if(!(l=n.stateParams&&n.stateParams.id?r.children.get(n.stateParams.id):r))return a.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome();l.login({minData:!0}).then((function(){return e.load(),a.loading.hide(),e.addListeners(),i((function(){e.resetUnreadCount()}),1e3)}))}})),e.refresh=function(t){return e.load(void 0,void 0,t)},e.load=function(t,n,i){if((l=l||r).data.pubkey){e.search.preventSelect=!0;var o=angular.copy(e.search.options);return o.from=o.from||t||0,o.size=o.size||n||40,o.pubkey=l.data.pubkey,e.search.loading=!i,s.load(o).then((function(t){o.from?t&&(e.search.results=e.search.results.concat(t)):e.search.results=t||[],e.search.loading=!1,e.search.preventSelect=!1,e.search.hasMore=e.search.results.length>=e.search.limit,e.updateView()})).catch((function(t){e.search.loading=!1,o.from||(e.search.results=[]),e.search.preventSelect=!1,e.search.hasMore=!1,a.onError("COMMON.NOTIFICATIONS.LOAD_NOTIFICATIONS_FAILED")(t)}))}e.search.loading=!0},e.updateView=function(){e.motion&&e.motion.ionListClass&&e.search.results.length&&e.motion.show({selector:".view-notification .item"})},e.markAllAsRead=function(){if(e.hideActionsPopover(),!l.isAuth())return l.auth().then((function(){return a.loading.hide(),e.markAllAsRead()}));e.search.results.length&&a.loading.show().then((function(){l.data.notifications.unreadCount=0;var t=e.search.results[0];return l.data.notifications.time=t?t.time:0,_.forEach(e.search.results,(function(e){e.markAsRead&&"function"==typeof e.markAsRead&&e.markAsRead()})),a.loading.hide()}))},e.resetUnreadCount=function(){if(e.search.loading||!l.data.notifications)return i(e.resetUnreadCount,2e3);if(l.data.notifications.unreadCount&&e.search.results&&e.search.results.length){l.data.notifications.unreadCount=0;var t=e.search.results[0],n=t.time?t.time:0;!n||l.data.notifications.time&&l.data.notifications.time==n||(l.data.notifications.time=n,l.storeData())}},e.select=function(t,a){e.search.loading||t.preventDefault()||e.search.preventSelect||(a.markAsRead&&"function"==typeof a.markAsRead&&i(a.markAsRead),a.state&&n.go(a.state,a.stateParams))},e.showMore=function(){e.search.limit=e.search.limit||40,e.search.limit+=40,e.search.limit<40&&(e.search.limit=40),e.search.loadingMore=!0,e.load(e.search.results.length,e.search.limit).then((function(){e.search.loadingMore=!1,e.$broadcast("scroll.infiniteScrollComplete")}))},e.onNewNotification=function(t){if(!e.search.loading&&!e.search.loadingMore){var n=_.findIndex(e.search.results,(function(e){return t.time>e.time}));n<0&&(n=0),e.search.results.splice(n,0,t),e.updateView()}},e.resetData=function(){e.search.loading||(console.debug("[ES] [notifications] Resetting data (settings or account may have changed)"),e.search.hasMore=!1,e.search.results=[],e.search.loading=!0,delete e.search.limit)},e.showActionsPopover=function(t){a.popover.show(t,{templateUrl:"plugins/es/templates/notification/popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.addListeners=function(){if(!l)throw"Controller wallet not set !";e.listeners=[o.api.node.on.stop(e,e.resetData),o.api.node.on.start(e,e.load),l.api.data.on.logout(e,e.resetData)],l.isDefault()&&e.listeners.push(s.api.data.on.new(e,e.onNewNotification))},e.removeListeners=function(){_.forEach(e.listeners,(function(e){e()})),e.listeners=[]}}function Ce(e,t,n,i,a,o){angular.extend(this,n("NotificationsCtrl",{$scope:e})),e.motion=null,e.setWallet(o),e.$on("popover.shown",(function(){e.search.loading&&(e.addListeners(),e.load())})),e.updateView=function(){e.search.results.length&&t((function(){a.ink({selector:".popover-notification .item.ink"})}),100)},e.$on("popover.hidden",e.resetUnreadCount),e.select=function(t,n){!t.preventDefault()&&n&&(n.markAsRead&&"function"==typeof n.markAsRead&&n.markAsRead(),n.state&&i.go(n.state,n.stateParams),e.closePopover(n))}}function Le(e,t,n,i,a,o){angular.extend(this,t("BlockLookupCtrl",{$scope:e})),e.search.text=null,e.search.type="last",e.search.sort=void 0,e.search.asc=!0,e.searchTextId="blockchainSearchText",e.compactMode=!0,e.enableFilter=!0,e.doSearchText=function(){if(!(e.search.text&&e.search.text.trim().length||e.search.filters&&e.search.filters.length))return e.doSearchLast();e.search.type="text",e.doSearch(),i.search({q:e.search.query}).replace()},e.doSearchLast=function(){e.hideActionsPopover(),e.search.type="last",e.search.sort=void 0,e.doSearch(),i.search({q:void 0}).replace()},e.doSearch=function(t){if(!e.search.error){var n;t=angular.isDefined(t)?t:0;var i={};if(e.search.loading=0===t,i.size=e.defaultSizeLimit,"last"==e.search.type)i.from=0===t?0:t+1,e.search.sort?(i.sort={},i.sort[e.search.sort]=e.search.asc?"asc":"desc"):i.sort={number:"desc"},i.excludeCurrent=0===t,n=o.block.search(e.currency,i);else if("text"==e.search.type){var r=o.block.parseSearchText(e.search.text,e.search.filters);e.search.filters=r.filters;var s=e.search.filters.reduce((function(e,t){return e+" AND "+t.text}),"");r.text.length&&(s+=" AND "+r.text),e.search.query=s.substr(5),e.search.text=r.text,i.from=t,e.search.sort?i.sort=e.search.sort+":"+(e.search.asc?"asc":"desc"):i.sort="number:desc",i.excludeCurrent=!0,n=o.block.searchText(e.currency,e.search.query,i)}var l=Date.now();return n.then((function(t){return e.doPrepareResult(t.hits).then((function(){return t}))})).then((function(n){e.showPubkey="issuer"==e.search.sort,e.search.took=0===t?Date.now()-l:e.search.took;var i=0===t?n.total:e.search.total;e.doDisplayResult(n.hits,t,i),e.search.loading=!1})).catch((function(t){e.search.error=!0,e.search.loading=!1,a.onError("BLOCKCHAIN.ERROR.SEARCH_BLOCKS_FAILED")(t).then((function(){e.search.error=!1}))}))}},e.toggleSort=function(t){e.search.sort!==t||e.search.asc?(e.search.asc=e.search.sort!==t||!e.search.asc,e.search.sort=t):(e.search.asc=void 0,e.search.sort=void 0),e.doSearch()},e.showHelpTip=function(){},e.showActionsPopover=function(t){a.popover.show(t,{templateUrl:"plugins/es/templates/blockchain/lookup_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.itemRemove=function(t){e.search.filters.splice(t,1),e.doSearchText()},e.toggleShowQuery=function(){e.showQuery=!e.showQuery}}function De(e,t,n,i,a,o,r,s,l,c,d,u,p){e.networkStarted=!1,e.ionItemClass="",e.expertMode=c.data.expertMode&&!s.screen.isSmall(),e.isHttps="https:"===a.location.protocol,e.search={text:"",loading:!0,online:!0,results:[],endpointFilter:r.constants.ES_USER_API,sort:void 0,asc:!0},e.compactMode=!0,e.listeners=[],e.helptipPrefix="helptip-network",e.enableLocationHref=!0,e.removeListeners=function(){e.listeners.length&&(console.debug("[ES] [network] Closing listeners"),_.forEach(e.listeners,(function(e){e()})),e.listeners=[])},e.enter=function(t,n){e.networkStarted||(e.networkStarted=!0,e.search.loading=!0,d.get().then((function(t){t&&(e.node=r.node.same(t.node.host,t.node.port)?r:r.instance(t.node.host,t.node.port),n&&n.stateParams&&("true"===n.stateParams.online&&(e.search.online=!0),n.stateParams.expert&&(e.expertMode="true"==n.stateParams.expert)),e.load())})).catch((function(t){s.onError("ERROR.GET_CURRENCY_FAILED")(t),e.networkStarted=!1})))},e.$on("$ionicParentView.enter",e.enter),e.leave=function(){e.networkStarted&&(e.removeListeners(),u.close(),e.networkStarted=!1,e.search.loading=!0)},e.$on("$ionicView.beforeLeave",e.leave),e.$on("$ionicParentView.beforeLeave",e.leave),e.$on("$destroy",e.leave),e.computeOptions=function(){return{filter:{member:!e.search.type||"member"===e.search.type,mirror:!e.search.type||"mirror"===e.search.type,endpointFilter:angular.isDefined(e.search.endpointFilter)?e.search.endpointFilter:null,online:e.search.online&&!0},sort:{type:e.search.sort,asc:e.search.asc},expertMode:e.expertMode,timeout:l.timeout&&(e.expertMode?l.timeout/10:l.timeout/100)}},e.load=function(){e.search.loading&&(u.start(e.node,e.computeOptions()),e.refreshing=!1,e.listeners.push(u.api.data.on.changed(e,(function(t){e.refreshing||(e.refreshing=!0,p.extendAll(t.peers).then((function(){e.networkStarted&&e.updateView(t),e.refreshing=!1})))}))))},e.updateView=function(t){console.debug("[peers] Updating UI"),e.$broadcast("$$rebind::rebind"),e.search.results=t.peers,e.search.memberPeersCount=t.memberPeersCount,e.search.loading=!e.networkStarted||u.isBusy(),e.loading||e.$broadcast("$$rebind::rebind"),e.motion&&e.search.results&&e.search.results.length>0&&e.motion.show({selector:".item-peer"})},e.refresh=function(){e.search.loading=!0,u.loadPeers()},e.sort=function(){e.search.loading=!0,e.refreshing=!0,u.sort(e.computeOptions()),e.updateView(u.data)},e.toggleOnline=function(t){e.hideActionsPopover(),e.search.online=!1!==t,u.close(),e.search.loading=!0,e.load(),e.enableLocationHref&&n.search(e.search.online?{}:{online:!1}).replace()},e.toggleSearchEndpoint=function(t){e.hideActionsPopover(),e.search.endpointFilter===t||null===t?e.search.endpointFilter=null:e.search.endpointFilter=t,e.sort()},e.toggleSort=function(t){e.search.sort!==t||e.search.asc?(e.search.asc=e.search.sort!==t||!e.search.asc,e.search.sort=t):(e.search.asc=void 0,e.search.sort=void 0),e.sort()},e.selectPeer=function(n){if(n.compacted&&e.compactMode)e.toggleCompactMode();else if(n.online){var i={server:n.getServer()};n.isSsl()&&(i.ssl=!0),n.isTor()&&(i.tor=!0),t.go("app.view_es_peer",i)}},e.$on("csView.action.refresh",(function(t,n){"peers"===n&&e.refresh()})),e.$on("csView.action.showActionsPopover",(function(t,n){e.showActionsPopover(n)})),e.showActionsPopover=function(t){s.popover.show(t,{templateUrl:"plugins/es/templates/network/lookup_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.showEndpointsPopover=function(e,t,n){e.preventDefault(),e.stopPropagation();var i=t.getEndpoints(n);(i=(i||[]).reduce((function(e,n){var i=r.node.parseEndPoint(n);return e.concat({label:"NETWORK.VIEW.NODE_ADDRESS",value:t.getServer()+(i.path||"")})}),[])).length&&s.popover.show(e,{templateUrl:"templates/network/popover_endpoints.html",bindings:{titleKey:"NETWORK.VIEW.ENDPOINTS."+n,items:i}})},e.showWs2pPopover=function(e,t){return e.stopPropagation(),o("NETWORK.VIEW.PRIVATE_ACCESS").then((function(n){s.popover.show(e,{templateUrl:"templates/network/popover_endpoints.html",bindings:{titleKey:"NETWORK.VIEW.ENDPOINTS.WS2P",valueKey:"NETWORK.VIEW.NODE_ADDRESS",items:[{label:"NETWORK.VIEW.NODE_ADDRESS",value:t.bma.private?n:t.getServer()+(t.bma.path||"")},{label:"NETWORK.VIEW.WS2PID",value:t.bma.ws2pid},{label:"NETWORK.VIEW.POW_PREFIX",value:t.powPrefix}]}})}))}}function ye(e,t,n){angular.extend(this,t("ESNetworkLookupCtrl",{$scope:e})),n=n||{},e.enableFilter=!angular.isDefined(n.enableFilter)||n.enableFilter,e.search.type=angular.isDefined(n.type)?n.type:e.search.type,e.search.endpointFilter=angular.isDefined(n.endpointFilter)?n.endpointFilter:e.search.endpointFilter,e.expertMode=angular.isDefined(n.expertMode)?n.expertMode:e.expertMode,e.ionItemClass=n.ionItemClass||"item-border-large",e.enableLocationHref=!1,e.helptipPrefix="",e.selectPeer=function(t){e.closeModal(t)},e.$on("modal.hidden",(function(){e.leave()})),e.showHelpTip=function(){},e.enter()}function Pe(e,t){angular.extend(this,t("NetworkLookupCtrl",{$scope:e}));var n=n||{};e.enableFilter=!angular.isDefined(n.enableFilter)||n.enableFilter,e.search.type=angular.isDefined(n.type)?n.type:e.search.type,e.search.endpointFilter=angular.isDefined(n.endpointFilter)?n.endpointFilter:e.search.endpointFilter,e.expertMode=angular.isDefined(n.expertMode)?n.expertMode:e.expertMode,e.ionItemClass=n.ionItemClass||"item-border-large",e.helptipPrefix="",e.selectPeer=function(t){e.closePopover(t)},e.$on("popover.hidden",(function(){e.leave()})),e.showHelpTip=function(){},e.enter()}function ke(e,t,n,i,a,o){e.loading=!0,e.formData={},e.load=function(){return e.loading=!0,e.formData={},t.all([o.blockchain.current().then((function(t){e.formData.number=t.number,e.formData.medianTime=t.medianTime,e.formData.powMin=t.powMin,e.formData.useSsl=o.useSsl})).catch((function(){delete e.formData.number,delete e.formData.medianTime,delete e.formData.powMin,delete e.formData.useSsl})),o.node.summary().then((function(t){e.formData.version=t&&t.duniter&&t.duniter.version,e.formData.software=t&&t.duniter&&t.duniter.software})).catch((function(){delete e.formData.version,delete e.formData.software})),o.version.latest().then((function(t){e.formData.latestRelease=t})).catch((function(){delete e.formData.latestRelease}))]).then((function(){if(e.formData.latestRelease&&"cesium-plus-pod"===e.formData.software){var t=a.version.compare(e.formData.version,e.formData.latestRelease.version);e.formData.isPreRelease=t>0,e.formData.hasNewRelease=t<0}else e.formData.isPreRelease=!1,e.formData.hasNewRelease=!1;e.loading=!1,e.$broadcast("$$rebind::rebind")}))},i.api.data.on.newBlock(e,(function(t){e.loading||(console.debug("[peer info] Received new block. Reload content"),e.load())})),n.api.data.on.changed(e,(function(t){e.loading||(console.debug("[peer info] Peer settings changed. Reload content"),e.load())})),e.load()}function Me(e,t,n,i,a,o,r,s,l){e.node={},e.loading=!0,e.isHttps="https:"===n.location.protocol,e.isReachable=!0,e.options={document:{index:l.data.plugins.es&&l.data.plugins.es.document&&l.data.plugins.es.document.index||"user",type:l.data.plugins.es&&l.data.plugins.es.document&&l.data.plugins.es.document.type||"profile"}},e.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!a.screen.isSmall()||t.enableBack})),e.$on("$ionicView.enter",(function(t,n){var i=!n.stateParams||!n.stateParams.server,a=n.stateParams&&n.stateParams.server||r.server,o=n.stateParams&&"true"==n.stateParams.ssl||!!i&&r.useSsl,s="true"==n.stateParams.tor||!!i&&r.useTor;return e.load(a,o,s).then((function(){return e.$broadcast("$csExtension.enter",t,n)})).then((function(){e.loading=!1})).catch((function(){e.loading=!1}))})),e.load=function(n,i,l){var c={server:n,host:n,useSsl:i,useTor:l},d=n.split(":");return 2===d.length&&(c.host=d[0],c.port=d[1]),c.url=s.getUrl(c.host,c.port,void 0,c.useSsl),angular.merge(e.node,l?r.lightInstance(c.host+".to",443,443,!0,6e4):r.lightInstance(c.host,c.port,c.useSsl),c),e.isReachable=!e.isHttps||i,e.isReachable?t.all([e.node.network.peering.self().then((function(t){e.node.pubkey=t.pubkey,e.node.currency=t.currency})),e.node.record.count(e.options.document.index,e.options.document.type).then((function(t){e.node.docCount=t})),e.node.network.peers().then((function(t){var n=t.peers.reduce((function(e,t){var n=new X(t);return n.hasEsEndpoint()?(n.online="UP"===t.status,n.blockNumber=n.block.replace(/-.+$/,""),n.ep=r.node.parseEndPoint(n.getEsEndpoints()[0]),n.dns=n.getDns(),n.id=n.keyID(),n.server=n.getServer(),e.concat(n)):e}),[]);return o.extendAll([e.node].concat(n)).then((function(){e.peers=_.sortBy(n,(function(e){var t=1;return t+=1e4*(e.online?1:0),t+=1e3*(e.hasMainConsensusBlock?1:0),-(t+=100*(e.name?1:0))})),e.motion.show({selector:".item-peer"})}))})),e.node.blockchain.current().then((function(t){e.current=t}))]).catch(a.onError(l?"PEER.VIEW.ERROR.LOADING_TOR_NODE_ERROR":"PEER.VIEW.ERROR.LOADING_NODE_ERROR")):r.network.peers().then((function(t){var n=(t&&t.peers||[]).reduce((function(e,t){var n=new X(t);if(!n.hasEsEndpoint())return e;var i=r.node.parseEndPoint(n.getEsEndpoints()[0]);return i.dns!=c.host&&i.ipv4!=c.host&&i.ipv6!=c.host||i.port!=c.port?e:(n.ep=i,e.concat(n))}),[]),i=n.length&&n[0];if(i)return e.node.pubkey=i.pubkey,e.node.currency=i.currency,o.extend(e.node);console.warn("Could not get peer from /network/peers")}))},e.selectPeer=function(e){if(e.online){var t={server:e.getServer()};e.isSsl()&&(t.ssl=!0),e.isTor()&&(t.tor=!0),i.go("app.view_es_peer",t)}},e.openRawPeering=function(t){return e.openLink(t,e.node.url+"/network/peering?pretty")},e.openRawCurrentBlock=function(t){return e.openLink(t,e.node.url+"/network/peering?pretty")}}function we(e,t,n,i,a,o){e.search={loading:!0,results:null,type:"last",hasMore:!1,loadingMore:!1,limit:40},e.enableFilter=!t.screen.isSmall(),e.ionItemClass="item-border-large",e.$on("$ionicView.enter",(function(){e.search.loading&&e.doSearch()})),e.doSearchText=function(){var t=e.search.text&&e.search.text.trim();return t&&t.length?(e.search.type="text",e.doSearch()):e.doSearchLast()},e.doSearchLast=function(){return e.search.type="last",e.doSearch()},e.doSearch=function(n,i){var o={};return o.from=n||0,o.size=i||40,o.text="text"==e.search.type&&e.search.text&&e.search.text.trim(),e.search.loading=!0,a.record.search(o).then((function(t){n?t&&(e.search.results=e.search.results.concat(t)):e.search.results=t||[],e.search.loading=!1,e.search.hasMore=e.search.results.length>=e.search.limit,e.updateView()})).catch((function(i){e.search.loading=!1,n||(e.search.results=[]),e.search.hasMore=!1,t.onError("GROUP.ERROR.SEARCH_GROUPS_FAILED")(i)}))},e.updateView=function(){e.$broadcast("$$rebind::rebind"),e.motion.show({selector:".list.{0} .item".format(e.motion.ionListClass)})},e.select=function(e){e&&e.id&&n.go("app.view_group",{id:e.id})},e.showMore=function(){e.search.limit=e.search.limit||40,e.search.limit+=40,e.search.limit<40&&(e.search.limit=40),e.search.loadingMore=!0,e.load(e.search.results.length,e.search.limit).then((function(){e.search.loadingMore=!1,e.$broadcast("scroll.infiniteScrollComplete")}))},e.resetData=function(){e.search.loading||(console.debug("[ES] [group] Resetting data (settings or account may have changed)"),e.search.hasMore=!1,e.search.results=[],e.search.loading=!0,delete e.search.limit)},i.api.data.on.logout(e,e.resetData),e.showNewRecordModal=function(){e.loadWallet({minData:!0}).then((function(i){t.loading.hide(),e.walletData=i,o.show("plugins/es/templates/group/modal_record_type.html").then((function(e){e&&n.go("app.add_group",{type:e})}))}))}}function Ue(e,t,n,i,a,o,r,s,l){e.formData={},e.id=null,e.pictures=[],e.canEdit=!1,e.loading=!0,e.motion=o.motion.fadeSlideIn,e.$on("$ionicView.enter",(function(n,i){i.stateParams&&i.stateParams.id?((e.loading||i.stateParams.refresh)&&e.load(i.stateParams.id,i.stateParams.anchor),o.loading.hide(),e.$broadcast("$recordView.enter",i)):t.go("app.groups")})),e.load=function(t){s.record.load(t,{fetchPictures:!0}).then((function(n){e.id=n.id,e.formData=n.record,e.issuer=n.issuer,e.canEdit=l.isUserPubkey(e.formData.issuer)||l.children.hasPubkey(e.formData.issuer),e.pictures=n.record.pictures||[],delete n.record.pictures,e.$broadcast("$recordView.load",t,s.record.comment),e.loading=!1,o.loading.hide(),e.updateView()})).catch(o.onError("GROUP.ERROR.LOAD_RECORD_FAILED"))},e.updateView=function(){e.motion.show()},e.edit=function(){o.loading.show(),t.go("app.edit_group",{id:e.id})},e.delete=function(){var n;e.hideActionsPopover(),a(["GROUP.VIEW.REMOVE_CONFIRMATION","GROUP.INFO.RECORD_REMOVED"]).then((function(e){return n=e,o.alert.confirm(e["GROUP.VIEW.REMOVE_CONFIRMATION"])})).then((function(a){a&&s.record.remove(e.id).then((function(){i.nextViewOptions({historyRoot:!0}),t.go("app.groups"),o.toast.show(n["GROUP.INFO.RECORD_REMOVED"])})).catch(o.onError("GROUP.ERROR.REMOVE_RECORD_FAILED"))}))},e.showActionsPopover=function(t){o.popover.show(t,{templateUrl:"plugins/es/templates/group/view_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.showSharePopover=function(n){e.hideActionsPopover();var i=e.formData.title,a=(r.shareBaseUrl||$rootScope.rootPath)+t.href("app.view_group",{id:e.id});o.screen.isSmall()&&(n=angular.element(document.querySelector("#group-share-anchor-"+e.id))||n),o.popover.share(n,{bindings:{url:a,titleKey:"GROUP.VIEW.POPOVER_SHARE_TITLE",titleValues:{title:i},time:e.formData.time,postMessage:i}})}}function xe(e,t,n,i,a,o,r,s,l,c){e.walletData={},e.formData={},e.id=null,e.pictures=[],e.loading=!0,e.setForm=function(t){e.form=t},e.$on("$ionicView.enter",(function(t,i){e.loadWallet({minData:!0}).then((function(t){e.walletData=t,i.stateParams&&i.stateParams.id?e.load(i.stateParams.id):(i.stateParams&&i.stateParams.type&&(e.formData.type=i.stateParams.type),e.loading=!1,n.loading.hide(),e.updateView()),l("group-record-title")}))})),e.load=function(i){t.record.load(i,{fetchPictures:!0,html:!1}).then((function(t){e.formData=t.record,e.issuer=t.issuer,e.id=t.id,e.pictures=t.record.pictures||[],delete t.record.pictures,e.loading=!1,n.loading.hide(),e.updateView()})).catch(n.onError("GROUP.ERROR.LOAD_RECORD_FAILED"))},e.updateView=function(){e.motion.show({selector:".list.{0} .item, .card-gallery".format(e.motion.ionListClass)})},e.save=function(){if(e.form.$submitted=!0,!e.saving&&e.form.$valid&&("managed"===e.formData.type||"open"===e.formData.type))return e.saving=!0,n.loading.show().then((function(){var t=e.formData;return t.time=moment().utc().unix(),t.picturesCount=e.pictures.length,t.picturesCount>0?(t.pictures=e.pictures.reduce((function(e,t){return e.concat({file:c.image.toAttachment(t)})}),[]),n.image.resizeSrc(e.pictures[0].src,!0).then((function(e){return t.avatar=c.image.toAttachment({src:e}),t}))):(t.avatar&&(t.avatar={_content:"",_content_type:""}),t.pictures=[],t)})).then((function(n){return e.id?t.record.update(n,{id:e.id}):(n.creationTime=moment().utc().unix(),t.record.add(n))})).then((function(t){return e.id=e.id||t,e.saving=!1,r.clearCache(r.currentView().stateId),r.nextViewOptions({historyRoot:!0}),i.go("app.view_group",{id:e.id,refresh:!0})})).catch((function(t){e.saving=!1,n.onError("GROUP.ERROR.SAVE_RECORD_FAILED")(t)}))},e.openPicturePopup=function(){o.camera.getPicture().then((function(t){e.pictures.push({src:"data:image/png;base64,"+t})})).catch(n.onError("ERROR.TAKE_PICTURE_FAILED"))},e.fileChanged=function(t){return n.loading.show(),a((function(i,a){var o=t.target.files[0];n.image.resizeFile(o).then((function(t){e.pictures.push({src:t}),n.loading.hide(),i()}))}))},e.removePicture=function(t){e.pictures.splice(t,1)},e.favoritePicture=function(t){if(t>0){var n=e.pictures[t];e.pictures.splice(t,1),e.pictures.splice(0,0,n)}},e.cancel=function(){r.goBack()},e.showRecordTypeModal=function(){s.show("plugins/es/templates/group/modal_record_type.html").then((function(t){t&&(e.formData.type=t)}))}}function Be(e,t,n,i,a,o,r,s,l,c,d){var u,p=d.constants.DEFAULT_LOAD_SIZE;e.search={loading:!0,results:null,hasMore:!1,loadingMore:!1,limit:p,options:{codes:{includes:c.constants.INVITATION_CODES}}},e.setWallet=function(e){u=e},e.$on("$ionicView.enter",(function(t,n){if(e.search.loading){if(!(u=n.stateParams&&n.stateParams.id?r.children.get(n.stateParams.id):r))return o.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome();e.loadWallet({wallet:u,minData:!0}).then((function(){e.addListeners(),s.isAlive()&&(e.load(),e.resetUnreadCount(),e.showFab("fab-new-invitation"))}))}})),e.load=function(t,n){var i=angular.copy(e.search.options);return i.from=i.from||t||0,i.size=i.size||n||p,u=u||r,d.load(i,u.data.keypair).then((function(t){e.search.results=t,e.search.loading=!1,e.search.hasMore=e.search.results&&e.search.results.length>=e.search.limit,e.updateView(),o.loading.hide()})).catch((function(n){if("CANCELLED"===n)return e.cancel();e.search.loading=!1,t||(e.search.results=[]),e.search.hasMore=!1,o.onError("INVITATION.ERROR.LOAD_INVITATIONS_FAILED")(n)}))},e.cancel=function(){},e.updateView=function(){e.motion&&e.search.results&&e.search.results.length&&e.motion.show({selector:".view-invitation .item"})},e.$watchCollection("search.results",e.updateView),e.showMore=function(){e.search.limit=e.search.limit||p,e.search.limit=2*e.search.limit,e.search.limit0,c=e.enableSelectWallet&&(e.formData.walletId?a.children.get(e.formData.walletId):a)||a,e.formData.walletId=c.id,c.isDefault()||console.debug("[transfer] Using {"+c.id+"} wallet"),c.login({sources:!0,silent:!0}).then((function(t){if(e.walletData=t,i.ink({selector:".modal-invitation .ink"}),e.destPub&&!e.destUid)return csWot.extend({pubkey:e.destPub}).then((function(t){e.destUid=t&&(t.name||t.uid),e.destUid&&(e.destPub=""),e.loading=!1}));e.loading=!1})).catch((function(t){if("CANCELLED"===t)return e.cancel();i.onError("ERROR.LOGIN_FAILED")(t)}))},e.$on("modal.shown",e.load),e.onUseCommentChanged=function(){e.formData.useComment||(e.formData.comment=null)},e.$watch("formData.useComment",e.onUseCommentChanged,!0),e.removeRecipient=function(t,n){e.recipients.splice(t,1),n.preventDefault()},e.removeSuggestion=function(t,n){e.suggestions.splice(t,1),n.preventDefault()},e.cancel=function(){e.closeModal()},e.doSend=function(){if(e.form.$submitted=!0,e.form.$valid&&e.recipients.length&&e.suggestions.length)return c.isLogin()?c.auth({silent:!0}).then((function(){return t.all([r.box.getKeypair(c.data.keypair),i.alert.confirm("INVITATION.CONFIRM.SEND_INVITATIONS_TO_CERTIFY",void 0,{okText:"COMMON.BTN_SEND"})])})).then((function(n){var a=n&&n[0],o=n&&n[1];if(a&&o){i.loading.show();var r=moment().utc().unix(),l=e.formData.useComment&&e.formData.comment&&e.formData.comment.trim();return t.all(e.recipients.reduce((function(t,n){return t.concat(e.suggestions.reduce((function(e,t){if(!t.uid||!t.pubkey)return console.error("Unable to send suggestion for this identity (no uid or pubkey)",t),e;var i={issuer:c.data.pubkey,recipient:n.pubkey,time:r,content:[t.uid,t.pubkey].join("-"),comment:l};return e.concat(s.send(i,{wallet:c,type:"certification"}))}),[]))}),[])).then((function(){return e.closeModal(),i.loading.hide()})).then((function(){i.toast.show("INVITATION.INFO.INVITATION_SENT")})).catch(i.onError("INVITATION.ERROR.SUGGEST_CERTIFICATIONS_FAILED"))}})):e.closeModal()},e.showSelectRecipientModal=function(t){if(!t.isDefaultPrevented())return n.showWotLookup({allowMultiple:!0,enableFilter:!0,title:"INVITATION.NEW.RECIPIENTS_MODAL_TITLE",help:"INVITATION.NEW.RECIPIENTS_MODAL_HELP",okText:"COMMON.BTN_OK",okType:"button-positive",selection:angular.copy(e.recipients)}).then((function(t){t&&(e.recipients=t)}))},e.showSelectSuggestionModal=function(t){if(!t.isDefaultPrevented())return n.showWotLookup({allowMultiple:!0,enableFilter:!0,title:"INVITATION.NEW.SUGGESTION_IDENTITIES_MODAL_TITLE",help:"INVITATION.NEW.SUGGESTION_IDENTITIES_MODAL_HELP",okText:"COMMON.BTN_OK",okType:"button-positive",selection:angular.copy(e.suggestions)}).then((function(t){t&&(e.suggestions=t)}))},e.showSelectWalletModal=function(){if(e.enableSelectWallet)return n.showSelectWallet().then((function(t){t&&e.formData.walletId!==t.id&&(console.debug("[transfer] Using {"+t.id+"} wallet"),e.wallet=t,e.walletData=t.data,e.formData.walletId=t.id,e.onAmountChanged())}))}}function We(e,t,n,i,a,o,r,s){var l;e.loading=!0,e.popupData={},e.search={results:[],loading:!0},e.emailFrequencies=[{id:"daily",label:"daily"},{id:"weekly",label:"weekly"}],e.enter=function(t,i){if(e.loading){if(!(l=i.stateParams&&i.stateParams.id?a.children.get(i.stateParams.id):a))return o.alert.error("ERROR.UNKNOWN_WALLET_ID"),e.showHome();l.auth({minData:!0}).then((function(){return o.loading.hide(),e.load()})).then((function(){e.showFab("fab-add-subscription-record")})).catch((function(t){if("CANCELLED"===t)return o.loading.hide(10),e.loading=!0,void n.goBack();o.onError("SUBSCRIPTION.ERROR.LOAD_SUBSCRIPTIONS_FAILED")(t)}))}},e.$on("$ionicView.enter",e.enter),e.load=function(){return e.loading=!0,s.record.load(l.data.pubkey,l.data.keypair).then((function(e){var t=_.groupBy(e||[],(function(e){return[e.type,e.recipient].join("|")}));return _.keys(t).reduce((function(e,n){var i=n.split("|");return e.concat({type:i[0],recipient:i[1],items:t[n]})}),[])})).then((function(e){return i.extendAll(e,"recipient")})).then(e.updateView).catch((function(t){o.loading.hide(10),t&&404==t.ucode?(e.updateView([]),e.existing=!1):o.onError("PROFILE.ERROR.LOAD_PROFILE_FAILED")(t)}))},e.updateView=function(t){t&&(e.search.results=t),e.search.results&&e.search.results.length&&e.motion.show(),e.search.loading=!1},e.addSubscription=function(){e.showCategoryModal().then((function(t){if(t){if("email"===t.id)return e.showEmailModal();o.alert.notImplemented()}})).then((function(t){t&&(o.loading.show(),s.record.add(t,{wallet:l}).then(e.addToUI).then((function(){l.data.subscriptions=l.data.subscriptions||{count:0},l.data.subscriptions.count++,o.loading.hide(),e.updateView()})).catch(o.onError("SUBSCRIPTION.ERROR.ADD_SUBSCRIPTION_FAILED")))}))},e.editSubscription=function(t){var n,i=angular.copy(t);if("email"===t.type&&(n=e.showEmailModal(t)),n)return n.then((function(n){if(n)return o.loading.show(),t.id=i.id,s.record.update(t,l).then((function(){if(i.type!==t.type||i.recipient!==t.recipient)return e.removeFromUI(i),e.addToUI(t)})).then((function(){o.loading.hide(),e.updateView()})).catch(o.onError("SUBSCRIPTION.ERROR.UPDATE_SUBSCRIPTION_FAILED"))}))},e.deleteSubscription=function(t,n){if(t&&t.id){if(!n)return o.alert.confirm("SUBSCRIPTION.CONFIRM.DELETE_SUBSCRIPTION").then((function(n){if(n)return e.deleteSubscription(t,n)}));o.loading.show(),s.record.remove(t.id,{wallet:l}).then((function(){l.data.subscriptions=l.data.subscriptions||{count:1},l.data.subscriptions.count--,e.removeFromUI(t),o.loading.hide()})).catch(o.onError("SUBSCRIPTION.ERROR.DELETE_SUBSCRIPTION_FAILED"))}},e.removeFromUI=function(t){var n=_.findWhere(e.search.results,{type:t.type,recipient:t.recipient}),i=_.findIndex(n.items,t);i>=0&&n.items.splice(i,1),n.items.length||(i=_.findIndex(e.search.results,n),e.search.results.splice(i,1))},e.addToUI=function(n){e.search.results=e.search.results||[];var a=_.findWhere(e.search.results,{type:n.type,recipient:n.recipient});return a?(a.items.push(n),t.when(n)):(a={type:n.type,recipient:n.recipient,items:[]},i.extendAll([a],"recipient").then((function(){return a.items.push(n),e.search.results.push(a),n})))},e.showCategoryModal=function(){return s.category.all().then((function(e){return r.show("plugins/es/templates/common/modal_category.html","ESCategoryModalCtrl as ctrl",{categories:e},{focusFirstInput:!0})})).then((function(e){if(e&&e.parent)return e}))},e.showEmailModal=function(e){return r.show("plugins/es/templates/subscription/modal_email.html","ModalEmailSubscriptionsCtrl",e,{focusFirstInput:!0})}}function Ve(e,t,n,i,a,o,r){e.frequencies=[{id:"daily",label:"daily"},{id:"weekly",label:"weekly"}],e.formData=r||{},e.formData.content=e.formData.content||{},e.formData.content.frequency=e.formData.content.frequency||e.frequencies[0].id,e.recipient={},e.$on("modal.shown",(function(){return e.formData.recipient?(e.recipient={pubkey:e.formData.recipient},a.extendAll([e.recipient])):i.network.peering.self().then((function(t){if(t)return e.formData.recipient=t.pubkey,e.recipient={pubkey:e.formData.recipient},a.extendAll([e.recipient])}))})),e.doSubmit=function(){if(e.form.$submitted=!0,e.form.$valid&&e.formData.content.email&&e.formData.content.frequency){var t={type:"email",recipient:e.formData.recipient,content:{email:e.formData.content.email,locale:n.data.locale.id,frequency:e.formData.content.frequency}};e.closeModal(t)}},e.cancel=function(){e.closeModal()},e.subscriptionForm&&e.subscriptionForm.$setPristine(),e.showNetworkLookup=function(){return o.showNetworkLookup({enableFilter:!0,endpointFilter:i.constants.ES_SUBSCRIPTION_API}).then((function(t){t&&(e.recipient=t,e.formData.recipient=t.pubkey)}))}}function Ge(e,t,n,i,a,o,r,s,l){e.search=e.search||{loading:!0,hasMore:!1,text:void 0,index:"invitation",type:"certification",results:[],sort:"time",asc:!1,loadingMore:!1},e.entered=!1,e.searchTextId="documentSearchText",e.ionItemClass="item-border-large",e.defaultSizeLimit=e.defaultSizeLimit||(r.screen.isSmall()?50:100),e.helptipPrefix="helptip-document",e.compactMode=!angular.isDefined(e.compactMode)||e.compactMode,e._source=e._source||["issuer","hash","time","creationTime","title","message"],e.showHeaders=!angular.isDefined(e.showHeaders)||e.showHeaders,e.enter=function(t,n){e.entered||(e.entered=!0,e.search.index=n.stateParams&&n.stateParams.index||e.search.index,e.search.type=n.stateParams&&n.stateParams.type||e.search.type,e.search.text=n.stateParams&&n.stateParams.q||e.search.text,e.search.last=!e.search.text,e.load()),e.expertMode=angular.isDefined(e.expertMode)?e.expertMode:!r.screen.isSmall()&&a.data.expertMode},e.$on("$ionicView.enter",e.enter),e.computeOptions=function(t,n){var i={index:e.search.index,type:e.search.type,from:t||0,size:n||e.defaultSizeLimit};return e.search.sort?(i.sort={},i.sort[e.search.sort]=e.search.asc?"asc":"desc"):i.sort={time:"desc"},i._source=i._source||e._source,i},e.load=function(t,n,i){if(!e.search.error){var a=e.computeOptions(t,n);return e.search.loading=!i,(e.search.last?l.search(a):l.searchText(e.search.text||"",a)).then((function(n){t?e.search.results=e.search.results.concat(n.hits):(e.search.results=n.hits,e.search.took=n.took),e.search.total=n.total,r.loading.hide(),e.search.loading=!1,e.search.hasMore=n.hits&&n.hits.length>0&&n.total>e.search.results.length,e.updateView()})).catch((function(t){e.search.results=[],e.search.loading=!1,e.search.error=!0,e.search.hasMore=!1,r.onError("DOCUMENT.ERROR.LOAD_DOCUMENTS_FAILED")(t).then((function(){e.search.error=!1}))}))}},e.updateView=function(){e.motion&&e.search.results&&e.search.results.length&&e.motion.show({selector:".list .item.item-document"}),e.$broadcast("$$rebind::rebind")},e.doSearchText=function(){return e.search.last=!e.search.text,e.load().then((function(){n.search({q:e.search.text}).replace()}))},e.doSearchLast=function(){return e.search.last=!0,e.search.text=void 0,e.load()},e.removeAll=function(){if(e.hideActionsPopover(),e.search.results&&e.search.results.length)return r.alert.confirm("DOCUMENT.CONFIRM.REMOVE_ALL").then((function(t){if(t)return r.loading.show(),l.removeAll(e.search.results).then((function(){return e.search.loading=!1,i((function(){return r.toast.show("DOCUMENT.INFO.REMOVED"),e.load()}),1e3)})).catch(r.onError("DOCUMENT.ERROR.REMOVE_ALL_FAILED"))}))},e.remove=function(t,n){var i=e.search.results[n];i&&!t.defaultPrevented&&(t.stopPropagation(),r.alert.confirm("DOCUMENT.CONFIRM.REMOVE").then((function(t){if(t)return l.remove(i).then((function(){e.search.results.splice(n,1),e.$broadcast("$$rebind::rebind"),r.toast.show("DOCUMENT.INFO.REMOVED")})).catch(r.onError("MESSAGE.ERROR.REMOVE_FAILED"))})))},e.selectDocument=function(t,n){console.debug("Selected document: ",n,s);var i=s.getUrl("/{0}/{1}/_search?pretty&q=_id:{2}".format(n.index,n.type,n.id));return e.openLink(t,i)},e.toggleCompactMode=function(){e.compactMode=!e.compactMode,e.updateView(),!e.search.hasMore&&e.search.results.length&&"last"==e.search.type&&i((function(){e.search.hasMore=!0}),500)},e.toggleSort=function(t){e.search.sort!==t||e.search.asc?(e.search.asc=e.search.sort!==t||!e.search.asc,e.search.sort=t):(e.search.asc=void 0,e.search.sort=void 0),e.load()},e.showMore=function(){e.search.loading||(e.search.loadingMore=!0,e.load(e.search.results.length,e.defaultSizeLimit,!0).then((function(){e.search.loadingMore=!1,e.$broadcast("scroll.infiniteScrollComplete")})))},e.startListenChanges=function(){var t=Date.now(),n=e.search.index+"/"+e.search.type,i=s.websocket.changes(n);return i.open().then((function(){console.debug("[ES] [document] Websocket opened in {0} ms".format(Date.now()-t)),i.on((function(t){e.search.last&&t&&l.fromHit(t).then((function(n){"DELETE"===t._operation?e.onDeleteDocument(n):e.onNewDocument(n)}))}))}))},e.onNewDocument=function(t){if(e.search.last&&!e.search.loading){console.debug("[ES] [document] Detected new document: ",t);var n=_.findIndex(e.search.results,{id:t.id,index:t.index,type:t.type});n<0?(e.search.total++,e.search.results.splice(0,0,t)):(t.updated=!0,i((function(){t.updated=!1}),2e3),e.search.results.splice(n,1,t)),e.updateView()}},e.onDeleteDocument=function(t){e.search.last&&!e.search.loading&&i((function(){var n=_.findIndex(e.search.results,{id:t.id,index:t.index,type:t.type});n<0||(console.debug("[ES] [document] Detected document deletion: ",t),e.search.results.splice(n,1),e.search.total--,e.updateView())}),750)},e.showActionsPopover=function(t){r.popover.show(t,{templateUrl:"plugins/es/templates/document/lookup_popover_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)},e.resetData=function(){e.search.loading||(console.debug("[ES] [document] Resetting data (settings or account may have changed)"),e.search.results=[],e.search.loading=!1,e.search.total=void 0,e.search.loadingMore=!1,e.entered=!1,delete e.search.limit)},o.api.data.on.unauth(e,e.resetData)}function Ye(e,t,n,i,a){angular.extend(this,t("ESDocumentLookupCtrl",{$scope:e})),e.search={loading:!0,hasMore:!0,text:void 0,index:"user,page,group",type:"profile,record,comment",results:void 0,sort:"time",asc:!1},e.expertMode=!1,e.defaultSizeLimit=20,e._source=["issuer","hash","time","creationTime","title","avatar._content_type","city","message","record","type"],e.showHeaders=!1,e.$on("$ionicParentView.enter",e.enter),e.selectDocument=function(e,t){var n;t&&e&&!e.defaultPrevented&&(e.stopPropagation(),"user"===t.index&&"profile"===t.type?i.go("app.wot_identity",{pubkey:t.pubkey,uid:t.name}):"page"===t.index&&"record"===t.type?i.go("app.view_page",{title:t.title,id:t.id}):"page"===t.index&&"comment"===t.type?(n=a("formatHash")(t.id),i.go("app.view_page_anchor",{title:t.title,id:t.record,anchor:n})):"group"===t.index&&"record"===t.type?i.go("app.view_group",{title:t.title,id:t.id}):"group"===t.index&&"comment"===t.type?(n=a("formatHash")(t.id),i.go("app.view_group_anchor",{title:t.title,id:t.record,anchor:n})):console.warn("Click on this kind of document not implement yet!",t))};var o=e.computeOptions;e.computeOptions=function(t,n){var i=o(t,n);if(!i.sort||i.sort.time){var a=i.sort&&i.sort.time||a;i.sort=[{time:a}]}return i._source=i._source||e._source,i.getTimeFunction=function(e){return e.time=e.creationTime||e.time,e.time},i},n((function(){e.startListenChanges()}),1e3)}function $e(e,t,n,i,a,o,r,s,l,c){e.entered=!1,e.abuseData={},e.abuseLevels=[{value:1,label:"LOW"},{value:2,label:"LOW"}],e.staring=!1,e.options=e.options||{},e.options.like=e.options.like||{kinds:c.constants.KINDS,index:void 0,type:void 0, id:void 0},e.$on("$recordView.enter",(function(t,n){e.entered?e.id&&e.loadLikes(e.id):e.entered=!1})),e.$on("$recordView.load",(function(t,n){e.id=n||e.id,e.id&&e.loadLikes(e.id)})),e.initLikes=function(){if(!e.likeData)throw new Error("Missing 'likeData' in scope. Cannot load likes counter");if(!e.options.like.service){if(!e.options.like.index||!e.options.like.type)throw new Error("Missing 'options.like.index' or 'options.like.type' in scope. Cannot load likes counter");e.options.like.service=c.instance(e.options.like.index,e.options.like.type)}e.options.like.kinds||(e.options.like.kinds=_.filter(c.constants.KINDS,(function(t){var n=t.toLowerCase()+"s";return angular.isDefined(e.likeData[n])})))},e.loadLikes=function(n){if(e.likeData&&!e.likeData.loading){n=n||e.likeData.id,e.initLikes();var i=e.options.like.kinds||[];if(i.length){e.likeData.loading=!0;var a=Date.now();console.debug("[ES] Loading counter of {0}... ({1})".format(n.substring(0,8),i));var o=s.isLogin()?s.pubkeys():void 0;return t.all(_.map(i,(function(t){var i=t.toLowerCase()+"s";return e.options.like.service.count(n,{issuers:o,kind:t}).then((function(t){e.likeData[i]&&angular.merge(e.likeData[i],t)}))}))).then((function(){e.likeData.id=n,console.debug("[ES] Loading counter of {0} [OK] in {1}ms".format(n.substring(0,8),Date.now()-a)),_.contains(i,"VIEW")&&!e.canEdit&&e.markAsView(),e.$parent&&(console.debug("[ES] [likes] Adding data and functions to parent scope"),e.$parent.toggleLike=e.toggleLike,e.$parent.reportAbuse=e.reportAbuse),e.likeData.loading=!1})).catch((function(t){console.error(t&&t.message||t),e.likeData.loading=!1}))}}},e.toggleLike=function(i,a){if(e.initLikes(),!e.likeData.id)throw new Error("Missing 'likeData.id' in scope. Cannot apply toggle");if(!s.isLogin())return s.auth({minData:!0}).then((function(t){if(o.loading.hide(),!t)throw new Error("CANCELLED");return a.pubkey=a.pubkey||t.pubkey,e.toggleLike(i,a)}));(a=a||{}).kind=a.kind&&a.kind.toUpperCase()||"LIKE";var l=a.kind.toLowerCase()+"s";if(e.likeData[l]=e.likeData[l]||{},!0===e.likeData[l].loading||e.likeData.loading)return i.preventDefault(),t.reject();if(!a.pubkey){if(0!==s.children.count())return r.showSelectWallet({displayBalance:!1}).then((function(t){if(!t)throw new Error("CANCELLED");return a.pubkey=t.data.pubkey,e.toggleLike(i,a)}));a.pubkey=s.data.pubkey}var c=s.getByPubkey(a.pubkey);return c?(e.likeData[l].loading=!0,c.auth({minData:!0}).then((function(t){if(t)return t.isMember,a.id=e.likeData.id,e.options.like.service.toggle(e.likeData.id,a);o.loading.hide()})).then((function(t){o.loading.hide(),0!==t&&(e.likeData[l].total=(e.likeData[l].total||0)+t,e.likeData[l].wasHitByPubkey=e.likeData[l].wasHitByPubkey||{},e.likeData[l].wasHitByPubkey[a.pubkey]=t>0,e.likeData[l].wasHitCount+=t),n((function(){e.likeData[l].loading=!1,e.$broadcast("$$rebind::like")}),1e3)})).catch((function(t){if(e.likeData[l].loading=!1,"CANCELLED"===t)throw"CANCELLED";console.error(t),o.onError("LIKE.ERROR.FAILED_TOGGLE_LIKE")(t),i.preventDefault()}))):void 0},e.setAbuseForm=function(t){e.abuseForm=t},e.showAbuseCommentPopover=function(t){return i(["COMMON.REPORT_ABUSE.TITLE","COMMON.REPORT_ABUSE.SUB_TITLE","COMMON.BTN_SEND","COMMON.BTN_CANCEL"]).then((function(t){return o.loading.hide(),a.show({templateUrl:"plugins/es/templates/common/popup_report_abuse.html",title:t["COMMON.REPORT_ABUSE.TITLE"],subTitle:t["COMMON.REPORT_ABUSE.SUB_TITLE"],cssClass:"popup-report-abuse",scope:e,buttons:[{text:t["COMMON.BTN_CANCEL"],type:"button-stable button-clear gray"},{text:t["COMMON.BTN_SEND"],type:"button button-positive ink",onTap:function(t){if(e.abuseForm.$submitted=!0,e.abuseForm.$valid&&e.abuseData.comment)return e.abuseData;t.preventDefault()}}]})})).then((function(t){if(e.abuseData={},t&&t.comment)return t;o.loading.hide()}))},e.reportAbuse=function(t,n){if(!s.isLogin())return s.auth({minData:!0}).then((function(i){if(o.loading.hide(),!i)throw new Error("CANCELLED");return n.pubkey=n.pubkey||i.pubkey,e.reportAbuse(t,n)}));if(e.likeData&&e.likeData.abuses&&!e.likeData.abuses.wasHitCount&&!e.likeData.abuses.wasHitCount){if(!(n=n||{}).pubkey){if(0!==s.children.count())return r.showSelectWallet({displayBalance:!1}).then((function(i){if(!i)throw"CANCELLED";return n.pubkey=i.data.pubkey,e.reportAbuse(t,n)}));n.pubkey=s.data.pubkey}var i=s.getByPubkey(n.pubkey);if(i&&i.isMember())return n.comment?(n.kind="ABUSE",e.toggleLike(t,n).then((function(){alert("BEFORE display toast"),o.toast.show("COMMON.REPORT_ABUSE.CONFIRM.SENT")}))):e.showAbuseCommentPopover(t).then((function(i){if(i&&i.comment)return n.comment=i.comment,n.level=i.level||i.delete&&5||void 0,e.reportAbuse(t,n)}));o.alert.info("ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION")}},s.api.data.on.reset(e,(function(){_.forEach(e.options.like.kinds||[],(function(t){var n=t.toLowerCase()+"s";e.likeData[n]&&(e.likeData[n].wasHitByPubkey={},e.likeData[n].wasHitCount=0)})),e.$broadcast("$$rebind::like")}),this)}function Ke(e,t,n,i,a,o,r,s,l){function c(t){return moment.unix(t).utc().startOf(e.formData.rangeDuration).unix()}e.loading=!0,e.formData=e.formData||{useRelative:o.data.useRelative,timePct:100,rangeDuration:"day",firstBlockTime:0,scale:"linear",hide:[],beginAtZero:!0},e.formData.useRelative=!1,e.scale="linear",e.height=void 0,e.width=void 0,e.maintainAspectRatio=!0,e.times=[],e.enter=function(t,n){if(e.loading){if(n&&n.stateParams&&(e.stateName=n&&n.stateName,e.stateParams=angular.copy(n&&n.stateParams||{}),!e.formData.currency&&n&&n.stateParams&&n.stateParams.currency&&(e.formData.currency=n.stateParams.currency),n.stateParams.t?e.formData.timePct=n.stateParams.t:n.stateParams.timePct&&(e.formData.timePct=n.stateParams.timePct),n.stateParams.stepUnit&&(e.formData.rangeDuration=n.stateParams.stepUnit),n.stateParams.scale&&(e.formData.scale=n.stateParams.scale),n.stateParams.hide&&(e.formData.hide=n.stateParams.hide.split(",").reduce((function(e,t){return e.concat(parseInt(t))}),[]))),e.init(t,n),!e.formData.currency)return r.get().then((function(i){return e.formData.currency=i?i.name:null,e.formData.firstBlockTime=i?c(i.firstBlockTime):0,e.formData.firstBlockTime||console.warn("[graph] currency.firstBlockTime not loaded ! Should have been loaded by currrency service!"),e.formData.currencyAge=c(moment().utc().unix())-e.formData.firstBlockTime,e.enter(t,n)}));e.load().then((function(){e.setScale(e.formData.scale),e.updateHiddenDataset(),e.loading=!1}))}},e.$on("$csExtension.enter",e.enter),e.$on("$ionicParentView.enter",e.enter),e.updateLocation=function(){e.stateName&&(i.nextViewOptions({disableAnimate:!0,disableBack:!0,historyRoot:!0}),e.stateParams=e.stateParams||{},e.stateParams.t=e.formData.timePct>=0&&e.formData.timePct<100?e.formData.timePct:void 0,e.stateParams.stepUnit="day"!=e.formData.rangeDuration?e.formData.rangeDuration:void 0,e.stateParams.hide=e.formData.hide&&e.formData.hide.length?e.formData.hide.join(","):void 0,e.stateParams.scale="linear"!=e.formData.scale?e.formData.scale:void 0,a.go(e.stateName,e.stateParams,{reload:!1,inherit:!0,notify:!1}))},e.setSize=function(t,n,i){e.height=t,e.width=n,e.maintainAspectRatio=angular.isDefined(i)?i:e.maintainAspectRatio},e.$on("csView.action.refresh",(function(t,n){if(!n||"currency"==n)return e.load()})),e.init=function(e,t){},e.load=function(){},e.toggleScale=function(){e.setScale("linear"===e.formData.scale?"logarithmic":"linear"),e.updateLocation()},e.setScale=function(n){if(e.hideActionsPopover(),e.formData.scale=n,e.options&&e.options.scales&&e.options.scales.yAxes){var i=t("formatInteger");_.forEach(e.options.scales.yAxes,(function(t,a){t.type=n,t.ticks=t.ticks||{},"linear"==n?(t.ticks.beginAtZero=!angular.isDefined(e.formData.beginAtZero)||e.formData.beginAtZero,delete t.ticks.min,t.ticks.callback=function(e){return i(e)}):(delete t.ticks.beginAtZero,delete t.ticks.callback,t.ticks.callback=function(e,t){if(e)return Math.log10(e)%1==0||Math.log10(e/3)%1==0?i(e):""})}))}},e.setRangeDuration=function(t){e.hideActionsPopover(),e.formData&&t==e.formData.rangeDuration||(e.formData.rangeDuration=t,delete e.formData.startTime,delete e.formData.endTime,delete e.formData.rangeDurationSec,e.load(),e.updateLocation())},e.updateHiddenDataset=function(t){t=t||e.datasetOverride||{},_.forEach(e.formData.hide||[],(function(n){if(t[n]){t[n].hidden=!0;var i=t[n].yAxisID,a=i&&e.options&&e.options.scales&&_.findWhere(e.options.scales.yAxes||[],{id:i});i&&a&&1==_.filter(t,(function(e){return e.yAxisID===i})).length&&(a.display=!1)}}))},e.onLegendClick=function(t,n){var i=n.datasetIndex,a=this.chart,o=a.getDatasetMeta(i);o.hidden=null===o.hidden?!a.data.datasets[i].hidden:null,a.config&&a.config.data&&a.config.data.datasets&&1===_.filter(a.config.data.datasets,(function(e){return e.yAxisID&&e.yAxisID===o.yAxisID})).length&&(a.scales[o.yAxisID].options.display=!1!==o.hidden),a.update(),e.formData.hide=e.formData.hide||[],e.formData.hide=o.hidden?_.union(e.formData.hide,[i]):_.difference(e.formData.hide,[i]),e.updateLocation()},e.goPreviousRange=function(){e.loadingRange||(e.loadingRange=!0,e.formData.startTime-=e.times.length*e.formData.rangeDurationSec,e.formData.startTimee.formData.firstBlockTime+e.formData.currencyAge-e.formData.timeWindow&&(e.formData.startTime=e.formData.firstBlockTime+e.formData.currencyAge-e.formData.timeWindow),e.formData.endTime=e.formData.startTime+e.times.length*e.formData.rangeDurationSec,e.load().then((function(){e.updateLocation(),e.loadingRange=!1})))},e.onRangeChanged=function(){e.loadingRange||(e.loadingRange=!0,e.formData.startTime=e.formData.firstBlockTime+parseFloat(e.formData.timePct)/100*(e.formData.currencyAge-e.formData.timeWindow),e.formData.endTime=e.formData.startTime+e.times.length*e.formData.rangeDurationSec,e.load().then((function(){e.updateLocation(),e.loadingRange=!1})))},e.updateRange=function(t,n,i){i=!angular.isDefined(i)||i,e.formData.startTime=t,e.formData.endTime=n,e.formData.timeWindow=e.formData.timeWindow||e.formData.endTime-e.formData.startTime,e.formData.rangeDurationSec=e.formData.rangeDurationSec||e.formData.timeWindow/(e.times.length-1),i&&(e.formData.timePct=Math.ceil(100*(e.formData.startTime-e.formData.firstBlockTime)/(e.formData.currencyAge-e.formData.timeWindow)))},e.showActionsPopover=function(t){l.popover.show(t,{templateUrl:"plugins/graph/templates/common/popover_range_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)}}function je(e,t,n,i,a,o,r,s){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.displayRightAxis=!0,e.init=function(t,n){n&&n.stateParams&&!e.formData.issuer&&n&&n.stateParams&&n.stateParams.pubkey&&(e.formData.issuer=n.stateParams.pubkey)},e.load=function(t){var i=e.formData;return n.all([o(e.formData.issuer?"GRAPH.BLOCKCHAIN.TX_AMOUNT_PUBKEY_TITLE":"GRAPH.BLOCKCHAIN.TX_AMOUNT_TITLE",i),o(["GRAPH.BLOCKCHAIN.TX_AMOUNT_LABEL","GRAPH.BLOCKCHAIN.TX_COUNT_LABEL","GRAPH.BLOCKCHAIN.TX_AVG_BY_BLOCK","COMMON.DATE_PATTERN","COMMON.DATE_SHORT_PATTERN","COMMON.DATE_MONTH_YEAR_PATTERN"]),r.blockchain.txCount(e.formData.currency,i)]).then((function(n){var i=n[0],o=n[1],r={hour:o["COMMON.DATE_PATTERN"],day:o["COMMON.DATE_SHORT_PATTERN"],month:o["COMMON.DATE_MONTH_YEAR_PATTERN"]};if((n=n[2])&&n.times){e.times=n.times,a("formatInteger");var l=a("formatDecimal");e.currencySymbol=a("currencySymbolNoHtml")(e.formData.currency,e.formData.useRelative),e.formData.rangeDuration,e.data=[n.amount,n.count];var c=r[e.formData.rangeDuration];e.labels=n.times.reduce((function(e,t){return e.concat(moment.unix(t).local().format(c))}),[]),e.colors=s.scale.fix(n.times.length),e.updateRange(n.times[0],n.times[n.times.length-1],t),e.options={responsive:!0,maintainAspectRatio:!0,title:{display:!0,text:i},scales:{yAxes:[{id:"y-axis-amount",position:"left"},{id:"y-axis-count",display:e.displayRightAxis,position:"right",gridLines:{drawOnChartArea:!1}}]},legend:{display:e.displayRightAxis,onClick:e.onLegendClick},tooltips:{enabled:!0,mode:"index",callbacks:{label:function(t,n){return 0===t.datasetIndex?n.datasets[t.datasetIndex].label+": "+l(t.yLabel)+" "+e.currencySymbol:n.datasets[t.datasetIndex].label+": "+t.yLabel}}}},e.datasetOverride=[{yAxisID:"y-axis-amount",type:"bar",label:o["GRAPH.BLOCKCHAIN.TX_AMOUNT_LABEL"],hoverBackgroundColor:s.rgba.calm(.6)},{yAxisID:"y-axis-count",type:"line",label:o["GRAPH.BLOCKCHAIN.TX_COUNT_LABEL"],fill:!1,borderColor:s.rgba.gray(.5),borderWidth:2,backgroundColor:s.rgba.gray(.5),pointBackgroundColor:s.rgba.gray(.5),pointBorderColor:s.rgba.white(),pointHoverBackgroundColor:s.rgba.gray(1),pointHoverBorderColor:s.rgba.translucent(),pointRadius:3}]}}))},e.onChartClick=function(t,n,a){if(a){var o=e.times[a._index],r=moment.unix(o).utc().add(1,e.formData.rangeDuration).unix(),s="_exists_:transactions AND medianTime:>={0} AND medianTime:<{1}".format(o,r);e.formData.issuer&&(s+=" AND issuer:"+e.formData.issuer),i.go("app.blockchain_search",{q:s})}}}function ze(e,t,n,i,a,o,r){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.load=function(){return n.all([a(["GRAPH.BLOCKCHAIN.BLOCKS_ISSUERS_TITLE","GRAPH.BLOCKCHAIN.BLOCKS_ISSUERS_LABEL"]),r.blockchain.countByIssuer(e.formData.currency)]).then((function(t){var n=t[0];(t=t[1])&&t.data&&(e.data=t.data,e.labels=t.labels,e.blockCount=t.blockCount,e.issuers=t.issuers,e.barOptions={responsive:!0,maintainAspectRatio:e.maintainAspectRatio,title:{display:!0,text:n["GRAPH.BLOCKCHAIN.BLOCKS_ISSUERS_TITLE"]},scales:{yAxes:[{type:"linear",ticks:{beginAtZero:!0}}]}},e.colors=o.scale.custom(t.data.length))}))},e.onChartClick=function(t,n,a){if(a){var o=e.issuers[a._index];i.go("app.wot_identity",o)}}}function qe(e,t,n,i,a,o){e.extensionPoint=n.extensions.points.current.get(),e.enable=i.isEnable(),e.loading=!0,e.node=e.node||{},i.api.state.on.changed(e,(function(t){e.enable=t})),e.enter=function(n,i){return!e.node.currency&&i&&i.stateParams&&i.stateParams.currency&&(e.node.currency=i.stateParams.currency),e.node.currency?e.node.pubkey?e.load():t((function(){return e.enter(n,i)}),500):a.get().then((function(t){return e.node.currency=t?t.name:null,e.enter(n,i)}))},e.$on("$csExtension.enter",e.enter),e.load=function(){if(e.node.currency||e.node.pubkey)return console.info("[Graph] [peer] Loading blocks count for [{0}]".format(e.node.pubkey.substr(0,8))),o.node.blockCount(e.node.currency,e.node.pubkey).then((function(t){e.blockCount=t,e.loading=!1}))}}function Xe(e,t,n,i){e.extensionPoint=t.extensions.points.current.get(),e.enable=i.isEnable(),e.smallscreen=n.screen.isSmall(),i.api.state.on.changed(e,(function(t){e.enable=t}))}function Qe(e,t,n,i,a,o,r,s,l,c){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.formData.useRelative=angular.isDefined(e.formData.useRelative)?e.formData.useRelative:c.data.useRelative,e.displayShareAxis=!0,e.hiddenDatasets=[],e.init=function(e,t){},e.onUseRelativeChanged=function(){e.loading||e.load()},e.$watch("formData.useRelative",e.onUseRelativeChanged);var d=function(e){return Math.trunc(100*e)/100};e.load=function(t,i){return t=t||0,i=i||1e4,n.all([a(["GRAPH.CURRENCY.MONETARY_MASS_TITLE","GRAPH.CURRENCY.MONETARY_MASS_LABEL","GRAPH.CURRENCY.MONETARY_MASS_SHARE_LABEL"]),s.blockchain.withDividend(e.formData.currency,{from:t,size:i})]).then((function(t){var n=t[0];if((t=t[1])&&t.times){e.times=t.times;var i,a=t.times[t.times.length-1]-t.times[0];i=l(a<31557600?"medianDateShort":"formatDateMonth");var o=l("formatDecimal");e.currencySymbol=l("currencySymbolNoHtml")(e.formData.currency,e.formData.useRelative);var s=[];e.formData.useRelative?(s.push(t.blocks.reduce((function(e,t){return e.concat(d(t.monetaryMass/t.dividend/t.membersCount))}),[])),s.push(t.blocks.reduce((function(e,t){return e.concat(d(t.monetaryMass/t.dividend))}),[]))):(s.push(t.blocks.reduce((function(e,t){return e.concat(d(t.monetaryMass/t.membersCount/100))}),[])),s.push(t.blocks.reduce((function(e,t){return e.concat(t.monetaryMass/100)}),[]))),e.data=s,e.labels=t.times.reduce((function(e,t){return e.concat(i(t))}),[]),e.colors=r.scale.fix(t.times.length),e.options={responsive:!0,maintainAspectRatio:e.maintainAspectRatio,title:{display:!0,text:n["GRAPH.CURRENCY.MONETARY_MASS_TITLE"]},legend:{display:e.displayShareAxis,onClick:e.onLegendClick},scales:{yAxes:[{id:"y-axis-mn"},{id:"y-axis-mass",display:e.displayShareAxis,position:"right",gridLines:{drawOnChartArea:!1}}]},tooltips:{enabled:!0,mode:"index",callbacks:{label:function(t,n){return n.datasets[t.datasetIndex].label+": "+o(t.yLabel)+" "+e.currencySymbol}}}},e.datasetOverride=[{yAxisID:"y-axis-mn",type:"line",label:n["GRAPH.CURRENCY.MONETARY_MASS_SHARE_LABEL"],borderWidth:2,pointRadius:0,pointHitRadius:4,pointHoverRadius:3},{yAxisID:"y-axis-mass",type:"line",label:n["GRAPH.CURRENCY.MONETARY_MASS_LABEL"],fill:!1,showLine:!0,borderColor:r.rgba.energized(),borderWidth:1,backgroundColor:r.rgba.energized(),pointBackgroundColor:r.rgba.energized(),pointBorderColor:r.rgba.energized(),pointHoverBackgroundColor:r.rgba.energized(),pointHoverBorderColor:r.rgba.energized(),pointRadius:0,pointHitRadius:4,pointHoverRadius:3}],e.setScale(e.scale),e.blocks=t.blocks.reduce((function(e,t){return e.concat(t.number)}),[])}}))},e.onChartClick=function(t,n,a){if(a){var o=e.blocks[a._index];i.go("app.view_block",{number:o})}},e.showActionsPopover=function(t){o.popover.show(t,{templateUrl:"plugins/graph/templates/currency/popover_monetary_mass_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)}}function Je(e,t,n,i,a,o,r,s){e.formData={scale:"linear",beginAtZero:!1},angular.extend(this,n("GpCurrencyMonetaryMassCtrl",{$scope:e})),e.load=function(n,s){return n=n||0,s=s||1e4,t.all([i(["GRAPH.CURRENCY.UD_TITLE","COMMON.UNIVERSAL_DIVIDEND"]),o.blockchain.withDividend(e.formData.currency,{from:n,size:s})]).then((function(t){var n=t[0];if((t=t[1])&&t.times){e.times=t.times;var i,o=t.times[t.times.length-1]-t.times[0];i=r(o<31557600?"medianDateShort":"formatDateMonth");var s=r("formatDecimal");e.currencySymbol=r("currencySymbolNoHtml")(e.formData.currency,!1),e.data=[t.blocks.reduce((function(e,t){return e.concat(t.dividend/100)}),[])],e.labels=t.times.reduce((function(e,t){return e.concat(i(t))}),[]),e.colors=t.blocks.reduce((function(e){return e.concat(a.rgba.calm(.5))}),[]),e.options={responsive:!0,maintainAspectRatio:e.maintainAspectRatio,title:{display:!0,text:n["GRAPH.CURRENCY.UD_TITLE"]},scales:{yAxes:[{id:"y-axis-ud",ticks:{beginAtZero:e.formData.beginAtZero}}]},tooltips:{enabled:!0,mode:"index",callbacks:{label:function(t,n){return n.datasets[t.datasetIndex].label+": "+s(t.yLabel)+" "+e.currencySymbol}}}},e.setScale(e.scale),e.datasetOverride=[{yAxisID:"y-axis-ud",type:"line",label:n["COMMON.UNIVERSAL_DIVIDEND"],borderWidth:2,pointRadius:0,pointHitRadius:4,pointHoverRadius:3}],e.blocks=t.blocks.reduce((function(e,t){return e.concat(t.number)}),[])}}))},e.showActionsPopover=function(t){s.popover.show(t,{templateUrl:"plugins/graph/templates/currency/popover_monetary_mass_actions.html",scope:e,autoremove:!0,afterShow:function(t){e.actionsPopover=t}})},e.hideActionsPopover=function(){e.actionsPopover&&(e.actionsPopover.hide(),e.actionsPopover=null)}}function Ze(e,t,n,i,a,o,r,s){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.load=function(t,i){return t=t||0,i=i||1e4,n.all([a(["GRAPH.CURRENCY.MEMBERS_COUNT_TITLE","GRAPH.CURRENCY.MEMBERS_COUNT_LABEL"]),r.blockchain.withDividend(e.formData.currency,{from:t,size:i,withCurrent:!0})]).then((function(t){var n=t[0];if((t=t[1])&&t.times){e.times=t.times;var i,a=t.times[t.blocks.length-1]-t.times[0];i=s(a<31557600?"medianDateShort":"formatDateMonth"),e.labels=t.times.reduce((function(e,t){return e.concat(i(t))}),[]),e.options={responsive:!0,maintainAspectRatio:e.maintainAspectRatio,title:{display:!0,text:n["GRAPH.CURRENCY.MEMBERS_COUNT_TITLE"]},scales:{xAxes:[{position:"bottom"}],yAxes:[{id:"y-axis-1",ticks:{beginAtZero:!1}}]}},e.datasetOverride=[{yAxisID:"y-axis-1",type:"line",label:n["GRAPH.CURRENCY.MEMBERS_COUNT_LABEL"],borderWidth:2,pointRadius:0,pointHitRadius:4,pointHoverRadius:3}],e.data=[t.blocks.reduce((function(e,t){return e.concat(t.membersCount)}),[])],e.colors=o.scale.fix(t.blocks.length)}}))},e.onChartClick=function(t,n,a){if(a)if(a._index){var o=e.times[a._index-1],r=moment.unix(o).utc().add(1,"day").unix();i.go("app.blockchain_search",{q:"(_exists_:joiners OR _exists_:leavers OR _exists_:revoked OR _exists_:excluded) AND medianTime:>{0} AND medianTime:<={1}".format(o,r)})}else i.go("app.view_block",{number:0})}}function et(e,t,n,i,a,o,r,s,l,c){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.init=function(t,n){n&&n.stateParams&&n.stateParams.pubkey?e.formData.pubkey=n.stateParams.pubkey:c.isLogin()&&(e.formData.pubkey=c.data.pubkey)};var d=e.setScale;e.setScale=function(t){e.data[e.data.length-2]="linear"===t?_.map(e.data[e.data.length-2],(function(e){return-1*Math.abs(e)})):_.map(e.data[e.data.length-2],(function(e){return Math.abs(e)})),d(t)},e.load=function(t){t=!angular.isDefined(t)||t;var i=!0;return r.load(e.formData.pubkey,null,{cache:!0}).then((function(t){return e.identity=t,i=e.identity.isMember||e.identity.wasMember,n.all([o("GRAPH.ACCOUNT.BALANCE_TITLE",e.formData),o(["GRAPH.ACCOUNT.UD_LABEL","GRAPH.ACCOUNT.TX_RECEIVED_LABEL","GRAPH.ACCOUNT.TX_SENT_LABEL","GRAPH.ACCOUNT.UD_ACCUMULATION_LABEL","GRAPH.ACCOUNT.TX_ACCUMULATION_LABEL","GRAPH.ACCOUNT.BALANCE_LABEL","COMMON.DATE_PATTERN","COMMON.DATE_SHORT_PATTERN","COMMON.DATE_MONTH_YEAR_PATTERN"]),s.blockchain.movement(e.formData.currency,angular.copy(e.formData,{withUD:i}))])})).then((function(n){var o=n[0],r=n[1];if((n=n[2])&&n.times){e.times=n.times;var s=a("formatDecimal");e.currencySymbol=a("currencySymbolNoHtml")(e.formData.currency,e.formData.useRelative),e.data=[n.ud,n.received,n.sent,n.balance];var c={hour:r["COMMON.DATE_PATTERN"],day:r["COMMON.DATE_SHORT_PATTERN"],month:r["COMMON.DATE_MONTH_YEAR_PATTERN"]}[e.formData.rangeDuration];e.labels=n.times.reduce((function(e,t){return e.concat(moment.unix(t).local().format(c))}),[]),e.colors=l.scale.fix(n.times.length),e.updateRange(n.times[0],n.times[n.times.length-1],t),e.options={responsive:!0,maintainAspectRatio:!0,title:{display:!0,text:o},scales:{xAxes:[{stacked:!0}],yAxes:[{id:"y-axis-left",type:"linear",position:"left",stacked:!0}]},legend:{display:!0,onClick:e.onLegendClick},tooltips:{enabled:!0,mode:"index",callbacks:{label:function(t,n){return n.datasets[t.datasetIndex].label+": "+(t.yLabel?s(t.yLabel)+" "+e.currencySymbol:"0")}}}},e.datasetOverride=[{yAxisID:"y-axis-left",type:"bar",label:r["GRAPH.ACCOUNT.UD_LABEL"],backgroundColor:l.rgba.energized(.3),hoverBackgroundColor:l.rgba.energized(.5),borderWidth:1},{yAxisID:"y-axis-left",type:"bar",label:r["GRAPH.ACCOUNT.TX_RECEIVED_LABEL"],backgroundColor:l.rgba.positive(.4),hoverBackgroundColor:l.rgba.positive(.6),borderWidth:1},{yAxisID:"y-axis-left",type:"bar",label:r["GRAPH.ACCOUNT.TX_SENT_LABEL"],backgroundColor:l.rgba.assertive(.4),hoverBackgroundColor:l.rgba.assertive(.6),borderWidth:1},{yAxisID:"y-axis-left",type:"line",label:r["GRAPH.ACCOUNT.BALANCE_LABEL"],fill:"origin",borderColor:l.rgba.calm(.5),borderWidth:2,pointBackgroundColor:l.rgba.calm(.5),pointBorderColor:l.rgba.white(),pointHoverBackgroundColor:l.rgba.calm(1),pointHoverBorderColor:"rgba(0,0,0,0)",pointRadius:3,lineTension:.1}],i||(e.data.splice(0,1),e.datasetOverride.splice(0,1))}}))},e.onChartClick=function(t,n,a){if(a){var o=e.times[a._index],r=moment.unix(o).utc().add(1,e.formData.rangeDuration).unix(),s="medianTime:>={0} AND medianTime:<{1}".format(o,r);e.formData.pubkey&&(s+=" AND (transactions.issuers:"+e.formData.pubkey+" OR transactions.outputs:*"+e.formData.pubkey+")"),i.go("app.blockchain_search",{q:s})}}}function tt(e,t,n,i,a,o){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.init=function(t,n){e.pubkey=n&&n.stateParams&&n.stateParams.pubkey},e.load=function(t,n){if(e.pubkey)return a.load(e.pubkey,-1).then((function(t){t&&t.tx&&t.tx.history&&(e.inputChart=e.computeChartData(_.filter(t.tx.history,(function(e){return e.amount>0}))),e.outputChart=e.computeChartData(_.filter(t.tx.history,(function(e){return e.amount<0}))))}))},e.computeChartData=function(e){var t=n("formatPubkey"),i={};_.forEach(e,(function(e){i[e.pubkey]=i[e.pubkey]||{label:e.name||e.uid||t(e.pubkey),pubkey:e.pubkey,sum:0},i[e.pubkey].sum+=Math.abs(e.amount)}));var a=_.sortBy(_.values(i),"sum").reverse();return _.each(a,(function(e){e.sum=e.sum/100})),{data:_.pluck(a,"sum"),labels:_.pluck(a,"label"),pubkeys:_.pluck(a,"pubkey"),colors:o.scale.custom(Math.max(10,a.length))}},e.onInputChartClick=function(t,n,a){if(a){var o=e.inputChart.pubkeys[a._index];i.go("app.wot_identity",{pubkey:o})}},e.onOutputChartClick=function(t,n,a){if(a){var o=e.outputChart.pubkeys[a._index];i.go("app.wot_identity",{pubkey:o})}}}function nt(e,t,n,i,a,o,r,s,l){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.init=function(t,n){n&&n.stateParams&&n.stateParams.pubkey?e.formData.pubkey=n.stateParams.pubkey:l.isLogin()&&(e.formData.pubkey=l.data.pubkey)},e.load=function(t){var i=e.formData;return n.all([o("GRAPH.ACCOUNT.CERTIFICATION_TITLE",i),o(["GRAPH.ACCOUNT.GIVEN_CERT_LABEL","GRAPH.ACCOUNT.RECEIVED_CERT_LABEL","GRAPH.ACCOUNT.GIVEN_CERT_DELTA_LABEL","GRAPH.ACCOUNT.RECEIVED_CERT_DELTA_LABEL","COMMON.DATE_PATTERN","COMMON.DATE_SHORT_PATTERN","COMMON.DATE_MONTH_YEAR_PATTERN"]),r.wot.certifications(i)]).then((function(n){var i=n[0],o=n[1];if((n=n[2])&&n.times){e.times=n.times;var r=a("formatInteger");e.data=[n.deltaReceived,n.received,n.deltaGiven,n.given],e.labels=n.labels;var l={hour:o["COMMON.DATE_PATTERN"],day:o["COMMON.DATE_SHORT_PATTERN"],month:o["COMMON.DATE_MONTH_YEAR_PATTERN"]}[e.formData.rangeDuration];e.labels=n.times.reduce((function(e,t){return e.concat(moment.unix(t).local().format(l))}),[]),e.colors=s.scale.fix(n.times.length),e.updateRange(n.times[0],n.times[n.times.length-1],t),e.options={responsive:!0,maintainAspectRatio:!0,title:{display:!0,text:i},scales:{yAxes:[{id:"y-axis-left",type:"linear",position:"left"},{id:"y-axis-hide",type:"linear",display:!1,position:"right"}]},legend:{display:!0},tooltips:{enabled:!0,mode:"index",callbacks:{label:function(e,t){var n=(0===e.datasetIndex||2===e.datasetIndex)&&e.yLabel>0;return t.datasets[e.datasetIndex].label+": "+(n?"+":"")+!e.yLabel?"0":r(e.yLabel)}}}},e.datasetOverride=[{yAxisID:"y-axis-left",type:"bar",label:o["GRAPH.ACCOUNT.RECEIVED_CERT_DELTA_LABEL"],borderColor:s.rgba.positive(.6),borderWidth:1,backgroundColor:s.rgba.positive(.4),hoverBackgroundColor:s.rgba.positive(.6)},{yAxisID:"y-axis-left",type:"line",label:o["GRAPH.ACCOUNT.RECEIVED_CERT_LABEL"],fill:!1,borderColor:s.rgba.positive(.5),borderWidth:2,backgroundColor:s.rgba.positive(1),pointBackgroundColor:s.rgba.positive(.5),pointBorderColor:s.rgba.white(),pointHoverBackgroundColor:s.rgba.positive(1),pointHoverBorderColor:"rgba(0,0,0,0)",pointRadius:3},{yAxisID:"y-axis-left",type:"bar",label:o["GRAPH.ACCOUNT.GIVEN_CERT_DELTA_LABEL"],borderColor:s.rgba.assertive(.6),borderWidth:1,backgroundColor:s.rgba.assertive(.4),hoverBackgroundColor:s.rgba.assertive(.6)},{yAxisID:"y-axis-left",type:"line",label:o["GRAPH.ACCOUNT.GIVEN_CERT_LABEL"],fill:!1,borderColor:s.rgba.assertive(.4),borderWidth:2,backgroundColor:s.rgba.assertive(1),pointBackgroundColor:s.rgba.assertive(.4),pointBorderColor:s.rgba.white(),pointHoverBackgroundColor:s.rgba.assertive(1),pointHoverBorderColor:"rgba(0,0,0,0)",pointRadius:3,lineTension:.1}]}}))},e.onChartClick=function(t,n,a){if(a){var o=e.times[a._index],r=moment.unix(o).utc().add(1,e.formData.rangeDuration).unix(),s="_exists_:transactions AND medianTime:>={0} AND medianTime:<{1}".format(o,r);e.formData.pubkey&&(s+=" AND (transactions.issuers:"+e.formData.pubkey+" OR transactions.outputs:*"+e.formData.pubkey+")"),i.go("app.blockchain_search",{q:s})}}}function it(e,t,n,i,a,o,r,s){angular.extend(this,n("GpCurrencyAbstractCtrl",{$scope:e})),e.formData.rangeDuration="month",e.displayRightAxis=!0,e.hiddenDatasets=[],e.chartIdPrefix="docstats-chart-",e.charts=[{id:"user",title:"GRAPH.DOC_STATS.USER.TITLE",series:[{key:"user_profile",label:"GRAPH.DOC_STATS.USER.USER_PROFILE",color:o.rgba.royal(.7),pointHoverBackgroundColor:o.rgba.royal(),clickState:{name:"app.document_search",params:{index:"user",type:"profile"}}},{key:"user_settings",label:"GRAPH.DOC_STATS.USER.USER_SETTINGS",color:o.rgba.gray(.5),pointHoverBackgroundColor:o.rgba.gray(),clickState:{name:"app.document_search",params:{index:"user",type:"settings"}}}]},{id:"user_delta",title:"GRAPH.DOC_STATS.USER_DELTA.TITLE",series:[{key:"user_profile_delta",label:"GRAPH.DOC_STATS.USER_DELTA.USER_PROFILE",type:"line",yAxisID:"y-axis-delta",color:o.rgba.royal(),pointHoverBackgroundColor:o.rgba.royal()},{key:"user_settings_delta",label:"GRAPH.DOC_STATS.USER_DELTA.USER_SETTINGS",type:"line",yAxisID:"y-axis-delta",color:o.rgba.gray(.5),pointHoverBackgroundColor:o.rgba.gray()}]},{id:"message",title:"GRAPH.DOC_STATS.MESSAGE.TITLE",series:[{key:"message_inbox",label:"GRAPH.DOC_STATS.MESSAGE.MESSAGE_INBOX",color:o.rgba.royal(),pointHoverBackgroundColor:o.rgba.royal(),clickState:{name:"app.document_search",params:{index:"message",type:"inbox"}}},{key:"message_outbox",label:"GRAPH.DOC_STATS.MESSAGE.MESSAGE_OUTBOX",color:o.rgba.calm(),pointHoverBackgroundColor:o.rgba.calm(),clickState:{name:"app.document_search",params:{index:"message",type:"outbox"}}},{key:"invitation_certification",label:"GRAPH.DOC_STATS.MESSAGE.INVITATION_CERTIFICATION",color:o.rgba.gray(.5),pointHoverBackgroundColor:o.rgba.gray(),clickState:{name:"app.document_search",params:{index:"invitation",type:"certification"}}}]},{id:"social",title:"GRAPH.DOC_STATS.SOCIAL.TITLE",series:[{key:"page_record",label:"GRAPH.DOC_STATS.SOCIAL.PAGE_RECORD",color:o.rgba.royal(),pointHoverBackgroundColor:o.rgba.royal(),clickState:{name:"app.document_search",params:{index:"page",type:"record"}}},{key:"group_record",label:"GRAPH.DOC_STATS.SOCIAL.GROUP_RECORD",color:o.rgba.calm(),pointHoverBackgroundColor:o.rgba.calm(),clickState:{name:"app.document_search",params:{index:"group",type:"record"}}},{key:"page_comment",label:"GRAPH.DOC_STATS.SOCIAL.PAGE_COMMENT",color:o.rgba.gray(.5),pointHoverBackgroundColor:o.rgba.gray(),clickState:{name:"app.document_search",params:{index:"page",type:"comment"}}}]},{id:"other",title:"GRAPH.DOC_STATS.OTHER.TITLE",series:[{key:"history_delete",label:"GRAPH.DOC_STATS.OTHER.HISTORY_DELETE",color:o.rgba.gray(.5),pointHoverBackgroundColor:o.rgba.gray(),clickState:{name:"app.document_search",params:{index:"history",type:"delete"}}}]}];var l=s("formatInteger");e.defaultChartOptions={responsive:!0,maintainAspectRatio:e.maintainAspectRatio,title:{display:!0},legend:{display:!0,onClick:e.onLegendClick},scales:{xAxes:[{stacked:!0}],yAxes:[{id:"y-axis",stacked:!0},{id:"y-axis-delta",stacked:!1},{id:"y-axis-delta-right",stacked:!1,display:e.displayRightAxis,position:"right",gridLines:{drawOnChartArea:!1}}]},tooltips:{enabled:!0,mode:"index",callbacks:{label:function(e,t){return t.datasets[e.datasetIndex].label+": "+l(e.yLabel)}}}},e.init=function(t,n){if(n&&n.stateParams){var i=n.stateParams&&n.stateParams.server||void 0;i&&(console.debug("[docstats] Will use server: "+i),angular.merge(e.formData,{server:n.stateParams.server,useSsl:n.stateParams.useSsl,useTor:n.stateParams.useTor}))}},e.load=function(t){return i.all([a(e.charts.reduce((function(e,t){return e.concat(t.series.reduce((function(e,t){return e.concat(t.label)}),[t.title]))}),["COMMON.DATE_PATTERN","COMMON.DATE_SHORT_PATTERN","COMMON.DATE_MONTH_YEAR_PATTERN"])),r.docstat.get(e.formData)]).then((function(n){var i=n[0],a={hour:i["COMMON.DATE_PATTERN"],day:i["COMMON.DATE_SHORT_PATTERN"],month:i["COMMON.DATE_MONTH_YEAR_PATTERN"]};if((n=n[1])&&n.times){e.times=n.times;var r=a[e.formData.rangeDuration];e.labels=_.map(n.times,(function(e){return moment.unix(e).local().format(r)})),e.updateRange(n.times[0],n.times[n.times.length-1],t),e.setScale(e.scale),_.forEach(e.charts,(function(t){var a={};t.data=_.map(t.series,(function(e){if(a[e.yAxisID||"y-axis"]=!0,e.key.endsWith("_delta")){var t=e.key.substring(0,e.key.length-"_delta".length);return((i=n[t])?_.map(i,(function(e){var t=void 0!==e&&void 0!==o?e-(o||e):void 0;return o=e,t})):void 0)||[]}var i,o;return n[e.key]||[]})),t.options=angular.copy(e.defaultChartOptions),t.options.title.text=i[t.title],t.options.scales.yAxes=t.options.scales.yAxes.reduce((function(e,t){return a[t.id]?e.concat(t):e}),[]),t.datasetOverride=_.map(t.series,(function(e){return{yAxisID:e.yAxisID||"y-axis",type:e.type||"line",label:i[e.label],fill:"line"!==e.type,borderWidth:2,pointRadius:"line"!==e.type?0:2,pointHitRadius:4,pointHoverRadius:3,borderColor:e.color,backgroundColor:e.color,pointBackgroundColor:e.color,pointBorderColor:e.color,pointHoverBackgroundColor:e.pointHoverBackgroundColor||e.color,pointHoverBorderColor:e.pointHoverBorderColor||o.rgba.white()}}))}))}}))},e.onChartClick=function(n,i,a){if(a){var o=_.find(e.charts,(function(t){return e.chartIdPrefix+t.id===a._chart.canvas.id})),r=o&&o.series[a._datasetIndex],s=e.times[a._index],l=moment.unix(s).utc().add(1,e.formData.rangeDuration).unix();if(r&&r.clickState&&r.clickState.name){var c=r.clickState.params?angular.copy(r.clickState.params):{};return c.q="time:>={0} AND time:<{1}".format(s,l),t.go(r.clickState.name,c)}r&&console.debug("Click on item index={0} on range [{1},{2}]".format(a._index,s,l))}}}function at(e,t,n,i,a,o,r){angular.extend(this,t("GpCurrencyAbstractCtrl",{$scope:e})),e.formData.rangeDuration="month",e.hiddenDatasets=[],e.charts=[{id:"count",title:"GRAPH.SYNCHRO.COUNT.TITLE",series:[{key:"inserts",type:"bar",label:"GRAPH.SYNCHRO.COUNT.INSERTS",color:a.rgba.royal(),pointHoverBackgroundColor:a.rgba.royal()},{key:"updates",type:"bar",label:"GRAPH.SYNCHRO.COUNT.UPDATES",color:a.rgba.calm(),pointHoverBackgroundColor:a.rgba.calm()},{key:"deletes",type:"bar",label:"GRAPH.SYNCHRO.COUNT.DELETES",color:a.rgba.assertive(.5),pointHoverBackgroundColor:a.rgba.assertive()}]},{id:"peer",title:"GRAPH.SYNCHRO.PEER.TITLE",series:[{key:"ES_USER_API",label:"GRAPH.SYNCHRO.PEER.ES_USER_API",color:a.rgba.royal(),pointHoverBackgroundColor:a.rgba.royal()},{key:"ES_SUBSCRIPTION_API",label:"GRAPH.SYNCHRO.PEER.ES_SUBSCRIPTION_API",color:a.rgba.gray(.5),pointHoverBackgroundColor:a.rgba.gray()}]},{id:"performance",title:"GRAPH.SYNCHRO.PERFORMANCE.TITLE",series:[{key:"duration",type:"bar",label:"GRAPH.SYNCHRO.PERFORMANCE.DURATION",color:a.rgba.gray(.5),pointHoverBackgroundColor:a.rgba.gray()}]}];var s=r("formatInteger");e.defaultChartOptions={responsive:!0,maintainAspectRatio:e.maintainAspectRatio,title:{display:!0},legend:{display:!0,onClick:e.onLegendClick},scales:{xAxes:[{stacked:!0}],yAxes:[{stacked:!0,id:"y-axis"}]},tooltips:{enabled:!0,mode:"index",callbacks:{label:function(e,t){return t.datasets[e.datasetIndex].label+": "+s(e.yLabel)}}}},e.init=function(t,n){if(n&&n.stateParams){var i=n.stateParams&&n.stateParams.server||void 0;i&&(console.debug("[synchro] Will use server: "+i),angular.merge(e.formData,n.stateParams))}},e.load=function(t){return n.all([i(e.charts.reduce((function(e,t){return e.concat(t.series.reduce((function(e,t){return e.concat(t.label)}),[t.title]))}),["COMMON.DATE_PATTERN","COMMON.DATE_SHORT_PATTERN","COMMON.DATE_MONTH_YEAR_PATTERN"])),o.synchro.execution.get(e.formData)]).then((function(n){var i=n[0],o={hour:i["COMMON.DATE_PATTERN"],day:i["COMMON.DATE_SHORT_PATTERN"],month:i["COMMON.DATE_MONTH_YEAR_PATTERN"]};if((n=n[1])&&n.times){e.times=n.times;var r=o[e.formData.rangeDuration];e.labels=n.times.reduce((function(e,t){return e.concat(moment.unix(t).local().format(r))}),[]),e.updateRange(n.times[0],n.times[n.times.length-1],t),e.setScale(e.scale),_.forEach(e.charts,(function(t){t.data=[],_.forEach(t.series,(function(e){t.data.push(n[e.key]||[])})),t.options=angular.copy(e.defaultChartOptions),t.options.title.text=i[t.title],t.datasetOverride=t.series.reduce((function(e,t){return e.concat({yAxisID:"y-axis",type:t.type||"line",label:i[t.label],fill:!0,borderWidth:2,pointRadius:0,pointHitRadius:4,pointHoverRadius:3,borderColor:t.color,backgroundColor:t.color,pointBackgroundColor:t.color,pointBorderColor:t.color,pointHoverBackgroundColor:t.pointHoverBackgroundColor||t.color,pointHoverBorderColor:t.pointHoverBorderColor||a.rgba.white()})}),[])}))}}))}}function ot(e,t,n,i,a){var o=[];e.mapId="map-user-profile-"+e.$id,e.map=i.map({markers:{},center:{zoom:13}}),e.loading=!0,e.mapId=e.mapId||"map-abstract-"+e.$id,e.enter=function(n,i){return e.formData&&(e.formData.title||e.formData.geoPoint)?(e.loading=!0,e.load()):t(e.enter,500)},e.$on("$csExtension.enter",e.enter),e.$on("$ionicParentView.enter",e.enter),e.load=function(){return e.formData.geoPoint&&e.formData.geoPoint.lat&&e.formData.geoPoint.lon?e.map.markers.geoPoint?(e.map.markers.geoPoint.lat=e.formData.geoPoint.lat,void(e.map.markers.geoPoint.lng=e.formData.geoPoint.lon)):a("MAP.PROFILE.MARKER_HELP").then((function(t){e.map.markers.geoPoint={message:t,lat:parseFloat(e.formData.geoPoint.lat),lng:parseFloat(e.formData.geoPoint.lon),draggable:!0,focus:!0},angular.extend(e.map.center,{lat:e.map.markers.geoPoint.lat,lng:e.map.markers.geoPoint.lng});var n=e.$watch("map.markers.geoPoint",(function(){e.loading||e.map.markers.geoPoint&&e.map.markers.geoPoint.lat&&e.map.markers.geoPoint.lng&&(e.formData.geoPoint=e.formData.geoPoint||{},e.formData.geoPoint.lat=e.map.markers.geoPoint.lat,e.formData.geoPoint.lon=e.map.markers.geoPoint.lng)}),!0);o.push(n),e.ionItemClass||(e.ionItemClass="done in"),e.loading=!1})):(_.forEach(o,(function(e){e()})),o=[],delete e.map.markers.geoPoint,e.loading=!1,n.when())},e.$watch("formData.geoPoint",(function(){e.loading||e.load()}),!0)}function rt(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E,b){angular.extend(this,l("WotIdentityAbstractCtrl",{$scope:e})),angular.extend(this,l("ESWotIdentityViewCtrl",{$scope:e}));var g,f={member:{type:"awesomeMarker",icon:"person",markerColor:"blue"},pending:{type:"awesomeMarker",icon:"clock",markerColor:"lightgreen",iconColor:"gray"},wallet:{type:"awesomeMarker",icon:"key",markerColor:"lightgray"}};e.loading=!0,e.loadingMarker=!0,e.mapId="map-wot-"+e.$id,e.map=E.map({cache:"map-wot",layers:{overlays:{member:{type:"featureGroup",name:"MAP.WOT.VIEW.LAYER.MEMBER",visible:!0},pending:{type:"featureGroup",name:"MAP.WOT.VIEW.LAYER.PENDING",visible:!0},wallet:{type:"featureGroup",name:"MAP.WOT.VIEW.LAYER.WALLET",visible:!0}}},bounds:{},markers:{},loading:!0},e.mapId),e.showDescription=!1,c().then((function(){e.enableDescription=!u.screen.isSmall()&&"a"===ionic.Platform.grade.toLowerCase(),e.enableDescription||console.debug("[map] [wot] Disable profile description.",ionic.Platform.grade)})),e.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!u.screen.isSmall()||t.enableBack})),e.enter=function(t,n){if(e.loading){if(u.loading.show({noBackdrop:!0}),n.stateParams&&n.stateParams.c){var i=n.stateParams.c.split(":");e.map.center.lat=parseFloat(i[0]),e.map.center.lng=parseFloat(i[1]),e.map.center.zoom=parseInt(i[2])}e.$watch("map.center",(function(){if(!e.loading)return a((function(){e.updateLocationHref()}),300)}),!0);var o=Date.now();e.loadMap().then(e.load).then((function(){console.debug("[map] [wot] Loaded in "+(Date.now()-o)+"ms"),e.showHelpTip()}))}else e.updateLocationHref(),e.showHelpTip()},e.$on("$ionicView.enter",e.enter),e.loadMap=function(){return s.all([r(["COMMON.BTN_HELP_TOUR_SCREEN","COMMON.BTN_REFRESH","MAP.COMMON.BTN_LOCALIZE_ME"]),d.getMap(e.mapId)]).then((function(t){var o=t[0],r=t[1];if(!e.map.loading)return r;u.screen.isSmall()||(L.easyButton({position:"topright",type:"replace",leafletClasses:!0,states:[{stateName:"show-help-tour",onClick:e.startHelpTour,title:o["COMMON.BTN_HELP_TOUR_SCREEN"],icon:"icon ion-easel"}]}).addTo(r),L.easyButton({position:"topright",type:"replace",leafletClasses:!0,states:[{stateName:"refresh",onClick:function(t,n){return e.load(n)},title:o["COMMON.BTN_REFRESH"],icon:"icon ion-refresh"}]}).addTo(r)),L.Control.loading({position:"topright",separate:!0}).addTo(r),E.control.localizeMe({title:o["MAP.COMMON.BTN_LOCALIZE_ME"]}).addTo(r),g=L.layerGroup({visible:!1});var s=i(n.get("plugins/map/templates/wot/item_search_tooltip.html"));E.control.search({layer:g,propertyName:"title",buildTip:function(e,t){return s(t.layer.options)},moveToLocation:function(e,t,n){this.options.zoom?this._map.setView(e,this.options.zoom):this._map.panTo(e);var i=e.layer&&e.layer.options&&e.layer.options.popupMarkerId;a((function(){var e=i&&_.find(n._layers,(function(e){return e.options&&e.options.id===i}));e&&e.openPopup()}),400)},firstTipSubmit:!0,tooltipLimit:50}).addTo(r);var l=function(e){return e.options&&e.options.layer},c=L.markerClusterGroup({disableClusteringAtZoom:E.constants.LOCALIZE_ZOOM,maxClusterRadius:65,showCoverageOnHover:!1,iconCreateFunction:function(e){var t=_.countBy(e.getAllChildMarkers(),l),n=t.member?"blue":t.pending?"lightgreen":"lightgray",i=e.getChildCount(),a="marker-cluster "+n+" marker-cluster-";return a+=i<10?"small":i<100?"medium":"large",L.divIcon({html:"
"+i+"
",className:a,iconSize:new L.Point(40,40)})}});return r.eachLayer((function(e){e.addLayer&&angular.extend(e,L.featureGroup.subGroup(c))})),c.addTo(r),e.map.loading=!1,r}))},e.load=function(i){if(!i)return d.getMap(e.mapId).then(e.load);e.loading=!0,i.fire("dataloading");var o={fields:{description:e.enableDescription}};return e.map.bounds,b.load(o).then((function(o){var r={};if(g.clearLayers(),o&&o.length){var s=t("formatPubkey"),l=n.get("plugins/map/templates/wot/popup_marker.html");_.forEach(o,(function(t){var n=t.pending?"pending":t.uid?"member":"wallet",i=s(t.pubkey),a=t.index+"_"+(t.id||(t.uid?t.uid+":"+t.pubkey:t.pubkey)).replace(/-/g,"_"),o={layer:n,icon:f[n],opacity:t.uid?1:.7,title:t.name+" | "+i,lat:t.geoPoint.lat,lng:t.geoPoint.lon,getMessageScope:function(){var n=e.$new();return n.loadingMarker=!0,n.formData={},n.$applyAsync((function(){n.formData={pubkey:t.pubkey,uid:t.uid,name:t.name,profile:t},n.loadingMarker=!1})),n},focus:!1,message:l,id:a};r[a]=o;var c=t.name+(t.uid&&t.uid!=t.name?" | "+t.uid:"")+" | "+i,d=angular.merge({type:n,opacity:0,icon:L.divIcon({className:n+" ng-hide",iconSize:L.point(0,0)})},{title:c,pubkey:t.pubkey,uid:t.uid,name:t.name,pending:t.pending,popupMarkerId:a});g.addLayer(new L.Marker({lat:t.geoPoint.lat,lng:t.geoPoint.lon},d))}))}return e.map.markers=r,a((function(){e.loading=!1,i.fire("dataload"),u.loading.hide()}))})).catch((function(t){e.map.markers={},e.loading=!1,u.onError("MAP.WOT.ERROR.LOAD_POSITION_FAILED")(t)}))},e.updateLocationHref=function(t){(o.search()||{}).c&&E.center.isDefault(e.map.center)||(t=t||"{0}:{1}:{2}".format(e.map.center.lat.toFixed(4),e.map.center.lng.toFixed(4),e.map.center.zoom),o.search({c:t}).replace())},e.startHelpTour=function(){return e.showHelpTip(0,!0)},e.showHelpTip=function(t,n){if((n||m.isLogin())&&(t=angular.isDefined(t)?t:angular.isNumber(p.data.helptip.mapwot)?p.data.helptip.mapwot:0,n=!!angular.isDefined(n)&&n,!(t<0||t>2))){var i=e.createHelptipScope(n,"MapHelpTipCtrl");if(i)return i.tour=n,i.mapId=e.mapId,i.startMapWotTour(t,!1).then((function(e){i.$destroy(),p.data.helptip.mapwot=angular.isNumber(p.data.helptip.mapwot)?Math.max(e,p.data.helptip.mapwot):e,p.store()}))}}}function st(e,t,n,i,a,o,r,s,l,c,d,u,p,m,E){var b,g={shop:{type:"awesomeMarker",icon:"page-shop",markerColor:"blue"},company:{type:"awesomeMarker",icon:"page-company",markerColor:"blue"},association:{type:"awesomeMarker",icon:"page-association",markerColor:"lightgreen",iconColor:"gray"},institution:{type:"awesomeMarker",icon:"page-institution",markerColor:"lightgray"}};e.loading=!0,e.loadingMarker=!0,e.mapId="map-registry-"+e.$id,e.map=m.map({cache:"map-registry",layers:{overlays:{shop:{type:"featureGroup",name:"MAP.REGISTRY.VIEW.LAYER.SHOP",visible:!0},company:{type:"featureGroup",name:"MAP.REGISTRY.VIEW.LAYER.COMPANY",visible:!0},association:{type:"featureGroup",name:"MAP.REGISTRY.VIEW.LAYER.ASSOCIATION",visible:!0},institution:{type:"featureGroup",name:"MAP.REGISTRY.VIEW.LAYER.INSTITUTION",visible:!0}}},bounds:{},markers:{},loading:!0},e.mapId),e.formData={},e.showDescription=!1,l().then((function(){e.enableDescription=!d.screen.isSmall()&&"a"===ionic.Platform.grade.toLowerCase(),e.enableDescription||console.debug("[map] [wot] Disable profile description.",ionic.Platform.grade)})),e.$on("$ionicView.beforeEnter",(function(e,t){t.enableBack=!!d.screen.isSmall()||t.enableBack})),e.enter=function(t,n){if(e.loading){if(n.stateParams&&n.stateParams.c){var i=n.stateParams.c.split(":");e.map.center.lat=parseFloat(i[0]),e.map.center.lng=parseFloat(i[1]),e.map.center.zoom=parseInt(i[2])}e.$watch("map.center",(function(){if(!e.loading)return a((function(){e.updateLocationHref()}),300)}),!0),e.loadMap().then((function(){return p.isLogin()&&e.showHelpTip(),e.load()}))}else e.updateLocationHref(),p.isLogin()&&e.showHelpTip()},e.$on("$ionicView.enter",e.enter),e.loadMap=function(){return s.all([r(["COMMON.BTN_HELP_TOUR_SCREEN","COMMON.BTN_REFRESH","MAP.COMMON.BTN_LOCALIZE_ME"]),c.getMap(e.mapId)]).then((function(t){var o=t[0],r=t[1];if(!e.map.loading)return r;d.screen.isSmall()||L.easyButton({position:"topright",type:"replace",leafletClasses:!0,states:[{stateName:"refresh",onClick:function(t,n){return e.load(n)},title:o["COMMON.BTN_REFRESH"],icon:"icon ion-refresh"}]}).addTo(r),L.Control.loading({position:"topright",separate:!0}).addTo(r),m.control.localizeMe({title:o["MAP.COMMON.BTN_LOCALIZE_ME"]}).addTo(r),b=L.layerGroup({visible:!1});var s=i(n.get("plugins/map/templates/registry/item_search_tooltip.html"));m.control.search({layer:b,propertyName:"title",buildTip:function(e,t){return s(t.layer.options)},moveToLocation:function(e,t,n){this.options.zoom?this._map.setView(e,this.options.zoom):this._map.panTo(e);var i=e.layer&&e.layer.options&&e.layer.options.popupMarkerId;a((function(){var e=i&&_.find(n._layers,(function(e){return e.options&&e.options.id===i}));e&&e.openPopup()}),400)},firstTipSubmit:!0,tooltipLimit:50}).addTo(r);var l=function(e){return e.options&&e.options.layer},c=L.markerClusterGroup({disableClusteringAtZoom:m.constants.LOCALIZE_ZOOM,maxClusterRadius:65,showCoverageOnHover:!1,iconCreateFunction:function(e){var t=_.countBy(e.getAllChildMarkers(),l),n=t.shop||t.company?"blue":t.association?"lightgreen":"lightgray",i=e.getChildCount(),a="marker-cluster "+n+" marker-cluster-";return a+=i<10?"small":i<100?"medium":"large",L.divIcon({html:"
"+i+"
",className:a,iconSize:new L.Point(40,40)})}});return r.eachLayer((function(e){e.addLayer&&angular.extend(e,L.featureGroup.subGroup(c))})),c.addTo(r),e.map.loading=!1,r}))},e.load=function(i){if(!i)return c.getMap(e.mapId).then(e.load);e.loading=!0,i.fire("dataloading");var a={fields:{description:e.enableDescription}};return E.load(a).then((function(a){var o={};if(b.clearLayers(),a&&a.length){var r=t("formatPubkey"),s=n.get("plugins/map/templates/registry/popup_marker.html");_.forEach(a,(function(t){var n=r(t.pubkey),i=t.index+"_"+t.id.replace(/-/g,"_"),a={layer:t.type,icon:g[t.type],opacity:1,title:t.name+" | "+n,lat:t.geoPoint.lat,lng:t.geoPoint.lon,getMessageScope:function(){var n=e.$new();return n.loadingMarker=!0,n.formData={},n.$applyAsync((function(){angular.extend(n.formData,t),n.loadingMarker=!1})),n},focus:!1,message:s,id:i};o[i]=a;var l=t.name+" | "+n,c=angular.merge({type:t.type,opacity:0,icon:L.divIcon({className:t.type+" ng-hide",iconSize:L.point(0,0)})},{title:l,pubkey:t.pubkey,name:t.name,popupMarkerId:i});b.addLayer(new L.Marker({lat:t.geoPoint.lat,lng:t.geoPoint.lon},c))}))}e.map.markers=o,e.loading=!1,i.fire("dataload")})).catch((function(t){e.map.markers={},e.loading=!1,d.onError("MAP.WOT.ERROR.LOAD_POSITION_FAILED")(t)}))},e.updateLocationHref=function(t){(o.search()||{}).c&&m.center.isDefault(e.map.center)||(t=t||"{0}:{1}:{2}".format(e.map.center.lat.toFixed(4),e.map.center.lng.toFixed(4),e.map.center.zoom),o.search({c:t}).replace())},e.$on("centerUrlHash",(function(t,n){if(!e.loading)return a((function(){e.updateLocationHref(n)}),300)})),e.startHelpTour=function(){return e.showHelpTip(0,!0)},e.showHelpTip=function(t,n){if(t=angular.isDefined(t)?t:angular.isNumber(u.data.helptip.mapwot)?u.data.helptip.mapwot:0,n=!!angular.isDefined(n)&&n,!(t<0||t>2)){var i=e.createHelptipScope(n,"MapHelpTipCtrl");if(i)return i.tour=n,i.mapId=e.mapId,i.startMapWotTour(t,!1).then((function(e){i.$destroy(),u.data.helptip.mapwot=angular.isNumber(u.data.helptip.mapwot)?Math.max(e,u.data.helptip.mapwot):e,u.store()}))}}}function lt(e,t){e.mapId="map-page-"+e.$id,angular.extend(this,t("MapEditPositionAbstractCtrl",{$scope:e}))}function ct(e,t){e.mapId="map-profile-"+e.$id,angular.extend(this,t("MapEditPositionAbstractCtrl",{$scope:e}))}function dt(e,t){angular.extend(this,t("HelpTipCtrl",{$scope:e})),e.mapId=void 0,e.startMapWotTour=function(t,n){var i=[function(){return e.showHelpTip("helptip-map-wot",{bindings:{content:"MAP.HELP.TIP.WOT",icon:{position:"center",glyph:"ion-information-circled"}}})},function(){return e.showHelpTip(null,{selector:"#{0} .leaflet-control-search".format(e.mapId),bindings:{content:"MAP.HELP.TIP.WOT_BTN_SEARCH",icon:{position:"center"}}})},function(){return e.showHelpTip(null,{selector:"#{0} .leaflet-control-layers".format(e.mapId),bindings:{content:"MAP.HELP.TIP.WOT_BTN_LAYERS",icon:{position:"right"},hasNext:n}})}];return e.executeStep("mapwot",i,t)}}if(angular.module("cesium.settings.services",["ngApi","cesium.config"]).factory("csSettings",["$rootScope","$q","$window","Api","localStorage","$translate","csConfig",function(e,t,n,i,a,o,r){var s=[{id:"en",label:"English",flag:"us"},{id:"en-GB",label:"English (UK)",flag:"gb"},{id:"eo-EO",label:"Esperanto",flag:"eo"},{id:"fr-FR",label:"Français",flag:"fr"},{id:"nl-NL",label:"Nederlands",flag:"nl"},{id:"es-ES",label:"Spanish",flag:"es"},{id:"it-IT",label:"Italiano",flag:"it"}],l=r.fallbackLanguage?c(r.fallbackLanguage):"en";function c(e){if(!e)return l;if(_.findWhere(s,{id:e}))return e;var t=e.split("-");if(t.length>1)return c(t[0]);var n=_.find(s,(function(t){return String.prototype.startsWith.call(t.id,e)}));return n?n.id:l}var d,u,p,m,E={STORAGE_KEY:"settings",KEEP_AUTH_IDLE_SESSION:9999},b={timeout:4e3,cacheTimeMs:6e4,timeWarningExpireMembership:5184e3,timeWarningExpire:7776e3,minVersion:"1.1.0",sourceUrl:"https://git.duniter.org/clients/cesium-grp/cesium",sourceLicenseUrl:"https://git.duniter.org/clients/cesium-grp/cesium/-/raw/master/LICENSE",newIssueUrl:"https://git.duniter.org/clients/cesium-grp/cesium/issues/new",userForumUrl:"https://forum.monnaie-libre.fr",latestReleaseUrl:"https://api.github.com/repos/duniter/cesium/releases/latest",duniterLatestReleaseUrl:"https://api.github.com/repos/duniter/duniter/releases/latest",httpsMode:!1},g=angular.merge({useRelative:!1,useLocalStorage:!!n.localStorage,useLocalStorageEncryption:!1,persistCache:!1,walletHistoryTimeSecond:2592e3,walletHistorySliceSecond:432e3,walletHistoryAutoRefresh:!0,rememberMe:!0,keepAuthIdle:600,showUDHistory:!0,expertMode:!1,decimalCount:4,uiEffects:!0,blockValidityWindow:6,helptip:{enable:!0,installDocUrl:"https://duniter.org/en/wiki/duniter/install/",currency:0,network:0,wotLookup:0,wot:0,wotCerts:0,wallet:0,walletCerts:0,wallets:0,header:0,settings:0},currency:{allRules:!1,allWotRules:!1},wallet:{showPubkey:!0,alertIfUnusedWallet:!0},locale:{id:(p=r.defaultLanguage||o.use(),m=c(p),p!==m&&console.debug("[settings] Fix locale [{0}] -> [{1}]".format(p,m)),m)},license:{en:"license/license_g1-en","fr-FR":"license/license_g1-fr-FR","es-ES":"license/license_g1-es-ES"}},b,r),f={},h=!1,T=new i(this,"csSettings"),v=function(){if(angular.isUndefined(d)||!angular.equals(d,f))return d=angular.copy(f),T.data.raise.changed(f)},I=function(){return h?(f.useLocalStorage?!0===f.node.temporary?a.getObject(E.STORAGE_KEY).then((function(e){var t=angular.copy(f);return t.node=e&&e.node||{},delete t.temporary,a.setObject(E.STORAGE_KEY,t)})):a.setObject(E.STORAGE_KEY,f):a.setObject(E.STORAGE_KEY,null)).then((function(){return f.useLocalStorage&&console.debug("[setting] Saved locally"),T.data.raisePromise.store(f)})).then(v):(console.debug("[setting] Waiting start finished..."),(u||R()).then(I))},O=function(e){if(e){var t=!1;if(e.locale&&e.locale.id){var n=c(e.locale.id);e.locale=_.findWhere(s,{id:n}),t=!f.locale||e.locale.id!==f.locale.id||e.locale.id!==o.use()}_.keys(b).forEach((function(t){e[t]=g[t]})),angular.merge(f,e),(e&&e.node&&!e.node.temporary||!f.node.temporary)&&delete f.node.temporary,t&&o.use(f.locale.id)}},N=function(){var e=Date.now();return a.getObject(E.STORAGE_KEY).then((function(t){if(!t)return console.debug("[settings] No settings in local storage. Using defaults."),O(g),void v();O(t),console.debug("[settings] Loaded from local storage in "+(Date.now()-e)+"ms"),v()}))},R=function(){return console.debug("[settings] Starting..."),u=a.ready().then(N).then((function(){console.debug("[settings] Started"),h=!0,u=null,T.data.raise.ready(f)}))};return e.$on("$translateChangeSuccess",(function(){var e=o.use();console.debug("[settings] Locale ["+e+"]");try{moment.locale(e.toLowerCase())}catch(t){try{moment.locale(e.substr(0,2))}catch(e){moment.locale("en-gb"),console.warn("[settings] Unknown local for moment lib. Using default [en]")}}try{numeral.language(e.toLowerCase())}catch(t){try{numeral.language(e.substring(0,2))}catch(e){numeral.language("en-gb"),console.warn("[settings] Unknown local for numeral lib. Using default [en]")}}T.locale.raise.changed(e)})),T.registerEvent("data","reset"),T.registerEvent("data","changed"),T.registerEvent("data","store"),T.registerEvent("data","ready"),T.registerEvent("locale","changed"),O(g),{isStarted:function(){return h},ready:function(){return h?t.when():u||R()},start:R,data:f,apply:O,getByPath:function(e,t){var n=f;return _.each(e.split("."),(function(e){n=n[e],angular.isUndefined(n)&&(n=t)})),n},reset:function(){return _.keys(f).forEach((function(e){delete f[e]})),O(g),T.data.raisePromise.reset(f).then(I)},store:I,restore:N,getLicenseUrl:function(){var e=f.locale&&f.locale.id||r.defaultLanguage||"en";return r.license?r.license[e]?r.license[e]:g.license[r.defaultLanguage||"en"]||r.license:void 0},getFeedUrl:function(){var e=f.locale&&f.locale.id||r.defaultLanguage||"en";return r.feed&&r.feed.jsonFeed?r.feed.jsonFeed[e]?r.feed.jsonFeed[e]:g.feed.jsonFeed[r.defaultLanguage||"en"]||r.feed:void 0},defaultSettings:g,api:T,locales:s,constants:E}}]),angular.module("cesium.network.services",["ngApi","cesium.currency.services","cesium.http.services"]).factory("csNetwork",["$rootScope","$q","$interval","$timeout","$window","csConfig","BMA","csHttp","csCurrency","Api",function(t,i,a,o,r,s,l,c,d,u){var p,m="https:"===r.location.protocol,E=new u(this,"csNetwork"),b={bma:null,listeners:[],loading:!0,peers:[],filter:{member:!0,mirror:!0,endpoint:null,online:!1,bma:!1,ssl:void 0,tor:void 0},sort:{type:null,asc:!0,compact:!0},groupBy:"pubkey",expertMode:!1,knownBlocks:[],mainBlock:null,minOnlineBlockNumber:0,uidsByPubkeys:null,searchingPeersOnNetwork:!1,difficulties:null,ws2pHeads:null,timeout:s.timeout},g=function(e){return e&&[e.number,e.hash].join("-")},f=function(){return b.bma.network.ws2p.heads().then((function(e){b.ws2pHeads=e.heads?e.heads.reduce((function(e,t){if(t.message&&t.sig)try{var i=new n(t.message);e[[i.pubkey,i.ws2pid].join("-")]=i}catch(e){console.error("[network] Ignoring WS2P head.",e&&e.message||e)}return e}),{}):{}})).catch((function(e){if(e&&e.ucode==l.errorCodes.HTTP_LIMITATION)return o((function(){return f()}),3e3);console.error(e),b.ws2pHeads={}}))},h=function(){return b.bma.blockchain.stats.difficulties().then((function(e){b.difficulties=e.levels?e.levels.reduce((function(e,t){return t.uid&&t.level&&(e[t.uid]=t.level),e}),{}):{}})).catch((function(e){if(e&&e.ucode==l.errorCodes.HTTP_LIMITATION)return o((function(){return h()}),3e3);console.error(e),b.difficulties={}}))},T=function(){b.peers=[],b.searchingPeersOnNetwork=!0,b.loading=!0,b.bma=b.bma||l;var t=[];p&&a.cancel(p),p=a((function(){t.length?R(t):b.loading&&!b.searchingPeersOnNetwork&&(b.loading=!1,a.cancel(p),S(!0),console.debug("[network] Finish: {0} peers found.".format(b.peers.length)))}),1e3);var n=[b.bma.wot.member.uids().then((function(e){b.uidsByPubkeys=e})).catch((function(e){console.error(e),b.uidsByPubkeys={}})),f()];return b.expertMode&&n.push(h()),i.all(n).then((function(){return b.bma&&b.bma.network.peers()})).then((function(n){if(n&&n.peers&&n.peers.length){if(!b.filter.online)return i.all(_(n&&n.peers||[]).reduce((function(e,n){return e.concat(I(n,t))}),[]));var a=[];_.forEach(n.peers,(function(e){"UP"===e.status&&(e.blockNumber=e.block&&parseInt(e.block.split("-")[0]),e.blockNumber&&e.blockNumber1)return o.reduce((function(e,n){return e.concat(O(t,n))}),[]);n=o[0]}return i.bma=n,i.server=i.getServer(),i.dns=i.getDns(),i.buid=i.buid||i.block,i.blockNumber=i.buid&&parseInt(i.buid.split("-")[0]),i.uid=i.pubkey&&b.uidsByPubkeys[i.pubkey],i.id=i.keyID(),[i]},N=function(e){if(!v(e))return i.when();if(!b.filter.online||!b.filter.online&&"DOWN"===e.status||!e.getHost())return e.online=!1,i.when(e);if(e.bma.useWs2p&&b.ws2pHeads){var t=[e.pubkey,e.bma.ws2pid].join("-"),n=b.ws2pHeads[t];return delete b.ws2pHeads[t],n&&(e.buid=n.buid,e.currentNumber=n.buid&&parseInt(n.buid.split("-")[0]),e.version=n.version,e.powPrefix=n.powPrefix),e.online=!!e.buid,e.uid&&b.expertMode&&b.difficulties&&(e.difficulty=b.difficulties[e.uid]),i.when(e)}return e.bma.useWs2p||!m||e.bma.useSsl?e.bma.useTor||e.bma.useWs2p?(e.online="UP"===e.status,e.buid=-1,delete e.version,e.uid&&b.expertMode&&b.difficulties&&(e.difficulty=b.difficulties[e.uid]),i.when(e)):(e.api=e.api||l.lightInstance(e.getHost(),e.getPort(),e.isSsl(),b.timeout),e.api.blockchain.current(!1).then((function(t){if(!t)throw new Error("Wrong response for /blockchain/current (empty)");return e.currentNumber=t.number,e.online=!0,e.buid=g(t),e.medianTime=t.medianTime,-1===b.knownBlocks.indexOf(e.buid)&&b.knownBlocks.push(e.buid),e})).catch((function(t){if(t&&t.ucode==l.errorCodes.NO_CURRENT_BLOCK)return e.online=!0,e.buid=g({number:0,hash:l.constants.ROOT_BLOCK_HASH}),e.difficulty=0,e;if(!e.secondTry){var n=e.bma||e.getBMA();if(n.dns&&-1===e.server.indexOf(n.dns))return e.secondTry=!0,e.api=l.lightInstance(n.dns,n.port,n.useSsl),N(e)}return e.buid=null,e.blockNumber=null,e.currentNumber=null,e.online=!1,e.uid=b.uidsByPubkeys[e.pubkey],e})).then((function(e){if(!(b.filter.online&&e&&e.online&&b.expertMode))return e;var t=[];return e.uid&&t.push(e.api.blockchain.stats.hardship({pubkey:e.pubkey}).then((function(t){e.difficulty=t?t.level:null})).catch((function(){e.difficulty=null}))),t.push(e.api.node.summary().then((function(t){e.software=t&&t.duniter&&t.duniter.software||void 0,e.version=t&&t.duniter&&t.duniter.version||"?"})).catch((function(){e.software=void 0,e.version="?"}))),i.all(t).then((function(){return e}))}))):(e.online="UP"===e.status,e.buid=-1,delete e.version,e.uid&&b.expertMode&&b.difficulties&&(e.difficulty=b.difficulties[e.uid]),i.when(e))},R=function(e,t){if((e=e||b.newPeers).length){var n=_.map(b.peers,(function(e){return e.id})),i=!1,a=0;_.forEach(e.splice(0),(function(e){n[e.id]||(b.peers.push(e),n[e.id]=e,i=!0,a++)})),i&&(console.debug("[network] Flushing {0} new peers...".format(a)),S(t))}},A=function(e,t,n){if(!e)return 0;var i=0;t>(e=e.toLowerCase()).length&&(t=e.length),i+=e.charCodeAt(0);for(var a=1;a1,e.hasConsensusBlock&&(e.consensusBlockDelta=t[e.buid].medianTime-i.medianTime)}))),b.peers=_.uniq(b.peers,!1,(function(e){return e.id})),b.peers=_.sortBy(b.peers,(function(e){var n=0;return b.sort.type&&(n+="uid"===b.sort.type?A(e.uid||e.pubkey,3,b.sort.asc):0,n+="api"===b.sort.type&&(e.isWs2p()&&(b.sort.asc?1:-1)||0)+(e.hasEndpoint("ES_USER_API")&&(b.sort.asc?.01:-.01)||0)+(e.isSsl()&&(b.sort.asc?.75:-.75)||0)||0,n+="difficulty"===b.sort.type&&e.difficulty?b.sort.asc?1e4-e.difficulty:e.difficulty:0,n+="current_block"===b.sort.type&&e.currentNumber?b.sort.asc?1e9-e.currentNumber:e.currentNumber:0),n*=1e10,n+=1e9*(e.online?1:0),n+=1e8*(e.hasMainConsensusBlock?1:0),n+=1e6*(e.hasConsensusBlock?t[e.buid].pct:0),b.expertMode?(n+=100*(e.difficulty?1e4-e.difficulty:0),n+=1*(e.uid?A(e.uid,2,!0):0),n+=.001*(e.uid?0:A(e.pubkey,3,!0))):(n+=100*(e.uid?A(e.uid,2,!0):0),n+=.001*(e.uid?0:A(e.pubkey,3,!0))),n+=1e-5*(e.isBma()?e.isSsl()?1:.5:0),e.score=n,-n})),b.groupBy&&b.peers.forEach((function(e){e.compacted=n&&e[b.groupBy]&&e[b.groupBy]===n[b.groupBy],n=e})),e&&i&&i.buid&&(!b.mainBlock||b.mainBlock.buid!==i.buid)&&(b.mainBlock=i,E.data.raise.mainBlockChanged(i)),E.data.raise.changed(b)},C=function(e,t){return t=t||{},l.ready().then((function(){if(L(),b.bma=e||l,b.filter=t.filter?angular.merge(b.filter,t.filter):b.filter,b.sort=t.sort?angular.merge(b.sort,t.sort):b.sort,b.expertMode=angular.isDefined(t.expertMode)?t.expertMode:b.expertMode,b.timeout=angular.isDefined(t.timeout)?t.timeout:s.timeout,b.minOnlineBlockNumber=b.mainBlock&&b.mainBlock.buid&&parseInt(b.mainBlock.buid.split("-")[0])-1e3||void 0,void 0===b.minOnlineBlockNumber)return d.blockchain.current(!0).then((function(e){b.minOnlineBlockNumber=e.number-1e3}))})).then((function(){console.info("[network] Starting network from [{0}]".format(e.server));var t=Date.now();return b.listeners=[b.bma.websocket.block().onListener((function(e){if(e&&!b.loading){var t=[e.number,e.hash].join("-");-1===b.knownBlocks.indexOf(t)&&(console.debug("[network] Receiving block: "+t.substring(0,20)),b.knownBlocks.push(t),1===b.knownBlocks.length||(b.loading=!0,o((function(){console.debug("[network] new block received by WS: will refresh peers"),T()}),2e3,!1)))}})),b.bma.websocket.peer().onListener((function(e){if(e&&!b.loading){var t=[];I(e,t).then((function(e){e&&(t.length>0?R(t,!0):(console.debug("[network] [ws] Peers updated received"),S(!0)))}))}}))],T().then((function(e){return console.debug("[network] Started in "+(Date.now()-t)+"ms"),e}))}))},L=function(){b.bma&&(console.info("[network-service] Stopping..."),_.forEach(b.listeners,(function(e){e()})),b.listeners=[],b.bma=null,b.listeners=[],b.peers.splice(0),b.filter={member:!0,mirror:!0,endpoint:null,online:!0,bma:!1,ssl:void 0,tor:void 0},b.sort={type:null,asc:!0},b.groupBy="pubkey",b.expertMode=!1,b.memberPeersCount=0,b.knownBlocks=[],b.mainBlock=null,b.minOnlineBlockNumber=0,b.uidsByPubkeys={},b.loading=!0,b.searchingPeersOnNetwork=!1,b.difficulties=null,b.ws2pHeads=null,b.timeout=s.timeout)},D=function(e){return b.bma?C().then((function(){return i(e)})):i(e)};return E.registerEvent("data","changed"),E.registerEvent("data","mainBlockChanged"),E.registerEvent("data","rollback"),{data:b,start:C,close:L,hasPeers:function(){return b.peers&&b.peers.length>0},getPeers:function(){return b.peers},sort:function(e){e=e||{},b.filter=e.filter?angular.merge(b.filter,e.filter):b.filter,b.sort=e.sort?angular.merge(b.sort,e.sort):b.sort,S(!1)},getTrustedPeers:function(){return D((function(e,t){e(b.peers.reduce((function(e,t){return t.hasMainConsensusBlock&&t.uid?e.concat(t):e}),[]))}))},getKnownBlocks:function(){return b.knownBlocks},getMainBlockUid:function(){return D((function(e,t){e(b.mainBuid)}))},loadPeers:T,isBusy:function(){return b.loading},api:E}}]),angular.module("cesium.crypto.services",["cesium.utils.services"]).factory("CryptoUtils",["$q","$timeout","ionicReady",function(e,t,n){function i(){this.loaded=!1;var e=this;this.copy=function(t){_.forEach(_.keys(t),(function(n){e[n]=t[n]}))},this.isLoaded=function(){return this.loaded},this.util=this.util||{},this.util.array_to_string=function(e,t){var n=new Blob([new Uint8Array(e)]),i=new FileReader;i.onload=function(e){t(e.target.result)},i.readAsText(n)}}i.prototype.constants={crypto_sign_BYTES:64,crypto_secretbox_NONCEBYTES:24,crypto_box_MACBYTES:16,SEED_LENGTH:32,SCRYPT_PARAMS:{SIMPLE:{N:2048,r:8,p:1,memory:-1},DEFAULT:{N:4096,r:16,p:1,memory:-1}}},i.prototype.async_load_base58=function(e){var n=this;if(null!==Base58)return e(Base58);t((function(){n.async_load_base58(e)}),100)},i.prototype.async_load_scrypt=function(e,n){var i=this;null!==scrypt_module_factory?scrypt_module_factory(e,n):t((function(){i.async_load_scrypt(e,n)}),100)},i.prototype.async_load_nacl_js=function(e,n){var i=this;null!==nacl_factory?nacl_factory.instantiate(e,n):t((function(){i.async_load_nacl_js(e,n)}),100)},i.prototype.async_load_base64=function(e){var n=this;null!==Base64?e(Base64):t((function(){n.async_load_base64(e)}),100)},i.prototype.async_load_sha256=function(e){var n=this;if(null!==sha256)return e(sha256);t((function(){n.async_load_sha256(e)}),100)},i.prototype.seed_from_signSk=function(e){for(var t=new Uint8Array(this.constants.SEED_LENGTH),n=0;n"+(o||a["ERROR.UNKNOWN_ERROR"])+"

",title:a["ERROR.POPUP_TITLE"],subTitle:n&&a[n]||void 0,buttons:[{text:""+a["COMMON.BTN_OK"]+"",type:"button-assertive",onTap:function(e){i(e)}}]})}))})):o.when()}function v(e,n,i){return e?((i=i||{}).cssClass=i.cssClass||"info",i.okText=i.okText||"COMMON.BTN_OK",o((function(o){a([e,"INFO.POPUP_TITLE",i.okText].concat(n?[n]:[])).then((function(a){t.show({template:"

"+a[e]+"

",title:a["INFO.POPUP_TITLE"],subTitle:n&&a[n]||void 0,cssClass:i.cssClass,buttons:[{text:a[i.okText],type:"button-positive",onTap:function(e){o(e)}}]})}))}))):o.reject("Missing 'message' argument")}function I(t){return t?c((function(){return e.hide()}),t):e.hide()}function O(t){return g?((t=t||{}).template=t.template||g,e.show(t)):a("COMMON.LOADING").then((function(e){return g=e,O(t)}))}function N(){return f.smallscreen.active}function R(e,t,n){return function(t){var i,a=t.target.width,o=t.target.height,r=n?200:640,s=n?200:480,l=document.createElement("canvas");if(n){a>o?(a*=s/o,o=s):(o*=r/a,a=r),l.width=r,l.height=s,i=l.getContext("2d");var c=Math.trunc((r-a)/2+.5),d=Math.trunc((s-o)/2+.5);i.drawImage(t.target,c,d,r+-2*c,s+-2*d)}else a>o?a>r&&(o*=r/a,a=r):o>s&&(a*=s/o,o=s),l.width=a,l.height=o,(i=l.getContext("2d")).drawImage(t.target,0,0,l.width,l.height);var u=l.toDataURL();l.remove(),e(u)}}function A(e,t){var n=o.defer();(t=t||{}).templateUrl=t.templateUrl?t.templateUrl:"templates/common/popover_copy.html",t.scope=t.scope||m,t.scope.popovers=t.scope.popovers||{},t.autoselect=t.autoselect||!1,t.autoremove=!angular.isDefined(t.autoremove)||t.autoremove,t.backdropClickToClose=!angular.isDefined(t.backdropClickToClose)||t.backdropClickToClose,t.focusFirstInput=!!angular.isDefined(t.focusFirstInput)&&t.focusFirstInput;var i=function(i){(i=i||t.scope.popovers[t.templateUrl]).isResolved=!1,i.deferred=n,i.options=t,t.bindings&&angular.merge(i.scope,t.bindings),c((function(){i.show(e).then((function(){var e;t.autoselect?(e=document.querySelectorAll(t.autoselect)[0])&&(l.getSelection&&!l.getSelection().toString()?(e.setSelectionRange(0,e.value.length),e.focus()):e.focus()):t.autofocus&&(e=document.querySelectorAll(t.autofocus)[0])&&e.focus(),i.scope.$parent.$emit("popover.shown"),t.afterShow&&t.afterShow(i)}))}))},a=function(e){(e=e||t.scope.popovers[t.templateUrl])&&(delete t.scope.popovers[t.templateUrl],e.remove().then((function(){angular.element(l.document.querySelectorAll("body")[0]).removeClass("popover-open")})))},r=t.scope.popovers[t.templateUrl];return r?i(r):u.fromTemplateUrl(t.templateUrl,{scope:t.scope,backdropClickToClose:t.backdropClickToClose}).then((function(e){e.isResolved=!1,e.scope.closePopover=function(t){var n=e.options&&e.options.autoremove;e.options&&delete e.options.autoremove,e.hide().then((function(){if(n)return a(e)})).then((function(){e.deferred&&e.deferred.resolve(t),delete e.deferred,delete e.options}))},e.scope.$on("popover.hidden",(function(){e.options&&e.options.afterHidden&&e.options.afterHidden(),e.options&&e.options.autoremove&&a(e)})),t.scope.$on("$remove",(function(){e.deferred&&e.deferred.resolve(),a()})),t.scope.popovers[t.templateUrl]=e,i(e)})),n.promise}function S(e,t){var n=N()?100:10,i=".list.{0} .item, .list .{0} .item".format(t,t);return{ionListClass:t,show:function(t){return(t=t||{}).selector=t.selector||i,t.ink=!angular.isDefined(t.ink)||t.ink,t.startVelocity=t.startVelocity||(N()?1100:3e3),c((function(){t.ink&&b.ink(),e(t)}),t.timeout||n)}}}function C(e,t,n,i,a){a=a||"default",qrcode.stringToBytes=qrcode.stringToBytesFuncs[a];var o=qrcode(t||4,n||"M");return o.addData(e,i),o.make(),o}function L(e,t){if("string"==typeof e&&(e={selector:e}),void 0===e.selector||""===e.selector)return console.error("invalid toggleOn selector"),!1;c((function(){var t=document.querySelectorAll(e.selector);t&&_.forEach(t,(function(e){e.classList.toggle("on",!0)}))}),t||100)}function D(e,t){if("string"==typeof e&&(e={selector:e}),void 0===e.selector||""===e.selector)return console.error("invalid toggleOff selector"),!1;c((function(){var t=document.querySelectorAll(e.selector);t&&_.forEach(t,(function(e){e.classList.toggle("on",!1)}))}),t||900)}return h.motion={enable:!0,default:S(s.ripple,"animate-ripple"),blinds:S(s.blinds,"animate-blinds"),fadeSlideIn:S(s.fadeSlideIn,"animate-fade-slide-in"),fadeSlideInRight:S(s.fadeSlideInRight,"animate-fade-slide-in-right"),panInLeft:S(s.panInLeft,"animate-pan-in-left"),pushDown:S(s.pushDown,"push-down"),ripple:S(s.ripple,"animate-ripple"),slideUp:S(s.slideUp,"slide-up"),fadeIn:S((function(e){L(e)}),"fade-in"),toggleOn:L,toggleOff:D},b={alert:{error:T,info:v,confirm:function(e,n,i){return n=n||"CONFIRM.POPUP_TITLE",(i=i||{}).cssClass=i.cssClass||"confirm",i.okText=i.okText||"COMMON.BTN_OK",i.cancelText=i.cancelText||"COMMON.BTN_CANCEL",a([e,n,i.cancelText,i.okText]).then((function(a){return t.confirm({template:a[e],cssClass:i.cssClass,title:a[n],cancelText:a[i.cancelText],cancelType:i.cancelType,okText:a[i.okText],okType:i.okType})}))},notImplemented:function(){return v("INFO.FEATURES_NOT_IMPLEMENTED")},demo:function(){return a(["MODE.DEMO.FEATURE_NOT_AVAILABLE","MODE.DEMO.INSTALL_HELP"]).then((function(e){return v(e["MODE.DEMO.FEATURE_NOT_AVAILABLE"]+"

"+e["MODE.DEMO.INSTALL_HELP"],void 0,{cssClass:"large"})}))}},loading:{show:O,hide:I,update:function(t){return e._getLoader().then((function(e){if(e&&e.isShown)return t&&t.template?a(t&&t.template).then((function(n){return t.template=n,e})):void 0})).then((function(e){if(e&&e.isShown)return O(t)}))}},toast:{show:function(t,n,i){return t?(n=n||"short",i=i||"bottom",a([t]).then((function(i){return"string"==typeof n&&(n="short"==n?2e3:5e3),e.show({template:i[t],noBackdrop:!0,duration:n})}))):o.reject("Missing 'message' argument")}},onError:function(e,t){return function(n){var i,a=e;if(n&&n.message?(a=n.message,i=e):e||(a=n),!t)return"CANCELLED"===a?I(10):(I(10),T(a,i));t(a)}},screen:{isSmall:N,fullscreen:d},ink:r.displayEffect,motion:h.motion,setEffects:function(e){if(b.motion.enable!==e){if(console.debug("[UI] [effects] "+(e?"Enable":"Disable")),b.motion.enable=e,e)n.views.transition("platform"),angular.merge(b.motion,h.motion);else{n.views.transition("none");var t={class:void 0,show:function(){}};angular.merge(b.motion,{enable:!1,default:t,fadeSlideIn:t,fadeSlideInRight:t,panInLeft:t,pushDown:t,ripple:t,slideUp:t,fadeIn:t,toggleOn:L,toggleOff:D}),m.motion=t}i.clearCache()}},qrcode:{svg:function(e,t,n,i,a){return C(e,t,n,i,a).createSvgTag()},img:function(e,t,n,i,a){return C(e,t,n,i,a).createImgTag()}},fab:{show:function(e,t){t||(t=900),c((function(){var t=document.getElementsByClassName("button-fab");_.forEach(t,(function(t){t.id==e&&t.classList.toggle("on",!0)}))}),t)},hide:function(e,t){t||(t=10),c((function(){var t=document.getElementsByClassName("button-fab");_.forEach(t,(function(t){t.id==e&&t.classList.toggle("on",!1)}))}),t)}},popover:{show:A,copy:function(e,t){var n=t&&t.indexOf("\n")>=0?t.split("\n").length:1;return A(e,{templateUrl:"templates/common/popover_copy.html",bindings:{value:t,rows:n},autoselect:".popover-copy "+(n<=1?"input":"textarea")})},share:function(e,t){return(t=t||{}).templateUrl=t.templateUrl?t.templateUrl:"templates/common/popover_share.html",t.autoselect=t.autoselect||".popover-share input",t.bindings=t.bindings||{},t.bindings.value=t.bindings.value||t.bindings.url||p.href(p.current,p.params,{absolute:!0}),t.bindings.postUrl=t.bindings.postUrl||t.bindings.value,t.bindings.postMessage=t.bindings.postMessage||"",t.bindings.titleKey=t.bindings.titleKey||"COMMON.POPOVER_SHARE.TITLE",A(e,t)},helptip:function e(t,n){var i="string"==typeof t&&t?l.document.getElementById(t):t;t||i||!n.selector||(i=l.document.querySelector(n.selector));var a=(n=n||{}).deferred||o.defer();if(i&&!n.timeout)n.preAction&&i[n.preAction](),n.templateUrl=n.templateUrl?n.templateUrl:"templates/common/popover_helptip.html",n.autofocus=n.autofocus||"#helptip-btn-ok",n.bindings=n.bindings||{},n.bindings.icon=n.bindings.icon||{},n.bindings.icon.position=n.bindings.icon.position||!1,n.bindings.icon.glyph=n.bindings.icon.glyph||(n.bindings.icon.position&&n.bindings.icon.position.startsWith("bottom-")?"ion-arrow-down-c":"ion-arrow-up-c"),n.bindings.icon.class=n.bindings.icon.class||"calm icon "+n.bindings.icon.glyph,n.bindings.tour=!!angular.isDefined(n.bindings.tour)&&n.bindings.tour,A(i,n).then((function(e){n.postAction&&i[n.postAction](),a.resolve(e)})).catch((function(e){n.postAction&&i[n.postAction](),a.reject(e)}));else if(n.timeout){var r=n.timeout;n.retryTimeout=n.retryTimeout||r,delete n.timeout,n.deferred=a,c((function(){e(t,n)}),r)}else angular.isDefined(n.retry)&&!n.retry?"continue"===n.onError?c((function(){a.resolve(!0)})):c((function(){a.reject("[helptip] element now found: "+t)})):(n.retry=angular.isUndefined(n.retry)?2:n.retry-1,n.deferred=a,c((function(){e(t,n)}),n.timeout||n.retryTimeout||100));return a.promise}},selection:{select:function e(t){if(t.value||"text"==t.type||"textarea"==t.type)l.getSelection&&!l.getSelection().toString()&&t.setSelectionRange(0,t.value.length);else if(t.childNodes&&t.childNodes.length>0)e(t.childNodes[0]);else{var n=l.document.createRange();n.selectNodeContents(t);var i=l.getSelection();i.removeAllRanges(),i.addRange(n)}},get:function(){var e="";return window.getSelection&&(e=l.getSelection().toString()),e}},image:{resizeFile:function(e,t){var n=document.createElement("img");return o((function(i,a){if(e){var o=new FileReader;o.onload=function(e){n.onload=R(i,0,t),n.src=e.target.result},o.readAsDataURL(e)}else a("no file to resize")})).then((function(e){return n.remove(),e}))},resizeSrc:function(e,t){var n=document.createElement("img");return o((function(i,a){n.onload=R(i,0,t),n.src=e})).then((function(e){return n.remove(),e}))},rotateSrc:function(e,t){var n=document.createElement("img");return o((function(t,i){n.onload=function(e,t){var n=Math.PI/180*90;return function(t){var i=t.target.width,a=t.target.height;i>a?i>640&&(a*=640/i,i=640):a>480&&(i*=480/a,a=480);var o=document.createElement("canvas");o.width=a,o.height=i;var r=o.getContext("2d");r.rotate(n),r.drawImage(t.target,0,-1*o.width);var s=o.toDataURL();o.remove(),e(s)}}(t),n.src=e})).then((function(e){return n.remove(),e}))}},raw:h}}]).factory("$focus",["$timeout","$window",function(e,t){return function(n){e((function(){var e=t.document.getElementById(n);e&&e.focus()}))}}]),angular.module("cesium.cache.services",["angular-cache"]).factory("csCache",["$rootScope","$http","$window","csSettings","CacheFactory",function(e,t,n,i,a){var o={VERY_LONG:54e6,LONG:36e5,MEDIUM:3e5,SHORT:i.defaultSettings.cacheTimeMs},r=l(),s=[];function l(e){return(e=e||i.data)&&e.useLocalStorage&&e.persistCache&&n.localStorage?"localStorage":"memory"}function c(e){return(e=e||{}).storageMode=l(),e.deleteOnExpire="localStorage"===e.storageMode||e.onExpire?"aggressive":"passive",e.cacheFlushInterval="passive"===e.deleteOnExpire?36e5:null,e}function d(e){var t=l(e);t!==r&&(r=t,console.debug("[cache] Updating caches with {storageMode: {0}}".format(r)),_.forEach(_.keys(s),(function(e){var t=a.get(e);t&&t.setOptions(c(),!0)})))}return function(){listeners=[i.api.data.on.changed(e,d,this)]}(),{get:function(e,t,n){var i,r=(e=e||"")+((t=t||o.SHORT)/1e3+"s");if(n&&"function"==typeof n){for(var l=1;a.get(r+l);)l++;r+=l}else i=a.get(r);if(s[r]||(s[r]=!0),i)return i;var d=c({maxAge:t,onExpire:n||null});return console.debug("[cache] Creating cache {{0}} with {storageMode: {1}}...".format(r,d.storageMode)),a.createCache(r,d)},clear:function(e){_.forEach(_.keys(s),(function(t){if(t.startsWith(e)){var n=a.get(t);n&&n.removeAll()}}))},clearAll:function(){console.debug("[cache] Cleaning all caches..."),_.forEach(_.keys(s),(function(e){var t=a.get(e);t&&t.removeAll()}))},constants:o}}]),angular.module("cesium.modal.services",["cesium.utils.services"]).controller("EmptyModalCtrl",(function(){})).controller("AboutModalCtrl",["$scope","csConfig","UIUtils","csHttp","filterTranslations",function(e,t,n,i,a){e.openLink=function(e,t,a){return(a=a||{}).onError=function(){return n.popover.copy(e,t)},i.uri.open(t,a)},e.buildDate=moment(t.build).format(a.DATE_PATTERN||"YYYY-MM-DD HH:mm")}]).factory("ModalUtils",["$ionicModal","$rootScope","$q","$injector","$controller","$timeout","Device",function(e,t,n,i,a,o,r){function s(e,t,i){e.deferred=t||n.defer(),e.resolved=!1,e.openModal=function(){return e.modal.show()},e.hideModal=function(){return e.modal.hide()},e.closeModal=function(t){return e.resolved=!0,e.modal.remove().then((function(){return document.body.classList.remove("modal-open"),e.deferred.resolve(t),t}))},e.setForm=function(t,n){n?e[n]=t:e.form=t},e.getParameters=function(){return i},e.$on("modal.hidden",(function(){e.resolved||(e.resolved=!0,o((function(){return e.deferred.resolve(),e.modal.remove().then((function(){document.body.classList.remove("modal-open")}))}),(e.modal.hideDelay||320)+20))}))}return{show:function(i,o,r,l){var c,d,u,p,m=n.defer();if((l=l||{}).animation=l.animation||"slide-in-up",c=!!angular.isDefined(l.focusFirstInput)&&l.focusFirstInput,l.focusFirstInput=c,o){l.scope=l.scope?l.scope.$new():t.$new(),s.call({},l.scope,m,r);var E={$scope:l.scope,parameters:r},b=(u={isControllerAs:!1,controllerName:"",propName:""},p=((d=o)||"").trim().split(/\s+/),u.isControllerAs=3===p.length&&"as"===(p[1]||"").toLowerCase(),u.isControllerAs?(u.controllerName=p[0],u.propName=p[2]):u.controllerName=d,u),g=a(o,E);b.isControllerAs&&(g.openModal=l.scope.openModal,g.closeModal=l.scope.closeModal)}return e.fromTemplateUrl(i,l).then((function(e){if(o)e.scope.$parent.modal=e;else{var t=e.scope;s.call({},t,m,r),t.modal=e}return e.show()}),(function(e){m.reject(e)})),m.promise}}}]).factory("Modals",["$rootScope","$translate","$ionicPopup","$timeout","ModalUtils","UIUtils",function(e,t,n,i,a,o){function r(e){return a.show("templates/join/modal_join_member.html","JoinModalCtrl",e)}function s(e){return a.show("templates/join/modal_join_wallet.html","JoinModalCtrl",e)}return{showTransfer:function(e){var t=o.screen.isSmall();return a.show("templates/wallet/modal_transfer.html","TransferModalCtrl",e,{focusFirstInput:!t})},showLogin:function(e){return a.show("templates/login/modal_login.html","LoginModalCtrl",e,{focusFirstInput:!0,backdropClickToClose:!1})},showWotLookup:function(e){return a.show("templates/wot/modal_lookup.html","WotLookupModalCtrl",e||{},{focusFirstInput:!0})},showNetworkLookup:function(e){return a.show("templates/network/modal_network.html","NetworkLookupModalCtrl",e,{focusFirstInput:!0})},showAbout:function(e){return a.show("templates/modal_about.html","AboutModalCtrl",e)},showJoin:function(e){return a.show("templates/join/modal_choose_account_type.html","JoinChooseAccountTypeModalCtrl",e).then((function(e){if(e)return"member"==e.accountType?r(e):s(e)}))},showJoinMember:r,showJoinWallet:s,showHelp:function(e){return a.show("templates/help/modal_help.html","HelpModalCtrl",e)},showAccountSecurity:function(e){return a.show("templates/wallet/modal_security.html","WalletSecurityModalCtrl",e)},showLicense:function(e){return a.show("templates/currency/modal_license.html","CurrencyLicenseModalCtrl",e)},showSelectPubkeyIdentity:function(e){return a.show("templates/wot/modal_select_pubkey_identity.html","WotSelectPubkeyIdentityModalCtrl",e)},showSelectWallet:function(e){return a.show("templates/wallet/list/modal_wallets.html","WalletSelectModalCtrl",e)},showPassword:function(i){(i=i||{}).title=i.title||"COMMON.SET_PASSWORD_TITLE",i.subTitle=i.subTitle||"COMMON.SET_PASSWORD_SUBTITLE";var a=i.scope?i.scope.$new():e.$new();return a.formData={password:void 0},a.setForm=function(e){a.form=e},a.submit=function(e){a.form.$submitted=!0,e&&e.preventDefault&&e.preventDefault(),a.form.$valid&&a.formData.password&&i.popup.close(a.formData.password)},a.error=i.error||void 0,t([i.title,i.subTitle,"COMMON.BTN_OK","COMMON.BTN_CANCEL"]).then((function(e){return i.popup=n.show({templateUrl:"templates/common/popup_password.html",title:e[i.title],subTitle:e[i.subTitle],scope:a,buttons:[{text:e["COMMON.BTN_CANCEL"]},{text:e["COMMON.BTN_OK"],type:"button-positive",onTap:a.submit}]}),i.popup}))}}}]).factory("csPopovers",["$rootScope","$translate","$ionicPopup","$timeout","UIUtils","$controller",function(e,t,n,i,a,o){return{showSelectWallet:function(t,n){var i=(n=n||{}).parameters||{};delete n.parameters;var r=n.scope&&n.scope.$new()||e.$new(!0);n.scope=r,n.templateUrl="templates/wallet/list/popover_wallets.html",n.autoremove=!0,angular.extend(this,o("WalletSelectPopoverCtrl",{$scope:n.scope,parameters:i}));var s=n.afterShow;return n.afterShow=function(e){r.closePopover=function(t){e.scope.closePopover(t)},s&&s(e)},a.popover.show(t,n).then((function(e){return r.$destroy(),e}))}}}]),angular.module("cesium.http.services",["cesium.cache.services"]).factory("csHttp",["$http","$q","$timeout","$window","csSettings","csCache","Device",function(e,t,n,i,a,o,r){var s=a.data.timeout,l=[],c={};function d(e,t){return e?e+(t&&80!=t&&443!=t?":"+t:""):null}function u(e,t,n,i){return(443==t||i?"https":"http")+"://"+d(e,t)+(n||"")}function p(e,t,n,i){t&&t.message?e(t):403==i?e({ucode:403,message:"Resource is forbidden"+(n?" ("+n+")":"")}):404==i?e({ucode:404,message:"Resource not found"+(n?" ("+n+")":"")}):n?(console.error("[http] Get HTTP error {status: "+i+"} on ["+n+"]"),e("Error while requesting ["+n+"]")):e("Unknown error from node")}function m(e,t,n,i){var a=[],o={},r=e;return"object"==typeof t&&(a=_.keys(t)),_.forEach(a,(function(e){r===(r=r.replace(":"+e,t[e]))&&(o[e]=t[e])})),n.params=o,i(r,n)}function E(e){var t;e.startsWith("duniter://")&&(t="duniter",e=e.replace("duniter://","http://"));var n=document.createElement("a");n.href=e;var i=n.pathname;i&&i.startsWith("/")&&(i=i.substring(1));var a={protocol:t||n.protocol,hostname:n.hostname,host:n.host,port:n.port,username:n.username,password:n.password,pathname:i,search:n.search,hash:n.hash};return n.remove(),a}function b(e,t){var n=e.split("."),i=t.split(".");function a(e){for(var t=0;ti[o]?1:-1}return n.length!=i.length?-1:0}return s||(s=4e3),{get:function(n,i,a,o,r){if(!n)return t.reject("[http] invalid URL from host: "+n);var l=u(n,i,a,o);return function(n){return t((function(t,i){m(l,n,{timeout:r||s,responseType:"json"},(function(n,a){e.get(n,a).success((function(e,n,i,a){t(e)})).error((function(e,t,a,o){p(i,e,n,t)}))}))}))}},getWithCache:function(n,i,a,r,l,d,E,b){var g=u(n,i,a,r);return b=b||"csHttp-",l=l||o.constants.LONG,c[b]=!0,function(n){return t((function(t,i){var a={timeout:E||s,responseType:"json"};a.cache=d?o.get(b,l,(function(t,n,i){console.debug("[http] Refreshing cache for {{0}} ".format(t)),e.get(t,a).success((function(e){a.cache.put(t,e),i&&i(t,e)}))})):o.get(b,l),m(g,n,a,(function(n,a){e.get(n,a).success((function(e){t(e)})).error((function(e,t){p(i,e,n,t)}))}))}))}},post:function(n,i,a,o,r){var l=u(n,i,a,o);return function(n,i){return t((function(t,a){m(l,i,{timeout:r||s,headers:{"Content-Type":"application/json;charset=UTF-8"}},(function(i,o){e.post(i,n,o).success((function(e){t(e)})).error((function(e,t){p(a,e,i,t)}))}))}))}},ws:function(e,i,o,r,s){if(!o)throw console.error("calling csHttp.ws without path argument"),"calling csHttp.ws without path argument";var c=function(e,t,n,i){return(443==t||i?"wss":"ws")+"://"+d(e,t)+(n||"")}(e,i,o,r);function u(e){if(!e.delegate)throw new Error("Websocket {0} was closed!".format(c));return 1==e.delegate.readyState?t.when(e.delegate):3==e.delegate.readyState?t.reject("Unable to connect to websocket ["+e.delegate.url+"]"):(e.waitDuration>=s?(e.waitRetryDelay=e.waitRetryDelay&&Math.min(e.waitRetryDelay+2e3,3e4)||2e3,console.debug("[http] Will retry websocket [{0}] in {1}s...".format(e.path,Math.round(e.waitRetryDelay/1e3)))):Math.round(e.waitDuration/1e3)%10==0&&console.debug("[http] Waiting websocket ["+e.path+"]..."),n((function(){return e.waitDuration+=e.waitRetryDelay,u(e)}),e.waitRetryDelay))}function p(e,t,n){return e.delegate||(e.path=o,e.callbacks=[],e.waitDuration=0,e.waitRetryDelay=200,m(c,n,{},(function(t){e.delegate=new WebSocket(t),e.delegate.onerror=function(t){e.delegate.readyState=3},e.delegate.onmessage=function(t){var n=JSON.parse(t.data);_.forEach(e.callbacks,(function(e){e(n)}))},e.delegate.onopen=function(t){console.debug("[http] Listening on websocket ["+e.path+"]..."),l.push(e),e.delegate.openTime=Date.now()},e.delegate.onclose=function(t){var i=_.findIndex(l,(function(t){return t.path===e.path}));i>=0&&l.splice(i,1),e.delegate.closing?e.delegate=null:e.delegate.openTime?(console.debug("[http] Unexpected close of websocket [{0}] (open {1} ms ago): re-opening...",o,Date.now()-e.delegate.openTime),e.delegate=null,p(e,null,n)):t&&(console.debug("[http] Unexpected close of websocket [{0}]: error code: ".format(o),t&&t.code||t),e.delegate=null,p(e,null,n))}}))),t&&e.callbacks.push(t),u(e)}function E(e){e.delegate&&(e.delegate.closing=!0,console.debug("[http] Closing websocket ["+e.path+"]..."),e.delegate.close(),e.callbacks=[],e.onclose&&e.onclose())}return s=s||a.data.timeout,{open:function(e){return p(this,null,e)},on:function(e,t){return p(this,e,t)},onListener:function(e,t){var n=this;return p(n,e,t),function(){!function(e,t){e.callbacks=_.reject(e.callbacks,(function(e){return e===t})),e.callbacks.length||E(e)}(n,e)}},send:function(e){var t=this;return u(t).then((function(){t.delegate&&t.delegate.send(e)}))},close:function(){E(this)},isClosed:function(){return!this.delegate||this.delegate.closing}}},closeAllWs:function(){l.length>0&&(console.debug("[http] Closing all websocket..."),_.forEach(l,(function(e){e.close()})),l=[])},getUrl:u,getServer:d,uri:{parse:E,open:function(e,t){if(t=t||{},!e.startsWith("http://")&&!e.startsWith("https://")){var n=E(e);if(!n.protocol&&t.type&&(n.protocol="email"==t.type?"mailto:":"phone"==t.type?"tel:":"",e=n.protocol+e),"mailto:"==n.protocol&&r.isDesktop())try{return void(void 0).Shell.openExternal(e)}catch(e){console.error("[http] Failed not open 'mailto:' URI into external tool.")}if("mailto:"!=n.protocol&&"tel:"!=n.protocol||!r.enable)return void(t.onError&&"function"==typeof t.onError&&t.onError(e))}var a,o=t.target||(r.enable?"_system":"_blank");if("_blank"===o||"_system"===o&&r.isDesktop())try{return void(void 0).Shell.openExternal(e)}catch(e){console.error("[http] Failed not open URI into external browser.")}"_blank"===o&&r.isDesktop()&&(a="location=1,titlebar=1,status=1,menubar=1,toolbar=1,resizable=1,scrollbars=1",i.screen&&i.screen.width&&i.screen.height&&(a+=",width={0},height={1}".format(Math.trunc(i.screen.width/2),Math.trunc(i.screen.height/2))));var s=i.open(e,o,a);a&&i.screen&&i.screen.width&&i.screen.height&&(s.moveTo(i.screen.width/2/2,i.screen.height/2/2),s.focus())}},date:{now:function(){return moment().utc().unix()}},version:{compare:b,isCompatible:function(e,t){return console.debug("[http] Checking actual version [{0}] is compatible with min expected version [{1}]".format(t,e)),b(e,t)<=0}},cache:angular.merge({clear:function(e){e=e||"csHttp-",console.debug("[http] Cleaning cache {prefix: '{0}'}...".format(e)),o.clear(e)},clearAll:function(){console.debug("[http] Cleaning all caches..."),_.keys(c).forEach((function(e){o.clear(e)}))}},o.constants)}}]),angular.module("cesium.storage.services",["cesium.config"]).factory("sessionStorage",["$window","$q",function(e,t){var n={storage:e.sessionStorage||{},put:function(e,i){return n.storage[e]=i,t.when()},get:function(e,i){return t.when(n.storage[e]||i)},setObject:function(e,i){return n.storage[e]=JSON.stringify(i),t.when()},getObject:function(e){return t.when(JSON.parse(n.storage[e]||"null"))}};return n}]).factory("localStorage",["$window","$q","$log","sessionStorage",function(e,t,n,i){var a,o=!1,r={standard:{storage:null},secure:{storage:null}};function s(){if(a)return a;var n=Date.now();return(e.localStorage?(console.debug("[storage] Starting {local} storage..."),r.standard.storage=e.localStorage,_.forEach(_.keys(r.standard),(function(e){r[e]=r.standard[e]}))):(console.debug("[storage] Starting {session} storage..."),_.forEach(_.keys(i),(function(e){r[e]=i[e]}))),a=t.when()).then((function(){console.debug("[storage] Started in "+(Date.now()-n)+"ms"),o=!0,a=null}))}return r.standard.put=function(e,n){return angular.isDefined(n)&&null!=n?r.standard.storage[e]=n:r.standard.storage.removeItem(e),t.when()},r.standard.remove=function(e,n){return r.standard.storage.removeItem(e),t.when()},r.standard.get=function(e,n){return t.when(r.standard.storage[e]||n)},r.standard.setObject=function(e,n){return r.standard.storage[e]=JSON.stringify(n),t.when()},r.standard.getObject=function(e){return t.when(JSON.parse(r.standard.storage[e]||"null"))},r.secure.put=function(e,i){return t((function(t,a){null!=i?r.secure.storage.set((function(e){t()}),(function(e){n.error(e),a(e)}),e,i):r.secure.storage.remove((function(){t()}),(function(e){n.error(e),t()}),e)}))},r.secure.get=function(e,i){return t((function(t,a){r.secure.storage.get((function(e){t(!e&&i?i:e)}),(function(e){n.error(e),t()}),e)}))},r.secure.setObject=function(e,i){return n.debug("[storage] Setting object into secure storage, using key="+e),t((function(t,n){r.secure.storage.set(t,n,e,i?JSON.stringify(i):void 0)}))},r.secure.getObject=function(e){return n.debug("[storage] Getting object from secure storage, using key="+e),t((function(t,i){r.secure.storage.get((function(e){t(JSON.parse(e||"null"))}),(function(e){n.error(e),t()}),e)}))},r.isStarted=function(){return o},r.ready=function(){return o?t.when():a||s()},s(),r}]),angular.module("cesium.device.services",["cesium.utils.services","cesium.settings.services"]).factory("Device",["$rootScope","$translate","$ionicPopup","$q","ionicReady",function(e,t,n,i,a){var o,r={enable:!0},s={},l=!1;function c(e){if(!r.enable)return i.reject("Barcode scanner not enable. Please call 'ionicReady()' once before use (e.g in app.js).");var t=i.defer();return cordova.plugins.barcodeScanner.scan((function(e){e.cancelled?(console.debug("[device] barcode scanner scan: CANCELLED"),t.resolve()):(console.debug("[device] barcode scanner scan: "+e.text),t.resolve(e.text))}),(function(e){console.error("[device] Error while using barcode scanner: "+e),t.reject(e)}),e),t.promise}return r.enable=!1,r.clipboard={copy:function(e,t){if(!r.enable)return i.reject("Device disabled");var n=i.defer();return $cordovaClipboard.copy(e).then((function(){t&&t(),n.resolve()}),(function(){n.reject({message:"ERROR.COPY_CLIPBOARD"})})),n.promise}},r.camera={getPicture:function(e){return r.camera.enable?(e&&"string"==typeof e&&(e={sourceType:e}),e=e||{},angular.isUndefined(e.sourceType)?t(["SYSTEM.PICTURE_CHOOSE_TYPE","SYSTEM.BTN_PICTURE_GALLERY","SYSTEM.BTN_PICTURE_CAMERA"]).then((function(t){return n.show({title:t["SYSTEM.PICTURE_CHOOSE_TYPE"],buttons:[{text:t["SYSTEM.BTN_PICTURE_GALLERY"],type:"button",onTap:function(e){return navigator.camera.PictureSourceType.PHOTOLIBRARY}},{text:t["SYSTEM.BTN_PICTURE_CAMERA"],type:"button button-positive",onTap:function(e){return navigator.camera.PictureSourceType.CAMERA}}]}).then((function(t){return console.info("[camera] User select sourceType:"+t),e.sourceType=t,r.camera.getPicture(e)}))})):(e.quality=e.quality||50,e.destinationType=e.destinationType||navigator.camera.DestinationType.DATA_URL,e.encodingType=e.encodingType||navigator.camera.EncodingType.PNG,e.targetWidth=e.targetWidth||400,e.targetHeight=e.targetHeight||400,$cordovaCamera.getPicture(e))):i.reject("Camera not enable. Please call 'ionicReady()' once before use (e.g in app.js).")},scan:function(e){return console.warn("Deprecated use of Device.camera.scan(). Use Device.barcode.scan() instead"),c(e)}},r.barcode={enable:!1,scan:c},r.keyboard={enable:!1,close:function(){r.keyboard.enable&&cordova.plugins.Keyboard.close()}},r.keyboard.digit={settings:{bindModel:function(t,n,i){t=t||e;var a=function(){return(n||"").split(".").reduce((function(e,t){return e?e[t]:void 0}),t)},o=function(e){var i=(n||"").split("."),a=i.length&&i[i.length-1];i.reduce((function(t,n){if(n!=a)return t[n];t[a]=e}),t)};return(i=i||{}).animation=i.animation||"pop",i.action=i.action||function(e){o((a()||"")+e)},i.decimal&&(i.decimalSeparator=i.decimalSeparator||".",i.leftButton={html:".",action:function(){var e=a()||"";e.indexOf(i.decimalSeparator)>=0||(e.trim().length||(e="0"),o(e+i.decimalSeparator))}}),i.rightButton=i.rightButton||{html:'',action:function(){var e=a();e&&e.length&&(e=e.slice(0,-1),o(e))}},i}}},r.isIOS=function(){return!!navigator.userAgent.match(/iPhone | iPad | iPod/i)||ionic.Platform.isIOS()},r.isOSX=function(){return!!navigator.userAgent.match(/Macintosh/i)||ionic.Platform.is("osx")},r.isDesktop=function(){if(!angular.isDefined(s.isDesktop))try{s.isDesktop=(r.enable||process,!1)}catch(e){s.isDesktop=!1}return s.isDesktop},r.isWeb=function(){return!r.enable&&!r.isDesktop()},r.ready=function(){return l?i.when():o||r.start()},r.start=function(){return o=a().then((function(){r.enable=window.cordova&&cordova&&cordova.plugins,r.enable?(r.camera.enable=!!navigator.camera,r.keyboard.enable=cordova&&cordova.plugins&&!!cordova.plugins.Keyboard,r.barcode.enable=cordova&&cordova.plugins&&!!cordova.plugins.barcodeScanner&&!r.isOSX(),r.clipboard.enable=cordova&&cordova.plugins&&!!cordova.plugins.clipboard,r.keyboard.enable&&angular.extend(r.keyboard,cordova.plugins.Keyboard),console.debug("[device] Ionic platform ready, with [camera: {0}] [barcode scanner: {1}] [keyboard: {2}] [clipboard: {3}]".format(r.camera.enable,r.barcode.enable,r.keyboard.enable,r.clipboard.enable)),cordova.InAppBrowser&&console.debug("[device] Enabling InAppBrowser")):console.debug("[device] Ionic platform ready - no device detected."),l=!0,o=null}))},r}]),angular.module("cesium.currency.services",["ngApi","cesium.bma.services"]).factory("csCurrency",["$rootScope","$q","$timeout","BMA","Api","csSettings",function(e,n,i,a,o,r){var s,l,c={WELL_KNOWN_CURRENCIES:{g1:{firstBlockTime:1488987127,medianTimeOffset:3600}}},d={},u=!1,p=new o(this,"csCurrency");function m(){d.name=null,d.parameters=null,d.firstBlockTime=null,d.membersCount=null,d.cache={},d.node=a,d.currentUD=null,d.medianTimeOffset=0,u=!1,s=void 0,p.data.raise.reset(d)}function E(){return n.all([a.blockchain.parameters().then((function(e){return d.name=e.currency,d.parameters=e,d.medianTimeOffset=e.avgGenTime*e.medianTimeBlocks/2,e})).then((function(e){return t=e.currency,c.WELL_KNOWN_CURRENCIES[t]?(angular.merge(d,c.WELL_KNOWN_CURRENCIES[t]),n.when()):a.blockchain.block({block:0}).then((function(e){d.firstBlockTime=e.medianTime})).catch((function(e){if(e&&e.ucode===a.errorCodes.BLOCK_NOT_FOUND)return d.firstBlockTime=0,d.initPhase=!0,void console.warn("[currency] Blockchain not launched: Enable init phase mode");throw e}));var t})),a.blockchain.stats.ud().then((function(e){return e.result.blocks.length?function e(t,n){if(!t.result.blocks.length||n<0)return d.currentUD=d.parameters?d.parameters.ud0:-1,d.currentUD;var i=t.result.blocks[n];return a.blockchain.block({block:i}).then((function(e){var t,n;return d.currentUD=(t=e.dividend,(n=e.unitbase)<=0?t:t*Math.pow(10,n)),d.currentUD})).catch((function(a){if(console.error("[currency] Unable to load last block with UD, with number {0}".format(i)),n>0)return console.error("[currency] Retrying to load UD from a previous block..."),e(t,n-1);throw d.currentUD=null,a}))}(e,e.result.blocks.length-1):(d.currentUD=d.parameters?d.parameters.ud0:-1,d.currentUD)})).catch((function(e){throw d.currentUD=null,e})),p.data.raisePromise.load(d)]).catch((function(e){throw m(),e}))}function b(){return u?n.when(d):s||v()}function g(e){return function(){return u?n.when(d[e]):s||v().then((function(){return d[e]}))}}function f(e){var n=new t(e);n.cleanData(),console.debug("[currency] Received new block {"+n.number+"-"+n.hash+"}"),d.currentBlock=n,d.currentBlock.receivedAt=moment().utc().unix(),d.medianTime=n.medianTime,d.membersCount=n.membersCount,n.dividend&&(d.currentUD=n.dividend),p.data.raise.newBlock(n)}function h(){console.debug("[currency] Stopping..."),_.forEach(l,(function(e){e()})),l=[],m()}function T(){return h(),i(v,200)}function v(t){if(s)return s;if(u)return n.when(d);if(!t)return a.ready().then((function(e){return e?v(e):i(v,500)}));console.debug("[currency] Starting...");var o=Date.now();return s=a.ready().then((function(e){return!!e||i((function(){return v(!0)}),500)})).then(E).then((function(){!function(){l=[a.api.node.on.restart(e,T,this),a.websocket.block().onListener(f)]}(),console.debug("[currency] Started in "+(Date.now()-o)+"ms"),u=!0,s=null,p.data.raise.ready(d)})).then((function(){return d}))}var I=g("currentBlock");function O(e){return I().then((function(t){var n=moment().utc().unix();if(e){if(t&&t.receivedAt&&n-t.receivedAt<60)return t;t||console.warn("[currency] No current block in cache: get it from network. Websocket [/ws/block] may not be started ?")}return a.blockchain.current(!1).catch((function(e){if(e&&e.ucode==a.errorCodes.NO_CURRENT_BLOCK)return{number:0,hash:a.constants.ROOT_BLOCK_HASH,medianTime:n};throw e})).then((function(e){return d.currentBlock=e,d.currentBlock.receivedAt=n,e}))}))}return p.registerEvent("data","ready"),p.registerEvent("data","load"),p.registerEvent("data","reset"),p.registerEvent("data","newBlock"),m(),{ready:function(){return u?n.when(d):s||v()},start:v,stop:h,data:d,get:b,name:g("name"),parameters:g("parameters"),currentUD:g("currentUD"),medianTimeOffset:g("medianTimeOffset"),blockchain:{current:O,lastValid:function(){return r.data.blockValidityWindow<=0?O(!0):O(!0).then((function(e){ var t=e.number-r.data.blockValidityWindow;return t>0?a.blockchain.block({block:t}):e}))}},date:{now:function(){return moment().utc().unix()-(d.medianTimeOffset||c.WELL_KNOWN_CURRENCIES.g1.medianTimeOffset)}},api:p,default:function(){return console.warn("[currency] 'csCurrency.default()' has been DEPRECATED - Please use 'csCurrency.get()' instead."),b()}}}]),angular.module("cesium.bma.services",["ngApi","cesium.http.services","cesium.settings.services"]).factory("BMA",["$q","$window","$rootScope","$timeout","csCrypto","Api","Device","UIUtils","csConfig","csSettings","csCache","csHttp",function(e,t,n,i,a,o,r,s,l,c,d,u){function p(r,p,m,E){var b,g=r?"{0}:{1}".format(r,p||(m?"443":"80")):"default",f="[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}",h="SIG\\(("+f+")\\)",T="OBJ\\(([0-9]+)\\)",v="( ([a-z_][a-z0-9-_.ğĞ]*))?( ([0-9.]+))?( ([0-9a-f:]+))?( ([0-9]+))( (.+))?",I={BMA:"BASIC_MERKLED_API",BMAS:"BMAS",WS2P:"WS2P",BMATOR:"BMATOR",WS2PTOR:"WS2PTOR"},O={USER_ID:"[0-9a-zA-Z-_]+",CURRENCY:"[0-9a-zA-Z-_]+",PUBKEY:f,PUBKEY_WITH_CHECKSUM:"("+f+"):([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{3})",COMMENT:"[ a-zA-Z0-9-_:/;*\\[\\]()?!^\\+=@&~#{}|\\\\<>%.]*",INVALID_COMMENT_CHARS:"[^ a-zA-Z0-9-_:/;*\\[\\]()?!^\\+=@&~#{}|\\\\<>%.]*",URI_WITH_AT:"duniter://(?:([A-Za-z0-9_-]+):)?("+f+"@([a-zA-Z0-9-.]+.[ a-zA-Z0-9-_:/;*?!^\\+=@&~#|<>%.]+)",URI_WITH_PATH:"duniter://([a-zA-Z0-9-.]+.[a-zA-Z0-9-_:.]+)/("+f+")(?:/([A-Za-z0-9_-]+))?",BMA_ENDPOINT:I.BMA+v,BMAS_ENDPOINT:I.BMAS+v,WS2P_ENDPOINT:I.WS2P+" ([a-f0-9]{8})"+v,BMATOR_ENDPOINT:I.BMATOR+" ([a-z0-9-_.]*|[0-9.]+|[0-9a-f:]+.onion)(?: ([0-9]+))?",WS2PTOR_ENDPOINT:I.WS2PTOR+" ([a-f0-9]{8}) ([a-z0-9-_.]*|[0-9.]+|[0-9a-f:]+.onion)(?: ([0-9]+))?(?: (.+))?"},N={PROTOCOL_VERSION:10,ROOT_BLOCK_HASH:"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",LIMIT_REQUEST_COUNT:5,LIMIT_REQUEST_DELAY:1e3,regexp:O,api:I},R=this;function A(e,t,n){R.started&&R.stop(),R.alive=!1,c.data&&c.data.node&&(e=e||c.data.node.host,t=t||c.data.node.port,n=angular.isDefined(n)?n:443==t||c.data.node.useSsl||R.forceUseSsl),e&&(R.host=e,R.port=t||80,R.useSsl=angular.isDefined(n)?n:443==R.port||R.forceUseSsl,R.server=u.getServer(e,t),R.url=u.getUrl(e,t,"",n))}function S(e){return new RegExp("^"+e+"$")}function C(e){return new RegExp(e)}function L(){R.raw&&(console.warn("[BMA] Closing all websockets..."),_.keys(R.raw.wsByPath||{}).forEach((function(e){R.raw.wsByPath[e].close()})),R.raw.wsByPath={})}function D(e,t){t=R.useCache&&t||0;var n=e+(t?"#"+t:""),a=function(o){if(!R.started)return R._startPromise||console.warn("[BMA] Trying to get [{0}] before start(). Waiting...".format(e)),R.ready().then((function(){return a(o)}));var r=R.raw.getByPath[n];r||(r=t?u.getWithCache(R.host,R.port,e,R.useSsl,t,null,null,"BMA-"):u.get(R.host,R.port,e,R.useSsl),R.raw.getByPath[n]=r);var l=1;return r(o).catch((function(e){if(e&&e.ucode===M.errorCodes.HTTP_LIMITATION&&l<=M.constants.LIMIT_REQUEST_COUNT)return 1===l&&(console.warn("[BMA] Too many HTTP requests: Will wait then retry..."),s.loading.update({template:"COMMON.LOADING_WAIT"})),i((function(){return l++,r(o)}),M.constants.LIMIT_REQUEST_DELAY);throw e}))};return a}function y(e){var t=function(n,i){if(!R.started)return R._startPromise||console.error("[BMA] Trying to post [{0}] before start()...".format(e)),R.ready().then((function(){return t(n,i)}));var a=R.raw.postByPath[e];return a||(a=u.post(R.host,R.port,e,R.useSsl),R.raw.postByPath[e]=a),a(n,i)};return t}function P(e){return function(){var t=R.raw.wsByPath[e];return t&&!t.isClosed()||((t=u.ws(R.host,R.port,e,R.useSsl)).onclose=function(){delete R.raw.wsByPath[e]},R.raw.wsByPath[e]=t),t}}function k(e){i((function(){M.copy(e.node)}),1e3)}R.raw={getByPath:{},postByPath:{},wsByPath:{}},R.api=new o(this,"BMA-"+g),R.started=!1,R.init=A,R.forceUseSsl=!!("true"===l.httpsMode||!0===l.httpsMode||"force"===l.httpsMode||t.location&&"https:"===t.location.protocol),R.forceUseSsl&&console.debug("[BMA] Enable SSL (forced by config or detected in URL)"),r&&A(r,p,m),R.useCache=!angular.isDefined(E)||E,R.isAlive=function(e){return e=e||R,u.get(e.host,e.port,"/node/summary",e.useSsl)().then((function(e){var t=e&&e.duniter&&e.duniter.software,n=!0;return"duniter"===t&&e.duniter.version?n=u.version.isCompatible(c.data.minVersion,e.duniter.version):console.debug("[BMA] Unknown node software [{0} v{1}]: could not check compatibility.".format(t||"?",e.duniter.version||"?")),n||console.error("[BMA] Incompatible node [{0} v{1}]: expected at least v{2}".format(t,e.duniter.version,c.data.minVersion)),n})).catch((function(){return!1}))},R.isStarted=function(){return R.started},R.ready=function(){return R.started?e.when(R.alive):R._startPromise||R.start()},R.start=function(){if(R._startPromise)return R._startPromise;if(R.started)return e.when(R.alive);if(!R.host)return c.ready().then((function(){return R.init(),R.useCache=!0,R.start()}));console.debug("[BMA] Starting {0} {ssl: {1})...".format(R.server,R.useSsl));var t=Date.now();return R._startPromise=e.all([c.ready(),R.isAlive()]).then((function(e){return R.alive=e[1],R.alive?(b&&b.length||function(){b=[c.api.data.on.changed(n,k,this)]}(),console.debug("[BMA] Started in "+(Date.now()-t)+"ms"),R.api.node.raise.start(),R.started=!0,delete R._startPromise,!0):(console.error("[BMA] Could not start {0} : unreachable".format(R.server)),R.started=!0,delete R._startPromise,!1)})),R._startPromise},R.stop=function(){return R.started||R._startPromise?(console.debug("[BMA] Stopping..."),_.forEach(b,(function(e){e()})),b=[],delete R._startPromise,R.alive?(L(),console.debug("[BMA] Cleaning cache {prefix: '{0}'}...".format("BMA-")),d.clear("BMA-"),R.raw.getByPath={},R.raw.postByPath={},R.raw.wsByPath={},R.alive=!1,R.started=!1,R.api.node.raise.stop()):R.started=!1,e.when()):e.when()},R.restart=function(){return R.stop(),i(R.start,200).then((function(e){return e&&R.api.node.raise.restart(),e}))},R.api.registerEvent("node","start"),R.api.registerEvent("node","stop"),R.api.registerEvent("node","restart");var M={errorCodes:{REVOCATION_ALREADY_REGISTERED:1002,HTTP_LIMITATION:1006,IDENTITY_SANDBOX_FULL:1007,NO_MATCHING_IDENTITY:2001,UID_ALREADY_USED:2003,NO_MATCHING_MEMBER:2004,NO_IDTY_MATCHING_PUB_OR_UID:2021,WRONG_SIGNATURE_MEMBERSHIP:2006,MEMBERSHIP_ALREADY_SEND:2007,NO_CURRENT_BLOCK:2010,BLOCK_NOT_FOUND:2011,SOURCE_ALREADY_CONSUMED:2015,TX_INPUTS_OUTPUTS_NOT_EQUAL:2024,TX_OUTPUT_SUM_NOT_EQUALS_PREV_DELTAS:2025,TX_ALREADY_PROCESSED:2030},constants:N,regexp:{USER_ID:S(O.USER_ID),COMMENT:S(O.COMMENT),PUBKEY:S(O.PUBKEY),PUBKEY_WITH_CHECKSUM:S(O.PUBKEY_WITH_CHECKSUM),CURRENCY:S(O.CURRENCY),URI:S(O.URI),BMA_ENDPOINT:S(O.BMA_ENDPOINT),BMAS_ENDPOINT:S(O.BMAS_ENDPOINT),WS2P_ENDPOINT:S(O.WS2P_ENDPOINT),BMATOR_ENDPOINT:S(O.BMATOR_ENDPOINT),WS2PTOR_ENDPOINT:S(O.WS2PTOR_ENDPOINT),TX_OUTPUT_SIG:S(h),TX_OUTPUT_FUNCTION:C("SIG\\(([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})\\)|XHX\\(([A-F0-9]{1,64})\\)|CSV\\(([0-9]{1,8})\\)|CLTV\\(([0-9]{1,10})\\)"),TX_OUTPUT_OBJ_OPERATOR_AND:C(T+"([ ]*&&[ ]*("+T+"))+"),TX_OUTPUT_OBJ_OPERATOR_OR:C(T+"([ ]*\\|\\|[ ]*("+T+"))+"),TX_OUTPUT_OBJ:C(T),TX_OUTPUT_OBJ_OPERATOR:C("OBJ\\(([0-9]+)\\)[ ]*(&&)|(\\|\\|)[ ]*OBJ\\(([0-9]+)\\)"),TX_OUTPUT_OBJ_PARENTHESIS:C("\\(("+T+")\\)"),TX_OUTPUT_FUNCTIONS:C("SIG\\(([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})\\)|XHX\\(([A-F0-9]{1,64})\\)|CSV\\(([0-9]{1,8})\\)|CLTV\\(([0-9]{1,10})\\)([ ]*(&&)|(\\|\\|)[ ]*SIG\\(([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44})\\)|XHX\\(([A-F0-9]{1,64})\\)|CSV\\(([0-9]{1,8})\\)|CLTV\\(([0-9]{1,10})\\))*")},node:{summary:D("/node/summary",d.constants.LONG),same:function(e){return(e=e||{}).useSsl=angular.isDefined(e.useSsl)?e.useSsl:e.port&&443==e.port,R.host===e.host&&(!R.port&&!e.port2||R.port==e.port2||80)&&R.useSsl===e.useSsl},forceUseSsl:R.forceUseSsl},network:{peering:{self:D("/network/peering"),peers:D("/network/peering/peers")},peers:D("/network/peers"),ws2p:{info:D("/network/ws2p/info"),heads:D("/network/ws2p/heads")}},wot:{lookup:D("/wot/lookup/:search"),certifiedBy:D("/wot/certified-by/:pubkey",d.constants.SHORT),certifiersOf:D("/wot/certifiers-of/:pubkey",d.constants.SHORT),member:{all:D("/wot/members",d.constants.LONG),pending:D("/wot/pending",d.constants.SHORT)},requirements:function(e,t){return!0!==t?M.raw.wot.requirements(e):M.raw.wot.requirementsWithCache(e)},add:y("/wot/add"),certify:y("/wot/certify"),revoke:y("/wot/revoke")},blockchain:{parameters:D("/blockchain/parameters",d.constants.VERY_LONG),block:D("/blockchain/block/:block",d.constants.SHORT),blocksSlice:D("/blockchain/blocks/:count/:from"),current:function(e){return!0!==e?M.raw.blockchain.current():M.raw.blockchain.currentWithCache()},membership:y("/blockchain/membership"),stats:{ud:D("/blockchain/with/ud",d.constants.MEDIUM),tx:D("/blockchain/with/tx"),newcomers:D("/blockchain/with/newcomers",d.constants.MEDIUM),hardship:D("/blockchain/hardship/:pubkey"),difficulties:D("/blockchain/difficulties")}},tx:{sources:D("/tx/sources/:pubkey",d.constants.SHORT),process:y("/tx/process"),history:{all:function(e){return M.raw.tx.history.all(e).then((function(e){return e.history=e.history||{},e.history.sending=[],e.history.pendings=[],e}))},times:function(e,t){return(!0!==t?M.raw.tx.history.times(e):M.raw.tx.history.timesWithCache(e)).then((function(e){return e.history=e.history||{},e.history.sending=[],e.history.pendings=[],e}))},blocks:D("/tx/history/:pubkey/blocks/:from/:to",d.constants.LONG),pending:D("/tx/history/:pubkey/pending")}},ud:{history:D("/ud/history/:pubkey")},uri:{},version:{},raw:{blockchain:{currentWithCache:D("/blockchain/current",d.constants.SHORT),current:D("/blockchain/current")},wot:{requirementsWithCache:D("/wot/requirements/:pubkey",d.constants.LONG),requirements:D("/wot/requirements/:pubkey")},tx:{history:{timesWithCache:D("/tx/history/:pubkey/times/:from/:to",d.constants.LONG),times:D("/tx/history/:pubkey/times/:from/:to"),all:D("/tx/history/:pubkey")}}}};M.tx.parseUnlockCondition=function(e){for(var t,n,i,a,o=e,r=[],s={},l=M.regexp.TX_OUTPUT_FUNCTION.exec(o);l;)t={},n="OBJ("+r.length+")",t.type=o.substr(l.index,l[0].indexOf("(")),t.value=l[1]||l[2]||l[3]||l[4],r.push(t),s[t.type]=s[t.type]++||1,o=o.replace(l[0],n),l=M.regexp.TX_OUTPUT_FUNCTION.exec(o);for(var c=!0;c;){for(c=!!(l=M.regexp.TX_OUTPUT_OBJ_OPERATOR_AND.exec(o));l;){for(t={},n="OBJ("+r.length+")",t.type="AND",t.children=[],r.push(t),i=l[0],a=M.regexp.TX_OUTPUT_OBJ.exec(i);a;)t.children.push(r[a[1]]),i=i.replace(a[0],""),a=M.regexp.TX_OUTPUT_OBJ.exec(i);o=o.replace(l[0],n),l=M.regexp.TX_OUTPUT_OBJ_OPERATOR_AND.exec(i)}for(l=M.regexp.TX_OUTPUT_OBJ_OPERATOR_OR.exec(o),c=c||!!l;l;){for(t={},n="OBJ("+r.length+")",t.type="OR",t.children=[],r.push(t),i=l[0],a=M.regexp.TX_OUTPUT_OBJ.exec(i);a;)t.children.push(r[a[1]]),i=i.replace(a[0],""),a=M.regexp.TX_OUTPUT_OBJ.exec(i);o=o.replace(l[0],n),l=M.regexp.TX_OUTPUT_OBJ_OPERATOR_AND.exec(o)}for(l=M.regexp.TX_OUTPUT_OBJ_PARENTHESIS.exec(o),c=c||!!l;l;)o=o.replace(l[0],l[1]),l=M.regexp.TX_OUTPUT_OBJ_PARENTHESIS.exec(o)}if(0!==(s=_.keys(s)).length)return console.debug("[BMA] Unlock conditions successfully parsed:",t),{unlockFunctions:s,unlockTree:t};console.error("[BMA] Unparseable unlock condition: ",output)},M.node.parseEndPoint=function(e,t){var n=M.regexp.BMA_ENDPOINT.exec(e);return n?{dns:n[2]||"",ipv4:n[4]||"",ipv6:n[6]||"",port:n[8]||80,useSsl:n[8]&&443==n[8],path:n[10],useBma:!0}:(n=M.regexp.BMAS_ENDPOINT.exec(e))?{dns:n[2]||"",ipv4:n[4]||"",ipv6:n[6]||"",port:n[8]||80,useSsl:!0,path:n[10],useBma:!0}:(n=M.regexp.BMATOR_ENDPOINT.exec(e))?{dns:n[1]||"",port:n[2]||80,useSsl:!1,useTor:!0,useBma:!0}:(n=M.regexp.WS2P_ENDPOINT.exec(e))?{ws2pid:n[1]||"",dns:n[3]||"",ipv4:n[5]||"",ipv6:n[7]||"",port:n[9]||80,useSsl:n[9]&&443==n[9],path:n[11]||"",useWs2p:!0}:(n=M.regexp.WS2PTOR_ENDPOINT.exec(e))?{ws2pid:n[1]||"",dns:n[2]||"",port:n[3]||80,path:n[4]||"",useSsl:!1,useTor:!0,useWs2p:!0}:t&&(n=S(t+v).exec(e))?{dns:n[2]||"",ipv4:n[4]||"",ipv6:n[6]||"",port:n[8]||80,useSsl:n[8]&&443==n[8],path:n[10],useBma:!1}:void 0},M.copy=function(e){if(u.getUrl(e.host,e.port,"",e.useSsl)!==R.url){var t=R.started;if(t&&R.stop(),R.init(e.host,e.port,e.useSsl,R.useCache),t)return i((function(){return R.start().then((function(e){return e&&R.api.node.raise.restart(),e}))}),200)}},M.wot.member.uids=function(){return M.wot.member.all().then((function(e){return e.results.reduce((function(e,t){return e[t.pubkey]=t.uid,e}),{})}))},M.wot.member.get=function(e){return M.wot.member.uids().then((function(t){var n=t[e];return{pubkey:e,uid:n||null}}))},M.wot.member.getByUid=function(e){return M.wot.member.all().then((function(t){return _.findWhere(t.results,{uid:e})}))},M.blockchain.blocks=function(e){return M.raw.getHttpRecursive(M.blockchain.block,"block",e)},M.network.peering.peersByLeaves=function(e){return M.raw.getHttpRecursive(M.network.peering.peers,"leaf",e,0,10)},M.raw.getHttpRecursive=function(t,n,a,o,r){return o=angular.isDefined(o)?o:0,r=r||M.constants.LIMIT_REQUEST_COUNT,e((function(s,l){var c=[],d=[];_.each(a.slice(o,o+r),(function(e){var i={};i[n]=e,d.push(t(i).then((function(e){e&&c.push(e)})))})),e.all(d).then((function(){o0?e.dividend*Math.pow(10,e.unitbase):e.dividend}))}))},M.uri.parse=function(t){return e((function(e,n){var i;if(S(O.PUBKEY).test(t))e({pubkey:t});else if(S(O.PUBKEY_WITH_CHECKSUM).test(t)){console.debug("[BMA.parse] Detecting a pubkey with checksum: "+t);var o=M.regexp.PUBKEY_WITH_CHECKSUM.exec(t);i=o[1];var r=o[2];console.debug("[BMA.parse] Detecting a pubkey {"+i+"} with checksum {"+r+"}");var s=a.util.pkChecksum(i);console.debug("[BMA.parse] Expecting checksum for pubkey is {"+s+"}"),r!=s?n({message:"ERROR.PUBKEY_INVALID_CHECKSUM"}):e({pubkey:i})}else if(t.startsWith("duniter://")){var l,c=u.uri.parse(t),d=-1===c.host.indexOf(".")?c.host:null,p=-1!==c.host.indexOf(".")?c.host:null;if(c.username&&(c.password?(l=c.username,i=c.password):i=c.username),c.pathname){var m=c.pathname.split("/"),E=m?m.length:0,b=0;if(!d&&E>b&&(d=m[b++]),!i&&E>b&&(i=m[b++]),!l&&E>b&&(l=m[b++]),E>b)return void n({message:"Bad Duniter URI format. Invalid path (incomplete or redundant): "+c.pathname})}if(d)return p||e({uid:l,pubkey:i,currency:d}),u.get(p+"/blockchain/parameters")().then((function(t){t.currency===d?e({uid:l,pubkey:i,host:p,currency:d}):n({message:"Node's currency ["+t.currency+"] does not matched URI's currency ["+d+"]."})})).catch((function(e){console.error(e),n({message:"Could not get node parameter. Currency could not be retrieve"})}));if(!p)return void n({message:"Bad Duniter URI format. Missing currency name (or node address)."});u.get(p+"/blockchain/parameters")().then((function(t){e({uid:l,pubkey:i,host:p,currency:t.currency})})).catch((function(e){console.error(e),n({message:"Could not get node parameter. Currency could not be retrieve"})}))}else console.debug("[BMA.parse] Could not parse URI: "+t),n({message:"ERROR.UNKNOWN_URI_FORMAT"})})).then((function(e){if(e){if(e.pubkey&&!S(O.PUBKEY).test(e.pubkey))throw{message:"Invalid pubkey format ["+e.pubkey+"]"};if(e.uid&&!S(O.USER_ID).test(e.uid))throw{message:"Invalid uid format ["+e.uid+"]"};if(e.currency&&!S(O.CURRENCY).test(e.currency))throw{message:"Invalid currency format ["+e.currency+"]"};return e}}))};var w=c.data.duniterLatestReleaseUrl&&u.uri.parse(c.data.duniterLatestReleaseUrl);M.raw.getLatestRelease=w?u.getWithCache(w.host,w.port,"/"+w.pathname,443==+w.port||"https:"===w.protocol||R.forceUseSsl,d.constants.LONG):function(){return e.when()},M.version.latest=function(){return M.raw.getLatestRelease().then((function(e){if(e)return e.name&&e.html_url?{version:e.name,url:e.html_url}:e.tag_name&&e.html_url?{version:e.tag_name.substring(1),url:e.html_url}:void 0})).catch((function(e){console.error("[BMA] Failed to get Duniter latest version",e)}))},M.websocket={block:P("/ws/block"),peer:P("/ws/peer"),close:L},angular.merge(R,M)}var m=new p;return m.instance=function(e,t,n,i){return new p(e,t,n,i=!!angular.isDefined(i)&&i)},m.lightInstance=function(e,t,n,i){return{host:e,port:t=t||80,useSsl:n=angular.isDefined(n)?n:443==t,url:u.getUrl(e,t,"",n),node:{summary:u.getWithCache(e,t,"/node/summary",n,d.constants.MEDIUM,!1,i)},network:{peering:{self:u.get(e,t,"/network/peering",n,i)},peers:u.get(e,t,"/network/peers",n,i)},blockchain:{current:u.get(e,t,"/blockchain/current",n,i),stats:{hardship:u.get(e,t,"/blockchain/hardship/:pubkey",n,i)}}}},m}]),angular.module("cesium.wot.services",["ngApi","cesium.bma.services","cesium.crypto.services","cesium.utils.services","cesium.settings.services"]).factory("csWot",["$rootScope","$q","$timeout","BMA","Api","CacheFactory","UIUtils","csConfig","csCurrency","csSettings","csCache",function(e,t,n,i,a,o,r,s,l,c,d){var u=new a(this,"csWot"),p=d.get("csWot-idty-",d.constants.MEDIUM),m=d.get("csWot-requirements-",d.constants.MEDIUM),E=function(e){var t={};return e.reduce((function(e,n){return n.id=n.id||n.uid+"-"+n.pubkey,t[n.id]?e:(t[n.id]=!0,e.concat(n))}),[])},b=function(e,t,n){return t=t||0,e=E(e),e=_.sortBy(e,(function(e){var t=1;return t+=1e6*e.block,-(t+=10*(900-e.uid.toLowerCase().charCodeAt(0)))})),angular.isDefined(n)&&e.length>n&&(e=e.slice(t,t+n)),e},g=function(e){e.requirements={loaded:!1,meta:{},hasSelf:!1,needSelf:!0,needMembership:!0,canMembershipOut:!1,needRenew:!1,pendingMembership:!1,isMember:!1,wasMember:!1,certificationCount:0,needCertifications:!1,needCertificationCount:0,willNeedCertificationCount:0,alternatives:void 0},e.blockUid=null,e.isMember=!1,e.sigDate=null,e.hasSelf=!1},f=function(e,t){if(e.hasSelf=!!e.meta.timestamp,e.needSelf=!e.hasSelf||e.meta.invalid,e.wasMember=!!angular.isDefined(e.wasMember)&&e.wasMember,e.needMembership=!e.revoked&&e.membershipExpiresIn<=0&&e.membershipPendingExpiresIn<=0&&!e.wasMember,e.needRenew=!e.needMembership&&!e.revoked&&e.membershipExpiresIn<=c.data.timeWarningExpireMembership&&e.membershipPendingExpiresIn<=0||e.wasMember&&!e.revoked&&0===e.membershipExpiresIn&&0===e.membershipPendingExpiresIn,e.canMembershipOut=!e.revoked&&e.membershipExpiresIn>0,e.pendingMembership=!e.revoked&&e.membershipExpiresIn<=0&&e.membershipPendingExpiresIn>0,e.isMember=!e.revoked&&e.membershipExpiresIn>0,e.blockUid=e.meta.timestamp,e.certificationCount=(e.isMember||e.wasMember&&!e.expired)&&e.certifications?e.certifications.length:0,e.willExpireCertificationCount=e.certifications?e.certifications.reduce((function(e,t){return e+(t.expiresIn<=c.data.timeWarningExpire?1:0)}),0):0,e.willExpire=e.willExpireCertificationCount>0,e.pendingRevocation=!e.revoked&&!!e.revocation_sig,e.isMember||e.wasMember)e.pendingCertificationCount=angular.isDefined(e.pendingCerts)?e.pendingCerts.length:0;else{var n=_.union(_.pluck(e.pendingCerts||[],"from"),_.pluck(e.certifications||[],"from"));e.pendingCertificationCount=_.size(n)}return e.needCertificationCount=!e.needSelf&&e.certificationCount1&&(i=_.sortBy(i,(function(e){var t=0;t+=1e12*(s.uid&&e.uid===s.uid?1:0),t+=1e11*(e.meta.invalid?0:1),t+=1e10*(s.blockUid&&e.meta.timestamp&&e.meta.timestamp===s.blockUid?1:0),t+=1e9*(e.membershipExpiresIn>0?1:0),t+=1e8*(e.membershipPendingExpiresIn>0?1:0),t+=1e7*(e.expired?0:1),t+=1e6*(e.outdistanced?0:1),t+=1e5*(e.wasMember?1:0);var n=!e.expired&&e.certifications?e.certifications.length:0;return t+=1*(n||0),-(t+=1*(!n&&e.membershipPendingExpiresIn>0?e.membershipPendingExpiresIn/1e3:0))})),console.debug("[wot] Found {0} identities (in requirements). Will selected the best one".format(i.length))),s.requirements=f(i[0],n.parameters),s.pubkey=s.requirements.pubkey,s.uid=s.requirements.uid,s.isMember=s.requirements.isMember,s.blockUid=s.requirements.meta&&s.requirements.meta.timestamp,s.hasSelf=s.requirements.hasSelf,s.sigDate=s.requirements.meta&&s.requirements.meta.time,!s.requirements.isMember&&!s.requirements.wasMember&&i.length>1&&(s.requirements.alternatives=i.splice(1),_.forEach(s.requirements.alternatives,(function(e){f(e,n.parameters)}))),m.put(o,s),angular.merge(e,s),console.debug("[wot] Requirements for '{0}' loaded in {1}ms".format(s.pubkey&&s.pubkey.substring(0,8)||s.uid,Date.now()-c)),e})).catch((function(t){if(s.requirements={loaded:!0},g(e),t&&(t.ucode==i.errorCodes.NO_MATCHING_MEMBER||t.ucode==i.errorCodes.NO_IDTY_MATCHING_PUB_OR_UID))return e.requirements.loaded=!0,e;throw t}))},v=function(e,t){var n={pubkey:e,uid:t,hasSelf:!1};return i.wot.lookup({search:e||t}).then((function(e){var t=e.results.reduce((function(e,t){return e.concat(t.uids.reduce((function(e,n){var i=n.meta.timestamp.split("-",2),a=parseInt(i[0]);return e.concat({uid:n.uid,pubkey:t.pubkey,meta:{timestamp:n.meta.timestamp,number:a,hash:i[1],sig:n.self},revoked:n.revoked,revoked_on:n.revoked_on})}),[]))}),[]);return h(t).then((function(t){return{identities:t,results:e.results}}))})).then((function(e){var t=e.identities;t.length>1&&(e.identities=_.sortBy(t,(function(e){var t=0;return t+=1e11*(n.uid&&e.uid===n.uid?1:0),t+=1e10*(e.meta.invalid?0:1),t+=1e9*(n.blockUid&&e.meta.timestamp&&e.meta.timestamp===n.blockUid?1:0),t+=1e8*(e.revoked?0:1),-(t+=1*(e.meta.number?e.meta.number:0)/1e3)})),console.debug("[wot] Found {0} identities (in lookup). Will selected the best one".format(t.length))),_.forEach(t,(function(e){e.hasSelf=!!(e.uid&&e.meta.timestamp&&e.meta.sig)})),n.requirements=t[0],n.pubkey=n.requirements.pubkey,n.uid=n.requirements.uid,n.blockUid=n.requirements.meta&&n.requirements.meta.timestamp,n.hasSelf=n.requirements.hasSelf,n.sigDate=n.requirements.meta&&n.requirements.meta.time,t.length>1&&(n.requirements.alternatives=t.splice(1)),n.lookup={};var i={};return n.lookup.certifications=(e.results||[]).reduce((function(e,t){return t.uids.reduce((function(e,t){var n=t.uid+"-"+(t.meta?t.meta.timestamp:"");return e[n]=(t.others||[]).reduce((function(e,t){var a=n+"-"+t.pubkey,o={pubkey:t.pubkey,uid:t.uids[0],cert_time:{block:t.meta&&t.meta.block_number?t.meta.block_number:0,block_hash:t.meta&&t.meta.block_hash?t.meta.block_hash:null},isMember:t.isMember,wasMember:t.wasMember};return i[a]?o.cert_time.block>i[a].cert_time.block?(i[a]=o,e.splice(_.findIndex(e,{pubkey:t.pubkey}),1,o),e):e:(i[a]=o,e.concat(o))}),[]),e}),e)}),{}),i={},n.lookup.givenCertifications=(e.results||[]).reduce((function(e,t){return(t.signed||[]).reduce((function(e,t){var n={pubkey:t.pubkey,uid:t.uid,cert_time:{block:t.cert_time&&t.cert_time.block?t.cert_time.block:0,block_hash:t.cert_time&&t.cert_time.block_hash?t.cert_time.block_hash:null},sigDate:t.meta?t.meta.timestamp:null,isMember:t.isMember,wasMember:t.wasMember};if(i[t.pubkey]){if(!(n.block>i[t.pubkey].block))return e;i[t.pubkey]=n}else i[t.pubkey]=n;return e.concat(n)}),e)}),[]),n})).catch((function(e){if(e&&e.ucode==i.errorCodes.NO_MATCHING_IDENTITY)return g(n),n;throw e}))},I=function(e,t,n,a,o,r){function s(e,t){return e+"-"+t}var d=!0,u=n?n.reduce((function(e,t){var n=s(t.pubkey,t.cert_time?t.cert_time.block:t.sigDate);return t.cert_time||(d=!1),e[n]=t,e}),{}):{};return e({pubkey:t}).then((function(e){return(e&&e.certifications||[]).reduce((function(e,t){var n=!t.written,i=t.cert_time?t.cert_time.medianTime:null,r=i?n?i+a.sigWindow-o:i+a.sigValidity-o:0;r=r<0?0:r;var l=s(t.pubkey,d&&t.cert_time?t.cert_time.block:t.sigDate);return delete u[l],e.concat({pubkey:t.pubkey,uid:t.uid,time:i,isMember:t.isMember,wasMember:t.wasMember,expiresIn:r,willExpire:r&&r<=c.data.timeWarningExpire,pending:n,block:null!==t.written?t.written.number:t.cert_time?t.cert_time.block:null,valid:r>0})}),[])})).catch((function(e){if(e&&e.ucode==i.errorCodes.NO_MATCHING_MEMBER)return[];if(e&&1002==e.ucode)return console.warn("[wallet-service] Detecting Duniter issue #1309 ! Applying workaround... "),[];throw e})).then((function(e){var t=_.values(u);if(!t.length)return e;if(l.data.initPhase)return t.reduce((function(e,t){return e.concat({pubkey:t.pubkey,uid:t.uid,isMember:t.isMember,wasMember:t.wasMember,time:null,expiresIn:a.sigWindow,willExpire:!1,pending:!0,block:0,valid:!0})}),e);var n=t.reduce((function(e,t){var n=d&&t.cert_time?t.cert_time.block:t.sigDate?t.sigDate.split("-")[0]:null;return angular.isDefined(n)&&(e[n]?e[n].push(t):e[n]=[t]),e}),{});return i.blockchain.blocks(_.keys(n)).then((function(t){return e=t.reduce((function(e,t){return e.concat(n[t.number].reduce((function(e,n){var i=t.medianTime,s=Math.max(0,i+a.sigWindow-o),l=!n.cert_time||!n.cert_time.block_hash||n.cert_time.block_hash==t.hash;l||console.debug("[wot] Invalid cert {0}: block hash changed".format(n.pubkey.substring(0,8)));var u=s>0&&(!r||n.isMember)&&l;return e.concat({pubkey:n.pubkey,uid:n.uid,isMember:n.isMember,wasMember:n.wasMember,time:i,expiresIn:s,willExpire:s&&s<=c.data.timeWarningExpire,pending:!0,block:d&&n.cert_time?n.cert_time.block:n.sigDate?n.sigDate.split("-")[0]:null,valid:u})}),[]))}),e)}))})).then((function(e){var t=e.reduce((function(e,t){return!t.pending&&t.valid&&t.expiresIn>=a.sigWindow&&(e[t.pubkey]=!0),e}),{});e=function(e){return _.sortBy(e,(function(e){var t=1;return t+=1e12*(e.expiresIn?e.expiresIn:0),t+=1e7*(e.isMember?1:0),-(t+=10*(e.block?e.block:0))}))}(e);var n=[],i=[];return{valid:e.reduce((function(e,a){return a.pending?(a.valid&&!t[a.pubkey]?n.push(a):a.valid||t[a.pubkey]||i.push(a),e):e.concat(a)}),[]),pending:n,error:i}}))},O=function(e,n,a){var o;if(a=a||{},!e&&n&&!a.force)return i.wot.member.getByUid(n).then((function(t){if(t)return O(t.pubkey,t.uid,i);var i=angular.copy(i||{});return i.force=!0,O(e,n,i)}));if(e){if((o=!1!==a.cache?p.get(e):null)&&(!n||o.uid===n)&&(!a.blockUid||o.blockUid===a.blockUid))return console.debug("[wot] Identity {{0}} found in cache".format(e.substring(0,8))),t.when(o);console.debug("[wot] Loading identity {{0}}...".format(e.substring(0,8))),o={pubkey:e,uid:n}}else console.debug("[wot] Loading identity from uid {{0}}...".format(n)),o={uid:n};a.blockUid&&(o.blockUid=a.blockUid);var r,s,c=Date.now();return t.all([l.parameters().then((function(e){r=e})),l.blockchain.current(!0).then((function(e){s=e.medianTime})).catch((function(e){if(!e||e.ucode!=i.errorCodes.NO_CURRENT_BLOCK)throw e;s=moment.utc().unix()})),T(o,!1!==a.cache),v(e,n)]).then((function(e){var n=e[3];if(!o.requirements.uid)return console.debug("[wot] No requirements found: using data from lookup"),angular.merge(o,n),void delete o.lookup;var a=o.requirements.uid+"-"+o.requirements.meta.timestamp;return t.all([I(i.wot.certifiersOf,o.pubkey,n.lookup?n.lookup.certifications[a]:null,r,s,!0).then((function(e){o.received_cert=e.valid,o.received_cert_pending=e.pending,o.received_cert_error=e.error})),I(i.wot.certifiedBy,o.pubkey,n.lookup?n.lookup.givenCertifications:null,r,s,!1).then((function(e){o.given_cert=e.valid,o.given_cert_pending=e.pending,o.given_cert_error=e.error}))])})).then((function(){return o.requirements.pendingCertificationCount=o.received_cert_pending?o.received_cert_pending.length:o.requirements.pendingCertificationCount,o.requirements.revoked=angular.isDefined(o.requirements.revoked)?o.requirements.revoked:o.revoked,function(e){e.requirements.revoked?(delete e.requirements.meta.invalid,e.requirements.revoked_on?(C(e,{type:"error",message:"ERROR.IDENTITY_REVOKED_WITH_TIME",messageParams:{revocationTime:e.requirements.revoked_on}}),console.debug("[wot] Identity [{0}] has been revoked on {1}".format(e.uid,e.requirements.revoked_on))):(C(e,{type:"error",message:"ERROR.IDENTITY_REVOKED"}),console.debug("[wot] Identity [{0}] has been revoked".format(e.uid)))):e.requirements.pendingRevocation?(delete e.requirements.meta.invalid,C(e,{type:"error",message:"ERROR.IDENTITY_PENDING_REVOCATION"}),console.debug("[wot] Identity [{0}] has pending revocation".format(e.uid))):e.requirements.meta&&e.requirements.meta.invalid?e.isMember||(C(e,{type:"error",message:"ERROR.IDENTITY_INVALID_BLOCK_HASH"}),console.debug("[wot] Invalid membership for uid {0}: block hash changed".format(e.uid))):e.requirements.expired?(C(e,{type:"error",message:"ERROR.IDENTITY_EXPIRED"}),console.debug("[wot] Identity {0} expired (in sandbox)".format(e.uid))):e.requirements.willNeedCertificationCount>0?(C(e,{type:"error",message:"INFO.IDENTITY_WILL_MISSING_CERTIFICATIONS",messageParams:e.requirements}),console.debug("[wot] Identity {0} will need {1} certification(s)".format(e.uid,e.requirements.willNeedCertificationCount))):!e.requirements.needSelf&&e.requirements.needMembership&&(C(e,{type:"error",message:"INFO.IDENTITY_NEED_MEMBERSHIP"}),console.debug("[wot] Identity {0} has a self but no membership".format(e.uid))),!e.isMember&&e.requirements.alternatives&&C(e,{type:"info",message:"INFO.HAS_ALTERNATIVE_IDENTITIES"})}(o),u.data.raisePromise.load(o).catch((function(e){console.debug("Error while loading identity data, on extension point."),console.error(e)}))})).then((function(){if(o.pubkey)return p.put(o.pubkey,o),console.debug("[wot] Identity "+o.pubkey.substring(0,8)+" loaded in "+(Date.now()-c)+"ms"),o}))},N=function(e,n){if(!e||e.trim()!==e)return t.when(void 0);var a=e.replace(/(^|\s)#\w+/g,"");return a=(a=a.replace(/[^a-zA-Z0-9_-\s]+/g,"")).replace(/\s+/g," ").trim(),(n=n||{}).addUniqueId=!angular.isDefined(n.addUniqueId)||n.addUniqueId,n.allowExtension=!angular.isDefined(n.allowExtension)||n.allowExtension,n.excludeRevoked=!!angular.isDefined(n.excludeRevoked)&&n.excludeRevoked,(a?t.all(a.split(" ").reduce((function(e,t){return console.debug("[wot] Will search on: '"+t+"'"),e.concat(i.wot.lookup({search:t}))}),[])).then((function(e){return e.reduce((function(e,t){return e.concat(t.results.reduce((function(e,t){return e.concat(t.uids.reduce((function(e,i){var a=i.meta.timestamp.split("-",2),o=!i.revoked&&i.revocation_sig;return n.excludeRevoked&&o?e:e.concat({uid:i.uid,pubkey:t.pubkey,number:a[0],hash:a[1],revoked:o})}),[]))}),[]))}),[])})).catch((function(e){if(e&&e.ucode==i.errorCodes.NO_MATCHING_IDENTITY)return[];throw e})):t.when([])).then((function(t){if(!n.allowExtension)return n.addUniqueId?E(t):t;var a=t.length;return u.data.raisePromise.search(e,t,"pubkey").then((function(){if(t.length>a&&_.filter(t,(function(e){return!e.uid&&e.pubkey})).length)return i.wot.member.uids().then((function(e){_.forEach(t,(function(t){!t.uid&&t.pubkey&&(t.uid=e[t.pubkey])}))}))})).then((function(){return n.addUniqueId?E(t):t}))}))},R=function(e,a,o,r){return t((function(s,l){var c=[],d=[];_.each(e.slice(a,a+o),(function(e){d.push(i.blockchain.block({block:e}).then((function(e){e&&e.joiners&&_.each(e.joiners,(function(t){var n=t.split(":"),i=n[n.length-1]+"-"+n[0];c.push({id:i,uid:n[n.length-1],pubkey:n[0],memberDate:e.medianTime,block:e.number})}))})))})),t.all(d).then((function(){c.lengthn.block)return;c[t.pubkey]=t,l[t.block]?l[t.block].push(t):l[t.block]=[t],n&&(l[n.block]=l[n.block].reduce((function(e,t){return t.pubkey==n.pubkey?e:(e||[]).concat(t)}),null),null===l[n.block]&&delete l[n.block])}}));var d=_.values(c),u=d.length,p=(d=b(d,e,n)).reduce((function(e,t){return e.concat(t.block)}),[]);return t.all([i.blockchain.blocks(_.uniq(p)).then((function(e){_.forEach(e,(function(e){_.forEach(l[e.number],(function(t){t.sigDate=e.medianTime,0!==e.number&&t.blockHash!==e.hash&&(C(t,{type:"error",message:"ERROR.WOT_PENDING_INVALID_BLOCK_HASH"}),console.debug("Invalid membership for uid={0}: block hash changed".format(t.uid)))}))}))})),S(d,"pubkey",!0)]).then((function(){return console.debug("[ES] [wot] Loaded {0}/{1} pending identities in {2} ms".format(d&&d.length||0,u,Date.now()-a)),{hits:d,total:u}}))}}))},all:function(){return A(["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","u","v","w","x","y","z"],0,i.constants.LIMIT_REQUEST_COUNT).then((function(e){return S(e,"pubkey",!0)})).then(E).then((function(){return{hits:idties,total:idties.length}}))},extend:function(e,t,n){return S([e],t,n).then((function(e){return e[0]}))},extendAll:S,api:u}}]),angular.module("cesium.tx.services",["ngApi","cesium.bma.services","cesium.settings.services","cesium.wot.services"]).factory("csTx",["$q","$timeout","$filter","$translate","FileSaver","UIUtils","BMA","Api","csConfig","csSettings","csWot","csCurrency",function(e,t,n,i,a,o,r,s,l,c,d,u){var p=new s(this,"csTx");function m(e,t,n,i,a){t&&t.length&&_.forEach(t,(function(t){if(null!==t.block_number||a){var o,s,l=!1,c=t.issuers.reduce((function(t,n){return l=l||n===e,n!==e?t.concat(n):t}),[]),d=[],u=[],p=t.outputs.reduce((function(n,i,a){var p="string"==typeof i?i.split(":",3):[i.amount,i.base,i.conditions];o=parseInt(p[1]);var m=b(parseInt(p[0]),o),E=p[2],g=r.regexp.TX_OUTPUT_SIG.exec(E);if(g){var f=g[1];if(f===e){if(!l)return n+m;null===t.block_number&&u.push({amount:parseInt(p[0]),base:o,type:"T",identifier:t.hash,noffset:a,consumed:!1,conditions:E})}else if(""===f||_.contains(c,f)||d.push(f),l)return n-m}else if(-1!==E.indexOf("SIG("+e+")")){var h=r.tx.parseUnlockCondition(E);if(h)return u.push(angular.merge({amount:parseInt(p[0]),base:o,type:"T",identifier:t.hash,noffset:a,conditions:E,consumed:!1},h)),h.amount=m,(s=s||[]).push(h),console.debug("[tx] has locked output:",h),n+m}return n}),0),m=p>0?c:d,E=t.time||t.blockstampTime,g=0!==p&&p+":"+t.hash+":"+E;if(g&&!i[g]){i[g]=!0;var f={time:E,amount:p,pubkey:1===m.length?m[0]:void 0,pubkeys:m.length>1?m:void 0,comment:t.comment,isUD:!1,hash:t.hash,locktime:t.locktime,block_number:t.block_number};l&&null===t.block_number&&(f.inputs=t.inputs,f.sources=u),s&&(f.lockedOutputs=s),n.push(f)}}}))}function E(t,n){return e((function(i,a){var o=moment().utc().unix();n=n||o-c.data.walletHistoryTimeSecond;var s={pendings:[],validating:[],history:[],errors:[]},l={},d=[u.blockchain.current(!0),r.tx.history.pending({pubkey:t}).then((function(e){m(t,e.history.sending,s.pendings,l,!0),m(t,e.history.pending,s.pendings,l,!0)}))];if("pending"!==n){var E=function(e){m(t,e.history.sent,s.history,l,!1),m(t,e.history.received,s.history,l,!1)};if(n>0){for(var b=c.data.walletHistorySliceSecond,g=n-=n%b;g-b0&&d.push(p.data.raisePromise.loadUDs({pubkey:t,fromTime:n}).then((function(e){e&&e.length&&_.forEach(e,(function(e){s.history.push(e)}))})).catch((function(e){console.debug("Error while loading UDs history, on extension point."),console.error(e)})))}e.all(d).then((function(e){var t=e[0];s.history.sort((function(e,t){return t.time-e.time}));var a=_.findIndex(s.history,(function(e){return e.block_number<=t.number-c.data.blockValidityWindow}));s.validating=a>0?s.history.splice(0,a):[],s.fromTime="pending"!==n&&n||void 0,s.toTime=s.history.length?s.history[0].time:s.fromTime,i(s)})).catch(a)}))}function b(e,t){return t<=0?e:e*Math.pow(10,t)}function g(e,t){_(t).forEach((function(t){!function(e,t,n){var i=e.type+":"+e.identifier+":"+e.noffset;angular.isUndefined(n[i])&&(t.push(e),n[i]=t.length-1)}(t,e.sources,e.sourcesIndexByKey)}))}function f(e){return r.tx.sources({pubkey:e}).then((function(e){var t={sources:[],sourcesIndexByKey:[],balance:0};return e.sources&&e.sources.length&&(_.forEach(e.sources,(function(e){e.consumed=!1,t.balance+=b(e.amount,e.base)})),g(t,e.sources)),t})).catch((function(e){throw console.warn("[tx] Error while getting sources...",e),e}))}function h(n,i){var a,r=Date.now();return t((function(){a||o.loading.update({template:"COMMON.LOADING_WAIT"})}),2e3),e.all([f(n),E(n,i)]).then((function(e){(a=e[0]).tx=e[1];var t=[],n=[],i=a.balance,o=a.balance;function s(e){var i=[],r=!0;e.amount>0?r=!1:(_.find(e.inputs,(function(e){var t=e.split(":").slice(2).join(":"),n=a.sourcesIndexByKey[t];if(!angular.isDefined(n))return r=!1,!0;i.push(a.sources[n])})),e.sources&&g(a,e.sources),delete e.sources,delete e.inputs),r?(o+=e.amount,t.push(e),_.forEach(i,(function(e){e.consumed=!0}))):n.push(e)}for(var l=a.tx.pendings,c=!0;l&&l.length;)_.forEach(l,s),n.length>0&&t.length>0&&c?(l=n,n=[],c=!1):l=null;a.tx=a.tx||{},a.tx.pendings=t.sort((function(e,t){return t.time-e.time})),a.tx.errors=n.sort((function(e,t){return t.time-e.time})),a.balance=o<0?i:o;var u=(a.tx.history||[]).concat(a.tx.validating||[],a.tx.pendings||[],a.tx.errors||[]);return d.extendAll(u,"pubkey").then((function(){return console.debug("[tx] TX and sources loaded in "+(Date.now()-r)+"ms"),a}))})).catch((function(e){throw console.warn("[tx] Error while getting sources and tx...",e),e}))}return p.registerEvent("data","loadUDs"),{load:h,loadSources:function(e){return console.debug("[tx] Loading sources for "+e.substring(0,8)),h(e,"pending")},downloadHistoryFile:function(t,r){return(r=r||{}).fromTime=r.fromTime||-1,console.debug("[tx] Exporting TX history for pubkey [{0}]".format(t.substr(0,8))),e.all([i(["ACCOUNT.HEADERS.TIME","COMMON.UID","COMMON.PUBKEY","COMMON.UNIVERSAL_DIVIDEND","ACCOUNT.HEADERS.AMOUNT","ACCOUNT.HEADERS.COMMENT"]),u.blockchain.current(!0),h(t,r.fromTime)]).then((function(e){var r=e[0],s=e[1],l=s&&s.medianTime||moment().utc().unix(),c=s&&s.currency,d=e[2];return d&&d.tx&&d.tx.history?i("ACCOUNT.FILE_NAME",{currency:c,pubkey:t,currentTime:l}).then((function(e){var t=n("formatDecimal"),i=n("medianDate"),o=n("currencySymbolNoHtml"),s=[r["ACCOUNT.HEADERS.TIME"],r["COMMON.UID"],r["COMMON.PUBKEY"],r["ACCOUNT.HEADERS.AMOUNT"]+" ("+o(c)+")",r["ACCOUNT.HEADERS.COMMENT"]],l=d.tx.history.concat(d.tx.validating).reduce((function(e,n){return e.concat([i(n.time),n.uid,n.pubkey,t(n.amount/100),'"'+(n.isUD?r["COMMON.UNIVERSAL_DIVIDEND"]:n.comment)+'"'].join(";")+"\n")}),[s.join(";")+"\n"]),u=new Blob(l,{type:"text/plain; charset=utf-8"});a.saveAs(u,e)})):o.toast.show("INFO.EMPTY_TX_HISTORY")}))},api:p}}]),angular.module("cesium.wallet.services",["ngApi","ngFileSaver","cesium.bma.services","cesium.crypto.services","cesium.utils.services","cesium.settings.services"]).factory("csWallet",["$q","$rootScope","$timeout","$translate","$filter","$ionicHistory","UIUtils","Api","Idle","localStorage","sessionStorage","Modals","CryptoUtils","csCrypto","BMA","csConfig","csSettings","FileSaver","Blob","csWot","csTx","csCurrency",function(e,t,n,a,o,r,s,l,c,d,u,p,m,E,b,g,f,h,T,v,I,O){var N,R=b;function A(b,A){var S,C,L,D,y,P,k=(A=A||R).constants.PROTOCOL_VERSION,M=A.constants.PROTOCOL_VERSION,w=A.constants.PROTOCOL_VERSION,U=A.constants.PROTOCOL_VERSION,x=A.constants.PROTOCOL_VERSION,B={},H=!1,F=new l(this,"csWallet-"+b),W=function(e){B.loaded=!1,B.pubkey=null,B.qrcode=null,B.uid=null,B.localName=null,B.isNew=null,B.sourcesIndexByKey=null,B.medianTime=null,B.requirements={},B.blockUid=null,B.sigDate=null,B.sigStock=null,B.isMember=!1,B.events=[],B.children=[],B.encryptedData=null,V(),G(),D=!1,y=void 0,e?F.data.raise.init(B):(Y()&&C&&!C.useLocalStorage&&f.reset(),F.data.raise.reset(B))},V=function(){B.keypair={signSk:null,signPk:null}},G=function(){B.sources=void 0,B.sourcesIndexByKey=void 0,B.balance=0,B.tx=B.tx||{},B.tx.history=[],B.tx.pendings=[],B.tx.validating=[],B.tx.errors=[],delete B.tx.fromTime,delete B.tx.toTime},Y=function(){return"default"===b},$=function(){return B.encryptedData&&B.encryptedData.nonce&&B.encryptedData.content},K=function(e){B.sources=B.sources||[],B.sourcesIndexByKey=B.sourcesIndexByKey||{},_(e).forEach((function(e){!function(e,t,n){var i=e.type+":"+e.identifier+":"+e.noffset;angular.isUndefined(n[i])&&(e.conditions||console.warn("Trying to add a source without output condition !",e),t.push(e),n[i]=t.length-1)}(e,B.sources,B.sourcesIndexByKey)}))},j=function(t){if(!D)return(y||Ve()).then((function(){return j(t)}));var i=!q(),a=t&&(t.auth&&!J()||t.forceAuth);if(!i&&!a)return ee(t)?e.when(B):Ee(t);var o,r=f.data.keepAuthIdle>0;return(t&&t.authData?e.when(t.authData):p.showLogin(t)).then((function(e){if(!e||!e.pubkey||!i&&e.pubkey!==B.pubkey||a&&(!e.keypair||!e.keypair.signPk||!e.keypair.signSk))throw"CANCELLED";if(o=e,B.pubkey=o.pubkey,B.uid=o.uid||B.uid,B.isNew=t&&angular.isDefined(t.isNew)?t.isNew:B.isNew,r&&(B.keypair=o.keypair||{signSk:null,signPk:null}),i)return F.data.raisePromise.loginCheck(B).catch((function(e){throw W(),e})).then((function(){if(i)return F.data.raisePromise.login(B).catch((function(e){console.warn("Error during extension call [wallet.api.data.on.login]",e)}))}))})).then((function(){return i?se():a?we():void 0})).then((function(){if(i&&ie(),a||J())return Ue(!0),F.data.raisePromise.auth(r?B:o)})).then((function(){var e=!i&&t&&t.minData?{minData:!0}:void 0;if(!ee(e))return Ee(e)})).then((function(){return t&&t.silent?s.loading.hide(10):s.loading.hide(1e3),r?B:angular.merge({},B,o)})).catch((function(e){if(!("RETRY"!==e||t&&t.authData))return n((function(){return j(t)}),300);throw e}))},z=function(){var t=J();return e((function(e,n){var i=B.pubkey;W(),ae(i),F.data.raise.logout(),t&&F.data.raise.unauth(),Ue(!1),r.clearCache(),e()}))},q=function(){return!!B.pubkey},X=function(t){return D?g.readonly||g.demo?s.alert.demo().then((function(){throw"CANCELLED"})):!J()||t&&t.forceAuth?((t=t||{}).expectedPubkey=q()&&B.pubkey,t.auth=!0,j(t)):e.when(B):(y||Ve()).then((function(){return X(t)}))},Q=function(){return e((function(e,t){V(),ie(),F.data.raise.unauth(),Ue(!1),r.clearCache(),e()}))},J=function(){return B.pubkey&&B.keypair&&B.keypair.signSk&&!0},Z=function(t){return D?J()?e.when(B.keypair):((t=t||{}).silent=!angular.isDefined(t.silent)||t.silent,X(t).then((function(){return B.keypair}))):(y||Ve()).then((function(){return Z(t)}))},ee=function(e){if(e){if(e.minData&&!e.sources)return B.loaded&&!0;if(e.requirements&&!B.requirements.loaded)return!1;if(e.tx&&e.tx.enable&&(!B.tx.fromTime||"pending"===B.tx.fromTime))return!1;if(e.sigStock&&!B.sigStock)return!1}return B.loaded&&B.sources&&!0},te=function(){if(B.loaded)return!B.pubkey||!(B.isMember||B.requirements.pendingMembership||B.requirements.revoked||!B.requirements.needSelf||B.requirements.wasMember||B.sources&&B.sources.length>0||B.tx.history.length>0||B.tx.validating.length>0||B.tx.pendings.length>0||B.localName||B.name||B.avatar)},ne=function(){return!!B.isNew},ie=function(t){if(t=t&&"string"==typeof t?t:B.pubkey,C&&C.useLocalStorage){if(q()&&C.rememberMe){var n=Date.now();console.debug("[wallet] Storing...");var i=[];return C.keepAuthIdle==f.constants.KEEP_AUTH_IDLE_SESSION&&J()?i.push(u.put("seckey",m.util.encode_base58(B.keypair.signSk))):i.push(u.put("seckey",null)),i.push(d.put("pubkey",B.pubkey)),B.uid?i.push(d.put("uid",B.uid)):i.push(d.put("uid",null)),e.all(i).then((function(){console.debug("[wallet] Stored in "+(Date.now()-n)+"ms")}))}return e.all([u.put("seckey",null),d.put("pubkey",null),d.put("uid",null),t?u.put("data-"+t,null):e.when()])}return e.all([u.put("seckey",null),d.put("pubkey",null),d.put("uid",null),t?u.put("data-"+t,null):e.when(),t?d.put("data-"+t,null):e.when()])},ae=function(t){return console.debug("[wallet] Resetting stored pubkey (and uid) in local storage..."),u.put("seckey",null),d.put("pubkey",null),d.put("uid",null),C&&C.useLocalStorage?t?u.put("data-"+t,null):e.when():(console.debug("[wallet] Resetting stored data in local storage..."),e.all([t?u.put("data-"+t,null):e.when(),t?d.put("data-"+t,null):e.when()]))},oe=function(){if(!q())throw{message:"ERROR.NEED_LOGIN_FIRST"};var t,n,i=C&&C.useLocalStorageEncryption,a="data-"+B.pubkey;B.notifications&&B.notifications.time&&((t=t||{}).notifications={time:B.notifications.time}),B.invitations&&B.invitations.time&&((t=t||{}).invitations={time:B.invitations.time}),B.children&&B.children.length&&((t=t||{}).childrenCount=B.children.length,(n=n||{}).children=_.map(B.children,(function(e){return{pubkey:e.data.pubkey,uid:e.data.uid,localName:e.data.localName}})));var o=(t||n)&&JSON.stringify(angular.merge({},t||{},n||{}));return i&&n?J()?e.all([m.util.random_nonce(),m.box.keypair.fromSignKeypair(B.keypair),u.put(a,o||null)]).then((function(e){var i=e[0],o=e[1];return m.box.pack(JSON.stringify(n),i,o.boxPk,o.boxSk).then((function(e){return t=angular.merge(t||{},{encryptedData:{nonce:m.util.encode_base58(i),content:e}}),d.put(a,JSON.stringify(t))}))})):u.put(a,o||null):e.all([u.put(a,null),d.put(a,o||null)])},re=function(){return e.all([u.get("seckey"),d.get("pubkey"),d.get("uid")]).then((function(e){var t=e[0],n=e[1],i=e[2];if(n&&"null"!=n){var a;if(console.debug("[wallet] Restore {"+n.substring(0,8)+"} from local storage"),t&&t.length&&"null"!=t)try{a={signPk:m.util.decode_base58(n),signSk:m.util.decode_base58(t)}}catch(e){console.warn("[wallet] Secret key restoration failed: ",e),a=void 0}return B.pubkey=n,B.uid=i&&"null"!=i?i:void 0,B.keypair=a||{signPk:void 0,signSk:void 0},se()}})).then((function(){return J()?e.all([F.data.raisePromise.login(B),Ue(!0),F.data.raisePromise.auth(B)]).catch((function(e){console.warn("Error during extension call [wallet.api.data.on.auth]",e)})):q()?F.data.raisePromise.login(B).catch((function(e){console.warn("Error during extension call [wallet.api.data.on.login]",e)})):void 0})).then((function(){return B}))},se=function(){if(!q())throw{message:"ERROR.NEED_LOGIN_FIRST"};return ne()?e.when(B):e.all([u.getObject("data-"+B.pubkey),d.getObject("data-"+B.pubkey)]).then((function(e){var t=e[0],n=e[1];return t&&t.children&&t.children.length===n.childrenCount?le(t).catch((function(e){return console.error("[wallet] Failed to restore from the session storage ! Retrying from the local storage...",e),le(n)})):le(n)}))},le=function(t){if(!t)return e.when();if(t.children){var n=B.childrenCount,i=ye({stop:!1,store:!1});try{var a={};_.forEach(t.children,(function(e){if(!a[e.pubkey]){a[e.pubkey]=!0;var t=ke();t.data.pubkey=e.pubkey,t.data.localName=e.localName,t.data.uid=e.uid,De(t,{store:!1})}})),delete t.children,delete B.childrenCount}catch(t){return console.error("[wallet] Failed to restore children wallet.",t),B.childrenCount=n,B.children=i,e.reject({message:"ERROR.RESTORE_WALLET_LIST_FAILED"})}_.forEach(i||[],(function(e){e.stop()}))}return delete t.pubkey,delete t.uid,angular.merge(B,t),$()&&J()?we({store:!1}).then((function(){return B})):e.when(B)},ce=function(e,t){return Le("requirements"),v.loadRequirements(B,e).catch((function(n){if(!t)return console.error("[wallet] Unable to load requirements (first try): {0}. Retrying once...".format(n&&n.message||n),n),s.loading.update({template:"COMMON.LOADING_WAIT"}),ce(e,!0);throw console.error("[wallet] Unable to load requirements (after a second try): {0}".format(n&&n.message||n),n),n}))},de=function(e){return I.load(B.pubkey,e).then((function(e){G(),angular.merge(B,e)})).catch((function(e){throw G(),e}))},ue=function(){B.requirements.revoked?(delete B.requirements.meta.invalid,Ae({type:"info",message:"ERROR.WALLET_REVOKED",context:"requirements"})):B.requirements.pendingRevocation?(delete B.requirements.meta.invalid,Ae({type:"pending",message:"INFO.REVOCATION_SENT_WAITING_PROCESS",context:"requirements"})):(!B.isMember&&B.requirements.meta&&B.requirements.meta.invalid?(Ae({type:"error",message:"ERROR.WALLET_INVALID_BLOCK_HASH",context:"requirements"}),console.debug("Invalid membership for uid={0}: block hash changed".format(B.uid))):!B.isMember&&B.requirements.expired?(Ae({type:"error",message:"ERROR.WALLET_IDENTITY_EXPIRED",context:"requirements"}),console.debug("Identity expired for uid={0}.".format(B.uid))):B.requirements.pendingMembership?(Ae({type:"pending",message:"ACCOUNT.WAITING_MEMBERSHIP",context:"requirements"}),!B.requirements.needCertificationCount&&B.requirements.outdistanced&&Ae({type:"warn",message:"ACCOUNT.OUT_DISTANCED",context:"requirements"})):!B.requirements.needSelf&&B.requirements.needMembership&&Ae({type:"warn",message:"ACCOUNT.NO_WAITING_MEMBERSHIP",context:"requirements"}),B.requirements.needRenew?B.isMember&&B.requirements.membershipExpiresIn>0?Ae({type:"warn",message:"ACCOUNT.WILL_NEED_RENEW_MEMBERSHIP",messageParams:B.requirements,context:"requirements"}):!B.isMember&&B.requirements.membershipExpiresIn>0&&B.requirements.needCertificationCount>0?Ae({type:"warn",message:"ACCOUNT.NEED_RENEW_MEMBERSHIP_AFTER_CANCELLED",messageParams:B.requirements,context:"requirements"}):Ae({type:"warn",message:"ACCOUNT.NEED_RENEW_MEMBERSHIP",messageParams:B.requirements,context:"requirements"}):(B.requirements.needCertificationCount>0&&(Ae({type:"info",message:"ACCOUNT.WAITING_CERTIFICATIONS",messageParams:B.requirements,context:"requirements"}),B.requirements.wasMember||Ae({type:"help",message:"ACCOUNT.WAITING_CERTIFICATIONS_HELP",messageParams:B.requirements,context:"requirements"})),B.requirements.willNeedCertificationCount>0&&Ae({type:"warn",message:"ACCOUNT.WILL_MISSING_CERTIFICATIONS",messageParams:B.requirements,context:"requirements"}),B.requirements.wasMember&&B.requirements.needMembership&&Ae({type:"warn",message:"ACCOUNT.NEED_RENEW_MEMBERSHIP",messageParams:B.requirements,context:"requirements"}),B.requirements.needCertificationCount||B.requirements.willNeedCertificationCount||!B.requirements.outdistanced||Ae({type:"warn",message:"ACCOUNT.OUT_DISTANCED",context:"requirements"})))},pe=function(){return A.wot.certifiedBy({pubkey:B.pubkey}).then((function(e){B.sigStock=e.certifications?e.certifications.reduce((function(e,t){return null===t.written?e:e+1}),0):0})).catch((function(e){if(e&&e.ucode==A.errorCodes.NO_MATCHING_MEMBER)B.sigStock=0;else{if(!e||1002!=e.ucode)throw e;console.warn("[wallet-service] Detecting Duniter issue #1309 ! Applying workaround... "),B.sigStock=0}}))},me=function(){return!B.pubkey||B.qrcode?e.when(B.qrcode):(console.debug("[wallet] Creating SVG QRCode..."),n((function(){return B.qrcode=s.qrcode.svg(B.pubkey),B.qrcode})))},Ee=function(t){var n=!O.data.initPhase&&(!f.data.wallet||f.data.wallet.alertIfUnusedWallet)&&!B.loaded&&(!t||!t.minData||!t.silent);return P?P.then((function(){return ee(t)?B:fe(t)})):(P=t&&t.minData?ge(t):t||B.loaded?fe(t):be(),e.all([P,me()]).then((function(){var e=te();return!(n&&!ne()&&!0===e)||s.loading.hide().then((function(){return s.alert.confirm("CONFIRM.LOGIN_UNUSED_WALLET","CONFIRM.LOGIN_UNUSED_WALLET_TITLE",{cancelText:"COMMON.BTN_CONTINUE",okText:"COMMON.BTN_RETRY"})})).then((function(e){return e?z().then((function(){throw"RETRY"})):(f.data.wallet.alertIfUnusedWallet&&(f.data.wallet.alertIfUnusedWallet=!1,f.store()),!0)}))})).then((function(e){if(P=null,e)return B;throw"CANCELLED"})))},be=function(t){B.loaded=!1;var n=Date.now();return console.debug("[wallet] Loading {{0}} full data...".format(B.pubkey&&B.pubkey.substr(0,8))),e.all([ce(!0).then((function(e){if(e.requirements&&(e.requirements.isMember||e.requirements.wasMember))return pe();e.sigStock=0})),de(t||"pending")]).then((function(){return ue(),F.data.raisePromise.load(B).catch((function(e){console.error("[wallet] Error during load API extension point. Try to continue",e)}))})).then((function(){return B.loaded=!0,console.debug("[wallet] Loaded {{0}} full data in {1}ms".format(B.pubkey&&B.pubkey.substr(0,8),Date.now()-n)),s.loading.hide(1e3),B})).catch((function(e){throw B.loaded=!1,e}))},ge=function(t){return(t=t||{}).requirements=angular.isDefined(t.requirements)?t.requirements:!B.requirements.loaded||angular.isUndefined(B.requirements.needSelf),t.requirements?fe(t).then((function(e){return e.loaded=!0,e})):e.when(B)},fe=function(t){(t=t||{requirements:!0,sources:!0,tx:{enable:!0,fromTime:B.tx&&"pending"!==B.tx.fromTime?B.tx.fromTime:void 0},sigStock:!0,api:!0}).requirements=angular.isDefined(t.requirements)?t.requirements:!B.requirements.loaded,angular.isUndefined(t.sources)&&t.tx&&t.tx.enable&&(t.sources=!0);var n=[],i=Date.now();return console.debug("[wallet] {0} {{1}} data, with options: ".format(B.loaded?"Refreshing":"Loading",B.pubkey.substr(0,8)),t),t.requirements&&(Le("requirements"),n.push(ce(!0).then(ue))),!t.sources||t.tx&&!t.tx.enable?t.sources&&t.tx&&!t.tx.enable&&n.push(de("pending")):n.push(de(t.tx?t.tx.fromTime:void 0)),t.sigStock&&n.push(pe()),(n.length?e.all(n):e.when()).then((function(){return angular.isDefined(t.api)&&!t.api?B:F.data.raisePromise.load(B).then((function(){return console.debug("[wallet] {0} {{1}} data in {2}ms".format(B.loaded?"Refreshed":"Loaded",B.pubkey.substr(0,8),Date.now()-i)),B.loaded||(B.loaded=B.requirements.loaded&&B.sources&&!0),B}))})).catch((function(e){throw console.error("[wallet] Error while {0} data: {1}".format(B.loaded?"Refreshing":"Loading",e&&e.message||e),e),B.loaded=B.requirements.loaded&&B.sources&&!0,e}))},_e=function(t,n){return B.uid!=t||n&&B.blockUid!=n?B.loaded?(B.uid=t,B.blockUid=n,fe({requirements:!0,sigStock:!0}).then((function(){return ie({skipData:!0})}))):P?P.then((function(){return _e(t,n)})):e.when():e.when()},he=function(e,t){var n=Math.pow(10,t);return e=e})),i0){var s=ve(e-i,t,n-=1);s.amount>0&&(o=s.minBase,i+=s.amount,[].push.apply(a,s.sources))}return{minBase:o,maxBase:r,amount:i,sources:a}},Ie=function(t,i,r,l,c,d){return e.all([Z(),O.get(),d&&e.when(d)||O.blockchain.current(!0)]).then((function(e){var u=e[0],p=e[1];if(d=e[2],!A.regexp.PUBKEY.test(t))throw{message:"ERROR.INVALID_PUBKEY"};if(!A.regexp.COMMENT.test(r))throw{message:"ERROR.INVALID_COMMENT"};if(!q())throw{message:"ERROR.NEED_LOGIN_FIRST"};if(t===B.pubkey)throw{message:"ERROR.SAME_TX_RECIPIENT"};if(!i)throw{message:"ERROR.AMOUNT_REQUIRED"};if(i<=0)throw{message:"ERROR.AMOUNT_NEGATIVE"};i=Math.floor(i);var m={amount:0,minBase:d.unitbase,maxBase:d.unitbase+1,sources:[]},E=[];E.push("[wallet] amount="+i);for(var b=0;m.amount0&&(console.debug("[wallet] Amount has been truncate to "+i),E.push("[wallet] Will use amount truncated to "+i+" (amountBase="+b+")")),Oe(p,d,u,t,i,m,r,c||B.pubkey,E).then((function(e){B.balance-=e.amount,B.balance<0&&(B.balance=0),_.forEach(m.sources,(function(e){e.consumed=!0})),e&&e.sources.length&&(console.debug("[wallet-service] New sources to be add after the TX: ",e.sources),K(e.sources));var n={time:O.date.now(),amount:-i,pubkey:t,comment:r,isUD:!1,hash:e.hash,locktime:0,block_number:null};return v.extendAll([n],"pubkey").then((function(){return B.tx.pendings.unshift(n),F.data.raise.balanceChanged(B),F.data.raise.newTx(B),{hash:e.hash}}))})).catch((function(e){if(e&&e.ucode===A.errorCodes.SOURCE_ALREADY_CONSUMED)return console.debug("[wallet] TX rejected by node with error [{0}]. Reloading sources then retry...".format(e.message||"Source already consumed")),n(de,500).then((function(){return Ie(t,i,r,l,c,d)}));if(e&&e.ucode===A.errorCodes.TX_INPUTS_OUTPUTS_NOT_EQUAL&&f.data.plugins&&f.data.plugins.es&&f.data.plugins.es.enable)return s.loading.hide(),s.alert.confirm("CONFIRM.ISSUE_524_SEND_LOG","ERROR.POPUP_TITLE",{cssClass:"warning",okText:"COMMON.BTN_OK",cancelText:"COMMON.BTN_NO"}).then((function(e){if(e)return F.error.raise.send({title:"Issue #524 logs",content:"App version: "+g.version+"\nApp build: "+g.build+"\nLogs:\n\n"+E.join("\n")}),n((function(){throw{message:"ERROR.ISSUE_524_TX_FAILED"}}),1500);throw{message:"ERROR.SEND_TX_FAILED"}}));throw e}))}))},Oe=function(e,t,n,a,o,r,s,l,c){if(r.sources.length>40){console.debug("[Wallet] TX has to many sources. Will chain TX...");var d={minBase:t.unitbase,maxBase:0,amount:0,sources:r.sources.slice(0,40)};return _.forEach(d.sources,(function(e){e.based.maxBase&&(d.maxBase=e.base),d.amount+=Te(e.amount,e.base)})),Oe(e,t,n,B.pubkey,d.amount,d,void 0,B.pubkey,c).then((function(i){_.forEach(d.sources,(function(e){e.consumed=!0})),K(i.sources);var u={minBase:t.unitbase,maxBase:0,amount:0,sources:r.sources.slice(40).concat(i.sources)};return _.forEach(u.sources,(function(e){e.baseu.maxBase&&(u.maxBase=e.base),u.amount+=Te(e.amount,e.base)})),Oe(e,t,n,a,o,u,s,l,c)}))}var u="Version: "+k+"\nType: Transaction\nCurrency: "+e.name+"\nBlockstamp: "+t.number+"-"+t.hash+"\nLocktime: 0\nIssuers:\n"+B.pubkey+"\nInputs:\n";for(_.forEach(r.sources,(function(e){u+=[e.amount,e.base,e.type,e.identifier,e.noffset].join(":")+"\n"})),u+="Unlocks:\n",i=0;i0;)E-=p=he(E,b),p>0&&(p=0===b?p:p/Math.pow(10,b),u+=p+":"+b+":SIG("+a+")\n",g++),b--;E=r.amount-o,b=r.maxBase}for(;E>0;)E-=p=he(E,b),p>0&&(p=0===b?p:p/Math.pow(10,b),u+=p+":"+b+":SIG("+l+")\n",B.pubkey===l&&f.push({type:"T",noffset:g,amount:p,base:b,conditions:"SIG("+l+")",consumed:!1}),g++),b--;return u+="Comment: "+(s||"")+"\n",c&&(a==B.pubkey?c.push("[wallet] Creating new TX, using inputs:\n - minBase: "+r.minBase+"\n - maxBase: "+r.maxBase):c.push("[wallet] Creating new TX, using inputs:\n - minBase: "+r.minBase+"\n - maxBase: "+r.maxBase+"\n - sources (=TX inputs):"),_.forEach(r.sources,(function(e){c.push([e.amount,e.base,e.type,e.identifier,e.noffset].join(":"))})),c.push("\n[wallet] generated TX document (without signature) :\n------ START ------\n"+u+"------ END ------\n")),m.sign(u,n).then((function(e){var t=u+e+"\n";return A.tx.process({transaction:t}).catch((function(e){if(!e||e.ucode!==A.errorCodes.TX_ALREADY_PROCESSED)throw e})).then((function(){return m.util.hash(t)})).then((function(e){return _.forEach(f,(function(t){t.identifier=e,t.consumed=!1,t.pending=!0})),{amount:B.pubkey===a?0:B.pubkey===l?o:r.amount,tx:t,hash:e,sources:f}}))}))},Ne=function(e,t,n,i){if(n=n||B.uid,i=i||B.blockUid,!n||!i)throw{message:"ERROR.WALLET_HAS_NO_SELF"};if(B.requirements.expired)throw{message:"ERROR.WALLET_IDENTITY_EXPIRED"};var a="Version: "+M+"\nType: Identity\nCurrency: "+e.name+"\nIssuer: "+B.pubkey+"\nUniqueID: "+n+"\nTimestamp: "+i+"\n";return m.sign(a,t).then((function(e){return a+=e+"\n",console.debug("Has generate an identity document:\n----\n"+a+"----"),a}))},Re=function(t){return function(){var i;return e.all([Z(),O.blockchain.lastValid()]).then((function(e){var n=e[0],a=e[1];return i="Version: "+w+"\nType: Membership\nCurrency: "+a.currency+"\nIssuer: "+B.pubkey+"\nBlock: "+a.number+"-"+a.hash+"\nMembership: "+(t?"IN":"OUT")+"\nUserID: "+B.uid+"\nCertTS: "+B.blockUid+"\n",m.sign(i,n)})).then((function(e){var t=i+e+"\n";return A.blockchain.membership({membership:t})})).then((function(){return n((function(){return ce(!1)}),1e3)})).then(ue)}},Ae=function(e,t){(e=e||{}).type=e.type||"info",e.message=e.message||"",e.messageParams=e.messageParams||{},e.context=e.context||"undefined",e.message.trim().length?t?B.events.splice(0,0,e):B.events.push(e):console.debug("Event without message. Skipping this event")},Se=function(e){var t=Math.round(e.answer.length/2),n=e.answer.substr(0,t),i=e.answer.substr(t);return m.scryptKeypair(n,i).then((function(t){return e.pubkey=m.util.encode_base58(t.signPk),e.keypair=t,e}))},Ce=function(){return e.all([Z(),O.get()]).then((function(e){var t=e[0],n=e[1];return Ne(n,t).then((function(e){var i=e.trim().split("\n"),a=i[i.length-1],o="Version: "+x+"\nType: Revocation\nCurrency: "+n.name+"\nIssuer: "+B.pubkey+"\nIdtyUniqueID: "+B.uid+"\nIdtyTimestamp: "+B.blockUid+"\nIdtySignature: "+a+"\n";return m.sign(o,t).then((function(e){return o+=e+"\n",console.debug("Has generate an revocation document:\n----\n"+o+"----"),o}))}))}))},Le=function(e){B.events=B.events.reduce((function(t,n){return n.context&&n.context==e?t:t.concat(n)}),[])},De=function(t,n){return t.children.setParent(S),B.children=B.children||[],B.children.push(t),!n||angular.isUndefined(n.store)||n.store?oe():e.when()},ye=function(e){e&&!e.stop||_.forEach(B.children||[],(function(e){e.stop()}));var t=B.children.splice(0,B.children.length);return!e||angular.isUndefined(e.store)||e.store?oe():t},Pe=function(e){return _.find(B.children||[],(function(t){return t.isUserPubkey(e)}))},ke=function(){var e=(B.children||[]).reduce((function(e,t){return Math.max(e,t.id)}),0)+1;return N.instance(e,A)},Me=function(){return we().then((function(){return B.children}))},we=function(t){return $()?J()?m.box.keypair.fromSignKeypair(B.keypair).then((function(e){var t=m.util.decode_base58(B.encryptedData.nonce);return m.box.open(B.encryptedData.content,t,e.boxPk,e.boxSk)})).then((function(e){B.encryptedData=null;var n=le(JSON.parse(e));return(!t||angular.isUndefined(t.store)||t.store)&&n.then((function(){return oe()})),n})):X().then(we):e.when()},Ue=function(e){var t=(e=angular.isDefined(e)?e:J())&&C&&C.keepAuthIdle>0&&C.keepAuthIdle!=f.constants.KEEP_AUTH_IDLE_SESSION,n=H!=t;n?(t?(console.debug("[wallet] Start idle (delay: {0}s)".format(C.keepAuthIdle)),c.setIdle(C.keepAuthIdle),c.watch()):H&&(console.debug("[wallet] Stop idle"),c.unwatch()),H=t):t&&c.getIdle()!==C.keepAuthIdle&&(console.debug("[idle] Updating auth idle (delay: {0}s)".format(C.keepAuthIdle)),c.setIdle(C.keepAuthIdle)),e&&C&&C.keepAuthIdle==f.constants.KEEP_AUTH_IDLE_SESSION?u.put("seckey",m.util.encode_base58(B.keypair.signSk)):n&&u.put("seckey",null)};function xe(e){return e&&{useLocalStorage:e.useLocalStorage,useLocalStorageEncryption:e.useLocalStorageEncryption,rememberMe:e.rememberMe,keepAuthIdle:e.keepAuthIdle}}function Be(e){var t=xe(e);if(!angular.equals(C,t)&&C){var n=!angular.equals(C.useLocalStorageEncryption,t.useLocalStorageEncryption),i=!angular.equals(C.useLocalStorage,t.useLocalStorage)||n,a=!angular.equals(C.keepAuthIdle,t.keepAuthIdle);if(C=t,a&&Ue(),i){if(C.useLocalStorage)return ie().then((function(){if(B.childrenCount>0&&n&&C.useLocalStorageEncryption)return X({minData:!0,silent:!0}).catch((function(e){if("CANCELLED"===e)return f.apply({useLocalStorageEncryption:!1}),f.store();throw e}))})).then(oe);ae(B.pubkey)}}}function He(){_.forEach(L,(function(e){e()})),L=[]}function Fe(){console.debug("[wallet] Stopping..."),He(),W()}function We(){return Fe(),n(Ve,200)}function Ve(n){(n=n||{}).restore=angular.isDefined(n.restore)?n.restore:"default"===b,console.debug("[wallet] Starting...");var i=Date.now();return y=e.all([f.ready().then((function(){C=xe(f.data)})),O.ready(),A.ready()]),n.restore&&(y=y.then(re)),y.then((function(){!function(){L=[f.api.data.on.changed(t,Be,this),A.api.node.on.restart(t,We,this)],t.$on("IdleStart",Q)}(),console.debug("[wallet] Started in "+(Date.now()-i)+"ms"),D=!0,y=null})).then((function(){return B})),y}return F.registerEvent("data","init"),F.registerEvent("data","loginCheck"),F.registerEvent("data","login"),F.registerEvent("data","auth"),F.registerEvent("data","unauth"),F.registerEvent("data","load"),F.registerEvent("data","logout"),F.registerEvent("data","reset"),F.registerEvent("data","store"),F.registerEvent("error","send"),F.registerEvent("data","balanceChanged"),F.registerEvent("data","newTx"),F.registerEvent("action","certify"),W(!0),"default"!==b&&(ie=e.when,re=e.when,se=e.when),S={id:b,data:B,ready:function(){return D?e.when():y||Ve()},start:Ve,stop:Fe,login:j,logout:z,auth:X,unauth:Q,isLogin:q,isAuth:J,getKeypair:Z,hasSelf:function(){return!!B.pubkey&&!B.requirements.needSelf},setSelf:_e,isMember:function(){return B.isMember},isDataLoaded:ee,isDefault:Y,isNeverUsed:te,isNew:ne,isUserPubkey:function(e){return q()&&B.pubkey===e},getData:function(){return B},loadData:Ee,refreshData:fe,loadQrCode:me,internal:{addListener:function(e){(L=L||[]).push(e)},removeListeners:He},store:ie,storeData:oe,transfer:Ie,transferAll:function(t,n,i,a,o){return q()?o&&t!=o?O.blockchain.lastValid().then((function(e){return console.debug("[wallet] Using last valid block as TX reference (to avoid network fork): ",e),Ie(t,n,i,a,o,e).then((function(){if(B.balance>0&&o)return console.debug("[wallet] Wallet has some more money: transfering fund to [{0}]".format(o.substring(0,8))),Ie(o,B.balance,void 0,!1,o,e)}))})):e.reject({message:"Could not have same pubkey for 'destPub' and 'restPub'"}):e.reject({message:"ERROR.NEED_LOGIN_FIRST"})},self:function(t,n){return A.regexp.USER_ID.test(t)?e.all([Z(),O.get(),O.blockchain.lastValid()]).then((function(e){var n=e[0],a=e[1];return i=e[2],Ne(a,n,t,i.number+"-"+i.hash)})).then((function(e){return A.wot.add({identity:e})})).then((function(){if(n)return ce(!1).then(ue);B.uid=t,B.blockUid=i.number+"-"+i.hash})).catch((function(e){if(e&&e.ucode===A.errorCodes.IDENTITY_SANDBOX_FULL)throw{ucode:A.errorCodes.IDENTITY_SANDBOX_FULL,message:"ERROR.IDENTITY_SANDBOX_FULL"};throw e})):e.reject({message:"ERROR.INVALID_USER_ID"});var i},revoke:function(){return Le("revocation"),Ce().then((function(e){return A.wot.revoke({revocation:e})})).then((function(){return n((function(){return ce(!1)}),1e3)})).then(ue).catch((function(e){if(!e||e.ucode!=A.errorCodes.REVOCATION_ALREADY_REGISTERED)throw e;Ae({type:"pending",message:"INFO.REVOCATION_SENT_WAITING_PROCESS",context:"requirements"},!0)}))},revokeWithFile:function(t){return e.all([A.wot.revoke({revocation:t})]).then((function(e){if(q())return n((function(){return ce(!1)}),1e3).then(ue).catch((function(e){if(!e||e.ucode!=A.errorCodes.REVOCATION_ALREADY_REGISTERED)throw e;Ae({type:"pending",message:"INFO.REVOCATION_SENT_WAITING_PROCESS",context:"requirements"},!0)}));Ae({type:"pending",message:"INFO.REVOCATION_SENT_WAITING_PROCESS",context:"requirements"},!0)}))},certify:function(t,n,i,a,o,r){return e.all([Z(),O.get(),O.blockchain.lastValid()]).then((function(e){var s=e[0],l=e[1],c=e[2];if(!B.isMember&&!g.initPhase)throw{message:"ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION"};var d="Version: "+U+"\nType: Certification\nCurrency: "+l.name+"\nIssuer: "+B.pubkey+"\nIdtyIssuer: "+n+"\nIdtyUniqueID: "+t+"\nIdtyTimestamp: "+i+"\nIdtySignature: "+a+"\nCertTimestamp: "+c.number+"-"+c.hash+"\n";return m.sign(d,s).then((function(e){var t=d+e+"\n";return A.wot.certify({cert:t})})).then((function(){var e={pubkey:n,uid:t,time:c.medianTime,isMember:o,wasMember:r,expiresIn:l.parameters.sigWindow,pending:!0,block:c.number,valid:!0};return F.action.raise.certify(e),e}))}))},downloadSaveId:function(e){return function(e){var t="Version: 10 \nType: SaveID\nQuestions: \n"+e.questions+"Issuer: "+B.pubkey+"\nCrypted-Nonce: "+e.nonce+"\nCrypted-Pubkey: "+e.pubkey+"\nCrypted-Salt: "+e.salt+"\nCrypted-Pwd: "+e.pwd+"\n";return m.sign(t,B.keypair).then((function(e){return t+=e+"\n",console.debug("Has generate an SaveID document:\n----\n"+t+"----"),t}))}(e).then((function(e){var t=new T([e],{type:"text/plain; charset=utf-8"});h.saveAs(t,"{0}-recover_ID.txt".format(B.pubkey.substring(0,8)))}))},getCryptedId:function(t){return Se(t).then(m.util.random_nonce).then((function(n){return t.nonce=m.util.encode_base58(n),e.all([m.box.pack(t.salt,n,t.keypair.boxPk,t.keypair.boxSk),m.box.pack(t.pwd,n,t.keypair.boxPk,t.keypair.boxSk)])})).then((function(e){return t.salt=e[0],t.pwd=e[1],t}))},recoverId:function(e){if(!(e&&e.cypherNonce&&e.cypherSalt&&e.cypherPwd))throw{message:"ERROR.INVALID_FILE_FORMAT"};var t=m.util.decode_base58(e.cypherNonce);return Se(e).then((function(e){return m.box.open(e.cypherSalt,t,e.keypair.boxPk,e.keypair.boxSk)})).then((function(n){return e.salt=n,m.box.open(e.cypherPwd,t,e.keypair.boxPk,e.keypair.boxSk)})).then((function(t){return e.pwd=t,e})).catch((function(e){throw console.warn("Incorrect answers: unable to recover identifiers",e),new Error("Incorrect answers: unable to recover identifiers")}))},downloadRevocation:function(){return e.all([O.get(),Ce()]).then((function(e){var t=e[0],n=e[1],i=new T([n],{type:"text/plain; charset=utf-8"});return a("ACCOUNT.SECURITY.REVOCATION_FILENAME",{uid:B.uid,currency:t.name,pubkey:B.pubkey}).then((function(e){h.saveAs(i,e)}))}))},downloadKeyFile:function(t){return J()?e.all([O.get(),E.keyfile.generateContent(B.keypair,{type:t,password:function(){return s.loading.hide(),p.showPassword({title:"ACCOUNT.SECURITY.KEYFILE.PASSWORD_POPUP.TITLE",subTitle:"ACCOUNT.SECURITY.KEYFILE.PASSWORD_POPUP.HELP"}).then((function(e){return s.loading.show(10).then((function(){return e}))}))}})]).then((function(e){var n=e[0],i=e[1];return a("ACCOUNT.SECURITY.KEYFILE_FILENAME",{currency:n.name,pubkey:B.pubkey,format:t}).then((function(e){var t=new T([i],{type:"text/plain; charset=utf-8"});h.saveAs(t,e)}))})):e.reject("user not authenticated")},pubkeys:function(){if(!B.pubkey)throw new Error("User not login!");return(B.children||[]).reduce((function(e,t){return t.data.pubkey?e.concat(t.data.pubkey):e}),[B.pubkey])},getByPubkey:function(e){if(!e)throw new Error("Missing 'pubkey' argument !");if(!B.pubkey)throw new Error("User not login!");return B.pubkey===e?S:Pe(e)},membership:{inside:Re(!0),out:Re(!1)},events:{add:Ae,cleanByContext:Le},children:{create:function(e){var t=ke();return De(t,e),t},add:De,remove:function(t,n){B.children=B.children||[];var i=_.findIndex(B.children,(function(e){return e.id===t}));if(-1===i)throw console.warn("[wallet] Unable to remove child wallet {{0}} (not found)".format(t)),new Error("Wallet with id {{0}} not found".format(t));return B.children.splice(i,1)[0].stop(),n&&!1===n.store?e.when():oe()},get:function(e){return"default"!==e&&_.find(B.children||[],(function(t){return t.id===+e}))||void 0},getByPubkey:Pe,all:Me,setParent:function(n){var i;L=L||[],_.forEach(["load","reset"],(function(a){i=F.data.on[a](t,(function(t,i){return i=i||e.defer(),n.api.data.raisePromise[a](t).then(i.resolve).catch(i.reject),i.promise}),this),L.push(i)})),i=n.api.data.on.unauth(t,(function(){J()&&Q()}),this),L.push(i)},count:function(){return angular.isDefined(B.childrenCount)?B.childrenCount:B.children&&B.children.length||0},hasPubkey:function(e){return!!Pe(e)},instance:ke,downloadFile:function(){return e.all([Me(),O.get()]).then((function(e){var t=e[0],n=e[1],i=(t||[]).reduce((function(e,t){return e+[t.data.pubkey,t.data.uid,t.data.localName||t.data.name].join("\t")+"\n"}),""),o=new T([i],{type:"text/plain; charset=utf-8"});return a("ACCOUNT.WALLET_LIST.EXPORT_FILENAME",{pubkey:B.pubkey,currency:n.name}).then((function(e){h.saveAs(o,e)}))}))}},api:F}}return(N=A("default",b)).instance=A,N}]),angular.module("cesium.help.services",[]).constant("csHelpConstants",{wallet:{stepCount:4}}).factory("csHelp",["$rootScope","csSettings","UIUtils","csHelpConstants","$controller",function(e,t,n,i,a){function o(o,r){if(o=angular.isDefined(o)?o:t.data.helptip.wallet,r=!!angular.isDefined(r)&&r,!(o<0||o>=i.wallet.stepCount)){var s=function(i,o){if(i||!e.tour&&t.data.helptip.enable&&!n.screen.isSmall()){var r=e.$new();return a("HelpTipCtrl",{$scope:r}),r}}(r);if(s)return s.tour=r,s.startWalletTour(o,!1).then((function(e){s.$destroy(),r||(t.data.helptip.wallet=e,t.store())}))}}return{wallet:{tour:function(){return o(0,!0)},helptip:o}}}]),angular.module("cesium.plugin.services",[]).provider("PluginService",(function(){var e=[],t={};this.registerEagerLoadingService=function(t){return e.push(t),this},this.extendState=function(e,n){return angular.isDefined(e)&&angular.isDefined(n)&&(t[e]||(t[e]=[]),t[e].push(n)),this},this.extendStates=function(e,t){var n=this;return e.forEach((function(e){n.extendState(e,t)})),this},this.$get=["$injector","$state",function(n,i){var a;return{start:function(){e.length>0&&_.forEach(e,(function(e){n.get(e)}))},extensions:{points:{getActivesByName:function(e){return _.keys(t).reduce((function(e,n){return i.includes(n)?e.concat(t[n]):e}),[]).reduce((function(t,n){return n.points&&n.points[e]?t.concat(n.points[e]):t}),[])},current:{get:function(){return a},set:function(e){a=e}}}}}}]})),angular.module("cesium.desktop.services",["cesium.device.services","cesium.settings.services"]).factory("csDesktop",["$rootScope","Device",function(e,t){t.isDesktop()&&console.info("Starting desktop mode...")}]),angular.module("cesium.services",["cesium.desktop.services","cesium.settings.services","cesium.http.services","cesium.network.services","cesium.bma.services","cesium.crypto.services","cesium.utils.services","cesium.modal.services","cesium.storage.services","cesium.device.services","cesium.currency.services","cesium.wot.services","cesium.tx.services","cesium.wallet.services","cesium.help.services","cesium.plugin.services"]),e.prototype.regexp={BMA:/^BASIC_MERKLED_API[ ]?/,BMAS:/^BMAS[ ]?/,WS2P:/^WS2P[ ]?/,BMA_REGEXP:/^BASIC_MERKLED_API([ ]+([a-z_][a-z0-9-_.ğĞ]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))$/,BMAS_REGEXP:/^BMAS([ ]+([a-z_][a-z0-9-_.ğĞ]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))$/,WS2P_REGEXP:/^WS2P[ ]+([a-z0-9]+)([ ]+([a-z_][a-z0-9-_.ğĞ]*))?([ ]+([0-9.]+))?([ ]+([0-9a-f:]+))?([ ]+([0-9]+))([ ]+([a-z0-9/.&#!]+))?$/,LOCAL_IP_ADDRESS:/^127[.]0[.]0.|192[.]168[.]|10[.]0[.]0[.]|172[.]16[.]/},e.prototype.regex=e.prototype.regexp,e.prototype.keyID=function(){var e=this.bma||this.getBMA();return e.useBma?[this.pubkey||"Unknown",e.dns,e.ipv4,e.ipv6,e.port,e.useSsl,e.path].join("-"):[this.pubkey||"Unknown",e.ws2pid,e.path].join("-")},e.prototype.copyValues=function(e){var t=this;["version","currency","pub","endpoints","hash","status","block","signature"].forEach((function(n){e[n]=t[n]}))},e.prototype.copyValuesFrom=function(e){var t=this;["version","currency","pub","endpoints","block","signature"].forEach((function(n){t[n]=e[n]}))},e.prototype.json=function(){var e=this,t={};return["version","currency","endpoints","status","block","signature"].forEach((function(n){t[n]=e[n]})),t.raw=this.raw&&this.getRaw(),t.pubkey=this.pubkey,t},e.prototype.getBMA=function(){if(this.bma)return this.bma;var e=null,t=this.regexp.BMA_REGEXP,n=this.regexp.BMAS_REGEXP;return this.endpoints.forEach((function(i){var a=!e&&t.exec(i);a&&(e={dns:a[2]||"",ipv4:a[4]||"",ipv6:a[6]||"",port:a[8]||80,useSsl:443==a[8],useBma:!0}),(a=!e&&n.exec(i))&&(e={dns:a[2]||"",ipv4:a[4]||"",ipv6:a[6]||"",port:a[8]||80,useSsl:!0,useBma:!0})})),e||{}},e.prototype.getEndpoints=function(e){return e?this.endpoints.reduce((function(t,n){return n.match(e)?t.concat(n):t}),[]):this.endpoints},e.prototype.hasEndpoint=function(e){var t=this.regexp[e]||new RegExp("^"+e);return!!this.getEndpoints(t).length},e.prototype.getDns=function(){var e=this.bma||this.getBMA();return e.dns?e.dns:null},e.prototype.getIPv4=function(){var e=this.bma||this.getBMA();return e.ipv4?e.ipv4:null},e.prototype.getIPv6=function(){var e=this.bma||this.getBMA();return e.ipv6?e.ipv6:null},e.prototype.getPort=function(){var e=this.bma||this.getBMA();return e.port?e.port:null},e.prototype.getHost=function(e){return bma=e||this.bma||this.getBMA(),(443==bma.port||bma.useSsl)&&bma.dns?bma.dns:this.hasValid4(bma)?bma.ipv4:bma.dns?bma.dns:bma.ipv6?"["+bma.ipv6+"]":""},e.prototype.getURL=function(e){e=e||this.bma||this.getBMA();var t=this.getHost(e);return(443==e.port||e.useSsl?"https":"http")+"://"+t+(e.port?":"+e.port:"")},e.prototype.getServer=function(e){e=e||this.bma||this.getBMA();var t=this.getHost(e);return t+(t&&e.port?":"+e.port:"")},e.prototype.hasValid4=function(e){return!(!e.ipv4||e.ipv4.match(this.regexp.LOCAL_IP_ADDRESS))},e.prototype.isReachable=function(){return!!this.getServer()},e.prototype.isSsl=function(){return(this.bma||this.getBMA()).useSsl},e.prototype.isTor=function(){return(this.bma||this.getBMA()).useTor},e.prototype.isWs2p=function(){return(this.bma||this.getBMA()).useWs2p},e.prototype.isBma=function(){var e=this.bma||this.getBMA();return!e.useWs2p&&!e.useTor},e.prototype.hasBma=function(){return this.hasEndpoint("(BASIC_MERKLE_API|BMAS|BMATOR)")},t.prototype.isEmpty=function(){"use strict";return!(this.transactionsCount||this.certificationsCount||this.joinersCount||this.dividend||this.activesCount||this.identitiesCount||this.leaversCount||this.excludedCount||this.revokedCount)},t.prototype.parseData=function(){this.identities=this.parseArrayValues(this.identities,["pubkey","signature","buid","uid"]),this.joiners=this.parseArrayValues(this.joiners,["pubkey","signature","mBuid","iBuid","uid"]),this.actives=this.parseArrayValues(this.actives,["pubkey","signature","mBuid","iBuid","uid"]),this.leavers=this.parseArrayValues(this.leavers,["pubkey","signature","mBuid","iBuid","uid"]),this.revoked=this.parseArrayValues(this.revoked,["pubkey","signature"]),this.excluded=this.parseArrayValues(this.excluded,["pubkey"]),this.certifications=this.parseArrayValues(this.certifications,["from","to","block","signature"]),this.transactions=this.parseTransactions(this.transactions),delete this.raw},t.prototype.cleanData=function(){delete this.identities,delete this.joiners,delete this.actives,delete this.leavers,delete this.revoked,delete this.excluded,delete this.certifications,delete this.transactions,delete this.raw},t.prototype.parseArrayValues=function(e,t){return e&&e.length?e.reduce((function(e,n){var i=n.split(":");if(i.length!=t.length)return console.debug("[block] Bad format for '{0}': [{1}]. Expected {1} parts. Skipping".format(arrayProperty,n,t.length)),e;for(var a={},o=0;oAPI.DOC.TRANSFER.TITLE

API.DOC.DESCRIPTION_DIVIDER

API.DOC.TRANSFER.DESCRIPTION

API.DOC.URL_DIVIDER

{{$root.rootPath}}#/v1/payment/:pubkey?amount=API.DOC.TRANSFER.PARAM_AMOUNT

API.DOC.PARAMETERS_DIVIDER

API.DOC.AVAILABLE_PARAMETERS

pubkey
API.DOC.TRANSFER.PARAM_PUBKEY_HELP
amount
API.DOC.TRANSFER.PARAM_AMOUNT_HELP
comment
API.DOC.TRANSFER.PARAM_COMMENT_HELP
name
API.DOC.TRANSFER.PARAM_NAME_HELP
preferred_node
API.DOC.TRANSFER.PARAM_PREFERRED_NODE_HELP
redirect_url
API.DOC.TRANSFER.PARAM_REDIRECT_URL_HELP
cancel_url
API.DOC.TRANSFER.PARAM_CANCEL_URL_HELP

API.DOC.DEMO_DIVIDER

API.DOC.DEMO_HELP

API.DOC.DEMO_SUCCEED

API.DOC.DEMO_RESULT

{{result.content}}

API.DOC.DEMO_RESULT_PEER {{result.node}}

API.DOC.DEMO_CANCELLED

API.DOC.INTEGRATE_DIVIDER

API.DOC.TRANSFER.EXAMPLES_HELP

API.DOC.TRANSFER.EXAMPLE_BUTTON

API.DOC.INTEGRATE_CODE

API.DOC.INTEGRATE_RESULT

API.DOC.INTEGRATE_PARAMETERS

{{\'API.DOC.TRANSFER.PARAM_PUBKEY\' | translate}} :

{{\'API.DOC.TRANSFER.PARAM_AMOUNT\' | translate}} :

{{\'API.DOC.TRANSFER.PARAM_COMMENT\' | translate}} :

{{\'API.DOC.TRANSFER.PARAM_NAME\' | translate}} :

{{\'API.DOC.TRANSFER.PARAM_PREFERRED_NODE\' | translate}} :

{{\'API.DOC.TRANSFER.PARAM_REDIRECT_URL\' | translate}} :

{{\'API.DOC.TRANSFER.PARAM_CANCEL_URL\' | translate}} :

API.DOC.TRANSFER.EXAMPLE_BUTTON_DEFAULT_STYLE

{{\'API.DOC.TRANSFER.EXAMPLE_BUTTON_TEXT_ICON\' | translate}} :

{{\'API.DOC.TRANSFER.EXAMPLE_BUTTON_TEXT_HELP\' | translate}} :

{{\'API.DOC.TRANSFER.EXAMPLE_BUTTON_BG_COLOR\' | translate}} :

{{\'API.DOC.TRANSFER.EXAMPLE_BUTTON_FONT_COLOR\' | translate}} :

{{\'API.DOC.TRANSFER.EXAMPLE_BUTTON_TEXT_WIDTH\' | translate}} :

'),e.put("templates/api/home.html",'API.HOME.TITLE

API.HOME.MESSAGE_SHORT

{{\'COMMON.APP_NAME\'|translate}} API - v{{$root.config.version}}

'),e.put("templates/api/menu.html",''),e.put("templates/api/popover_locales.html",''),e.put("templates/api/transfer.html",'API.TRANSFER.TITLE_SHORT

API.TRANSFER.DEMO.HELP

MODE.DEMO.INSTALL_HELP

API.TRANSFER.SUMMARY

API.TRANSFER.AMOUNT

API.TRANSFER.NAME

{{transferData.name}}

API.TRANSFER.PUBKEY


{{transferData.pubkey|formatPubkey}}

API.TRANSFER.COMMENT


{{::transferData.comment}}

API.TRANSFER.NODE


 {{node.server}}

 

{{\'COMMON.APP_NAME\'|translate}} - v{{$root.config.version}}

'),e.put("templates/blockchain/item_block_empty_lg.html",'

{{:rebind:block.medianTime|medianDate}}

{{:rebind:block.issuer|formatPubkey}} {{:rebind:block.name||block.uid}}

{{block.number|formatInteger}}
'),e.put("templates/blockchain/item_block_lg.html",'

{{:rebind:block.medianTime|medianDate}}

{{:rebind:\'BLOCKCHAIN.HASH\'|translate}} {{:rebind:block.hash|formatHash}}

{{:rebind:block.issuer|formatPubkey}} {{:rebind:block.name||block.uid}}

+{{:rebind:block.joinersCount}} -{{:rebind:block.excludedCount-block.revokedCount}}    -{{:rebind:block.revokedCount}}   {{:rebind:block.activesCount}}   {{:rebind:block.certificationsCount}}   {{:rebind:\'COMMON.UD\'|translate}}   {{:rebind:block.transactionsCount}}  
{{:rebind:block.number}}
'), e.put("templates/blockchain/item_block.html",'

{{:rebind:block.medianTime|medianDate}}

+{{:rebind:block.joinersCount}} -{{:rebind:block.excludedCount-block.revokedCount}} {{:rebind:block.revokedCount}}   {{:rebind:block.activesCount}}   {{:rebind:block.certificationsCount}}   {{\'COMMON.UD\'|translate}}   {{:rebind:block.transactionsCount}}

{{:rebind:block.name||block.uid}}

{{::block.number|formatInteger}}
'),e.put("templates/blockchain/items_blocks.html",'
BLOCKCHAIN.LOOKUP.NO_BLOCK
'),e.put("templates/blockchain/link_identity.html",' {{::identity.uid}}   {{::identity.pubkey|formatPubkey}}'),e.put("templates/blockchain/list_blocks_lg.html",'
{{:locale:\'BLOCKCHAIN.LOOKUP.NO_BLOCK\'|translate}}
'),e.put("templates/blockchain/list_blocks.html",'
BLOCKCHAIN.LOOKUP.NO_BLOCK
'),e.put("templates/blockchain/lookup_lg.html",'BLOCKCHAIN.LOOKUP.TITLE'),e.put("templates/blockchain/lookup.html",'BLOCKCHAIN.LOOKUP.TITLE'),e.put("templates/blockchain/unlock_condition_popover.html",'

BLOCKCHAIN.VIEW.TX_OUTPUT_UNLOCK_CONDITIONS

{{::\'BLOCKCHAIN.VIEW.TX_OUTPUT_OPERATOR.\'+condition.operator|translate}} 
{{::condition.value|formatDuration}}
{{::condition.value|medianDate}}
'),e.put("templates/blockchain/view_block.html",'{{\'BLOCKCHAIN.VIEW.TITLE_CURRENT\'|translate}} {{\'BLOCKCHAIN.VIEW.TITLE\'|translate:formData}}

{{\'BLOCKCHAIN.VIEW.TITLE\'|translate:formData}} {{\'BLOCKCHAIN.VIEW.TITLE_CURRENT\'|translate}}

{{formData.medianTime | medianFromNowAndDate}}

{{\'BLOCKCHAIN.VIEW.COMPUTED_BY\'|translate}} {{issuer.name||issuer.uid}} ({{issuer.uid}})

{{\'BLOCKCHAIN.VIEW.SHOW_RAW\'|translate}}

{{\'BLOCKCHAIN.VIEW.TECHNICAL_DIVIDER\' | translate}} {{\'BLOCKCHAIN.VIEW.VERSION\'|translate}} {{::formData.version}} {{\'BLOCKCHAIN.VIEW.POW_MIN\'|translate}}

{{\'BLOCKCHAIN.VIEW.POW_MIN_HELP\'|translate}}

{{::formData.powMin}}
{{\'BLOCKCHAIN.VIEW.HASH\'|translate}}
{{::formData.hash}}
{{\'BLOCKCHAIN.VIEW.DATA_DIVIDER\' | translate}}{{\'BLOCKCHAIN.VIEW.EMPTY\'|translate}}
{{\'COMMON.UNIVERSAL_DIVIDEND\'|translate}}

{{\'BLOCKCHAIN.VIEW.UNIVERSAL_DIVIDEND_HELP\'|translate: {membersCount: formData.membersCount} }}

+1 / {{\'COMMON.MEMBER\'|translate|lowercase}} 0 + {{formData.dividend| formatAmount: {currency: formData.currency, useRelative: false} }} / {{\'COMMON.MEMBER\'|translate|lowercase}}
{{\'BLOCKCHAIN.VIEW.IDENTITIES_COUNT\'|translate}} +{{::formData.identitiesCount}} 0
{{\'BLOCKCHAIN.VIEW.JOINERS_COUNT\'|translate}} +{{::formData.joinersCount}} 0
{{\'BLOCKCHAIN.VIEW.ACTIVES_COUNT\'|translate}}

{{\'BLOCKCHAIN.VIEW.ACTIVES_COUNT_HELP\'|translate}}

{{::formData.activesCount}} 0
{{\'BLOCKCHAIN.VIEW.EXCLUDED_COUNT\'|translate}}

{{\'BLOCKCHAIN.VIEW.EXCLUDED_COUNT_HELP\'|translate}}

-{{::formData.excludedCount-formData.revokedCount}} 0
{{\'BLOCKCHAIN.VIEW.LEAVERS_COUNT\'|translate}}

{{\'BLOCKCHAIN.VIEW.LEAVERS_COUNT_HELP\'|translate}}

-{{::formData.leaversCount}} 0
{{\'BLOCKCHAIN.VIEW.REVOKED_COUNT\'|translate}}

{{\'BLOCKCHAIN.VIEW.REVOKED_COUNT_HELP\'|translate}}

-{{::formData.revokedCount}} 0
{{\'BLOCKCHAIN.VIEW.CERT_COUNT\'|translate}} {{::formData.certificationsCount}}

{{\'BLOCKCHAIN.VIEW.TX_COUNT\'|translate}} {{::formData.transactionsCount}}

BLOCKCHAIN.VIEW.TX_TO_HIMSELF
( )
'),e.put("templates/common/badge_certification_count.html",' {{$ctrl.requirements.certificationCount}} + {{$ctrl.requirements.pendingCertificationCount}}'),e.put("templates/common/badge_given_certification_count.html",'
{{$ctrl.identity.given_cert.length}} (+ {{$ctrl.identity.given_cert_pending.length}}) / {{$ctrl.parameters.sigStock}}
'),e.put("templates/common/form_error_messages.html",'
'),e.put("templates/common/note_feature_not_available.html",'

MODE.DEMO.FEATURE_NOT_AVAILABLE

'),e.put("templates/common/popover_copy.html",'
'),e.put("templates/common/popover_helptip.html",'

 

'),e.put("templates/common/popover_locales.html",''),e.put("templates/common/popover_profile.html",''),e.put("templates/common/popover_share.html",'

{{titleKey|translate:titleValues}}

{{time|formatDate}}
'),e.put("templates/common/popup_password.html",'
{{error|translate}}
'),e.put("templates/common/qrcode.html",'
'),e.put("templates/common/view_passcode.html",'COMMON.PASSCODE.TITLE'),e.put("templates/currency/items_network.html",' CURRENCY.VIEW.MEDIAN_TIME {{formData.medianTime | medianDate}} CURRENCY.VIEW.POW_MIN {{formData.difficulty | formatInteger}}
CURRENCY.VIEW.NETWORK_RULES_DIVIDER
CURRENCY.VIEW.AVG_GEN_TIME {{formData.avgGenTime | formatDuration}}
PEER.MEMBERS PEER.MIRRORS PEER.OFFLINE PEER.PEERS ({{search.results.length}})
'),e.put("templates/currency/items_parameters.html",'
CURRENCY.VIEW.CURRENCY_NAME
{{formData.currency}} ()
CURRENCY.VIEW.SHARE (Mt/Nt)
CURRENCY.VIEW.MASS (Mt)
CURRENCY.VIEW.C_ACTUAL (c{{\'CURRENCY.VIEW.CURRENT\'|translate}})
{{formData.cactual | formatNumeral: \'0,0.00\'}} % / {{formData.dt | formatPeriod}}
CURRENCY.VIEW.UD ({{\'COMMON.UD\'|translate}}t)
1  / {{formData.dt | formatPeriod}}
COMMON.BTN_RELATIVE_UNIT
CURRENCY.VIEW.MONEY_RULES_DIVIDER
CURRENCY.VIEW.C_RULE (c)
{{formData.c*100 | formatNumeral: \'0,0.00\'}} % / {{formData.dt | formatPeriod}}{{formData.c*100 | formatNumeral: \'0,0.00\'}} % / {{formData.dtReeval | formatDuration}}
CURRENCY.VIEW.DT_REEVAL (dt{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}})
CURRENCY.VIEW.UD_REEVAL_TIME0 (t0{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}})
{{formData.udReevalTime0|medianDate}}
CURRENCY.VIEW.UD_RULE - {{\'COMMON.UD\'|translate}}{{formData.dt|formatPeriod}}(t{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}})
{{\'COMMON.UD\'|translate}}t-1 + c2 * Mt-1/Nt-1{{\'COMMON.UD\'|translate}}{{formData.dt|formatPeriod}}(t{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}} - dt{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}})+ c2 * (M/N)(t{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}} - dt{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}}) / dt{{\'CURRENCY.VIEW.REEVAL_SYMBOL\'|translate}}
CURRENCY.VIEW.DISPLAY_ALL_RULES
'),e.put("templates/currency/items_wot.html",'
CURRENCY.VIEW.MEMBERS (N{{\'CURRENCY.VIEW.CURRENT\'|translate}})
{{formData.N | formatInteger}}
(ΔN)
{{formData.N > formData.Nprev ? \'+\' : \'\'}}{{formData.N - formData.Nprev}}
CURRENCY.VIEW.WOT_RULES_DIVIDER
CURRENCY.VIEW.SIG_QTY_RULE {{formData.sigQty}} CURRENCY.VIEW.MS_WINDOW {{formData.msWindow | formatDuration}} CURRENCY.VIEW.MS_VALIDITY {{formData.msValidity | formatDuration}} CURRENCY.VIEW.SIG_WINDOW {{formData.sigWindow | formatDuration}} CURRENCY.VIEW.SIG_VALIDITY {{formData.sigValidity | formatDuration}} CURRENCY.VIEW.SIG_STOCK {{formData.sigStock}} CURRENCY.VIEW.SIG_PERIOD {{formData.sigPeriod | formatDuration}}
(stepMax)
{{formData.stepMax}}
CURRENCY.VIEW.SENTRIES {{formData.sentries}} CURRENCY.VIEW.SENTRIES_FORMULA {{\'CURRENCY.VIEW.MATH_CEILING\'| translate}}( Nt^ (1 / stepMax)) CURRENCY.VIEW.XPERCENT {{formData.xpercent*100| formatNumeral: \'0,0\'}} %
CURRENCY.VIEW.DISPLAY_ALL_RULES
'),e.put("templates/currency/lookup_form.html",'
'),e.put("templates/currency/lookup.html",'

CURRENCY.SELECT.CURRENCIES

'),e.put("templates/currency/modal_license.html",'

CURRENCY.LICENSE.TITLE

translate>CURRENCY.LICENSE.NO_LICENSE_FILE

'),e.put("templates/currency/popover_actions.html",'

COMMON.POPOVER_ACTIONS_TITLE

'),e.put("templates/currency/tabs/tab_blocks.html",'
BLOCKCHAIN.LOOKUP.LAST_BLOCKS
'),e.put("templates/currency/tabs/tab_network.html",'
'),e.put("templates/currency/tabs/tab_parameters.html",'
'),e.put("templates/currency/tabs/tab_wot.html",'
'),e.put("templates/currency/view_currency_lg.html",'{{\'CURRENCY.VIEW.TITLE\' | translate}} {{formData.currency|abbreviate}}
CURRENCY.VIEW.MONEY_DIVIDER
CURRENCY.VIEW.WOT_DIVIDER
'),e.put("templates/currency/view_currency.html",''),e.put("templates/help/help.html",'
MODE.DEMO.MODE
MODE.DEMO.MODE_HELP
MODE.DEMO.INSTALL_HELP
MODE.READONLY.MODE
MODE.READONLY.MODE_HELP
MODE.READONLY.INSTALL_HELP

HELP.JOIN.SECTION

LOGIN.SALT
HELP.JOIN.SALT
LOGIN.PASSWORD
HELP.JOIN.PASSWORD
ACCOUNT.NEW.PSEUDO
HELP.JOIN.PSEUDO

HELP.LOGIN.SECTION

HELP.LOGIN.PUBKEY
HELP.LOGIN.PUBKEY_DEF
HELP.LOGIN.METHOD
HELP.LOGIN.METHOD_DEF

HELP.GLOSSARY.SECTION

COMMON.PUBKEY
HELP.GLOSSARY.PUBKEY_DEF
HELP.GLOSSARY.BLOCKCHAIN
HELP.GLOSSARY.BLOCKCHAIN_DEF
COMMON.UNIVERSAL_DIVIDEND
HELP.GLOSSARY.UNIVERSAL_DIVIDEND_DEF
HELP.GLOSSARY.MEMBER
HELP.GLOSSARY.MEMBER_DEF
HELP.GLOSSARY.WOT
HELP.GLOSSARY.WOT_DEF
HELP.GLOSSARY.CURRENCY_RULES
HELP.GLOSSARY.CURRENCY_RULES_DEF
HELP.GLOSSARY.DISTANCE_RULE
HELP.GLOSSARY.DISTANCE_RULE_DEF
'),e.put("templates/help/modal_help.html",'

HELP.TITLE

'),e.put("templates/help/view_help.html",'HELP.TITLE

HELP.TITLE

'),e.put("templates/home/home.html",'

HOME.MESSAGE

HOME.WELCOME_READONLY

HOME.MESSAGE_READONLY



{{\'LOGIN.HAVE_ACCOUNT_QUESTION\'|translate}}

MODE.DEMO.MODE_HELP HOME.READ_MORE


MODE.READONLY.INSTALL_HELP


{{:locale:\'COMMON.APP_VERSION\'|translate:{version: config.version} }} | HOME.BTN_ABOUT
 
'),e.put("templates/join/modal_choose_account_type.html",'

ACCOUNT.NEW.TITLE

ACCOUNT.NEW.INTRO_WARNING_SECURITY
ACCOUNT.NEW.INTRO_WARNING_SECURITY_HELP


ACCOUNT.NEW.SELECT_ACCOUNT_TYPE

'),e.put("templates/join/modal_join_member.html",'

ACCOUNT.NEW.MEMBER_ACCOUNT_TITLE

ACCOUNT.NEW.INFO_LICENSE
ACCOUNT.NEW.PSEUDO_WARNING
ACCOUNT.NEW.PSEUDO
ACCOUNT.NEW.CHECKING_PSEUDO
ACCOUNT.NEW.PSEUDO_AVAILABLE
ACCOUNT.NEW.PSEUDO_NOT_AVAILABLE
LOGIN.SALT
ACCOUNT.NEW.SALT_CONFIRM
COMMON.SHOW_VALUES
LOGIN.PASSWORD
ACCOUNT.NEW.PASSWORD_CONFIRM
COMMON.SHOW_VALUES
ACCOUNT.NEW.LAST_SLIDE_CONGRATULATION

LOGIN.ASSOCIATED_PUBKEY

{{formData.pubkey}}

{{formData.pubkey}}
ERROR.EXISTING_ACCOUNT_REQUEST
'),e.put("templates/join/modal_join_wallet.html",'

ACCOUNT.NEW.WALLET_ACCOUNT_TITLE

LOGIN.SALT
ACCOUNT.NEW.SALT_CONFIRM
COMMON.SHOW_VALUES
LOGIN.PASSWORD
ACCOUNT.NEW.PASSWORD_CONFIRM
COMMON.SHOW_VALUES
ACCOUNT.NEW.LAST_SLIDE_CONGRATULATION
COMMON.PUBKEY ACCOUNT.NEW.COMPUTING_PUBKEY {{formData.pubkey}}
ERROR.EXISTING_ACCOUNT
ACCOUNT.NEW.COMPUTING_PUBKEY
{{formData.pubkey}}
ERROR.EXISTING_ACCOUNT_REQUEST
'),e.put("templates/login/form_file_import.html",'

LOGIN.FILE_FORM_HELP

LOGIN.FILE.HELP

COMMON.CHOOSE_FILE

{{formData.file.name}}

COMMON.FILE.DATE {{formData.file.lastModified/1000|formatDate}}

COMMON.FILE.SIZE {{formData.file.size|formatInteger}} Ko

COMMON.PUBKEY

COMMON.FILE.VALIDATING

{{formData.file.pubkey}}
{{formData.file.pubkey ? \'ERROR.AUTH_INVALID_PUBKEY\' : \'ERROR.AUTH_INVALID_FILE\' |translate}}

LOGIN.MEMORIZE_AUTH_FILE
'),e.put("templates/login/form_login.html",'


{{\'LOGIN.NO_ACCOUNT_QUESTION\'|translate}}
LOGIN.CREATE_ACCOUNT

'),e.put("templates/login/form_pubkey.html",'

LOGIN.PUBKEY_FORM_HELP

'),e.put("templates/login/form_scan.html",'

COMMON.PUBKEY
{{formData.pubkey}}
'),e.put("templates/login/form_scrypt_advanced.html",'

INFO.FEATURES_NOT_IMPLEMENTED

'),e.put("templates/login/form_scrypt.html",'

'),e.put("templates/login/item_remember_me.html",'
SETTINGS.REMEMBER_ME
'),e.put("templates/login/modal_login.html",''),e.put("templates/login/popover_methods.html",''),e.put("templates/menu.html",'

{{:locale:\'COMMON.APP_NAME\'|translate}} {{$root.currency.name|abbreviate}} {{:locale:\'MODE.DEMO.BADGE\'|translate}} {{:locale:\'MODE.READONLY.BADGE\'|translate}}

{{:locale:\'MENU.HOME\'|translate}}
{{:locale:\'MENU.ACCOUNT\'|translate}} {{:locale:\'MENU.TRANSACTIONS\'|translate}} {{:locale:\'MENU.WALLETS\'|translate}}
{{:locale:\'MENU.WOT\'|translate}} {{:locale:\'MENU.CURRENCY\'|translate}}
{{:locale:\'HOME.BTN_HELP\'|translate}} {{:locale:\'MENU.SETTINGS\'|translate}}
{{:locale:\'COMMON.BTN_LOGOUT\'|translate}}
'),e.put("templates/modal_about.html",'

ABOUT.TITLE

{{\'COMMON.APP_NAME\'|translate}} {{\'COMMON.APP_VERSION\'|translate:$root.config}} - www.cesium.app

{{\'COMMON.APP_BUILD\'|translate:{build: buildDate} }}

ABOUT.LICENSE

{{::$root.newRelease.url}}

ABOUT.OFFICIAL_WEB_SITE

https://www.cesium.app

{{\'ABOUT.FORUM\' | translate}}

{{::$root.settings.userForumUrl}}

ABOUT.PLEASE_REPORT_ISSUE

ABOUT.REPORT_ISSUE

{{\'ABOUT.CODE\' | translate}}

{{$root.settings.sourceUrl}}

{{\'ABOUT.DEVELOPERS\' | translate}}

Benoit Lavenier, bpresles, cgeek, DiG, Ji_emme

'),e.put("templates/network/item_content_peer.html",'

{{:rebind:peer.dns || peer.server}}

{{:locale:\'NETWORK.VIEW.PRIVATE_ACCESS\'|translate}}

{{:rebind:peer.pubkey|formatPubkey}} {{:rebind:peer.name || peer.uid}} {{:rebind:peer.dns && (\' | \' + peer.server) + (peer.bma.path||\'\') }}

{{:locale:!expertMode ? (\'COMMON.BLOCK\'|translate) : \'\' }} {{:rebind:(peer.currentNumber || peer.blockNumber) | formatInteger}}   {{:rebind:peer.consensusBlockDelta|formatDurationTime}}
'),e.put("templates/network/items_peers.html",''), e.put("templates/network/lookup_popover_actions.html",'

PEER.POPOVER_FILTER_TITLE

'),e.put("templates/network/modal_network.html",'

PEER.PEER_LIST

PEER.MEMBER_PEERS PEER.MIRROR_PEERS PEER.ALL_PEERS ({{search.results.length}})

'),e.put("templates/network/popover_endpoints.html",'
{{titleKey | translate:titleValues }}
{{item.label | translate}}
{{item.value}}
'),e.put("templates/network/popover_network.html",''),e.put("templates/network/popover_peer_info.html",''),e.put("templates/network/view_network.html",'MENU.NETWORK'),e.put("templates/network/view_peer.html",'PEER.VIEW.TITLE

PEER.VIEW.TITLE {{node.host}}

{{node.bma.dns || node.server}} SSL ({{\'PEER.MIRROR\'|translate}})

{{\'PEER.VIEW.OWNER\'|translate}} {{node.name || node.uid}} ({{node.uid}}) {{node.pubkey|formatPubkey}} ({{node.name}})

{{\'PEER.VIEW.SHOW_RAW_PEERING\'|translate}} | PEER.VIEW.SHOW_RAW_CURRENT_BLOCK

PEER.VIEW.GENERAL_DIVIDER
COMMON.PUBKEY

{{node.pubkey}}

BLOCKCHAIN.VIEW.TITLE_CURRENT
{{current.number|formatInteger}}
PEER.VIEW.LAST_BLOCKS
PEER.VIEW.KNOWN_PEERS
{{\'NETWORK.INFO.ONLY_SSL_PEERS\'|translate}}
'),e.put("templates/settings/popover_actions.html",'

COMMON.POPOVER_ACTIONS_TITLE

'),e.put("templates/settings/popup_node.html",'
{{\'SETTINGS.POPUP_PEER.USE_SSL\' | translate}}

{{\'SETTINGS.POPUP_PEER.BTN_SHOW_LIST\' | translate}}
'),e.put("templates/settings/settings.html",'SETTINGS.TITLE
SETTINGS.DISPLAY_DIVIDER
{{\'COMMON.BTN_RELATIVE_UNIT\' | translate}}
SETTINGS.STORAGE_DIVIDER
{{\'SETTINGS.USE_LOCAL_STORAGE\' | translate}}

{{\'SETTINGS.AUTHENTICATION_SETTINGS\' | translate}}
{{\'SETTINGS.REMEMBER_ME\' | translate}}

{{\'SETTINGS.WALLETS_SETTINGS\' | translate}}
SETTINGS.USE_WALLETS_ENCRYPTION

SETTINGS.HISTORY_SETTINGS
SETTINGS.DISPLAY_UD_HISTORY
SETTINGS.NETWORK_SETTINGS
SETTINGS.PEER_SHORT

{{bma.server}}
{{bma.server}}
SETTINGS.PLUGINS_SETTINGS
'),e.put("templates/wallet/item_tx.html",' '),e.put("templates/wallet/item_ud.html",'
COMMON.UNIVERSAL_DIVIDEND

{{::tx.time | medianFromNowAndDate}}

()
'),e.put("templates/wallet/list/item_wallet_light.html",'

{{::walletData.localName||walletData.name||walletData.uid}}{{::walletData.pubkey|formatPubkey}}

{{::walletData.uid}}  {{::walletData.pubkey | formatPubkey}} WOT.NOT_MEMBER_PARENTHESIS

'),e.put("templates/wallet/list/item_wallet.html",'

{{::walletData.pubkey|formatPubkey}}

{{::walletData.uid}}  {{::walletData.pubkey | formatPubkey}} WOT.NOT_MEMBER_PARENTHESIS

'),e.put("templates/wallet/list/modal_import_file.html",'

ACCOUNT.WALLET_LIST.IMPORT_MODAL.TITLE

ACCOUNT.WALLET_LIST.IMPORT_MODAL.HELP

COMMON.CHOOSE_FILE

{{fileData.name}}

COMMON.FILE.DATE {{fileData.lastModified/1000|formatDate}}

COMMON.FILE.SIZE {{fileData.size|formatInteger}} Ko

COMMON.FILE.VALIDATING


{{\'ACCOUNT.WALLET_LIST.IMPORT_MODAL.NO_NEW_WALLET\' |translate}}

{{\'ERROR.INVALID_FILE_FORMAT\' |translate}}

'),e.put("templates/wallet/list/modal_wallets.html",'

ACCOUNT.SELECT_WALLET_MODAL.TITLE

{{:locale:\'ACCOUNT.WALLET_LIST.NO_WALLET\'|translate}}
'),e.put("templates/wallet/list/popover_actions.html",'

COMMON.POPOVER_ACTIONS_TITLE

'),e.put("templates/wallet/list/popover_wallets.html",'
ACCOUNT.SELECT_WALLET_MODAL.TITLE
{{:locale:\'ACCOUNT.WALLET_LIST.NO_WALLET\'|translate}}
'),e.put("templates/wallet/list/popup_edit_name.html",'
'),e.put("templates/wallet/list/view_wallets.html",'
{{:locale:\'ACCOUNT.WALLET_LIST.NO_WALLET\'|translate}}
'),e.put("templates/wallet/modal_security.html",'

ACCOUNT.SECURITY.TITLE

ACCOUNT.SECURITY.RECOVER_ID

ACCOUNT.SECURITY.RECOVER_ID_HELP

ACCOUNT.SECURITY.REVOCATION_WITH_FILE

ACCOUNT.SECURITY.REVOCATION_WITH_FILE_DESCRIPTION

ACCOUNT.SECURITY.SEND_IDENTITY

ACCOUNT.SECURITY.MEMBERSHIP_IN

ACCOUNT.SECURITY.REVOCATION_WALLET

ACCOUNT.SECURITY.REVOCATION_WALLET_HELP

'),e.put("templates/wallet/modal_transfer.html",'

TRANSFER.MODAL.TITLE

'),e.put("templates/wallet/new_transfer.html",'TRANSFER.TITLE
'),e.put("templates/wallet/popover_actions.html",'

COMMON.POPOVER_ACTIONS_TITLE

'),e.put("templates/wallet/popover_unit.html",''),e.put("templates/wallet/popup_register.html",'
'),e.put("templates/wallet/slides/slides_generate_keyfile.html",'

ACCOUNT.SECURITY.GENERATE_KEYFILE

ACCOUNT.SECURITY.KEYFILE.PUBSEC_FORMAT

ACCOUNT.SECURITY.KEYFILE.PUBSEC_FORMAT_HELP

ACCOUNT.SECURITY.KEYFILE.WIF_FORMAT

ACCOUNT.SECURITY.KEYFILE.WIF_FORMAT_HELP

ACCOUNT.SECURITY.KEYFILE.EWIF_FORMAT

ACCOUNT.SECURITY.KEYFILE.EWIF_FORMAT_HELP

'),e.put("templates/wallet/slides/slides_recoverID_1.html",'

ACCOUNT.SECURITY.RECOVER_ID_SELECT_FILE

COMMON.CHOOSE_FILE

{{fileData.name}}
{{fileData.size}} Ko
'),e.put("templates/wallet/slides/slides_recoverID_2.html",'

ACCOUNT.SECURITY.RECOVER_ID

'),e.put("templates/wallet/slides/slides_recoverID_3.html",'

ACCOUNT.SECURITY.RECOVER_ID

{{\'LOGIN.SALT\' | translate}} : {{recover.salt}}
{{\'LOGIN.PASSWORD\' | translate}} : {{recover.pwd}}
'),e.put("templates/wallet/slides/slides_revocation_file.html",'

ACCOUNT.SECURITY.REVOCATION_WITH_FILE_HELP

COMMON.CHOOSE_FILE

{{fileData.name}}

COMMON.FILE.DATE {{fileData.lastModified/1000|formatDate}}

COMMON.FILE.SIZE {{fileData.size|formatInteger}} Ko


{{revocationError|translate}}

'),e.put("templates/wallet/slides/slides_saveID_1.html",'

ACCOUNT.SECURITY.SAVE_ID

{{question.value | translate}}
'),e.put("templates/wallet/slides/slides_saveID_2.html",'

ACCOUNT.SECURITY.SAVE_ID

'),e.put("templates/wallet/transfer_form.html",'
TRANSFER.TO {{destUid}}   {{formData.destPub | formatPubkey}}
TRANSFER.FROM {{walletData.pubkey| formatPubkey}}   {{walletData.name||walletData.uid}}  
TRANSFER.AMOUNT ()
 
TRANSFER.REST()TRANSFER.REST_TO {{restUid}}   {{formData.restPub | formatPubkey}}

TRANSFER.WARN_COMMENT_IS_PUBLIC

'),e.put("templates/wallet/tx_locked_outputs_popover.html",'

ACCOUNT.LOCKED_OUTPUTS_POPOVER.TITLE

ACCOUNT.LOCKED_OUTPUTS_POPOVER.DESCRIPTION

ACCOUNT.LOCKED_OUTPUTS_POPOVER.DESCRIPTION_MANY

ACCOUNT.LOCKED_OUTPUTS_POPOVER.LOCKED_AMOUNT

{{::\'BLOCKCHAIN.VIEW.TX_OUTPUT_OPERATOR.\'+condition.operator|translate}} 
{{::condition.value|formatDuration}}
{{::condition.value|medianDate}}
'),e.put("templates/wallet/view_wallet_tx_error.html",'
{{:locale:\'ACCOUNT.PENDING_TX_RECEIVED\'|translate}}
({{$root.currency.name | abbreviate}}) ({{\'COMMON.UD\' | translate}}{{$root.currency.name | abbreviate}})
{{:locale:\'ACCOUNT.NO_TX\'|translate}}
{{:locale:\'ACCOUNT.ERROR_TX_SENT\'|translate}}
({{$root.currency.name | abbreviate}}) ({{\'COMMON.UD\' | translate}}{{$root.currency.name | abbreviate}})
{{:locale:\'ACCOUNT.NO_TX\'|translate}}
'),e.put("templates/wallet/view_wallet_tx.html",'MENU.TRANSACTIONS
{{:locale:\'ACCOUNT.ERROR_TX\'|translate}}
{{formData.tx.errors.length}}
{{:locale:\'ACCOUNT.PENDING_TX\'|translate}}
{{:locale:\'ACCOUNT.VALIDATING_TX\'|translate}}
{{:locale:\'ACCOUNT.LAST_TX\'|translate}}   {{:locale:\'ACCOUNT.NO_TX\'|translate}}
'),e.put("templates/wallet/view_wallet.html",'
WOT.GENERAL_DIVIDER
{{:locale:\'COMMON.PUBKEY\'|translate}}

{{:rebind:formData.pubkey}}

COMMON.UID
WOT.REGISTERED_SINCE {{:rebind:formData.sigDate | medianDate}}
{{:rebind:formData.uid}}
{{:locale:\'ACCOUNT.CERTIFICATION_COUNT\'|translate}} WOT.GIVEN_CERTIFICATIONS.SENT WOT.ACCOUNT_OPERATIONS {{:locale:\'ACCOUNT.EVENTS\' | translate}}
'),e.put("templates/wot/item_certification.html",'

{{::cert.name||cert.uid}}

{{::cert.pubkey | formatPubkey}} | {{::cert.time|medianDate}} | {{::cert.pending ? \'WOT.SIGNED_ON_BLOCK\' : \'WOT.WRITTEN_ON_BLOCK\' | translate:cert}}

{{::cert.name||cert.uid}} {{::cert.pubkey | formatPubkey}}

{{::\'WOT.NOT_MEMBER_PARENTHESIS\'|translate}}

{{::cert.pubkey | formatPubkey}} | {{::cert.time|medianDate}} | {{::cert.pending ? \'WOT.SIGNED_ON_BLOCK\' : \'WOT.WRITTEN_ON_BLOCK\' | translate:cert}}

{{::cert.expiresIn | formatDurationTo}}
{{::\'WOT.EXPIRED\' | translate}}
'),e.put("templates/wot/item_content_identity.html",'

{{::item.pubkey|formatPubkey}}

{{::\'WOT.LOOKUP.REGISTERED\' | translate:item }}

{{::\'WOT.LOOKUP.MEMBER_FROM\' | translate:item}}

{{::item.uid}}  {{::item.pubkey | formatPubkey}} WOT.NOT_MEMBER_PARENTHESIS WOT.IDENTITY_REVOKED_PARENTHESIS

#

'),e.put("templates/wot/items_given_certifications.html",'
WOT.GIVEN_CERTIFICATIONS.SENT
WOT.GIVEN_CERTIFICATIONS.ERROR {{formData.given_cert_error.length}}
WOT.GIVEN_CERTIFICATIONS.PENDING_LIST
WOT.NOT_WRITTEN_EXPIRE_IN
WOT.GIVEN_CERTIFICATIONS.LIST
WOT.EXPIRE_IN
WOT.NO_GIVEN_CERTIFICATION
'),e.put("templates/wot/items_received_certifications.html",'
WOT.CERTIFICATIONS.RECEIVED

WOT.CERTIFICATIONS.SENTRY_MEMBER

WOT.CERTIFICATIONS.ERROR {{formData.received_cert_error.length}}
WOT.CERTIFICATIONS.PENDING_LIST
WOT.NOT_WRITTEN_EXPIRE_IN
WOT.CERTIFICATIONS.LIST
WOT.EXPIRE_IN
WOT.NO_CERTIFICATION
'),e.put("templates/wot/lookup_form.html",'
{{::parameters.help|translate}}
  

WOT.LOOKUP.NEWCOMERS

{{\'WOT.LOOKUP.NEWCOMERS_COUNT\'|translate:{count: search.total} }}

WOT.LOOKUP.PENDING

{{\'WOT.LOOKUP.PENDING_COUNT\'|translate:{count: search.total} }}

COMMON.RESULTS_LIST ({{search.total}})

WOT.SEARCH_INIT_PHASE_WARNING

COMMON.SEARCH_NO_RESULT WOT.LOOKUP.NO_PENDING WOT.LOOKUP.NO_NEWCOMERS
{{::(\'WOT.SEARCH.DIVIDER_\' + item.index)|upper|translate}}
'),e.put("templates/wot/lookup_lg.html",'{{\'MENU.WOT\' | translate}}'),e.put("templates/wot/lookup_popover_actions.html",'

COMMON.POPOVER_FILTER_TITLE

'),e.put("templates/wot/lookup.html",''),e.put("templates/wot/modal_lookup.html",'

{{::parameters.title?parameters.title:\'WOT.MODAL.TITLE\'|translate}}

'),e.put("templates/wot/modal_select_pubkey_identity.html",'

ACCOUNT.SELECT_IDENTITY_MODAL.TITLE

{{item.uid}}

{{::item.pubkey | formatPubkey}} WOT.NOT_MEMBER_PARENTHESIS WOT.IDENTITY_REVOKED_PARENTHESIS ERROR.WOT_PENDING_INVALID_BLOCK_HASH

WOT.REGISTERED_SINCE {{::item.meta.time|medianDate}}

'),e.put("templates/wot/tabs/tab_given_certifications.html",'
'),e.put("templates/wot/tabs/tab_lookup.html",''),e.put("templates/wot/tabs/tab_received_certifications.html",'
'),e.put("templates/wot/view_certifications.html",'{{::formData.name||formData.uid}}
'),e.put("templates/wot/view_identity_tx.html",'{{formData.name || formData.uid}} {{formData.pubkey|formatPubkey}}
{{:locale:\'ACCOUNT.BALANCE_ACCOUNT\'|translate}}
()
{{:locale:\'ACCOUNT.ERROR_TX\'|translate}}
{{formData.tx.errors.length}}
{{:locale:\'ACCOUNT.PENDING_TX\'|translate}}
{{:locale:\'ACCOUNT.VALIDATING_TX\'|translate}}
{{:locale:\'ACCOUNT.LAST_TX\'|translate}}  
'), e.put("templates/wot/view_identity.html",'

{{::formData.name}}

{{:rebind:formData.uid}}

{{:rebind:formData.pubkey | formatPubkey}}

WOT.IDENTITY_REVOKED_PARENTHESISWOT.MEMBER_PENDING_REVOCATION_PARENTHESIS

WOT.GENERAL_DIVIDER COMMON.PUBKEY

{{:rebind:formData.pubkey}}

WOT.NOT_MEMBER_ACCOUNT

WOT.NOT_MEMBER_ACCOUNT_HELP

COMMON.UID
WOT.REGISTERED_SINCE {{:rebind:formData.sigDate|medianDate}}
{{:rebind:formData.uid}}
ACCOUNT.CERTIFICATION_COUNT WOT.GIVEN_CERTIFICATIONS.SENT WOT.ACCOUNT_OPERATIONS
')}]),angular.module("cesium.translations",[]).config(["$translateProvider",function(e){e.translations("en-GB",{COMMON:{APP_NAME:"Cesium",APP_VERSION:"v{{version}}",APP_BUILD:"build {{build}}",PUBKEY:"Public key",MEMBER:"Member",BLOCK:"Block",BTN_OK:"OK",BTN_YES:"Yes",BTN_NO:"No",BTN_SEND:"Send",BTN_SEND_MONEY:"Transfer money",BTN_SEND_MONEY_SHORT:"Transfer",BTN_SAVE:"Save",BTN_YES_SAVE:"Yes, Save",BTN_YES_CONTINUE:"Yes, Continue",BTN_SHOW:"Show",BTN_SHOW_PUBKEY:"Show key",BTN_RELATIVE_UNIT:"Display amounts in UD?",BTN_BACK:"Back",BTN_NEXT:"Next",BTN_IMPORT:"Import",BTN_CANCEL:"Cancel",BTN_CLOSE:"Close",BTN_LATER:"Later",BTN_LOGIN:"Sign In",BTN_LOGOUT:"Logout",BTN_ADD_ACCOUNT:"New Account",BTN_SHARE:"Share",BTN_EDIT:"Edit",BTN_DELETE:"Delete",BTN_ADD:"Add",BTN_SEARCH:"Search",BTN_REFRESH:"Refresh",BTN_RETRY:"Retry",BTN_START:"Start",BTN_CONTINUE:"Continue",BTN_CREATE:"Create",BTN_UNDERSTOOD:"I understand",BTN_OPTIONS:"Options",BTN_HELP_TOUR:"Features tour",BTN_HELP_TOUR_SCREEN:"Discover this screen",BTN_DOWNLOAD:"Download",BTN_DOWNLOAD_ACCOUNT_STATEMENT:"Download account statement",BTN_MODIFY:"Modify",CHOOSE_FILE:"Drag your file
or click to select",DAYS:"days",NO_ACCOUNT_QUESTION:"Not a member yet? Register now!",SEARCH_NO_RESULT:"No result found",LOADING:"Loading...",LOADING_WAIT:"Loading...
(Waiting for node availability)",SEARCHING:"Searching...",FROM:"From",TO:"To",COPY:"Copy",LANGUAGE:"Language",UNIVERSAL_DIVIDEND:"Universal dividend",UD:"UD",DATE_PATTERN:"DD/MM/YYYY HH:mm",DATE_FILE_PATTERN:"YYYY-MM-DD",DATE_SHORT_PATTERN:"DD/MM/YY",DATE_MONTH_YEAR_PATTERN:"MM/YYYY",EMPTY_PARENTHESIS:"(empty)",UID:"Pseudonym",ENABLE:"Enabled",DISABLE:"Disabled",RESULTS_LIST:"Results:",RESULTS_COUNT:"{{count}} results",EXECUTION_TIME:"executed in {{duration|formatDurationMs}}",SHOW_VALUES:"Display values openly?",POPOVER_ACTIONS_TITLE:"Options",POPOVER_FILTER_TITLE:"Filters",SHOW_MORE:"Show more",SHOW_MORE_COUNT:"(current limit at {{limit}})",POPOVER_SHARE:{TITLE:"Share",SHARE_ON_TWITTER:"Share on Twitter",SHARE_ON_FACEBOOK:"Share on Facebook",SHARE_ON_DIASPORA:"Share on Diaspora*",SHARE_ON_GOOGLEPLUS:"Share on Google+"},FILE:{DATE:"Date:",TYPE:"Type:",SIZE:"Size:",VALIDATING:"Validating..."}},SYSTEM:{PICTURE_CHOOSE_TYPE:"Choose source:",BTN_PICTURE_GALLERY:"Gallery",BTN_PICTURE_CAMERA:"Camera"},MENU:{HOME:"Home",WOT:"Registry",CURRENCY:"Currency",ACCOUNT:"My Account",WALLETS:"My wallets",SETTINGS:"Settings",NETWORK:"Network",TRANSACTIONS:"My transactions"},ABOUT:{TITLE:"About",LICENSE:"Free/libre software (License GNU AGPLv3).",LATEST_RELEASE:"There is a newer version of {{'COMMON.APP_NAME' | translate}} (v{{version}})",PLEASE_UPDATE:"Please update {{'COMMON.APP_NAME' | translate}} (latest version: v{{version}})",CODE:"Source code:",OFFICIAL_WEB_SITE:"Official web site:",DEVELOPERS:"Developers:",FORUM:"Forum:",PLEASE_REPORT_ISSUE:"Please report any issue to us!",REPORT_ISSUE:"Report an issue",BTN_OPEN_DEV_WINDOW:"Open the debug window"},HOME:{TITLE:"Cesium",WELCOME:"Welcome to the Cesium application!",WELCOME_READONLY:"Welcome to Cesium Monit !",MESSAGE:"Receive and send libre currency {{currency|abbreviate}}",MESSAGE_READONLY:"Real-time monitoring of libre currency {{currency|abbreviate}}",BTN_CURRENCY:"Explore currency {{currency|abbreviate}}",BTN_ABOUT:"about",BTN_HELP:"Help",BTN_NETWORK:"Network status",FREE_SOFTWARE:"Free software",FORK_ME:"Fork me!",SHOW_LICENSE:"Show license",REPORT_ISSUE:"Report an issue",NOT_YOUR_ACCOUNT_QUESTION:'You do not own the account {{pubkey|formatPubkey}}?',BTN_CHANGE_ACCOUNT:"Disconnect this account",CONNECTION_ERROR:'Peer {{server}} unreachable or invalid address.

Check your Internet connection, or change node in the settings.',SHOW_ALL_FEED:"Show all",READ_MORE:"Read more",FEED_SOURCE:"Source"},SETTINGS:{TITLE:"Settings",DISPLAY_DIVIDER:"Display",STORAGE_DIVIDER:"Storage",NETWORK_SETTINGS:"Network",PEER:"Duniter peer address",PEER_SHORT:"Peer address",PEER_CHANGED_TEMPORARY:"Address used temporarily",PERSIST_CACHE:"Keep navigation data (experimental)",PERSIST_CACHE_HELP:"Allows faster navigation, locally retaining the data received, for use from one session to another.",USE_LOCAL_STORAGE:"Enable local storage",USE_LOCAL_STORAGE_HELP:"Allows you to save your settings",WALLETS_SETTINGS:"My wallets",USE_WALLETS_ENCRYPTION:"Secure the list",USE_WALLETS_ENCRYPTION_HELP:"Enables you to encrypt the list of your wallets. Authentication required to access it.",ENABLE_HELPTIP:"Enable contextual help tips",DISABLE_HELPTIP:"Disable contextual help tips",ENABLE_UI_EFFECTS:"Enable visual effects",HISTORY_SETTINGS:"Account operations",DISPLAY_UD_HISTORY:"Display produced dividends?",TX_HISTORY_AUTO_REFRESH:"Enable automatic refresh?",TX_HISTORY_AUTO_REFRESH_HELP:"Updates the list of operations to each new block.",AUTHENTICATION_SETTINGS:"Authentication",KEEP_AUTH:"Expiration of authentication",KEEP_AUTH_SHORT:"Expiration",KEEP_AUTH_HELP:"Define when authentication is cleared from memory.",KEEP_AUTH_OPTION:{NEVER:"After each operation",SECONDS:"After {{value}}s of inactivity",MINUTE:"After {{value}}min of inactivity",MINUTES:"After {{value}}min of inactivity",HOUR:"After {{value}}h of inactivity",ALWAYS:"At the end of the session"},KEYRING_FILE:"Keyring file",KEYRING_FILE_HELP:'Allow auto-connect at startup, or to authenticate (only if "Expiration of authentication" is "at the end of the session"',REMEMBER_ME:"Remember me ?",REMEMBER_ME_HELP:"Allows to remain identified from one session to another, keeping the public key locally.",PLUGINS_SETTINGS:"Extensions",BTN_RESET:"Restore default values",EXPERT_MODE:"Enable expert mode",EXPERT_MODE_HELP:"Allow to see more details",BLOCK_VALIDITY_WINDOW:"Block uncertainty time",BLOCK_VALIDITY_WINDOW_SHORT:"Time of uncertainty",BLOCK_VALIDITY_WINDOW_HELP:"Time to wait before considering an information is validated",BLOCK_VALIDITY_OPTION:{NONE:"No delay",N:"{{time | formatDuration}} ({{count}} blocks)"},POPUP_PEER:{TITLE:"Duniter peer",HOST:"Address",HOST_HELP:"Address: server:port",USE_SSL:"Secured?",USE_SSL_HELP:"(SSL Encryption)",BTN_SHOW_LIST:"Peer's list"}},BLOCKCHAIN:{HASH:"Hash: {{hash}}",VIEW:{HEADER_TITLE:"Block #{{number}}-{{hash|formatHash}}",TITLE_CURRENT:"Current block",TITLE:"Block #{{number|formatInteger}}",COMPUTED_BY:"Computed by",SHOW_RAW:"Show raw data",TECHNICAL_DIVIDER:"Technical informations",VERSION:"Format version",HASH:"Computed hash",UNIVERSAL_DIVIDEND_HELP:"Money co-produced by each of the {{membersCount}} members",EMPTY:"Aucune donnée dans ce bloc",POW_MIN:"Minimal difficulty",POW_MIN_HELP:"Difficulty imposed in calculating hash",DATA_DIVIDER:"Data",IDENTITIES_COUNT:"New identities",JOINERS_COUNT:"Joiners",ACTIVES_COUNT:"Renewals",ACTIVES_COUNT_HELP:"Members having renewed their membership",LEAVERS_COUNT:"Leavers",LEAVERS_COUNT_HELP:"Members that now refused certification",EXCLUDED_COUNT:"Excluded members",EXCLUDED_COUNT_HELP:"Old members, excluded because missing membreship renewal or certifications",REVOKED_COUNT:"Revoked identities",REVOKED_COUNT_HELP:"These accounts may no longer be member",TX_COUNT:"Transactions",CERT_COUNT:"Certifications",TX_TO_HIMSELF:"Change",TX_OUTPUT_UNLOCK_CONDITIONS:"Unlock conditions",TX_OUTPUT_OPERATOR:{AND:"and",OR:"or"},TX_OUTPUT_FUNCTION:{SIG:"Sign of the public key",XHX:"Password, including SHA256 =",CSV:"Blocked during",CLTV:"Bloqué until"}},LOOKUP:{TITLE:"Blocks",NO_BLOCK:"No bloc",LAST_BLOCKS:"Last blocks:",BTN_COMPACT:"Compact"}},CURRENCY:{VIEW:{TITLE:"Currency",TAB_CURRENCY:"Currency",TAB_WOT:"Web of trust",TAB_NETWORK:"Network",TAB_BLOCKS:"Blocks",CURRENCY_SHORT_DESCRIPTION:"{{currency|capitalize}} is a libre money, started {{firstBlockTime | formatFromNow}}. It currently counts {{N}} members , who produce and collect a Universal Dividend (DU), each {{dt | formatPeriod}}.",NETWORK_RULES_DIVIDER:"Network rules",CURRENCY_NAME:"Currency name",MEMBERS:"Members count",MEMBERS_VARIATION:"Variation since {{duration|formatDuration}} (since last UD)",MONEY_DIVIDER:"Money",MASS:"Monetary mass",SHARE:"Money share",UD:"Universal Dividend",C_ACTUAL:"Current growth",MEDIAN_TIME:"Current blockchain time",POW_MIN:"Common difficulty",MONEY_RULES_DIVIDER:"Rules of currency",C_RULE:"Theoretical growth target",UD_RULE:"Universal dividend (formula)",DT_REEVAL:"Period between two re-evaluation of the UD",REEVAL_SYMBOL:"reeval",DT_REEVAL_VALUE:"Every {{dtReeval|formatDuration}} ({{dtReeval/86400}} {{'COMMON.DAYS'|translate}})",UD_REEVAL_TIME0:"Date of first reevaluation of the UD",SIG_QTY_RULE:"Required number of certifications to become a member",SIG_STOCK:"Maximum number of certifications sent by a member",SIG_PERIOD:"Minimum delay between 2 certifications sent by one and the same issuer.",SIG_WINDOW:"Maximum delay before a certification will be treated",SIG_VALIDITY:"Lifetime of a certification that has been treated",MS_WINDOW:"Maximum delay before a pending membership will be treated",MS_VALIDITY:"Lifetime of a membership that has been treated",STEP_MAX:"Maximum distance between a newcomer and each referring members.",WOT_RULES_DIVIDER:"Rules for web of trust",SENTRIES:"Required number of certifications (given and received) to become a referring member",SENTRIES_FORMULA:"Required number of certifications to become a referring member (formula)",XPERCENT:"Minimum percent of referring member to reach to match the distance rule",AVG_GEN_TIME:"The average time between 2 blocks",CURRENT:"current",MATH_CEILING:"CEILING",DISPLAY_ALL_RULES:"Display all rules?",BTN_SHOW_LICENSE:"Show license",WOT_DIVIDER:"Web of trust"},LICENSE:{TITLE:"Currency license",BTN_DOWNLOAD:"Download file",NO_LICENSE_FILE:"License file not found."}},NETWORK:{VIEW:{MEDIAN_TIME:"Blockchain time",LOADING_PEERS:"Loading peers...",NODE_ADDRESS:"Address:",SOFTWARE:"Software:",WARN_PRE_RELEASE:"Pre-release (latest stable: {{version}})",WARN_NEW_RELEASE:"Version {{version}} available",WS2PID:"Identifier:",PRIVATE_ACCESS:"Private access",POW_PREFIX:"Proof of work prefix:",ENDPOINTS:{BMAS:"Secure endpoint (SSL)",BMATOR:"TOR endpoint",WS2P:"WS2P endpoint",ES_USER_API:"Cesium+ data node"}},INFO:{ONLY_SSL_PEERS:"Non-SSL nodes have a degraded display because Cesium works in HTTPS mode."}},PEER:{PEERS:"Peers",SIGNED_ON_BLOCK:"Signed on block",MIRROR:"mirror",MIRRORS:"Mirrors",MIRROR_PEERS:"Mirror peers",PEER_LIST:"Peer's list",MEMBERS:"Members",MEMBER_PEERS:"Member peers",ALL_PEERS:"All peers",DIFFICULTY:"Difficulty",API:"API",CURRENT_BLOCK:"Block #",POPOVER_FILTER_TITLE:"Filter",OFFLINE:"Offline",OFFLINE_PEERS:"Offline peers",BTN_SHOW_PEER:"Show peer",VIEW:{TITLE:"Peer",OWNER:"Owned by ",SHOW_RAW_PEERING:"See peering document",SHOW_RAW_CURRENT_BLOCK:"See current block (raw format)",LAST_BLOCKS:"Last blocks",KNOWN_PEERS:"Known peers :",GENERAL_DIVIDER:"General information",ERROR:{LOADING_TOR_NODE_ERROR:"Could not get peer data, using the TOR network.",LOADING_NODE_ERROR:"Could not get peer data"}}},WOT:{SEARCH_HELP:"Search (member or public key)",SEARCH_INIT_PHASE_WARNING:"During the pre-registration phase, the search for pending registrations may be long. Please wait ...",REGISTERED_SINCE:"Registered on",REGISTERED_SINCE_BLOCK:"Registered since block #",NO_CERTIFICATION:"No validated certification",NO_GIVEN_CERTIFICATION:"No given certification",NOT_MEMBER_PARENTHESIS:"(non-member)",IDENTITY_REVOKED_PARENTHESIS:"(identity revoked)",MEMBER_PENDING_REVOCATION_PARENTHESIS:"(being revoked)",EXPIRE_IN:"Expires",NOT_WRITTEN_EXPIRE_IN:"Deadline
treatment",EXPIRED:"Expired",PSEUDO:"Pseudonym",SIGNED_ON_BLOCK:"Emitted on block #{{block}}",WRITTEN_ON_BLOCK:"Written on block #{{block}}",GENERAL_DIVIDER:"General information",NOT_MEMBER_ACCOUNT:"Non-member account",NOT_MEMBER_ACCOUNT_HELP:"This is a simple wallet, with no pending membership application.",TECHNICAL_DIVIDER:"Technical data",BTN_CERTIFY:"Certify",BTN_YES_CERTIFY:"Yes, certify",BTN_SELECT_AND_CERTIFY:"New certification",ACCOUNT_OPERATIONS:"Account operations",VIEW:{POPOVER_SHARE_TITLE:"Identity {{title}}"},LOOKUP:{TITLE:"Registry",NEWCOMERS:"New members:",NEWCOMERS_COUNT:"{{count}} members",PENDING:"Pending registrations:",PENDING_COUNT:"{{count}} pending registrations",REGISTERED:"Registered {{sigDate | formatFromNow}}",MEMBER_FROM:"Member since {{memberDate|medianFromNowShort}}",BTN_NEWCOMERS:"Latest members",BTN_PENDING:"Pending registrations",SHOW_MORE:"Show more",SHOW_MORE_COUNT:"(current limit to {{limit}})",NO_PENDING:"No pending registrations.",NO_NEWCOMERS:"No members."},CONTACTS:{TITLE:"Contacts"},MODAL:{TITLE:"Search"},CERTIFICATIONS:{TITLE:"{{uid}} - Certifications",SUMMARY:"Received certifications",LIST:"Details of received certifications",PENDING_LIST:"Pending certifications",RECEIVED:"Received certifications",RECEIVED_BY:"Certifications received by {{uid}}",ERROR:"Received certifications in error",SENTRY_MEMBER:"Referring member"},OPERATIONS:{TITLE:"{{uid}} - Operations"},GIVEN_CERTIFICATIONS:{TITLE:"{{uid}} - Certifications sent",SUMMARY:"Sent certifications",LIST:"Details of sent certifications",PENDING_LIST:"Pending certifications",SENT:"Sent certifications",SENT_BY:"Certifications sent by {{uid}}",ERROR:"Sent certifications with error"}},LOGIN:{TITLE:' Login',SCRYPT_FORM_HELP:"Please enter your credentials.
Remember to check the public key for your account.",PUBKEY_FORM_HELP:"Please enter a public account key:",FILE_FORM_HELP:"Choose the keychain file to use:",SCAN_FORM_HELP:"Scan the QR code of a wallet.",SALT:"Secret identifier",SALT_HELP:"Secret identifier",SHOW_SALT:"Display secret identifier?",PASSWORD:"Password",PASSWORD_HELP:"Password",PUBKEY_HELP:"Public key or pseudonym",NO_ACCOUNT_QUESTION:"Don't have an account yet?",HAVE_ACCOUNT_QUESTION:"Already have an account ?",CREATE_ACCOUNT:"Create an account",CREATE_FREE_ACCOUNT:"Create a free account",FORGOTTEN_ID:"Forgot password?",ASSOCIATED_PUBKEY:"Public key :",BTN_METHODS:"Other methods",BTN_METHODS_DOTS:"Change method...",METHOD_POPOVER_TITLE:"Methods",MEMORIZE_AUTH_FILE:"Memorize this keychain during the navigation session",SCRYPT_PARAMETERS:"Paramètres (Scrypt) :",AUTO_LOGOUT:{TITLE:"Information",MESSAGE:' You were logout automatically, due to prolonged inactivity.',BTN_RELOGIN:"Sign In",IDLE_WARNING:"You will be logout... {{countdown}}"},METHOD:{SCRYPT_DEFAULT:"Secret identifier and password",SCRYPT_ADVANCED:"Advanced salt",FILE:"Keychain file",PUBKEY:"Public key or pseudonym",SCAN:"Scan a QR code"},SCRYPT:{SIMPLE:"Light salt",DEFAULT:"Standard salt",SECURE:"Secure salt",HARDEST:"Hardest salt",EXTREME:"Extreme salt",USER:"Personal value",N:"N (Loop):",r:"r (RAM):",p:"p (CPU):"},FILE:{HELP:"Expected file format: .dunikey (type PubSec). Other formats are under development (EWIF, WIF)."}},AUTH:{TITLE:' Authentication',BTN_AUTH:"Authenticate",GENERAL_HELP:"Please authenticate yourself:",EXPECTED_UID_HELP:'Please authenticate to the account {{uid}}:',EXPECTED_PUBKEY_HELP:'Please authenticate to the wallet {{pubkey|formatPubkey}}:',SCAN_FORM_HELP:"Scan the QR code of the private key of the wallet."},ACCOUNT:{TITLE:"My Account",BALANCE:"Balance",LAST_TX:"Latest validated transactions",BALANCE_ACCOUNT:"Account balance",NO_TX:"No transaction",SHOW_MORE_TX:"Show more",SHOW_ALL_TX:"Show all",TX_FROM_DATE:"(current limit to {{fromTime|medianFromNowShort}})",PENDING_TX:"Pending transactions",VALIDATING_TX:"Transactions being validated",ERROR_TX:"Transaction not executed",ERROR_TX_SENT:"Sent transactions",PENDING_TX_RECEIVED:"Transactions awaiting receipt",EVENTS:"Events",OUT_DISTANCED:"Your current certifications come from a group too isolated from the Web of Trust (WoT): the maximum distance rule is violated.
You must obtain certifications from another area of the Web of Trust, or wait for it to tighten.",WAITING_MEMBERSHIP:"Membership application sent. Waiting validation.",WAITING_CERTIFICATIONS:"You need {{needCertificationCount}} certification(s) to become a member and produce the Universal Dividend. Your account is however already operational, to receive and send payments.",WAITING_CERTIFICATIONS_HELP:'To get your certifications, only request members who know you enough, as required by the currency license that you have accepted.
If you do not know enough members, let them know on the user forum.',WILL_MISSING_CERTIFICATIONS:"You will lack certifications soon (at least {{willNeedCertificationCount}} more are needed)",WILL_NEED_RENEW_MEMBERSHIP:"Your membership will expire {{membershipExpiresIn|formatDurationTo}}. Remember to renew your membership before then.",NEED_RENEW_MEMBERSHIP:"You are no longer a member because your membership has expired. Remember to renew your membership.",NEED_RENEW_MEMBERSHIP_AFTER_CANCELLED:"You are no longer a member because your membership has been cancelled for lack of certifications. Remember to renew your membership.",NO_WAITING_MEMBERSHIP:"No membership application pending. If you'd like to become a member, please send the membership application.",CERTIFICATION_COUNT:"Received certifications",CERTIFICATION_COUNT_SHORT:"Certifications",SIG_STOCK:"Stock of certifications to give",BTN_RECEIVE_MONEY:"Receive",BTN_SELECT_ALTERNATIVES_IDENTITIES:"Switch to another identity...",BTN_FIX_MEMBERSHIP:"Resubmit membership request...",BTN_MEMBERSHIP_RENEW:"Renew membership",BTN_MEMBERSHIP_RENEW_DOTS:"Renew membership...",BTN_MEMBERSHIP_OUT_DOTS:"Revoke membership...",BTN_SECURITY_DOTS:"Sign-in and security...",BTN_SHOW_DETAILS:"Display technical data",LOCKED_OUTPUTS_POPOVER:{TITLE:"Locked amount",DESCRIPTION:"Here are the conditions for unlocking this amount:",DESCRIPTION_MANY:"This transaction consists of several parts, of which the unlock conditions are:",LOCKED_AMOUNT:"Conditions for the amount:"},NEW:{TITLE:"Registration",INTRO_WARNING_TIME:"Creating an account on {{name|capitalize}} is very simple. Please take sufficient time to do this correctly (not to forget the usernames, passwords, etc.).",INTRO_WARNING_SECURITY:"Check that the hardware you are currently using (computer, tablet, phone) is secure and trustworthy .",INTRO_WARNING_SECURITY_HELP:"Up-to-date anti-virus, firewall enabled, session protected by password or pin code...",INTRO_HELP:"Click {{'COMMON.BTN_START'|translate}} to begin creating an account. You will be guided step by step.",REGISTRATION_NODE:"Your registration will be registered via the Duniter peer {{server}} node, which will then be distributed to the rest of the currency network.",REGISTRATION_NODE_HELP:"If you do not trust this peer, please change in the settings of Cesium.",SELECT_ACCOUNT_TYPE:"Choose the type of account to create:",MEMBER_ACCOUNT:"Member account",MEMBER_ACCOUNT_TITLE:"Create a member account",MEMBER_ACCOUNT_HELP:"If you are not yet registered as an individual (one account possible per individual).",WALLET_ACCOUNT:"Simple wallet",WALLET_ACCOUNT_TITLE:"Create a wallet",WALLET_ACCOUNT_HELP:"If you represent a company, association, etc. or simply need an additional wallet. No universal dividend will be created by this account.",SALT_WARNING:"Choose a secret identifier.
You need it for each connection to this account.

Make sure to remember this identifier.
If lost, there are no means to retrieve it!",PASSWORD_WARNING:"Choose a password.
You need it for each connection to this account.

Make sure to remember this password.
If lost, there are no means to retrieve it!",PSEUDO_WARNING:"Choose a pseudonym.
It may be used by other people to find you more easily.

.Use of commas, spaces and accents is not allowed.