import type { FunctionalComponent } from 'preact';
import { h } from 'preact';
import './LanguageSelect.css';
import { KNOWN_LANGUAGES, langPathRegex } from '../../languages';

const LanguageSelect: FunctionalComponent<{ lang: string }> = ({ lang }) => {
  return (
    <div class="language-select-wrapper">
      <svg aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 88.6 77.3" height="1.2em" width="1.2em">
        <path fill="currentColor" d="M61,24.6h7.9l18.7,51.6h-7.7l-5.4-15.5H54.3l-5.6,15.5h-7.2L61,24.6z M72.6,55l-8-22.8L56.3,55H72.6z" />
        <path
          fill="currentColor"
          d="M53.6,60.6c-10-4-16-9-22-14c0,0,1.3,1.3,0,0c-6,5-20,13-20,13l-4-6c8-5,10-6,19-13c-2.1-1.9-12-13-13-19h8          c4,9,10,14,10,14c10-8,10-19,10-19h8c0,0-1,13-12,24l0,0c5,5,10,9,19,13L53.6,60.6z M1.6,16.6h56v-8h-23v-7h-9v7h-24V16.6z"
        />
      </svg>
      <select
        class="language-select"
        value={lang}
        onChange={(e) => {
          const newLang = e.target.value;
          let actualDest = window.location.pathname.replace(langPathRegex, '/');
          if (actualDest == '/') actualDest = `/introduction`;
          window.location.pathname = '/' + newLang + actualDest;
        }}
      >
        {Object.keys(KNOWN_LANGUAGES).map((key) => {
          return (
            <option value={KNOWN_LANGUAGES[key]}>
              <span>{key}</span>
            </option>
          );
        })}
      </select>
    </div>
  );
};

export default LanguageSelect;
/a><a href='/ansg191/rss-bridge/tree/lib/contents.php'>tree</a><a href='/ansg191/rss-bridge/commit/lib/contents.php?follow=1'>commit</a><a href='/ansg191/rss-bridge/diff/lib/contents.php?follow=1'>diff</a></td><td class='form'><form class='right' method='get' action='/ansg191/rss-bridge/log/lib/contents.php'>
<select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/ansg191/rss-bridge/log/?follow=1'>root</a>/<a href='/ansg191/rss-bridge/log/lib?follow=1'>lib</a>/<a href='/ansg191/rss-bridge/log/lib/contents.php?follow=1'>contents.php</a> (<a href='/ansg191/rss-bridge/log/lib/contents.php'>unfollow</a>)</div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/ansg191/rss-bridge/log/lib/contents.php?showmsg=1&amp;follow=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
<tr><td><span title='2025-02-24 17:58:24 +0100'>2025-02-24</span></td><td><a href='/ansg191/rss-bridge/commit/bridges/BukowskisBridge.php?id=92b5e7093ff310f0fa28c17d0ab89b7289282d02&amp;follow=1'>Fix data-lot-id not being correctly set so use href instead (#4453)</a></td><td><img src='//www.gravatar.com/avatar/1facfafd96fa2c5d86751ef51b44bbaa?s=13&amp;d=retro' width='13' height='13' alt='Gravatar' /> André Andersson
</td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+1</span></td></tr>
<tr><td><span title='2025-02-14 02:42:23 +0100'>2025-02-14</span></td><td><a href='/ansg191/rss-bridge/commit/bridges/GithubIssueBridge.php?id=b52f01505d524039e78e83844225f574ce101145&amp;follow=1'>fix(github): semi-repair (#4449)</a></td><td><img src='//www.gravatar.com/avatar/ae6a607ff34e971259ff9666b9c68c98?s=13&amp;d=retro' width='13' height='13' alt='Gravatar' /> Dag
</td><td>1</td><td><span class='deletions'>-12</span>/<span class='insertions'>+15</span></td></tr>
<tr><td><span title='2025-02-14 02:00:07 +0100'>2025-02-14</span></td><td><a href='/ansg191/rss-bridge/commit/bridges/VkBridge.php?id=e4c32bb046011a95ffecf3693db3a754b37dac13&amp;follow=1'>fix(vk): semi-disable broken bridge (#4448)</a></td><td><img src='//www.gravatar.com/avatar/ae6a607ff34e971259ff9666b9c68c98?s=13&amp;d=retro' width='13' height='13' alt='Gravatar' /> Dag
</td><td>1</td><td><span class='deletions'>-8</span>/<span class='insertions'>+15</span></td></tr>
<tr><td><span title='2025-02-08 01:41:51 +0100'>2025-02-08</span></td><td><a href='/ansg191/rss-bridge/commit/bridges/NurembergerNachrichtenBridge.php?id=dd4dcfa59c08e5bece71861647f82c05e60c0cfa&amp;follow=1'>fix nn.de description and paywall filter (#4444)</a></td><td><img src='//www.gravatar.com/avatar/c547f56b15e1fda3fda0c38545dfd74a?s=13&amp;d=retro' width='13' height='13' alt='Gravatar' /> Christian Schabesberger
</td><td>1</td><td><span class='deletions'>-2</span>/<span class='insertions'>+2</span></td></tr>
<tr><td><span title='2025-02-05 18:41:42 +0100'>2025-02-05</span></td><td><a href='/ansg191/rss-bridge/commit/bridges/CarThrottleBridge.php?id=4e678c955fed511667160776b3f27e75178b4eaf&amp;follow=1'>fix CarThrottleBridge (#4442)</a></td><td><img src='//www.gravatar.com/avatar/e31e7774d942032fb28cd702860f6ec2?s=13&amp;d=retro' width='13' height='13' alt='Gravatar' /> Tostiman
</td><td>1</td><td><span class='deletions'>-3</span>/<span class='insertions'>+3</span></td></tr>
