When the echo of gunfire stilled in Christchurch that awful day, one of Facebook's most senior executives was quick to present the company as a willing solution to the massacre it had broadcast live.
"My deepest condolences for the attack that took place yesterday," wrote chief operating officer Sheryl Sandberg at 6.39am, the morning after the March 15 attack, to Prime Minister Jacinda Ardern.
"It's absolutely heartbreaking. I'm keeping the people of New Zealand in my thoughts and wishing you all strength during this difficult time.
The email - one of many released through the Official Information Act - would have arrived by the time Ardern had arrived in Christchurch, donned a hijab and walked into grief.
• Big Read: The hunt for a 'lone wolf' killer.
• Spies knew of security gaps and developed plan to keep New Zealand safe
• 'Small' improvements to spy problems after $179m upgrade
• Big Read: Four months after the massacre - how Christchurch changed.
The correspondence is a fascinating insight into the social media giant's response and the Prime Minister's careful, distant approach. Valued at $835 billion, its value is almost three times the value of New Zealand's GDP. With 2.4bn members, Facebook's global population was vastly larger than New Zealand's 4.5m population.
For all the disparity, Ardern and Sandberg had met previously in November 2017 under the auspices of the Facebook executive's LeanIn charity, promoting women leadership. The following year, Ardern was named in Time magazine's Top 100 influential people list. Her photograph ran with an extended caption, written by Sandberg.
Now Sandberg was writing to Ardern, not about her. She told the Prime Minister: "My team is fully engaged with the police and standing by ready to help however we can."
While the alleged shooter was quickly arrested, and charged with murder, detectives had only begun the arduous investigation into the weeks and months which preceded the deaths of 51 people.
"We are sending a member of our law enforcement team to New Zealand to support on the ground," she wrote. "We removed both the shooter's Facebook and Instagram accounts and the video."
'All Muslims are terrorists': Man in Trump T-shirt sentenced for rant outside mosque
His worshippers gunned down before his eyes: Imam's tearful interview
The hunt for answers - what you need to know about the massacre inquiry
By this time, Ardern had been clear to label the massacre a "terrorist act".
This wasn't the language Sandberg used. Instead, she labelled the mass-killing a "crime", promising to remove any content which praised the act or its alleged perpetrator.
Signing off, Sandberg told the Prime Minister she was "personally" available if more was required of Facebook.
"Please don't hesitate to reach out to me personally if there's anything else we can do."
Sandberg's email wasn't the first from Facebook, but signalled the entry of one of the most senior executives at the global media player. It was Sandberg who, on joining the company in 2008, designed the strategy which made profitable inside two years.
She became the 14th person to sit on the company's board in 2012, and the first woman.
When the Cambridge Analytica scandal broke, and when Facebook was drawn into allegations of Russian interference in the United States' elections, it was Sandberg who managed its public image.
Facebook - first contact
The first Facebook contact came the day of the attack, in an email from Sydney-based Mia Garlick, Facebook's policy director for Australia and New Zealand. In the month to come, Garlick handled much of Facebook's communication with the Prime Minister's office, through Raj Nahna, deputy chief of staff at the time and now chief of staff, and Andrew Campbell, Ardern's chief press secretary.
Garlick's initial email came just hours after the attack, expressing sympathy and offering a quick summary of the company's immediate efforts. She said it had been told of the livestream by police in New Zealand, removing and the alleged shooter's accounts "within minutes of being notified of it".
All content praising or supporting "the shooter or shooters" - it was early days and initial reports suggested conspirators - would be removed, as would "any content of which we become aware that mocks the victims". Also, Facebook would "memorialise" or delete pages belonging to those who were victims of the attack.
Garlick then explained she was boarding a 14-hour flight and asked, if they needed to make contact before she landed, to call the company's public relations manager or, alternately, its New Zealand public relations company.
Sandberg's email to Ardern the following morning was many executive levels higher. It was a communication between two leaders - one whose nation had suffered a horrific tragedy and the other whose company had broadcast it to the world.
It would fall to Garlick, in the month which followed, to deal with the detail and maintain regular contact with Campbell and Nahna on behalf of Facebook.
Three hours after Sandberg's email - and its description of the attack as a "crime" - Garlick was back on the ground and updating Ardern's senior advisers, this time using the term the Prime Minister herself had used to label the massacre.
She said the company's Content Policy team had "designated both shootings as terror attacks". The designation appeared to give Facebook a process it could following, and meant it would remove any "praise, support and representation of the events".
Garlick said the company had removed the initial video and digitally analysed it so as to recognise copies. Tarrant's Facebook and Instagram accounts had also been removed, and the company was stamping out accounts others set up in the name of the accused shooter following the attack.
Seemingly well-practised at the evolution of such attacks, Facebook was alert should "content on our site allege that the event did not happen or that the victims are just actors". If so, it would be removed. In doing so, Garlick foresaw the multitude of Facebook threads which spawned with conspiracy theories.
On Sunday evening, Garlick emailed Ardern's advisers again to signal Facebook was moving in concert with New Zealand's response.
"Following the New Zealand Government's determination that any of the content associated with the attack should be removed - including edited versions shared by news media or by well intentioned member of the public to condemn it - we've begun to remove instances of the video that do not show graphic content."
She was also eager to portray Facebook as active in "our work to remove harmful content of this nature". "Hate speech" breached the company's policies, she said, and its determination was reflected in five million "pieces of content" removed in the first half of 2018. More than half had been reported by other Facebook users.
Campbell responded: "Apologies for the radio silence. As you can imagine we have been run off our feet here responding to the tragedy. Thanks so much for the updates. They are helpful and appreciated."
The direct line Garlick had established with the Prime Minister's Office saw staff sending her directly content which raised concerns. Garlick had also established a line of communication with the Department of Internal Affairs, which administers the laws around broadcast of objectionable material.
Correspondence shows Garlick being notified of content which "doesn't typically violate our policies", yet seeking further clarification from Internal Affairs in case it broke New Zealand law. The move illustrates Facebook's willingness to move beyond its corporate imperative to meet New Zealand's needs, at a time when the company was fielding international criticism and facing a stock price drive. Along with other moves, it also provided advertising credits to domestic mental health services.
Facebook offers to brief Ardern
Garlick was also seeking an opportunity to get Facebook and the Prime Minister together, making a "formal offer" for Ardern, or officials, to meet with a "senior delegation of Facebook representatives".
Information continued to flow in both directions, with Garlick sending Campbell and Nahna an "urgent heads up" on Monday evening - a preview of a statement Facebook was about to release "a timeline of what we know so far about how our service was used in the attack and what we did in response".
"We understand that people have questions and want answers and we have been working to identify what information we can share."
The proposed public statement contained five specific time markers, three of which had Campbell write to Garlick with urgency.
"Can you please stop this post going," he wrote. "I can see this post causing significant concern and contains information relevant to the police investigation."
The three points Facebook intended publicising were redacted in the material supplied to the Herald. Campbell specifically highlighted the first point - possibly when the alleged shooter began livestreaming or registered his Facebook account - as a detail which should not be made public.
It was enough to prompt a call to Garlick from Assistant Commissioner Richard Chambers. Campbell was told by a colleague "police have a very good relationship with Facebook".
"He has advised her the time in the first three bullet points should not be publicly released (crucial to investigation)." If Facebook was to produce a timeline, it should start from the point police contacted Facebook to alert it to the livestream.
Campbell: "Great, good outcome then. Yes, it was the initial times that alarmed me."
Garlick noted Facebook "was being pressed by media to respond" and edited its press release after Campbell's intervention. It took almost 24 hours before police were comfortable with Facebook's public response, which published the Tuesday after the attacks.
The press release also had Facebook detailing the steps it had taken to deal with the video content, and the reaction.
The company's desire to present its story came as Ardern pointed the finger squarely at social media companies, saying: "We cannot simply sit back and accept that these platforms just exist and that what is said on them is not the responsibility of the place where they are published. They are the publisher. Not just the postman."
Garlick continued to push for a meeting between Ardern and a Facebook delegation, led by a global vice-president - to provide a " detailed briefing" on the company's response.
Along with its management of the aftermath of the tragedy, Facebook wanted to discuss "areas for further collaboration" with the New Zealand Government "to address online hate and improve out strategic relationships in crisis situations".
A week on, Facebook marked the passage of time with a message displayed across its platform. Garlick told Campbell and Nahna: "We were asked by the Department of Internal Affairs to make a gesture today as a mark of respect for today's Nationwide reflection and have started to show everyone in New Zealand the below prompt."
The "prompt" carried a fern emblem with the message: "Together in tears, together in hope." The 1737 mental health helpline number was included.
Garlick's email also showed Facebook expanding its response beyond the livestream of the Christchurch attack. It was now "improving our matching technology so that we can stop the spread of viral videos of this nature". It was also "reacting faster to this kind of content on a live streamed video" and "continuing to combat hate speech of all kinds on our platform".
"Our Community Standards prohibit terrorist and hate groups of all kinds. This includes more than 200 white supremacist organisations globally, whose content we are removing through proactive detection technology."
For all Facebook was claiming it was policing its platform, the inherent weakness in its structure was exposed again in an email from the Office of the Prime Minister that afternoon.
Around the time of the two minutes silence - which Garlick had said Facebook staff would be joining - an unnamed Beehive staffer emailed: "Hi Mia, I think this is a video showing a deceased body (sorry) that needs to be taken down."
That same day, Privacy Commissioner John Edwards emailed Facebook about its response so far.
"It would be very difficult for you and your colleagues to overestimate the growing frustration and anger here at Facebook's facilitation of and inability to mitigate the deep, deep pain and harm from the live-streamed massacre of our colleagues, family members and countrymen broadcast over your network.
"Your silence is an insult to our grief."
Mark Zuckerberg emerges
The following Monday - 10 days after the attacks - the name of Facebook founder Mark Zuckerberg was mentioned for the first time.
Garlick told Campbell and Nahna the company was taking part in a summit in Brisbane the following day, organised by the Australian government to discuss the Christchurch attack. Four Facebook executives would take part - Garlick, along with the company's global head of cyber security, Nathaniel Gleicher, its Asia-Pacific heads of counter-terrorism (Gullnaz Baig) and head of law enforcement (Jeff Wu).
Garlick reiterated her offer of a Facebook delegation. It had been almost a week since she first made the offer and there is no sign it had been accepted.
She also repeated an offer of video chats or phone calls to answer "any immediate questions", "including from our Chief Executive Officer Mark Zuckerberg".
The following day - as the Australian summit gathered - Garlick sent copies of the presentations the Facebook executives were going to make.
By this stage, there was still no apparent acceptance by the Prime Minister's office of the offer to meet with a Facebook delegation.
Garlick told Campbell and Nahna she was heading to New Zealand anyway, to "meet with the New Zealand telco sector" and "discuss industry responses".
She was also intending to meet with Netsafe - "our long standing safety partner" - and "possibly also the New Zealand Privacy Commissioner given his very public concerns about our response to date".
There is no indication this led to Facebook's sought-after meeting with Ardern, who took almost a month to respond to Sandberg's original email.
In that time, Ardern's response had won plaudits internationally. She had been publicly critical of Facebook's delay removing the livestream, apparently because its software didn't detect the content because of a lack of obvious "gore".
Ardern had already forecast a desire to see global action, and was only a week away from attempting to use some of that capital in announcing the "Christchurch Call", which would aim to "bring to an end the ability to use social media to organise and promote terrorism and violent extremism".
It was in this space Ardern finally wrote back to Sandberg, copying in Garlick.
"I wanted to send a personal note to say thank you for your recent message of condolence in the wake of the terrorist attack on the 15th of March.
"As I know you will have observed, New Zealand has been experiencing a period of shock and grief following the attack, which has been unlike anything we have experienced before."
There had been offers of contact and briefings from Facebook, Ardern acknowledged, "which we have not taken up formally to date".
"I did personally want to follow up, though, on the offer of a phone call with Mark as your Chief Executive …" she wrote.
She agreed, she said, with sentiments he had conveyed after the attack. "I share the view that a collective approach needs to be taken by the global community if we are to successfully tackle the challenges we face. I'd welcome the opportunity to discuss that with Mark at the earliest convenience."
Sandberg responds: "Thank you for your note - and more importantly, for your leadership during what I know has been an incredibly difficult time."
Acknowledging Facebook had "more work to do", Sandberg connected Ardern with Zuckerberg's assistant to "find time for your two to connect".
The following afternoon, Ardern spoke to Zuckerberg. It was 33 days since the massacre.
Ardern's Christchurch Call summit took place a month later, attended by world leaders and powerful tech company executives.
Zuckerberg did not come, even though asked by Ardern. Sandberg, also, didn't show.
It was a year since Sandberg had written in Time magazine : "In a world that too often tells women to stay small, keep quiet – and that we can't have both motherhood and a career – Jacinda Ardern proves how wrong and outdated those notions of womanhood are.
"She's not just leading a country. She's changing the game."
Facebook's briefing to the Australian ministerial summit, March 2019.