<commit_before>import {
  History as FakeHistory,
  back, create, current, currentState, previous, pushState
} from 'fake-history-fns';
import xs from 'xstream';
import { HistoryPoppedEvent, HistoryPushedEvent, StateEvent } from '../event';
import { Command, Event, Message } from '../model/message';
import {
  getCurrentFocusedEntry,
  getCurrentSelectedEntry
} from '../model/entry-viewer';

type P = {
  path: string;
  title: string;
};

type T = {
  event: HistoryPoppedEvent | HistoryPushedEvent | null;
  history: FakeHistory;
};

const p$ = (message$: xs<Message>): xs<P> => {
  const bbn = 'blog.bouzuya.net';
  return message$
    .filter((m): m is StateEvent => m.type === 'state')
    .map(({ state: { entryViewer, focus } }: StateEvent) => {
      const focused = getCurrentFocusedEntry(entryViewer);
      const selected = getCurrentSelectedEntry(entryViewer);
      const path = focus === 'entry-list'
        ? focused === null
          ? '/'
          : `/${focused.id.replace(/-/g, '/')}/related/`
        : selected === null
          ? '/'
          : `/${selected.id.replace(/-/g, '/')}/`;
      const title = focus === 'entry-list'
        ? bbn
        : selected === null<commit_msg>fix root path<commit_after>import {
  History as FakeHistory,
  back, create, current, currentState, previous, pushState
} from 'fake-history-fns';
import xs from 'xstream';
import { HistoryPoppedEvent, HistoryPushedEvent, StateEvent } from '../event';
import { Command, Event, Message } from '../model/message';
import {
  getCurrentFocusedEntry,
  getCurrentSelectedEntry,
  getPrevFocusedEntry
} from '../model/entry-viewer';

type P = {
  path: string;
  title: string;
};

type T = {
  event: HistoryPoppedEvent | HistoryPushedEvent | null;
  history: FakeHistory;
};

const p$ = (message$: xs<Message>): xs<P> => {
  const bbn = 'blog.bouzuya.net';
  return message$
    .filter((m): m is StateEvent => m.type === 'state')
    .map(({ state: { entryViewer, focus } }: StateEvent) => {
      const focused = getCurrentFocusedEntry(entryViewer);
      const selected = getCurrentSelectedEntry(entryViewer);
      const path = focus === 'entry-list'
        ? focused === null || getPrevFocusedEntry(entryViewer) === null
          ? '/'
          : `/${focused.id.replace(/-/g, '/')}/related/`
        : selected === null
          ? '/'
          : `/${selected.id.replace(/-/g, '/')}/`;
      const title = focus === 'entry-list'
        ? bbn
        : selected === null
{'fraction_non_alphanumeric': 0.16492357200321803, 'fraction_numerical': 0.0, 'mean_word_length': 3.011290322580645, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6620164', 'n_tokens_mistral': 786, 'n_tokens_neox': 779, 'n_words': 188}