(()=>{"use strict";var e,o,n,a={85781:(e,o,n)=>{var a=n(32981),s=n(85471),r=n(56760),c=n(18740),d=n(84237),i=(n(51257),n(96763));const l={name:"PersonalSettings",components:{NcButton:c.A,NcLoadingIcon:d.A},data:()=>({generatingCodes:!1}),computed:{downloadUrl(){return this.codes?"data:text/plain,"+encodeURIComponent(this.codes.reduce(((e,t)=>e+t+"\r\n"),"")):""},downloadFilename:()=>(OC.theme.name||"Nextcloud")+"-backup-codes.txt",enabled(){return this.$store.state.enabled},total(){return this.$store.state.total},used(){return this.$store.state.used},codes(){return this.$store.state.codes},name:()=>OC.theme.name||"Nextcloud",haveCodes(){return this.codes&&this.codes.length>0}},methods:{generateBackupCodes(){(0,r.C5)().then((()=>{this.generatingCodes=!0,this.$store.dispatch("generate").then((()=>{this.generatingCodes=!1})).catch((e=>{throw OC.Notification.showTemporary(t("twofactor_backupcodes","An error occurred while generating your backup codes")),this.generatingCodes=!1,e}))})).catch(i.error.bind(this))},getPrintData:e=>e?e.reduce(((e,t)=>e+t+"
"),""):"",printCodes(){!function(e){const o=OC.theme.name||"Nextcloud",n=window.open("",t("twofactor_backupcodes","{name} backup codes",{name:o}));n.document.write("
"+e+""),n.print(),n.close()}(this.getPrintData(this.codes))}}};var u=n(85072),p=n.n(u),f=n(97825),b=n.n(f),g=n(77659),h=n.n(g),m=n(55056),v=n.n(m),_=n(10540),A=n.n(_),k=n(41113),C=n.n(k),w=n(40097),y={};y.styleTagTransform=C(),y.setAttributes=v(),y.insert=h().bind(null,"head"),y.domAPI=b(),y.insertStyleElement=A(),p()(w.A,y),w.A&&w.A.locals&&w.A.locals;const x=(0,n(14486).A)(l,(function(){var e=this,t=e._self._c;return t("div",{staticClass:"backupcodes-settings"},[e.enabled?[t("p",{staticClass:"backupcodes-settings__codes"},[e.haveCodes?[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","These are your backup codes. Please save and/or print them as you will not be able to read the codes again later."))+"\n\t\t\t\t"),t("ul",e._l(e.codes,(function(o){return t("li",{key:o,staticClass:"backupcodes-settings__codes__code"},[e._v("\n\t\t\t\t\t\t"+e._s(o)+"\n\t\t\t\t\t")])})),0)]:[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Backup codes have been generated. {used} of {total} codes have been used.",{used:e.used,total:e.total}))+"\n\t\t\t")]],2),e._v(" "),t("p",{staticClass:"backupcodes-settings__actions"},[e.haveCodes?[t("NcButton",{attrs:{href:e.downloadUrl,download:e.downloadFilename,type:"primary"}},[e._v("\n\t\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Save backup codes"))+"\n\t\t\t\t")]),e._v(" "),t("NcButton",{on:{click:e.printCodes}},[e._v("\n\t\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Print backup codes"))+"\n\t\t\t\t")])]:e._e(),e._v(" "),t("NcButton",{attrs:{id:"generate-backup-codes"},on:{click:e.generateBackupCodes}},[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","Regenerate backup codes"))+"\n\t\t\t")])],2),e._v(" "),t("p",[t("em",[e._v("\n\t\t\t\t"+e._s(e.t("twofactor_backupcodes","If you regenerate backup codes, you automatically invalidate old codes."))+"\n\t\t\t")])])]:t("NcButton",{attrs:{id:"generate-backup-codes",disabled:e.generatingCodes},on:{click:e.generateBackupCodes},scopedSlots:e._u([{key:"icon",fn:function(){return[e.generatingCodes?t("NcLoadingIcon"):e._e()]},proxy:!0}],null,!1,4108280908)},[e._v("\n\t\t"+e._s(e.t("twofactor_backupcodes","Generate backup codes"))+"\n\t")])],2)}),[],!1,null,"70ee3f3c",null).exports;var O=n(95353),N=n(65043),S=n(63814);s.Ay.use(O.Ay);const P={setEnabled(e,t){s.Ay.set(e,"enabled",t)},setTotal(e,t){s.Ay.set(e,"total",t)},setUsed(e,t){s.Ay.set(e,"used",t)},setCodes(e,t){s.Ay.set(e,"codes",t)}},T={generate(e){let{commit:t}=e;return t("setEnabled",!1),function(){const e=(0,S.Jv)("/apps/twofactor_backupcodes/settings/create");return N.Ay.post(e,{}).then((e=>e.data))}().then((e=>{let{codes:o,state:n}=e;return t("setEnabled",n.enabled),t("setTotal",n.total),t("setUsed",n.used),t("setCodes",o),!0}))}},B=new O.il({strict:!1,state:{enabled:!1,total:0,used:0,codes:[]},mutations:P,actions:T});s.Ay.prototype.t=t;const E=(0,a.C)("twofactor_backupcodes","state");B.replaceState(E),new(s.Ay.extend(x))({store:B}).$mount("#twofactor-backupcodes-settings")},40097:(e,t,o)=>{o.d(t,{A:()=>c});var n=o(71354),a=o.n(n),s=o(76314),r=o.n(s)()(a());r.push([e.id,".backupcodes-settings__codes__code[data-v-70ee3f3c]{font-family:monospace;letter-spacing:.02em;font-size:1.2em}.backupcodes-settings__actions[data-v-70ee3f3c]{display:flex;flex-wrap:wrap;align-items:center;gap:var(--default-grid-baseline)}","",{version:3,sources:["webpack://./apps/twofactor_backupcodes/src/views/PersonalSettings.vue"],names:[],mappings:"AAGE,oDACC,qBAAA,CACA,oBAAA,CACA,eAAA,CAIF,gDACC,YAAA,CACA,cAAA,CACA,kBAAA,CACA,gCAAA",sourcesContent:["\n.backupcodes-settings {\n\t&__codes {\n\t\t&__code {\n\t\t\tfont-family: monospace;\n\t\t\tletter-spacing: 0.02em;\n\t\t\tfont-size: 1.2em;\n\t\t}\n\t}\n\n\t&__actions {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tgap: var(--default-grid-baseline);\n\t}\n}\n"],sourceRoot:""}]);const c=r}},s={};function r(e){var t=s[e];if(void 0!==t)return t.exports;var o=s[e]={id:e,loaded:!1,exports:{}};return a[e].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}r.m=a,e=[],r.O=(t,o,n,a)=>{if(!o){var s=1/0;for(l=0;l