(()=>{"use strict";var e,o,a,n={85781:(e,o,a)=>{var n=a(32981),s=a(85471),r=a(56760),c=a(70995),d=a(59892);a(51257);const i={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(console.error.bind(this))},getPrintData:e=>e?e.reduce(((e,t)=>e+t+"
"),""):"",printCodes(){!function(e){const o=OC.theme.name||"Nextcloud",a=window.open("",t("twofactor_backupcodes","{name} backup codes",{name:o}));a.document.write("

"+t("twofactor_backupcodes","{name} backup codes",{name:o})+"

"),a.document.write("
"+e+"
"),a.print(),a.close()}(this.getPrintData(this.codes))}}};var u=a(85072),l=a.n(u),p=a(97825),b=a.n(p),f=a(77659),h=a.n(f),g=a(55056),v=a.n(g),m=a(10540),A=a.n(m),_=a(41113),k=a.n(_),C=a(40097),w={};w.styleTagTransform=k(),w.setAttributes=v(),w.insert=h().bind(null,"head"),w.domAPI=b(),w.insertStyleElement=A(),l()(C.A,w),C.A&&C.A.locals&&C.A.locals;const y=(0,a(14486).A)(i,(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 x=a(95353),O=a(65043),N=a(63814);s.Ay.use(x.Ay);const S={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)}},P={generate(e){let{commit:t}=e;return t("setEnabled",!1),function(){const e=(0,N.Jv)("/apps/twofactor_backupcodes/settings/create");return O.Ay.post(e,{}).then((e=>e.data))}().then((e=>{let{codes:o,state:a}=e;return t("setEnabled",a.enabled),t("setTotal",a.total),t("setUsed",a.used),t("setCodes",o),!0}))}},T=new x.il({strict:!1,state:{enabled:!1,total:0,used:0,codes:[]},mutations:S,actions:P});s.Ay.prototype.t=t;const B=(0,n.C)("twofactor_backupcodes","state");T.replaceState(B),new(s.Ay.extend(y))({store:T}).$mount("#twofactor-backupcodes-settings")},40097:(e,t,o)=>{o.d(t,{A:()=>c});var a=o(71354),n=o.n(a),s=o(76314),r=o.n(s)()(n());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",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 n[e].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}r.m=n,e=[],r.O=(t,o,a,n)=>{if(!o){var s=1/0;for(u=0;u=n)&&Object.keys(r.O).every((e=>r.O[e](o[d])))?o.splice(d--,1):(c=!1,n0&&e[u-1][2]>n;u--)e[u]=e[u-1];e[u]=[o,a,n]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((t,o)=>(r.f[o](e,t),t)),[])),r.u=e=>e+"-"+e+".js?v="+{5706:"3153330af47fc26a725a",6127:"da37b69cd9ee64a1836b"}[e],r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},a="nextcloud:",r.l=(e,t,n,s)=>{if(o[e])o[e].push(t);else{var c,d;if(void 0!==n)for(var i=document.getElementsByTagName("script"),u=0;u{c.onerror=c.onload=null,clearTimeout(b);var n=o[e];if(delete o[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach((e=>e(a))),t)return t(a)},b=setTimeout(p.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=p.bind(null,c.onerror),c.onload=p.bind(null,c.onload),d&&document.head.appendChild(c)}},r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r.j=4423,(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var o=t.getElementsByTagName("script");if(o.length)for(var a=o.length-1;a>-1&&(!e||!/^http(s?):/.test(e));)e=o[a--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),(()=>{r.b=document.baseURI||self.location.href;var e={4423:0};r.f.j=(t,o)=>{var a=r.o(e,t)?e[t]:void 0;if(0!==a)if(a)o.push(a[2]);else{var n=new Promise(((o,n)=>a=e[t]=[o,n]));o.push(a[2]=n);var s=r.p+r.u(t),c=new Error;r.l(s,(o=>{if(r.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var n=o&&("load"===o.type?"missing":o.type),s=o&&o.target&&o.target.src;c.message="Loading chunk "+t+" failed.\n("+n+": "+s+")",c.name="ChunkLoadError",c.type=n,c.request=s,a[1](c)}}),"chunk-"+t,t)}},r.O.j=t=>0===e[t];var t=(t,o)=>{var a,n,s=o[0],c=o[1],d=o[2],i=0;if(s.some((t=>0!==e[t]))){for(a in c)r.o(c,a)&&(r.m[a]=c[a]);if(d)var u=d(r)}for(t&&t(o);ir(85781)));c=r.O(c)})(); //# sourceMappingURL=twofactor_backupcodes-settings.js.map?v=03ab400baead114c8d87