"use strict";(self.webpackChunkdotcms_ui=self.webpackChunkdotcms_ui||[]).push([[4976],{4976:(L,d,o)=>{o.r(d),o.d(d,{DotContentTypeCopyDialogComponent:()=>N});var t=o(86353),n=o(24006),r=o(38131),m=o(56498),c=o(21086),p=o(36053);const f=/^[a-zA-Z0-9_]*$/,h={alphaNumericError:"contenttypes.form.field.validation.alphanumeric"};class g{static alphaNumeric(s){return f.test(s.value)?null:h}}var v=o(24850),u=o(51740),y=o(94632),C=o(23106),b=o(61873),D=o(76925),A=o(43740),T=o(36895),Z=o(48778);const F=["dot-site-selector-field"],x=function(a){return[a]};let N=(()=>{class a{constructor(e,i,l){this.fb=e,this.dotMessageService=i,this.cd=l,this.inputNameWithType="",this.dialogTitle="",this.isVisibleDialog=!1,this.isSaving$=new m.y,this.cancelBtn=new t.vpe,this.validFormFields=new t.vpe,this.initForm()}get variableControl(){return this.form.get("variable")}get nameControl(){return this.form.get("name")}openDialog(e){this.inputNameWithType=this.getNameFieldLabel(e.baseType),this.dialogTitle=e.title,this.isVisibleDialog=!0,e.data&&this.patchForm(e.data)}ngOnInit(){this.setDialogConfig()}submitForm(){this.form.valid&&this.validFormFields.emit(this.form.value)}closeDialog(){this.cancelBtn.emit(!0),this.initForm(),this.isVisibleDialog=!1}ngAfterViewChecked(){this.cd.detectChanges()}setDialogConfig(){const e=(0,c.of)({accept:{action:()=>{this.submitForm()},label:this.dotMessageService.get("contenttypes.content.copy"),disabled:!0},cancel:{action:()=>{this.closeDialog()},label:this.dotMessageService.get("contenttypes.content.add_to_bundle.form.cancel")}});this.dialogActions$=(0,p.aj)([e,this.form.valueChanges]).pipe((0,v.U)(([i])=>(i.accept.disabled=!this.form.valid,i)))}initForm(){this.form=this.fb.group({name:["",[n.kI.required]],variable:["",[g.alphaNumeric,n.kI.maxLength(255)]],folder:[""],host:[""],icon:[""]})}getNameFieldLabel(e){return`${this.dotMessageService.get(`contenttypes.content.${e.toLowerCase()}`)} ${this.dotMessageService.get("contenttypes.form.name")}`}patchForm(e){this.form.patchValue(e)}}return a.\u0275fac=function(e){return new(e||a)(t.Y36(n.QS),t.Y36(r.l),t.Y36(t.sBO))},a.\u0275cmp=t.Xpm({type:a,selectors:[["dot-content-type-copy-dialog"]],viewQuery:function(e,i){if(1&e&&t.Gf(F,5),2&e){let l;t.iGM(l=t.CRH())&&(i.siteSelector=l.first)}},inputs:{isSaving$:"isSaving$"},outputs:{cancelBtn:"cancelBtn",validFormFields:"validFormFields"},decls:28,vars:35,consts:[["width","600px",1,"no-overflow",3,"actions","header","isSaving","visible","hide"],["novalidate","",1,"p-fluid",3,"formGroup"],["formEl","ngForm"],[1,"field","form__group--validation"],["for","content-type-form-name"],["dotAutofocus","","formControlName","name","id","content-type-form-name","name","name","pInputText","","type","text",3,"tabindex"],[3,"field","message"],["for","content-type-form-variable-name"],["formControlName","variable","id","content-type-form-variable-name","name","variable","pInputText","","type","text",3,"tabindex","placeholder"],[3,"field"],[1,"field"],["for","content-type-form-icon"],["formControlName","icon","id","content-type-form-icon",3,"tabindex"],["for","content-type-form-host"],["formControlName","host","id","content-type-form-host",3,"system","tabindex"]],template:function(e,i){1&e&&(t.TgZ(0,"dot-dialog",0),t.NdJ("hide",function(){return i.closeDialog()}),t.ALo(1,"async"),t.ALo(2,"async"),t.TgZ(3,"form",1,2)(5,"div",3)(6,"label",4),t._uU(7),t.qZA(),t._UZ(8,"input",5)(9,"dot-field-validation-message",6),t.ALo(10,"dm"),t.qZA(),t.TgZ(11,"div",3)(12,"label",7),t._uU(13),t.ALo(14,"dm"),t.qZA(),t._UZ(15,"input",8),t.ALo(16,"dm"),t._UZ(17,"dot-field-validation-message",9),t.qZA(),t.TgZ(18,"div",10)(19,"label",11),t._uU(20),t.ALo(21,"dm"),t.qZA(),t._UZ(22,"dot-md-icon-selector",12),t.qZA(),t.TgZ(23,"div",10)(24,"label",13),t._uU(25),t.ALo(26,"dm"),t.qZA(),t._UZ(27,"dot-site-selector-field",14),t.qZA()()()),2&e&&(t.Q6J("actions",t.lcZ(1,18,i.dialogActions$))("header",i.dialogTitle)("isSaving",t.lcZ(2,20,i.isSaving$))("visible",i.isVisibleDialog),t.xp6(3),t.Q6J("formGroup",i.form),t.xp6(4),t.hij("",i.inputNameWithType," *"),t.xp6(1),t.Q6J("tabindex",1),t.xp6(1),t.Q6J("field",i.nameControl)("message",t.xi3(10,22,"dot.common.message.field.required",t.VKq(33,x,i.inputNameWithType))),t.xp6(4),t.hij("",t.lcZ(14,25,"contenttypes.form.label.variable_name")," "),t.xp6(2),t.s9C("placeholder",t.lcZ(16,27,"contentType.form.variable.placeholder")),t.Q6J("tabindex",2),t.xp6(2),t.Q6J("field",i.variableControl),t.xp6(3),t.Oqu(t.lcZ(21,29,"contenttypes.form.label.icon")),t.xp6(2),t.Q6J("tabindex",3),t.xp6(3),t.Oqu(t.lcZ(26,31,"contenttypes.form.field.host_folder.label")),t.xp6(2),t.Q6J("system",!0)("tabindex",4))},dependencies:[n._Y,n.Fj,n.JJ,n.JL,n.sg,n.u,u.o,y.g,C.Q,b.b,D.o,A.h,T.Ov,Z.t],encapsulation:2,changeDetection:0}),a})()}}]);