"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["views/dns/records/edit"],{1023:(e,t,s)=>{s.r(t),s.d(t,{default:()=>i});var a=s(285),l=s(583),n=s(286);const i=({onClose:e,isOpen:t=!0,closeOnFormSuccess:s=!0,closeUrl:i="..",form:o,...r})=>{const d=(0,l.useNavigate)(),[u,c]=(0,a.useState)(t),p=(0,a.useRef)(null),m=(0,a.useCallback)(((...t)=>{const s=e??(()=>d(i,{preventScrollReset:!0}));c(!1),p.current=setTimeout((()=>{s(...t),p.current=null}),300)}),[i,d,e]);(0,a.useEffect)((()=>()=>{p.current&&clearTimeout(p.current)}),[]),(0,a.useEffect)((()=>{t?p.current&&clearTimeout(p.current):c(t)}),[t]);const x=(0,a.useMemo)((()=>{if(o&&s){if((0,a.isValidElement)(o))return(0,a.cloneElement)(o,{onSuccess:(...e)=>{o.props.onSuccess?.(...e),m()}});if("object"==typeof o)return{...o,onSuccess:(...e)=>{o.onSuccess?.(...e),m()}}}return o}),[s,m,o]);return(0,a.jsx)(n.Drawer,{...r,form:x,onClose:m,isOpen:u})}},1881:(e,t,s)=>{s.r(t),s.d(t,{default:()=>f});var a=s(285),l=s(737),n=s(627),i=s(583),o=s(286),r=s(1023),d=s(906),u=s(89),c=s(1882),p=s(539);const m=u.Locale.getTranslate("smb.components.forms.dns-zone.record"),x=l.gql`
    mutation UpdateDnsTemplateRecord($input: UpdateDnsTemplateRecordInput!) {
        updateDnsTemplate(input: $input) {
            dnsRecordTemplate {
                id
                type
                ttl
                opt
                host
                displayVal
                displayHost
                domainName
            }
        }
    }
`,f=()=>{const e=(0,i.useParams)(),[t,l]=(0,a.useState)(),{data:u}=(0,i.useLoaderData)(),{dns:{template:{isEnabled:f}}}=u,[j,y]=(0,a.useState)((()=>{if(u.node){const{toFormValues:e}=(0,c.default)(u.os.isUnix,f)[u.node.type];return"function"==typeof e?e(u.node):u.node}const e=f?"A":"NS";return{...(0,c.default)(u.os.isUnix,f)[e].defaults,type:e}})),[g,{loading:h}]=(0,n.useMutation)(x,{refetchQueries:u.node?[]:[{query:s(849),awaitRefetchQueries:!0}]}),S=e.id?"edit-title":f?"add-title":"add-ns-title",{fields:F}=(0,a.useMemo)((()=>u?(0,c.default)(u?.os?.isUnix,f)[j.type]??{}:{}),[j.type,u,f]);return(0,a.jsx)(r.default,{"data-type":"dns-record-form",size:"sm",title:(0,a.jsx)(m,{content:S}),form:(0,a.jsx)(d.default,{mutation:g,applyButton:!1,values:j,onSubmit:e=>{const{__typename:t,...s}=e,{toSubmitValues:a}=(0,c.default)(u.os.isUnix,f)[s.type];return"function"==typeof a?a(s):s},onFieldChange:(e,t)=>{"type"===e&&(l(null),y({...(0,c.default)(u?.os?.isUnix,f)[t]?.defaults,type:t}))},onSuccess:()=>{(0,p.addToast)({intent:"success",message:(0,a.jsx)(m,{content:(e.id?"edit":"add")+"-success"})})},onError:e=>{l(e.general)},state:h?"submit":null,submitButton:{id:"btn-send"},children:(0,a.jsxs)(a.Fragment,{children:[t?(0,a.jsx)(o.StatusMessage,{intent:"danger",children:(0,a.jsx)("span",{dangerouslySetInnerHTML:{__html:t}})}):null,f?(0,a.jsx)(o.FormFieldSelect,{width:"90px","data-type":"dns-type",name:"type",label:(0,a.jsx)(m,{content:"type"}),children:u.dns.supportedRecordTypes.map((e=>(0,a.jsx)(o.SelectOption,{value:e,children:e},e)))}):null,(0,a.jsx)(o.FormField,{label:(0,a.jsx)(m,{content:"ttl"}),name:"ttl",children:({getName:e,getValue:t,setValue:s})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Input,{min:0,max:4294967295,type:"number",name:e(),value:t(),onChange:({target:e})=>s(+e.value)})," ",(0,a.jsx)(m,{content:"ttl-seconds"})]})}),F]})})})}},1883:(e,t,s)=>{s.r(t),s.d(t,{default:()=>u});var a=s(286),l=s(287),n=s.n(l),i=s(89),o=s(285);const r=i.Locale.getTranslate("smb.components.forms.dns-zone.record"),d=({name:e="domainName",label:t="domainName"})=>(0,o.jsx)(a.FormField,{label:(0,o.jsx)(r,{content:t}),name:e,children:({getName:e,getValue:t,setValue:s})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.Input,{name:e(),value:t(),onChange:({target:e})=>s(e.value)})," ",(0,o.jsx)(r,{content:"domainNamePostfix"})]})});d.propTypes={name:n().string,label:n().string};const u=d},1882:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var a=s(286),l=s(89),n=s(1883),i=s(285);const o=l.Locale.getTranslate("smb.components.forms.dns-zone.record"),r=l.Locale.getSection("smb.components.forms.dns-zone.record"),d=(e,t)=>({NS:{defaults:{},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[t?(0,i.jsx)(n.default,{},"ns_domain_name"):null,(0,i.jsx)(a.FormFieldText,{required:!0,name:"displayVal",label:(0,i.jsx)(o,{content:"nameServer"}),inputProps:{suffix:".",size:"lg"}},"ns_ext_host")]},A:{defaults:{},fields:[(0,i.jsx)(n.default,{},"a_domain_name"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"ipAddress"}),description:(0,i.jsx)(o,{content:"ipAddressDescriptionExt"})},"A_ip")]},AAAA:{defaults:{},fields:[(0,i.jsx)(n.default,{},"aaaa_int_host"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"ipAddressV6"}),description:(0,i.jsx)(o,{content:"ipAddressV6DescriptionExt"})},"AAAA_ip")]},CNAME:{defaults:{},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[(0,i.jsx)(n.default,{},"cname_int_host"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"canonicalName"})},"CNAME_canonical")]},MX:{defaults:{opt:"0"},toFormValues:({displayVal:e,...t})=>({displayVal:e.replace(/.$/,""),...t}),toSubmitValues:e=>e,fields:[(0,i.jsx)(n.default,{label:"mailDomain"},"mx_displayHost"),(0,i.jsx)(a.FormFieldText,{size:"fill",name:"displayVal",required:!0,label:(0,i.jsx)(o,{content:"mxServer"})},"mx_displayVal"),(0,i.jsxs)(a.FormFieldSelect,{name:"opt",label:(0,i.jsx)(o,{content:"mxServerPriority"}),children:[(0,i.jsx)(a.SelectOption,{value:"0",children:r.lmsg("priorityHigh",{priority:0})}),Array.from({length:9}).map(((e,t)=>{const s=0===t?1:5*t;return(0,i.jsx)(a.SelectOption,{value:s.toString(),children:s.toString()},s)})),(0,i.jsx)(a.SelectOption,{value:"50",children:r.lmsg("priorityLow",{priority:50})})]},"mx_opt")]},PTR:{defaults:{},toFormValues:({displayHost:e,opt:t,displayVal:s,...a})=>({...a,displayVal:s.replace(/\.?<domain>./,""),ipMask:{ip:e,mask:t}}),toSubmitValues:({ipMask:e,...t})=>({...t,displayHost:e?.ip,opt:e?.mask}),fields:[(0,i.jsx)(a.FormField,{required:!0,label:(0,i.jsx)(o,{content:"ipAddress"}),name:"ipMask",description:(0,i.jsx)(o,{content:"ipAddressWithMaskDescriptionExt"}),children:({getId:e,getName:t,getValue:s,setValue:l})=>{const{ip:n,mask:o}=s()??{};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.Input,{id:`${e()}-ip`,size:"lg",name:`${t()}[ip]`,value:n,onChange:({target:e})=>l({ip:e.value,mask:o})})," / ",(0,i.jsx)(a.Input,{id:`${e()}-mask`,size:"sm",name:`${t()}[mask]`,value:o,onChange:({target:e})=>l({ip:n,mask:e.value})})]})}},"prt_ip"),(0,i.jsx)(n.default,{name:"displayVal"},"ptr_int_host")]},TXT:{defaults:e?{}:{value:"+all",spfSyntax:"spf"},toFormValues:t=>{if(e)return t;const{displayVal:s,...a}=t,l=s.startsWith("v=spf1 ")?"spf":"multiline";return{...a,spfSyntax:l,value:"spf"===l?s.slice(7):"",multilineValue:"spf"!==l?s:""}},toSubmitValues:t=>{if(e)return t;const{spfSyntax:s,value:a,multilineValue:l,displayHost:n,...i}=t;return{...i,displayHost:n,displayVal:"spf"===s?`v=spf1 ${a}`:l}},fields:[(0,i.jsx)(n.default,{},"txt_int_host"),e?(0,i.jsx)(a.FormFieldText,{size:"fill",name:"displayVal",label:(0,i.jsx)(o,{content:"txtRecord"})},"TXT_ext_host"):(0,i.jsx)(a.FormFieldRadioButtons,{className:"dns-spf-radiobutton",name:"spfSyntax",label:(0,i.jsx)(o,{content:"txtRecordString"}),options:[{value:"spf",className:"mx-sfp",label:(0,i.jsx)(o,{content:"txtSpfSyntax"}),indentFields:[(0,i.jsx)(a.Input,{size:null,disabled:!0,value:"v=spf1",style:{width:"60px"}},"spf1"),(0,i.jsx)(a.FormFieldText,{name:"value",label:null},"txt_value")]},{value:"multiline",label:"",indentFields:[(0,i.jsx)(a.FormFieldText,{name:"multilineValue",multiline:!0,label:null},"txt_multiline_value")]}]},"txt_spf_syntax")]},SRV:{defaults:e?{priority:"5",weight:"25",displayVal:"."}:{priority:"5",weight:"10",displayVal:"."},toFormValues:({domainName:e,opt:t,...s})=>{const[a,l,n]=t.split(" "),{serviceName:i,protocol:o,domainName:r}=e.match(/_(?<serviceName>[a-zA-Z0-9-]+)\._(?<protocol>[a-zA-Z0-9-]+)(\.(?<domainName>[a-zA-Z0-9-]+))?$/)?.groups||{};return{...s,priority:a,weight:l,targetPort:n,serviceName:i,protocol:o,domainName:r}},toSubmitValues:({protocol:e,domainName:t,serviceName:s,priority:a,weight:l,targetPort:n,...i})=>{t=t?`.${t}`:"";return{...i,domainName:s&&e?`_${s}._${e}${t}`:void 0,opt:[a,l,n].join(" "),serviceName:s,protocol:e}},fields:[(0,i.jsx)(a.FormFieldText,{name:"serviceName",required:!0,label:(0,i.jsx)(o,{content:"serviceName"}),description:(0,i.jsx)(o,{content:"serviceNameDescription"})},"SRV_service_name"),(0,i.jsx)(a.FormFieldText,{name:"protocol",required:!0,label:(0,i.jsx)(o,{content:"protocol"}),description:(0,i.jsx)(o,{content:"protocolNameDescription"})},"SRV_protocol"),e?(0,i.jsx)(n.default,{name:"domainName"},"txt_int_host"):null,(0,i.jsx)(a.FormFieldText,{required:!0,name:"displayVal",label:(0,i.jsx)(o,{content:"targetHost"}),description:(0,i.jsx)(o,{content:"targetHostDescription"})},"SRV_target_host"),(0,i.jsx)(a.FormFieldText,{required:!0,name:"targetPort",inputProps:{type:"number",max:65535,min:0},label:(0,i.jsx)(o,{content:"targetPort"})},"SRV_target_port"),(0,i.jsx)(a.FormFieldSelect,{name:"priority",label:(0,i.jsx)(o,{content:"priority"}),children:Array.from({length:11}).map(((e,t)=>{const s=5*t;let l;switch(s){case 0:l=r.lmsg("priorityHigh",{priority:s});break;case 50:l=r.lmsg("priorityLow",{priority:s});break;default:l=s.toString()}return(0,i.jsx)(a.SelectOption,{value:s.toString(),children:l},s)}))},"SRV_priority"),(0,i.jsx)(a.FormFieldSelect,{name:"weight",label:(0,i.jsx)(o,{content:"srvWeight"}),children:Array.from({length:e?11:10}).map(((t,s)=>{const l=e?5*Math.abs(s-10):10*(s+1);let n;if(e)switch(l){case 0:n=r.lmsg("weightLow",{weight:l});break;case 50:n=r.lmsg("weightHigh",{weight:l});break;default:n=l.toString()}else n=l.toString();return(0,i.jsx)(a.SelectOption,{value:l.toString(),children:n},l)}))},"SRV_weight")]},CAA:{defaults:{opt:"issue"},fields:[(0,i.jsx)(n.default,{},"caa_int_host"),(0,i.jsxs)(a.FormFieldSelect,{name:"opt",label:(0,i.jsx)(o,{content:"caaTag"}),children:[(0,i.jsx)(a.SelectOption,{value:"issue",children:"issue"}),(0,i.jsx)(a.SelectOption,{value:"issuewild",children:"issuewild"}),(0,i.jsx)(a.SelectOption,{value:"iodef",children:"iodef"})]},"CAA_tag"),(0,i.jsx)(a.FormFieldText,{name:"displayVal",label:(0,i.jsx)(o,{content:"caaRecord"}),size:"fill"},"CAA_value")]}})},1880:(e,t,s)=>{s.r(t),s.d(t,{default:()=>a.default});var a=s(1881)}}]);
//# sourceMappingURL=edit.js.map?4738077162e872f86835