import{a1 as n,d as t,T as _,p as D,K as d,e as u}from"./RootComponent-D2L6IHol.js";import{O as r,d as o}from"./index-C5-RKZEw.js";const C=["ViewDHCPServerObjectsService","ViewCloudNetworksInService","Service_ViewServerObjectsDNSServer","Service_ViewServerObjectsDHCPServer","Service_ViewServerObjectsApplianceZones","Service_ViewServerObjectsApplianceScopes","Service_ViewSuperscopesOnDHCPServer","Service_CreateXHACluster","Service_InitializeDNSServer","Service_InitializeDHCPServer","EditServiceProperties","Service_EditDNSServerProperties","Service_EditDHCPServerProperties","Service_EditApplianceProperties","Service_EditApplianceServiceProperties",null,"Service_EditBINDServerOptions","Service_ReconnectToDNSServer","Service_EnableDNSServer","Service_DisableDNSServer","Service_MoveToOrganizationDNSServer",null,"Service_DownloadServerLogFiles","Service_CacheManagement","Service_ServerInfo",null,"Service_EditDHCPServerConfiguration","Service_EditDHCPServerOptions","Service_EditCustomDHCPServerOptions","Service_EditDHCPv6ServerOptions","Service_EditCustomDHCPv6ServerOptions","Service_ManageDHCPPolicyForServer","Service_ReconnectToDHCPServer","Service_EditXHACluster","Service_RepairXHACluster","Service_TriggerXHAFailover","Service_EnableDHCPServer","Service_DisableDHCPServer","Service_ReconcileDHCPServer","Service_MoveToOrganizationDHCPServer","Service_FailoverManagement","Service_FailoverReplicateServer","Service_ViewClientClasses",null,"Service_EnableDisableApplianceServices","Service_ApplianceDNSResolverConfiguration","Service_EditApplianceAnycast","Service_ApplianceNTPConfiguration","Service_ApplianceSNMPConfiguration","Service_ApplianceSyslog","Service_ApplianceNetworkConfiguration","Service_MoveToOrganizationAppliance",null,"Copy","Export",null,"Service_ReloadDNSService","Service_RestartDHCPServer","SyncService",null,"Service_RestartAppliance","Service_ShutdownAppliance",null,"RemoveService","Service_RemoveApplianceDNSService","Service_RemoveApplianceDHCPService","Service_BreakXHACluster",null,"Service_ManageDNSServerObjectAccess","Service_ManageDNSServerObjectAccessMultiple","Service_ManageDHCPServerObjectAccess","Service_ManageDHCPServerObjectAccessMultiple","Service_ApplianceSupportInfo","Service_ViewDNSServerHistory","Service_ViewDHCPServerHistory","Service_ViewApplianceHistory"],p=a=>e=>a===r.DNSServer?e.dnsServer:a===r.DHCPServer?e.dhcpServer:{ref:e.applianceRef},A=a=>{const e=a.metadata.objType;t([r.DNSServer,r.DHCPServer,r.Appliance].includes(e));const c=a.metadata.disabledCallback;return e===r.Appliance?async(i,S,s)=>!i.every(v=>v.applianceRef)||(await c?.(i.map(v=>u.getAppliance(v.applianceRef))??[],S,s)??!1):(i,S,s)=>{if(i.some(l=>l.applianceRef))return!0;const v=i.map(p(e));return v.every(o)?c?c(v,S,s):!1:!0}},H=a=>{const{objType:e,hasAccess:c,access:i}=a.metadata;return r.Appliance,c?{hasAccess:(S,s)=>{t([r.DNSServer,r.DHCPServer].includes(e));const v=S.map(p(e));return v.every(o)?c(v,s):!1},access:void 0}:i?{hasAccess:S=>{t([r.DNSServer,r.DHCPServer,r.Appliance].includes(e));const s=S.map(p(e));return s.every(o)?d.hasAccess(i,s.map(v=>v.ref)):!1},access:void 0}:{}};class f extends _{doRun=async e=>{const c=n.getTask(this.info.id.replace("Service_",""));let i=e.objects.map(p(c.metadata.objType));return c.metadata.objType===r.Appliance&&(i=await Promise.all(i.map(({ref:S})=>D.getObj(S)))),c._getTaskInstance().doRun({...e,objects:i})}}const P=a=>["Export","Copy","InitializeAppliance","ViewServerObjectsApplianceDNSServer","ViewServerObjectsApplianceDHCPServer","SyncDNSServer","SyncDHCPServer","RemoveDNSService","RemoveDHCPService","RemoveAppliance"].includes(a),m=()=>{n.getActionMenuTaskIDs(r.Service).forEach(a=>t()),[r.DNSServer,r.DHCPServer,r.Appliance].forEach(a=>{n.getActionMenuTaskIDs(a).forEach(e=>{if(e&&!P(e)){const c=n.getTask(e),i=`Service_${e}`;n.tasks.find(S=>S.id===i)||n.registerTask(f,{...c.metadata,id:i,objType:r.Service,disabledCallback:A(c),...H(c)})}})}),n.setActionMenuTaskIDs({[r.Service]:C})};export{m as addServiceTaskHacks};
