Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Astronomical object

From the Star Citizen Wiki, the fidelity™ encyclopedia
Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Astronomical object/doc. Changes can be proposed in the talk page.

-- Code bundled using https://github.com/ari-party/scribunto-bundler
-- Find module source code at https://github.com/ari-party/sct-module-astronomical-object

--- Global dictionary for `mw.smw.set`
---@type table<string, any>
local smwData = {}
local _bundler_load, _bundler_register = (function(superRequire)
    local loadingPlaceholder = { [{}] = true }

    local register
    local modules = {}

    local load
    local loaded = {}

    ---@param name string
    ---@param body function
    register = function(name, body)
        if not modules[name] then
            modules[name] = body
        end
    end

    ---@param name string
    ---@return any
    load = function(name)
        local loadedModule = loaded[name]

        if loadedModule then
            if loadedModule == loadingPlaceholder then
                return nil
            end
        else
            if not modules[name] then
                if not superRequire then
                    local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name)
                    error('Tried to require ' .. identifier .. ', but no such module has been registered')
                else
                    return superRequire(name)
                end
            end

            loaded[name] = loadingPlaceholder
            loadedModule = modules[name]()
            loaded[name] = loadedModule
        end

        return loadedModule
    end

    return load, register
end)(require)

_bundler_register('bundler_main', function()
    local AstronomicalObject = {}

local Starmap = require( 'Module:Starmap_old' )
local Infobox = require( 'Module:InfoboxNeue' )
local config = mw.loadJsonData( 'Module:Astronomical object/config.json' )
local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local getMetadata = _bundler_load("qqIivEkpEzI-S8jKgY-PO")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")
local stringUtil = _bundler_load("LqcyuoqcgR16kBloizIfu")

local characteristicsSection = _bundler_load("aMzhP4yRWn_DL-gyVh5ma")
local detailsSection = _bundler_load("0ZBPzWtXUhIfhmylujQtS")
local featuresSection = _bundler_load("laZXalvuFwB-WExC9ra2U")
local footerSection = _bundler_load("o_kAUNNxCc7NiBSIG0A61")
local jumppointSection = _bundler_load("pCUqUMXDjO00k_s6kun2g")
local sensorsSection = _bundler_load("GJAfegS6nWBdSQk4HCMhR")

---@alias args { affiliation: string?, classification: string?, code: string?, designation: string?, founded: string?, founder: string?, galactapedia: string?, habitable: string?, image: string?, landingzones: string?, location: string?, name: string?, population: string?, satellites: string?, sensordanger: string?, sensoreconomy: string?, sensorpopulation: string?, services: string?, shops: string?, starmap: string?, tunneldirection: string?, tunnelentry: string?, tunnelexit: string?, tunnelsize: string?, type: string?, equatorialradius: string?, gravity: string?, atmosphere: string?, atmosphericpressure: string?, siderealday: string?, axialtilt: string?, density: string?, tidallylocked: string?, orbitalperiod: string?, orbitalspeed: string?, orbitalradius: string?, orbitaleccentricity: string?, aphelion: string?, perihelion: string?, inclination: string?, senator: string?, siderealrotation: string? }

---@param args args
---@param object table?
---@return string?
local function infoboxSubtitle( args, object )
    if args.location then return args.location end
    if not object then return nil end
    return stringUtil.clean( Starmap.pathTo( object ) )
end

---@param infobox any
local function renderError( infobox )
    return infobox:renderInfobox( infobox:renderMessage( {
        title = t( 'error_title' ),
        desc = t( 'error_invalid_args_desc' )
    } ) )
end

---@param frame table https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Frame_object
function AstronomicalObject.main( frame )
    ---@type args
    local args = frame:getParent().args

    local infobox = Infobox:new( { placeholderImage = config.placeholder_image } )

    local pageTitle = mw.title.getCurrentTitle().text
    local searchParameter = args.code or args.name or pageTitle

    if not searchParameter then return renderError( infobox ) end

    -- Find the astronomical object
    local object = Starmap.findStructure( 'object', searchParameter )
    if not object then return renderError( infobox ) end

    --- Infobox

    local title = stringUtil.clean(
        args.name or
        object.name or
        args.designation or
        object.designation or
        pageTitle or
        'Unknown'
    )

    local fullTitle = title
    if (args.name or object.name) and (args.designation or object.designation) ~= (args.name or object.name) then
        fullTitle = fullTitle ..
            ' : ' .. stringUtil.clean( args.designation or object.designation )
    end

    infobox:renderImage( args.image )
    infobox:renderHeader( {
        title = fullTitle,
        subtitle = infoboxSubtitle( args, object )
    } )

    local type, translatedType, classification = detailsSection( infobox, args, object )

    infobox:renderSection( {
        content = {
            infobox:renderItem( {
                label = t( 'lbl_services' ),
                data = args.services
            } ),
            infobox:renderItem( {
                label = t( 'lbl_shops' ),
                data = args.shops
            } )
        },
        col = 2
    } )

    jumppointSection( infobox, args, object )
    featuresSection( infobox, args, object )
    sensorsSection( infobox, args, object )
    characteristicsSection( infobox, args, object )

    infobox:renderSection( {
        title = t( 'lbl_history' ),
        content = {
            infobox:renderItem( {
                label = t( 'lbl_founded' ),
                data = args.founded,
            } ),
            infobox:renderItem( {
                label = t( 'lbl_founder' ),
                data = args.founder,
            } )
        },
        col = 2
    } )

    footerSection( infobox, args, object )

    ---

    local renderedInfobox = infobox:renderInfobox( nil, title )
    local categories, shortDesc = getMetadata(
        object,
        type,
        translatedType,
        classification
    )

    frame:callParserFunction(
        'SHORTDESC',
        stringUtil.clean( stringUtil.removeParentheses( shortDesc ) )
    )

    return renderedInfobox .. categories
end

return AstronomicalObject

end)

_bundler_register('Z5x8snU4sjkD3qLJGPy1D', function()
    local TNT = require( 'Module:Translate' ):new()
local config = mw.loadJsonData( 'Module:Astronomical object/config.json' )

local lang
if config.module_lang then
    lang = mw.getLanguage( config.module_lang )
else
    lang = mw.getContentLanguage()
end
local langCode = lang:getCode()

--- Wrapper function for Module:Translate.translate
---@param key string The translation key
---@param addSuffix? boolean Adds a language suffix if config.smw_multilingual_text is true
---@return string value If the key was not found in the .tab page, the key is returned
return function ( key, addSuffix, ... )
    return TNT:translate( 'Module:Astronomical object/i18n.json', config, key, addSuffix, { ... } ) or key
end

end)

_bundler_register('qqIivEkpEzI-S8jKgY-PO', function()
    local config = mw.loadJsonData( 'Module:Astronomical object/config.json' )
local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local linksUtil = _bundler_load("IhHmleEzICJDWYrwBq1XT")
local stringUtil = _bundler_load("LqcyuoqcgR16kBloizIfu")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")
local pluralize = _bundler_load("0_S--UpdcwCozsaCBXH4g")

---@param object table?
---@param type string?
---@param translatedType string?
---@param classification string?
---@return string categories
---@return string shortDesc
return function ( object, type, translatedType, classification )
    local parent = (object or {}).parent

    --- SMW
    smwData[ t( 'lbl_starmap_id' ) ] = tableUtil.safeAccess( object, 'id' )
    smwData[ t( 'lbl_starmap_code' ) ] = tableUtil.safeAccess( object, 'code' )

    mw.smw.set( smwData )

    --- Categories
    local categories = { 'Astronomical objects', 'Locations' } -- Defaults

    if classification then table.insert( categories, pluralize( classification ) ) end

    local systemName = tableUtil.safeAccess( object, 'star_system', 'name' )
    if systemName then
        table.insert(
            categories,
            stringUtil.clean( stringUtil.removeParentheses( systemName ) ) .. ' system'
        )
    end

    if type then table.insert( categories, pluralize( t( 'val_type_' .. string.lower( type ) ) ) ) end

    local shortDesc = ''
    if translatedType and object and tableUtil.safeAccess( object, 'star_system', 'name' ) and parent then
        -- Has a parent that isn't a star
        if parent.type ~= 'STAR' then
            if tableUtil.contains( config.planetary_types, object.type ) then -- Planetary based
                shortDesc = string.format(
                    t( 'lbl_shortdesc_on' ),
                    translatedType,
                    parent.name or parent.designation or t( 'val_unknown' ),
                    object.star_system.name
                )
            else -- Space station or something
                shortDesc = string.format(
                    t( 'lbl_shortdesc_orbiting' ),
                    translatedType,
                    parent.name or parent.designation or t( 'val_unknown' ),
                    object.star_system.name
                )
            end
        else -- Planet or asteroid belt or of sorts (decendant of the system's star)
            shortDesc = string.format(
                t( 'lbl_shortdesc_in' ),
                translatedType,
                object.star_system.name
            )
        end
    end

    return linksUtil.convertCategories( categories ), shortDesc
end

end)

_bundler_register('IhHmleEzICJDWYrwBq1XT', function()
    local LinksUtil = {}

---@param categories table<string> Plain text categories (Stanton, instead of Category:Stanton)
---@return string categories Categories as internal links)
function LinksUtil.convertCategories( categories )
    local mapped = {}
    for _, category in pairs( categories ) do
        if category ~= nil then
            if string.sub( category, 1, 2 ) ~= '[[' then
                category = string.format( '[[Category:%s]]', category )
            end
            table.insert( mapped, category )
        end
    end
    return table.concat( mapped )
end

---@param links table<string> Plain text links (Stanton, instead of [[Stanton]])
---@return table<string> links Now in [[link]] format
function LinksUtil.convertLinks( links )
    local converted = {}
    for _, link in ipairs( links ) do
        table.insert( converted, string.format( '[[%s]]', link ) )
    end
    return converted
end

return LinksUtil

end)

_bundler_register('LqcyuoqcgR16kBloizIfu', function()
    local Common = require( 'Module:Common' )

local StringUtil = {
    removeParentheses = Common.removeParentheses,
    split = Common.split
}

--- Replace obnoxious characters
---@param str string Input string
---@return string
function StringUtil.clean( str )
    local apostrophe = string.gsub( str, '’', '\'' )
    return apostrophe
end

--- Lower first character
---@param str string Input string
---@return string
function StringUtil.lowerFirst( str )
    return string.lower( string.sub( str, 1, 1 ) ) .. string.sub( str, 2 )
end

return StringUtil

end)

_bundler_register('vrceqVUhYydyNif7ebocA', function()
    local Common = require( 'Module:Common' )

local TableUtil = {
    safeAccess = Common.safeAccess
}

--- Filter table
---@param array table
---@param key string
---@param value any
---@param zero any Value to return if zero matches
function TableUtil.filter( array, key, value, zero )
    local matches = {}
    if array then
        for _, item in ipairs( array ) do
            if item[ key ] == value then
                table.insert( matches, item )
            end
        end
    end
    if zero and #matches == 0 then
        return zero
    else
        return matches
    end
end

--- Value is in table
---@param array table<any>
---@param target any
---@return boolean
function TableUtil.contains( array, target )
    for _, value in ipairs( array ) do
        if value == target then
            return true
        end
    end

    return false
end

return TableUtil

end)

_bundler_register('0_S--UpdcwCozsaCBXH4g', function()
    local mPluralize = require( 'Module:Pluralize' )

---@param str string
---@return string
return function ( str )
    return mPluralize.pluralize( { args = { str } } )
end

end)

_bundler_register('aMzhP4yRWn_DL-gyVh5ma', function()
    local common = require( 'Module:Common' )
local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")

---@param args args
---@param object table?
---@return string?
local function getAxialTilt( args, object )
    if args.axialtilt then return args.axialtilt end

    local axialTilt = tableUtil.safeAccess( object, 'axial_tilt' )
    if not axialTilt or axialTilt == 0 then return nil end

    return string.format( '%.3f', common.formatNum( axialTilt ) ) .. '°'
end

---@param args args
---@param object table?
---@return string?
local function getOrbitalPeriod( args, object )
    if args.orbitalperiod then return args.orbitalperiod end

    local orbitalPeriod = tableUtil.safeAccess( object, 'orbit_period' )
    if not orbitalPeriod or orbitalPeriod <= 0 then return nil end

    return string.format( '%s', common.formatNum( orbitalPeriod ) ) .. ' SED'
end

---@param infobox any
---@param args args
---@param object table?
return function ( infobox, args, object )
    --- Atmosphere
    smwData[ t( 'lbl_atmosphere' ) ] = args.atmosphere
    --- Atmospheric pressure
    smwData[ t( 'lbl_atmospheric_pressure' ) ] = args.atmosphericpressure
    --- Density
    smwData[ t( 'lbl_density' ) ] = args.density

    infobox:renderSection( {
        title = t( 'lbl_atmospheric_properties' ),
        content = {
            infobox:renderItem( {
                label = t( 'lbl_atmosphere' ),
                data = args.atmosphere
            } ),
            infobox:renderItem( {
                label = t( 'lbl_atmospheric_pressure' ),
                data = args.atmosphericpressure
            } ),

            infobox:renderItem( {
                label = t( 'lbl_density' ),
                data = args.density
            } ),
        },
        col = 2
    } )

    --- Equatorial radius
    smwData[ t( 'lbl_equatorial_radius' ) ] = args.equatorialradius
    --- Sidereal rotation
    smwData[ t( 'lbl_sidereal_rotation' ) ] = args.siderealrotation
    --- Sidereal day
    smwData[ t( 'lbl_sidereal_day' ) ] = args.siderealday
    --- Axial tilt
    local axialTilt = getAxialTilt( args, object )
    smwData[ t( 'lbl_axial_tilt' ) ] = axialTilt
    --- Tidally locked
    smwData[ t( 'lbl_tidally_locked' ) ] = args.tidallylocked

    infobox:renderSection( {
        title = t( 'lbl_physical_characteristics' ),
        content = {
            infobox:renderItem( {
                label = t( 'lbl_equatorial_radius' ),
                data = args.equatorialradius
            } ),
            infobox:renderItem( {
                label = t( 'lbl_gravity' ),
                data = args.gravity
            } ),

            infobox:renderItem( {
                label = t( 'lbl_sidereal_rotation' ),
                data = args.siderealrotation
            } ),
            infobox:renderItem( {
                label = t( 'lbl_sidereal_day' ),
                data = args.siderealday
            } ),

            infobox:renderItem( {
                label = t( 'lbl_axial_tilt' ),
                data = axialTilt
            } ),
            infobox:renderItem( {
                label = t( 'lbl_tidally_locked' ),
                data = args.tidallylocked
            } ),
        },
        col = 2
    } )

    --- Orbital period
    local orbitalPeriod = getOrbitalPeriod( args, object )
    smwData[ t( 'lbl_orbital_period' ) ] = orbitalPeriod
    --- Orbital speed
    smwData[ t( 'lbl_orbital_speed' ) ] = args.orbitalspeed
    --- Orbital radius
    smwData[ t( 'lbl_orbital_radius' ) ] = args.orbitalradius
    --- Orbital eccentricity
    smwData[ t( 'lbl_orbital_eccentricity' ) ] = args.orbitaleccentricity
    --- Aphelion
    smwData[ t( 'lbl_aphelion' ) ] = args.aphelion
    --- Perihelion
    smwData[ t( 'lbl_perihelion' ) ] = args.perihelion
    --- Inclination
    smwData[ t( 'lbl_inclination' ) ] = args.inclination

    infobox:renderSection( {
        title = t( 'lbl_orbital_parameters' ),
        content = {
            infobox:renderItem( {
                label = t( 'lbl_orbital_period' ),
                data = orbitalPeriod
            } ),
            infobox:renderItem( {
                label = t( 'lbl_orbital_speed' ),
                data = args.orbitalspeed
            } ),

            infobox:renderItem( {
                label = t( 'lbl_orbital_radius' ),
                data = args.orbitalradius
            } ),
            infobox:renderItem( {
                label = t( 'lbl_orbital_eccentricity' ),
                data = args.orbitaleccentricity
            } ),

            infobox:renderItem( {
                label = t( 'lbl_aphelion' ),
                data = args.aphelion
            } ),
            infobox:renderItem( {
                label = t( 'lbl_perihelion' ),
                data = args.perihelion
            } ),

            infobox:renderItem( {
                label = t( 'lbl_inclination' ),
                data = args.inclination
            } )
        },
        col = 2
    } )
end

end)

_bundler_register('0ZBPzWtXUhIfhmylujQtS', function()
    local Yesno = require( 'Module:Yesno' )
local config = mw.loadJsonData( 'Module:Astronomical object/config.json' )
local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local linksUtil = _bundler_load("IhHmleEzICJDWYrwBq1XT")
local stringUtil = _bundler_load("LqcyuoqcgR16kBloizIfu")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")

---@param args args
---@param object table?
---@return string? type
---@return string? classification
local function getType( args, object )
    local plainType = args.type
    if not plainType and object then plainType = object.type end

    local translatedType = nil
    if plainType then translatedType = t( 'val_type_' .. string.lower( plainType ) ) end

    return plainType, translatedType
end

---@param args args
---@param object table?
---@param type string?
---@return string?
local function getClassification( args, object, type )
    if args.classification then return args.classification end
    if not object then return nil end

    local possibleClassification = tableUtil.safeAccess( object, 'subtype', 'name' )
    if not possibleClassification then return nil end
    if possibleClassification == type then return nil end

    return config.subtype_rename[ possibleClassification ] or possibleClassification
end

---@param args args
---@param object table?
---@return string?
local function getAffiliation( args, object )
    local affiliation = stringUtil.split( args.affiliation or '', ',' ) -- Is an empty table if the arg isn't defined
    if #affiliation == 0 then
        if not object then return nil end
        for _, empire in ipairs( object.affiliation ) do table.insert( affiliation, empire.name ) end
    end
    return table.concat( linksUtil.convertLinks( affiliation ), ', ' )
end

---@param args args
---@param object table?
---@return table
local function getSMWAffiliation( args, object )
    local affiliation = stringUtil.split( args.affiliation or '', ',' )
    if #affiliation == 0 then
        if not object then return {} end
        for _, empire in ipairs( object.affiliation ) do table.insert( affiliation, empire.name ) end
    end
    return affiliation
end

---@param args args
---@param object table?
---@return string?
local function getHabitable( args, object )
    local habitable = nil

    if args.habitable then
        habitable = Yesno( args.habitable )
    elseif
        object then
        habitable = object.habitable
    end

    if habitable ~= nil then
        return t( 'val_habitable_' .. tostring( habitable ) )
    else
        return nil
    end
end

---@param infobox any
---@param args args
---@param object table?
---@return string? type Plain type
---@return string? translatedType Translated type
---@return string? classification Classification
return function ( infobox, args, object )
    local plainType, translatedType = getType( args, object )
    --- Type
    smwData[ t( 'lbl_type' ) ] = plainType
    --- Classification
    local classification = getClassification( args, object, plainType )
    smwData[ t( 'lbl_classification' ) ] = classification
    --- Affiliation
    smwData[ t( 'lbl_affiliation' ) ] = getSMWAffiliation( args, object )
    --- Habitable
    local habitable = getHabitable( args, object )
    smwData[ t( 'lbl_habitable' ) ] = habitable
    --- Population
    smwData[ t( 'lbl_population' ) ] = args.population
    --- Senator
    smwData[ t( 'lbl_senator' ) ] = args.senator

    infobox:renderSection( {
        content = {
            infobox:renderItem( {
                label = t( 'lbl_type' ),
                data = translatedType,
            } ),
            infobox:renderItem( {
                label = t( 'lbl_classification' ),
                data = classification,
            } ),

            infobox:renderItem( {
                label = t( 'lbl_affiliation' ),
                data = getAffiliation( args, object ),
            } ),
            infobox:renderItem( {
                label = t( 'lbl_habitable' ),
                data = habitable,
            } ),

            infobox:renderItem( {
                label = t( 'lbl_population' ),
                data = args.population,
            } ),
            infobox:renderItem( {
                label = t( 'lbl_senator' ),
                data = args.senator,
            } )
        },
        col = 2
    } )

    return plainType, translatedType, classification
end

end)

_bundler_register('laZXalvuFwB-WExC9ra2U', function()
    local Starmap = require( 'Module:Starmap_old' )
local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")

---@param infobox any
---@param args args
---@param object table?
return function ( infobox, args, object )
    ---@type string | number
    local landingzones = args.landingzones
    ---@type string | number
    local satellites = args.satellites

    if (not landingzones or not satellites) and object then
        local children = Starmap.children( object.id, false )

        local landingzoneCount = #tableUtil.filter( children, 'type', 'LZ', nil )
        local satelliteCount = #tableUtil.filter( children, 'type', 'SATELLITE', nil )

        if not landingzones and landingzoneCount > 0 then landingzones = landingzoneCount end
        if not satellites and satelliteCount > 0 then satellites = satelliteCount end
    end

    --- Landing zones
    smwData[ t( 'lbl_landing_zones' ) ] = landingzones
    --- Satellites
    smwData[ t( 'lbl_satellites' ) ] = satellites

    infobox:renderSection( {
        content = {
            infobox:renderItem( {
                label = t( 'lbl_landing_zones' ),
                data = landingzones
            } ),
            infobox:renderItem( {
                label = t( 'lbl_satellites' ),
                data = satellites
            } )
        },
        col = 2
    } )
end

end)

_bundler_register('o_kAUNNxCc7NiBSIG0A61', function()
    local Starmap = require( 'Module:Starmap_old' )
local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")

---@param args args
---@param object table?
---@return string?
local function getStarmapLink( args, object )
    if not object then return end
    return Starmap.link( object.code, object.star_system.code )
end

---@param infobox any
---@param args args
---@param object table?
return function ( infobox, args, object )
    infobox:renderFooter( {
        content = {
            infobox:renderItem( {
                label = t( 'lbl_starmap_id' ),
                data = tableUtil.safeAccess( object, 'id' ),
                row = true,
                spacebetween = true
            } ),
            infobox:renderItem( {
                label = t( 'lbl_starmap_code' ),
                data = tableUtil.safeAccess( object, 'code' ),
                row = true,
                spacebetween = true
            } ),
        },

        button = {
            icon = 'WikimediaUI-Globe.svg',
            label = t( 'lbl_other_sites' ),
            type = 'popup',
            content = infobox:renderSection( {
                content = {
                    infobox:renderItem( {
                        label = t( 'lbl_official_sites' ),
                        data = table.concat( {
                            infobox:renderLinkButton( {
                                label = t( 'lbl_starmap' ),
                                link = getStarmapLink( args, object )
                            } ),
                            infobox:renderLinkButton( {
                                label = t( 'lbl_galactapedia' ),
                                link = args.galactapedia
                            } )
                        }, ' ' )
                    } ),
                },
                class = 'infobox__section--linkButtons',
            }, true )
        }
    } )
end

end)

_bundler_register('pCUqUMXDjO00k_s6kun2g', function()
    local Starmap = require( 'Module:Starmap_old' )
local config = mw.loadJsonData( 'Module:Astronomical object/config.json' )
local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local stringUtil = _bundler_load("LqcyuoqcgR16kBloizIfu")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")

---@param args args
---@param object table?
---@return string? direction
---@return string? formattedDirection
local function getDirection( args, object )
    if args.tunneldirection then return args.tunneldirection end
    if not object or object.type ~= 'JUMPPOINT' then return nil end

    local translated = t( 'val_tunnel_direction_' .. string.lower( object.tunnel.direction ) )

    local icon = config.tunnelDirectionIcons[ object.tunnel.direction ]

    return translated, translated .. ' ' .. (icon or '')
end

---@param args args
---@param object table?
---@return string?
local function getSize( args, object )
    if args.tunnelsize then return args.tunnelsize end
    if not object or object.type ~= 'JUMPPOINT' then return nil end

    return t( 'val_tunnel_size_' .. string.lower( object.tunnel.size ) )
end

---@param args args
---@param object table?
---@return string? entry
---@return string? entryCode
---@return string? exit
---@return string? exitCode
local function getEntryAndExit( args, object )
    local entry = args.tunnelentry
    local entryCode
    local exit = args.tunnelexit
    local exitCode

    if object and object.type == 'JUMPPOINT' then
        if not entry then
            entry = stringUtil.clean(
                '[[' .. stringUtil.removeParentheses( object.tunnel.entry.designation ) .. ']], '
                .. Starmap.inSystem(
                    Starmap.findStructure( 'system', object.tunnel.entry.star_system_id )
                )
            )

            entryCode = object.tunnel.entry.code
        end

        if not exit then
            exit = stringUtil.clean(
                '[[' .. stringUtil.removeParentheses( object.tunnel.exit.designation ) .. ']], ' ..
                Starmap.inSystem(
                    Starmap.findStructure( 'system', object.tunnel.exit.star_system_id )
                )
            )

            exitCode = object.tunnel.exit.code
        end
    end

    return entry, entryCode, exit, exitCode
end

---@param infobox any
---@param args args
---@param object table
return function ( infobox, args, object )
    --- Direction
    local direction, formattedDirection = getDirection( args, object )
    smwData[ t( 'lbl_direction' ) ] = direction
    --- Size
    local size = getSize( args, object )
    smwData[ t( 'lbl_jumpgate_size' ) ] = size
    --- Exit
    local entry, entryCode, exit, exitCode = getEntryAndExit( args, object )
    smwData[ t( 'lbl_entry' ) ] = entryCode
    smwData[ t( 'lbl_exit' ) ] = exitCode

    infobox:renderSection( {
        title = t( 'lbl_jumpgate' ),
        content = {
            infobox:renderItem( {
                label = t( 'lbl_direction' ),
                data = formattedDirection,
            } ),
            infobox:renderItem( {
                label = t( 'lbl_jumpgate_size' ),
                data = size,
            } ),

            infobox:renderItem( {
                label = t( 'lbl_entry' ),
                data = entry,
            } ),
            infobox:renderItem( {
                label = t( 'lbl_exit' ),
                data = exit,
            } )
        },
        col = 2
    } )
end

end)

_bundler_register('GJAfegS6nWBdSQk4HCMhR', function()
    local t = _bundler_load("Z5x8snU4sjkD3qLJGPy1D")
local tableUtil = _bundler_load("vrceqVUhYydyNif7ebocA")

---@param args args
---@param object table?
---@return string?
local function getSensorDanger( args, object )
    if args.sensordanger then return args.sensordanger end
    local value = tableUtil.safeAccess( object, 'sensor_danger' )
    if value > 0 then return tostring( value ) .. '/10' else return nil end
end

---@param args args
---@param object table?
---@return string?
local function getSensorEconomy( args, object )
    if args.sensoreconomy then return args.sensoreconomy end
    local value = tableUtil.safeAccess( object, 'sensor_economy' )
    if value > 0 then return tostring( value ) .. '/10' else return nil end
end

---@param args args
---@param object table?
---@return string?
local function getSensorPopulation( args, object )
    if args.sensorpopulation then return args.sensorpopulation end
    local value = tableUtil.safeAccess( object, 'sensor_population' )
    if value > 0 then return tostring( value ) .. '/10' else return nil end
end

---@param infobox any
---@param args args
---@param object table?
return function ( infobox, args, object )
    --- Sensor: Danger
    local sensorDanger = getSensorDanger( args, object )
    smwData[ t( 'lbl_sensor_danger' ) ] = sensorDanger
    --- Sensor: Economy
    local sensorEconomy = getSensorEconomy( args, object )
    smwData[ t( 'lbl_sensor_economy' ) ] = sensorEconomy
    --- Sensor: Population
    local sensorPopulation = getSensorPopulation( args, object )
    smwData[ t( 'lbl_sensor_population' ) ] = sensorPopulation

    infobox:renderSection( {
        title = t( 'lbl_sensors' ),
        content = {
            infobox:renderItem( {
                label = t( 'lbl_sensor_danger' ),
                data = sensorEconomy
            } ),
            infobox:renderItem( {
                label = t( 'lbl_sensor_economy' ),
                data = sensorEconomy
            } ),
            infobox:renderItem( {
                label = t( 'lbl_sensor_population' ),
                data = sensorPopulation
            } )
        },
        col = 3
    } )
end

end)

return _bundler_load('bundler_main')
Heya! We only use cookie to make the site function and save your preferences, nothing else :)