/*! For license information please see calendar-node_modules_nextcloud_dialogs_dist_chunks_PublicAuthPrompt-BSFsDqYB_mjs.js.LICENSE.txt */
"use strict";(self.webpackChunkcalendar=self.webpackChunkcalendar||[]).push([["node_modules_nextcloud_dialogs_dist_chunks_PublicAuthPrompt-BSFsDqYB_mjs"],{75771:(t,e,a)=>{a.r(e),a.d(e,{default:()=>f});var n=a(85471),i=a(59097),s=a(21777),r=a(85168),l=a(94219),o=a(5137),c=a(82182),u=a(93095),m=a(75377);const d=(0,i.c0)("public").build(),p=(0,n.pM)({name:"PublicAuthPrompt",components:{NcDialog:l.A,NcNoteCard:o.A,NcTextField:c.A},props:{nickname:{type:String,default:""},title:{type:String,default:(0,u.t)("Guest identification")},text:{type:String,default:""},notice:{type:String,default:(0,u.t)("You are currently not identified.")},submitLabel:{type:String,default:(0,u.t)("Submit name")},cancellable:{type:Boolean,default:!1}},setup:()=>({t:u.t}),emits:["close"],data:()=>({name:""}),computed:{dialogButtons(){const t={label:(0,u.t)("Cancel"),variant:"tertiary",callback:()=>this.$emit("close")},e={label:this.submitLabel,type:"submit",variant:"primary"};return this.cancellable?[t,e]:[e]}},watch:{nickname:{handler(){this.name=this.nickname},immediate:!0},name(){const t=this.name.trim?.()||"",e=this.$refs.input?.$el.querySelector("input");if(!e)return;const a=function(t){if(""===t.trim())return(0,u.t)("Names must not be empty.");if(t.startsWith("."))return(0,u.t)("Names must not start with a dot.");try{return(0,m.KT)(t),""}catch(t){if(!(t instanceof m.di))throw t;switch(t.reason){case m.nF.Character:return(0,u.t)('"{char}" is not allowed inside a name.',{char:t.segment});case m.nF.ReservedName:return(0,u.t)('"{segment}" is a reserved name and not allowed.',{segment:t.segment});case m.nF.Extension:return t.segment.match(/\.[a-z]/i)?(0,u.t)('"{extension}" is not an allowed name.',{extension:t.segment}):(0,u.t)('Names must not end with "{extension}".',{extension:t.segment});default:return(0,u.t)("Invalid name.")}}}(t);e.setCustomValidity(a),e.reportValidity()}},methods:{onSubmit(){const t=this.$refs.input,e=this.name.trim();if(""===e)return t.setCustomValidity((0,u.t)("You cannot leave the name empty.")),t.reportValidity(),void t.focus();if(e.length<2)return t.setCustomValidity((0,u.t)("Please enter a name with at least 2 characters.")),t.reportValidity(),void t.focus();try{(0,s.L$)(e)}catch(e){return(0,r.Qg)((0,u.t)("Failed to set nickname.")),console.error("Failed to set nickname",e),void t.focus()}d.setItem("public-auth-prompt-shown","true"),this.$emit("close",this.name)}}});var h=function(){var t=this,e=t._self._c;return t._self._setupProxy,e("NcDialog",{staticClass:"public-auth-prompt",attrs:{buttons:t.dialogButtons,"data-cy-public-auth-prompt-dialog":"","is-form":"","no-close":"",name:t.title},on:{submit:t.onSubmit}},[t.text?e("p",{staticClass:"public-auth-prompt__text"},[t._v(" "+t._s(t.text)+" ")]):t._e(),e("NcNoteCard",{staticClass:"public-auth-prompt__header",attrs:{text:t.notice,type:"info"}}),e("NcTextField",{ref:"input",staticClass:"public-auth-prompt__input",attrs:{"data-cy-public-auth-prompt-dialog-name":"",label:t.t("Name"),placeholder:t.t("Enter your name"),required:!t.cancellable,minlength:"2",name:"name"},model:{value:t.name,callback:function(e){t.name=e},expression:"name"}})],1)},b=[];const f=(0,u.n)(p,h,b,!1,null,"143ac1fb").exports}}]);
//# sourceMappingURL=calendar-node_modules_nextcloud_dialogs_dist_chunks_PublicAuthPrompt-BSFsDqYB_mjs.js.map?v=b9a1ad5d84b473afeec0