Comparing emission-and absorption-based gas-phase metallicities in GRB host galaxies at z = 24 using JWST

Much of what is known of the chemical composition of the universe is based on emission line spectra from star-forming galaxies. Emission-based inferences are, nevertheless, model-dependent and they are dominated by light from luminous star-forming re gions. An alternativ e and sensitive probe of the metallicity of galaxies is through absorption lines imprinted on the luminous afterglow spectra of long gamma ray bursts (GRBs) from neutral material within their host galaxy. We present results from a JWST/NIRSpec programme to investigate for the ﬁrst time the relation between the metallicity of neutral gas probed in absorption by GRB afterglows and the metallicity of the star-forming regions for the same host galaxy sample. Using an initial sample of eight GRB host galaxies at z = 2.1–4.7, we ﬁnd a tight relation between absorption and emission line metallicities when using the recently proposed ˆ R metallicity diagnostic ( ± 0.2 dex). This agreement implies a relatively chemically homogeneous multiphase interstellar medium and indicates that absorption and emission line probes can be directly compared. Ho we ver, the relation is less clear when using other diagnostics, such as R 23 and R 3 . We also ﬁnd possible evidence of an elevated N/O ratio in the host galaxy of GRB 090323 at z = 4.7, consistent with what has been seen in other z > 4 galaxies. Ultimate conﬁrmation of an enhanced N/O ratio and of the relation between absorption and emission line metallicities will require a more direct determination of the emission line metallicity via the detection of temperature-sensitive auroral lines in our GRB host galaxy sample.


INTRODUCTION
The chemical enrichment of galaxies across cosmic time encodes vital information on galaxy evolution, tracing the successive episodes of star formation that synthesise and recycle metals back into the galactic interstellar medium (ISM).Galaxy-scale outflows and accretion of pristine gas further redistributes and dilutes enriched material.Tracing the metallicity of the multi-phase ISM of galaxies thus enables the relative importance of these competing processes in enriching a galaxy to be studied.
The majority of gas-phase metallicity measurements of galaxies are based on emission lines, which trace the ionised gas within star forming regions.In such a case, the most direct method available to trace the gas phase metallicity is using metal recombination lines (e.g.Osterbrock 1989;Peimbert et al. 1993), which are relatively unaffected by temperature fluctuations.However, they are extremely faint (∼ 10 3 times fainter than the hydrogen recombination line, H), ★ E-mail: p.schady@bath.ac.uk limiting this method to only the highest-resolution spectra of nearby systems (e.g.Esteban et al. 2009Esteban et al. , 2014)).Alternatively, measurements of the electron temperature ( e ) can also provide (semi-)direct metallicity estimates (e.g.Peimbert 1967;Osterbrock 1989).This method requires metal auroral lines such as [O iii]4363, which although still faint (∼ 10 2 times fainter than H), are ten times brighter than metal recombination lines and are thus detectable in a wider range of systems in the nearby Universe, or in gravitationally lensed galaxies out to  ≈ 3.6 (e.g.Villar-Martín et al. 2004;Christensen et al. 2012;Sanders et al. 2016).Oxygen auroral lines have now also been detected out to  ∼ 8 for a few galaxies with the James Webb Space Telescope (JWST, e.g.Schaerer et al. 2022;Arellano-Córdova et al. 2022;Curti et al. 2023b;Trump et al. 2023;Heintz et al. 2023b;Nakajima et al. 2023;Rhoads et al. 2023), but these remain the exception.
In the absence of metal recombination or auroral lines, indirect metallicity estimates of star forming regions must be used, which are obtained via strong emission line ratios (e.g.Kewley & Dopita 2002;Pettini & Pagel 2004;Pilyugin & Grebel 2016).Calibrations for such diagnostics are now becoming possible at high redshift (e.g.Laseter et al. 2023;Hirschmann et al. 2023;Sanders et al. 2023).However, strong-line metallicity estimates are known to vary by up to ∼ 0.6 dex depending on the line ratios chosen (Kewley & Ellison 2008;Teimoorinia et al. 2021).Moreover, all such emission line methods are luminosity-weighted tracers of the star forming regions of galaxies, which at  > 2 contain just 20% of the baryon fraction (Fukugita & Peebles 2004;Behroozi et al. 2010;McGaugh et al. 2010;Peeples et al. 2014).
A very different but complementary method of studying the cosmic build up of heavy elements is with absorption lines from the cold ISM, using the luminous light offered by background quasi-stellar objects (QSOs) and long gamma ray bursts (GRBs).Absorption from neutral hydrogen reveals copious quantities of neutral gas in these systems (e.g.Tanvir et al. 2019), in the large majority of cases classifying them as damped Lyman- (Ly ) absorbers (DLAs, defined as having log[ HI /cm −2 ] > 20.3; see Wolfe et al. 2005), where ionisation corrections are negligible.Combining the neutral hydrogen abundance with the measured abundances of metals provides an accurate and largely model-independent measure of the neutral gas metallicity (Prochaska et al. 2003a,b;Savaglio et al. 2003;Savaglio 2006;Wolfe et al. 2005;Fynbo et al. 2011;Rafelski et al. 2012;Neeleman et al. 2013;Krogager et al. 2013).Such data have enabled abundances to be measured out to  > 6 (Kawai et al. 2006;Thöne et al. 2013;Hartoog et al. 2015;Saccardi et al. 2023) and a few dex below what can be probed with emission lines (Péroux & Howk 2020;Wiseman et al. 2017;Bolmer et al. 2019;De Cia et al. 2013).The combination of absorption and emission line probes can therefore provide a more complete understanding of the chemical enrichment of galaxies.
Extensive efforts have been made to identify the emission counterparts to QSO-DLAs, but the often large, projected offsets of tens of kpc between the QSO line of sight and the centre of the galaxy associated with the absorber (or 'impact parameter') (e.g Chen et al. 2005;Rao et al. 2006;Krogager et al. 2012;Rahmani et al. 2016) make it challenging to identify the intervening system in emission (e.g.Fumagalli et al. 2015).Detecting emission counterparts at smaller impact parameters is also complex due to the bright light from the background QSO.Thus despite there now being on the order of a few hundred QSO-DLAs with measured absorption metallicities (Berg et al. 2015;De Cia et al. 2016, 2018), of these, the emission line metallicity (or limits) has only been reported for 20-30 QSO-DLA emission counterparts (Christensen et al. 2014;Rahmani et al. 2016;Weng et al. 2023), most of which are at  < 2. The measured emission line metallicities are generally larger than the absorption-based metallicities, although it remains unclear whether this offset is a result of a difference in the phase or in the location of the gas probed, or the presence of systematics.The QSO-DLA towards SBS 1544+5912 has an impact parameter of just 1 kpc (Rahmani et al. 2016), and in this case the emission and absorption line metallicities were consistent within the uncertainties (Schulte-Ladbeck et al. 2004, 2005).
Unlike QSO-DLAs, long GRBs fade, enabling even faint host galaxies to be observed in emission.Furthermore, their association to the death of a massive star 1 (Galama et al. 1998;Hjorth et al. 2003;Woosley & Bloom 2006) offer a sightline that pierces through 1 The detection of a kilonova associated with the long GRB 211211A and GRB 230307A has shown that not all long GRBs are formed from the core collapse of a massive star (e.g.Troja et al. 2022;Rastinejad et al. 2022;Gompertz et al. 2023;Levan et al. 2023).Nevertheless, the majority of long GRB at  < 1 that are followed up show supernova (SN) features in their light curves and/or spectra (e.g.Cano et al. 2017).
the same star forming regions that dominate emission-line spectra (e.g.Fruchter et al. 2006;Wiersema et al. 2007;Krühler et al. 2017).The closest absorbing clouds have been found to typically lie at a distance of just a few hundred parsec from the GRB (Vreeswĳk et al. 2007(Vreeswĳk et al. , 2013;;D'Elia et al. 2014) (although see Saccardi et al. 2023), which is far smaller than typical QSO-DLA impact parameters and places the absorbing material within the galaxy ISM.Any difference between emission and absorption line metallicities in the case of GRB host galaxies would therefore reflect differences in the chemical enrichment of the multi-phase ISM.
Prior to the launch of JWST, only the host galaxy of GRB 121024A at  = 2.298 (Friis et al. 2015) had a well-measured absorption line metallicity together with an emission line metallicity.This is due to the need for restframe optical galaxy spectroscopy to capture the emission lines required for the metallicity diagnostic (e.g., Krühler et al. 2015;Palmerio et al. 2019;Graham et al. 2023) as well as rest-frame UV GRB afterglow spectra for deriving the absorption metallicity.Ly  absorption can only be detected from the ground for GRBs at  ≳ 2, but at such redshifts it becomes challenging to detect the weaker emission lines from the same host galaxies.In the case of GRB 121024A, the emission line metallicity was larger than the absorption metallicity by 0.2-0.7 dex (Friis et al. 2015;Krühler et al. 2015).Deriving emission metallicities at higher redshifts ( ≳ 2) from direct observations of the host galaxies requires near-infrared spectroscopy.
It is only now, with the sensitivity and near-infrared coverage of JWST, that it is possible to obtain sensitive emission-line data at wavelengths out to H for a sample of GRB hosts with wellconstrained absorption line metallicities.In this paper, we report results from a cycle-1 JWST NIRSpec program (PI: P. Schady, ID 2344) to measure emission line metallicities for a subset of 10 GRB host galaxies at 2.1 <  < 4.7 that have accurately measured (< 0.1 dex) absorption line metallicities.In section 2 we describe our sample and provide details on our NIRSpec observations, followed by our data analysis in section 3. We present our results in section 4, and in section 5 we discuss the implications of our analysis on the relation between emission and absorption metallicity probes.All uncertainties are given as 1 unless otherwise stated and we assume a standard Lambda cold dark matter (ΛCDM) cosmological model with Ω M = 0.31, Ω Λ = 0.69, and H 0 = 67.8km s −1 Mpc −1 (Planck Collaboration et al. 2016).

JWST GRB HOST GALAXY SAMPLE
There are around 30 GRBs with an afterglow absorption line metallicity measured with a statistical uncertainty of better than 0.25 dex (Wiseman et al. 2017;Bolmer et al. 2019;Heintz et al. 2023a).From this parent sample we selected those host galaxies with measured UV/optical star-formation rates (SFRs) from UV continuum or emission line fluxes, but without the necessary spectra to measure a metallicity.This left us with a sample of 15 GRB host galaxies.We then further down-selected the sample to only include those GRB host galaxies with an estimated H flux brighter than 3.5 × 10 −18 erg cm −2 s −1 based on the SFR, leaving us with a final sample of 10 long GRB host galaxies.This flux limit was set by our requirement to measure strong emission lines at wavelengths spanning from [O ii]3726,3729 to H with S/N> 5 in less than 4 hours (including overheads) according to the JWST exposure time calcu- ★ Observed with the IFS † Window given for when target due to be observed lator, above which the data volume exceeds the middle threshold set by JWST when using the nrsirs2rapid readout pattern 2 .
Our GRB host galaxy sample and the details of the JWST/NIRSpec observations are given in Table 1.The detection of Ly  absorption in the optical afterglow spectrum is necessary in order to be able to measure the metallicity in absorption (see 3.4 for details), and this requirement imposes a hard lower bound on the redshift of  > 2 for the sample.It should be noted that our need for an accurate absorption line metallicity in our selection criteria biases our sample against more metal-rich and thus dusty host galaxies, which significantly attenuate the afterglow spectrum.In addition, the requirement that our host galaxies were previously detected in emission, either in imaging or spectra, introduces a preference for the brightest, and thus most star-forming galaxies of those with accurate absorption metallicities.The redshift range spanned by our final sample is  = 2.1-4.7 (Table 2), and the absorption line metallicities range from 0.04 Z ⊙ to 2.5 Z ⊙ (Table 4).

OBSERVATIONS AND DATA ANALYSIS
Our sample of GRB host galaxies were all observed with NIRSpec (Jakobsen et al. 2022), two using the integral field spectrograph (IFS) and the rest with the S400A fixed slit.
The host galaxies of GRB 050820A and GRB 150403A showed evidence of spatially extended emission in the available imaging data, and NIRSpec observations were therefore performed using the IFS, which has a 3 ′′ × 3 ′′ field of view.For the same given object, 2 jwst-docs.stsci.edu/jwst-general-supportlonger exposures are required in IFS mode than with the fixed slit to reach the same integrated line flux sensitivity, which is why we only used the IFS in cases where there was evidence of extended emission.For both these GRB host galaxies the G140M/F100LP and G235M/F170LP grating and filter combinations were used, corresponding to a spectral resolution of  ∼ 1000.In the case of GRB 050820A, previous Hubble Space Telescope (HST) imaging data showed that the host galaxy consists of at least two components separated by < 1. ′′ 5 (12.3 kpc physical size) (Chen 2012), and the galaxy complex was therefore sufficiently compact to be able to perform a two-point nod to cover both components and additionally sample the sky background.For GRB 150403A, pre-imaging data were available with the GRB Optical and Near-infrared Detector (GROND; Greiner et al. 2008) mounted on the 2.2 m Max Planck Institute telescope in La Silla, Chile.From these data the host galaxy appeared extended over ∼ 2 ′′ (17.1 kpc physical size), and thus a four-point dither was used instead of nodding to avoid any of the galaxy falling out of the 3 ′′ × 3 ′′ NIRSpec field of view during a nod.The reduced and flux calibrated IFS data were downloaded from the Mikulski Archive for Space Telescopes (MAST) Data Discovery Portal 3 .The QFitsView 4 software package was used to visualise the cubes and to extract stacked spectra and corresponding uncertainties from the regions of interest.For the remaining eight GRB host galaxies in our sample observed with the NIRSpec S400A fixed slit, a two-point nod pattern was used.The reduced and combined 2D spectra were similarly downloaded from MAST.All downloaded data were reduced with version 11.17.2 of the CRDS file selection software, using context jwst_1140.pmap.The galaxies appear compact in the 2D spectra but in some cases they are resolved.The 1D spectra were extracted manually using the JWST Extract1DStep python function (v1.8.3), applying an extraction region centred on the detectable line emission and with a width 0. ′′ 7-0.′′ 9.
The resolving power of NIRSpec is in the range  = 350 − 1400 in the G140M grating, corresponding to a velocity dispersion  = 90 − 360 km/s, and in the G235M grating it is  = 630 − 1500 or  = 80 − 200 km s −1 .The typical intrinsic line velocities measured in our sample are  ∼ 50 − 150 km s −1 after accounting for the line spread function.The emission lines in the 1D spectra are generally well fit by a single Gaussian component, with the exception of the [N ii]6549,6584 and H emission lines from the host galaxy of GRB 090323, where there is evidence of additional emission that likely originates from unresolved additional components in velocity space (section 3.3).The current version of Extract1DStep fails to provide a flux uncertainty, which is due to the relevant flat field reference files not having an associated variance array.New flat fields are required to resolve this problem, and for now the recommendation provided on the JWST webpages 5 is to calculate the flux error by summing in quadrature the contribution from the Poisson noise and read-out noise alone, which are available in the extracted 1D spectral file.In the remainder of this section we describe the JWST observations and data analysis process for each of the GRB host galaxies in our sample, beginning with the two targets with IFS observations.

GRB 050820A
Level 3 data show clear emission from H, H, [O ii]3726,3729 and [O iii]4959,5007 at an observer wavelength consistent with the GRB afterglow absorption redshift ( = 2.6147; Ledoux et al. 2005;Prochaska et al. 2007b;Fox et al. 2008) (see Fig. A1).An image of the G140M/F100LP NIRSpec data cube centered at the redshifted [O iii]5007 line is shown in Fig. 1, where a galaxy complex made up of numerous emission components can be seen.Spectroscopic observations of this host galaxy were previously taken using the Folded port InfraRed Echellette (FIRE) spectrograph on the Magellan Baade Telescope, covering the wavelength range 0.8-2.5mwith a spectral resolution of ∼ 50 km s −1 (Chen 2012).In line with the naming convention used in Chen (2012), we refer to the upper, northern component as component A, and the lower, southern component as component B, which are separated by a projected distance of ∼ 13 kpc, consistent with the HST observations (Chen 2012).The GRB projected position was located between components A and B, and is indicated by an 'X' in Fig. 1, which lies on a third emission component seen in Fig. 1, which we have identified as C. The absolute astrometry of the JWST image is limited by the JWST pointing accuracy, which is 0. ′′ 1, corresponding to a single NIRSpec pixel.Component C is not the brightest region of its host galaxy (see Table 2), but it nevertheless has a high SFR (see Section 3.3 and Table 4).This is in line with what is observed at  < 1, with long GRBs tracing, on average, some of the brightest regions of their host galaxy (Fruchter et al. 2006), even if not the brightest (e.g.GRB 980425 Christensen et al. 2008;Krühler et al. 2017).The environmental properties at the position of the GRB will be presented in greater detail in Topçu et al. (in prep).An intervening absorption system was detected in the GRB afterglow at  = 2.3597 (Ledoux et al. 2005;   5 jwst-docs.stsci.edu/jwst-calibration-pipeline-caveats2012) and labelled in the image above.The position of the GRB afterglow is indicated with an 'X', which lies close to a third emission component, labelled here as C. Additional emission can also be seen to the left of region C, which is only detected at 1.79m, consistent with [O iii]5007 at  = 2.615.However no corresponding emission from [O iii]4959 or H at this same redshift is detected at this location.The image is orientated with north up and east left.The pixel scale of the image is 0. ′′ 1, corresponding to 819 pc, and the offset from the image centre in kpc is indicated along the axes.Observations were taken with a two-point dither, which is why the shape of the field of view comprises two overlapping squares.Vergani et al. 2009), but no emission lines of this intervening system are detected in the NIRSpec data cube.
Spectra of the stacked pixels within each of the A, B and C components were extracted within QFitsView, as well as a spectrum of all emission host galaxy regions combined (see Table 2).Component A is the brightest of the host galaxy complex, and the velocity dispersion for all three components is consistent within 2, although in the case of component C we only measure an upper limit (< 98 km s −1 , corresponding to the instrument resolution at 1.8m).
After applying the barycentric correction to the measured radial velocities, the Gaussian fits to the H, H and [O iii]4959,5007 doublet give a best-fit redshift of  = 2.6129 ± 0.0001 for component A,  = 2.6133 ± 0.0001 for component B, and  = 2.6136 ± 0.0002 for component C, corresponding to a maximum velocity separation of Δ ≈ 58 ± 25 km s −1 between the components.This is consistent with the redshifts for components A and B reported in Chen (2012).

GRB 150403A
An image taken of the field of GRB 150403A almost six months after the GRB with GROND (Greiner et al. 2008) showed extended emission at the position of the GRB.This is confirmed with the NIRSpec IFS observations, where line emission from H, H, [O ii]3726,3729 and [O iii]4959,5007 is clearly detected in three regions of the data cube at a redshift consistent with the GRB afterglow ( = 2.06; Pugliese et al. 2015) (see Fig. A2).We have labelled the three brightest emission components A, B and C on an image taken from the NIRSpec G140M/L100LP data, centred  on the observer frame [O iii]5007 emission line (Fig. 2).The GRB afterglow position (labelled 'X') appears to lie just to the west of component C, and not evidently on a star forming region.However, the astrometry of these data is limited by the combined pointing accuracy of JWST (within 1 pixel) and the accuracy of the acquisition target position, which was ∼ 0. ′′ 3. The estimated total 1 uncertainty on the GRB afterglow position within the NIRSpec IFS field of view is indicated in Fig. 2 with the dashed white circle.Accurate astrometry was possible in the case of the host galaxy of GRB 050820A because the A and B components were detected in previous HST imaging data, allowing the GRB position to be located accurately.However, for the host galaxy of GRB 150403A, there is no imaging data available that resolves the components shown in Fig. 2, so that further refined astrometry is not possible.Component B has the brightest emission lines, followed by components A and then C. The largest velocity separation is between components B and C, which are offset by Δ ≈ 88 km s −1 , whereas component A lies somewhere between the other two components.

Fixed slit observations
The remaining eight GRB host galaxies in the sample for which we had no evidence of extended emission were all observed with the NIRSpec S400A fixed slit (0. ′′ 4 slit width).In most cases this required observations in two grating/filter combinations with the exception of GRB 090323A, which at  = 3.57 (Chornock et al. 2009;Savaglio et al. 2012), had all relevant nebular emission lines redshifted into the wavelength range of the F170LP filter.
In four of the seven GRB host galaxy candidates that have been observed with the fixed slit6 (host galaxies of GRB030323, GRB080804, GRB090323 and GRB100219A), hydrogen Balmer and [O iii]4959,5007 emission was detected at observer wavelengths consistent with the corresponding GRB afterglow absorption redshift.Emission from [O ii]3726,3729 was also detected from the host galaxy of GRB080804 and GRB 090323, and tentatively from the host of GRB 030323.However, no [O ii]3726,3729 emission was detected in the host galaxy spectrum of GRB 100219A.In the case of the host galaxy of GRB 090323, emission from [N ii]6549,6584 and [S ii]6717,6731 was also detected as well as the galaxy continuum.This is indicative of a luminous, metalrich galaxy, consistent with the high absorption-based metallicity (> 2  ⊙ ).
In the case of two targets (GRB 120327A and GRB 120815A), the candidate host galaxies we observed were unfortunately found to be relatively dim foreground stars.These stars were not present in Gaia or other publicly available catalogues and the field is not covered by SDSS.The targeted sources could thus not previously be ruled out as the host galaxy.In the case of GRB 120815A, the offset between the identified host galaxy candidate and the GRB position was 1. ′′ 5, whereas in the case of GRB120327A the offset was 0. ′′ 3.However, in the latter case the observed source is three magnitudes brighter than expected, implying that the wrong source was targeted in the JWST NIRspec observations.No emission was detected in the NIRSpec spectrum at the position of the candidate of the host galaxy of GRB 141109A.
The host galaxy candidate of GRB120327A was identified by D'Elia et al. ( 2014) at the position of the GRB afterglow with AB magnitude  ′ = 24.50±0.23.However, the NIRSpec spectrum of this source does not reveal any emission lines at the expected observer frame wavelength, and instead resembles a black body with a temperature ∼ 3500 K, suggesting that the source is in fact a foreground star (see Fig. B1, left panel).
In a late time observation of the field of GRB 120815A taken with the High Acuity Wide field K-band Imager (HAWK-I) a source is detected 1. ′′ 1 north-west of the GRB afterglow position, and this was considered to be the host galaxy (9.2 kpc).However, the NIRSpec data show the detection of two sources spatially offset by ∼1.′′ 2 (corresponding to 10 kpc), neither of which correspond to a galaxy at the redshift of GRB 120815A, at  = 2.358.The spectrum of the trace at the centre of the 2D spectrum resembles the Rayleigh-Jeans tail of a black body spectrum, implying that the targeted source is in fact a foreground star (see Fig. B1, right panel).Precise astrometry was performed on the available imaging data of the GRB fields, and the lack of host galaxy detections in the case of GRB 120327A and GRB 120815A was therefore the result of the incorrect target being identified as the host galaxy in our pre-JWST imaging data, rather than due to an error in the positioning of the NIRSpec fixed slit.
In the case of GRB 141109A an extended source was detected at the location of the GRB in  ′ -band GROND observations taken three months after the GRB, and also in 3.6µm observations taken with the Spitzer Space Telescope in March 2018 (program ID 13104; PI Perley), which we considered a to be a host galaxy candidate.The astrometry in our GROND images was typically good to within 0. ′′ 2, and we therefore accredit the lack of detected continuum or emission lines in our NIRSpec fixed slit observations to the host galaxy being dimmer than expected, rather than the slit having missed the target.
The second trace detected in the 2D spectra taken for GRB 120815A shows a bright continuum with strong Balmer and metal emission lines at observer wavelengths consistent with a galaxy at  = 1.539.This galaxy is therefore likely the emission counterpart to a strong intervening absorption line system that was detected in the GRB afterglow spectrum at the same redshift (Krühler et al. 2013).At  = 1.539 the [O ii]3726,3729 line doublet lies blueward of the NIRSpec F100LP spectral range.However, H, H and [O iii]4959,5007, as well as [N ii]6549,6584 and [S ii]6717,6731 are detected and are given in Table 3.
Emission lines from the host galaxy of GRB 120815A were previously detected with X-shooter (Krühler et al. 2015), and the lack of detection in our NIRSpec data is therefore due to a mistake in the target that we selected to observe rather than a lack of sensitivity.The H and H emission lines in the X-shooter data (Krühler et al. 2015) were detected at only 3, and [O ii]3726,3729 was undetected.Nevertheless, the reported line fluxes are sufficient to be able to mea-sure an emission line metallicity, albeit with large uncertainties (see Table 4).

Emission line flux measurements
Host galaxy emission lines in the 1D spectra were fit with Gaussian functions, with the velocity width of all lines in a given galaxy tied (corrected for the instrument resolution), and the position of the lines kept at a constant redshift (see Figs. A1-A5).In the case of [O iii]4959,5007 the line doublet was fixed to have a one-to-three line flux ratio (Osterbrock 1989).The model was generally a good fit to the data with the exception of the fits to the [N ii]6549,6584 and H lines from the host galaxy of GRB 090323 (see Fig. A6).The best fit Gaussian slightly under predicts the observed H line flux amplitude, and the fit to [N ii]6584 is too narrow.Furthermore, the best-fit [N ii]6549,6584 doublet line ratio is [N ii]6584/[N ii]6549=1.6,which is far smaller than the expected line ratio of 3 (Storey & Zeippen 2000).Forcing the line ratio to be 3 results in the fit to [N ii]6549 significantly underestimating the observed emission of this line.The afterglow of GRB 090323 had strong absorption from two systems separated by just Δ ≈ 660 km s −1 , which are proposed to be the signature of two interacting galaxies (Savaglio et al. 2012).It is therefore possible that our NIRSpec spectrum contains the combined emission from two galaxies, which may explain why our single Gaussian fits cannot fully describe the data.Although no spatial offset is evident around the H and [N ii]6549,6584 lines in the 2D spectrum (Fig. A5, left), we tried fitting the lines with a twocomponent model.The fit to the H line was marginally improved when using a two components model (Fig. A5, right), but the fit to [N ii]6584 still appears too narrow.The Akaike and Bayesian information criterion increases by 10-15 when applying a two component fit, suggesting that the additional component does not significantly improve the fit, and thus for the rest of our analysis we use the flux measurements from the single Gaussian.The line fluxes from our single component fits are reported in Table 2.
Measured line fluxes for all host galaxies were corrected for Milky Way dust extinction along the GRB line of sight using the Schlafly & Finkbeiner (2011) E(B-V) reddening maps (values given in Table 1) and assuming a Cardelli et al. (1989) dust extinction curve with an average total-to-selective dust extinction value   = 3.08.The dust reddening from the GRB host galaxy was calculated from the H/H Balmer decrement assuming an intrinsic ratio H/H= 2.86 (Osterbrock 1989), which is appropriate for star-forming regions with temperature ∼ 10 4 K and electron densities   = 10-100 cm −3 .We corrected the line fluxes for host galaxy dust extinction using the average extinction law from the Small Magellanic Clouds (SMC) Pei (1992), which has a total-to-selective extinction   = 2.96.We note that the majority of the host galaxies in the sample have uncertain host galaxy dust reddening such that only the host galaxy of GRB 090323 has a reddening measured at > 2 confidence ( ( − ) = 0.34 ± 0.06).In section 4.2 we investigate the effect of these uncertain dust reddening corrections on our results.
The Milky Way dust-corrected fluxes for all lines detected at a SNR> 2 are reported in Table 2, and the fits to the lines are shown in the appendix (Figs.A1-A5).In Table 4 we give the measured host galaxy dust reddening and the SFR based on the Galactic and host galaxy dust-corrected H luminosity using the Kennicutt (1998) relation adopting a Chabrier (2003) IMF, which reduces the predicted SFR by a factor of ∼ 1.6 compared to a Salpeter IMF (Salpeter 1955).The errors on the SFR include the uncertainty on the dust reddening correction.In Table 4 we also provide the line velocity widths (corrected for the intrinsic instrument resolution) and the absorption and Table 3. Nebular line fluxes of intervening galaxy along line of sight to GRB 120815A at z=1.539.All lines have been corrected for a Milky Way dust reddening of E(B-V)=0.10(Schlafly & Finkbeiner 2011).
For the host galaxies of GRB 080804 and GRB 090323, lower signal to noise emission line flux measurements were already reported by Krühler et al. (2015) from X-shooter data, most of which are consistent at 1 with our NIRSpec measurements.The lack of any H detection from the host galaxy of GRB 090323 in Krühler et al. (2015) (< 1.5 × 10 −17 erg cm −2 s −1 at 3) is only marginally consistent (3) with the strong emission line that we measure in the NIRSpec spectra, in contrast to the very good agreement in the [O ii]3726,3729 line flux.It is therefore possible that the uncertainties in the X-shooter H measurement for the host of GRB 090323 are underestimated.

Absorption line metallicities
The GRB absorption line metallicities used in this paper were taken from the literature, and they are given in Table 4 together with references.Three of the GRBs in the sample were observed with low resolution spectrographs ( ∼ 1000 − 2000); either the Focal Reducer and low dispersion Spectrograph 2 (FORS2) mounted on the 8 m Very Large Telescope (VLT) (GRB 030323 and GRB 090323 Vreeswĳk et al. 2004;Savaglio et al. 2012), or the Low Resolution Imaging Spectrometer (LRIS) mounted on the Keck I 10 m telescope (GRB 050505).Two GRBs were observed with high resolution echelle spectrographs ( ∼ 30, 000 − 50, 000); GRB 080804 with the VLT/Ultraviolet and Visual Echelle Spectrograph (UVES) (Thöne et al. 2008;Fynbo et al. 2009), and GRB 050820A with UVES as well as the Keck/Higher Resolution Echelle Spectrometer (HiRES) (Prochaska et al. 2007a).The remaining GRBs in the sample were observed with the medium resolution VLT/X-Shooter ( ∼ 6, 000 − 10, 000) (Selsing et al. 2019).
In all cases broad Ly- absorption was detected in the afterglow spectra, corresponding to absorption from neutral hydrogen.Narrow metal absorption lines from species such as Zn, Si, S and Mg are also common (e.g.Fynbo et al. 2009).Assuming solar relative abundances, it is then possible to obtain a largely model-independent measure of the neutral gas metallicity by combining the measured hydrogen absorption column density with metal column densities using unsaturated absorption lines, ideally from non-refractory metals.At the large column densities of neutral material in DLAs, hydrogen self-shielding make ionisation corrections negligible, and thus the greatest uncertainty in such a technique is the corrections for depleted metals that are in the dust phase, as well as the assumption of solar relative abundances, which we discuss further in section 4.2.
For seven GRBs in the sample the dust-depletion corrected metallicities were determined following the method described in De Cia et al. (2013), where the abundances of numerous singly-ionised metals are fitted simultaneously with a dust depletion model in order to measure a consistent, dust depletion-corrected metallicity (Wiseman et al. 2017;Bolmer et al. 2019).For the remaining three GRBs, a sin-gle, non-refractory element was used to determine the metallicity; either sulphur (GRB 030323 and GRB 050505), or zinc (GRB 080804) (Cucchiara et al. 2015).In these cases, dust depletion corrections were applied following the method of De Cia et al. (2018), where the [S/Fe] or [Zn/Fe] relative abundance can be used to determine the level of dust depletion, giving results that are consistent to when multi abundances are fit (e.g.Heintz et al. 2023a).The Fe ii column density along the line of sight to GRB 080804 is only constrained to lie within the range log  Fe /cm 2 = 14.66−15.14(C.Ledoux private communication), which corresponds to a dust depletion correction    between −0.26 and −0.39.We therefore use the mid-range dust depletion corrected metallicity and propagate through the uncertainty of 0.07 dex on the dust depletion correction to our absorption metallicity accordingly.In the case of GRB 030323 and GRB 050505, where only low resolution spectra were available, the published absorption metallicities should be considered lower limits.We nevertheless give the published metallicities in Table 4, but will discuss the corresponding uncertainty on the absorption metallicity in section 4.2.Although the optical afterglow spectrum of GRB 090323 was also low resolution, we consider the measured metallicity more robust due to the numerous metal abundances (Zn, S, Si, Cr, Fe) that were used to measure the dust depletion and metallicity, which reduce the effect of saturation in any single line (Wiseman et al. 2017).The uncertainties on the absorption metallicity given in Table 4 correspond to the statistical uncertainty on the metal and H i column densities, and do not include systematic uncertainties, such as from the dust depletion correction.

Emission line metallicities
No emission was detected from the temperature-sensitive [O iii]4363 line in any of the GRB host galaxies in our sample.For the majority of the sample, the 3 upper limit on the [O iii]4363/[O iii]4959,5007 line flux ratio is < 0.05, corresponding to a limit on the temperature of  e (O iii) < 35, 000 K.More stringent constraints on the average electron temperature of our GRB host galaxy sample can be placed from a stacked spectrum, resulting in a 3 upper limit on the [O iii]4363 line flux of 1.3 × 10 −18 erg cm −2 s, and an auroral-to-nebular line flux ratio of < 0.04, corresponding to a limit on the temperature of  e (O iii) ≲ 27, 000 K. The electron temperatures measured in other  = 2 − 3 galaxies is generally lower than this upper limit that we obtain (e.g Christensen et al. 2012;Patrício et al. 2018;Laseter et al. 2023;Sanders et al. 2023;Strom et al. 2023), and we therefore need to rely on strong emission line diagnostics to obtain gas-phase metallicities for our sample of galaxies.
The majority of strong emission line metallicity diagnostics are calibrated to galaxies and H ii regions within the local Universe   ★ In these cases the measured line ratio in question is larger than the maximum value covered by the diagnostics ( 23 >0.96,  3 >0.78,or R = 0.47 2 + 0.88 3 > 0.81 at 1), and the resulting best-fit metallicity thus corresponds to the value at the turn over point between the lower and upper branch (see Fig. 5).The host galaxy of GRB 080804 and region C of the host galaxy of GRB 150403A also have a large value of R, but with an uncertainty that lies within the range of values considered in the LMC23 metallicity diagnostic.
2004; Maiolino et al. 2008;Andrews & Martini 2013;Dopita et al. 2016;Pilyugin & Grebel 2016;Curti et al. 2017), whereas high- galaxies have higher radiation fields and/or ionisation parameters (e.g.Kewley et al. 2013;Steidel et al. 2014).Attempts have been made to calibrate strong emission line diagnostics to the conditions present in distant galaxies, either by using local analogues to high- galaxies (e.g.Bian et al. 2018;Nakajima et al. 2022), or by using recent, small samples of high- galaxy spectra with metallicities measured from the temperature-sensitive [O iii]4363 line detected with JWST (e.g.Hirschmann et al. 2023;Sanders et al. 2023).
The emission line diagnostics that are available for our GRB host galaxy sample are generally limited to those that use hydrogen and oxygen lines, since we do not detect emission from  2023) (SST23 from hereon).NOX22 and SST23 provide diagnostics that include the hydrogen and oxygen line ratios listed above, but NOX22 additionally includes N 2 and O 3 N 2 diagnostics.The LMC23 and SST23 diagnostics are calibrated against samples of high- galaxies (2 <  < 9) that have  e -based metallicities, whereas NOX22 used a combination of local SDSS galaxies and extremely metal-poor galaxies to extend the metallicity range down to far lower metallicities (> 1 dex) than is covered in standard calibration samples (e.g.Curti et al. 2017), making their diagnostics more appropriate for high- galaxies.We note that the  23 and  3 from Maiolino et al. (2008) and NOX22 are very similar (SST23; see their fig.6), and Patrício et al. (2018) found that the Maiolino et al. (2008) line diagnostics provided the best agreement (within 0.1 dex) to their measured   -based metallicities for a sample of 16 galaxies at  = 1.4 − 3.6.This gives some support to the applicability of the NOX22 diagnostics to high- galaxies.
The NOX22 sample has a large scatter (up to an order of magnitude) in metallicity for a given  3 or O 32 line ratio at the low metallicity end (12 + log (O/H) ≲ 8).They find this scatter to be dependent on the H equivalent width, EW(H), whereby galaxies with higher average EW(H) have a lower  2 but a higher O 32 at a fixed metallicity.We only detect the galaxy continuum in the host galaxy of GRB 090323, for which we measure a rest-frame EW(H)=44 ± 4Å, placing it in the NOX22 low EW(H) bin.For the rest of the sample we can only place lower limits on the equivalent width, the most constraining being EW(H)> 50Å for the host galaxy of GRB 030323.We therefore cannot determine which NOX22 EW(H) bin the majority of our sample should lie in (low: < 100Å, intermediate: 100-200Å, or high: > 200Å).For this reason we do not consider the NOX22  2 and O 32 diagnostics in our analysis, considering only the NOX22  23 and  3 diagnostics.Although these two latter diagnostics also show an EW(H) dependence, but it is much weaker than for  2 and O 32 (∼ 0.5 dex in metallicity at a fixed line ratio).To compute the NOX22  23 and  3 , we initially use the high EW(H) calibrations, which NOX22 argue are most appropriate for high- galaxies, but in cases where we measure 12 + log(O/H)> 8, we use the EW-averaged value, which are valid up to 12 + log(O/H)=8.9.For those diagnostics that are double branched, such as the NOX22  2 and  23 , and the LMC23 R diagnostic, we use the absorption line metallicity to select between the two solutions.
The SST23 diagnostics generally show a weaker dependence between metallicity and the relevant line ratios, than the NOX22 diagnostics for example (see Fig. 5), and the SST23 metallicities thus cover a smaller dynamical range.We therefore move results based on the ST23 diagnostics to the appendix.
In the case of the host galaxy of GRB 090323, the [S ii]6717,6731 and [N ii]6549,6584 line doublets were detected and thus the Dopita et al. ( 2016) (DKS16 from hereon) N 2 S 2 H diagnostic could be used, which has the advantage that it is independent of dust reddening, relatively independent of the ionisation parameter, and the authors claim it can be used over the full abundance range encountered at high-.The N 2 S 2 H best fit metallicity is 12 + log (O/H) = 8.89 ± 0.08, corresponding to log(/ ⊙ ) = 0.20 ± 0.08, which is within 2 of the measured absorption line metallicity (0.41 ± 0.11; Wiseman et al. 2017).
In Table 4 we list the computed NOX22  23 and  3 , the LMC23 R, and the DKS16 N 2 S 2 H metallicities.In this table we also provide the afterglow absorption metallicities and redshifts, and the emission line redshift and velocity dispersion corrected for the instrument resolution.The SST23  23 ,  3 ,  2 and O 32 metallicities are given in Table D1.

Nebular versus neutral gas-phase metallicity
In Fig. 3 we plot the absorption line metallicity against the NOX22  23 (left) and NOX22  3 (right) emission line metallicities for our GRB host galaxy sample (red) and for a compilation of QSO-DLAs (shades of blue) from Rahmani et al. (2016) with absorption and emission line metallicities of the intervening galaxy counterpart.The sample of QSO-DLAs are generally at  < 0.7, but three lie at  > 2 (blue circle data points from Bouché et al. 2013;Fynbo et al. 2013;Krogager et al. 2013) consistent with our GRB host galaxy sample (see Table C1 for details on the QSO sample).In our GRB host galaxy sample we also include the hosts of GRB 120815A and GRB 121024A, which have absorption and emission lines detected from ground-based observations (Krühler et al. 2013;Friis et al. 2015).In Fig. 4 we show the absorption against the LMC23 R emission metallicity, as well as against the DKS16 N 2 S 2 H emission line metallicity for the host galaxy of GRB 090323 (green open star) and two QSO-DLAs (green open triangles; J0441-4313 at  = 0.1010 and J1544+5912 at  = 0.0102), all of which have the necessary [N ii]6584 and [S ii]6717,6731 emission line detections to compute the N 2 S 2 H metallicity.In both Figs. 3 and 4 the emission and absorption metallicities are in units of [M/H], assuming a solar metallicity value 12 + log(O/H) = 8.69 (Asplund et al. 2021) 7 .The QSO-DLA data points are colour-coded by their impact parameter, ranging from 1 − 50 kpc, although the association with the emission counterparts at large impact parameters is less secure.The offset from the galaxy centre of our sample of GRB sightlines is generally unknown, but when measured, they are typically small (e.g.average offset of 1 kpc in sample of 68 GRB host galaxies observed with HST; Blanchard et al. 2016).All GRB data points in Fig. 3 and Fig. 4 are therefore plotted with the same red colour.The sample of plotted QSO-DLA data points is smaller than the sample in Rahmani et al. ( 2016) because we did not consider limits, and we have the additional requirement that H and either [O ii]3726,3729 or [O iii]4959,5007 have to be detected in order to apply the the emission line diagnostics that we consider in this work.
For the two galaxies observed with the IFS (for GRB 050820A and GRB 150403A) we plot the emission line metallicity of the resolved component closest in projection to the GRB afterglow, which in both cases is component C in Figs. 1 and 2. In the case of GRB 050820A the  23 ,  3 and R line ratios of all components are larger than the maximum value covered by the NOX22 and LMC23 diagnostics, and the computed emission line metallicity in all cases is thus the maximum value possible with these diagnostics.The resolved components considered in the host galaxy of GRB 150403A, on the other hand, do vary in metallicity by up to 0.3 dex within the same diagnostic.The absorption line metallicity is most consistent with the emission line metallicity of component C in the case of NOX22  23 and  3 , but it is most consistent with the R metallicity of component B. A more detailed analysis on the resolved spectroscopic properties of these two GRB host galaxies will be presented in a follow-up paper (Topçu et al., in prep).In Fig. D1 we show the results for the four SST23 diagnostics.
The well-known discrepancy between emission line metallicities (e.g.Kewley & Ellison 2008;Andrews & Martini 2013) is evident in Fig. 3 and Fig. 4, with NOX22 and LMC23 giving notably different results.In the former case, the NOX22 metallicities are larger than the absorption metallicities by ∼ 0.2 dex on average (Fig. 3), although this offset is predominantly at [M/H] abs < −0.5, where there appears to be a relatively weak relation between the absorption and emission metallicity.The standard deviation in the NOX22 emission line metallicities relative to the line of equality (dashed black line) is 0.4-0.5 dex.Applying a Spearman's rank test returns a rank coefficient  = 0.2 − 0.3 with p-value of ∼ 0.2, indicating a weak and non-significant correlation.The LMC23 metallicities, on the other hand, are more evenly distributed on both sides of the line of equality (Fig. 4), with LMC23 generally lying within ±0.2 dex of the absorption metallicities.In this case the Spearman's rank coefficient is  = 0.8 with p-value=2 × 10 −5 , demonstrating that there is a strong and significant positive correlation.The DKS16 N 2 S 2 H metallicity is also within ±0.2 dex of the absorption metallicity for the three cases where this diagnostic could be applied (Fig. 4, green data points).Of note is the good agreement between the absorption and the DKS16 metallicity for the host galaxy of GRB 090323 (consistent within 2), which for NOX22 and LMC23 differed by a factor of four.
Given the large uncertainty on the host galaxy dust reddening corrections, we repeated the analysis in which we only applied a host galaxy dust correction if dust reddening was detected at more than 3 significance.This only applies to the two most metal-rich absorbers in our sample; the host galaxy of GRB 090323 and the  emission counterpart of QSO-DLA J0441-4313.We found that the results were only marginally affected, with the points having similar offsets and standard deviations as shown in Fig. 3 and 4. Systematic uncertainties also exist in the absorption line metallicities, primarily from the possible saturation of metal absorption lines in low-and even mid-resolution spectra, and also in the dust depletion corrections.All QSO-DLA absorption line metallicities shown in Fig. 3 and 4 are measured from mid-or high-resolution spectra, and systematic effects should therefore be less of a prob-lem (Wiseman et al. 2017).However, the absorption metallicities for GRB 030323 and GRB 090323 are measured from low resolution data, and these metallicities should therefore be considered as lower limits (Prochaska et al. 2006).We have accordingly plotted these data points with right-pointing arrows, although, as described in section 3.4, we consider the absorption metallicity for GRB 090323 more robust due to the multiple metal lines used to constrain the dust depletion and metallicity.
Dust depletion corrections can be well constrained when multiple metals are used (e.g De Cia et al. 2013Cia et al. , 2016;;Wiseman et al. 2017), although De Cia et al. (2018) also found that corrections based on just the [Zn/Fe] and [S/Fe] relative abundance can give very similar results.An additional advantage of using multiple lines to measure the absorption line metallicity is that the method is also sensitive to -element enhancements, whereby enhanced elements will have relative abundances that lie above the best-fit dust depletion curve provided there are enough Fe-group elements to constrain the depletion curve.Of those GRBs in our sample with absorption metallicities measured in this way (i.e. from Wiseman et al. 2017;Bolmer et al. 2019), only GRB 121024A shows a tentative Si overabundance of ∼ 0.5 dex although no corresponding enhancement is observed in other -elements, such as O or S (Bolmer et al. 2019).The Si abundance therefore appears as an outlier in the fit and does not contribute to the best-fit absorption metallicity.The absorption metallicity for the host galaxies of a further two GRBs was determined from the [S/H] abundance, which if they have an -element enhancement, may overestimate the metallicity by ∼ 0.2 − 0.3 dex (Becker et al. 2012;De Cia et al. 2016, 2024), further increasing the apparent discrepancy between absorption and emission line metallicities.The QSO-DLA absorption metallicities are similarly measured using a range of metals, three of which relied on alpha-element abundances (S or Si), although they all had measured metallicities [M/H]> −0.5, where the agreement between the NOX22 and absorption metallicities is relatively good.Any uncertainties in -element enhancements are therefore likely to bring absorption and emission line metallicities further apart, and although dust depletion corrections introduce some uncertainty to the absorption-based metallicities, these are unable to explain the extent of the disparity with the NOX22 metallicities at the low metallicity end.
We do not see any clear dependence in Fig. 3 and 4 on the emission and absorption metallicity offset of the QSO-DLA data points with impact parameter (i.e.colour of data point), as would be expected if QSO-DLAs with large impact parameters probe correspondingly less enriched material.The QSO-DLA with greatest difference between the emission and absorption line metallicity is QSO-DLA J0958+0549, which has an impact parameter of 20 kpc (Rahmani et al. 2016), whereas the QSO-DLA with the largest impact parameter of 50 kpc (J1436-0051) has an emission line metallicity that is within 0.2 dex of the absorption line metallicity in Fig. 3 and Fig. 4.This is consistent with the relatively shallow (but negative) metallicity gradient reported in the literature out to 20-40 kpc (e.g.Chen et al. 2005;Péroux et al. 2013;Christensen et al. 2014;Rahmani et al. 2016;Rhodin et al. 2018).
The agreement between the absorption and the LMC23 emission line metallicities (and also the DKS16 metallicities) for the GRB and QSO-DLA sample is quite remarkable given that absorption and emission lines probe different phases of the gas, and the measured metallicities are averaged over different regions of the galaxy; either luminosity-weighted over the whole galaxy in emission, or densityweighted along a single sightline through the galaxy in absorption.The standard deviation of the full GRB and QSO-DLA sample is 0.24 dex, which is comparable (if not slightly better) to the scatter that has been observed between   -based and strong line metallicities in recent high- galaxy samples observed with JWST (Laseter et al. 2023;Sanders et al. 2023).The NOX22 metallicities, on the other hand, are systematically larger than the absorption metallicities, even though there may be some weak relation with the absorption line metallicity (Fig. 3).However, the uncertainties on what is the most appropriate emission line diagnostic to use clearly dominates over any statistical uncertainty, and limits the conclusions that can be reached on the relation between the metallicity of the neutral gas ISM probed in absorption and that of ionised star-forming regions probed in emission, or on the effect of single sightline versus galaxyintegrated measurements.

GRB host stellar masses and implied metallicities
Several GRB host galaxies in our sample have stellar masses reported in the literature, which we use to investigate where our GRB host galaxy sample lies on the mass-metallicity relation (MZR).The host galaxies with mass estimates or limits are GRB 030323 (log  ★ / ⊙ < 9.23; Laskar et al. 2011), GRB 050820A (log  ★ / ⊙ = 9.29; Chen et al. 2009), GRB 080804 (log  ★ / ⊙ = 9.28; Perley et al. 2016), GRB 090323 (log  ★ / ⊙ = 10.2;Krühler & Schady 2017), and GRB 121024A (log  ★ / ⊙ = 9.9; Friis et al. 2015).Although the stellar masses are taken from several different references, the majority are determined from fits to the optical through to NIR galaxy spectral energy distribution (SED), and are thus relatively insensitive to assumptions made on the SFR history and dust attenuation prescriptions (e.g.Palmerio et al. 2019).The exception is in the case of the host galaxy of GRB 080804, where the stellar mass is based on a single mid-infrared data point, which can over-estimate  ★ by ∼ 0.4 dex compared to stellar masses from SED fitting.This stellar mass can therefore be considered an upper limit.
Using the best-fit relation of Maiolino et al. (2008) and Mannucci et al. (2009) for galaxies at  ∼ 2.2 and  = 3 − 4, respectively, we estimate the expected (emission line) metallicity given the host galaxy stellar mass.The emission line metallicity diagnostics used in these papers combined a number of line ratios, but the authors state that the results are dominated by the  23 or  3 diagnostic (Maiolino et al. 2008), which is thus comparable to our analysis.More recently Sanders et al. (2021) measured the MZR for a sample of galaxies at  ∼ 2.3 and  ∼ 3.3 from the MOSDEF survey (Kriek et al. 2015).However, in their analysis they used the Bian et al. (2018) metallicity diagnostics, which can differ significantly from the NOX22 calibrations that we used (e.g.see  3 and O 32 panels in Fig. 5), which will cause there to be a systematic difference in the derived metallicities.
For the five host galaxies in our sample with stellar mass estimates, the Maiolino et al. (2008) and Mannucci et al. (2009) MZRs predict metallicities that are on average within ∼ 0.2 dex of the NOX22 and LMC23 metallicities computed in section 4.1.The largest discrepancy is in the  = 3 − 4 MZR, and if we only consider those host galaxies at  = 2 − 3, the predicted and measured metallicities are consistent within 0.01 dex for the R LMC23 metallicities, and within 0.1 dex for the NOX22 diagnostics.GRB host galaxies have also been found to agree well with the fundamental metallicity relation (FMR) (Mannucci et al. 2011;Palmerio et al. 2019), which adds a SFR-dependency to the MZR (FMR; Mannucci et al. 2010).To check this with our sample of GRB hosts with  ★ estimates, we use our H-based SFRs to determine the metallicity predicted by the FMR, but we find that this increases the disagreement between the expected and measured emission line metallicities, with the FMR predicting metallicities that are on average ∼ 0.4 dex larger than we measure using strong emission line diagnostics.A larger sample of host galaxies and a more consistent approach in measuring  ★ is required to investigate further where GRB host galaxies lie in high- MZR and FMR relations.

Emission line ratios
Given that absorption line metallicities are less model-dependent compared to emission line metallicities, we investigate the relation between common emission line ratios and the GRB afterglow absorption metallicity.In Fig. 5 we plot the absorption line metallicity for our GRB host galaxy (red) and QSO-DLA (blue) sample (using the 12 + log (O/H) scale) against the logarithm of the  3 ,  23 , O 32 and  2 line ratios in the top two panels, and against the LMC23 R (left) and the DKS16 N 2 S 2 H line ratios in the bottom two panels.For reference, we also show the best-fit metallicity diagnostics from a number of papers, indicated in the top left figure legend.We show the NOX22 metallicity diagnostics calibrated across the full metallicity range of their sample (yellow solid), as well as the relations for their sample of high H EW galaxies (yellow dotted), which are valid for 12 + log (O/H) < 8.0.The Bian et al. (2018) (BKD18; green dotdashed) and SST23 (solid magenta) relations are generally shifted upwards relative to the NOX22 curves, and the greatest differences are in the O 32 diagnostics, where the SST23 and Bian et al. (2018) relations do not turn over at low metallicities.Note that Bian et al. (2018) did not provide an  2 diagnostic calibration.
The data are in general good agreement with the models for the  23 and  3 diagnostics, especially the GRB data points.However, greater offsets are present in the O 32 and  2 panels, where the curves predict metallicities that are typically larger than the absorption metallicity for a given O 32 or  2 line ratio.Much of the good agreement in the top two panels of Fig. 5 could in part be due to the GRB and QSO-DLA data points lying on the fairly flat portion of the  23 and  3 diagnostics, where the empirical relations between the line ratios and metallicity is fairly weak.As such, an increase in metallicity of 0.3-0.5 dex would shift the GRB data points closer to the O 32 and  2 diagnostics while still maintaining a relatively good agreement with the  23 and  3 diagnostics.
There is better agreement between the data points and the LMC23 best-fit relation (Fig. 5 bottom left panel; black solid curve) than seen for the  23 ,  3 ,  2 and O 32 diagnostics, as expected given the general agreement between the absorption metallicity and LMC23 emission metallicity shown in Fig. 4. Although, as was the case for the  23 and  3 line ratios, the majority of the data points lie close to the LMC23 diagnostic turn over point.A greater sample of data points with low (12 + log (O/H) < 7.7) and high (12 + log (O/H) > 8.5) absorption line metallicities are therefore required to determine how closely the absorption metallicities and galaxy emission line ratios trace each other.
A clear outlier in the top two rows of Fig. 5 and in the R line ratio is the super-solar metallicity data point corresponding to the afterglow of GRB 090323.However, as seen in the bottom right panel, the combined N 2 S 2 H line ratio of this host galaxy is as expected if the absorption metallicity is representative of the nebular gas-phase metallicity.There are two QSO-DLAs with absorption line metallicities that also have detected [N ii]6549,6584 and [S ii]6717,6731 emission lines, which are shown in this figure, and their N 2 S 2 H line ratios are also as expected given their absorption line metallicities.This diagnostic has the additional advantage that it is not double branched.Nevertheless, an important potential limitation of the diagnostic is that is assumes a fixed O/H-N/O relation based on observations in the local Universe that may not be applicable at high- (e.g.Fosbury et al. 2003;Christensen et al. 2012;Bunker et al. 2023;Cameron et al. 2023;Marques-Chaves et al. 2024).We discuss this diagnostic, and specifically the host galaxy of GRB 090323, in greater detail in section 5.2.

Emission line diagnostics
We find remarkable agreement between our sample of GRB and QSO-DLA absorption line metallicities and the LMC23 metallicity diagnostic, with a scatter that is comparable to that seen in high- calibration samples (Laseter et al. 2023;Sanders et al. 2023).This agreement has two important implications for the use of absorption and emission line probes to study the cosmic chemical enrichment.Firstly, it presents the possibility of combining absorption and emission line probes to study the cosmic chemical evolution out to higher redshifts and down to lower mass galaxies than is possible with emission line metallicities alone, even with JWST.Current JWST mass-metallicity samples at  > 4 extend down to  ★ ∼ 10 7  ⊙ and 12 + log(O/H) ∼ 7.5 (Curti et al. 2023a;Nakajima et al. 2023), whereas absorption line metallicities go down to equivalent oxygen abundances 12 + log(O/H) < 7 (e.g.Bolmer et al. 2019;Heintz et al. 2023a), corresponding to  ★ ∼ 10 5 M ⊙ when extrapolating the best-fit  = 4 − 10 MZR from Nakajima et al. (2023).Secondly, it suggests that star forming regions and the interstellar neutral gas have a very similar chemical composition, implying that the multi-phase ISM is well mixed within the galaxy.Furthermore, the similar scatter in the GRB and the QSO-DLA samples implies that the neutral gas is chemically homogeneous out to large distances from the galaxy centre.This would require enriched material within star forming regions to be efficiently distributed through outflows into the CGM in agreement with recent semi-analytic models of galaxy evolution (L-Galaxies 2020; Yates et al. 2021).
Although the scatter is larger in the NOX22 results, there is nevertheless an indication that the emission and absorption metallicities still trace each other.This is especially true when using the  23 diagnostic.These results thus still offer the possibility of combining emission and absorption line probes to study the cosmic chemical evolution in high- galaxies, as long as the relation between emission and absorption metallicities can be quantified with a larger sample.
The NOX22, SST23 and LMC23 diagnostics all yield metallicities for the host galaxy of GRB 090323 (star symbol in Figs. 3 and 4) that are a factor of ∼ 5 smaller than the absorption line metallicity.In contrast, the DKS16 N 2 S 2 H diagnostic gives a metallicity that are in very good agreement with the absorption metallicity for GRB 090323, and the N 2 S 2 H metallicities for the two QSO-DLA counterparts with [N ii]6549,6584 and [S ii]6717,6731 line detections (QSO-DLAS J0441-4313 and J1544+5912) and also consistent with the absorption metalicities (see Fig. 5, bottom right panel).We discuss the N 2 S 2 H diagnostic and the case of GRB 090323 in more detail in the next section.

The host galaxy and afterglow of GRB090323
Aside from appearing as an outlier in the emission and absorption metallicity parameter space, the host galaxy of GRB 090323 was also unusual in its high absorption line metallicity ([M/H]=0.41± 11) compared to the rest of the GRB host galaxy sample, and to the population of GRB-DLAs (e.g.Cucchiara et al. 2015;De Cia et al. 2018), which at  = 3.57, is all the more extraordinary.There is one QSO-DLA in our comparison sample that also has a super-solar absorption line metallicity (J0441-4313), although it is at much lower redshift than GRB 090323 ( = 0.10).
The difference in the NOX22 and LMC23 emission line metallicities considered here and the absorption metallicity of GRB 090323 is driven by the significantly higher  2 and  3 values than expected given its absorption line metallicity (see Fig. 5).In contrast, the N/O ratio determined using the strong line diagnostic from Thurston et al. (1996) is log(N/O) = −0.61±0.13 or log(N/O) = −0.57±0.10 when using the diagnostic from Pérez-Montero & Contini (2009), which although high, is consistent with the N/O-O/H relation from Andrews & Martini (2013) when extrapolated to the super-solar metallicity measured in absorption.This GRB host galaxy therefore has nonstandard line ratios with either enhanced  3 and  2 if the absorption line metallicity is assumed, or, if the  23 and  3 NOX22 emission line metallicities are true, then a significantly enhanced N/O ratio.Below we consider these two possibilities and corresponding implications separately.
The former scenario, where the  2 and  3 lines ratios are enhanced, would have been possible in the presence of an AGN, which can boost the  3 ratio.However, the [O iii]5007/H, [N ii]6584/H and [S ii]6717,6731/H line ratios place the host galaxy of GRB 090323 within the star-forming region of the Baldwin-Phillips-Terlevich, or so-called 'BPT' diagram (Baldwin et al. 1981), and of the [S ii] variant of the BPT diagram (Veilleux & Osterbrock 1987), indicating that the observed line emission is excited by stars only, and not an AGN.Instead, the apparent enhanced [O iii]5007 and [O ii]3726,3729 line fluxes may be a result of selection effects in the current samples used to calibrate the metallicity diagnostics, which do not include high- galaxies with 12 + log(O/H) ≳ 8.4.This would not affect the majority of our galaxy sample, with the host galaxy of GRB 090323 being the only case where the metallicity may be 12 + log(O/H) ≫ 8.4.It is also worth noting that, for its given stellar mass and SFR, the metallicities obtained from the NOX22 diagnostics for the host galaxy of GRB090323 are in reasonable agreement with those inferred from the  23 -dominated MZR at  = 3.5 (12 + log(O/H) = 8.3; Mannucci et al. 2009) and FMR (12 + log(O/H) = 8.55; Mannucci et al. 2010).This at least indicates that the oxygen emission lines in the host galaxy of GRB090323 are comparable to other star-forming galaxies at high- of the same stellar mass and SFR.One way to investigate possible selection effects at high metallicity in diagnostic calibration samples could be to study the dependence between  2 and  3 as a function of stellar mass at high-, which would reduce the selection effects present at the high mass end since no weak spectral lines are needed.
The alternative scenario that the N/O (and thus N/S) ratio is enhanced, would cause the DKS16 metallicity to be over-estimated, since a fixed N/O-O/H relation is assumed in this diagnostic.It would then just be a coincidence that the GRB absorption metallicity and host galaxy log(N/O) ratio are consistent with the locally observed N/O-O/H relation, which is the reason for the good agreement between the absorption and the DKS16 metallicity.A metallicity of 12 + log(O/H) ∼ 8.4 as measured with the NOX22 diagnostics would put the N/O ratio a factor of 10 above what is observed in the local Universe.Although a small sample of nearby GRB host galaxies ( < 0.1) with   -based metallicity measurements have previously been found to have enhanced N/O ratios (Wiersema et al. 2007), the ratios were not as large as is observed in the host galaxy of GRB 090323.The N/O ratio that we report here is based on strong emission lines, and as such is diagnostic-dependent.The Thurston et al. (1996) diagnostic can over-predict N/O by up to 0.3 dex compared to measurements using auroral lines (e.g.Kojima et al. 2017), although this is a worse case scenario.Even when using auroral lines to measure the N/O ratio, there is dispersion in the O/H-N/O relation, which has been found to correlate with EW(H) (Izotov et al. 2006) and SFR (Andrews & Martini 2013).The dispersion has further been found to decrease when considering the relation between N/O and galaxy stellar mass (Pérez-Montero & Contini 2009;Andrews & Martini 2013;Masters et al. 2016).However, even when taking this into account, the N/O ratio observed in the host galaxy of GRB 090323 continues to be ∼ 0.4 dex higher than expected.
N/O ratios enhanced by > 1 dex have been observed in other galaxies at  ≈3-10 with metallicities in the range 12 + log(O/H) = 7.5 − 8.0 and N/O ratios log(N/O) = −0.7 − −0.1 (Fosbury et al. 2003;Christensen et al. 2012;Bunker et al. 2023;Cameron et al. 2023;Marques-Chaves et al. 2024).Such non-standard relative abundances have been observed in globular clusters (GCs), leading to the suggestion that high- galaxies with an enhanced N/O may contain proto-GCs (Cameron et al. 2023;Senchyna et al. 2023;Marques-Chaves et al. 2024).Suggested origins for high N/O ratios at high- are very-massive or super-massive stars that efficiently pollute their environment with hydrogen-burning elements (Gieles et al. 2018;Cameron et al. 2023;Nagele & Umeda 2023;Watanabe et al. 2023;Vink 2023), and the enhancement of nitrogen from the stellar winds of young Wolf-Rayet (WR) stars that are in the hydrogen burning phase (WN phase), with fast rotation further extending this phase (Vangioni et al. 2018;Cameron et al. 2023;Kobayashi & Ferrara 2023;Senchyna et al. 2023;Marques-Chaves et al. 2024).These effects may also occur alongside specific star-formation histories (Kobayashi & Ferrara 2023).Inflows have also been used to explain the N/O enhancement whereby accretion of pristine gas dilutes the metallicity without affecting the N/O ratio (e.g.Köppen & Hensler 2005;Andrews & Martini 2013;Kojima et al. 2017).
The fact that the NOX22 metallicities place the host galaxy of GRB 090323 in a similar region of the N/O-O/H parameter space as other high- galaxies could be taken as indication that the NOX22 metallicities are correct, but an explanation is then needed for why the absorption metallicity is so much larger.One possibility is that the GRB line of sight crossed a particularly metal-rich but nonrepresentative cloud within the host galaxy, which could arise if the galaxy had a very inhomogeneous metallicity distribution.As already mentioned in Section 3.3, two strong absorbers were detected in the afterglow of GRB 090323, which were attributed to absorption from two interacting systems separated by Δ = 660 km s −1 (Savaglio et al. 2012).Both absorbers were found to have super-solar metallicities (Savaglio et al. 2012), but it may be possible that these metal-rich absorbers are mixed in with other regions of metal-poor gas.For example, there is evidence that bursts of star formation and induced pristine gas accretion in strongly interacting galaxies can introduce significant variation in the metallicity of the interacting system (Michel-Dansac et al. 2008;Perez et al. 2011;Torrey et al. 2012;Grønnow et al. 2015;Torrey et al. 2019;Sparre et al. 2022).The absorption metallicity given in Table 4 is the metallicity measured from the total absorption profile (Wiseman et al. 2017).The NOX22 and LMC23 diagnostics considered in this paper are calibrated against stacked SDSS spectra from Curti et al. (2017) at the high metallicity end (12 + log(O/H) ≳ 8.4), and thus the absorption and emission line metallicities both correspond to averaged measurements.To check that the possible contribution to the observed spectrum from two emission components is not the cause of the unusual line ratios, we measured the emission metallicity and N/O ratio using the results from our two component fits to the [N ii]6549,6584 and H lines (Section 3.3 and Fig. A5).The results remained very comparable, with NOX22 metallicities of 12 + log(O/H) ∼ 8.It is therefore not clear what the origin is of the large disagreement between the absorption and NOX22 and LMC23 emission line metallicities for the host galaxy of GRB 090323, with both the possibility of either enhanced  3 and  2 line ratios, or of an enhanced N/O ratio, implying an atypical ISM in a potentially merging galaxy.The N 2 S 2 H diagnostic has also been found to give good agreement with the metallicities of H ii regions predicted by the BPASS (Binary Population and Spectral Synthesis; Stanway et al. 2016;Eldridge et al. 2017;Xiao et al. 2018), and metallicity gradients predicted by the modified L-Galaxies 2000 galaxy evolution model (Yates et al. 2021).Although this may be a byproduct of assumptions made on the N/O-O/H relation in these simulations.It should be possible to further verify the robustness of the N 2 S 2 H diagnostic with future, more sensitive JWST observations capable of detecting the weaker [N ii]6549,6584 and [S ii]6717,6731 line doublets in all but the most metal right galaxies in our sample.

Comparison with simulations
Several efforts have been made to quantify the relation between single sightline absorption metallicities and galaxy-integrated emission line metallicities using cosmological hydrodynamical simulations (Metha & Trenti 2020;Metha et al. 2021;Metha & Trenti 2023;Arabsalmani et al. 2023).These have generally found absorption line metallicities to be lower than emission line metallicities, although the difference is smaller for more metal-rich host galaxies and sightlines.The results from our GRB host galaxy sample are in qualitative agreement with this predication when using the NOX22  23 and  3 diagnostics, with the emission metallicities being generally larger than the absorption metallicities, but with increased agreement for higher metallicity absorbers (see Fig. 3).Arabsalmani et al. (2023) used the Evolution and Assembly of GaLaxies and their Environments (EAGLE) simulations (Schaye et al. 2015) to investigate third parameter dependencies on the absorption-emission line metallicity relation.They found that absorber sightlines with very small impact parameters or offsets from the galaxy centre, which thus probe a higher column density of material within the galaxy disc, had absorption metallicities that were in better agreement with the average metallicity of the star forming regions (probed by emission lines).
In our GRB and QSO-DLA sample we do not find any dependence on the difference in absorption and emission line metallicities with impact parameter (Fig. 3 and 4).However, the impact parameters of our QSO-DLA sample are generally large (> 6 kpc), whereas the good agreement between absorption and emission line metallicities predicted by the EAGLE simulations is generally for impact parameters  < 0. the distribution of QSO-DLA data points thus seems contrary to the predictions from the EAGLE simulations.Nevertheless, there is of course the complication that more massive galaxies will be physically larger, making comparisons between absolute offsets of impact parameters less meaningful.A fairer comparison may thus be to use the impact parameter normalised by the galaxy effective radius, although at  > 2 the emission counterparts to QSO-DLAs appear to have comparable effective radii to GRB host galaxies (Rhodin et al. 2021;Blanchard et al. 2016).
Smaller impact parameters have been found to have larger HI column densities, N HI , (Chen & Lanzetta 2003;Chen et al. 2005;Christensen et al. 2007;Péroux et al. 2016;Krogager et al. 2017;Kulkarni et al. 2022;Arabsalmani et al. 2023), which can be understood by the fact that the sightline probes more central, and thus denser regions of the host galaxy (e.g Krogager et al. 2020).One may therefore expect greater agreement between absorption and emission line metallicities for those sightlines with larger HI column density.N HI is a parameter that is measured for our complete GRB and QSO-DLA sample by selection, and in Fig. 6 we thus plot the emission against absorption line metallicity for the NOX22 and LMC23 diagnostics, as in Figs. 3  and 4, but now with the data points colour-coded by the N HI .There is a possible indication that data points in the lower left of the plots in Fig. 6 have the largest column densities, and N HI decreases as we go to larger metallicities, at the top right corner of the plots.However, the relative offsets between the absorption and emission line metallicities do not show any clear dependence with N HI .The results from Arabsalmani et al. (2023) imply some level of dependency on the relation between absorption and emission metallicities with N HI , but they found large scatter in the relation due to the intrinsic inhomogenities that exist in galaxies.It is therefore possible that we do not see a clear absorption metallicity-emission metallicity-N HI dependence in our observations due to our small sample size.Nevertheless, by investigating the dependence of the relation between the emission and absorption metallicities with N HI we can at least include the GRB host galaxy sample (unlike when considering impact parameter).
The lack of any clear, third-parameter dependency on the relation between absorption and NOX22 emission line metallicities along GRB and QSO-DLA sightlines may also imply that metals within the neutral phase ISM (and possibly also CGM) are poorly mixed, and the scatter observed in Figs. 3 and 6 could thus be indicative of the large intrinsic variation in the regions of the galaxy probed in absorption depending on the line of sight.Sightlines with the same impact parameter and N HI may probe very different regions of the galaxy depending on the galaxy orientation, the stellar mass, and the level of mixing, which in turn is dependent on feedback processes.Moreover, whereas QSO-DLA sightlines will cross through the full radial extent of the intervening galaxy, GRBs may lie at the front side of their host galaxy, and thus on average their sightlines will cross through 50% of the galaxy along the radial direction.However, the good agreement between absorption and emission line metallicities when using the R diagnostic implies that the metallicity of the ionised and neutral material is relatively homogeneous, and that the effect of any metallicity gradients are averaged out along the radial and longitudinal direction in absorption and emission line probes.To understand the lack of an N HI -dependency in this case may therefore require analysis using zoom-in hydrodynamic simulations that include the relevant physics on the formation of molecular clouds and stellar feedback that is necessary to capture the smaller scale inhomogeneities present in star forming regions and the ISM.
It will also be important to increase the samples of QSO-DLA and GRBs with both emission and absorption line metallicites in order to be able to average out the intrinsic scatter that is likely introduced by the pencil-beam sightline offered by GRBs and QSO-DLAs.Knowing the characteristic properties of the GRB host galaxies and QSO-DLA emission counterparts is also important to be able to study the emission-absorption metallicity relation in bins of stellar mass, normalised impact parameter and N HI , for example.

CONCLUSIONS
In this paper we present the first investiation on a sample of GRB host galaxies on the relation between the gas-phase metallicity in star forming regions and in the neutral cold interstellar gas.This is probed through emission and absorption using the incredible IR sensitivity of NIRSpec as part of our cycle-1 JWST programme.We find good agreement between the absorption metallicities and the emission metallicities determined with the LMC23 R diagnostic ( = 0.2 dex).The DKS16 N 2 S 2 H diagnostic also shows promise, but a larger sample of galaxies with [S ii]6717,6731 detections is required to verify the consistency with the N 2 S 2 H diagnostic.Although our results are dependent on the emission line metallicity diagnostic, we find that, when considering only the most reliable emission diagnostics, there is a relation between the two metallicity probes (even if not one-to-one).This opens the possibility of combining both emission and absorption line probes in the future to study the cosmic chemical evolution down to lower mass galaxies than is currently possible through emission line studies alone.At high- GRBs are likely to have small and faint host galaxies that could be significant sources of ionising photons (Salvaterra et al. 2013), but for which spectra cannot be taken even with NIRSpec.The combination of emission and absorption line probes could therefore provide a less biased view of the chemical enrichment of galaxies at high-.
The first results on new strong-line metallicity diagnostics for high- galaxies based on sensitive JWST data have started to be published, but significant progress is still required in the size of the calibration samples currently available, and especially in the range of galaxy properties covered by the calibration samples.A more conclusive analysis on the relation between emission and absorption line metallicities may thus require GRB host galaxies with direct,  based emission line metallicities.In order to detect the temperaturesensitive, weak auroral lines in our sample of GRB host galaxies, of which [O iii]4363 is the strongest, each galaxy would need to be observed for several hours, even with JWST.Nevertheless, the resulting observations would provide possibly the only definitive result on how absorption and emission line metallicities compare, paving a way for both probes to be used in unison, as well as enabling the relation between the ionised and neutral phase gas in the ISM of high- galaxies to be investigated.

)Figure 1 .
Figure 1.Surface brightness (SB) map of the G140M/L100LP NIRSpec IFS observations of the host galaxy of GRB 050820A at  abs = 2.615 centred on [O iii]5007.A number of resolved emission regions are detected, including components A and B identified in Chen (2012) and labelled in the image above.The position of the GRB afterglow is indicated with an 'X', which lies close to a third emission component, labelled here as C. Additional emission can also be seen to the left of region C, which is only detected at 1.79m, consistent with [O iii]5007 at  = 2.615.However no corresponding emission from [O iii]4959 or H at this same redshift is detected at this location.The image is orientated with north up and east left.The pixel scale of the image is 0. ′′ 1, corresponding to 819 pc, and the offset from the image centre in kpc is indicated along the axes.Observations were taken with a two-point dither, which is why the shape of the field of view comprises two overlapping squares.

)Figure 2 .
Figure 2. Surface brightness (SB) map of the G140M/L100LP IFS observations of the host galaxy of GRB 150403A centred on [O iii]5007 at  = 2.057.A number of resolved emission regions are detected, and the labels A, B and C indicate the regions where stacked spectra have been extracted.Region B is itself resolved into multiple components.The position of the GRB afterglow is just west of component C, marked with a 'X', and the corresponding 1 positional uncertainty is indicated with the white dashed circle.Note that no background subtraction has been applied and the colour bar thus does not go down to zero.The image is oriented with north up and east left.The pixel scale of the image is 0. ′′ 1, corresponding to 857 pc, and the offset from the image centre in kpc is indicated along the axes.

(
2003) IMF.The large uncertainties in some cases are dominanted by the uncertainty on the dust correction.§ Velocity width has been corrected for the intrinsic instrument resolution.References: Vreeswĳk et al. (2004); Thöne et al. (2008); Cucchiara et al. (2015); Wiseman et al. (2017); Bolmer et al. (2019) [N ii]6549,6584 or the [S ii]6717,6731 doublet in the majority of our sample.The most common of such line ratios used to trace metallicity are  2 ([O ii]3726,3729/H),  3 ([O iii]5007/H) (also referred to as O 3 ), O 32 ([O iii]5007/[O ii]3726,3729) and  23 (([O ii]3726,3729 + [O iii]4959,5007)/H).Given that our galaxy sample is at  > 2, we only considered diagnostics that have been calibrated to the conditions present in the high- Universe, either using high redshift galaxy samples, or local analogues.We chose to use the Laseter et al. (2023) (LMC23 from hereon) so-called R diagnostic, which is based on a combination of  2 and  3 , and the metallicity diagnostics calibrated by Nakajima et al. (2022) (NOX22 from hereon) and Sanders et al. (

Figure 3 .
Figure 3.The NOX22  23 (left) and NOX22  3 (right) emission line metallicities against absorption line metallicities for our sample of GRB host galaxies and a compilation of QSO-DLAs and emission counterparts taken from Rahmani et al. (2016).The emission line metallicities are in units of [M/H] = log(O/H) − log(O/H) ⊙ .For the host galaxies of GRB050820A and GRB150403A, metallicities for the resolved component closest to the projected GRB afterglow position (components C in both cases; see Figs. 1 and 2) are plotted as an open pentagon and diamond symbol, respectively.For GRB 030323 and GRB 090323 the absorption metallicity is considered a lower limit because they were measured with low resolution spectra, and this is represented in the figures with right-pointing arrows.GRB 090323 is plotted with a star symbol.The host galaxy of GRB 100219A had no [O ii]3726,3729 detection and the  23 emission line metallicity is therefore shown as an upper limit.The QSO-DLA data points are colour-coded by the impact parameter.The dashed line indicates where the absorption and emission line metallicities are equal, and the dotted lines represent the emission line metallicity offset from the absorption metallicity by the amount shown on the label.The number of QSO-DLA and GRB data points in each panel varies due to the need for different line ratios in each metallicity diagnostic.

Figure 4 .
Figure 4. Same as Fig. 3 but now with the emission line metallicity derived from the LMC23 R diagnostic.We additionally show the DKS16 N 2 S 2 H emission line metallicity for GRB 090323 (green star) and for two QSO-DLAs (green triangles), which are the only GRB host galaxy and QSO-DLA emission counterparts in the sample with detected [N ii]6584 and [S ii]6717,6731 emission lines necessary for this diagnostic.

Figure 5 .
Figure 5. GRB host galaxy and QSO-DLA galaxy counterpart absorption line metallicity against the logarithmic line ratios  23 (top left),  3 (top right), O 32 (middle left),  2 (middle right), the LMC23 combined  2 and  3 line ratio diagnostic ( R) (bottom left) and the Dopita et al. (2016) (DKS16) N 2 S 2 H diagnostic (bottom right).All data points are the same as in Fig.3 and 4. The best-fit curves fromBian et al. (2018) (BKD18; green dot-dashed), SST23 (solid magenta), and the NOX22 H EW-averaged (yellow solid) and high H EW (yellow dotted) relations are overplotted in the top four panels for reference.Note thatBian et al. (2018) did not provide an  2 diagnostic.
3 and slightly lower N/O ratios in the range log(N/O) ∼ −0.7 − −0.8, but still well above the typical values expected from the locally observed N/O-O/H relation.

Figure 6 .
Figure 6.The NOX22  23 and  3 and the LMC23 R emission line metallicities against absorption line metallicities, as in Fig. 3, but now colour-coded by the HI column density, N HI .
05 *  200 where  200 is the radius from the galaxy centre where the average density is 200 times the critical density at the respective redshift.Typical values of  200 in EAGLE are 40-90 kpc, and 0.05 *  200 thus corresponds to 2.0-4.5 kpc.Nevertheless, although we do not know the offset of the GRB position from the host galaxy centre for the majority of our sample, on average we would expect GRBs to probe the very central regions of their host galaxies.The fact that our GRB sample of data points in Fig 3 and 4 do not appear to lie closer to the line of equality (black dashed) than

Figure A1 .
Figure A1.Emission line spectra of the host galaxy of GRB 050820A, taken from components A (top), B (middle) and C (bottom).The spectra are zoomed in on [O ii]3726,3729 (left), H and [O iii]4959,5007 (centre), and H (right).In all cases the redshift and velocity dispersion were fixed to the best-fit values to H and the [O iii]4959,5007 doublet.The best-fit velocity to the lines from component C was below the instrumental resolution, and it was therefore left as a free parameter for all lines, but the redshift was fixed to the best-fit value to H and [O iii]4959,5007.The location of the undetected [N ii]6549,6584 line doublet is indicated in the right-most panel in each row.The vertical dotted lines correspond to the observer-frame position of H for a systemic redshift  = 2.6133 determined from the galaxy-integrated spectrum, which provides an indication of the relative velocity shift of each component.A summary of the best-fit parameters and line fluxes are given in Table2.

Figure A2 .
Figure A2.Emission line spectra of the host galaxy of GRB 150403A, taken from components A (top), B (middle) and C (bottom).The spectra are zoomed in on [O ii]3726,3729 (left), H and [O iii]4959,5007 (centre), and H (right).For component A, the redshift and velocity dispersion was fixed to the best-fit values to H and the [O iii]4959,5007 doublet.The best-fit velocity to the lines from component B and C were below the instrumental resolution, and it was therefore left as a free parameter for all lines, but the redshift was fixed to the best-fit values fitted to H and [O iii]4959,5007.As in Fig.A1, the location of the undetected [N ii]6549,6584 line doublet is indicated in the right-most panel in each row, and the vertical dotted lines correspond to the observer-frame position of H for a systemic redshift  = 2.0570 determined from the galaxy-integrated spectrum.A summary of the best-fit parameters and line fluxes are given in Table2.

Figure A3 .
Figure A3.Spectrum of the host galaxy of GRB030323 (blue data points) zoomed in on the tentative [O ii]3726,3729 emission line doublet detection (left), H and [O iii]4959,5007 emission lines (middle) and on H (right), with best-fit model overplotted (black line).The location of the undetected [N ii]6549,6584 line doublet is indicated in the right panel.The best-fit velocity dispersion and redshift fitted to H is  = 3.3710 and  = 80 ± 15 km s −1 , and these values were fixed in the fit to H, [O iii]4959,5007 and [O ii]3726,3729.

Figure A4 .Figure A5 .
Figure A4.Detected emission lines (blue data points) from the host galaxy of GRB 080804 from [O ii]3726,3729 (left), H and the [O iii]4959,5007 doublet (middle), and H (right), with best-fit model (black line).The location of the undetected [N ii]6549,6584 line doublet is indicated in the right panel.The best-fit velocity dispersion and redshift from fits to H are  = 2.2065 and  = 148 ± 23 km s −1 , and these best-fit parameters were frozen in the fits to H, [O iii]4959,5007 and [O ii]3726,3729.

Figure A7 .Figure B1 .
Figure A7.Emission line spectra of the host galaxy of GRB 100219A (blue data points) zoomed in on H and [O iii]4959,5007 (left), and the tentative H emission line detection (right).The location of the undetected [N ii]6549,6584 line doublet is indicated in the right panel.The best-fit velocity dispersion and redshift from simultaneous fits to H and [O iii]4959,5007 are  = 4.6698 and  = 66 ± 9 km s −1 .The line peak positions and velocity widths were kept fixed to the best-fit values fitted to the H and [O iii]4959,5007 lines.

Table 1 .
GRB host galaxy sample and details on JWST/NIRSpec observations

Table 4 .
Krühler et al. (2015)ion line properties.The host galaxies of GRB 120815A and GRB 121024A, listed separately at the bottom of the table, were not observed with NIRSpec, and instead line flux measurements were available from X-shooter observations inKrühler et al. (2015).
(Asplund et al. 2009etallicity relative to solar and corrected for dust depletion.To convert to units of [M/H], more commonly used in GRB absorption line studies, need to subtract the solar metallicity value 12+log(O/H)=8.69(Asplundetal.2009).‡SFR derived from the Galactic and host galaxy dust extinction corrected H luminosity using the Kennicutt (1998) relation adopting a Chabrier

Table 2 .
Emission line spectra of the host galaxy of GRB 090323, corresponding to [O ii]3726,3729 (left), H and [O iii]4959,5007 (middle), and [S ii]6717,6731 (right).The line peak positions and velocity widths were kept fixed to the best-fit values fitted to the H and [N ii]6549,6584 lines (Fig. A5).Note, the data blueward of 1.71 m shown in the fit to [O ii]3726,3729 all show zero flux because they lie below the effective lower-bound of the F170LP filter.