"use strict";(self.webpackChunkapp_api=self.webpackChunkapp_api||[]).push([["node_modules_nextcloud_dialogs_dist_chunks_PublicAuthPrompt-uFWxS9Cy_mjs"],{4471:(e,t,a)=>{a.r(t),a.d(t,{default:()=>v});var n=a(641),l=a(953),u=a(33),i=a(1777),s=a(474),r=a(6001),o=a(402),c=a(9455),m=a(2439),p=a(8040),d=a(240);function h(e){if(""===e.trim())return(0,m.t)("Names must not be empty.");if(e.startsWith("."))return(0,m.t)("Names must not start with a dot.");if(e.length>64)return(0,m.t)("Names may be at most 64 characters long.");try{return(0,p.KT)(e),""}catch(e){if(!(e instanceof p.di))throw e;switch(e.reason){case p.nF.Character:return(0,m.t)('"{char}" is not allowed inside a name.',{char:e.segment});case p.nF.ReservedName:return(0,m.t)('"{segment}" is a reserved name and not allowed.',{segment:e.segment});case p.nF.Extension:return e.segment.match(/\.[a-z]/i)?(0,m.t)('"{extension}" is not an allowed name.',{extension:e.segment}):(0,m.t)('Names must not end with "{extension}".',{extension:e.segment});default:return(0,m.t)("Invalid name.")}}}const b={key:0,class:"public-auth-prompt__text"},f=(0,n.pM)({__name:"PublicAuthPrompt",props:{nickname:{default:""},title:{default:(0,m.t)("Guest identification")},text:{default:""},notice:{default:""},submitLabel:{default:(0,m.t)("Submit name")},cancellable:{type:Boolean}},emits:["close"],setup(e,{emit:t}){const a=e,p=t,d=(0,n.rk)("input"),f=(0,s.c0)("public").build(),v=(0,l.KR)(a.nickname);(0,n.wB)(()=>a.nickname,()=>{v.value=a.nickname}),(0,n.wB)(v,e=>{const t=h(e);t||!d.value||g(t)});const _=(0,n.EW)(()=>{const e={label:(0,m.t)("Cancel"),variant:"tertiary",callback:()=>p("close")},t={label:a.submitLabel,type:"submit",variant:"primary"};return a.cancellable?[e,t]:[t]}),y=(0,n.EW)(()=>a.notice?a.notice:v.value?(0,m.t)("You are currently identified as {nickname}.",{nickname:v.value}):(0,m.t)("You are currently not identified."));function k(){const e=v.value.trim(),t=h(e);if(t)g(t);else if(""!==e)if(e.length<2)g((0,m.t)("Please enter a name with at least 2 characters."));else{try{(0,i.L$)(e)}catch(e){return m.l.error("Failed to set nickname",{error:e}),(0,m.s)((0,m.t)("Failed to set nickname.")),void d.value.focus()}f.setItem("public-auth-prompt-shown","true"),p("close",v.value)}else g((0,m.t)("You cannot leave the name empty."))}function g(e){d.value&&(d.value.setCustomValidity(e),d.value.reportValidity(),d.value.focus())}return(t,a)=>((0,n.uX)(),(0,n.Wv)((0,l.R1)(r.A),{buttons:_.value,class:"public-auth-prompt","data-cy-public-auth-prompt-dialog":"","is-form":"","no-close":"",name:e.title,onSubmit:k},{default:(0,n.k6)(()=>[e.text?((0,n.uX)(),(0,n.CE)("p",b,(0,u.v_)(e.text),1)):(0,n.Q3)("",!0),(0,n.bF)((0,l.R1)(o.A),{class:"public-auth-prompt__header",text:y.value,type:"info"},null,8,["text"]),(0,n.bF)((0,l.R1)(c.A),{ref:"input",modelValue:v.value,"onUpdate:modelValue":a[0]||(a[0]=e=>v.value=e),class:"public-auth-prompt__input","data-cy-public-auth-prompt-dialog-name":"",label:(0,l.R1)(m.t)("Name"),placeholder:(0,l.R1)(m.t)("Enter your name"),required:!e.cancellable,minlength:"2",maxlength:"64",name:"name"},null,8,["modelValue","label","placeholder","required"])]),_:1},8,["buttons","name"]))}}),v=(0,d._)(f,[["__scopeId","data-v-065a07c1"]])}}]);
//# sourceMappingURL=app_api-node_modules_nextcloud_dialogs_dist_chunks_PublicAuthPrompt-uFWxS9Cy_mjs.js.map?v=db1097e84e45c79df1b0