module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = require('../../../ssr-module-cache.js');
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		var threw = true;
/******/ 		try {
/******/ 			modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 			threw = false;
/******/ 		} finally {
/******/ 			if(threw) delete installedModules[moduleId];
/******/ 		}
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ({

/***/ "/0+H":
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _Object$defineProperty = __webpack_require__("hfKm");

var __importDefault = this && this.__importDefault || function (mod) {
  return mod && mod.__esModule ? mod : {
    "default": mod
  };
};

_Object$defineProperty(exports, "__esModule", {
  value: true
});

const react_1 = __importDefault(__webpack_require__("cDcd"));

const amp_context_1 = __webpack_require__("lwAK");

function isInAmpMode({
  ampFirst = false,
  hybrid = false,
  hasQuery = false
} = {}) {
  return ampFirst || hybrid && hasQuery;
}

exports.isInAmpMode = isInAmpMode;

function useAmp() {
  // Don't assign the context value to a variable to save bytes
  return isInAmpMode(react_1.default.useContext(amp_context_1.AmpStateContext));
}

exports.useAmp = useAmp;

/***/ }),

/***/ "/a9y":
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _interopRequireDefault = __webpack_require__("KI45");

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(__webpack_require__("cDcd"));

var _head = _interopRequireDefault(__webpack_require__("8Kt/"));

var statusCodes = {
  400: 'Bad Request',
  404: 'This page could not be found',
  405: 'Method Not Allowed',
  500: 'Internal Server Error'
};
/**
* `Error` component used for handling errors.
*/

class Error extends _react.default.Component {
  static getInitialProps(_ref) {
    var {
      res,
      err
    } = _ref;
    var statusCode = res && res.statusCode ? res.statusCode : err ? err.statusCode : 404;
    return {
      statusCode
    };
  }

  render() {
    var {
      statusCode
    } = this.props;
    var title = this.props.title || statusCodes[statusCode] || 'An unexpected error has occurred';
    return _react.default.createElement("div", {
      style: styles.error
    }, _react.default.createElement(_head.default, null, _react.default.createElement("title", null, statusCode, ": ", title)), _react.default.createElement("div", null, _react.default.createElement("style", {
      dangerouslySetInnerHTML: {
        __html: 'body { margin: 0 }'
      }
    }), statusCode ? _react.default.createElement("h1", {
      style: styles.h1
    }, statusCode) : null, _react.default.createElement("div", {
      style: styles.desc
    }, _react.default.createElement("h2", {
      style: styles.h2
    }, title, "."))));
  }

}

exports.default = Error;
Error.displayName = 'ErrorPage';
var styles = {
  error: {
    color: '#000',
    background: '#fff',
    fontFamily: '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif',
    height: '100vh',
    textAlign: 'center',
    display: 'flex',
    flexDirection: 'column',
    alignItems: 'center',
    justifyContent: 'center'
  },
  desc: {
    display: 'inline-block',
    textAlign: 'left',
    lineHeight: '49px',
    height: '49px',
    verticalAlign: 'middle'
  },
  h1: {
    display: 'inline-block',
    borderRight: '1px solid rgba(0, 0, 0,.3)',
    margin: 0,
    marginRight: '20px',
    padding: '10px 23px 10px 0',
    fontSize: '24px',
    fontWeight: 500,
    verticalAlign: 'top'
  },
  h2: {
    fontSize: '14px',
    fontWeight: 'normal',
    lineHeight: 'inherit',
    margin: 0,
    padding: 0
  }
};

/***/ }),

/***/ "/xJA":
/***/ (function(module, exports) {

module.exports = require("markdown-it-footnote");

/***/ }),

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__("TrX6");


/***/ }),

/***/ "2xWL":
/***/ (function(module, exports) {

module.exports = require("markdown-it-anchor");

/***/ }),

/***/ "5JtJ":
/***/ (function(module, exports) {



/***/ }),

/***/ "8Kt/":
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _Set = __webpack_require__("ttDY");

var _Object$defineProperty = __webpack_require__("hfKm");

var __importDefault = this && this.__importDefault || function (mod) {
  return mod && mod.__esModule ? mod : {
    "default": mod
  };
};

_Object$defineProperty(exports, "__esModule", {
  value: true
});

const react_1 = __importDefault(__webpack_require__("cDcd"));

const side_effect_1 = __importDefault(__webpack_require__("Xuae"));

const amp_context_1 = __webpack_require__("lwAK");

const head_manager_context_1 = __webpack_require__("FYa8");

const amp_1 = __webpack_require__("/0+H");

function defaultHead(inAmpMode = false) {
  const head = [react_1.default.createElement("meta", {
    key: "charSet",
    charSet: "utf-8"
  })];

  if (!inAmpMode) {
    head.push(react_1.default.createElement("meta", {
      key: "viewport",
      name: "viewport",
      content: "width=device-width,minimum-scale=1,initial-scale=1"
    }));
  }

  return head;
}

exports.defaultHead = defaultHead;

function onlyReactElement(list, child) {
  // React children can be "string" or "number" in this case we ignore them for backwards compat
  if (typeof child === 'string' || typeof child === 'number') {
    return list;
  } // Adds support for React.Fragment


  if (child.type === react_1.default.Fragment) {
    return list.concat(react_1.default.Children.toArray(child.props.children).reduce((fragmentList, fragmentChild) => {
      if (typeof fragmentChild === 'string' || typeof fragmentChild === 'number') {
        return fragmentList;
      }

      return fragmentList.concat(fragmentChild);
    }, []));
  }

  return list.concat(child);
}

const METATYPES = ['name', 'httpEquiv', 'charSet', 'itemProp'];
/*
 returns a function for filtering head child elements
 which shouldn't be duplicated, like <title/>
 Also adds support for deduplicated `key` properties
*/

function unique() {
  const keys = new _Set();
  const tags = new _Set();
  const metaTypes = new _Set();
  const metaCategories = {};
  return h => {
    if (h.key && typeof h.key !== 'number' && h.key.indexOf('.$') === 0) {
      if (keys.has(h.key)) return false;
      keys.add(h.key);
      return true;
    } // If custom meta tag has been added the key will be prepended with `.$`, we can
    // check for this and dedupe in favor of the custom one, so the default
    // is not rendered as well


    if (keys.has(`.$${h.key}`)) return false; // eslint-disable-next-line default-case

    switch (h.type) {
      case 'title':
      case 'base':
        if (tags.has(h.type)) return false;
        tags.add(h.type);
        break;

      case 'meta':
        for (let i = 0, len = METATYPES.length; i < len; i++) {
          const metatype = METATYPES[i];
          if (!h.props.hasOwnProperty(metatype)) continue;

          if (metatype === 'charSet') {
            if (metaTypes.has(metatype)) return false;
            metaTypes.add(metatype);
          } else {
            const category = h.props[metatype];
            const categories = metaCategories[metatype] || new _Set();
            if (categories.has(category)) return false;
            categories.add(category);
            metaCategories[metatype] = categories;
          }
        }

        break;
    }

    return true;
  };
}
/**
 *
 * @param headElement List of multiple <Head> instances
 */


function reduceComponents(headElements, props) {
  return headElements.reduce((list, headElement) => {
    const headElementChildren = react_1.default.Children.toArray(headElement.props.children);
    return list.concat(headElementChildren);
  }, []).reduce(onlyReactElement, []).reverse().concat(defaultHead(props.inAmpMode)).filter(unique()).reverse().map((c, i) => {
    const key = c.key || i;
    return react_1.default.cloneElement(c, {
      key
    });
  });
}

const Effect = side_effect_1.default();
/**
 * This component injects elements to `<head>` of your page.
 * To avoid duplicated `tags` in `<head>` you can use the `key` property, which will make sure every tag is only rendered once.
 */

function Head({
  children
}) {
  return react_1.default.createElement(amp_context_1.AmpStateContext.Consumer, null, ampState => react_1.default.createElement(head_manager_context_1.HeadManagerContext.Consumer, null, updateHead => react_1.default.createElement(Effect, {
    reduceComponentsToState: reduceComponents,
    handleStateChange: updateHead,
    inAmpMode: amp_1.isInAmpMode(ampState)
  }, children)));
}

Head.rewind = Effect.rewind;
exports.default = Head;

/***/ }),

/***/ "FYa8":
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _Object$defineProperty = __webpack_require__("hfKm");

var __importStar = this && this.__importStar || function (mod) {
  if (mod && mod.__esModule) return mod;
  var result = {};
  if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  result["default"] = mod;
  return result;
};

_Object$defineProperty(exports, "__esModule", {
  value: true
});

const React = __importStar(__webpack_require__("cDcd"));

exports.HeadManagerContext = React.createContext(null);

/***/ }),

/***/ "KI45":
/***/ (function(module, exports) {

function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : {
    "default": obj
  };
}

module.exports = _interopRequireDefault;

/***/ }),

/***/ "KNus":
/***/ (function(module, exports) {

module.exports = require("next/config");

/***/ }),

/***/ "LG7s":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";

// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs2/helpers/esm/defineProperty.js
var defineProperty = __webpack_require__("vYYK");

// EXTERNAL MODULE: external "react"
var external_react_ = __webpack_require__("cDcd");
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);

// EXTERNAL MODULE: external "next/head"
var head_ = __webpack_require__("xnum");
var head_default = /*#__PURE__*/__webpack_require__.n(head_);

// EXTERNAL MODULE: ./utils/index.ts + 1 modules
var utils = __webpack_require__("cBaE");

// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs2/core-js/array/from.js
var from = __webpack_require__("d04V");
var from_default = /*#__PURE__*/__webpack_require__.n(from);

// EXTERNAL MODULE: ./components/extensions/collapsible/collapsible.scss
var collapsible = __webpack_require__("R/v/");

// CONCATENATED MODULE: ./components/extensions/collapsible/collapsible.ts


function initCollapsibles(element) {
  element.addEventListener('click', event => {
    const target = event.target;

    if (target && from_default()(target.classList).includes('collapsible__open')) {
      target.parentElement.classList.add('collapsible_opened');
    }

    if (target && from_default()(target.classList).includes('collapsible__close')) {
      target.parentElement.classList.remove('collapsible_opened');
    }
  });
}
// EXTERNAL MODULE: ./components/extensions/tabs/tabs.scss
var tabs = __webpack_require__("5JtJ");

// CONCATENATED MODULE: ./components/extensions/tabs/tabs.ts



function createElementFromHTML(input) {
  var template = document.createElement('template');
  template.innerHTML = input.trim();
  return template.content.firstChild;
}

function generateId() {
  return Math.random().toString(36).substring(2);
}

function prepareTabsElements(rootElement) {
  from_default()(rootElement.querySelectorAll('.tabs')).forEach(element => {
    const idSequence = [];

    const getNextId = () => {
      const id = generateId();
      idSequence.push(id);
      return id;
    };

    const titleElements = from_default()(element.querySelectorAll('.tab__title'));

    const titles = titleElements.map(e => e.innerHTML);
    let titlesHtml = '<div class="tabs__titles">';

    for (let i = 0; i < titles.length; i++) {
      titlesHtml += `<div class="tabs__title${i === 0 ? ' tabs__title_active' : ''}" data-tab-id="${getNextId()}">${titles[i]}</div>`;
    }

    titlesHtml += '</div>';
    const titlesBlock = createElementFromHTML(titlesHtml);
    element.prepend(titlesBlock);
    titleElements.map(e => e.remove());

    from_default()(element.querySelectorAll('.tab')).forEach((tabElement, i) => {
      tabElement.dataset.tabContentId = idSequence[i];

      if (i === 0) {
        tabElement.classList.add('tab_active');
      }
    });
  });
}
function initTabs(element) {
  element.addEventListener('click', event => {
    const target = event.target;

    if (target && from_default()(target.classList).includes('tabs__title')) {
      const tabsRoot = target.parentElement.parentElement;
      const tabId = target.dataset.tabId;
      const oldActiveTab = tabsRoot.querySelector('.tabs__title_active');

      if (oldActiveTab) {
        const oldTabId = oldActiveTab.dataset.tabId;
        tabsRoot.querySelector(`.tabs__title[data-tab-id="${oldTabId}"]`).classList.remove('tabs__title_active');
        tabsRoot.querySelector(`.tab[data-tab-content-id="${oldTabId}"]`).classList.remove('tab_active');
      }

      target.classList.add('tabs__title_active');
      tabsRoot.querySelector(`.tab[data-tab-content-id="${tabId}"]`).classList.add('tab_active');
    }
  });
  prepareTabsElements(element);
}
// CONCATENATED MODULE: ./components/extensions/index.tsx


// EXTERNAL MODULE: ./components/App/App.scss
var App_App = __webpack_require__("V2f5");

// EXTERNAL MODULE: ./components/App/Header/Header.scss
var Header_Header = __webpack_require__("x7bt");

// CONCATENATED MODULE: ./components/App/Header/Header.tsx
var __jsx = external_react_default.a.createElement;


;
class Header_Header_Header extends external_react_default.a.Component {
  render() {
    return __jsx("header", {
      className: "header"
    }, __jsx("div", {
      className: "header__container"
    }, __jsx("div", {
      className: "header__top-content"
    }, __jsx("a", {
      href: "/"
    }, "SCP Foundation")), this.renderSignIn()), __jsx("div", {
      className: "header__navigation"
    }, this.renderNavigation()));
  }

  renderSignIn() {
    const {
      user
    } = this.props;

    if (user.id !== null) {
      return __jsx("div", {
        className: "header__top-content header__top-content_right"
      }, __jsx("a", {
        href: "/auth/logout"
      }, "Sign out"));
    }

    return __jsx("div", {
      className: "header__top-content header__top-content_right"
    }, __jsx("a", {
      href: `/auth/google?returnPath=${encodeURIComponent(window.location.pathname)}`
    }, "Sign in"));
  }

  renderNavigation() {
    return __jsx("div", {
      className: "header__navigation-content"
    }, __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/random",
      className: "header__random-page-link"
    }, "Random page")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/scp-list"
    }, "Series I")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/scp-list-2"
    }, "Series II")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/scp-list-3"
    }, "Series III")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/scp-list-4"
    }, "Series IV")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/scp-list-5"
    }, "Series V")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/scp-list-ru"
    }, "Series RU")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/stories"
    }, "Stories")), __jsx("span", {
      className: "header__navigation-element"
    }, __jsx("a", {
      href: "/canon-hub"
    }, "Canons")));
  }

}
;
// EXTERNAL MODULE: ./components/App/Footer/Footer.scss
var Footer = __webpack_require__("i0sC");

// CONCATENATED MODULE: ./components/App/Footer/Footer.tsx
var Footer_jsx = external_react_default.a.createElement;



const Footer_Footer = () => Footer_jsx("footer", {
  className: "footer"
}, "Unless otherwise stated, the content of this page is licensed under ", Footer_jsx("a", {
  href: "https://creativecommons.org/licenses/by-sa/3.0/",
  target: "_blank",
  rel: "noopener noreferrer"
}, "Creative Commons Attribution-ShareAlike 3.0 License"));

/* harmony default export */ var App_Footer_Footer = (Footer_Footer);
// CONCATENATED MODULE: ./components/App/App.tsx
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return App_App_App; });

var App_jsx = external_react_default.a.createElement;







class App_App_App extends external_react_default.a.Component {
  constructor(...args) {
    super(...args);

    Object(defineProperty["a" /* default */])(this, "state", {
      isLoaded: false
    });
  }

  componentDidMount() {
    initCollapsibles(document.body);
    initTabs(document.body);
    utils["a" /* sdk */].whoami().then(whoami => this.setState({
      whoami,
      isLoaded: true
    })).catch(() => this.setState({
      isLoaded: true
    }));
  }

  render() {
    const {
      children,
      pageName
    } = this.props;
    const user = this.state.whoami;
    const title = pageName ? `${pageName} - SCP Foundation` : 'SCP Foundation';

    if (!this.state.isLoaded) {
      return null;
    }

    return App_jsx(external_react_default.a.Fragment, null, App_jsx(head_default.a, null, App_jsx("title", null, title), App_jsx("meta", {
      name: "viewport",
      content: "initial-scale=1.0, width=device-width"
    })), App_jsx("div", {
      className: "app"
    }, App_jsx("div", {
      className: "app-header"
    }, App_jsx(Header_Header_Header, {
      user: user
    })), App_jsx("main", {
      className: "app-content"
    }, children, App_jsx("div", {
      className: "app-footer"
    }, App_jsx(App_Footer_Footer, null)))));
  }

}

/***/ }),

/***/ "R/v/":
/***/ (function(module, exports) {



/***/ }),

/***/ "TUA0":
/***/ (function(module, exports) {

module.exports = require("core-js/library/fn/object/define-property");

/***/ }),

/***/ "TVgv":
/***/ (function(module, exports) {

module.exports = require("markdown-it-sup");

/***/ }),

/***/ "TrX6":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);

// EXTERNAL MODULE: external "react"
var external_react_ = __webpack_require__("cDcd");
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);

// EXTERNAL MODULE: ./node_modules/next/error.js
var error = __webpack_require__("eomm");
var error_default = /*#__PURE__*/__webpack_require__.n(error);

// EXTERNAL MODULE: ./components/App/App.tsx + 5 modules
var App = __webpack_require__("LG7s");

// EXTERNAL MODULE: ./utils/index.ts + 1 modules
var utils = __webpack_require__("cBaE");

// EXTERNAL MODULE: ./components/Page/Page.scss
var Page = __webpack_require__("au+6");

// CONCATENATED MODULE: ./components/Page/Page.tsx
var __jsx = external_react_default.a.createElement;



const Page_Page = ({
  page
}) => {
  if (page) {
    return __jsx("div", {
      className: "page"
    }, __jsx("div", {
      className: "page__title"
    }, page.title, __jsx("div", {
      className: "page__rating"
    }, page.rating > 0 ? `+${page.rating}` : page.rating)), __jsx("div", {
      className: "page__content",
      dangerouslySetInnerHTML: {
        __html: page.html
      }
    }));
  } else {
    return __jsx("div", {
      className: "page"
    });
  }
};

/* harmony default export */ var components_Page_Page = (Page_Page);
// EXTERNAL MODULE: external "markdown-it"
var external_markdown_it_ = __webpack_require__("XUTK");
var external_markdown_it_default = /*#__PURE__*/__webpack_require__.n(external_markdown_it_);

// CONCATENATED MODULE: ./renderer/plugins/collapsible.ts
const CloseTypes = {
  top: 'top',
  bottom: 'bottom',
  both: 'both'
};
/* harmony default export */ var collapsible = (function (md) {
  md.core.ruler.push('collapsible', state => {
    const COLLAPSIBLE_OPEN_REGEX = /\[\[collapsible\s*(.*)\s*]]/;
    const COLLAPSIBLE_CLOSE_REGEX = /\[\[\/collapsible]]/;
    const COLLAPSIBLE_OPTION_HIDE = 'hide="';
    const COLLAPSIBLE_OPTION_SHOW = 'show="';
    let closeTexts = []; // for invested collapsible blocks

    let closeTypes = []; // for invested collapsible blocks

    const tokens = state.tokens;
    let i = 0;

    while (i < tokens.length) {
      const openToken = tokens[i];
      const token = tokens[i + 1];
      let matchOpen,
          closeType = CloseTypes.top;

      if (openToken.type === 'paragraph_open' && (matchOpen = token.content.match(COLLAPSIBLE_OPEN_REGEX))) {
        const collapsible = new state.Token('collapsible_open', 'div', 0);
        const collapsibleOptions = matchOpen[1].split(/" /); //Initial values

        collapsible.content = {
          openText: '',
          closeText: '',
          closeType: ''
        };
        collapsibleOptions.forEach(option => {
          if (option.endsWith('"')) {
            option = option.slice(0, -1);
          }

          if (option.startsWith(COLLAPSIBLE_OPTION_HIDE)) {
            collapsible.content.closeText = option.substr(COLLAPSIBLE_OPTION_HIDE.length);
          } else if (option.startsWith(COLLAPSIBLE_OPTION_SHOW)) {
            collapsible.content.openText = option.substr(COLLAPSIBLE_OPTION_SHOW.length);
          } else if (option.startsWith('hideLocation="both')) {
            closeType = CloseTypes.both;
          } else if (option.startsWith('hideLocation="bottom')) {
            closeType = CloseTypes.bottom;
          }
        });
        collapsible.content.closeType = closeType;
        closeTypes.push(closeType);
        closeTexts.push(collapsible.content.closeText);
        tokens.splice(i, 3, collapsible);
      }

      if (openToken.type === 'paragraph_open' && token.content.match(COLLAPSIBLE_CLOSE_REGEX)) {
        const collapsible = new state.Token('collapsible_close', 'div', 0);
        collapsible.content = {
          closeType: closeTypes.pop(),
          closeText: closeTexts.pop()
        };
        tokens.splice(i, 3, collapsible);
      }

      i++;
    }
  });
});
;
// CONCATENATED MODULE: ./renderer/plugins/tabs.ts
/* harmony default export */ var tabs = (function (md) {
  md.core.ruler.push('tabs', state => {
    const TABVIEW_OPEN_REGEX = /\[\[tabview]]/;
    const TABVIEW_CLOSE_REGEX = /\[\[\/tabview]]/;
    const TAB_OPEN_REGEX = /\[\[tab\stitle="(.*)"]]/;
    const TAB_OPEN_REGEX_2 = /\[\[tab\s(.*)]]/;
    const TAB_CLOSE_REGEX = /\[\[\/tab]]/;
    const tokens = state.tokens;
    let i = 0;

    while (i < tokens.length - 1) {
      const openToken = tokens[i];
      const token = tokens[i + 1];
      let match; // <Open>

      if (openToken.type === 'paragraph_open' && token.content.match(TABVIEW_OPEN_REGEX)) {
        const tabviewOpen = new state.Token('tabview_open', 'div', 0);
        tokens.splice(i, 3, tabviewOpen);
      }

      if (openToken.type === 'paragraph_open' && (match = token.content.match(TAB_OPEN_REGEX) || token.content.match(TAB_OPEN_REGEX_2))) {
        const tabOpen = new state.Token('tab_open', 'div', 0);
        tabOpen.content = match[1];
        tokens.splice(i, 3, tabOpen);
      } // <Close>


      if (openToken.type === 'paragraph_open' && token.content.match(TABVIEW_CLOSE_REGEX)) {
        const tabviewClose = new state.Token('tabview_close', 'div', 0);
        tokens.splice(i, 3, tabviewClose);
      }

      if (openToken.type === 'paragraph_open' && token.content.match(TAB_CLOSE_REGEX)) {
        const tabClose = new state.Token('tab_close', 'div', 0);
        tokens.splice(i, 3, tabClose);
      }

      i++;
    }
  });
});
;
// CONCATENATED MODULE: ./renderer/markdown.ts



const md = external_markdown_it_default()({
  breaks: true
}).use(__webpack_require__("t28V")).use(__webpack_require__("TVgv")).use(__webpack_require__("/xJA")).use(__webpack_require__("sdgC")).use(__webpack_require__("UxWH")).use(__webpack_require__("2xWL")).use(__webpack_require__("wqGw")).use(__webpack_require__("Wsky"), 'image-right').use(__webpack_require__("Wsky"), 'align-center').use(collapsible).use(tabs);
function renderMarkdown(meta, content) {
  md.renderer.rules.collapsible_close = (tokens, index) => {
    const content = tokens[index].content;
    return content.closeType === CloseTypes.top ? '</div></div>' : `</div><div class="collapsible__close">${content.closeText}</div></div>`;
  };

  md.renderer.rules.collapsible_open = (tokens, index) => {
    const content = tokens[index].content;
    const closeType = content.closeType;
    let collapsibleBlock = `<div class="collapsible"><div class="collapsible__open">${content.openText}</div>`;

    if (closeType === CloseTypes.top || closeType === CloseTypes.both) {
      collapsibleBlock += `<div class="collapsible__close">${content.closeText}</div>`;
    }

    return collapsibleBlock + '<div class="collapsible__content">';
  };

  md.renderer.rules.tabview_open = () => '<div class="tabs">';

  md.renderer.rules.tabview_close = () => '</div>';

  md.renderer.rules.tab_close = () => '</div></div>';

  md.renderer.rules.tab_open = (tokens, index) => {
    const title = tokens[index].content;
    return `<div class="tab"><div class="tab__title">${title}</div><div class="tab__content">`;
  };

  return md.render(content);
}
// CONCATENATED MODULE: ./renderer/plugins/table.ts
const SEPARATOR = '---|';

function getTableHead(cells) {
  // String after tableHead
  let headSeparator = '\n|' + SEPARATOR.repeat(cells.length + 1) + '\n';
  let head = '|',
      firstRow = '';

  if (cells[0].startsWith('~')) {
    cells.forEach(cell => {
      head += cell.replace(/~\s/, '') + '|';
    });
  } else {
    head = head.repeat(cells.length + 1);
    firstRow = cells.reduce((prevCells, cell) => prevCells += `${cell}|`, '|') + '\n';
  }

  return '\n' + head + headSeparator + firstRow;
}

function prepareTableRow(row, isFirst = false) {
  const cells = row.substring(2, row.lastIndexOf('||')).split('||');

  if (isFirst) {
    return getTableHead(cells);
  }

  return cells.reduce((prevCells, cell) => prevCells += `${cell}|`, '|') + '\n';
}

function isNextRowTable(row) {
  return row.startsWith('||');
}

/* harmony default export */ var table = (function (input) {
  const rows = input.split('\n');
  let preparedContent = '';
  let inTable = false;
  rows.forEach((row, index) => {
    if (inTable) {
      preparedContent += prepareTableRow(row);
      inTable = rows[index + 1] ? isNextRowTable(rows[index + 1]) : false;
    } else if (row.startsWith('||')) {
      preparedContent += prepareTableRow(row, true);
      inTable = rows[index + 1] ? isNextRowTable(rows[index + 1]) : false;
    } else {
      preparedContent += row + '\n';
    }
  });
  return preparedContent;
});
// CONCATENATED MODULE: ./renderer/preprocess.ts

const imgBlockRegex = /\[\[include component:image-block\s+name=(.+?)\s*\|\s*caption=(.*?)\]\]/sgi;
const imgRightRegex = /\[\[div class="rimg"]]\s*\[\[image\s+(.+?)\s+width="(\d+?)"\s?]]\s*\[\[span]](.+?)\[\[\/span]]\s*\[\[\/div]]/sgi;
const imgCenterRegex = /\[\[div class="cimg"]]\s*\[\[image\s+(.+?)\s+width="(\d+?)"\s?]]\s*\[\[span]](.+?)\[\[\/span]]\s*\[\[\/div]]/sgi;
const imgLeftRegex = /\[\[div class="limg"]]\s*\[\[image\s+(.+?)\s+width="(\d+?)"\s?]]\s*\[\[span]](.+?)\[\[\/span]]\s*\[\[\/div]]/sgi;
const imgLinkedRightRegex = /\[\[div class="rimg"]]\s*\[\[image\s+(.+?)\s+link=".+?"\s+width="(\d+?)"\s?]]\s*\[\[span]](.+?)\[\[\/span]]\s*\[\[\/div]]/gi;
function preprocess(meta, input) {
  const parsedInput = input // Vote blocks
  .replace(/\[\[>]]\n\[\[module\sRate]]\n\[\[\/>]]/gi, '') // CSS blocks
  .replace(/\[\[module\sCSS]](.*?)\[\[\/module]]/sgi, '').replace(/\[\[module\sCountPages.+?]](.*?)\[\[\/module]]/sgi, '') // Wiki links with title [[scp-173 | The Sculpture]]
  .replace(/\[\[\[(.+?)\s*\|(.+?)]]]/gi, '[$2](./$1)') // Wiki links without title [[SCP-173]]
  .replace(/\[\[\[([a-z_0-9#-]+)]]]/gi, '[$1](./$1)') // Italic
  .replace(/\/\/(.*?)\/\//gi, '*$1*') // HR
  .replace(/\n-+[\n$]/g, '\n\n----\n\n') // Strike
  .replace(/--(.+?)--/gi, '~~$1~~') // Footnotes
  .replace(/\[\[footnote]](.+?)\[\[\/footnote]]/gi, '^[$1]') // Monospace
  .replace(/{{(.+?)}}/gi, '`$1`') // Numbered lists
  .replace(/^# /mgi, '1. ') // Headers
  .replace(/^\+ /mgi, '# ').replace(/^\+\+ /mgi, '## ').replace(/^\+\+\+ /mgi, '### ').replace(/^\+\+\+\+ /mgi, '#### ').replace(/^\+\+\+\+\+ /mgi, '##### ').replace(/^\+\+\+\+\+\+ /mgi, '###### ') // Collapsible
  .replace(/\[\[(\/)?collapsible(.*)?]]/gi, '\n[[$1collapsible$2]]\n') // Tabs
  .replace(/\[\[(\/)?tab(view)?]]/gi, '\n[[$1tab$2]]\n') // Code block [[code]] & [[/code]]
  .replace(/\n\[\[(\/)?code]]\n/gi, '\n```\n').replace(imgBlockRegex, `::: image-right\n![$2]($1)\n$2\n:::`).replace(imgLinkedRightRegex, `::: image-right\n![$3]($1)\n$3\n:::`).replace(imgRightRegex, `::: image-right\n![$3]($1)\n$3\n:::`).replace(imgCenterRegex, `::: image-center\n![$3]($1)\n$3\n:::`).replace(imgLeftRegex, `::: image-left\n![$3]($1)\n$3\n:::`) // Simple inline images
  .replace(/\[\[=?image (.*?) style="(.*?)"]]/g, '![$1](./$1)').replace(/\[\[=?image (.*?)]]/g, '![$1](./$1)') // Blank lines
  .replace(/@@@@\n/g, '<br />') // Center align
  .replace(/\[\[==]](.*?)\[\[\/==]]/sg, ':::align-center\n$1\n:::\n') // Dialogs
  .replace(/^-\s/mg, '— '); // Plugin for parsing tables

  return table(parsedInput);
}
// CONCATENATED MODULE: ./renderer/postprocess.ts
const linkTag = '<a class="link" href="$1">$2</a>';
const imgSrcRegex = /<img src="(?!http)/g;
const documentLinkRegex = /\[\[\[(document-.*)\s*\|(.*)]]]/g;
function postprocess(meta, input) {
  const imgSrc = `<img src="https://scp.storage.yandexcloud.net/wikidot/scp-ru/${meta.name.toLowerCase()}/`;
  return input.replace(/\s*_<br>\s*/g, ' ') // Colored text
  .replace(/##(\w+?)\|(.+?)##/g, '<span class="colored-text colored-text_$1">$2</span>') // Center text
  .replace(/\[\[=]](.*?)\[\[\/=]]/smg, '<div class="aligned-text aligned-text_center">$1</div>').replace(imgSrcRegex, imgSrc).replace(documentLinkRegex, linkTag) // Mdash - вызывает проблемы в урлах до картинок
  // .replace(/[^-]--[^-]/g, ' &mdash; ')
  .replace(/\[\[size (.*?)]](.*?)\[\[\/size]]/g, '<font size="$1">$2</font>') // Styled blocks
  .replace(/\[\[div style=&quot;.*?&quot;]](.*?)\[\[\/div]]/smg, '$1').replace(/\[\[div class=&quot;.*?&quot;]]/g, '').replace(/\[\[\/div]]/g, '').replace(/\[\[span style=&quot;.*?&quot;]](.*?)\[\[\/span]]/smg, '$1');
}
// CONCATENATED MODULE: ./renderer/index.ts



function render(meta, source = '') {
  const preprocessed = preprocess(meta, source);
  const rendered = renderMarkdown(meta, preprocessed);
  const postprocessed = postprocess(meta, rendered);
  return postprocessed;
}
// CONCATENATED MODULE: ./pages/[page].tsx
var _page_jsx = external_react_default.a.createElement;







const PageContainer = ({
  page
}) => {
  if (!page) {
    return _page_jsx(error_default.a, {
      statusCode: 404
    });
  }

  return _page_jsx(App["a" /* default */], {
    pageName: page.title
  }, _page_jsx(components_Page_Page, {
    page: page
  }));
};

PageContainer.getInitialProps = async ({
  query
}) => {
  const pageName = query.page;
  const page = await utils["a" /* sdk */].getWikidotPage(pageName);

  if (!page) {
    return {};
  }

  const renderedContent = render({
    name: pageName
  }, page.content);
  return {
    page: {
      title: page.title,
      html: renderedContent,
      rating: page.rating
    }
  };
};

/* harmony default export */ var _page_ = __webpack_exports__["default"] = (PageContainer);

/***/ }),

/***/ "UxWH":
/***/ (function(module, exports) {

module.exports = require("markdown-it-abbr");

/***/ }),

/***/ "V2f5":
/***/ (function(module, exports) {



/***/ }),

/***/ "Wsky":
/***/ (function(module, exports) {

module.exports = require("markdown-it-container");

/***/ }),

/***/ "XUTK":
/***/ (function(module, exports) {

module.exports = require("markdown-it");

/***/ }),

/***/ "Xuae":
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _Set = __webpack_require__("ttDY");

var _Object$defineProperty = __webpack_require__("hfKm");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

const react_1 = __webpack_require__("cDcd");

const isServer = true;

exports.default = () => {
  const mountedInstances = new _Set();
  let state;

  function emitChange(component) {
    state = component.props.reduceComponentsToState([...mountedInstances], component.props);

    if (component.props.handleStateChange) {
      component.props.handleStateChange(state);
    }
  }

  return class extends react_1.Component {
    // Used when server rendering
    static rewind() {
      const recordedState = state;
      state = undefined;
      mountedInstances.clear();
      return recordedState;
    }

    constructor(props) {
      super(props);

      if (isServer) {
        mountedInstances.add(this);
        emitChange(this);
      }
    }

    componentDidMount() {
      mountedInstances.add(this);
      emitChange(this);
    }

    componentDidUpdate() {
      emitChange(this);
    }

    componentWillUnmount() {
      mountedInstances.delete(this);
      emitChange(this);
    }

    render() {
      return null;
    }

  };
};

/***/ }),

/***/ "au+6":
/***/ (function(module, exports) {



/***/ }),

/***/ "cBaE":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";

// EXTERNAL MODULE: external "axios"
var external_axios_ = __webpack_require__("zr5I");
var external_axios_default = /*#__PURE__*/__webpack_require__.n(external_axios_);

// EXTERNAL MODULE: external "next/config"
var config_ = __webpack_require__("KNus");
var config_default = /*#__PURE__*/__webpack_require__.n(config_);

// CONCATENATED MODULE: ./utils/sdk.ts


const {
  publicRuntimeConfig
} = config_default()();
const {
  BROWSER_API_ENDPOINT,
  SERVER_API_ENDPOINT
} = publicRuntimeConfig;
const WIKI_NAME = 'scp-ru';

function getApiEndpoint() {
  if (false) {} else {
    return SERVER_API_ENDPOINT;
  }
}

/* harmony default export */ var sdk = ({
  whoami: async () => {
    const response = await external_axios_default.a.get(`${getApiEndpoint()}/auth/whoami`);
    return response.data;
  },
  getWikidotPage: async pageName => {
    const url = `${getApiEndpoint()}/api/wikidot/pages/${WIKI_NAME}/${pageName.toLowerCase()}`;
    const response = await external_axios_default.a.get(url);
    return response.data.page;
  },
  getRandomWikidotPageName: async () => {
    try {
      const response = await external_axios_default.a.get(`${getApiEndpoint()}/api/wikidot_random_page`);
      return response.data.name;
    } catch (error) {
      console.error('Failed to get random page', error);
      throw error;
    }
  },
  tetherWikidotAccount: async () => {
    try {
      const response = await external_axios_default.a.post(`${getApiEndpoint()}/wikidot/api/tether-account`);
      return response.data && response.data.code;
    } catch (error) {
      const response = error.response;

      if (response && response.data && response.data.code) {
        return response.data.code;
      } else {
        throw error;
      }
    }
  }
});
// CONCATENATED MODULE: ./utils/index.ts
/* concated harmony reexport sdk */__webpack_require__.d(__webpack_exports__, "a", function() { return sdk; });


/***/ }),

/***/ "cDcd":
/***/ (function(module, exports) {

module.exports = require("react");

/***/ }),

/***/ "d04V":
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__("r7XW");

/***/ }),

/***/ "eomm":
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__("/a9y")


/***/ }),

/***/ "hfKm":
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__("TUA0");

/***/ }),

/***/ "i0sC":
/***/ (function(module, exports) {



/***/ }),

/***/ "lwAK":
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _Object$defineProperty = __webpack_require__("hfKm");

var __importStar = this && this.__importStar || function (mod) {
  if (mod && mod.__esModule) return mod;
  var result = {};
  if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  result["default"] = mod;
  return result;
};

_Object$defineProperty(exports, "__esModule", {
  value: true
});

const React = __importStar(__webpack_require__("cDcd"));

exports.AmpStateContext = React.createContext({});

/***/ }),

/***/ "r7XW":
/***/ (function(module, exports) {

module.exports = require("core-js/library/fn/array/from");

/***/ }),

/***/ "sdgC":
/***/ (function(module, exports) {

module.exports = require("markdown-it-deflist");

/***/ }),

/***/ "t28V":
/***/ (function(module, exports) {

module.exports = require("markdown-it-sub");

/***/ }),

/***/ "ttDY":
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__("zQQD");

/***/ }),

/***/ "vYYK":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
/* harmony import */ var _core_js_object_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("hfKm");
/* harmony import */ var _core_js_object_define_property__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_core_js_object_define_property__WEBPACK_IMPORTED_MODULE_0__);

function _defineProperty(obj, key, value) {
  if (key in obj) {
    _core_js_object_define_property__WEBPACK_IMPORTED_MODULE_0___default()(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

/***/ }),

/***/ "wqGw":
/***/ (function(module, exports) {

module.exports = require("markdown-it-table-of-contents");

/***/ }),

/***/ "x7bt":
/***/ (function(module, exports) {



/***/ }),

/***/ "xnum":
/***/ (function(module, exports) {

module.exports = require("next/head");

/***/ }),

/***/ "zQQD":
/***/ (function(module, exports) {

module.exports = require("core-js/library/fn/set");

/***/ }),

/***/ "zr5I":
/***/ (function(module, exports) {

module.exports = require("axios");

/***/ })

/******/ });