Merge mozilla-central to inbound
authorarthur.iakab <aiakab@mozilla.com>
Sat, 29 Sep 2018 07:18:21 +0300
changeset 487176 5474778a6ee33a20620ba2a2b962456887c082bf
parent 487152 77168ec151a961b6c8676f143ca9d2847b2921ee (current diff)
parent 487175 13b0256be4492426f51005b65d3526f7ca89683e (diff)
child 487177 0236f549f73f1e220ba0d44e7a3e350c252dd2a4
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
milestone64.0a1
Merge mozilla-central to inbound
devtools/client/shared/source-map/dwarf_to_json.wasm
--- a/browser/app/macbuild/Contents/Info.plist.in
+++ b/browser/app/macbuild/Contents/Info.plist.in
@@ -242,10 +242,16 @@
 	<dict>
 		<key>org.mozilla.updater</key>
 		<string>identifier "org.mozilla.updater" and ((anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9]) or (anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] and certificate leaf[field.1.2.840.113635.100.6.1.13] and certificate leaf[subject.OU] = "43AQ936H96"))</string>
 	</dict>
   <key>MozillaDeveloperRepoPath</key>
   <string>%MOZ_DEVELOPER_REPO_PATH%</string>
   <key>MozillaDeveloperObjPath</key>
   <string>%MOZ_DEVELOPER_OBJ_PATH%</string>
+
+  <key>NSCameraUsageDescription</key>
+  <string>Only sites you allow within %MAC_APP_NAME% will be able to use the camera.</string>
+
+  <key>NSMicrophoneUsageDescription</key>
+  <string>Only sites you allow within %MAC_APP_NAME% will be able to use the microphone.</string>
 </dict>
 </plist>
--- a/browser/app/winlauncher/LauncherProcessWin.cpp
+++ b/browser/app/winlauncher/LauncherProcessWin.cpp
@@ -94,17 +94,21 @@ ProcessCmdLine(int& aArgc, wchar_t* aArg
   mozilla::LauncherFlags result = mozilla::LauncherFlags::eNone;
 
   if (mozilla::CheckArg(aArgc, aArgv, L"wait-for-browser",
                         static_cast<const wchar_t**>(nullptr),
                         mozilla::CheckArgFlag::RemoveArg) == mozilla::ARG_FOUND ||
       mozilla::CheckArg(aArgc, aArgv, L"marionette",
                         static_cast<const wchar_t**>(nullptr),
                         mozilla::CheckArgFlag::None) == mozilla::ARG_FOUND ||
-      mozilla::EnvHasValue("MOZ_AUTOMATION")) {
+      mozilla::CheckArg(aArgc, aArgv, L"headless",
+                        static_cast<const wchar_t**>(nullptr),
+                        mozilla::CheckArgFlag::None) == mozilla::ARG_FOUND ||
+      mozilla::EnvHasValue("MOZ_AUTOMATION") ||
+      mozilla::EnvHasValue("MOZ_HEADLESS")) {
     result |= mozilla::LauncherFlags::eWaitForBrowser;
   }
 
   if (mozilla::CheckArg(aArgc, aArgv, L"no-deelevate",
                         static_cast<const wchar_t**>(nullptr),
                         mozilla::CheckArgFlag::CheckOSInt |
                         mozilla::CheckArgFlag::RemoveArg) == mozilla::ARG_FOUND) {
     result |= mozilla::LauncherFlags::eNoDeelevate;
--- a/browser/components/extensions/parent/ext-chrome-settings-overrides.js
+++ b/browser/components/extensions/parent/ext-chrome-settings-overrides.js
@@ -282,16 +282,20 @@ this.chrome_settings_overrides = class e
       let params = {
         template: searchProvider.search_url,
         iconURL: searchProvider.favicon_url,
         alias: searchProvider.keyword,
         extensionID: extension.id,
         suggestURL: searchProvider.suggest_url,
         queryCharset: "UTF-8",
       };
+      if (searchProvider.search_url_post_params) {
+        params.method = "POST";
+        params.postData = searchProvider.search_url_post_params;
+      }
       Services.search.addEngineWithDetails(searchProvider.name.trim(), params);
       await ExtensionSettingsStore.addSetting(
         extension.id, DEFAULT_SEARCH_STORE_TYPE, ENGINE_ADDED_SETTING_NAME,
         searchProvider.name.trim());
       if (extension.startupReason === "ADDON_UPGRADE") {
         let engine = Services.search.getEngineByName(searchProvider.name.trim());
         if (isCurrent) {
           Services.search.currentEngine = engine;
--- a/browser/components/extensions/schemas/chrome_settings_overrides.json
+++ b/browser/components/extensions/schemas/chrome_settings_overrides.json
@@ -61,17 +61,17 @@
                     "format": "url",
                     "preprocess": "localize",
                     "deprecated": "Unsupported on Firefox at this time."
                   },
                   "search_url_post_params": {
                     "type": "string",
                     "optional": true,
                     "preprocess": "localize",
-                    "deprecated": "Unsupported on Firefox at this time."
+                    "description": "POST parameters to the search_url as a query string."
                   },
                   "instant_url_post_params": {
                     "type": "string",
                     "optional": true,
                     "preprocess": "localize",
                     "deprecated": "Unsupported on Firefox at this time."
                   },
                   "image_url_post_params": {
--- a/browser/components/newtab/aboutNewTabService.js
+++ b/browser/components/newtab/aboutNewTabService.js
@@ -15,17 +15,17 @@ ChromeUtils.defineModuleGetter(this, "Ab
                                "resource:///modules/AboutNewTab.jsm");
 
 const TOPIC_APP_QUIT = "quit-application-granted";
 const TOPIC_LOCALES_CHANGE = "intl:app-locales-changed";
 const TOPIC_CONTENT_DOCUMENT_INTERACTIVE = "content-document-interactive";
 
 // Automated tests ensure packaged locales are in this list. Copied output of:
 // https://github.com/mozilla/activity-stream/blob/master/bin/render-activity-stream-html.js
-const ACTIVITY_STREAM_BCP47 = "en-US ach an ar ast az be bg bn-BD bn-IN br bs ca cak crh cs cy da de dsb el en-CA en-GB eo es-AR es-CL es-ES es-MX et eu fa ff fi fr fy-NL ga-IE gd gl gn gu-IN he hi-IN hr hsb hu hy-AM ia id it ja ja-JP-macos ka kab kk km kn ko lij lo lt ltg lv mai mk ml mr ms my nb-NO ne-NP nl nn-NO oc pa-IN pl pt-BR pt-PT rm ro ru si sk sl sq sr sv-SE ta te th tl tr uk ur uz vi zh-CN zh-TW".split(" ");
+const ACTIVITY_STREAM_BCP47 = "en-US ach an ar ast az be bg bn-BD bn-IN br bs ca cak crh cs cy da de dsb el en-CA en-GB eo es-AR es-CL es-ES es-MX et eu fa ff fi fr fy-NL ga-IE gd gl gn gu-IN he hi-IN hr hsb hu hy-AM ia id is it ja ja-JP-macos ka kab kk km kn ko lij lo lt ltg lv mai mk ml mr ms my nb-NO ne-NP nl nn-NO oc pa-IN pl pt-BR pt-PT rm ro ru si sk sl sq sr sv-SE ta te th tl tr uk ur uz vi zh-CN zh-TW".split(" ");
 
 const ABOUT_URL = "about:newtab";
 const BASE_URL = "resource://activity-stream/";
 const ACTIVITY_STREAM_PAGES = new Set(["home", "newtab", "welcome"]);
 
 const IS_MAIN_PROCESS = Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_DEFAULT;
 const IS_PRIVILEGED_PROCESS = Services.appinfo.remoteType === E10SUtils.PRIVILEGED_REMOTE_TYPE;
 
--- a/browser/components/newtab/content-src/asrouter/asrouter-content.jsx
+++ b/browser/components/newtab/content-src/asrouter/asrouter-content.jsx
@@ -6,16 +6,17 @@ import {MessageContext} from "fluent";
 import {OnboardingMessage} from "./templates/OnboardingMessage/OnboardingMessage";
 import React from "react";
 import ReactDOM from "react-dom";
 import {safeURI} from "./template-utils";
 import {SimpleSnippet} from "./templates/SimpleSnippet/SimpleSnippet";
 
 const INCOMING_MESSAGE_NAME = "ASRouter:parent-to-child";
 const OUTGOING_MESSAGE_NAME = "ASRouter:child-to-parent";
+const ASR_CONTAINER_ID = "asr-newtab-container";
 
 export const ASRouterUtils = {
   addListener(listener) {
     global.RPMAddMessageListener(INCOMING_MESSAGE_NAME, listener);
   },
   removeListener(listener) {
     global.RPMRemoveMessageListener(INCOMING_MESSAGE_NAME, listener);
   },
@@ -35,27 +36,24 @@ export const ASRouterUtils = {
     });
   },
   unblockById(id) {
     ASRouterUtils.sendMessage({type: "UNBLOCK_MESSAGE_BY_ID", data: {id}});
   },
   unblockBundle(bundle) {
     ASRouterUtils.sendMessage({type: "UNBLOCK_BUNDLE", data: {bundle}});
   },
-  getNextMessage() {
-    ASRouterUtils.sendMessage({type: "GET_NEXT_MESSAGE"});
-  },
   overrideMessage(id) {
     ASRouterUtils.sendMessage({type: "OVERRIDE_MESSAGE", data: {id}});
   },
   sendTelemetry(ping) {
     const payload = ac.ASRouterUserEvent(ping);
     global.RPMSendAsyncMessage(AS_GENERAL_OUTGOING_MESSAGE_NAME, payload);
   },
-  getEndpoint() {
+  getPreviewEndpoint() {
     if (window.location.href.includes("endpoint")) {
       const params = new URLSearchParams(window.location.href.slice(window.location.href.indexOf("endpoint")));
       try {
         const endpoint = new URL(params.get("endpoint"));
         return {
           url: endpoint.href,
           snippetId: params.get("snippetId"),
         };
@@ -198,24 +196,24 @@ export class ASRouterUISurface extends R
         }
         break;
       case "CLEAR_ALL":
         this.setState({message: {}, bundle: {}});
     }
   }
 
   componentWillMount() {
-    const endpoint = ASRouterUtils.getEndpoint();
+    const endpoint = ASRouterUtils.getPreviewEndpoint();
     ASRouterUtils.addListener(this.onMessageFromParent);
 
     // If we are loading about:welcome we want to trigger the onboarding messages
     if (this.props.document.location.href === "about:welcome") {
       ASRouterUtils.sendMessage({type: "TRIGGER", data: {trigger: {id: "firstRun"}}});
     } else {
-      ASRouterUtils.sendMessage({type: "CONNECT_UI_REQUEST", data: {endpoint}});
+      ASRouterUtils.sendMessage({type: "SNIPPETS_REQUEST", data: {endpoint}});
     }
   }
 
   componentWillUnmount() {
     ASRouterUtils.removeListener(this.onMessageFromParent);
   }
 
   renderSnippets() {
@@ -229,32 +227,30 @@ export class ASRouterUISurface extends R
         document={this.props.document}>
           <LocalizationProvider messages={generateMessages(this.state.message.content.text)}>
             <SimpleSnippet
               {...this.state.message}
               richText={<RichText text={this.state.message.content.text}
                                   links={this.state.message.content.links}
                                   sendClick={this.sendClick} />}
               UISurface="NEWTAB_FOOTER_BAR"
-              getNextMessage={ASRouterUtils.getNextMessage}
               onBlock={this.onBlockById(this.state.message.id)}
               onAction={ASRouterUtils.executeAction}
               sendUserActionTelemetry={this.sendUserActionTelemetry} />
           </LocalizationProvider>
       </ImpressionsWrapper>);
   }
 
   renderOnboarding() {
     return (
       <OnboardingMessage
         {...this.state.bundle}
         UISurface="NEWTAB_OVERLAY"
         onAction={ASRouterUtils.executeAction}
         onDoneButton={this.clearBundle(this.state.bundle.bundle)}
-        getNextMessage={ASRouterUtils.getNextMessage}
         sendUserActionTelemetry={this.sendUserActionTelemetry} />);
   }
 
   renderPreviewBanner() {
     if (this.state.message.provider !== "preview") {
       return null;
     }
 
@@ -265,34 +261,41 @@ export class ASRouterUISurface extends R
       </div>
     );
   }
 
   render() {
     const {message, bundle} = this.state;
     if (!message.id && !bundle.template) { return null; }
     return (
-      <div>
+      <React.Fragment>
         {this.renderPreviewBanner()}
         {bundle.template === "onboarding" ? this.renderOnboarding() : this.renderSnippets()}
-      </div>
+      </React.Fragment>
     );
   }
 }
 
 ASRouterUISurface.defaultProps = {document: global.document};
 
 export class ASRouterContent {
   constructor() {
     this.initialized = false;
     this.containerElement = null;
   }
 
   _mount() {
-    this.containerElement = global.document.getElementById("snippets-container");
+    this.containerElement = global.document.getElementById(ASR_CONTAINER_ID);
+    if (!this.containerElement) {
+      this.containerElement = global.document.createElement("div");
+      this.containerElement.id = ASR_CONTAINER_ID;
+      this.containerElement.style.zIndex = 1;
+      global.document.body.appendChild(this.containerElement);
+    }
+
     ReactDOM.render(<ASRouterUISurface />, this.containerElement);
   }
 
   _unmount() {
     ReactDOM.unmountComponentAtNode(this.containerElement);
   }
 
   init() {
--- a/browser/components/newtab/content-src/asrouter/schemas/message-format.md
+++ b/browser/components/newtab/content-src/asrouter/schemas/message-format.md
@@ -95,18 +95,20 @@ Name | Type | Example value | Descriptio
 `profileAgeCreated` | Number | `1522843725924` | Profile creation timestamp
 `profileAgeReset` | `Number` or `undefined` | `1522843725924` | When (if) the profile was reset
 `currentDate` | `Date` | `Date 2018-08-22T15:48:04.100Z` | Date object of current time in UTC
 `searchEngines` | `Object` | [example below](#searchengines-example) | Information about the current and available search engines
 `browserSettings.attribution` | `Object` or `undefined` | [example below](#attribution-example) | Attribution for the source of of where the browser was downloaded.
 `providerCohorts` | `Object` | `{onboarding: "hello"}` | Cohorts defined for all providers
 `previousSessionEnd` | `Number` | `1536325802800` | Timestamp in milliseconds of previously closed session
 `totalBookmarksCount` | `Number` | `8` | Total number of bookmarks
-`firefoxVersion` | `Number` | `64` | The major Firefox version of the browser 
+`firefoxVersion` | `Number` | `64` | The major Firefox version of the browser
 `region` | `String` | `US` | Country code retrieved from `location.services.mozilla.com` can be `""` if request did not finish, encountered an error
+`locale` | `String` | `en-US` | Locale of the browser
+`localeLanguageCode` | `String` | `en` | Locale language code (without country code) of the browser
 #### addonsInfo Example
 
 ```javascript
 {
   "addons": {
     ...
     "activity-stream@mozilla.org": {
       "version": "2018.07.06.1113-783442c0",
--- a/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
+++ b/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
@@ -11,17 +11,17 @@ export class ASRouterAdmin extends React
 
   onMessage({data: action}) {
     if (action.type === "ADMIN_SET_STATE") {
       this.setState(action.data);
     }
   }
 
   componentWillMount() {
-    const endpoint = ASRouterUtils.getEndpoint();
+    const endpoint = ASRouterUtils.getPreviewEndpoint();
     ASRouterUtils.sendMessage({type: "ADMIN_CONNECT_STATE", data: {endpoint}});
     ASRouterUtils.addListener(this.onMessage);
   }
 
   componentWillUnmount() {
     ASRouterUtils.removeListener(this.onMessage);
   }
 
@@ -46,16 +46,20 @@ export class ASRouterAdmin extends React
     }
     return () => ASRouterUtils.unblockById(msg.id);
   }
 
   handleOverride(id) {
     return () => ASRouterUtils.overrideMessage(id);
   }
 
+  expireCache() {
+    ASRouterUtils.sendMessage({type: "EXPIRE_QUERY_CACHE"});
+  }
+
   renderMessageItem(msg) {
     const isCurrent = msg.id === this.state.lastMessageId;
     const isBlocked = this.state.messageBlockList.includes(msg.id);
     const impressions = this.state.messageImpressions[msg.id] ? this.state.messageImpressions[msg.id].length : 0;
 
     let itemClassName = "message-item";
     if (isCurrent) { itemClassName += " current"; }
     if (isBlocked) { itemClassName += " blocked"; }
@@ -108,16 +112,17 @@ export class ASRouterAdmin extends React
         </tr>);
       })}
     </tbody></table>);
   }
 
   render() {
     return (<div className="asrouter-admin outer-wrapper">
       <h1>AS Router Admin</h1>
-      <button className="button primary" onClick={ASRouterUtils.getNextMessage}>Refresh Current Message</button>
+      <h2>Targeting Utilities</h2>
+      <button className="button" onClick={this.expireCache}>Expire Cache</button> (This expires the cache in ASR Targeting for bookmarks and top sites)
       <h2>Message Providers</h2>
       {this.state.providers ? this.renderProviders() : null}
       <h2>Messages</h2>
       {this.renderMessages()}
     </div>);
   }
 }
--- a/browser/components/newtab/content-src/components/StartupOverlay/StartupOverlay.jsx
+++ b/browser/components/newtab/content-src/components/StartupOverlay/StartupOverlay.jsx
@@ -26,16 +26,18 @@ export class _StartupOverlay extends Rea
     if (this.props.fxa_endpoint && !this.didFetch) {
       try {
         this.didFetch = true;
         const fxaParams = "entrypoint=activity-stream-firstrun&utm_source=activity-stream&utm_campaign=firstrun&form_type=email";
         const response = await fetch(`${this.props.fxa_endpoint}/metrics-flow?${fxaParams}`);
         if (response.status === 200) {
           const {flowId, flowBeginTime} = await response.json();
           this.setState({flowId, flowBeginTime});
+        } else {
+          this.props.dispatch(ac.OnlyToMain({type: at.TELEMETRY_UNDESIRED_EVENT, data: {event: "FXA_METRICS_FETCH_ERROR", value: response.status}}));
         }
       } catch (error) {
         this.props.dispatch(ac.OnlyToMain({type: at.TELEMETRY_UNDESIRED_EVENT, data: {event: "FXA_METRICS_ERROR"}}));
       }
     }
   }
 
   componentDidMount() {
@@ -64,25 +66,34 @@ export class _StartupOverlay extends Rea
   onInputChange(e) {
     let error = e.target.previousSibling;
     this.setState({emailInput: e.target.value});
     error.classList.remove("active");
     e.target.classList.remove("invalid");
   }
 
   onSubmit() {
-    this.props.dispatch(ac.UserEvent({event: "SUBMIT_EMAIL"}));
+    this.props.dispatch(ac.UserEvent({event: "SUBMIT_EMAIL", ...this._getFormInfo()}));
+
     window.addEventListener("visibilitychange", this.removeOverlay);
   }
 
   clickSkip() {
-    this.props.dispatch(ac.UserEvent({event: "SKIPPED_SIGNIN"}));
+    this.props.dispatch(ac.UserEvent({event: "SKIPPED_SIGNIN", ...this._getFormInfo()}));
     this.removeOverlay();
   }
 
+  /**
+   * Report to telemetry additional information about the form submission.
+   */
+  _getFormInfo() {
+    const value = {has_flow_params: this.state.flowId.length > 0};
+    return {value};
+  }
+
   onInputInvalid(e) {
     let error = e.target.previousSibling;
     error.classList.add("active");
     e.target.classList.add("invalid");
     e.preventDefault(); // Override built-in form validation popup
     e.target.focus();
   }
 
--- a/browser/components/newtab/data/content/activity-stream.bundle.js
+++ b/browser/components/newtab/data/content/activity-stream.bundle.js
@@ -959,16 +959,17 @@ var _extends = Object.assign || function
 
 
 
 
 
 
 const INCOMING_MESSAGE_NAME = "ASRouter:parent-to-child";
 const OUTGOING_MESSAGE_NAME = "ASRouter:child-to-parent";
+const ASR_CONTAINER_ID = "asr-newtab-container";
 
 const ASRouterUtils = {
   addListener(listener) {
     global.RPMAddMessageListener(INCOMING_MESSAGE_NAME, listener);
   },
   removeListener(listener) {
     global.RPMRemoveMessageListener(INCOMING_MESSAGE_NAME, listener);
   },
@@ -988,27 +989,24 @@ const ASRouterUtils = {
     });
   },
   unblockById(id) {
     ASRouterUtils.sendMessage({ type: "UNBLOCK_MESSAGE_BY_ID", data: { id } });
   },
   unblockBundle(bundle) {
     ASRouterUtils.sendMessage({ type: "UNBLOCK_BUNDLE", data: { bundle } });
   },
-  getNextMessage() {
-    ASRouterUtils.sendMessage({ type: "GET_NEXT_MESSAGE" });
-  },
   overrideMessage(id) {
     ASRouterUtils.sendMessage({ type: "OVERRIDE_MESSAGE", data: { id } });
   },
   sendTelemetry(ping) {
     const payload = common_Actions_jsm__WEBPACK_IMPORTED_MODULE_1__["actionCreators"].ASRouterUserEvent(ping);
     global.RPMSendAsyncMessage(content_src_lib_init_store__WEBPACK_IMPORTED_MODULE_2__["OUTGOING_MESSAGE_NAME"], payload);
   },
-  getEndpoint() {
+  getPreviewEndpoint() {
     if (window.location.href.includes("endpoint")) {
       const params = new URLSearchParams(window.location.href.slice(window.location.href.indexOf("endpoint")));
       try {
         const endpoint = new URL(params.get("endpoint"));
         return {
           url: endpoint.href,
           snippetId: params.get("snippetId")
         };
@@ -1154,24 +1152,24 @@ class ASRouterUISurface extends react__W
         }
         break;
       case "CLEAR_ALL":
         this.setState({ message: {}, bundle: {} });
     }
   }
 
   componentWillMount() {
-    const endpoint = ASRouterUtils.getEndpoint();
+    const endpoint = ASRouterUtils.getPreviewEndpoint();
     ASRouterUtils.addListener(this.onMessageFromParent);
 
     // If we are loading about:welcome we want to trigger the onboarding messages
     if (this.props.document.location.href === "about:welcome") {
       ASRouterUtils.sendMessage({ type: "TRIGGER", data: { trigger: { id: "firstRun" } } });
     } else {
-      ASRouterUtils.sendMessage({ type: "CONNECT_UI_REQUEST", data: { endpoint } });
+      ASRouterUtils.sendMessage({ type: "SNIPPETS_REQUEST", data: { endpoint } });
     }
   }
 
   componentWillUnmount() {
     ASRouterUtils.removeListener(this.onMessageFromParent);
   }
 
   renderSnippets() {
@@ -1187,30 +1185,28 @@ class ASRouterUISurface extends react__W
       react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(
         fluent_react__WEBPACK_IMPORTED_MODULE_0__["LocalizationProvider"],
         { messages: generateMessages(this.state.message.content.text) },
         react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(_templates_SimpleSnippet_SimpleSnippet__WEBPACK_IMPORTED_MODULE_9__["SimpleSnippet"], _extends({}, this.state.message, {
           richText: react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(RichText, { text: this.state.message.content.text,
             links: this.state.message.content.links,
             sendClick: this.sendClick }),
           UISurface: "NEWTAB_FOOTER_BAR",
-          getNextMessage: ASRouterUtils.getNextMessage,
           onBlock: this.onBlockById(this.state.message.id),
           onAction: ASRouterUtils.executeAction,
           sendUserActionTelemetry: this.sendUserActionTelemetry }))
       )
     );
   }
 
   renderOnboarding() {
     return react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(_templates_OnboardingMessage_OnboardingMessage__WEBPACK_IMPORTED_MODULE_5__["OnboardingMessage"], _extends({}, this.state.bundle, {
       UISurface: "NEWTAB_OVERLAY",
       onAction: ASRouterUtils.executeAction,
       onDoneButton: this.clearBundle(this.state.bundle.bundle),
-      getNextMessage: ASRouterUtils.getNextMessage,
       sendUserActionTelemetry: this.sendUserActionTelemetry }));
   }
 
   renderPreviewBanner() {
     if (this.state.message.provider !== "preview") {
       return null;
     }
 
@@ -1227,34 +1223,41 @@ class ASRouterUISurface extends react__W
   }
 
   render() {
     const { message, bundle } = this.state;
     if (!message.id && !bundle.template) {
       return null;
     }
     return react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(
-      "div",
+      react__WEBPACK_IMPORTED_MODULE_6___default.a.Fragment,
       null,
       this.renderPreviewBanner(),
       bundle.template === "onboarding" ? this.renderOnboarding() : this.renderSnippets()
     );
   }
 }
 
 ASRouterUISurface.defaultProps = { document: global.document };
 
 class ASRouterContent {
   constructor() {
     this.initialized = false;
     this.containerElement = null;
   }
 
   _mount() {
-    this.containerElement = global.document.getElementById("snippets-container");
+    this.containerElement = global.document.getElementById(ASR_CONTAINER_ID);
+    if (!this.containerElement) {
+      this.containerElement = global.document.createElement("div");
+      this.containerElement.id = ASR_CONTAINER_ID;
+      this.containerElement.style.zIndex = 1;
+      global.document.body.appendChild(this.containerElement);
+    }
+
     react_dom__WEBPACK_IMPORTED_MODULE_7___default.a.render(react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(ASRouterUISurface, null), this.containerElement);
   }
 
   _unmount() {
     react_dom__WEBPACK_IMPORTED_MODULE_7___default.a.unmountComponentAtNode(this.containerElement);
   }
 
   init() {
@@ -1779,17 +1782,17 @@ class ASRouterAdmin extends react__WEBPA
 
   onMessage({ data: action }) {
     if (action.type === "ADMIN_SET_STATE") {
       this.setState(action.data);
     }
   }
 
   componentWillMount() {
-    const endpoint = _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].getEndpoint();
+    const endpoint = _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].getPreviewEndpoint();
     _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].sendMessage({ type: "ADMIN_CONNECT_STATE", data: { endpoint } });
     _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].addListener(this.onMessage);
   }
 
   componentWillUnmount() {
     _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].removeListener(this.onMessage);
   }
 
@@ -1814,16 +1817,20 @@ class ASRouterAdmin extends react__WEBPA
     }
     return () => _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].unblockById(msg.id);
   }
 
   handleOverride(id) {
     return () => _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].overrideMessage(id);
   }
 
+  expireCache() {
+    _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].sendMessage({ type: "EXPIRE_QUERY_CACHE" });
+  }
+
   renderMessageItem(msg) {
     const isCurrent = msg.id === this.state.lastMessageId;
     const isBlocked = this.state.messageBlockList.includes(msg.id);
     const impressions = this.state.messageImpressions[msg.id] ? this.state.messageImpressions[msg.id].length : 0;
 
     let itemClassName = "message-item";
     if (isCurrent) {
       itemClassName += " current";
@@ -1965,20 +1972,26 @@ class ASRouterAdmin extends react__WEBPA
       "div",
       { className: "asrouter-admin outer-wrapper" },
       react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
         "h1",
         null,
         "AS Router Admin"
       ),
       react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
+        "h2",
+        null,
+        "Targeting Utilities"
+      ),
+      react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
         "button",
-        { className: "button primary", onClick: _asrouter_asrouter_content__WEBPACK_IMPORTED_MODULE_0__["ASRouterUtils"].getNextMessage },
-        "Refresh Current Message"
+        { className: "button", onClick: this.expireCache },
+        "Expire Cache"
       ),
+      " (This expires the cache in ASR Targeting for bookmarks and top sites)",
       react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
         "h2",
         null,
         "Message Providers"
       ),
       this.state.providers ? this.renderProviders() : null,
       react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
         "h2",
@@ -5139,16 +5152,18 @@ class _StartupOverlay extends react__WEB
       if (_this.props.fxa_endpoint && !_this.didFetch) {
         try {
           _this.didFetch = true;
           const fxaParams = "entrypoint=activity-stream-firstrun&utm_source=activity-stream&utm_campaign=firstrun&form_type=email";
           const response = yield fetch(`${_this.props.fxa_endpoint}/metrics-flow?${fxaParams}`);
           if (response.status === 200) {
             const { flowId, flowBeginTime } = yield response.json();
             _this.setState({ flowId, flowBeginTime });
+          } else {
+            _this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].OnlyToMain({ type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].TELEMETRY_UNDESIRED_EVENT, data: { event: "FXA_METRICS_FETCH_ERROR", value: response.status } }));
           }
         } catch (error) {
           _this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].OnlyToMain({ type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].TELEMETRY_UNDESIRED_EVENT, data: { event: "FXA_METRICS_ERROR" } }));
         }
       }
     })();
   }
 
@@ -5178,25 +5193,34 @@ class _StartupOverlay extends react__WEB
   onInputChange(e) {
     let error = e.target.previousSibling;
     this.setState({ emailInput: e.target.value });
     error.classList.remove("active");
     e.target.classList.remove("invalid");
   }
 
   onSubmit() {
-    this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].UserEvent({ event: "SUBMIT_EMAIL" }));
+    this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].UserEvent(Object.assign({ event: "SUBMIT_EMAIL" }, this._getFormInfo())));
+
     window.addEventListener("visibilitychange", this.removeOverlay);
   }
 
   clickSkip() {
-    this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].UserEvent({ event: "SKIPPED_SIGNIN" }));
+    this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].UserEvent(Object.assign({ event: "SKIPPED_SIGNIN" }, this._getFormInfo())));
     this.removeOverlay();
   }
 
+  /**
+   * Report to telemetry additional information about the form submission.
+   */
+  _getFormInfo() {
+    const value = { has_flow_params: this.state.flowId.length > 0 };
+    return { value };
+  }
+
   onInputInvalid(e) {
     let error = e.target.previousSibling;
     error.classList.add("active");
     e.target.classList.add("invalid");
     e.preventDefault(); // Override built-in form validation popup
     e.target.focus();
   }
 
--- a/browser/components/newtab/data/content/activity-stream.bundle.js.map
+++ b/browser/components/newtab/data/content/activity-stream.bundle.js.map
@@ -1,1 +1,1 @@
-{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./content-src/activity-stream.jsx","webpack:///(webpack)/buildin/global.js","webpack:///./common/Actions.jsm","webpack:///./content-src/lib/snippets.js","webpack:///./content-src/asrouter/asrouter-content.jsx","webpack:///external \"React\"","webpack:///external \"PropTypes\"","webpack:///./content-src/lib/init-store.js","webpack:///external \"Redux\"","webpack:///./content-src/asrouter/components/ImpressionsWrapper/ImpressionsWrapper.jsx","webpack:///external \"ReactDOM\"","webpack:///./content-src/asrouter/template-utils.js","webpack:///./content-src/components/Base/Base.jsx","webpack:///external \"ReactIntl\"","webpack:///./content-src/components/ASRouterAdmin/ASRouterAdmin.jsx","webpack:///./content-src/components/ConfirmDialog/ConfirmDialog.jsx","webpack:///external \"ReactRedux\"","webpack:///./content-src/components/ErrorBoundary/ErrorBoundary.jsx","webpack:///./content-src/components/ManualMigration/ManualMigration.jsx","webpack:///./common/PrerenderData.jsm","webpack:///./content-src/components/Search/Search.jsx","webpack:///./content-src/lib/constants.js","webpack:///./content-src/components/Sections/Sections.jsx","webpack:///./content-src/lib/link-menu-options.js","webpack:///./content-src/components/LinkMenu/LinkMenu.jsx","webpack:///./content-src/components/ContextMenu/ContextMenu.jsx","webpack:///./content-src/lib/screenshot-utils.js","webpack:///./content-src/components/CollapsibleSection/CollapsibleSection.jsx","webpack:///./content-src/components/SectionMenu/SectionMenu.jsx","webpack:///./content-src/lib/section-menu-options.js","webpack:///./content-src/components/ComponentPerfTimer/ComponentPerfTimer.jsx","webpack:///./common/PerfService.jsm","webpack:///./content-src/components/MoreRecommendations/MoreRecommendations.jsx","webpack:///./content-src/components/PocketLoggedInCta/PocketLoggedInCta.jsx","webpack:///./content-src/components/Topics/Topics.jsx","webpack:///./content-src/components/TopSites/TopSites.jsx","webpack:///./content-src/components/TopSites/TopSitesConstants.js","webpack:///./content-src/components/TopSites/SearchShortcutsForm.jsx","webpack:///./content-src/components/TopSites/TopSite.jsx","webpack:///./content-src/components/StartupOverlay/StartupOverlay.jsx","webpack:///./content-src/lib/detect-user-session-start.js","webpack:///./content-src/lib/asroutercontent.js","webpack:///./node_modules/fluent/src/parser.js","webpack:///./node_modules/fluent/src/types.js","webpack:///./node_modules/fluent/src/builtins.js","webpack:///./node_modules/fluent/src/resolver.js","webpack:///./node_modules/fluent/src/context.js","webpack:///./node_modules/fluent/src/cached_iterable.js","webpack:///./node_modules/fluent/src/fallback.js","webpack:///./node_modules/fluent/src/util.js","webpack:///./node_modules/fluent/src/index.js","webpack:///./node_modules/fluent-react/src/localization.js","webpack:///./node_modules/fluent-react/src/provider.js","webpack:///./node_modules/fluent-react/src/with_localization.js","webpack:///./node_modules/fluent-react/src/markup.js","webpack:///./node_modules/fluent-react/vendor/omittedCloseTags.js","webpack:///./node_modules/fluent-react/vendor/voidElementTags.js","webpack:///./node_modules/fluent-react/src/localized.js","webpack:///./node_modules/fluent-react/src/index.js","webpack:///./content-src/asrouter/components/Button/Button.jsx","webpack:///./content-src/asrouter/components/SnippetBase/SnippetBase.jsx","webpack:///./content-src/asrouter/templates/SimpleSnippet/SimpleSnippet.jsx","webpack:///./common/Dedupe.jsm","webpack:///./common/Reducers.jsm","webpack:///./content-src/asrouter/components/ModalOverlay/ModalOverlay.jsx","webpack:///./content-src/asrouter/templates/OnboardingMessage/OnboardingMessage.jsx","webpack:///./content-src/components/Card/types.js","webpack:///./content-src/components/Card/Card.jsx","webpack:///./content-src/components/TopSites/TopSiteFormInput.jsx","webpack:///./content-src/components/TopSites/TopSiteForm.jsx"],"names":["store","initStore","global","gActivityStreamPrerenderedState","asrouterContent","sendEventOrAddListener","dispatch","ac","AlsoToMain","type","at","NEW_TAB_STATE_REQUEST","ReactDOM","hydrate","document","location","href","documentElement","lang","gActivityStreamStrings","getElementById","enableASRouterContent","addSnippetsSubscriber","globalImportContext","Window","BACKGROUND_PROCESS","UI_CODE","actionTypes","ASRouterActions","_RouteMessage","action","options","meta","from","to","Error","forEach","o","fromTarget","skipLocal","CONTENT_MESSAGE_TYPE","MAIN_MESSAGE_TYPE","OnlyToMain","BroadcastToContent","AlsoToOneContent","target","skipMain","toTarget","OnlyToOneContent","AlsoToPreloaded","PRELOAD_MESSAGE_TYPE","UserEvent","data","TELEMETRY_USER_EVENT","ASRouterUserEvent","AS_ROUTER_TELEMETRY_USER_EVENT","UndesiredEvent","importContext","TELEMETRY_UNDESIRED_EVENT","PerfEvent","TELEMETRY_PERFORMANCE_EVENT","ImpressionStats","TELEMETRY_IMPRESSION_STATS","SetPref","name","value","SET_PREF","WebExtEvent","source","isSendToMain","isBroadcastToContent","isSendToOneContent","isSendToPreloaded","isFromMain","getPortIdOfSender","DATABASE_NAME","DATABASE_VERSION","SNIPPETS_OBJECTSTORE_NAME","SNIPPETS_UPDATE_INTERVAL_MS","SNIPPETS_ENABLED_EVENT","SNIPPETS_DISABLED_EVENT","SnippetsMap","Map","constructor","_db","_dispatch","set","key","_dbTransaction","db","put","delete","clear","SNIPPETS_BLOCKLIST_CLEARED","blockList","get","blockSnippetById","id","includes","push","SNIPPETS_BLOCKLIST_UPDATED","disableOnboarding","DISABLE_ONBOARDING","showFirefoxAccounts","SHOW_FIREFOX_ACCOUNTS","getTotalBookmarksCount","Promise","resolve","TOTAL_BOOKMARKS_REQUEST","RPMAddMessageListener","onMessage","TOTAL_BOOKMARKS_RESPONSE","RPMRemoveMessageListener","getAddonsInfo","ADDONS_INFO_REQUEST","ADDONS_INFO_RESPONSE","connect","_openDB","_restoreFromDb","modifier","reject","transaction","objectStore","onsuccess","event","onerror","error","openRequest","indexedDB","open","deleteDatabase","onupgradeneeded","result","objectStoreNames","contains","createObjectStore","err","console","onversionchange","versionChangeEvent","close","cursorRequest","openCursor","cursor","continue","SnippetsProvider","gSnippetsMap","_onAction","bind","snippetsMap","_refreshSnippets","cachedVersion","appData","version","lastUpdate","needsUpdate","Date","now","snippetsURL","response","fetch","status","payload","text","e","_noSnippetFallback","_forceOnboardingVisibility","shouldBeVisible","onboardingEl","style","display","_showRemoteSnippets","snippetsEl","elementId","innerHTML","scriptEl","getElementsByTagName","relocatedScript","createElement","parentNode","replaceChild","msg","SNIPPET_BLOCKED","concat","init","Object","assign","keys","window","dispatchEvent","Event","initialized","uninit","snippets","initializing","subscribe","state","getState","Prefs","values","ASRouter","allowLegacySnippets","disableSnippets","Snippets","log","INCOMING_MESSAGE_NAME","OUTGOING_MESSAGE_NAME","ASRouterUtils","addListener","listener","removeListener","sendMessage","RPMSendAsyncMessage","blockById","blockBundle","bundle","executeAction","button_action","unblockById","unblockBundle","getNextMessage","overrideMessage","sendTelemetry","ping","getEndpoint","params","URLSearchParams","slice","indexOf","endpoint","URL","url","snippetId","shouldSendImpressionOnUpdate","nextProps","prevProps","message","generateMessages","content","cx","addMessages","ALLOWED_TAGS","b","i","u","strong","em","br","convertLinks","links","sendClick","reduce","acc","linkTag","safeURI","metric","RichText","props","ASRouterUISurface","React","PureComponent","onMessageFromParent","sendImpression","sendUserActionTelemetry","extraProps","message_id","eventType","provider","dataset","do_not_autoblock","onBlockById","clearBundle","setState","componentWillMount","trigger","componentWillUnmount","renderSnippets","renderOnboarding","renderPreviewBanner","render","template","defaultProps","ASRouterContent","containerElement","_mount","_unmount","unmountComponentAtNode","MERGE_STORE_ACTION","EARLY_QUEUED_ACTIONS","SAVE_SESSION_PERF_DATA","PAGE_PRERENDERED","mergeStateReducer","mainReducer","prevState","messageMiddleware","next","au","rehydrationMiddleware","_didRehydrate","isMergeStoreAction","isRehydrationRequest","_didRequestInitialState","INIT","queueEarlyMessageMiddleware","_receivedFromMain","_earlyActionQueue","reducers","initialState","createStore","combineReducers","applyMiddleware","ex","dump","JSON","stringify","stack","VISIBLE","VISIBILITY_CHANGE_EVENT","ImpressionsWrapper","sendImpressionOrAddListener","visibilityState","_onVisibilityChange","removeEventListener","addEventListener","componentDidMount","sendOnMount","componentDidUpdate","children","protocol","isAllowed","warn","PrefsButton","injectIntl","onClick","intl","formatMessage","addLocaleDataForReactIntl","locale","addLocaleData","parentLocale","debounce","func","wait","timer","args","wakeUp","setTimeout","apply","_Base","isFirstrun","body","classList","add","isPrerendered","updateTheme","componentWillUpdate","bodyClassName","filter","v","join","className","App","strings","prefs","hash","BaseContent","openPreferences","onWindowScroll","fixedSearch","SCROLL_THRESHOLD","scrollY","SETTINGS_OPEN","shouldBeFixedToTop","PrerenderData","arePrefsValid","noSectionsEnabled","Sections","section","enabled","length","outerClassName","showSearch","migrationExpired","Base","ASRouterAdmin","findOtherBundledMessagesOfSameTemplate","messages","bundled","handleBlock","handleUnblock","handleOverride","renderMessageItem","isCurrent","lastMessageId","isBlocked","messageBlockList","impressions","messageImpressions","itemClassName","renderMessages","map","renderTableHead","renderProviders","providers","label","bucket","lastUpdated","toString","_ConfirmDialog","_handleCancelBtn","_handleConfirmBtn","DIALOG_CANCEL","eventSource","onConfirm","_renderModalMessage","message_body","body_string_id","visible","icon","cancel_button_string_id","confirm_button_string_id","ConfirmDialog","Dialog","ErrorBoundaryFallback","windowObj","reload","defaultClass","ErrorBoundary","hasError","componentDidCatch","info","FallbackComponent","_ManualMigration","onLaunchTour","onCancelTour","MIGRATION_START","MIGRATION_CANCEL","ManualMigration","_PrerenderData","initialPrefs","initialSections","_setValidation","validation","_validation","invalidatingPrefs","_invalidatingPrefs","oneOf","getPref","indexedDBPrefs","some","anyModifiedPrefs","prefName","pref","order","title","_Search","onInputMount","handleEvent","detail","gContentSearchController","search","input","healthReportKey","IS_NEWTAB","searchSource","ContentSearchUIController","showLogo","Search","documentURI","CARDS_PER_ROW_DEFAULT","CARDS_PER_ROW_COMPACT_WIDE","getFormattedMessage","Section","numRows","rowsPref","maxRows","_dispatchImpressionStats","cardsPerRow","compactCards","matchMedia","matches","maxCards","cards","rows","needsImpressionStats","tiles","link","guid","impressionCardGuids","sendImpressionStatsOrAddListener","shouldSendImpressionStats","collapsed","sendNewTabRehydrated","isCollapsed","wasCollapsed","renderNotified","NEW_TAB_REHYDRATED","Pocket","topics","emptyState","read_more_endpoint","contextMenuOptions","learnMore","privacyNoticeURL","isFirst","isLast","waitingForSpoc","maxCardsPerRow","maxCardsOnNarrow","pocketCta","isUserLoggedIn","useCta","isPocketLoggedInDefined","shouldShowPocketCta","shouldShowTopics","realRows","shouldShowEmptyState","usePlaceholder","isWebExtension","sectionClassName","feed","padding","startsWith","SectionIntl","_Sections","renderSections","sections","enabledSections","sectionOrder","showTopSites","expectedCount","sectionId","split","commonProps","find","s","_OpenInPrivateWindow","site","OPEN_PRIVATE_WINDOW","referrer","userEvent","GetPlatformString","platform","LinkMenuOptions","Separator","EmptyItem","RemoveBookmark","DELETE_BOOKMARK_BY_ID","bookmarkGuid","AddBookmark","BOOKMARK_URL","OpenInNewWindow","OPEN_NEW_WINDOW","typedBonus","BlockUrl","index","BLOCK_URL","open_url","pocket_id","impression","block","pos","WebExtDismiss","string_id","WEBEXT_DISMISS","action_position","DeleteUrl","isEnabled","siteInfo","DIALOG_OPEN","DELETE_HISTORY_URL","forceBlock","ShowFile","SHOW_DOWNLOAD_FILE","OpenFile","OPEN_DOWNLOAD_FILE","CopyDownloadLink","COPY_DOWNLOAD_LINK","GoToDownloadPage","OPEN_LINK","disabled","RemoveDownload","REMOVE_DOWNLOAD_FILE","PinTopSite","searchTopSite","TOP_SITES_PIN","UnpinTopSite","TOP_SITES_UNPIN","SaveToPocket","SAVE_TO_POCKET","pocket","DeleteFromPocket","DELETE_FROM_POCKET","ArchiveFromPocket","ARCHIVE_FROM_POCKET","EditTopSite","TOP_SITES_EDIT","CheckBookmark","CheckPinTopSite","isPinned","CheckSavedToPocket","CheckBookmarkOrArchive","OpenInPrivateWindow","DEFAULT_SITE_MENU_OPTIONS","_LinkMenu","getOptions","isPrivateBrowsingEnabled","propOptions","isDefault","option","userEventData","first","last","onUpdate","LinkMenu","ContextMenu","hideContext","stopPropagation","ContextMenuItem","onKeyDown","shiftKey","ScreenshotUtils","isBlob","isLocal","image","path","createLocalImageObject","remoteImage","createObjectURL","maybeRevokeBlobObjectURL","localImage","revokeObjectURL","isRemoteImageLocal","_CollapsibleSection","onBodyMount","onHeaderClick","onTransitionEnd","enableOrDisableAnimation","onMenuButtonClick","onMenuButtonMouseEnter","onMenuButtonMouseLeave","onMenuUpdate","enableAnimation","isAnimating","menuButtonHover","showContextMenu","sectionBody","scrollHeight","node","undefined","maxHeight","_getSectionBodyHeight","SectionMenuOptions","CheckCollapsed","div","currentTarget","renderIcon","backgroundImage","preventDefault","isCollapsible","extraMenuOptions","showPrefName","active","bodyStyle","CollapsibleSection","DEFAULT_SECTION_MENU_OPTIONS","WEBEXT_SECTION_MENU_OPTIONS","_SectionMenu","extraOptions","splice","SectionMenu","MoveUp","SECTION_MOVE","direction","MoveDown","RemoveSection","CollapseSection","UPDATE_SECTION_PREFS","ExpandSection","ManageSection","ManageWebExtension","OPEN_WEBEXT_SETTINGS","AddTopSite","AddSearchShortcut","TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL","PrivacyNotice","RECORDED_SECTIONS","ComponentPerfTimer","Component","perfSvc","_sendBadStateEvent","_sendPaintedEvent","_reportMissingData","_timestampHandled","_recordedFirstRender","_maybeSendPaintedEvent","_afterFramePaint","callback","requestAnimationFrame","_maybeSendBadStateEvent","_ensureFirstRenderTsRecorded","mark","dataReadyKey","firstRenderKey","parseInt","getMostRecentAbsMarkStartByName","ChromeUtils","import","usablePerfObj","Services","appShell","hiddenDOMWindow","performance","_PerfService","performanceObj","_perf","prototype","str","getEntriesByName","timeOrigin","absNow","entries","mostRecentEntry","startTime","MoreRecommendations","_PocketLoggedInCta","ctaUrl","ctaButton","ctaText","PocketLoggedInCta","Topic","Topics","t","topSiteIconType","customScreenshotURL","tippyTopIcon","faviconRef","faviconSize","screenshot","countTopSitesIconsTypes","topSites","countTopSitesTypes","_TopSites","onEditFormClose","onSearchShortcutsFormClose","_dispatchTopSitesStats","_getVisibleTopSites","topSitesIconsStats","topSitesPinned","searchShortcuts","topsites_icon_stats","topsites_pinned","topsites_search_shortcuts","sitesPerRow","TopSites","TopSitesRows","TOP_SITES_CANCEL_EDIT","TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL","editForm","showSearchShortcutsForm","topSitesRows","TOP_SITES_SOURCE","TOP_SITES_CONTEXT_MENU_OPTIONS","TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS","MIN_RICH_FAVICON_SIZE","MIN_CORNER_FAVICON_SIZE","SelectableSearchShortcut","shortcut","selected","imageStyle","keyword","onChange","SearchShortcutsForm","handleChange","onCancelButtonClick","onSaveButtonClick","shortcuts","isSelected","row","checked","ev","onClose","pinQueue","unpinQueue","alreadyPinned","_searchTopSite","searchVendor","shortURL","UPDATE_PINNED_SEARCH_SHORTCUTS","addedShortcuts","deletedShortcuts","search_vendor","TopSiteLink","screenshotImage","onDragEvent","onKeyPress","_allowDrop","dataTransfer","types","dragged","effectAllowed","setData","blur","button","getNextStateFromProps","imageInState","nextState","componentWillReceiveProps","defaultStyle","isDraggable","topSiteOuterClassName","isDragged","letterFallback","imageClassName","showSmallFavicon","smallFaviconStyle","smallFaviconFallback","hasScreenshotImage","backgroundColor","favicon","draggableProps","onDragEnd","onDragStart","onMouseDown","TopSite","onLinkClick","_getTelemetryInfo","icon_type","iconType","card_type","hostname","altKey","ctrlKey","metaKey","FILL_SEARCH_TERM","onActivate","isContextMenuOpen","activeIndex","TopSitePlaceholder","onEditButtonClick","_TopSiteList","DEFAULT_STATE","draggedIndex","draggedSite","draggedTitle","topSitesPreview","prevTopSites","newTopSites","dropped","_makeTopSitesPreview","TOP_SITES_INSERT","draggedFromIndex","_getTopSites","pinnedOnly","unpinned","siteToInsert","holeIndex","indexStep","shiftingStep","nextIndex","preview","shift","topSitesUI","maxNarrowVisibleIndex","l","slotProps","TopSiteList","_StartupOverlay","onInputChange","onSubmit","clickSkip","initScene","removeOverlay","onInputInvalid","emailInput","overlayRemoved","flowId","flowBeginTime","didFetch","fxa_endpoint","fxaParams","json","show","remove","previousSibling","focus","termsLink","privacyLink","terms","privacy","StartupOverlay","DetectUserSessionStart","_store","_perfService","perfService","_sendEvent","visibility_event_rcvd_ts","didHideOnboarding","allowLegacyOnboarding","MAX_PLACEABLES","entryIdentifierRe","identifierRe","functionIdentifierRe","RuntimeParser","getResource","string","_source","_index","_length","errors","skipWS","getEntry","SyntaxError","skipToNextEntryStart","ch","skipComment","skipSection","getMessage","skipInlineWS","getVariantName","getEntryIdentifier","val","getPattern","attrs","lineStart","getAttributes","skipBlankLines","ptr","getIdentifier","re","lastIndex","exec","start","cc","charCodeAt","getString","substring","eol","firstLineContent","getComplexPattern","buffer","placeables","blankLinesStart","blankLinesEnd","ch2","getPlaceable","variants","getVariants","exp","vars","def","selector","getSelectorExpression","literal","getLiteral","getVariantKey","getCallArgs","test","fun","Array","isArray","lastIndexOf","getNumber","num","defaultIndex","cc0","cc1","parse","parser","FluentType","opts","valueOf","FluentNone","FluentNumber","parseFloat","ctx","nf","_memoizeIntlObject","Intl","NumberFormat","format","match","other","FluentDateTime","dtf","DateTimeFormat","FluentSymbol","pr","PluralRules","select","arg","merge","argopts","unwrapped","opt","MAX_PLACEABLE_LENGTH","FSI","PDI","DefaultMember","env","members","RangeError","MessageReference","_terms","_messages","ReferenceError","VariantExpression","Type","isVariantList","variant","variantKey","AttributeExpression","attrName","SelectExpression","keyCanMatch","expr","Pattern","ExternalArgument","FunctionReference","CallExpression","attr","member","hasOwnProperty","TypeError","_functions","builtins","callee","posargs","keyargs","ptn","dirty","has","useIsolating","_useIsolating","elem","part","WeakSet","locales","functions","_intls","WeakMap","Symbol","iterator","hasMessage","ctor","cache","CachedIterable","iterable","asyncIterator","seen","cur","touchNext","done","mapContextSync","ids","getContextForId","context","remainingCount","foundContexts","fill","mapContextAsync","nonBlank","line","countIndent","indent","ftl","code","lines","indents","common","Math","min","RegExp","replace","contexts","subs","Set","comp","unsubscribe","setMessages","relocalize","getMessageContext","formatCompound","mcx","fallback","isReactLocalization","propName","prop","l10n","getChildContext","Children","only","LocalizationProvider","childContextTypes","propTypes","PropTypes","element","isRequired","isIterable","componentName","withLocalization","Inner","WithLocalization","forceUpdate","displayName","contextTypes","component","TEMPLATE","parseMarkup","omittedCloseTags","area","base","col","embed","hr","img","keygen","param","track","wbr","voidElementTags","menuitem","reMarkup","toArguments","elems","propname","propval","substr","isValidElement","toLowerCase","messageValue","messageAttrs","localizedProps","cloneElement","translationNodes","childNodes","translatedChildren","childNode","nodeType","TEXT_NODE","textContent","localName","sourceChild","Localized","ALLOWED_STYLE_TAGS","Button","tag","border","onBlockClicked","UISurface","onBlock","containerClassName","DEFAULT_ICON_PATH","onButtonClick","onAction","renderTitle","renderTitleIcon","titleIcon","title_icon","renderButton","button_color","button_background_color","button_label","tall","richText","Dedupe","createKey","defaultCreateKey","item","group","groups","globalKeys","valueMap","m","TOP_SITES_DEFAULT_ROWS","TOP_SITES_MAX_SITES_PER_ROW","dedupe","INITIAL_STATE","AS_ROUTER_INITIALIZED","AS_ROUTER_PREF_CHANGED","insertPinned","pinned","pinnedUrls","newLinks","pinIndex","hasMatch","newRows","TOP_SITES_UPDATED","TOP_SITES_PREFS_UPDATED","previewResponse","PREVIEW_RESPONSE","previewUrl","PREVIEW_REQUEST","PREVIEW_REQUEST_CANCEL","SCREENSHOT_UPDATED","PLACES_BOOKMARK_ADDED","bookmarkTitle","dateAdded","bookmarkDateCreated","PLACES_BOOKMARK_REMOVED","newSite","PLACES_LINK_DELETED","UPDATE_SEARCH_SHORTCUTS","SNIPPETS_PREVIEW_MODE","newValues","PREFS_INITIAL_VALUES","PREF_CHANGED","newState","SECTION_DEREGISTER","SECTION_REGISTER","SECTION_UPDATE","card","dedupeConfigurations","dedupeConf","dedupedRows","dedupeFrom","dedupeSectionId","dedupeSection","SECTION_UPDATE_CARD","PLACES_SAVED_TO_POCKET","PLACES_LINK_BLOCKED","SNIPPETS_DATA","SNIPPETS_RESET","POCKET_WAITING_FOR_SPOC","POCKET_LOGGED_IN","POCKET_CTA","cta_button","cta_text","cta_url","use_cta","onDoneButton","includeClientID","header","extraTemplateStrings","cardContextTypes","history","intlID","bookmark","trending","download","gImageLoading","activeCard","imageLoaded","cardImage","maybeLoadImage","imageUrl","loaderPromise","loader","Image","src","catch","then","WEBEXT_CLICK","click","_Card","hasImage","placeholder","description","Card","PlaceholderCard","validationError","onMount","shouldFocus","showClearButton","onClear","typeUrl","titleId","loading","placeholderId","errorMessageId","TopSiteFormInput","customScreenshotUrl","showCustomScreenshotForm","onClearScreenshotInput","onLabelChange","onUrlChange","onClearUrlClick","onDoneButtonClick","onCustomScreenshotUrlChange","onPreviewButtonClick","onEnableScreenshotUrlForm","validateUrl","_updateCustomScreenshotInput","validateForm","cleanUrl","_tryParseUrl","validProtocols","urlObj","validateCustomScreenshotUrl","validate","_renderCustomScreenshotInput","requestFailed","isLoading","showAsAdd","previous","changed","previewMode","previewLink","TopSiteForm"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,WAAU,QAAlB,EAA2B,MAAK,QAAhC,EAAyC,SAAS,KAAKkX,mBAAvD;AACE,iDAAC,uCAAD,IAAkB,IAAG,6BAArB;AADF,SADF;AAIG0gB,sBACC;AAAA;AAAA,YAAQ,WAAU,cAAlB,EAAiC,MAAK,QAAtC,EAA+C,SAAS,KAAKjB,oBAA7D;AACE,iDAAC,uCAAD,IAAkB,IAAG,8BAArB;AADF,SADD,GAIC;AAAA;AAAA,YAAQ,WAAU,MAAlB,EAAyB,MAAK,QAA9B,EAAuC,SAAS,KAAKF,iBAArD;AACE,iDAAC,uCAAD,IAAkB,IAAIgB,YAAY,0BAAZ,GAAyC,2BAA/D;AADF;AARJ;AA7BF,KADF;AA4CD;AA7OkD;;AAgPrD,uBAAAK,CAAYz/B,YAAZ,GAA2B;AACzBgQ,QAAM,IADmB;AAEzBkB,SAAO,CAAC;AAFiB,CAA3B,C","file":"activity-stream.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {addSnippetsSubscriber} from \"content-src/lib/snippets\";\nimport {ASRouterContent} from \"content-src/asrouter/asrouter-content\";\nimport {Base} from \"content-src/components/Base/Base\";\nimport {DetectUserSessionStart} from \"content-src/lib/detect-user-session-start\";\nimport {enableASRouterContent} from \"content-src/lib/asroutercontent\";\nimport {initStore} from \"content-src/lib/init-store\";\nimport {Provider} from \"react-redux\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport {reducers} from \"common/Reducers.jsm\";\n\nconst store = initStore(reducers, global.gActivityStreamPrerenderedState);\nconst asrouterContent = new ASRouterContent();\n\nnew DetectUserSessionStart(store).sendEventOrAddListener();\n\n// If we are starting in a prerendered state, we must wait until the first render\n// to request state rehydration (see Base.jsx). If we are NOT in a prerendered state,\n// we can request it immedately.\nif (!global.gActivityStreamPrerenderedState) {\n  store.dispatch(ac.AlsoToMain({type: at.NEW_TAB_STATE_REQUEST}));\n}\n\nReactDOM.hydrate(<Provider store={store}>\n  <Base\n    isFirstrun={global.document.location.href === \"about:welcome\"}\n    isPrerendered={!!global.gActivityStreamPrerenderedState}\n    locale={global.document.documentElement.lang}\n    strings={global.gActivityStreamStrings} />\n</Provider>, document.getElementById(\"root\"));\n\nenableASRouterContent(store, asrouterContent);\naddSnippetsSubscriber(store);\n","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\r\n} catch (e) {\r\n\t// This works if the window reference is available\r\n\tif (typeof window === \"object\") g = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\"use strict\";\n\nthis.MAIN_MESSAGE_TYPE = \"ActivityStream:Main\";\nthis.CONTENT_MESSAGE_TYPE = \"ActivityStream:Content\";\nthis.PRELOAD_MESSAGE_TYPE = \"ActivityStream:PreloadedBrowser\";\nthis.UI_CODE = 1;\nthis.BACKGROUND_PROCESS = 2;\n\n/**\n * globalImportContext - Are we in UI code (i.e. react, a dom) or some kind of background process?\n *                       Use this in action creators if you need different logic\n *                       for ui/background processes.\n */\nconst globalImportContext = typeof Window === \"undefined\" ? BACKGROUND_PROCESS : UI_CODE;\n// Export for tests\nthis.globalImportContext = globalImportContext;\n\n// Create an object that avoids accidental differing key/value pairs:\n// {\n//   INIT: \"INIT\",\n//   UNINIT: \"UNINIT\"\n// }\nconst actionTypes = {};\nfor (const type of [\n  \"ADDONS_INFO_REQUEST\",\n  \"ADDONS_INFO_RESPONSE\",\n  \"ARCHIVE_FROM_POCKET\",\n  \"AS_ROUTER_INITIALIZED\",\n  \"AS_ROUTER_PREF_CHANGED\",\n  \"AS_ROUTER_TELEMETRY_USER_EVENT\",\n  \"BLOCK_URL\",\n  \"BOOKMARK_URL\",\n  \"COPY_DOWNLOAD_LINK\",\n  \"DELETE_BOOKMARK_BY_ID\",\n  \"DELETE_FROM_POCKET\",\n  \"DELETE_HISTORY_URL\",\n  \"DIALOG_CANCEL\",\n  \"DIALOG_OPEN\",\n  \"DISABLE_ONBOARDING\",\n  \"DOWNLOAD_CHANGED\",\n  \"FILL_SEARCH_TERM\",\n  \"INIT\",\n  \"MIGRATION_CANCEL\",\n  \"MIGRATION_COMPLETED\",\n  \"MIGRATION_START\",\n  \"NEW_TAB_INIT\",\n  \"NEW_TAB_INITIAL_STATE\",\n  \"NEW_TAB_LOAD\",\n  \"NEW_TAB_REHYDRATED\",\n  \"NEW_TAB_STATE_REQUEST\",\n  \"NEW_TAB_UNLOAD\",\n  \"OPEN_DOWNLOAD_FILE\",\n  \"OPEN_LINK\",\n  \"OPEN_NEW_WINDOW\",\n  \"OPEN_PRIVATE_WINDOW\",\n  \"OPEN_WEBEXT_SETTINGS\",\n  \"PAGE_PRERENDERED\",\n  \"PLACES_BOOKMARK_ADDED\",\n  \"PLACES_BOOKMARK_REMOVED\",\n  \"PLACES_HISTORY_CLEARED\",\n  \"PLACES_LINKS_CHANGED\",\n  \"PLACES_LINK_BLOCKED\",\n  \"PLACES_LINK_DELETED\",\n  \"PLACES_SAVED_TO_POCKET\",\n  \"POCKET_CTA\",\n  \"POCKET_LOGGED_IN\",\n  \"POCKET_WAITING_FOR_SPOC\",\n  \"PREFS_INITIAL_VALUES\",\n  \"PREF_CHANGED\",\n  \"PREVIEW_REQUEST\",\n  \"PREVIEW_REQUEST_CANCEL\",\n  \"PREVIEW_RESPONSE\",\n  \"REMOVE_DOWNLOAD_FILE\",\n  \"RICH_ICON_MISSING\",\n  \"SAVE_SESSION_PERF_DATA\",\n  \"SAVE_TO_POCKET\",\n  \"SCREENSHOT_UPDATED\",\n  \"SECTION_DEREGISTER\",\n  \"SECTION_DISABLE\",\n  \"SECTION_ENABLE\",\n  \"SECTION_MOVE\",\n  \"SECTION_OPTIONS_CHANGED\",\n  \"SECTION_REGISTER\",\n  \"SECTION_UPDATE\",\n  \"SECTION_UPDATE_CARD\",\n  \"SETTINGS_CLOSE\",\n  \"SETTINGS_OPEN\",\n  \"SET_PREF\",\n  \"SHOW_DOWNLOAD_FILE\",\n  \"SHOW_FIREFOX_ACCOUNTS\",\n  \"SKIPPED_SIGNIN\",\n  \"SNIPPETS_BLOCKLIST_CLEARED\",\n  \"SNIPPETS_BLOCKLIST_UPDATED\",\n  \"SNIPPETS_DATA\",\n  \"SNIPPETS_PREVIEW_MODE\",\n  \"SNIPPETS_RESET\",\n  \"SNIPPET_BLOCKED\",\n  \"SUBMIT_EMAIL\",\n  \"SYSTEM_TICK\",\n  \"TELEMETRY_IMPRESSION_STATS\",\n  \"TELEMETRY_PERFORMANCE_EVENT\",\n  \"TELEMETRY_UNDESIRED_EVENT\",\n  \"TELEMETRY_USER_EVENT\",\n  \"TOP_SITES_CANCEL_EDIT\",\n  \"TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL\",\n  \"TOP_SITES_EDIT\",\n  \"TOP_SITES_INSERT\",\n  \"TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL\",\n  \"TOP_SITES_PIN\",\n  \"TOP_SITES_PREFS_UPDATED\",\n  \"TOP_SITES_UNPIN\",\n  \"TOP_SITES_UPDATED\",\n  \"TOTAL_BOOKMARKS_REQUEST\",\n  \"TOTAL_BOOKMARKS_RESPONSE\",\n  \"UNINIT\",\n  \"UPDATE_PINNED_SEARCH_SHORTCUTS\",\n  \"UPDATE_SEARCH_SHORTCUTS\",\n  \"UPDATE_SECTION_PREFS\",\n  \"WEBEXT_CLICK\",\n  \"WEBEXT_DISMISS\",\n]) {\n  actionTypes[type] = type;\n}\n\n// These are acceptable actions for AS Router messages to have. They can show up\n// as call-to-action buttons in snippets, onboarding tour, etc.\nconst ASRouterActions = {};\nfor (const type of [\n  \"INSTALL_ADDON_FROM_URL\",\n  \"OPEN_APPLICATIONS_MENU\",\n  \"OPEN_PRIVATE_BROWSER_WINDOW\",\n  \"OPEN_URL\",\n  \"OPEN_ABOUT_PAGE\",\n]) {\n  ASRouterActions[type] = type;\n}\n\n// Helper function for creating routed actions between content and main\n// Not intended to be used by consumers\nfunction _RouteMessage(action, options) {\n  const meta = action.meta ? {...action.meta} : {};\n  if (!options || !options.from || !options.to) {\n    throw new Error(\"Routed Messages must have options as the second parameter, and must at least include a .from and .to property.\");\n  }\n  // For each of these fields, if they are passed as an option,\n  // add them to the action. If they are not defined, remove them.\n  [\"from\", \"to\", \"toTarget\", \"fromTarget\", \"skipMain\", \"skipLocal\"].forEach(o => {\n    if (typeof options[o] !== \"undefined\") {\n      meta[o] = options[o];\n    } else if (meta[o]) {\n      delete meta[o];\n    }\n  });\n  return {...action, meta};\n}\n\n/**\n * AlsoToMain - Creates a message that will be dispatched locally and also sent to the Main process.\n *\n * @param  {object} action Any redux action (required)\n * @param  {object} options\n * @param  {bool}   skipLocal Used by OnlyToMain to skip the main reducer\n * @param  {string} fromTarget The id of the content port from which the action originated. (optional)\n * @return {object} An action with added .meta properties\n */\nfunction AlsoToMain(action, fromTarget, skipLocal) {\n  return _RouteMessage(action, {\n    from: CONTENT_MESSAGE_TYPE,\n    to: MAIN_MESSAGE_TYPE,\n    fromTarget,\n    skipLocal,\n  });\n}\n\n/**\n * OnlyToMain - Creates a message that will be sent to the Main process and skip the local reducer.\n *\n * @param  {object} action Any redux action (required)\n * @param  {object} options\n * @param  {string} fromTarget The id of the content port from which the action originated. (optional)\n * @return {object} An action with added .meta properties\n */\nfunction OnlyToMain(action, fromTarget) {\n  return AlsoToMain(action, fromTarget, true);\n}\n\n/**\n * BroadcastToContent - Creates a message that will be dispatched to main and sent to ALL content processes.\n *\n * @param  {object} action Any redux action (required)\n * @return {object} An action with added .meta properties\n */\nfunction BroadcastToContent(action) {\n  return _RouteMessage(action, {\n    from: MAIN_MESSAGE_TYPE,\n    to: CONTENT_MESSAGE_TYPE,\n  });\n}\n\n/**\n * AlsoToOneContent - Creates a message that will be will be dispatched to the main store\n *                    and also sent to a particular Content process.\n *\n * @param  {object} action Any redux action (required)\n * @param  {string} target The id of a content port\n * @param  {bool} skipMain Used by OnlyToOneContent to skip the main process\n * @return {object} An action with added .meta properties\n */\nfunction AlsoToOneContent(action, target, skipMain) {\n  if (!target) {\n    throw new Error(\"You must provide a target ID as the second parameter of AlsoToOneContent. If you want to send to all content processes, use BroadcastToContent\");\n  }\n  return _RouteMessage(action, {\n    from: MAIN_MESSAGE_TYPE,\n    to: CONTENT_MESSAGE_TYPE,\n    toTarget: target,\n    skipMain,\n  });\n}\n\n/**\n * OnlyToOneContent - Creates a message that will be sent to a particular Content process\n *                    and skip the main reducer.\n *\n * @param  {object} action Any redux action (required)\n * @param  {string} target The id of a content port\n * @return {object} An action with added .meta properties\n */\nfunction OnlyToOneContent(action, target) {\n  return AlsoToOneContent(action, target, true);\n}\n\n/**\n * AlsoToPreloaded - Creates a message that dispatched to the main reducer and also sent to the preloaded tab.\n *\n * @param  {object} action Any redux action (required)\n * @return {object} An action with added .meta properties\n */\nfunction AlsoToPreloaded(action) {\n  return _RouteMessage(action, {\n    from: MAIN_MESSAGE_TYPE,\n    to: PRELOAD_MESSAGE_TYPE,\n  });\n}\n\n/**\n * UserEvent - A telemetry ping indicating a user action. This should only\n *                   be sent from the UI during a user session.\n *\n * @param  {object} data Fields to include in the ping (source, etc.)\n * @return {object} An AlsoToMain action\n */\nfunction UserEvent(data) {\n  return AlsoToMain({\n    type: actionTypes.TELEMETRY_USER_EVENT,\n    data,\n  });\n}\n\n/**\n * ASRouterUserEvent - A telemetry ping indicating a user action from AS router. This should only\n *                     be sent from the UI during a user session.\n *\n * @param  {object} data Fields to include in the ping (source, etc.)\n * @return {object} An AlsoToMain action\n */\nfunction ASRouterUserEvent(data) {\n  return AlsoToMain({\n    type: actionTypes.AS_ROUTER_TELEMETRY_USER_EVENT,\n    data,\n  });\n}\n\n/**\n * UndesiredEvent - A telemetry ping indicating an undesired state.\n *\n * @param  {object} data Fields to include in the ping (value, etc.)\n * @param  {int} importContext (For testing) Override the import context for testing.\n * @return {object} An action. For UI code, a AlsoToMain action.\n */\nfunction UndesiredEvent(data, importContext = globalImportContext) {\n  const action = {\n    type: actionTypes.TELEMETRY_UNDESIRED_EVENT,\n    data,\n  };\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\n/**\n * PerfEvent - A telemetry ping indicating a performance-related event.\n *\n * @param  {object} data Fields to include in the ping (value, etc.)\n * @param  {int} importContext (For testing) Override the import context for testing.\n * @return {object} An action. For UI code, a AlsoToMain action.\n */\nfunction PerfEvent(data, importContext = globalImportContext) {\n  const action = {\n    type: actionTypes.TELEMETRY_PERFORMANCE_EVENT,\n    data,\n  };\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\n/**\n * ImpressionStats - A telemetry ping indicating an impression stats.\n *\n * @param  {object} data Fields to include in the ping\n * @param  {int} importContext (For testing) Override the import context for testing.\n * #return {object} An action. For UI code, a AlsoToMain action.\n */\nfunction ImpressionStats(data, importContext = globalImportContext) {\n  const action = {\n    type: actionTypes.TELEMETRY_IMPRESSION_STATS,\n    data,\n  };\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\nfunction SetPref(name, value, importContext = globalImportContext) {\n  const action = {type: actionTypes.SET_PREF, data: {name, value}};\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\nfunction WebExtEvent(type, data, importContext = globalImportContext) {\n  if (!data || !data.source) {\n    throw new Error(\"WebExtEvent actions should include a property \\\"source\\\", the id of the webextension that should receive the event.\");\n  }\n  const action = {type, data};\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\nthis.actionTypes = actionTypes;\nthis.ASRouterActions = ASRouterActions;\n\nthis.actionCreators = {\n  BroadcastToContent,\n  UserEvent,\n  ASRouterUserEvent,\n  UndesiredEvent,\n  PerfEvent,\n  ImpressionStats,\n  AlsoToOneContent,\n  OnlyToOneContent,\n  AlsoToMain,\n  OnlyToMain,\n  AlsoToPreloaded,\n  SetPref,\n  WebExtEvent,\n};\n\n// These are helpers to test for certain kinds of actions\nthis.actionUtils = {\n  isSendToMain(action) {\n    if (!action.meta) {\n      return false;\n    }\n    return action.meta.to === MAIN_MESSAGE_TYPE && action.meta.from === CONTENT_MESSAGE_TYPE;\n  },\n  isBroadcastToContent(action) {\n    if (!action.meta) {\n      return false;\n    }\n    if (action.meta.to === CONTENT_MESSAGE_TYPE && !action.meta.toTarget) {\n      return true;\n    }\n    return false;\n  },\n  isSendToOneContent(action) {\n    if (!action.meta) {\n      return false;\n    }\n    if (action.meta.to === CONTENT_MESSAGE_TYPE && action.meta.toTarget) {\n      return true;\n    }\n    return false;\n  },\n  isSendToPreloaded(action) {\n    if (!action.meta) {\n      return false;\n    }\n    return action.meta.to === PRELOAD_MESSAGE_TYPE &&\n      action.meta.from === MAIN_MESSAGE_TYPE;\n  },\n  isFromMain(action) {\n    if (!action.meta) {\n      return false;\n    }\n    return action.meta.from === MAIN_MESSAGE_TYPE &&\n      action.meta.to === CONTENT_MESSAGE_TYPE;\n  },\n  getPortIdOfSender(action) {\n    return (action.meta && action.meta.fromTarget) || null;\n  },\n  _RouteMessage,\n};\n\nconst EXPORTED_SYMBOLS = [\n  \"actionTypes\",\n  \"actionCreators\",\n  \"actionUtils\",\n  \"ASRouterActions\",\n  \"globalImportContext\",\n  \"UI_CODE\",\n  \"BACKGROUND_PROCESS\",\n  \"MAIN_MESSAGE_TYPE\",\n  \"CONTENT_MESSAGE_TYPE\",\n  \"PRELOAD_MESSAGE_TYPE\",\n];\n","const DATABASE_NAME = \"snippets_db\";\nconst DATABASE_VERSION = 1;\nconst SNIPPETS_OBJECTSTORE_NAME = \"snippets\";\nexport const SNIPPETS_UPDATE_INTERVAL_MS = 14400000; // 4 hours.\n\nconst SNIPPETS_ENABLED_EVENT = \"Snippets:Enabled\";\nconst SNIPPETS_DISABLED_EVENT = \"Snippets:Disabled\";\n\nimport {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\n\n/**\n * SnippetsMap - A utility for cacheing values related to the snippet. It has\n *               the same interface as a Map, but is optionally backed by\n *               indexedDB for persistent storage.\n *               Call .connect() to open a database connection and restore any\n *               previously cached data, if necessary.\n *\n */\nexport class SnippetsMap extends Map {\n  constructor(dispatch) {\n    super();\n    this._db = null;\n    this._dispatch = dispatch;\n  }\n\n  set(key, value) {\n    super.set(key, value);\n    return this._dbTransaction(db => db.put(value, key));\n  }\n\n  delete(key) {\n    super.delete(key);\n    return this._dbTransaction(db => db.delete(key));\n  }\n\n  clear() {\n    super.clear();\n    this._dispatch(ac.OnlyToMain({type: at.SNIPPETS_BLOCKLIST_CLEARED}));\n    return this._dbTransaction(db => db.clear());\n  }\n\n  get blockList() {\n    return this.get(\"blockList\") || [];\n  }\n\n  /**\n   * blockSnippetById - Blocks a snippet given an id\n   *\n   * @param  {str|int} id   The id of the snippet\n   * @return {Promise}      Resolves when the id has been written to indexedDB,\n   *                        or immediately if the snippetMap is not connected\n   */\n  async blockSnippetById(id) {\n    if (!id) {\n      return;\n    }\n    const {blockList} = this;\n    if (!blockList.includes(id)) {\n      blockList.push(id);\n      this._dispatch(ac.AlsoToMain({type: at.SNIPPETS_BLOCKLIST_UPDATED, data: id}));\n      await this.set(\"blockList\", blockList);\n    }\n  }\n\n  disableOnboarding() {\n    this._dispatch(ac.AlsoToMain({type: at.DISABLE_ONBOARDING}));\n  }\n\n  showFirefoxAccounts() {\n    this._dispatch(ac.AlsoToMain({type: at.SHOW_FIREFOX_ACCOUNTS}));\n  }\n\n  getTotalBookmarksCount() {\n    return new Promise(resolve => {\n      this._dispatch(ac.OnlyToMain({type: at.TOTAL_BOOKMARKS_REQUEST}));\n      global.RPMAddMessageListener(\"ActivityStream:MainToContent\", function onMessage({data: action}) {\n        if (action.type === at.TOTAL_BOOKMARKS_RESPONSE) {\n          resolve(action.data);\n          global.RPMRemoveMessageListener(\"ActivityStream:MainToContent\", onMessage);\n        }\n      });\n    });\n  }\n\n  getAddonsInfo() {\n    return new Promise(resolve => {\n      this._dispatch(ac.OnlyToMain({type: at.ADDONS_INFO_REQUEST}));\n      global.RPMAddMessageListener(\"ActivityStream:MainToContent\", function onMessage({data: action}) {\n        if (action.type === at.ADDONS_INFO_RESPONSE) {\n          resolve(action.data);\n          global.RPMRemoveMessageListener(\"ActivityStream:MainToContent\", onMessage);\n        }\n      });\n    });\n  }\n\n  /**\n   * connect - Attaches an indexedDB back-end to the Map so that any set values\n   *           are also cached in a store. It also restores any existing values\n   *           that are already stored in the indexedDB store.\n   *\n   * @return {type}  description\n   */\n  async connect() {\n    // Open the connection\n    const db = await this._openDB();\n\n    // Restore any existing values\n    await this._restoreFromDb(db);\n\n    // Attach a reference to the db\n    this._db = db;\n  }\n\n  /**\n   * _dbTransaction - Returns a db transaction wrapped with the given modifier\n   *                  function as a Promise. If the db has not been connected,\n   *                  it resolves immediately.\n   *\n   * @param  {func} modifier A function to call with the transaction\n   * @return {obj}           A Promise that resolves when the transaction has\n   *                         completed or errored\n   */\n  _dbTransaction(modifier) {\n    if (!this._db) {\n      return Promise.resolve();\n    }\n    return new Promise((resolve, reject) => {\n      const transaction = modifier(\n        this._db\n          .transaction(SNIPPETS_OBJECTSTORE_NAME, \"readwrite\")\n          .objectStore(SNIPPETS_OBJECTSTORE_NAME)\n      );\n      transaction.onsuccess = event => resolve();\n\n      /* istanbul ignore next */\n      transaction.onerror = event => reject(transaction.error);\n    });\n  }\n\n  _openDB() {\n    return new Promise((resolve, reject) => {\n      const openRequest = indexedDB.open(DATABASE_NAME, DATABASE_VERSION);\n\n      /* istanbul ignore next */\n      openRequest.onerror = event => {\n        // Try to delete the old database so that we can start this process over\n        // next time.\n        indexedDB.deleteDatabase(DATABASE_NAME);\n        reject(event);\n      };\n\n      openRequest.onupgradeneeded = event => {\n        const db = event.target.result;\n        if (!db.objectStoreNames.contains(SNIPPETS_OBJECTSTORE_NAME)) {\n          db.createObjectStore(SNIPPETS_OBJECTSTORE_NAME);\n        }\n      };\n\n      openRequest.onsuccess = event => {\n        let db = event.target.result;\n\n        /* istanbul ignore next */\n        db.onerror = err => console.error(err); // eslint-disable-line no-console\n        /* istanbul ignore next */\n        db.onversionchange = versionChangeEvent => versionChangeEvent.target.close();\n\n        resolve(db);\n      };\n    });\n  }\n\n  _restoreFromDb(db) {\n    return new Promise((resolve, reject) => {\n      let cursorRequest;\n      try {\n        cursorRequest = db.transaction(SNIPPETS_OBJECTSTORE_NAME)\n          .objectStore(SNIPPETS_OBJECTSTORE_NAME).openCursor();\n      } catch (err) {\n        // istanbul ignore next\n        reject(err);\n        // istanbul ignore next\n        return;\n      }\n\n      /* istanbul ignore next */\n      cursorRequest.onerror = event => reject(event);\n\n      cursorRequest.onsuccess = event => {\n        let cursor = event.target.result;\n        // Populate the cache from the persistent storage.\n        if (cursor) {\n          if (cursor.value !== \"blockList\") {\n            this.set(cursor.key, cursor.value);\n          }\n          cursor.continue();\n        } else {\n          // We are done.\n          resolve();\n        }\n      };\n    });\n  }\n}\n\n/**\n * SnippetsProvider - Initializes a SnippetsMap and loads snippets from a\n *                    remote location, or else default snippets if the remote\n *                    snippets cannot be retrieved.\n */\nexport class SnippetsProvider {\n  constructor(dispatch) {\n    // Initialize the Snippets Map and attaches it to a global so that\n    // the snippet payload can interact with it.\n    global.gSnippetsMap = new SnippetsMap(dispatch);\n    this._onAction = this._onAction.bind(this);\n  }\n\n  get snippetsMap() {\n    return global.gSnippetsMap;\n  }\n\n  async _refreshSnippets() {\n    // Check if the cached version of of the snippets in snippetsMap. If it's too\n    // old, blow away the entire snippetsMap.\n    const cachedVersion = this.snippetsMap.get(\"snippets-cached-version\");\n\n    if (cachedVersion !== this.appData.version) {\n      this.snippetsMap.clear();\n    }\n\n    // Has enough time passed for us to require an update?\n    const lastUpdate = this.snippetsMap.get(\"snippets-last-update\");\n    const needsUpdate = !(lastUpdate >= 0) || Date.now() - lastUpdate > SNIPPETS_UPDATE_INTERVAL_MS;\n\n    if (needsUpdate && this.appData.snippetsURL) {\n      this.snippetsMap.set(\"snippets-last-update\", Date.now());\n      try {\n        const response = await fetch(this.appData.snippetsURL);\n        if (response.status === 200) {\n          const payload = await response.text();\n\n          this.snippetsMap.set(\"snippets\", payload);\n          this.snippetsMap.set(\"snippets-cached-version\", this.appData.version);\n        }\n      } catch (e) {\n        console.error(e); // eslint-disable-line no-console\n      }\n    }\n  }\n\n  _noSnippetFallback() {\n    // TODO\n  }\n\n  _forceOnboardingVisibility(shouldBeVisible) {\n    const onboardingEl = document.getElementById(\"onboarding-notification-bar\");\n\n    if (onboardingEl) {\n      onboardingEl.style.display = shouldBeVisible ? \"\" : \"none\";\n    }\n  }\n\n  _showRemoteSnippets() {\n    const snippetsEl = document.getElementById(this.elementId);\n    const payload = this.snippetsMap.get(\"snippets\");\n\n    if (!snippetsEl) {\n      throw new Error(`No element was found with id '${this.elementId}'.`);\n    }\n\n    // This could happen if fetching failed\n    if (!payload) {\n      throw new Error(\"No remote snippets were found in gSnippetsMap.\");\n    }\n\n    if (typeof payload !== \"string\") {\n      throw new Error(\"Snippet payload was incorrectly formatted\");\n    }\n\n    // Note that injecting snippets can throw if they're invalid XML.\n    // eslint-disable-next-line no-unsanitized/property\n    snippetsEl.innerHTML = payload;\n\n    // Scripts injected by innerHTML are inactive, so we have to relocate them\n    // through DOM manipulation to activate their contents.\n    for (const scriptEl of snippetsEl.getElementsByTagName(\"script\")) {\n      const relocatedScript = document.createElement(\"script\");\n      relocatedScript.text = scriptEl.text;\n      scriptEl.parentNode.replaceChild(relocatedScript, scriptEl);\n    }\n  }\n\n  _onAction(msg) {\n    if (msg.data.type === at.SNIPPET_BLOCKED) {\n      if (!this.snippetsMap.blockList.includes(msg.data.data)) {\n        this.snippetsMap.set(\"blockList\", this.snippetsMap.blockList.concat(msg.data.data));\n        document.getElementById(\"snippets-container\").style.display = \"none\";\n      }\n    }\n  }\n\n  /**\n   * init - Fetch the snippet payload and show snippets\n   *\n   * @param  {obj} options\n   * @param  {str} options.appData.snippetsURL  The URL from which we fetch snippets\n   * @param  {int} options.appData.version  The current snippets version\n   * @param  {str} options.elementId  The id of the element in which to inject snippets\n   * @param  {bool} options.connect  Should gSnippetsMap connect to indexedDB?\n   */\n  async init(options) {\n    Object.assign(this, {\n      appData: {},\n      elementId: \"snippets\",\n      connect: true,\n    }, options);\n\n    // Add listener so we know when snippets are blocked on other pages\n    if (global.RPMAddMessageListener) {\n      global.RPMAddMessageListener(\"ActivityStream:MainToContent\", this._onAction);\n    }\n\n    // TODO: Requires enabling indexedDB on newtab\n    // Restore the snippets map from indexedDB\n    if (this.connect) {\n      try {\n        await this.snippetsMap.connect();\n      } catch (e) {\n        console.error(e); // eslint-disable-line no-console\n      }\n    }\n\n    // Cache app data values so they can be accessible from gSnippetsMap\n    for (const key of Object.keys(this.appData)) {\n      if (key === \"blockList\") {\n        this.snippetsMap.set(\"blockList\", this.appData[key]);\n      } else {\n        this.snippetsMap.set(`appData.${key}`, this.appData[key]);\n      }\n    }\n\n    // Refresh snippets, if enough time has passed.\n    await this._refreshSnippets();\n\n    // Try showing remote snippets, falling back to defaults if necessary.\n    try {\n      this._showRemoteSnippets();\n    } catch (e) {\n      this._noSnippetFallback(e);\n    }\n\n    window.dispatchEvent(new Event(SNIPPETS_ENABLED_EVENT));\n\n    this._forceOnboardingVisibility(true);\n    this.initialized = true;\n  }\n\n  uninit() {\n    window.dispatchEvent(new Event(SNIPPETS_DISABLED_EVENT));\n    this._forceOnboardingVisibility(false);\n    if (global.RPMRemoveMessageListener) {\n      global.RPMRemoveMessageListener(\"ActivityStream:MainToContent\", this._onAction);\n    }\n    this.initialized = false;\n  }\n}\n\n/**\n * addSnippetsSubscriber - Creates a SnippetsProvider that Initializes\n *                         when the store has received the appropriate\n *                         Snippet data.\n *\n * @param  {obj} store   The redux store\n * @return {obj}         Returns the snippets instance, asrouterContent instance and unsubscribe function\n */\nexport function addSnippetsSubscriber(store) {\n  const snippets = new SnippetsProvider(store.dispatch);\n\n  let initializing = false;\n\n  store.subscribe(async () => {\n    const state = store.getState();\n\n    /**\n     * Sorry this code is so complicated. It will be removed soon.\n     * This is what the different values actually mean:\n     *\n     * ASRouter.initialized                   Is ASRouter.jsm initialised?\n     * ASRouter.allowLegacySnippets           Are ASRouter snippets turned OFF (i.e. legacy snippets are allowed)\n     * state.Prefs.values[\"feeds.snippets\"]   User preference for snippets\n     * state.Snippets.initialized             Is SnippetsFeed.jsm initialised?\n     * snippets.initialized                   Is in-content snippets currently initialised?\n     * state.Prefs.values.disableSnippets     This pref is used to disable legacy snippets in an emergency\n     *                                        in a way that is not user-editable (true = disabled)\n     */\n\n    /** If we should initialize snippets... */\n    if (\n      state.Prefs.values[\"feeds.snippets\"] &&\n      state.ASRouter.initialized &&\n      state.ASRouter.allowLegacySnippets &&\n      !state.Prefs.values.disableSnippets &&\n      state.Snippets.initialized &&\n      !snippets.initialized &&\n      // Don't call init multiple times\n      !initializing &&\n      location.href !== \"about:welcome\"\n    ) {\n      initializing = true;\n      await snippets.init({appData: state.Snippets});\n      // istanbul ignore if\n      if (state.Prefs.values[\"asrouter.devtoolsEnabled\"]) {\n        console.log(\"Legacy snippets initialized\"); // eslint-disable-line no-console\n      }\n      initializing = false;\n\n    /** If we should remove snippets... */\n    } else if (\n      (\n        state.Prefs.values[\"feeds.snippets\"] === false ||\n        state.Prefs.values.disableSnippets === true ||\n        (state.ASRouter.initialized && !state.ASRouter.allowLegacySnippets)\n      ) &&\n      snippets.initialized\n    ) {\n      // Remove snippets\n      snippets.uninit();\n      // istanbul ignore if\n      if (state.Prefs.values[\"asrouter.devtoolsEnabled\"]) {\n        console.log(\"Legacy snippets removed\"); // eslint-disable-line no-console\n      }\n    }\n  });\n\n  // Returned for testing purposes\n  return {snippets};\n}\n","import {LocalizationProvider, Localized} from \"fluent-react\";\nimport {actionCreators as ac} from \"common/Actions.jsm\";\nimport {OUTGOING_MESSAGE_NAME as AS_GENERAL_OUTGOING_MESSAGE_NAME} from \"content-src/lib/init-store\";\nimport {ImpressionsWrapper} from \"./components/ImpressionsWrapper/ImpressionsWrapper\";\nimport {MessageContext} from \"fluent\";\nimport {OnboardingMessage} from \"./templates/OnboardingMessage/OnboardingMessage\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport {safeURI} from \"./template-utils\";\nimport {SimpleSnippet} from \"./templates/SimpleSnippet/SimpleSnippet\";\n\nconst INCOMING_MESSAGE_NAME = \"ASRouter:parent-to-child\";\nconst OUTGOING_MESSAGE_NAME = \"ASRouter:child-to-parent\";\n\nexport const ASRouterUtils = {\n  addListener(listener) {\n    global.RPMAddMessageListener(INCOMING_MESSAGE_NAME, listener);\n  },\n  removeListener(listener) {\n    global.RPMRemoveMessageListener(INCOMING_MESSAGE_NAME, listener);\n  },\n  sendMessage(action) {\n    global.RPMSendAsyncMessage(OUTGOING_MESSAGE_NAME, action);\n  },\n  blockById(id) {\n    ASRouterUtils.sendMessage({type: \"BLOCK_MESSAGE_BY_ID\", data: {id}});\n  },\n  blockBundle(bundle) {\n    ASRouterUtils.sendMessage({type: \"BLOCK_BUNDLE\", data: {bundle}});\n  },\n  executeAction(button_action) {\n    ASRouterUtils.sendMessage({\n      type: \"USER_ACTION\",\n      data: button_action,\n    });\n  },\n  unblockById(id) {\n    ASRouterUtils.sendMessage({type: \"UNBLOCK_MESSAGE_BY_ID\", data: {id}});\n  },\n  unblockBundle(bundle) {\n    ASRouterUtils.sendMessage({type: \"UNBLOCK_BUNDLE\", data: {bundle}});\n  },\n  getNextMessage() {\n    ASRouterUtils.sendMessage({type: \"GET_NEXT_MESSAGE\"});\n  },\n  overrideMessage(id) {\n    ASRouterUtils.sendMessage({type: \"OVERRIDE_MESSAGE\", data: {id}});\n  },\n  sendTelemetry(ping) {\n    const payload = ac.ASRouterUserEvent(ping);\n    global.RPMSendAsyncMessage(AS_GENERAL_OUTGOING_MESSAGE_NAME, payload);\n  },\n  getEndpoint() {\n    if (window.location.href.includes(\"endpoint\")) {\n      const params = new URLSearchParams(window.location.href.slice(window.location.href.indexOf(\"endpoint\")));\n      try {\n        const endpoint = new URL(params.get(\"endpoint\"));\n        return {\n          url: endpoint.href,\n          snippetId: params.get(\"snippetId\"),\n        };\n      } catch (e) {}\n    }\n\n    return null;\n  },\n};\n\n// Note: nextProps/prevProps refer to props passed to <ImpressionsWrapper />, not <ASRouterUISurface />\nfunction shouldSendImpressionOnUpdate(nextProps, prevProps) {\n  return (nextProps.message.id && (!prevProps.message || prevProps.message.id !== nextProps.message.id));\n}\n\nfunction generateMessages(content) {\n  const cx = new MessageContext(\"en-US\");\n  cx.addMessages(`RichTextSnippet = ${content}`);\n  return [cx];\n}\n\n// Elements allowed in snippet content\nconst ALLOWED_TAGS = {\n  b: <b />,\n  i: <i />,\n  u: <u />,\n  strong: <strong />,\n  em: <em />,\n  br: <br />,\n};\n\n/**\n * Transform an object (tag name: {url}) into (tag name: anchor) where the url\n * is used as href, in order to render links inside a Fluent.Localized component.\n */\nexport function convertLinks(links, sendClick) {\n  if (links) {\n    return Object.keys(links).reduce((acc, linkTag) => {\n      acc[linkTag] = <a href={safeURI(links[linkTag].url)} data-metric={links[linkTag].metric} onClick={sendClick} />;\n      return acc;\n    }, {});\n  }\n\n  return null;\n}\n\n/**\n * Message wrapper used to sanitize markup and render HTML.\n */\nfunction RichText(props) {\n  return (\n    <Localized id=\"RichTextSnippet\" {...ALLOWED_TAGS} {...convertLinks(props.links, props.sendClick)}>\n      <span>{props.text}</span>\n    </Localized>\n  );\n}\n\nexport class ASRouterUISurface extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onMessageFromParent = this.onMessageFromParent.bind(this);\n    this.sendClick = this.sendClick.bind(this);\n    this.sendImpression = this.sendImpression.bind(this);\n    this.sendUserActionTelemetry = this.sendUserActionTelemetry.bind(this);\n    this.state = {message: {}, bundle: {}};\n  }\n\n  sendUserActionTelemetry(extraProps = {}) {\n    const {message, bundle} = this.state;\n    if (!message && !extraProps.message_id) {\n      throw new Error(`You must provide a message_id for bundled messages`);\n    }\n    const eventType = `${message.provider || bundle.provider}_user_event`;\n    ASRouterUtils.sendTelemetry({\n      message_id: message.id || extraProps.message_id,\n      source: extraProps.id,\n      action: eventType,\n      ...extraProps,\n    });\n  }\n\n  sendImpression(extraProps) {\n    if (this.state.message.provider === \"preview\") {\n      return;\n    }\n\n    ASRouterUtils.sendMessage({type: \"IMPRESSION\", data: this.state.message});\n    this.sendUserActionTelemetry({event: \"IMPRESSION\", ...extraProps});\n  }\n\n  // If link has a `metric` data attribute send it as part of the `value`\n  // telemetry field which can have arbitrary values.\n  // Used for router messages with links as part of the content.\n  sendClick(event) {\n    if (this.state.message.provider === \"preview\") {\n      return;\n    }\n\n    const metric = {\n      value: event.target.dataset.metric,\n      // Used for the `source` of the event. Needed to differentiate\n      // from other snippet or onboarding events that may occur.\n      id: \"NEWTAB_FOOTER_BAR_CONTENT\",\n    };\n    this.sendUserActionTelemetry({event: \"CLICK_BUTTON\", ...metric});\n    if (!this.state.message.content.do_not_autoblock) {\n      ASRouterUtils.blockById(this.state.message.id);\n    }\n  }\n\n  onBlockById(id) {\n    return () => ASRouterUtils.blockById(id);\n  }\n\n  clearBundle(bundle) {\n    return () => ASRouterUtils.blockBundle(bundle);\n  }\n\n  onMessageFromParent({data: action}) {\n    switch (action.type) {\n      case \"SET_MESSAGE\":\n        this.setState({message: action.data});\n        break;\n      case \"SET_BUNDLED_MESSAGES\":\n        this.setState({bundle: action.data});\n        break;\n      case \"CLEAR_MESSAGE\":\n        if (action.data.id === this.state.message.id) {\n          this.setState({message: {}});\n        }\n        break;\n      case \"CLEAR_PROVIDER\":\n        if (action.data.id === this.state.message.provider) {\n          this.setState({message: {}});\n        }\n        break;\n      case \"CLEAR_BUNDLE\":\n        if (this.state.bundle.bundle) {\n          this.setState({bundle: {}});\n        }\n        break;\n      case \"CLEAR_ALL\":\n        this.setState({message: {}, bundle: {}});\n    }\n  }\n\n  componentWillMount() {\n    const endpoint = ASRouterUtils.getEndpoint();\n    ASRouterUtils.addListener(this.onMessageFromParent);\n\n    // If we are loading about:welcome we want to trigger the onboarding messages\n    if (this.props.document.location.href === \"about:welcome\") {\n      ASRouterUtils.sendMessage({type: \"TRIGGER\", data: {trigger: {id: \"firstRun\"}}});\n    } else {\n      ASRouterUtils.sendMessage({type: \"CONNECT_UI_REQUEST\", data: {endpoint}});\n    }\n  }\n\n  componentWillUnmount() {\n    ASRouterUtils.removeListener(this.onMessageFromParent);\n  }\n\n  renderSnippets() {\n    return (\n      <ImpressionsWrapper\n        id=\"NEWTAB_FOOTER_BAR\"\n        message={this.state.message}\n        sendImpression={this.sendImpression}\n        shouldSendImpressionOnUpdate={shouldSendImpressionOnUpdate}\n        // This helps with testing\n        document={this.props.document}>\n          <LocalizationProvider messages={generateMessages(this.state.message.content.text)}>\n            <SimpleSnippet\n              {...this.state.message}\n              richText={<RichText text={this.state.message.content.text}\n                                  links={this.state.message.content.links}\n                                  sendClick={this.sendClick} />}\n              UISurface=\"NEWTAB_FOOTER_BAR\"\n              getNextMessage={ASRouterUtils.getNextMessage}\n              onBlock={this.onBlockById(this.state.message.id)}\n              onAction={ASRouterUtils.executeAction}\n              sendUserActionTelemetry={this.sendUserActionTelemetry} />\n          </LocalizationProvider>\n      </ImpressionsWrapper>);\n  }\n\n  renderOnboarding() {\n    return (\n      <OnboardingMessage\n        {...this.state.bundle}\n        UISurface=\"NEWTAB_OVERLAY\"\n        onAction={ASRouterUtils.executeAction}\n        onDoneButton={this.clearBundle(this.state.bundle.bundle)}\n        getNextMessage={ASRouterUtils.getNextMessage}\n        sendUserActionTelemetry={this.sendUserActionTelemetry} />);\n  }\n\n  renderPreviewBanner() {\n    if (this.state.message.provider !== \"preview\") {\n      return null;\n    }\n\n    return (\n      <div className=\"snippets-preview-banner\">\n        <span className=\"icon icon-small-spacer icon-info\" />\n        <span>Preview Purposes Only</span>\n      </div>\n    );\n  }\n\n  render() {\n    const {message, bundle} = this.state;\n    if (!message.id && !bundle.template) { return null; }\n    return (\n      <div>\n        {this.renderPreviewBanner()}\n        {bundle.template === \"onboarding\" ? this.renderOnboarding() : this.renderSnippets()}\n      </div>\n    );\n  }\n}\n\nASRouterUISurface.defaultProps = {document: global.document};\n\nexport class ASRouterContent {\n  constructor() {\n    this.initialized = false;\n    this.containerElement = null;\n  }\n\n  _mount() {\n    this.containerElement = global.document.getElementById(\"snippets-container\");\n    ReactDOM.render(<ASRouterUISurface />, this.containerElement);\n  }\n\n  _unmount() {\n    ReactDOM.unmountComponentAtNode(this.containerElement);\n  }\n\n  init() {\n    this._mount();\n    this.initialized = true;\n  }\n\n  uninit() {\n    if (this.initialized) {\n      this._unmount();\n      this.initialized = false;\n    }\n  }\n}\n","module.exports = React;","module.exports = PropTypes;","/* eslint-env mozilla/frame-script */\n\nimport {actionCreators as ac, actionTypes as at, actionUtils as au} from \"common/Actions.jsm\";\nimport {applyMiddleware, combineReducers, createStore} from \"redux\";\n\nexport const MERGE_STORE_ACTION = \"NEW_TAB_INITIAL_STATE\";\nexport const OUTGOING_MESSAGE_NAME = \"ActivityStream:ContentToMain\";\nexport const INCOMING_MESSAGE_NAME = \"ActivityStream:MainToContent\";\nexport const EARLY_QUEUED_ACTIONS = [at.SAVE_SESSION_PERF_DATA, at.PAGE_PRERENDERED];\n\n/**\n * A higher-order function which returns a reducer that, on MERGE_STORE action,\n * will return the action.data object merged into the previous state.\n *\n * For all other actions, it merely calls mainReducer.\n *\n * Because we want this to merge the entire state object, it's written as a\n * higher order function which takes the main reducer (itself often a call to\n * combineReducers) as a parameter.\n *\n * @param  {function} mainReducer reducer to call if action != MERGE_STORE_ACTION\n * @return {function}             a reducer that, on MERGE_STORE_ACTION action,\n *                                will return the action.data object merged\n *                                into the previous state, and the result\n *                                of calling mainReducer otherwise.\n */\nfunction mergeStateReducer(mainReducer) {\n  return (prevState, action) => {\n    if (action.type === MERGE_STORE_ACTION) {\n      return {...prevState, ...action.data};\n    }\n\n    return mainReducer(prevState, action);\n  };\n}\n\n/**\n * messageMiddleware - Middleware that looks for SentToMain type actions, and sends them if necessary\n */\nconst messageMiddleware = store => next => action => {\n  const skipLocal = action.meta && action.meta.skipLocal;\n  if (au.isSendToMain(action)) {\n    RPMSendAsyncMessage(OUTGOING_MESSAGE_NAME, action);\n  }\n  if (!skipLocal) {\n    next(action);\n  }\n};\n\nexport const rehydrationMiddleware = store => next => action => {\n  if (store._didRehydrate) {\n    return next(action);\n  }\n\n  const isMergeStoreAction = action.type === MERGE_STORE_ACTION;\n  const isRehydrationRequest = action.type === at.NEW_TAB_STATE_REQUEST;\n\n  if (isRehydrationRequest) {\n    store._didRequestInitialState = true;\n    return next(action);\n  }\n\n  if (isMergeStoreAction) {\n    store._didRehydrate = true;\n    return next(action);\n  }\n\n  // If init happened after our request was made, we need to re-request\n  if (store._didRequestInitialState && action.type === at.INIT) {\n    return next(ac.AlsoToMain({type: at.NEW_TAB_STATE_REQUEST}));\n  }\n\n  if (au.isBroadcastToContent(action) || au.isSendToOneContent(action) || au.isSendToPreloaded(action)) {\n    // Note that actions received before didRehydrate will not be dispatched\n    // because this could negatively affect preloading and the the state\n    // will be replaced by rehydration anyway.\n    return null;\n  }\n\n  return next(action);\n};\n\n/**\n * This middleware queues up all the EARLY_QUEUED_ACTIONS until it receives\n * the first action from main. This is useful for those actions for main which\n * require higher reliability, i.e. the action will not be lost in the case\n * that it gets sent before the main is ready to receive it. Conversely, any\n * actions allowed early are accepted to be ignorable or re-sendable.\n */\nexport const queueEarlyMessageMiddleware = store => next => action => {\n  if (store._receivedFromMain) {\n    next(action);\n  } else if (au.isFromMain(action)) {\n    next(action);\n    store._receivedFromMain = true;\n    // Sending out all the early actions as main is ready now\n    if (store._earlyActionQueue) {\n      store._earlyActionQueue.forEach(next);\n      store._earlyActionQueue = [];\n    }\n  } else if (EARLY_QUEUED_ACTIONS.includes(action.type)) {\n    store._earlyActionQueue = store._earlyActionQueue || [];\n    store._earlyActionQueue.push(action);\n  } else {\n    // Let any other type of action go through\n    next(action);\n  }\n};\n\n/**\n * initStore - Create a store and listen for incoming actions\n *\n * @param  {object} reducers An object containing Redux reducers\n * @param  {object} intialState (optional) The initial state of the store, if desired\n * @return {object}          A redux store\n */\nexport function initStore(reducers, initialState) {\n  const store = createStore(\n    mergeStateReducer(combineReducers(reducers)),\n    initialState,\n    global.RPMAddMessageListener && applyMiddleware(rehydrationMiddleware, queueEarlyMessageMiddleware, messageMiddleware)\n  );\n\n  store._didRehydrate = false;\n  store._didRequestInitialState = false;\n\n  if (global.RPMAddMessageListener) {\n    global.RPMAddMessageListener(INCOMING_MESSAGE_NAME, msg => {\n      try {\n        store.dispatch(msg.data);\n      } catch (ex) {\n        console.error(\"Content msg:\", msg, \"Dispatch error: \", ex); // eslint-disable-line no-console\n        dump(`Content msg: ${JSON.stringify(msg)}\\nDispatch error: ${ex}\\n${ex.stack}`);\n      }\n    });\n  }\n\n  return store;\n}\n","module.exports = Redux;","import React from \"react\";\n\nexport const VISIBLE = \"visible\";\nexport const VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\n\n/**\n * Component wrapper used to send telemetry pings on every impression.\n */\nexport class ImpressionsWrapper extends React.PureComponent {\n  // This sends an event when a user sees a set of new content. If content\n  // changes while the page is hidden (i.e. preloaded or on a hidden tab),\n  // only send the event if the page becomes visible again.\n  sendImpressionOrAddListener() {\n    if (this.props.document.visibilityState === VISIBLE) {\n      this.props.sendImpression({id: this.props.id});\n    } else {\n      // We should only ever send the latest impression stats ping, so remove any\n      // older listeners.\n      if (this._onVisibilityChange) {\n        this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n      }\n\n      // When the page becomes visible, send the impression stats ping if the section isn't collapsed.\n      this._onVisibilityChange = () => {\n        if (this.props.document.visibilityState === VISIBLE) {\n          this.props.sendImpression({id: this.props.id});\n          this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n        }\n      };\n      this.props.document.addEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  componentWillUnmount() {\n    if (this._onVisibilityChange) {\n      this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  componentDidMount() {\n    if (this.props.sendOnMount) {\n      this.sendImpressionOrAddListener();\n    }\n  }\n\n  componentDidUpdate(prevProps) {\n    if (this.props.shouldSendImpressionOnUpdate(this.props, prevProps)) {\n      this.sendImpressionOrAddListener();\n    }\n  }\n\n  render() {\n    return this.props.children;\n  }\n}\n\nImpressionsWrapper.defaultProps = {\n  document: global.document,\n  sendOnMount: true,\n};\n","module.exports = ReactDOM;","export function safeURI(url) {\n  if (!url) {\n    return \"\";\n  }\n  const {protocol} = new URL(url);\n  const isAllowed = [\n    \"http:\",\n    \"https:\",\n    \"data:\",\n    \"resource:\",\n    \"chrome:\",\n  ].includes(protocol);\n  if (!isAllowed) {\n    console.warn(`The protocol ${protocol} is not allowed for template URLs.`); // eslint-disable-line no-console\n  }\n  return isAllowed ? url : \"\";\n}\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {addLocaleData, injectIntl, IntlProvider} from \"react-intl\";\nimport {ASRouterAdmin} from \"content-src/components/ASRouterAdmin/ASRouterAdmin\";\nimport {ConfirmDialog} from \"content-src/components/ConfirmDialog/ConfirmDialog\";\nimport {connect} from \"react-redux\";\nimport {ErrorBoundary} from \"content-src/components/ErrorBoundary/ErrorBoundary\";\nimport {ManualMigration} from \"content-src/components/ManualMigration/ManualMigration\";\nimport {PrerenderData} from \"common/PrerenderData.jsm\";\nimport React from \"react\";\nimport {Search} from \"content-src/components/Search/Search\";\nimport {Sections} from \"content-src/components/Sections/Sections\";\nimport {StartupOverlay} from \"content-src/components/StartupOverlay/StartupOverlay\";\n\nconst PrefsButton = injectIntl(props => (\n  <div className=\"prefs-button\">\n    <button className=\"icon icon-settings\" onClick={props.onClick} title={props.intl.formatMessage({id: \"settings_pane_button_label\"})} />\n  </div>\n));\n\n// Add the locale data for pluralization and relative-time formatting for now,\n// this just uses english locale data. We can make this more sophisticated if\n// more features are needed.\nfunction addLocaleDataForReactIntl(locale) {\n  addLocaleData([{locale, parentLocale: \"en\"}]);\n}\n\n// Returns a function will not be continuously triggered when called. The\n// function will be triggered if called again after `wait` milliseconds.\nfunction debounce(func, wait) {\n  let timer;\n  return (...args) => {\n    if (timer) { return; }\n\n    let wakeUp = () => { timer = null; };\n\n    timer = setTimeout(wakeUp, wait);\n    func.apply(this, args);\n  };\n}\n\nexport class _Base extends React.PureComponent {\n  componentWillMount() {\n    const {locale} = this.props;\n    addLocaleDataForReactIntl(locale);\n    if (this.props.isFirstrun) {\n      global.document.body.classList.add(\"welcome\", \"hide-main\");\n    }\n  }\n\n  componentDidMount() {\n    // Request state AFTER the first render to ensure we don't cause the\n    // prerendered DOM to be unmounted. Otherwise, NEW_TAB_STATE_REQUEST is\n    // dispatched right after the store is ready.\n    if (this.props.isPrerendered) {\n      this.props.dispatch(ac.AlsoToMain({type: at.NEW_TAB_STATE_REQUEST}));\n      this.props.dispatch(ac.AlsoToMain({type: at.PAGE_PRERENDERED}));\n    }\n  }\n\n  componentWillUnmount() {\n    this.updateTheme();\n  }\n\n  componentWillUpdate() {\n    this.updateTheme();\n  }\n\n  updateTheme() {\n    const bodyClassName = [\n      \"activity-stream\",\n      // If we skipped the about:welcome overlay and removed the CSS classes\n      // we don't want to add them back to the Activity Stream view\n      document.body.classList.contains(\"welcome\") ? \"welcome\" : \"\",\n      document.body.classList.contains(\"hide-main\") ? \"hide-main\" : \"\",\n    ].filter(v => v).join(\" \");\n    global.document.body.className = bodyClassName;\n  }\n\n  render() {\n    const {props} = this;\n    const {App, locale, strings} = props;\n    const {initialized} = App;\n\n    const prefs = props.Prefs.values;\n    if (prefs[\"asrouter.devtoolsEnabled\"] && window.location.hash === \"#asrouter\") {\n      return (<ASRouterAdmin />);\n    }\n\n    if (!props.isPrerendered && !initialized) {\n      return null;\n    }\n\n    return (<IntlProvider locale={locale} messages={strings}>\n        <ErrorBoundary className=\"base-content-fallback\">\n          <BaseContent {...this.props} />\n        </ErrorBoundary>\n      </IntlProvider>);\n  }\n}\n\nexport class BaseContent extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.openPreferences = this.openPreferences.bind(this);\n    this.onWindowScroll = debounce(this.onWindowScroll.bind(this), 5);\n    this.state = {fixedSearch: false};\n  }\n\n  componentDidMount() {\n    global.addEventListener(\"scroll\", this.onWindowScroll);\n  }\n\n  componentWillUnmount() {\n    global.removeEventListener(\"scroll\", this.onWindowScroll);\n  }\n\n  onWindowScroll() {\n    const SCROLL_THRESHOLD = 34;\n    if (global.scrollY > SCROLL_THRESHOLD && !this.state.fixedSearch) {\n      this.setState({fixedSearch: true});\n    } else if (global.scrollY <= SCROLL_THRESHOLD && this.state.fixedSearch) {\n      this.setState({fixedSearch: false});\n    }\n  }\n\n  openPreferences() {\n    this.props.dispatch(ac.OnlyToMain({type: at.SETTINGS_OPEN}));\n    this.props.dispatch(ac.UserEvent({event: \"OPEN_NEWTAB_PREFS\"}));\n  }\n\n  render() {\n    const {props} = this;\n    const {App} = props;\n    const {initialized} = App;\n    const prefs = props.Prefs.values;\n\n    const shouldBeFixedToTop = PrerenderData.arePrefsValid(name => prefs[name]);\n    const noSectionsEnabled = !prefs[\"feeds.topsites\"] && props.Sections.filter(section => section.enabled).length === 0;\n\n    const outerClassName = [\n      \"outer-wrapper\",\n      shouldBeFixedToTop && \"fixed-to-top\",\n      prefs.showSearch && this.state.fixedSearch && !noSectionsEnabled && \"fixed-search\",\n      prefs.showSearch && noSectionsEnabled && \"only-search\",\n    ].filter(v => v).join(\" \");\n\n    return (\n      <div>\n        <div className={outerClassName}>\n          <main>\n            {prefs.showSearch &&\n              <div className=\"non-collapsible-section\">\n                <ErrorBoundary>\n                  <Search showLogo={noSectionsEnabled} />\n                </ErrorBoundary>\n              </div>\n            }\n            <div className={`body-wrapper${(initialized ? \" on\" : \"\")}`}>\n              {!prefs.migrationExpired &&\n                <div className=\"non-collapsible-section\">\n                  <ManualMigration />\n                </div>\n                }\n              <Sections />\n              <PrefsButton onClick={this.openPreferences} />\n            </div>\n            <ConfirmDialog />\n          </main>\n        </div>\n        {this.props.isFirstrun && <StartupOverlay />}\n      </div>);\n  }\n}\n\nexport const Base = connect(state => ({App: state.App, Prefs: state.Prefs, Sections: state.Sections}))(_Base);\n","module.exports = ReactIntl;","import {ASRouterUtils} from \"../../asrouter/asrouter-content\";\nimport React from \"react\";\n\nexport class ASRouterAdmin extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onMessage = this.onMessage.bind(this);\n    this.findOtherBundledMessagesOfSameTemplate = this.findOtherBundledMessagesOfSameTemplate.bind(this);\n    this.state = {};\n  }\n\n  onMessage({data: action}) {\n    if (action.type === \"ADMIN_SET_STATE\") {\n      this.setState(action.data);\n    }\n  }\n\n  componentWillMount() {\n    const endpoint = ASRouterUtils.getEndpoint();\n    ASRouterUtils.sendMessage({type: \"ADMIN_CONNECT_STATE\", data: {endpoint}});\n    ASRouterUtils.addListener(this.onMessage);\n  }\n\n  componentWillUnmount() {\n    ASRouterUtils.removeListener(this.onMessage);\n  }\n\n  findOtherBundledMessagesOfSameTemplate(template) {\n    return this.state.messages.filter(msg => msg.template === template && msg.bundled);\n  }\n\n  handleBlock(msg) {\n    if (msg.bundled) {\n      // If we are blocking a message that belongs to a bundle, block all other messages that are bundled of that same template\n      let bundle = this.findOtherBundledMessagesOfSameTemplate(msg.template);\n      return () => ASRouterUtils.blockBundle(bundle);\n    }\n    return () => ASRouterUtils.blockById(msg.id);\n  }\n\n  handleUnblock(msg) {\n    if (msg.bundled) {\n      // If we are unblocking a message that belongs to a bundle, unblock all other messages that are bundled of that same template\n      let bundle = this.findOtherBundledMessagesOfSameTemplate(msg.template);\n      return () => ASRouterUtils.unblockBundle(bundle);\n    }\n    return () => ASRouterUtils.unblockById(msg.id);\n  }\n\n  handleOverride(id) {\n    return () => ASRouterUtils.overrideMessage(id);\n  }\n\n  renderMessageItem(msg) {\n    const isCurrent = msg.id === this.state.lastMessageId;\n    const isBlocked = this.state.messageBlockList.includes(msg.id);\n    const impressions = this.state.messageImpressions[msg.id] ? this.state.messageImpressions[msg.id].length : 0;\n\n    let itemClassName = \"message-item\";\n    if (isCurrent) { itemClassName += \" current\"; }\n    if (isBlocked) { itemClassName += \" blocked\"; }\n\n    return (<tr className={itemClassName} key={msg.id}>\n      <td className=\"message-id\"><span>{msg.id} <br /></span></td>\n      <td>\n        <button className={`button ${(isBlocked ? \"\" : \" primary\")}`} onClick={isBlocked ? this.handleUnblock(msg) : this.handleBlock(msg)}>{isBlocked ? \"Unblock\" : \"Block\"}</button>\n       {isBlocked ? null : <button className=\"button\" onClick={this.handleOverride(msg.id)}>Show</button>}\n       <br />({impressions} impressions)\n      </td>\n      <td className=\"message-summary\">\n        <pre>{JSON.stringify(msg, null, 2)}</pre>\n      </td>\n    </tr>);\n  }\n\n  renderMessages() {\n    if (!this.state.messages) {\n      return null;\n    }\n    return (<table><tbody>\n      {this.state.messages.map(msg => this.renderMessageItem(msg))}\n    </tbody></table>);\n  }\n\n  renderTableHead() {\n    return (<thead>\n      <tr className=\"message-item\">\n        <td>id</td>\n        <td>source</td>\n        <td>last updated</td>\n      </tr>\n    </thead>);\n  }\n\n  renderProviders() {\n    return (<table>{this.renderTableHead()}<tbody>\n      {this.state.providers.map((provider, i) => {\n        let label = \"(local)\";\n        if (provider.type === \"remote\") {\n          label = <a target=\"_blank\" href={provider.url}>{provider.url}</a>;\n        } else if (provider.type === \"remote-settings\") {\n          label = `${provider.bucket} (Remote Settings)`;\n        }\n        return (<tr className=\"message-item\" key={i}>\n          <td>{provider.id}</td>\n          <td>{label}</td>\n          <td>{provider.lastUpdated ? new Date(provider.lastUpdated).toString() : \"\"}</td>\n        </tr>);\n      })}\n    </tbody></table>);\n  }\n\n  render() {\n    return (<div className=\"asrouter-admin outer-wrapper\">\n      <h1>AS Router Admin</h1>\n      <button className=\"button primary\" onClick={ASRouterUtils.getNextMessage}>Refresh Current Message</button>\n      <h2>Message Providers</h2>\n      {this.state.providers ? this.renderProviders() : null}\n      <h2>Messages</h2>\n      {this.renderMessages()}\n    </div>);\n  }\n}\n","import {actionCreators as ac, actionTypes} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\n/**\n * ConfirmDialog component.\n * One primary action button, one cancel button.\n *\n * Content displayed is controlled by `data` prop the component receives.\n * Example:\n * data: {\n *   // Any sort of data needed to be passed around by actions.\n *   payload: site.url,\n *   // Primary button AlsoToMain action.\n *   action: \"DELETE_HISTORY_URL\",\n *   // Primary button USerEvent action.\n *   userEvent: \"DELETE\",\n *   // Array of locale ids to display.\n *   message_body: [\"confirm_history_delete_p1\", \"confirm_history_delete_notice_p2\"],\n *   // Text for primary button.\n *   confirm_button_string_id: \"menu_action_delete\"\n * },\n */\nexport class _ConfirmDialog extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this._handleCancelBtn = this._handleCancelBtn.bind(this);\n    this._handleConfirmBtn = this._handleConfirmBtn.bind(this);\n  }\n\n  _handleCancelBtn() {\n    this.props.dispatch({type: actionTypes.DIALOG_CANCEL});\n    this.props.dispatch(ac.UserEvent({event: actionTypes.DIALOG_CANCEL, source: this.props.data.eventSource}));\n  }\n\n  _handleConfirmBtn() {\n    this.props.data.onConfirm.forEach(this.props.dispatch);\n  }\n\n  _renderModalMessage() {\n    const message_body = this.props.data.body_string_id;\n\n    if (!message_body) {\n      return null;\n    }\n\n    return (<span>\n      {message_body.map(msg => <p key={msg}><FormattedMessage id={msg} /></p>)}\n    </span>);\n  }\n\n  render() {\n    if (!this.props.visible) {\n      return null;\n    }\n\n    return (<div className=\"confirmation-dialog\">\n      <div className=\"modal-overlay\" onClick={this._handleCancelBtn} />\n      <div className=\"modal\">\n        <section className=\"modal-message\">\n          {this.props.data.icon && <span className={`icon icon-spacer icon-${this.props.data.icon}`} />}\n          {this._renderModalMessage()}\n        </section>\n        <section className=\"actions\">\n          <button onClick={this._handleCancelBtn}>\n            <FormattedMessage id={this.props.data.cancel_button_string_id} />\n          </button>\n          <button className=\"done\" onClick={this._handleConfirmBtn}>\n            <FormattedMessage id={this.props.data.confirm_button_string_id} />\n          </button>\n        </section>\n      </div>\n    </div>);\n  }\n}\n\nexport const ConfirmDialog = connect(state => state.Dialog)(_ConfirmDialog);\n","module.exports = ReactRedux;","import {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class ErrorBoundaryFallback extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.windowObj = this.props.windowObj || window;\n    this.onClick = this.onClick.bind(this);\n  }\n\n  /**\n   * Since we only get here if part of the page has crashed, do a\n   * forced reload to give us the best chance at recovering.\n   */\n  onClick() {\n    this.windowObj.location.reload(true);\n  }\n\n  render() {\n    const defaultClass = \"as-error-fallback\";\n    let className;\n    if (\"className\" in this.props) {\n      className = `${this.props.className} ${defaultClass}`;\n    } else {\n      className = defaultClass;\n    }\n\n    // href=\"#\" to force normal link styling stuff (eg cursor on hover)\n    return (\n      <div className={className}>\n        <div>\n          <FormattedMessage\n            defaultMessage=\"Oops, something went wrong loading this content.\"\n            id=\"error_fallback_default_info\" />\n        </div>\n        <span>\n          <a href=\"#\" className=\"reload-button\" onClick={this.onClick}>\n            <FormattedMessage\n              defaultMessage=\"Refresh page to try again.\"\n              id=\"error_fallback_default_refresh_suggestion\" />\n          </a>\n        </span>\n      </div>\n    );\n  }\n}\nErrorBoundaryFallback.defaultProps = {className: \"as-error-fallback\"};\n\nexport class ErrorBoundary extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {hasError: false};\n  }\n\n  componentDidCatch(error, info) {\n    this.setState({hasError: true});\n  }\n\n  render() {\n    if (!this.state.hasError) {\n      return (this.props.children);\n    }\n\n    return <this.props.FallbackComponent className={this.props.className} />;\n  }\n}\n\nErrorBoundary.defaultProps = {FallbackComponent: ErrorBoundaryFallback};\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\n/**\n * Manual migration component used to start the profile import wizard.\n * Message is presented temporarily and will go away if:\n * 1.  User clicks \"No Thanks\"\n * 2.  User completed the data import\n * 3.  After 3 active days\n * 4.  User clicks \"Cancel\" on the import wizard (currently not implemented).\n */\nexport class _ManualMigration extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onLaunchTour = this.onLaunchTour.bind(this);\n    this.onCancelTour = this.onCancelTour.bind(this);\n  }\n\n  onLaunchTour() {\n    this.props.dispatch(ac.AlsoToMain({type: at.MIGRATION_START}));\n    this.props.dispatch(ac.UserEvent({event: at.MIGRATION_START}));\n  }\n\n  onCancelTour() {\n    this.props.dispatch(ac.AlsoToMain({type: at.MIGRATION_CANCEL}));\n    this.props.dispatch(ac.UserEvent({event: at.MIGRATION_CANCEL}));\n  }\n\n  render() {\n    return (<div className=\"manual-migration-container\">\n        <p>\n          <span className=\"icon icon-import\" />\n          <FormattedMessage id=\"manual_migration_explanation2\" />\n        </p>\n        <div className=\"manual-migration-actions actions\">\n          <button className=\"dismiss\" onClick={this.onCancelTour}>\n            <FormattedMessage id=\"manual_migration_cancel_button\" />\n          </button>\n          <button onClick={this.onLaunchTour}>\n            <FormattedMessage id=\"manual_migration_import_button\" />\n          </button>\n        </div>\n    </div>);\n  }\n}\n\nexport const ManualMigration = connect()(_ManualMigration);\n","class _PrerenderData {\n  constructor(options) {\n    this.initialPrefs = options.initialPrefs;\n    this.initialSections = options.initialSections;\n    this._setValidation(options.validation);\n  }\n\n  get validation() {\n    return this._validation;\n  }\n\n  set validation(value) {\n    this._setValidation(value);\n  }\n\n  get invalidatingPrefs() {\n    return this._invalidatingPrefs;\n  }\n\n    // This is needed so we can use it in the constructor\n  _setValidation(value = []) {\n    this._validation = value;\n    this._invalidatingPrefs = value.reduce((result, next) => {\n      if (typeof next === \"string\") {\n        result.push(next);\n        return result;\n      } else if (next && next.oneOf) {\n        return result.concat(next.oneOf);\n      } else if (next && next.indexedDB) {\n        return result.concat(next.indexedDB);\n      }\n      throw new Error(\"Your validation configuration is not properly configured\");\n    }, []);\n  }\n\n  arePrefsValid(getPref, indexedDBPrefs) {\n    for (const prefs of this.validation) {\n      // {oneOf: [\"foo\", \"bar\"]}\n      if (prefs && prefs.oneOf && !prefs.oneOf.some(name => getPref(name) === this.initialPrefs[name])) {\n        return false;\n\n        // {indexedDB: [\"foo\", \"bar\"]}\n      } else if (indexedDBPrefs && prefs && prefs.indexedDB) {\n        const anyModifiedPrefs = prefs.indexedDB.some(prefName => indexedDBPrefs.some(pref => pref && pref[prefName]));\n        if (anyModifiedPrefs) {\n          return false;\n        }\n        // \"foo\"\n      } else if (getPref(prefs) !== this.initialPrefs[prefs]) {\n        return false;\n      }\n    }\n    return true;\n  }\n}\n\nthis.PrerenderData = new _PrerenderData({\n  initialPrefs: {\n    \"migrationExpired\": true,\n    \"feeds.topsites\": true,\n    \"showSearch\": true,\n    \"topSitesRows\": 1,\n    \"feeds.section.topstories\": true,\n    \"feeds.section.highlights\": true,\n    \"sectionOrder\": \"topsites,topstories,highlights\",\n    \"collapsed\": false,\n  },\n  // Prefs listed as invalidating will prevent the prerendered version\n  // of AS from being used if their value is something other than what is listed\n  // here. This is required because some preferences cause the page layout to be\n  // too different for the prerendered version to be used. Unfortunately, this\n  // will result in users who have modified some of their preferences not being\n  // able to get the benefits of prerendering.\n  validation: [\n    \"feeds.topsites\",\n    \"showSearch\",\n    \"topSitesRows\",\n    \"sectionOrder\",\n    // This means if either of these are set to their default values,\n    // prerendering can be used.\n    {oneOf: [\"feeds.section.topstories\", \"feeds.section.highlights\"]},\n    // If any component has the following preference set to `true` it will\n    // invalidate the prerendered version.\n    {indexedDB: [\"collapsed\"]},\n  ],\n  initialSections: [\n    {\n      enabled: true,\n      icon: \"pocket\",\n      id: \"topstories\",\n      order: 1,\n      title: {id: \"header_recommended_by\", values: {provider: \"Pocket\"}},\n    },\n    {\n      enabled: true,\n      id: \"highlights\",\n      icon: \"highlights\",\n      order: 2,\n      title: {id: \"header_highlights\"},\n    },\n  ],\n});\n\nthis._PrerenderData = _PrerenderData;\nconst EXPORTED_SYMBOLS = [\"PrerenderData\", \"_PrerenderData\"];\n","/* globals ContentSearchUIController */\n\"use strict\";\n\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {actionCreators as ac} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {IS_NEWTAB} from \"content-src/lib/constants\";\nimport React from \"react\";\n\nexport class _Search extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onClick = this.onClick.bind(this);\n    this.onInputMount = this.onInputMount.bind(this);\n  }\n\n  handleEvent(event) {\n    // Also track search events with our own telemetry\n    if (event.detail.type === \"Search\") {\n      this.props.dispatch(ac.UserEvent({event: \"SEARCH\"}));\n    }\n  }\n\n  onClick(event) {\n    window.gContentSearchController.search(event);\n  }\n\n  componentWillUnmount() {\n    delete window.gContentSearchController;\n  }\n\n  onInputMount(input) {\n    if (input) {\n      // The \"healthReportKey\" and needs to be \"newtab\" or \"abouthome\" so that\n      // BrowserUsageTelemetry.jsm knows to handle events with this name, and\n      // can add the appropriate telemetry probes for search. Without the correct\n      // name, certain tests like browser_UsageTelemetry_content.js will fail\n      // (See github ticket #2348 for more details)\n      const healthReportKey = IS_NEWTAB ? \"newtab\" : \"abouthome\";\n\n      // The \"searchSource\" needs to be \"newtab\" or \"homepage\" and is sent with\n      // the search data and acts as context for the search request (See\n      // nsISearchEngine.getSubmission). It is necessary so that search engine\n      // plugins can correctly atribute referrals. (See github ticket #3321 for\n      // more details)\n      const searchSource = IS_NEWTAB ? \"newtab\" : \"homepage\";\n\n      // gContentSearchController needs to exist as a global so that tests for\n      // the existing about:home can find it; and so it allows these tests to pass.\n      // In the future, when activity stream is default about:home, this can be renamed\n      window.gContentSearchController = new ContentSearchUIController(input, input.parentNode,\n        healthReportKey, searchSource);\n      addEventListener(\"ContentSearchClient\", this);\n    } else {\n      window.gContentSearchController = null;\n      removeEventListener(\"ContentSearchClient\", this);\n    }\n  }\n\n  /*\n   * Do not change the ID on the input field, as legacy newtab code\n   * specifically looks for the id 'newtab-search-text' on input fields\n   * in order to execute searches in various tests\n   */\n  render() {\n    return (<div className=\"search-wrapper\">\n      {this.props.showLogo &&\n        <div className=\"logo-and-wordmark\">\n          <div className=\"logo\" />\n          <div className=\"wordmark\" />\n        </div>\n      }\n      <div className=\"search-inner-wrapper\">\n        <label htmlFor=\"newtab-search-text\" className=\"search-label\">\n          <span className=\"sr-only\"><FormattedMessage id=\"search_web_placeholder\" /></span>\n        </label>\n        <input\n          id=\"newtab-search-text\"\n          maxLength=\"256\"\n          placeholder={this.props.intl.formatMessage({id: \"search_web_placeholder\"})}\n          ref={this.onInputMount}\n          title={this.props.intl.formatMessage({id: \"search_web_placeholder\"})}\n          type=\"search\" />\n        <button\n          id=\"searchSubmit\"\n          className=\"search-button\"\n          onClick={this.onClick}\n          title={this.props.intl.formatMessage({id: \"search_button\"})}>\n          <span className=\"sr-only\"><FormattedMessage id=\"search_button\" /></span>\n        </button>\n      </div>\n    </div>);\n  }\n}\n\nexport const Search = connect()(injectIntl(_Search));\n","export const IS_NEWTAB = global.document && global.document.documentURI === \"about:newtab\";\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {Card, PlaceholderCard} from \"content-src/components/Card/Card\";\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {CollapsibleSection} from \"content-src/components/CollapsibleSection/CollapsibleSection\";\nimport {ComponentPerfTimer} from \"content-src/components/ComponentPerfTimer/ComponentPerfTimer\";\nimport {connect} from \"react-redux\";\nimport {MoreRecommendations} from \"content-src/components/MoreRecommendations/MoreRecommendations\";\nimport {PocketLoggedInCta} from \"content-src/components/PocketLoggedInCta/PocketLoggedInCta\";\nimport React from \"react\";\nimport {Topics} from \"content-src/components/Topics/Topics\";\nimport {TopSites} from \"content-src/components/TopSites/TopSites\";\n\nconst VISIBLE = \"visible\";\nconst VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\nconst CARDS_PER_ROW_DEFAULT = 3;\nconst CARDS_PER_ROW_COMPACT_WIDE = 4;\n\nfunction getFormattedMessage(message) {\n  return typeof message === \"string\" ? <span>{message}</span> : <FormattedMessage {...message} />;\n}\n\nexport class Section extends React.PureComponent {\n  get numRows() {\n    const {rowsPref, maxRows, Prefs} = this.props;\n    return rowsPref ? Prefs.values[rowsPref] : maxRows;\n  }\n\n  _dispatchImpressionStats() {\n    const {props} = this;\n    let cardsPerRow = CARDS_PER_ROW_DEFAULT;\n    if (props.compactCards && global.matchMedia(`(min-width: 1072px)`).matches) {\n      // If the section has compact cards and the viewport is wide enough, we show\n      // 4 columns instead of 3.\n      // $break-point-widest = 1072px (from _variables.scss)\n      cardsPerRow = CARDS_PER_ROW_COMPACT_WIDE;\n    }\n    const maxCards = cardsPerRow * this.numRows;\n    const cards = props.rows.slice(0, maxCards);\n\n    if (this.needsImpressionStats(cards)) {\n      props.dispatch(ac.ImpressionStats({\n        source: props.eventSource,\n        tiles: cards.map(link => ({id: link.guid})),\n      }));\n      this.impressionCardGuids = cards.map(link => link.guid);\n    }\n  }\n\n  // This sends an event when a user sees a set of new content. If content\n  // changes while the page is hidden (i.e. preloaded or on a hidden tab),\n  // only send the event if the page becomes visible again.\n  sendImpressionStatsOrAddListener() {\n    const {props} = this;\n\n    if (!props.shouldSendImpressionStats || !props.dispatch) {\n      return;\n    }\n\n    if (props.document.visibilityState === VISIBLE) {\n      this._dispatchImpressionStats();\n    } else {\n      // We should only ever send the latest impression stats ping, so remove any\n      // older listeners.\n      if (this._onVisibilityChange) {\n        props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n      }\n\n      // When the page becomes visible, send the impression stats ping if the section isn't collapsed.\n      this._onVisibilityChange = () => {\n        if (props.document.visibilityState === VISIBLE) {\n          if (!this.props.pref.collapsed) {\n            this._dispatchImpressionStats();\n          }\n          props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n        }\n      };\n      props.document.addEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  componentWillMount() {\n    this.sendNewTabRehydrated(this.props.initialized);\n  }\n\n  componentDidMount() {\n    if (this.props.rows.length && !this.props.pref.collapsed) {\n      this.sendImpressionStatsOrAddListener();\n    }\n  }\n\n  componentDidUpdate(prevProps) {\n    const {props} = this;\n    const isCollapsed = props.pref.collapsed;\n    const wasCollapsed = prevProps.pref.collapsed;\n    if (\n      // Don't send impression stats for the empty state\n      props.rows.length &&\n      (\n        // We only want to send impression stats if the content of the cards has changed\n        // and the section is not collapsed...\n        (props.rows !== prevProps.rows && !isCollapsed) ||\n        // or if we are expanding a section that was collapsed.\n        (wasCollapsed && !isCollapsed)\n      )\n    ) {\n      this.sendImpressionStatsOrAddListener();\n    }\n  }\n\n  componentWillUpdate(nextProps) {\n    this.sendNewTabRehydrated(nextProps.initialized);\n  }\n\n  componentWillUnmount() {\n    if (this._onVisibilityChange) {\n      this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  needsImpressionStats(cards) {\n    if (!this.impressionCardGuids || (this.impressionCardGuids.length !== cards.length)) {\n      return true;\n    }\n\n    for (let i = 0; i < cards.length; i++) {\n      if (cards[i].guid !== this.impressionCardGuids[i]) {\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  // The NEW_TAB_REHYDRATED event is used to inform feeds that their\n  // data has been consumed e.g. for counting the number of tabs that\n  // have rendered that data.\n  sendNewTabRehydrated(initialized) {\n    if (initialized && !this.renderNotified) {\n      this.props.dispatch(ac.AlsoToMain({type: at.NEW_TAB_REHYDRATED, data: {}}));\n      this.renderNotified = true;\n    }\n  }\n\n  render() {\n    const {\n      id, eventSource, title, icon, rows, Pocket, topics,\n      emptyState, dispatch, compactCards, read_more_endpoint,\n      contextMenuOptions, initialized, learnMore,\n      pref, privacyNoticeURL, isFirst, isLast,\n    } = this.props;\n\n    const waitingForSpoc = id === \"topstories\" && this.props.Pocket.waitingForSpoc;\n    const maxCardsPerRow = compactCards ? CARDS_PER_ROW_COMPACT_WIDE : CARDS_PER_ROW_DEFAULT;\n    const {numRows} = this;\n    const maxCards = maxCardsPerRow * numRows;\n    const maxCardsOnNarrow = CARDS_PER_ROW_DEFAULT * numRows;\n\n    const {pocketCta, isUserLoggedIn} = Pocket || {};\n    const {useCta} = pocketCta || {};\n\n    // Don't display anything until we have a definitve result from Pocket,\n    // to avoid a flash of logged out state while we render.\n    const isPocketLoggedInDefined = (isUserLoggedIn === true || isUserLoggedIn === false);\n\n    const shouldShowPocketCta = (id === \"topstories\" &&\n      useCta && isUserLoggedIn === false);\n\n    // Show topics only for top stories and if it has loaded with topics.\n    // The classs .top-stories-bottom-container ensures content doesn't shift as things load.\n    const shouldShowTopics = (id === \"topstories\" &&\n      (topics && topics.length > 0) &&\n      ((useCta && isUserLoggedIn === true) || (!useCta && isPocketLoggedInDefined)));\n\n    const realRows = rows.slice(0, maxCards);\n\n    // The empty state should only be shown after we have initialized and there is no content.\n    // Otherwise, we should show placeholders.\n    const shouldShowEmptyState = initialized && !rows.length;\n\n    const cards = [];\n    if (!shouldShowEmptyState) {\n      for (let i = 0; i < maxCards; i++) {\n        const link = realRows[i];\n        // On narrow viewports, we only show 3 cards per row. We'll mark the rest as\n        // .hide-for-narrow to hide in CSS via @media query.\n        const className = (i >= maxCardsOnNarrow) ? \"hide-for-narrow\" : \"\";\n        let usePlaceholder = !link;\n        // If we are in the third card and waiting for spoc,\n        // use the placeholder.\n        if (!usePlaceholder && i === 2 && waitingForSpoc) {\n          usePlaceholder = true;\n        }\n        cards.push(!usePlaceholder ? (\n          <Card key={i}\n            index={i}\n            className={className}\n            dispatch={dispatch}\n            link={link}\n            contextMenuOptions={contextMenuOptions}\n            eventSource={eventSource}\n            shouldSendImpressionStats={this.props.shouldSendImpressionStats}\n            isWebExtension={this.props.isWebExtension} />\n        ) : (\n          <PlaceholderCard key={i} className={className} />\n        ));\n      }\n    }\n\n    const sectionClassName = [\n      \"section\",\n      compactCards ? \"compact-cards\" : \"normal-cards\",\n    ].join(\" \");\n\n    // <Section> <-- React component\n    // <section> <-- HTML5 element\n    return (<ComponentPerfTimer {...this.props}>\n      <CollapsibleSection className={sectionClassName} icon={icon}\n        title={title}\n        id={id}\n        eventSource={eventSource}\n        collapsed={this.props.pref.collapsed}\n        showPrefName={(pref && pref.feed) || id}\n        privacyNoticeURL={privacyNoticeURL}\n        Prefs={this.props.Prefs}\n        isFirst={isFirst}\n        isLast={isLast}\n        learnMore={learnMore}\n        dispatch={this.props.dispatch}\n        isWebExtension={this.props.isWebExtension}>\n\n        {!shouldShowEmptyState && (<ul className=\"section-list\" style={{padding: 0}}>\n          {cards}\n        </ul>)}\n        {shouldShowEmptyState &&\n          <div className=\"section-empty-state\">\n            <div className=\"empty-state\">\n              {emptyState.icon && emptyState.icon.startsWith(\"moz-extension://\") ?\n                <img className=\"empty-state-icon icon\" style={{\"background-image\": `url('${emptyState.icon}')`}} /> :\n                <img className={`empty-state-icon icon icon-${emptyState.icon}`} />}\n              <p className=\"empty-state-message\">\n                {getFormattedMessage(emptyState.message)}\n              </p>\n            </div>\n          </div>}\n        {id === \"topstories\" &&\n          <div className=\"top-stories-bottom-container\">\n            {shouldShowTopics && <Topics topics={this.props.topics} />}\n            {shouldShowPocketCta && <PocketLoggedInCta />}\n            {read_more_endpoint &&\n              <MoreRecommendations read_more_endpoint={read_more_endpoint} />}\n          </div>}\n      </CollapsibleSection>\n    </ComponentPerfTimer>);\n  }\n}\n\nSection.defaultProps = {\n  document: global.document,\n  rows: [],\n  emptyState: {},\n  pref: {},\n  title: \"\",\n};\n\nexport const SectionIntl = connect(state => ({Prefs: state.Prefs, Pocket: state.Pocket}))(injectIntl(Section));\n\nexport class _Sections extends React.PureComponent {\n  renderSections() {\n    const sections = [];\n    const enabledSections = this.props.Sections.filter(section => section.enabled);\n    const {sectionOrder, \"feeds.topsites\": showTopSites} = this.props.Prefs.values;\n    // Enabled sections doesn't include Top Sites, so we add it if enabled.\n    const expectedCount = enabledSections.length + ~~showTopSites;\n\n    for (const sectionId of sectionOrder.split(\",\")) {\n      const commonProps = {\n        key: sectionId,\n        isFirst: sections.length === 0,\n        isLast: sections.length === expectedCount - 1,\n      };\n      if (sectionId === \"topsites\" && showTopSites) {\n        sections.push(<TopSites {...commonProps} />);\n      } else {\n        const section = enabledSections.find(s => s.id === sectionId);\n        if (section) {\n          sections.push(<SectionIntl {...section} {...commonProps} />);\n        }\n      }\n    }\n    return sections;\n  }\n\n  render() {\n    return (\n      <div className=\"sections-list\">\n        {this.renderSections()}\n      </div>\n    );\n  }\n}\n\nexport const Sections = connect(state => ({Sections: state.Sections, Prefs: state.Prefs}))(_Sections);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\n\nconst _OpenInPrivateWindow = site => ({\n  id: \"menu_action_open_private_window\",\n  icon: \"new-window-private\",\n  action: ac.OnlyToMain({\n    type: at.OPEN_PRIVATE_WINDOW,\n    data: {url: site.url, referrer: site.referrer},\n  }),\n  userEvent: \"OPEN_PRIVATE_WINDOW\",\n});\n\nexport const GetPlatformString = platform => {\n  switch (platform) {\n    case \"win\":\n      return \"menu_action_show_file_windows\";\n    case \"macosx\":\n      return \"menu_action_show_file_mac_os\";\n    case \"linux\":\n      return \"menu_action_show_file_linux\";\n    default:\n      return \"menu_action_show_file_default\";\n  }\n};\n\n/**\n * List of functions that return items that can be included as menu options in a\n * LinkMenu. All functions take the site as the first parameter, and optionally\n * the index of the site.\n */\nexport const LinkMenuOptions = {\n  Separator: () => ({type: \"separator\"}),\n  EmptyItem: () => ({type: \"empty\"}),\n  RemoveBookmark: site => ({\n    id: \"menu_action_remove_bookmark\",\n    icon: \"bookmark-added\",\n    action: ac.AlsoToMain({\n      type: at.DELETE_BOOKMARK_BY_ID,\n      data: site.bookmarkGuid,\n    }),\n    userEvent: \"BOOKMARK_DELETE\",\n  }),\n  AddBookmark: site => ({\n    id: \"menu_action_bookmark\",\n    icon: \"bookmark-hollow\",\n    action: ac.AlsoToMain({\n      type: at.BOOKMARK_URL,\n      data: {url: site.url, title: site.title, type: site.type},\n    }),\n    userEvent: \"BOOKMARK_ADD\",\n  }),\n  OpenInNewWindow: site => ({\n    id: \"menu_action_open_new_window\",\n    icon: \"new-window\",\n    action: ac.AlsoToMain({\n      type: at.OPEN_NEW_WINDOW,\n      data: {\n        referrer: site.referrer,\n        typedBonus: site.typedBonus,\n        url: site.url,\n      },\n    }),\n    userEvent: \"OPEN_NEW_WINDOW\",\n  }),\n  BlockUrl: (site, index, eventSource) => ({\n    id: \"menu_action_dismiss\",\n    icon: \"dismiss\",\n    action: ac.AlsoToMain({\n      type: at.BLOCK_URL,\n      data: {url: site.open_url || site.url, pocket_id: site.pocket_id},\n    }),\n    impression: ac.ImpressionStats({\n      source: eventSource,\n      block: 0,\n      tiles: [{id: site.guid, pos: index}],\n    }),\n    userEvent: \"BLOCK\",\n  }),\n\n  // This is an option for web extentions which will result in remove items from\n  // memory and notify the web extenion, rather than using the built-in block list.\n  WebExtDismiss: (site, index, eventSource) => ({\n    id: \"menu_action_webext_dismiss\",\n    string_id: \"menu_action_dismiss\",\n    icon: \"dismiss\",\n    action: ac.WebExtEvent(at.WEBEXT_DISMISS, {\n      source: eventSource,\n      url: site.url,\n      action_position: index,\n    }),\n  }),\n  DeleteUrl: (site, index, eventSource, isEnabled, siteInfo) => ({\n    id: \"menu_action_delete\",\n    icon: \"delete\",\n    action: {\n      type: at.DIALOG_OPEN,\n      data: {\n        onConfirm: [\n          ac.AlsoToMain({type: at.DELETE_HISTORY_URL, data: {url: site.url, pocket_id: site.pocket_id, forceBlock: site.bookmarkGuid}}),\n          ac.UserEvent(Object.assign({event: \"DELETE\", source: eventSource, action_position: index}, siteInfo)),\n        ],\n        eventSource,\n        body_string_id: [\"confirm_history_delete_p1\", \"confirm_history_delete_notice_p2\"],\n        confirm_button_string_id: \"menu_action_delete\",\n        cancel_button_string_id: \"topsites_form_cancel_button\",\n        icon: \"modal-delete\",\n      },\n    },\n    userEvent: \"DIALOG_OPEN\",\n  }),\n  ShowFile: (site, index, eventSource, isEnabled, siteInfo, platform) => ({\n    id: GetPlatformString(platform),\n    icon: \"search\",\n    action: ac.OnlyToMain({\n      type: at.SHOW_DOWNLOAD_FILE,\n      data: {url: site.url},\n    }),\n  }),\n  OpenFile: site => ({\n    id: \"menu_action_open_file\",\n    icon: \"open-file\",\n    action: ac.OnlyToMain({\n      type: at.OPEN_DOWNLOAD_FILE,\n      data: {url: site.url},\n    }),\n  }),\n  CopyDownloadLink: site => ({\n    id: \"menu_action_copy_download_link\",\n    icon: \"copy\",\n    action: ac.OnlyToMain({\n      type: at.COPY_DOWNLOAD_LINK,\n      data: {url: site.url},\n    }),\n  }),\n  GoToDownloadPage: site => ({\n    id: \"menu_action_go_to_download_page\",\n    icon: \"download\",\n    action: ac.OnlyToMain({\n      type: at.OPEN_LINK,\n      data: {url: site.referrer},\n    }),\n    disabled: !site.referrer,\n  }),\n  RemoveDownload: site => ({\n    id: \"menu_action_remove_download\",\n    icon: \"delete\",\n    action: ac.OnlyToMain({\n      type: at.REMOVE_DOWNLOAD_FILE,\n      data: {url: site.url},\n    }),\n  }),\n  PinTopSite: ({url, searchTopSite, label}, index) => ({\n    id: \"menu_action_pin\",\n    icon: \"pin\",\n    action: ac.AlsoToMain({\n      type: at.TOP_SITES_PIN,\n      data: {\n        site: {\n          url,\n          ...(searchTopSite && {searchTopSite, label}),\n        },\n        index,\n      },\n    }),\n    userEvent: \"PIN\",\n  }),\n  UnpinTopSite: site => ({\n    id: \"menu_action_unpin\",\n    icon: \"unpin\",\n    action: ac.AlsoToMain({\n      type: at.TOP_SITES_UNPIN,\n      data: {site: {url: site.url}},\n    }),\n    userEvent: \"UNPIN\",\n  }),\n  SaveToPocket: (site, index, eventSource) => ({\n    id: \"menu_action_save_to_pocket\",\n    icon: \"pocket-save\",\n    action: ac.AlsoToMain({\n      type: at.SAVE_TO_POCKET,\n      data: {site: {url: site.url, title: site.title}},\n    }),\n    impression: ac.ImpressionStats({\n      source: eventSource,\n      pocket: 0,\n      tiles: [{id: site.guid, pos: index}],\n    }),\n    userEvent: \"SAVE_TO_POCKET\",\n  }),\n  DeleteFromPocket: site => ({\n    id: \"menu_action_delete_pocket\",\n    icon: \"delete\",\n    action: ac.AlsoToMain({\n      type: at.DELETE_FROM_POCKET,\n      data: {pocket_id: site.pocket_id},\n    }),\n    userEvent: \"DELETE_FROM_POCKET\",\n  }),\n  ArchiveFromPocket: site => ({\n    id: \"menu_action_archive_pocket\",\n    icon: \"check\",\n    action: ac.AlsoToMain({\n      type: at.ARCHIVE_FROM_POCKET,\n      data: {pocket_id: site.pocket_id},\n    }),\n    userEvent: \"ARCHIVE_FROM_POCKET\",\n  }),\n  EditTopSite: (site, index) => ({\n    id: \"edit_topsites_button_text\",\n    icon: \"edit\",\n    action: {\n      type: at.TOP_SITES_EDIT,\n      data: {index},\n    },\n  }),\n  CheckBookmark: site => (site.bookmarkGuid ? LinkMenuOptions.RemoveBookmark(site) : LinkMenuOptions.AddBookmark(site)),\n  CheckPinTopSite: (site, index) => (site.isPinned ? LinkMenuOptions.UnpinTopSite(site) : LinkMenuOptions.PinTopSite(site, index)),\n  CheckSavedToPocket: (site, index) => (site.pocket_id ? LinkMenuOptions.DeleteFromPocket(site) : LinkMenuOptions.SaveToPocket(site, index)),\n  CheckBookmarkOrArchive: site => (site.pocket_id ? LinkMenuOptions.ArchiveFromPocket(site) : LinkMenuOptions.CheckBookmark(site)),\n  OpenInPrivateWindow: (site, index, eventSource, isEnabled) => (isEnabled ? _OpenInPrivateWindow(site) : LinkMenuOptions.EmptyItem()),\n};\n","import {actionCreators as ac} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {ContextMenu} from \"content-src/components/ContextMenu/ContextMenu\";\nimport {injectIntl} from \"react-intl\";\nimport {LinkMenuOptions} from \"content-src/lib/link-menu-options\";\nimport React from \"react\";\n\nconst DEFAULT_SITE_MENU_OPTIONS = [\"CheckPinTopSite\", \"EditTopSite\", \"Separator\", \"OpenInNewWindow\", \"OpenInPrivateWindow\", \"Separator\", \"BlockUrl\"];\n\nexport class _LinkMenu extends React.PureComponent {\n  getOptions() {\n    const {props} = this;\n    const {site, index, source, isPrivateBrowsingEnabled, siteInfo, platform} = props;\n\n    // Handle special case of default site\n    const propOptions = (!site.isDefault || site.searchTopSite) ? props.options : DEFAULT_SITE_MENU_OPTIONS;\n\n    const options = propOptions.map(o => LinkMenuOptions[o](site, index, source, isPrivateBrowsingEnabled, siteInfo, platform)).map(option => {\n      const {action, impression, id, string_id, type, userEvent} = option;\n      if (!type && id) {\n        option.label = props.intl.formatMessage({id: string_id || id});\n        option.onClick = () => {\n          props.dispatch(action);\n          if (userEvent) {\n            const userEventData = Object.assign({\n              event: userEvent,\n              source,\n              action_position: index,\n            }, siteInfo);\n            props.dispatch(ac.UserEvent(userEventData));\n          }\n          if (impression && props.shouldSendImpressionStats) {\n            props.dispatch(impression);\n          }\n        };\n      }\n      return option;\n    });\n\n    // This is for accessibility to support making each item tabbable.\n    // We want to know which item is the first and which item\n    // is the last, so we can close the context menu accordingly.\n    options[0].first = true;\n    options[options.length - 1].last = true;\n    return options;\n  }\n\n  render() {\n    return (<ContextMenu\n      onUpdate={this.props.onUpdate}\n      options={this.getOptions()} />);\n  }\n}\n\nconst getState = state => ({isPrivateBrowsingEnabled: state.Prefs.values.isPrivateBrowsingEnabled, platform: state.Prefs.values.platform});\nexport const LinkMenu = connect(getState)(injectIntl(_LinkMenu));\n","import React from \"react\";\n\nexport class ContextMenu extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.hideContext = this.hideContext.bind(this);\n    this.onClick = this.onClick.bind(this);\n  }\n\n  hideContext() {\n    this.props.onUpdate(false);\n  }\n\n  componentDidMount() {\n    setTimeout(() => {\n      global.addEventListener(\"click\", this.hideContext);\n    }, 0);\n  }\n\n  componentWillUnmount() {\n    global.removeEventListener(\"click\", this.hideContext);\n  }\n\n  onClick(event) {\n    // Eat all clicks on the context menu so they don't bubble up to window.\n    // This prevents the context menu from closing when clicking disabled items\n    // or the separators.\n    event.stopPropagation();\n  }\n\n  render() {\n    return (<span className=\"context-menu\" onClick={this.onClick}>\n      <ul role=\"menu\" className=\"context-menu-list\">\n        {this.props.options.map((option, i) => (option.type === \"separator\" ?\n          (<li key={i} className=\"separator\" />) :\n          (option.type !== \"empty\" && <ContextMenuItem key={i} option={option} hideContext={this.hideContext} />)\n        ))}\n      </ul>\n    </span>);\n  }\n}\n\nexport class ContextMenuItem extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onClick = this.onClick.bind(this);\n    this.onKeyDown = this.onKeyDown.bind(this);\n  }\n\n  onClick() {\n    this.props.hideContext();\n    this.props.option.onClick();\n  }\n\n  onKeyDown(event) {\n    const {option} = this.props;\n    switch (event.key) {\n      case \"Tab\":\n        // tab goes down in context menu, shift + tab goes up in context menu\n        // if we're on the last item, one more tab will close the context menu\n        // similarly, if we're on the first item, one more shift + tab will close it\n        if ((event.shiftKey && option.first) || (!event.shiftKey && option.last)) {\n          this.props.hideContext();\n        }\n        break;\n      case \"Enter\":\n        this.props.hideContext();\n        option.onClick();\n        break;\n    }\n  }\n\n  render() {\n    const {option} = this.props;\n    return (\n      <li role=\"menuitem\" className=\"context-menu-item\">\n        <a onClick={this.onClick} onKeyDown={this.onKeyDown} tabIndex=\"0\" className={option.disabled ? \"disabled\" : \"\"}>\n          {option.icon && <span className={`icon icon-spacer icon-${option.icon}`} />}\n          {option.label}\n        </a>\n      </li>);\n  }\n}\n","/**\n * List of helper functions for screenshot-based images.\n *\n * There are two kinds of images:\n * 1. Remote Image: This is the image from the main process and it refers to\n *    the image in the React props. This can either be an object with the `data`\n *    and `path` properties, if it is a blob, or a string, if it is a normal image.\n * 2. Local Image: This is the image object in the content process and it refers\n *    to the image *object* in the React component's state. All local image\n *    objects have the `url` property, and an additional property `path`, if they\n *    are blobs.\n */\nexport const ScreenshotUtils = {\n  isBlob(isLocal, image) {\n    return !!(image && image.path && ((!isLocal && image.data) || (isLocal && image.url)));\n  },\n\n  // This should always be called with a remote image and not a local image.\n  createLocalImageObject(remoteImage) {\n    if (!remoteImage) {\n      return null;\n    }\n    if (this.isBlob(false, remoteImage)) {\n      return {url: global.URL.createObjectURL(remoteImage.data), path: remoteImage.path};\n    }\n    return {url: remoteImage};\n  },\n\n  // Revokes the object URL of the image if the local image is a blob.\n  // This should always be called with a local image and not a remote image.\n  maybeRevokeBlobObjectURL(localImage) {\n    if (this.isBlob(true, localImage)) {\n      global.URL.revokeObjectURL(localImage.url);\n    }\n  },\n\n  // Checks if remoteImage and localImage are the same.\n  isRemoteImageLocal(localImage, remoteImage) {\n    // Both remoteImage and localImage are present.\n    if (remoteImage && localImage) {\n      return this.isBlob(false, remoteImage) ?\n             localImage.path === remoteImage.path :\n             localImage.url === remoteImage;\n    }\n\n    // This will only handle the remaining three possible outcomes.\n    // (i.e. everything except when both image and localImage are present)\n    return !remoteImage && !localImage;\n  },\n};\n","import {FormattedMessage, injectIntl} from \"react-intl\";\nimport {actionCreators as ac} from \"common/Actions.jsm\";\nimport {ErrorBoundary} from \"content-src/components/ErrorBoundary/ErrorBoundary\";\nimport React from \"react\";\nimport {SectionMenu} from \"content-src/components/SectionMenu/SectionMenu\";\nimport {SectionMenuOptions} from \"content-src/lib/section-menu-options\";\n\nconst VISIBLE = \"visible\";\nconst VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\n\nfunction getFormattedMessage(message) {\n  return typeof message === \"string\" ? <span>{message}</span> : <FormattedMessage {...message} />;\n}\n\nexport class _CollapsibleSection extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onBodyMount = this.onBodyMount.bind(this);\n    this.onHeaderClick = this.onHeaderClick.bind(this);\n    this.onTransitionEnd = this.onTransitionEnd.bind(this);\n    this.enableOrDisableAnimation = this.enableOrDisableAnimation.bind(this);\n    this.onMenuButtonClick = this.onMenuButtonClick.bind(this);\n    this.onMenuButtonMouseEnter = this.onMenuButtonMouseEnter.bind(this);\n    this.onMenuButtonMouseLeave = this.onMenuButtonMouseLeave.bind(this);\n    this.onMenuUpdate = this.onMenuUpdate.bind(this);\n    this.state = {enableAnimation: true, isAnimating: false, menuButtonHover: false, showContextMenu: false};\n  }\n\n  componentWillMount() {\n    this.props.document.addEventListener(VISIBILITY_CHANGE_EVENT, this.enableOrDisableAnimation);\n  }\n\n  componentWillUpdate(nextProps) {\n    // Check if we're about to go from expanded to collapsed\n    if (!this.props.collapsed && nextProps.collapsed) {\n      // This next line forces a layout flush of the section body, which has a\n      // max-height style set, so that the upcoming collapse animation can\n      // animate from that height to the collapsed height. Without this, the\n      // update is coalesced and there's no animation from no-max-height to 0.\n      this.sectionBody.scrollHeight; // eslint-disable-line no-unused-expressions\n    }\n  }\n\n  componentWillUnmount() {\n    this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this.enableOrDisableAnimation);\n  }\n\n  enableOrDisableAnimation() {\n    // Only animate the collapse/expand for visible tabs.\n    const visible = this.props.document.visibilityState === VISIBLE;\n    if (this.state.enableAnimation !== visible) {\n      this.setState({enableAnimation: visible});\n    }\n  }\n\n  onBodyMount(node) {\n    this.sectionBody = node;\n  }\n\n  onHeaderClick() {\n    // If this.sectionBody is unset, it means that we're in some sort of error\n    // state, probably displaying the error fallback, so we won't be able to\n    // compute the height, and we don't want to persist the preference.\n    // If props.collapsed is undefined handler shouldn't do anything.\n    if (!this.sectionBody || this.props.collapsed === undefined) {\n      return;\n    }\n\n    // Get the current height of the body so max-height transitions can work\n    this.setState({\n      isAnimating: true,\n      maxHeight: `${this._getSectionBodyHeight()}px`,\n    });\n    const {action, userEvent} = SectionMenuOptions.CheckCollapsed(this.props);\n    this.props.dispatch(action);\n    this.props.dispatch(ac.UserEvent({\n      event: userEvent,\n      source: this.props.source,\n    }));\n  }\n\n  _getSectionBodyHeight() {\n    const div = this.sectionBody;\n    if (div.style.display === \"none\") {\n      // If the div isn't displayed, we can't get it's height. So we display it\n      // to get the height (it doesn't show up because max-height is set to 0px\n      // in CSS). We don't undo this because we are about to expand the section.\n      div.style.display = \"block\";\n    }\n    return div.scrollHeight;\n  }\n\n  onTransitionEnd(event) {\n    // Only update the animating state for our own transition (not a child's)\n    if (event.target === event.currentTarget) {\n      this.setState({isAnimating: false});\n    }\n  }\n\n  renderIcon() {\n    const {icon} = this.props;\n    if (icon && icon.startsWith(\"moz-extension://\")) {\n      return <span className=\"icon icon-small-spacer\" style={{backgroundImage: `url('${icon}')`}} />;\n    }\n    return <span className={`icon icon-small-spacer icon-${icon || \"webextension\"}`} />;\n  }\n\n  onMenuButtonClick(event) {\n    event.preventDefault();\n    this.setState({showContextMenu: true});\n  }\n\n  onMenuButtonMouseEnter() {\n    this.setState({menuButtonHover: true});\n  }\n\n  onMenuButtonMouseLeave() {\n    this.setState({menuButtonHover: false});\n  }\n\n  onMenuUpdate(showContextMenu) {\n    this.setState({showContextMenu});\n  }\n\n  render() {\n    const isCollapsible = this.props.collapsed !== undefined;\n    const {enableAnimation, isAnimating, maxHeight, menuButtonHover, showContextMenu} = this.state;\n    const {id, eventSource, collapsed, learnMore, title, extraMenuOptions, showPrefName, privacyNoticeURL, dispatch, isFirst, isLast, isWebExtension} = this.props;\n    const active = menuButtonHover || showContextMenu;\n    let bodyStyle;\n    if (isAnimating && !collapsed) {\n      bodyStyle = {maxHeight};\n    } else if (!isAnimating && collapsed) {\n      bodyStyle = {display: \"none\"};\n    }\n    return (\n      <section\n        className={`collapsible-section ${this.props.className}${enableAnimation ? \" animation-enabled\" : \"\"}${collapsed ? \" collapsed\" : \"\"}${active ? \" active\" : \"\"}`}\n        // Note: data-section-id is used for web extension api tests in mozilla central\n        data-section-id={id}>\n        <div className=\"section-top-bar\">\n          <h3 className=\"section-title\">\n            <span className=\"click-target-container\">\n              <span className=\"click-target\" onClick={this.onHeaderClick}>\n                {this.renderIcon()}\n                {getFormattedMessage(title)}\n              </span>\n              <span>\n                {learnMore &&\n                  <span className=\"learn-more-link\">\n                    <a href={learnMore.link.href}>\n                      <FormattedMessage id={learnMore.link.id} />\n                    </a>\n                  </span>\n                }\n              </span>\n              <span className=\"click-target\" onClick={this.onHeaderClick}>\n                {isCollapsible && <span className={`collapsible-arrow icon ${collapsed ? \"icon-arrowhead-forward-small\" : \"icon-arrowhead-down-small\"}`} />}\n              </span>\n            </span>\n          </h3>\n          <div>\n            <button\n              className=\"context-menu-button icon\"\n              onClick={this.onMenuButtonClick}\n              onMouseEnter={this.onMenuButtonMouseEnter}\n              onMouseLeave={this.onMenuButtonMouseLeave}>\n              <span className=\"sr-only\">\n                <FormattedMessage id=\"section_context_menu_button_sr\" />\n              </span>\n            </button>\n            {showContextMenu &&\n              <SectionMenu\n                id={id}\n                extraOptions={extraMenuOptions}\n                eventSource={eventSource}\n                showPrefName={showPrefName}\n                privacyNoticeURL={privacyNoticeURL}\n                collapsed={collapsed}\n                onUpdate={this.onMenuUpdate}\n                isFirst={isFirst}\n                isLast={isLast}\n                dispatch={dispatch}\n                isWebExtension={isWebExtension} />\n            }\n          </div>\n        </div>\n        <ErrorBoundary className=\"section-body-fallback\">\n          <div\n            className={`section-body${isAnimating ? \" animating\" : \"\"}`}\n            onTransitionEnd={this.onTransitionEnd}\n            ref={this.onBodyMount}\n            style={bodyStyle}>\n            {this.props.children}\n          </div>\n        </ErrorBoundary>\n      </section>\n    );\n  }\n}\n\n_CollapsibleSection.defaultProps = {\n  document: global.document || {\n    addEventListener: () => {},\n    removeEventListener: () => {},\n    visibilityState: \"hidden\",\n  },\n  Prefs: {values: {}},\n};\n\nexport const CollapsibleSection = injectIntl(_CollapsibleSection);\n","import {actionCreators as ac} from \"common/Actions.jsm\";\nimport {ContextMenu} from \"content-src/components/ContextMenu/ContextMenu\";\nimport {injectIntl} from \"react-intl\";\nimport React from \"react\";\nimport {SectionMenuOptions} from \"content-src/lib/section-menu-options\";\n\nconst DEFAULT_SECTION_MENU_OPTIONS = [\"MoveUp\", \"MoveDown\", \"Separator\", \"RemoveSection\", \"CheckCollapsed\", \"Separator\", \"ManageSection\"];\nconst WEBEXT_SECTION_MENU_OPTIONS = [\"MoveUp\", \"MoveDown\", \"Separator\", \"CheckCollapsed\", \"Separator\", \"ManageWebExtension\"];\n\nexport class _SectionMenu extends React.PureComponent {\n  getOptions() {\n    const {props} = this;\n\n    const propOptions = props.isWebExtension ? [...WEBEXT_SECTION_MENU_OPTIONS] : [...DEFAULT_SECTION_MENU_OPTIONS];\n    // Prepend custom options and a separator\n    if (props.extraOptions) {\n      propOptions.splice(0, 0, ...props.extraOptions, \"Separator\");\n    }\n    // Insert privacy notice before the last option (\"ManageSection\")\n    if (props.privacyNoticeURL) {\n      propOptions.splice(-1, 0, \"PrivacyNotice\");\n    }\n\n    const options = propOptions.map(o => SectionMenuOptions[o](props)).map(option => {\n      const {action, id, type, userEvent} = option;\n      if (!type && id) {\n        option.label = props.intl.formatMessage({id});\n        option.onClick = () => {\n          props.dispatch(action);\n          if (userEvent) {\n            props.dispatch(ac.UserEvent({\n              event: userEvent,\n              source: props.source,\n            }));\n          }\n        };\n      }\n      return option;\n    });\n\n    // This is for accessibility to support making each item tabbable.\n    // We want to know which item is the first and which item\n    // is the last, so we can close the context menu accordingly.\n    options[0].first = true;\n    options[options.length - 1].last = true;\n    return options;\n  }\n\n  render() {\n    return (<ContextMenu\n      onUpdate={this.props.onUpdate}\n      options={this.getOptions()} />);\n  }\n}\n\nexport const SectionMenu = injectIntl(_SectionMenu);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\n\n/**\n * List of functions that return items that can be included as menu options in a\n * SectionMenu. All functions take the section as the only parameter.\n */\nexport const SectionMenuOptions = {\n  Separator: () => ({type: \"separator\"}),\n  MoveUp: section => ({\n    id: \"section_menu_action_move_up\",\n    icon: \"arrowhead-up\",\n    action: ac.OnlyToMain({\n      type: at.SECTION_MOVE,\n      data: {id: section.id, direction: -1},\n    }),\n    userEvent: \"MENU_MOVE_UP\",\n    disabled: !!section.isFirst,\n  }),\n  MoveDown: section => ({\n    id: \"section_menu_action_move_down\",\n    icon: \"arrowhead-down\",\n    action: ac.OnlyToMain({\n      type: at.SECTION_MOVE,\n      data: {id: section.id, direction: +1},\n    }),\n    userEvent: \"MENU_MOVE_DOWN\",\n    disabled: !!section.isLast,\n  }),\n  RemoveSection: section => ({\n    id: \"section_menu_action_remove_section\",\n    icon: \"dismiss\",\n    action: ac.SetPref(section.showPrefName, false),\n    userEvent: \"MENU_REMOVE\",\n  }),\n  CollapseSection: section => ({\n    id: \"section_menu_action_collapse_section\",\n    icon: \"minimize\",\n    action: ac.OnlyToMain({type: at.UPDATE_SECTION_PREFS, data: {id: section.id, value: {collapsed: true}}}),\n    userEvent: \"MENU_COLLAPSE\",\n  }),\n  ExpandSection: section => ({\n    id: \"section_menu_action_expand_section\",\n    icon: \"maximize\",\n    action: ac.OnlyToMain({type: at.UPDATE_SECTION_PREFS, data: {id: section.id, value: {collapsed: false}}}),\n    userEvent: \"MENU_EXPAND\",\n  }),\n  ManageSection: section => ({\n    id: \"section_menu_action_manage_section\",\n    icon: \"settings\",\n    action: ac.OnlyToMain({type: at.SETTINGS_OPEN}),\n    userEvent: \"MENU_MANAGE\",\n  }),\n  ManageWebExtension: section => ({\n    id: \"section_menu_action_manage_webext\",\n    icon: \"settings\",\n    action: ac.OnlyToMain({type: at.OPEN_WEBEXT_SETTINGS, data: section.id}),\n  }),\n  AddTopSite: section => ({\n    id: \"section_menu_action_add_topsite\",\n    icon: \"add\",\n    action: {type: at.TOP_SITES_EDIT, data: {index: -1}},\n    userEvent: \"MENU_ADD_TOPSITE\",\n  }),\n  AddSearchShortcut: section => ({\n    id: \"section_menu_action_add_search_engine\",\n    icon: \"search\",\n    action: {type: at.TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL},\n    userEvent: \"MENU_ADD_SEARCH\",\n  }),\n  PrivacyNotice: section => ({\n    id: \"section_menu_action_privacy_notice\",\n    icon: \"info\",\n    action: ac.OnlyToMain({\n      type: at.OPEN_LINK,\n      data: {url: section.privacyNoticeURL},\n    }),\n    userEvent: \"MENU_PRIVACY_NOTICE\",\n  }),\n  CheckCollapsed: section => (section.collapsed ? SectionMenuOptions.ExpandSection(section) : SectionMenuOptions.CollapseSection(section)),\n};\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {perfService as perfSvc} from \"common/PerfService.jsm\";\nimport React from \"react\";\n\n// Currently record only a fixed set of sections. This will prevent data\n// from custom sections from showing up or from topstories.\nconst RECORDED_SECTIONS = [\"highlights\", \"topsites\"];\n\nexport class ComponentPerfTimer extends React.Component {\n  constructor(props) {\n    super(props);\n    // Just for test dependency injection:\n    this.perfSvc = this.props.perfSvc || perfSvc;\n\n    this._sendBadStateEvent = this._sendBadStateEvent.bind(this);\n    this._sendPaintedEvent = this._sendPaintedEvent.bind(this);\n    this._reportMissingData = false;\n    this._timestampHandled = false;\n    this._recordedFirstRender = false;\n  }\n\n  componentDidMount() {\n    if (!RECORDED_SECTIONS.includes(this.props.id)) {\n      return;\n    }\n\n    this._maybeSendPaintedEvent();\n  }\n\n  componentDidUpdate() {\n    if (!RECORDED_SECTIONS.includes(this.props.id)) {\n      return;\n    }\n\n    this._maybeSendPaintedEvent();\n  }\n\n  /**\n   * Call the given callback after the upcoming frame paints.\n   *\n   * @note Both setTimeout and requestAnimationFrame are throttled when the page\n   * is hidden, so this callback may get called up to a second or so after the\n   * requestAnimationFrame \"paint\" for hidden tabs.\n   *\n   * Newtabs hidden while loading will presumably be fairly rare (other than\n   * preloaded tabs, which we will be filtering out on the server side), so such\n   * cases should get lost in the noise.\n   *\n   * If we decide that it's important to find out when something that's hidden\n   * has \"painted\", however, another option is to post a message to this window.\n   * That should happen even faster than setTimeout, and, at least as of this\n   * writing, it's not throttled in hidden windows in Firefox.\n   *\n   * @param {Function} callback\n   *\n   * @returns void\n   */\n  _afterFramePaint(callback) {\n    requestAnimationFrame(() => setTimeout(callback, 0));\n  }\n\n  _maybeSendBadStateEvent() {\n    // Follow up bugs:\n    // https://github.com/mozilla/activity-stream/issues/3691\n    if (!this.props.initialized) {\n      // Remember to report back when data is available.\n      this._reportMissingData = true;\n    } else if (this._reportMissingData) {\n      this._reportMissingData = false;\n      // Report how long it took for component to become initialized.\n      this._sendBadStateEvent();\n    }\n  }\n\n  _maybeSendPaintedEvent() {\n    // If we've already handled a timestamp, don't do it again.\n    if (this._timestampHandled || !this.props.initialized) {\n      return;\n    }\n\n    // And if we haven't, we're doing so now, so remember that. Even if\n    // something goes wrong in the callback, we can't try again, as we'd be\n    // sending back the wrong data, and we have to do it here, so that other\n    // calls to this method while waiting for the next frame won't also try to\n    // handle it.\n    this._timestampHandled = true;\n    this._afterFramePaint(this._sendPaintedEvent);\n  }\n\n  /**\n   * Triggered by call to render. Only first call goes through due to\n   * `_recordedFirstRender`.\n   */\n  _ensureFirstRenderTsRecorded() {\n    // Used as t0 for recording how long component took to initialize.\n    if (!this._recordedFirstRender) {\n      this._recordedFirstRender = true;\n      // topsites_first_render_ts, highlights_first_render_ts.\n      const key = `${this.props.id}_first_render_ts`;\n      this.perfSvc.mark(key);\n    }\n  }\n\n  /**\n   * Creates `TELEMETRY_UNDESIRED_EVENT` with timestamp in ms\n   * of how much longer the data took to be ready for display than it would\n   * have been the ideal case.\n   * https://github.com/mozilla/ping-centre/issues/98\n   */\n  _sendBadStateEvent() {\n    // highlights_data_ready_ts, topsites_data_ready_ts.\n    const dataReadyKey = `${this.props.id}_data_ready_ts`;\n    this.perfSvc.mark(dataReadyKey);\n\n    try {\n      const firstRenderKey = `${this.props.id}_first_render_ts`;\n      // value has to be Int32.\n      const value = parseInt(this.perfSvc.getMostRecentAbsMarkStartByName(dataReadyKey) -\n                             this.perfSvc.getMostRecentAbsMarkStartByName(firstRenderKey), 10);\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.SAVE_SESSION_PERF_DATA,\n        // highlights_data_late_by_ms, topsites_data_late_by_ms.\n        data: {[`${this.props.id}_data_late_by_ms`]: value},\n      }));\n    } catch (ex) {\n      // If this failed, it's likely because the `privacy.resistFingerprinting`\n      // pref is true.\n    }\n  }\n\n  _sendPaintedEvent() {\n    // Record first_painted event but only send if topsites.\n    if (this.props.id !== \"topsites\") {\n      return;\n    }\n\n    // topsites_first_painted_ts.\n    const key = `${this.props.id}_first_painted_ts`;\n    this.perfSvc.mark(key);\n\n    try {\n      const data = {};\n      data[key] = this.perfSvc.getMostRecentAbsMarkStartByName(key);\n\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.SAVE_SESSION_PERF_DATA,\n        data,\n      }));\n    } catch (ex) {\n      // If this failed, it's likely because the `privacy.resistFingerprinting`\n      // pref is true.  We should at least not blow up, and should continue\n      // to set this._timestampHandled to avoid going through this again.\n    }\n  }\n\n  render() {\n    if (RECORDED_SECTIONS.includes(this.props.id)) {\n      this._ensureFirstRenderTsRecorded();\n      this._maybeSendBadStateEvent();\n    }\n    return this.props.children;\n  }\n}\n","/* globals Services */\n\"use strict\";\n\n/* istanbul ignore if */\nif (typeof ChromeUtils !== \"undefined\") {\n  ChromeUtils.import(\"resource://gre/modules/Services.jsm\");\n}\n\nlet usablePerfObj;\n\n/* istanbul ignore if */\n/* istanbul ignore else */\nif (typeof Services !== \"undefined\") {\n  // Borrow the high-resolution timer from the hidden window....\n  usablePerfObj = Services.appShell.hiddenDOMWindow.performance;\n} else if (typeof performance !== \"undefined\") {\n  // we must be running in content space\n  // eslint-disable-next-line no-undef\n  usablePerfObj = performance;\n} else {\n  // This is a dummy object so this file doesn't crash in the node prerendering\n  // task.\n  usablePerfObj = {\n    now() {},\n    mark() {},\n  };\n}\n\nfunction _PerfService(options) {\n  // For testing, so that we can use a fake Window.performance object with\n  // known state.\n  if (options && options.performanceObj) {\n    this._perf = options.performanceObj;\n  } else {\n    this._perf = usablePerfObj;\n  }\n}\n\n_PerfService.prototype = {\n  /**\n   * Calls the underlying mark() method on the appropriate Window.performance\n   * object to add a mark with the given name to the appropriate performance\n   * timeline.\n   *\n   * @param  {String} name  the name to give the current mark\n   * @return {void}\n   */\n  mark: function mark(str) {\n    this._perf.mark(str);\n  },\n\n  /**\n   * Calls the underlying getEntriesByName on the appropriate Window.performance\n   * object.\n   *\n   * @param  {String} name\n   * @param  {String} type eg \"mark\"\n   * @return {Array}       Performance* objects\n   */\n  getEntriesByName: function getEntriesByName(name, type) {\n    return this._perf.getEntriesByName(name, type);\n  },\n\n  /**\n   * The timeOrigin property from the appropriate performance object.\n   * Used to ensure that timestamps from the add-on code and the content code\n   * are comparable.\n   *\n   * @note If this is called from a context without a window\n   * (eg a JSM in chrome), it will return the timeOrigin of the XUL hidden\n   * window, which appears to be the first created window (and thus\n   * timeOrigin) in the browser.  Note also, however, there is also a private\n   * hidden window, presumably for private browsing, which appears to be\n   * created dynamically later.  Exactly how/when that shows up needs to be\n   * investigated.\n   *\n   * @return {Number} A double of milliseconds with a precision of 0.5us.\n   */\n  get timeOrigin() {\n    return this._perf.timeOrigin;\n  },\n\n  /**\n   * Returns the \"absolute\" version of performance.now(), i.e. one that\n   * should ([bug 1401406](https://bugzilla.mozilla.org/show_bug.cgi?id=1401406)\n   * be comparable across both chrome and content.\n   *\n   * @return {Number}\n   */\n  absNow: function absNow() {\n    return this.timeOrigin + this._perf.now();\n  },\n\n  /**\n   * This returns the absolute startTime from the most recent performance.mark()\n   * with the given name.\n   *\n   * @param  {String} name  the name to lookup the start time for\n   *\n   * @return {Number}       the returned start time, as a DOMHighResTimeStamp\n   *\n   * @throws {Error}        \"No Marks with the name ...\" if none are available\n   *\n   * @note Always surround calls to this by try/catch.  Otherwise your code\n   * may fail when the `privacy.resistFingerprinting` pref is true.  When\n   * this pref is set, all attempts to get marks will likely fail, which will\n   * cause this method to throw.\n   *\n   * See [bug 1369303](https://bugzilla.mozilla.org/show_bug.cgi?id=1369303)\n   * for more info.\n   */\n  getMostRecentAbsMarkStartByName(name) {\n    let entries = this.getEntriesByName(name, \"mark\");\n\n    if (!entries.length) {\n      throw new Error(`No marks with the name ${name}`);\n    }\n\n    let mostRecentEntry = entries[entries.length - 1];\n    return this._perf.timeOrigin + mostRecentEntry.startTime;\n  },\n};\n\nthis.perfService = new _PerfService();\nconst EXPORTED_SYMBOLS = [\"_PerfService\", \"perfService\"];\n","import {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class MoreRecommendations extends React.PureComponent {\n  render() {\n    const {read_more_endpoint} = this.props;\n    if (read_more_endpoint) {\n      return (\n        <a className=\"more-recommendations\" href={read_more_endpoint}>\n          <FormattedMessage id=\"pocket_more_reccommendations\" />\n        </a>\n      );\n    }\n    return null;\n  }\n}\n","import {connect} from \"react-redux\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class _PocketLoggedInCta extends React.PureComponent {\n  render() {\n    const {pocketCta} = this.props.Pocket;\n    return (\n      <span className=\"pocket-logged-in-cta\">\n        <a href={pocketCta.ctaUrl ? pocketCta.ctaUrl : \"https://getpocket.com/\"}>\n         {pocketCta.ctaButton ? pocketCta.ctaButton : <FormattedMessage id=\"pocket_cta_button\" />}\n        </a>\n\n        <span className=\"cta-text\">\n         {pocketCta.ctaText ? pocketCta.ctaText : <FormattedMessage id=\"pocket_cta_text\" />}\n        </span>\n      </span>\n    );\n  }\n}\n\nexport const PocketLoggedInCta = connect(state => ({Pocket: state.Pocket}))(_PocketLoggedInCta);\n","import {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class Topic extends React.PureComponent {\n  render() {\n    const {url, name} = this.props;\n    return (<li><a key={name} href={url}>{name}</a></li>);\n  }\n}\n\nexport class Topics extends React.PureComponent {\n  render() {\n    const {topics} = this.props;\n    return (\n      <span className=\"topics\">\n        <span><FormattedMessage id=\"pocket_read_more\" /></span>\n        <ul>{topics && topics.map(t => <Topic key={t.name} url={t.url} name={t.name} />)}</ul>\n      </span>\n    );\n  }\n}\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {MIN_CORNER_FAVICON_SIZE, MIN_RICH_FAVICON_SIZE, TOP_SITES_SOURCE} from \"./TopSitesConstants\";\nimport {CollapsibleSection} from \"content-src/components/CollapsibleSection/CollapsibleSection\";\nimport {ComponentPerfTimer} from \"content-src/components/ComponentPerfTimer/ComponentPerfTimer\";\nimport {connect} from \"react-redux\";\nimport {injectIntl} from \"react-intl\";\nimport React from \"react\";\nimport {SearchShortcutsForm} from \"./SearchShortcutsForm\";\nimport {TOP_SITES_MAX_SITES_PER_ROW} from \"common/Reducers.jsm\";\nimport {TopSiteForm} from \"./TopSiteForm\";\nimport {TopSiteList} from \"./TopSite\";\n\nfunction topSiteIconType(link) {\n  if (link.customScreenshotURL) {\n    return \"custom_screenshot\";\n  }\n  if (link.tippyTopIcon || link.faviconRef === \"tippytop\") {\n    return \"tippytop\";\n  }\n  if (link.faviconSize >= MIN_RICH_FAVICON_SIZE) {\n    return \"rich_icon\";\n  }\n  if (link.screenshot && link.faviconSize >= MIN_CORNER_FAVICON_SIZE) {\n    return \"screenshot_with_icon\";\n  }\n  if (link.screenshot) {\n    return \"screenshot\";\n  }\n  return \"no_image\";\n}\n\n/**\n * Iterates through TopSites and counts types of images.\n * @param acc Accumulator for reducer.\n * @param topsite Entry in TopSites.\n */\nfunction countTopSitesIconsTypes(topSites) {\n  const countTopSitesTypes = (acc, link) => {\n    acc[topSiteIconType(link)]++;\n    return acc;\n  };\n\n  return topSites.reduce(countTopSitesTypes, {\n    \"custom_screenshot\": 0,\n    \"screenshot_with_icon\": 0,\n    \"screenshot\": 0,\n    \"tippytop\": 0,\n    \"rich_icon\": 0,\n    \"no_image\": 0,\n  });\n}\n\nexport class _TopSites extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onEditFormClose = this.onEditFormClose.bind(this);\n    this.onSearchShortcutsFormClose = this.onSearchShortcutsFormClose.bind(this);\n  }\n\n  /**\n   * Dispatch session statistics about the quality of TopSites icons and pinned count.\n   */\n  _dispatchTopSitesStats() {\n    const topSites = this._getVisibleTopSites();\n    const topSitesIconsStats = countTopSitesIconsTypes(topSites);\n    const topSitesPinned = topSites.filter(site => !!site.isPinned).length;\n    const searchShortcuts = topSites.filter(site => !!site.searchTopSite).length;\n    // Dispatch telemetry event with the count of TopSites images types.\n    this.props.dispatch(ac.AlsoToMain({\n      type: at.SAVE_SESSION_PERF_DATA,\n      data: {\n        topsites_icon_stats: topSitesIconsStats,\n        topsites_pinned: topSitesPinned,\n        topsites_search_shortcuts: searchShortcuts,\n      },\n    }));\n  }\n\n  /**\n   * Return the TopSites that are visible based on prefs and window width.\n   */\n  _getVisibleTopSites() {\n    // We hide 2 sites per row when not in the wide layout.\n    let sitesPerRow = TOP_SITES_MAX_SITES_PER_ROW;\n    // $break-point-widest = 1072px (from _variables.scss)\n    if (!global.matchMedia(`(min-width: 1072px)`).matches) {\n      sitesPerRow -= 2;\n    }\n    return this.props.TopSites.rows.slice(0, this.props.TopSitesRows * sitesPerRow);\n  }\n\n  componentDidUpdate() {\n    this._dispatchTopSitesStats();\n  }\n\n  componentDidMount() {\n    this._dispatchTopSitesStats();\n  }\n\n  onEditFormClose() {\n    this.props.dispatch(ac.UserEvent({\n      source: TOP_SITES_SOURCE,\n      event: \"TOP_SITES_EDIT_CLOSE\",\n    }));\n    this.props.dispatch({type: at.TOP_SITES_CANCEL_EDIT});\n  }\n\n  onSearchShortcutsFormClose() {\n    this.props.dispatch(ac.UserEvent({\n      source: TOP_SITES_SOURCE,\n      event: \"SEARCH_EDIT_CLOSE\",\n    }));\n    this.props.dispatch({type: at.TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL});\n  }\n\n  render() {\n    const {props} = this;\n    const {editForm, showSearchShortcutsForm} = props.TopSites;\n    const extraMenuOptions = [\"AddTopSite\"];\n    if (props.Prefs.values[\"improvesearch.topSiteSearchShortcuts\"]) {\n      extraMenuOptions.push(\"AddSearchShortcut\");\n    }\n\n    return (<ComponentPerfTimer id=\"topsites\" initialized={props.TopSites.initialized} dispatch={props.dispatch}>\n      <CollapsibleSection\n        className=\"top-sites\"\n        icon=\"topsites\"\n        id=\"topsites\"\n        title={{id: \"header_top_sites\"}}\n        extraMenuOptions={extraMenuOptions}\n        showPrefName=\"feeds.topsites\"\n        eventSource={TOP_SITES_SOURCE}\n        collapsed={props.TopSites.pref ? props.TopSites.pref.collapsed : undefined}\n        isFirst={props.isFirst}\n        isLast={props.isLast}\n        dispatch={props.dispatch}>\n        <TopSiteList TopSites={props.TopSites} TopSitesRows={props.TopSitesRows} dispatch={props.dispatch} intl={props.intl} topSiteIconType={topSiteIconType} />\n        <div className=\"edit-topsites-wrapper\">\n          {editForm &&\n            <div className=\"edit-topsites\">\n              <div className=\"modal-overlay\" onClick={this.onEditFormClose} />\n              <div className=\"modal\">\n                <TopSiteForm\n                  site={props.TopSites.rows[editForm.index]}\n                  onClose={this.onEditFormClose}\n                  dispatch={this.props.dispatch}\n                  intl={this.props.intl}\n                  {...editForm} />\n              </div>\n            </div>\n          }\n          {showSearchShortcutsForm &&\n            <div className=\"edit-search-shortcuts\">\n              <div className=\"modal-overlay\" onClick={this.onSearchShortcutsFormClose} />\n              <div className=\"modal\">\n                <SearchShortcutsForm\n                  TopSites={props.TopSites}\n                  onClose={this.onSearchShortcutsFormClose}\n                  dispatch={this.props.dispatch} />\n              </div>\n            </div>\n          }\n        </div>\n      </CollapsibleSection>\n    </ComponentPerfTimer>);\n  }\n}\n\nexport const TopSites = connect(state => ({\n  TopSites: state.TopSites,\n  Prefs: state.Prefs,\n  TopSitesRows: state.Prefs.values.topSitesRows,\n}))(injectIntl(_TopSites));\n","export const TOP_SITES_SOURCE = \"TOP_SITES\";\nexport const TOP_SITES_CONTEXT_MENU_OPTIONS = [\"CheckPinTopSite\", \"EditTopSite\", \"Separator\",\n  \"OpenInNewWindow\", \"OpenInPrivateWindow\", \"Separator\", \"BlockUrl\", \"DeleteUrl\"];\n// the special top site for search shortcut experiment can only have the option to unpin (which removes) the topsite\nexport const TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS = [\"CheckPinTopSite\", \"Separator\", \"BlockUrl\"];\n// minimum size necessary to show a rich icon instead of a screenshot\nexport const MIN_RICH_FAVICON_SIZE = 96;\n// minimum size necessary to show any icon in the top left corner with a screenshot\nexport const MIN_CORNER_FAVICON_SIZE = 16;\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\nimport {TOP_SITES_SOURCE} from \"./TopSitesConstants\";\n\nclass SelectableSearchShortcut extends React.PureComponent {\n  render() {\n    const {shortcut, selected} = this.props;\n    const imageStyle = {backgroundImage: `url(\"${shortcut.tippyTopIcon}\")`};\n    return (\n      <div className=\"top-site-outer search-shortcut\">\n        <input type=\"checkbox\" id={shortcut.keyword} name={shortcut.keyword} checked={selected} onChange={this.props.onChange} />\n        <label htmlFor={shortcut.keyword}>\n          <div className=\"top-site-inner\">\n            <span>\n              <div className=\"tile\">\n                <div className=\"top-site-icon rich-icon\" style={imageStyle} data-fallback=\"@\" />\n                <div className=\"top-site-icon search-topsite\" />\n              </div>\n              <div className=\"title\">\n                <span dir=\"auto\">{shortcut.keyword}</span>\n              </div>\n            </span>\n          </div>\n        </label>\n      </div>\n    );\n  }\n}\n\nexport class SearchShortcutsForm extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.handleChange = this.handleChange.bind(this);\n    this.onCancelButtonClick = this.onCancelButtonClick.bind(this);\n    this.onSaveButtonClick = this.onSaveButtonClick.bind(this);\n\n    // clone the shortcuts and add them to the state so we can add isSelected property\n    const shortcuts = [];\n    const {rows, searchShortcuts} = props.TopSites;\n    searchShortcuts.forEach(shortcut => {\n      shortcuts.push({\n        ...shortcut,\n        isSelected: !!rows.find(row => row && row.isPinned && row.searchTopSite && row.label === shortcut.keyword),\n      });\n    });\n    this.state = {shortcuts};\n  }\n\n  handleChange(event) {\n    const {target} = event;\n    const {name, checked} = target;\n    this.setState(prevState => {\n      const shortcuts = prevState.shortcuts.slice();\n      let shortcut = shortcuts.find(({keyword}) => keyword === name);\n      shortcut.isSelected = checked;\n      return {shortcuts};\n    });\n  }\n\n  onCancelButtonClick(ev) {\n    ev.preventDefault();\n    this.props.onClose();\n  }\n\n  onSaveButtonClick(ev) {\n    ev.preventDefault();\n\n    // Check if there were any changes and act accordingly\n    const {rows} = this.props.TopSites;\n    const pinQueue = [];\n    const unpinQueue = [];\n    this.state.shortcuts.forEach(shortcut => {\n      const alreadyPinned = rows.find(row => row && row.isPinned && row.searchTopSite && row.label === shortcut.keyword);\n      if (shortcut.isSelected && !alreadyPinned) {\n        pinQueue.push(this._searchTopSite(shortcut));\n      } else if (!shortcut.isSelected && alreadyPinned) {\n        unpinQueue.push({url: alreadyPinned.url, searchVendor: shortcut.shortURL});\n      }\n    });\n\n    // Tell the feed to do the work.\n    this.props.dispatch(ac.OnlyToMain({\n      type: at.UPDATE_PINNED_SEARCH_SHORTCUTS,\n      data: {\n        addedShortcuts: pinQueue,\n        deletedShortcuts: unpinQueue,\n      },\n    }));\n\n    // Send the Telemetry pings.\n    pinQueue.forEach(shortcut => {\n      this.props.dispatch(ac.UserEvent({\n        source: TOP_SITES_SOURCE,\n        event: \"SEARCH_EDIT_ADD\",\n        value: {search_vendor: shortcut.searchVendor},\n      }));\n    });\n    unpinQueue.forEach(shortcut => {\n      this.props.dispatch(ac.UserEvent({\n        source: TOP_SITES_SOURCE,\n        event: \"SEARCH_EDIT_DELETE\",\n        value: {search_vendor: shortcut.searchVendor},\n      }));\n    });\n\n    this.props.onClose();\n  }\n\n  _searchTopSite(shortcut) {\n    return {\n      url: shortcut.url,\n      searchTopSite: true,\n      label: shortcut.keyword,\n      searchVendor: shortcut.shortURL,\n    };\n  }\n\n  render() {\n    return (\n      <form className=\"topsite-form\">\n        <div className=\"search-shortcuts-container\">\n          <h3 className=\"section-title\">\n            <FormattedMessage id=\"section_menu_action_add_search_engine\" />\n          </h3>\n          <div>\n            {this.state.shortcuts.map(shortcut => <SelectableSearchShortcut key={shortcut.keyword} shortcut={shortcut} selected={shortcut.isSelected} onChange={this.handleChange} />)}\n          </div>\n        </div>\n        <section className=\"actions\">\n          <button className=\"cancel\" type=\"button\" onClick={this.onCancelButtonClick}>\n            <FormattedMessage id=\"topsites_form_cancel_button\" />\n          </button>\n          <button className=\"done\" type=\"submit\" onClick={this.onSaveButtonClick}>\n            <FormattedMessage id=\"topsites_form_save_button\" />\n          </button>\n        </section>\n      </form>\n    );\n  }\n}\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {\n  MIN_CORNER_FAVICON_SIZE,\n  MIN_RICH_FAVICON_SIZE,\n  TOP_SITES_CONTEXT_MENU_OPTIONS,\n  TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS,\n  TOP_SITES_SOURCE,\n} from \"./TopSitesConstants\";\nimport {LinkMenu} from \"content-src/components/LinkMenu/LinkMenu\";\nimport React from \"react\";\nimport {ScreenshotUtils} from \"content-src/lib/screenshot-utils\";\nimport {TOP_SITES_MAX_SITES_PER_ROW} from \"common/Reducers.jsm\";\n\nexport class TopSiteLink extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {screenshotImage: null};\n    this.onDragEvent = this.onDragEvent.bind(this);\n    this.onKeyPress = this.onKeyPress.bind(this);\n  }\n\n  /*\n   * Helper to determine whether the drop zone should allow a drop. We only allow\n   * dropping top sites for now.\n   */\n  _allowDrop(e) {\n    return e.dataTransfer.types.includes(\"text/topsite-index\");\n  }\n\n  onDragEvent(event) {\n    switch (event.type) {\n      case \"click\":\n        // Stop any link clicks if we started any dragging\n        if (this.dragged) {\n          event.preventDefault();\n        }\n        break;\n      case \"dragstart\":\n        this.dragged = true;\n        event.dataTransfer.effectAllowed = \"move\";\n        event.dataTransfer.setData(\"text/topsite-index\", this.props.index);\n        event.target.blur();\n        this.props.onDragEvent(event, this.props.index, this.props.link, this.props.title);\n        break;\n      case \"dragend\":\n        this.props.onDragEvent(event);\n        break;\n      case \"dragenter\":\n      case \"dragover\":\n      case \"drop\":\n        if (this._allowDrop(event)) {\n          event.preventDefault();\n          this.props.onDragEvent(event, this.props.index);\n        }\n        break;\n      case \"mousedown\":\n        // Block the scroll wheel from appearing for middle clicks on search top sites\n        if (event.button === 1 && this.props.link.searchTopSite) {\n          event.preventDefault();\n        }\n        // Reset at the first mouse event of a potential drag\n        this.dragged = false;\n        break;\n    }\n  }\n\n  /**\n   * Helper to obtain the next state based on nextProps and prevState.\n   *\n   * NOTE: Rename this method to getDerivedStateFromProps when we update React\n   *       to >= 16.3. We will need to update tests as well. We cannot rename this\n   *       method to getDerivedStateFromProps now because there is a mismatch in\n   *       the React version that we are using for both testing and production.\n   *       (i.e. react-test-render => \"16.3.2\", react => \"16.2.0\").\n   *\n   * See https://github.com/airbnb/enzyme/blob/master/packages/enzyme-adapter-react-16/package.json#L43.\n   */\n  static getNextStateFromProps(nextProps, prevState) {\n    const {screenshot} = nextProps.link;\n    const imageInState = ScreenshotUtils.isRemoteImageLocal(prevState.screenshotImage, screenshot);\n    if (imageInState) {\n      return null;\n    }\n\n    // Since image was updated, attempt to revoke old image blob URL, if it exists.\n    ScreenshotUtils.maybeRevokeBlobObjectURL(prevState.screenshotImage);\n\n    return {screenshotImage: ScreenshotUtils.createLocalImageObject(screenshot)};\n  }\n\n  // NOTE: Remove this function when we update React to >= 16.3 since React will\n  //       call getDerivedStateFromProps automatically. We will also need to\n  //       rename getNextStateFromProps to getDerivedStateFromProps.\n  componentWillMount() {\n    const nextState = TopSiteLink.getNextStateFromProps(this.props, this.state);\n    if (nextState) {\n      this.setState(nextState);\n    }\n  }\n\n  // NOTE: Remove this function when we update React to >= 16.3 since React will\n  //       call getDerivedStateFromProps automatically. We will also need to\n  //       rename getNextStateFromProps to getDerivedStateFromProps.\n  componentWillReceiveProps(nextProps) {\n    const nextState = TopSiteLink.getNextStateFromProps(nextProps, this.state);\n    if (nextState) {\n      this.setState(nextState);\n    }\n  }\n\n  componentWillUnmount() {\n    ScreenshotUtils.maybeRevokeBlobObjectURL(this.state.screenshotImage);\n  }\n\n  onKeyPress(event) {\n    // If we have tabbed to a search shortcut top site, and we click 'enter',\n    // we should execute the onClick function. This needs to be added because\n    // search top sites are anchor tags without an href. See bug 1483135\n    if (this.props.link.searchTopSite && event.key === \"Enter\") {\n      this.props.onClick(event);\n    }\n  }\n\n  render() {\n    const {children, className, defaultStyle, isDraggable, link, onClick, title} = this.props;\n    const topSiteOuterClassName = `top-site-outer${className ? ` ${className}` : \"\"}${link.isDragged ? \" dragged\" : \"\"}${link.searchTopSite ? \" search-shortcut\" : \"\"}`;\n    const {tippyTopIcon, faviconSize} = link;\n    const [letterFallback] = title;\n    let imageClassName;\n    let imageStyle;\n    let showSmallFavicon = false;\n    let smallFaviconStyle;\n    let smallFaviconFallback;\n    let hasScreenshotImage = this.state.screenshotImage && this.state.screenshotImage.url;\n    if (defaultStyle) { // force no styles (letter fallback) even if the link has imagery\n      smallFaviconFallback = false;\n    } else if (link.searchTopSite) {\n      imageClassName = \"top-site-icon rich-icon\";\n      imageStyle = {\n        backgroundColor: link.backgroundColor,\n        backgroundImage: `url(${tippyTopIcon})`,\n      };\n      smallFaviconStyle = {backgroundImage:  `url(${tippyTopIcon})`};\n    } else if (link.customScreenshotURL) {\n      // assume high quality custom screenshot and use rich icon styles and class names\n      imageClassName = \"top-site-icon rich-icon\";\n      imageStyle = {\n        backgroundColor: link.backgroundColor,\n        backgroundImage: hasScreenshotImage ? `url(${this.state.screenshotImage.url})` : \"none\",\n      };\n    } else if (tippyTopIcon || faviconSize >= MIN_RICH_FAVICON_SIZE) {\n      // styles and class names for top sites with rich icons\n      imageClassName = \"top-site-icon rich-icon\";\n      imageStyle = {\n        backgroundColor: link.backgroundColor,\n        backgroundImage: `url(${tippyTopIcon || link.favicon})`,\n      };\n    } else {\n      // styles and class names for top sites with screenshot + small icon in top left corner\n      imageClassName = `screenshot${hasScreenshotImage ? \" active\" : \"\"}`;\n      imageStyle = {backgroundImage: hasScreenshotImage ? `url(${this.state.screenshotImage.url})` : \"none\"};\n\n      // only show a favicon in top left if it's greater than 16x16\n      if (faviconSize >= MIN_CORNER_FAVICON_SIZE) {\n        showSmallFavicon = true;\n        smallFaviconStyle = {backgroundImage:  `url(${link.favicon})`};\n      } else if (hasScreenshotImage) {\n        // Don't show a small favicon if there is no screenshot, because that\n        // would result in two fallback icons\n        showSmallFavicon = true;\n        smallFaviconFallback = true;\n      }\n    }\n    let draggableProps = {};\n    if (isDraggable) {\n      draggableProps = {\n        onClick: this.onDragEvent,\n        onDragEnd: this.onDragEvent,\n        onDragStart: this.onDragEvent,\n        onMouseDown: this.onDragEvent,\n      };\n    }\n    return (<li className={topSiteOuterClassName} onDrop={this.onDragEvent} onDragOver={this.onDragEvent} onDragEnter={this.onDragEvent} onDragLeave={this.onDragEvent} {...draggableProps}>\n      <div className=\"top-site-inner\">\n         <a href={!link.searchTopSite && link.url} tabIndex=\"0\" onKeyPress={this.onKeyPress} onClick={onClick} draggable={true}>\n            <div className=\"tile\" aria-hidden={true} data-fallback={letterFallback}>\n              <div className={imageClassName} style={imageStyle} />\n              {link.searchTopSite && <div className=\"top-site-icon search-topsite\" />}\n              {showSmallFavicon && <div\n                className=\"top-site-icon default-icon\"\n                data-fallback={smallFaviconFallback && letterFallback}\n                style={smallFaviconStyle} />}\n           </div>\n           <div className={`title ${link.isPinned ? \"pinned\" : \"\"}`}>\n             {link.isPinned && <div className=\"icon icon-pin-small\" />}\n              <span dir=\"auto\">{title}</span>\n           </div>\n         </a>\n         {children}\n      </div>\n    </li>);\n  }\n}\nTopSiteLink.defaultProps = {\n  title: \"\",\n  link: {},\n  isDraggable: true,\n};\n\nexport class TopSite extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {showContextMenu: false};\n    this.onLinkClick = this.onLinkClick.bind(this);\n    this.onMenuButtonClick = this.onMenuButtonClick.bind(this);\n    this.onMenuUpdate = this.onMenuUpdate.bind(this);\n  }\n\n  /**\n   * Report to telemetry additional information about the item.\n   */\n  _getTelemetryInfo() {\n    const value = {icon_type: this.props.link.iconType};\n    // Filter out \"not_pinned\" type for being the default\n    if (this.props.link.isPinned) {\n      value.card_type = \"pinned\";\n    }\n    if (this.props.link.searchTopSite) {\n      // Set the card_type as \"search\" regardless of its pinning status\n      value.card_type = \"search\";\n      value.search_vendor = this.props.link.hostname;\n    }\n    return {value};\n  }\n\n  userEvent(event) {\n    this.props.dispatch(ac.UserEvent(Object.assign({\n      event,\n      source: TOP_SITES_SOURCE,\n      action_position: this.props.index,\n    }, this._getTelemetryInfo())));\n  }\n\n  onLinkClick(event) {\n    this.userEvent(\"CLICK\");\n\n    // Specially handle a top site link click for \"typed\" frecency bonus as\n    // specified as a property on the link.\n    event.preventDefault();\n    const {altKey, button, ctrlKey, metaKey, shiftKey} = event;\n    if (!this.props.link.searchTopSite) {\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.OPEN_LINK,\n        data: Object.assign(this.props.link, {event: {altKey, button, ctrlKey, metaKey, shiftKey}}),\n      }));\n    } else {\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.FILL_SEARCH_TERM,\n        data: {label: this.props.link.label},\n      }));\n    }\n  }\n\n  onMenuButtonClick(event) {\n    event.preventDefault();\n    this.props.onActivate(this.props.index);\n    this.setState({showContextMenu: true});\n  }\n\n  onMenuUpdate(showContextMenu) {\n    this.setState({showContextMenu});\n  }\n\n  render() {\n    const {props} = this;\n    const {link} = props;\n    const isContextMenuOpen = this.state.showContextMenu && props.activeIndex === props.index;\n    const title = link.label || link.hostname;\n    return (<TopSiteLink {...props} onClick={this.onLinkClick} onDragEvent={this.props.onDragEvent} className={`${props.className || \"\"}${isContextMenuOpen ? \" active\" : \"\"}`} title={title}>\n        <div>\n          <button className=\"context-menu-button icon\" onClick={this.onMenuButtonClick}>\n            <span className=\"sr-only\">\n              <FormattedMessage id=\"context_menu_button_sr\" values={{title}} />\n            </span>\n          </button>\n          {isContextMenuOpen &&\n            <LinkMenu\n              dispatch={props.dispatch}\n              index={props.index}\n              onUpdate={this.onMenuUpdate}\n              options={link.searchTopSite ? TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS : TOP_SITES_CONTEXT_MENU_OPTIONS}\n              site={link}\n              siteInfo={this._getTelemetryInfo()}\n              source={TOP_SITES_SOURCE} />\n          }\n        </div>\n    </TopSiteLink>);\n  }\n}\nTopSite.defaultProps = {\n  link: {},\n  onActivate() {},\n};\n\nexport class TopSitePlaceholder extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onEditButtonClick = this.onEditButtonClick.bind(this);\n  }\n\n  onEditButtonClick() {\n    this.props.dispatch(\n      {type: at.TOP_SITES_EDIT, data: {index: this.props.index}});\n  }\n\n  render() {\n    return (<TopSiteLink {...this.props} className={`placeholder ${this.props.className || \"\"}`} isDraggable={false}>\n      <button className=\"context-menu-button edit-button icon\"\n       title={this.props.intl.formatMessage({id: \"edit_topsites_edit_button\"})}\n       onClick={this.onEditButtonClick} />\n    </TopSiteLink>);\n  }\n}\n\nexport class _TopSiteList extends React.PureComponent {\n  static get DEFAULT_STATE() {\n    return {\n      activeIndex: null,\n      draggedIndex: null,\n      draggedSite: null,\n      draggedTitle: null,\n      topSitesPreview: null,\n    };\n  }\n\n  constructor(props) {\n    super(props);\n    this.state = _TopSiteList.DEFAULT_STATE;\n    this.onDragEvent = this.onDragEvent.bind(this);\n    this.onActivate = this.onActivate.bind(this);\n  }\n\n  componentWillReceiveProps(nextProps) {\n    if (this.state.draggedSite) {\n      const prevTopSites = this.props.TopSites && this.props.TopSites.rows;\n      const newTopSites = nextProps.TopSites && nextProps.TopSites.rows;\n      if (prevTopSites && prevTopSites[this.state.draggedIndex] &&\n        prevTopSites[this.state.draggedIndex].url === this.state.draggedSite.url &&\n        (!newTopSites[this.state.draggedIndex] || newTopSites[this.state.draggedIndex].url !== this.state.draggedSite.url)) {\n        // We got the new order from the redux store via props. We can clear state now.\n        this.setState(_TopSiteList.DEFAULT_STATE);\n      }\n    }\n  }\n\n  userEvent(event, index) {\n    this.props.dispatch(ac.UserEvent({\n      event,\n      source: TOP_SITES_SOURCE,\n      action_position: index,\n    }));\n  }\n\n  onDragEvent(event, index, link, title) {\n    switch (event.type) {\n      case \"dragstart\":\n        this.dropped = false;\n        this.setState({\n          draggedIndex: index,\n          draggedSite: link,\n          draggedTitle: title,\n          activeIndex: null,\n        });\n        this.userEvent(\"DRAG\", index);\n        break;\n      case \"dragend\":\n        if (!this.dropped) {\n          // If there was no drop event, reset the state to the default.\n          this.setState(_TopSiteList.DEFAULT_STATE);\n        }\n        break;\n      case \"dragenter\":\n        if (index === this.state.draggedIndex) {\n          this.setState({topSitesPreview: null});\n        } else {\n          this.setState({topSitesPreview: this._makeTopSitesPreview(index)});\n        }\n        break;\n      case \"drop\":\n        if (index !== this.state.draggedIndex) {\n          this.dropped = true;\n          this.props.dispatch(ac.AlsoToMain({\n            type: at.TOP_SITES_INSERT,\n            data: {\n              site: {\n                url: this.state.draggedSite.url,\n                label: this.state.draggedTitle,\n                customScreenshotURL: this.state.draggedSite.customScreenshotURL,\n                // Only if the search topsites experiment is enabled\n                ...(this.state.draggedSite.searchTopSite && {searchTopSite: true}),\n              },\n              index,\n              draggedFromIndex: this.state.draggedIndex,\n            },\n          }));\n          this.userEvent(\"DROP\", index);\n        }\n        break;\n    }\n  }\n\n  _getTopSites() {\n    // Make a copy of the sites to truncate or extend to desired length\n    let topSites = this.props.TopSites.rows.slice();\n    topSites.length = this.props.TopSitesRows * TOP_SITES_MAX_SITES_PER_ROW;\n    return topSites;\n  }\n\n  /**\n   * Make a preview of the topsites that will be the result of dropping the currently\n   * dragged site at the specified index.\n   */\n  _makeTopSitesPreview(index) {\n    const topSites = this._getTopSites();\n    topSites[this.state.draggedIndex] = null;\n    const pinnedOnly = topSites.map(site => ((site && site.isPinned) ? site : null));\n    const unpinned = topSites.filter(site => site && !site.isPinned);\n    const siteToInsert = Object.assign({}, this.state.draggedSite, {isPinned: true, isDragged: true});\n    if (!pinnedOnly[index]) {\n      pinnedOnly[index] = siteToInsert;\n    } else {\n      // Find the hole to shift the pinned site(s) towards. We shift towards the\n      // hole left by the site being dragged.\n      let holeIndex = index;\n      const indexStep = index > this.state.draggedIndex ? -1 : 1;\n      while (pinnedOnly[holeIndex]) {\n        holeIndex += indexStep;\n      }\n\n      // Shift towards the hole.\n      const shiftingStep = index > this.state.draggedIndex ? 1 : -1;\n      while (holeIndex !== index) {\n        const nextIndex = holeIndex + shiftingStep;\n        pinnedOnly[holeIndex] = pinnedOnly[nextIndex];\n        holeIndex = nextIndex;\n      }\n      pinnedOnly[index] = siteToInsert;\n    }\n\n    // Fill in the remaining holes with unpinned sites.\n    const preview = pinnedOnly;\n    for (let i = 0; i < preview.length; i++) {\n      if (!preview[i]) {\n        preview[i] = unpinned.shift() || null;\n      }\n    }\n\n    return preview;\n  }\n\n  onActivate(index) {\n    this.setState({activeIndex: index});\n  }\n\n  render() {\n    const {props} = this;\n    const topSites = this.state.topSitesPreview || this._getTopSites();\n    const topSitesUI = [];\n    const commonProps = {\n      onDragEvent: this.onDragEvent,\n      dispatch: props.dispatch,\n      intl: props.intl,\n    };\n    // We assign a key to each placeholder slot. We need it to be independent\n    // of the slot index (i below) so that the keys used stay the same during\n    // drag and drop reordering and the underlying DOM nodes are reused.\n    // This mostly (only?) affects linux so be sure to test on linux before changing.\n    let holeIndex = 0;\n\n    // On narrow viewports, we only show 6 sites per row. We'll mark the rest as\n    // .hide-for-narrow to hide in CSS via @media query.\n    const maxNarrowVisibleIndex = props.TopSitesRows * 6;\n\n    for (let i = 0, l = topSites.length; i < l; i++) {\n      const link = topSites[i] && Object.assign({}, topSites[i], {iconType: this.props.topSiteIconType(topSites[i])});\n      const slotProps = {\n        key: link ? link.url : holeIndex++,\n        index: i,\n      };\n      if (i >= maxNarrowVisibleIndex) {\n        slotProps.className = \"hide-for-narrow\";\n      }\n      topSitesUI.push(!link ? (\n        <TopSitePlaceholder\n          {...slotProps}\n          {...commonProps} />\n      ) : (\n        <TopSite\n          link={link}\n          activeIndex={this.state.activeIndex}\n          onActivate={this.onActivate}\n          {...slotProps}\n          {...commonProps} />\n      ));\n    }\n    return (<ul className={`top-sites-list${this.state.draggedSite ? \" dnd-active\" : \"\"}`}>\n      {topSitesUI}\n    </ul>);\n  }\n}\n\nexport const TopSiteList = injectIntl(_TopSiteList);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {connect} from \"react-redux\";\nimport React from \"react\";\n\nexport class _StartupOverlay extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onInputChange = this.onInputChange.bind(this);\n    this.onSubmit = this.onSubmit.bind(this);\n    this.clickSkip = this.clickSkip.bind(this);\n    this.initScene = this.initScene.bind(this);\n    this.removeOverlay = this.removeOverlay.bind(this);\n    this.onInputInvalid = this.onInputInvalid.bind(this);\n\n    this.state = {\n      emailInput: \"\",\n      overlayRemoved: false,\n      flowId: \"\",\n      flowBeginTime: 0,\n    };\n    this.didFetch = false;\n  }\n\n  async componentWillUpdate() {\n    if (this.props.fxa_endpoint && !this.didFetch) {\n      try {\n        this.didFetch = true;\n        const fxaParams = \"entrypoint=activity-stream-firstrun&utm_source=activity-stream&utm_campaign=firstrun&form_type=email\";\n        const response = await fetch(`${this.props.fxa_endpoint}/metrics-flow?${fxaParams}`);\n        if (response.status === 200) {\n          const {flowId, flowBeginTime} = await response.json();\n          this.setState({flowId, flowBeginTime});\n        }\n      } catch (error) {\n        this.props.dispatch(ac.OnlyToMain({type: at.TELEMETRY_UNDESIRED_EVENT, data: {event: \"FXA_METRICS_ERROR\"}}));\n      }\n    }\n  }\n\n  componentDidMount() {\n    this.initScene();\n  }\n\n  initScene() {\n    // Timeout to allow the scene to render once before attaching the attribute\n    // to trigger the animation.\n    setTimeout(() => {\n      this.setState({show: true});\n    }, 10);\n  }\n\n  removeOverlay() {\n    window.removeEventListener(\"visibilitychange\", this.removeOverlay);\n    document.body.classList.remove(\"hide-main\");\n    this.setState({show: false});\n    setTimeout(() => {\n      // Allow scrolling and fully remove overlay after animation finishes.\n      document.body.classList.remove(\"welcome\");\n      this.setState({overlayRemoved: true});\n    }, 400);\n  }\n\n  onInputChange(e) {\n    let error = e.target.previousSibling;\n    this.setState({emailInput: e.target.value});\n    error.classList.remove(\"active\");\n    e.target.classList.remove(\"invalid\");\n  }\n\n  onSubmit() {\n    this.props.dispatch(ac.UserEvent({event: \"SUBMIT_EMAIL\"}));\n    window.addEventListener(\"visibilitychange\", this.removeOverlay);\n  }\n\n  clickSkip() {\n    this.props.dispatch(ac.UserEvent({event: \"SKIPPED_SIGNIN\"}));\n    this.removeOverlay();\n  }\n\n  onInputInvalid(e) {\n    let error = e.target.previousSibling;\n    error.classList.add(\"active\");\n    e.target.classList.add(\"invalid\");\n    e.preventDefault(); // Override built-in form validation popup\n    e.target.focus();\n  }\n\n  render() {\n    // When skipping the onboarding tour we show AS but we are still on\n    // about:welcome, prop.isFirstrun is true and StartupOverlay is rendered\n    if (this.state.overlayRemoved) {\n      return null;\n    }\n\n    let termsLink = (<a href={`${this.props.fxa_endpoint}/legal/terms`} target=\"_blank\" rel=\"noopener noreferrer\"><FormattedMessage id=\"firstrun_terms_of_service\" /></a>);\n    let privacyLink = (<a href={`${this.props.fxa_endpoint}/legal/privacy`} target=\"_blank\" rel=\"noopener noreferrer\"><FormattedMessage id=\"firstrun_privacy_notice\" /></a>);\n\n    return (\n      <div className={`overlay-wrapper ${this.state.show ? \"show\" : \"\"}`}>\n        <div className=\"background\" />\n        <div className=\"firstrun-scene\">\n          <div className=\"fxaccounts-container\">\n            <div className=\"firstrun-left-divider\">\n              <h1 className=\"firstrun-title\"><FormattedMessage id=\"firstrun_title\" /></h1>\n              <p className=\"firstrun-content\"><FormattedMessage id=\"firstrun_content\" /></p>\n              <a className=\"firstrun-link\" href=\"https://www.mozilla.org/firefox/features/sync/\" target=\"_blank\" rel=\"noopener noreferrer\"><FormattedMessage id=\"firstrun_learn_more_link\" /></a>\n            </div>\n            <div className=\"firstrun-sign-in\">\n              <p className=\"form-header\"><FormattedMessage id=\"firstrun_form_header\" /><span className=\"sub-header\"><FormattedMessage id=\"firstrun_form_sub_header\" /></span></p>\n              <form method=\"get\" action={this.props.fxa_endpoint} target=\"_blank\" rel=\"noopener noreferrer\" onSubmit={this.onSubmit}>\n                <input name=\"service\" type=\"hidden\" value=\"sync\" />\n                <input name=\"action\" type=\"hidden\" value=\"email\" />\n                <input name=\"context\" type=\"hidden\" value=\"fx_desktop_v3\" />\n                <input name=\"entrypoint\" type=\"hidden\" value=\"activity-stream-firstrun\" />\n                <input name=\"utm_source\" type=\"hidden\" value=\"activity-stream\" />\n                <input name=\"utm_campaign\" type=\"hidden\" value=\"firstrun\" />\n                <input name=\"flow_id\" type=\"hidden\" value={this.state.flowId} />\n                <input name=\"flow_begin_time\" type=\"hidden\" value={this.state.flowBeginTime} />\n                <span className=\"error\">{this.props.intl.formatMessage({id: \"firstrun_invalid_input\"})}</span>\n                <input className=\"email-input\" name=\"email\" type=\"email\" required=\"true\" onInvalid={this.onInputInvalid} placeholder={this.props.intl.formatMessage({id: \"firstrun_email_input_placeholder\"})} onChange={this.onInputChange} />\n                <div className=\"extra-links\">\n                  <FormattedMessage\n                    id=\"firstrun_extra_legal_links\"\n                    values={{\n                      terms: termsLink,\n                      privacy: privacyLink,\n                    }} />\n                </div>\n                <button className=\"continue-button\" type=\"submit\"><FormattedMessage id=\"firstrun_continue_to_login\" /></button>\n              </form>\n              <button className=\"skip-button\" disabled={!!this.state.emailInput} onClick={this.clickSkip}><FormattedMessage id=\"firstrun_skip_login\" /></button>\n            </div>\n          </div>\n        </div>\n      </div>\n    );\n  }\n}\n\nconst getState = state => ({fxa_endpoint: state.Prefs.values.fxa_endpoint});\nexport const StartupOverlay = connect(getState)(injectIntl(_StartupOverlay));\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {perfService as perfSvc} from \"common/PerfService.jsm\";\n\nconst VISIBLE = \"visible\";\nconst VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\n\nexport class DetectUserSessionStart {\n  constructor(store, options = {}) {\n    this._store = store;\n    // Overrides for testing\n    this.document = options.document || global.document;\n    this._perfService = options.perfService || perfSvc;\n    this._onVisibilityChange = this._onVisibilityChange.bind(this);\n  }\n\n  /**\n   * sendEventOrAddListener - Notify immediately if the page is already visible,\n   *                    or else set up a listener for when visibility changes.\n   *                    This is needed for accurate session tracking for telemetry,\n   *                    because tabs are pre-loaded.\n   */\n  sendEventOrAddListener() {\n    if (this.document.visibilityState === VISIBLE) {\n      // If the document is already visible, to the user, send a notification\n      // immediately that a session has started.\n      this._sendEvent();\n    } else {\n      // If the document is not visible, listen for when it does become visible.\n      this.document.addEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  /**\n   * _sendEvent - Sends a message to the main process to indicate the current\n   *              tab is now visible to the user, includes the\n   *              visibility_event_rcvd_ts time in ms from the UNIX epoch.\n   */\n  _sendEvent() {\n    this._perfService.mark(\"visibility_event_rcvd_ts\");\n\n    try {\n      let visibility_event_rcvd_ts = this._perfService\n        .getMostRecentAbsMarkStartByName(\"visibility_event_rcvd_ts\");\n\n      this._store.dispatch(ac.AlsoToMain({\n        type: at.SAVE_SESSION_PERF_DATA,\n        data: {visibility_event_rcvd_ts},\n      }));\n    } catch (ex) {\n      // If this failed, it's likely because the `privacy.resistFingerprinting`\n      // pref is true.  We should at least not blow up.\n    }\n  }\n\n  /**\n   * _onVisibilityChange - If the visibility has changed to visible, sends a notification\n   *                      and removes the event listener. This should only be called once per tab.\n   */\n  _onVisibilityChange() {\n    if (this.document.visibilityState === VISIBLE) {\n      this._sendEvent();\n      this.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n}\n","export function enableASRouterContent(store, asrouterContent) {\n  let didHideOnboarding = false;\n\n  // Enable asrouter content\n  store.subscribe(() => {\n    const state = store.getState();\n    if (!state.ASRouter.initialized) {\n      return;\n    }\n\n    if (!asrouterContent.initialized) {\n      asrouterContent.init();\n    }\n\n    // Until we can delete the existing onboarding tour, just hide the onboarding button when users are in\n    // the new simplified onboarding experiment. CSS hacks ftw\n    if (state.ASRouter.allowLegacyOnboarding === false && !didHideOnboarding) {\n      global.document.body.classList.add(\"hide-onboarding\");\n      didHideOnboarding = true;\n    } else if (state.ASRouter.allowLegacyOnboarding === true && didHideOnboarding) {\n      global.document.body.classList.remove(\"hide-onboarding\");\n      didHideOnboarding = false;\n    }\n  });\n  // Return this for testing purposes\n  return {asrouterContent};\n}\n","/*  eslint no-magic-numbers: [0]  */\n\nconst MAX_PLACEABLES = 100;\n\nconst entryIdentifierRe = /-?[a-zA-Z][a-zA-Z0-9_-]*/y;\nconst identifierRe = /[a-zA-Z][a-zA-Z0-9_-]*/y;\nconst functionIdentifierRe = /^[A-Z][A-Z_?-]*$/;\n\n/**\n * The `Parser` class is responsible for parsing FTL resources.\n *\n * It's only public method is `getResource(source)` which takes an FTL string\n * and returns a two element Array with an Object of entries generated from the\n * source as the first element and an array of SyntaxError objects as the\n * second.\n *\n * This parser is optimized for runtime performance.\n *\n * There is an equivalent of this parser in syntax/parser which is\n * generating full AST which is useful for FTL tools.\n */\nclass RuntimeParser {\n  /**\n   * Parse FTL code into entries formattable by the MessageContext.\n   *\n   * Given a string of FTL syntax, return a map of entries that can be passed\n   * to MessageContext.format and a list of errors encountered during parsing.\n   *\n   * @param {String} string\n   * @returns {Array<Object, Array>}\n   */\n  getResource(string) {\n    this._source = string;\n    this._index = 0;\n    this._length = string.length;\n    this.entries = {};\n\n    const errors = [];\n\n    this.skipWS();\n    while (this._index < this._length) {\n      try {\n        this.getEntry();\n      } catch (e) {\n        if (e instanceof SyntaxError) {\n          errors.push(e);\n\n          this.skipToNextEntryStart();\n        } else {\n          throw e;\n        }\n      }\n      this.skipWS();\n    }\n\n    return [this.entries, errors];\n  }\n\n  /**\n   * Parse the source string from the current index as an FTL entry\n   * and add it to object's entries property.\n   *\n   * @private\n   */\n  getEntry() {\n    // The index here should either be at the beginning of the file\n    // or right after new line.\n    if (this._index !== 0 &&\n        this._source[this._index - 1] !== \"\\n\") {\n      throw this.error(`Expected an entry to start\n        at the beginning of the file or on a new line.`);\n    }\n\n    const ch = this._source[this._index];\n\n    // We don't care about comments or sections at runtime\n    if (ch === \"/\" ||\n      (ch === \"#\" &&\n        [\" \", \"#\", \"\\n\"].includes(this._source[this._index + 1]))) {\n      this.skipComment();\n      return;\n    }\n\n    if (ch === \"[\") {\n      this.skipSection();\n      return;\n    }\n\n    this.getMessage();\n  }\n\n  /**\n   * Skip the section entry from the current index.\n   *\n   * @private\n   */\n  skipSection() {\n    this._index += 1;\n    if (this._source[this._index] !== \"[\") {\n      throw this.error('Expected \"[[\" to open a section');\n    }\n\n    this._index += 1;\n\n    this.skipInlineWS();\n    this.getVariantName();\n    this.skipInlineWS();\n\n    if (this._source[this._index] !== \"]\" ||\n        this._source[this._index + 1] !== \"]\") {\n      throw this.error('Expected \"]]\" to close a section');\n    }\n\n    this._index += 2;\n  }\n\n  /**\n   * Parse the source string from the current index as an FTL message\n   * and add it to the entries property on the Parser.\n   *\n   * @private\n   */\n  getMessage() {\n    const id = this.getEntryIdentifier();\n\n    this.skipInlineWS();\n\n    if (this._source[this._index] === \"=\") {\n      this._index++;\n    }\n\n    this.skipInlineWS();\n\n    const val = this.getPattern();\n\n    if (id.startsWith(\"-\") && val === null) {\n      throw this.error(\"Expected term to have a value\");\n    }\n\n    let attrs = null;\n\n    if (this._source[this._index] === \" \") {\n      const lineStart = this._index;\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \".\") {\n        this._index = lineStart;\n        attrs = this.getAttributes();\n      }\n    }\n\n    if (attrs === null && typeof val === \"string\") {\n      this.entries[id] = val;\n    } else {\n      if (val === null && attrs === null) {\n        throw this.error(\"Expected message to have a value or attributes\");\n      }\n\n      this.entries[id] = {};\n\n      if (val !== null) {\n        this.entries[id].val = val;\n      }\n\n      if (attrs !== null) {\n        this.entries[id].attrs = attrs;\n      }\n    }\n  }\n\n  /**\n   * Skip whitespace.\n   *\n   * @private\n   */\n  skipWS() {\n    let ch = this._source[this._index];\n    while (ch === \" \" || ch === \"\\n\" || ch === \"\\t\" || ch === \"\\r\") {\n      ch = this._source[++this._index];\n    }\n  }\n\n  /**\n   * Skip inline whitespace (space and \\t).\n   *\n   * @private\n   */\n  skipInlineWS() {\n    let ch = this._source[this._index];\n    while (ch === \" \" || ch === \"\\t\") {\n      ch = this._source[++this._index];\n    }\n  }\n\n  /**\n   * Skip blank lines.\n   *\n   * @private\n   */\n  skipBlankLines() {\n    while (true) {\n      const ptr = this._index;\n\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \"\\n\") {\n        this._index += 1;\n      } else {\n        this._index = ptr;\n        break;\n      }\n    }\n  }\n\n  /**\n   * Get identifier using the provided regex.\n   *\n   * By default this will get identifiers of public messages, attributes and\n   * external arguments (without the $).\n   *\n   * @returns {String}\n   * @private\n   */\n  getIdentifier(re = identifierRe) {\n    re.lastIndex = this._index;\n    const result = re.exec(this._source);\n\n    if (result === null) {\n      this._index += 1;\n      throw this.error(`Expected an identifier [${re.toString()}]`);\n    }\n\n    this._index = re.lastIndex;\n    return result[0];\n  }\n\n  /**\n   * Get identifier of a Message or a Term (staring with a dash).\n   *\n   * @returns {String}\n   * @private\n   */\n  getEntryIdentifier() {\n    return this.getIdentifier(entryIdentifierRe);\n  }\n\n  /**\n   * Get Variant name.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getVariantName() {\n    let name = \"\";\n\n    const start = this._index;\n    let cc = this._source.charCodeAt(this._index);\n\n    if ((cc >= 97 && cc <= 122) || // a-z\n        (cc >= 65 && cc <= 90) || // A-Z\n        cc === 95 || cc === 32) { // _ <space>\n      cc = this._source.charCodeAt(++this._index);\n    } else {\n      throw this.error(\"Expected a keyword (starting with [a-zA-Z_])\");\n    }\n\n    while ((cc >= 97 && cc <= 122) || // a-z\n           (cc >= 65 && cc <= 90) || // A-Z\n           (cc >= 48 && cc <= 57) || // 0-9\n           cc === 95 || cc === 45 || cc === 32) { // _- <space>\n      cc = this._source.charCodeAt(++this._index);\n    }\n\n    // If we encountered the end of name, we want to test if the last\n    // collected character is a space.\n    // If it is, we will backtrack to the last non-space character because\n    // the keyword cannot end with a space character.\n    while (this._source.charCodeAt(this._index - 1) === 32) {\n      this._index--;\n    }\n\n    name += this._source.slice(start, this._index);\n\n    return { type: \"varname\", name };\n  }\n\n  /**\n   * Get simple string argument enclosed in `\"`.\n   *\n   * @returns {String}\n   * @private\n   */\n  getString() {\n    const start = this._index + 1;\n\n    while (++this._index < this._length) {\n      const ch = this._source[this._index];\n\n      if (ch === '\"') {\n        break;\n      }\n\n      if (ch === \"\\n\") {\n        throw this.error(\"Unterminated string expression\");\n      }\n    }\n\n    return this._source.substring(start, this._index++);\n  }\n\n  /**\n   * Parses a Message pattern.\n   * Message Pattern may be a simple string or an array of strings\n   * and placeable expressions.\n   *\n   * @returns {String|Array}\n   * @private\n   */\n  getPattern() {\n    // We're going to first try to see if the pattern is simple.\n    // If it is we can just look for the end of the line and read the string.\n    //\n    // Then, if either the line contains a placeable opening `{` or the\n    // next line starts an indentation, we switch to complex pattern.\n    const start = this._index;\n    let eol = this._source.indexOf(\"\\n\", this._index);\n\n    if (eol === -1) {\n      eol = this._length;\n    }\n\n    const firstLineContent = start !== eol ?\n      this._source.slice(start, eol) : null;\n\n    if (firstLineContent && firstLineContent.includes(\"{\")) {\n      return this.getComplexPattern();\n    }\n\n    this._index = eol + 1;\n\n    this.skipBlankLines();\n\n    if (this._source[this._index] !== \" \") {\n      // No indentation means we're done with this message. Callers should check\n      // if the return value here is null. It may be OK for messages, but not OK\n      // for terms, attributes and variants.\n      return firstLineContent;\n    }\n\n    const lineStart = this._index;\n\n    this.skipInlineWS();\n\n    if (this._source[this._index] === \".\") {\n      // The pattern is followed by an attribute. Rewind _index to the first\n      // column of the current line as expected by getAttributes.\n      this._index = lineStart;\n      return firstLineContent;\n    }\n\n    if (firstLineContent) {\n      // It's a multiline pattern which started on the same line as the\n      // identifier. Reparse the whole pattern to make sure we get all of it.\n      this._index = start;\n    }\n\n    return this.getComplexPattern();\n  }\n\n  /**\n   * Parses a complex Message pattern.\n   * This function is called by getPattern when the message is multiline,\n   * or contains escape chars or placeables.\n   * It does full parsing of complex patterns.\n   *\n   * @returns {Array}\n   * @private\n   */\n  /* eslint-disable complexity */\n  getComplexPattern() {\n    let buffer = \"\";\n    const content = [];\n    let placeables = 0;\n\n    let ch = this._source[this._index];\n\n    while (this._index < this._length) {\n      // This block handles multi-line strings combining strings separated\n      // by new line.\n      if (ch === \"\\n\") {\n        this._index++;\n\n        // We want to capture the start and end pointers\n        // around blank lines and add them to the buffer\n        // but only if the blank lines are in the middle\n        // of the string.\n        const blankLinesStart = this._index;\n        this.skipBlankLines();\n        const blankLinesEnd = this._index;\n\n\n        if (this._source[this._index] !== \" \") {\n          break;\n        }\n        this.skipInlineWS();\n\n        if (this._source[this._index] === \"}\" ||\n            this._source[this._index] === \"[\" ||\n            this._source[this._index] === \"*\" ||\n            this._source[this._index] === \".\") {\n          this._index = blankLinesEnd;\n          break;\n        }\n\n        buffer += this._source.substring(blankLinesStart, blankLinesEnd);\n\n        if (buffer.length || content.length) {\n          buffer += \"\\n\";\n        }\n        ch = this._source[this._index];\n        continue;\n      } else if (ch === \"\\\\\") {\n        const ch2 = this._source[this._index + 1];\n        if (ch2 === '\"' || ch2 === \"{\" || ch2 === \"\\\\\") {\n          ch = ch2;\n          this._index++;\n        }\n      } else if (ch === \"{\") {\n        // Push the buffer to content array right before placeable\n        if (buffer.length) {\n          content.push(buffer);\n        }\n        if (placeables > MAX_PLACEABLES - 1) {\n          throw this.error(\n            `Too many placeables, maximum allowed is ${MAX_PLACEABLES}`);\n        }\n        buffer = \"\";\n        content.push(this.getPlaceable());\n\n        this._index++;\n\n        ch = this._source[this._index];\n        placeables++;\n        continue;\n      }\n\n      if (ch) {\n        buffer += ch;\n      }\n      this._index++;\n      ch = this._source[this._index];\n    }\n\n    if (content.length === 0) {\n      return buffer.length ? buffer : null;\n    }\n\n    if (buffer.length) {\n      content.push(buffer);\n    }\n\n    return content;\n  }\n  /* eslint-enable complexity */\n\n  /**\n   * Parses a single placeable in a Message pattern and returns its\n   * expression.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getPlaceable() {\n    const start = ++this._index;\n\n    this.skipWS();\n\n    if (this._source[this._index] === \"*\" ||\n       (this._source[this._index] === \"[\" &&\n        this._source[this._index + 1] !== \"]\")) {\n      const variants = this.getVariants();\n\n      return {\n        type: \"sel\",\n        exp: null,\n        vars: variants[0],\n        def: variants[1]\n      };\n    }\n\n    // Rewind the index and only support in-line white-space now.\n    this._index = start;\n    this.skipInlineWS();\n\n    const selector = this.getSelectorExpression();\n\n    this.skipWS();\n\n    const ch = this._source[this._index];\n\n    if (ch === \"}\") {\n      if (selector.type === \"attr\" && selector.id.name.startsWith(\"-\")) {\n        throw this.error(\n          \"Attributes of private messages cannot be interpolated.\"\n        );\n      }\n\n      return selector;\n    }\n\n    if (ch !== \"-\" || this._source[this._index + 1] !== \">\") {\n      throw this.error('Expected \"}\" or \"->\"');\n    }\n\n    if (selector.type === \"ref\") {\n      throw this.error(\"Message references cannot be used as selectors.\");\n    }\n\n    if (selector.type === \"var\") {\n      throw this.error(\"Variants cannot be used as selectors.\");\n    }\n\n    if (selector.type === \"attr\" && !selector.id.name.startsWith(\"-\")) {\n      throw this.error(\n        \"Attributes of public messages cannot be used as selectors.\"\n      );\n    }\n\n\n    this._index += 2; // ->\n\n    this.skipInlineWS();\n\n    if (this._source[this._index] !== \"\\n\") {\n      throw this.error(\"Variants should be listed in a new line\");\n    }\n\n    this.skipWS();\n\n    const variants = this.getVariants();\n\n    if (variants[0].length === 0) {\n      throw this.error(\"Expected members for the select expression\");\n    }\n\n    return {\n      type: \"sel\",\n      exp: selector,\n      vars: variants[0],\n      def: variants[1]\n    };\n  }\n\n  /**\n   * Parses a selector expression.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getSelectorExpression() {\n    const literal = this.getLiteral();\n\n    if (literal.type !== \"ref\") {\n      return literal;\n    }\n\n    if (this._source[this._index] === \".\") {\n      this._index++;\n\n      const name = this.getIdentifier();\n      this._index++;\n      return {\n        type: \"attr\",\n        id: literal,\n        name\n      };\n    }\n\n    if (this._source[this._index] === \"[\") {\n      this._index++;\n\n      const key = this.getVariantKey();\n      this._index++;\n      return {\n        type: \"var\",\n        id: literal,\n        key\n      };\n    }\n\n    if (this._source[this._index] === \"(\") {\n      this._index++;\n      const args = this.getCallArgs();\n\n      if (!functionIdentifierRe.test(literal.name)) {\n        throw this.error(\"Function names must be all upper-case\");\n      }\n\n      this._index++;\n\n      literal.type = \"fun\";\n\n      return {\n        type: \"call\",\n        fun: literal,\n        args\n      };\n    }\n\n    return literal;\n  }\n\n  /**\n   * Parses call arguments for a CallExpression.\n   *\n   * @returns {Array}\n   * @private\n   */\n  getCallArgs() {\n    const args = [];\n\n    while (this._index < this._length) {\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \")\") {\n        return args;\n      }\n\n      const exp = this.getSelectorExpression();\n\n      // MessageReference in this place may be an entity reference, like:\n      // `call(foo)`, or, if it's followed by `:` it will be a key-value pair.\n      if (exp.type !== \"ref\") {\n        args.push(exp);\n      } else {\n        this.skipInlineWS();\n\n        if (this._source[this._index] === \":\") {\n          this._index++;\n          this.skipInlineWS();\n\n          const val = this.getSelectorExpression();\n\n          // If the expression returned as a value of the argument\n          // is not a quote delimited string or number, throw.\n          //\n          // We don't have to check here if the pattern is quote delimited\n          // because that's the only type of string allowed in expressions.\n          if (typeof val === \"string\" ||\n              Array.isArray(val) ||\n              val.type === \"num\") {\n            args.push({\n              type: \"narg\",\n              name: exp.name,\n              val\n            });\n          } else {\n            this._index = this._source.lastIndexOf(\":\", this._index) + 1;\n            throw this.error(\n              \"Expected string in quotes, number.\");\n          }\n\n        } else {\n          args.push(exp);\n        }\n      }\n\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \")\") {\n        break;\n      } else if (this._source[this._index] === \",\") {\n        this._index++;\n      } else {\n        throw this.error('Expected \",\" or \")\"');\n      }\n    }\n\n    return args;\n  }\n\n  /**\n   * Parses an FTL Number.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getNumber() {\n    let num = \"\";\n    let cc = this._source.charCodeAt(this._index);\n\n    // The number literal may start with negative sign `-`.\n    if (cc === 45) {\n      num += \"-\";\n      cc = this._source.charCodeAt(++this._index);\n    }\n\n    // next, we expect at least one digit\n    if (cc < 48 || cc > 57) {\n      throw this.error(`Unknown literal \"${num}\"`);\n    }\n\n    // followed by potentially more digits\n    while (cc >= 48 && cc <= 57) {\n      num += this._source[this._index++];\n      cc = this._source.charCodeAt(this._index);\n    }\n\n    // followed by an optional decimal separator `.`\n    if (cc === 46) {\n      num += this._source[this._index++];\n      cc = this._source.charCodeAt(this._index);\n\n      // followed by at least one digit\n      if (cc < 48 || cc > 57) {\n        throw this.error(`Unknown literal \"${num}\"`);\n      }\n\n      // and optionally more digits\n      while (cc >= 48 && cc <= 57) {\n        num += this._source[this._index++];\n        cc = this._source.charCodeAt(this._index);\n      }\n    }\n\n    return {\n      type: \"num\",\n      val: num\n    };\n  }\n\n  /**\n   * Parses a list of Message attributes.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getAttributes() {\n    const attrs = {};\n\n    while (this._index < this._length) {\n      if (this._source[this._index] !== \" \") {\n        break;\n      }\n      this.skipInlineWS();\n\n      if (this._source[this._index] !== \".\") {\n        break;\n      }\n      this._index++;\n\n      const key = this.getIdentifier();\n\n      this.skipInlineWS();\n\n      if (this._source[this._index] !== \"=\") {\n        throw this.error('Expected \"=\"');\n      }\n      this._index++;\n\n      this.skipInlineWS();\n\n      const val = this.getPattern();\n\n      if (val === null) {\n        throw this.error(\"Expected attribute to have a value\");\n      }\n\n      if (typeof val === \"string\") {\n        attrs[key] = val;\n      } else {\n        attrs[key] = {\n          val\n        };\n      }\n\n      this.skipBlankLines();\n    }\n\n    return attrs;\n  }\n\n  /**\n   * Parses a list of Selector variants.\n   *\n   * @returns {Array}\n   * @private\n   */\n  getVariants() {\n    const variants = [];\n    let index = 0;\n    let defaultIndex;\n\n    while (this._index < this._length) {\n      const ch = this._source[this._index];\n\n      if ((ch !== \"[\" || this._source[this._index + 1] === \"[\") &&\n          ch !== \"*\") {\n        break;\n      }\n      if (ch === \"*\") {\n        this._index++;\n        defaultIndex = index;\n      }\n\n      if (this._source[this._index] !== \"[\") {\n        throw this.error('Expected \"[\"');\n      }\n\n      this._index++;\n\n      const key = this.getVariantKey();\n\n      this.skipInlineWS();\n\n      const val = this.getPattern();\n\n      if (val === null) {\n        throw this.error(\"Expected variant to have a value\");\n      }\n\n      variants[index++] = {key, val};\n\n      this.skipWS();\n    }\n\n    return [variants, defaultIndex];\n  }\n\n  /**\n   * Parses a Variant key.\n   *\n   * @returns {String}\n   * @private\n   */\n  getVariantKey() {\n    // VariantKey may be a Keyword or Number\n\n    const cc = this._source.charCodeAt(this._index);\n    let literal;\n\n    if ((cc >= 48 && cc <= 57) || cc === 45) {\n      literal = this.getNumber();\n    } else {\n      literal = this.getVariantName();\n    }\n\n    if (this._source[this._index] !== \"]\") {\n      throw this.error('Expected \"]\"');\n    }\n\n    this._index++;\n    return literal;\n  }\n\n  /**\n   * Parses an FTL literal.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getLiteral() {\n    const cc0 = this._source.charCodeAt(this._index);\n\n    if (cc0 === 36) { // $\n      this._index++;\n      return {\n        type: \"ext\",\n        name: this.getIdentifier()\n      };\n    }\n\n    const cc1 = cc0 === 45 // -\n      // Peek at the next character after the dash.\n      ? this._source.charCodeAt(this._index + 1)\n      // Or keep using the character at the current index.\n      : cc0;\n\n    if ((cc1 >= 97 && cc1 <= 122) || // a-z\n        (cc1 >= 65 && cc1 <= 90)) { // A-Z\n      return {\n        type: \"ref\",\n        name: this.getEntryIdentifier()\n      };\n    }\n\n    if ((cc1 >= 48 && cc1 <= 57)) { // 0-9\n      return this.getNumber();\n    }\n\n    if (cc0 === 34) { // \"\n      return this.getString();\n    }\n\n    throw this.error(\"Expected literal\");\n  }\n\n  /**\n   * Skips an FTL comment.\n   *\n   * @private\n   */\n  skipComment() {\n    // At runtime, we don't care about comments so we just have\n    // to parse them properly and skip their content.\n    let eol = this._source.indexOf(\"\\n\", this._index);\n\n    while (eol !== -1 &&\n      ((this._source[eol + 1] === \"/\" && this._source[eol + 2] === \"/\") ||\n       (this._source[eol + 1] === \"#\" &&\n         [\" \", \"#\"].includes(this._source[eol + 2])))) {\n      this._index = eol + 3;\n\n      eol = this._source.indexOf(\"\\n\", this._index);\n\n      if (eol === -1) {\n        break;\n      }\n    }\n\n    if (eol === -1) {\n      this._index = this._length;\n    } else {\n      this._index = eol + 1;\n    }\n  }\n\n  /**\n   * Creates a new SyntaxError object with a given message.\n   *\n   * @param {String} message\n   * @returns {Object}\n   * @private\n   */\n  error(message) {\n    return new SyntaxError(message);\n  }\n\n  /**\n   * Skips to the beginning of a next entry after the current position.\n   * This is used to mark the boundary of junk entry in case of error,\n   * and recover from the returned position.\n   *\n   * @private\n   */\n  skipToNextEntryStart() {\n    let start = this._index;\n\n    while (true) {\n      if (start === 0 || this._source[start - 1] === \"\\n\") {\n        const cc = this._source.charCodeAt(start);\n\n        if ((cc >= 97 && cc <= 122) || // a-z\n            (cc >= 65 && cc <= 90) || // A-Z\n             cc === 47 || cc === 91) { // /[\n          this._index = start;\n          return;\n        }\n      }\n\n      start = this._source.indexOf(\"\\n\", start);\n\n      if (start === -1) {\n        this._index = this._length;\n        return;\n      }\n      start++;\n    }\n  }\n}\n\n/**\n * Parses an FTL string using RuntimeParser and returns the generated\n * object with entries and a list of errors.\n *\n * @param {String} string\n * @returns {Array<Object, Array>}\n */\nexport default function parse(string) {\n  const parser = new RuntimeParser();\n  return parser.getResource(string);\n}\n","/* global Intl */\n\n/**\n * The `FluentType` class is the base of Fluent's type system.\n *\n * Fluent types wrap JavaScript values and store additional configuration for\n * them, which can then be used in the `toString` method together with a proper\n * `Intl` formatter.\n */\nexport class FluentType {\n\n  /**\n   * Create an `FluentType` instance.\n   *\n   * @param   {Any}    value - JavaScript value to wrap.\n   * @param   {Object} opts  - Configuration.\n   * @returns {FluentType}\n   */\n  constructor(value, opts) {\n    this.value = value;\n    this.opts = opts;\n  }\n\n  /**\n   * Unwrap the raw value stored by this `FluentType`.\n   *\n   * @returns {Any}\n   */\n  valueOf() {\n    return this.value;\n  }\n\n  /**\n   * Format this instance of `FluentType` to a string.\n   *\n   * Formatted values are suitable for use outside of the `MessageContext`.\n   * This method can use `Intl` formatters memoized by the `MessageContext`\n   * instance passed as an argument.\n   *\n   * @param   {MessageContext} [ctx]\n   * @returns {string}\n   */\n  toString() {\n    throw new Error(\"Subclasses of FluentType must implement toString.\");\n  }\n}\n\nexport class FluentNone extends FluentType {\n  toString() {\n    return this.value || \"???\";\n  }\n}\n\nexport class FluentNumber extends FluentType {\n  constructor(value, opts) {\n    super(parseFloat(value), opts);\n  }\n\n  toString(ctx) {\n    try {\n      const nf = ctx._memoizeIntlObject(\n        Intl.NumberFormat, this.opts\n      );\n      return nf.format(this.value);\n    } catch (e) {\n      // XXX Report the error.\n      return this.value;\n    }\n  }\n\n  /**\n   * Compare the object with another instance of a FluentType.\n   *\n   * @param   {MessageContext} ctx\n   * @param   {FluentType}     other\n   * @returns {bool}\n   */\n  match(ctx, other) {\n    if (other instanceof FluentNumber) {\n      return this.value === other.value;\n    }\n    return false;\n  }\n}\n\nexport class FluentDateTime extends FluentType {\n  constructor(value, opts) {\n    super(new Date(value), opts);\n  }\n\n  toString(ctx) {\n    try {\n      const dtf = ctx._memoizeIntlObject(\n        Intl.DateTimeFormat, this.opts\n      );\n      return dtf.format(this.value);\n    } catch (e) {\n      // XXX Report the error.\n      return this.value;\n    }\n  }\n}\n\nexport class FluentSymbol extends FluentType {\n  toString() {\n    return this.value;\n  }\n\n  /**\n   * Compare the object with another instance of a FluentType.\n   *\n   * @param   {MessageContext} ctx\n   * @param   {FluentType}     other\n   * @returns {bool}\n   */\n  match(ctx, other) {\n    if (other instanceof FluentSymbol) {\n      return this.value === other.value;\n    } else if (typeof other === \"string\") {\n      return this.value === other;\n    } else if (other instanceof FluentNumber) {\n      const pr = ctx._memoizeIntlObject(\n        Intl.PluralRules, other.opts\n      );\n      return this.value === pr.select(other.value);\n    }\n    return false;\n  }\n}\n","/**\n * @overview\n *\n * The FTL resolver ships with a number of functions built-in.\n *\n * Each function take two arguments:\n *   - args - an array of positional args\n *   - opts - an object of key-value args\n *\n * Arguments to functions are guaranteed to already be instances of\n * `FluentType`.  Functions must return `FluentType` objects as well.\n */\n\nimport { FluentNumber, FluentDateTime } from \"./types\";\n\nexport default {\n  \"NUMBER\": ([arg], opts) =>\n    new FluentNumber(arg.valueOf(), merge(arg.opts, opts)),\n  \"DATETIME\": ([arg], opts) =>\n    new FluentDateTime(arg.valueOf(), merge(arg.opts, opts)),\n};\n\nfunction merge(argopts, opts) {\n  return Object.assign({}, argopts, values(opts));\n}\n\nfunction values(opts) {\n  const unwrapped = {};\n  for (const [name, opt] of Object.entries(opts)) {\n    unwrapped[name] = opt.valueOf();\n  }\n  return unwrapped;\n}\n","/**\n * @overview\n *\n * The role of the Fluent resolver is to format a translation object to an\n * instance of `FluentType` or an array of instances.\n *\n * Translations can contain references to other messages or external arguments,\n * conditional logic in form of select expressions, traits which describe their\n * grammatical features, and can use Fluent builtins which make use of the\n * `Intl` formatters to format numbers, dates, lists and more into the\n * context's language.  See the documentation of the Fluent syntax for more\n * information.\n *\n * In case of errors the resolver will try to salvage as much of the\n * translation as possible.  In rare situations where the resolver didn't know\n * how to recover from an error it will return an instance of `FluentNone`.\n *\n * `MessageReference`, `VariantExpression`, `AttributeExpression` and\n * `SelectExpression` resolve to raw Runtime Entries objects and the result of\n * the resolution needs to be passed into `Type` to get their real value.\n * This is useful for composing expressions.  Consider:\n *\n *     brand-name[nominative]\n *\n * which is a `VariantExpression` with properties `id: MessageReference` and\n * `key: Keyword`.  If `MessageReference` was resolved eagerly, it would\n * instantly resolve to the value of the `brand-name` message.  Instead, we\n * want to get the message object and look for its `nominative` variant.\n *\n * All other expressions (except for `FunctionReference` which is only used in\n * `CallExpression`) resolve to an instance of `FluentType`.  The caller should\n * use the `toString` method to convert the instance to a native value.\n *\n *\n * All functions in this file pass around a special object called `env`.\n * This object stores a set of elements used by all resolve functions:\n *\n *  * {MessageContext} ctx\n *      context for which the given resolution is happening\n *  * {Object} args\n *      list of developer provided arguments that can be used\n *  * {Array} errors\n *      list of errors collected while resolving\n *  * {WeakSet} dirty\n *      Set of patterns already encountered during this resolution.\n *      This is used to prevent cyclic resolutions.\n */\n\n\nimport { FluentType, FluentNone, FluentNumber, FluentDateTime, FluentSymbol }\n  from \"./types\";\nimport builtins from \"./builtins\";\n\n// Prevent expansion of too long placeables.\nconst MAX_PLACEABLE_LENGTH = 2500;\n\n// Unicode bidi isolation characters.\nconst FSI = \"\\u2068\";\nconst PDI = \"\\u2069\";\n\n\n/**\n * Helper for choosing the default value from a set of members.\n *\n * Used in SelectExpressions and Type.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} members\n *    Hash map of variants from which the default value is to be selected.\n * @param   {Number} def\n *    The index of the default variant.\n * @returns {FluentType}\n * @private\n */\nfunction DefaultMember(env, members, def) {\n  if (members[def]) {\n    return members[def];\n  }\n\n  const { errors } = env;\n  errors.push(new RangeError(\"No default\"));\n  return new FluentNone();\n}\n\n\n/**\n * Resolve a reference to another message.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} id\n *    The identifier of the message to be resolved.\n * @param   {String} id.name\n *    The name of the identifier.\n * @returns {FluentType}\n * @private\n */\nfunction MessageReference(env, {name}) {\n  const { ctx, errors } = env;\n  const message = name.startsWith(\"-\")\n    ? ctx._terms.get(name)\n    : ctx._messages.get(name);\n\n  if (!message) {\n    const err = name.startsWith(\"-\")\n      ? new ReferenceError(`Unknown term: ${name}`)\n      : new ReferenceError(`Unknown message: ${name}`);\n    errors.push(err);\n    return new FluentNone(name);\n  }\n\n  return message;\n}\n\n/**\n * Resolve a variant expression to the variant object.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {Object} expr.id\n *    An Identifier of a message for which the variant is resolved.\n * @param   {Object} expr.id.name\n *    Name a message for which the variant is resolved.\n * @param   {Object} expr.key\n *    Variant key to be resolved.\n * @returns {FluentType}\n * @private\n */\nfunction VariantExpression(env, {id, key}) {\n  const message = MessageReference(env, id);\n  if (message instanceof FluentNone) {\n    return message;\n  }\n\n  const { ctx, errors } = env;\n  const keyword = Type(env, key);\n\n  function isVariantList(node) {\n    return Array.isArray(node) &&\n      node[0].type === \"sel\" &&\n      node[0].exp === null;\n  }\n\n  if (isVariantList(message.val)) {\n    // Match the specified key against keys of each variant, in order.\n    for (const variant of message.val[0].vars) {\n      const variantKey = Type(env, variant.key);\n      if (keyword.match(ctx, variantKey)) {\n        return variant;\n      }\n    }\n  }\n\n  errors.push(new ReferenceError(`Unknown variant: ${keyword.toString(ctx)}`));\n  return Type(env, message);\n}\n\n\n/**\n * Resolve an attribute expression to the attribute object.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.id\n *    An ID of a message for which the attribute is resolved.\n * @param   {String} expr.name\n *    Name of the attribute to be resolved.\n * @returns {FluentType}\n * @private\n */\nfunction AttributeExpression(env, {id, name}) {\n  const message = MessageReference(env, id);\n  if (message instanceof FluentNone) {\n    return message;\n  }\n\n  if (message.attrs) {\n    // Match the specified name against keys of each attribute.\n    for (const attrName in message.attrs) {\n      if (name === attrName) {\n        return message.attrs[name];\n      }\n    }\n  }\n\n  const { errors } = env;\n  errors.push(new ReferenceError(`Unknown attribute: ${name}`));\n  return Type(env, message);\n}\n\n/**\n * Resolve a select expression to the member object.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.exp\n *    Selector expression\n * @param   {Array} expr.vars\n *    List of variants for the select expression.\n * @param   {Number} expr.def\n *    Index of the default variant.\n * @returns {FluentType}\n * @private\n */\nfunction SelectExpression(env, {exp, vars, def}) {\n  if (exp === null) {\n    return DefaultMember(env, vars, def);\n  }\n\n  const selector = Type(env, exp);\n  if (selector instanceof FluentNone) {\n    return DefaultMember(env, vars, def);\n  }\n\n  // Match the selector against keys of each variant, in order.\n  for (const variant of vars) {\n    const key = Type(env, variant.key);\n    const keyCanMatch =\n      key instanceof FluentNumber || key instanceof FluentSymbol;\n\n    if (!keyCanMatch) {\n      continue;\n    }\n\n    const { ctx } = env;\n\n    if (key.match(ctx, selector)) {\n      return variant;\n    }\n  }\n\n  return DefaultMember(env, vars, def);\n}\n\n\n/**\n * Resolve expression to a Fluent type.\n *\n * JavaScript strings are a special case.  Since they natively have the\n * `toString` method they can be used as if they were a Fluent type without\n * paying the cost of creating a instance of one.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression object to be resolved into a Fluent type.\n * @returns {FluentType}\n * @private\n */\nfunction Type(env, expr) {\n  // A fast-path for strings which are the most common case, and for\n  // `FluentNone` which doesn't require any additional logic.\n  if (typeof expr === \"string\" || expr instanceof FluentNone) {\n    return expr;\n  }\n\n  // The Runtime AST (Entries) encodes patterns (complex strings with\n  // placeables) as Arrays.\n  if (Array.isArray(expr)) {\n    return Pattern(env, expr);\n  }\n\n\n  switch (expr.type) {\n    case \"varname\":\n      return new FluentSymbol(expr.name);\n    case \"num\":\n      return new FluentNumber(expr.val);\n    case \"ext\":\n      return ExternalArgument(env, expr);\n    case \"fun\":\n      return FunctionReference(env, expr);\n    case \"call\":\n      return CallExpression(env, expr);\n    case \"ref\": {\n      const message = MessageReference(env, expr);\n      return Type(env, message);\n    }\n    case \"attr\": {\n      const attr = AttributeExpression(env, expr);\n      return Type(env, attr);\n    }\n    case \"var\": {\n      const variant = VariantExpression(env, expr);\n      return Type(env, variant);\n    }\n    case \"sel\": {\n      const member = SelectExpression(env, expr);\n      return Type(env, member);\n    }\n    case undefined: {\n      // If it's a node with a value, resolve the value.\n      if (expr.val !== null && expr.val !== undefined) {\n        return Type(env, expr.val);\n      }\n\n      const { errors } = env;\n      errors.push(new RangeError(\"No value\"));\n      return new FluentNone();\n    }\n    default:\n      return new FluentNone();\n  }\n}\n\n/**\n * Resolve a reference to an external argument.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.name\n *    Name of an argument to be returned.\n * @returns {FluentType}\n * @private\n */\nfunction ExternalArgument(env, {name}) {\n  const { args, errors } = env;\n\n  if (!args || !args.hasOwnProperty(name)) {\n    errors.push(new ReferenceError(`Unknown external: ${name}`));\n    return new FluentNone(name);\n  }\n\n  const arg = args[name];\n\n  // Return early if the argument already is an instance of FluentType.\n  if (arg instanceof FluentType) {\n    return arg;\n  }\n\n  // Convert the argument to a Fluent type.\n  switch (typeof arg) {\n    case \"string\":\n      return arg;\n    case \"number\":\n      return new FluentNumber(arg);\n    case \"object\":\n      if (arg instanceof Date) {\n        return new FluentDateTime(arg);\n      }\n    default:\n      errors.push(\n        new TypeError(`Unsupported external type: ${name}, ${typeof arg}`)\n      );\n      return new FluentNone(name);\n  }\n}\n\n/**\n * Resolve a reference to a function.\n *\n * @param   {Object}  env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.name\n *    Name of the function to be returned.\n * @returns {Function}\n * @private\n */\nfunction FunctionReference(env, {name}) {\n  // Some functions are built-in.  Others may be provided by the runtime via\n  // the `MessageContext` constructor.\n  const { ctx: { _functions }, errors } = env;\n  const func = _functions[name] || builtins[name];\n\n  if (!func) {\n    errors.push(new ReferenceError(`Unknown function: ${name}()`));\n    return new FluentNone(`${name}()`);\n  }\n\n  if (typeof func !== \"function\") {\n    errors.push(new TypeError(`Function ${name}() is not callable`));\n    return new FluentNone(`${name}()`);\n  }\n\n  return func;\n}\n\n/**\n * Resolve a call to a Function with positional and key-value arguments.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {Object} expr.fun\n *    FTL Function object.\n * @param   {Array} expr.args\n *    FTL Function argument list.\n * @returns {FluentType}\n * @private\n */\nfunction CallExpression(env, {fun, args}) {\n  const callee = FunctionReference(env, fun);\n\n  if (callee instanceof FluentNone) {\n    return callee;\n  }\n\n  const posargs = [];\n  const keyargs = {};\n\n  for (const arg of args) {\n    if (arg.type === \"narg\") {\n      keyargs[arg.name] = Type(env, arg.val);\n    } else {\n      posargs.push(Type(env, arg));\n    }\n  }\n\n  try {\n    return callee(posargs, keyargs);\n  } catch (e) {\n    // XXX Report errors.\n    return new FluentNone();\n  }\n}\n\n/**\n * Resolve a pattern (a complex string with placeables).\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Array} ptn\n *    Array of pattern elements.\n * @returns {Array}\n * @private\n */\nfunction Pattern(env, ptn) {\n  const { ctx, dirty, errors } = env;\n\n  if (dirty.has(ptn)) {\n    errors.push(new RangeError(\"Cyclic reference\"));\n    return new FluentNone();\n  }\n\n  // Tag the pattern as dirty for the purpose of the current resolution.\n  dirty.add(ptn);\n  const result = [];\n\n  // Wrap interpolations with Directional Isolate Formatting characters\n  // only when the pattern has more than one element.\n  const useIsolating = ctx._useIsolating && ptn.length > 1;\n\n  for (const elem of ptn) {\n    if (typeof elem === \"string\") {\n      result.push(elem);\n      continue;\n    }\n\n    const part = Type(env, elem).toString(ctx);\n\n    if (useIsolating) {\n      result.push(FSI);\n    }\n\n    if (part.length > MAX_PLACEABLE_LENGTH) {\n      errors.push(\n        new RangeError(\n          \"Too many characters in placeable \" +\n          `(${part.length}, max allowed is ${MAX_PLACEABLE_LENGTH})`\n        )\n      );\n      result.push(part.slice(MAX_PLACEABLE_LENGTH));\n    } else {\n      result.push(part);\n    }\n\n    if (useIsolating) {\n      result.push(PDI);\n    }\n  }\n\n  dirty.delete(ptn);\n  return result.join(\"\");\n}\n\n/**\n * Format a translation into a string.\n *\n * @param   {MessageContext} ctx\n *    A MessageContext instance which will be used to resolve the\n *    contextual information of the message.\n * @param   {Object}         args\n *    List of arguments provided by the developer which can be accessed\n *    from the message.\n * @param   {Object}         message\n *    An object with the Message to be resolved.\n * @param   {Array}          errors\n *    An error array that any encountered errors will be appended to.\n * @returns {FluentType}\n */\nexport default function resolve(ctx, args, message, errors = []) {\n  const env = {\n    ctx, args, errors, dirty: new WeakSet()\n  };\n  return Type(env, message).toString(ctx);\n}\n","import resolve from \"./resolver\";\nimport parse from \"./parser\";\n\n/**\n * Message contexts are single-language stores of translations.  They are\n * responsible for parsing translation resources in the Fluent syntax and can\n * format translation units (entities) to strings.\n *\n * Always use `MessageContext.format` to retrieve translation units from\n * a context.  Translations can contain references to other entities or\n * external arguments, conditional logic in form of select expressions, traits\n * which describe their grammatical features, and can use Fluent builtins which\n * make use of the `Intl` formatters to format numbers, dates, lists and more\n * into the context's language.  See the documentation of the Fluent syntax for\n * more information.\n */\nexport class MessageContext {\n\n  /**\n   * Create an instance of `MessageContext`.\n   *\n   * The `locales` argument is used to instantiate `Intl` formatters used by\n   * translations.  The `options` object can be used to configure the context.\n   *\n   * Examples:\n   *\n   *     const ctx = new MessageContext(locales);\n   *\n   *     const ctx = new MessageContext(locales, { useIsolating: false });\n   *\n   *     const ctx = new MessageContext(locales, {\n   *       useIsolating: true,\n   *       functions: {\n   *         NODE_ENV: () => process.env.NODE_ENV\n   *       }\n   *     });\n   *\n   * Available options:\n   *\n   *   - `functions` - an object of additional functions available to\n   *                   translations as builtins.\n   *\n   *   - `useIsolating` - boolean specifying whether to use Unicode isolation\n   *                    marks (FSI, PDI) for bidi interpolations.\n   *\n   * @param   {string|Array<string>} locales - Locale or locales of the context\n   * @param   {Object} [options]\n   * @returns {MessageContext}\n   */\n  constructor(locales, { functions = {}, useIsolating = true } = {}) {\n    this.locales = Array.isArray(locales) ? locales : [locales];\n\n    this._terms = new Map();\n    this._messages = new Map();\n    this._functions = functions;\n    this._useIsolating = useIsolating;\n    this._intls = new WeakMap();\n  }\n\n  /*\n   * Return an iterator over public `[id, message]` pairs.\n   *\n   * @returns {Iterator}\n   */\n  get messages() {\n    return this._messages[Symbol.iterator]();\n  }\n\n  /*\n   * Check if a message is present in the context.\n   *\n   * @param {string} id - The identifier of the message to check.\n   * @returns {bool}\n   */\n  hasMessage(id) {\n    return this._messages.has(id);\n  }\n\n  /*\n   * Return the internal representation of a message.\n   *\n   * The internal representation should only be used as an argument to\n   * `MessageContext.format`.\n   *\n   * @param {string} id - The identifier of the message to check.\n   * @returns {Any}\n   */\n  getMessage(id) {\n    return this._messages.get(id);\n  }\n\n  /**\n   * Add a translation resource to the context.\n   *\n   * The translation resource must use the Fluent syntax.  It will be parsed by\n   * the context and each translation unit (message) will be available in the\n   * context by its identifier.\n   *\n   *     ctx.addMessages('foo = Foo');\n   *     ctx.getMessage('foo');\n   *\n   *     // Returns a raw representation of the 'foo' message.\n   *\n   * Parsed entities should be formatted with the `format` method in case they\n   * contain logic (references, select expressions etc.).\n   *\n   * @param   {string} source - Text resource with translations.\n   * @returns {Array<Error>}\n   */\n  addMessages(source) {\n    const [entries, errors] = parse(source);\n    for (const id in entries) {\n      if (id.startsWith(\"-\")) {\n        // Identifiers starting with a dash (-) define terms. Terms are private\n        // and cannot be retrieved from MessageContext.\n        if (this._terms.has(id)) {\n          errors.push(`Attempt to override an existing term: \"${id}\"`);\n          continue;\n        }\n        this._terms.set(id, entries[id]);\n      } else {\n        if (this._messages.has(id)) {\n          errors.push(`Attempt to override an existing message: \"${id}\"`);\n          continue;\n        }\n        this._messages.set(id, entries[id]);\n      }\n    }\n\n    return errors;\n  }\n\n  /**\n   * Format a message to a string or null.\n   *\n   * Format a raw `message` from the context into a string (or a null if it has\n   * a null value).  `args` will be used to resolve references to external\n   * arguments inside of the translation.\n   *\n   * In case of errors `format` will try to salvage as much of the translation\n   * as possible and will still return a string.  For performance reasons, the\n   * encountered errors are not returned but instead are appended to the\n   * `errors` array passed as the third argument.\n   *\n   *     const errors = [];\n   *     ctx.addMessages('hello = Hello, { $name }!');\n   *     const hello = ctx.getMessage('hello');\n   *     ctx.format(hello, { name: 'Jane' }, errors);\n   *\n   *     // Returns 'Hello, Jane!' and `errors` is empty.\n   *\n   *     ctx.format(hello, undefined, errors);\n   *\n   *     // Returns 'Hello, name!' and `errors` is now:\n   *\n   *     [<ReferenceError: Unknown external: name>]\n   *\n   * @param   {Object | string}    message\n   * @param   {Object | undefined} args\n   * @param   {Array}              errors\n   * @returns {?string}\n   */\n  format(message, args, errors) {\n    // optimize entities which are simple strings with no attributes\n    if (typeof message === \"string\") {\n      return message;\n    }\n\n    // optimize simple-string entities with attributes\n    if (typeof message.val === \"string\") {\n      return message.val;\n    }\n\n    // optimize entities with null values\n    if (message.val === undefined) {\n      return null;\n    }\n\n    return resolve(this, args, message, errors);\n  }\n\n  _memoizeIntlObject(ctor, opts) {\n    const cache = this._intls.get(ctor) || {};\n    const id = JSON.stringify(opts);\n\n    if (!cache[id]) {\n      cache[id] = new ctor(this.locales, opts);\n      this._intls.set(ctor, cache);\n    }\n\n    return cache[id];\n  }\n}\n","/*\n * CachedIterable caches the elements yielded by an iterable.\n *\n * It can be used to iterate over an iterable many times without depleting the\n * iterable.\n */\nexport default class CachedIterable {\n  /**\n   * Create an `CachedIterable` instance.\n   *\n   * @param {Iterable} iterable\n   * @returns {CachedIterable}\n   */\n  constructor(iterable) {\n    if (Symbol.asyncIterator in Object(iterable)) {\n      this.iterator = iterable[Symbol.asyncIterator]();\n    } else if (Symbol.iterator in Object(iterable)) {\n      this.iterator = iterable[Symbol.iterator]();\n    } else {\n      throw new TypeError(\"Argument must implement the iteration protocol.\");\n    }\n\n    this.seen = [];\n  }\n\n  [Symbol.iterator]() {\n    const { seen, iterator } = this;\n    let cur = 0;\n\n    return {\n      next() {\n        if (seen.length <= cur) {\n          seen.push(iterator.next());\n        }\n        return seen[cur++];\n      }\n    };\n  }\n\n  [Symbol.asyncIterator]() {\n    const { seen, iterator } = this;\n    let cur = 0;\n\n    return {\n      async next() {\n        if (seen.length <= cur) {\n          seen.push(await iterator.next());\n        }\n        return seen[cur++];\n      }\n    };\n  }\n\n  /**\n   * This method allows user to consume the next element from the iterator\n   * into the cache.\n   */\n  touchNext() {\n    const { seen, iterator } = this;\n    if (seen.length === 0 || seen[seen.length - 1].done === false) {\n      seen.push(iterator.next());\n    }\n  }\n}\n","/*\n * @overview\n *\n * Functions for managing ordered sequences of MessageContexts.\n *\n * An ordered iterable of MessageContext instances can represent the current\n * negotiated fallback chain of languages.  This iterable can be used to find\n * the best existing translation for a given identifier.\n *\n * The mapContext* methods can be used to find the first MessageContext in the\n * given iterable which contains the translation with the given identifier.  If\n * the iterable is ordered according to the result of a language negotiation\n * the returned MessageContext contains the best available translation.\n *\n * A simple function which formats translations based on the identifier might\n * be implemented as follows:\n *\n *     formatString(id, args) {\n *         const ctx = mapContextSync(contexts, id);\n *\n *         if (ctx === null) {\n *             return id;\n *         }\n *\n *         const msg = ctx.getMessage(id);\n *         return ctx.format(msg, args);\n *     }\n *\n * In order to pass an iterator to mapContext*, wrap it in CachedIterable.\n * This allows multiple calls to mapContext* without advancing and eventually\n * depleting the iterator.\n *\n *     function *generateMessages() {\n *         // Some lazy logic for yielding MessageContexts.\n *         yield *[ctx1, ctx2];\n *     }\n *\n *     const contexts = new CachedIterable(generateMessages());\n *     const ctx = mapContextSync(contexts, id);\n *\n */\n\n/*\n * Synchronously map an identifier or an array of identifiers to the best\n * `MessageContext` instance(s).\n *\n * @param {Iterable} iterable\n * @param {string|Array<string>} ids\n * @returns {MessageContext|Array<MessageContext>}\n */\nexport function mapContextSync(iterable, ids) {\n  if (!Array.isArray(ids)) {\n    return getContextForId(iterable, ids);\n  }\n\n  return ids.map(\n    id => getContextForId(iterable, id)\n  );\n}\n\n/*\n * Find the best `MessageContext` with the translation for `id`.\n */\nfunction getContextForId(iterable, id) {\n  for (const context of iterable) {\n    if (context.hasMessage(id)) {\n      return context;\n    }\n  }\n\n  return null;\n}\n\n/*\n * Asynchronously map an identifier or an array of identifiers to the best\n * `MessageContext` instance(s).\n *\n * @param {AsyncIterable} iterable\n * @param {string|Array<string>} ids\n * @returns {Promise<MessageContext|Array<MessageContext>>}\n */\nexport async function mapContextAsync(iterable, ids) {\n  if (!Array.isArray(ids)) {\n    for await (const context of iterable) {\n      if (context.hasMessage(ids)) {\n        return context;\n      }\n    }\n  }\n\n  let remainingCount = ids.length;\n  const foundContexts = new Array(remainingCount).fill(null);\n\n  for await (const context of iterable) {\n    // XXX Switch to const [index, id] of id.entries() when we move to Babel 7.\n    // See https://github.com/babel/babel/issues/5880.\n    for (let index = 0; index < ids.length; index++) {\n      const id = ids[index];\n      if (!foundContexts[index] && context.hasMessage(id)) {\n        foundContexts[index] = context;\n        remainingCount--;\n      }\n\n      // Return early when all ids have been mapped to contexts.\n      if (remainingCount === 0) {\n        return foundContexts;\n      }\n    }\n  }\n\n  return foundContexts;\n}\n","function nonBlank(line) {\n  return !/^\\s*$/.test(line);\n}\n\nfunction countIndent(line) {\n  const [indent] = line.match(/^\\s*/);\n  return indent.length;\n}\n\n/**\n * Template literal tag for dedenting FTL code.\n *\n * Strip the common indent of non-blank lines. Remove blank lines.\n *\n * @param {Array<string>} strings\n */\nexport function ftl(strings) {\n  const [code] = strings;\n  const lines = code.split(\"\\n\").filter(nonBlank);\n  const indents = lines.map(countIndent);\n  const common = Math.min(...indents);\n  const indent = new RegExp(`^\\\\s{${common}}`);\n\n  return lines.map(\n    line => line.replace(indent, \"\")\n  ).join(\"\\n\");\n}\n","/*\n * @module fluent\n * @overview\n *\n * `fluent` is a JavaScript implementation of Project Fluent, a localization\n * framework designed to unleash the expressive power of the natural language.\n *\n */\n\nexport { default as _parse } from \"./parser\";\n\nexport { MessageContext } from \"./context\";\nexport {\n  FluentType as MessageArgument,\n  FluentNumber as MessageNumberArgument,\n  FluentDateTime as MessageDateTimeArgument,\n} from \"./types\";\n\nexport { default as CachedIterable } from \"./cached_iterable\";\nexport { mapContextSync, mapContextAsync } from \"./fallback\";\n\nexport { ftl } from \"./util\";\n","import { CachedIterable, mapContextSync } from \"fluent\";\n\n/*\n * `ReactLocalization` handles translation formatting and fallback.\n *\n * The current negotiated fallback chain of languages is stored in the\n * `ReactLocalization` instance in form of an iterable of `MessageContext`\n * instances.  This iterable is used to find the best existing translation for\n * a given identifier.\n *\n * `Localized` components must subscribe to the changes of the\n * `ReactLocalization`'s fallback chain.  When the fallback chain changes (the\n * `messages` iterable is set anew), all subscribed compontent must relocalize.\n *\n * The `ReactLocalization` class instances are exposed to `Localized` elements\n * via the `LocalizationProvider` component.\n */\nexport default class ReactLocalization {\n  constructor(messages) {\n    this.contexts = new CachedIterable(messages);\n    this.subs = new Set();\n  }\n\n  /*\n   * Subscribe a `Localized` component to changes of `messages`.\n   */\n  subscribe(comp) {\n    this.subs.add(comp);\n  }\n\n  /*\n   * Unsubscribe a `Localized` component from `messages` changes.\n   */\n  unsubscribe(comp) {\n    this.subs.delete(comp);\n  }\n\n  /*\n   * Set a new `messages` iterable and trigger the retranslation.\n   */\n  setMessages(messages) {\n    this.contexts = new CachedIterable(messages);\n\n    // Update all subscribed Localized components.\n    this.subs.forEach(comp => comp.relocalize());\n  }\n\n  getMessageContext(id) {\n    return mapContextSync(this.contexts, id);\n  }\n\n  formatCompound(mcx, msg, args) {\n    const value = mcx.format(msg, args);\n\n    if (msg.attrs) {\n      var attrs = {};\n      for (const name of Object.keys(msg.attrs)) {\n        attrs[name] = mcx.format(msg.attrs[name], args);\n      }\n    }\n\n    return { value, attrs };\n  }\n\n  /*\n   * Find a translation by `id` and format it to a string using `args`.\n   */\n  getString(id, args, fallback) {\n    const mcx = this.getMessageContext(id);\n\n    if (mcx === null) {\n      return fallback || id;\n    }\n\n    const msg = mcx.getMessage(id);\n    return mcx.format(msg, args);\n  }\n}\n\nexport function isReactLocalization(props, propName) {\n  const prop = props[propName];\n\n  if (prop instanceof ReactLocalization) {\n    return null;\n  }\n\n  return new Error(\n    `The ${propName} context field must be an instance of ReactLocalization.`\n  );\n}\n","import { Component, Children } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport ReactLocalization, { isReactLocalization} from \"./localization\";\n\n/*\n * The Provider component for the `ReactLocalization` class.\n *\n * Exposes a `ReactLocalization` instance to all descendants via React's\n * context feature.  It makes translations available to all localizable\n * elements in the descendant's render tree without the need to pass them\n * explicitly.\n *\n *     <LocalizationProvider messages={…}>\n *         …\n *     </LocalizationProvider>\n *\n * The `LocalizationProvider` component takes one prop: `messages`.  It should\n * be an iterable of `MessageContext` instances in order of the user's\n * preferred languages.  The `MessageContext` instances will be used by\n * `ReactLocalization` to format translations.  If a translation is missing in\n * one instance, `ReactLocalization` will fall back to the next one.\n */\nexport default class LocalizationProvider extends Component {\n  constructor(props) {\n    super(props);\n    const { messages } = props;\n\n    if (messages === undefined) {\n      throw new Error(\"LocalizationProvider must receive the messages prop.\");\n    }\n\n    if (!messages[Symbol.iterator]) {\n      throw new Error(\"The messages prop must be an iterable.\");\n    }\n\n    this.l10n = new ReactLocalization(messages);\n  }\n\n  getChildContext() {\n    return {\n      l10n: this.l10n\n    };\n  }\n\n  componentWillReceiveProps(next) {\n    const { messages } = next;\n\n    if (messages !== this.props.messages) {\n      this.l10n.setMessages(messages);\n    }\n  }\n\n  render() {\n    return Children.only(this.props.children);\n  }\n}\n\nLocalizationProvider.childContextTypes = {\n  l10n: isReactLocalization\n};\n\nLocalizationProvider.propTypes = {\n  children: PropTypes.element.isRequired,\n  messages: isIterable\n};\n\nfunction isIterable(props, propName, componentName) {\n  const prop = props[propName];\n\n  if (Symbol.iterator in Object(prop)) {\n    return null;\n  }\n\n  return new Error(\n    `The ${propName} prop supplied to ${componentName} must be an iterable.`\n  );\n}\n","import { createElement, Component } from \"react\";\n\nimport { isReactLocalization } from \"./localization\";\n\nexport default function withLocalization(Inner) {\n  class WithLocalization extends Component {\n    componentDidMount() {\n      const { l10n } = this.context;\n\n      if (l10n) {\n        l10n.subscribe(this);\n      }\n    }\n\n    componentWillUnmount() {\n      const { l10n } = this.context;\n\n      if (l10n) {\n        l10n.unsubscribe(this);\n      }\n    }\n\n    /*\n     * Rerender this component in a new language.\n     */\n    relocalize() {\n      // When the `ReactLocalization`'s fallback chain changes, update the\n      // component.\n      this.forceUpdate();\n    }\n\n    /*\n     * Find a translation by `id` and format it to a string using `args`.\n     */\n    getString(id, args, fallback) {\n      const { l10n } = this.context;\n\n      if (!l10n) {\n        return fallback || id;\n      }\n\n      return l10n.getString(id, args, fallback);\n    }\n\n    render() {\n      return createElement(\n        Inner,\n        Object.assign(\n          // getString needs to be re-bound on updates to trigger a re-render\n          { getString: (...args) => this.getString(...args) },\n          this.props\n        )\n      );\n    }\n  }\n\n  WithLocalization.displayName = `WithLocalization(${displayName(Inner)})`;\n\n  WithLocalization.contextTypes = {\n    l10n: isReactLocalization\n  };\n\n  return WithLocalization;\n}\n\nfunction displayName(component) {\n  return component.displayName || component.name || \"Component\";\n}\n","/* eslint-env browser */\n\nconst TEMPLATE = document.createElement(\"template\");\n\nexport function parseMarkup(str) {\n  TEMPLATE.innerHTML = str;\n  return TEMPLATE.content;\n}\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in this directory.\n */\n\n// For HTML, certain tags should omit their close tag. We keep a whitelist for\n// those special-case tags.\n\nvar omittedCloseTags = {\n  area: true,\n  base: true,\n  br: true,\n  col: true,\n  embed: true,\n  hr: true,\n  img: true,\n  input: true,\n  keygen: true,\n  link: true,\n  meta: true,\n  param: true,\n  source: true,\n  track: true,\n  wbr: true,\n  // NOTE: menuitem's close tag should be omitted, but that causes problems.\n};\n\nexport default omittedCloseTags;\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in this directory.\n */\n\nimport omittedCloseTags from './omittedCloseTags';\n\n// For HTML, certain tags cannot have children. This has the same purpose as\n// `omittedCloseTags` except that `menuitem` should still have its closing tag.\n\nvar voidElementTags = {\n  menuitem: true,\n  ...omittedCloseTags,\n};\n\nexport default voidElementTags;\n","import { isValidElement, cloneElement, Component, Children } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport { isReactLocalization } from \"./localization\";\nimport { parseMarkup } from \"./markup\";\nimport VOID_ELEMENTS from \"../vendor/voidElementTags\";\n\n// Match the opening angle bracket (<) in HTML tags, and HTML entities like\n// &amp;, &#0038;, &#x0026;.\nconst reMarkup = /<|&#?\\w+;/;\n\n/*\n * Prepare props passed to `Localized` for formatting.\n */\nfunction toArguments(props) {\n  const args = {};\n  const elems = {};\n\n  for (const [propname, propval] of Object.entries(props)) {\n    if (propname.startsWith(\"$\")) {\n      const name = propname.substr(1);\n      args[name] = propval;\n    } else if (isValidElement(propval)) {\n      // We'll try to match localNames of elements found in the translation with\n      // names of elements passed as props. localNames are always lowercase.\n      const name = propname.toLowerCase();\n      elems[name] = propval;\n    }\n  }\n\n  return [args, elems];\n}\n\n/*\n * The `Localized` class renders its child with translated props and children.\n *\n *     <Localized id=\"hello-world\">\n *         <p>{'Hello, world!'}</p>\n *     </Localized>\n *\n * The `id` prop should be the unique identifier of the translation.  Any\n * attributes found in the translation will be applied to the wrapped element.\n *\n * Arguments to the translation can be passed as `$`-prefixed props on\n * `Localized`.\n *\n *     <Localized id=\"hello-world\" $username={name}>\n *         <p>{'Hello, { $username }!'}</p>\n *     </Localized>\n *\n *  It's recommended that the contents of the wrapped component be a string\n *  expression.  The string will be used as the ultimate fallback if no\n *  translation is available.  It also makes it easy to grep for strings in the\n *  source code.\n */\nexport default class Localized extends Component {\n  componentDidMount() {\n    const { l10n } = this.context;\n\n    if (l10n) {\n      l10n.subscribe(this);\n    }\n  }\n\n  componentWillUnmount() {\n    const { l10n } = this.context;\n\n    if (l10n) {\n      l10n.unsubscribe(this);\n    }\n  }\n\n  /*\n   * Rerender this component in a new language.\n   */\n  relocalize() {\n    // When the `ReactLocalization`'s fallback chain changes, update the\n    // component.\n    this.forceUpdate();\n  }\n\n  render() {\n    const { l10n } = this.context;\n    const { id, attrs, children } = this.props;\n    const elem = Children.only(children);\n\n    if (!l10n) {\n      // Use the wrapped component as fallback.\n      return elem;\n    }\n\n    const mcx = l10n.getMessageContext(id);\n\n    if (mcx === null) {\n      // Use the wrapped component as fallback.\n      return elem;\n    }\n\n    const msg = mcx.getMessage(id);\n    const [args, elems] = toArguments(this.props);\n    const {\n      value: messageValue,\n      attrs: messageAttrs\n    } = l10n.formatCompound(mcx, msg, args);\n\n    // The default is to forbid all message attributes. If the attrs prop exists\n    // on the Localized instance, only set message attributes which have been\n    // explicitly allowed by the developer.\n    if (attrs && messageAttrs) {\n      var localizedProps = {};\n\n      for (const [name, value] of Object.entries(messageAttrs)) {\n        if (attrs[name]) {\n          localizedProps[name] = value;\n        }\n      }\n    }\n\n    // If the wrapped component is a known void element, explicitly dismiss the\n    // message value and do not pass it to cloneElement in order to avoid the\n    // \"void element tags must neither have `children` nor use\n    // `dangerouslySetInnerHTML`\" error.\n    if (elem.type in VOID_ELEMENTS) {\n      return cloneElement(elem, localizedProps);\n    }\n\n    // If the message has a null value, we're only interested in its attributes.\n    // Do not pass the null value to cloneElement as it would nuke all children\n    // of the wrapped component.\n    if (messageValue === null) {\n      return cloneElement(elem, localizedProps);\n    }\n\n    // If the message value doesn't contain any markup nor any HTML entities,\n    // insert it as the only child of the wrapped component.\n    if (!reMarkup.test(messageValue)) {\n      return cloneElement(elem, localizedProps, messageValue);\n    }\n\n    // If the message contains markup, parse it and try to match the children\n    // found in the translation with the props passed to this Localized.\n    const translationNodes = Array.from(parseMarkup(messageValue).childNodes);\n    const translatedChildren = translationNodes.map(childNode => {\n      if (childNode.nodeType === childNode.TEXT_NODE) {\n        return childNode.textContent;\n      }\n\n      // If the child is not expected just take its textContent.\n      if (!elems.hasOwnProperty(childNode.localName)) {\n        return childNode.textContent;\n      }\n\n      const sourceChild = elems[childNode.localName];\n\n      // If the element passed as a prop to <Localized> is a known void element,\n      // explicitly dismiss any textContent which might have accidentally been\n      // defined in the translation to prevent the \"void element tags must not\n      // have children\" error.\n      if (sourceChild.type in VOID_ELEMENTS) {\n        return sourceChild;\n      }\n\n      // TODO Protect contents of elements wrapped in <Localized>\n      // https://github.com/projectfluent/fluent.js/issues/184\n      // TODO  Control localizable attributes on elements passed as props\n      // https://github.com/projectfluent/fluent.js/issues/185\n      return cloneElement(sourceChild, null, childNode.textContent);\n    });\n\n    return cloneElement(elem, localizedProps, ...translatedChildren);\n  }\n}\n\nLocalized.contextTypes = {\n  l10n: isReactLocalization\n};\n\nLocalized.propTypes = {\n  children: PropTypes.element.isRequired,\n};\n","/*\n * @module fluent-react\n * @overview\n *\n\n * `fluent-react` provides React bindings for Fluent.  It takes advantage of\n * React's Components system and the virtual DOM.  Translations are exposed to\n * components via the provider pattern.\n *\n *     <LocalizationProvider messages={…}>\n *         <Localized id=\"hello-world\">\n *             <p>{'Hello, world!'}</p>\n *         </Localized>\n *     </LocalizationProvider>\n *\n * Consult the documentation of the `LocalizationProvider` and the `Localized`\n * components for more information.\n */\n\nexport { default as LocalizationProvider } from \"./provider\";\nexport { default as withLocalization } from \"./with_localization\";\nexport { default as Localized } from \"./localized\";\nexport { default as ReactLocalization, isReactLocalization }\n  from \"./localization\";\n","import React from \"react\";\n\nconst ALLOWED_STYLE_TAGS = [\"color\", \"backgroundColor\"];\n\nexport const Button = props => {\n  const style = {};\n\n  // Add allowed style tags from props, e.g. props.color becomes style={color: props.color}\n  for (const tag of ALLOWED_STYLE_TAGS) {\n    if (typeof props[tag] !== \"undefined\") {\n      style[tag] = props[tag];\n    }\n  }\n  // remove border if bg is set to something custom\n  if (style.backgroundColor) {\n    style.border = \"0\";\n  }\n\n  return (<button onClick={props.onClick}\n    className={props.className || \"ASRouterButton\"}\n    style={style}>\n    {props.children}\n  </button>);\n};\n","import React from \"react\";\n\nexport class SnippetBase extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onBlockClicked = this.onBlockClicked.bind(this);\n  }\n\n  onBlockClicked() {\n    if (this.props.provider !== \"preview\") {\n      this.props.sendUserActionTelemetry({event: \"BLOCK\", id: this.props.UISurface});\n    }\n\n    this.props.onBlock();\n  }\n\n  render() {\n    const {props} = this;\n\n    const containerClassName = `SnippetBaseContainer${props.className ? ` ${props.className}` : \"\"}`;\n\n    return (<div className={containerClassName}>\n      <div className=\"innerWrapper\">\n        {props.children}\n      </div>\n      <button className=\"blockButton\" onClick={this.onBlockClicked} />\n    </div>);\n  }\n}\n","import {Button} from \"../../components/Button/Button\";\nimport React from \"react\";\nimport {safeURI} from \"../../template-utils\";\nimport {SnippetBase} from \"../../components/SnippetBase/SnippetBase\";\n\nconst DEFAULT_ICON_PATH = \"chrome://branding/content/icon64.png\";\n\nexport class SimpleSnippet extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onButtonClick = this.onButtonClick.bind(this);\n  }\n\n  onButtonClick() {\n    if (this.props.provider !== \"preview\") {\n      this.props.sendUserActionTelemetry({event: \"CLICK_BUTTON\", id: this.props.UISurface});\n    }\n    this.props.onAction(this.props.content.button_action);\n    if (!this.props.content.do_not_autoblock) {\n      this.props.onBlock();\n    }\n  }\n\n  renderTitle() {\n    const {title} = this.props.content;\n    return title ? <h3 className=\"title\">{title}</h3> : null;\n  }\n\n  renderTitleIcon() {\n    const titleIcon = safeURI(this.props.content.title_icon);\n    return titleIcon ? <span className=\"titleIcon\" style={{backgroundImage: `url(\"${titleIcon}\")`}} /> : null;\n  }\n\n  renderButton() {\n    const {props} = this;\n    if (!props.content.button_action) {\n      return null;\n    }\n\n    return (<Button\n      onClick={this.onButtonClick}\n      color={props.content.button_color}\n      backgroundColor={props.content.button_background_color}>\n      {props.content.button_label}\n    </Button>);\n  }\n\n  render() {\n    const {props} = this;\n    const className = `SimpleSnippet${props.content.tall ? \" tall\" : \"\"}`;\n    return (<SnippetBase {...props} className={className}>\n      <img src={safeURI(props.content.icon) || DEFAULT_ICON_PATH} className=\"icon\" />\n      <div>\n        {this.renderTitleIcon()} {this.renderTitle()} <p className=\"body\">{props.richText || props.content.text}</p>\n      </div>\n      {<div>{this.renderButton()}</div>}\n    </SnippetBase>);\n  }\n}\n","this.Dedupe = class Dedupe {\n  constructor(createKey) {\n    this.createKey = createKey || this.defaultCreateKey;\n  }\n\n  defaultCreateKey(item) {\n    return item;\n  }\n\n  /**\n   * Dedupe any number of grouped elements favoring those from earlier groups.\n   *\n   * @param {Array} groups Contains an arbitrary number of arrays of elements.\n   * @returns {Array} A matching array of each provided group deduped.\n   */\n  group(...groups) {\n    const globalKeys = new Set();\n    const result = [];\n    for (const values of groups) {\n      const valueMap = new Map();\n      for (const value of values) {\n        const key = this.createKey(value);\n        if (!globalKeys.has(key) && !valueMap.has(key)) {\n          valueMap.set(key, value);\n        }\n      }\n      result.push(valueMap);\n      valueMap.forEach((value, key) => globalKeys.add(key));\n    }\n    return result.map(m => Array.from(m.values()));\n  }\n};\n\nconst EXPORTED_SYMBOLS = [\"Dedupe\"];\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\"use strict\";\n\nconst {actionTypes: at} = ChromeUtils.import(\"resource://activity-stream/common/Actions.jsm\", {});\nconst {Dedupe} = ChromeUtils.import(\"resource://activity-stream/common/Dedupe.jsm\", {});\n\nconst TOP_SITES_DEFAULT_ROWS = 1;\nconst TOP_SITES_MAX_SITES_PER_ROW = 8;\n\nconst dedupe = new Dedupe(site => site && site.url);\n\nconst INITIAL_STATE = {\n  App: {\n    // Have we received real data from the app yet?\n    initialized: false,\n  },\n  ASRouter: {\n    initialized: false,\n    allowLegacyOnboarding: null,\n    allowLegacySnippets: null,\n  },\n  Snippets: {initialized: false},\n  TopSites: {\n    // Have we received real data from history yet?\n    initialized: false,\n    // The history (and possibly default) links\n    rows: [],\n    // Used in content only to dispatch action to TopSiteForm.\n    editForm: null,\n    // Used in content only to open the SearchShortcutsForm modal.\n    showSearchShortcutsForm: false,\n    // The list of available search shortcuts.\n    searchShortcuts: [],\n  },\n  Prefs: {\n    initialized: false,\n    values: {},\n  },\n  Dialog: {\n    visible: false,\n    data: {},\n  },\n  Sections: [],\n  Pocket: {\n    isUserLoggedIn: null,\n    pocketCta: {},\n    waitingForSpoc: true,\n  },\n};\n\nfunction App(prevState = INITIAL_STATE.App, action) {\n  switch (action.type) {\n    case at.INIT:\n      return Object.assign({}, prevState, action.data || {}, {initialized: true});\n    default:\n      return prevState;\n  }\n}\n\nfunction ASRouter(prevState = INITIAL_STATE.ASRouter, action) {\n  switch (action.type) {\n    case at.AS_ROUTER_INITIALIZED:\n      return {...action.data, initialized: true};\n    case at.AS_ROUTER_PREF_CHANGED:\n      return {...prevState, ...action.data};\n    default:\n      return prevState;\n  }\n}\n\n/**\n * insertPinned - Inserts pinned links in their specified slots\n *\n * @param {array} a list of links\n * @param {array} a list of pinned links\n * @return {array} resulting list of links with pinned links inserted\n */\nfunction insertPinned(links, pinned) {\n  // Remove any pinned links\n  const pinnedUrls = pinned.map(link => link && link.url);\n  let newLinks = links.filter(link => (link ? !pinnedUrls.includes(link.url) : false));\n  newLinks = newLinks.map(link => {\n    if (link && link.isPinned) {\n      delete link.isPinned;\n      delete link.pinIndex;\n    }\n    return link;\n  });\n\n  // Then insert them in their specified location\n  pinned.forEach((val, index) => {\n    if (!val) { return; }\n    let link = Object.assign({}, val, {isPinned: true, pinIndex: index});\n    if (index > newLinks.length) {\n      newLinks[index] = link;\n    } else {\n      newLinks.splice(index, 0, link);\n    }\n  });\n\n  return newLinks;\n}\n\nfunction TopSites(prevState = INITIAL_STATE.TopSites, action) {\n  let hasMatch;\n  let newRows;\n  switch (action.type) {\n    case at.TOP_SITES_UPDATED:\n      if (!action.data || !action.data.links) {\n        return prevState;\n      }\n      return Object.assign({}, prevState, {initialized: true, rows: action.data.links}, action.data.pref ? {pref: action.data.pref} : {});\n    case at.TOP_SITES_PREFS_UPDATED:\n      return Object.assign({}, prevState, {pref: action.data.pref});\n    case at.TOP_SITES_EDIT:\n      return Object.assign({}, prevState, {\n        editForm: {\n          index: action.data.index,\n          previewResponse: null,\n        },\n      });\n    case at.TOP_SITES_CANCEL_EDIT:\n      return Object.assign({}, prevState, {editForm: null});\n    case at.TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL:\n      return Object.assign({}, prevState, {showSearchShortcutsForm: true});\n    case at.TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL:\n      return Object.assign({}, prevState, {showSearchShortcutsForm: false});\n    case at.PREVIEW_RESPONSE:\n      if (!prevState.editForm || action.data.url !== prevState.editForm.previewUrl) {\n        return prevState;\n      }\n      return Object.assign({}, prevState, {\n        editForm: {\n          index: prevState.editForm.index,\n          previewResponse: action.data.preview,\n          previewUrl: action.data.url,\n        },\n      });\n    case at.PREVIEW_REQUEST:\n      if (!prevState.editForm) {\n        return prevState;\n      }\n      return Object.assign({}, prevState, {\n        editForm: {\n          index: prevState.editForm.index,\n          previewResponse: null,\n          previewUrl: action.data.url,\n        },\n      });\n    case at.PREVIEW_REQUEST_CANCEL:\n      if (!prevState.editForm) {\n        return prevState;\n      }\n      return Object.assign({}, prevState, {\n        editForm: {\n          index: prevState.editForm.index,\n          previewResponse: null,\n        },\n      });\n    case at.SCREENSHOT_UPDATED:\n      newRows = prevState.rows.map(row => {\n        if (row && row.url === action.data.url) {\n          hasMatch = true;\n          return Object.assign({}, row, {screenshot: action.data.screenshot});\n        }\n        return row;\n      });\n      return hasMatch ? Object.assign({}, prevState, {rows: newRows}) : prevState;\n    case at.PLACES_BOOKMARK_ADDED:\n      if (!action.data) {\n        return prevState;\n      }\n      newRows = prevState.rows.map(site => {\n        if (site && site.url === action.data.url) {\n          const {bookmarkGuid, bookmarkTitle, dateAdded} = action.data;\n          return Object.assign({}, site, {bookmarkGuid, bookmarkTitle, bookmarkDateCreated: dateAdded});\n        }\n        return site;\n      });\n      return Object.assign({}, prevState, {rows: newRows});\n    case at.PLACES_BOOKMARK_REMOVED:\n      if (!action.data) {\n        return prevState;\n      }\n      newRows = prevState.rows.map(site => {\n        if (site && site.url === action.data.url) {\n          const newSite = Object.assign({}, site);\n          delete newSite.bookmarkGuid;\n          delete newSite.bookmarkTitle;\n          delete newSite.bookmarkDateCreated;\n          return newSite;\n        }\n        return site;\n      });\n      return Object.assign({}, prevState, {rows: newRows});\n    case at.PLACES_LINK_DELETED:\n      if (!action.data) {\n        return prevState;\n      }\n      newRows = prevState.rows.filter(site => action.data.url !== site.url);\n      return Object.assign({}, prevState, {rows: newRows});\n    case at.UPDATE_SEARCH_SHORTCUTS:\n      return {...prevState, searchShortcuts: action.data.searchShortcuts};\n    case at.SNIPPETS_PREVIEW_MODE:\n      return {...prevState, rows: []};\n    default:\n      return prevState;\n  }\n}\n\nfunction Dialog(prevState = INITIAL_STATE.Dialog, action) {\n  switch (action.type) {\n    case at.DIALOG_OPEN:\n      return Object.assign({}, prevState, {visible: true, data: action.data});\n    case at.DIALOG_CANCEL:\n      return Object.assign({}, prevState, {visible: false});\n    case at.DELETE_HISTORY_URL:\n      return Object.assign({}, INITIAL_STATE.Dialog);\n    default:\n      return prevState;\n  }\n}\n\nfunction Prefs(prevState = INITIAL_STATE.Prefs, action) {\n  let newValues;\n  switch (action.type) {\n    case at.PREFS_INITIAL_VALUES:\n      return Object.assign({}, prevState, {initialized: true, values: action.data});\n    case at.PREF_CHANGED:\n      newValues = Object.assign({}, prevState.values);\n      newValues[action.data.name] = action.data.value;\n      return Object.assign({}, prevState, {values: newValues});\n    default:\n      return prevState;\n  }\n}\n\nfunction Sections(prevState = INITIAL_STATE.Sections, action) {\n  let hasMatch;\n  let newState;\n  switch (action.type) {\n    case at.SECTION_DEREGISTER:\n      return prevState.filter(section => section.id !== action.data);\n    case at.SECTION_REGISTER:\n      // If section exists in prevState, update it\n      newState = prevState.map(section => {\n        if (section && section.id === action.data.id) {\n          hasMatch = true;\n          return Object.assign({}, section, action.data);\n        }\n        return section;\n      });\n      // Otherwise, append it\n      if (!hasMatch) {\n        const initialized = !!(action.data.rows && action.data.rows.length > 0);\n        const section = Object.assign({title: \"\", rows: [], enabled: false}, action.data, {initialized});\n        newState.push(section);\n      }\n      return newState;\n    case at.SECTION_UPDATE:\n      newState = prevState.map(section => {\n        if (section && section.id === action.data.id) {\n          // If the action is updating rows, we should consider initialized to be true.\n          // This can be overridden if initialized is defined in the action.data\n          const initialized = action.data.rows ? {initialized: true} : {};\n\n          // Make sure pinned cards stay at their current position when rows are updated.\n          // Disabling a section (SECTION_UPDATE with empty rows) does not retain pinned cards.\n          if (action.data.rows && action.data.rows.length > 0 && section.rows.find(card => card.pinned)) {\n            const rows = Array.from(action.data.rows);\n            section.rows.forEach((card, index) => {\n              if (card.pinned) {\n                rows.splice(index, 0, card);\n              }\n            });\n            return Object.assign({}, section, initialized, Object.assign({}, action.data, {rows}));\n          }\n\n          return Object.assign({}, section, initialized, action.data);\n        }\n        return section;\n      });\n\n      if (!action.data.dedupeConfigurations) {\n        return newState;\n      }\n\n      action.data.dedupeConfigurations.forEach(dedupeConf => {\n        newState = newState.map(section => {\n          if (section.id === dedupeConf.id) {\n            const dedupedRows = dedupeConf.dedupeFrom.reduce((rows, dedupeSectionId) => {\n              const dedupeSection = newState.find(s => s.id === dedupeSectionId);\n              const [, newRows] = dedupe.group(dedupeSection.rows, rows);\n              return newRows;\n            }, section.rows);\n\n            return Object.assign({}, section, {rows: dedupedRows});\n          }\n\n          return section;\n        });\n      });\n\n      return newState;\n    case at.SECTION_UPDATE_CARD:\n      return prevState.map(section => {\n        if (section && section.id === action.data.id && section.rows) {\n          const newRows = section.rows.map(card => {\n            if (card.url === action.data.url) {\n              return Object.assign({}, card, action.data.options);\n            }\n            return card;\n          });\n          return Object.assign({}, section, {rows: newRows});\n        }\n        return section;\n      });\n    case at.PLACES_BOOKMARK_ADDED:\n      if (!action.data) {\n        return prevState;\n      }\n      return prevState.map(section => Object.assign({}, section, {\n        rows: section.rows.map(item => {\n          // find the item within the rows that is attempted to be bookmarked\n          if (item.url === action.data.url) {\n            const {bookmarkGuid, bookmarkTitle, dateAdded} = action.data;\n            return Object.assign({}, item, {\n              bookmarkGuid,\n              bookmarkTitle,\n              bookmarkDateCreated: dateAdded,\n              type: \"bookmark\",\n            });\n          }\n          return item;\n        }),\n      }));\n    case at.PLACES_SAVED_TO_POCKET:\n      if (!action.data) {\n        return prevState;\n      }\n      return prevState.map(section => Object.assign({}, section, {\n        rows: section.rows.map(item => {\n          if (item.url === action.data.url) {\n            return Object.assign({}, item, {\n              open_url: action.data.open_url,\n              pocket_id: action.data.pocket_id,\n              title: action.data.title,\n              type: \"pocket\",\n            });\n          }\n          return item;\n        }),\n      }));\n    case at.PLACES_BOOKMARK_REMOVED:\n      if (!action.data) {\n        return prevState;\n      }\n      return prevState.map(section => Object.assign({}, section, {\n        rows: section.rows.map(item => {\n          // find the bookmark within the rows that is attempted to be removed\n          if (item.url === action.data.url) {\n            const newSite = Object.assign({}, item);\n            delete newSite.bookmarkGuid;\n            delete newSite.bookmarkTitle;\n            delete newSite.bookmarkDateCreated;\n            if (!newSite.type || newSite.type === \"bookmark\") {\n              newSite.type = \"history\";\n            }\n            return newSite;\n          }\n          return item;\n        }),\n      }));\n    case at.PLACES_LINK_DELETED:\n    case at.PLACES_LINK_BLOCKED:\n      if (!action.data) {\n        return prevState;\n      }\n      return prevState.map(section =>\n        Object.assign({}, section, {rows: section.rows.filter(site => site.url !== action.data.url)}));\n    case at.DELETE_FROM_POCKET:\n    case at.ARCHIVE_FROM_POCKET:\n      return prevState.map(section =>\n        Object.assign({}, section, {rows: section.rows.filter(site => site.pocket_id !== action.data.pocket_id)}));\n    case at.SNIPPETS_PREVIEW_MODE:\n      return prevState.map(section => ({...section, rows: []}));\n    default:\n      return prevState;\n  }\n}\n\nfunction Snippets(prevState = INITIAL_STATE.Snippets, action) {\n  switch (action.type) {\n    case at.SNIPPETS_DATA:\n      return Object.assign({}, prevState, {initialized: true}, action.data);\n    case at.SNIPPET_BLOCKED:\n      return Object.assign({}, prevState, {blockList: prevState.blockList.concat(action.data)});\n    case at.SNIPPETS_BLOCKLIST_CLEARED:\n      return Object.assign({}, prevState, {blockList: []});\n    case at.SNIPPETS_RESET:\n      return INITIAL_STATE.Snippets;\n    default:\n      return prevState;\n  }\n}\n\nfunction Pocket(prevState = INITIAL_STATE.Pocket, action) {\n  switch (action.type) {\n    case at.POCKET_WAITING_FOR_SPOC:\n      return {...prevState, waitingForSpoc: action.data};\n    case at.POCKET_LOGGED_IN:\n      return {...prevState, isUserLoggedIn: !!action.data};\n    case at.POCKET_CTA:\n      return {\n        ...prevState,\n        pocketCta: {\n          ctaButton: action.data.cta_button,\n          ctaText: action.data.cta_text,\n          ctaUrl: action.data.cta_url,\n          useCta: action.data.use_cta,\n        },\n      };\n    default:\n      return prevState;\n  }\n}\n\nthis.INITIAL_STATE = INITIAL_STATE;\nthis.TOP_SITES_DEFAULT_ROWS = TOP_SITES_DEFAULT_ROWS;\nthis.TOP_SITES_MAX_SITES_PER_ROW = TOP_SITES_MAX_SITES_PER_ROW;\n\nthis.reducers = {TopSites, App, ASRouter, Snippets, Prefs, Dialog, Sections, Pocket};\n\nconst EXPORTED_SYMBOLS = [\"reducers\", \"INITIAL_STATE\", \"insertPinned\", \"TOP_SITES_DEFAULT_ROWS\", \"TOP_SITES_MAX_SITES_PER_ROW\"];\n","import React from \"react\";\n\nexport class ModalOverlay extends React.PureComponent {\n  componentWillMount() {\n    this.setState({active: true});\n    document.body.classList.add(\"modal-open\");\n  }\n\n  componentWillUnmount() {\n    document.body.classList.remove(\"modal-open\");\n    this.setState({active: false});\n  }\n\n  render() {\n    const {active} = this.state;\n    const {title, button_label} = this.props;\n    return (\n      <div>\n        <div className={`modalOverlayOuter ${active ? \"active\" : \"\"}`} />\n        <div className={`modalOverlayInner ${active ? \"active\" : \"\"}`}>\n          <h2> {title} </h2>\n          {this.props.children}\n          <div className=\"footer\">\n            <button tabIndex=\"2\" onClick={this.props.onDoneButton} className=\"button primary modalButton\"> {button_label} </button>\n          </div>\n        </div>\n      </div>\n    );\n  }\n}\n","import {ModalOverlay} from \"../../components/ModalOverlay/ModalOverlay\";\nimport React from \"react\";\n\nclass OnboardingCard extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onClick = this.onClick.bind(this);\n  }\n\n  onClick() {\n    const {props} = this;\n    const ping = {\n      event: \"CLICK_BUTTON\",\n      message_id: props.id,\n      id: props.UISurface,\n      includeClientID: true,\n    };\n    props.sendUserActionTelemetry(ping);\n    props.onAction(props.content.button_action);\n  }\n\n  render() {\n    const {content} = this.props;\n    return (\n      <div className=\"onboardingMessage\">\n        <div className={`onboardingMessageImage ${content.icon}`} />\n        <div className=\"onboardingContent\">\n          <span>\n            <h3> {content.title} </h3>\n            <p> {content.text} </p>\n          </span>\n          <span>\n            <button tabIndex=\"1\" className=\"button onboardingButton\" onClick={this.onClick}> {content.button_label} </button>\n          </span>\n        </div>\n      </div>\n    );\n  }\n}\n\nexport class OnboardingMessage extends React.PureComponent {\n  render() {\n    const {props} = this;\n    const {button_label, header} = props.extraTemplateStrings;\n    return (\n      <ModalOverlay {...props} button_label={button_label} title={header}>\n        <div className=\"onboardingMessageContainer\">\n          {props.bundle.map(message => (\n            <OnboardingCard key={message.id}\n              sendUserActionTelemetry={props.sendUserActionTelemetry}\n              onAction={props.onAction}\n              UISurface={props.UISurface}\n              {...message} />\n          ))}\n        </div>\n      </ModalOverlay>\n    );\n  }\n}\n","export const cardContextTypes = {\n  history: {\n    intlID: \"type_label_visited\",\n    icon: \"history-item\",\n  },\n  bookmark: {\n    intlID: \"type_label_bookmarked\",\n    icon: \"bookmark-added\",\n  },\n  trending: {\n    intlID: \"type_label_recommended\",\n    icon: \"trending\",\n  },\n  now: {\n    intlID: \"type_label_now\",\n    icon: \"now\",\n  },\n  pocket: {\n    intlID: \"type_label_pocket\",\n    icon: \"pocket\",\n  },\n  download: {\n    intlID: \"type_label_downloaded\",\n    icon: \"download\",\n  },\n};\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {cardContextTypes} from \"./types\";\nimport {connect} from \"react-redux\";\nimport {FormattedMessage} from \"react-intl\";\nimport {GetPlatformString} from \"content-src/lib/link-menu-options\";\nimport {LinkMenu} from \"content-src/components/LinkMenu/LinkMenu\";\nimport React from \"react\";\nimport {ScreenshotUtils} from \"content-src/lib/screenshot-utils\";\n\n// Keep track of pending image loads to only request once\nconst gImageLoading = new Map();\n\n/**\n * Card component.\n * Cards are found within a Section component and contain information about a link such\n * as preview image, page title, page description, and some context about if the page\n * was visited, bookmarked, trending etc...\n * Each Section can make an unordered list of Cards which will create one instane of\n * this class. Each card will then get a context menu which reflects the actions that\n * can be done on this Card.\n */\nexport class _Card extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {\n      activeCard: null,\n      imageLoaded: false,\n      showContextMenu: false,\n      cardImage: null,\n    };\n    this.onMenuButtonClick = this.onMenuButtonClick.bind(this);\n    this.onMenuUpdate = this.onMenuUpdate.bind(this);\n    this.onLinkClick = this.onLinkClick.bind(this);\n  }\n\n  /**\n   * Helper to conditionally load an image and update state when it loads.\n   */\n  async maybeLoadImage() {\n    // No need to load if it's already loaded or no image\n    const {cardImage} = this.state;\n    if (!cardImage) {\n      return;\n    }\n\n    const imageUrl = cardImage.url;\n    if (!this.state.imageLoaded) {\n      // Initialize a promise to share a load across multiple card updates\n      if (!gImageLoading.has(imageUrl)) {\n        const loaderPromise = new Promise((resolve, reject) => {\n          const loader = new Image();\n          loader.addEventListener(\"load\", resolve);\n          loader.addEventListener(\"error\", reject);\n          loader.src = imageUrl;\n        });\n\n        // Save and remove the promise only while it's pending\n        gImageLoading.set(imageUrl, loaderPromise);\n        loaderPromise.catch(ex => ex).then(() => gImageLoading.delete(imageUrl)).catch();\n      }\n\n      // Wait for the image whether just started loading or reused promise\n      await gImageLoading.get(imageUrl);\n\n      // Only update state if we're still waiting to load the original image\n      if (ScreenshotUtils.isRemoteImageLocal(this.state.cardImage, this.props.link.image) &&\n          !this.state.imageLoaded) {\n        this.setState({imageLoaded: true});\n      }\n    }\n  }\n\n  /**\n   * Helper to obtain the next state based on nextProps and prevState.\n   *\n   * NOTE: Rename this method to getDerivedStateFromProps when we update React\n   *       to >= 16.3. We will need to update tests as well. We cannot rename this\n   *       method to getDerivedStateFromProps now because there is a mismatch in\n   *       the React version that we are using for both testing and production.\n   *       (i.e. react-test-render => \"16.3.2\", react => \"16.2.0\").\n   *\n   * See https://github.com/airbnb/enzyme/blob/master/packages/enzyme-adapter-react-16/package.json#L43.\n   */\n  static getNextStateFromProps(nextProps, prevState) {\n    const {image} = nextProps.link;\n    const imageInState = ScreenshotUtils.isRemoteImageLocal(prevState.cardImage, image);\n    let nextState = null;\n\n    // Image is updating.\n    if (!imageInState && nextProps.link) {\n      nextState = {imageLoaded: false};\n    }\n\n    if (imageInState) {\n      return nextState;\n    }\n\n    // Since image was updated, attempt to revoke old image blob URL, if it exists.\n    ScreenshotUtils.maybeRevokeBlobObjectURL(prevState.cardImage);\n\n    nextState = nextState || {};\n    nextState.cardImage = ScreenshotUtils.createLocalImageObject(image);\n\n    return nextState;\n  }\n\n  onMenuButtonClick(event) {\n    event.preventDefault();\n    this.setState({\n      activeCard: this.props.index,\n      showContextMenu: true,\n    });\n  }\n\n  /**\n   * Report to telemetry additional information about the item.\n   */\n  _getTelemetryInfo() {\n    // Filter out \"history\" type for being the default\n    if (this.props.link.type !== \"history\") {\n      return {value: {card_type: this.props.link.type}};\n    }\n\n    return null;\n  }\n\n  onLinkClick(event) {\n    event.preventDefault();\n    if (this.props.link.type === \"download\") {\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.SHOW_DOWNLOAD_FILE,\n        data: this.props.link,\n      }));\n    } else {\n      const {altKey, button, ctrlKey, metaKey, shiftKey} = event;\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.OPEN_LINK,\n        data: Object.assign(this.props.link, {event: {altKey, button, ctrlKey, metaKey, shiftKey}}),\n      }));\n    }\n    if (this.props.isWebExtension) {\n      this.props.dispatch(ac.WebExtEvent(at.WEBEXT_CLICK, {\n        source: this.props.eventSource,\n        url: this.props.link.url,\n        action_position: this.props.index,\n      }));\n    } else {\n      this.props.dispatch(ac.UserEvent(Object.assign({\n        event: \"CLICK\",\n        source: this.props.eventSource,\n        action_position: this.props.index,\n      }, this._getTelemetryInfo())));\n\n      if (this.props.shouldSendImpressionStats) {\n        this.props.dispatch(ac.ImpressionStats({\n          source: this.props.eventSource,\n          click: 0,\n          tiles: [{id: this.props.link.guid, pos: this.props.index}],\n        }));\n      }\n    }\n  }\n\n  onMenuUpdate(showContextMenu) {\n    this.setState({showContextMenu});\n  }\n\n  componentDidMount() {\n    this.maybeLoadImage();\n  }\n\n  componentDidUpdate() {\n    this.maybeLoadImage();\n  }\n\n  // NOTE: Remove this function when we update React to >= 16.3 since React will\n  //       call getDerivedStateFromProps automatically. We will also need to\n  //       rename getNextStateFromProps to getDerivedStateFromProps.\n  componentWillMount() {\n    const nextState = _Card.getNextStateFromProps(this.props, this.state);\n    if (nextState) {\n      this.setState(nextState);\n    }\n  }\n\n  // NOTE: Remove this function when we update React to >= 16.3 since React will\n  //       call getDerivedStateFromProps automatically. We will also need to\n  //       rename getNextStateFromProps to getDerivedStateFromProps.\n  componentWillReceiveProps(nextProps) {\n    const nextState = _Card.getNextStateFromProps(nextProps, this.state);\n    if (nextState) {\n      this.setState(nextState);\n    }\n  }\n\n  componentWillUnmount() {\n    ScreenshotUtils.maybeRevokeBlobObjectURL(this.state.cardImage);\n  }\n\n  render() {\n    const {index, className, link, dispatch, contextMenuOptions, eventSource, shouldSendImpressionStats} = this.props;\n    const {props} = this;\n    const isContextMenuOpen = this.state.showContextMenu && this.state.activeCard === index;\n    // Display \"now\" as \"trending\" until we have new strings #3402\n    const {icon, intlID} = cardContextTypes[link.type === \"now\" ? \"trending\" : link.type] || {};\n    const hasImage = this.state.cardImage || link.hasImage;\n    const imageStyle = {backgroundImage: this.state.cardImage ? `url(${this.state.cardImage.url})` : \"none\"};\n    const outerClassName = [\n      \"card-outer\",\n      className,\n      isContextMenuOpen && \"active\",\n      props.placeholder && \"placeholder\",\n    ].filter(v => v).join(\" \");\n\n    return (<li className={outerClassName}>\n      <a href={link.type === \"pocket\" ? link.open_url : link.url} onClick={!props.placeholder ? this.onLinkClick : undefined}>\n        <div className=\"card\">\n          <div className=\"card-preview-image-outer\">\n            {hasImage &&\n              <div className={`card-preview-image${this.state.imageLoaded ? \" loaded\" : \"\"}`} style={imageStyle} />\n            }\n          </div>\n          <div className=\"card-details\">\n            {link.type === \"download\" && <div className=\"card-host-name alternate\"><FormattedMessage id={GetPlatformString(this.props.platform)} /></div>}\n            {link.hostname &&\n              <div className=\"card-host-name\">\n                {link.hostname.slice(0, 100)}{link.type === \"download\" && `  \\u2014 ${link.description}`}\n              </div>\n            }\n            <div className={[\n              \"card-text\",\n              icon ? \"\" : \"no-context\",\n              link.description ? \"\" : \"no-description\",\n              link.hostname ? \"\" : \"no-host-name\",\n            ].join(\" \")}>\n              <h4 className=\"card-title\" dir=\"auto\">{link.title}</h4>\n              <p className=\"card-description\" dir=\"auto\">{link.description}</p>\n            </div>\n            <div className=\"card-context\">\n              {icon && !link.context && <span className={`card-context-icon icon icon-${icon}`} />}\n              {link.icon && link.context && <span className=\"card-context-icon icon\" style={{backgroundImage: `url('${link.icon}')`}} />}\n              {intlID && !link.context && <div className=\"card-context-label\"><FormattedMessage id={intlID} defaultMessage=\"Visited\" /></div>}\n              {link.context && <div className=\"card-context-label\">{link.context}</div>}\n            </div>\n          </div>\n        </div>\n      </a>\n      {!props.placeholder && <button className=\"context-menu-button icon\"\n        onClick={this.onMenuButtonClick}>\n        <span className=\"sr-only\">{`Open context menu for ${link.title}`}</span>\n      </button>}\n      {isContextMenuOpen &&\n        <LinkMenu\n          dispatch={dispatch}\n          index={index}\n          source={eventSource}\n          onUpdate={this.onMenuUpdate}\n          options={link.contextMenuOptions || contextMenuOptions}\n          site={link}\n          siteInfo={this._getTelemetryInfo()}\n          shouldSendImpressionStats={shouldSendImpressionStats} />\n      }\n   </li>);\n  }\n}\n_Card.defaultProps = {link: {}};\nexport const Card = connect(state => ({platform: state.Prefs.values.platform}))(_Card);\nexport const PlaceholderCard = props => <Card placeholder={true} className={props.className} />;\n","import {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class TopSiteFormInput extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {validationError: this.props.validationError};\n    this.onChange = this.onChange.bind(this);\n    this.onMount = this.onMount.bind(this);\n  }\n\n  componentWillReceiveProps(nextProps) {\n    if (nextProps.shouldFocus && !this.props.shouldFocus) {\n      this.input.focus();\n    }\n    if (nextProps.validationError && !this.props.validationError) {\n      this.setState({validationError: true});\n    }\n    // If the component is in an error state but the value was cleared by the parent\n    if (this.state.validationError && !nextProps.value) {\n      this.setState({validationError: false});\n    }\n  }\n\n  onChange(ev) {\n    if (this.state.validationError) {\n      this.setState({validationError: false});\n    }\n    this.props.onChange(ev);\n  }\n\n  onMount(input) {\n    this.input = input;\n  }\n\n  render() {\n    const showClearButton = this.props.value && this.props.onClear;\n    const {typeUrl} = this.props;\n    const {validationError} = this.state;\n\n    return (<label><FormattedMessage id={this.props.titleId} />\n      <div className={`field ${typeUrl ? \"url\" : \"\"}${validationError ? \" invalid\" : \"\"}`}>\n        {this.props.loading ?\n          <div className=\"loading-container\"><div className=\"loading-animation\" /></div> :\n          showClearButton && <div className=\"icon icon-clear-input\" onClick={this.props.onClear} />}\n        <input type=\"text\"\n          value={this.props.value}\n          ref={this.onMount}\n          onChange={this.onChange}\n          placeholder={this.props.intl.formatMessage({id: this.props.placeholderId})}\n          autoFocus={this.props.shouldFocus}\n          disabled={this.props.loading} />\n        {validationError &&\n          <aside className=\"error-tooltip\">\n            <FormattedMessage id={this.props.errorMessageId} />\n          </aside>}\n      </div>\n    </label>);\n  }\n}\n\nTopSiteFormInput.defaultProps = {\n  showClearButton: false,\n  value: \"\",\n  validationError: false,\n};\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\nimport {TOP_SITES_SOURCE} from \"./TopSitesConstants\";\nimport {TopSiteFormInput} from \"./TopSiteFormInput\";\nimport {TopSiteLink} from \"./TopSite\";\n\nexport class TopSiteForm extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    const {site} = props;\n    this.state = {\n      label: site ? (site.label || site.hostname) : \"\",\n      url: site ? site.url : \"\",\n      validationError: false,\n      customScreenshotUrl: site ? site.customScreenshotURL : \"\",\n      showCustomScreenshotForm: site ? site.customScreenshotURL : false,\n    };\n    this.onClearScreenshotInput = this.onClearScreenshotInput.bind(this);\n    this.onLabelChange = this.onLabelChange.bind(this);\n    this.onUrlChange = this.onUrlChange.bind(this);\n    this.onCancelButtonClick = this.onCancelButtonClick.bind(this);\n    this.onClearUrlClick = this.onClearUrlClick.bind(this);\n    this.onDoneButtonClick = this.onDoneButtonClick.bind(this);\n    this.onCustomScreenshotUrlChange = this.onCustomScreenshotUrlChange.bind(this);\n    this.onPreviewButtonClick = this.onPreviewButtonClick.bind(this);\n    this.onEnableScreenshotUrlForm = this.onEnableScreenshotUrlForm.bind(this);\n    this.validateUrl = this.validateUrl.bind(this);\n  }\n\n  onLabelChange(event) {\n    this.setState({\"label\": event.target.value});\n  }\n\n  onUrlChange(event) {\n    this.setState({\n      url: event.target.value,\n      validationError: false,\n    });\n  }\n\n  onClearUrlClick() {\n    this.setState({\n      url: \"\",\n      validationError: false,\n    });\n  }\n\n  onEnableScreenshotUrlForm() {\n    this.setState({showCustomScreenshotForm: true});\n  }\n\n  _updateCustomScreenshotInput(customScreenshotUrl) {\n    this.setState({\n      customScreenshotUrl,\n      validationError: false,\n    });\n    this.props.dispatch({type: at.PREVIEW_REQUEST_CANCEL});\n  }\n\n  onCustomScreenshotUrlChange(event) {\n    this._updateCustomScreenshotInput(event.target.value);\n  }\n\n  onClearScreenshotInput() {\n    this._updateCustomScreenshotInput(\"\");\n  }\n\n  onCancelButtonClick(ev) {\n    ev.preventDefault();\n    this.props.onClose();\n  }\n\n  onDoneButtonClick(ev) {\n    ev.preventDefault();\n\n    if (this.validateForm()) {\n      const site = {url: this.cleanUrl(this.state.url)};\n      const {index} = this.props;\n      if (this.state.label !== \"\") {\n        site.label = this.state.label;\n      }\n\n      if (this.state.customScreenshotUrl) {\n        site.customScreenshotURL = this.cleanUrl(this.state.customScreenshotUrl);\n      } else if (this.props.site && this.props.site.customScreenshotURL) {\n        // Used to flag that previously cached screenshot should be removed\n        site.customScreenshotURL = null;\n      }\n      this.props.dispatch(ac.AlsoToMain({\n        type: at.TOP_SITES_PIN,\n        data: {site, index},\n      }));\n      this.props.dispatch(ac.UserEvent({\n        source: TOP_SITES_SOURCE,\n        event: \"TOP_SITES_EDIT\",\n        action_position: index,\n      }));\n\n      this.props.onClose();\n    }\n  }\n\n  onPreviewButtonClick(event) {\n    event.preventDefault();\n    if (this.validateForm()) {\n      this.props.dispatch(ac.AlsoToMain({\n        type: at.PREVIEW_REQUEST,\n        data: {url: this.cleanUrl(this.state.customScreenshotUrl)},\n      }));\n      this.props.dispatch(ac.UserEvent({\n        source: TOP_SITES_SOURCE,\n        event: \"PREVIEW_REQUEST\",\n      }));\n    }\n  }\n\n  cleanUrl(url) {\n    // If we are missing a protocol, prepend http://\n    if (!url.startsWith(\"http:\") && !url.startsWith(\"https:\")) {\n      return `http://${url}`;\n    }\n    return url;\n  }\n\n  _tryParseUrl(url) {\n    try {\n      return new URL(url);\n    } catch (e) {\n      return null;\n    }\n  }\n\n  validateUrl(url) {\n    const validProtocols = [\"http:\", \"https:\"];\n    const urlObj = this._tryParseUrl(url) || this._tryParseUrl(this.cleanUrl(url));\n\n    return urlObj && validProtocols.includes(urlObj.protocol);\n  }\n\n  validateCustomScreenshotUrl() {\n    const {customScreenshotUrl} = this.state;\n    return !customScreenshotUrl || this.validateUrl(customScreenshotUrl);\n  }\n\n  validateForm() {\n    const validate = this.validateUrl(this.state.url) && this.validateCustomScreenshotUrl();\n\n    if (!validate) {\n      this.setState({validationError: true});\n    }\n\n    return validate;\n  }\n\n  _renderCustomScreenshotInput() {\n    const {customScreenshotUrl} = this.state;\n    const requestFailed = this.props.previewResponse === \"\";\n    const validationError = (this.state.validationError && !this.validateCustomScreenshotUrl()) || requestFailed;\n    // Set focus on error if the url field is valid or when the input is first rendered and is empty\n    const shouldFocus = (validationError && this.validateUrl(this.state.url)) || !customScreenshotUrl;\n    const isLoading = this.props.previewResponse === null &&\n      customScreenshotUrl && this.props.previewUrl === this.cleanUrl(customScreenshotUrl);\n\n    if (!this.state.showCustomScreenshotForm) {\n      return (<a className=\"enable-custom-image-input\" onClick={this.onEnableScreenshotUrlForm}>\n        <FormattedMessage id=\"topsites_form_use_image_link\" />\n      </a>);\n    }\n    return (<div className=\"custom-image-input-container\">\n      <TopSiteFormInput\n        errorMessageId={requestFailed ? \"topsites_form_image_validation\" : \"topsites_form_url_validation\"}\n        loading={isLoading}\n        onChange={this.onCustomScreenshotUrlChange}\n        onClear={this.onClearScreenshotInput}\n        shouldFocus={shouldFocus}\n        typeUrl={true}\n        value={customScreenshotUrl}\n        validationError={validationError}\n        titleId=\"topsites_form_image_url_label\"\n        placeholderId=\"topsites_form_url_placeholder\"\n        intl={this.props.intl} />\n    </div>);\n  }\n\n  render() {\n    const {customScreenshotUrl} = this.state;\n    const requestFailed = this.props.previewResponse === \"\";\n    // For UI purposes, editing without an existing link is \"add\"\n    const showAsAdd = !this.props.site;\n    const previous = (this.props.site && this.props.site.customScreenshotURL) || \"\";\n    const changed = customScreenshotUrl && this.cleanUrl(customScreenshotUrl) !== previous;\n    // Preview mode if changes were made to the custom screenshot URL and no preview was received yet\n    // or the request failed\n    const previewMode = changed && !this.props.previewResponse;\n    const previewLink = Object.assign({}, this.props.site);\n    if (this.props.previewResponse) {\n      previewLink.screenshot = this.props.previewResponse;\n      previewLink.customScreenshotURL = this.props.previewUrl;\n    }\n    return (\n      <form className=\"topsite-form\">\n        <div className=\"form-input-container\">\n          <h3 className=\"section-title\">\n            <FormattedMessage id={showAsAdd ? \"topsites_form_add_header\" : \"topsites_form_edit_header\"} />\n          </h3>\n          <div className=\"fields-and-preview\">\n            <div className=\"form-wrapper\">\n              <TopSiteFormInput onChange={this.onLabelChange}\n                value={this.state.label}\n                titleId=\"topsites_form_title_label\"\n                placeholderId=\"topsites_form_title_placeholder\"\n                intl={this.props.intl} />\n              <TopSiteFormInput onChange={this.onUrlChange}\n                shouldFocus={this.state.validationError && !this.validateUrl(this.state.url)}\n                value={this.state.url}\n                onClear={this.onClearUrlClick}\n                validationError={this.state.validationError && !this.validateUrl(this.state.url)}\n                titleId=\"topsites_form_url_label\"\n                typeUrl={true}\n                placeholderId=\"topsites_form_url_placeholder\"\n                errorMessageId=\"topsites_form_url_validation\"\n                intl={this.props.intl} />\n              {this._renderCustomScreenshotInput()}\n            </div>\n            <TopSiteLink link={previewLink}\n              defaultStyle={requestFailed}\n              title={this.state.label} />\n          </div>\n        </div>\n        <section className=\"actions\">\n          <button className=\"cancel\" type=\"button\" onClick={this.onCancelButtonClick}>\n            <FormattedMessage id=\"topsites_form_cancel_button\" />\n          </button>\n          {previewMode ?\n            <button className=\"done preview\" type=\"submit\" onClick={this.onPreviewButtonClick}>\n              <FormattedMessage id=\"topsites_form_preview_button\" />\n            </button> :\n            <button className=\"done\" type=\"submit\" onClick={this.onDoneButtonClick}>\n              <FormattedMessage id={showAsAdd ? \"topsites_form_add_button\" : \"topsites_form_save_button\"} />\n            </button>}\n        </section>\n      </form>\n    );\n  }\n}\n\nTopSiteForm.defaultProps = {\n  site: null,\n  index: -1,\n};\n"],"sourceRoot":""}
\ No newline at end of file
+{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./content-src/activity-stream.jsx","webpack:///(webpack)/buildin/global.js","webpack:///./common/Actions.jsm","webpack:///./content-src/lib/snippets.js","webpack:///./content-src/asrouter/asrouter-content.jsx","webpack:///external \"React\"","webpack:///external \"PropTypes\"","webpack:///./content-src/lib/init-store.js","webpack:///external \"Redux\"","webpack:///./content-src/asrouter/components/ImpressionsWrapper/ImpressionsWrapper.jsx","webpack:///external \"ReactDOM\"","webpack:///./content-src/asrouter/template-utils.js","webpack:///./content-src/components/Base/Base.jsx","webpack:///external \"ReactIntl\"","webpack:///./content-src/components/ASRouterAdmin/ASRouterAdmin.jsx","webpack:///./content-src/components/ConfirmDialog/ConfirmDialog.jsx","webpack:///external \"ReactRedux\"","webpack:///./content-src/components/ErrorBoundary/ErrorBoundary.jsx","webpack:///./content-src/components/ManualMigration/ManualMigration.jsx","webpack:///./common/PrerenderData.jsm","webpack:///./content-src/components/Search/Search.jsx","webpack:///./content-src/lib/constants.js","webpack:///./content-src/components/Sections/Sections.jsx","webpack:///./content-src/lib/link-menu-options.js","webpack:///./content-src/components/LinkMenu/LinkMenu.jsx","webpack:///./content-src/components/ContextMenu/ContextMenu.jsx","webpack:///./content-src/lib/screenshot-utils.js","webpack:///./content-src/components/CollapsibleSection/CollapsibleSection.jsx","webpack:///./content-src/components/SectionMenu/SectionMenu.jsx","webpack:///./content-src/lib/section-menu-options.js","webpack:///./content-src/components/ComponentPerfTimer/ComponentPerfTimer.jsx","webpack:///./common/PerfService.jsm","webpack:///./content-src/components/MoreRecommendations/MoreRecommendations.jsx","webpack:///./content-src/components/PocketLoggedInCta/PocketLoggedInCta.jsx","webpack:///./content-src/components/Topics/Topics.jsx","webpack:///./content-src/components/TopSites/TopSites.jsx","webpack:///./content-src/components/TopSites/TopSitesConstants.js","webpack:///./content-src/components/TopSites/SearchShortcutsForm.jsx","webpack:///./content-src/components/TopSites/TopSite.jsx","webpack:///./content-src/components/StartupOverlay/StartupOverlay.jsx","webpack:///./content-src/lib/detect-user-session-start.js","webpack:///./content-src/lib/asroutercontent.js","webpack:///./node_modules/fluent/src/parser.js","webpack:///./node_modules/fluent/src/types.js","webpack:///./node_modules/fluent/src/builtins.js","webpack:///./node_modules/fluent/src/resolver.js","webpack:///./node_modules/fluent/src/context.js","webpack:///./node_modules/fluent/src/cached_iterable.js","webpack:///./node_modules/fluent/src/fallback.js","webpack:///./node_modules/fluent/src/util.js","webpack:///./node_modules/fluent/src/index.js","webpack:///./node_modules/fluent-react/src/localization.js","webpack:///./node_modules/fluent-react/src/provider.js","webpack:///./node_modules/fluent-react/src/with_localization.js","webpack:///./node_modules/fluent-react/src/markup.js","webpack:///./node_modules/fluent-react/vendor/omittedCloseTags.js","webpack:///./node_modules/fluent-react/vendor/voidElementTags.js","webpack:///./node_modules/fluent-react/src/localized.js","webpack:///./node_modules/fluent-react/src/index.js","webpack:///./content-src/asrouter/components/Button/Button.jsx","webpack:///./content-src/asrouter/components/SnippetBase/SnippetBase.jsx","webpack:///./content-src/asrouter/templates/SimpleSnippet/SimpleSnippet.jsx","webpack:///./common/Dedupe.jsm","webpack:///./common/Reducers.jsm","webpack:///./content-src/asrouter/components/ModalOverlay/ModalOverlay.jsx","webpack:///./content-src/asrouter/templates/OnboardingMessage/OnboardingMessage.jsx","webpack:///./content-src/components/Card/types.js","webpack:///./content-src/components/Card/Card.jsx","webpack:///./content-src/components/TopSites/TopSiteFormInput.jsx","webpack:///./content-src/components/TopSites/TopSiteForm.jsx"],"names":["store","initStore","global","gActivityStreamPrerenderedState","asrouterContent","sendEventOrAddListener","dispatch","ac","AlsoToMain","type","at","NEW_TAB_STATE_REQUEST","ReactDOM","hydrate","document","location","href","documentElement","lang","gActivityStreamStrings","getElementById","enableASRouterContent","addSnippetsSubscriber","globalImportContext","Window","BACKGROUND_PROCESS","UI_CODE","actionTypes","ASRouterActions","_RouteMessage","action","options","meta","from","to","Error","forEach","o","fromTarget","skipLocal","CONTENT_MESSAGE_TYPE","MAIN_MESSAGE_TYPE","OnlyToMain","BroadcastToContent","AlsoToOneContent","target","skipMain","toTarget","OnlyToOneContent","AlsoToPreloaded","PRELOAD_MESSAGE_TYPE","UserEvent","data","TELEMETRY_USER_EVENT","ASRouterUserEvent","AS_ROUTER_TELEMETRY_USER_EVENT","UndesiredEvent","importContext","TELEMETRY_UNDESIRED_EVENT","PerfEvent","TELEMETRY_PERFORMANCE_EVENT","ImpressionStats","TELEMETRY_IMPRESSION_STATS","SetPref","name","value","SET_PREF","WebExtEvent","source","isSendToMain","isBroadcastToContent","isSendToOneContent","isSendToPreloaded","isFromMain","getPortIdOfSender","DATABASE_NAME","DATABASE_VERSION","SNIPPETS_OBJECTSTORE_NAME","SNIPPETS_UPDATE_INTERVAL_MS","SNIPPETS_ENABLED_EVENT","SNIPPETS_DISABLED_EVENT","SnippetsMap","Map","constructor","_db","_dispatch","set","key","_dbTransaction","db","put","delete","clear","SNIPPETS_BLOCKLIST_CLEARED","blockList","get","blockSnippetById","id","includes","push","SNIPPETS_BLOCKLIST_UPDATED","disableOnboarding","DISABLE_ONBOARDING","showFirefoxAccounts","SHOW_FIREFOX_ACCOUNTS","getTotalBookmarksCount","Promise","resolve","TOTAL_BOOKMARKS_REQUEST","RPMAddMessageListener","onMessage","TOTAL_BOOKMARKS_RESPONSE","RPMRemoveMessageListener","getAddonsInfo","ADDONS_INFO_REQUEST","ADDONS_INFO_RESPONSE","connect","_openDB","_restoreFromDb","modifier","reject","transaction","objectStore","onsuccess","event","onerror","error","openRequest","indexedDB","open","deleteDatabase","onupgradeneeded","result","objectStoreNames","contains","createObjectStore","err","console","onversionchange","versionChangeEvent","close","cursorRequest","openCursor","cursor","continue","SnippetsProvider","gSnippetsMap","_onAction","bind","snippetsMap","_refreshSnippets","cachedVersion","appData","version","lastUpdate","needsUpdate","Date","now","snippetsURL","response","fetch","status","payload","text","e","_noSnippetFallback","_forceOnboardingVisibility","shouldBeVisible","onboardingEl","style","display","_showRemoteSnippets","snippetsEl","elementId","innerHTML","scriptEl","getElementsByTagName","relocatedScript","createElement","parentNode","replaceChild","msg","SNIPPET_BLOCKED","concat","init","Object","assign","keys","window","dispatchEvent","Event","initialized","uninit","snippets","initializing","subscribe","state","getState","Prefs","values","ASRouter","allowLegacySnippets","disableSnippets","Snippets","log","INCOMING_MESSAGE_NAME","OUTGOING_MESSAGE_NAME","ASR_CONTAINER_ID","ASRouterUtils","addListener","listener","removeListener","sendMessage","RPMSendAsyncMessage","blockById","blockBundle","bundle","executeAction","button_action","unblockById","unblockBundle","overrideMessage","sendTelemetry","ping","getPreviewEndpoint","params","URLSearchParams","slice","indexOf","endpoint","URL","url","snippetId","shouldSendImpressionOnUpdate","nextProps","prevProps","message","generateMessages","content","cx","addMessages","ALLOWED_TAGS","b","i","u","strong","em","br","convertLinks","links","sendClick","reduce","acc","linkTag","safeURI","metric","RichText","props","ASRouterUISurface","React","PureComponent","onMessageFromParent","sendImpression","sendUserActionTelemetry","extraProps","message_id","eventType","provider","dataset","do_not_autoblock","onBlockById","clearBundle","setState","componentWillMount","trigger","componentWillUnmount","renderSnippets","renderOnboarding","renderPreviewBanner","render","template","defaultProps","ASRouterContent","containerElement","_mount","zIndex","body","appendChild","_unmount","unmountComponentAtNode","MERGE_STORE_ACTION","EARLY_QUEUED_ACTIONS","SAVE_SESSION_PERF_DATA","PAGE_PRERENDERED","mergeStateReducer","mainReducer","prevState","messageMiddleware","next","au","rehydrationMiddleware","_didRehydrate","isMergeStoreAction","isRehydrationRequest","_didRequestInitialState","INIT","queueEarlyMessageMiddleware","_receivedFromMain","_earlyActionQueue","reducers","initialState","createStore","combineReducers","applyMiddleware","ex","dump","JSON","stringify","stack","VISIBLE","VISIBILITY_CHANGE_EVENT","ImpressionsWrapper","sendImpressionOrAddListener","visibilityState","_onVisibilityChange","removeEventListener","addEventListener","componentDidMount","sendOnMount","componentDidUpdate","children","protocol","isAllowed","warn","PrefsButton","injectIntl","onClick","intl","formatMessage","addLocaleDataForReactIntl","locale","addLocaleData","parentLocale","debounce","func","wait","timer","args","wakeUp","setTimeout","apply","_Base","isFirstrun","classList","add","isPrerendered","updateTheme","componentWillUpdate","bodyClassName","filter","v","join","className","App","strings","prefs","hash","BaseContent","openPreferences","onWindowScroll","fixedSearch","SCROLL_THRESHOLD","scrollY","SETTINGS_OPEN","shouldBeFixedToTop","PrerenderData","arePrefsValid","noSectionsEnabled","Sections","section","enabled","length","outerClassName","showSearch","migrationExpired","Base","ASRouterAdmin","findOtherBundledMessagesOfSameTemplate","messages","bundled","handleBlock","handleUnblock","handleOverride","expireCache","renderMessageItem","isCurrent","lastMessageId","isBlocked","messageBlockList","impressions","messageImpressions","itemClassName","renderMessages","map","renderTableHead","renderProviders","providers","label","bucket","lastUpdated","toString","_ConfirmDialog","_handleCancelBtn","_handleConfirmBtn","DIALOG_CANCEL","eventSource","onConfirm","_renderModalMessage","message_body","body_string_id","visible","icon","cancel_button_string_id","confirm_button_string_id","ConfirmDialog","Dialog","ErrorBoundaryFallback","windowObj","reload","defaultClass","ErrorBoundary","hasError","componentDidCatch","info","FallbackComponent","_ManualMigration","onLaunchTour","onCancelTour","MIGRATION_START","MIGRATION_CANCEL","ManualMigration","_PrerenderData","initialPrefs","initialSections","_setValidation","validation","_validation","invalidatingPrefs","_invalidatingPrefs","oneOf","getPref","indexedDBPrefs","some","anyModifiedPrefs","prefName","pref","order","title","_Search","onInputMount","handleEvent","detail","gContentSearchController","search","input","healthReportKey","IS_NEWTAB","searchSource","ContentSearchUIController","showLogo","Search","documentURI","CARDS_PER_ROW_DEFAULT","CARDS_PER_ROW_COMPACT_WIDE","getFormattedMessage","Section","numRows","rowsPref","maxRows","_dispatchImpressionStats","cardsPerRow","compactCards","matchMedia","matches","maxCards","cards","rows","needsImpressionStats","tiles","link","guid","impressionCardGuids","sendImpressionStatsOrAddListener","shouldSendImpressionStats","collapsed","sendNewTabRehydrated","isCollapsed","wasCollapsed","renderNotified","NEW_TAB_REHYDRATED","Pocket","topics","emptyState","read_more_endpoint","contextMenuOptions","learnMore","privacyNoticeURL","isFirst","isLast","waitingForSpoc","maxCardsPerRow","maxCardsOnNarrow","pocketCta","isUserLoggedIn","useCta","isPocketLoggedInDefined","shouldShowPocketCta","shouldShowTopics","realRows","shouldShowEmptyState","usePlaceholder","isWebExtension","sectionClassName","feed","padding","startsWith","SectionIntl","_Sections","renderSections","sections","enabledSections","sectionOrder","showTopSites","expectedCount","sectionId","split","commonProps","find","s","_OpenInPrivateWindow","site","OPEN_PRIVATE_WINDOW","referrer","userEvent","GetPlatformString","platform","LinkMenuOptions","Separator","EmptyItem","RemoveBookmark","DELETE_BOOKMARK_BY_ID","bookmarkGuid","AddBookmark","BOOKMARK_URL","OpenInNewWindow","OPEN_NEW_WINDOW","typedBonus","BlockUrl","index","BLOCK_URL","open_url","pocket_id","impression","block","pos","WebExtDismiss","string_id","WEBEXT_DISMISS","action_position","DeleteUrl","isEnabled","siteInfo","DIALOG_OPEN","DELETE_HISTORY_URL","forceBlock","ShowFile","SHOW_DOWNLOAD_FILE","OpenFile","OPEN_DOWNLOAD_FILE","CopyDownloadLink","COPY_DOWNLOAD_LINK","GoToDownloadPage","OPEN_LINK","disabled","RemoveDownload","REMOVE_DOWNLOAD_FILE","PinTopSite","searchTopSite","TOP_SITES_PIN","UnpinTopSite","TOP_SITES_UNPIN","SaveToPocket","SAVE_TO_POCKET","pocket","DeleteFromPocket","DELETE_FROM_POCKET","ArchiveFromPocket","ARCHIVE_FROM_POCKET","EditTopSite","TOP_SITES_EDIT","CheckBookmark","CheckPinTopSite","isPinned","CheckSavedToPocket","CheckBookmarkOrArchive","OpenInPrivateWindow","DEFAULT_SITE_MENU_OPTIONS","_LinkMenu","getOptions","isPrivateBrowsingEnabled","propOptions","isDefault","option","userEventData","first","last","onUpdate","LinkMenu","ContextMenu","hideContext","stopPropagation","ContextMenuItem","onKeyDown","shiftKey","ScreenshotUtils","isBlob","isLocal","image","path","createLocalImageObject","remoteImage","createObjectURL","maybeRevokeBlobObjectURL","localImage","revokeObjectURL","isRemoteImageLocal","_CollapsibleSection","onBodyMount","onHeaderClick","onTransitionEnd","enableOrDisableAnimation","onMenuButtonClick","onMenuButtonMouseEnter","onMenuButtonMouseLeave","onMenuUpdate","enableAnimation","isAnimating","menuButtonHover","showContextMenu","sectionBody","scrollHeight","node","undefined","maxHeight","_getSectionBodyHeight","SectionMenuOptions","CheckCollapsed","div","currentTarget","renderIcon","backgroundImage","preventDefault","isCollapsible","extraMenuOptions","showPrefName","active","bodyStyle","CollapsibleSection","DEFAULT_SECTION_MENU_OPTIONS","WEBEXT_SECTION_MENU_OPTIONS","_SectionMenu","extraOptions","splice","SectionMenu","MoveUp","SECTION_MOVE","direction","MoveDown","RemoveSection","CollapseSection","UPDATE_SECTION_PREFS","ExpandSection","ManageSection","ManageWebExtension","OPEN_WEBEXT_SETTINGS","AddTopSite","AddSearchShortcut","TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL","PrivacyNotice","RECORDED_SECTIONS","ComponentPerfTimer","Component","perfSvc","_sendBadStateEvent","_sendPaintedEvent","_reportMissingData","_timestampHandled","_recordedFirstRender","_maybeSendPaintedEvent","_afterFramePaint","callback","requestAnimationFrame","_maybeSendBadStateEvent","_ensureFirstRenderTsRecorded","mark","dataReadyKey","firstRenderKey","parseInt","getMostRecentAbsMarkStartByName","ChromeUtils","import","usablePerfObj","Services","appShell","hiddenDOMWindow","performance","_PerfService","performanceObj","_perf","prototype","str","getEntriesByName","timeOrigin","absNow","entries","mostRecentEntry","startTime","MoreRecommendations","_PocketLoggedInCta","ctaUrl","ctaButton","ctaText","PocketLoggedInCta","Topic","Topics","t","topSiteIconType","customScreenshotURL","tippyTopIcon","faviconRef","faviconSize","screenshot","countTopSitesIconsTypes","topSites","countTopSitesTypes","_TopSites","onEditFormClose","onSearchShortcutsFormClose","_dispatchTopSitesStats","_getVisibleTopSites","topSitesIconsStats","topSitesPinned","searchShortcuts","topsites_icon_stats","topsites_pinned","topsites_search_shortcuts","sitesPerRow","TopSites","TopSitesRows","TOP_SITES_CANCEL_EDIT","TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL","editForm","showSearchShortcutsForm","topSitesRows","TOP_SITES_SOURCE","TOP_SITES_CONTEXT_MENU_OPTIONS","TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS","MIN_RICH_FAVICON_SIZE","MIN_CORNER_FAVICON_SIZE","SelectableSearchShortcut","shortcut","selected","imageStyle","keyword","onChange","SearchShortcutsForm","handleChange","onCancelButtonClick","onSaveButtonClick","shortcuts","isSelected","row","checked","ev","onClose","pinQueue","unpinQueue","alreadyPinned","_searchTopSite","searchVendor","shortURL","UPDATE_PINNED_SEARCH_SHORTCUTS","addedShortcuts","deletedShortcuts","search_vendor","TopSiteLink","screenshotImage","onDragEvent","onKeyPress","_allowDrop","dataTransfer","types","dragged","effectAllowed","setData","blur","button","getNextStateFromProps","imageInState","nextState","componentWillReceiveProps","defaultStyle","isDraggable","topSiteOuterClassName","isDragged","letterFallback","imageClassName","showSmallFavicon","smallFaviconStyle","smallFaviconFallback","hasScreenshotImage","backgroundColor","favicon","draggableProps","onDragEnd","onDragStart","onMouseDown","TopSite","onLinkClick","_getTelemetryInfo","icon_type","iconType","card_type","hostname","altKey","ctrlKey","metaKey","FILL_SEARCH_TERM","onActivate","isContextMenuOpen","activeIndex","TopSitePlaceholder","onEditButtonClick","_TopSiteList","DEFAULT_STATE","draggedIndex","draggedSite","draggedTitle","topSitesPreview","prevTopSites","newTopSites","dropped","_makeTopSitesPreview","TOP_SITES_INSERT","draggedFromIndex","_getTopSites","pinnedOnly","unpinned","siteToInsert","holeIndex","indexStep","shiftingStep","nextIndex","preview","shift","topSitesUI","maxNarrowVisibleIndex","l","slotProps","TopSiteList","_StartupOverlay","onInputChange","onSubmit","clickSkip","initScene","removeOverlay","onInputInvalid","emailInput","overlayRemoved","flowId","flowBeginTime","didFetch","fxa_endpoint","fxaParams","json","show","remove","previousSibling","_getFormInfo","has_flow_params","focus","termsLink","privacyLink","terms","privacy","StartupOverlay","DetectUserSessionStart","_store","_perfService","perfService","_sendEvent","visibility_event_rcvd_ts","didHideOnboarding","allowLegacyOnboarding","MAX_PLACEABLES","entryIdentifierRe","identifierRe","functionIdentifierRe","RuntimeParser","getResource","string","_source","_index","_length","errors","skipWS","getEntry","SyntaxError","skipToNextEntryStart","ch","skipComment","skipSection","getMessage","skipInlineWS","getVariantName","getEntryIdentifier","val","getPattern","attrs","lineStart","getAttributes","skipBlankLines","ptr","getIdentifier","re","lastIndex","exec","start","cc","charCodeAt","getString","substring","eol","firstLineContent","getComplexPattern","buffer","placeables","blankLinesStart","blankLinesEnd","ch2","getPlaceable","variants","getVariants","exp","vars","def","selector","getSelectorExpression","literal","getLiteral","getVariantKey","getCallArgs","test","fun","Array","isArray","lastIndexOf","getNumber","num","defaultIndex","cc0","cc1","parse","parser","FluentType","opts","valueOf","FluentNone","FluentNumber","parseFloat","ctx","nf","_memoizeIntlObject","Intl","NumberFormat","format","match","other","FluentDateTime","dtf","DateTimeFormat","FluentSymbol","pr","PluralRules","select","arg","merge","argopts","unwrapped","opt","MAX_PLACEABLE_LENGTH","FSI","PDI","DefaultMember","env","members","RangeError","MessageReference","_terms","_messages","ReferenceError","VariantExpression","Type","isVariantList","variant","variantKey","AttributeExpression","attrName","SelectExpression","keyCanMatch","expr","Pattern","ExternalArgument","FunctionReference","CallExpression","attr","member","hasOwnProperty","TypeError","_functions","builtins","callee","posargs","keyargs","ptn","dirty","has","useIsolating","_useIsolating","elem","part","WeakSet","locales","functions","_intls","WeakMap","Symbol","iterator","hasMessage","ctor","cache","CachedIterable","iterable","asyncIterator","seen","cur","touchNext","done","mapContextSync","ids","getContextForId","context","remainingCount","foundContexts","fill","mapContextAsync","nonBlank","line","countIndent","indent","ftl","code","lines","indents","common","Math","min","RegExp","replace","contexts","subs","Set","comp","unsubscribe","setMessages","relocalize","getMessageContext","formatCompound","mcx","fallback","isReactLocalization","propName","prop","l10n","getChildContext","Children","only","LocalizationProvider","childContextTypes","propTypes","PropTypes","element","isRequired","isIterable","componentName","withLocalization","Inner","WithLocalization","forceUpdate","displayName","contextTypes","component","TEMPLATE","parseMarkup","omittedCloseTags","area","base","col","embed","hr","img","keygen","param","track","wbr","voidElementTags","menuitem","reMarkup","toArguments","elems","propname","propval","substr","isValidElement","toLowerCase","messageValue","messageAttrs","localizedProps","cloneElement","translationNodes","childNodes","translatedChildren","childNode","nodeType","TEXT_NODE","textContent","localName","sourceChild","Localized","ALLOWED_STYLE_TAGS","Button","tag","border","onBlockClicked","UISurface","onBlock","containerClassName","DEFAULT_ICON_PATH","onButtonClick","onAction","renderTitle","renderTitleIcon","titleIcon","title_icon","renderButton","button_color","button_background_color","button_label","tall","richText","Dedupe","createKey","defaultCreateKey","item","group","groups","globalKeys","valueMap","m","TOP_SITES_DEFAULT_ROWS","TOP_SITES_MAX_SITES_PER_ROW","dedupe","INITIAL_STATE","AS_ROUTER_INITIALIZED","AS_ROUTER_PREF_CHANGED","insertPinned","pinned","pinnedUrls","newLinks","pinIndex","hasMatch","newRows","TOP_SITES_UPDATED","TOP_SITES_PREFS_UPDATED","previewResponse","PREVIEW_RESPONSE","previewUrl","PREVIEW_REQUEST","PREVIEW_REQUEST_CANCEL","SCREENSHOT_UPDATED","PLACES_BOOKMARK_ADDED","bookmarkTitle","dateAdded","bookmarkDateCreated","PLACES_BOOKMARK_REMOVED","newSite","PLACES_LINK_DELETED","UPDATE_SEARCH_SHORTCUTS","SNIPPETS_PREVIEW_MODE","newValues","PREFS_INITIAL_VALUES","PREF_CHANGED","newState","SECTION_DEREGISTER","SECTION_REGISTER","SECTION_UPDATE","card","dedupeConfigurations","dedupeConf","dedupedRows","dedupeFrom","dedupeSectionId","dedupeSection","SECTION_UPDATE_CARD","PLACES_SAVED_TO_POCKET","PLACES_LINK_BLOCKED","SNIPPETS_DATA","SNIPPETS_RESET","POCKET_WAITING_FOR_SPOC","POCKET_LOGGED_IN","POCKET_CTA","cta_button","cta_text","cta_url","use_cta","onDoneButton","includeClientID","header","extraTemplateStrings","cardContextTypes","history","intlID","bookmark","trending","download","gImageLoading","activeCard","imageLoaded","cardImage","maybeLoadImage","imageUrl","loaderPromise","loader","Image","src","catch","then","WEBEXT_CLICK","click","_Card","hasImage","placeholder","description","Card","PlaceholderCard","validationError","onMount","shouldFocus","showClearButton","onClear","typeUrl","titleId","loading","placeholderId","errorMessageId","TopSiteFormInput","customScreenshotUrl","showCustomScreenshotForm","onClearScreenshotInput","onLabelChange","onUrlChange","onClearUrlClick","onDoneButtonClick","onCustomScreenshotUrlChange","onPreviewButtonClick","onEnableScreenshotUrlForm","validateUrl","_updateCustomScreenshotInput","validateForm","cleanUrl","_tryParseUrl","validProtocols","urlObj","validateCustomScreenshotUrl","validate","_renderCustomScreenshotInput","requestFailed","isLoading","showAsAdd","previous","changed","previewMode","previewLink","TopSiteForm"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,m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A7OkD;;AAgPrD,uBAAAK,CAAY9/B,YAAZ,GAA2B;AACzBmQ,QAAM,IADmB;AAEzBkB,SAAO,CAAC;AAFiB,CAA3B,C","file":"activity-stream.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {addSnippetsSubscriber} from \"content-src/lib/snippets\";\nimport {ASRouterContent} from \"content-src/asrouter/asrouter-content\";\nimport {Base} from \"content-src/components/Base/Base\";\nimport {DetectUserSessionStart} from \"content-src/lib/detect-user-session-start\";\nimport {enableASRouterContent} from \"content-src/lib/asroutercontent\";\nimport {initStore} from \"content-src/lib/init-store\";\nimport {Provider} from \"react-redux\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport {reducers} from \"common/Reducers.jsm\";\n\nconst store = initStore(reducers, global.gActivityStreamPrerenderedState);\nconst asrouterContent = new ASRouterContent();\n\nnew DetectUserSessionStart(store).sendEventOrAddListener();\n\n// If we are starting in a prerendered state, we must wait until the first render\n// to request state rehydration (see Base.jsx). If we are NOT in a prerendered state,\n// we can request it immedately.\nif (!global.gActivityStreamPrerenderedState) {\n  store.dispatch(ac.AlsoToMain({type: at.NEW_TAB_STATE_REQUEST}));\n}\n\nReactDOM.hydrate(<Provider store={store}>\n  <Base\n    isFirstrun={global.document.location.href === \"about:welcome\"}\n    isPrerendered={!!global.gActivityStreamPrerenderedState}\n    locale={global.document.documentElement.lang}\n    strings={global.gActivityStreamStrings} />\n</Provider>, document.getElementById(\"root\"));\n\nenableASRouterContent(store, asrouterContent);\naddSnippetsSubscriber(store);\n","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\r\n} catch (e) {\r\n\t// This works if the window reference is available\r\n\tif (typeof window === \"object\") g = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\"use strict\";\n\nthis.MAIN_MESSAGE_TYPE = \"ActivityStream:Main\";\nthis.CONTENT_MESSAGE_TYPE = \"ActivityStream:Content\";\nthis.PRELOAD_MESSAGE_TYPE = \"ActivityStream:PreloadedBrowser\";\nthis.UI_CODE = 1;\nthis.BACKGROUND_PROCESS = 2;\n\n/**\n * globalImportContext - Are we in UI code (i.e. react, a dom) or some kind of background process?\n *                       Use this in action creators if you need different logic\n *                       for ui/background processes.\n */\nconst globalImportContext = typeof Window === \"undefined\" ? BACKGROUND_PROCESS : UI_CODE;\n// Export for tests\nthis.globalImportContext = globalImportContext;\n\n// Create an object that avoids accidental differing key/value pairs:\n// {\n//   INIT: \"INIT\",\n//   UNINIT: \"UNINIT\"\n// }\nconst actionTypes = {};\nfor (const type of [\n  \"ADDONS_INFO_REQUEST\",\n  \"ADDONS_INFO_RESPONSE\",\n  \"ARCHIVE_FROM_POCKET\",\n  \"AS_ROUTER_INITIALIZED\",\n  \"AS_ROUTER_PREF_CHANGED\",\n  \"AS_ROUTER_TELEMETRY_USER_EVENT\",\n  \"BLOCK_URL\",\n  \"BOOKMARK_URL\",\n  \"COPY_DOWNLOAD_LINK\",\n  \"DELETE_BOOKMARK_BY_ID\",\n  \"DELETE_FROM_POCKET\",\n  \"DELETE_HISTORY_URL\",\n  \"DIALOG_CANCEL\",\n  \"DIALOG_OPEN\",\n  \"DISABLE_ONBOARDING\",\n  \"DOWNLOAD_CHANGED\",\n  \"FILL_SEARCH_TERM\",\n  \"INIT\",\n  \"MIGRATION_CANCEL\",\n  \"MIGRATION_COMPLETED\",\n  \"MIGRATION_START\",\n  \"NEW_TAB_INIT\",\n  \"NEW_TAB_INITIAL_STATE\",\n  \"NEW_TAB_LOAD\",\n  \"NEW_TAB_REHYDRATED\",\n  \"NEW_TAB_STATE_REQUEST\",\n  \"NEW_TAB_UNLOAD\",\n  \"OPEN_DOWNLOAD_FILE\",\n  \"OPEN_LINK\",\n  \"OPEN_NEW_WINDOW\",\n  \"OPEN_PRIVATE_WINDOW\",\n  \"OPEN_WEBEXT_SETTINGS\",\n  \"PAGE_PRERENDERED\",\n  \"PLACES_BOOKMARK_ADDED\",\n  \"PLACES_BOOKMARK_REMOVED\",\n  \"PLACES_HISTORY_CLEARED\",\n  \"PLACES_LINKS_CHANGED\",\n  \"PLACES_LINK_BLOCKED\",\n  \"PLACES_LINK_DELETED\",\n  \"PLACES_SAVED_TO_POCKET\",\n  \"POCKET_CTA\",\n  \"POCKET_LOGGED_IN\",\n  \"POCKET_WAITING_FOR_SPOC\",\n  \"PREFS_INITIAL_VALUES\",\n  \"PREF_CHANGED\",\n  \"PREVIEW_REQUEST\",\n  \"PREVIEW_REQUEST_CANCEL\",\n  \"PREVIEW_RESPONSE\",\n  \"REMOVE_DOWNLOAD_FILE\",\n  \"RICH_ICON_MISSING\",\n  \"SAVE_SESSION_PERF_DATA\",\n  \"SAVE_TO_POCKET\",\n  \"SCREENSHOT_UPDATED\",\n  \"SECTION_DEREGISTER\",\n  \"SECTION_DISABLE\",\n  \"SECTION_ENABLE\",\n  \"SECTION_MOVE\",\n  \"SECTION_OPTIONS_CHANGED\",\n  \"SECTION_REGISTER\",\n  \"SECTION_UPDATE\",\n  \"SECTION_UPDATE_CARD\",\n  \"SETTINGS_CLOSE\",\n  \"SETTINGS_OPEN\",\n  \"SET_PREF\",\n  \"SHOW_DOWNLOAD_FILE\",\n  \"SHOW_FIREFOX_ACCOUNTS\",\n  \"SKIPPED_SIGNIN\",\n  \"SNIPPETS_BLOCKLIST_CLEARED\",\n  \"SNIPPETS_BLOCKLIST_UPDATED\",\n  \"SNIPPETS_DATA\",\n  \"SNIPPETS_PREVIEW_MODE\",\n  \"SNIPPETS_RESET\",\n  \"SNIPPET_BLOCKED\",\n  \"SUBMIT_EMAIL\",\n  \"SYSTEM_TICK\",\n  \"TELEMETRY_IMPRESSION_STATS\",\n  \"TELEMETRY_PERFORMANCE_EVENT\",\n  \"TELEMETRY_UNDESIRED_EVENT\",\n  \"TELEMETRY_USER_EVENT\",\n  \"TOP_SITES_CANCEL_EDIT\",\n  \"TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL\",\n  \"TOP_SITES_EDIT\",\n  \"TOP_SITES_INSERT\",\n  \"TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL\",\n  \"TOP_SITES_PIN\",\n  \"TOP_SITES_PREFS_UPDATED\",\n  \"TOP_SITES_UNPIN\",\n  \"TOP_SITES_UPDATED\",\n  \"TOTAL_BOOKMARKS_REQUEST\",\n  \"TOTAL_BOOKMARKS_RESPONSE\",\n  \"UNINIT\",\n  \"UPDATE_PINNED_SEARCH_SHORTCUTS\",\n  \"UPDATE_SEARCH_SHORTCUTS\",\n  \"UPDATE_SECTION_PREFS\",\n  \"WEBEXT_CLICK\",\n  \"WEBEXT_DISMISS\",\n]) {\n  actionTypes[type] = type;\n}\n\n// These are acceptable actions for AS Router messages to have. They can show up\n// as call-to-action buttons in snippets, onboarding tour, etc.\nconst ASRouterActions = {};\nfor (const type of [\n  \"INSTALL_ADDON_FROM_URL\",\n  \"OPEN_APPLICATIONS_MENU\",\n  \"OPEN_PRIVATE_BROWSER_WINDOW\",\n  \"OPEN_URL\",\n  \"OPEN_ABOUT_PAGE\",\n]) {\n  ASRouterActions[type] = type;\n}\n\n// Helper function for creating routed actions between content and main\n// Not intended to be used by consumers\nfunction _RouteMessage(action, options) {\n  const meta = action.meta ? {...action.meta} : {};\n  if (!options || !options.from || !options.to) {\n    throw new Error(\"Routed Messages must have options as the second parameter, and must at least include a .from and .to property.\");\n  }\n  // For each of these fields, if they are passed as an option,\n  // add them to the action. If they are not defined, remove them.\n  [\"from\", \"to\", \"toTarget\", \"fromTarget\", \"skipMain\", \"skipLocal\"].forEach(o => {\n    if (typeof options[o] !== \"undefined\") {\n      meta[o] = options[o];\n    } else if (meta[o]) {\n      delete meta[o];\n    }\n  });\n  return {...action, meta};\n}\n\n/**\n * AlsoToMain - Creates a message that will be dispatched locally and also sent to the Main process.\n *\n * @param  {object} action Any redux action (required)\n * @param  {object} options\n * @param  {bool}   skipLocal Used by OnlyToMain to skip the main reducer\n * @param  {string} fromTarget The id of the content port from which the action originated. (optional)\n * @return {object} An action with added .meta properties\n */\nfunction AlsoToMain(action, fromTarget, skipLocal) {\n  return _RouteMessage(action, {\n    from: CONTENT_MESSAGE_TYPE,\n    to: MAIN_MESSAGE_TYPE,\n    fromTarget,\n    skipLocal,\n  });\n}\n\n/**\n * OnlyToMain - Creates a message that will be sent to the Main process and skip the local reducer.\n *\n * @param  {object} action Any redux action (required)\n * @param  {object} options\n * @param  {string} fromTarget The id of the content port from which the action originated. (optional)\n * @return {object} An action with added .meta properties\n */\nfunction OnlyToMain(action, fromTarget) {\n  return AlsoToMain(action, fromTarget, true);\n}\n\n/**\n * BroadcastToContent - Creates a message that will be dispatched to main and sent to ALL content processes.\n *\n * @param  {object} action Any redux action (required)\n * @return {object} An action with added .meta properties\n */\nfunction BroadcastToContent(action) {\n  return _RouteMessage(action, {\n    from: MAIN_MESSAGE_TYPE,\n    to: CONTENT_MESSAGE_TYPE,\n  });\n}\n\n/**\n * AlsoToOneContent - Creates a message that will be will be dispatched to the main store\n *                    and also sent to a particular Content process.\n *\n * @param  {object} action Any redux action (required)\n * @param  {string} target The id of a content port\n * @param  {bool} skipMain Used by OnlyToOneContent to skip the main process\n * @return {object} An action with added .meta properties\n */\nfunction AlsoToOneContent(action, target, skipMain) {\n  if (!target) {\n    throw new Error(\"You must provide a target ID as the second parameter of AlsoToOneContent. If you want to send to all content processes, use BroadcastToContent\");\n  }\n  return _RouteMessage(action, {\n    from: MAIN_MESSAGE_TYPE,\n    to: CONTENT_MESSAGE_TYPE,\n    toTarget: target,\n    skipMain,\n  });\n}\n\n/**\n * OnlyToOneContent - Creates a message that will be sent to a particular Content process\n *                    and skip the main reducer.\n *\n * @param  {object} action Any redux action (required)\n * @param  {string} target The id of a content port\n * @return {object} An action with added .meta properties\n */\nfunction OnlyToOneContent(action, target) {\n  return AlsoToOneContent(action, target, true);\n}\n\n/**\n * AlsoToPreloaded - Creates a message that dispatched to the main reducer and also sent to the preloaded tab.\n *\n * @param  {object} action Any redux action (required)\n * @return {object} An action with added .meta properties\n */\nfunction AlsoToPreloaded(action) {\n  return _RouteMessage(action, {\n    from: MAIN_MESSAGE_TYPE,\n    to: PRELOAD_MESSAGE_TYPE,\n  });\n}\n\n/**\n * UserEvent - A telemetry ping indicating a user action. This should only\n *                   be sent from the UI during a user session.\n *\n * @param  {object} data Fields to include in the ping (source, etc.)\n * @return {object} An AlsoToMain action\n */\nfunction UserEvent(data) {\n  return AlsoToMain({\n    type: actionTypes.TELEMETRY_USER_EVENT,\n    data,\n  });\n}\n\n/**\n * ASRouterUserEvent - A telemetry ping indicating a user action from AS router. This should only\n *                     be sent from the UI during a user session.\n *\n * @param  {object} data Fields to include in the ping (source, etc.)\n * @return {object} An AlsoToMain action\n */\nfunction ASRouterUserEvent(data) {\n  return AlsoToMain({\n    type: actionTypes.AS_ROUTER_TELEMETRY_USER_EVENT,\n    data,\n  });\n}\n\n/**\n * UndesiredEvent - A telemetry ping indicating an undesired state.\n *\n * @param  {object} data Fields to include in the ping (value, etc.)\n * @param  {int} importContext (For testing) Override the import context for testing.\n * @return {object} An action. For UI code, a AlsoToMain action.\n */\nfunction UndesiredEvent(data, importContext = globalImportContext) {\n  const action = {\n    type: actionTypes.TELEMETRY_UNDESIRED_EVENT,\n    data,\n  };\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\n/**\n * PerfEvent - A telemetry ping indicating a performance-related event.\n *\n * @param  {object} data Fields to include in the ping (value, etc.)\n * @param  {int} importContext (For testing) Override the import context for testing.\n * @return {object} An action. For UI code, a AlsoToMain action.\n */\nfunction PerfEvent(data, importContext = globalImportContext) {\n  const action = {\n    type: actionTypes.TELEMETRY_PERFORMANCE_EVENT,\n    data,\n  };\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\n/**\n * ImpressionStats - A telemetry ping indicating an impression stats.\n *\n * @param  {object} data Fields to include in the ping\n * @param  {int} importContext (For testing) Override the import context for testing.\n * #return {object} An action. For UI code, a AlsoToMain action.\n */\nfunction ImpressionStats(data, importContext = globalImportContext) {\n  const action = {\n    type: actionTypes.TELEMETRY_IMPRESSION_STATS,\n    data,\n  };\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\nfunction SetPref(name, value, importContext = globalImportContext) {\n  const action = {type: actionTypes.SET_PREF, data: {name, value}};\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\nfunction WebExtEvent(type, data, importContext = globalImportContext) {\n  if (!data || !data.source) {\n    throw new Error(\"WebExtEvent actions should include a property \\\"source\\\", the id of the webextension that should receive the event.\");\n  }\n  const action = {type, data};\n  return importContext === UI_CODE ? AlsoToMain(action) : action;\n}\n\nthis.actionTypes = actionTypes;\nthis.ASRouterActions = ASRouterActions;\n\nthis.actionCreators = {\n  BroadcastToContent,\n  UserEvent,\n  ASRouterUserEvent,\n  UndesiredEvent,\n  PerfEvent,\n  ImpressionStats,\n  AlsoToOneContent,\n  OnlyToOneContent,\n  AlsoToMain,\n  OnlyToMain,\n  AlsoToPreloaded,\n  SetPref,\n  WebExtEvent,\n};\n\n// These are helpers to test for certain kinds of actions\nthis.actionUtils = {\n  isSendToMain(action) {\n    if (!action.meta) {\n      return false;\n    }\n    return action.meta.to === MAIN_MESSAGE_TYPE && action.meta.from === CONTENT_MESSAGE_TYPE;\n  },\n  isBroadcastToContent(action) {\n    if (!action.meta) {\n      return false;\n    }\n    if (action.meta.to === CONTENT_MESSAGE_TYPE && !action.meta.toTarget) {\n      return true;\n    }\n    return false;\n  },\n  isSendToOneContent(action) {\n    if (!action.meta) {\n      return false;\n    }\n    if (action.meta.to === CONTENT_MESSAGE_TYPE && action.meta.toTarget) {\n      return true;\n    }\n    return false;\n  },\n  isSendToPreloaded(action) {\n    if (!action.meta) {\n      return false;\n    }\n    return action.meta.to === PRELOAD_MESSAGE_TYPE &&\n      action.meta.from === MAIN_MESSAGE_TYPE;\n  },\n  isFromMain(action) {\n    if (!action.meta) {\n      return false;\n    }\n    return action.meta.from === MAIN_MESSAGE_TYPE &&\n      action.meta.to === CONTENT_MESSAGE_TYPE;\n  },\n  getPortIdOfSender(action) {\n    return (action.meta && action.meta.fromTarget) || null;\n  },\n  _RouteMessage,\n};\n\nconst EXPORTED_SYMBOLS = [\n  \"actionTypes\",\n  \"actionCreators\",\n  \"actionUtils\",\n  \"ASRouterActions\",\n  \"globalImportContext\",\n  \"UI_CODE\",\n  \"BACKGROUND_PROCESS\",\n  \"MAIN_MESSAGE_TYPE\",\n  \"CONTENT_MESSAGE_TYPE\",\n  \"PRELOAD_MESSAGE_TYPE\",\n];\n","const DATABASE_NAME = \"snippets_db\";\nconst DATABASE_VERSION = 1;\nconst SNIPPETS_OBJECTSTORE_NAME = \"snippets\";\nexport const SNIPPETS_UPDATE_INTERVAL_MS = 14400000; // 4 hours.\n\nconst SNIPPETS_ENABLED_EVENT = \"Snippets:Enabled\";\nconst SNIPPETS_DISABLED_EVENT = \"Snippets:Disabled\";\n\nimport {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\n\n/**\n * SnippetsMap - A utility for cacheing values related to the snippet. It has\n *               the same interface as a Map, but is optionally backed by\n *               indexedDB for persistent storage.\n *               Call .connect() to open a database connection and restore any\n *               previously cached data, if necessary.\n *\n */\nexport class SnippetsMap extends Map {\n  constructor(dispatch) {\n    super();\n    this._db = null;\n    this._dispatch = dispatch;\n  }\n\n  set(key, value) {\n    super.set(key, value);\n    return this._dbTransaction(db => db.put(value, key));\n  }\n\n  delete(key) {\n    super.delete(key);\n    return this._dbTransaction(db => db.delete(key));\n  }\n\n  clear() {\n    super.clear();\n    this._dispatch(ac.OnlyToMain({type: at.SNIPPETS_BLOCKLIST_CLEARED}));\n    return this._dbTransaction(db => db.clear());\n  }\n\n  get blockList() {\n    return this.get(\"blockList\") || [];\n  }\n\n  /**\n   * blockSnippetById - Blocks a snippet given an id\n   *\n   * @param  {str|int} id   The id of the snippet\n   * @return {Promise}      Resolves when the id has been written to indexedDB,\n   *                        or immediately if the snippetMap is not connected\n   */\n  async blockSnippetById(id) {\n    if (!id) {\n      return;\n    }\n    const {blockList} = this;\n    if (!blockList.includes(id)) {\n      blockList.push(id);\n      this._dispatch(ac.AlsoToMain({type: at.SNIPPETS_BLOCKLIST_UPDATED, data: id}));\n      await this.set(\"blockList\", blockList);\n    }\n  }\n\n  disableOnboarding() {\n    this._dispatch(ac.AlsoToMain({type: at.DISABLE_ONBOARDING}));\n  }\n\n  showFirefoxAccounts() {\n    this._dispatch(ac.AlsoToMain({type: at.SHOW_FIREFOX_ACCOUNTS}));\n  }\n\n  getTotalBookmarksCount() {\n    return new Promise(resolve => {\n      this._dispatch(ac.OnlyToMain({type: at.TOTAL_BOOKMARKS_REQUEST}));\n      global.RPMAddMessageListener(\"ActivityStream:MainToContent\", function onMessage({data: action}) {\n        if (action.type === at.TOTAL_BOOKMARKS_RESPONSE) {\n          resolve(action.data);\n          global.RPMRemoveMessageListener(\"ActivityStream:MainToContent\", onMessage);\n        }\n      });\n    });\n  }\n\n  getAddonsInfo() {\n    return new Promise(resolve => {\n      this._dispatch(ac.OnlyToMain({type: at.ADDONS_INFO_REQUEST}));\n      global.RPMAddMessageListener(\"ActivityStream:MainToContent\", function onMessage({data: action}) {\n        if (action.type === at.ADDONS_INFO_RESPONSE) {\n          resolve(action.data);\n          global.RPMRemoveMessageListener(\"ActivityStream:MainToContent\", onMessage);\n        }\n      });\n    });\n  }\n\n  /**\n   * connect - Attaches an indexedDB back-end to the Map so that any set values\n   *           are also cached in a store. It also restores any existing values\n   *           that are already stored in the indexedDB store.\n   *\n   * @return {type}  description\n   */\n  async connect() {\n    // Open the connection\n    const db = await this._openDB();\n\n    // Restore any existing values\n    await this._restoreFromDb(db);\n\n    // Attach a reference to the db\n    this._db = db;\n  }\n\n  /**\n   * _dbTransaction - Returns a db transaction wrapped with the given modifier\n   *                  function as a Promise. If the db has not been connected,\n   *                  it resolves immediately.\n   *\n   * @param  {func} modifier A function to call with the transaction\n   * @return {obj}           A Promise that resolves when the transaction has\n   *                         completed or errored\n   */\n  _dbTransaction(modifier) {\n    if (!this._db) {\n      return Promise.resolve();\n    }\n    return new Promise((resolve, reject) => {\n      const transaction = modifier(\n        this._db\n          .transaction(SNIPPETS_OBJECTSTORE_NAME, \"readwrite\")\n          .objectStore(SNIPPETS_OBJECTSTORE_NAME)\n      );\n      transaction.onsuccess = event => resolve();\n\n      /* istanbul ignore next */\n      transaction.onerror = event => reject(transaction.error);\n    });\n  }\n\n  _openDB() {\n    return new Promise((resolve, reject) => {\n      const openRequest = indexedDB.open(DATABASE_NAME, DATABASE_VERSION);\n\n      /* istanbul ignore next */\n      openRequest.onerror = event => {\n        // Try to delete the old database so that we can start this process over\n        // next time.\n        indexedDB.deleteDatabase(DATABASE_NAME);\n        reject(event);\n      };\n\n      openRequest.onupgradeneeded = event => {\n        const db = event.target.result;\n        if (!db.objectStoreNames.contains(SNIPPETS_OBJECTSTORE_NAME)) {\n          db.createObjectStore(SNIPPETS_OBJECTSTORE_NAME);\n        }\n      };\n\n      openRequest.onsuccess = event => {\n        let db = event.target.result;\n\n        /* istanbul ignore next */\n        db.onerror = err => console.error(err); // eslint-disable-line no-console\n        /* istanbul ignore next */\n        db.onversionchange = versionChangeEvent => versionChangeEvent.target.close();\n\n        resolve(db);\n      };\n    });\n  }\n\n  _restoreFromDb(db) {\n    return new Promise((resolve, reject) => {\n      let cursorRequest;\n      try {\n        cursorRequest = db.transaction(SNIPPETS_OBJECTSTORE_NAME)\n          .objectStore(SNIPPETS_OBJECTSTORE_NAME).openCursor();\n      } catch (err) {\n        // istanbul ignore next\n        reject(err);\n        // istanbul ignore next\n        return;\n      }\n\n      /* istanbul ignore next */\n      cursorRequest.onerror = event => reject(event);\n\n      cursorRequest.onsuccess = event => {\n        let cursor = event.target.result;\n        // Populate the cache from the persistent storage.\n        if (cursor) {\n          if (cursor.value !== \"blockList\") {\n            this.set(cursor.key, cursor.value);\n          }\n          cursor.continue();\n        } else {\n          // We are done.\n          resolve();\n        }\n      };\n    });\n  }\n}\n\n/**\n * SnippetsProvider - Initializes a SnippetsMap and loads snippets from a\n *                    remote location, or else default snippets if the remote\n *                    snippets cannot be retrieved.\n */\nexport class SnippetsProvider {\n  constructor(dispatch) {\n    // Initialize the Snippets Map and attaches it to a global so that\n    // the snippet payload can interact with it.\n    global.gSnippetsMap = new SnippetsMap(dispatch);\n    this._onAction = this._onAction.bind(this);\n  }\n\n  get snippetsMap() {\n    return global.gSnippetsMap;\n  }\n\n  async _refreshSnippets() {\n    // Check if the cached version of of the snippets in snippetsMap. If it's too\n    // old, blow away the entire snippetsMap.\n    const cachedVersion = this.snippetsMap.get(\"snippets-cached-version\");\n\n    if (cachedVersion !== this.appData.version) {\n      this.snippetsMap.clear();\n    }\n\n    // Has enough time passed for us to require an update?\n    const lastUpdate = this.snippetsMap.get(\"snippets-last-update\");\n    const needsUpdate = !(lastUpdate >= 0) || Date.now() - lastUpdate > SNIPPETS_UPDATE_INTERVAL_MS;\n\n    if (needsUpdate && this.appData.snippetsURL) {\n      this.snippetsMap.set(\"snippets-last-update\", Date.now());\n      try {\n        const response = await fetch(this.appData.snippetsURL);\n        if (response.status === 200) {\n          const payload = await response.text();\n\n          this.snippetsMap.set(\"snippets\", payload);\n          this.snippetsMap.set(\"snippets-cached-version\", this.appData.version);\n        }\n      } catch (e) {\n        console.error(e); // eslint-disable-line no-console\n      }\n    }\n  }\n\n  _noSnippetFallback() {\n    // TODO\n  }\n\n  _forceOnboardingVisibility(shouldBeVisible) {\n    const onboardingEl = document.getElementById(\"onboarding-notification-bar\");\n\n    if (onboardingEl) {\n      onboardingEl.style.display = shouldBeVisible ? \"\" : \"none\";\n    }\n  }\n\n  _showRemoteSnippets() {\n    const snippetsEl = document.getElementById(this.elementId);\n    const payload = this.snippetsMap.get(\"snippets\");\n\n    if (!snippetsEl) {\n      throw new Error(`No element was found with id '${this.elementId}'.`);\n    }\n\n    // This could happen if fetching failed\n    if (!payload) {\n      throw new Error(\"No remote snippets were found in gSnippetsMap.\");\n    }\n\n    if (typeof payload !== \"string\") {\n      throw new Error(\"Snippet payload was incorrectly formatted\");\n    }\n\n    // Note that injecting snippets can throw if they're invalid XML.\n    // eslint-disable-next-line no-unsanitized/property\n    snippetsEl.innerHTML = payload;\n\n    // Scripts injected by innerHTML are inactive, so we have to relocate them\n    // through DOM manipulation to activate their contents.\n    for (const scriptEl of snippetsEl.getElementsByTagName(\"script\")) {\n      const relocatedScript = document.createElement(\"script\");\n      relocatedScript.text = scriptEl.text;\n      scriptEl.parentNode.replaceChild(relocatedScript, scriptEl);\n    }\n  }\n\n  _onAction(msg) {\n    if (msg.data.type === at.SNIPPET_BLOCKED) {\n      if (!this.snippetsMap.blockList.includes(msg.data.data)) {\n        this.snippetsMap.set(\"blockList\", this.snippetsMap.blockList.concat(msg.data.data));\n        document.getElementById(\"snippets-container\").style.display = \"none\";\n      }\n    }\n  }\n\n  /**\n   * init - Fetch the snippet payload and show snippets\n   *\n   * @param  {obj} options\n   * @param  {str} options.appData.snippetsURL  The URL from which we fetch snippets\n   * @param  {int} options.appData.version  The current snippets version\n   * @param  {str} options.elementId  The id of the element in which to inject snippets\n   * @param  {bool} options.connect  Should gSnippetsMap connect to indexedDB?\n   */\n  async init(options) {\n    Object.assign(this, {\n      appData: {},\n      elementId: \"snippets\",\n      connect: true,\n    }, options);\n\n    // Add listener so we know when snippets are blocked on other pages\n    if (global.RPMAddMessageListener) {\n      global.RPMAddMessageListener(\"ActivityStream:MainToContent\", this._onAction);\n    }\n\n    // TODO: Requires enabling indexedDB on newtab\n    // Restore the snippets map from indexedDB\n    if (this.connect) {\n      try {\n        await this.snippetsMap.connect();\n      } catch (e) {\n        console.error(e); // eslint-disable-line no-console\n      }\n    }\n\n    // Cache app data values so they can be accessible from gSnippetsMap\n    for (const key of Object.keys(this.appData)) {\n      if (key === \"blockList\") {\n        this.snippetsMap.set(\"blockList\", this.appData[key]);\n      } else {\n        this.snippetsMap.set(`appData.${key}`, this.appData[key]);\n      }\n    }\n\n    // Refresh snippets, if enough time has passed.\n    await this._refreshSnippets();\n\n    // Try showing remote snippets, falling back to defaults if necessary.\n    try {\n      this._showRemoteSnippets();\n    } catch (e) {\n      this._noSnippetFallback(e);\n    }\n\n    window.dispatchEvent(new Event(SNIPPETS_ENABLED_EVENT));\n\n    this._forceOnboardingVisibility(true);\n    this.initialized = true;\n  }\n\n  uninit() {\n    window.dispatchEvent(new Event(SNIPPETS_DISABLED_EVENT));\n    this._forceOnboardingVisibility(false);\n    if (global.RPMRemoveMessageListener) {\n      global.RPMRemoveMessageListener(\"ActivityStream:MainToContent\", this._onAction);\n    }\n    this.initialized = false;\n  }\n}\n\n/**\n * addSnippetsSubscriber - Creates a SnippetsProvider that Initializes\n *                         when the store has received the appropriate\n *                         Snippet data.\n *\n * @param  {obj} store   The redux store\n * @return {obj}         Returns the snippets instance, asrouterContent instance and unsubscribe function\n */\nexport function addSnippetsSubscriber(store) {\n  const snippets = new SnippetsProvider(store.dispatch);\n\n  let initializing = false;\n\n  store.subscribe(async () => {\n    const state = store.getState();\n\n    /**\n     * Sorry this code is so complicated. It will be removed soon.\n     * This is what the different values actually mean:\n     *\n     * ASRouter.initialized                   Is ASRouter.jsm initialised?\n     * ASRouter.allowLegacySnippets           Are ASRouter snippets turned OFF (i.e. legacy snippets are allowed)\n     * state.Prefs.values[\"feeds.snippets\"]   User preference for snippets\n     * state.Snippets.initialized             Is SnippetsFeed.jsm initialised?\n     * snippets.initialized                   Is in-content snippets currently initialised?\n     * state.Prefs.values.disableSnippets     This pref is used to disable legacy snippets in an emergency\n     *                                        in a way that is not user-editable (true = disabled)\n     */\n\n    /** If we should initialize snippets... */\n    if (\n      state.Prefs.values[\"feeds.snippets\"] &&\n      state.ASRouter.initialized &&\n      state.ASRouter.allowLegacySnippets &&\n      !state.Prefs.values.disableSnippets &&\n      state.Snippets.initialized &&\n      !snippets.initialized &&\n      // Don't call init multiple times\n      !initializing &&\n      location.href !== \"about:welcome\"\n    ) {\n      initializing = true;\n      await snippets.init({appData: state.Snippets});\n      // istanbul ignore if\n      if (state.Prefs.values[\"asrouter.devtoolsEnabled\"]) {\n        console.log(\"Legacy snippets initialized\"); // eslint-disable-line no-console\n      }\n      initializing = false;\n\n    /** If we should remove snippets... */\n    } else if (\n      (\n        state.Prefs.values[\"feeds.snippets\"] === false ||\n        state.Prefs.values.disableSnippets === true ||\n        (state.ASRouter.initialized && !state.ASRouter.allowLegacySnippets)\n      ) &&\n      snippets.initialized\n    ) {\n      // Remove snippets\n      snippets.uninit();\n      // istanbul ignore if\n      if (state.Prefs.values[\"asrouter.devtoolsEnabled\"]) {\n        console.log(\"Legacy snippets removed\"); // eslint-disable-line no-console\n      }\n    }\n  });\n\n  // Returned for testing purposes\n  return {snippets};\n}\n","import {LocalizationProvider, Localized} from \"fluent-react\";\nimport {actionCreators as ac} from \"common/Actions.jsm\";\nimport {OUTGOING_MESSAGE_NAME as AS_GENERAL_OUTGOING_MESSAGE_NAME} from \"content-src/lib/init-store\";\nimport {ImpressionsWrapper} from \"./components/ImpressionsWrapper/ImpressionsWrapper\";\nimport {MessageContext} from \"fluent\";\nimport {OnboardingMessage} from \"./templates/OnboardingMessage/OnboardingMessage\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport {safeURI} from \"./template-utils\";\nimport {SimpleSnippet} from \"./templates/SimpleSnippet/SimpleSnippet\";\n\nconst INCOMING_MESSAGE_NAME = \"ASRouter:parent-to-child\";\nconst OUTGOING_MESSAGE_NAME = \"ASRouter:child-to-parent\";\nconst ASR_CONTAINER_ID = \"asr-newtab-container\";\n\nexport const ASRouterUtils = {\n  addListener(listener) {\n    global.RPMAddMessageListener(INCOMING_MESSAGE_NAME, listener);\n  },\n  removeListener(listener) {\n    global.RPMRemoveMessageListener(INCOMING_MESSAGE_NAME, listener);\n  },\n  sendMessage(action) {\n    global.RPMSendAsyncMessage(OUTGOING_MESSAGE_NAME, action);\n  },\n  blockById(id) {\n    ASRouterUtils.sendMessage({type: \"BLOCK_MESSAGE_BY_ID\", data: {id}});\n  },\n  blockBundle(bundle) {\n    ASRouterUtils.sendMessage({type: \"BLOCK_BUNDLE\", data: {bundle}});\n  },\n  executeAction(button_action) {\n    ASRouterUtils.sendMessage({\n      type: \"USER_ACTION\",\n      data: button_action,\n    });\n  },\n  unblockById(id) {\n    ASRouterUtils.sendMessage({type: \"UNBLOCK_MESSAGE_BY_ID\", data: {id}});\n  },\n  unblockBundle(bundle) {\n    ASRouterUtils.sendMessage({type: \"UNBLOCK_BUNDLE\", data: {bundle}});\n  },\n  overrideMessage(id) {\n    ASRouterUtils.sendMessage({type: \"OVERRIDE_MESSAGE\", data: {id}});\n  },\n  sendTelemetry(ping) {\n    const payload = ac.ASRouterUserEvent(ping);\n    global.RPMSendAsyncMessage(AS_GENERAL_OUTGOING_MESSAGE_NAME, payload);\n  },\n  getPreviewEndpoint() {\n    if (window.location.href.includes(\"endpoint\")) {\n      const params = new URLSearchParams(window.location.href.slice(window.location.href.indexOf(\"endpoint\")));\n      try {\n        const endpoint = new URL(params.get(\"endpoint\"));\n        return {\n          url: endpoint.href,\n          snippetId: params.get(\"snippetId\"),\n        };\n      } catch (e) {}\n    }\n\n    return null;\n  },\n};\n\n// Note: nextProps/prevProps refer to props passed to <ImpressionsWrapper />, not <ASRouterUISurface />\nfunction shouldSendImpressionOnUpdate(nextProps, prevProps) {\n  return (nextProps.message.id && (!prevProps.message || prevProps.message.id !== nextProps.message.id));\n}\n\nfunction generateMessages(content) {\n  const cx = new MessageContext(\"en-US\");\n  cx.addMessages(`RichTextSnippet = ${content}`);\n  return [cx];\n}\n\n// Elements allowed in snippet content\nconst ALLOWED_TAGS = {\n  b: <b />,\n  i: <i />,\n  u: <u />,\n  strong: <strong />,\n  em: <em />,\n  br: <br />,\n};\n\n/**\n * Transform an object (tag name: {url}) into (tag name: anchor) where the url\n * is used as href, in order to render links inside a Fluent.Localized component.\n */\nexport function convertLinks(links, sendClick) {\n  if (links) {\n    return Object.keys(links).reduce((acc, linkTag) => {\n      acc[linkTag] = <a href={safeURI(links[linkTag].url)} data-metric={links[linkTag].metric} onClick={sendClick} />;\n      return acc;\n    }, {});\n  }\n\n  return null;\n}\n\n/**\n * Message wrapper used to sanitize markup and render HTML.\n */\nfunction RichText(props) {\n  return (\n    <Localized id=\"RichTextSnippet\" {...ALLOWED_TAGS} {...convertLinks(props.links, props.sendClick)}>\n      <span>{props.text}</span>\n    </Localized>\n  );\n}\n\nexport class ASRouterUISurface extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onMessageFromParent = this.onMessageFromParent.bind(this);\n    this.sendClick = this.sendClick.bind(this);\n    this.sendImpression = this.sendImpression.bind(this);\n    this.sendUserActionTelemetry = this.sendUserActionTelemetry.bind(this);\n    this.state = {message: {}, bundle: {}};\n  }\n\n  sendUserActionTelemetry(extraProps = {}) {\n    const {message, bundle} = this.state;\n    if (!message && !extraProps.message_id) {\n      throw new Error(`You must provide a message_id for bundled messages`);\n    }\n    const eventType = `${message.provider || bundle.provider}_user_event`;\n    ASRouterUtils.sendTelemetry({\n      message_id: message.id || extraProps.message_id,\n      source: extraProps.id,\n      action: eventType,\n      ...extraProps,\n    });\n  }\n\n  sendImpression(extraProps) {\n    if (this.state.message.provider === \"preview\") {\n      return;\n    }\n\n    ASRouterUtils.sendMessage({type: \"IMPRESSION\", data: this.state.message});\n    this.sendUserActionTelemetry({event: \"IMPRESSION\", ...extraProps});\n  }\n\n  // If link has a `metric` data attribute send it as part of the `value`\n  // telemetry field which can have arbitrary values.\n  // Used for router messages with links as part of the content.\n  sendClick(event) {\n    if (this.state.message.provider === \"preview\") {\n      return;\n    }\n\n    const metric = {\n      value: event.target.dataset.metric,\n      // Used for the `source` of the event. Needed to differentiate\n      // from other snippet or onboarding events that may occur.\n      id: \"NEWTAB_FOOTER_BAR_CONTENT\",\n    };\n    this.sendUserActionTelemetry({event: \"CLICK_BUTTON\", ...metric});\n    if (!this.state.message.content.do_not_autoblock) {\n      ASRouterUtils.blockById(this.state.message.id);\n    }\n  }\n\n  onBlockById(id) {\n    return () => ASRouterUtils.blockById(id);\n  }\n\n  clearBundle(bundle) {\n    return () => ASRouterUtils.blockBundle(bundle);\n  }\n\n  onMessageFromParent({data: action}) {\n    switch (action.type) {\n      case \"SET_MESSAGE\":\n        this.setState({message: action.data});\n        break;\n      case \"SET_BUNDLED_MESSAGES\":\n        this.setState({bundle: action.data});\n        break;\n      case \"CLEAR_MESSAGE\":\n        if (action.data.id === this.state.message.id) {\n          this.setState({message: {}});\n        }\n        break;\n      case \"CLEAR_PROVIDER\":\n        if (action.data.id === this.state.message.provider) {\n          this.setState({message: {}});\n        }\n        break;\n      case \"CLEAR_BUNDLE\":\n        if (this.state.bundle.bundle) {\n          this.setState({bundle: {}});\n        }\n        break;\n      case \"CLEAR_ALL\":\n        this.setState({message: {}, bundle: {}});\n    }\n  }\n\n  componentWillMount() {\n    const endpoint = ASRouterUtils.getPreviewEndpoint();\n    ASRouterUtils.addListener(this.onMessageFromParent);\n\n    // If we are loading about:welcome we want to trigger the onboarding messages\n    if (this.props.document.location.href === \"about:welcome\") {\n      ASRouterUtils.sendMessage({type: \"TRIGGER\", data: {trigger: {id: \"firstRun\"}}});\n    } else {\n      ASRouterUtils.sendMessage({type: \"SNIPPETS_REQUEST\", data: {endpoint}});\n    }\n  }\n\n  componentWillUnmount() {\n    ASRouterUtils.removeListener(this.onMessageFromParent);\n  }\n\n  renderSnippets() {\n    return (\n      <ImpressionsWrapper\n        id=\"NEWTAB_FOOTER_BAR\"\n        message={this.state.message}\n        sendImpression={this.sendImpression}\n        shouldSendImpressionOnUpdate={shouldSendImpressionOnUpdate}\n        // This helps with testing\n        document={this.props.document}>\n          <LocalizationProvider messages={generateMessages(this.state.message.content.text)}>\n            <SimpleSnippet\n              {...this.state.message}\n              richText={<RichText text={this.state.message.content.text}\n                                  links={this.state.message.content.links}\n                                  sendClick={this.sendClick} />}\n              UISurface=\"NEWTAB_FOOTER_BAR\"\n              onBlock={this.onBlockById(this.state.message.id)}\n              onAction={ASRouterUtils.executeAction}\n              sendUserActionTelemetry={this.sendUserActionTelemetry} />\n          </LocalizationProvider>\n      </ImpressionsWrapper>);\n  }\n\n  renderOnboarding() {\n    return (\n      <OnboardingMessage\n        {...this.state.bundle}\n        UISurface=\"NEWTAB_OVERLAY\"\n        onAction={ASRouterUtils.executeAction}\n        onDoneButton={this.clearBundle(this.state.bundle.bundle)}\n        sendUserActionTelemetry={this.sendUserActionTelemetry} />);\n  }\n\n  renderPreviewBanner() {\n    if (this.state.message.provider !== \"preview\") {\n      return null;\n    }\n\n    return (\n      <div className=\"snippets-preview-banner\">\n        <span className=\"icon icon-small-spacer icon-info\" />\n        <span>Preview Purposes Only</span>\n      </div>\n    );\n  }\n\n  render() {\n    const {message, bundle} = this.state;\n    if (!message.id && !bundle.template) { return null; }\n    return (\n      <React.Fragment>\n        {this.renderPreviewBanner()}\n        {bundle.template === \"onboarding\" ? this.renderOnboarding() : this.renderSnippets()}\n      </React.Fragment>\n    );\n  }\n}\n\nASRouterUISurface.defaultProps = {document: global.document};\n\nexport class ASRouterContent {\n  constructor() {\n    this.initialized = false;\n    this.containerElement = null;\n  }\n\n  _mount() {\n    this.containerElement = global.document.getElementById(ASR_CONTAINER_ID);\n    if (!this.containerElement) {\n      this.containerElement = global.document.createElement(\"div\");\n      this.containerElement.id = ASR_CONTAINER_ID;\n      this.containerElement.style.zIndex = 1;\n      global.document.body.appendChild(this.containerElement);\n    }\n\n    ReactDOM.render(<ASRouterUISurface />, this.containerElement);\n  }\n\n  _unmount() {\n    ReactDOM.unmountComponentAtNode(this.containerElement);\n  }\n\n  init() {\n    this._mount();\n    this.initialized = true;\n  }\n\n  uninit() {\n    if (this.initialized) {\n      this._unmount();\n      this.initialized = false;\n    }\n  }\n}\n","module.exports = React;","module.exports = PropTypes;","/* eslint-env mozilla/frame-script */\n\nimport {actionCreators as ac, actionTypes as at, actionUtils as au} from \"common/Actions.jsm\";\nimport {applyMiddleware, combineReducers, createStore} from \"redux\";\n\nexport const MERGE_STORE_ACTION = \"NEW_TAB_INITIAL_STATE\";\nexport const OUTGOING_MESSAGE_NAME = \"ActivityStream:ContentToMain\";\nexport const INCOMING_MESSAGE_NAME = \"ActivityStream:MainToContent\";\nexport const EARLY_QUEUED_ACTIONS = [at.SAVE_SESSION_PERF_DATA, at.PAGE_PRERENDERED];\n\n/**\n * A higher-order function which returns a reducer that, on MERGE_STORE action,\n * will return the action.data object merged into the previous state.\n *\n * For all other actions, it merely calls mainReducer.\n *\n * Because we want this to merge the entire state object, it's written as a\n * higher order function which takes the main reducer (itself often a call to\n * combineReducers) as a parameter.\n *\n * @param  {function} mainReducer reducer to call if action != MERGE_STORE_ACTION\n * @return {function}             a reducer that, on MERGE_STORE_ACTION action,\n *                                will return the action.data object merged\n *                                into the previous state, and the result\n *                                of calling mainReducer otherwise.\n */\nfunction mergeStateReducer(mainReducer) {\n  return (prevState, action) => {\n    if (action.type === MERGE_STORE_ACTION) {\n      return {...prevState, ...action.data};\n    }\n\n    return mainReducer(prevState, action);\n  };\n}\n\n/**\n * messageMiddleware - Middleware that looks for SentToMain type actions, and sends them if necessary\n */\nconst messageMiddleware = store => next => action => {\n  const skipLocal = action.meta && action.meta.skipLocal;\n  if (au.isSendToMain(action)) {\n    RPMSendAsyncMessage(OUTGOING_MESSAGE_NAME, action);\n  }\n  if (!skipLocal) {\n    next(action);\n  }\n};\n\nexport const rehydrationMiddleware = store => next => action => {\n  if (store._didRehydrate) {\n    return next(action);\n  }\n\n  const isMergeStoreAction = action.type === MERGE_STORE_ACTION;\n  const isRehydrationRequest = action.type === at.NEW_TAB_STATE_REQUEST;\n\n  if (isRehydrationRequest) {\n    store._didRequestInitialState = true;\n    return next(action);\n  }\n\n  if (isMergeStoreAction) {\n    store._didRehydrate = true;\n    return next(action);\n  }\n\n  // If init happened after our request was made, we need to re-request\n  if (store._didRequestInitialState && action.type === at.INIT) {\n    return next(ac.AlsoToMain({type: at.NEW_TAB_STATE_REQUEST}));\n  }\n\n  if (au.isBroadcastToContent(action) || au.isSendToOneContent(action) || au.isSendToPreloaded(action)) {\n    // Note that actions received before didRehydrate will not be dispatched\n    // because this could negatively affect preloading and the the state\n    // will be replaced by rehydration anyway.\n    return null;\n  }\n\n  return next(action);\n};\n\n/**\n * This middleware queues up all the EARLY_QUEUED_ACTIONS until it receives\n * the first action from main. This is useful for those actions for main which\n * require higher reliability, i.e. the action will not be lost in the case\n * that it gets sent before the main is ready to receive it. Conversely, any\n * actions allowed early are accepted to be ignorable or re-sendable.\n */\nexport const queueEarlyMessageMiddleware = store => next => action => {\n  if (store._receivedFromMain) {\n    next(action);\n  } else if (au.isFromMain(action)) {\n    next(action);\n    store._receivedFromMain = true;\n    // Sending out all the early actions as main is ready now\n    if (store._earlyActionQueue) {\n      store._earlyActionQueue.forEach(next);\n      store._earlyActionQueue = [];\n    }\n  } else if (EARLY_QUEUED_ACTIONS.includes(action.type)) {\n    store._earlyActionQueue = store._earlyActionQueue || [];\n    store._earlyActionQueue.push(action);\n  } else {\n    // Let any other type of action go through\n    next(action);\n  }\n};\n\n/**\n * initStore - Create a store and listen for incoming actions\n *\n * @param  {object} reducers An object containing Redux reducers\n * @param  {object} intialState (optional) The initial state of the store, if desired\n * @return {object}          A redux store\n */\nexport function initStore(reducers, initialState) {\n  const store = createStore(\n    mergeStateReducer(combineReducers(reducers)),\n    initialState,\n    global.RPMAddMessageListener && applyMiddleware(rehydrationMiddleware, queueEarlyMessageMiddleware, messageMiddleware)\n  );\n\n  store._didRehydrate = false;\n  store._didRequestInitialState = false;\n\n  if (global.RPMAddMessageListener) {\n    global.RPMAddMessageListener(INCOMING_MESSAGE_NAME, msg => {\n      try {\n        store.dispatch(msg.data);\n      } catch (ex) {\n        console.error(\"Content msg:\", msg, \"Dispatch error: \", ex); // eslint-disable-line no-console\n        dump(`Content msg: ${JSON.stringify(msg)}\\nDispatch error: ${ex}\\n${ex.stack}`);\n      }\n    });\n  }\n\n  return store;\n}\n","module.exports = Redux;","import React from \"react\";\n\nexport const VISIBLE = \"visible\";\nexport const VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\n\n/**\n * Component wrapper used to send telemetry pings on every impression.\n */\nexport class ImpressionsWrapper extends React.PureComponent {\n  // This sends an event when a user sees a set of new content. If content\n  // changes while the page is hidden (i.e. preloaded or on a hidden tab),\n  // only send the event if the page becomes visible again.\n  sendImpressionOrAddListener() {\n    if (this.props.document.visibilityState === VISIBLE) {\n      this.props.sendImpression({id: this.props.id});\n    } else {\n      // We should only ever send the latest impression stats ping, so remove any\n      // older listeners.\n      if (this._onVisibilityChange) {\n        this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n      }\n\n      // When the page becomes visible, send the impression stats ping if the section isn't collapsed.\n      this._onVisibilityChange = () => {\n        if (this.props.document.visibilityState === VISIBLE) {\n          this.props.sendImpression({id: this.props.id});\n          this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n        }\n      };\n      this.props.document.addEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  componentWillUnmount() {\n    if (this._onVisibilityChange) {\n      this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  componentDidMount() {\n    if (this.props.sendOnMount) {\n      this.sendImpressionOrAddListener();\n    }\n  }\n\n  componentDidUpdate(prevProps) {\n    if (this.props.shouldSendImpressionOnUpdate(this.props, prevProps)) {\n      this.sendImpressionOrAddListener();\n    }\n  }\n\n  render() {\n    return this.props.children;\n  }\n}\n\nImpressionsWrapper.defaultProps = {\n  document: global.document,\n  sendOnMount: true,\n};\n","module.exports = ReactDOM;","export function safeURI(url) {\n  if (!url) {\n    return \"\";\n  }\n  const {protocol} = new URL(url);\n  const isAllowed = [\n    \"http:\",\n    \"https:\",\n    \"data:\",\n    \"resource:\",\n    \"chrome:\",\n  ].includes(protocol);\n  if (!isAllowed) {\n    console.warn(`The protocol ${protocol} is not allowed for template URLs.`); // eslint-disable-line no-console\n  }\n  return isAllowed ? url : \"\";\n}\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {addLocaleData, injectIntl, IntlProvider} from \"react-intl\";\nimport {ASRouterAdmin} from \"content-src/components/ASRouterAdmin/ASRouterAdmin\";\nimport {ConfirmDialog} from \"content-src/components/ConfirmDialog/ConfirmDialog\";\nimport {connect} from \"react-redux\";\nimport {ErrorBoundary} from \"content-src/components/ErrorBoundary/ErrorBoundary\";\nimport {ManualMigration} from \"content-src/components/ManualMigration/ManualMigration\";\nimport {PrerenderData} from \"common/PrerenderData.jsm\";\nimport React from \"react\";\nimport {Search} from \"content-src/components/Search/Search\";\nimport {Sections} from \"content-src/components/Sections/Sections\";\nimport {StartupOverlay} from \"content-src/components/StartupOverlay/StartupOverlay\";\n\nconst PrefsButton = injectIntl(props => (\n  <div className=\"prefs-button\">\n    <button className=\"icon icon-settings\" onClick={props.onClick} title={props.intl.formatMessage({id: \"settings_pane_button_label\"})} />\n  </div>\n));\n\n// Add the locale data for pluralization and relative-time formatting for now,\n// this just uses english locale data. We can make this more sophisticated if\n// more features are needed.\nfunction addLocaleDataForReactIntl(locale) {\n  addLocaleData([{locale, parentLocale: \"en\"}]);\n}\n\n// Returns a function will not be continuously triggered when called. The\n// function will be triggered if called again after `wait` milliseconds.\nfunction debounce(func, wait) {\n  let timer;\n  return (...args) => {\n    if (timer) { return; }\n\n    let wakeUp = () => { timer = null; };\n\n    timer = setTimeout(wakeUp, wait);\n    func.apply(this, args);\n  };\n}\n\nexport class _Base extends React.PureComponent {\n  componentWillMount() {\n    const {locale} = this.props;\n    addLocaleDataForReactIntl(locale);\n    if (this.props.isFirstrun) {\n      global.document.body.classList.add(\"welcome\", \"hide-main\");\n    }\n  }\n\n  componentDidMount() {\n    // Request state AFTER the first render to ensure we don't cause the\n    // prerendered DOM to be unmounted. Otherwise, NEW_TAB_STATE_REQUEST is\n    // dispatched right after the store is ready.\n    if (this.props.isPrerendered) {\n      this.props.dispatch(ac.AlsoToMain({type: at.NEW_TAB_STATE_REQUEST}));\n      this.props.dispatch(ac.AlsoToMain({type: at.PAGE_PRERENDERED}));\n    }\n  }\n\n  componentWillUnmount() {\n    this.updateTheme();\n  }\n\n  componentWillUpdate() {\n    this.updateTheme();\n  }\n\n  updateTheme() {\n    const bodyClassName = [\n      \"activity-stream\",\n      // If we skipped the about:welcome overlay and removed the CSS classes\n      // we don't want to add them back to the Activity Stream view\n      document.body.classList.contains(\"welcome\") ? \"welcome\" : \"\",\n      document.body.classList.contains(\"hide-main\") ? \"hide-main\" : \"\",\n    ].filter(v => v).join(\" \");\n    global.document.body.className = bodyClassName;\n  }\n\n  render() {\n    const {props} = this;\n    const {App, locale, strings} = props;\n    const {initialized} = App;\n\n    const prefs = props.Prefs.values;\n    if (prefs[\"asrouter.devtoolsEnabled\"] && window.location.hash === \"#asrouter\") {\n      return (<ASRouterAdmin />);\n    }\n\n    if (!props.isPrerendered && !initialized) {\n      return null;\n    }\n\n    return (<IntlProvider locale={locale} messages={strings}>\n        <ErrorBoundary className=\"base-content-fallback\">\n          <BaseContent {...this.props} />\n        </ErrorBoundary>\n      </IntlProvider>);\n  }\n}\n\nexport class BaseContent extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.openPreferences = this.openPreferences.bind(this);\n    this.onWindowScroll = debounce(this.onWindowScroll.bind(this), 5);\n    this.state = {fixedSearch: false};\n  }\n\n  componentDidMount() {\n    global.addEventListener(\"scroll\", this.onWindowScroll);\n  }\n\n  componentWillUnmount() {\n    global.removeEventListener(\"scroll\", this.onWindowScroll);\n  }\n\n  onWindowScroll() {\n    const SCROLL_THRESHOLD = 34;\n    if (global.scrollY > SCROLL_THRESHOLD && !this.state.fixedSearch) {\n      this.setState({fixedSearch: true});\n    } else if (global.scrollY <= SCROLL_THRESHOLD && this.state.fixedSearch) {\n      this.setState({fixedSearch: false});\n    }\n  }\n\n  openPreferences() {\n    this.props.dispatch(ac.OnlyToMain({type: at.SETTINGS_OPEN}));\n    this.props.dispatch(ac.UserEvent({event: \"OPEN_NEWTAB_PREFS\"}));\n  }\n\n  render() {\n    const {props} = this;\n    const {App} = props;\n    const {initialized} = App;\n    const prefs = props.Prefs.values;\n\n    const shouldBeFixedToTop = PrerenderData.arePrefsValid(name => prefs[name]);\n    const noSectionsEnabled = !prefs[\"feeds.topsites\"] && props.Sections.filter(section => section.enabled).length === 0;\n\n    const outerClassName = [\n      \"outer-wrapper\",\n      shouldBeFixedToTop && \"fixed-to-top\",\n      prefs.showSearch && this.state.fixedSearch && !noSectionsEnabled && \"fixed-search\",\n      prefs.showSearch && noSectionsEnabled && \"only-search\",\n    ].filter(v => v).join(\" \");\n\n    return (\n      <div>\n        <div className={outerClassName}>\n          <main>\n            {prefs.showSearch &&\n              <div className=\"non-collapsible-section\">\n                <ErrorBoundary>\n                  <Search showLogo={noSectionsEnabled} />\n                </ErrorBoundary>\n              </div>\n            }\n            <div className={`body-wrapper${(initialized ? \" on\" : \"\")}`}>\n              {!prefs.migrationExpired &&\n                <div className=\"non-collapsible-section\">\n                  <ManualMigration />\n                </div>\n                }\n              <Sections />\n              <PrefsButton onClick={this.openPreferences} />\n            </div>\n            <ConfirmDialog />\n          </main>\n        </div>\n        {this.props.isFirstrun && <StartupOverlay />}\n      </div>);\n  }\n}\n\nexport const Base = connect(state => ({App: state.App, Prefs: state.Prefs, Sections: state.Sections}))(_Base);\n","module.exports = ReactIntl;","import {ASRouterUtils} from \"../../asrouter/asrouter-content\";\nimport React from \"react\";\n\nexport class ASRouterAdmin extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onMessage = this.onMessage.bind(this);\n    this.findOtherBundledMessagesOfSameTemplate = this.findOtherBundledMessagesOfSameTemplate.bind(this);\n    this.state = {};\n  }\n\n  onMessage({data: action}) {\n    if (action.type === \"ADMIN_SET_STATE\") {\n      this.setState(action.data);\n    }\n  }\n\n  componentWillMount() {\n    const endpoint = ASRouterUtils.getPreviewEndpoint();\n    ASRouterUtils.sendMessage({type: \"ADMIN_CONNECT_STATE\", data: {endpoint}});\n    ASRouterUtils.addListener(this.onMessage);\n  }\n\n  componentWillUnmount() {\n    ASRouterUtils.removeListener(this.onMessage);\n  }\n\n  findOtherBundledMessagesOfSameTemplate(template) {\n    return this.state.messages.filter(msg => msg.template === template && msg.bundled);\n  }\n\n  handleBlock(msg) {\n    if (msg.bundled) {\n      // If we are blocking a message that belongs to a bundle, block all other messages that are bundled of that same template\n      let bundle = this.findOtherBundledMessagesOfSameTemplate(msg.template);\n      return () => ASRouterUtils.blockBundle(bundle);\n    }\n    return () => ASRouterUtils.blockById(msg.id);\n  }\n\n  handleUnblock(msg) {\n    if (msg.bundled) {\n      // If we are unblocking a message that belongs to a bundle, unblock all other messages that are bundled of that same template\n      let bundle = this.findOtherBundledMessagesOfSameTemplate(msg.template);\n      return () => ASRouterUtils.unblockBundle(bundle);\n    }\n    return () => ASRouterUtils.unblockById(msg.id);\n  }\n\n  handleOverride(id) {\n    return () => ASRouterUtils.overrideMessage(id);\n  }\n\n  expireCache() {\n    ASRouterUtils.sendMessage({type: \"EXPIRE_QUERY_CACHE\"});\n  }\n\n  renderMessageItem(msg) {\n    const isCurrent = msg.id === this.state.lastMessageId;\n    const isBlocked = this.state.messageBlockList.includes(msg.id);\n    const impressions = this.state.messageImpressions[msg.id] ? this.state.messageImpressions[msg.id].length : 0;\n\n    let itemClassName = \"message-item\";\n    if (isCurrent) { itemClassName += \" current\"; }\n    if (isBlocked) { itemClassName += \" blocked\"; }\n\n    return (<tr className={itemClassName} key={msg.id}>\n      <td className=\"message-id\"><span>{msg.id} <br /></span></td>\n      <td>\n        <button className={`button ${(isBlocked ? \"\" : \" primary\")}`} onClick={isBlocked ? this.handleUnblock(msg) : this.handleBlock(msg)}>{isBlocked ? \"Unblock\" : \"Block\"}</button>\n       {isBlocked ? null : <button className=\"button\" onClick={this.handleOverride(msg.id)}>Show</button>}\n       <br />({impressions} impressions)\n      </td>\n      <td className=\"message-summary\">\n        <pre>{JSON.stringify(msg, null, 2)}</pre>\n      </td>\n    </tr>);\n  }\n\n  renderMessages() {\n    if (!this.state.messages) {\n      return null;\n    }\n    return (<table><tbody>\n      {this.state.messages.map(msg => this.renderMessageItem(msg))}\n    </tbody></table>);\n  }\n\n  renderTableHead() {\n    return (<thead>\n      <tr className=\"message-item\">\n        <td>id</td>\n        <td>source</td>\n        <td>last updated</td>\n      </tr>\n    </thead>);\n  }\n\n  renderProviders() {\n    return (<table>{this.renderTableHead()}<tbody>\n      {this.state.providers.map((provider, i) => {\n        let label = \"(local)\";\n        if (provider.type === \"remote\") {\n          label = <a target=\"_blank\" href={provider.url}>{provider.url}</a>;\n        } else if (provider.type === \"remote-settings\") {\n          label = `${provider.bucket} (Remote Settings)`;\n        }\n        return (<tr className=\"message-item\" key={i}>\n          <td>{provider.id}</td>\n          <td>{label}</td>\n          <td>{provider.lastUpdated ? new Date(provider.lastUpdated).toString() : \"\"}</td>\n        </tr>);\n      })}\n    </tbody></table>);\n  }\n\n  render() {\n    return (<div className=\"asrouter-admin outer-wrapper\">\n      <h1>AS Router Admin</h1>\n      <h2>Targeting Utilities</h2>\n      <button className=\"button\" onClick={this.expireCache}>Expire Cache</button> (This expires the cache in ASR Targeting for bookmarks and top sites)\n      <h2>Message Providers</h2>\n      {this.state.providers ? this.renderProviders() : null}\n      <h2>Messages</h2>\n      {this.renderMessages()}\n    </div>);\n  }\n}\n","import {actionCreators as ac, actionTypes} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\n/**\n * ConfirmDialog component.\n * One primary action button, one cancel button.\n *\n * Content displayed is controlled by `data` prop the component receives.\n * Example:\n * data: {\n *   // Any sort of data needed to be passed around by actions.\n *   payload: site.url,\n *   // Primary button AlsoToMain action.\n *   action: \"DELETE_HISTORY_URL\",\n *   // Primary button USerEvent action.\n *   userEvent: \"DELETE\",\n *   // Array of locale ids to display.\n *   message_body: [\"confirm_history_delete_p1\", \"confirm_history_delete_notice_p2\"],\n *   // Text for primary button.\n *   confirm_button_string_id: \"menu_action_delete\"\n * },\n */\nexport class _ConfirmDialog extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this._handleCancelBtn = this._handleCancelBtn.bind(this);\n    this._handleConfirmBtn = this._handleConfirmBtn.bind(this);\n  }\n\n  _handleCancelBtn() {\n    this.props.dispatch({type: actionTypes.DIALOG_CANCEL});\n    this.props.dispatch(ac.UserEvent({event: actionTypes.DIALOG_CANCEL, source: this.props.data.eventSource}));\n  }\n\n  _handleConfirmBtn() {\n    this.props.data.onConfirm.forEach(this.props.dispatch);\n  }\n\n  _renderModalMessage() {\n    const message_body = this.props.data.body_string_id;\n\n    if (!message_body) {\n      return null;\n    }\n\n    return (<span>\n      {message_body.map(msg => <p key={msg}><FormattedMessage id={msg} /></p>)}\n    </span>);\n  }\n\n  render() {\n    if (!this.props.visible) {\n      return null;\n    }\n\n    return (<div className=\"confirmation-dialog\">\n      <div className=\"modal-overlay\" onClick={this._handleCancelBtn} />\n      <div className=\"modal\">\n        <section className=\"modal-message\">\n          {this.props.data.icon && <span className={`icon icon-spacer icon-${this.props.data.icon}`} />}\n          {this._renderModalMessage()}\n        </section>\n        <section className=\"actions\">\n          <button onClick={this._handleCancelBtn}>\n            <FormattedMessage id={this.props.data.cancel_button_string_id} />\n          </button>\n          <button className=\"done\" onClick={this._handleConfirmBtn}>\n            <FormattedMessage id={this.props.data.confirm_button_string_id} />\n          </button>\n        </section>\n      </div>\n    </div>);\n  }\n}\n\nexport const ConfirmDialog = connect(state => state.Dialog)(_ConfirmDialog);\n","module.exports = ReactRedux;","import {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class ErrorBoundaryFallback extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.windowObj = this.props.windowObj || window;\n    this.onClick = this.onClick.bind(this);\n  }\n\n  /**\n   * Since we only get here if part of the page has crashed, do a\n   * forced reload to give us the best chance at recovering.\n   */\n  onClick() {\n    this.windowObj.location.reload(true);\n  }\n\n  render() {\n    const defaultClass = \"as-error-fallback\";\n    let className;\n    if (\"className\" in this.props) {\n      className = `${this.props.className} ${defaultClass}`;\n    } else {\n      className = defaultClass;\n    }\n\n    // href=\"#\" to force normal link styling stuff (eg cursor on hover)\n    return (\n      <div className={className}>\n        <div>\n          <FormattedMessage\n            defaultMessage=\"Oops, something went wrong loading this content.\"\n            id=\"error_fallback_default_info\" />\n        </div>\n        <span>\n          <a href=\"#\" className=\"reload-button\" onClick={this.onClick}>\n            <FormattedMessage\n              defaultMessage=\"Refresh page to try again.\"\n              id=\"error_fallback_default_refresh_suggestion\" />\n          </a>\n        </span>\n      </div>\n    );\n  }\n}\nErrorBoundaryFallback.defaultProps = {className: \"as-error-fallback\"};\n\nexport class ErrorBoundary extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {hasError: false};\n  }\n\n  componentDidCatch(error, info) {\n    this.setState({hasError: true});\n  }\n\n  render() {\n    if (!this.state.hasError) {\n      return (this.props.children);\n    }\n\n    return <this.props.FallbackComponent className={this.props.className} />;\n  }\n}\n\nErrorBoundary.defaultProps = {FallbackComponent: ErrorBoundaryFallback};\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\n/**\n * Manual migration component used to start the profile import wizard.\n * Message is presented temporarily and will go away if:\n * 1.  User clicks \"No Thanks\"\n * 2.  User completed the data import\n * 3.  After 3 active days\n * 4.  User clicks \"Cancel\" on the import wizard (currently not implemented).\n */\nexport class _ManualMigration extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onLaunchTour = this.onLaunchTour.bind(this);\n    this.onCancelTour = this.onCancelTour.bind(this);\n  }\n\n  onLaunchTour() {\n    this.props.dispatch(ac.AlsoToMain({type: at.MIGRATION_START}));\n    this.props.dispatch(ac.UserEvent({event: at.MIGRATION_START}));\n  }\n\n  onCancelTour() {\n    this.props.dispatch(ac.AlsoToMain({type: at.MIGRATION_CANCEL}));\n    this.props.dispatch(ac.UserEvent({event: at.MIGRATION_CANCEL}));\n  }\n\n  render() {\n    return (<div className=\"manual-migration-container\">\n        <p>\n          <span className=\"icon icon-import\" />\n          <FormattedMessage id=\"manual_migration_explanation2\" />\n        </p>\n        <div className=\"manual-migration-actions actions\">\n          <button className=\"dismiss\" onClick={this.onCancelTour}>\n            <FormattedMessage id=\"manual_migration_cancel_button\" />\n          </button>\n          <button onClick={this.onLaunchTour}>\n            <FormattedMessage id=\"manual_migration_import_button\" />\n          </button>\n        </div>\n    </div>);\n  }\n}\n\nexport const ManualMigration = connect()(_ManualMigration);\n","class _PrerenderData {\n  constructor(options) {\n    this.initialPrefs = options.initialPrefs;\n    this.initialSections = options.initialSections;\n    this._setValidation(options.validation);\n  }\n\n  get validation() {\n    return this._validation;\n  }\n\n  set validation(value) {\n    this._setValidation(value);\n  }\n\n  get invalidatingPrefs() {\n    return this._invalidatingPrefs;\n  }\n\n    // This is needed so we can use it in the constructor\n  _setValidation(value = []) {\n    this._validation = value;\n    this._invalidatingPrefs = value.reduce((result, next) => {\n      if (typeof next === \"string\") {\n        result.push(next);\n        return result;\n      } else if (next && next.oneOf) {\n        return result.concat(next.oneOf);\n      } else if (next && next.indexedDB) {\n        return result.concat(next.indexedDB);\n      }\n      throw new Error(\"Your validation configuration is not properly configured\");\n    }, []);\n  }\n\n  arePrefsValid(getPref, indexedDBPrefs) {\n    for (const prefs of this.validation) {\n      // {oneOf: [\"foo\", \"bar\"]}\n      if (prefs && prefs.oneOf && !prefs.oneOf.some(name => getPref(name) === this.initialPrefs[name])) {\n        return false;\n\n        // {indexedDB: [\"foo\", \"bar\"]}\n      } else if (indexedDBPrefs && prefs && prefs.indexedDB) {\n        const anyModifiedPrefs = prefs.indexedDB.some(prefName => indexedDBPrefs.some(pref => pref && pref[prefName]));\n        if (anyModifiedPrefs) {\n          return false;\n        }\n        // \"foo\"\n      } else if (getPref(prefs) !== this.initialPrefs[prefs]) {\n        return false;\n      }\n    }\n    return true;\n  }\n}\n\nthis.PrerenderData = new _PrerenderData({\n  initialPrefs: {\n    \"migrationExpired\": true,\n    \"feeds.topsites\": true,\n    \"showSearch\": true,\n    \"topSitesRows\": 1,\n    \"feeds.section.topstories\": true,\n    \"feeds.section.highlights\": true,\n    \"sectionOrder\": \"topsites,topstories,highlights\",\n    \"collapsed\": false,\n  },\n  // Prefs listed as invalidating will prevent the prerendered version\n  // of AS from being used if their value is something other than what is listed\n  // here. This is required because some preferences cause the page layout to be\n  // too different for the prerendered version to be used. Unfortunately, this\n  // will result in users who have modified some of their preferences not being\n  // able to get the benefits of prerendering.\n  validation: [\n    \"feeds.topsites\",\n    \"showSearch\",\n    \"topSitesRows\",\n    \"sectionOrder\",\n    // This means if either of these are set to their default values,\n    // prerendering can be used.\n    {oneOf: [\"feeds.section.topstories\", \"feeds.section.highlights\"]},\n    // If any component has the following preference set to `true` it will\n    // invalidate the prerendered version.\n    {indexedDB: [\"collapsed\"]},\n  ],\n  initialSections: [\n    {\n      enabled: true,\n      icon: \"pocket\",\n      id: \"topstories\",\n      order: 1,\n      title: {id: \"header_recommended_by\", values: {provider: \"Pocket\"}},\n    },\n    {\n      enabled: true,\n      id: \"highlights\",\n      icon: \"highlights\",\n      order: 2,\n      title: {id: \"header_highlights\"},\n    },\n  ],\n});\n\nthis._PrerenderData = _PrerenderData;\nconst EXPORTED_SYMBOLS = [\"PrerenderData\", \"_PrerenderData\"];\n","/* globals ContentSearchUIController */\n\"use strict\";\n\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {actionCreators as ac} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {IS_NEWTAB} from \"content-src/lib/constants\";\nimport React from \"react\";\n\nexport class _Search extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onClick = this.onClick.bind(this);\n    this.onInputMount = this.onInputMount.bind(this);\n  }\n\n  handleEvent(event) {\n    // Also track search events with our own telemetry\n    if (event.detail.type === \"Search\") {\n      this.props.dispatch(ac.UserEvent({event: \"SEARCH\"}));\n    }\n  }\n\n  onClick(event) {\n    window.gContentSearchController.search(event);\n  }\n\n  componentWillUnmount() {\n    delete window.gContentSearchController;\n  }\n\n  onInputMount(input) {\n    if (input) {\n      // The \"healthReportKey\" and needs to be \"newtab\" or \"abouthome\" so that\n      // BrowserUsageTelemetry.jsm knows to handle events with this name, and\n      // can add the appropriate telemetry probes for search. Without the correct\n      // name, certain tests like browser_UsageTelemetry_content.js will fail\n      // (See github ticket #2348 for more details)\n      const healthReportKey = IS_NEWTAB ? \"newtab\" : \"abouthome\";\n\n      // The \"searchSource\" needs to be \"newtab\" or \"homepage\" and is sent with\n      // the search data and acts as context for the search request (See\n      // nsISearchEngine.getSubmission). It is necessary so that search engine\n      // plugins can correctly atribute referrals. (See github ticket #3321 for\n      // more details)\n      const searchSource = IS_NEWTAB ? \"newtab\" : \"homepage\";\n\n      // gContentSearchController needs to exist as a global so that tests for\n      // the existing about:home can find it; and so it allows these tests to pass.\n      // In the future, when activity stream is default about:home, this can be renamed\n      window.gContentSearchController = new ContentSearchUIController(input, input.parentNode,\n        healthReportKey, searchSource);\n      addEventListener(\"ContentSearchClient\", this);\n    } else {\n      window.gContentSearchController = null;\n      removeEventListener(\"ContentSearchClient\", this);\n    }\n  }\n\n  /*\n   * Do not change the ID on the input field, as legacy newtab code\n   * specifically looks for the id 'newtab-search-text' on input fields\n   * in order to execute searches in various tests\n   */\n  render() {\n    return (<div className=\"search-wrapper\">\n      {this.props.showLogo &&\n        <div className=\"logo-and-wordmark\">\n          <div className=\"logo\" />\n          <div className=\"wordmark\" />\n        </div>\n      }\n      <div className=\"search-inner-wrapper\">\n        <label htmlFor=\"newtab-search-text\" className=\"search-label\">\n          <span className=\"sr-only\"><FormattedMessage id=\"search_web_placeholder\" /></span>\n        </label>\n        <input\n          id=\"newtab-search-text\"\n          maxLength=\"256\"\n          placeholder={this.props.intl.formatMessage({id: \"search_web_placeholder\"})}\n          ref={this.onInputMount}\n          title={this.props.intl.formatMessage({id: \"search_web_placeholder\"})}\n          type=\"search\" />\n        <button\n          id=\"searchSubmit\"\n          className=\"search-button\"\n          onClick={this.onClick}\n          title={this.props.intl.formatMessage({id: \"search_button\"})}>\n          <span className=\"sr-only\"><FormattedMessage id=\"search_button\" /></span>\n        </button>\n      </div>\n    </div>);\n  }\n}\n\nexport const Search = connect()(injectIntl(_Search));\n","export const IS_NEWTAB = global.document && global.document.documentURI === \"about:newtab\";\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {Card, PlaceholderCard} from \"content-src/components/Card/Card\";\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {CollapsibleSection} from \"content-src/components/CollapsibleSection/CollapsibleSection\";\nimport {ComponentPerfTimer} from \"content-src/components/ComponentPerfTimer/ComponentPerfTimer\";\nimport {connect} from \"react-redux\";\nimport {MoreRecommendations} from \"content-src/components/MoreRecommendations/MoreRecommendations\";\nimport {PocketLoggedInCta} from \"content-src/components/PocketLoggedInCta/PocketLoggedInCta\";\nimport React from \"react\";\nimport {Topics} from \"content-src/components/Topics/Topics\";\nimport {TopSites} from \"content-src/components/TopSites/TopSites\";\n\nconst VISIBLE = \"visible\";\nconst VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\nconst CARDS_PER_ROW_DEFAULT = 3;\nconst CARDS_PER_ROW_COMPACT_WIDE = 4;\n\nfunction getFormattedMessage(message) {\n  return typeof message === \"string\" ? <span>{message}</span> : <FormattedMessage {...message} />;\n}\n\nexport class Section extends React.PureComponent {\n  get numRows() {\n    const {rowsPref, maxRows, Prefs} = this.props;\n    return rowsPref ? Prefs.values[rowsPref] : maxRows;\n  }\n\n  _dispatchImpressionStats() {\n    const {props} = this;\n    let cardsPerRow = CARDS_PER_ROW_DEFAULT;\n    if (props.compactCards && global.matchMedia(`(min-width: 1072px)`).matches) {\n      // If the section has compact cards and the viewport is wide enough, we show\n      // 4 columns instead of 3.\n      // $break-point-widest = 1072px (from _variables.scss)\n      cardsPerRow = CARDS_PER_ROW_COMPACT_WIDE;\n    }\n    const maxCards = cardsPerRow * this.numRows;\n    const cards = props.rows.slice(0, maxCards);\n\n    if (this.needsImpressionStats(cards)) {\n      props.dispatch(ac.ImpressionStats({\n        source: props.eventSource,\n        tiles: cards.map(link => ({id: link.guid})),\n      }));\n      this.impressionCardGuids = cards.map(link => link.guid);\n    }\n  }\n\n  // This sends an event when a user sees a set of new content. If content\n  // changes while the page is hidden (i.e. preloaded or on a hidden tab),\n  // only send the event if the page becomes visible again.\n  sendImpressionStatsOrAddListener() {\n    const {props} = this;\n\n    if (!props.shouldSendImpressionStats || !props.dispatch) {\n      return;\n    }\n\n    if (props.document.visibilityState === VISIBLE) {\n      this._dispatchImpressionStats();\n    } else {\n      // We should only ever send the latest impression stats ping, so remove any\n      // older listeners.\n      if (this._onVisibilityChange) {\n        props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n      }\n\n      // When the page becomes visible, send the impression stats ping if the section isn't collapsed.\n      this._onVisibilityChange = () => {\n        if (props.document.visibilityState === VISIBLE) {\n          if (!this.props.pref.collapsed) {\n            this._dispatchImpressionStats();\n          }\n          props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n        }\n      };\n      props.document.addEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  componentWillMount() {\n    this.sendNewTabRehydrated(this.props.initialized);\n  }\n\n  componentDidMount() {\n    if (this.props.rows.length && !this.props.pref.collapsed) {\n      this.sendImpressionStatsOrAddListener();\n    }\n  }\n\n  componentDidUpdate(prevProps) {\n    const {props} = this;\n    const isCollapsed = props.pref.collapsed;\n    const wasCollapsed = prevProps.pref.collapsed;\n    if (\n      // Don't send impression stats for the empty state\n      props.rows.length &&\n      (\n        // We only want to send impression stats if the content of the cards has changed\n        // and the section is not collapsed...\n        (props.rows !== prevProps.rows && !isCollapsed) ||\n        // or if we are expanding a section that was collapsed.\n        (wasCollapsed && !isCollapsed)\n      )\n    ) {\n      this.sendImpressionStatsOrAddListener();\n    }\n  }\n\n  componentWillUpdate(nextProps) {\n    this.sendNewTabRehydrated(nextProps.initialized);\n  }\n\n  componentWillUnmount() {\n    if (this._onVisibilityChange) {\n      this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  needsImpressionStats(cards) {\n    if (!this.impressionCardGuids || (this.impressionCardGuids.length !== cards.length)) {\n      return true;\n    }\n\n    for (let i = 0; i < cards.length; i++) {\n      if (cards[i].guid !== this.impressionCardGuids[i]) {\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  // The NEW_TAB_REHYDRATED event is used to inform feeds that their\n  // data has been consumed e.g. for counting the number of tabs that\n  // have rendered that data.\n  sendNewTabRehydrated(initialized) {\n    if (initialized && !this.renderNotified) {\n      this.props.dispatch(ac.AlsoToMain({type: at.NEW_TAB_REHYDRATED, data: {}}));\n      this.renderNotified = true;\n    }\n  }\n\n  render() {\n    const {\n      id, eventSource, title, icon, rows, Pocket, topics,\n      emptyState, dispatch, compactCards, read_more_endpoint,\n      contextMenuOptions, initialized, learnMore,\n      pref, privacyNoticeURL, isFirst, isLast,\n    } = this.props;\n\n    const waitingForSpoc = id === \"topstories\" && this.props.Pocket.waitingForSpoc;\n    const maxCardsPerRow = compactCards ? CARDS_PER_ROW_COMPACT_WIDE : CARDS_PER_ROW_DEFAULT;\n    const {numRows} = this;\n    const maxCards = maxCardsPerRow * numRows;\n    const maxCardsOnNarrow = CARDS_PER_ROW_DEFAULT * numRows;\n\n    const {pocketCta, isUserLoggedIn} = Pocket || {};\n    const {useCta} = pocketCta || {};\n\n    // Don't display anything until we have a definitve result from Pocket,\n    // to avoid a flash of logged out state while we render.\n    const isPocketLoggedInDefined = (isUserLoggedIn === true || isUserLoggedIn === false);\n\n    const shouldShowPocketCta = (id === \"topstories\" &&\n      useCta && isUserLoggedIn === false);\n\n    // Show topics only for top stories and if it has loaded with topics.\n    // The classs .top-stories-bottom-container ensures content doesn't shift as things load.\n    const shouldShowTopics = (id === \"topstories\" &&\n      (topics && topics.length > 0) &&\n      ((useCta && isUserLoggedIn === true) || (!useCta && isPocketLoggedInDefined)));\n\n    const realRows = rows.slice(0, maxCards);\n\n    // The empty state should only be shown after we have initialized and there is no content.\n    // Otherwise, we should show placeholders.\n    const shouldShowEmptyState = initialized && !rows.length;\n\n    const cards = [];\n    if (!shouldShowEmptyState) {\n      for (let i = 0; i < maxCards; i++) {\n        const link = realRows[i];\n        // On narrow viewports, we only show 3 cards per row. We'll mark the rest as\n        // .hide-for-narrow to hide in CSS via @media query.\n        const className = (i >= maxCardsOnNarrow) ? \"hide-for-narrow\" : \"\";\n        let usePlaceholder = !link;\n        // If we are in the third card and waiting for spoc,\n        // use the placeholder.\n        if (!usePlaceholder && i === 2 && waitingForSpoc) {\n          usePlaceholder = true;\n        }\n        cards.push(!usePlaceholder ? (\n          <Card key={i}\n            index={i}\n            className={className}\n            dispatch={dispatch}\n            link={link}\n            contextMenuOptions={contextMenuOptions}\n            eventSource={eventSource}\n            shouldSendImpressionStats={this.props.shouldSendImpressionStats}\n            isWebExtension={this.props.isWebExtension} />\n        ) : (\n          <PlaceholderCard key={i} className={className} />\n        ));\n      }\n    }\n\n    const sectionClassName = [\n      \"section\",\n      compactCards ? \"compact-cards\" : \"normal-cards\",\n    ].join(\" \");\n\n    // <Section> <-- React component\n    // <section> <-- HTML5 element\n    return (<ComponentPerfTimer {...this.props}>\n      <CollapsibleSection className={sectionClassName} icon={icon}\n        title={title}\n        id={id}\n        eventSource={eventSource}\n        collapsed={this.props.pref.collapsed}\n        showPrefName={(pref && pref.feed) || id}\n        privacyNoticeURL={privacyNoticeURL}\n        Prefs={this.props.Prefs}\n        isFirst={isFirst}\n        isLast={isLast}\n        learnMore={learnMore}\n        dispatch={this.props.dispatch}\n        isWebExtension={this.props.isWebExtension}>\n\n        {!shouldShowEmptyState && (<ul className=\"section-list\" style={{padding: 0}}>\n          {cards}\n        </ul>)}\n        {shouldShowEmptyState &&\n          <div className=\"section-empty-state\">\n            <div className=\"empty-state\">\n              {emptyState.icon && emptyState.icon.startsWith(\"moz-extension://\") ?\n                <img className=\"empty-state-icon icon\" style={{\"background-image\": `url('${emptyState.icon}')`}} /> :\n                <img className={`empty-state-icon icon icon-${emptyState.icon}`} />}\n              <p className=\"empty-state-message\">\n                {getFormattedMessage(emptyState.message)}\n              </p>\n            </div>\n          </div>}\n        {id === \"topstories\" &&\n          <div className=\"top-stories-bottom-container\">\n            {shouldShowTopics && <Topics topics={this.props.topics} />}\n            {shouldShowPocketCta && <PocketLoggedInCta />}\n            {read_more_endpoint &&\n              <MoreRecommendations read_more_endpoint={read_more_endpoint} />}\n          </div>}\n      </CollapsibleSection>\n    </ComponentPerfTimer>);\n  }\n}\n\nSection.defaultProps = {\n  document: global.document,\n  rows: [],\n  emptyState: {},\n  pref: {},\n  title: \"\",\n};\n\nexport const SectionIntl = connect(state => ({Prefs: state.Prefs, Pocket: state.Pocket}))(injectIntl(Section));\n\nexport class _Sections extends React.PureComponent {\n  renderSections() {\n    const sections = [];\n    const enabledSections = this.props.Sections.filter(section => section.enabled);\n    const {sectionOrder, \"feeds.topsites\": showTopSites} = this.props.Prefs.values;\n    // Enabled sections doesn't include Top Sites, so we add it if enabled.\n    const expectedCount = enabledSections.length + ~~showTopSites;\n\n    for (const sectionId of sectionOrder.split(\",\")) {\n      const commonProps = {\n        key: sectionId,\n        isFirst: sections.length === 0,\n        isLast: sections.length === expectedCount - 1,\n      };\n      if (sectionId === \"topsites\" && showTopSites) {\n        sections.push(<TopSites {...commonProps} />);\n      } else {\n        const section = enabledSections.find(s => s.id === sectionId);\n        if (section) {\n          sections.push(<SectionIntl {...section} {...commonProps} />);\n        }\n      }\n    }\n    return sections;\n  }\n\n  render() {\n    return (\n      <div className=\"sections-list\">\n        {this.renderSections()}\n      </div>\n    );\n  }\n}\n\nexport const Sections = connect(state => ({Sections: state.Sections, Prefs: state.Prefs}))(_Sections);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\n\nconst _OpenInPrivateWindow = site => ({\n  id: \"menu_action_open_private_window\",\n  icon: \"new-window-private\",\n  action: ac.OnlyToMain({\n    type: at.OPEN_PRIVATE_WINDOW,\n    data: {url: site.url, referrer: site.referrer},\n  }),\n  userEvent: \"OPEN_PRIVATE_WINDOW\",\n});\n\nexport const GetPlatformString = platform => {\n  switch (platform) {\n    case \"win\":\n      return \"menu_action_show_file_windows\";\n    case \"macosx\":\n      return \"menu_action_show_file_mac_os\";\n    case \"linux\":\n      return \"menu_action_show_file_linux\";\n    default:\n      return \"menu_action_show_file_default\";\n  }\n};\n\n/**\n * List of functions that return items that can be included as menu options in a\n * LinkMenu. All functions take the site as the first parameter, and optionally\n * the index of the site.\n */\nexport const LinkMenuOptions = {\n  Separator: () => ({type: \"separator\"}),\n  EmptyItem: () => ({type: \"empty\"}),\n  RemoveBookmark: site => ({\n    id: \"menu_action_remove_bookmark\",\n    icon: \"bookmark-added\",\n    action: ac.AlsoToMain({\n      type: at.DELETE_BOOKMARK_BY_ID,\n      data: site.bookmarkGuid,\n    }),\n    userEvent: \"BOOKMARK_DELETE\",\n  }),\n  AddBookmark: site => ({\n    id: \"menu_action_bookmark\",\n    icon: \"bookmark-hollow\",\n    action: ac.AlsoToMain({\n      type: at.BOOKMARK_URL,\n      data: {url: site.url, title: site.title, type: site.type},\n    }),\n    userEvent: \"BOOKMARK_ADD\",\n  }),\n  OpenInNewWindow: site => ({\n    id: \"menu_action_open_new_window\",\n    icon: \"new-window\",\n    action: ac.AlsoToMain({\n      type: at.OPEN_NEW_WINDOW,\n      data: {\n        referrer: site.referrer,\n        typedBonus: site.typedBonus,\n        url: site.url,\n      },\n    }),\n    userEvent: \"OPEN_NEW_WINDOW\",\n  }),\n  BlockUrl: (site, index, eventSource) => ({\n    id: \"menu_action_dismiss\",\n    icon: \"dismiss\",\n    action: ac.AlsoToMain({\n      type: at.BLOCK_URL,\n      data: {url: site.open_url || site.url, pocket_id: site.pocket_id},\n    }),\n    impression: ac.ImpressionStats({\n      source: eventSource,\n      block: 0,\n      tiles: [{id: site.guid, pos: index}],\n    }),\n    userEvent: \"BLOCK\",\n  }),\n\n  // This is an option for web extentions which will result in remove items from\n  // memory and notify the web extenion, rather than using the built-in block list.\n  WebExtDismiss: (site, index, eventSource) => ({\n    id: \"menu_action_webext_dismiss\",\n    string_id: \"menu_action_dismiss\",\n    icon: \"dismiss\",\n    action: ac.WebExtEvent(at.WEBEXT_DISMISS, {\n      source: eventSource,\n      url: site.url,\n      action_position: index,\n    }),\n  }),\n  DeleteUrl: (site, index, eventSource, isEnabled, siteInfo) => ({\n    id: \"menu_action_delete\",\n    icon: \"delete\",\n    action: {\n      type: at.DIALOG_OPEN,\n      data: {\n        onConfirm: [\n          ac.AlsoToMain({type: at.DELETE_HISTORY_URL, data: {url: site.url, pocket_id: site.pocket_id, forceBlock: site.bookmarkGuid}}),\n          ac.UserEvent(Object.assign({event: \"DELETE\", source: eventSource, action_position: index}, siteInfo)),\n        ],\n        eventSource,\n        body_string_id: [\"confirm_history_delete_p1\", \"confirm_history_delete_notice_p2\"],\n        confirm_button_string_id: \"menu_action_delete\",\n        cancel_button_string_id: \"topsites_form_cancel_button\",\n        icon: \"modal-delete\",\n      },\n    },\n    userEvent: \"DIALOG_OPEN\",\n  }),\n  ShowFile: (site, index, eventSource, isEnabled, siteInfo, platform) => ({\n    id: GetPlatformString(platform),\n    icon: \"search\",\n    action: ac.OnlyToMain({\n      type: at.SHOW_DOWNLOAD_FILE,\n      data: {url: site.url},\n    }),\n  }),\n  OpenFile: site => ({\n    id: \"menu_action_open_file\",\n    icon: \"open-file\",\n    action: ac.OnlyToMain({\n      type: at.OPEN_DOWNLOAD_FILE,\n      data: {url: site.url},\n    }),\n  }),\n  CopyDownloadLink: site => ({\n    id: \"menu_action_copy_download_link\",\n    icon: \"copy\",\n    action: ac.OnlyToMain({\n      type: at.COPY_DOWNLOAD_LINK,\n      data: {url: site.url},\n    }),\n  }),\n  GoToDownloadPage: site => ({\n    id: \"menu_action_go_to_download_page\",\n    icon: \"download\",\n    action: ac.OnlyToMain({\n      type: at.OPEN_LINK,\n      data: {url: site.referrer},\n    }),\n    disabled: !site.referrer,\n  }),\n  RemoveDownload: site => ({\n    id: \"menu_action_remove_download\",\n    icon: \"delete\",\n    action: ac.OnlyToMain({\n      type: at.REMOVE_DOWNLOAD_FILE,\n      data: {url: site.url},\n    }),\n  }),\n  PinTopSite: ({url, searchTopSite, label}, index) => ({\n    id: \"menu_action_pin\",\n    icon: \"pin\",\n    action: ac.AlsoToMain({\n      type: at.TOP_SITES_PIN,\n      data: {\n        site: {\n          url,\n          ...(searchTopSite && {searchTopSite, label}),\n        },\n        index,\n      },\n    }),\n    userEvent: \"PIN\",\n  }),\n  UnpinTopSite: site => ({\n    id: \"menu_action_unpin\",\n    icon: \"unpin\",\n    action: ac.AlsoToMain({\n      type: at.TOP_SITES_UNPIN,\n      data: {site: {url: site.url}},\n    }),\n    userEvent: \"UNPIN\",\n  }),\n  SaveToPocket: (site, index, eventSource) => ({\n    id: \"menu_action_save_to_pocket\",\n    icon: \"pocket-save\",\n    action: ac.AlsoToMain({\n      type: at.SAVE_TO_POCKET,\n      data: {site: {url: site.url, title: site.title}},\n    }),\n    impression: ac.ImpressionStats({\n      source: eventSource,\n      pocket: 0,\n      tiles: [{id: site.guid, pos: index}],\n    }),\n    userEvent: \"SAVE_TO_POCKET\",\n  }),\n  DeleteFromPocket: site => ({\n    id: \"menu_action_delete_pocket\",\n    icon: \"delete\",\n    action: ac.AlsoToMain({\n      type: at.DELETE_FROM_POCKET,\n      data: {pocket_id: site.pocket_id},\n    }),\n    userEvent: \"DELETE_FROM_POCKET\",\n  }),\n  ArchiveFromPocket: site => ({\n    id: \"menu_action_archive_pocket\",\n    icon: \"check\",\n    action: ac.AlsoToMain({\n      type: at.ARCHIVE_FROM_POCKET,\n      data: {pocket_id: site.pocket_id},\n    }),\n    userEvent: \"ARCHIVE_FROM_POCKET\",\n  }),\n  EditTopSite: (site, index) => ({\n    id: \"edit_topsites_button_text\",\n    icon: \"edit\",\n    action: {\n      type: at.TOP_SITES_EDIT,\n      data: {index},\n    },\n  }),\n  CheckBookmark: site => (site.bookmarkGuid ? LinkMenuOptions.RemoveBookmark(site) : LinkMenuOptions.AddBookmark(site)),\n  CheckPinTopSite: (site, index) => (site.isPinned ? LinkMenuOptions.UnpinTopSite(site) : LinkMenuOptions.PinTopSite(site, index)),\n  CheckSavedToPocket: (site, index) => (site.pocket_id ? LinkMenuOptions.DeleteFromPocket(site) : LinkMenuOptions.SaveToPocket(site, index)),\n  CheckBookmarkOrArchive: site => (site.pocket_id ? LinkMenuOptions.ArchiveFromPocket(site) : LinkMenuOptions.CheckBookmark(site)),\n  OpenInPrivateWindow: (site, index, eventSource, isEnabled) => (isEnabled ? _OpenInPrivateWindow(site) : LinkMenuOptions.EmptyItem()),\n};\n","import {actionCreators as ac} from \"common/Actions.jsm\";\nimport {connect} from \"react-redux\";\nimport {ContextMenu} from \"content-src/components/ContextMenu/ContextMenu\";\nimport {injectIntl} from \"react-intl\";\nimport {LinkMenuOptions} from \"content-src/lib/link-menu-options\";\nimport React from \"react\";\n\nconst DEFAULT_SITE_MENU_OPTIONS = [\"CheckPinTopSite\", \"EditTopSite\", \"Separator\", \"OpenInNewWindow\", \"OpenInPrivateWindow\", \"Separator\", \"BlockUrl\"];\n\nexport class _LinkMenu extends React.PureComponent {\n  getOptions() {\n    const {props} = this;\n    const {site, index, source, isPrivateBrowsingEnabled, siteInfo, platform} = props;\n\n    // Handle special case of default site\n    const propOptions = (!site.isDefault || site.searchTopSite) ? props.options : DEFAULT_SITE_MENU_OPTIONS;\n\n    const options = propOptions.map(o => LinkMenuOptions[o](site, index, source, isPrivateBrowsingEnabled, siteInfo, platform)).map(option => {\n      const {action, impression, id, string_id, type, userEvent} = option;\n      if (!type && id) {\n        option.label = props.intl.formatMessage({id: string_id || id});\n        option.onClick = () => {\n          props.dispatch(action);\n          if (userEvent) {\n            const userEventData = Object.assign({\n              event: userEvent,\n              source,\n              action_position: index,\n            }, siteInfo);\n            props.dispatch(ac.UserEvent(userEventData));\n          }\n          if (impression && props.shouldSendImpressionStats) {\n            props.dispatch(impression);\n          }\n        };\n      }\n      return option;\n    });\n\n    // This is for accessibility to support making each item tabbable.\n    // We want to know which item is the first and which item\n    // is the last, so we can close the context menu accordingly.\n    options[0].first = true;\n    options[options.length - 1].last = true;\n    return options;\n  }\n\n  render() {\n    return (<ContextMenu\n      onUpdate={this.props.onUpdate}\n      options={this.getOptions()} />);\n  }\n}\n\nconst getState = state => ({isPrivateBrowsingEnabled: state.Prefs.values.isPrivateBrowsingEnabled, platform: state.Prefs.values.platform});\nexport const LinkMenu = connect(getState)(injectIntl(_LinkMenu));\n","import React from \"react\";\n\nexport class ContextMenu extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.hideContext = this.hideContext.bind(this);\n    this.onClick = this.onClick.bind(this);\n  }\n\n  hideContext() {\n    this.props.onUpdate(false);\n  }\n\n  componentDidMount() {\n    setTimeout(() => {\n      global.addEventListener(\"click\", this.hideContext);\n    }, 0);\n  }\n\n  componentWillUnmount() {\n    global.removeEventListener(\"click\", this.hideContext);\n  }\n\n  onClick(event) {\n    // Eat all clicks on the context menu so they don't bubble up to window.\n    // This prevents the context menu from closing when clicking disabled items\n    // or the separators.\n    event.stopPropagation();\n  }\n\n  render() {\n    return (<span className=\"context-menu\" onClick={this.onClick}>\n      <ul role=\"menu\" className=\"context-menu-list\">\n        {this.props.options.map((option, i) => (option.type === \"separator\" ?\n          (<li key={i} className=\"separator\" />) :\n          (option.type !== \"empty\" && <ContextMenuItem key={i} option={option} hideContext={this.hideContext} />)\n        ))}\n      </ul>\n    </span>);\n  }\n}\n\nexport class ContextMenuItem extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onClick = this.onClick.bind(this);\n    this.onKeyDown = this.onKeyDown.bind(this);\n  }\n\n  onClick() {\n    this.props.hideContext();\n    this.props.option.onClick();\n  }\n\n  onKeyDown(event) {\n    const {option} = this.props;\n    switch (event.key) {\n      case \"Tab\":\n        // tab goes down in context menu, shift + tab goes up in context menu\n        // if we're on the last item, one more tab will close the context menu\n        // similarly, if we're on the first item, one more shift + tab will close it\n        if ((event.shiftKey && option.first) || (!event.shiftKey && option.last)) {\n          this.props.hideContext();\n        }\n        break;\n      case \"Enter\":\n        this.props.hideContext();\n        option.onClick();\n        break;\n    }\n  }\n\n  render() {\n    const {option} = this.props;\n    return (\n      <li role=\"menuitem\" className=\"context-menu-item\">\n        <a onClick={this.onClick} onKeyDown={this.onKeyDown} tabIndex=\"0\" className={option.disabled ? \"disabled\" : \"\"}>\n          {option.icon && <span className={`icon icon-spacer icon-${option.icon}`} />}\n          {option.label}\n        </a>\n      </li>);\n  }\n}\n","/**\n * List of helper functions for screenshot-based images.\n *\n * There are two kinds of images:\n * 1. Remote Image: This is the image from the main process and it refers to\n *    the image in the React props. This can either be an object with the `data`\n *    and `path` properties, if it is a blob, or a string, if it is a normal image.\n * 2. Local Image: This is the image object in the content process and it refers\n *    to the image *object* in the React component's state. All local image\n *    objects have the `url` property, and an additional property `path`, if they\n *    are blobs.\n */\nexport const ScreenshotUtils = {\n  isBlob(isLocal, image) {\n    return !!(image && image.path && ((!isLocal && image.data) || (isLocal && image.url)));\n  },\n\n  // This should always be called with a remote image and not a local image.\n  createLocalImageObject(remoteImage) {\n    if (!remoteImage) {\n      return null;\n    }\n    if (this.isBlob(false, remoteImage)) {\n      return {url: global.URL.createObjectURL(remoteImage.data), path: remoteImage.path};\n    }\n    return {url: remoteImage};\n  },\n\n  // Revokes the object URL of the image if the local image is a blob.\n  // This should always be called with a local image and not a remote image.\n  maybeRevokeBlobObjectURL(localImage) {\n    if (this.isBlob(true, localImage)) {\n      global.URL.revokeObjectURL(localImage.url);\n    }\n  },\n\n  // Checks if remoteImage and localImage are the same.\n  isRemoteImageLocal(localImage, remoteImage) {\n    // Both remoteImage and localImage are present.\n    if (remoteImage && localImage) {\n      return this.isBlob(false, remoteImage) ?\n             localImage.path === remoteImage.path :\n             localImage.url === remoteImage;\n    }\n\n    // This will only handle the remaining three possible outcomes.\n    // (i.e. everything except when both image and localImage are present)\n    return !remoteImage && !localImage;\n  },\n};\n","import {FormattedMessage, injectIntl} from \"react-intl\";\nimport {actionCreators as ac} from \"common/Actions.jsm\";\nimport {ErrorBoundary} from \"content-src/components/ErrorBoundary/ErrorBoundary\";\nimport React from \"react\";\nimport {SectionMenu} from \"content-src/components/SectionMenu/SectionMenu\";\nimport {SectionMenuOptions} from \"content-src/lib/section-menu-options\";\n\nconst VISIBLE = \"visible\";\nconst VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\n\nfunction getFormattedMessage(message) {\n  return typeof message === \"string\" ? <span>{message}</span> : <FormattedMessage {...message} />;\n}\n\nexport class _CollapsibleSection extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onBodyMount = this.onBodyMount.bind(this);\n    this.onHeaderClick = this.onHeaderClick.bind(this);\n    this.onTransitionEnd = this.onTransitionEnd.bind(this);\n    this.enableOrDisableAnimation = this.enableOrDisableAnimation.bind(this);\n    this.onMenuButtonClick = this.onMenuButtonClick.bind(this);\n    this.onMenuButtonMouseEnter = this.onMenuButtonMouseEnter.bind(this);\n    this.onMenuButtonMouseLeave = this.onMenuButtonMouseLeave.bind(this);\n    this.onMenuUpdate = this.onMenuUpdate.bind(this);\n    this.state = {enableAnimation: true, isAnimating: false, menuButtonHover: false, showContextMenu: false};\n  }\n\n  componentWillMount() {\n    this.props.document.addEventListener(VISIBILITY_CHANGE_EVENT, this.enableOrDisableAnimation);\n  }\n\n  componentWillUpdate(nextProps) {\n    // Check if we're about to go from expanded to collapsed\n    if (!this.props.collapsed && nextProps.collapsed) {\n      // This next line forces a layout flush of the section body, which has a\n      // max-height style set, so that the upcoming collapse animation can\n      // animate from that height to the collapsed height. Without this, the\n      // update is coalesced and there's no animation from no-max-height to 0.\n      this.sectionBody.scrollHeight; // eslint-disable-line no-unused-expressions\n    }\n  }\n\n  componentWillUnmount() {\n    this.props.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this.enableOrDisableAnimation);\n  }\n\n  enableOrDisableAnimation() {\n    // Only animate the collapse/expand for visible tabs.\n    const visible = this.props.document.visibilityState === VISIBLE;\n    if (this.state.enableAnimation !== visible) {\n      this.setState({enableAnimation: visible});\n    }\n  }\n\n  onBodyMount(node) {\n    this.sectionBody = node;\n  }\n\n  onHeaderClick() {\n    // If this.sectionBody is unset, it means that we're in some sort of error\n    // state, probably displaying the error fallback, so we won't be able to\n    // compute the height, and we don't want to persist the preference.\n    // If props.collapsed is undefined handler shouldn't do anything.\n    if (!this.sectionBody || this.props.collapsed === undefined) {\n      return;\n    }\n\n    // Get the current height of the body so max-height transitions can work\n    this.setState({\n      isAnimating: true,\n      maxHeight: `${this._getSectionBodyHeight()}px`,\n    });\n    const {action, userEvent} = SectionMenuOptions.CheckCollapsed(this.props);\n    this.props.dispatch(action);\n    this.props.dispatch(ac.UserEvent({\n      event: userEvent,\n      source: this.props.source,\n    }));\n  }\n\n  _getSectionBodyHeight() {\n    const div = this.sectionBody;\n    if (div.style.display === \"none\") {\n      // If the div isn't displayed, we can't get it's height. So we display it\n      // to get the height (it doesn't show up because max-height is set to 0px\n      // in CSS). We don't undo this because we are about to expand the section.\n      div.style.display = \"block\";\n    }\n    return div.scrollHeight;\n  }\n\n  onTransitionEnd(event) {\n    // Only update the animating state for our own transition (not a child's)\n    if (event.target === event.currentTarget) {\n      this.setState({isAnimating: false});\n    }\n  }\n\n  renderIcon() {\n    const {icon} = this.props;\n    if (icon && icon.startsWith(\"moz-extension://\")) {\n      return <span className=\"icon icon-small-spacer\" style={{backgroundImage: `url('${icon}')`}} />;\n    }\n    return <span className={`icon icon-small-spacer icon-${icon || \"webextension\"}`} />;\n  }\n\n  onMenuButtonClick(event) {\n    event.preventDefault();\n    this.setState({showContextMenu: true});\n  }\n\n  onMenuButtonMouseEnter() {\n    this.setState({menuButtonHover: true});\n  }\n\n  onMenuButtonMouseLeave() {\n    this.setState({menuButtonHover: false});\n  }\n\n  onMenuUpdate(showContextMenu) {\n    this.setState({showContextMenu});\n  }\n\n  render() {\n    const isCollapsible = this.props.collapsed !== undefined;\n    const {enableAnimation, isAnimating, maxHeight, menuButtonHover, showContextMenu} = this.state;\n    const {id, eventSource, collapsed, learnMore, title, extraMenuOptions, showPrefName, privacyNoticeURL, dispatch, isFirst, isLast, isWebExtension} = this.props;\n    const active = menuButtonHover || showContextMenu;\n    let bodyStyle;\n    if (isAnimating && !collapsed) {\n      bodyStyle = {maxHeight};\n    } else if (!isAnimating && collapsed) {\n      bodyStyle = {display: \"none\"};\n    }\n    return (\n      <section\n        className={`collapsible-section ${this.props.className}${enableAnimation ? \" animation-enabled\" : \"\"}${collapsed ? \" collapsed\" : \"\"}${active ? \" active\" : \"\"}`}\n        // Note: data-section-id is used for web extension api tests in mozilla central\n        data-section-id={id}>\n        <div className=\"section-top-bar\">\n          <h3 className=\"section-title\">\n            <span className=\"click-target-container\">\n              <span className=\"click-target\" onClick={this.onHeaderClick}>\n                {this.renderIcon()}\n                {getFormattedMessage(title)}\n              </span>\n              <span>\n                {learnMore &&\n                  <span className=\"learn-more-link\">\n                    <a href={learnMore.link.href}>\n                      <FormattedMessage id={learnMore.link.id} />\n                    </a>\n                  </span>\n                }\n              </span>\n              <span className=\"click-target\" onClick={this.onHeaderClick}>\n                {isCollapsible && <span className={`collapsible-arrow icon ${collapsed ? \"icon-arrowhead-forward-small\" : \"icon-arrowhead-down-small\"}`} />}\n              </span>\n            </span>\n          </h3>\n          <div>\n            <button\n              className=\"context-menu-button icon\"\n              onClick={this.onMenuButtonClick}\n              onMouseEnter={this.onMenuButtonMouseEnter}\n              onMouseLeave={this.onMenuButtonMouseLeave}>\n              <span className=\"sr-only\">\n                <FormattedMessage id=\"section_context_menu_button_sr\" />\n              </span>\n            </button>\n            {showContextMenu &&\n              <SectionMenu\n                id={id}\n                extraOptions={extraMenuOptions}\n                eventSource={eventSource}\n                showPrefName={showPrefName}\n                privacyNoticeURL={privacyNoticeURL}\n                collapsed={collapsed}\n                onUpdate={this.onMenuUpdate}\n                isFirst={isFirst}\n                isLast={isLast}\n                dispatch={dispatch}\n                isWebExtension={isWebExtension} />\n            }\n          </div>\n        </div>\n        <ErrorBoundary className=\"section-body-fallback\">\n          <div\n            className={`section-body${isAnimating ? \" animating\" : \"\"}`}\n            onTransitionEnd={this.onTransitionEnd}\n            ref={this.onBodyMount}\n            style={bodyStyle}>\n            {this.props.children}\n          </div>\n        </ErrorBoundary>\n      </section>\n    );\n  }\n}\n\n_CollapsibleSection.defaultProps = {\n  document: global.document || {\n    addEventListener: () => {},\n    removeEventListener: () => {},\n    visibilityState: \"hidden\",\n  },\n  Prefs: {values: {}},\n};\n\nexport const CollapsibleSection = injectIntl(_CollapsibleSection);\n","import {actionCreators as ac} from \"common/Actions.jsm\";\nimport {ContextMenu} from \"content-src/components/ContextMenu/ContextMenu\";\nimport {injectIntl} from \"react-intl\";\nimport React from \"react\";\nimport {SectionMenuOptions} from \"content-src/lib/section-menu-options\";\n\nconst DEFAULT_SECTION_MENU_OPTIONS = [\"MoveUp\", \"MoveDown\", \"Separator\", \"RemoveSection\", \"CheckCollapsed\", \"Separator\", \"ManageSection\"];\nconst WEBEXT_SECTION_MENU_OPTIONS = [\"MoveUp\", \"MoveDown\", \"Separator\", \"CheckCollapsed\", \"Separator\", \"ManageWebExtension\"];\n\nexport class _SectionMenu extends React.PureComponent {\n  getOptions() {\n    const {props} = this;\n\n    const propOptions = props.isWebExtension ? [...WEBEXT_SECTION_MENU_OPTIONS] : [...DEFAULT_SECTION_MENU_OPTIONS];\n    // Prepend custom options and a separator\n    if (props.extraOptions) {\n      propOptions.splice(0, 0, ...props.extraOptions, \"Separator\");\n    }\n    // Insert privacy notice before the last option (\"ManageSection\")\n    if (props.privacyNoticeURL) {\n      propOptions.splice(-1, 0, \"PrivacyNotice\");\n    }\n\n    const options = propOptions.map(o => SectionMenuOptions[o](props)).map(option => {\n      const {action, id, type, userEvent} = option;\n      if (!type && id) {\n        option.label = props.intl.formatMessage({id});\n        option.onClick = () => {\n          props.dispatch(action);\n          if (userEvent) {\n            props.dispatch(ac.UserEvent({\n              event: userEvent,\n              source: props.source,\n            }));\n          }\n        };\n      }\n      return option;\n    });\n\n    // This is for accessibility to support making each item tabbable.\n    // We want to know which item is the first and which item\n    // is the last, so we can close the context menu accordingly.\n    options[0].first = true;\n    options[options.length - 1].last = true;\n    return options;\n  }\n\n  render() {\n    return (<ContextMenu\n      onUpdate={this.props.onUpdate}\n      options={this.getOptions()} />);\n  }\n}\n\nexport const SectionMenu = injectIntl(_SectionMenu);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\n\n/**\n * List of functions that return items that can be included as menu options in a\n * SectionMenu. All functions take the section as the only parameter.\n */\nexport const SectionMenuOptions = {\n  Separator: () => ({type: \"separator\"}),\n  MoveUp: section => ({\n    id: \"section_menu_action_move_up\",\n    icon: \"arrowhead-up\",\n    action: ac.OnlyToMain({\n      type: at.SECTION_MOVE,\n      data: {id: section.id, direction: -1},\n    }),\n    userEvent: \"MENU_MOVE_UP\",\n    disabled: !!section.isFirst,\n  }),\n  MoveDown: section => ({\n    id: \"section_menu_action_move_down\",\n    icon: \"arrowhead-down\",\n    action: ac.OnlyToMain({\n      type: at.SECTION_MOVE,\n      data: {id: section.id, direction: +1},\n    }),\n    userEvent: \"MENU_MOVE_DOWN\",\n    disabled: !!section.isLast,\n  }),\n  RemoveSection: section => ({\n    id: \"section_menu_action_remove_section\",\n    icon: \"dismiss\",\n    action: ac.SetPref(section.showPrefName, false),\n    userEvent: \"MENU_REMOVE\",\n  }),\n  CollapseSection: section => ({\n    id: \"section_menu_action_collapse_section\",\n    icon: \"minimize\",\n    action: ac.OnlyToMain({type: at.UPDATE_SECTION_PREFS, data: {id: section.id, value: {collapsed: true}}}),\n    userEvent: \"MENU_COLLAPSE\",\n  }),\n  ExpandSection: section => ({\n    id: \"section_menu_action_expand_section\",\n    icon: \"maximize\",\n    action: ac.OnlyToMain({type: at.UPDATE_SECTION_PREFS, data: {id: section.id, value: {collapsed: false}}}),\n    userEvent: \"MENU_EXPAND\",\n  }),\n  ManageSection: section => ({\n    id: \"section_menu_action_manage_section\",\n    icon: \"settings\",\n    action: ac.OnlyToMain({type: at.SETTINGS_OPEN}),\n    userEvent: \"MENU_MANAGE\",\n  }),\n  ManageWebExtension: section => ({\n    id: \"section_menu_action_manage_webext\",\n    icon: \"settings\",\n    action: ac.OnlyToMain({type: at.OPEN_WEBEXT_SETTINGS, data: section.id}),\n  }),\n  AddTopSite: section => ({\n    id: \"section_menu_action_add_topsite\",\n    icon: \"add\",\n    action: {type: at.TOP_SITES_EDIT, data: {index: -1}},\n    userEvent: \"MENU_ADD_TOPSITE\",\n  }),\n  AddSearchShortcut: section => ({\n    id: \"section_menu_action_add_search_engine\",\n    icon: \"search\",\n    action: {type: at.TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL},\n    userEvent: \"MENU_ADD_SEARCH\",\n  }),\n  PrivacyNotice: section => ({\n    id: \"section_menu_action_privacy_notice\",\n    icon: \"info\",\n    action: ac.OnlyToMain({\n      type: at.OPEN_LINK,\n      data: {url: section.privacyNoticeURL},\n    }),\n    userEvent: \"MENU_PRIVACY_NOTICE\",\n  }),\n  CheckCollapsed: section => (section.collapsed ? SectionMenuOptions.ExpandSection(section) : SectionMenuOptions.CollapseSection(section)),\n};\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {perfService as perfSvc} from \"common/PerfService.jsm\";\nimport React from \"react\";\n\n// Currently record only a fixed set of sections. This will prevent data\n// from custom sections from showing up or from topstories.\nconst RECORDED_SECTIONS = [\"highlights\", \"topsites\"];\n\nexport class ComponentPerfTimer extends React.Component {\n  constructor(props) {\n    super(props);\n    // Just for test dependency injection:\n    this.perfSvc = this.props.perfSvc || perfSvc;\n\n    this._sendBadStateEvent = this._sendBadStateEvent.bind(this);\n    this._sendPaintedEvent = this._sendPaintedEvent.bind(this);\n    this._reportMissingData = false;\n    this._timestampHandled = false;\n    this._recordedFirstRender = false;\n  }\n\n  componentDidMount() {\n    if (!RECORDED_SECTIONS.includes(this.props.id)) {\n      return;\n    }\n\n    this._maybeSendPaintedEvent();\n  }\n\n  componentDidUpdate() {\n    if (!RECORDED_SECTIONS.includes(this.props.id)) {\n      return;\n    }\n\n    this._maybeSendPaintedEvent();\n  }\n\n  /**\n   * Call the given callback after the upcoming frame paints.\n   *\n   * @note Both setTimeout and requestAnimationFrame are throttled when the page\n   * is hidden, so this callback may get called up to a second or so after the\n   * requestAnimationFrame \"paint\" for hidden tabs.\n   *\n   * Newtabs hidden while loading will presumably be fairly rare (other than\n   * preloaded tabs, which we will be filtering out on the server side), so such\n   * cases should get lost in the noise.\n   *\n   * If we decide that it's important to find out when something that's hidden\n   * has \"painted\", however, another option is to post a message to this window.\n   * That should happen even faster than setTimeout, and, at least as of this\n   * writing, it's not throttled in hidden windows in Firefox.\n   *\n   * @param {Function} callback\n   *\n   * @returns void\n   */\n  _afterFramePaint(callback) {\n    requestAnimationFrame(() => setTimeout(callback, 0));\n  }\n\n  _maybeSendBadStateEvent() {\n    // Follow up bugs:\n    // https://github.com/mozilla/activity-stream/issues/3691\n    if (!this.props.initialized) {\n      // Remember to report back when data is available.\n      this._reportMissingData = true;\n    } else if (this._reportMissingData) {\n      this._reportMissingData = false;\n      // Report how long it took for component to become initialized.\n      this._sendBadStateEvent();\n    }\n  }\n\n  _maybeSendPaintedEvent() {\n    // If we've already handled a timestamp, don't do it again.\n    if (this._timestampHandled || !this.props.initialized) {\n      return;\n    }\n\n    // And if we haven't, we're doing so now, so remember that. Even if\n    // something goes wrong in the callback, we can't try again, as we'd be\n    // sending back the wrong data, and we have to do it here, so that other\n    // calls to this method while waiting for the next frame won't also try to\n    // handle it.\n    this._timestampHandled = true;\n    this._afterFramePaint(this._sendPaintedEvent);\n  }\n\n  /**\n   * Triggered by call to render. Only first call goes through due to\n   * `_recordedFirstRender`.\n   */\n  _ensureFirstRenderTsRecorded() {\n    // Used as t0 for recording how long component took to initialize.\n    if (!this._recordedFirstRender) {\n      this._recordedFirstRender = true;\n      // topsites_first_render_ts, highlights_first_render_ts.\n      const key = `${this.props.id}_first_render_ts`;\n      this.perfSvc.mark(key);\n    }\n  }\n\n  /**\n   * Creates `TELEMETRY_UNDESIRED_EVENT` with timestamp in ms\n   * of how much longer the data took to be ready for display than it would\n   * have been the ideal case.\n   * https://github.com/mozilla/ping-centre/issues/98\n   */\n  _sendBadStateEvent() {\n    // highlights_data_ready_ts, topsites_data_ready_ts.\n    const dataReadyKey = `${this.props.id}_data_ready_ts`;\n    this.perfSvc.mark(dataReadyKey);\n\n    try {\n      const firstRenderKey = `${this.props.id}_first_render_ts`;\n      // value has to be Int32.\n      const value = parseInt(this.perfSvc.getMostRecentAbsMarkStartByName(dataReadyKey) -\n                             this.perfSvc.getMostRecentAbsMarkStartByName(firstRenderKey), 10);\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.SAVE_SESSION_PERF_DATA,\n        // highlights_data_late_by_ms, topsites_data_late_by_ms.\n        data: {[`${this.props.id}_data_late_by_ms`]: value},\n      }));\n    } catch (ex) {\n      // If this failed, it's likely because the `privacy.resistFingerprinting`\n      // pref is true.\n    }\n  }\n\n  _sendPaintedEvent() {\n    // Record first_painted event but only send if topsites.\n    if (this.props.id !== \"topsites\") {\n      return;\n    }\n\n    // topsites_first_painted_ts.\n    const key = `${this.props.id}_first_painted_ts`;\n    this.perfSvc.mark(key);\n\n    try {\n      const data = {};\n      data[key] = this.perfSvc.getMostRecentAbsMarkStartByName(key);\n\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.SAVE_SESSION_PERF_DATA,\n        data,\n      }));\n    } catch (ex) {\n      // If this failed, it's likely because the `privacy.resistFingerprinting`\n      // pref is true.  We should at least not blow up, and should continue\n      // to set this._timestampHandled to avoid going through this again.\n    }\n  }\n\n  render() {\n    if (RECORDED_SECTIONS.includes(this.props.id)) {\n      this._ensureFirstRenderTsRecorded();\n      this._maybeSendBadStateEvent();\n    }\n    return this.props.children;\n  }\n}\n","/* globals Services */\n\"use strict\";\n\n/* istanbul ignore if */\nif (typeof ChromeUtils !== \"undefined\") {\n  ChromeUtils.import(\"resource://gre/modules/Services.jsm\");\n}\n\nlet usablePerfObj;\n\n/* istanbul ignore if */\n/* istanbul ignore else */\nif (typeof Services !== \"undefined\") {\n  // Borrow the high-resolution timer from the hidden window....\n  usablePerfObj = Services.appShell.hiddenDOMWindow.performance;\n} else if (typeof performance !== \"undefined\") {\n  // we must be running in content space\n  // eslint-disable-next-line no-undef\n  usablePerfObj = performance;\n} else {\n  // This is a dummy object so this file doesn't crash in the node prerendering\n  // task.\n  usablePerfObj = {\n    now() {},\n    mark() {},\n  };\n}\n\nfunction _PerfService(options) {\n  // For testing, so that we can use a fake Window.performance object with\n  // known state.\n  if (options && options.performanceObj) {\n    this._perf = options.performanceObj;\n  } else {\n    this._perf = usablePerfObj;\n  }\n}\n\n_PerfService.prototype = {\n  /**\n   * Calls the underlying mark() method on the appropriate Window.performance\n   * object to add a mark with the given name to the appropriate performance\n   * timeline.\n   *\n   * @param  {String} name  the name to give the current mark\n   * @return {void}\n   */\n  mark: function mark(str) {\n    this._perf.mark(str);\n  },\n\n  /**\n   * Calls the underlying getEntriesByName on the appropriate Window.performance\n   * object.\n   *\n   * @param  {String} name\n   * @param  {String} type eg \"mark\"\n   * @return {Array}       Performance* objects\n   */\n  getEntriesByName: function getEntriesByName(name, type) {\n    return this._perf.getEntriesByName(name, type);\n  },\n\n  /**\n   * The timeOrigin property from the appropriate performance object.\n   * Used to ensure that timestamps from the add-on code and the content code\n   * are comparable.\n   *\n   * @note If this is called from a context without a window\n   * (eg a JSM in chrome), it will return the timeOrigin of the XUL hidden\n   * window, which appears to be the first created window (and thus\n   * timeOrigin) in the browser.  Note also, however, there is also a private\n   * hidden window, presumably for private browsing, which appears to be\n   * created dynamically later.  Exactly how/when that shows up needs to be\n   * investigated.\n   *\n   * @return {Number} A double of milliseconds with a precision of 0.5us.\n   */\n  get timeOrigin() {\n    return this._perf.timeOrigin;\n  },\n\n  /**\n   * Returns the \"absolute\" version of performance.now(), i.e. one that\n   * should ([bug 1401406](https://bugzilla.mozilla.org/show_bug.cgi?id=1401406)\n   * be comparable across both chrome and content.\n   *\n   * @return {Number}\n   */\n  absNow: function absNow() {\n    return this.timeOrigin + this._perf.now();\n  },\n\n  /**\n   * This returns the absolute startTime from the most recent performance.mark()\n   * with the given name.\n   *\n   * @param  {String} name  the name to lookup the start time for\n   *\n   * @return {Number}       the returned start time, as a DOMHighResTimeStamp\n   *\n   * @throws {Error}        \"No Marks with the name ...\" if none are available\n   *\n   * @note Always surround calls to this by try/catch.  Otherwise your code\n   * may fail when the `privacy.resistFingerprinting` pref is true.  When\n   * this pref is set, all attempts to get marks will likely fail, which will\n   * cause this method to throw.\n   *\n   * See [bug 1369303](https://bugzilla.mozilla.org/show_bug.cgi?id=1369303)\n   * for more info.\n   */\n  getMostRecentAbsMarkStartByName(name) {\n    let entries = this.getEntriesByName(name, \"mark\");\n\n    if (!entries.length) {\n      throw new Error(`No marks with the name ${name}`);\n    }\n\n    let mostRecentEntry = entries[entries.length - 1];\n    return this._perf.timeOrigin + mostRecentEntry.startTime;\n  },\n};\n\nthis.perfService = new _PerfService();\nconst EXPORTED_SYMBOLS = [\"_PerfService\", \"perfService\"];\n","import {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class MoreRecommendations extends React.PureComponent {\n  render() {\n    const {read_more_endpoint} = this.props;\n    if (read_more_endpoint) {\n      return (\n        <a className=\"more-recommendations\" href={read_more_endpoint}>\n          <FormattedMessage id=\"pocket_more_reccommendations\" />\n        </a>\n      );\n    }\n    return null;\n  }\n}\n","import {connect} from \"react-redux\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class _PocketLoggedInCta extends React.PureComponent {\n  render() {\n    const {pocketCta} = this.props.Pocket;\n    return (\n      <span className=\"pocket-logged-in-cta\">\n        <a href={pocketCta.ctaUrl ? pocketCta.ctaUrl : \"https://getpocket.com/\"}>\n         {pocketCta.ctaButton ? pocketCta.ctaButton : <FormattedMessage id=\"pocket_cta_button\" />}\n        </a>\n\n        <span className=\"cta-text\">\n         {pocketCta.ctaText ? pocketCta.ctaText : <FormattedMessage id=\"pocket_cta_text\" />}\n        </span>\n      </span>\n    );\n  }\n}\n\nexport const PocketLoggedInCta = connect(state => ({Pocket: state.Pocket}))(_PocketLoggedInCta);\n","import {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\n\nexport class Topic extends React.PureComponent {\n  render() {\n    const {url, name} = this.props;\n    return (<li><a key={name} href={url}>{name}</a></li>);\n  }\n}\n\nexport class Topics extends React.PureComponent {\n  render() {\n    const {topics} = this.props;\n    return (\n      <span className=\"topics\">\n        <span><FormattedMessage id=\"pocket_read_more\" /></span>\n        <ul>{topics && topics.map(t => <Topic key={t.name} url={t.url} name={t.name} />)}</ul>\n      </span>\n    );\n  }\n}\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {MIN_CORNER_FAVICON_SIZE, MIN_RICH_FAVICON_SIZE, TOP_SITES_SOURCE} from \"./TopSitesConstants\";\nimport {CollapsibleSection} from \"content-src/components/CollapsibleSection/CollapsibleSection\";\nimport {ComponentPerfTimer} from \"content-src/components/ComponentPerfTimer/ComponentPerfTimer\";\nimport {connect} from \"react-redux\";\nimport {injectIntl} from \"react-intl\";\nimport React from \"react\";\nimport {SearchShortcutsForm} from \"./SearchShortcutsForm\";\nimport {TOP_SITES_MAX_SITES_PER_ROW} from \"common/Reducers.jsm\";\nimport {TopSiteForm} from \"./TopSiteForm\";\nimport {TopSiteList} from \"./TopSite\";\n\nfunction topSiteIconType(link) {\n  if (link.customScreenshotURL) {\n    return \"custom_screenshot\";\n  }\n  if (link.tippyTopIcon || link.faviconRef === \"tippytop\") {\n    return \"tippytop\";\n  }\n  if (link.faviconSize >= MIN_RICH_FAVICON_SIZE) {\n    return \"rich_icon\";\n  }\n  if (link.screenshot && link.faviconSize >= MIN_CORNER_FAVICON_SIZE) {\n    return \"screenshot_with_icon\";\n  }\n  if (link.screenshot) {\n    return \"screenshot\";\n  }\n  return \"no_image\";\n}\n\n/**\n * Iterates through TopSites and counts types of images.\n * @param acc Accumulator for reducer.\n * @param topsite Entry in TopSites.\n */\nfunction countTopSitesIconsTypes(topSites) {\n  const countTopSitesTypes = (acc, link) => {\n    acc[topSiteIconType(link)]++;\n    return acc;\n  };\n\n  return topSites.reduce(countTopSitesTypes, {\n    \"custom_screenshot\": 0,\n    \"screenshot_with_icon\": 0,\n    \"screenshot\": 0,\n    \"tippytop\": 0,\n    \"rich_icon\": 0,\n    \"no_image\": 0,\n  });\n}\n\nexport class _TopSites extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onEditFormClose = this.onEditFormClose.bind(this);\n    this.onSearchShortcutsFormClose = this.onSearchShortcutsFormClose.bind(this);\n  }\n\n  /**\n   * Dispatch session statistics about the quality of TopSites icons and pinned count.\n   */\n  _dispatchTopSitesStats() {\n    const topSites = this._getVisibleTopSites();\n    const topSitesIconsStats = countTopSitesIconsTypes(topSites);\n    const topSitesPinned = topSites.filter(site => !!site.isPinned).length;\n    const searchShortcuts = topSites.filter(site => !!site.searchTopSite).length;\n    // Dispatch telemetry event with the count of TopSites images types.\n    this.props.dispatch(ac.AlsoToMain({\n      type: at.SAVE_SESSION_PERF_DATA,\n      data: {\n        topsites_icon_stats: topSitesIconsStats,\n        topsites_pinned: topSitesPinned,\n        topsites_search_shortcuts: searchShortcuts,\n      },\n    }));\n  }\n\n  /**\n   * Return the TopSites that are visible based on prefs and window width.\n   */\n  _getVisibleTopSites() {\n    // We hide 2 sites per row when not in the wide layout.\n    let sitesPerRow = TOP_SITES_MAX_SITES_PER_ROW;\n    // $break-point-widest = 1072px (from _variables.scss)\n    if (!global.matchMedia(`(min-width: 1072px)`).matches) {\n      sitesPerRow -= 2;\n    }\n    return this.props.TopSites.rows.slice(0, this.props.TopSitesRows * sitesPerRow);\n  }\n\n  componentDidUpdate() {\n    this._dispatchTopSitesStats();\n  }\n\n  componentDidMount() {\n    this._dispatchTopSitesStats();\n  }\n\n  onEditFormClose() {\n    this.props.dispatch(ac.UserEvent({\n      source: TOP_SITES_SOURCE,\n      event: \"TOP_SITES_EDIT_CLOSE\",\n    }));\n    this.props.dispatch({type: at.TOP_SITES_CANCEL_EDIT});\n  }\n\n  onSearchShortcutsFormClose() {\n    this.props.dispatch(ac.UserEvent({\n      source: TOP_SITES_SOURCE,\n      event: \"SEARCH_EDIT_CLOSE\",\n    }));\n    this.props.dispatch({type: at.TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL});\n  }\n\n  render() {\n    const {props} = this;\n    const {editForm, showSearchShortcutsForm} = props.TopSites;\n    const extraMenuOptions = [\"AddTopSite\"];\n    if (props.Prefs.values[\"improvesearch.topSiteSearchShortcuts\"]) {\n      extraMenuOptions.push(\"AddSearchShortcut\");\n    }\n\n    return (<ComponentPerfTimer id=\"topsites\" initialized={props.TopSites.initialized} dispatch={props.dispatch}>\n      <CollapsibleSection\n        className=\"top-sites\"\n        icon=\"topsites\"\n        id=\"topsites\"\n        title={{id: \"header_top_sites\"}}\n        extraMenuOptions={extraMenuOptions}\n        showPrefName=\"feeds.topsites\"\n        eventSource={TOP_SITES_SOURCE}\n        collapsed={props.TopSites.pref ? props.TopSites.pref.collapsed : undefined}\n        isFirst={props.isFirst}\n        isLast={props.isLast}\n        dispatch={props.dispatch}>\n        <TopSiteList TopSites={props.TopSites} TopSitesRows={props.TopSitesRows} dispatch={props.dispatch} intl={props.intl} topSiteIconType={topSiteIconType} />\n        <div className=\"edit-topsites-wrapper\">\n          {editForm &&\n            <div className=\"edit-topsites\">\n              <div className=\"modal-overlay\" onClick={this.onEditFormClose} />\n              <div className=\"modal\">\n                <TopSiteForm\n                  site={props.TopSites.rows[editForm.index]}\n                  onClose={this.onEditFormClose}\n                  dispatch={this.props.dispatch}\n                  intl={this.props.intl}\n                  {...editForm} />\n              </div>\n            </div>\n          }\n          {showSearchShortcutsForm &&\n            <div className=\"edit-search-shortcuts\">\n              <div className=\"modal-overlay\" onClick={this.onSearchShortcutsFormClose} />\n              <div className=\"modal\">\n                <SearchShortcutsForm\n                  TopSites={props.TopSites}\n                  onClose={this.onSearchShortcutsFormClose}\n                  dispatch={this.props.dispatch} />\n              </div>\n            </div>\n          }\n        </div>\n      </CollapsibleSection>\n    </ComponentPerfTimer>);\n  }\n}\n\nexport const TopSites = connect(state => ({\n  TopSites: state.TopSites,\n  Prefs: state.Prefs,\n  TopSitesRows: state.Prefs.values.topSitesRows,\n}))(injectIntl(_TopSites));\n","export const TOP_SITES_SOURCE = \"TOP_SITES\";\nexport const TOP_SITES_CONTEXT_MENU_OPTIONS = [\"CheckPinTopSite\", \"EditTopSite\", \"Separator\",\n  \"OpenInNewWindow\", \"OpenInPrivateWindow\", \"Separator\", \"BlockUrl\", \"DeleteUrl\"];\n// the special top site for search shortcut experiment can only have the option to unpin (which removes) the topsite\nexport const TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS = [\"CheckPinTopSite\", \"Separator\", \"BlockUrl\"];\n// minimum size necessary to show a rich icon instead of a screenshot\nexport const MIN_RICH_FAVICON_SIZE = 96;\n// minimum size necessary to show any icon in the top left corner with a screenshot\nexport const MIN_CORNER_FAVICON_SIZE = 16;\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {FormattedMessage} from \"react-intl\";\nimport React from \"react\";\nimport {TOP_SITES_SOURCE} from \"./TopSitesConstants\";\n\nclass SelectableSearchShortcut extends React.PureComponent {\n  render() {\n    const {shortcut, selected} = this.props;\n    const imageStyle = {backgroundImage: `url(\"${shortcut.tippyTopIcon}\")`};\n    return (\n      <div className=\"top-site-outer search-shortcut\">\n        <input type=\"checkbox\" id={shortcut.keyword} name={shortcut.keyword} checked={selected} onChange={this.props.onChange} />\n        <label htmlFor={shortcut.keyword}>\n          <div className=\"top-site-inner\">\n            <span>\n              <div className=\"tile\">\n                <div className=\"top-site-icon rich-icon\" style={imageStyle} data-fallback=\"@\" />\n                <div className=\"top-site-icon search-topsite\" />\n              </div>\n              <div className=\"title\">\n                <span dir=\"auto\">{shortcut.keyword}</span>\n              </div>\n            </span>\n          </div>\n        </label>\n      </div>\n    );\n  }\n}\n\nexport class SearchShortcutsForm extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.handleChange = this.handleChange.bind(this);\n    this.onCancelButtonClick = this.onCancelButtonClick.bind(this);\n    this.onSaveButtonClick = this.onSaveButtonClick.bind(this);\n\n    // clone the shortcuts and add them to the state so we can add isSelected property\n    const shortcuts = [];\n    const {rows, searchShortcuts} = props.TopSites;\n    searchShortcuts.forEach(shortcut => {\n      shortcuts.push({\n        ...shortcut,\n        isSelected: !!rows.find(row => row && row.isPinned && row.searchTopSite && row.label === shortcut.keyword),\n      });\n    });\n    this.state = {shortcuts};\n  }\n\n  handleChange(event) {\n    const {target} = event;\n    const {name, checked} = target;\n    this.setState(prevState => {\n      const shortcuts = prevState.shortcuts.slice();\n      let shortcut = shortcuts.find(({keyword}) => keyword === name);\n      shortcut.isSelected = checked;\n      return {shortcuts};\n    });\n  }\n\n  onCancelButtonClick(ev) {\n    ev.preventDefault();\n    this.props.onClose();\n  }\n\n  onSaveButtonClick(ev) {\n    ev.preventDefault();\n\n    // Check if there were any changes and act accordingly\n    const {rows} = this.props.TopSites;\n    const pinQueue = [];\n    const unpinQueue = [];\n    this.state.shortcuts.forEach(shortcut => {\n      const alreadyPinned = rows.find(row => row && row.isPinned && row.searchTopSite && row.label === shortcut.keyword);\n      if (shortcut.isSelected && !alreadyPinned) {\n        pinQueue.push(this._searchTopSite(shortcut));\n      } else if (!shortcut.isSelected && alreadyPinned) {\n        unpinQueue.push({url: alreadyPinned.url, searchVendor: shortcut.shortURL});\n      }\n    });\n\n    // Tell the feed to do the work.\n    this.props.dispatch(ac.OnlyToMain({\n      type: at.UPDATE_PINNED_SEARCH_SHORTCUTS,\n      data: {\n        addedShortcuts: pinQueue,\n        deletedShortcuts: unpinQueue,\n      },\n    }));\n\n    // Send the Telemetry pings.\n    pinQueue.forEach(shortcut => {\n      this.props.dispatch(ac.UserEvent({\n        source: TOP_SITES_SOURCE,\n        event: \"SEARCH_EDIT_ADD\",\n        value: {search_vendor: shortcut.searchVendor},\n      }));\n    });\n    unpinQueue.forEach(shortcut => {\n      this.props.dispatch(ac.UserEvent({\n        source: TOP_SITES_SOURCE,\n        event: \"SEARCH_EDIT_DELETE\",\n        value: {search_vendor: shortcut.searchVendor},\n      }));\n    });\n\n    this.props.onClose();\n  }\n\n  _searchTopSite(shortcut) {\n    return {\n      url: shortcut.url,\n      searchTopSite: true,\n      label: shortcut.keyword,\n      searchVendor: shortcut.shortURL,\n    };\n  }\n\n  render() {\n    return (\n      <form className=\"topsite-form\">\n        <div className=\"search-shortcuts-container\">\n          <h3 className=\"section-title\">\n            <FormattedMessage id=\"section_menu_action_add_search_engine\" />\n          </h3>\n          <div>\n            {this.state.shortcuts.map(shortcut => <SelectableSearchShortcut key={shortcut.keyword} shortcut={shortcut} selected={shortcut.isSelected} onChange={this.handleChange} />)}\n          </div>\n        </div>\n        <section className=\"actions\">\n          <button className=\"cancel\" type=\"button\" onClick={this.onCancelButtonClick}>\n            <FormattedMessage id=\"topsites_form_cancel_button\" />\n          </button>\n          <button className=\"done\" type=\"submit\" onClick={this.onSaveButtonClick}>\n            <FormattedMessage id=\"topsites_form_save_button\" />\n          </button>\n        </section>\n      </form>\n    );\n  }\n}\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {\n  MIN_CORNER_FAVICON_SIZE,\n  MIN_RICH_FAVICON_SIZE,\n  TOP_SITES_CONTEXT_MENU_OPTIONS,\n  TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS,\n  TOP_SITES_SOURCE,\n} from \"./TopSitesConstants\";\nimport {LinkMenu} from \"content-src/components/LinkMenu/LinkMenu\";\nimport React from \"react\";\nimport {ScreenshotUtils} from \"content-src/lib/screenshot-utils\";\nimport {TOP_SITES_MAX_SITES_PER_ROW} from \"common/Reducers.jsm\";\n\nexport class TopSiteLink extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {screenshotImage: null};\n    this.onDragEvent = this.onDragEvent.bind(this);\n    this.onKeyPress = this.onKeyPress.bind(this);\n  }\n\n  /*\n   * Helper to determine whether the drop zone should allow a drop. We only allow\n   * dropping top sites for now.\n   */\n  _allowDrop(e) {\n    return e.dataTransfer.types.includes(\"text/topsite-index\");\n  }\n\n  onDragEvent(event) {\n    switch (event.type) {\n      case \"click\":\n        // Stop any link clicks if we started any dragging\n        if (this.dragged) {\n          event.preventDefault();\n        }\n        break;\n      case \"dragstart\":\n        this.dragged = true;\n        event.dataTransfer.effectAllowed = \"move\";\n        event.dataTransfer.setData(\"text/topsite-index\", this.props.index);\n        event.target.blur();\n        this.props.onDragEvent(event, this.props.index, this.props.link, this.props.title);\n        break;\n      case \"dragend\":\n        this.props.onDragEvent(event);\n        break;\n      case \"dragenter\":\n      case \"dragover\":\n      case \"drop\":\n        if (this._allowDrop(event)) {\n          event.preventDefault();\n          this.props.onDragEvent(event, this.props.index);\n        }\n        break;\n      case \"mousedown\":\n        // Block the scroll wheel from appearing for middle clicks on search top sites\n        if (event.button === 1 && this.props.link.searchTopSite) {\n          event.preventDefault();\n        }\n        // Reset at the first mouse event of a potential drag\n        this.dragged = false;\n        break;\n    }\n  }\n\n  /**\n   * Helper to obtain the next state based on nextProps and prevState.\n   *\n   * NOTE: Rename this method to getDerivedStateFromProps when we update React\n   *       to >= 16.3. We will need to update tests as well. We cannot rename this\n   *       method to getDerivedStateFromProps now because there is a mismatch in\n   *       the React version that we are using for both testing and production.\n   *       (i.e. react-test-render => \"16.3.2\", react => \"16.2.0\").\n   *\n   * See https://github.com/airbnb/enzyme/blob/master/packages/enzyme-adapter-react-16/package.json#L43.\n   */\n  static getNextStateFromProps(nextProps, prevState) {\n    const {screenshot} = nextProps.link;\n    const imageInState = ScreenshotUtils.isRemoteImageLocal(prevState.screenshotImage, screenshot);\n    if (imageInState) {\n      return null;\n    }\n\n    // Since image was updated, attempt to revoke old image blob URL, if it exists.\n    ScreenshotUtils.maybeRevokeBlobObjectURL(prevState.screenshotImage);\n\n    return {screenshotImage: ScreenshotUtils.createLocalImageObject(screenshot)};\n  }\n\n  // NOTE: Remove this function when we update React to >= 16.3 since React will\n  //       call getDerivedStateFromProps automatically. We will also need to\n  //       rename getNextStateFromProps to getDerivedStateFromProps.\n  componentWillMount() {\n    const nextState = TopSiteLink.getNextStateFromProps(this.props, this.state);\n    if (nextState) {\n      this.setState(nextState);\n    }\n  }\n\n  // NOTE: Remove this function when we update React to >= 16.3 since React will\n  //       call getDerivedStateFromProps automatically. We will also need to\n  //       rename getNextStateFromProps to getDerivedStateFromProps.\n  componentWillReceiveProps(nextProps) {\n    const nextState = TopSiteLink.getNextStateFromProps(nextProps, this.state);\n    if (nextState) {\n      this.setState(nextState);\n    }\n  }\n\n  componentWillUnmount() {\n    ScreenshotUtils.maybeRevokeBlobObjectURL(this.state.screenshotImage);\n  }\n\n  onKeyPress(event) {\n    // If we have tabbed to a search shortcut top site, and we click 'enter',\n    // we should execute the onClick function. This needs to be added because\n    // search top sites are anchor tags without an href. See bug 1483135\n    if (this.props.link.searchTopSite && event.key === \"Enter\") {\n      this.props.onClick(event);\n    }\n  }\n\n  render() {\n    const {children, className, defaultStyle, isDraggable, link, onClick, title} = this.props;\n    const topSiteOuterClassName = `top-site-outer${className ? ` ${className}` : \"\"}${link.isDragged ? \" dragged\" : \"\"}${link.searchTopSite ? \" search-shortcut\" : \"\"}`;\n    const {tippyTopIcon, faviconSize} = link;\n    const [letterFallback] = title;\n    let imageClassName;\n    let imageStyle;\n    let showSmallFavicon = false;\n    let smallFaviconStyle;\n    let smallFaviconFallback;\n    let hasScreenshotImage = this.state.screenshotImage && this.state.screenshotImage.url;\n    if (defaultStyle) { // force no styles (letter fallback) even if the link has imagery\n      smallFaviconFallback = false;\n    } else if (link.searchTopSite) {\n      imageClassName = \"top-site-icon rich-icon\";\n      imageStyle = {\n        backgroundColor: link.backgroundColor,\n        backgroundImage: `url(${tippyTopIcon})`,\n      };\n      smallFaviconStyle = {backgroundImage:  `url(${tippyTopIcon})`};\n    } else if (link.customScreenshotURL) {\n      // assume high quality custom screenshot and use rich icon styles and class names\n      imageClassName = \"top-site-icon rich-icon\";\n      imageStyle = {\n        backgroundColor: link.backgroundColor,\n        backgroundImage: hasScreenshotImage ? `url(${this.state.screenshotImage.url})` : \"none\",\n      };\n    } else if (tippyTopIcon || faviconSize >= MIN_RICH_FAVICON_SIZE) {\n      // styles and class names for top sites with rich icons\n      imageClassName = \"top-site-icon rich-icon\";\n      imageStyle = {\n        backgroundColor: link.backgroundColor,\n        backgroundImage: `url(${tippyTopIcon || link.favicon})`,\n      };\n    } else {\n      // styles and class names for top sites with screenshot + small icon in top left corner\n      imageClassName = `screenshot${hasScreenshotImage ? \" active\" : \"\"}`;\n      imageStyle = {backgroundImage: hasScreenshotImage ? `url(${this.state.screenshotImage.url})` : \"none\"};\n\n      // only show a favicon in top left if it's greater than 16x16\n      if (faviconSize >= MIN_CORNER_FAVICON_SIZE) {\n        showSmallFavicon = true;\n        smallFaviconStyle = {backgroundImage:  `url(${link.favicon})`};\n      } else if (hasScreenshotImage) {\n        // Don't show a small favicon if there is no screenshot, because that\n        // would result in two fallback icons\n        showSmallFavicon = true;\n        smallFaviconFallback = true;\n      }\n    }\n    let draggableProps = {};\n    if (isDraggable) {\n      draggableProps = {\n        onClick: this.onDragEvent,\n        onDragEnd: this.onDragEvent,\n        onDragStart: this.onDragEvent,\n        onMouseDown: this.onDragEvent,\n      };\n    }\n    return (<li className={topSiteOuterClassName} onDrop={this.onDragEvent} onDragOver={this.onDragEvent} onDragEnter={this.onDragEvent} onDragLeave={this.onDragEvent} {...draggableProps}>\n      <div className=\"top-site-inner\">\n         <a href={!link.searchTopSite && link.url} tabIndex=\"0\" onKeyPress={this.onKeyPress} onClick={onClick} draggable={true}>\n            <div className=\"tile\" aria-hidden={true} data-fallback={letterFallback}>\n              <div className={imageClassName} style={imageStyle} />\n              {link.searchTopSite && <div className=\"top-site-icon search-topsite\" />}\n              {showSmallFavicon && <div\n                className=\"top-site-icon default-icon\"\n                data-fallback={smallFaviconFallback && letterFallback}\n                style={smallFaviconStyle} />}\n           </div>\n           <div className={`title ${link.isPinned ? \"pinned\" : \"\"}`}>\n             {link.isPinned && <div className=\"icon icon-pin-small\" />}\n              <span dir=\"auto\">{title}</span>\n           </div>\n         </a>\n         {children}\n      </div>\n    </li>);\n  }\n}\nTopSiteLink.defaultProps = {\n  title: \"\",\n  link: {},\n  isDraggable: true,\n};\n\nexport class TopSite extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.state = {showContextMenu: false};\n    this.onLinkClick = this.onLinkClick.bind(this);\n    this.onMenuButtonClick = this.onMenuButtonClick.bind(this);\n    this.onMenuUpdate = this.onMenuUpdate.bind(this);\n  }\n\n  /**\n   * Report to telemetry additional information about the item.\n   */\n  _getTelemetryInfo() {\n    const value = {icon_type: this.props.link.iconType};\n    // Filter out \"not_pinned\" type for being the default\n    if (this.props.link.isPinned) {\n      value.card_type = \"pinned\";\n    }\n    if (this.props.link.searchTopSite) {\n      // Set the card_type as \"search\" regardless of its pinning status\n      value.card_type = \"search\";\n      value.search_vendor = this.props.link.hostname;\n    }\n    return {value};\n  }\n\n  userEvent(event) {\n    this.props.dispatch(ac.UserEvent(Object.assign({\n      event,\n      source: TOP_SITES_SOURCE,\n      action_position: this.props.index,\n    }, this._getTelemetryInfo())));\n  }\n\n  onLinkClick(event) {\n    this.userEvent(\"CLICK\");\n\n    // Specially handle a top site link click for \"typed\" frecency bonus as\n    // specified as a property on the link.\n    event.preventDefault();\n    const {altKey, button, ctrlKey, metaKey, shiftKey} = event;\n    if (!this.props.link.searchTopSite) {\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.OPEN_LINK,\n        data: Object.assign(this.props.link, {event: {altKey, button, ctrlKey, metaKey, shiftKey}}),\n      }));\n    } else {\n      this.props.dispatch(ac.OnlyToMain({\n        type: at.FILL_SEARCH_TERM,\n        data: {label: this.props.link.label},\n      }));\n    }\n  }\n\n  onMenuButtonClick(event) {\n    event.preventDefault();\n    this.props.onActivate(this.props.index);\n    this.setState({showContextMenu: true});\n  }\n\n  onMenuUpdate(showContextMenu) {\n    this.setState({showContextMenu});\n  }\n\n  render() {\n    const {props} = this;\n    const {link} = props;\n    const isContextMenuOpen = this.state.showContextMenu && props.activeIndex === props.index;\n    const title = link.label || link.hostname;\n    return (<TopSiteLink {...props} onClick={this.onLinkClick} onDragEvent={this.props.onDragEvent} className={`${props.className || \"\"}${isContextMenuOpen ? \" active\" : \"\"}`} title={title}>\n        <div>\n          <button className=\"context-menu-button icon\" onClick={this.onMenuButtonClick}>\n            <span className=\"sr-only\">\n              <FormattedMessage id=\"context_menu_button_sr\" values={{title}} />\n            </span>\n          </button>\n          {isContextMenuOpen &&\n            <LinkMenu\n              dispatch={props.dispatch}\n              index={props.index}\n              onUpdate={this.onMenuUpdate}\n              options={link.searchTopSite ? TOP_SITES_SEARCH_SHORTCUTS_CONTEXT_MENU_OPTIONS : TOP_SITES_CONTEXT_MENU_OPTIONS}\n              site={link}\n              siteInfo={this._getTelemetryInfo()}\n              source={TOP_SITES_SOURCE} />\n          }\n        </div>\n    </TopSiteLink>);\n  }\n}\nTopSite.defaultProps = {\n  link: {},\n  onActivate() {},\n};\n\nexport class TopSitePlaceholder extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onEditButtonClick = this.onEditButtonClick.bind(this);\n  }\n\n  onEditButtonClick() {\n    this.props.dispatch(\n      {type: at.TOP_SITES_EDIT, data: {index: this.props.index}});\n  }\n\n  render() {\n    return (<TopSiteLink {...this.props} className={`placeholder ${this.props.className || \"\"}`} isDraggable={false}>\n      <button className=\"context-menu-button edit-button icon\"\n       title={this.props.intl.formatMessage({id: \"edit_topsites_edit_button\"})}\n       onClick={this.onEditButtonClick} />\n    </TopSiteLink>);\n  }\n}\n\nexport class _TopSiteList extends React.PureComponent {\n  static get DEFAULT_STATE() {\n    return {\n      activeIndex: null,\n      draggedIndex: null,\n      draggedSite: null,\n      draggedTitle: null,\n      topSitesPreview: null,\n    };\n  }\n\n  constructor(props) {\n    super(props);\n    this.state = _TopSiteList.DEFAULT_STATE;\n    this.onDragEvent = this.onDragEvent.bind(this);\n    this.onActivate = this.onActivate.bind(this);\n  }\n\n  componentWillReceiveProps(nextProps) {\n    if (this.state.draggedSite) {\n      const prevTopSites = this.props.TopSites && this.props.TopSites.rows;\n      const newTopSites = nextProps.TopSites && nextProps.TopSites.rows;\n      if (prevTopSites && prevTopSites[this.state.draggedIndex] &&\n        prevTopSites[this.state.draggedIndex].url === this.state.draggedSite.url &&\n        (!newTopSites[this.state.draggedIndex] || newTopSites[this.state.draggedIndex].url !== this.state.draggedSite.url)) {\n        // We got the new order from the redux store via props. We can clear state now.\n        this.setState(_TopSiteList.DEFAULT_STATE);\n      }\n    }\n  }\n\n  userEvent(event, index) {\n    this.props.dispatch(ac.UserEvent({\n      event,\n      source: TOP_SITES_SOURCE,\n      action_position: index,\n    }));\n  }\n\n  onDragEvent(event, index, link, title) {\n    switch (event.type) {\n      case \"dragstart\":\n        this.dropped = false;\n        this.setState({\n          draggedIndex: index,\n          draggedSite: link,\n          draggedTitle: title,\n          activeIndex: null,\n        });\n        this.userEvent(\"DRAG\", index);\n        break;\n      case \"dragend\":\n        if (!this.dropped) {\n          // If there was no drop event, reset the state to the default.\n          this.setState(_TopSiteList.DEFAULT_STATE);\n        }\n        break;\n      case \"dragenter\":\n        if (index === this.state.draggedIndex) {\n          this.setState({topSitesPreview: null});\n        } else {\n          this.setState({topSitesPreview: this._makeTopSitesPreview(index)});\n        }\n        break;\n      case \"drop\":\n        if (index !== this.state.draggedIndex) {\n          this.dropped = true;\n          this.props.dispatch(ac.AlsoToMain({\n            type: at.TOP_SITES_INSERT,\n            data: {\n              site: {\n                url: this.state.draggedSite.url,\n                label: this.state.draggedTitle,\n                customScreenshotURL: this.state.draggedSite.customScreenshotURL,\n                // Only if the search topsites experiment is enabled\n                ...(this.state.draggedSite.searchTopSite && {searchTopSite: true}),\n              },\n              index,\n              draggedFromIndex: this.state.draggedIndex,\n            },\n          }));\n          this.userEvent(\"DROP\", index);\n        }\n        break;\n    }\n  }\n\n  _getTopSites() {\n    // Make a copy of the sites to truncate or extend to desired length\n    let topSites = this.props.TopSites.rows.slice();\n    topSites.length = this.props.TopSitesRows * TOP_SITES_MAX_SITES_PER_ROW;\n    return topSites;\n  }\n\n  /**\n   * Make a preview of the topsites that will be the result of dropping the currently\n   * dragged site at the specified index.\n   */\n  _makeTopSitesPreview(index) {\n    const topSites = this._getTopSites();\n    topSites[this.state.draggedIndex] = null;\n    const pinnedOnly = topSites.map(site => ((site && site.isPinned) ? site : null));\n    const unpinned = topSites.filter(site => site && !site.isPinned);\n    const siteToInsert = Object.assign({}, this.state.draggedSite, {isPinned: true, isDragged: true});\n    if (!pinnedOnly[index]) {\n      pinnedOnly[index] = siteToInsert;\n    } else {\n      // Find the hole to shift the pinned site(s) towards. We shift towards the\n      // hole left by the site being dragged.\n      let holeIndex = index;\n      const indexStep = index > this.state.draggedIndex ? -1 : 1;\n      while (pinnedOnly[holeIndex]) {\n        holeIndex += indexStep;\n      }\n\n      // Shift towards the hole.\n      const shiftingStep = index > this.state.draggedIndex ? 1 : -1;\n      while (holeIndex !== index) {\n        const nextIndex = holeIndex + shiftingStep;\n        pinnedOnly[holeIndex] = pinnedOnly[nextIndex];\n        holeIndex = nextIndex;\n      }\n      pinnedOnly[index] = siteToInsert;\n    }\n\n    // Fill in the remaining holes with unpinned sites.\n    const preview = pinnedOnly;\n    for (let i = 0; i < preview.length; i++) {\n      if (!preview[i]) {\n        preview[i] = unpinned.shift() || null;\n      }\n    }\n\n    return preview;\n  }\n\n  onActivate(index) {\n    this.setState({activeIndex: index});\n  }\n\n  render() {\n    const {props} = this;\n    const topSites = this.state.topSitesPreview || this._getTopSites();\n    const topSitesUI = [];\n    const commonProps = {\n      onDragEvent: this.onDragEvent,\n      dispatch: props.dispatch,\n      intl: props.intl,\n    };\n    // We assign a key to each placeholder slot. We need it to be independent\n    // of the slot index (i below) so that the keys used stay the same during\n    // drag and drop reordering and the underlying DOM nodes are reused.\n    // This mostly (only?) affects linux so be sure to test on linux before changing.\n    let holeIndex = 0;\n\n    // On narrow viewports, we only show 6 sites per row. We'll mark the rest as\n    // .hide-for-narrow to hide in CSS via @media query.\n    const maxNarrowVisibleIndex = props.TopSitesRows * 6;\n\n    for (let i = 0, l = topSites.length; i < l; i++) {\n      const link = topSites[i] && Object.assign({}, topSites[i], {iconType: this.props.topSiteIconType(topSites[i])});\n      const slotProps = {\n        key: link ? link.url : holeIndex++,\n        index: i,\n      };\n      if (i >= maxNarrowVisibleIndex) {\n        slotProps.className = \"hide-for-narrow\";\n      }\n      topSitesUI.push(!link ? (\n        <TopSitePlaceholder\n          {...slotProps}\n          {...commonProps} />\n      ) : (\n        <TopSite\n          link={link}\n          activeIndex={this.state.activeIndex}\n          onActivate={this.onActivate}\n          {...slotProps}\n          {...commonProps} />\n      ));\n    }\n    return (<ul className={`top-sites-list${this.state.draggedSite ? \" dnd-active\" : \"\"}`}>\n      {topSitesUI}\n    </ul>);\n  }\n}\n\nexport const TopSiteList = injectIntl(_TopSiteList);\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {FormattedMessage, injectIntl} from \"react-intl\";\nimport {connect} from \"react-redux\";\nimport React from \"react\";\n\nexport class _StartupOverlay extends React.PureComponent {\n  constructor(props) {\n    super(props);\n    this.onInputChange = this.onInputChange.bind(this);\n    this.onSubmit = this.onSubmit.bind(this);\n    this.clickSkip = this.clickSkip.bind(this);\n    this.initScene = this.initScene.bind(this);\n    this.removeOverlay = this.removeOverlay.bind(this);\n    this.onInputInvalid = this.onInputInvalid.bind(this);\n\n    this.state = {\n      emailInput: \"\",\n      overlayRemoved: false,\n      flowId: \"\",\n      flowBeginTime: 0,\n    };\n    this.didFetch = false;\n  }\n\n  async componentWillUpdate() {\n    if (this.props.fxa_endpoint && !this.didFetch) {\n      try {\n        this.didFetch = true;\n        const fxaParams = \"entrypoint=activity-stream-firstrun&utm_source=activity-stream&utm_campaign=firstrun&form_type=email\";\n        const response = await fetch(`${this.props.fxa_endpoint}/metrics-flow?${fxaParams}`);\n        if (response.status === 200) {\n          const {flowId, flowBeginTime} = await response.json();\n          this.setState({flowId, flowBeginTime});\n        } else {\n          this.props.dispatch(ac.OnlyToMain({type: at.TELEMETRY_UNDESIRED_EVENT, data: {event: \"FXA_METRICS_FETCH_ERROR\", value: response.status}}));\n        }\n      } catch (error) {\n        this.props.dispatch(ac.OnlyToMain({type: at.TELEMETRY_UNDESIRED_EVENT, data: {event: \"FXA_METRICS_ERROR\"}}));\n      }\n    }\n  }\n\n  componentDidMount() {\n    this.initScene();\n  }\n\n  initScene() {\n    // Timeout to allow the scene to render once before attaching the attribute\n    // to trigger the animation.\n    setTimeout(() => {\n      this.setState({show: true});\n    }, 10);\n  }\n\n  removeOverlay() {\n    window.removeEventListener(\"visibilitychange\", this.removeOverlay);\n    document.body.classList.remove(\"hide-main\");\n    this.setState({show: false});\n    setTimeout(() => {\n      // Allow scrolling and fully remove overlay after animation finishes.\n      document.body.classList.remove(\"welcome\");\n      this.setState({overlayRemoved: true});\n    }, 400);\n  }\n\n  onInputChange(e) {\n    let error = e.target.previousSibling;\n    this.setState({emailInput: e.target.value});\n    error.classList.remove(\"active\");\n    e.target.classList.remove(\"invalid\");\n  }\n\n  onSubmit() {\n    this.props.dispatch(ac.UserEvent({event: \"SUBMIT_EMAIL\", ...this._getFormInfo()}));\n\n    window.addEventListener(\"visibilitychange\", this.removeOverlay);\n  }\n\n  clickSkip() {\n    this.props.dispatch(ac.UserEvent({event: \"SKIPPED_SIGNIN\", ...this._getFormInfo()}));\n    this.removeOverlay();\n  }\n\n  /**\n   * Report to telemetry additional information about the form submission.\n   */\n  _getFormInfo() {\n    const value = {has_flow_params: this.state.flowId.length > 0};\n    return {value};\n  }\n\n  onInputInvalid(e) {\n    let error = e.target.previousSibling;\n    error.classList.add(\"active\");\n    e.target.classList.add(\"invalid\");\n    e.preventDefault(); // Override built-in form validation popup\n    e.target.focus();\n  }\n\n  render() {\n    // When skipping the onboarding tour we show AS but we are still on\n    // about:welcome, prop.isFirstrun is true and StartupOverlay is rendered\n    if (this.state.overlayRemoved) {\n      return null;\n    }\n\n    let termsLink = (<a href={`${this.props.fxa_endpoint}/legal/terms`} target=\"_blank\" rel=\"noopener noreferrer\"><FormattedMessage id=\"firstrun_terms_of_service\" /></a>);\n    let privacyLink = (<a href={`${this.props.fxa_endpoint}/legal/privacy`} target=\"_blank\" rel=\"noopener noreferrer\"><FormattedMessage id=\"firstrun_privacy_notice\" /></a>);\n\n    return (\n      <div className={`overlay-wrapper ${this.state.show ? \"show\" : \"\"}`}>\n        <div className=\"background\" />\n        <div className=\"firstrun-scene\">\n          <div className=\"fxaccounts-container\">\n            <div className=\"firstrun-left-divider\">\n              <h1 className=\"firstrun-title\"><FormattedMessage id=\"firstrun_title\" /></h1>\n              <p className=\"firstrun-content\"><FormattedMessage id=\"firstrun_content\" /></p>\n              <a className=\"firstrun-link\" href=\"https://www.mozilla.org/firefox/features/sync/\" target=\"_blank\" rel=\"noopener noreferrer\"><FormattedMessage id=\"firstrun_learn_more_link\" /></a>\n            </div>\n            <div className=\"firstrun-sign-in\">\n              <p className=\"form-header\"><FormattedMessage id=\"firstrun_form_header\" /><span className=\"sub-header\"><FormattedMessage id=\"firstrun_form_sub_header\" /></span></p>\n              <form method=\"get\" action={this.props.fxa_endpoint} target=\"_blank\" rel=\"noopener noreferrer\" onSubmit={this.onSubmit}>\n                <input name=\"service\" type=\"hidden\" value=\"sync\" />\n                <input name=\"action\" type=\"hidden\" value=\"email\" />\n                <input name=\"context\" type=\"hidden\" value=\"fx_desktop_v3\" />\n                <input name=\"entrypoint\" type=\"hidden\" value=\"activity-stream-firstrun\" />\n                <input name=\"utm_source\" type=\"hidden\" value=\"activity-stream\" />\n                <input name=\"utm_campaign\" type=\"hidden\" value=\"firstrun\" />\n                <input name=\"flow_id\" type=\"hidden\" value={this.state.flowId} />\n                <input name=\"flow_begin_time\" type=\"hidden\" value={this.state.flowBeginTime} />\n                <span className=\"error\">{this.props.intl.formatMessage({id: \"firstrun_invalid_input\"})}</span>\n                <input className=\"email-input\" name=\"email\" type=\"email\" required=\"true\" onInvalid={this.onInputInvalid} placeholder={this.props.intl.formatMessage({id: \"firstrun_email_input_placeholder\"})} onChange={this.onInputChange} />\n                <div className=\"extra-links\">\n                  <FormattedMessage\n                    id=\"firstrun_extra_legal_links\"\n                    values={{\n                      terms: termsLink,\n                      privacy: privacyLink,\n                    }} />\n                </div>\n                <button className=\"continue-button\" type=\"submit\"><FormattedMessage id=\"firstrun_continue_to_login\" /></button>\n              </form>\n              <button className=\"skip-button\" disabled={!!this.state.emailInput} onClick={this.clickSkip}><FormattedMessage id=\"firstrun_skip_login\" /></button>\n            </div>\n          </div>\n        </div>\n      </div>\n    );\n  }\n}\n\nconst getState = state => ({fxa_endpoint: state.Prefs.values.fxa_endpoint});\nexport const StartupOverlay = connect(getState)(injectIntl(_StartupOverlay));\n","import {actionCreators as ac, actionTypes as at} from \"common/Actions.jsm\";\nimport {perfService as perfSvc} from \"common/PerfService.jsm\";\n\nconst VISIBLE = \"visible\";\nconst VISIBILITY_CHANGE_EVENT = \"visibilitychange\";\n\nexport class DetectUserSessionStart {\n  constructor(store, options = {}) {\n    this._store = store;\n    // Overrides for testing\n    this.document = options.document || global.document;\n    this._perfService = options.perfService || perfSvc;\n    this._onVisibilityChange = this._onVisibilityChange.bind(this);\n  }\n\n  /**\n   * sendEventOrAddListener - Notify immediately if the page is already visible,\n   *                    or else set up a listener for when visibility changes.\n   *                    This is needed for accurate session tracking for telemetry,\n   *                    because tabs are pre-loaded.\n   */\n  sendEventOrAddListener() {\n    if (this.document.visibilityState === VISIBLE) {\n      // If the document is already visible, to the user, send a notification\n      // immediately that a session has started.\n      this._sendEvent();\n    } else {\n      // If the document is not visible, listen for when it does become visible.\n      this.document.addEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n\n  /**\n   * _sendEvent - Sends a message to the main process to indicate the current\n   *              tab is now visible to the user, includes the\n   *              visibility_event_rcvd_ts time in ms from the UNIX epoch.\n   */\n  _sendEvent() {\n    this._perfService.mark(\"visibility_event_rcvd_ts\");\n\n    try {\n      let visibility_event_rcvd_ts = this._perfService\n        .getMostRecentAbsMarkStartByName(\"visibility_event_rcvd_ts\");\n\n      this._store.dispatch(ac.AlsoToMain({\n        type: at.SAVE_SESSION_PERF_DATA,\n        data: {visibility_event_rcvd_ts},\n      }));\n    } catch (ex) {\n      // If this failed, it's likely because the `privacy.resistFingerprinting`\n      // pref is true.  We should at least not blow up.\n    }\n  }\n\n  /**\n   * _onVisibilityChange - If the visibility has changed to visible, sends a notification\n   *                      and removes the event listener. This should only be called once per tab.\n   */\n  _onVisibilityChange() {\n    if (this.document.visibilityState === VISIBLE) {\n      this._sendEvent();\n      this.document.removeEventListener(VISIBILITY_CHANGE_EVENT, this._onVisibilityChange);\n    }\n  }\n}\n","export function enableASRouterContent(store, asrouterContent) {\n  let didHideOnboarding = false;\n\n  // Enable asrouter content\n  store.subscribe(() => {\n    const state = store.getState();\n    if (!state.ASRouter.initialized) {\n      return;\n    }\n\n    if (!asrouterContent.initialized) {\n      asrouterContent.init();\n    }\n\n    // Until we can delete the existing onboarding tour, just hide the onboarding button when users are in\n    // the new simplified onboarding experiment. CSS hacks ftw\n    if (state.ASRouter.allowLegacyOnboarding === false && !didHideOnboarding) {\n      global.document.body.classList.add(\"hide-onboarding\");\n      didHideOnboarding = true;\n    } else if (state.ASRouter.allowLegacyOnboarding === true && didHideOnboarding) {\n      global.document.body.classList.remove(\"hide-onboarding\");\n      didHideOnboarding = false;\n    }\n  });\n  // Return this for testing purposes\n  return {asrouterContent};\n}\n","/*  eslint no-magic-numbers: [0]  */\n\nconst MAX_PLACEABLES = 100;\n\nconst entryIdentifierRe = /-?[a-zA-Z][a-zA-Z0-9_-]*/y;\nconst identifierRe = /[a-zA-Z][a-zA-Z0-9_-]*/y;\nconst functionIdentifierRe = /^[A-Z][A-Z_?-]*$/;\n\n/**\n * The `Parser` class is responsible for parsing FTL resources.\n *\n * It's only public method is `getResource(source)` which takes an FTL string\n * and returns a two element Array with an Object of entries generated from the\n * source as the first element and an array of SyntaxError objects as the\n * second.\n *\n * This parser is optimized for runtime performance.\n *\n * There is an equivalent of this parser in syntax/parser which is\n * generating full AST which is useful for FTL tools.\n */\nclass RuntimeParser {\n  /**\n   * Parse FTL code into entries formattable by the MessageContext.\n   *\n   * Given a string of FTL syntax, return a map of entries that can be passed\n   * to MessageContext.format and a list of errors encountered during parsing.\n   *\n   * @param {String} string\n   * @returns {Array<Object, Array>}\n   */\n  getResource(string) {\n    this._source = string;\n    this._index = 0;\n    this._length = string.length;\n    this.entries = {};\n\n    const errors = [];\n\n    this.skipWS();\n    while (this._index < this._length) {\n      try {\n        this.getEntry();\n      } catch (e) {\n        if (e instanceof SyntaxError) {\n          errors.push(e);\n\n          this.skipToNextEntryStart();\n        } else {\n          throw e;\n        }\n      }\n      this.skipWS();\n    }\n\n    return [this.entries, errors];\n  }\n\n  /**\n   * Parse the source string from the current index as an FTL entry\n   * and add it to object's entries property.\n   *\n   * @private\n   */\n  getEntry() {\n    // The index here should either be at the beginning of the file\n    // or right after new line.\n    if (this._index !== 0 &&\n        this._source[this._index - 1] !== \"\\n\") {\n      throw this.error(`Expected an entry to start\n        at the beginning of the file or on a new line.`);\n    }\n\n    const ch = this._source[this._index];\n\n    // We don't care about comments or sections at runtime\n    if (ch === \"/\" ||\n      (ch === \"#\" &&\n        [\" \", \"#\", \"\\n\"].includes(this._source[this._index + 1]))) {\n      this.skipComment();\n      return;\n    }\n\n    if (ch === \"[\") {\n      this.skipSection();\n      return;\n    }\n\n    this.getMessage();\n  }\n\n  /**\n   * Skip the section entry from the current index.\n   *\n   * @private\n   */\n  skipSection() {\n    this._index += 1;\n    if (this._source[this._index] !== \"[\") {\n      throw this.error('Expected \"[[\" to open a section');\n    }\n\n    this._index += 1;\n\n    this.skipInlineWS();\n    this.getVariantName();\n    this.skipInlineWS();\n\n    if (this._source[this._index] !== \"]\" ||\n        this._source[this._index + 1] !== \"]\") {\n      throw this.error('Expected \"]]\" to close a section');\n    }\n\n    this._index += 2;\n  }\n\n  /**\n   * Parse the source string from the current index as an FTL message\n   * and add it to the entries property on the Parser.\n   *\n   * @private\n   */\n  getMessage() {\n    const id = this.getEntryIdentifier();\n\n    this.skipInlineWS();\n\n    if (this._source[this._index] === \"=\") {\n      this._index++;\n    }\n\n    this.skipInlineWS();\n\n    const val = this.getPattern();\n\n    if (id.startsWith(\"-\") && val === null) {\n      throw this.error(\"Expected term to have a value\");\n    }\n\n    let attrs = null;\n\n    if (this._source[this._index] === \" \") {\n      const lineStart = this._index;\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \".\") {\n        this._index = lineStart;\n        attrs = this.getAttributes();\n      }\n    }\n\n    if (attrs === null && typeof val === \"string\") {\n      this.entries[id] = val;\n    } else {\n      if (val === null && attrs === null) {\n        throw this.error(\"Expected message to have a value or attributes\");\n      }\n\n      this.entries[id] = {};\n\n      if (val !== null) {\n        this.entries[id].val = val;\n      }\n\n      if (attrs !== null) {\n        this.entries[id].attrs = attrs;\n      }\n    }\n  }\n\n  /**\n   * Skip whitespace.\n   *\n   * @private\n   */\n  skipWS() {\n    let ch = this._source[this._index];\n    while (ch === \" \" || ch === \"\\n\" || ch === \"\\t\" || ch === \"\\r\") {\n      ch = this._source[++this._index];\n    }\n  }\n\n  /**\n   * Skip inline whitespace (space and \\t).\n   *\n   * @private\n   */\n  skipInlineWS() {\n    let ch = this._source[this._index];\n    while (ch === \" \" || ch === \"\\t\") {\n      ch = this._source[++this._index];\n    }\n  }\n\n  /**\n   * Skip blank lines.\n   *\n   * @private\n   */\n  skipBlankLines() {\n    while (true) {\n      const ptr = this._index;\n\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \"\\n\") {\n        this._index += 1;\n      } else {\n        this._index = ptr;\n        break;\n      }\n    }\n  }\n\n  /**\n   * Get identifier using the provided regex.\n   *\n   * By default this will get identifiers of public messages, attributes and\n   * external arguments (without the $).\n   *\n   * @returns {String}\n   * @private\n   */\n  getIdentifier(re = identifierRe) {\n    re.lastIndex = this._index;\n    const result = re.exec(this._source);\n\n    if (result === null) {\n      this._index += 1;\n      throw this.error(`Expected an identifier [${re.toString()}]`);\n    }\n\n    this._index = re.lastIndex;\n    return result[0];\n  }\n\n  /**\n   * Get identifier of a Message or a Term (staring with a dash).\n   *\n   * @returns {String}\n   * @private\n   */\n  getEntryIdentifier() {\n    return this.getIdentifier(entryIdentifierRe);\n  }\n\n  /**\n   * Get Variant name.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getVariantName() {\n    let name = \"\";\n\n    const start = this._index;\n    let cc = this._source.charCodeAt(this._index);\n\n    if ((cc >= 97 && cc <= 122) || // a-z\n        (cc >= 65 && cc <= 90) || // A-Z\n        cc === 95 || cc === 32) { // _ <space>\n      cc = this._source.charCodeAt(++this._index);\n    } else {\n      throw this.error(\"Expected a keyword (starting with [a-zA-Z_])\");\n    }\n\n    while ((cc >= 97 && cc <= 122) || // a-z\n           (cc >= 65 && cc <= 90) || // A-Z\n           (cc >= 48 && cc <= 57) || // 0-9\n           cc === 95 || cc === 45 || cc === 32) { // _- <space>\n      cc = this._source.charCodeAt(++this._index);\n    }\n\n    // If we encountered the end of name, we want to test if the last\n    // collected character is a space.\n    // If it is, we will backtrack to the last non-space character because\n    // the keyword cannot end with a space character.\n    while (this._source.charCodeAt(this._index - 1) === 32) {\n      this._index--;\n    }\n\n    name += this._source.slice(start, this._index);\n\n    return { type: \"varname\", name };\n  }\n\n  /**\n   * Get simple string argument enclosed in `\"`.\n   *\n   * @returns {String}\n   * @private\n   */\n  getString() {\n    const start = this._index + 1;\n\n    while (++this._index < this._length) {\n      const ch = this._source[this._index];\n\n      if (ch === '\"') {\n        break;\n      }\n\n      if (ch === \"\\n\") {\n        throw this.error(\"Unterminated string expression\");\n      }\n    }\n\n    return this._source.substring(start, this._index++);\n  }\n\n  /**\n   * Parses a Message pattern.\n   * Message Pattern may be a simple string or an array of strings\n   * and placeable expressions.\n   *\n   * @returns {String|Array}\n   * @private\n   */\n  getPattern() {\n    // We're going to first try to see if the pattern is simple.\n    // If it is we can just look for the end of the line and read the string.\n    //\n    // Then, if either the line contains a placeable opening `{` or the\n    // next line starts an indentation, we switch to complex pattern.\n    const start = this._index;\n    let eol = this._source.indexOf(\"\\n\", this._index);\n\n    if (eol === -1) {\n      eol = this._length;\n    }\n\n    const firstLineContent = start !== eol ?\n      this._source.slice(start, eol) : null;\n\n    if (firstLineContent && firstLineContent.includes(\"{\")) {\n      return this.getComplexPattern();\n    }\n\n    this._index = eol + 1;\n\n    this.skipBlankLines();\n\n    if (this._source[this._index] !== \" \") {\n      // No indentation means we're done with this message. Callers should check\n      // if the return value here is null. It may be OK for messages, but not OK\n      // for terms, attributes and variants.\n      return firstLineContent;\n    }\n\n    const lineStart = this._index;\n\n    this.skipInlineWS();\n\n    if (this._source[this._index] === \".\") {\n      // The pattern is followed by an attribute. Rewind _index to the first\n      // column of the current line as expected by getAttributes.\n      this._index = lineStart;\n      return firstLineContent;\n    }\n\n    if (firstLineContent) {\n      // It's a multiline pattern which started on the same line as the\n      // identifier. Reparse the whole pattern to make sure we get all of it.\n      this._index = start;\n    }\n\n    return this.getComplexPattern();\n  }\n\n  /**\n   * Parses a complex Message pattern.\n   * This function is called by getPattern when the message is multiline,\n   * or contains escape chars or placeables.\n   * It does full parsing of complex patterns.\n   *\n   * @returns {Array}\n   * @private\n   */\n  /* eslint-disable complexity */\n  getComplexPattern() {\n    let buffer = \"\";\n    const content = [];\n    let placeables = 0;\n\n    let ch = this._source[this._index];\n\n    while (this._index < this._length) {\n      // This block handles multi-line strings combining strings separated\n      // by new line.\n      if (ch === \"\\n\") {\n        this._index++;\n\n        // We want to capture the start and end pointers\n        // around blank lines and add them to the buffer\n        // but only if the blank lines are in the middle\n        // of the string.\n        const blankLinesStart = this._index;\n        this.skipBlankLines();\n        const blankLinesEnd = this._index;\n\n\n        if (this._source[this._index] !== \" \") {\n          break;\n        }\n        this.skipInlineWS();\n\n        if (this._source[this._index] === \"}\" ||\n            this._source[this._index] === \"[\" ||\n            this._source[this._index] === \"*\" ||\n            this._source[this._index] === \".\") {\n          this._index = blankLinesEnd;\n          break;\n        }\n\n        buffer += this._source.substring(blankLinesStart, blankLinesEnd);\n\n        if (buffer.length || content.length) {\n          buffer += \"\\n\";\n        }\n        ch = this._source[this._index];\n        continue;\n      } else if (ch === \"\\\\\") {\n        const ch2 = this._source[this._index + 1];\n        if (ch2 === '\"' || ch2 === \"{\" || ch2 === \"\\\\\") {\n          ch = ch2;\n          this._index++;\n        }\n      } else if (ch === \"{\") {\n        // Push the buffer to content array right before placeable\n        if (buffer.length) {\n          content.push(buffer);\n        }\n        if (placeables > MAX_PLACEABLES - 1) {\n          throw this.error(\n            `Too many placeables, maximum allowed is ${MAX_PLACEABLES}`);\n        }\n        buffer = \"\";\n        content.push(this.getPlaceable());\n\n        this._index++;\n\n        ch = this._source[this._index];\n        placeables++;\n        continue;\n      }\n\n      if (ch) {\n        buffer += ch;\n      }\n      this._index++;\n      ch = this._source[this._index];\n    }\n\n    if (content.length === 0) {\n      return buffer.length ? buffer : null;\n    }\n\n    if (buffer.length) {\n      content.push(buffer);\n    }\n\n    return content;\n  }\n  /* eslint-enable complexity */\n\n  /**\n   * Parses a single placeable in a Message pattern and returns its\n   * expression.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getPlaceable() {\n    const start = ++this._index;\n\n    this.skipWS();\n\n    if (this._source[this._index] === \"*\" ||\n       (this._source[this._index] === \"[\" &&\n        this._source[this._index + 1] !== \"]\")) {\n      const variants = this.getVariants();\n\n      return {\n        type: \"sel\",\n        exp: null,\n        vars: variants[0],\n        def: variants[1]\n      };\n    }\n\n    // Rewind the index and only support in-line white-space now.\n    this._index = start;\n    this.skipInlineWS();\n\n    const selector = this.getSelectorExpression();\n\n    this.skipWS();\n\n    const ch = this._source[this._index];\n\n    if (ch === \"}\") {\n      if (selector.type === \"attr\" && selector.id.name.startsWith(\"-\")) {\n        throw this.error(\n          \"Attributes of private messages cannot be interpolated.\"\n        );\n      }\n\n      return selector;\n    }\n\n    if (ch !== \"-\" || this._source[this._index + 1] !== \">\") {\n      throw this.error('Expected \"}\" or \"->\"');\n    }\n\n    if (selector.type === \"ref\") {\n      throw this.error(\"Message references cannot be used as selectors.\");\n    }\n\n    if (selector.type === \"var\") {\n      throw this.error(\"Variants cannot be used as selectors.\");\n    }\n\n    if (selector.type === \"attr\" && !selector.id.name.startsWith(\"-\")) {\n      throw this.error(\n        \"Attributes of public messages cannot be used as selectors.\"\n      );\n    }\n\n\n    this._index += 2; // ->\n\n    this.skipInlineWS();\n\n    if (this._source[this._index] !== \"\\n\") {\n      throw this.error(\"Variants should be listed in a new line\");\n    }\n\n    this.skipWS();\n\n    const variants = this.getVariants();\n\n    if (variants[0].length === 0) {\n      throw this.error(\"Expected members for the select expression\");\n    }\n\n    return {\n      type: \"sel\",\n      exp: selector,\n      vars: variants[0],\n      def: variants[1]\n    };\n  }\n\n  /**\n   * Parses a selector expression.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getSelectorExpression() {\n    const literal = this.getLiteral();\n\n    if (literal.type !== \"ref\") {\n      return literal;\n    }\n\n    if (this._source[this._index] === \".\") {\n      this._index++;\n\n      const name = this.getIdentifier();\n      this._index++;\n      return {\n        type: \"attr\",\n        id: literal,\n        name\n      };\n    }\n\n    if (this._source[this._index] === \"[\") {\n      this._index++;\n\n      const key = this.getVariantKey();\n      this._index++;\n      return {\n        type: \"var\",\n        id: literal,\n        key\n      };\n    }\n\n    if (this._source[this._index] === \"(\") {\n      this._index++;\n      const args = this.getCallArgs();\n\n      if (!functionIdentifierRe.test(literal.name)) {\n        throw this.error(\"Function names must be all upper-case\");\n      }\n\n      this._index++;\n\n      literal.type = \"fun\";\n\n      return {\n        type: \"call\",\n        fun: literal,\n        args\n      };\n    }\n\n    return literal;\n  }\n\n  /**\n   * Parses call arguments for a CallExpression.\n   *\n   * @returns {Array}\n   * @private\n   */\n  getCallArgs() {\n    const args = [];\n\n    while (this._index < this._length) {\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \")\") {\n        return args;\n      }\n\n      const exp = this.getSelectorExpression();\n\n      // MessageReference in this place may be an entity reference, like:\n      // `call(foo)`, or, if it's followed by `:` it will be a key-value pair.\n      if (exp.type !== \"ref\") {\n        args.push(exp);\n      } else {\n        this.skipInlineWS();\n\n        if (this._source[this._index] === \":\") {\n          this._index++;\n          this.skipInlineWS();\n\n          const val = this.getSelectorExpression();\n\n          // If the expression returned as a value of the argument\n          // is not a quote delimited string or number, throw.\n          //\n          // We don't have to check here if the pattern is quote delimited\n          // because that's the only type of string allowed in expressions.\n          if (typeof val === \"string\" ||\n              Array.isArray(val) ||\n              val.type === \"num\") {\n            args.push({\n              type: \"narg\",\n              name: exp.name,\n              val\n            });\n          } else {\n            this._index = this._source.lastIndexOf(\":\", this._index) + 1;\n            throw this.error(\n              \"Expected string in quotes, number.\");\n          }\n\n        } else {\n          args.push(exp);\n        }\n      }\n\n      this.skipInlineWS();\n\n      if (this._source[this._index] === \")\") {\n        break;\n      } else if (this._source[this._index] === \",\") {\n        this._index++;\n      } else {\n        throw this.error('Expected \",\" or \")\"');\n      }\n    }\n\n    return args;\n  }\n\n  /**\n   * Parses an FTL Number.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getNumber() {\n    let num = \"\";\n    let cc = this._source.charCodeAt(this._index);\n\n    // The number literal may start with negative sign `-`.\n    if (cc === 45) {\n      num += \"-\";\n      cc = this._source.charCodeAt(++this._index);\n    }\n\n    // next, we expect at least one digit\n    if (cc < 48 || cc > 57) {\n      throw this.error(`Unknown literal \"${num}\"`);\n    }\n\n    // followed by potentially more digits\n    while (cc >= 48 && cc <= 57) {\n      num += this._source[this._index++];\n      cc = this._source.charCodeAt(this._index);\n    }\n\n    // followed by an optional decimal separator `.`\n    if (cc === 46) {\n      num += this._source[this._index++];\n      cc = this._source.charCodeAt(this._index);\n\n      // followed by at least one digit\n      if (cc < 48 || cc > 57) {\n        throw this.error(`Unknown literal \"${num}\"`);\n      }\n\n      // and optionally more digits\n      while (cc >= 48 && cc <= 57) {\n        num += this._source[this._index++];\n        cc = this._source.charCodeAt(this._index);\n      }\n    }\n\n    return {\n      type: \"num\",\n      val: num\n    };\n  }\n\n  /**\n   * Parses a list of Message attributes.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getAttributes() {\n    const attrs = {};\n\n    while (this._index < this._length) {\n      if (this._source[this._index] !== \" \") {\n        break;\n      }\n      this.skipInlineWS();\n\n      if (this._source[this._index] !== \".\") {\n        break;\n      }\n      this._index++;\n\n      const key = this.getIdentifier();\n\n      this.skipInlineWS();\n\n      if (this._source[this._index] !== \"=\") {\n        throw this.error('Expected \"=\"');\n      }\n      this._index++;\n\n      this.skipInlineWS();\n\n      const val = this.getPattern();\n\n      if (val === null) {\n        throw this.error(\"Expected attribute to have a value\");\n      }\n\n      if (typeof val === \"string\") {\n        attrs[key] = val;\n      } else {\n        attrs[key] = {\n          val\n        };\n      }\n\n      this.skipBlankLines();\n    }\n\n    return attrs;\n  }\n\n  /**\n   * Parses a list of Selector variants.\n   *\n   * @returns {Array}\n   * @private\n   */\n  getVariants() {\n    const variants = [];\n    let index = 0;\n    let defaultIndex;\n\n    while (this._index < this._length) {\n      const ch = this._source[this._index];\n\n      if ((ch !== \"[\" || this._source[this._index + 1] === \"[\") &&\n          ch !== \"*\") {\n        break;\n      }\n      if (ch === \"*\") {\n        this._index++;\n        defaultIndex = index;\n      }\n\n      if (this._source[this._index] !== \"[\") {\n        throw this.error('Expected \"[\"');\n      }\n\n      this._index++;\n\n      const key = this.getVariantKey();\n\n      this.skipInlineWS();\n\n      const val = this.getPattern();\n\n      if (val === null) {\n        throw this.error(\"Expected variant to have a value\");\n      }\n\n      variants[index++] = {key, val};\n\n      this.skipWS();\n    }\n\n    return [variants, defaultIndex];\n  }\n\n  /**\n   * Parses a Variant key.\n   *\n   * @returns {String}\n   * @private\n   */\n  getVariantKey() {\n    // VariantKey may be a Keyword or Number\n\n    const cc = this._source.charCodeAt(this._index);\n    let literal;\n\n    if ((cc >= 48 && cc <= 57) || cc === 45) {\n      literal = this.getNumber();\n    } else {\n      literal = this.getVariantName();\n    }\n\n    if (this._source[this._index] !== \"]\") {\n      throw this.error('Expected \"]\"');\n    }\n\n    this._index++;\n    return literal;\n  }\n\n  /**\n   * Parses an FTL literal.\n   *\n   * @returns {Object}\n   * @private\n   */\n  getLiteral() {\n    const cc0 = this._source.charCodeAt(this._index);\n\n    if (cc0 === 36) { // $\n      this._index++;\n      return {\n        type: \"ext\",\n        name: this.getIdentifier()\n      };\n    }\n\n    const cc1 = cc0 === 45 // -\n      // Peek at the next character after the dash.\n      ? this._source.charCodeAt(this._index + 1)\n      // Or keep using the character at the current index.\n      : cc0;\n\n    if ((cc1 >= 97 && cc1 <= 122) || // a-z\n        (cc1 >= 65 && cc1 <= 90)) { // A-Z\n      return {\n        type: \"ref\",\n        name: this.getEntryIdentifier()\n      };\n    }\n\n    if ((cc1 >= 48 && cc1 <= 57)) { // 0-9\n      return this.getNumber();\n    }\n\n    if (cc0 === 34) { // \"\n      return this.getString();\n    }\n\n    throw this.error(\"Expected literal\");\n  }\n\n  /**\n   * Skips an FTL comment.\n   *\n   * @private\n   */\n  skipComment() {\n    // At runtime, we don't care about comments so we just have\n    // to parse them properly and skip their content.\n    let eol = this._source.indexOf(\"\\n\", this._index);\n\n    while (eol !== -1 &&\n      ((this._source[eol + 1] === \"/\" && this._source[eol + 2] === \"/\") ||\n       (this._source[eol + 1] === \"#\" &&\n         [\" \", \"#\"].includes(this._source[eol + 2])))) {\n      this._index = eol + 3;\n\n      eol = this._source.indexOf(\"\\n\", this._index);\n\n      if (eol === -1) {\n        break;\n      }\n    }\n\n    if (eol === -1) {\n      this._index = this._length;\n    } else {\n      this._index = eol + 1;\n    }\n  }\n\n  /**\n   * Creates a new SyntaxError object with a given message.\n   *\n   * @param {String} message\n   * @returns {Object}\n   * @private\n   */\n  error(message) {\n    return new SyntaxError(message);\n  }\n\n  /**\n   * Skips to the beginning of a next entry after the current position.\n   * This is used to mark the boundary of junk entry in case of error,\n   * and recover from the returned position.\n   *\n   * @private\n   */\n  skipToNextEntryStart() {\n    let start = this._index;\n\n    while (true) {\n      if (start === 0 || this._source[start - 1] === \"\\n\") {\n        const cc = this._source.charCodeAt(start);\n\n        if ((cc >= 97 && cc <= 122) || // a-z\n            (cc >= 65 && cc <= 90) || // A-Z\n             cc === 47 || cc === 91) { // /[\n          this._index = start;\n          return;\n        }\n      }\n\n      start = this._source.indexOf(\"\\n\", start);\n\n      if (start === -1) {\n        this._index = this._length;\n        return;\n      }\n      start++;\n    }\n  }\n}\n\n/**\n * Parses an FTL string using RuntimeParser and returns the generated\n * object with entries and a list of errors.\n *\n * @param {String} string\n * @returns {Array<Object, Array>}\n */\nexport default function parse(string) {\n  const parser = new RuntimeParser();\n  return parser.getResource(string);\n}\n","/* global Intl */\n\n/**\n * The `FluentType` class is the base of Fluent's type system.\n *\n * Fluent types wrap JavaScript values and store additional configuration for\n * them, which can then be used in the `toString` method together with a proper\n * `Intl` formatter.\n */\nexport class FluentType {\n\n  /**\n   * Create an `FluentType` instance.\n   *\n   * @param   {Any}    value - JavaScript value to wrap.\n   * @param   {Object} opts  - Configuration.\n   * @returns {FluentType}\n   */\n  constructor(value, opts) {\n    this.value = value;\n    this.opts = opts;\n  }\n\n  /**\n   * Unwrap the raw value stored by this `FluentType`.\n   *\n   * @returns {Any}\n   */\n  valueOf() {\n    return this.value;\n  }\n\n  /**\n   * Format this instance of `FluentType` to a string.\n   *\n   * Formatted values are suitable for use outside of the `MessageContext`.\n   * This method can use `Intl` formatters memoized by the `MessageContext`\n   * instance passed as an argument.\n   *\n   * @param   {MessageContext} [ctx]\n   * @returns {string}\n   */\n  toString() {\n    throw new Error(\"Subclasses of FluentType must implement toString.\");\n  }\n}\n\nexport class FluentNone extends FluentType {\n  toString() {\n    return this.value || \"???\";\n  }\n}\n\nexport class FluentNumber extends FluentType {\n  constructor(value, opts) {\n    super(parseFloat(value), opts);\n  }\n\n  toString(ctx) {\n    try {\n      const nf = ctx._memoizeIntlObject(\n        Intl.NumberFormat, this.opts\n      );\n      return nf.format(this.value);\n    } catch (e) {\n      // XXX Report the error.\n      return this.value;\n    }\n  }\n\n  /**\n   * Compare the object with another instance of a FluentType.\n   *\n   * @param   {MessageContext} ctx\n   * @param   {FluentType}     other\n   * @returns {bool}\n   */\n  match(ctx, other) {\n    if (other instanceof FluentNumber) {\n      return this.value === other.value;\n    }\n    return false;\n  }\n}\n\nexport class FluentDateTime extends FluentType {\n  constructor(value, opts) {\n    super(new Date(value), opts);\n  }\n\n  toString(ctx) {\n    try {\n      const dtf = ctx._memoizeIntlObject(\n        Intl.DateTimeFormat, this.opts\n      );\n      return dtf.format(this.value);\n    } catch (e) {\n      // XXX Report the error.\n      return this.value;\n    }\n  }\n}\n\nexport class FluentSymbol extends FluentType {\n  toString() {\n    return this.value;\n  }\n\n  /**\n   * Compare the object with another instance of a FluentType.\n   *\n   * @param   {MessageContext} ctx\n   * @param   {FluentType}     other\n   * @returns {bool}\n   */\n  match(ctx, other) {\n    if (other instanceof FluentSymbol) {\n      return this.value === other.value;\n    } else if (typeof other === \"string\") {\n      return this.value === other;\n    } else if (other instanceof FluentNumber) {\n      const pr = ctx._memoizeIntlObject(\n        Intl.PluralRules, other.opts\n      );\n      return this.value === pr.select(other.value);\n    }\n    return false;\n  }\n}\n","/**\n * @overview\n *\n * The FTL resolver ships with a number of functions built-in.\n *\n * Each function take two arguments:\n *   - args - an array of positional args\n *   - opts - an object of key-value args\n *\n * Arguments to functions are guaranteed to already be instances of\n * `FluentType`.  Functions must return `FluentType` objects as well.\n */\n\nimport { FluentNumber, FluentDateTime } from \"./types\";\n\nexport default {\n  \"NUMBER\": ([arg], opts) =>\n    new FluentNumber(arg.valueOf(), merge(arg.opts, opts)),\n  \"DATETIME\": ([arg], opts) =>\n    new FluentDateTime(arg.valueOf(), merge(arg.opts, opts)),\n};\n\nfunction merge(argopts, opts) {\n  return Object.assign({}, argopts, values(opts));\n}\n\nfunction values(opts) {\n  const unwrapped = {};\n  for (const [name, opt] of Object.entries(opts)) {\n    unwrapped[name] = opt.valueOf();\n  }\n  return unwrapped;\n}\n","/**\n * @overview\n *\n * The role of the Fluent resolver is to format a translation object to an\n * instance of `FluentType` or an array of instances.\n *\n * Translations can contain references to other messages or external arguments,\n * conditional logic in form of select expressions, traits which describe their\n * grammatical features, and can use Fluent builtins which make use of the\n * `Intl` formatters to format numbers, dates, lists and more into the\n * context's language.  See the documentation of the Fluent syntax for more\n * information.\n *\n * In case of errors the resolver will try to salvage as much of the\n * translation as possible.  In rare situations where the resolver didn't know\n * how to recover from an error it will return an instance of `FluentNone`.\n *\n * `MessageReference`, `VariantExpression`, `AttributeExpression` and\n * `SelectExpression` resolve to raw Runtime Entries objects and the result of\n * the resolution needs to be passed into `Type` to get their real value.\n * This is useful for composing expressions.  Consider:\n *\n *     brand-name[nominative]\n *\n * which is a `VariantExpression` with properties `id: MessageReference` and\n * `key: Keyword`.  If `MessageReference` was resolved eagerly, it would\n * instantly resolve to the value of the `brand-name` message.  Instead, we\n * want to get the message object and look for its `nominative` variant.\n *\n * All other expressions (except for `FunctionReference` which is only used in\n * `CallExpression`) resolve to an instance of `FluentType`.  The caller should\n * use the `toString` method to convert the instance to a native value.\n *\n *\n * All functions in this file pass around a special object called `env`.\n * This object stores a set of elements used by all resolve functions:\n *\n *  * {MessageContext} ctx\n *      context for which the given resolution is happening\n *  * {Object} args\n *      list of developer provided arguments that can be used\n *  * {Array} errors\n *      list of errors collected while resolving\n *  * {WeakSet} dirty\n *      Set of patterns already encountered during this resolution.\n *      This is used to prevent cyclic resolutions.\n */\n\n\nimport { FluentType, FluentNone, FluentNumber, FluentDateTime, FluentSymbol }\n  from \"./types\";\nimport builtins from \"./builtins\";\n\n// Prevent expansion of too long placeables.\nconst MAX_PLACEABLE_LENGTH = 2500;\n\n// Unicode bidi isolation characters.\nconst FSI = \"\\u2068\";\nconst PDI = \"\\u2069\";\n\n\n/**\n * Helper for choosing the default value from a set of members.\n *\n * Used in SelectExpressions and Type.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} members\n *    Hash map of variants from which the default value is to be selected.\n * @param   {Number} def\n *    The index of the default variant.\n * @returns {FluentType}\n * @private\n */\nfunction DefaultMember(env, members, def) {\n  if (members[def]) {\n    return members[def];\n  }\n\n  const { errors } = env;\n  errors.push(new RangeError(\"No default\"));\n  return new FluentNone();\n}\n\n\n/**\n * Resolve a reference to another message.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} id\n *    The identifier of the message to be resolved.\n * @param   {String} id.name\n *    The name of the identifier.\n * @returns {FluentType}\n * @private\n */\nfunction MessageReference(env, {name}) {\n  const { ctx, errors } = env;\n  const message = name.startsWith(\"-\")\n    ? ctx._terms.get(name)\n    : ctx._messages.get(name);\n\n  if (!message) {\n    const err = name.startsWith(\"-\")\n      ? new ReferenceError(`Unknown term: ${name}`)\n      : new ReferenceError(`Unknown message: ${name}`);\n    errors.push(err);\n    return new FluentNone(name);\n  }\n\n  return message;\n}\n\n/**\n * Resolve a variant expression to the variant object.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {Object} expr.id\n *    An Identifier of a message for which the variant is resolved.\n * @param   {Object} expr.id.name\n *    Name a message for which the variant is resolved.\n * @param   {Object} expr.key\n *    Variant key to be resolved.\n * @returns {FluentType}\n * @private\n */\nfunction VariantExpression(env, {id, key}) {\n  const message = MessageReference(env, id);\n  if (message instanceof FluentNone) {\n    return message;\n  }\n\n  const { ctx, errors } = env;\n  const keyword = Type(env, key);\n\n  function isVariantList(node) {\n    return Array.isArray(node) &&\n      node[0].type === \"sel\" &&\n      node[0].exp === null;\n  }\n\n  if (isVariantList(message.val)) {\n    // Match the specified key against keys of each variant, in order.\n    for (const variant of message.val[0].vars) {\n      const variantKey = Type(env, variant.key);\n      if (keyword.match(ctx, variantKey)) {\n        return variant;\n      }\n    }\n  }\n\n  errors.push(new ReferenceError(`Unknown variant: ${keyword.toString(ctx)}`));\n  return Type(env, message);\n}\n\n\n/**\n * Resolve an attribute expression to the attribute object.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.id\n *    An ID of a message for which the attribute is resolved.\n * @param   {String} expr.name\n *    Name of the attribute to be resolved.\n * @returns {FluentType}\n * @private\n */\nfunction AttributeExpression(env, {id, name}) {\n  const message = MessageReference(env, id);\n  if (message instanceof FluentNone) {\n    return message;\n  }\n\n  if (message.attrs) {\n    // Match the specified name against keys of each attribute.\n    for (const attrName in message.attrs) {\n      if (name === attrName) {\n        return message.attrs[name];\n      }\n    }\n  }\n\n  const { errors } = env;\n  errors.push(new ReferenceError(`Unknown attribute: ${name}`));\n  return Type(env, message);\n}\n\n/**\n * Resolve a select expression to the member object.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.exp\n *    Selector expression\n * @param   {Array} expr.vars\n *    List of variants for the select expression.\n * @param   {Number} expr.def\n *    Index of the default variant.\n * @returns {FluentType}\n * @private\n */\nfunction SelectExpression(env, {exp, vars, def}) {\n  if (exp === null) {\n    return DefaultMember(env, vars, def);\n  }\n\n  const selector = Type(env, exp);\n  if (selector instanceof FluentNone) {\n    return DefaultMember(env, vars, def);\n  }\n\n  // Match the selector against keys of each variant, in order.\n  for (const variant of vars) {\n    const key = Type(env, variant.key);\n    const keyCanMatch =\n      key instanceof FluentNumber || key instanceof FluentSymbol;\n\n    if (!keyCanMatch) {\n      continue;\n    }\n\n    const { ctx } = env;\n\n    if (key.match(ctx, selector)) {\n      return variant;\n    }\n  }\n\n  return DefaultMember(env, vars, def);\n}\n\n\n/**\n * Resolve expression to a Fluent type.\n *\n * JavaScript strings are a special case.  Since they natively have the\n * `toString` method they can be used as if they were a Fluent type without\n * paying the cost of creating a instance of one.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression object to be resolved into a Fluent type.\n * @returns {FluentType}\n * @private\n */\nfunction Type(env, expr) {\n  // A fast-path for strings which are the most common case, and for\n  // `FluentNone` which doesn't require any additional logic.\n  if (typeof expr === \"string\" || expr instanceof FluentNone) {\n    return expr;\n  }\n\n  // The Runtime AST (Entries) encodes patterns (complex strings with\n  // placeables) as Arrays.\n  if (Array.isArray(expr)) {\n    return Pattern(env, expr);\n  }\n\n\n  switch (expr.type) {\n    case \"varname\":\n      return new FluentSymbol(expr.name);\n    case \"num\":\n      return new FluentNumber(expr.val);\n    case \"ext\":\n      return ExternalArgument(env, expr);\n    case \"fun\":\n      return FunctionReference(env, expr);\n    case \"call\":\n      return CallExpression(env, expr);\n    case \"ref\": {\n      const message = MessageReference(env, expr);\n      return Type(env, message);\n    }\n    case \"attr\": {\n      const attr = AttributeExpression(env, expr);\n      return Type(env, attr);\n    }\n    case \"var\": {\n      const variant = VariantExpression(env, expr);\n      return Type(env, variant);\n    }\n    case \"sel\": {\n      const member = SelectExpression(env, expr);\n      return Type(env, member);\n    }\n    case undefined: {\n      // If it's a node with a value, resolve the value.\n      if (expr.val !== null && expr.val !== undefined) {\n        return Type(env, expr.val);\n      }\n\n      const { errors } = env;\n      errors.push(new RangeError(\"No value\"));\n      return new FluentNone();\n    }\n    default:\n      return new FluentNone();\n  }\n}\n\n/**\n * Resolve a reference to an external argument.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.name\n *    Name of an argument to be returned.\n * @returns {FluentType}\n * @private\n */\nfunction ExternalArgument(env, {name}) {\n  const { args, errors } = env;\n\n  if (!args || !args.hasOwnProperty(name)) {\n    errors.push(new ReferenceError(`Unknown external: ${name}`));\n    return new FluentNone(name);\n  }\n\n  const arg = args[name];\n\n  // Return early if the argument already is an instance of FluentType.\n  if (arg instanceof FluentType) {\n    return arg;\n  }\n\n  // Convert the argument to a Fluent type.\n  switch (typeof arg) {\n    case \"string\":\n      return arg;\n    case \"number\":\n      return new FluentNumber(arg);\n    case \"object\":\n      if (arg instanceof Date) {\n        return new FluentDateTime(arg);\n      }\n    default:\n      errors.push(\n        new TypeError(`Unsupported external type: ${name}, ${typeof arg}`)\n      );\n      return new FluentNone(name);\n  }\n}\n\n/**\n * Resolve a reference to a function.\n *\n * @param   {Object}  env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {String} expr.name\n *    Name of the function to be returned.\n * @returns {Function}\n * @private\n */\nfunction FunctionReference(env, {name}) {\n  // Some functions are built-in.  Others may be provided by the runtime via\n  // the `MessageContext` constructor.\n  const { ctx: { _functions }, errors } = env;\n  const func = _functions[name] || builtins[name];\n\n  if (!func) {\n    errors.push(new ReferenceError(`Unknown function: ${name}()`));\n    return new FluentNone(`${name}()`);\n  }\n\n  if (typeof func !== \"function\") {\n    errors.push(new TypeError(`Function ${name}() is not callable`));\n    return new FluentNone(`${name}()`);\n  }\n\n  return func;\n}\n\n/**\n * Resolve a call to a Function with positional and key-value arguments.\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Object} expr\n *    An expression to be resolved.\n * @param   {Object} expr.fun\n *    FTL Function object.\n * @param   {Array} expr.args\n *    FTL Function argument list.\n * @returns {FluentType}\n * @private\n */\nfunction CallExpression(env, {fun, args}) {\n  const callee = FunctionReference(env, fun);\n\n  if (callee instanceof FluentNone) {\n    return callee;\n  }\n\n  const posargs = [];\n  const keyargs = {};\n\n  for (const arg of args) {\n    if (arg.type === \"narg\") {\n      keyargs[arg.name] = Type(env, arg.val);\n    } else {\n      posargs.push(Type(env, arg));\n    }\n  }\n\n  try {\n    return callee(posargs, keyargs);\n  } catch (e) {\n    // XXX Report errors.\n    return new FluentNone();\n  }\n}\n\n/**\n * Resolve a pattern (a complex string with placeables).\n *\n * @param   {Object} env\n *    Resolver environment object.\n * @param   {Array} ptn\n *    Array of pattern elements.\n * @returns {Array}\n * @private\n */\nfunction Pattern(env, ptn) {\n  const { ctx, dirty, errors } = env;\n\n  if (dirty.has(ptn)) {\n    errors.push(new RangeError(\"Cyclic reference\"));\n    return new FluentNone();\n  }\n\n  // Tag the pattern as dirty for the purpose of the current resolution.\n  dirty.add(ptn);\n  const result = [];\n\n  // Wrap interpolations with Directional Isolate Formatting characters\n  // only when the pattern has more than one element.\n  const useIsolating = ctx._useIsolating && ptn.length > 1;\n\n  for (const elem of ptn) {\n    if (typeof elem === \"string\") {\n      result.push(elem);\n      continue;\n    }\n\n    const part = Type(env, elem).toString(ctx);\n\n    if (useIsolating) {\n      result.push(FSI);\n    }\n\n    if (part.length > MAX_PLACEABLE_LENGTH) {\n      errors.push(\n        new RangeError(\n          \"Too many characters in placeable \" +\n          `(${part.length}, max allowed is ${MAX_PLACEABLE_LENGTH})`\n        )\n      );\n      result.push(part.slice(MAX_PLACEABLE_LENGTH));\n    } else {\n      result.push(part);\n    }\n\n    if (useIsolating) {\n      result.push(PDI);\n    }\n  }\n\n  dirty.delete(ptn);\n  return result.join(\"\");\n}\n\n/**\n * Format a translation into a string.\n *\n * @param   {MessageContext} ctx\n *    A MessageContext instance which will be used to resolve the\n *    contextual information of the message.\n * @param   {Object}         args\n *    List of arguments provided by the developer which can be accessed\n *    from the message.\n * @param   {Object}         message\n *    An object with the Message to be resolved.\n * @param   {Array}          errors\n *    An error array that any encountered errors will be appended to.\n * @returns {FluentType}\n */\nexport default function resolve(ctx, args, message, errors = []) {\n  const env = {\n    ctx, args, errors, dirty: new WeakSet()\n  };\n  return Type(env, message).toString(ctx);\n}\n","import resolve from \"./resolver\";\nimport parse from \"./parser\";\n\n/**\n * Message contexts are single-language stores of translations.  They are\n * responsible for parsing translation resources in the Fluent syntax and can\n * format translation units (entities) to strings.\n *\n * Always use `MessageContext.format` to retrieve translation units from\n * a context.  Translations can contain references to other entities or\n * external arguments, conditional logic in form of select expressions, traits\n * which describe their grammatical features, and can use Fluent builtins which\n * make use of the `Intl` formatters to format numbers, dates, lists and more\n * into the context's language.  See the documentation of the Fluent syntax for\n * more information.\n */\nexport class MessageContext {\n\n  /**\n   * Create an instance of `MessageContext`.\n   *\n   * The `locales` argument is used to instantiate `Intl` formatters used by\n   * translations.  The `options` object can be used to configure the context.\n   *\n   * Examples:\n   *\n   *     const ctx = new MessageContext(locales);\n   *\n   *     const ctx = new MessageContext(locales, { useIsolating: false });\n   *\n   *     const ctx = new MessageContext(locales, {\n   *       useIsolating: true,\n   *       functions: {\n   *         NODE_ENV: () => process.env.NODE_ENV\n   *       }\n   *     });\n   *\n   * Available options:\n   *\n   *   - `functions` - an object of additional functions available to\n   *                   translations as builtins.\n   *\n   *   - `useIsolating` - boolean specifying whether to use Unicode isolation\n   *                    marks (FSI, PDI) for bidi interpolations.\n   *\n   * @param   {string|Array<string>} locales - Locale or locales of the context\n   * @param   {Object} [options]\n   * @returns {MessageContext}\n   */\n  constructor(locales, { functions = {}, useIsolating = true } = {}) {\n    this.locales = Array.isArray(locales) ? locales : [locales];\n\n    this._terms = new Map();\n    this._messages = new Map();\n    this._functions = functions;\n    this._useIsolating = useIsolating;\n    this._intls = new WeakMap();\n  }\n\n  /*\n   * Return an iterator over public `[id, message]` pairs.\n   *\n   * @returns {Iterator}\n   */\n  get messages() {\n    return this._messages[Symbol.iterator]();\n  }\n\n  /*\n   * Check if a message is present in the context.\n   *\n   * @param {string} id - The identifier of the message to check.\n   * @returns {bool}\n   */\n  hasMessage(id) {\n    return this._messages.has(id);\n  }\n\n  /*\n   * Return the internal representation of a message.\n   *\n   * The internal representation should only be used as an argument to\n   * `MessageContext.format`.\n   *\n   * @param {string} id - The identifier of the message to check.\n   * @returns {Any}\n   */\n  getMessage(id) {\n    return this._messages.get(id);\n  }\n\n  /**\n   * Add a translation resource to the context.\n   *\n   * The translation resource must use the Fluent syntax.  It will be parsed by\n   * the context and each translation unit (message) will be available in the\n   * context by its identifier.\n   *\n   *     ctx.addMessages('foo = Foo');\n   *     ctx.getMessage('foo');\n   *\n   *     // Returns a raw representation of the 'foo' message.\n   *\n   * Parsed entities should be formatted with the `format` method in case they\n   * contain logic (references, select expressions etc.).\n   *\n   * @param   {string} source - Text resource with translations.\n   * @returns {Array<Error>}\n   */\n  addMessages(source) {\n    const [entries, errors] = parse(source);\n    for (const id in entries) {\n      if (id.startsWith(\"-\")) {\n        // Identifiers starting with a dash (-) define terms. Terms are private\n        // and cannot be retrieved from MessageContext.\n        if (this._terms.has(id)) {\n          errors.push(`Attempt to override an existing term: \"${id}\"`);\n          continue;\n        }\n        this._terms.set(id, entries[id]);\n      } else {\n        if (this._messages.has(id)) {\n          errors.push(`Attempt to override an existing message: \"${id}\"`);\n          continue;\n        }\n        this._messages.set(id, entries[id]);\n      }\n    }\n\n    return errors;\n  }\n\n  /**\n   * Format a message to a string or null.\n   *\n   * Format a raw `message` from the context into a string (or a null if it has\n   * a null value).  `args` will be used to resolve references to external\n   * arguments inside of the translation.\n   *\n   * In case of errors `format` will try to salvage as much of the translation\n   * as possible and will still return a string.  For performance reasons, the\n   * encountered errors are not returned but instead are appended to the\n   * `errors` array passed as the third argument.\n   *\n   *     const errors = [];\n   *     ctx.addMessages('hello = Hello, { $name }!');\n   *     const hello = ctx.getMessage('hello');\n   *     ctx.format(hello, { name: 'Jane' }, errors);\n   *\n   *     // Returns 'Hello, Jane!' and `errors` is empty.\n   *\n   *     ctx.format(hello, undefined, errors);\n   *\n   *     // Returns 'Hello, name!' and `errors` is now:\n   *\n   *     [<ReferenceError: Unknown external: name>]\n   *\n   * @param   {Object | string}    message\n   * @param   {Object | undefined} args\n   * @param   {Array}              errors\n   * @returns {?string}\n   */\n  format(message, args, errors) {\n    // optimize entities which are simple strings with no attributes\n    if (typeof message === \"string\") {\n      return message;\n    }\n\n    // optimize simple-string entities with attributes\n    if (typeof message.val === \"string\") {\n      return message.val;\n    }\n\n    // optimize entities with null values\n    if (message.val === undefined) {\n      return null;\n    }\n\n    return resolve(this, args, message, errors);\n  }\n\n  _memoizeIntlObject(ctor, opts) {\n    const cache = this._intls.get(ctor) || {};\n    const id = JSON.stringify(opts);\n\n    if (!cache[id]) {\n      cache[id] = new ctor(this.locales, opts);\n      this._intls.set(ctor, cache);\n    }\n\n    return cache[id];\n  }\n}\n","/*\n * CachedIterable caches the elements yielded by an iterable.\n *\n * It can be used to iterate over an iterable many times without depleting the\n * iterable.\n */\nexport default class CachedIterable {\n  /**\n   * Create an `CachedIterable` instance.\n   *\n   * @param {Iterable} iterable\n   * @returns {CachedIterable}\n   */\n  constructor(iterable) {\n    if (Symbol.asyncIterator in Object(iterable)) {\n      this.iterator = iterable[Symbol.asyncIterator]();\n    } else if (Symbol.iterator in Object(iterable)) {\n      this.iterator = iterable[Symbol.iterator]();\n    } else {\n      throw new TypeError(\"Argument must implement the iteration protocol.\");\n    }\n\n    this.seen = [];\n  }\n\n  [Symbol.iterator]() {\n    const { seen, iterator } = this;\n    let cur = 0;\n\n    return {\n      next() {\n        if (seen.length <= cur) {\n          seen.push(iterator.next());\n        }\n        return seen[cur++];\n      }\n    };\n  }\n\n  [Symbol.asyncIterator]() {\n    const { seen, iterator } = this;\n    let cur = 0;\n\n    return {\n      async next() {\n        if (seen.length <= cur) {\n          seen.push(await iterator.next());\n        }\n        return seen[cur++];\n      }\n    };\n  }\n\n  /**\n   * This method allows user to consume the next element from the iterator\n   * into the cache.\n   */\n  touchNext() {\n    const { seen, iterator } = this;\n    if (seen.length === 0 || seen[seen.length - 1].done === false) {\n      seen.push(iterator.next());\n    }\n  }\n}\n","/*\n * @overview\n *\n * Functions for managing ordered sequences of MessageContexts.\n *\n * An ordered iterable of MessageContext instances can represent the current\n * negotiated fallback chain of languages.  This iterable can be used to find\n * the best existing translation for a given identifier.\n *\n * The mapContext* methods can be used to find the first MessageContext in the\n * given iterable which contains the translation with the given identifier.  If\n * the iterable is ordered according to the result of a language negotiation\n * the returned MessageContext contains the best available translation.\n *\n * A simple function which formats translations based on the identifier might\n * be implemented as follows:\n *\n *     formatString(id, args) {\n *         const ctx = mapContextSync(contexts, id);\n *\n *         if (ctx === null) {\n *             return id;\n *         }\n *\n *         const msg = ctx.getMessage(id);\n *         return ctx.format(msg, args);\n *     }\n *\n * In order to pass an iterator to mapContext*, wrap it in CachedIterable.\n * This allows multiple calls to mapContext* without advancing and eventually\n * depleting the iterator.\n *\n *     function *generateMessages() {\n *         // Some lazy logic for yielding MessageContexts.\n *         yield *[ctx1, ctx2];\n *     }\n *\n *     const contexts = new CachedIterable(generateMessages());\n *     const ctx = mapContextSync(contexts, id);\n *\n */\n\n/*\n * Synchronously map an identifier or an array of identifiers to the best\n * `MessageContext` instance(s).\n *\n * @param {Iterable} iterable\n * @param {string|Array<string>} ids\n * @returns {MessageContext|Array<MessageContext>}\n */\nexport function mapContextSync(iterable, ids) {\n  if (!Array.isArray(ids)) {\n    return getContextForId(iterable, ids);\n  }\n\n  return ids.map(\n    id => getContextForId(iterable, id)\n  );\n}\n\n/*\n * Find the best `MessageContext` with the translation for `id`.\n */\nfunction getContextForId(iterable, id) {\n  for (const context of iterable) {\n    if (context.hasMessage(id)) {\n      return context;\n    }\n  }\n\n  return null;\n}\n\n/*\n * Asynchronously map an identifier or an array of identifiers to the best\n * `MessageContext` instance(s).\n *\n * @param {AsyncIterable} iterable\n * @param {string|Array<string>} ids\n * @returns {Promise<MessageContext|Array<MessageContext>>}\n */\nexport async function mapContextAsync(iterable, ids) {\n  if (!Array.isArray(ids)) {\n    for await (const context of iterable) {\n      if (context.hasMessage(ids)) {\n        return context;\n      }\n    }\n  }\n\n  let remainingCount = ids.length;\n  const foundContexts = new Array(remainingCount).fill(null);\n\n  for await (const context of iterable) {\n    // XXX Switch to const [index, id] of id.entries() when we move to Babel 7.\n    // See https://github.com/babel/babel/issues/5880.\n    for (let index = 0; index < ids.length; index++) {\n      const id = ids[index];\n      if (!foundContexts[index] && context.hasMessage(id)) {\n        foundContexts[index] = context;\n        remainingCount--;\n      }\n\n      // Return early when all ids have been mapped to contexts.\n      if (remainingCount === 0) {\n        return foundContexts;\n      }\n    }\n  }\n\n  return foundContexts;\n}\n","function nonBlank(line) {\n  return !/^\\s*$/.test(line);\n}\n\nfunction countIndent(line) {\n  const [indent] = line.match(/^\\s*/);\n  return indent.length;\n}\n\n/**\n * Template literal tag for dedenting FTL code.\n *\n * Strip the common indent of non-blank lines. Remove blank lines.\n *\n * @param {Array<string>} strings\n */\nexport function ftl(strings) {\n  const [code] = strings;\n  const lines = code.split(\"\\n\").filter(nonBlank);\n  const indents = lines.map(countIndent);\n  const common = Math.min(...indents);\n  const indent = new RegExp(`^\\\\s{${common}}`);\n\n  return lines.map(\n    line => line.replace(indent, \"\")\n  ).join(\"\\n\");\n}\n","/*\n * @module fluent\n * @overview\n *\n * `fluent` is a JavaScript implementation of Project Fluent, a localization\n * framework designed to unleash the expressive power of the natural language.\n *\n */\n\nexport { default as _parse } from \"./parser\";\n\nexport { MessageContext } from \"./context\";\nexport {\n  FluentType as MessageArgument,\n  FluentNumber as MessageNumberArgument,\n  FluentDateTime as MessageDateTimeArgument,\n} from \"./types\";\n\nexport { default as CachedIterable } from \"./cached_iterable\";\nexport { mapContextSync, mapContextAsync } from \"./fallback\";\n\nexport { ftl } from \"./util\";\n","import { CachedIterable, mapContextSync } from \"fluent\";\n\n/*\n * `ReactLocalization` handles translation formatting and fallback.\n *\n * The current negotiated fallback chain of languages is stored in the\n * `ReactLocalization` instance in form of an iterable of `MessageContext`\n * instances.  This iterable is used to find the best existing translation for\n * a given identifier.\n *\n * `Localized` components must subscribe to the changes of the\n * `ReactLocalization`'s fallback chain.  When the fallback chain changes (the\n * `messages` iterable is set anew), all subscribed compontent must relocalize.\n *\n * The `ReactLocalization` class instances are exposed to `Localized` elements\n * via the `LocalizationProvider` component.\n */\nexport default class ReactLocalization {\n  constructor(messages) {\n    this.contexts = new CachedIterable(messages);\n    this.subs = new Set();\n  }\n\n  /*\n   * Subscribe a `Localized` component to changes of `messages`.\n   */\n  subscribe(comp) {\n    this.subs.add(comp);\n  }\n\n  /*\n   * Unsubscribe a `Localized` component from `messages` changes.\n   */\n  unsubscribe(comp) {\n    this.subs.delete(comp);\n  }\n\n  /*\n   * Set a new `messages` iterable and trigger the retranslation.\n   */\n  setMessages(messages) {\n    this.contexts = new CachedIterable(messages);\n\n    // Update all subscribed Localized components.\n    this.subs.forEach(comp => comp.relocalize());\n  }\n\n  getMessageContext(id) {\n    return mapContextSync(this.contexts, id);\n  }\n\n  formatCompound(mcx, msg, args) {\n    const value = mcx.format(msg, args);\n\n    if (msg.attrs) {\n      var attrs = {};\n      for (const name of Object.keys(msg.attrs)) {\n        attrs[name] = mcx.format(msg.attrs[name], args);\n      }\n    }\n\n    return { value, attrs };\n  }\n\n  /*\n   * Find a translation by `id` and format it to a string using `args`.\n   */\n  getString(id, args, fallback) {\n    const mcx = this.getMessageContext(id);\n\n    if (mcx === null) {\n      return fallback || id;\n    }\n\n    const msg = mcx.getMessage(id);\n    return mcx.format(msg, args);\n  }\n}\n\nexport function isReactLocalization(props, propName) {\n  const prop = props[propName];\n\n  if (prop instanceof ReactLocalization) {\n    return null;\n  }\n\n  return new Error(\n    `The ${propName} context field must be an instance of ReactLocalization.`\n  );\n}\n","import { Component, Children } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport ReactLocalization, { isReactLocalization} from \"./localization\";\n\n/*\n * The Provider component for the `ReactLocalization` class.\n *\n * Exposes a `ReactLocalization` instance to all descendants via React's\n * context feature.  It makes translations available to all localizable\n * elements in the descendant's render tree without the need to pass them\n * explicitly.\n *\n *     <LocalizationProvider messages={…}>\n *         …\n *     </LocalizationProvider>\n *\n * The `LocalizationProvider` component takes one prop: `messages`.  It should\n * be an iterable of `MessageContext` instances in order of the user's\n * preferred languages.  The `MessageContext` instances will be used by\n * `ReactLocalization` to format translations.  If a translation is missing in\n * one instance, `ReactLocalization` will fall back to the next one.\n */\nexport default class LocalizationProvider extends Component {\n  constructor(props) {\n    super(props);\n    const { messages } = props;\n\n