- an upgrade only stays on http if --http was given explicitly (marker file data/http-only); before, a 4.0 install that had fallen back to http never switched to https - look for certificates in all nginx config files and prefer a CA-signed one (chain file or issuer != subject) over the self-signed default - hint how to install libustream-openssl when uhttpd lacks TLS Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4414 lines
247 KiB
Bash
Executable File
4414 lines
247 KiB
Bash
Executable File
#!/bin/sh
|
||
# Cabin Chat 4.0.0 - self-contained installer for OpenWrt / GL.iNet routers.
|
||
# Uses only what the firmware already ships (uhttpd, busybox, uci).
|
||
#
|
||
# sh install-cabinchat.sh install, or upgrade an existing install
|
||
# (keeps accounts, messages, photos, port)
|
||
# sh install-cabinchat.sh -p 8090 install/upgrade on a specific port
|
||
# sh install-cabinchat.sh --http plain http instead of https
|
||
# sh install-cabinchat.sh --cert C --key K https with your own certificate
|
||
# sh install-cabinchat.sh wipe delete all messages and photos
|
||
# sh install-cabinchat.sh uninstall remove Cabin Chat completely
|
||
#
|
||
# https uses the certificate of the router's web admin unless --cert is given.
|
||
#
|
||
# Generated by build.sh - edit www/ and installer.sh.in instead of this file.
|
||
|
||
VERSION="4.0.0"
|
||
APP=/www-chat
|
||
WEB=$APP/htdocs
|
||
DATA=$APP/data
|
||
RUN=/tmp/cabinchat
|
||
CLOCK=/etc/cabinchat.clock
|
||
DNSNAME=chat.lan
|
||
DEFAULT_PORT=8088
|
||
STAGE=/tmp/cabinchat-stage.$$
|
||
|
||
info() { echo ">> $*"; }
|
||
warn() { echo "WARNING: $*" >&2; }
|
||
die() { echo "ERROR: $*" >&2; rm -rf "$STAGE"; exit 1; }
|
||
usage() {
|
||
if [ -f "$0" ]; then sed -n '4,13p' "$0" | sed 's/^# \{0,1\}//'
|
||
else echo "usage: sh install-cabinchat.sh [-p <port>] [--http | --cert <file> --key <file>] [wipe | uninstall]"; fi
|
||
}
|
||
|
||
listening() { netstat -tln 2>/dev/null | grep -qE "[:.]$1[[:space:]]"; }
|
||
|
||
configured_port() {
|
||
{ uci -q get uhttpd.chat.listen_https; uci -q get uhttpd.chat.listen_http; } |
|
||
tr ' ' '\n' | sed -n 's/.*:\([0-9][0-9]*\)$/\1/p' | head -n 1
|
||
}
|
||
|
||
# "cert key" pairs from the nginx configuration (GL.iNet firmware), in order
|
||
nginx_certs() {
|
||
for f in /etc/nginx/nginx.conf /etc/nginx/conf.d/* /etc/nginx/*/*.conf; do
|
||
[ -f "$f" ] || continue
|
||
awk '{ sub(/#.*/, "") }
|
||
$1 == "ssl_certificate" { c = $2; sub(/;.*/, "", c) }
|
||
$1 == "ssl_certificate_key" { k = $2; sub(/;.*/, "", k) }
|
||
c != "" && k != "" { print c, k; c = k = "" }' "$f"
|
||
done | awk '!seen[$0]++'
|
||
}
|
||
|
||
# is this certificate issued by a CA (not self-signed)? A chain file with more
|
||
# than one certificate is; otherwise ask openssl if it is there.
|
||
ca_signed() {
|
||
[ "$(grep -c 'BEGIN CERTIFICATE' "$1" 2>/dev/null)" -gt 1 ] && return 0
|
||
command -v openssl >/dev/null || return 1
|
||
s=$(openssl x509 -in "$1" -noout -subject 2>/dev/null | sed 's/^subject=[[:space:]]*//')
|
||
i=$(openssl x509 -in "$1" -noout -issuer 2>/dev/null | sed 's/^issuer=[[:space:]]*//')
|
||
[ -n "$i" ] && [ "$s" != "$i" ]
|
||
}
|
||
|
||
# the certificate of the router's own web admin -> CERT, KEY
|
||
# (GL.iNet firmware: nginx, preferring a CA-signed one; plain OpenWrt: uhttpd)
|
||
admin_cert() {
|
||
CERT=; KEY=
|
||
while read -r c k; do
|
||
[ -s "$c" ] && [ -s "$k" ] || continue
|
||
[ -n "$CERT" ] || { CERT=$c; KEY=$k; }
|
||
if ca_signed "$c"; then CERT=$c; KEY=$k; break; fi
|
||
done <<EOF
|
||
$(nginx_certs)
|
||
EOF
|
||
[ -n "$CERT" ] && return 0
|
||
c=$(uci -q get uhttpd.main.cert); k=$(uci -q get uhttpd.main.key)
|
||
if [ -s "$c" ] && [ -s "$k" ]; then CERT=$c; KEY=$k; return 0; fi
|
||
if [ -s /etc/uhttpd.crt ] && [ -s /etc/uhttpd.key ]; then CERT=/etc/uhttpd.crt; KEY=/etc/uhttpd.key; return 0; fi
|
||
return 1
|
||
}
|
||
|
||
# uhttpd does TLS through libustream-ssl
|
||
have_tls() { ls /lib/libustream-ssl.so* /usr/lib/libustream-ssl.so* >/dev/null 2>&1; }
|
||
|
||
remove_config() {
|
||
if uci -q get uhttpd.chat >/dev/null; then
|
||
uci delete uhttpd.chat
|
||
uci commit uhttpd
|
||
fi
|
||
for a in $(uci -q get dhcp.@dnsmasq[0].address); do
|
||
case $a in "/$DNSNAME/"*) uci del_list dhcp.@dnsmasq[0].address="$a" ;; esac
|
||
done
|
||
uci commit dhcp
|
||
[ -f /etc/sysupgrade.conf ] && sed -i "\#^$APP/\$#d" /etc/sysupgrade.conf
|
||
}
|
||
|
||
extract_payload() {
|
||
rm -rf "$STAGE"
|
||
mkdir -p "$STAGE" || die "cannot create $STAGE"
|
||
{
|
||
printf '\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122'
|
||
printf '\000\000\000\264\000\000\000\264\010\006\000\000\000\075\315\006'
|
||
printf '\062\000\000\023\057\111\104\101\124\170\332\355\335\173\160\134'
|
||
printf '\325\175\300\361\357\271\167\127\157\077\144\371\051\031\033\033'
|
||
printf '\313\022\357\224\227\047\223\222\022\222\024\160\247\217\044\245'
|
||
printf '\045\235\166\112\062\055\323\246\217\231\316\264\345\217\114\247'
|
||
printf '\217\111\073\303\024\150\150\302\220\014\011\151\033\032\206\020'
|
||
printf '\132\012\001\302\020\214\061\065\004\014\304\250\066\140\331\172'
|
||
printf '\200\237\222\045\131\326\153\137\367\336\323\077\326\053\351\356'
|
||
printf '\256\036\226\245\335\163\356\376\176\063\073\040\041\356\336\325'
|
||
printf '\176\366\247\337\357\334\163\317\121\067\176\325\327\000\212\151'
|
||
printf '\241\363\276\076\027\063\176\117\317\365\063\072\374\265\136\314'
|
||
printf '\143\347\105\221\163\137\374\143\353\371\375\177\172\211\316\173'
|
||
printf '\216\163\077\277\143\353\013\073\366\074\337\317\222\034\033\160'
|
||
printf '\004\263\140\216\012\146\264\306\021\314\202\071\052\230\047\063'
|
||
printf '\264\140\026\314\121\300\254\046\101\013\146\301\034\001\314\331'
|
||
printf '\014\055\230\005\163\104\060\003\171\065\264\140\026\314\026\143'
|
||
printf '\016\327\320\202\131\060\133\216\131\345\203\026\314\202\331\146'
|
||
printf '\314\241\014\055\230\005\263\355\230\047\101\013\146\301\034\005'
|
||
printf '\314\263\067\205\202\131\060\133\206\171\346\246\120\060\013\146'
|
||
printf '\013\061\053\135\254\051\024\314\202\331\122\314\205\115\241\140'
|
||
printf '\026\314\026\143\016\067\205\202\131\060\133\216\171\252\051\024'
|
||
printf '\314\202\071\002\230\263\031\132\060\013\346\210\140\126\314\171'
|
||
printf '\141\105\060\013\146\173\060\207\153\150\301\054\230\055\307\074'
|
||
printf '\125\103\013\146\301\034\001\314\241\141\073\301\054\230\155\307'
|
||
printf '\134\144\266\235\140\026\314\366\142\046\334\024\012\146\301\154'
|
||
printf '\067\346\151\115\241\140\026\314\366\143\106\203\043\230\005\163'
|
||
printf '\124\060\027\064\205\202\131\060\333\214\071\174\141\105\060\013'
|
||
printf '\146\313\061\117\325\320\202\131\060\107\000\063\200\043\230\005'
|
||
printf '\163\124\060\027\324\320\202\131\060\333\214\271\260\051\024\314'
|
||
printf '\202\331\142\314\363\230\155\047\230\005\263\075\230\247\232\102'
|
||
printf '\301\054\230\043\200\071\333\024\012\146\301\034\021\314\063\067'
|
||
printf '\205\202\131\060\133\210\171\201\313\030\010\146\301\154\046\146'
|
||
printf '\070\357\145\014\004\263\140\066\027\163\270\051\024\314\202\331'
|
||
printf '\162\314\123\115\241\140\026\314\021\300\234\315\320\202\131\060'
|
||
printf '\107\004\363\374\056\254\010\146\301\154\011\346\160\015\055\230'
|
||
printf '\005\263\345\230\001\142\202\171\351\060\073\016\324\325\100\125'
|
||
printf '\134\201\206\164\106\223\110\202\016\004\363\122\140\006\210\011'
|
||
printf '\346\205\141\216\071\260\161\203\242\145\035\254\135\245\130\263'
|
||
printf '\012\326\066\145\377\331\120\247\250\251\006\327\245\150\370\076'
|
||
printf '\044\123\060\066\241\031\030\202\376\101\315\351\301\354\277\237'
|
||
printf '\350\323\034\077\241\361\265\140\136\310\261\143\202\171\176\050'
|
||
printf '\226\325\303\245\227\050\132\067\051\266\155\126\154\275\110\121'
|
||
printf '\135\305\202\302\165\241\276\016\352\353\024\353\126\303\345\171'
|
||
printf '\317\232\112\103\357\121\315\221\336\354\243\263\053\140\154\134'
|
||
printf '\060\317\347\330\061\301\074\363\317\255\151\204\253\333\035\256'
|
||
printf '\275\134\161\165\233\232\061\343\056\166\124\127\101\333\045\212'
|
||
printf '\266\113\262\147\024\004\056\135\275\232\237\037\014\170\247\103'
|
||
printf '\163\252\137\013\346\031\276\126\267\334\355\151\301\074\365\275'
|
||
printf '\372\132\270\361\072\207\233\167\050\066\067\053\114\214\217\216'
|
||
printf '\153\366\274\036\260\167\137\100\062\041\230\103\357\377\255\167'
|
||
printf '\173\132\060\303\326\215\212\117\177\134\161\343\265\316\202\113'
|
||
printf '\211\122\107\046\003\373\017\004\354\176\055\340\275\103\272\342'
|
||
printf '\061\103\076\350\012\304\334\276\105\361\333\267\071\134\276\115'
|
||
printf '\141\163\034\351\321\374\367\263\076\357\167\352\312\305\034\002'
|
||
printf '\135\141\230\133\067\053\276\360\131\207\153\056\263\033\162\176'
|
||
printf '\034\356\326\374\327\217\175\072\017\353\212\303\074\225\241\053'
|
||
printf '\010\363\252\025\360\245\317\271\354\270\052\132\220\363\343\255'
|
||
printf '\375\001\217\375\050\140\370\254\256\030\314\331\121\216\012\301'
|
||
printf '\254\200\117\177\334\341\367\176\325\241\266\206\310\307\165\037'
|
||
printf '\163\270\274\315\341\251\347\174\136\336\023\020\004\321\307\014'
|
||
printf '\032\165\333\137\207\233\302\050\142\156\131\243\370\312\027\035'
|
||
printf '\132\067\053\052\061\272\172\064\337\173\324\347\124\277\216\064'
|
||
printf '\146\040\014\072\212\230\257\277\102\361\047\137\164\251\253\241'
|
||
printf '\242\043\225\202\177\177\314\147\337\333\101\164\061\063\333\205'
|
||
printf '\025\313\061\273\016\334\161\233\303\257\337\354\224\024\116\240'
|
||
printf '\041\231\012\110\146\002\062\236\306\363\065\101\356\366\040\005'
|
||
printf '\061\127\021\217\051\152\342\016\065\325\116\361\273\224\227\040'
|
||
printf '\252\253\341\256\073\135\332\133\025\217\375\320\303\363\243\207'
|
||
printf '\231\034\350\250\141\136\126\017\167\177\331\145\373\305\245\053'
|
||
printf '\061\022\251\200\221\011\237\211\124\220\113\176\305\063\145\046'
|
||
printf '\367\037\175\224\202\272\152\207\345\165\056\265\325\245\371\340'
|
||
printf '\175\362\023\016\055\315\161\036\374\166\206\261\261\150\141\006'
|
||
printf '\120\073\363\152\150\333\061\067\056\207\257\336\345\262\151\103'
|
||
printf '\151\060\247\062\001\003\147\275\151\120\027\230\101\343\016\253'
|
||
printf '\127\270\124\307\113\003\373\124\237\346\353\337\364\030\072\243'
|
||
printf '\043\203\031\026\175\031\203\362\142\136\327\244\370\207\077\055'
|
||
printf '\015\146\255\141\160\304\343\370\100\346\202\061\347\076\030\307'
|
||
printf '\007\062\014\216\170\263\146\370\305\212\365\353\024\177\365\027'
|
||
printf '\061\326\257\125\221\301\254\362\063\264\315\230\057\132\257\370'
|
||
printf '\333\077\166\131\336\260\364\030\374\100\163\152\150\146\310\307'
|
||
printf '\007\175\336\354\114\163\350\230\317\360\170\300\340\150\200\002'
|
||
printf '\232\226\053\126\324\273\264\265\270\334\320\126\105\313\052\167'
|
||
printf '\306\154\275\176\125\014\267\004\005\366\350\250\346\276\007\074'
|
||
printf '\116\236\322\326\143\106\117\003\155\173\231\361\265\077\217\261'
|
||
printf '\246\261\004\230\175\315\211\241\014\231\374\051\060\032\176\326'
|
||
printf '\231\346\211\275\111\216\236\366\347\165\254\115\153\134\156\377'
|
||
printf '\104\015\073\266\127\241\362\136\134\074\246\150\156\212\227\004'
|
||
printf '\365\231\141\315\075\367\171\014\017\151\253\061\117\326\320\066'
|
||
printf '\143\256\255\201\277\377\212\313\305\055\113\377\306\007\032\116'
|
||
printf '\014\244\111\347\141\076\066\340\363\355\027\046\070\174\302\137'
|
||
printf '\320\161\133\233\135\376\350\326\072\132\232\302\031\273\052\256'
|
||
printf '\150\156\252\052\311\110\310\211\023\232\173\357\317\060\221\260'
|
||
printf '\027\163\156\044\311\352\241\271\277\274\263\064\230\001\006\316'
|
||
printf '\146\012\060\167\364\172\374\335\343\343\164\365\005\070\256\132'
|
||
printf '\320\243\253\057\340\157\036\033\347\355\256\114\350\330\351\214'
|
||
printf '\346\364\160\246\044\257\255\271\131\361\207\177\020\303\161\354'
|
||
printf '\305\234\155\012\055\276\150\362\133\267\070\134\331\132\032\314'
|
||
printf '\243\011\237\261\104\370\146\300\327\016\145\270\367\231\011\222'
|
||
printf '\036\013\306\234\173\244\175\170\340\271\004\257\167\206\001\217'
|
||
printf '\047\003\306\022\176\111\136\343\245\355\016\277\262\323\265\026'
|
||
printf '\363\005\054\143\120\176\314\227\156\125\045\273\150\022\150\030'
|
||
printf '\032\011\243\352\355\367\371\267\135\051\024\012\327\131\234\207'
|
||
printf '\102\361\335\237\246\350\072\025\376\340\014\216\370\223\027\147'
|
||
printf '\226\072\166\336\352\262\175\273\143\045\346\311\141\073\333\060'
|
||
printf '\327\327\300\237\375\216\073\371\347\161\251\343\354\270\217\077'
|
||
printf '\115\124\042\255\171\340\371\044\031\175\341\231\071\377\341\003'
|
||
printf '\337\174\041\101\062\255\103\243\052\043\343\245\311\322\112\301'
|
||
printf '\235\277\357\122\137\157\037\346\251\032\332\042\314\150\370\362'
|
||
printf '\347\135\126\067\226\006\263\206\002\114\077\331\357\061\222\000'
|
||
printf '\307\121\113\362\030\111\300\117\072\274\202\017\125\211\222\064'
|
||
printf '\215\053\025\267\177\041\146\035\146\230\317\246\101\206\141\156'
|
||
printf '\335\254\370\305\153\112\170\111\073\031\204\262\363\331\011\315'
|
||
printf '\256\203\036\256\253\226\364\361\322\001\217\221\104\070\113\047'
|
||
printf '\122\101\311\136\367\015\067\070\134\174\261\262\012\263\142\256'
|
||
printf '\115\203\014\303\254\024\174\351\163\116\301\230\355\122\306\170'
|
||
printf '\036\242\267\272\375\045\051\065\362\037\231\000\336\356\011\377'
|
||
printf '\145\230\110\226\016\264\122\160\373\157\306\120\312\036\314\314'
|
||
printf '\332\024\032\170\333\324\215\327\052\266\155\052\355\234\346\144'
|
||
printf '\072\214\250\343\230\217\343\120\222\107\307\321\060\350\104\072'
|
||
printf '\050\351\153\337\262\105\161\375\365\216\065\230\141\246\331\166'
|
||
printf '\006\142\126\012\076\377\231\322\116\005\325\232\320\025\301\124'
|
||
printf '\106\323\063\250\161\334\322\174\250\272\007\064\251\214\246\072'
|
||
printf '\236\175\276\214\247\321\347\376\122\225\052\166\356\164\171\153'
|
||
printf '\337\324\014\102\223\061\243\213\255\155\147\350\335\331\327\136'
|
||
printf '\246\150\136\133\332\354\234\311\133\217\153\070\301\271\141\272'
|
||
printf '\322\235\103\377\250\346\242\125\052\164\116\125\261\322\375\036'
|
||
printf '\326\256\125\134\166\271\303\301\003\201\361\230\047\063\264\351'
|
||
printf '\230\025\260\363\223\245\315\316\000\101\336\340\357\110\202\222'
|
||
printf '\145\347\134\214\046\213\235\123\151\317\341\123\237\162\170\357'
|
||
printf '\100\140\074\346\360\332\166\006\143\336\270\136\225\145\335\214'
|
||
printf '\374\151\234\343\151\135\162\320\151\177\366\163\052\105\264\267'
|
||
printf '\073\254\137\257\070\265\250\063\362\026\037\363\124\206\066\174'
|
||
printf '\171\256\033\257\125\045\255\033\213\234\312\144\035\357\072\245'
|
||
printf '\075\221\374\327\135\006\317\050\005\327\135\357\360\343\147\174'
|
||
printf '\243\061\147\101\133\260\160\342\165\127\030\162\267\266\122\045'
|
||
printf '\317\320\145\371\044\027\211\053\257\162\170\366\151\337\150\314'
|
||
printf '\060\331\024\232\213\171\135\223\142\343\072\063\336\124\105\366'
|
||
printf '\352\140\251\237\323\204\150\151\121\064\255\126\014\016\150\143'
|
||
printf '\061\237\053\071\314\136\322\366\372\053\314\131\113\103\051\160'
|
||
printf '\335\362\226\034\345\214\053\256\164\170\345\145\337\130\314\363'
|
||
printf '\133\306\240\214\230\025\320\276\325\040\320\216\302\161\113\375'
|
||
printf '\234\346\200\336\326\252\170\345\145\163\061\117\066\205\046\257'
|
||
printf '\234\277\271\005\243\302\161\250\330\150\331\250\214\306\074\255'
|
||
printf '\206\066\023\163\155\015\254\151\254\364\222\103\033\363\372\127'
|
||
printf '\257\126\324\324\100\062\151\046\146\230\155\323\040\003\066\350'
|
||
printf '\331\274\101\031\125\103\052\125\206\246\320\040\320\112\301\206'
|
||
printf '\146\105\117\267\066\022\363\314\233\006\031\262\333\324\372\325'
|
||
printf '\146\055\256\250\312\060\154\247\224\242\074\243\317\305\143\315'
|
||
printf '\132\105\157\267\066\022\063\272\130\123\150\320\326\151\365\265'
|
||
printf '\030\006\272\262\107\071\000\352\352\224\261\230\013\233\102\303'
|
||
printf '\066\265\254\063\020\264\343\124\066\350\332\132\163\061\207\233'
|
||
printf '\102\003\167\150\065\156\011\334\262\135\051\324\146\201\066\024'
|
||
printf '\363\124\123\150\350\166\303\065\325\206\171\146\376\031\172\125'
|
||
printf '\055\354\330\004\333\127\103\123\135\366\327\060\064\001\207\116'
|
||
printf '\303\033\107\341\114\142\376\317\151\122\124\127\053\143\061\147'
|
||
printf '\233\102\203\367\316\326\332\060\320\012\142\356\334\077\363\313'
|
||
printf '\333\340\346\113\262\333\047\117\217\225\065\260\165\025\174\266'
|
||
printf '\025\136\352\202\027\017\317\235\173\115\053\071\322\151\155\054'
|
||
printf '\346\302\032\332\040\314\012\110\147\314\172\063\035\005\161\167'
|
||
printf '\366\154\172\307\125\160\365\206\331\217\023\163\340\226\126\130'
|
||
printf '\327\000\217\167\314\216\332\061\014\164\170\243\117\263\060\207'
|
||
printf '\153\150\303\060\003\214\047\314\172\063\225\052\314\272\323\343'
|
||
printf '\246\055\163\143\236\036\037\333\000\375\143\260\247\327\236\014'
|
||
printf '\235\110\230\213\171\252\206\066\020\063\150\206\107\314\252\071'
|
||
printf '\234\131\112\216\145\325\360\113\133\316\377\230\067\155\205\216'
|
||
printf '\076\030\113\333\221\241\023\023\332\130\314\005\240\115\302\014'
|
||
printf '\060\064\134\136\320\371\331\261\332\205\334\002\373\365\125\160'
|
||
printf '\115\063\134\274\022\032\252\301\235\243\034\231\051\252\134\370'
|
||
printf '\205\015\320\073\014\365\161\110\172\160\152\014\374\140\352\071'
|
||
printf '\115\002\176\346\214\271\230\147\237\155\127\146\314\000\047\373'
|
||
printf '\313\235\221\303\147\131\027\327\304\134\150\137\015\267\155\317'
|
||
printf '\142\134\214\270\151\153\366\003\221\213\224\017\373\117\302\153'
|
||
printf '\037\101\135\114\347\175\310\312\053\372\304\061\155\054\346\231'
|
||
printf '\233\102\003\060\053\240\177\120\223\116\103\125\231\066\223\217'
|
||
printf '\347\215\071\327\306\262\303\160\277\326\276\270\265\255\133\344'
|
||
printf '\057\301\216\215\260\265\021\006\363\376\112\305\335\362\201\036'
|
||
printf '\071\253\031\037\325\306\142\106\027\373\013\146\010\146\000\035'
|
||
printf '\100\367\321\362\225\035\216\023\276\207\260\312\321\354\330\130'
|
||
printf '\272\106\315\165\240\312\231\376\265\052\353\364\325\023\307\314'
|
||
printf '\306\014\371\153\333\031\204\071\367\255\316\236\362\326\321\065'
|
||
printf '\125\341\263\116\244\113\167\076\147\046\302\317\125\133\135\336'
|
||
printf '\162\343\303\036\155\064\346\360\332\166\006\142\006\350\170\077'
|
||
printf '\050\353\233\130\227\267\177\240\237\366\112\162\041\132\003\176'
|
||
printf '\306\313\003\135\336\273\013\016\164\370\106\143\236\312\320\206'
|
||
printf '\142\126\300\241\156\315\231\263\345\313\322\365\265\156\250\304'
|
||
printf '\210\021\160\262\004\303\211\047\106\064\061\035\204\106\134\352'
|
||
printf '\153\334\262\375\036\316\016\153\216\037\325\106\143\316\202\066'
|
||
printf '\030\063\144\057\177\357\173\267\214\165\264\202\145\265\141\110'
|
||
printf '\343\023\336\222\256\250\357\153\110\114\204\263\363\262\132\267'
|
||
printf '\254\103\166\007\336\015\262\357\217\301\230\163\357\227\261\230'
|
||
printf '\163\361\346\376\362\226\035\053\033\302\131\332\325\001\275\203'
|
||
printf '\113\267\242\376\207\103\001\116\136\166\136\331\340\226\365\167'
|
||
printf '\360\356\073\201\361\230\013\232\102\023\061\253\163\215\341\300'
|
||
printf '\120\371\262\164\314\315\156\230\031\212\214\307\361\045\050\075'
|
||
printf '\216\235\325\005\223\130\126\326\273\304\312\070\134\167\362\204'
|
||
printf '\246\353\120\140\074\346\371\157\032\124\106\314\271\262\343\331'
|
||
printf '\135\345\315\322\215\015\061\252\342\341\063\114\215\247\263\000'
|
||
printf '\027\261\156\116\115\204\257\201\127\305\025\053\033\142\145\175'
|
||
printf '\355\257\276\344\207\146\076\232\212\171\062\103\233\214\071\027'
|
||
printf '\273\177\026\224\265\071\124\012\326\255\214\027\214\003\247\047'
|
||
printf '\322\364\016\371\170\027\360\171\363\002\350\035\362\111\216\247'
|
||
printf '\303\015\216\223\175\316\162\136\034\234\030\207\167\336\364\255'
|
||
printf '\300\134\264\206\066\021\063\200\237\201\027\166\227\067\113\307'
|
||
printf '\143\212\365\215\205\300\202\224\307\321\323\151\116\216\350\363'
|
||
printf '\152\026\265\206\276\061\315\107\375\031\202\224\127\360\001\132'
|
||
printf '\337\030\047\036\053\357\330\363\236\227\074\322\151\073\060\203'
|
||
printf '\236\145\323\040\203\060\347\356\344\337\265\067\140\164\254\254'
|
||
printf '\357\057\065\125\116\321\075\270\165\240\111\214\247\351\355\313'
|
||
printf '\160\154\070\340\114\122\343\353\342\331\370\114\122\163\164\070'
|
||
printf '\240\247\057\303\370\150\072\173\111\164\132\270\116\166\237\357'
|
||
printf '\232\252\362\216\073\017\237\321\354\176\321\267\006\363\234\313'
|
||
printf '\030\230\204\031\040\231\202\307\236\362\271\353\167\313\333\361'
|
||
printf '\127\307\035\132\126\307\351\037\366\012\366\140\101\007\244\023'
|
||
printf '\001\351\004\234\311\352\234\166\051\077\230\363\026\225\352\270'
|
||
printf '\142\155\143\274\254\163\066\162\361\314\223\331\354\154\013\146'
|
||
printf '\164\261\246\320\120\314\271\237\331\273\057\340\300\007\345\237'
|
||
printf '\047\035\163\025\033\232\342\064\055\217\315\076\076\354\007\350'
|
||
printf '\163\217\331\060\073\012\232\226\307\150\136\135\145\004\346\336'
|
||
printf '\356\200\375\157\005\126\141\056\154\012\015\307\234\213\357\075'
|
||
printf '\356\223\114\225\375\075\107\001\053\352\135\056\132\133\105\143'
|
||
printf '\203\273\240\305\320\135\107\321\330\220\075\306\212\172\327\210'
|
||
printf '\233\142\275\014\074\361\250\067\073\100\003\061\103\221\145\014'
|
||
printf '\114\307\014\060\060\244\171\352\171\237\073\176\303\305\204\160'
|
||
printf '\035\105\343\262\030\215\313\040\221\012\230\110\005\244\062\232'
|
||
printf '\264\027\020\344\125\044\216\003\125\061\207\232\270\242\266\332'
|
||
printf '\051\373\374\214\142\361\324\017\075\116\035\327\326\141\206\274'
|
||
printf '\145\014\154\300\234\373\336\013\273\003\266\154\122\354\270\306'
|
||
printf '\054\020\371\110\003\015\372\334\040\256\122\312\270\133\252\362'
|
||
printf '\343\377\366\007\274\276\307\267\022\163\366\302\212\205\230\317'
|
||
printf '\365\136\074\362\003\237\243\307\265\321\100\234\163\373\262\270'
|
||
printf '\216\371\230\207\006\065\117\374\207\147\055\346\311\032\332\066'
|
||
printf '\314\271\143\247\322\360\300\303\076\043\243\110\134\140\214\217'
|
||
printf '\153\036\376\327\014\343\343\332\132\314\205\115\241\105\230\163'
|
||
printf '\337\033\034\322\074\370\210\107\052\055\050\027\032\231\014\074'
|
||
printf '\362\240\107\377\051\273\061\347\376\042\132\213\071\027\235\135'
|
||
printf '\232\257\177\313\043\225\022\234\347\033\101\000\217\176\047\103'
|
||
printf '\157\127\140\075\346\120\311\141\053\346\334\327\207\216\150\356'
|
||
printf '\177\310\043\221\024\244\363\015\337\203\357\077\234\341\300\376'
|
||
printf '\150\140\236\175\266\235\105\230\163\161\270\133\363\057\017\171'
|
||
printf '\323\126\367\221\230\051\122\051\170\370\033\031\072\336\211\016'
|
||
printf '\346\031\153\150\033\061\347\242\253\133\363\217\367\171\234\354'
|
||
printf '\323\242\166\226\006\360\133\367\247\071\374\101\264\060\027\255'
|
||
printf '\241\155\306\234\073\366\311\076\315\327\376\331\343\235\167\003'
|
||
printf '\321\233\027\307\076\322\074\360\117\031\076\352\325\221\303\034'
|
||
printf '\232\313\021\025\314\271\110\246\340\241\357\372\074\371\264\157'
|
||
printf '\334\262\274\345\212\327\137\365\371\306\075\351\231\167\203\265'
|
||
printf '\034\363\171\054\143\140\027\346\334\317\151\015\273\137\015\052'
|
||
printf '\036\164\142\002\276\377\235\014\077\172\324\303\363\210\054\146'
|
||
printf '\230\166\351\073\152\230\163\321\172\211\252\350\315\062\337\353'
|
||
printf '\010\170\342\077\075\106\206\355\234\233\161\076\230\263\240\043'
|
||
printf '\214\031\240\175\173\145\152\036\032\324\074\371\003\217\367\017'
|
||
printf '\330\067\005\164\241\230\241\310\202\347\121\302\254\200\366\126'
|
||
printf '\125\121\220\307\307\064\273\136\360\331\273\333\267\156\162\376'
|
||
printf '\205\142\236\052\071\042\212\271\256\026\066\266\124\006\350\124'
|
||
printf '\022\366\276\342\363\323\347\275\311\155\043\052\015\363\014\353'
|
||
printf '\103\107\003\063\300\366\126\047\362\365\363\351\076\315\153\257'
|
||
printf '\372\274\361\277\176\150\377\223\112\304\074\231\241\243\210\031'
|
||
printf '\240\275\065\232\210\203\000\336\077\030\260\147\227\317\221\017'
|
||
printf '\202\374\173\154\053\026\163\136\015\035\055\314\150\115\133\153'
|
||
printf '\164\322\163\046\003\235\037\004\034\354\010\070\360\156\300\350'
|
||
printf '\210\371\013\047\226\032\363\264\032\072\172\230\033\032\240\245'
|
||
printf '\371\302\353\347\203\357\005\274\370\142\100\135\035\264\266\052'
|
||
printf '\132\267\071\264\264\250\045\137\374\305\363\262\127\365\076\354'
|
||
printf '\011\350\374\040\373\360\062\347\007\256\322\060\237\253\241\043'
|
||
printf '\204\171\332\025\224\266\155\316\005\241\073\370\136\300\263\317'
|
||
printf '\371\364\116\133\344\173\377\317\001\174\352\152\241\245\105\321'
|
||
printf '\334\254\150\151\161\330\260\101\261\252\011\226\057\127\270\356'
|
||
printf '\371\303\035\032\324\014\016\150\006\007\240\277\057\213\370\330'
|
||
printf '\121\215\357\231\275\101\217\151\230\321\305\232\302\010\140\126'
|
||
printf '\100\333\002\207\353\162\220\173\172\364\214\050\022\011\070\162'
|
||
printf '\104\163\344\210\106\021\136\045\164\371\162\305\362\006\250\157'
|
||
printf '\310\146\361\332\132\160\334\354\377\357\145\262\263\334\222\051'
|
||
printf '\215\237\201\261\121\030\031\321\223\065\260\311\073\264\332\200'
|
||
printf '\271\260\051\214\010\146\200\366\266\363\253\237\273\272\065\117'
|
||
printf '\077\355\323\171\070\230\067\212\142\133\071\217\014\153\106\206'
|
||
printf '\147\050\343\346\015\116\060\057\004\163\270\051\214\020\346\145'
|
||
printf '\313\024\353\327\251\005\101\136\050\346\205\325\372\202\171\061'
|
||
printf '\061\117\065\205\021\302\234\035\256\233\273\151\353\352\326\374'
|
||
printf '\317\323\076\207\017\007\347\215\102\060\233\211\071\333\024\106'
|
||
printf '\014\063\100\333\054\363\067\162\220\073\017\057\154\216\203\140'
|
||
printf '\066\027\363\264\141\273\350\140\126\100\333\166\065\053\344\205'
|
||
printf '\242\020\314\146\143\056\154\012\043\200\171\305\012\305\272\265'
|
||
printf '\152\106\310\202\071\272\230\303\115\141\004\060\003\264\237\313'
|
||
printf '\316\305\040\013\346\150\143\016\225\034\121\300\234\213\173\356'
|
||
printf '\315\320\123\144\007\132\301\034\155\314\152\266\032\332\126\314'
|
||
printf '\157\354\013\026\011\234\140\266\015\063\314\266\151\220\205\230'
|
||
printf '\027\017\234\140\266\021\063\314\264\151\220\140\026\314\026\142'
|
||
printf '\056\134\306\100\060\013\146\213\061\207\227\061\020\314\202\331'
|
||
printf '\162\314\114\007\055\230\005\263\355\230\247\232\102\301\054\230'
|
||
printf '\043\200\071\333\024\012\146\301\034\021\314\060\327\372\320\202'
|
||
printf '\131\060\133\204\171\366\365\241\005\263\140\266\014\363\124\015'
|
||
printf '\055\230\005\163\004\060\147\153\150\301\054\230\043\202\271\240'
|
||
printf '\206\026\314\202\331\146\314\063\067\205\202\131\060\133\210\131'
|
||
printf '\351\142\115\241\140\026\314\226\142\056\154\012\005\263\140\266'
|
||
printf '\030\163\270\051\024\314\202\331\162\314\123\065\264\140\026\314'
|
||
printf '\021\300\254\320\070\202\131\060\107\005\163\150\224\103\060\013'
|
||
printf '\146\333\061\027\066\205\202\131\060\133\214\071\334\024\012\146'
|
||
printf '\301\154\071\346\120\311\041\230\005\263\355\230\347\236\155\047'
|
||
printf '\230\005\263\105\230\147\254\241\005\263\140\266\021\163\321\032'
|
||
printf '\132\060\013\146\133\061\317\153\031\003\301\054\230\155\301\074'
|
||
printf '\347\062\006\202\131\060\333\204\071\064\312\041\230\005\263\355'
|
||
printf '\230\247\232\102\301\054\230\043\200\071\333\024\012\146\301\034'
|
||
printf '\021\314\060\333\055\130\202\131\060\133\206\271\260\051\024\314'
|
||
printf '\202\331\142\314\341\246\120\060\013\146\313\061\117\065\205\202'
|
||
printf '\131\060\107\000\163\266\051\024\314\202\071\042\230\231\261\206'
|
||
printf '\026\314\202\331\102\314\305\147\333\011\146\301\154\051\346\311'
|
||
printf '\271\034\202\131\060\107\001\163\270\206\026\314\202\331\162\314'
|
||
printf '\123\065\264\140\026\314\021\300\234\255\241\005\263\140\216\010'
|
||
printf '\146\200\377\007\270\201\346\037\275\317\201\136\000\000\000\000'
|
||
printf '\111\105\116\104\256\102\140\202'
|
||
} > "$STAGE/apple-touch-icon.png"
|
||
mkdir -p "$STAGE/cgi-bin"
|
||
cat > "$STAGE/cgi-bin/chat" <<'__CABINCHAT_EOF__'
|
||
#!/bin/sh
|
||
# Cabin Chat backend - CGI script for uhttpd (OpenWrt) or devserver.py.
|
||
# Needs only POSIX sh + busybox tools.
|
||
#
|
||
# Layout (APP = /www-chat on the router, the project folder when developing):
|
||
# APP/htdocs/ web root: index.html, cgi-bin/chat, img/ (photos)
|
||
# APP/data/messages one message per line, 8 TAB-separated fields:
|
||
# id ts type from to re nick payload
|
||
# type t: payload = text
|
||
# type i: payload = "<file> <width> <height>" (file in img/)
|
||
# to: "*" = everyone, otherwise the recipient's user id
|
||
# re: id of the quoted message, 0 = none
|
||
# APP/data/seq last message id (never decreases)
|
||
# APP/data/gen bumped when messages are deleted (clients reload)
|
||
# APP/data/accounts/UID "namehex salt sha256(salt+password) avatar-version|-"
|
||
# APP/data/names/LNAME UID (LNAME = hex of the ASCII-lowercased name)
|
||
# APP/data/sessions/TOK "UID created" - one per logged-in device
|
||
# APP/data/avatars/UID.jpg
|
||
# /tmp/cabinchat/ volatile state: presence, typing, link codes, event token
|
||
# data/ is outside the web root, so private messages can't be downloaded directly;
|
||
# photo file names contain a random part, so they can't be guessed.
|
||
#
|
||
# Identity: an account is a name + password. Logging in (or redeeming a link code
|
||
# from another device) gives the browser a random session token (k, 32 hex).
|
||
# A user id (UID, 16 hex) is public; tokens are never sent to other users.
|
||
#
|
||
# API (k = session token)
|
||
# GET chat?k=K&since=ID&ev=TOKEN&w=1
|
||
# Long poll: if nothing changed since TOKEN, waits up to HOLD seconds.
|
||
# Reply: @now <TAB> lastid <TAB> token <TAB> my-uid <TAB> gen
|
||
# U <TAB> uid <TAB> namehex <TAB> last-seen <TAB> avatar-version|-
|
||
# W <TAB> uid <TAB> to <TAB> ts (who is typing)
|
||
# messages with since < id <= lastid that this user may see
|
||
# GET chat?a=avatar&u=UID profile picture (JPEG)
|
||
# GET chat?a=check&n=NAMEHEX "1" if the name is taken, else "0"
|
||
# GET chat?a=ping "@cabinchat VERSION" (installer self-test)
|
||
# POST chat?a=login&n=NAMEHEX[&ok=OLDKEY] body: password -> "token <TAB> uid <TAB> new"
|
||
# unknown name: creates the account; OLDKEY (a 3.x browser key) keeps its old id
|
||
# POST chat?a=redeem&c=CODE -> "token <TAB> uid" (link a device)
|
||
# POST chat?a=link&k=K -> "code <TAB> seconds-valid"
|
||
# POST chat?a=logout&k=K
|
||
# POST chat?a=passwd&k=K body: old-password LF new-password
|
||
# POST chat?a=delete&k=K body: password (removes account + posts)
|
||
# POST chat?a=avatar&k=K body: JPEG
|
||
# POST chat?a=noavatar&k=K
|
||
# POST chat?a=text&k=K&to=*|UID&re=ID body: UTF-8 text
|
||
# POST chat?a=img&k=K&to=*|UID&re=ID&w=W&h=H&r=RND body: JPEG
|
||
# POST chat?a=typing&k=K&to=*|UID|- (- = stopped)
|
||
#
|
||
# Timestamps come from the router's clock; clients only show relative ages.
|
||
# To keep that clock sane after a power cut (no RTC, no NTP in the air), the
|
||
# script touches CLOCK in /etc every few minutes: OpenWrt's sysfixtime sets the
|
||
# clock at boot to the newest file time found in /etc.
|
||
|
||
KEEP=86400 # rolling window: 24 h
|
||
HOLD=25 # long-poll hold time, seconds
|
||
ONLINE=70 # seen within this many seconds = online (clients do the math)
|
||
TYPING=8 # a typing notice lives this long
|
||
LINK_TTL=600 # a "link a device" code is valid this long
|
||
MAX_TEXT=4000 # bytes per text message
|
||
MAX_IMG=400000 # bytes per photo (the client aims for ~100 kB)
|
||
MAX_AVATAR=100000 # bytes per profile picture (the client sends ~20 kB)
|
||
MAX_NAME=192 # hex digits per name (the client allows 24 characters)
|
||
MAX_DATA_KB=51200 # refuse new photos once img/ exceeds 50 MB
|
||
|
||
case $0 in */*) WEB=${0%/*}; WEB=${WEB%/*} ;; *) WEB=.. ;; esac
|
||
DATA=${CABINCHAT_DATA:-$WEB/../data}
|
||
IMG=$WEB/img
|
||
LOG=$DATA/messages
|
||
SEQ=$DATA/seq
|
||
GEN=$DATA/gen
|
||
ACC=$DATA/accounts
|
||
NAMES=$DATA/names
|
||
SESS=$DATA/sessions
|
||
AVA=$DATA/avatars
|
||
RUN=${TMPDIR:-/tmp}/cabinchat
|
||
EV=$RUN/ev
|
||
LOCKDIR=$RUN/lock
|
||
CLOCK=${CABINCHAT_CLOCK-/etc/cabinchat.clock}
|
||
NOW=$(date +%s)
|
||
NL='
|
||
'
|
||
qs="&$QUERY_STRING&"
|
||
me=
|
||
|
||
# ---------------------------------------------------------------- helpers
|
||
hdr() { printf 'Status: %s\r\nContent-Type: text/plain; charset=utf-8\r\nCache-Control: no-store\r\n\r\n' "$1"; }
|
||
fail() { hdr "$1"; echo "$2"; exit 0; }
|
||
ok() { hdr "200 OK"; printf '%s\n' "${1:-ok}"; exit 0; }
|
||
|
||
# get NAME -> $v (raw value from the query string, empty if missing)
|
||
get() { v=${qs#*"&$1="}; if [ "$v" = "$qs" ]; then v=; else v=${v%%&*}; fi; }
|
||
|
||
num() { case $1 in ''|*[!0-9]*) return 1 ;; esac; }
|
||
hex() { case $1 in ''|*[!0-9a-f]*) return 1 ;; esac; }
|
||
pubid() { hex "$1" && [ ${#1} -eq 16 ]; }
|
||
tok32() { hex "$1" && [ ${#1} -eq 32 ]; }
|
||
|
||
take_lock() {
|
||
i=0
|
||
while ! mkdir "$LOCKDIR" 2>/dev/null; do
|
||
i=$((i + 1))
|
||
[ $i -gt 50 ] && { rm -rf "$LOCKDIR"; i=0; } # stale lock
|
||
sleep 0.1 2>/dev/null || sleep 1
|
||
done
|
||
}
|
||
drop_lock() { rmdir "$LOCKDIR" 2>/dev/null; }
|
||
|
||
# something changed: wakes up every waiting long poll
|
||
bump() { echo "$NOW.$$" > "$EV"; }
|
||
|
||
read_body() {
|
||
if head -c 1 </dev/null >/dev/null 2>&1; then head -c "$cl"; else cat; fi
|
||
}
|
||
body_len() { # max-bytes -> $cl, fails if missing or too long
|
||
cl=${CONTENT_LENGTH:-0}; num "$cl" || cl=0
|
||
[ "$cl" -gt 0 ] || fail "400 Bad Request" "empty"
|
||
[ "$cl" -le "$1" ] || fail "413 Payload Too Large" "too large"
|
||
}
|
||
|
||
hash16() {
|
||
if command -v md5sum >/dev/null 2>&1; then printf '%s' "$1" | md5sum | cut -c 1-16
|
||
elif command -v md5 >/dev/null 2>&1; then printf '%s' "$1" | md5 -q | cut -c 1-16
|
||
else printf '%016x\n' "$(printf '%s' "$1" | cksum | cut -d ' ' -f 1)"
|
||
fi
|
||
}
|
||
sha() {
|
||
if command -v sha256sum >/dev/null 2>&1; then sha256sum | cut -c 1-64
|
||
elif command -v shasum >/dev/null 2>&1; then shasum -a 256 | cut -c 1-64
|
||
else openssl dgst -sha256 -r | cut -c 1-64
|
||
fi
|
||
}
|
||
rnd() { # N -> N random hex digits (N <= 64)
|
||
{ dd if=/dev/urandom bs=32 count=1 2>/dev/null; date; echo "$$"; } | sha | cut -c "1-$1"
|
||
}
|
||
pwhash() { printf '%s%s' "$1" "$2" | sha; } # salt password
|
||
|
||
# hex of a UTF-8 name -> same with ASCII A-Z lowercased (hex 41-5a -> 61-7a)
|
||
lower() {
|
||
printf '%s\n' "$1" | awk '{
|
||
s = ""
|
||
for (i = 1; i <= length($0); i += 2) {
|
||
p = substr($0, i, 2)
|
||
if (p >= "41" && p <= "5a") p = (substr(p, 1, 1) == "4" ? "6" : "7") substr(p, 2, 1)
|
||
s = s p
|
||
}
|
||
print s
|
||
}'
|
||
}
|
||
valid_name() { hex "$1" && [ $((${#1} % 2)) -eq 0 ] && [ ${#1} -le $MAX_NAME ]; }
|
||
|
||
# UID -> a_name a_salt a_hash a_ava
|
||
read_account() {
|
||
a_name=; a_salt=; a_hash=; a_ava=
|
||
[ -f "$ACC/$1" ] && read -r a_name a_salt a_hash a_ava < "$ACC/$1"
|
||
[ -n "$a_hash" ]
|
||
}
|
||
write_account() { # UID name salt hash avatar
|
||
printf '%s %s %s %s\n' "$2" "$3" "$4" "${5:--}" > "$ACC/$1.tmp" && mv "$ACC/$1.tmp" "$ACC/$1"
|
||
}
|
||
|
||
new_session() { # UID -> $tok
|
||
tok=$(rnd 32)
|
||
printf '%s %s\n' "$1" "$NOW" > "$SESS/$tok"
|
||
}
|
||
|
||
# k -> $me (user id), $nick (name hex); 401 makes the client show the login
|
||
identify() {
|
||
get k; tok=$v
|
||
tok32 "$tok" && [ -f "$SESS/$tok" ] || fail "401 Unauthorized" "login"
|
||
read -r me _ < "$SESS/$tok"
|
||
if ! pubid "$me" || ! read_account "$me"; then
|
||
rm -f "$SESS/$tok"
|
||
fail "401 Unauthorized" "login"
|
||
fi
|
||
nick=$a_name
|
||
}
|
||
|
||
# record that $me is here; wake everybody if that is news
|
||
seen_me() {
|
||
f=$RUN/seen/$me; ps=0
|
||
[ -f "$f" ] && read -r ps < "$f"
|
||
num "$ps" || ps=0
|
||
printf '%s\n' "$NOW" > "$f"
|
||
[ "$ps" -ge $((NOW - ONLINE + 20)) ] || bump
|
||
}
|
||
|
||
# a power cut can leave a half-written last line: make sure we start on a new one
|
||
ensure_nl() { [ -s "$LOG" ] && [ -n "$(tail -c 1 "$LOG")" ] && echo >> "$LOG"; }
|
||
|
||
next_id() {
|
||
id=$(cat "$SEQ" 2>/dev/null)
|
||
if ! num "$id"; then
|
||
id=$(tail -n 1 "$LOG" 2>/dev/null | cut -f 1)
|
||
num "$id" || id=0
|
||
fi
|
||
id=$((id + 1))
|
||
printf '%s\n' "$id" > "$SEQ.tmp" && mv "$SEQ.tmp" "$SEQ"
|
||
}
|
||
|
||
read_seq() { lastid=0; [ -f "$SEQ" ] && read -r lastid < "$SEQ"; num "$lastid" || lastid=0; }
|
||
read_gen() { gen=0; [ -f "$GEN" ] && read -r gen < "$GEN"; num "$gen" || gen=0; }
|
||
next_gen() { read_gen; printf '%s\n' $((gen + 1)) > "$GEN.tmp" && mv "$GEN.tmp" "$GEN"; }
|
||
|
||
needs_prune() {
|
||
[ -s "$LOG" ] || return 1
|
||
first=$(head -n 1 "$LOG" | cut -f 2)
|
||
num "$first" || return 0
|
||
[ "$first" -lt $((NOW - KEEP)) ]
|
||
}
|
||
|
||
# delete the photos listed in DATA/.del (written by the awk filters below)
|
||
del_photos() {
|
||
[ -f "$DATA/.del" ] || return 0
|
||
while IFS= read -r f; do
|
||
case $f in .*|*[!0-9a-f.-]*) ;; *.jpg) rm -f "$IMG/$f" ;; esac
|
||
done < "$DATA/.del"
|
||
rm -f "$DATA/.del"
|
||
}
|
||
|
||
# drop expired (and malformed) lines, delete their photos; call with lock held
|
||
prune() {
|
||
needs_prune || return 0
|
||
awk -F '\t' -v c=$((NOW - KEEP)) -v del="$DATA/.del" '
|
||
NF == 8 && $1 ~ /^[0-9]+$/ && $2 >= c { print; next }
|
||
$3 == "i" { split($8, a, " "); print a[1] > del }
|
||
' "$LOG" > "$LOG.tmp" && mv "$LOG.tmp" "$LOG"
|
||
del_photos
|
||
# photos whose message line never got written (power cut during upload)
|
||
find "$IMG" -type f -mtime +2 -exec rm -f {} \; 2>/dev/null
|
||
}
|
||
|
||
touch_clock() {
|
||
[ -n "$CLOCK" ] || return 0
|
||
last=$(cat "$CLOCK" 2>/dev/null); num "$last" || last=0
|
||
[ $((NOW - last)) -ge 300 ] || return 0
|
||
printf '%s\n' "$NOW" > "$CLOCK.tmp" && mv "$CLOCK.tmp" "$CLOCK"
|
||
}
|
||
|
||
append() { # type payload
|
||
ensure_nl
|
||
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$id" "$NOW" "$1" "$me" "$to" "$re" "$nick" "$2" >> "$LOG"
|
||
}
|
||
|
||
# body = JPEG of at most $1 bytes -> file $2 (or fail)
|
||
save_jpeg() {
|
||
body_len "$1"
|
||
read_body > "$2.$$"
|
||
size=$(wc -c < "$2.$$"); size=$((size))
|
||
if [ "$size" -ne "$cl" ]; then rm -f "$2.$$"; fail "400 Bad Request" "incomplete upload"; fi
|
||
if [ "$(head -c 3 "$2.$$")" != "$(printf '\377\330\377')" ]; then
|
||
rm -f "$2.$$"; fail "415 Unsupported Media Type" "JPEG expected"
|
||
fi
|
||
mv "$2.$$" "$2"
|
||
}
|
||
|
||
for d in "$DATA" "$IMG" "$ACC" "$NAMES" "$SESS" "$AVA" "$RUN/seen" "$RUN/typing" "$RUN/links"; do
|
||
[ -d "$d" ] || mkdir -p "$d" || fail "500 Internal Server Error" "cannot create $d"
|
||
done
|
||
[ -f "$EV" ] || bump
|
||
get a; act=$v
|
||
|
||
# ---------------------------------------------------------------- public GETs
|
||
if [ "$REQUEST_METHOD" != POST ]; then
|
||
case $act in
|
||
avatar)
|
||
get u; u=$v
|
||
pubid "$u" && [ -f "$AVA/$u.jpg" ] || fail "404 Not Found" "no picture"
|
||
printf 'Status: 200 OK\r\nContent-Type: image/jpeg\r\nCache-Control: max-age=31536000, immutable\r\n\r\n'
|
||
cat "$AVA/$u.jpg"
|
||
exit 0 ;;
|
||
check)
|
||
get n; valid_name "$v" || fail "400 Bad Request" "bad name"
|
||
[ -f "$NAMES/$(lower "$v")" ] && ok 1 || ok 0 ;;
|
||
ping)
|
||
ok "@cabinchat $(cat "$WEB/VERSION" 2>/dev/null)" ;;
|
||
esac
|
||
fi
|
||
|
||
# ---------------------------------------------------------------- POST
|
||
if [ "$REQUEST_METHOD" = POST ]; then
|
||
case $act in
|
||
login)
|
||
get n; name=$v
|
||
valid_name "$name" || fail "400 Bad Request" "bad name"
|
||
body_len 1024
|
||
pw=$(read_body)
|
||
[ -n "$pw" ] || fail "400 Bad Request" "empty password"
|
||
lk=$(lower "$name")
|
||
take_lock
|
||
uid=; [ -f "$NAMES/$lk" ] && read -r uid < "$NAMES/$lk"
|
||
if pubid "$uid" && read_account "$uid"; then
|
||
drop_lock
|
||
if [ "$(pwhash "$a_salt" "$pw")" != "$a_hash" ]; then
|
||
sleep 1 # slows down guessing
|
||
fail "403 Forbidden" "wrong password"
|
||
fi
|
||
new=0
|
||
else
|
||
# new account; a 3.x browser hands in its old key to keep its id (and messages)
|
||
get ok; uid=
|
||
tok32 "$v" && uid=$(hash16 "$v")
|
||
while ! pubid "$uid" || [ -f "$ACC/$uid" ]; do uid=$(rnd 16); done
|
||
salt=$(rnd 16)
|
||
write_account "$uid" "$name" "$salt" "$(pwhash "$salt" "$pw")" -
|
||
printf '%s\n' "$uid" > "$NAMES/$lk"
|
||
drop_lock
|
||
bump
|
||
new=1
|
||
fi
|
||
new_session "$uid"
|
||
ok "$tok $uid $new" ;;
|
||
|
||
redeem)
|
||
get c; code=$v
|
||
tok32 "$code" && [ -f "$RUN/links/$code" ] || fail "403 Forbidden" "invalid link"
|
||
read -r uid ts < "$RUN/links/$code"
|
||
rm -f "$RUN/links/$code" # one device per code
|
||
num "$ts" && [ "$ts" -ge $((NOW - LINK_TTL)) ] || fail "403 Forbidden" "link expired"
|
||
pubid "$uid" && read_account "$uid" || fail "403 Forbidden" "account deleted"
|
||
new_session "$uid"
|
||
ok "$tok $uid" ;;
|
||
esac
|
||
|
||
identify
|
||
seen_me
|
||
get to; to=$v
|
||
|
||
case $act in
|
||
typing)
|
||
case $to in
|
||
-) rm -f "$RUN/typing/$me" ;;
|
||
'*') printf '* %s\n' "$NOW" > "$RUN/typing/$me" ;;
|
||
*) pubid "$to" || fail "400 Bad Request" "bad recipient"
|
||
printf '%s %s\n' "$to" "$NOW" > "$RUN/typing/$me" ;;
|
||
esac
|
||
bump
|
||
ok ;;
|
||
|
||
logout)
|
||
rm -f "$SESS/$tok"
|
||
ok ;;
|
||
|
||
link)
|
||
for f in "$RUN"/links/*; do # forget expired codes
|
||
[ -f "$f" ] || continue
|
||
read -r u ts < "$f"
|
||
num "$ts" && [ "$ts" -ge $((NOW - LINK_TTL)) ] || rm -f "$f"
|
||
done
|
||
code=$(rnd 32)
|
||
printf '%s %s\n' "$me" "$NOW" > "$RUN/links/$code"
|
||
ok "$code $LINK_TTL" ;;
|
||
|
||
passwd)
|
||
body_len 2048
|
||
body=$(read_body)
|
||
old=${body%%"$NL"*}; pw=${body#*"$NL"}
|
||
[ "$old" != "$body" ] && [ -n "$pw" ] || fail "400 Bad Request" "bad request"
|
||
take_lock
|
||
read_account "$me"
|
||
if [ "$(pwhash "$a_salt" "$old")" != "$a_hash" ]; then
|
||
drop_lock; sleep 1; fail "403 Forbidden" "wrong password"
|
||
fi
|
||
salt=$(rnd 16)
|
||
write_account "$me" "$a_name" "$salt" "$(pwhash "$salt" "$pw")" "$a_ava"
|
||
drop_lock
|
||
ok ;;
|
||
|
||
delete)
|
||
body_len 1024
|
||
pw=$(read_body)
|
||
[ "$(pwhash "$a_salt" "$pw")" = "$a_hash" ] || { sleep 1; fail "403 Forbidden" "wrong password"; }
|
||
take_lock
|
||
rm -f "$ACC/$me" "$NAMES/$(lower "$nick")" "$AVA/$me.jpg" "$RUN/seen/$me" "$RUN/typing/$me"
|
||
for f in "$SESS"/*; do
|
||
[ -f "$f" ] || continue
|
||
read -r u _ < "$f"
|
||
[ "$u" = "$me" ] && rm -f "$f"
|
||
done
|
||
# everything this user posted goes too
|
||
if [ -s "$LOG" ]; then
|
||
awk -F '\t' -v me="$me" -v del="$DATA/.del" '
|
||
$4 == me { if ($3 == "i") { split($8, a, " "); print a[1] > del }; next }
|
||
{ print }
|
||
' "$LOG" > "$LOG.tmp" && mv "$LOG.tmp" "$LOG"
|
||
del_photos
|
||
fi
|
||
next_gen
|
||
drop_lock
|
||
bump
|
||
ok ;;
|
||
|
||
avatar|noavatar)
|
||
ver=-
|
||
if [ "$act" = avatar ]; then
|
||
save_jpeg $MAX_AVATAR "$AVA/$me.jpg"
|
||
ver=$(rnd 8)
|
||
else
|
||
rm -f "$AVA/$me.jpg"
|
||
fi
|
||
take_lock
|
||
read_account "$me" && write_account "$me" "$a_name" "$a_salt" "$a_hash" "$ver"
|
||
drop_lock
|
||
bump
|
||
ok "$ver" ;;
|
||
|
||
text|img)
|
||
[ "$to" = '*' ] || pubid "$to" || fail "400 Bad Request" "bad recipient"
|
||
get re; re=$v; num "$re" || re=0
|
||
if [ "$act" = text ]; then
|
||
body_len $MAX_TEXT
|
||
msg=$(read_body | tr '\t\r\n' ' ')
|
||
case $msg in *[![:space:]]*) ;; *) fail "400 Bad Request" "empty" ;; esac
|
||
take_lock; prune; next_id; append t "$msg"; drop_lock
|
||
else
|
||
used=$(du -sk "$IMG" 2>/dev/null | cut -f 1); num "$used" || used=0
|
||
[ "$used" -lt $MAX_DATA_KB ] || fail "507 Insufficient Storage" "storage full"
|
||
get w; w=$v; num "$w" || w=0
|
||
get h; h=$v; num "$h" || h=0
|
||
get r; rnd=$v
|
||
hex "$rnd" && [ ${#rnd} -eq 16 ] || fail "400 Bad Request" "bad r"
|
||
save_jpeg $MAX_IMG "$IMG/.upload-$$"
|
||
take_lock; prune; next_id
|
||
mv "$IMG/.upload-$$" "$IMG/$id-$rnd.jpg"
|
||
append i "$id-$rnd.jpg $w $h"
|
||
drop_lock
|
||
fi
|
||
rm -f "$RUN/typing/$me"
|
||
bump
|
||
touch_clock
|
||
ok "$id" ;;
|
||
|
||
*) fail "400 Bad Request" "unknown action" ;;
|
||
esac
|
||
fi
|
||
|
||
# ---------------------------------------------------------------- GET (long poll)
|
||
identify
|
||
seen_me
|
||
get since; since=$v; num "$since" || since=0
|
||
get ev; cev=$v
|
||
get w; wait=$v
|
||
if needs_prune; then take_lock; prune; drop_lock; fi
|
||
read_seq
|
||
read -r ev < "$EV"
|
||
|
||
if [ "$wait" = 1 ] && [ "$cev" = "$ev" ] && [ "$since" -ge "$lastid" ]; then
|
||
# nothing new: hold the request until something changes or HOLD runs out.
|
||
# Only builtins (read) and sleep run in this loop.
|
||
if sleep 0.01 2>/dev/null; then step=0.5; loops=$((HOLD * 2)); else step=1; loops=$HOLD; fi
|
||
while [ $loops -gt 0 ]; do
|
||
sleep $step
|
||
read -r ev < "$EV"
|
||
[ "$ev" != "$cev" ] && break
|
||
loops=$((loops - 1))
|
||
done
|
||
NOW=$(date +%s)
|
||
read_seq
|
||
[ -f "$ACC/$me" ] && printf '%s\n' "$NOW" > "$RUN/seen/$me"
|
||
fi
|
||
|
||
read_gen
|
||
touch_clock
|
||
hdr "200 OK"
|
||
printf '@%s\t%s\t%s\t%s\t%s\n' "$NOW" "$lastid" "$ev" "$me" "$gen"
|
||
|
||
for f in "$ACC"/*; do
|
||
[ -f "$f" ] || continue
|
||
u=${f##*/}
|
||
pubid "$u" || continue
|
||
read -r n _ _ av < "$f"
|
||
s=0; [ -f "$RUN/seen/$u" ] && read -r s < "$RUN/seen/$u"
|
||
num "$s" || s=0
|
||
printf 'U\t%s\t%s\t%s\t%s\n' "$u" "$n" "$s" "${av:--}"
|
||
done
|
||
|
||
for f in "$RUN"/typing/*; do
|
||
[ -f "$f" ] || continue
|
||
p=${f##*/}
|
||
[ "$p" = "$me" ] && continue
|
||
read -r t ts < "$f"
|
||
num "$ts" || continue
|
||
[ "$ts" -ge $((NOW - TYPING)) ] || continue
|
||
case $t in '*'|"$me") printf 'W\t%s\t%s\t%s\n' "$p" "$t" "$ts" ;; esac
|
||
done
|
||
|
||
if [ "$since" -lt "$lastid" ] && [ -s "$LOG" ]; then
|
||
awk -F '\t' -v s="$since" -v l="$lastid" -v me="$me" '
|
||
NF == 8 && $1 ~ /^[0-9]+$/ && $1 + 0 > s + 0 && $1 + 0 <= l + 0 &&
|
||
($5 == "*" || $5 == me || $4 == me)
|
||
' "$LOG"
|
||
fi
|
||
__CABINCHAT_EOF__
|
||
{
|
||
printf '\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122'
|
||
printf '\000\000\000\300\000\000\000\300\010\006\000\000\000\122\334\154'
|
||
printf '\007\000\000\034\332\111\104\101\124\170\332\355\335\171\220\034'
|
||
printf '\325\235\340\361\357\313\314\252\076\324\167\113\215\016\044\001'
|
||
printf '\072\221\144\151\014\302\306\003\036\015\267\261\147\006\143\073'
|
||
printf '\026\306\036\360\072\030\033\143\033\074\023\304\030\011\074\313'
|
||
printf '\072\114\330\343\205\011\154\031\314\310\346\076\274\230\163\327'
|
||
printf '\013\346\030\201\070\045\020\207\006\335\047\152\251\045\013\251'
|
||
printf '\357\273\273\052\363\375\366\217\352\352\103\135\175\251\253\262'
|
||
printf '\062\253\337\057\242\102\250\110\125\126\145\176\176\371\336\057'
|
||
printf '\363\345\113\045\042\144\073\276\260\212\271\236\170\213\121\152'
|
||
printf '\276\102\346\003\363\101\125\040\062\011\105\231\202\042\040\102'
|
||
printf '\277\257\252\122\174\316\240\367\144\224\313\365\177\357\204\327'
|
||
printf '\041\243\133\307\130\077\037\120\222\341\337\060\342\072\344\104'
|
||
printf '\326\021\007\332\200\046\240\035\241\301\202\335\210\332\255\055'
|
||
printf '\157\227\255\331\366\340\352\274\175\331\266\247\262\221\000\347'
|
||
printf '\255\342\024\133\171\027\050\341\074\340\074\140\172\346\140\032'
|
||
printf '\374\131\300\077\312\175\241\376\014\362\052\302\072\127\173\257'
|
||
printf '\074\166\127\376\201\234\115\200\213\126\122\212\355\135\046\232'
|
||
printf '\253\024\134\160\374\166\062\370\047\032\376\224\177\377\100\340'
|
||
printf '\221\170\044\362\330\357\357\240\056\047\022\340\374\225\361\145'
|
||
printf '\266\145\335\044\360\025\204\074\377\140\032\374\041\303\337\177'
|
||
printf '\035\135\112\361\214\126\362\213\207\176\031\335\034\312\004\270'
|
||
printf '\150\025\237\306\362\126\211\360\065\100\371\013\323\340\017\061'
|
||
printf '\376\001\357\011\254\125\360\257\017\254\216\274\023\212\004\270'
|
||
printf '\340\307\314\126\132\176\011\372\313\331\201\151\360\347\012\376'
|
||
printf '\376\313\211\122\117\053\067\376\317\367\337\135\120\023\310\004'
|
||
printf '\130\176\055\221\262\311\372\173\010\267\201\024\031\374\006\177'
|
||
printf '\272\360\367\213\016\245\344\366\111\022\375\371\352\325\164\007'
|
||
printf '\046\001\056\274\231\105\202\376\203\202\045\003\266\230\301\157'
|
||
printf '\360\247\017\177\337\157\120\154\266\074\271\362\167\167\107\167'
|
||
printf '\214\327\256\065\356\042\367\026\357\152\101\157\064\370\015\176'
|
||
printf '\137\360\047\376\335\122\155\251\017\256\271\041\376\355\254\265'
|
||
printf '\000\137\274\201\274\256\042\275\106\301\067\007\001\061\370\015'
|
||
printf '\376\114\341\037\274\315\357\157\231\022\271\356\211\133\211\371'
|
||
printf '\226\000\347\375\204\042\273\133\236\022\344\022\203\337\340\317'
|
||
printf '\032\376\276\217\173\265\133\105\056\177\164\065\055\031\117\200'
|
||
printf '\013\157\246\022\361\236\023\245\316\066\370\015\376\154\343\357'
|
||
printf '\367\336\373\216\033\371\322\075\367\160\054\143\011\160\311\277'
|
||
printf '\120\345\072\372\015\024\013\014\176\203\077\100\370\223\261\323'
|
||
printf '\123\221\277\272\177\065\265\151\057\202\317\275\211\142\067\242'
|
||
printf '\377\144\360\033\374\001\305\017\042\013\155\035\373\323\367\277'
|
||
printf '\117\121\132\023\340\277\375\204\150\276\055\117\002\147\032\374'
|
||
printf '\006\177\100\361\047\337\133\036\127\361\377\173\303\015\344\245'
|
||
printf '\055\001\352\272\365\157\115\301\153\360\207\000\177\362\215\363'
|
||
printf '\273\274\356\273\323\222\000\027\334\354\175\313\234\352\064\370'
|
||
printf '\303\203\077\271\220\272\346\273\337\217\137\075\256\042\370\302'
|
||
printf '\233\231\057\350\367\025\024\033\374\006\177\150\360\367\275\327'
|
||
printf '\256\205\263\206\273\142\154\015\327\357\027\364\323\006\277\301'
|
||
printf '\037\122\374\000\223\054\305\377\276\366\132\042\143\116\200\272'
|
||
printf '\056\175\243\031\336\140\360\207\030\177\062\226\051\247\373\207'
|
||
printf '\143\352\002\135\362\143\146\172\132\357\000\231\144\360\033\374'
|
||
printf '\041\306\237\134\107\207\243\364\242\273\122\334\162\231\262\005'
|
||
printf '\360\264\254\066\370\015\376\034\301\017\120\350\212\165\307\250'
|
||
printf '\132\200\363\157\346\263\026\336\073\006\277\301\237\043\370\173'
|
||
printf '\303\106\175\346\356\273\043\357\015\333\002\130\170\077\066\370'
|
||
printf '\015\376\134\303\257\000\017\271\171\330\026\340\374\225\361\145'
|
||
printf '\226\145\155\302\334\303\153\360\347\030\376\344\247\151\213\145'
|
||
printf '\153\176\035\335\222\262\005\260\055\353\046\203\337\340\317\121'
|
||
printf '\374\000\312\322\334\224\262\005\370\374\052\312\363\224\167\304'
|
||
printf '\114\135\142\360\347\050\376\344\173\135\171\321\350\264\073\357'
|
||
printf '\244\151\100\013\020\105\137\141\360\033\374\071\216\037\040\077'
|
||
printf '\026\213\177\165\120\027\110\041\127\031\374\006\177\216\343\007'
|
||
printf '\001\021\175\325\200\056\320\171\253\070\305\301\373\030\063\135'
|
||
printf '\241\301\237\343\370\223\377\345\070\336\254\325\253\013\016\131'
|
||
printf '\000\021\274\013\015\176\203\177\202\340\107\201\162\135\347\202'
|
||
printf '\336\056\220\050\316\063\370\015\376\011\202\277\247\357\057\347'
|
||
printf '\365\325\000\302\012\203\337\340\237\050\370\173\336\276\020\100'
|
||
printf '\135\262\122\346\172\170\173\014\176\203\177\242\340\357\373\337'
|
||
printf '\062\307\111\074\231\305\340\317\304\006\267\055\250\050\203\322'
|
||
printf '\142\105\101\036\024\344\201\143\103\141\201\042\057\002\216\223'
|
||
printf '\130\056\356\102\054\006\035\135\102\334\205\356\156\350\352\206'
|
||
printf '\346\126\241\241\011\074\155\360\147\342\100\244\204\105\116\317'
|
||
printf '\143\211\014\376\161\154\360\251\223\025\163\116\206\223\052\025'
|
||
printf '\125\225\120\125\221\370\263\262\114\141\217\163\362\111\317\203'
|
||
printf '\372\046\241\266\036\152\033\204\332\172\341\223\072\250\256\021'
|
||
printf '\216\326\211\301\077\036\117\212\371\216\022\131\060\350\172\261'
|
||
printf '\301\077\344\162\005\171\060\173\272\342\264\223\025\013\117\125'
|
||
printf '\054\232\243\050\055\042\143\141\333\120\325\223\130\307\177\333'
|
||
printf '\216\056\370\370\240\260\373\143\241\272\106\330\123\255\151\153'
|
||
printf '\067\370\307\260\277\027\070\050\346\031\374\303\157\360\331\123'
|
||
printf '\025\313\227\050\316\132\242\230\163\262\102\051\002\021\205\371'
|
||
printf '\260\144\276\142\311\374\236\255\042\066\373\153\204\017\066\153'
|
||
printf '\066\155\025\016\035\021\203\177\330\177\153\315\127\027\255\364'
|
||
printf '\266\202\054\066\370\373\066\270\122\160\352\014\305\362\305\212'
|
||
printf '\163\376\102\061\243\052\040\342\307\030\165\015\302\207\133\204'
|
||
printf '\115\333\064\273\366\012\236\147\360\037\267\216\055\352\242\225'
|
||
printf '\156\065\060\333\340\207\362\022\130\261\334\342\222\277\264\230'
|
||
printf '\122\116\116\105\123\013\274\275\121\363\352\333\232\372\006\061'
|
||
printf '\370\005\004\252\325\105\253\334\172\045\124\114\124\374\112\301'
|
||
printf '\322\271\212\213\316\266\370\314\022\205\155\223\323\041\002\333'
|
||
printf '\167\013\257\255\327\174\360\221\106\353\211\211\277\047\352\035'
|
||
printf '\045\075\363\050\116\060\374\021\007\056\076\333\342\157\376\112'
|
||
printf '\121\125\241\230\050\241\024\054\136\240\130\274\300\246\266\336'
|
||
printf '\342\245\165\232\327\327\153\134\167\302\341\007\050\126\027\257'
|
||
printf '\164\145\042\341\267\155\370\374\247\025\127\134\154\115\050\370'
|
||
printf '\303\105\103\243\360\342\072\315\272\267\064\236\073\141\360\047'
|
||
printf '\256\005\134\174\223\053\023\001\277\122\360\271\245\212\157\134'
|
||
printf '\152\061\165\262\201\237\052\352\033\204\347\136\326\274\371\116'
|
||
printf '\242\153\224\353\370\351\237\000\271\214\177\311\134\305\167\276'
|
||
printf '\142\205\366\154\216\337\161\344\250\360\310\023\036\273\166\113'
|
||
printf '\116\343\357\115\200\134\305\137\134\000\377\360\045\213\013\077'
|
||
printf '\153\005\346\334\175\230\342\375\115\232\107\236\360\150\153\313'
|
||
printf '\115\374\000\116\256\342\077\147\231\342\037\057\267\063\172\225'
|
||
printf '\066\327\143\371\247\055\116\137\140\361\364\037\075\336\134\257'
|
||
printf '\021\311\055\374\000\352\222\176\065\100\056\340\257\050\205\353'
|
||
printf '\257\260\131\066\337\034\362\323\031\333\166\012\017\074\352\321'
|
||
printf '\324\054\271\203\237\343\246\105\011\073\376\305\163\024\167\374'
|
||
printf '\223\143\360\147\040\026\057\124\334\272\322\141\321\102\225\063'
|
||
printf '\370\007\264\000\141\306\257\024\174\351\134\213\157\376\255\065'
|
||
printf '\356\321\227\231\014\117\013\161\127\210\173\202\150\320\075\277'
|
||
printf '\307\122\240\054\210\330\212\210\243\260\255\340\046\260\326\360'
|
||
printf '\374\113\232\377\367\202\207\350\160\343\007\160\302\216\277\060'
|
||
printf '\037\256\277\322\346\263\113\202\207\106\004\072\272\065\035\335'
|
||
printf '\232\256\156\115\334\033\335\023\071\043\266\042\077\317\242\260'
|
||
printf '\347\025\244\002\336\262\340\157\057\265\230\075\023\356\177\330'
|
||
printf '\245\243\043\274\370\021\120\137\070\256\006\010\023\376\151\223'
|
||
printf '\025\377\343\333\026\047\125\006\013\177\334\023\232\333\074\332'
|
||
printf '\272\274\336\363\351\343\001\127\224\157\123\132\144\023\261\203'
|
||
printf '\365\073\153\353\204\137\336\345\122\133\047\241\304\317\361\065'
|
||
printf '\100\230\360\317\234\252\370\351\165\166\240\360\273\236\160\254'
|
||
printf '\311\345\320\261\030\055\035\343\307\237\354\162\264\164\170\034'
|
||
printf '\072\026\243\266\311\305\363\044\060\277\167\312\144\305\115\067'
|
||
printf '\072\314\074\131\205\022\377\300\042\070\104\370\347\315\122\334'
|
||
printf '\366\075\233\212\322\340\034\015\233\333\075\016\325\306\150\353'
|
||
printf '\364\310\004\121\001\132\073\075\152\152\143\064\267\173\201\371'
|
||
printf '\335\045\305\212\033\177\030\141\336\034\025\072\374\220\354\002'
|
||
printf '\205\010\377\322\171\212\225\377\335\046\077\057\030\000\074\055'
|
||
printf '\324\066\271\164\164\217\376\160\337\326\051\324\265\172\304\342'
|
||
printf '\211\277\107\043\060\271\330\246\250\140\364\255\131\101\236\105'
|
||
printf '\125\231\023\230\202\071\026\203\065\367\272\154\335\256\103\203'
|
||
printf '\077\221\000\077\032\345\225\340\000\340\077\363\364\004\376\240'
|
||
printf '\014\131\216\273\302\221\206\070\356\010\335\222\272\026\315\372'
|
||
printf '\035\061\266\036\160\331\165\330\245\255\063\365\362\305\205\212'
|
||
printf '\005\063\034\226\314\166\370\334\302\050\223\113\206\077\245\345'
|
||
printf '\330\212\151\025\021\042\116\060\222\300\365\340\236\065\056\333'
|
||
printf '\266\351\120\340\007\101\135\372\043\127\302\200\177\316\114\305'
|
||
printf '\117\277\033\234\043\177\167\134\370\244\041\216\247\207\306\277'
|
||
printf '\265\332\345\377\274\333\305\226\352\070\172\214\375\042\113\301'
|
||
printf '\322\123\042\174\371\354\174\026\317\166\206\134\316\266\022\111'
|
||
printf '\020\215\004\247\045\270\163\165\234\375\373\045\360\370\201\301'
|
||
printf '\011\020\104\374\047\125\052\176\376\003\233\262\342\340\234\345'
|
||
printf '\371\163\335\320\370\217\064\152\356\173\271\203\055\007\334\264'
|
||
printf '\254\157\351\051\016\327\134\124\310\324\162\153\310\044\230\136'
|
||
printf '\031\234\226\240\255\015\376\327\277\307\071\166\114\202\215\377'
|
||
printf '\370\004\010\042\376\222\111\360\263\037\330\114\237\022\214\235'
|
||
printf '\253\065\034\256\213\015\171\116\377\315\155\161\356\133\333\111'
|
||
printf '\167\074\275\245\160\304\126\174\175\105\036\137\070\043\165\023'
|
||
printf '\030\161\024\063\052\243\130\001\271\020\130\133\047\334\176\207'
|
||
printf '\113\153\253\004\026\077\014\230\036\075\170\370\043\016\334\174'
|
||
printf '\115\160\360\003\324\066\307\123\342\327\032\356\375\317\116\356'
|
||
printf '\171\251\203\230\047\050\213\264\276\134\021\036\176\255\213\373'
|
||
printf '\326\166\246\074\275\032\167\205\143\315\361\300\154\247\051\223'
|
||
printf '\025\327\135\353\340\070\301\305\337\233\000\101\035\333\363\315'
|
||
printf '\277\261\230\077\053\070\370\133\073\074\332\273\164\112\374\277'
|
||
printf '\171\261\223\327\266\305\261\054\225\321\327\272\255\161\176\363'
|
||
printf '\142\352\044\350\350\322\264\166\004\347\024\351\251\247\052\276'
|
||
printf '\174\231\035\130\374\311\132\053\220\370\317\130\250\270\364\234'
|
||
printf '\340\014\354\361\264\320\320\232\032\327\043\157\164\261\161\257'
|
||
printf '\233\161\374\311\327\306\275\056\217\276\331\225\362\273\064\264'
|
||
printf '\172\303\026\346\176\307\371\347\331\054\135\142\005\022\377\200'
|
||
printf '\056\120\220\360\227\025\303\017\256\260\003\065\006\246\251\055'
|
||
printf '\065\254\267\166\304\171\165\153\074\355\135\236\221\136\257\154'
|
||
printf '\211\363\366\116\067\145\242\066\265\005\247\025\120\012\256\272'
|
||
printf '\312\241\264\104\005\016\377\320\303\241\263\210\137\051\370\341'
|
||
printf '\337\007\347\214\117\022\125\113\212\256\105\175\233\360\350\133'
|
||
printf '\061\337\216\374\307\277\036\171\263\233\206\266\301\111\331\322'
|
||
printf '\021\254\126\240\250\010\256\276\072\161\100\013\022\176\044\125'
|
||
printf '\021\234\041\374\212\321\335\311\365\245\163\255\300\215\347\157'
|
||
printf '\151\367\006\335\015\005\360\370\333\061\342\036\131\113\200\270'
|
||
printf '\007\117\154\210\015\372\136\042\211\357\034\244\070\375\164\213'
|
||
printf '\025\053\354\021\075\051\077\360\013\003\007\303\371\201\177\064'
|
||
printf '\237\137\136\014\127\136\022\274\001\375\255\235\203\053\316\203'
|
||
printf '\365\232\217\016\270\130\026\131\175\175\260\337\345\140\235\067'
|
||
printf '\252\357\234\355\370\273\277\263\051\055\125\303\073\361\003\177'
|
||
printf '\312\042\070\313\370\025\360\255\313\154\012\363\203\265\323\272'
|
||
printf '\142\072\345\120\207\227\067\273\140\051\124\000\136\057\157\031'
|
||
printf '\234\000\256\047\164\305\202\225\004\371\371\160\371\345\166\140'
|
||
printf '\360\103\317\015\061\101\300\077\157\226\342\234\145\301\273\251'
|
||
printf '\045\325\040\267\316\230\260\371\240\306\012\310\100\264\217\016'
|
||
printf '\152\072\143\102\101\164\340\367\351\354\326\344\107\203\325\242'
|
||
printf '\056\077\313\342\365\327\025\325\307\017\225\310\002\376\104\021'
|
||
printf '\034\000\374\000\337\370\142\060\247\056\351\212\015\336\162\133'
|
||
printf '\016\171\270\042\131\357\376\044\137\236\010\333\017\173\051\023'
|
||
printf '\065\150\241\024\134\366\145\047\020\370\373\132\200\054\343\137'
|
||
printf '\072\117\361\251\271\301\274\017\266\073\076\270\005\330\363\211'
|
||
printf '\004\346\350\237\214\335\107\205\063\117\035\371\273\007\041\346'
|
||
printf '\315\123\314\137\140\261\147\227\316\052\376\336\004\310\046\176'
|
||
printf '\200\257\134\020\314\073\331\135\117\122\236\375\251\151\000\025'
|
||
printf '\260\004\070\130\117\312\263\101\256\047\070\166\360\016\056\027'
|
||
printf '\137\154\261\147\247\316\052\176\030\363\304\130\351\307\077\157'
|
||
printf '\126\160\217\376\251\306\374\210\100\175\207\004\146\320\131\062'
|
||
printf '\352\333\023\163\034\253\024\111\034\304\004\130\170\272\305\314'
|
||
printf '\131\212\232\203\222\065\374\060\334\225\140\037\360\003\174\361'
|
||
printf '\334\340\316\143\222\152\274\115\227\053\270\072\173\347\376\207'
|
||
printf '\274\046\240\041\026\227\121\375\206\240\304\212\277\266\263\212'
|
||
printf '\137\365\257\001\262\201\277\270\060\061\143\163\120\103\122\364'
|
||
printf '\177\142\256\012\134\377\277\057\071\023\217\137\035\220\000\042'
|
||
printf '\201\335\276\147\054\267\170\366\151\350\150\317\016\376\001\055'
|
||
printf '\200\337\370\001\126\234\141\021\161\202\173\204\112\105\307\323'
|
||
printf '\342\373\270\237\321\276\122\015\177\010\056\177\210\104\140\371'
|
||
printf '\147\354\254\341\037\272\010\366\001\277\022\370\374\031\141\234'
|
||
printf '\302\120\141\005\166\252\351\360\155\317\063\227\133\274\261\316'
|
||
printf '\313\012\176\044\125\021\354\023\376\252\012\305\234\231\341\333'
|
||
printf '\141\112\021\330\056\120\030\247\200\077\345\124\105\105\205\242'
|
||
printf '\161\304\007\367\245\037\377\340\042\330\047\374\000\237\131\242'
|
||
printf '\102\073\147\177\120\273\100\241\334\226\012\076\265\314\312\012'
|
||
printf '\376\201\105\260\217\370\001\226\055\010\357\014\316\226\145\146'
|
||
printf '\237\116\147\054\134\244\170\143\235\377\370\173\153\000\277\361'
|
||
printf '\073\066\054\072\315\044\200\211\104\314\233\147\341\330\340\272'
|
||
printf '\376\342\117\044\200\317\370\001\346\316\122\344\105\303\333\144'
|
||
printf '\133\126\160\277\133\030\043\232\007\063\147\053\252\367\211\257'
|
||
printf '\370\241\267\010\366\017\077\044\256\376\206\071\224\151\001\322'
|
||
printf '\036\263\147\133\124\357\363\174\305\337\323\005\362\027\277\002'
|
||
printf '\346\316\014\067\240\340\166\201\044\264\333\164\326\051\312\167'
|
||
printf '\374\043\136\011\316\004\176\200\231\323\010\171\002\230\043\166'
|
||
printf '\272\143\352\164\345\073\176\030\146\070\164\246\360\053\225\170'
|
||
printf '\260\105\170\373\077\001\156\001\124\170\133\200\252\223\172\116'
|
||
printf '\213\213\177\370\173\023\300\057\374\000\223\313\011\364\360\207'
|
||
printf '\121\370\017\154\015\020\346\216\145\044\002\145\145\212\246\106'
|
||
printf '\361\015\177\277\042\330\037\374\000\225\245\141\057\040\125\200'
|
||
printf '\153\000\025\352\072\240\364\270\004\310\064\176\206\254\001\062'
|
||
printf '\204\037\240\054\007\036\134\155\152\200\314\104\161\011\276\342'
|
||
printf '\127\222\252\006\310\040\176\005\224\024\205\274\005\010\164\015'
|
||
printf '\020\362\004\050\126\276\342\037\134\003\144\030\077\044\036\007'
|
||
printf '\024\366\060\327\001\062\124\007\104\375\305\077\260\006\360\001'
|
||
printf '\077\002\121\047\344\370\323\320\005\262\024\024\347\101\111\317'
|
||
printf '\034\110\055\135\320\322\015\343\275\167\045\354\151\231\352\344'
|
||
printf '\110\046\361\367\325\000\076\341\007\002\363\174\257\361\325\000'
|
||
printf '\047\106\155\126\031\374\345\054\130\062\025\212\216\033\012\322'
|
||
printf '\326\015\133\217\302\372\203\160\260\151\142\266\000\216\343\057'
|
||
printf '\376\104\002\370\210\037\300\363\102\276\227\024\330\143\154\001'
|
||
printf '\046\105\341\253\213\141\351\264\241\217\322\105\171\160\366\054'
|
||
printf '\370\354\054\370\350\010\074\263\015\332\143\023\253\011\160\135'
|
||
printf '\177\361\017\270\022\354\007\176\005\275\217\006\015\163\027\150'
|
||
printf '\054\011\160\122\021\174\353\114\250\050\030\375\347\377\305\064'
|
||
printf '\230\125\012\017\174\010\107\333\046\116\027\050\231\000\176\341'
|
||
printf '\207\321\074\041\046\215\370\311\201\004\240\047\001\106\363\052'
|
||
printf '\053\200\177\134\076\172\374\375\243\242\020\276\175\026\224\027'
|
||
printf '\214\176\175\141\217\130\314\137\374\311\172\314\067\374\000\055'
|
||
printf '\355\022\352\235\244\000\307\032\371\025\261\340\033\313\240\164'
|
||
printf '\034\223\375\226\344\301\225\113\107\267\076\307\012\177\013\320'
|
||
printf '\326\042\276\342\207\343\056\204\145\032\077\100\143\163\016\324'
|
||
printf '\000\243\220\266\250\012\146\227\215\177\165\247\226\303\342\052'
|
||
printf '\330\131\233\373\175\240\326\026\177\361\017\112\200\114\343\007'
|
||
printf '\150\152\221\060\131\037\334\375\031\242\010\256\054\204\223\113'
|
||
printf '\022\005\157\134\303\131\063\322\367\075\316\235\015\173\352\107'
|
||
printf '\321\065\123\341\316\211\226\046\361\025\377\310\105\160\232\361'
|
||
printf '\053\240\241\031\342\156\070\006\304\251\024\267\130\331\226\014'
|
||
printf '\110\200\271\225\260\342\224\104\261\233\251\230\121\012\347\314'
|
||
printf '\206\051\223\140\122\044\221\140\215\235\260\267\001\152\232\372'
|
||
printf '\066\173\304\032\274\303\254\220\334\046\026\213\101\163\223\370'
|
||
printf '\212\277\267\005\360\013\077\044\246\352\073\162\114\230\065\075'
|
||
printf '\370\073\046\325\005\257\210\005\371\066\170\300\005\247\301\031'
|
||
printf '\323\375\151\211\316\077\155\360\373\147\317\114\234\045\132\273'
|
||
printf '\057\361\247\143\215\356\067\004\061\152\217\046\046\042\366\023'
|
||
printf '\377\320\105\160\206\360\047\343\320\321\160\354\224\110\212\076'
|
||
printf '\205\002\112\362\204\013\347\370\203\177\244\070\251\010\376\176'
|
||
printf '\051\174\252\052\165\327\062\210\023\343\246\212\243\177\326\276'
|
||
printf '\343\037\360\220\074\277\360\003\124\037\012\107\035\340\330\251'
|
||
printf '\347\056\072\265\114\370\164\200\356\152\263\124\242\053\066\270'
|
||
printf '\013\027\236\004\070\130\055\276\343\207\343\037\223\352\003\176'
|
||
printf '\045\260\363\343\360\024\302\171\221\301\175\210\251\105\301\233'
|
||
printf '\162\071\226\342\141\030\251\276\173\120\243\046\231\000\076\342'
|
||
printf '\037\360\234\140\277\360\003\354\257\021\272\143\341\330\061\371'
|
||
printf '\321\301\277\044\117\074\334\000\345\200\253\301\326\203\037\232'
|
||
printf '\135\020\015\111\001\334\015\207\017\152\337\361\367\266\000\176'
|
||
printf '\342\007\160\075\330\275\077\034\255\100\141\236\225\262\313\361'
|
||
printf '\111\153\160\276\377\047\255\102\252\143\175\101\136\070\132\200'
|
||
printf '\175\273\065\156\334\177\374\211\175\351\063\376\144\154\332\036'
|
||
printf '\216\004\310\217\132\051\373\321\035\235\156\140\276\143\147\212'
|
||
printf '\357\342\330\052\160\117\210\034\052\166\156\325\131\301\077\250'
|
||
printf '\006\360\013\277\002\336\337\242\011\113\024\027\014\206\344\210'
|
||
printf '\346\110\000\132\201\043\255\202\055\172\124\337\071\210\041\002'
|
||
printf '\333\076\322\131\301\257\006\025\301\076\341\007\250\153\024\366'
|
||
printf '\327\204\243\025\050\231\144\247\074\033\324\336\356\146\265\026'
|
||
printf '\210\353\304\167\110\165\366\247\144\122\070\156\274\250\336\247'
|
||
printf '\151\156\220\254\340\037\320\002\370\211\077\371\201\257\277\027'
|
||
printf '\216\126\300\266\024\045\205\203\101\131\242\071\320\220\275\033'
|
||
printf '\034\152\032\074\254\024\107\377\222\102\033\073\044\267\155\176'
|
||
printf '\224\302\200\137\370\373\212\340\054\340\007\330\360\241\306\015'
|
||
printf '\311\015\062\345\105\116\112\124\052\356\162\070\013\343\233\016'
|
||
printf '\067\113\142\114\111\212\144\055\053\012\307\321\077\036\203\017'
|
||
printf '\337\365\262\206\077\171\102\043\053\370\025\320\326\016\357\154'
|
||
printf '\012\107\053\140\131\120\121\234\032\126\127\173\214\243\155\376'
|
||
printf '\045\301\321\066\241\253\043\365\171\344\212\222\360\034\375\377'
|
||
printf '\353\075\217\316\216\354\341\007\031\246\010\316\060\376\344\133'
|
||
printf '\057\274\026\242\142\270\320\146\122\276\225\362\067\266\265\306'
|
||
printf '\174\051\212\217\264\012\155\255\261\224\333\177\122\276\105\161'
|
||
printf '\101\170\156\272\176\173\235\227\125\374\103\027\301\076\341\207'
|
||
printf '\304\260\210\035\173\303\163\145\170\112\151\144\310\061\102\235'
|
||
printf '\155\061\016\064\170\170\031\370\071\132\240\246\111\323\331\226'
|
||
printf '\032\177\304\121\114\051\013\317\234\063\273\267\153\016\037\224'
|
||
printf '\254\342\037\060\026\050\033\370\223\357\075\373\122\170\356\224'
|
||
printf '\267\054\230\132\031\031\262\233\341\165\273\034\250\215\323\330'
|
||
printf '\231\276\054\150\350\024\016\324\306\211\167\306\207\054\322\247'
|
||
printf '\226\107\010\323\164\105\353\136\364\262\216\177\160\021\234\005'
|
||
printf '\374\000\333\367\010\333\367\204\247\025\210\330\212\151\025\103'
|
||
printf '\047\001\236\246\261\051\106\165\235\113\143\227\234\320\154\235'
|
||
printf '\002\064\166\011\373\353\134\232\232\142\210\247\207\304\077\255'
|
||
printf '\042\102\304\011\217\376\175\273\064\173\167\352\254\343\037\130'
|
||
printf '\004\147\011\177\062\236\170\336\103\102\164\273\160\064\242\230'
|
||
printf '\136\031\031\166\264\245\216\173\064\066\306\250\076\026\347\160'
|
||
printf '\263\246\261\113\210\017\123\362\044\156\164\021\016\067\153\252'
|
||
printf '\217\305\151\154\214\041\161\157\330\104\234\136\031\041\032\011'
|
||
printf '\017\176\021\170\356\051\067\020\370\041\143\023\143\215\015\077'
|
||
printf '\300\276\152\341\355\367\065\347\236\025\236\021\214\021\107\061'
|
||
printf '\143\162\204\332\046\227\216\356\241\145\213\247\351\356\320\164'
|
||
printf '\167\100\143\117\273\153\051\013\145\253\104\322\153\101\213\206'
|
||
printf '\061\234\017\050\314\263\230\122\346\204\346\214\117\062\066\275'
|
||
printf '\353\161\370\200\004\002\177\242\010\016\000\376\344\173\217\377'
|
||
printf '\321\243\243\063\124\373\063\321\377\256\210\120\131\342\214\276'
|
||
printf '\017\256\101\173\032\057\346\241\343\036\332\033\075\176\113\301'
|
||
printf '\344\022\207\251\303\165\301\002\032\135\135\360\247\247\275\300'
|
||
printf '\340\207\321\136\011\366\001\077\100\163\053\074\371\174\070\247'
|
||
printf '\216\053\235\144\063\263\052\112\161\201\235\221\033\321\025\211'
|
||
printf '\323\260\063\253\242\241\031\346\160\174\274\360\214\113\113\263'
|
||
printf '\004\006\377\340\042\070\213\370\223\313\277\372\226\146\313\316'
|
||
printf '\160\316\035\144\133\212\051\145\116\057\322\164\334\217\153\131'
|
||
printf '\211\161\075\063\253\242\114\051\015\137\227\047\031\273\267\151'
|
||
printf '\336\171\335\013\024\376\201\105\160\000\360\253\236\042\351\376'
|
||
printf '\307\303\327\025\032\120\130\331\212\311\045\016\263\253\362\070'
|
||
printf '\251\074\102\111\241\075\246\263\064\021\047\061\366\350\244\362'
|
||
printf '\010\263\253\362\230\134\342\204\346\326\306\124\321\326\042\074'
|
||
printf '\376\200\073\340\044\107\020\360\367\025\301\001\301\237\214\372'
|
||
printf '\106\341\167\217\171\334\160\215\035\332\207\077\103\142\124\346'
|
||
printf '\244\174\253\367\352\261\326\020\367\064\061\067\061\003\202\326'
|
||
printf '\175\107\171\113\045\340\107\154\053\247\236\100\043\002\117\076'
|
||
printf '\354\016\230\365\055\050\370\107\174\114\152\066\360\047\227\371'
|
||
printf '\160\213\346\345\327\025\227\374\165\356\150\260\054\310\263\054'
|
||
printf '\362\042\114\230\170\163\255\307\216\315\072\220\370\107\056\202'
|
||
printf '\263\204\077\031\177\370\243\307\256\175\202\211\160\306\201\217'
|
||
printf '\065\057\076\353\006\026\377\360\105\160\226\361\103\342\131\002'
|
||
printf '\253\357\165\371\344\230\111\202\260\105\175\255\360\320\335\156'
|
||
printf '\337\224\347\001\304\217\234\320\304\130\376\340\117\276\327\336'
|
||
printf '\001\167\376\326\243\265\335\240\012\113\264\266\010\277\273\063'
|
||
printf '\116\133\317\350\330\240\342\037\320\005\012\042\376\144\034\075'
|
||
printf '\046\334\176\227\113\173\207\301\025\364\210\307\340\241\273\135'
|
||
printf '\032\352\202\217\177\360\160\350\000\342\117\256\243\346\260\360'
|
||
printf '\313\065\056\335\335\006\131\120\303\163\341\341\173\342\034\334'
|
||
printf '\257\103\201\277\257\005\220\314\343\127\343\300\237\174\157\357'
|
||
printf '\176\341\316\377\160\351\354\062\330\202\026\261\156\170\340\356'
|
||
printf '\070\273\266\215\017\277\362\021\177\042\001\144\244\177\230\036'
|
||
printf '\374\351\072\022\354\332\047\334\376\153\227\326\066\203\056\050'
|
||
printf '\321\331\001\367\376\052\316\356\064\340\307\107\374\060\342\225'
|
||
printf '\340\140\341\117\276\127\135\043\374\333\257\134\352\032\314\331'
|
||
printf '\241\040\024\274\377\161\107\214\352\275\341\303\237\272\010\016'
|
||
printf '\070\376\144\034\071\052\334\366\357\056\173\367\233\044\310\126'
|
||
printf '\064\324\012\277\371\105\234\043\207\044\224\370\207\231\030\053'
|
||
printf '\330\370\373\216\076\160\373\152\227\365\033\265\321\350\163\354'
|
||
printf '\330\254\131\375\263\030\365\265\341\305\017\051\037\221\024\016'
|
||
printf '\374\311\165\270\056\334\367\210\307\216\135\302\125\127\330\104'
|
||
printf '\243\006\147\046\103\153\170\345\171\217\265\317\365\015\156\013'
|
||
printf '\053\376\336\004\010\053\376\376\261\141\243\346\320\141\141\325'
|
||
printf '\215\016\321\210\201\232\251\376\376\357\177\347\262\157\327\370'
|
||
printf '\307\366\004\001\077\200\223\013\370\223\313\265\264\212\301\237'
|
||
printf '\241\330\265\115\363\344\203\003\157\150\011\073\376\176\135\240'
|
||
printf '\360\343\007\130\070\337\062\122\063\160\324\377\323\323\036\037'
|
||
printf '\154\110\317\315\054\101\302\337\063\034\072\067\360\003\054\234'
|
||
printf '\247\214\330\064\205\110\142\336\316\347\236\360\150\157\223\234'
|
||
printf '\304\217\244\052\202\103\212\037\140\201\111\200\264\304\321\043'
|
||
printf '\302\063\217\271\354\337\255\117\170\137\204\001\377\340\042\070'
|
||
printf '\304\370\053\313\025\125\123\114\002\214\047\032\353\205\127\137'
|
||
printf '\360\330\370\226\107\212\131\327\163\016\377\300\042\070\304\370'
|
||
printf '\225\071\372\217\053\232\032\204\067\376\323\143\303\353\036\256'
|
||
printf '\233\336\351\012\203\214\277\257\010\016\071\176\323\375\071\261'
|
||
printf '\250\073\046\274\271\326\343\335\267\074\074\067\175\373\042\054'
|
||
printf '\370\023\105\160\016\340\107\304\024\300\143\050\156\367\356\324'
|
||
printf '\274\363\206\307\326\115\272\367\306\374\211\210\277\257\005\010'
|
||
printf '\071\376\312\112\105\145\245\111\200\341\242\245\131\370\140\203'
|
||
printf '\346\355\327\274\214\077\223\053\054\370\007\027\301\041\304\017'
|
||
printf '\346\364\347\120\321\120\047\154\337\254\331\266\131\363\361\056'
|
||
printf '\215\347\145\376\121\244\141\302\077\260\010\016\051\176\310\374'
|
||
printf '\005\260\332\132\141\347\016\341\224\123\025\063\146\250\300\316'
|
||
printf '\333\043\002\065\007\204\255\377\345\261\375\043\315\047\177\026'
|
||
printf '\177\366\105\110\361\017\350\002\205\025\277\002\346\147\250\005'
|
||
printf '\250\255\025\136\170\301\343\275\215\175\175\345\202\002\230\073'
|
||
printf '\327\142\356\134\305\151\163\054\246\117\127\344\347\147\007\174'
|
||
printf '\133\253\160\160\277\160\160\277\346\100\317\237\135\135\076\357'
|
||
printf '\213\020\343\037\161\142\254\060\340\257\232\242\250\050\127\031'
|
||
printf '\201\277\161\243\036\164\076\274\253\023\266\156\321\154\335\002'
|
||
printf '\340\241\024\114\256\124\114\237\256\230\066\135\061\343\144\105'
|
||
printf '\171\271\242\274\002\212\213\307\337\132\170\036\064\066\010\015'
|
||
printf '\165\075\257\172\241\256\126\250\071\040\064\324\112\166\367\105'
|
||
printf '\310\361\017\133\004\207\001\077\300\202\371\052\043\360\265\036'
|
||
printf '\335\075\314\010\324\325\046\120\156\376\150\340\162\226\005\305'
|
||
printf '\045\212\362\362\104\062\070\016\344\345\201\155\103\101\201\032'
|
||
printf '\070\355\243\010\235\235\320\335\055\164\166\044\022\255\251\121'
|
||
printf '\150\156\022\304\013\340\276\310\001\374\103\026\301\141\301\017'
|
||
printf '\260\140\336\370\073\344\365\365\302\113\057\173\254\177\273\257'
|
||
printf '\253\243\322\260\301\265\206\346\046\241\245\251\337\202\051\267'
|
||
printf '\223\077\017\213\063\370\007\257\303\121\020\003\242\141\304\317'
|
||
printf '\070\373\377\275\360\327\153\264\067\114\127\060\215\033\334\340'
|
||
printf '\017\016\176\240\333\121\320\046\120\021\106\374\123\117\122\224'
|
||
printf '\225\252\023\202\377\342\313\036\033\326\367\034\361\305\340\237'
|
||
printf '\200\370\121\320\352\210\242\025\241\042\154\370\023\247\077\325'
|
||
printf '\011\301\137\277\276\137\161\153\360\117\124\374\000\255\216\010'
|
||
printf '\155\126\010\361\053\140\301\050\317\377\367\207\077\240\270\065'
|
||
printf '\370\047\062\176\100\132\035\113\250\013\043\176\245\140\336\134'
|
||
printf '\065\046\370\003\327\141\360\117\154\374\240\120\365\216\202\075'
|
||
printf '\002\053\302\204\037\140\332\064\105\111\261\032\065\174\203\337'
|
||
printf '\340\077\176\071\121\354\166\020\265\073\271\145\302\202\177\250'
|
||
printf '\323\237\103\301\067\370\015\376\224\313\151\331\355\150\313\333'
|
||
printf '\245\304\012\025\176\030\170\001\054\011\377\355\365\072\365\235'
|
||
printf '\114\006\277\301\237\262\033\155\355\162\260\330\256\274\160\341'
|
||
printf '\127\012\346\315\261\006\300\117\165\345\326\340\067\370\207\133'
|
||
printf '\116\153\331\256\104\204\157\376\320\075\004\062\043\014\370\001'
|
||
printf '\312\112\024\213\116\127\274\273\161\350\053\267\006\277\301\077'
|
||
printf '\302\162\065\267\074\230\077\313\112\054\057\257\205\005\277\022'
|
||
printf '\150\156\026\066\274\143\360\033\374\343\132\307\053\220\234\034'
|
||
printf '\127\261\056\054\370\307\266\016\203\337\340\037\162\377\257\353'
|
||
printf '\115\000\317\365\326\252\376\253\063\370\015\376\034\306\017\150'
|
||
printf '\021\351\153\001\036\273\053\377\000\212\365\006\277\301\077\001'
|
||
printf '\360\143\301\033\267\074\124\160\270\257\013\004\210\346\021\203'
|
||
printf '\337\340\317\165\374\052\301\360\221\176\311\220\210\374\356\310'
|
||
printf '\343\100\247\301\157\360\347\062\176\204\256\270\325\365\314\240'
|
||
printf '\004\130\263\206\146\245\170\326\340\067\370\163\030\077\300\123'
|
||
printf '\267\076\120\326\064\050\001\000\304\223\237\001\332\340\067\370'
|
||
printf '\163\024\277\040\326\057\216\253\007\372\342\301\273\242\333\100'
|
||
printf '\075\157\360\033\374\071\210\037\120\317\336\374\160\164\353\220'
|
||
printf '\011\000\240\221\333\014\176\203\077\367\360\203\210\367\363\024'
|
||
printf '\147\204\006\306\103\253\043\033\105\251\247\015\176\203\077\227'
|
||
printf '\360\053\344\017\267\074\134\370\376\210\011\000\240\334\370\077'
|
||
printf '\003\155\006\277\301\237\013\370\101\132\065\334\230\312\172\312'
|
||
printf '\004\270\377\356\202\032\101\335\146\360\033\374\071\200\037\005'
|
||
printf '\377\063\171\341\153\124\011\000\320\136\351\334\211\142\263\301'
|
||
printf '\157\360\207\034\377\246\312\374\202\137\017\345\174\310\004\170'
|
||
printf '\342\126\142\132\351\257\041\264\032\374\006\177\110\361\267\141'
|
||
printf '\331\137\377\316\032\342\143\116\000\200\007\176\225\267\107\041'
|
||
printf '\337\061\370\015\376\020\342\107\120\327\255\172\040\272\163\070'
|
||
printf '\343\043\316\053\162\357\135\321\307\021\356\067\370\015\376\120'
|
||
printf '\341\027\365\333\233\037\312\177\164\044\337\243\232\130\307\216'
|
||
printf '\107\276\213\222\027\015\176\203\077\014\370\101\326\306\273\362'
|
||
printf '\257\037\215\155\045\042\243\131\216\153\257\245\120\107\343\153'
|
||
printf '\201\317\031\374\006\177\140\361\013\357\305\272\012\316\277\365'
|
||
printf '\211\304\151\374\264\264\000\000\153\326\320\341\251\310\145\210'
|
||
printf '\354\064\370\015\376\140\366\371\145\107\324\165\277\070\132\374'
|
||
printf '\143\112\000\200\373\127\123\053\321\350\071\300\006\203\337\340'
|
||
printf '\017\332\221\137\331\172\305\215\277\057\256\033\213\351\121\167'
|
||
printf '\201\372\307\325\377\302\244\274\316\330\123\012\276\140\360\033'
|
||
printf '\374\331\357\363\363\212\355\024\134\376\243\373\022\247\354\307'
|
||
printf '\022\047\364\164\211\207\157\247\275\171\112\364\062\104\356\063'
|
||
printf '\370\015\376\154\237\355\251\314\057\270\364\104\360\237\160\013'
|
||
printf '\320\077\276\173\175\354\037\104\270\007\050\062\370\015\176\037'
|
||
printf '\361\267\052\245\256\133\371\140\376\143\343\361\073\356\004\000'
|
||
printf '\270\366\372\330\102\204\307\201\145\006\277\301\357\003\376\115'
|
||
printf '\140\135\271\352\241\274\335\343\265\233\226\047\336\256\371\165'
|
||
printf '\164\347\364\051\321\345\112\344\237\140\140\123\144\360\033\374'
|
||
printf '\151\304\337\001\362\223\130\147\301\331\351\300\237\266\026\240'
|
||
printf '\177\174\373\206\316\223\155\317\276\023\370\232\301\157\360\247'
|
||
printf '\153\035\012\371\203\206\033\207\032\325\031\230\004\350\255\015'
|
||
printf '\156\210\057\123\256\334\210\342\353\200\155\360\033\374\047\162'
|
||
printf '\017\257\040\317\003\077\275\345\241\202\215\231\160\232\261\004'
|
||
printf '\110\306\165\327\305\226\140\261\122\301\127\201\174\203\337\340'
|
||
printf '\037\305\072\272\200\247\074\145\375\333\277\076\030\335\226\111'
|
||
printf '\237\031\117\200\336\102\371\132\112\035\047\176\231\010\127\201'
|
||
printf '\134\240\216\373\375\006\277\231\256\120\301\006\104\075\251\210'
|
||
printf '\075\272\352\241\342\172\077\134\372\226\000\375\343\206\033\072'
|
||
printf '\117\166\135\347\002\205\234\217\160\276\122\234\154\360\117\110'
|
||
printf '\374\065\050\136\125\302\253\042\362\112\272\373\367\201\115\200'
|
||
printf '\343\343\173\337\353\076\315\022\026\011\054\120\212\371\012\153'
|
||
printf '\276\022\251\220\304\265\205\162\140\222\352\367\060\157\203\077'
|
||
printf '\024\370\143\012\332\024\064\011\322\006\252\101\301\156\205\354'
|
||
printf '\006\153\247\326\262\375\307\017\347\357\317\266\275\377\017\161'
|
||
printf '\157\274\260\035\164\356\302\000\000\000\000\111\105\116\104\256'
|
||
printf '\102\140\202'
|
||
} > "$STAGE/icon-192.png"
|
||
{
|
||
printf '\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122'
|
||
printf '\000\000\002\000\000\000\002\000\010\006\000\000\000\364\170\324'
|
||
printf '\372\000\000\103\364\111\104\101\124\170\332\355\335\151\230\144'
|
||
printf '\127\141\346\371\367\334\130\162\251\134\052\063\053\153\125\155'
|
||
printf '\224\252\112\073\132\100\010\220\130\054\203\130\045\014\266\141'
|
||
printf '\214\215\115\273\155\267\333\117\117\217\237\356\161\217\147\372'
|
||
printf '\323\114\117\267\333\230\156\143\013\321\264\005\006\306\062\302'
|
||
printf '\200\214\220\204\204\044\044\241\135\245\102\013\245\222\152\125'
|
||
printf '\355\173\126\356\133\104\334\173\317\174\210\312\254\112\145\144'
|
||
printf '\146\334\330\362\056\377\227\047\036\112\005\241\310\074\021\161'
|
||
printf '\177\357\075\167\071\346\246\377\313\263\052\021\243\062\143\053'
|
||
printf '\170\216\152\374\034\133\357\327\262\261\031\207\272\377\154\266'
|
||
printf '\362\327\211\377\070\330\306\215\101\031\057\327\220\367\310\056'
|
||
printf '\362\167\242\116\343\020\370\071\266\226\343\155\023\067\016\065'
|
||
printf '\175\216\135\344\357\104\130\306\101\222\003\376\340\017\376\340'
|
||
printf '\017\376\340\017\376\311\302\137\326\316\056\000\340\017\376\340'
|
||
printf '\017\376\340\017\376\340\037\157\374\147\315\000\200\077\370\203'
|
||
printf '\077\370\203\077\370\203\177\374\361\237\121\000\300\037\374\301'
|
||
printf '\037\374\301\037\374\301\077\031\370\117\027\000\360\007\177\360'
|
||
printf '\007\177\360\007\177\360\117\016\376\222\344\200\077\370\203\077'
|
||
printf '\370\203\077\370\203\177\262\360\237\236\001\000\177\360\007\177'
|
||
printf '\360\007\177\360\007\377\344\340\157\312\052\000\340\017\376\340'
|
||
printf '\017\376\340\017\376\340\037\053\374\027\236\001\000\177\360\007'
|
||
printf '\177\360\007\177\360\007\377\330\341\077\177\001\000\177\360\007'
|
||
printf '\177\360\007\177\360\007\377\130\342\077\167\001\000\177\360\007'
|
||
printf '\177\360\007\177\360\007\377\330\342\137\272\000\200\077\370\203'
|
||
printf '\077\370\203\077\370\203\177\254\361\237\135\000\300\037\374\301'
|
||
printf '\037\374\301\037\374\301\077\366\370\317\054\000\340\017\376\340'
|
||
printf '\017\376\340\017\376\340\237\010\374\317\027\000\360\007\177\360'
|
||
printf '\007\177\360\007\177\360\117\014\376\305\002\000\376\340\017\376'
|
||
printf '\340\017\376\340\017\376\211\302\377\374\014\000\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\047\006\377\351\002\000\376\340\017\376'
|
||
printf '\340\017\376\340\017\376\311\301\137\012\262\030\020\370\203\077'
|
||
printf '\370\203\077\370\203\077\370\307\002\377\351\031\000\360\007\075'
|
||
printf '\360\007\177\360\007\177\360\117\016\376\345\055\006\004\376\340'
|
||
printf '\017\376\340\017\376\340\017\376\261\302\077\320\014\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\003\377\262\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\007\377\262\012\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\013\377\005\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\017\377\171\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\023\377\071\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\027\377\222\005\000\374\301'
|
||
printf '\037\374\301\037\374\301\037\374\343\215\377\254\002\000\376\340'
|
||
printf '\017\376\340\017\376\340\017\376\361\307\177\106\001\000\177\360'
|
||
printf '\007\177\360\007\177\360\007\377\144\340\077\135\000\300\037\374'
|
||
printf '\301\037\374\301\037\374\301\077\071\370\113\265\132\014\010\374'
|
||
printf '\301\037\374\301\037\374\301\037\374\043\203\377\364\014\000\370'
|
||
printf '\203\077\370\203\077\370\203\077\370\047\007\377\352\027\003\002'
|
||
printf '\177\360\007\177\360\007\177\360\007\377\310\341\057\133\315\142'
|
||
printf '\100\340\017\376\340\017\376\340\017\376\340\037\111\374\245\112'
|
||
printf '\027\003\002\177\360\007\177\360\007\177\360\007\377\310\342\137'
|
||
printf '\126\001\000\177\360\007\177\360\007\177\360\007\377\170\341\277'
|
||
printf '\140\001\000\177\360\007\177\360\007\177\360\007\377\370\341\077'
|
||
printf '\157\001\000\177\360\007\177\360\007\177\360\007\377\170\342\077'
|
||
printf '\147\001\000\177\360\007\177\360\007\177\360\007\377\370\342\137'
|
||
printf '\262\000\200\077\370\203\077\370\203\077\370\203\177\274\361\237'
|
||
printf '\125\000\300\037\374\301\037\374\301\037\374\301\077\376\370\317'
|
||
printf '\050\000\340\017\376\340\017\376\340\017\376\340\237\014\374\247'
|
||
printf '\013\000\370\203\077\370\203\077\370\203\077\370\047\007\177\251'
|
||
printf '\324\142\100\340\017\376\340\017\376\340\017\376\340\037\153\374'
|
||
printf '\247\147\000\300\037\374\301\037\374\301\037\374\301\077\071\370'
|
||
printf '\317\134\014\010\374\301\037\374\301\037\374\301\037\374\023\201'
|
||
printf '\377\371\031\000\360\007\177\360\007\177\360\007\177\360\117\014'
|
||
printf '\376\305\002\000\376\340\017\376\340\017\376\340\017\376\211\302'
|
||
printf '\377\374\014\000\370\203\077\370\203\077\370\203\077\370\047\006'
|
||
printf '\377\262\012\000\370\203\077\370\203\077\370\203\077\370\307\013'
|
||
printf '\377\005\013\000\370\203\077\370\203\077\370\203\077\370\307\017'
|
||
printf '\377\171\013\000\370\203\077\370\203\077\370\203\077\370\307\023'
|
||
printf '\377\071\013\000\370\203\077\370\203\077\370\203\077\370\307\027'
|
||
printf '\377\222\005\000\374\301\037\374\301\037\374\301\037\374\343\215'
|
||
printf '\377\254\002\000\376\340\017\376\340\017\376\340\017\376\361\307'
|
||
printf '\177\106\001\000\177\360\007\177\360\007\177\360\007\377\144\340'
|
||
printf '\077\135\000\300\037\374\301\037\374\301\037\374\301\077\071\370'
|
||
printf '\113\245\126\003\004\177\360\007\177\360\007\177\360\007\377\130'
|
||
printf '\343\077\075\003\000\376\340\017\376\340\017\376\340\017\376\311'
|
||
printf '\301\337\004\055\000\340\017\376\340\017\376\340\017\376\340\037'
|
||
printf '\175\374\003\315\000\200\077\370\203\077\370\203\077\370\203\177'
|
||
printf '\074\360\057\273\000\200\077\370\203\077\370\203\077\370\203\177'
|
||
printf '\174\360\057\253\000\200\077\370\203\077\370\203\077\370\203\177'
|
||
printf '\274\360\137\260\000\200\077\370\203\077\370\203\077\370\203\177'
|
||
printf '\374\360\237\267\000\200\077\370\203\077\370\203\077\370\203\177'
|
||
printf '\074\361\237\263\000\200\077\370\203\077\370\203\077\370\203\177'
|
||
printf '\174\361\227\235\163\061\040\360\007\177\360\007\177\360\007\177'
|
||
printf '\360\217\053\376\263\146\000\300\037\374\301\037\374\301\037\374'
|
||
printf '\301\077\376\370\317\050\000\340\017\376\340\017\376\340\017\376'
|
||
printf '\340\237\014\374\247\013\000\370\203\077\370\203\077\370\203\077'
|
||
printf '\370\047\007\177\151\172\061\040\360\007\177\360\007\177\360\007'
|
||
printf '\177\360\117\012\376\347\146\000\300\037\374\301\037\374\301\037'
|
||
printf '\374\301\077\111\370\227\267\030\020\370\203\077\370\203\077\370'
|
||
printf '\203\077\370\307\012\177\055\130\000\300\037\374\301\037\374\301'
|
||
printf '\037\374\301\077\166\370\317\137\000\300\037\374\301\037\374\301'
|
||
printf '\037\374\301\077\226\370\317\135\000\300\037\374\301\037\374\301'
|
||
printf '\037\374\301\077\266\370\227\056\000\340\017\376\340\017\376\340'
|
||
printf '\017\376\340\037\153\374\147\027\000\360\007\177\360\007\177\360'
|
||
printf '\007\177\360\217\075\376\063\013\000\370\203\077\370\203\077\370'
|
||
printf '\203\077\370\047\002\377\363\005\000\374\301\037\374\301\037\374'
|
||
printf '\301\037\374\023\203\177\261\000\200\077\370\203\077\370\203\077'
|
||
printf '\370\203\177\242\360\077\077\003\000\376\340\017\376\340\017\376'
|
||
printf '\340\017\376\211\301\177\272\000\200\077\370\203\077\370\203\077'
|
||
printf '\370\203\177\162\360\227\246\027\003\002\075\360\007\177\360\007'
|
||
printf '\177\360\007\377\244\340\077\075\003\000\172\340\017\376\340\017'
|
||
printf '\376\340\017\376\311\301\277\274\305\200\300\037\374\301\037\374'
|
||
printf '\301\037\374\301\077\126\370\007\232\001\000\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\170\340\137\166\001\000\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\370\340\137\126\001\000\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\170\341\277\140\001\000\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\370\341\077\157\001\000\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\170\342\077\147\001\000\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\370\342\137\262\000\200\077\370\203\077\370'
|
||
printf '\203\077\370\203\177\274\361\237\125\000\300\037\374\301\037\374'
|
||
printf '\301\037\374\301\077\376\370\317\050\000\340\017\376\340\017\376'
|
||
printf '\340\017\376\340\237\014\374\247\013\000\370\203\077\370\203\077'
|
||
printf '\370\203\077\370\047\007\177\251\126\213\001\201\077\370\203\077'
|
||
printf '\370\203\077\370\203\177\144\360\237\236\001\000\177\360\007\177'
|
||
printf '\360\007\177\360\007\377\344\340\137\375\142\100\340\017\376\340'
|
||
printf '\017\376\340\017\376\340\037\071\374\145\253\131\014\010\374\301'
|
||
printf '\037\374\301\037\374\301\037\374\043\211\277\124\351\142\100\340'
|
||
printf '\017\376\340\017\376\340\017\376\340\037\131\374\313\052\000\340'
|
||
printf '\017\376\340\017\376\340\017\376\340\037\057\374\027\054\000\340'
|
||
printf '\017\376\340\017\376\340\017\376\340\037\077\374\347\055\000\340'
|
||
printf '\017\376\340\017\376\340\017\376\340\037\117\374\347\054\000\340'
|
||
printf '\017\376\340\017\376\340\017\376\340\037\137\374\113\026\000\360'
|
||
printf '\007\177\360\007\177\360\007\177\360\217\067\376\263\012\000\370'
|
||
printf '\203\077\370\203\077\370\203\077\370\307\037\377\031\005\000\374'
|
||
printf '\301\037\374\301\037\374\301\037\374\223\201\377\164\001\000\177'
|
||
printf '\360\007\177\360\007\177\360\007\377\344\340\057\225\132\014\010'
|
||
printf '\374\301\037\374\301\037\374\301\037\374\143\215\377\364\014\000'
|
||
printf '\370\203\077\370\203\077\370\203\077\370\047\007\377\231\213\001'
|
||
printf '\201\077\370\203\077\370\203\077\370\203\177\042\360\077\077\003'
|
||
printf '\000\376\340\017\376\340\017\376\340\017\376\211\301\277\130\000'
|
||
printf '\300\037\374\301\037\374\301\037\374\301\077\121\370\237\237\001'
|
||
printf '\000\177\360\007\177\360\007\177\360\007\377\304\340\277\140\001'
|
||
printf '\000\177\360\007\177\360\007\177\360\007\377\370\341\077\157\001'
|
||
printf '\000\177\360\007\177\360\007\177\360\007\377\170\342\077\147\001'
|
||
printf '\000\177\360\007\177\360\007\177\360\007\377\370\342\137\262\000'
|
||
printf '\200\077\370\203\077\370\203\077\370\203\177\274\361\237\125\000'
|
||
printf '\300\037\374\301\037\374\301\037\374\301\077\376\370\317\050\000'
|
||
printf '\340\017\376\340\017\376\340\017\376\340\237\014\374\247\013\000'
|
||
printf '\370\203\077\370\203\077\370\203\077\370\047\007\177\111\112\203'
|
||
printf '\077\370\203\177\174\361\317\146\244\114\246\370\234\346\254\121'
|
||
printf '\052\165\301\337\247\213\177\056\024\244\174\241\370\147\317\223'
|
||
printf '\046\363\305\177\237\173\301\337\203\077\370\203\177\374\306\041'
|
||
printf '\015\376\340\017\376\321\301\277\265\131\352\136\152\324\323\051'
|
||
printf '\055\355\220\172\272\244\245\035\216\226\264\110\255\055\106\155'
|
||
printf '\255\122\353\271\077\057\151\071\217\174\245\051\270\322\370\270'
|
||
printf '\064\066\141\065\066\041\215\117\110\343\023\126\243\343\322\320'
|
||
printf '\210\325\331\001\151\140\310\152\140\110\032\030\264\232\230\004'
|
||
printf '\177\360\007\377\050\214\203\011\132\000\300\037\374\301\277\376'
|
||
printf '\033\373\256\116\151\165\257\321\312\345\106\253\172\245\065\313'
|
||
printf '\215\172\173\244\145\135\106\115\131\065\064\231\264\324\331\041'
|
||
printf '\165\166\230\262\176\353\311\234\324\077\150\165\372\254\164\342'
|
||
printf '\264\325\311\323\126\047\317\130\235\070\135\054\012\340\017\376'
|
||
printf '\340\037\016\374\045\311\334\362\037\134\133\363\027\001\177\360'
|
||
printf '\007\377\005\067\366\055\115\322\272\065\106\033\057\062\332\260'
|
||
printf '\106\132\267\252\210\176\113\223\142\231\311\134\261\024\034\075'
|
||
printf '\156\165\360\150\361\161\344\230\325\144\016\374\301\037\374\033'
|
||
printf '\215\177\331\005\000\374\301\037\374\253\173\116\046\045\155\132'
|
||
printf '\147\264\145\203\321\206\163\340\257\352\065\062\225\276\011\061'
|
||
printf '\211\265\322\311\323\305\062\160\350\250\325\336\203\126\007\016'
|
||
printf '\131\271\036\370\203\077\370\327\373\263\260\140\001\000\177\360'
|
||
printf '\007\377\340\317\151\312\112\033\327\030\155\331\150\164\345\026'
|
||
printf '\243\255\033\215\262\031\221\062\342\171\322\221\343\126\257\355'
|
||
printf '\266\332\173\300\152\317\176\137\343\023\340\017\376\340\137\353'
|
||
printf '\237\055\015\376\340\017\376\325\377\154\216\043\155\136\157\164'
|
||
printf '\365\245\106\127\155\051\356\345\247\034\221\012\222\112\111\033'
|
||
printf '\326\032\155\130\133\034\155\317\117\351\340\021\253\235\273\254'
|
||
printf '\136\175\335\327\233\207\255\174\037\374\301\037\374\253\175\316'
|
||
printf '\234\063\000\340\017\376\340\077\377\163\072\332\244\313\066\031'
|
||
printf '\135\167\271\243\153\056\053\236\201\117\352\237\261\161\151\347'
|
||
printf '\036\137\073\167\133\275\272\323\316\070\271\020\374\301\037\374'
|
||
printf '\313\177\116\311\002\000\376\340\017\376\245\237\263\274\333\350'
|
||
printf '\206\253\215\336\165\225\321\333\326\162\014\177\261\143\255\164'
|
||
printf '\340\260\325\266\127\174\155\177\305\252\257\337\202\077\370\203'
|
||
printf '\177\231\317\231\125\000\300\037\374\301\177\146\172\273\244\167'
|
||
printf '\136\351\350\206\267\027\117\342\003\375\360\346\370\111\253\155'
|
||
printf '\257\130\075\267\335\327\251\063\026\374\301\037\374\347\373\134'
|
||
printf '\136\130\000\300\037\374\301\277\230\366\045\322\215\327\072\272'
|
||
printf '\351\072\243\115\353\020\077\252\063\003\317\276\350\353\271\355'
|
||
printf '\276\306\306\301\037\374\301\177\326\366\172\252\000\200\077\370'
|
||
printf '\047\035\177\143\244\053\066\033\275\357\035\305\275\175\316\332'
|
||
printf '\217\107\134\127\172\155\227\325\063\057\372\172\351\125\177\336'
|
||
printf '\023\010\301\037\374\223\202\377\164\001\000\177\360\117\062\376'
|
||
printf '\253\172\215\076\160\275\321\373\337\351\250\253\003\060\343\234'
|
||
printf '\201\101\253\147\266\131\075\365\274\257\323\175\266\176\237\125'
|
||
printf '\360\007\377\220\343\057\111\346\043\145\336\011\020\374\301\077'
|
||
printf '\156\370\137\262\321\350\243\357\163\164\375\225\106\016\227\354'
|
||
printf '\045\052\326\112\157\354\261\172\344\347\276\136\335\351\317\345'
|
||
printf '\044\370\203\177\154\361\227\202\254\005\000\376\340\037\003\374'
|
||
printf '\063\151\351\335\127\033\335\372\101\107\153\127\161\154\077\251'
|
||
printf '\061\106\272\154\253\321\145\133\123\072\171\332\321\143\117\373'
|
||
printf '\172\362\131\137\271\074\370\203\177\062\360\067\145\317\000\200'
|
||
printf '\077\370\107\034\377\316\166\351\343\357\167\364\253\357\056\256'
|
||
printf '\234\107\310\133\063\072\046\375\374\131\137\017\077\341\151\170'
|
||
printf '\004\374\301\077\336\370\253\254\002\000\376\340\037\141\374\247'
|
||
printf '\340\377\310\215\116\303\127\322\043\321\214\353\112\317\154\363'
|
||
printf '\365\343\207\174\015\014\332\262\277\027\340\017\376\121\302\177'
|
||
printf '\341\002\000\376\340\037\121\374\173\273\244\217\177\240\270\307'
|
||
printf '\237\111\213\220\340\105\300\223\266\275\124\054\002\247\317\130'
|
||
printf '\360\007\377\130\341\077\177\001\000\177\360\217\040\376\313\272'
|
||
printf '\244\337\370\210\243\233\256\163\270\027\077\251\111\074\117\172'
|
||
printf '\166\233\257\173\037\362\325\077\140\301\037\374\143\201\377\334'
|
||
printf '\005\000\374\301\077\142\370\267\265\110\267\335\354\350\143\357'
|
||
printf '\143\217\237\324\157\106\340\231\027\174\335\163\277\247\221\121'
|
||
printf '\360\007\377\150\343\137\272\000\200\077\370\107\010\377\164\112'
|
||
printf '\272\345\275\216\176\375\026\116\356\043\215\311\330\270\364\340'
|
||
printf '\243\236\176\366\204\257\174\001\374\301\077\232\370\317\056\000'
|
||
printf '\340\017\376\021\301\337\030\351\175\327\031\175\356\143\051\365'
|
||
printf '\054\005\045\322\370\364\017\130\335\163\237\257\347\267\317\177'
|
||
printf '\037\001\360\007\377\060\342\077\263\000\200\077\370\107\004\377'
|
||
printf '\365\253\215\176\377\063\216\056\331\310\165\374\144\361\263\147'
|
||
printf '\277\325\135\337\367\164\364\230\005\177\360\217\014\376\347\013'
|
||
printf '\000\370\203\177\004\360\137\322\042\375\346\107\034\175\370\275'
|
||
printf '\234\340\107\302\025\337\227\036\173\312\327\217\036\360\064\061'
|
||
printf '\001\376\340\037\176\374\045\053\363\221\077\253\140\061\040\360'
|
||
printf '\007\377\006\216\203\061\322\373\337\341\350\363\237\164\324\331'
|
||
printf '\006\066\044\274\031\032\226\276\177\257\247\347\137\054\036\026'
|
||
printf '\000\177\360\017\053\376\305\031\200\077\013\270\030\020\370\203'
|
||
printf '\177\003\307\241\267\133\372\127\237\115\351\312\315\114\367\223'
|
||
printf '\350\144\317\176\253\157\335\345\315\177\377\000\360\007\377\105'
|
||
printf '\304\137\222\314\107\377\314\265\152\344\300\201\077\370\227\061'
|
||
printf '\016\306\110\067\337\340\350\167\156\165\324\322\004\050\044\172'
|
||
printf '\311\347\245\373\036\362\364\320\243\065\070\111\020\374\301\277'
|
||
printf '\306\370\113\101\026\003\002\177\360\157\320\070\054\357\066\372'
|
||
printf '\127\237\165\164\005\173\375\044\302\311\146\245\317\334\232\322'
|
||
printf '\125\227\073\372\326\135\236\116\235\251\360\044\101\360\007\377'
|
||
printf '\072\340\157\052\231\001\000\177\360\257\327\070\030\123\274\246'
|
||
printf '\377\363\237\340\276\375\044\136\311\345\244\357\377\310\323\023'
|
||
printf '\117\373\340\017\376\241\300\077\360\014\000\370\203\177\275\306'
|
||
printf '\241\175\211\364\257\077\227\322\165\227\263\327\117\342\227\246'
|
||
printf '\046\351\267\077\233\322\025\227\032\175\353\037\075\215\216\201'
|
||
printf '\077\370\057\056\376\012\062\003\000\376\340\137\257\161\270\374'
|
||
printf '\142\243\177\363\371\224\272\073\201\202\304\077\375\003\126\167'
|
||
printf '\176\307\323\336\175\026\374\301\177\321\360\057\273\000\200\077'
|
||
printf '\370\327\143\034\034\107\372\314\207\034\175\346\103\216\034\256'
|
||
printf '\353\047\011\212\357\113\017\374\324\327\375\017\171\362\175\360'
|
||
printf '\007\377\306\343\057\225\161\010\000\374\301\277\036\343\260\264'
|
||
printf '\135\372\323\337\115\351\322\267\061\345\337\310\130\133\174\170'
|
||
printf '\326\116\073\143\214\224\062\106\306\024\377\114\352\037\307\221'
|
||
printf '\076\371\121\107\133\056\066\372\372\337\273\032\031\001\177\360'
|
||
printf '\157\054\376\013\316\000\200\077\370\327\143\034\066\136\144\364'
|
||
printf '\277\177\061\245\145\135\100\120\217\024\134\253\202\153\225\367'
|
||
printf '\354\364\237\013\256\225\177\001\372\163\276\147\106\162\214\121'
|
||
printf '\046\135\174\144\323\106\231\224\121\046\123\374\157\122\373\014'
|
||
printf '\016\132\335\161\247\247\003\007\175\360\007\377\206\341\077\157'
|
||
printf '\001\000\177\360\257\307\070\334\164\235\321\037\375\146\112\331'
|
||
printf '\014\033\376\132\305\363\254\046\013\126\023\071\137\343\071\137'
|
||
printf '\256\147\353\362\072\051\307\250\071\153\324\322\344\250\071\353'
|
||
printf '\050\233\246\020\324\052\256\053\335\365\075\127\117\077\347\203'
|
||
printf '\077\370\067\004\177\151\216\103\000\340\017\376\265\036\207\224'
|
||
printf '\221\076\367\161\107\267\375\012\007\373\153\265\227\077\072\341'
|
||
printf '\151\164\302\127\241\116\340\317\052\032\276\325\330\244\325\330'
|
||
printf '\144\021\251\114\312\250\255\305\121\133\113\112\031\312\100\125'
|
||
printf '\111\247\245\337\375\174\132\033\067\370\372\307\177\162\345\171'
|
||
printf '\340\017\376\365\305\277\144\001\000\177\360\257\365\070\054\151'
|
||
printf '\226\376\375\027\123\272\374\142\220\250\046\276\057\215\116\172'
|
||
printf '\032\031\367\225\053\370\213\137\102\074\253\201\121\117\003\243'
|
||
printf '\236\232\263\116\261\014\064\247\070\241\263\212\274\357\275\216'
|
||
printf '\172\227\245\365\365\073\135\215\117\200\077\370\327\017\177\351'
|
||
printf '\055\207\000\300\037\374\153\075\016\335\035\322\237\377\101\112'
|
||
printf '\353\127\203\177\065\173\336\303\143\236\206\306\074\371\066\334'
|
||
printf '\077\253\143\244\366\326\224\072\227\244\224\346\234\201\212\163'
|
||
printf '\342\244\325\127\276\352\252\177\240\316\333\055\360\117\054\376'
|
||
printf '\063\012\000\370\203\177\255\307\141\335\112\243\077\377\203\224'
|
||
printf '\172\226\262\101\257\044\256\147\065\064\346\151\170\334\053\353'
|
||
printf '\136\362\141\212\061\322\222\346\224\272\332\070\074\120\151\206'
|
||
printf '\206\254\376\366\153\256\016\037\265\340\017\376\065\307\177\272'
|
||
printf '\000\200\077\370\327\172\034\256\274\330\350\337\175\061\245\326'
|
||
printf '\146\066\344\101\343\133\151\140\304\325\360\230\047\033\361\337'
|
||
printf '\305\110\352\154\113\251\253\055\315\045\206\025\044\227\223\376'
|
||
printf '\307\067\134\355\174\275\306\127\010\200\177\342\361\227\212\063'
|
||
printf '\166\340\017\376\065\175\316\373\256\063\372\077\377\020\374\053'
|
||
printf '\311\370\244\257\243\147\362\032\212\001\376\123\037\307\301\121'
|
||
printf '\117\207\317\344\065\062\341\361\006\007\114\123\223\364\047\177'
|
||
printf '\224\326\365\357\160\300\037\374\153\212\277\124\301\152\200\340'
|
||
printf '\017\376\363\075\347\346\167\071\372\303\337\160\330\333\013\030'
|
||
printf '\327\263\072\063\344\152\042\347\307\362\367\363\074\253\063\203'
|
||
printf '\256\306\046\174\055\353\114\163\176\100\220\215\164\112\372\375'
|
||
printf '\337\115\053\223\161\365\314\271\313\004\301\037\374\153\361\036'
|
||
printf '\071\125\375\102\340\017\376\027\344\103\357\006\377\112\062\066'
|
||
printf '\351\353\150\137\076\266\370\317\230\341\310\025\147\070\246\056'
|
||
printf '\045\044\145\176\337\214\364\205\337\112\353\127\336\237\002\177'
|
||
printf '\360\257\315\173\144\003\314\000\200\077\370\317\367\234\117\276'
|
||
printf '\337\321\157\177\022\374\203\276\155\003\043\256\006\107\223\065'
|
||
printf '\065\356\133\351\324\100\101\035\255\051\365\164\160\156\100\220'
|
||
printf '\022\360\331\137\057\136\146\371\263\307\275\140\337\127\360\007'
|
||
printf '\377\022\343\220\256\350\027\002\177\360\277\040\267\175\320\321'
|
||
printf '\347\077\301\305\337\101\342\172\126\247\006\012\312\025\352\167'
|
||
printf '\244\377\354\210\257\103\247\074\035\075\353\351\170\177\361\061'
|
||
printf '\062\136\274\153\340\330\204\064\231\057\276\166\163\326\150\111'
|
||
printf '\213\324\234\061\352\150\065\132\335\235\322\352\356\224\326\364'
|
||
printf '\244\264\176\105\112\075\355\365\171\157\207\307\075\345\012\276'
|
||
printf '\126\164\145\070\044\020\240\004\374\346\147\122\152\156\226\036'
|
||
printf '\170\320\053\357\373\012\376\340\077\307\070\004\137\014\010\374'
|
||
printf '\301\377\202\174\354\046\360\017\232\274\153\165\262\277\120\363'
|
||
printf '\133\366\216\214\133\275\172\060\257\327\016\272\332\161\310\325'
|
||
printf '\311\201\362\366\022\307\162\126\143\271\363\377\374\332\041\167'
|
||
printf '\306\377\276\252\053\245\053\066\244\165\345\372\264\336\276\061'
|
||
printf '\253\266\226\332\141\235\053\130\035\353\053\150\125\167\106\331'
|
||
printf '\014\045\240\334\334\372\361\224\012\171\351\341\237\171\340\017'
|
||
printf '\376\025\217\203\371\130\220\305\200\300\037\374\057\310\007\336'
|
||
printf '\341\350\217\077\307\264\177\060\360\174\235\354\167\345\325\350'
|
||
printf '\216\076\005\317\352\325\003\256\236\174\055\257\155\273\013\162'
|
||
printf '\353\174\247\040\307\221\256\130\227\326\373\257\150\322\273\057'
|
||
printf '\315\324\154\075\000\307\221\126\166\145\324\234\245\114\226\275'
|
||
printf '\011\260\322\077\174\327\325\323\317\372\340\017\376\025\215\303'
|
||
printf '\234\005\000\374\301\177\276\347\274\353\112\243\077\375\002\267'
|
||
printf '\175\015\222\361\234\257\123\003\205\232\334\324\147\150\314\352'
|
||
printf '\201\355\223\172\344\345\274\106\027\351\204\272\266\146\107\037'
|
||
printf '\276\046\253\217\277\263\131\035\255\325\027\001\143\244\025\135'
|
||
printf '\031\265\066\361\241\052\067\276\057\175\343\133\256\266\277\344'
|
||
printf '\203\077\370\007\036\207\222\005\000\374\301\177\276\347\134\265'
|
||
printf '\331\350\077\374\313\224\062\151\221\062\063\221\363\165\262\006'
|
||
printf '\370\367\217\370\272\367\205\111\075\366\313\174\135\317\037\010'
|
||
printf '\222\246\214\321\315\157\317\352\326\167\065\253\273\255\072\274'
|
||
printf '\215\244\025\335\224\200\040\161\075\351\153\137\167\365\332\353'
|
||
printf '\076\370\203\177\240\161\230\125\000\300\037\374\347\173\316\326'
|
||
printf '\015\106\377\361\217\122\152\312\262\341\055\067\271\202\325\211'
|
||
printf '\263\371\252\356\343\357\171\322\117\137\311\351\356\247\046\247'
|
||
printf '\117\336\013\133\262\151\243\333\336\325\244\117\335\320\244\114'
|
||
printf '\025\047\365\031\043\255\352\346\160\100\240\317\130\136\372\353'
|
||
printf '\277\051\350\300\001\133\367\355\002\370\307\003\377\131\005\000'
|
||
printf '\374\301\177\276\347\364\166\111\377\371\177\113\253\263\215\015'
|
||
printf '\156\271\051\270\126\307\317\026\252\072\346\277\343\220\253\157'
|
||
printf '\076\072\241\343\375\321\270\134\160\115\167\112\377\342\127\133'
|
||
printf '\164\305\372\312\247\210\122\216\321\352\236\014\353\010\004\310'
|
||
printf '\350\250\364\027\137\052\250\257\257\176\333\107\360\217\017\376'
|
||
printf '\063\012\000\370\203\377\174\317\151\151\222\376\323\277\111\151'
|
||
printf '\355\052\066\310\345\357\265\133\035\073\133\371\331\376\276\057'
|
||
printf '\335\375\364\244\356\173\161\062\222\213\001\335\162\115\223\176'
|
||
printf '\373\003\315\112\073\225\175\146\322\051\243\065\313\062\112\071'
|
||
printf '\174\346\312\315\211\023\126\177\371\345\202\046\046\300\037\374'
|
||
printf '\313\054\000\340\017\376\363\075\307\061\322\237\375\213\224\256'
|
||
printf '\275\214\015\161\240\215\361\331\202\046\362\225\235\240\327\067'
|
||
printf '\354\353\157\036\030\327\336\343\321\276\111\320\306\025\051\375'
|
||
printf '\333\117\264\152\305\322\312\246\363\233\263\216\126\367\144\370'
|
||
printf '\060\005\310\316\327\175\175\365\153\256\174\037\374\301\177\376'
|
||
printf '\070\340\017\376\013\215\303\027\077\345\200\177\300\364\217\270'
|
||
printf '\025\343\277\343\220\253\377\343\377\033\325\276\023\236\214\121'
|
||
printf '\244\037\007\117\173\372\217\167\215\352\265\303\156\105\143\061'
|
||
printf '\231\367\065\060\342\362\201\012\220\313\057\163\364\231\117\247'
|
||
printf '\300\037\374\027\056\000\340\017\376\363\215\303\207\336\343\350'
|
||
printf '\226\033\071\031\053\110\046\362\176\305\267\367\335\276\257\240'
|
||
printf '\057\337\073\256\211\274\215\074\376\123\217\361\274\325\227\376'
|
||
printf '\171\134\317\355\316\127\064\046\003\243\136\042\326\111\250\145'
|
||
printf '\156\376\140\112\067\276\307\001\177\360\237\367\071\016\370\203'
|
||
printf '\377\134\343\260\151\235\321\357\175\012\374\203\304\363\255\116'
|
||
printf '\017\124\266\307\372\360\253\171\175\345\201\011\025\174\051\066'
|
||
printf '\372\237\173\270\126\272\343\241\111\075\374\152\145\045\340\364'
|
||
printf '\140\355\156\236\224\224\174\366\067\323\132\267\326\200\077\370'
|
||
printf '\317\371\363\071\340\017\376\245\176\206\045\055\322\237\176\301'
|
||
printf '\341\132\377\200\071\073\134\031\124\217\355\050\350\073\217\027'
|
||
printf '\117\366\063\212\347\303\132\351\073\217\117\352\341\127\202\227'
|
||
printf '\000\317\267\352\037\366\370\200\005\110\046\043\375\301\277\114'
|
||
printf '\253\265\005\374\301\277\364\153\071\340\017\376\157\375\031\214'
|
||
printf '\221\376\365\347\122\132\336\315\161\377\040\231\314\373\032\235'
|
||
printf '\010\076\125\375\322\233\005\175\373\211\211\270\355\364\317\371'
|
||
printf '\270\353\311\111\155\333\133\010\074\116\043\023\136\305\347\125'
|
||
printf '\044\065\275\313\214\176\357\013\301\127\134\004\377\370\343\177'
|
||
printf '\176\006\000\374\301\377\202\237\341\326\017\072\172\347\225\340'
|
||
printf '\037\364\355\353\033\012\076\365\277\353\250\247\333\037\314\311'
|
||
printf '\132\043\143\222\361\260\062\372\372\303\071\355\072\026\174\217'
|
||
printf '\376\354\220\053\016\004\004\313\125\127\071\372\340\007\122\340'
|
||
printf '\017\376\263\342\200\077\370\137\370\063\154\331\140\364\271\217'
|
||
printf '\161\334\077\150\206\106\075\345\335\140\337\310\241\061\253\073'
|
||
printf '\036\236\220\347\333\304\354\375\117\075\134\337\352\253\017\115'
|
||
printf '\150\140\054\330\230\345\135\253\341\061\016\005\004\315\247\177'
|
||
printf '\055\245\365\353\114\165\333\023\360\217\025\376\363\026\000\360'
|
||
printf '\117\036\376\115\131\351\117\376\027\107\051\374\017\024\337\112'
|
||
printf '\203\143\156\340\347\174\355\221\011\015\215\307\370\240\377\002'
|
||
printf '\217\341\011\253\377\361\360\304\234\327\253\317\225\201\021\127'
|
||
printf '\234\017\030\054\251\224\364\173\277\227\126\046\003\376\340\277'
|
||
printf '\100\001\000\377\344\341\057\111\237\377\204\243\125\275\114\375'
|
||
printf '\007\336\373\037\363\002\043\366\243\155\171\355\072\346\047\146'
|
||
printf '\332\177\256\307\356\343\276\356\335\036\354\244\100\337\212\131'
|
||
printf '\200\012\262\162\205\321\255\237\254\340\376\000\340\037\113\374'
|
||
printf '\113\026\000\360\117\046\376\127\154\066\272\345\275\354\372\007'
|
||
printf '\215\255\000\243\103\147\074\075\360\162\076\161\323\376\163\075'
|
||
printf '\356\177\051\257\303\175\301\306\160\150\314\213\334\355\221\303'
|
||
printf '\220\233\177\045\245\055\233\003\334\037\000\374\143\213\377\254'
|
||
printf '\002\000\376\311\304\277\245\271\170\326\277\141\347\077\160\206'
|
||
printf '\307\275\100\227\375\371\126\372\207\247\163\305\313\375\300\137'
|
||
printf '\306\024\113\324\267\177\036\154\265\104\317\267\032\036\147\026'
|
||
printf '\040\360\266\300\110\137\370\235\224\232\233\301\077\351\370\317'
|
||
printf '\050\000\340\237\114\374\045\351\013\267\072\132\326\305\306\061'
|
||
printf '\360\336\377\271\075\321\040\171\362\165\127\157\236\262\211\237'
|
||
printf '\372\177\353\343\340\031\137\317\354\016\166\036\305\020\207\001'
|
||
printf '\052\112\117\217\321\257\175\052\015\376\011\307\177\272\000\200'
|
||
printf '\177\162\361\277\170\235\321\257\274\213\251\377\112\062\221\363'
|
||
printf '\003\255\364\067\231\267\272\347\305\174\142\117\372\133\350\361'
|
||
printf '\203\027\162\312\025\312\037\117\327\263\334\042\270\302\334\164'
|
||
printf '\243\243\215\033\015\370\047\030\177\251\324\142\100\340\237\030'
|
||
printf '\374\035\107\372\303\337\160\230\372\257\060\243\023\301\366\100'
|
||
printf '\037\177\335\325\170\336\062\355\077\307\143\054\047\075\361\106'
|
||
printf '\260\131\200\221\011\146\001\052\332\166\031\351\163\237\115\313'
|
||
printf '\161\300\077\251\370\117\317\000\200\177\362\360\227\244\217\336'
|
||
printf '\344\150\303\032\364\257\044\276\225\306\046\313\337\373\054\170'
|
||
printf '\126\217\355\054\000\375\002\217\107\166\024\224\017\060\253\062'
|
||
printf '\066\351\163\111\140\205\131\273\326\350\175\067\245\300\077\241'
|
||
printf '\370\233\240\005\000\374\343\203\377\322\166\351\067\156\141\352'
|
||
printf '\277\322\214\115\004\073\013\375\251\335\236\206\306\045\303\177'
|
||
printf '\346\375\317\360\270\364\354\356\362\367\352\255\225\306\046\231'
|
||
printf '\005\250\064\267\336\232\122\147\247\001\377\004\342\037\150\006'
|
||
printf '\000\374\343\203\277\044\375\356\155\051\265\066\263\001\254\064'
|
||
printf '\243\223\301\216\075\077\265\313\145\017\277\314\307\317\003\036'
|
||
printf '\006\030\233\340\074\200\112\323\334\054\175\352\266\124\175\267'
|
||
printf '\101\340\037\332\161\160\152\376\042\340\037\172\374\067\255\065'
|
||
printf '\172\317\065\114\375\127\032\153\213\013\377\224\233\303\175\276'
|
||
printf '\116\014\370\340\136\346\343\304\240\257\043\375\345\217\357\144'
|
||
printf '\336\147\175\200\052\162\375\365\216\326\275\345\066\301\340\037'
|
||
printf '\177\374\313\052\000\340\037\057\374\045\351\267\076\301\211\177'
|
||
printf '\325\044\127\360\003\115\377\077\277\337\103\365\200\217\027\366'
|
||
printf '\225\077\255\357\133\051\307\052\201\025\307\030\351\266\013\146'
|
||
printf '\001\300\077\031\370\057\130\000\300\077\176\370\277\375\022\243'
|
||
printf '\053\067\243\177\065\231\310\007\273\361\317\366\003\114\377\007'
|
||
printf '\175\154\077\020\354\034\213\040\357\011\231\235\113\057\165\164'
|
||
printf '\311\045\016\370\047\010\377\171\013\000\370\307\017\177\143\244'
|
||
printf '\337\142\245\277\352\013\100\200\153\317\217\234\365\065\072\011'
|
||
printf '\350\101\037\303\023\126\107\007\002\034\006\340\176\000\125\347'
|
||
printf '\323\237\016\176\067\120\360\217\056\376\222\224\006\377\144\340'
|
||
printf '\057\111\067\136\143\264\361\042\366\376\253\115\256\120\076\066'
|
||
printf '\173\117\026\027\374\041\301\263\367\244\257\265\335\345\025\326'
|
||
printf '\311\002\005\240\332\134\164\221\321\265\327\072\372\305\057\312'
|
||
printf '\033\113\360\217\066\376\045\147\000\300\077\236\370\073\106\372'
|
||
printf '\364\207\331\373\257\066\005\317\006\232\232\336\163\212\223\377'
|
||
printf '\052\175\354\075\131\376\100\133\253\100\167\145\044\245\363\261'
|
||
printf '\217\227\067\013\000\376\321\307\137\266\232\305\200\300\077\062'
|
||
printf '\370\033\111\327\137\151\264\146\071\173\242\125\027\000\067\030'
|
||
printf '\112\373\317\130\156\363\133\341\143\357\351\140\147\367\007\171'
|
||
printf '\157\110\351\254\134\151\164\325\125\016\370\047\000\177\351\202'
|
||
printf '\103\000\340\037\137\374\045\351\223\037\144\357\277\321\005\240'
|
||
printf '\177\314\052\357\212\103\000\025\046\347\112\203\343\126\135\255'
|
||
printf '\345\215\137\336\265\152\151\142\334\252\315\207\157\111\351\325'
|
||
printf '\127\175\360\217\071\376\323\005\000\374\343\215\377\025\233\215'
|
||
printf '\066\257\007\241\106\027\200\323\043\226\313\055\253\314\351\341'
|
||
printf '\362\013\000\063\000\265\311\206\015\106\233\067\033\355\335\133'
|
||
printf '\075\174\340\037\356\161\160\300\077\336\370\113\322\155\067\263'
|
||
printf '\367\137\263\002\020\340\070\363\231\141\313\114\176\225\217\063'
|
||
printf '\303\301\126\007\044\265\311\207\076\234\002\377\230\343\077\075'
|
||
printf '\003\000\376\361\305\177\343\105\106\127\155\141\067\264\126\361'
|
||
printf '\003\254\074\323\067\312\364\177\265\071\063\132\376\377\327\343'
|
||
printf '\102\200\232\345\262\313\034\255\131\143\164\354\230\005\377\230'
|
||
printf '\342\137\376\142\100\340\037\111\374\045\351\303\357\001\240\232'
|
||
printf '\026\200\000\137\346\361\074\047\000\126\373\030\317\007\071\351'
|
||
printf '\222\031\200\132\305\030\351\246\233\122\340\037\143\374\125\126'
|
||
printf '\001\000\377\310\342\337\322\044\275\373\032\246\377\153\231\040'
|
||
printf '\306\344\134\056\345\253\366\221\013\260\056\020\313\002\327\066'
|
||
printf '\357\274\336\121\163\163\005\333\055\360\217\314\070\244\301\077'
|
||
printf '\236\370\113\322\115\327\071\234\025\135\363\031\200\362\277\325'
|
||
printf '\134\001\120\175\362\156\175\336\033\262\160\232\233\245\153\257'
|
||
printf '\163\364\354\063\001\156\014\004\376\221\032\207\064\370\307\023'
|
||
printf '\177\111\272\371\335\340\123\363\031\200\000\307\231\013\276\270'
|
||
printf '\012\240\332\002\340\325\347\275\041\345\345\306\033\123\145\025'
|
||
printf '\000\360\217\346\070\244\301\077\236\370\137\274\336\150\303\032'
|
||
printf '\364\251\171\001\010\064\133\100\001\250\066\101\246\365\331\377'
|
||
printf '\257\175\326\255\067\132\267\316\350\360\141\013\376\061\054\101'
|
||
printf '\151\360\217\037\376\222\364\301\353\221\147\261\063\165\034\233'
|
||
printf '\124\067\206\144\161\163\303\173\122\072\174\330\005\377\030\316'
|
||
printf '\200\070\340\037\077\374\123\216\164\375\225\234\374\027\232\006'
|
||
printf '\300\243\272\007\131\324\134\173\255\043\307\001\377\070\316\200'
|
||
printf '\244\301\077\136\370\113\322\025\133\214\072\332\330\160\261\007'
|
||
printf '\113\110\365\151\153\223\056\336\354\150\317\156\037\374\143\126'
|
||
printf '\202\322\340\037\057\374\045\351\335\157\107\235\060\115\000\020'
|
||
printf '\012\124\034\146\001\246\012\000\370\307\245\004\111\151\360\217'
|
||
printf '\027\376\251\224\364\116\246\377\103\202\227\001\260\032\214\041'
|
||
printf '\131\374\134\175\215\243\177\372\336\271\053\055\300\077\026\370'
|
||
printf '\113\347\316\001\000\377\170\340\057\111\157\337\152\324\326\312'
|
||
printf '\006\053\024\170\361\250\311\203\054\176\332\332\244\255\133\035'
|
||
printf '\360\217\021\376\322\254\305\200\300\077\312\370\113\322\165\227'
|
||
printf '\263\311\244\001\320\000\110\355\163\305\025\246\372\155\035\370'
|
||
printf '\207\006\177\151\306\145\200\340\037\165\374\045\351\112\026\376'
|
||
printf '\011\217\377\034\002\250\311\030\222\160\344\322\313\034\111\345'
|
||
printf '\335\231\011\374\303\217\277\071\137\000\300\077\016\370\257\134'
|
||
printf '\146\264\242\207\015\146\270\000\143\014\110\074\262\174\205\121'
|
||
printf '\317\062\243\263\175\026\374\143\200\377\271\031\000\360\217\003'
|
||
printf '\376\122\361\370\077\011\027\376\024\000\012\124\234\162\311\045'
|
||
printf '\106\317\074\155\301\077\006\370\113\013\055\006\004\376\221\031'
|
||
printf '\007\043\246\377\303\207\027\207\000\152\061\206\044\104\005\340'
|
||
printf '\062\107\317\074\355\203\177\014\360\057\253\000\200\177\064\360'
|
||
printf '\117\071\322\345\233\331\130\206\113\057\161\022\133\055\306\220'
|
||
printf '\204\046\133\057\051\336\025\320\367\301\077\352\370\057\130\000'
|
||
printf '\300\077\032\370\113\322\372\325\106\255\315\042\241\332\173\145'
|
||
printf '\012\273\026\143\110\302\223\226\026\151\365\152\243\243\107\055'
|
||
printf '\370\107\034\377\171\013\000\370\107\007\177\111\332\264\216\055'
|
||
printf '\145\050\047\000\020\214\011\200\230\145\375\206\363\005\000\374'
|
||
printf '\243\213\377\234\005\000\374\243\205\277\124\134\376\227\204\117'
|
||
printf '\057\374\247\001\304\257\000\024\317\003\000\377\150\343\137\262'
|
||
printf '\000\200\177\364\360\227\244\213\327\261\141\012\235\135\024\200'
|
||
printf '\232\214\041\011\337\014\000\370\107\037\377\131\005\000\374\243'
|
||
printf '\211\177\153\263\264\172\071\133\312\360\341\305\125\000\265\051'
|
||
printf '\000\226\201\010\121\126\255\066\152\152\226\162\223\340\037\145'
|
||
printf '\374\245\163\153\001\200\177\164\361\227\244\267\255\005\032\102'
|
||
printf '\110\343\112\331\332\265\345\157\160\300\077\234\370\117\317\000'
|
||
printf '\200\177\164\361\227\244\165\253\320\077\254\033\112\212\131\055'
|
||
printf '\146\000\110\370\146\001\034\355\333\273\360\155\201\301\077\274'
|
||
printf '\370\113\122\032\374\243\215\277\044\255\132\316\006\051\224\170'
|
||
printf '\211\231\231\352\307\260\202\055\064\251\173\126\254\140\317\077'
|
||
printf '\352\370\117\317\000\200\177\164\361\227\244\325\275\050\023\126'
|
||
printf '\275\050\000\065\151\000\044\144\131\276\322\200\177\304\361\067'
|
||
printf '\101\013\000\370\207\017\177\111\132\105\001\010\247\135\024\200'
|
||
printf '\232\214\041\011\141\001\230\347\244\143\360\217\006\376\201\146'
|
||
printf '\000\300\077\234\370\067\145\245\256\116\066\110\241\335\173\005'
|
||
printf '\060\146\000\142\230\256\156\243\114\106\052\024\300\077\252\370'
|
||
printf '\313\126\263\030\020\370\057\072\376\123\173\377\354\045\205\165'
|
||
printf '\357\225\367\206\031\200\370\276\057\275\313\215\216\037\013\160'
|
||
printf '\113\140\360\017\025\376\145\315\000\200\177\170\361\227\244\145'
|
||
printf '\113\331\030\205\172\002\000\300\230\000\210\151\272\273\317\027'
|
||
printf '\000\360\217\036\376\013\026\000\360\017\067\376\262\322\322\166'
|
||
printf '\066\221\141\336\113\242\000\060\003\020\327\264\167\260\347\037'
|
||
printf '\145\374\347\055\000\340\037\176\374\215\244\245\035\154\210\302'
|
||
printf '\254\027\200\061\005\020\337\002\140\300\077\302\370\317\131\000'
|
||
printf '\300\077\032\370\113\122\147\073\033\042\146\000\230\001\040\215'
|
||
printf '\117\307\102\333\036\360\017\065\376\322\005\267\002\006\377\350'
|
||
printf '\341\057\111\235\155\154\041\011\041\213\063\003\000\376\321\305'
|
||
printf '\177\326\014\000\370\107\013\177\146\000\242\060\003\100\101\253'
|
||
printf '\156\014\271\013\140\344\012\000\370\107\002\377\031\005\000\374'
|
||
printf '\243\207\277\044\265\266\260\041\012\055\136\142\012\273\026\143'
|
||
printf '\110\302\231\326\126\360\217\062\376\323\005\000\374\243\211\277'
|
||
printf '\044\145\062\154\210\302\075\003\300\070\124\073\206\044\234\111'
|
||
printf '\247\301\077\312\370\113\163\055\006\004\376\221\300\137\222\262'
|
||
printf '\151\266\220\141\326\213\103\000\114\001\304\266\000\144\300\077'
|
||
printf '\312\370\117\317\000\200\177\064\361\057\331\302\111\270\360\002'
|
||
printf '\060\012\100\114\223\111\203\177\224\361\237\275\030\020\370\107'
|
||
printf '\012\177\211\103\000\041\237\000\010\345\024\166\066\045\265\067'
|
||
printf '\111\115\347\276\375\071\127\032\311\111\171\057\234\143\110\302'
|
||
printf '\072\003\140\300\077\302\370\317\234\001\000\377\310\341\077\243'
|
||
printf '\205\223\020\356\274\056\376\041\000\143\244\215\135\322\226\145'
|
||
printf '\322\246\036\151\145\233\324\321\134\372\377\073\074\051\235\030'
|
||
printf '\221\336\354\227\366\364\111\007\006\044\153\027\173\014\111\150'
|
||
printf '\147\000\062\340\037\145\374\317\027\000\360\217\044\376\222\224'
|
||
printf '\162\330\020\061\003\060\073\235\315\322\215\033\244\167\256\221'
|
||
printf '\226\226\171\245\110\107\163\361\261\265\127\372\350\126\151\140'
|
||
printf '\102\332\176\124\172\352\240\064\234\143\006\200\274\145\333\223'
|
||
printf '\002\377\050\343\137\054\000\340\037\131\374\045\311\365\230\005'
|
||
printf '\240\000\234\117\133\126\372\310\026\351\135\153\245\164\225\345'
|
||
printf '\260\253\105\372\320\146\351\203\233\244\347\217\110\017\355\221'
|
||
printf '\306\362\024\000\162\156\333\343\202\177\224\361\077\077\003\000'
|
||
printf '\376\221\304\137\222\362\171\012\100\230\013\200\323\100\300\336'
|
||
printf '\265\126\372\304\045\122\153\215\317\013\111\073\322\215\353\245'
|
||
printf '\153\126\111\367\355\222\136\074\112\001\040\122\241\000\376\121'
|
||
printf '\306\177\336\002\000\376\341\307\137\222\012\056\033\242\244\317'
|
||
printf '\000\064\247\245\137\277\102\272\172\125\175\137\147\111\126\372'
|
||
printf '\334\125\322\326\145\322\017\166\026\117\036\244\000\044\170\006'
|
||
printf '\240\140\301\077\302\370\317\131\000\300\077\032\370\033\111\205'
|
||
printf '\202\025\247\112\205\063\216\112\054\266\121\343\264\065\111\277'
|
||
printf '\377\016\151\115\003\127\205\274\146\265\264\252\135\272\363\305'
|
||
printf '\372\237\033\300\051\056\341\237\001\000\377\150\342\137\362\373'
|
||
printf '\005\376\321\301\137\222\362\314\000\104\142\026\240\036\217\316'
|
||
printf '\146\351\117\156\150\054\376\123\131\331\056\375\361\015\305\223'
|
||
printf '\006\353\371\073\222\020\317\000\270\145\154\340\300\077\264\370'
|
||
printf '\317\052\000\340\037\055\374\045\051\137\020\011\353\014\200\251'
|
||
printf '\337\143\111\266\270\347\337\323\272\170\277\137\117\153\361\147'
|
||
printf '\150\315\324\367\167\045\121\234\001\000\377\260\343\077\243\000'
|
||
printf '\200\177\364\360\227\244\311\234\110\302\366\376\035\123\074\346'
|
||
printf '\277\062\004\053\101\256\152\057\236\027\340\060\013\220\270\214'
|
||
printf '\217\132\360\217\060\376\322\174\213\001\201\177\350\361\227\254'
|
||
printf '\006\207\071\007\040\314\005\240\036\173\260\357\135\057\135\266'
|
||
printf '\074\074\277\347\326\136\351\075\353\245\347\016\327\147\014\111'
|
||
printf '\070\063\074\014\376\121\306\137\232\153\061\040\360\217\004\376'
|
||
printf '\222\064\070\314\206\050\354\063\000\265\114\147\263\164\363\246'
|
||
printf '\360\375\256\037\276\130\332\325\047\015\116\120\000\222\222\221'
|
||
printf '\141\013\376\021\306\137\252\360\044\133\360\017\007\376\305\002'
|
||
printf '\140\105\302\031\107\265\077\036\376\361\255\305\173\371\207\055'
|
||
printf '\231\224\364\221\315\165\070\007\200\217\121\170\013\300\010\370'
|
||
printf '\107\031\377\331\213\001\201\177\244\360\227\244\001\146\000\022'
|
||
printf '\063\003\260\242\115\272\244\067\274\277\357\145\313\213\347\045'
|
||
printf '\234\032\145\006\040\021\005\140\310\202\177\204\361\017\074\003'
|
||
printf '\000\376\341\302\237\031\200\220\317\000\070\265\335\033\276\161'
|
||
printf '\175\270\317\366\060\222\336\273\256\306\063\000\114\001\204\174'
|
||
printf '\006\000\374\243\212\277\202\314\000\200\177\370\360\147\006\140'
|
||
printf '\021\120\067\222\137\346\027\064\355\330\262\127\003\064\246\270'
|
||
printf '\122\337\272\116\251\167\211\324\371\326\345\172\363\322\145\275'
|
||
printf '\341\037\237\113\173\245\007\367\326\156\151\341\114\312\006\172'
|
||
printf '\157\110\343\162\266\317\007\377\010\343\137\166\001\000\377\160'
|
||
printf '\342\057\111\175\375\126\326\062\125\332\260\275\134\307\110\136'
|
||
printf '\171\337\322\046\147\141\224\226\066\113\357\130\043\135\276\274'
|
||
printf '\270\220\117\324\223\111\025\113\300\216\123\347\077\313\355\115'
|
||
printf '\305\363\026\322\216\064\351\026\027\024\052\370\345\375\373\262'
|
||
printf '\001\146\000\034\032\100\303\342\171\122\377\131\013\376\021\306'
|
||
printf '\277\254\002\000\376\341\305\137\222\162\371\142\011\350\355\141'
|
||
printf '\343\327\250\031\200\162\167\156\263\251\271\013\100\153\106\372'
|
||
printf '\300\106\351\312\025\361\333\163\275\142\105\161\066\143\355\271'
|
||
printf '\331\214\122\253\022\016\115\112\307\206\245\003\003\322\356\076'
|
||
printf '\051\347\315\125\242\312\337\052\122\202\033\227\276\063\126\236'
|
||
printf '\007\376\121\306\177\301\002\000\376\341\306\177\352\071\107\117'
|
||
printf '\111\275\075\154\224\032\125\000\312\337\033\056\275\130\312\226'
|
||
printf '\036\351\143\133\213\213\370\304\061\157\353\052\076\346\113\147'
|
||
printf '\163\361\161\331\162\351\226\315\322\153\247\212\113\016\017\116'
|
||
printf '\316\236\121\250\307\173\103\252\313\351\123\026\374\043\216\277'
|
||
printf '\064\317\111\200\340\037\015\374\045\351\330\111\116\004\154\134'
|
||
printf '\001\050\377\035\156\113\333\131\047\265\275\177\203\364\351\313'
|
||
printf '\343\213\177\045\111\073\305\225\014\377\340\235\305\131\221\251'
|
||
printf '\231\023\307\110\355\231\000\347\000\320\000\032\132\000\300\077'
|
||
printf '\332\370\317\131\000\300\077\072\370\113\322\261\123\024\200\206'
|
||
printf '\141\025\340\326\131\355\115\166\306\055\155\177\165\223\364\356'
|
||
printf '\165\214\341\134\111\031\351\206\265\322\157\137\055\165\267\026'
|
||
printf '\307\054\110\001\110\247\050\000\215\112\137\205\333\034\360\017'
|
||
printf '\017\376\045\013\000\370\107\013\177\111\072\116\001\150\130\062'
|
||
printf '\001\220\151\317\234\237\001\170\317\072\351\332\325\214\137\071'
|
||
printf '\131\276\104\372\374\333\213\253\034\266\067\225\377\331\316\244'
|
||
printf '\051\000\215\312\321\043\176\340\347\200\177\270\360\227\255\146'
|
||
printf '\065\100\360\017\005\376\222\164\364\104\361\112\000\322\200\002'
|
||
printf '\220\016\166\010\040\145\244\015\135\305\002\100\312\117\113\132'
|
||
printf '\372\265\113\245\326\000\227\001\146\231\001\150\110\334\202\164'
|
||
printf '\342\130\260\015\016\370\207\017\377\031\063\000\340\037\115\374'
|
||
printf '\145\213\053\002\036\345\074\200\320\025\000\143\244\345\113\174'
|
||
printf '\175\150\023\313\065\125\222\341\234\015\164\146\077\063\000\215'
|
||
printf '\311\221\303\376\364\025\000\340\037\135\374\247\013\000\370\107'
|
||
printf '\027\377\251\354\171\223\002\320\220\002\020\160\057\363\342\156'
|
||
printf '\251\243\211\161\253\044\043\023\066\320\167\212\163\000\032\223'
|
||
printf '\303\007\203\275\057\340\037\116\374\245\240\127\316\200\177\050'
|
||
printf '\361\227\244\075\007\050\000\215\210\061\122\123\246\374\167\277'
|
||
printf '\043\355\063\150\025\306\365\312\037\273\154\306\160\037\200\106'
|
||
printf '\025\200\103\345\275\057\340\037\156\374\247\147\000\300\077\332'
|
||
printf '\370\113\322\156\012\100\303\322\034\340\366\164\031\343\225\175'
|
||
printf '\327\073\162\076\171\117\312\250\374\171\346\226\046\026\015\150'
|
||
printf '\130\001\070\120\346\166\013\374\103\215\277\051\273\000\200\177'
|
||
printf '\250\361\227\244\063\147\255\372\007\051\001\215\110\020\154\214'
|
||
printf '\225\116\216\360\276\004\315\311\141\053\023\140\330\132\262\024'
|
||
printf '\200\106\144\150\320\252\357\214\005\377\030\340\137\336\014\000'
|
||
printf '\370\207\036\377\251\354\075\010\064\215\232\001\010\362\131\030'
|
||
printf '\237\364\030\264\200\231\310\225\077\146\306\004\233\225\041\225'
|
||
printf '\147\327\353\076\370\307\004\377\205\013\000\370\107\006\177\043'
|
||
printf '\351\365\275\024\200\106\304\061\122\123\000\160\322\276\247\261'
|
||
printf '\074\343\126\166\141\052\024\307\254\334\064\145\034\216\377\067'
|
||
printf '\050\273\347\051\000\340\037\055\374\347\057\000\340\037\051\374'
|
||
printf '\045\351\245\327\270\037\100\243\322\332\354\004\372\034\234\342'
|
||
printf '\060\100\331\071\071\034\354\362\277\045\315\354\375\067\042\326'
|
||
printf '\112\173\167\133\360\217\011\376\163\027\000\360\217\034\376\222'
|
||
printf '\064\060\144\165\370\070\320\064\042\355\001\321\261\371\002\047'
|
||
printf '\003\226\021\327\227\374\174\041\320\367\254\255\205\002\320\210'
|
||
printf '\034\071\144\065\132\242\310\202\177\064\361\057\135\000\300\077'
|
||
printf '\222\370\117\345\345\327\050\000\215\110\052\145\202\235\014\050'
|
||
printf '\253\343\103\274\067\013\345\350\220\225\023\140\053\332\322\344'
|
||
printf '\050\305\042\100\015\111\251\343\377\340\037\135\374\147\027\000'
|
||
printf '\360\217\064\376\222\364\362\116\166\063\033\066\013\020\160\317'
|
||
printf '\063\237\163\345\321\001\346\214\347\113\356\244\033\350\071\155'
|
||
printf '\055\051\006\256\101\371\345\313\036\370\307\010\377\231\005\000'
|
||
printf '\374\043\217\277\044\275\171\304\152\200\075\315\206\144\111\163'
|
||
printf '\052\320\235\264\122\326\327\021\056\325\234\063\207\007\175\071'
|
||
printf '\052\277\300\072\206\343\377\215\112\337\031\253\143\107\054\370'
|
||
printf '\307\010\377\363\005\000\374\143\201\277\124\074\121\347\225\327'
|
||
printf '\101\246\021\061\106\352\130\022\154\017\324\233\314\163\105\100'
|
||
printf '\211\214\346\203\035\373\227\212\143\317\331\377\215\311\053\333'
|
||
printf '\175\360\217\031\376\305\002\000\376\261\301\177\052\317\154\347'
|
||
printf '\060\100\243\322\031\020\041\043\351\304\240\313\300\275\045\047'
|
||
printf '\007\335\100\067\376\061\246\070\366\244\061\171\171\273\007\376'
|
||
printf '\061\303\177\172\006\000\374\343\203\277\044\355\176\323\352\124'
|
||
printf '\037\263\000\215\110\312\061\152\157\015\006\221\343\171\072\301'
|
||
printf '\145\201\323\071\061\142\345\170\301\156\226\324\321\232\342\344'
|
||
printf '\277\006\345\364\051\253\343\307\054\370\307\014\177\051\350\142'
|
||
printf '\100\340\037\172\374\245\342\141\200\147\267\003\114\243\262\264'
|
||
printf '\202\251\350\211\321\274\106\071\024\240\261\274\064\036\160\040'
|
||
printf '\330\373\157\364\336\277\017\376\061\304\177\172\006\000\374\343'
|
||
printf '\203\377\324\163\236\334\346\163\123\240\006\045\235\062\352\150'
|
||
printf '\015\016\322\311\201\102\242\257\012\360\254\164\142\240\020\370'
|
||
printf '\063\336\321\232\142\351\337\006\305\132\351\305\147\075\360\217'
|
||
printf '\041\376\345\057\006\004\376\221\302\137\222\372\372\055\113\004'
|
||
printf '\067\060\135\355\351\300\123\322\216\357\353\160\177\162\317\327'
|
||
printf '\070\334\357\313\361\203\375\376\051\307\250\253\075\315\007\256'
|
||
printf '\101\331\265\323\127\177\300\303\211\340\037\015\374\003\315\000'
|
||
printf '\200\177\164\360\237\312\123\333\070\031\260\121\161\214\324\335'
|
||
printf '\021\174\026\300\346\013\072\074\220\274\367\351\320\200\057\033'
|
||
printf '\360\254\177\111\352\351\110\213\103\377\215\313\163\117\006\073'
|
||
printf '\067\003\374\243\203\177\331\005\000\374\243\207\277\044\075\367'
|
||
printf '\222\257\221\061\066\142\215\112\173\113\252\242\145\151\335\311'
|
||
printf '\202\216\045\350\336\015\307\207\255\274\311\340\370\067\147\035'
|
||
printf '\156\373\333\300\014\017\131\275\276\243\374\162\012\376\321\302'
|
||
printf '\277\254\002\000\376\321\304\137\222\362\171\351\361\147\231\005'
|
||
printf '\150\144\172\072\323\025\135\233\076\071\236\327\311\004\134\031'
|
||
printf '\160\142\304\152\242\202\033\041\030\043\365\166\062\365\337\320'
|
||
printf '\275\377\247\174\225\173\204\006\374\243\207\377\202\005\000\374'
|
||
printf '\243\213\377\124\036\175\332\227\313\162\364\015\113\066\155\324'
|
||
printf '\323\221\256\350\175\034\037\315\353\150\214\147\002\216\016\131'
|
||
printf '\115\214\346\053\372\234\057\353\110\053\223\146\356\277\121\361'
|
||
printf '\134\351\371\247\274\262\077\273\340\037\075\374\347\055\000\340'
|
||
printf '\037\175\374\245\342\012\201\317\277\304\054\100\043\323\321\232'
|
||
printf '\252\170\252\072\077\236\327\341\001\137\161\252\001\126\305\143'
|
||
printf '\376\371\361\312\256\173\154\153\161\002\337\153\201\124\227\355'
|
||
printf '\057\170\032\032\254\160\133\007\376\221\300\177\316\002\000\376'
|
||
printf '\361\300\177\052\077\171\214\113\002\033\235\145\235\231\212\367'
|
||
printf '\130\335\311\202\016\234\161\225\213\301\314\115\336\223\016\366'
|
||
printf '\271\025\035\363\227\244\114\332\150\131\147\206\017\124\043\013'
|
||
printf '\233\225\236\170\144\341\017\037\370\107\033\377\222\005\000\374'
|
||
printf '\343\205\277\044\035\071\156\265\153\037\015\240\221\161\214\264'
|
||
printf '\142\151\246\362\063\326\135\117\107\317\024\324\077\021\335\367'
|
||
printf '\155\140\322\352\110\137\101\266\340\055\316\030\222\212\362\332'
|
||
printf '\053\276\116\235\260\340\037\163\374\147\025\000\360\217\037\376'
|
||
printf '\123\343\160\317\203\234\010\320\350\144\063\106\053\272\063\025'
|
||
printf '\057\130\143\254\257\201\301\274\216\014\372\362\042\164\024\307'
|
||
printf '\365\245\043\203\276\372\007\362\062\276\137\361\167\160\105\127'
|
||
printf '\106\331\014\372\067\072\217\077\354\201\177\002\360\237\121\000'
|
||
printf '\300\077\276\370\113\322\356\375\126\073\167\063\013\320\350\264'
|
||
printf '\144\035\365\126\061\205\155\044\025\046\012\072\324\127\320\231'
|
||
printf '\261\360\277\177\375\023\126\207\317\024\124\230\050\250\032\272'
|
||
printf '\227\055\115\253\245\211\113\376\032\235\175\273\175\035\174\323'
|
||
printf '\007\377\004\340\057\331\032\057\006\004\376\241\036\207\357\337'
|
||
printf '\357\161\056\300\042\244\255\305\321\262\152\057\141\363\174\215'
|
||
printf '\014\347\165\260\317\325\120\056\174\277\343\340\244\325\301\076'
|
||
printf '\127\203\203\171\311\257\156\272\242\247\043\255\366\026\116\372'
|
||
printf '\133\214\074\170\257\007\376\011\301\137\252\345\142\100\340\037'
|
||
printf '\372\161\170\363\260\325\053\073\271\042\140\061\322\321\232\122'
|
||
printf '\167\015\156\141\353\027\074\235\355\317\351\140\237\033\212\363'
|
||
printf '\003\206\163\305\223\374\372\007\362\362\013\325\037\146\352\156'
|
||
printf '\117\263\320\317\042\145\307\313\276\016\354\367\301\077\041\370'
|
||
printf '\113\122\272\046\057\002\376\221\031\207\037\074\340\353\352\313'
|
||
printf '\235\212\217\113\223\312\263\264\055\245\124\112\352\033\164\253'
|
||
printf '\276\314\317\057\170\032\034\364\064\064\354\050\333\222\122\167'
|
||
printf '\253\243\226\006\335\047\047\347\111\003\343\126\023\223\256\254'
|
||
printf '\133\273\102\331\333\231\346\162\277\105\212\357\113\077\271\327'
|
||
printf '\005\377\004\341\157\202\026\000\360\217\376\070\034\071\156\365'
|
||
printf '\302\313\276\156\270\226\343\253\213\221\366\226\224\122\306\350'
|
||
printf '\324\140\241\046\207\143\254\357\053\067\346\353\304\230\344\144'
|
||
printf '\122\152\156\112\251\255\311\150\111\126\252\125\307\263\222\106'
|
||
printf '\363\322\130\316\152\062\347\325\144\117\177\306\347\334\110\313'
|
||
printf '\227\146\264\244\231\317\344\142\345\305\347\274\222\147\376\203'
|
||
printf '\177\174\361\017\064\003\000\376\361\031\207\273\357\365\165\315'
|
||
printf '\025\216\232\262\154\370\026\043\255\315\216\126\165\147\164\152'
|
||
printf '\300\225\347\327\156\032\337\057\170\032\057\170\032\037\055\176'
|
||
printf '\200\122\331\264\262\151\243\154\332\250\051\155\324\234\226\322'
|
||
printf '\013\030\353\372\322\204\053\345\135\073\375\360\362\256\352\165'
|
||
printf '\147\242\224\143\264\242\053\255\346\054\370\057\126\334\202\364'
|
||
printf '\323\373\074\360\117\030\376\262\145\026\000\360\217\327\070\364'
|
||
printf '\017\132\335\377\250\247\317\174\214\351\326\305\112\163\326\321'
|
||
printf '\105\275\031\235\036\164\065\221\253\303\171\031\126\362\162\256'
|
||
printf '\046\162\322\304\133\076\133\326\221\214\034\031\147\152\026\101'
|
||
printf '\262\362\145\174\065\364\016\204\055\131\107\313\273\202\057\243'
|
||
printf '\114\152\233\307\036\366\064\070\140\301\077\141\370\113\225\056'
|
||
printf '\006\004\376\221\037\207\237\374\314\327\311\323\134\022\260\230'
|
||
printf '\111\071\106\253\272\063\065\071\071\060\320\246\300\057\036\072'
|
||
printf '\360\335\342\303\372\176\361\357\032\370\273\057\155\113\151\125'
|
||
printf '\117\006\374\027\071\003\147\255\036\173\310\005\377\004\342\277'
|
||
printf '\140\001\000\377\170\216\203\221\344\272\322\077\374\220\233\003'
|
||
printf '\205\041\123\030\246\123\361\307\060\223\062\132\325\323\330\322'
|
||
printf '\103\346\316\017\357\166\225\317\203\177\022\361\237\267\000\200'
|
||
printf '\177\174\361\237\312\216\135\126\057\277\306\145\201\141\110\113'
|
||
printf '\326\321\332\336\254\272\332\122\261\274\102\303\110\352\134\222'
|
||
printf '\322\232\336\254\132\070\336\037\212\354\170\331\327\353\277\364'
|
||
printf '\301\077\241\370\317\131\000\300\077\376\370\117\345\256\173\374'
|
||
printf '\031\173\000\144\021\221\064\122\127\173\132\027\055\313\252\065'
|
||
printf '\106\167\301\153\311\072\272\250\067\253\236\216\064\367\365\017'
|
||
printf '\111\362\071\351\107\377\344\202\177\202\361\057\131\000\300\077'
|
||
printf '\071\370\113\322\231\263\126\337\373\061\207\002\302\224\114\332'
|
||
printf '\150\145\167\106\053\273\063\221\076\073\276\071\353\150\145\167'
|
||
printf '\106\253\172\052\137\031\221\324\047\017\335\347\152\240\337\202'
|
||
printf '\177\202\361\227\336\162\025\000\370\047\013\377\251\374\354\151'
|
||
printf '\137\127\137\341\350\312\113\330\110\207\051\255\115\216\132\233'
|
||
printf '\034\115\346\175\015\216\172\032\317\105\343\160\115\163\326\321'
|
||
printf '\322\045\051\265\162\135\177\050\163\160\277\257\047\177\346\201'
|
||
printf '\177\302\361\237\061\003\000\376\311\304\137\052\256\377\375\215'
|
||
printf '\177\364\064\066\316\306\061\314\173\322\153\226\145\325\336\232'
|
||
printf '\222\023\102\127\035\107\152\157\115\151\315\262\254\126\367\144'
|
||
printf '\300\077\244\311\347\244\357\176\313\225\357\203\177\322\361\237'
|
||
printf '\056\000\340\237\134\374\247\062\060\144\165\367\275\034\012\010'
|
||
printf '\163\232\062\106\275\235\151\255\137\336\244\225\135\305\073\347'
|
||
printf '\055\366\011\203\055\115\216\172\227\026\177\246\336\316\264\232'
|
||
printf '\130\276\067\324\271\367\373\256\316\234\266\340\017\376\222\244'
|
||
printf '\064\370\203\377\124\236\172\336\327\325\227\031\135\367\166\366'
|
||
printf '\336\302\034\143\212\167\023\154\155\166\344\373\322\104\336\327'
|
||
printf '\104\336\327\144\316\127\336\255\357\325\374\331\264\121\113\223'
|
||
printf '\243\346\254\243\226\254\023\312\331\010\122\072\173\336\360\365'
|
||
printf '\374\323\036\370\203\377\371\002\000\376\340\177\341\163\276\375'
|
||
printf '\175\117\233\066\030\055\355\144\117\056\012\161\034\151\111\263'
|
||
printf '\063\175\037\175\317\267\232\314\027\157\341\133\160\175\025\134'
|
||
printf '\253\202\153\025\364\216\303\216\051\236\214\130\174\070\312\246'
|
||
printf '\215\232\263\206\033\367\104\064\143\243\126\337\375\126\145\267'
|
||
printf '\164\006\377\170\342\077\173\061\040\360\117\064\376\222\064\074'
|
||
printf '\042\335\376\115\117\177\376\277\246\225\342\116\301\221\113\312'
|
||
printf '\061\132\322\154\264\244\370\117\323\177\357\371\126\236\057\131'
|
||
printf '\153\345\373\222\157\045\337\116\255\011\156\344\230\142\231\060'
|
||
printf '\306\050\345\010\350\143\024\153\245\273\276\351\152\170\320\326'
|
||
printf '\176\173\002\376\221\305\177\346\014\000\370\047\036\377\251\354'
|
||
printf '\073\150\365\203\373\075\175\366\066\032\100\234\212\101\312\251'
|
||
printf '\364\123\102\242\234\107\037\364\264\173\247\137\223\155\003\370'
|
||
printf '\307\007\177\151\352\052\000\360\007\377\267\374\014\017\075\346'
|
||
printf '\153\373\053\334\045\220\220\050\147\337\036\137\017\337\347\202'
|
||
printf '\077\370\227\174\035\007\374\301\277\324\070\130\053\335\171\227'
|
||
printf '\307\202\101\204\104\064\043\303\126\167\175\243\170\311\037\370'
|
||
printf '\203\177\251\327\161\026\145\340\300\077\324\370\117\145\062\047'
|
||
printf '\335\361\367\236\162\334\052\230\220\110\305\163\245\357\374\317'
|
||
printf '\340\307\375\301\077\071\370\317\133\000\300\077\331\370\117\345'
|
||
printf '\360\061\253\257\375\175\360\275\010\102\310\342\345\237\277\347'
|
||
printf '\352\315\275\301\276\264\340\237\054\374\347\054\000\340\017\376'
|
||
printf '\027\076\347\325\235\126\337\373\021\067\011\042\044\012\171\374'
|
||
printf '\247\236\236\173\062\330\367\025\374\223\207\177\311\002\000\376'
|
||
printf '\340\137\352\071\017\077\341\353\321\047\231\006\040\044\314\171'
|
||
printf '\143\207\257\237\374\050\330\111\177\340\237\114\374\147\025\000'
|
||
printf '\360\007\377\371\236\363\335\173\074\275\274\203\022\100\110\030'
|
||
printf '\163\354\210\325\167\376\256\020\350\160\035\370\047\027\377\031'
|
||
printf '\005\000\374\301\177\241\347\370\276\364\365\357\170\072\164\204'
|
||
printf '\053\003\010\011\123\372\373\254\356\274\275\240\174\016\374\301'
|
||
printf '\277\374\070\015\173\123\301\077\322\370\117\045\227\223\276\374'
|
||
printf '\065\127\307\116\120\002\010\011\103\106\107\254\376\356\157\012'
|
||
printf '\201\316\370\007\177\360\227\212\267\374\006\177\360\017\364\072'
|
||
printf '\043\243\322\137\336\356\352\304\051\112\000\041\213\231\311\011'
|
||
printf '\351\177\176\245\240\323\247\300\037\374\203\307\251\373\233\012'
|
||
printf '\376\261\302\177\052\303\043\322\137\335\341\251\357\054\045\200'
|
||
printf '\220\305\110\076\057\335\171\173\101\307\216\200\077\370\127\366'
|
||
printf '\263\071\165\175\123\301\077\226\370\117\145\140\300\352\257\356'
|
||
printf '\360\064\070\104\011\040\244\221\161\135\351\133\137\053\350\300'
|
||
printf '\076\277\372\155\003\370\047\022\377\100\063\000\340\017\376\245'
|
||
printf '\236\167\372\214\325\227\156\367\064\074\302\106\231\220\106\244'
|
||
printf '\120\220\276\171\107\101\273\137\007\177\360\257\356\147\163\352'
|
||
printf '\362\042\340\237\010\374\247\162\342\224\325\377\373\337\134\235'
|
||
printf '\341\160\000\041\165\115\076\057\175\363\253\205\100\253\373\201'
|
||
printf '\077\370\317\365\034\247\346\057\002\376\211\302\177\052\147\316'
|
||
printf '\132\375\227\277\366\270\072\200\220\172\341\237\223\276\161\173'
|
||
printf '\101\173\336\000\177\360\257\315\317\126\333\305\200\300\077\221'
|
||
printf '\370\117\145\160\310\352\057\276\342\352\300\041\112\000\041\265'
|
||
printf '\314\344\204\364\365\277\056\150\337\156\360\007\377\332\375\154'
|
||
printf '\265\133\014\010\374\023\215\377\124\306\306\245\277\272\303\325'
|
||
printf '\236\375\224\000\102\152\221\341\041\253\073\276\234\327\301\067'
|
||
printf '\301\037\374\153\373\263\325\146\061\040\360\007\377\013\062\061'
|
||
printf '\056\375\367\073\134\275\372\032\267\015\046\244\232\234\076\151'
|
||
printf '\365\267\377\225\113\375\300\277\076\077\133\365\213\001\201\077'
|
||
printf '\370\227\030\207\174\136\272\375\357\074\075\370\010\045\200\220'
|
||
printf '\112\162\350\115\137\267\177\251\240\376\263\340\017\376\365\371'
|
||
printf '\331\322\340\017\376\365\032\007\337\227\176\360\143\117\247\316'
|
||
printf '\130\375\316\147\123\112\245\330\250\023\122\116\136\173\305\327'
|
||
printf '\077\334\131\120\241\120\303\357\053\370\203\377\133\176\254\064'
|
||
printf '\370\203\177\275\307\341\251\347\174\365\235\265\372\343\337\117'
|
||
printf '\153\111\053\033\167\102\346\313\023\217\170\272\377\207\256\154'
|
||
printf '\055\221\000\177\360\057\361\143\125\266\030\020\370\203\177\300'
|
||
printf '\161\170\143\217\325\177\372\022\353\007\020\062\127\334\202\164'
|
||
printf '\367\267\135\335\367\003\360\007\377\306\214\203\003\376\340\337'
|
||
printf '\250\161\070\335\147\365\237\277\354\352\345\137\162\136\000\041'
|
||
printf '\027\146\340\254\325\337\376\145\136\057\076\353\325\366\373\012'
|
||
printf '\376\340\077\317\070\004\133\014\010\374\301\277\312\161\030\237'
|
||
printf '\220\356\270\323\323\335\077\364\344\172\042\044\361\171\163\257'
|
||
printf '\257\257\374\105\101\107\017\333\332\176\137\301\037\374\347\031'
|
||
printf '\007\243\267\234\004\010\376\340\337\210\161\260\126\172\364\011'
|
||
printf '\137\007\016\131\375\321\027\123\352\356\252\364\247\046\044\272'
|
||
printf '\261\126\372\371\243\236\036\270\307\225\357\327\370\373\012\376'
|
||
printf '\340\277\000\376\345\317\000\200\077\370\327\141\034\366\037\260'
|
||
printf '\372\277\377\253\253\035\073\071\057\200\044\053\243\043\126\337'
|
||
printf '\370\152\101\367\375\000\374\301\177\161\360\057\257\000\200\077'
|
||
printf '\370\327\161\034\106\307\244\277\371\272\253\135\173\051\001\044'
|
||
printf '\031\331\273\313\327\137\375\077\005\275\261\303\257\375\367\025'
|
||
printf '\374\301\277\114\374\245\205\016\001\200\077\370\067\140\034\254'
|
||
printf '\225\172\173\200\201\304\073\276\057\075\362\023\117\017\337\357'
|
||
printf '\006\302\001\374\301\277\036\370\317\137\000\300\037\374\033\064'
|
||
printf '\016\275\313\214\172\272\071\017\200\304\067\247\116\130\335\375'
|
||
printf '\155\127\207\016\370\365\371\036\201\077\370\007\304\177\356\002'
|
||
printf '\000\376\340\337\300\161\270\144\063\370\223\370\356\365\077\363'
|
||
printf '\204\247\007\376\331\125\076\057\360\007\377\320\340\137\272\000'
|
||
printf '\200\077\370\067\170\034\266\156\241\000\220\370\345\344\161\253'
|
||
printf '\273\277\135\320\341\203\266\176\333\055\360\007\377\012\361\237'
|
||
printf '\135\000\300\037\374\027\141\034\266\136\114\001\040\361\211\347'
|
||
printf '\111\217\377\324\323\303\017\270\162\335\072\156\267\300\037\374'
|
||
printf '\253\300\177\146\001\000\177\360\137\204\161\130\261\334\250\153'
|
||
printf '\051\005\200\304\043\373\367\372\272\347\273\256\116\034\263\365'
|
||
printf '\335\156\201\077\370\127\211\377\371\002\000\376\340\277\110\343'
|
||
printf '\160\051\307\377\111\014\062\074\144\165\377\075\236\176\361\202'
|
||
printf '\067\343\076\376\340\017\376\141\305\277\130\000\300\037\374\027'
|
||
printf '\161\034\070\376\117\242\234\251\223\374\036\274\327\325\344\144'
|
||
printf '\003\266\133\340\017\376\065\302\137\222\322\340\017\376\213\065'
|
||
printf '\016\306\110\133\056\166\104\110\024\363\372\057\175\335\377\317'
|
||
printf '\256\116\036\267\215\331\156\201\077\370\327\020\377\342\014\000'
|
||
printf '\370\203\377\042\215\303\252\025\106\235\035\100\102\242\225\303'
|
||
printf '\007\255\356\377\241\253\175\173\374\306\155\267\300\037\374\153'
|
||
printf '\214\177\260\305\200\300\037\374\153\074\016\114\377\223\050\345'
|
||
printf '\364\051\253\007\357\165\365\313\227\374\031\307\371\301\037\374'
|
||
printf '\243\210\177\340\031\000\360\007\377\132\216\303\126\116\000\044'
|
||
printf '\021\110\177\237\325\243\017\172\332\366\254\067\357\302\075\340'
|
||
printf '\017\376\121\302\077\120\001\000\177\360\257\345\070\030\043\155'
|
||
printf '\345\370\077\011\161\316\366\131\075\366\220\247\027\236\361\026'
|
||
printf '\134\261\017\374\301\077\152\370\227\135\000\300\037\374\153\075'
|
||
printf '\016\153\126\033\265\265\201\014\011\137\116\034\267\172\374\247'
|
||
printf '\236\136\332\346\225\265\124\057\370\203\177\024\361\057\253\000'
|
||
printf '\200\077\370\327\143\034\270\373\037\011\133\366\355\366\365\344'
|
||
printf '\317\074\355\374\345\334\307\370\301\037\374\343\202\377\202\005'
|
||
printf '\000\374\301\277\136\357\321\045\234\000\110\102\020\327\225\136'
|
||
printf '\371\205\247\047\036\361\164\374\210\135\324\357\004\370\203\177'
|
||
printf '\043\361\237\267\000\200\077\370\327\353\075\062\262\272\170\023'
|
||
printf '\307\377\311\342\145\144\330\352\331\047\175\075\365\204\247\361'
|
||
printf '\121\033\150\143\017\376\340\037\007\374\347\054\000\340\017\376'
|
||
printf '\165\173\217\254\325\332\265\106\155\113\100\210\064\066\276\137'
|
||
printf '\234\346\177\356\151\117\073\136\361\345\171\347\076\253\340\017'
|
||
printf '\376\011\304\277\144\001\000\177\360\257\047\376\222\164\311\026'
|
||
printf '\366\376\111\343\162\372\244\325\266\347\074\155\173\316\327\310'
|
||
printf '\360\133\066\370\340\017\376\011\305\177\126\001\000\177\360\257'
|
||
printf '\067\376\022\327\377\223\372\147\170\310\352\227\057\373\332\376'
|
||
printf '\202\257\103\007\374\322\237\125\360\007\377\004\343\077\243\000'
|
||
printf '\200\077\370\067\002\177\307\021\307\377\111\135\062\066\152\365'
|
||
printf '\306\116\137\257\374\302\327\033\257\371\163\136\302\007\376\340'
|
||
printf '\017\376\027\024\000\360\007\377\106\340\057\111\353\326\032\265'
|
||
printf '\266\200\025\251\115\372\316\130\275\276\303\327\253\057\371\072'
|
||
printf '\260\177\341\313\367\300\037\374\301\377\202\002\000\376\340\337'
|
||
printf '\050\374\045\351\222\315\361\332\373\267\126\332\371\272\257\236'
|
||
printf '\156\243\125\253\070\264\121\357\024\012\322\376\275\305\075\374'
|
||
printf '\067\166\372\072\163\312\006\373\254\202\077\370\203\377\314\031'
|
||
printf '\000\360\007\377\106\340\057\305\347\372\177\153\245\355\277\360'
|
||
printf '\365\223\007\075\235\072\131\374\135\073\073\215\266\156\061\332'
|
||
printf '\272\325\321\326\255\106\335\335\024\202\132\214\363\361\143\126'
|
||
printf '\373\367\372\332\365\272\257\375\273\175\345\363\025\176\126\301'
|
||
printf '\037\374\301\177\306\363\322\340\017\376\215\302\077\345\110\233'
|
||
printf '\336\026\355\031\000\153\245\327\166\372\372\361\175\236\216\036'
|
||
printf '\265\063\306\141\150\310\152\333\213\126\333\136\054\036\174\356'
|
||
printf '\354\060\332\264\251\370\130\267\316\321\206\015\106\251\024\250'
|
||
printf '\317\027\337\227\216\035\265\072\260\317\327\233\373\175\355\331'
|
||
printf '\345\153\174\254\006\337\043\360\007\177\360\237\365\274\064\370'
|
||
printf '\203\177\043\360\067\222\066\254\067\152\156\216\376\036\377\311'
|
||
printf '\163\173\374\146\201\367\143\150\310\352\245\227\254\136\172\111'
|
||
printf '\222\074\065\067\113\033\067\070\132\267\316\150\355\132\243\213'
|
||
printf '\326\032\365\366\032\231\204\116\024\370\276\164\352\244\325\321'
|
||
printf '\303\305\307\221\303\276\216\034\262\052\024\146\177\251\300\037'
|
||
printf '\374\301\277\306\266\130\051\015\376\340\337\010\374\245\150\136'
|
||
printf '\377\137\012\376\162\360\057\225\334\244\264\153\227\257\135\273'
|
||
printf '\316\377\135\163\263\164\321\105\106\153\056\162\264\152\245\321'
|
||
printf '\212\225\322\252\125\106\355\355\361\152\005\203\003\126\247\117'
|
||
printf '\133\235\071\045\235\070\346\353\350\141\253\143\107\247\260\237'
|
||
printf '\177\000\301\037\374\301\277\366\370\137\060\003\000\376\340\137'
|
||
printf '\137\374\045\151\113\204\256\377\237\013\376\112\361\237\353\071'
|
||
printf '\223\223\322\276\175\126\373\366\171\063\376\176\311\022\151\345'
|
||
printf '\112\243\336\145\106\075\313\214\272\173\214\272\273\245\236\036'
|
||
printf '\243\245\113\303\167\050\041\237\227\006\372\255\206\206\254\206'
|
||
printf '\006\212\147\347\237\072\145\165\346\264\325\231\123\126\271\134'
|
||
printf '\271\237\071\360\007\177\360\157\004\376\013\026\000\360\007\377'
|
||
printf '\132\341\237\116\111\027\107\340\370\377\174\360\327\032\377\371'
|
||
printf '\062\076\046\275\271\337\352\315\375\263\377\245\216\043\265\265'
|
||
printf '\031\265\267\113\035\035\106\355\035\305\177\356\354\220\232\133'
|
||
printf '\214\132\132\212\063\013\115\115\305\103\056\115\315\122\066\043'
|
||
printf '\245\063\146\306\314\203\163\356\355\050\024\064\275\047\136\050'
|
||
printf '\130\271\205\363\250\117\214\113\343\343\126\023\023\322\304\270'
|
||
printf '\325\370\270\246\377\074\064\124\334\263\037\032\054\376\357\325'
|
||
printf '\157\354\301\037\374\301\277\121\370\317\133\000\300\037\374\153'
|
||
printf '\205\277\044\155\334\140\224\315\206\033\376\013\117\356\013\076'
|
||
printf '\016\215\373\116\370\276\064\074\154\065\074\054\035\073\146\143'
|
||
printf '\202\036\370\203\077\370\067\022\377\071\013\000\370\203\177\055'
|
||
printf '\361\227\244\255\041\075\376\137\016\374\141\302\077\236\350\201'
|
||
printf '\077\370\203\177\243\361\057\131\000\300\037\374\153\215\177\261'
|
||
printf '\000\204\353\370\177\271\360\203\077\370\203\077\370\307\021\377'
|
||
printf '\131\005\000\374\301\277\036\370\147\062\322\333\066\204\143\006'
|
||
printf '\040\010\374\340\017\376\340\017\376\161\305\177\106\001\000\177'
|
||
printf '\360\257\007\376\222\364\266\215\216\062\231\150\301\017\376\340'
|
||
printf '\017\376\340\037\147\374\247\013\000\370\203\177\275\360\227\244'
|
||
printf '\113\026\361\362\277\112\340\007\177\360\007\177\360\217\073\376'
|
||
printf '\122\311\305\200\300\037\374\153\207\277\044\155\131\204\023\000'
|
||
printf '\053\205\037\374\301\037\374\301\077\011\370\117\317\000\200\077'
|
||
printf '\370\327\013\377\154\126\332\270\276\161\063\000\325\300\017\376'
|
||
printf '\340\017\376\340\237\024\374\315\254\002\000\376\340\137\103\374'
|
||
printf '\045\151\323\106\107\351\264\352\236\152\341\007\177\360\007\177'
|
||
printf '\360\117\022\376\063\147\000\300\037\374\153\214\277\124\377\313'
|
||
printf '\377\056\204\377\310\133\126\347\003\177\360\007\177\360\007\377'
|
||
printf '\271\137\053\015\376\340\137\057\374\245\372\055\000\364\126\370'
|
||
printf '\353\366\036\201\077\370\203\077\370\307\020\377\142\001\000\177'
|
||
printf '\360\257\023\376\115\115\322\372\165\265\235\001\050\005\077\370'
|
||
printf '\203\077\370\203\077\370\007\177\255\364\242\014\034\370\307\036'
|
||
printf '\177\111\332\274\311\251\331\252\165\163\301\017\376\340\017\376'
|
||
printf '\340\017\376\225\275\126\272\341\003\007\376\211\300\337\250\066'
|
||
printf '\307\377\347\203\037\374\301\037\374\301\037\374\053\177\255\164'
|
||
printf '\103\007\016\374\023\203\277\044\155\335\134\371\361\377\205\340'
|
||
printf '\007\177\360\007\177\360\007\377\352\136\053\275\050\037\156\360'
|
||
printf '\217\075\376\055\055\322\272\265\301\377\015\345\300\017\376\340'
|
||
printf '\017\376\340\017\376\325\277\126\272\341\277\020\370\307\036\177'
|
||
printf '\251\170\374\337\011\060\001\120\056\374\340\017\376\340\017\376'
|
||
printf '\340\137\233\327\112\203\077\370\327\343\165\312\075\376\037\004'
|
||
printf '\176\360\007\177\360\007\177\360\257\335\153\245\301\037\374\353'
|
||
printf '\361\072\133\027\270\376\077\050\374\340\017\376\340\017\376\340'
|
||
printf '\137\333\327\112\203\077\370\327\372\165\132\133\244\065\253\115'
|
||
printf '\315\340\007\177\360\007\177\360\007\377\332\277\126\272\356\277'
|
||
printf '\020\370\047\012\177\111\332\262\171\366\361\177\153\245\035\073'
|
||
printf '\175\335\167\277\247\043\107\154\143\277\104\340\017\376\340\017'
|
||
printf '\376\340\077\353\071\351\272\376\102\340\237\070\374\245\231\307'
|
||
printf '\377\247\340\377\361\375\347\026\351\261\015\376\022\201\077\370'
|
||
printf '\203\077\370\203\177\311\347\244\353\366\042\340\237\110\374\213'
|
||
printf '\005\300\231\001\377\364\042\075\340\017\376\340\017\376\340\037'
|
||
printf '\232\317\103\272\056\057\002\376\211\305\177\111\253\164\364\230'
|
||
printf '\325\337\175\323\325\211\223\266\241\033\173\360\007\177\360\007'
|
||
printf '\177\360\057\377\071\346\363\377\066\157\301\037\374\243\216\036'
|
||
printf '\370\203\077\370\203\077\370\007\173\216\003\376\340\017\376\340'
|
||
printf '\017\376\340\017\376\311\302\177\336\002\000\376\340\017\376\340'
|
||
printf '\017\376\340\017\376\361\304\177\316\002\000\376\340\017\376\340'
|
||
printf '\017\376\340\017\376\361\305\277\144\001\000\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\170\343\077\253\000\200\077\370\203\077\370'
|
||
printf '\203\077\370\203\177\374\361\227\275\240\000\200\077\370\203\077'
|
||
printf '\370\203\077\370\203\177\062\360\237\236\001\000\177\360\007\177'
|
||
printf '\360\007\177\360\007\377\344\340\057\111\016\370\203\077\370\203'
|
||
printf '\077\370\203\077\370\047\013\377\351\031\000\360\007\177\360\007'
|
||
printf '\177\360\007\177\360\117\016\376\046\120\001\000\177\360\007\177'
|
||
printf '\360\007\177\360\007\377\130\340\137\376\014\000\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\307\006\377\362\012\000\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\307\012\377\205\013\000\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\307\016\377\371\013\000\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\307\022\377\271\013\000\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\307\026\377\322\005\000\374\301\037\374'
|
||
printf '\301\037\374\301\037\374\143\215\377\354\002\000\376\340\017\376'
|
||
printf '\340\017\376\340\017\376\261\307\177\146\001\000\177\360\007\177'
|
||
printf '\360\007\177\360\007\377\104\340\177\276\000\200\077\370\203\077'
|
||
printf '\370\203\077\370\203\177\142\360\057\026\000\360\007\177\360\007'
|
||
printf '\177\360\007\177\360\117\024\376\122\045\213\001\201\077\370\203'
|
||
printf '\077\370\203\077\370\203\177\344\307\301\151\350\227\010\374\301'
|
||
printf '\037\374\301\037\374\301\037\374\103\061\016\316\242\175\301\301'
|
||
printf '\037\374\301\037\374\301\037\374\301\177\321\306\301\131\224\137'
|
||
printf '\006\374\301\037\374\301\037\374\301\037\374\027\165\034\234\206'
|
||
printf '\377\062\340\017\376\340\017\376\340\017\376\340\277\350\343\340'
|
||
printf '\064\364\227\001\177\360\007\177\360\007\177\360\007\377\120\214'
|
||
printf '\203\003\376\340\017\376\340\017\376\340\017\376\112\334\070\070'
|
||
printf '\340\017\376\340\017\376\340\017\376\340\237\274\161\160\300\037'
|
||
printf '\374\301\037\374\301\037\374\301\077\171\343\340\200\077\370\203'
|
||
printf '\077\370\203\077\370\203\177\362\306\301\001\177\360\007\177\360'
|
||
printf '\007\177\360\007\377\344\215\203\003\376\340\017\376\340\017\376'
|
||
printf '\340\017\376\311\033\007\007\374\301\037\374\301\037\374\301\037'
|
||
printf '\374\223\067\016\016\370\203\077\370\203\077\370\203\077\370\047'
|
||
printf '\157\034\152\267\030\020\370\203\077\370\203\077\370\203\077\370'
|
||
printf '\107\142\034\152\267\030\020\370\203\077\370\203\077\370\203\077'
|
||
printf '\370\107\006\377\100\063\000\340\017\376\340\017\376\340\017\376'
|
||
printf '\340\037\017\374\313\056\000\340\017\376\340\017\376\340\017\376'
|
||
printf '\340\037\037\374\145\253\131\014\010\374\301\037\374\301\037\374'
|
||
printf '\301\037\374\043\211\377\202\063\000\340\017\376\340\017\376\340'
|
||
printf '\017\376\340\037\077\374\347\055\000\340\017\376\340\017\376\340'
|
||
printf '\017\376\340\037\117\374\347\054\000\340\017\376\340\017\376\340'
|
||
printf '\017\376\340\037\137\374\113\026\000\360\007\177\360\007\177\360'
|
||
printf '\007\177\360\217\067\376\263\012\000\370\203\077\370\203\077\370'
|
||
printf '\203\077\370\307\037\377\031\005\000\374\301\037\374\301\037\374'
|
||
printf '\301\037\374\223\201\377\164\001\000\177\360\007\177\360\007\177'
|
||
printf '\360\007\377\344\340\057\315\267\030\020\370\203\077\370\203\077'
|
||
printf '\370\203\077\370\307\022\177\311\316\161\031\040\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\307\026\377\322\213\001\201\077\370\203'
|
||
printf '\077\370\203\077\370\203\177\254\361\327\254\002\000\376\340\017'
|
||
printf '\376\340\017\376\340\017\376\261\307\177\146\001\000\177\360\007'
|
||
printf '\177\360\007\177\360\007\377\104\340\177\276\000\200\077\370\203'
|
||
printf '\077\370\203\077\370\203\177\142\360\057\026\000\360\007\177\360'
|
||
printf '\007\177\360\007\177\360\117\024\376\347\147\000\300\037\374\301'
|
||
printf '\037\374\301\037\374\301\077\061\370\317\131\000\300\037\374\301'
|
||
printf '\037\374\301\037\374\301\077\276\370\227\054\000\340\017\376\340'
|
||
printf '\017\376\340\017\376\340\037\157\374\147\025\000\360\007\177\360'
|
||
printf '\007\177\360\007\177\360\217\077\376\063\012\000\370\203\077\370'
|
||
printf '\203\077\370\203\077\370\047\003\377\351\002\000\376\340\017\376'
|
||
printf '\340\017\376\340\017\376\311\301\137\232\157\061\040\360\007\177'
|
||
printf '\360\007\177\360\007\177\360\217\045\376\323\063\000\340\017\376'
|
||
printf '\340\017\376\340\017\376\340\237\034\374\115\045\005\000\374\301'
|
||
printf '\037\374\301\037\374\301\037\374\243\215\177\340\031\000\360\007'
|
||
printf '\177\360\007\177\360\007\177\360\217\076\376\201\012\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\003\377\262\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\007\377\262\012\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\013\377\005\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\017\377\171\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\023\377\071\013\000\370\203'
|
||
printf '\077\370\203\077\370\203\077\370\307\027\377\222\005\000\374\301'
|
||
printf '\037\374\301\037\374\301\037\374\343\215\377\254\002\000\376\340'
|
||
printf '\017\376\340\017\376\340\017\376\361\307\137\266\232\325\000\301'
|
||
printf '\037\374\301\037\374\301\037\374\301\077\222\370\117\317\000\200'
|
||
printf '\077\370\203\077\370\203\077\370\203\177\162\360\227\052\131\015'
|
||
printf '\020\374\301\037\374\301\037\374\301\037\374\043\215\377\364\014'
|
||
printf '\000\370\203\077\370\203\077\370\203\077\370\047\007\377\140\253'
|
||
printf '\001\202\077\370\203\077\370\203\077\370\203\177\054\360\057\177'
|
||
printf '\006\000\374\301\037\374\301\037\374\301\037\374\143\203\177\171'
|
||
printf '\005\000\374\301\037\374\301\037\374\301\037\374\143\205\377\302'
|
||
printf '\005\000\374\301\037\374\301\037\374\301\037\374\143\207\377\374'
|
||
printf '\005\000\374\301\037\374\301\037\374\301\037\374\143\211\377\334'
|
||
printf '\005\000\374\301\037\374\301\037\374\301\037\374\143\213\177\351'
|
||
printf '\002\000\376\340\017\376\340\017\376\340\017\376\261\306\177\166'
|
||
printf '\001\000\177\360\007\177\360\007\177\360\007\377\330\343\077\263'
|
||
printf '\000\200\077\370\203\077\370\203\077\370\203\177\042\360\077\137'
|
||
printf '\000\300\037\374\301\037\374\301\037\374\301\077\061\370\027\013'
|
||
printf '\000\370\203\077\370\203\077\370\203\077\370\047\012\177\251\222'
|
||
printf '\305\200\300\037\374\301\037\374\301\037\374\301\077\322\370\027'
|
||
printf '\147\000\300\037\374\301\037\374\301\037\374\301\077\121\370\007'
|
||
printf '\133\014\010\374\301\037\374\301\037\374\301\037\374\143\201\177'
|
||
printf '\240\031\000\360\007\177\360\007\177\360\007\177\360\217\007\376'
|
||
printf '\145\027\000\360\007\177\360\007\177\360\007\177\360\217\017\376'
|
||
printf '\145\025\000\360\007\177\360\007\177\360\007\177\360\217\027\376'
|
||
printf '\013\026\000\360\007\177\360\007\177\360\007\177\360\217\037\376'
|
||
printf '\363\026\000\360\007\177\360\007\177\360\007\177\360\217\047\376'
|
||
printf '\163\026\000\360\007\177\360\007\177\360\007\177\360\217\057\376'
|
||
printf '\045\013\000\370\203\077\370\203\077\370\203\077\370\307\033\377'
|
||
printf '\131\005\000\374\301\037\374\301\037\374\301\037\374\343\217\377'
|
||
printf '\214\002\000\376\340\017\376\340\017\376\340\017\376\311\300\177'
|
||
printf '\272\000\200\077\370\203\077\370\203\077\370\203\177\162\360\227'
|
||
printf '\352\261\030\020\370\203\077\370\203\077\370\203\077\370\207\032'
|
||
printf '\377\351\031\000\360\007\177\360\007\177\360\007\177\360\117\016'
|
||
printf '\376\265\135\014\010\374\301\037\374\301\037\374\301\037\374\043'
|
||
printf '\201\177\240\031\000\360\007\177\360\007\177\360\007\177\360\217'
|
||
printf '\007\376\145\027\000\360\007\177\360\007\177\360\007\177\360\217'
|
||
printf '\017\376\262\325\056\006\004\376\340\017\376\340\017\376\340\017'
|
||
printf '\376\221\303\177\301\031\000\360\007\177\360\007\177\360\007\177'
|
||
printf '\360\217\037\376\363\026\000\360\007\177\360\007\177\360\007\177'
|
||
printf '\360\217\047\376\163\026\000\360\007\177\360\007\177\360\007\177'
|
||
printf '\360\217\057\376\045\013\000\370\203\077\370\203\077\370\203\077'
|
||
printf '\370\307\033\377\131\005\000\374\301\037\374\301\037\374\301\037'
|
||
printf '\374\343\217\377\214\002\000\376\340\017\376\340\017\376\340\017'
|
||
printf '\376\311\300\177\272\000\200\077\370\203\077\370\203\077\370\203'
|
||
printf '\177\162\360\227\026\132\014\010\374\301\037\374\301\037\374\301'
|
||
printf '\037\374\143\207\377\364\014\000\370\203\077\370\203\077\370\203'
|
||
printf '\077\370\047\007\377\271\027\003\002\177\360\007\177\360\007\177'
|
||
printf '\360\007\377\330\342\137\172\006\000\374\301\037\374\301\037\374'
|
||
printf '\301\037\374\143\215\377\354\002\000\376\340\017\376\340\017\376'
|
||
printf '\340\017\376\261\307\177\146\001\000\177\360\007\177\360\007\177'
|
||
printf '\360\007\377\104\340\177\276\000\200\077\370\203\077\370\203\077'
|
||
printf '\370\203\177\142\360\227\244\377\037\207\157\145\227\137\015\142'
|
||
printf '\011\000\000\000\000\111\105\116\104\256\102\140\202'
|
||
} > "$STAGE/icon-maskable-512.png"
|
||
cat > "$STAGE/index.html" <<'__CABINCHAT_EOF__'
|
||
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content">
|
||
<meta name="theme-color" content="#14171d">
|
||
<meta name="color-scheme" content="dark">
|
||
<meta name="mobile-web-app-capable" content="yes">
|
||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||
<meta name="apple-mobile-web-app-title" content="Cabin Chat">
|
||
<title>Cabin Chat</title>
|
||
<link rel="icon" href="logo.svg" type="image/svg+xml">
|
||
<link rel="icon" href="icon-192.png" sizes="192x192" type="image/png">
|
||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||
<link rel="manifest" href="manifest.json">
|
||
<style>
|
||
:root{
|
||
--bg:#0e1014; --panel:#14171d; --panel2:#1d2129; --line:#252a34;
|
||
--text:#e8ecf2; --muted:#8b93a5; --accent:#3d7bfd; --mine:#2f6be6; --theirs:#1e232c;
|
||
--ok:#22c55e; --bad:#f05252;
|
||
--emoji:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
|
||
}
|
||
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
|
||
[hidden]{display:none!important}
|
||
html,body{margin:0;height:100%;overflow:hidden;background:var(--bg);color:var(--text);
|
||
font:16px/1.38 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif}
|
||
button{font:inherit;color:inherit;cursor:pointer}
|
||
#app{position:fixed;left:0;right:0;top:0;height:100dvh;display:flex;will-change:transform;overflow:hidden}
|
||
#chat{position:relative;flex:1;min-width:0;display:flex;flex-direction:column}
|
||
|
||
/* avatars */
|
||
.avatar{position:relative;flex:none;width:44px;height:44px;border-radius:50%;display:grid;place-items:center;
|
||
font-weight:600;font-size:18px;color:#fff}
|
||
.avatar.group{background:linear-gradient(135deg,#3d7bfd,#8b5cf6);font:20px var(--emoji)}
|
||
.avatar .on{position:absolute;right:-1px;bottom:-1px;width:13px;height:13px;border-radius:50%;
|
||
background:var(--ok);border:2.5px solid var(--panel)}
|
||
header .avatar{width:38px;height:38px;font-size:16px}
|
||
|
||
/* people drawer (sidebar on wide screens) */
|
||
#people{position:absolute;inset:0;z-index:6;display:flex;flex-direction:column;background:var(--panel);
|
||
transform:translateX(-100%);transition:transform .25s ease;visibility:hidden}
|
||
#app.people #people{transform:none;visibility:visible}
|
||
.phead{display:flex;align-items:center;gap:10px;padding:calc(env(safe-area-inset-top) + 12px) 12px 12px 18px;
|
||
border-bottom:1px solid var(--line)}
|
||
.phead b{flex:1;font-size:21px}
|
||
#plist{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:6px}
|
||
.psec{padding:14px 12px 5px;font-size:12px;font-weight:600;letter-spacing:.6px;text-transform:uppercase;color:var(--muted)}
|
||
.pitem{display:flex;align-items:center;gap:12px;width:100%;padding:9px 10px;border:0;border-radius:14px;
|
||
background:none;text-align:left}
|
||
.pitem:active,.pitem.active{background:var(--panel2)}
|
||
.pmain{flex:1;min-width:0}
|
||
.pname,.psub{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||
.pname{font-weight:600;font-size:15.5px}
|
||
.psub{font-size:13.5px;color:var(--muted)}
|
||
.psub.typing{color:var(--accent)}
|
||
.pside{display:flex;flex-direction:column;align-items:flex-end;gap:5px;min-height:38px}
|
||
.ptime{font-size:11.5px;color:var(--muted)}
|
||
.pbadge{min-width:20px;height:20px;padding:0 6px;border-radius:10px;background:var(--accent);color:#fff;
|
||
font-size:12px;line-height:20px;text-align:center}
|
||
.pnone{padding:8px 12px;color:var(--muted);font-size:14px}
|
||
.pfoot{display:flex;align-items:center;gap:10px;padding:10px 14px calc(10px + env(safe-area-inset-bottom));
|
||
border-top:1px solid var(--line)}
|
||
.pfoot .ver{flex:1;text-align:right;font-size:11.5px;color:#596173}
|
||
.chip{max-width:60%;border:0;border-radius:999px;padding:8px 14px;background:var(--panel2);font-size:14px;
|
||
white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||
@media (min-width:760px){
|
||
#people{position:relative;inset:auto;width:310px;flex:none;transform:none;visibility:visible;border-right:1px solid var(--line)}
|
||
#peopleBtn,#closePeople{display:none!important}
|
||
}
|
||
|
||
/* header */
|
||
header{flex:none;display:flex;align-items:center;gap:10px;
|
||
padding:calc(env(safe-area-inset-top) + 9px) 14px 9px 6px;
|
||
background:rgba(20,23,29,.92);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);
|
||
border-bottom:1px solid var(--line);z-index:2}
|
||
@media (min-width:760px){ header{padding-left:16px} }
|
||
#peopleBtn{position:relative;width:42px;height:42px}
|
||
#peopleBadge{position:absolute;top:2px;right:0;min-width:18px;height:18px;padding:0 5px;border-radius:9px;
|
||
background:var(--accent);color:#fff;font-size:11px;line-height:18px;text-align:center}
|
||
.title{flex:1;min-width:0}
|
||
.title b{display:block;font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||
.status{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--muted);white-space:nowrap;overflow:hidden}
|
||
.status.typing{color:var(--accent)}
|
||
.status.bad{color:var(--bad)}
|
||
|
||
/* messages */
|
||
#wrap{position:relative;flex:1;min-height:0}
|
||
#log{position:absolute;inset:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
|
||
padding:10px 10px 8px}
|
||
.empty{color:var(--muted);text-align:center;margin-top:26vh;font-size:15px;line-height:1.6}
|
||
.row{display:flex;flex-direction:column;align-items:flex-start;margin-top:2px;touch-action:pan-y}
|
||
.row.first{margin-top:12px}
|
||
.row.mine{align-items:flex-end}
|
||
.name{font-size:12.5px;font-weight:600;margin:0 0 3px 12px}
|
||
.bubble{position:relative;max-width:min(80%,520px);padding:7px 12px 7px;border-radius:20px;
|
||
background:var(--theirs);overflow-wrap:anywhere;white-space:pre-wrap;transition:transform .2s,filter .2s}
|
||
.bubble.swiping{transition:none}
|
||
.bubble.sel{filter:brightness(1.3)}
|
||
.bubble.flash{animation:flash 1.4s ease}
|
||
@keyframes flash{0%,45%{box-shadow:0 0 0 3px var(--accent)}100%{box-shadow:0 0 0 3px transparent}}
|
||
@media (pointer:coarse){ .bubble,.bubble img{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none} }
|
||
.mine .bubble{background:var(--mine);color:#fff}
|
||
.row:not(.mine).last .bubble{border-bottom-left-radius:6px}
|
||
.row.mine.last .bubble{border-bottom-right-radius:6px}
|
||
.meta{float:right;margin:7px 0 -3px 10px;font-size:11px;line-height:1;color:var(--muted);white-space:nowrap}
|
||
.mine .meta{color:rgba(255,255,255,.72)}
|
||
.bubble.jumbo{background:none!important;padding:0 2px;font:44px/1.15 var(--emoji)}
|
||
.bubble.jumbo .meta{display:block;float:none;text-align:right;margin:2px 4px 0;font:11px/1 -apple-system,sans-serif;color:var(--muted)}
|
||
.bubble.media{padding:3px;line-height:0}
|
||
.media img.photo{display:block;width:min(280px,64vw);height:auto;min-height:60px;border-radius:17px;background:#0006;cursor:zoom-in}
|
||
.row.mine.last .media img.photo{border-bottom-right-radius:4px}
|
||
.row:not(.mine).last .media img.photo{border-bottom-left-radius:4px}
|
||
.media .meta{position:absolute;right:10px;bottom:9px;float:none;margin:0;padding:4px 7px;border-radius:10px;
|
||
background:rgba(0,0,0,.55);color:#fff}
|
||
.pending img.photo{opacity:.45}
|
||
.spin{position:absolute;inset:0;margin:auto;width:34px;height:34px;border-radius:50%;
|
||
border:3px solid rgba(255,255,255,.3);border-top-color:#fff;animation:spin 1s linear infinite}
|
||
@keyframes spin{to{transform:rotate(360deg)}}
|
||
|
||
/* quotes */
|
||
.quote{display:flex;align-items:center;gap:8px;margin:1px 0 6px;padding:5px 9px;border-left:3px solid var(--accent);
|
||
border-radius:8px;background:rgba(255,255,255,.06);font-size:13.5px;line-height:1.3;white-space:normal;cursor:pointer}
|
||
.quote .qt{min-width:0}
|
||
.quote b{display:block;font-size:12.5px}
|
||
.quote span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:var(--muted)}
|
||
.quote img{flex:none;width:36px;height:36px;object-fit:cover;border-radius:6px}
|
||
.quote.gone span{font-style:italic}
|
||
.mine .quote{background:rgba(255,255,255,.16);border-left-color:rgba(255,255,255,.8)}
|
||
.mine .quote b{color:#fff!important}
|
||
.mine .quote span{color:rgba(255,255,255,.82)}
|
||
.media .quote{margin:4px 4px 6px}
|
||
.bubble.hasq{min-width:min(200px,70vw)}
|
||
|
||
/* typing indicator */
|
||
#typingRow{display:flex;flex-direction:column;align-items:flex-start;margin-top:12px}
|
||
#typingRow .tn{font-size:12px;color:var(--muted);margin:0 0 3px 12px}
|
||
.dots{display:flex;gap:4px;padding:13px 14px;border-radius:20px;border-bottom-left-radius:6px;background:var(--theirs)}
|
||
.dots i{width:7px;height:7px;border-radius:50%;background:var(--muted);animation:blink 1.3s infinite}
|
||
.dots i:nth-child(2){animation-delay:.18s}
|
||
.dots i:nth-child(3){animation-delay:.36s}
|
||
@keyframes blink{0%,60%,100%{opacity:.35;transform:none}30%{opacity:1;transform:translateY(-3px)}}
|
||
|
||
#jump{position:absolute;right:14px;bottom:14px;width:44px;height:44px;border-radius:50%;
|
||
border:1px solid var(--line);background:var(--panel2);display:grid;place-items:center;
|
||
box-shadow:0 6px 20px rgba(0,0,0,.5)}
|
||
#jump svg{width:22px;height:22px}
|
||
#badge{position:absolute;top:-6px;right:-4px;min-width:20px;height:20px;padding:0 5px;border-radius:10px;
|
||
background:var(--accent);color:#fff;font-size:12px;line-height:20px;text-align:center}
|
||
|
||
/* composer */
|
||
footer{flex:none;background:var(--panel);border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom)}
|
||
#app.kb footer{padding-bottom:0}
|
||
#replyBar{display:flex;align-items:center;gap:8px;padding:8px 8px 0 14px}
|
||
#replyBar .rq{flex:1;min-width:0;padding:2px 10px;border-left:3px solid var(--accent);font-size:13.5px}
|
||
#replyBar b{display:block;font-size:13px;color:var(--accent)}
|
||
#replyBar span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}
|
||
#bar{display:flex;align-items:flex-end;gap:8px;padding:8px 10px}
|
||
.field{flex:1;min-width:0;display:flex;align-items:center;min-height:44px;padding:3px;border-radius:24px;
|
||
background:var(--panel2);border:1px solid transparent;transition:border-color .2s}
|
||
.field:focus-within{border-color:#34405a}
|
||
.field input{flex:1;min-width:0;border:0;outline:0;background:transparent;color:var(--text);font-size:16px;padding:8px 4px}
|
||
.field input::placeholder{color:var(--muted)}
|
||
.icon{flex:none;width:38px;height:38px;border:0;border-radius:50%;background:transparent;color:var(--muted);
|
||
display:grid;place-items:center;padding:0}
|
||
.icon:active{background:rgba(255,255,255,.08)}
|
||
.icon svg{width:24px;height:24px}
|
||
.send{flex:none;width:46px;height:46px;border:0;border-radius:50%;background:var(--accent);color:#fff;
|
||
display:grid;place-items:center;padding:0;transition:transform .15s,opacity .2s}
|
||
.send svg{width:22px;height:22px;margin-left:2px}
|
||
.send:disabled{opacity:.35}
|
||
.send:not(:disabled):active{transform:scale(.92)}
|
||
|
||
/* emoji panel */
|
||
#emoji{height:0;overflow:hidden;transition:height .2s ease}
|
||
#emoji.open{height:290px}
|
||
#egrid{height:244px;overflow-y:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(46px,1fr));
|
||
align-content:start;padding:4px 8px}
|
||
#egrid button{height:46px;border:0;border-radius:12px;background:none;font:28px/1 var(--emoji);padding:0}
|
||
#egrid button:active{background:rgba(255,255,255,.08)}
|
||
.enone{grid-column:1/-1;color:var(--muted);text-align:center;padding-top:80px;font-size:14px}
|
||
#etabs{height:46px;display:flex;border-top:1px solid var(--line)}
|
||
#etabs button{flex:1;border:0;background:none;font:21px/1 var(--emoji);opacity:.4;transition:opacity .2s}
|
||
#etabs button.on{opacity:1}
|
||
|
||
/* message menu */
|
||
#menuBack{position:fixed;inset:0;z-index:8}
|
||
#menu{position:fixed;z-index:9;min-width:180px;padding:5px;border:1px solid var(--line);border-radius:14px;
|
||
background:#232833;box-shadow:0 12px 36px rgba(0,0,0,.6)}
|
||
#menu button{display:flex;align-items:center;gap:12px;width:100%;padding:11px 12px;border:0;border-radius:10px;
|
||
background:none;font-size:15px;text-align:left}
|
||
#menu button:hover,#menu button:active{background:rgba(255,255,255,.07)}
|
||
#menu svg{width:20px;height:20px;color:var(--muted)}
|
||
|
||
/* overlays */
|
||
#viewer{position:fixed;inset:0;z-index:10;background:rgba(0,0,0,.94);display:flex;align-items:center;justify-content:center;
|
||
padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom)}
|
||
#viewer img{max-width:100%;max-height:100%;object-fit:contain}
|
||
#modal{position:fixed;inset:0;z-index:11;background:rgba(5,6,9,.7);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
|
||
display:flex;justify-content:center;align-items:flex-start;padding:16vh 20px 0}
|
||
.card{width:100%;max-width:360px;background:var(--panel);border:1px solid var(--line);border-radius:24px;padding:26px 22px 20px;
|
||
text-align:center;box-shadow:0 20px 60px rgba(0,0,0,.6)}
|
||
.card .avatar{margin:0 auto 14px;width:58px;height:58px;font-size:30px}
|
||
.card h2{margin:0 0 6px;font-size:21px}
|
||
.card p{margin:0 0 18px;color:var(--muted);font-size:14.5px}
|
||
.card input{width:100%;font-size:17px;padding:13px 16px;border-radius:14px;border:1px solid var(--line);
|
||
background:var(--panel2);color:var(--text);outline:0;text-align:center}
|
||
.card input:focus{border-color:var(--accent)}
|
||
.primary{width:100%;margin-top:12px;padding:13px;border:0;border-radius:14px;background:var(--accent);color:#fff;font-weight:600;font-size:16px}
|
||
#toast{position:fixed;left:50%;top:calc(env(safe-area-inset-top) + 70px);z-index:12;transform:translate(-50%,-10px);
|
||
max-width:86vw;padding:10px 16px;border-radius:14px;background:#2a303b;color:var(--text);font-size:14px;
|
||
white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
|
||
box-shadow:0 8px 24px rgba(0,0,0,.5);opacity:0;pointer-events:none;transition:opacity .25s,transform .25s}
|
||
#toast.show{opacity:1;transform:translate(-50%,0)}
|
||
#toast.click{pointer-events:auto;cursor:pointer}
|
||
|
||
/* profile pictures */
|
||
.avatar img{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block}
|
||
.name{display:flex;align-items:center;gap:6px}
|
||
.name .avatar{width:20px;height:20px;font-size:11px}
|
||
.name .avatar .on{display:none}
|
||
.chip{display:flex;align-items:center;gap:8px;padding:5px 14px 5px 5px}
|
||
.chip .avatar{width:28px;height:28px;font-size:13px}
|
||
.chip span{overflow:hidden;text-overflow:ellipsis}
|
||
|
||
/* mentions */
|
||
.mention{color:#9cc0ff;font-weight:600}
|
||
.mine .mention{color:#fff;text-decoration:underline;text-underline-offset:2px}
|
||
.mention.me{background:rgba(250,204,21,.18);color:#fde68a;border-radius:5px;padding:0 2px}
|
||
.bubble.atme:not(.media){box-shadow:inset 3px 0 0 #facc15}
|
||
#mentions{position:absolute;left:10px;right:10px;bottom:100%;margin-bottom:6px;max-width:360px;padding:5px;
|
||
border:1px solid var(--line);border-radius:14px;background:#232833;box-shadow:0 12px 36px rgba(0,0,0,.6);z-index:5}
|
||
#mentions button{display:flex;align-items:center;gap:10px;width:100%;padding:7px 9px;border:0;border-radius:10px;
|
||
background:none;text-align:left;font-size:15px}
|
||
#mentions button.on{background:rgba(255,255,255,.09)}
|
||
#mentions .avatar{width:30px;height:30px;font-size:14px}
|
||
footer{position:relative}
|
||
|
||
/* login & profile */
|
||
.card .logo{width:72px;height:72px;margin:0 auto 12px;display:block}
|
||
.card input+input{margin-top:10px}
|
||
.err{min-height:20px;margin-top:8px;color:var(--bad);font-size:14px}
|
||
#sheetBack{position:fixed;inset:0;z-index:11;background:rgba(5,6,9,.7);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
|
||
display:flex;justify-content:center;align-items:flex-start;padding:max(6vh,env(safe-area-inset-top)) 16px 16px;overflow-y:auto}
|
||
#sheet{position:relative;padding-top:22px;text-align:left}
|
||
#sheet h2{text-align:center}
|
||
#sheet>p{text-align:center}
|
||
#sheet .avatar.big{width:86px;height:86px;font-size:38px;margin:0 auto 10px;cursor:pointer}
|
||
.xbtn{position:absolute;top:10px;right:10px}
|
||
.items{display:flex;flex-direction:column;gap:2px;margin-top:8px}
|
||
.items button{display:flex;align-items:center;gap:12px;width:100%;padding:12px;border:0;border-radius:12px;background:none;
|
||
text-align:left;font-size:15.5px}
|
||
.items button:active,.items button:hover{background:rgba(255,255,255,.06)}
|
||
.items button small{margin-left:auto;color:var(--muted);font-size:13px}
|
||
.items svg{flex:none;width:21px;height:21px;color:var(--muted)}
|
||
.items .danger,.items .danger svg{color:var(--bad)}
|
||
.primary.danger{background:var(--bad)}
|
||
.ghost{width:100%;margin-top:8px;padding:11px;border:0;border-radius:14px;background:var(--panel2);font-size:15px}
|
||
#sheet input{text-align:left}
|
||
.qr{display:block;width:220px;height:220px;margin:4px auto 12px;border-radius:12px;background:#fff}
|
||
.linkbox{display:block;padding:10px 12px;border-radius:12px;background:var(--panel2);font:13px/1.4 ui-monospace,monospace;
|
||
color:var(--muted);overflow-wrap:anywhere;user-select:all;-webkit-user-select:all}
|
||
.note{margin-top:12px;color:var(--muted);font-size:13.5px;text-align:center}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="app">
|
||
<aside id="people">
|
||
<div class="phead">
|
||
<b>Chats</b>
|
||
<button class="icon" id="closePeople" aria-label="Close">
|
||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>
|
||
</button>
|
||
</div>
|
||
<div id="plist"></div>
|
||
<div class="pfoot">
|
||
<button class="chip" id="me" title="Your profile"></button>
|
||
<span class="ver" id="ver"></span>
|
||
</div>
|
||
</aside>
|
||
|
||
<section id="chat">
|
||
<header>
|
||
<button class="icon" id="peopleBtn" aria-label="Chats and people">
|
||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="8.5" r="3.3"/><path d="M2.8 19.5c.6-3.3 3.1-5.3 6.2-5.3s5.6 2 6.2 5.3"/><path d="M15.5 5.6a3.2 3.2 0 0 1 0 6M17.6 14.6c1.9.6 3.2 2.3 3.6 4.9"/></svg>
|
||
<span id="peopleBadge" hidden></span>
|
||
</button>
|
||
<div id="hAvatar"></div>
|
||
<div class="title">
|
||
<b id="hTitle">Everyone</b>
|
||
<span class="status" id="hSub">Connecting…</span>
|
||
</div>
|
||
</header>
|
||
|
||
<main id="wrap">
|
||
<div id="log">
|
||
<div class="empty" id="empty"></div>
|
||
<div id="typingRow" hidden><span class="tn" id="typingName"></span><div class="dots"><i></i><i></i><i></i></div></div>
|
||
</div>
|
||
<button id="jump" hidden aria-label="Jump to newest">
|
||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14M6 13l6 6 6-6"/></svg>
|
||
<span id="badge" hidden></span>
|
||
</button>
|
||
</main>
|
||
|
||
<footer>
|
||
<div id="mentions" hidden></div>
|
||
<div id="replyBar" hidden>
|
||
<div class="rq"><b id="rName"></b><span id="rText"></span></div>
|
||
<button type="button" class="icon" id="rCancel" aria-label="Cancel reply">
|
||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M7 7l10 10M17 7L7 17"/></svg>
|
||
</button>
|
||
</div>
|
||
<form id="bar" autocomplete="off">
|
||
<div class="field">
|
||
<button type="button" class="icon" id="emojiBtn" aria-label="Emoji"></button>
|
||
<input id="msg" maxlength="1000" placeholder="Message" enterkeyhint="send" autocomplete="off" autocorrect="on">
|
||
<button type="button" class="icon" id="photoBtn" aria-label="Send a photo">
|
||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="3.5"/><circle cx="9" cy="10.5" r="1.7"/><path d="M21 15.5l-4.6-4.6a1.2 1.2 0 0 0-1.7 0L7 18.6"/></svg>
|
||
</button>
|
||
</div>
|
||
<button class="send" id="send" aria-label="Send" disabled>
|
||
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3.4 20.4c-.7.3-1.4-.4-1.1-1.1L5 12 2.3 4.7c-.3-.7.4-1.4 1.1-1.1l17.5 7.5c.8.3.8 1.5 0 1.8L3.4 20.4zM6.6 12.9l-2 5.2 13.1-6.1L4.6 5.9l2 5.2H12v1.8H6.6z"/></svg>
|
||
</button>
|
||
</form>
|
||
<input type="file" id="file" accept="image/*" hidden>
|
||
<div id="emoji"><div id="egrid"></div><div id="etabs"></div></div>
|
||
</footer>
|
||
</section>
|
||
</div>
|
||
|
||
<div id="menuBack" hidden></div>
|
||
<div id="menu" hidden>
|
||
<button data-act="reply"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M9 7L4 12l5 5"/><path d="M4 12h10a6 6 0 0 1 6 6v1"/></svg>Reply</button>
|
||
<button data-act="copy"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linejoin="round"><rect x="8" y="8" width="12" height="12" rx="2.5"/><path d="M16 8V6.5A2.5 2.5 0 0 0 13.5 4h-7A2.5 2.5 0 0 0 4 6.5v7A2.5 2.5 0 0 0 6.5 16H8"/></svg>Copy text</button>
|
||
</div>
|
||
|
||
<div id="viewer" hidden><img alt=""></div>
|
||
|
||
<div id="modal" hidden>
|
||
<form class="card" id="loginForm">
|
||
<img class="logo" src="logo.svg" alt="">
|
||
<h2>Welcome aboard</h2>
|
||
<p id="lHint">Pick a name and a password. Use the same name and password to join from your other devices.</p>
|
||
<input id="nameIn" name="username" autocomplete="username" maxlength="24" placeholder="Your name" autocapitalize="words" enterkeyhint="next">
|
||
<input id="pwIn" name="password" type="password" autocomplete="current-password" maxlength="100" placeholder="Password" enterkeyhint="go">
|
||
<div class="err" id="lErr"></div>
|
||
<button class="primary" id="lBtn">Join the chat</button>
|
||
</form>
|
||
</div>
|
||
|
||
<div id="sheetBack" hidden><div class="card" id="sheet"></div></div>
|
||
<input type="file" id="avatarFile" accept="image/*" hidden>
|
||
|
||
<div id="toast"></div>
|
||
|
||
<script>
|
||
(() => {
|
||
'use strict';
|
||
|
||
/* ================================================================ basics */
|
||
const $ = id => document.getElementById(id);
|
||
const app = $('app'), log = $('log'), input = $('msg'), sendBtn = $('send'),
|
||
emojiPanel = $('emoji'), egrid = $('egrid'), etabs = $('etabs'), typingRow = $('typingRow');
|
||
const store = {
|
||
get(k) { try { return localStorage.getItem(k); } catch (e) { return null; } },
|
||
set(k, v) { try { localStorage.setItem(k, v); } catch (e) {} }
|
||
};
|
||
const enc = new TextEncoder(), dec = new TextDecoder();
|
||
const toHex = s => Array.from(enc.encode(s), b => b.toString(16).padStart(2, '0')).join('');
|
||
const fromHex = h => { try { return dec.decode(new Uint8Array((h.match(/../g) || []).map(x => parseInt(x, 16)))); } catch (e) { return '?'; } };
|
||
const randHex = n => Array.from(crypto.getRandomValues(new Uint8Array(n)), b => b.toString(16).padStart(2, '0')).join('');
|
||
const clean = s => s.replace(/[\t\r\n]+/g, ' ').trim();
|
||
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
|
||
const touch = matchMedia('(pointer: coarse)').matches;
|
||
const wide = () => matchMedia('(min-width: 760px)').matches;
|
||
const KEEP = 86400, ONLINE = 70, TYPING_SHOW = 7;
|
||
const ALL = '*';
|
||
|
||
const ICON_SMILE = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M8.3 14.2c.9 1.3 2.2 2 3.7 2s2.8-.7 3.7-2"/><circle cx="9" cy="9.8" r=".9" fill="currentColor" stroke="none"/><circle cx="15" cy="9.8" r=".9" fill="currentColor" stroke="none"/></svg>';
|
||
const ICON_KBD = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><rect x="2.5" y="6" width="19" height="12" rx="2.5"/><path d="M6 10h.01M9 10h.01M12 10h.01M15 10h.01M18 10h.01M6 13h.01M18 13h.01M8.5 14.5h7"/></svg>';
|
||
|
||
// identity: logging in gives this device a session token; the server only ever shows user ids
|
||
let tok = store.get('cc.tok') || '';
|
||
if (!/^[0-9a-f]{32}$/.test(tok)) tok = '';
|
||
const oldKey = store.get('cc.key'); // 3.x browser key: lets the first login keep the old id
|
||
const legacyId = store.get('cc.uid'); // id used by version 2, to recognise own old messages
|
||
let me = store.get('cc.me') || ''; // user id
|
||
|
||
/* ================================================================ state */
|
||
const msgs = new Map(); // id -> message (all conversations)
|
||
const convs = new Map(); // conversation key -> [messages]
|
||
const users = new Map(); // public id -> {nick, seen}
|
||
let typing = new Map(); // public id -> {to, ts}
|
||
let readMarks = {}; // conversation key -> last read id
|
||
try { readMarks = JSON.parse(store.get('cc.read') || '{}') || {}; } catch (e) {}
|
||
const firstVisit = !store.get('cc.read');
|
||
let conv = ALL; // the open conversation
|
||
let since = 0, ev = '', gen = '', offset = 0, online = null, loaded = false;
|
||
let stick = true, unseen = 0, prev = null, replyTo = null;
|
||
|
||
/* ================================================================ time */
|
||
const serverNow = () => Date.now() / 1000 + offset;
|
||
function ago(ts) {
|
||
const s = Math.max(0, serverNow() - ts);
|
||
if (s < 45) return 'now';
|
||
const m = Math.round(s / 60);
|
||
if (m < 60) return m + 'm ago';
|
||
return Math.floor(m / 60) + 'h ' + String(m % 60).padStart(2, '0') + 'm ago';
|
||
}
|
||
const shortAgo = ts => ago(ts).replace(' ago', '');
|
||
|
||
/* ================================================================ people & conversations */
|
||
const isMine = m => m.from === me || (legacyId && m.from === legacyId);
|
||
const convOf = m => m.to === ALL ? ALL : (isMine(m) ? m.to : m.from);
|
||
const hue = u => { let h = 0; for (const c of u) h = (h * 31 + c.charCodeAt(0)) >>> 0; return h % 360; };
|
||
const nameColor = id => 'hsl(' + hue(id) + ' 75% 70%)';
|
||
const nickOf = id => (users.get(id) || {}).nick || '?';
|
||
const isOnline = id => { const u = users.get(id); return !!u && serverNow() - u.seen < ONLINE; };
|
||
const isTyping = (id, to) => { const t = typing.get(id); return !!t && t.to === to && serverNow() - t.ts < TYPING_SHOW; };
|
||
|
||
const avatarUrl = id => { const u = users.get(id); return u && u.ava && u.ava !== '-' ? 'cgi-bin/chat?a=avatar&u=' + id + '&v=' + u.ava : ''; };
|
||
function avatar(id) {
|
||
const a = el('div', 'avatar');
|
||
if (id === ALL) { a.classList.add('group'); a.textContent = '👥'; return a; }
|
||
const src = avatarUrl(id);
|
||
if (src) { const im = new Image(); im.alt = ''; im.src = src; a.appendChild(im); }
|
||
else a.textContent = (Array.from(nickOf(id).trim())[0] || '?').toUpperCase();
|
||
a.style.background = 'hsl(' + hue(id) + ' 42% 34%)';
|
||
if (id !== me && isOnline(id)) a.appendChild(el('span', 'on'));
|
||
return a;
|
||
}
|
||
|
||
function typersIn(c) { // names typing in conversation c
|
||
const out = [];
|
||
for (const [id, t] of typing) {
|
||
if (serverNow() - t.ts >= TYPING_SHOW) continue;
|
||
if (c === ALL ? t.to === ALL : (id === c && t.to === me)) out.push(nickOf(id));
|
||
}
|
||
return out;
|
||
}
|
||
function typingText(names) {
|
||
if (!names.length) return '';
|
||
if (names.length === 1) return names[0] + ' is typing…';
|
||
if (names.length === 2) return names[0] + ' and ' + names[1] + ' are typing…';
|
||
return names.length + ' people are typing…';
|
||
}
|
||
|
||
const lastOf = c => { const a = convs.get(c); return a && a.length ? a[a.length - 1] : null; };
|
||
function unreadIn(c) {
|
||
const a = convs.get(c); if (!a) return 0;
|
||
const mark = readMarks[c] || 0; let n = 0;
|
||
for (let i = a.length - 1; i >= 0 && a[i].id > mark; i--) if (!isMine(a[i])) n++;
|
||
return n;
|
||
}
|
||
let saveReadTimer = 0;
|
||
function markRead(c) {
|
||
const last = lastOf(c);
|
||
if (!last || (readMarks[c] || 0) >= last.id) return;
|
||
readMarks[c] = last.id;
|
||
clearTimeout(saveReadTimer);
|
||
saveReadTimer = setTimeout(() => store.set('cc.read', JSON.stringify(readMarks)), 500);
|
||
}
|
||
function markReadIfSeen() { if (!document.hidden && stick && loaded) markRead(conv); }
|
||
|
||
const snippet = m => m.type === 'i' ? '📷 Photo' : (m.text.length > 120 ? m.text.slice(0, 120) + '…' : m.text);
|
||
|
||
/* ================================================================ mentions */
|
||
// "@Name" where Name is a known user; names may contain spaces, so the longest match wins
|
||
let wordChar = /\w/;
|
||
try { wordChar = new RegExp('[\\p{L}\\p{N}_]', 'u'); } catch (e) {}
|
||
function knownNames() {
|
||
const s = new Set();
|
||
for (const u of users.values()) if (u.nick && u.nick !== '?') s.add(u.nick);
|
||
return [...s].sort((a, b) => b.length - a.length);
|
||
}
|
||
function mentionParts(text, names) { // -> strings and {name, text} pieces
|
||
const out = [], low = text.toLowerCase();
|
||
let last = 0;
|
||
for (let i = text.indexOf('@'); i >= 0; i = text.indexOf('@', i + 1)) {
|
||
if (i > 0 && wordChar.test(text[i - 1])) continue;
|
||
const n = names.find(n => low.startsWith(n.toLowerCase(), i + 1) && !wordChar.test(text.charAt(i + 1 + n.length)));
|
||
if (!n) continue;
|
||
if (i > last) out.push(text.slice(last, i));
|
||
out.push({ name: n, text: text.slice(i, i + 1 + n.length) });
|
||
i += n.length; last = i + 1;
|
||
}
|
||
if (last < text.length) out.push(text.slice(last));
|
||
return out;
|
||
}
|
||
const isMe = name => name.toLowerCase() === nickOf(me).toLowerCase();
|
||
const mentionsMe = m => m.type === 't' && !isMine(m) && m.text.includes('@') &&
|
||
mentionParts(m.text, knownNames()).some(p => typeof p === 'object' && isMe(p.name));
|
||
function textEl(text) {
|
||
const s = el('span');
|
||
for (const p of mentionParts(text, knownNames())) {
|
||
if (typeof p === 'string') s.appendChild(document.createTextNode(p));
|
||
else s.appendChild(el('span', 'mention' + (isMe(p.name) ? ' me' : ''), p.text));
|
||
}
|
||
return s;
|
||
}
|
||
|
||
/* ================================================================ message rendering */
|
||
let emojiOnly = null;
|
||
try { emojiOnly = new RegExp('^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|\\u200d|\\ufe0f|\\s)+$', 'u'); } catch (e) {}
|
||
|
||
function parse(line) {
|
||
const f = line.split('\t');
|
||
if (f.length !== 8) return null;
|
||
const m = { id: +f[0], ts: +f[1], type: f[2], from: f[3], to: f[4], re: +f[5] || 0, nick: fromHex(f[6]) };
|
||
if (!(m.id > 0)) return null;
|
||
if (m.type === 'i') {
|
||
const p = f[7].split(' ');
|
||
m.file = p[0]; m.w = +p[1] || 0; m.h = +p[2] || 0;
|
||
if (!/^\d+(-[0-9a-f]{16})?\.jpg$/.test(m.file)) return null;
|
||
} else m.text = f[7];
|
||
return m;
|
||
}
|
||
|
||
function metaEl(ts) { const s = el('span', 'meta', ago(ts)); s.dataset.ts = ts; return s; }
|
||
|
||
function photoEl(src, w, h, cls) {
|
||
const im = new Image();
|
||
im.alt = 'Photo'; im.decoding = 'async'; im.loading = 'lazy'; im.draggable = false;
|
||
if (cls) im.className = cls;
|
||
if (w && h) im.style.aspectRatio = w + ' / ' + h;
|
||
im.onload = () => { if (stick) toBottom(); };
|
||
im.src = src;
|
||
return im;
|
||
}
|
||
|
||
function quoteEl(reId) {
|
||
const q = msgs.get(reId), d = el('div', 'quote');
|
||
d.dataset.re = reId;
|
||
const t = el('div', 'qt');
|
||
if (!q) { d.classList.add('gone'); t.append(el('b', null, ''), el('span', null, 'Message no longer available')); }
|
||
else {
|
||
if (q.type === 'i') d.appendChild(photoEl('img/' + q.file, 0, 0));
|
||
const b = el('b', null, isMine(q) ? 'You' : q.nick);
|
||
b.style.color = isMine(q) ? 'var(--accent)' : nameColor(q.from);
|
||
t.append(b, el('span', null, snippet(q)));
|
||
}
|
||
d.appendChild(t);
|
||
return d;
|
||
}
|
||
|
||
function render(m) {
|
||
const mine = isMine(m);
|
||
const grouped = prev && prev.row.isConnected && prev.from === m.from && Math.abs(m.ts - prev.ts) < 300;
|
||
const row = el('div', 'row last' + (mine ? ' mine' : '') + (grouped ? '' : ' first'));
|
||
if (grouped) prev.row.classList.remove('last');
|
||
if (!grouped && !mine && conv === ALL) {
|
||
const n = el('div', 'name');
|
||
n.append(avatar(m.from), el('span', null, m.nick));
|
||
n.style.color = nameColor(m.from);
|
||
row.appendChild(n);
|
||
}
|
||
const b = el('div', 'bubble');
|
||
b.dataset.id = m.id;
|
||
if (m.re) { b.classList.add('hasq'); b.appendChild(quoteEl(m.re)); }
|
||
if (m.type === 'i') {
|
||
b.classList.add('media');
|
||
b.append(photoEl('img/' + m.file, m.w, m.h, 'photo'), metaEl(m.ts));
|
||
} else {
|
||
if (!m.re && emojiOnly && m.text.length <= 16 && emojiOnly.test(m.text)) b.classList.add('jumbo');
|
||
if (mentionsMe(m)) b.classList.add('atme');
|
||
b.append(textEl(m.text), metaEl(m.ts));
|
||
}
|
||
row.appendChild(b);
|
||
row.dataset.ts = m.ts;
|
||
log.insertBefore(row, typingRow);
|
||
prev = { from: m.from, ts: m.ts, row };
|
||
$('empty').hidden = true;
|
||
}
|
||
|
||
function emptyText() {
|
||
return conv === ALL ? 'No messages yet.\nSay hi to everyone 👋'
|
||
: 'This is your private chat with ' + nickOf(conv) + '.\nOnly the two of you can see it.';
|
||
}
|
||
|
||
function renderConv() {
|
||
for (const r of log.querySelectorAll('.row')) r.remove();
|
||
prev = null;
|
||
for (const m of convs.get(conv) || []) render(m);
|
||
const e = $('empty');
|
||
e.textContent = emptyText(); e.style.whiteSpace = 'pre-line';
|
||
e.hidden = !!log.querySelector('.row');
|
||
stick = true; unseen = 0; updateJump();
|
||
toBottom();
|
||
}
|
||
|
||
function updateAges() {
|
||
for (const m of log.querySelectorAll('.meta[data-ts]')) m.textContent = ago(+m.dataset.ts);
|
||
}
|
||
|
||
// rolling 24 h window on the client as well
|
||
function expire() {
|
||
const cut = serverNow() - KEEP;
|
||
let changed = false;
|
||
for (const [id, m] of msgs) {
|
||
if (m.ts >= cut) continue;
|
||
msgs.delete(id); changed = true;
|
||
const a = convs.get(convOf(m));
|
||
if (a) { const i = a.indexOf(m); if (i >= 0) a.splice(i, 1); }
|
||
}
|
||
if (changed) {
|
||
for (const row of log.querySelectorAll('.row[data-ts]')) { if (+row.dataset.ts < cut) row.remove(); else break; }
|
||
$('empty').hidden = !!log.querySelector('.row');
|
||
}
|
||
}
|
||
|
||
/* ================================================================ header, people list, typing */
|
||
let listSig = '', headSig = '', meSig = '';
|
||
function refreshUI() {
|
||
// header
|
||
const sub = $('hSub');
|
||
let text, cls = '';
|
||
if (online === false) { text = 'Reconnecting…'; cls = 'bad'; }
|
||
else if (conv === ALL) {
|
||
const t = typingText(typersIn(ALL));
|
||
if (t) { text = t; cls = 'typing'; }
|
||
else { let n = 1; for (const id of users.keys()) if (id !== me && isOnline(id)) n++; text = online ? n + ' online' : 'Connecting…'; }
|
||
} else if (isTyping(conv, me)) { text = 'typing…'; cls = 'typing'; }
|
||
else if (isOnline(conv)) text = 'online';
|
||
else { const u = users.get(conv); text = u && u.seen ? 'last seen ' + ago(u.seen) : 'offline'; }
|
||
sub.textContent = text; sub.className = 'status ' + cls;
|
||
$('hTitle').textContent = conv === ALL ? 'Everyone' : nickOf(conv);
|
||
const hsig = conv + avatarUrl(conv) + nickOf(conv) + isOnline(conv);
|
||
if (hsig !== headSig) { headSig = hsig; const ha = $('hAvatar'); ha.textContent = ''; ha.appendChild(avatar(conv)); }
|
||
const msig = nickOf(me) + avatarUrl(me);
|
||
if (me && msig !== meSig) { meSig = msig; $('me').textContent = ''; $('me').append(avatar(me), el('span', null, nickOf(me))); }
|
||
|
||
// typing bubble at the bottom of the open chat
|
||
const names = typersIn(conv);
|
||
const wasHidden = typingRow.hidden;
|
||
typingRow.hidden = !names.length;
|
||
$('typingName').textContent = conv === ALL && names.length ? names.join(', ') : '';
|
||
$('typingName').hidden = conv !== ALL;
|
||
if (wasHidden !== typingRow.hidden && stick) toBottom();
|
||
|
||
// unread badge on the people button: messages waiting in other chats
|
||
let others = 0, total = 0;
|
||
for (const c of convs.keys()) { const n = unreadIn(c); total += n; if (c !== conv) others += n; }
|
||
$('peopleBadge').hidden = !others;
|
||
$('peopleBadge').textContent = others > 99 ? '99+' : others;
|
||
document.title = document.hidden && total ? '(' + total + ') Cabin Chat' : 'Cabin Chat';
|
||
|
||
renderList();
|
||
}
|
||
|
||
function peopleIds() {
|
||
const ids = new Set();
|
||
for (const [id, u] of users) if (serverNow() - u.seen < KEEP) ids.add(id); // accounts stay; show the recent ones
|
||
for (const c of convs.keys()) if (c !== ALL) ids.add(c);
|
||
for (const m of convs.get(ALL) || []) ids.add(m.from);
|
||
ids.delete(me); ids.delete(ALL); if (legacyId) ids.delete(legacyId);
|
||
return [...ids];
|
||
}
|
||
function activity(id) {
|
||
const u = users.get(id), l = lastOf(id);
|
||
return Math.max(u ? u.seen : 0, l ? l.ts : 0);
|
||
}
|
||
|
||
function renderList() {
|
||
const ids = peopleIds().sort((a, b) => (isOnline(b) - isOnline(a)) || (activity(b) - activity(a)));
|
||
const rows = [ALL, ...ids].map(c => {
|
||
const last = lastOf(c), n = unreadIn(c);
|
||
let sub, typ = false;
|
||
if (c === ALL) {
|
||
const t = typingText(typersIn(ALL));
|
||
if (t) { sub = t; typ = true; }
|
||
else sub = last ? (isMine(last) ? 'You' : last.nick) + ': ' + snippet(last) : 'Group chat with everyone';
|
||
} else if (isTyping(c, me)) { sub = 'typing…'; typ = true; }
|
||
else if (last) sub = (isMine(last) ? 'You: ' : '') + snippet(last);
|
||
else sub = isOnline(c) ? 'online' : (users.get(c) && users.get(c).seen ? 'last seen ' + ago(users.get(c).seen) : 'offline');
|
||
return { c, name: c === ALL ? 'Everyone' : nickOf(c), sub, typ, n, time: last ? shortAgo(last.ts) : '', on: c !== ALL && isOnline(c), ava: avatarUrl(c) };
|
||
});
|
||
const sig = conv + JSON.stringify(rows);
|
||
if (sig === listSig) return;
|
||
listSig = sig;
|
||
|
||
const list = $('plist'); list.textContent = '';
|
||
rows.forEach((r, i) => {
|
||
if (i === 1) list.appendChild(el('div', 'psec', 'People'));
|
||
const b = el('button', 'pitem' + (r.c === conv ? ' active' : ''));
|
||
b.type = 'button';
|
||
b.dataset.conv = r.c;
|
||
const main = el('div', 'pmain');
|
||
main.append(el('div', 'pname', r.name), el('div', 'psub' + (r.typ ? ' typing' : ''), r.sub));
|
||
const side = el('div', 'pside');
|
||
side.appendChild(el('span', 'ptime', r.time));
|
||
if (r.n) side.appendChild(el('span', 'pbadge', r.n > 99 ? '99+' : r.n));
|
||
b.append(avatar(r.c), main, side);
|
||
list.appendChild(b);
|
||
});
|
||
if (rows.length === 1) list.appendChild(el('div', 'pnone', 'Nobody else here yet. People show up as soon as they open the chat.'));
|
||
}
|
||
|
||
$('plist').addEventListener('click', e => {
|
||
const b = e.target.closest('.pitem');
|
||
if (b) openConv(b.dataset.conv);
|
||
});
|
||
|
||
function openConv(c) {
|
||
if (c !== conv) {
|
||
stopTyping();
|
||
conv = c;
|
||
store.set('cc.conv', c);
|
||
cancelReply();
|
||
renderConv();
|
||
input.placeholder = c === ALL ? 'Message everyone' : 'Message ' + nickOf(c);
|
||
listSig = '';
|
||
}
|
||
closePeople();
|
||
markReadIfSeen();
|
||
refreshUI();
|
||
}
|
||
|
||
/* drawer: on phones the people list slides over the chat; the back button closes it */
|
||
function openPeople() {
|
||
if (wide() || app.classList.contains('people')) return;
|
||
app.classList.add('people');
|
||
history.pushState({ cc: 'people' }, '');
|
||
}
|
||
function closePeople() {
|
||
if (!app.classList.contains('people')) return;
|
||
app.classList.remove('people');
|
||
if (history.state && history.state.cc === 'people') history.back();
|
||
}
|
||
addEventListener('popstate', () => app.classList.remove('people'));
|
||
$('peopleBtn').addEventListener('click', openPeople);
|
||
$('closePeople').addEventListener('click', closePeople);
|
||
|
||
/* ================================================================ scrolling & keyboard */
|
||
function toBottom() { log.scrollTop = log.scrollHeight; }
|
||
function updateJump() {
|
||
$('jump').hidden = stick;
|
||
$('badge').hidden = !unseen;
|
||
$('badge').textContent = unseen > 99 ? '99+' : unseen;
|
||
}
|
||
log.addEventListener('scroll', () => {
|
||
const s = log.scrollHeight - log.scrollTop - log.clientHeight < 70;
|
||
if (s !== stick) { stick = s; if (s) { unseen = 0; markReadIfSeen(); refreshUI(); } updateJump(); }
|
||
if (menuOpen) closeMenu();
|
||
}, { passive: true });
|
||
$('jump').addEventListener('click', () => { stick = true; unseen = 0; toBottom(); updateJump(); markReadIfSeen(); refreshUI(); });
|
||
|
||
// keep the layout above the soft keyboard (iOS ignores interactive-widget)
|
||
let fullH = 0;
|
||
function fit() {
|
||
const vv = window.visualViewport;
|
||
if (!vv) return;
|
||
fullH = Math.max(fullH, vv.height);
|
||
app.style.height = vv.height + 'px';
|
||
app.style.transform = vv.offsetTop ? 'translateY(' + vv.offsetTop + 'px)' : '';
|
||
app.classList.toggle('kb', vv.height < fullH - 120);
|
||
if (stick) toBottom();
|
||
}
|
||
if (window.visualViewport) {
|
||
visualViewport.addEventListener('resize', fit);
|
||
visualViewport.addEventListener('scroll', fit);
|
||
addEventListener('orientationchange', () => { fullH = 0; setTimeout(fit, 300); });
|
||
fit();
|
||
}
|
||
|
||
/* ================================================================ network: long poll */
|
||
let ctrl = null, kicked = false, wake = null, fails = 0;
|
||
const nap = ms => new Promise(r => { const t = setTimeout(r, ms); wake = () => { clearTimeout(t); r(); }; });
|
||
|
||
function kick() { // restart the long poll right now
|
||
kicked = true;
|
||
if (ctrl) ctrl.abort();
|
||
if (wake) wake();
|
||
}
|
||
|
||
function setOnline(v) { if (v !== online) { online = v; refreshUI(); } }
|
||
|
||
function resetAll() { // reload everything with the next poll (quietly, like the first load)
|
||
msgs.clear(); convs.clear(); users.clear(); since = 0; ev = ''; loaded = false;
|
||
renderConv();
|
||
}
|
||
|
||
function addMessage(m) {
|
||
if (msgs.has(m.id)) return false;
|
||
msgs.set(m.id, m);
|
||
const c = convOf(m);
|
||
if (!convs.has(c)) convs.set(c, []);
|
||
convs.get(c).push(m);
|
||
if (!isMine(m) && !users.has(m.from)) users.set(m.from, { nick: m.nick, seen: 0 });
|
||
if (!isMine(m)) typing.delete(m.from);
|
||
return true;
|
||
}
|
||
|
||
function handle(text) {
|
||
const lines = text.split('\n');
|
||
lines.pop(); // '' or a half-written line
|
||
const h = (lines.shift() || '').split('\t');
|
||
if (h.length < 5 || h[0][0] !== '@') throw new Error('bad response');
|
||
offset = +h[0].slice(1) - Date.now() / 1000;
|
||
const last = +h[1];
|
||
if (me !== h[3]) { me = h[3]; store.set('cc.me', me); }
|
||
if (gen && h[4] !== gen) { gen = h[4]; resetAll(); return; } // messages were deleted
|
||
gen = h[4];
|
||
if (last < since) { resetAll(); return; } // chat was wiped on the router
|
||
ev = h[2];
|
||
|
||
const fresh = [];
|
||
typing = new Map();
|
||
for (const l of lines) {
|
||
if (l[0] === 'U') {
|
||
const [, id, n, s, ava] = l.split('\t');
|
||
users.set(id, { nick: fromHex(n) || '?', seen: +s, ava: ava || '-' });
|
||
} else if (l[0] === 'W') {
|
||
const [, id, to, ts] = l.split('\t');
|
||
typing.set(id, { to, ts: +ts });
|
||
} else {
|
||
const m = parse(l);
|
||
if (m && addMessage(m)) fresh.push(m);
|
||
}
|
||
}
|
||
since = last;
|
||
|
||
if (!loaded) { // first answer: build everything
|
||
loaded = true;
|
||
if (firstVisit) { for (const c of convs.keys()) markRead(c); }
|
||
if (conv !== ALL && !peopleIds().includes(conv)) conv = ALL;
|
||
input.placeholder = conv === ALL ? 'Message everyone' : 'Message ' + nickOf(conv);
|
||
renderConv();
|
||
} else if (fresh.length) {
|
||
let here = 0, theirs = 0;
|
||
for (const m of fresh) {
|
||
const inView = convOf(m) === conv;
|
||
if (inView) { render(m); here++; if (!isMine(m)) theirs++; }
|
||
if (!isMine(m)) notify(m, inView);
|
||
}
|
||
if (here) { if (stick) toBottom(); else { unseen += theirs; updateJump(); } }
|
||
}
|
||
markReadIfSeen();
|
||
}
|
||
|
||
async function pollOnce() {
|
||
ctrl = new AbortController();
|
||
kicked = false;
|
||
const watchdog = setTimeout(() => ctrl.abort(), 40000); // dead connection (router reboot, WiFi drop)
|
||
try {
|
||
const url = 'cgi-bin/chat?k=' + tok + '&since=' + since + '&ev=' + ev + '&w=' + (ev ? 1 : 0);
|
||
const r = await fetch(url, { cache: 'no-store', signal: ctrl.signal });
|
||
if (r.status === 401) { signedOut(); return 0; }
|
||
if (!r.ok) throw new Error(r.status);
|
||
handle(await r.text());
|
||
fails = 0;
|
||
setOnline(true);
|
||
} catch (e) {
|
||
if (!kicked) { fails++; if (fails > 1) setOnline(false); }
|
||
} finally {
|
||
clearTimeout(watchdog);
|
||
}
|
||
updateAges(); refreshUI();
|
||
if (kicked) return 0;
|
||
if (fails) return Math.min(10000, 1000 * fails);
|
||
return document.hidden ? 3000 : 0; // background: fewer wake-ups
|
||
}
|
||
|
||
let running = false;
|
||
async function loop() {
|
||
if (running) return;
|
||
running = true;
|
||
while (tok) {
|
||
const d = await pollOnce();
|
||
if (d && tok) await nap(d);
|
||
wake = null;
|
||
}
|
||
running = false;
|
||
}
|
||
|
||
// POST to the backend; resolves with the reply text, rejects with the server's message
|
||
async function api(act, body, extra) {
|
||
const r = await fetch('cgi-bin/chat?a=' + act + (tok ? '&k=' + tok : '') + (extra || ''), {
|
||
method: 'POST', body,
|
||
headers: { 'Content-Type': body instanceof Blob ? 'image/jpeg' : 'text/plain;charset=utf-8' }
|
||
});
|
||
const t = (await r.text()).trim();
|
||
if (r.status === 401 && tok) { signedOut(); throw new Error('Please log in again'); }
|
||
if (!r.ok) throw new Error(t || 'error ' + r.status);
|
||
return t;
|
||
}
|
||
|
||
document.addEventListener('visibilitychange', () => {
|
||
if (!document.hidden) { markReadIfSeen(); refreshUI(); kick(); } // a frozen tab's request may be dead
|
||
});
|
||
|
||
const postUrl = (act, extra) =>
|
||
'cgi-bin/chat?a=' + act + '&k=' + tok + '&to=' + encodeURIComponent(conv) + (extra || '');
|
||
|
||
/* ================================================================ typing notices */
|
||
let typingSent = 0, typingConv = null;
|
||
function sendTyping(to) {
|
||
fetch('cgi-bin/chat?a=typing&k=' + tok + '&to=' + encodeURIComponent(to), { method: 'POST' }).catch(() => {});
|
||
}
|
||
function onTyping() {
|
||
const now = Date.now();
|
||
if (input.value.trim()) {
|
||
if (now - typingSent > 3000 || typingConv !== conv) { typingSent = now; typingConv = conv; sendTyping(conv); }
|
||
} else stopTyping();
|
||
}
|
||
function stopTyping() {
|
||
if (typingSent && Date.now() - typingSent < 9000) sendTyping('-');
|
||
typingSent = 0; typingConv = null;
|
||
}
|
||
|
||
/* ================================================================ sending */
|
||
async function sendText() {
|
||
const m = clean(input.value).slice(0, 1000);
|
||
if (!m) return;
|
||
const re = replyTo;
|
||
input.value = ''; updateSend(); cancelReply(); hideMentions();
|
||
typingSent = 0; typingConv = null; // the server clears our typing notice
|
||
try {
|
||
const r = await fetch(postUrl('text', re ? '&re=' + re : ''), { method: 'POST', headers: { 'Content-Type': 'text/plain;charset=utf-8' }, body: m });
|
||
if (!r.ok) throw new Error();
|
||
} catch (e) {
|
||
if (!input.value) { input.value = m; updateSend(); if (re) setReply(re); }
|
||
toast('Message not sent – are you on the chat WiFi?');
|
||
}
|
||
stick = true;
|
||
}
|
||
|
||
function loadImage(file) {
|
||
return new Promise((res, rej) => {
|
||
const url = URL.createObjectURL(file), img = new Image();
|
||
img.onload = () => { URL.revokeObjectURL(url); res(img); };
|
||
img.onerror = () => { URL.revokeObjectURL(url); rej(new Error('Can’t read this image format')); };
|
||
img.src = url;
|
||
});
|
||
}
|
||
|
||
// scale down + re-encode as JPEG until it fits into ~100 kB
|
||
async function shrink(file, target = 100 * 1024) {
|
||
const img = await loadImage(file); // browsers apply EXIF rotation here
|
||
const W = img.naturalWidth, H = img.naturalHeight;
|
||
const c = document.createElement('canvas'), ctx = c.getContext('2d');
|
||
let max = 1280, q = 0.8, blob = null;
|
||
for (let i = 0; i < 12; i++) {
|
||
const s = Math.min(1, max / Math.max(W, H));
|
||
c.width = Math.max(1, Math.round(W * s)); c.height = Math.max(1, Math.round(H * s));
|
||
ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, c.width, c.height);
|
||
ctx.drawImage(img, 0, 0, c.width, c.height);
|
||
blob = await new Promise(r => c.toBlob(r, 'image/jpeg', q));
|
||
if (!blob) throw new Error('Could not process the photo');
|
||
if (blob.size <= target) break;
|
||
if (q > 0.55) q -= 0.1; else max = Math.round(max * 0.8);
|
||
}
|
||
return { blob, w: c.width, h: c.height };
|
||
}
|
||
|
||
function pendingRow(blob, w, h) {
|
||
const row = el('div', 'row mine last first');
|
||
const b = el('div', 'bubble media pending');
|
||
const url = URL.createObjectURL(blob);
|
||
b.append(photoEl(url, w, h, 'photo'), el('div', 'spin'));
|
||
row.appendChild(b);
|
||
log.insertBefore(row, typingRow);
|
||
$('empty').hidden = true;
|
||
stick = true; toBottom();
|
||
return () => { row.remove(); URL.revokeObjectURL(url); };
|
||
}
|
||
|
||
async function sendPhoto(file) {
|
||
let done = null;
|
||
const re = replyTo;
|
||
cancelReply();
|
||
try {
|
||
const { blob, w, h } = await shrink(file);
|
||
done = pendingRow(blob, w, h);
|
||
const extra = '&w=' + w + '&h=' + h + '&r=' + randHex(8) + (re ? '&re=' + re : '');
|
||
const r = await fetch(postUrl('img', extra), { method: 'POST', headers: { 'Content-Type': 'image/jpeg' }, body: blob });
|
||
if (!r.ok) throw new Error(r.status === 507 ? 'Chat storage is full' : 'Photo upload failed (' + r.status + ')');
|
||
} catch (e) {
|
||
toast(e.message && !/fetch|network|load/i.test(e.message) ? e.message : 'Photo not sent – are you on the chat WiFi?');
|
||
}
|
||
if (done) setTimeout(done, 400); // the real message arrives through the long poll
|
||
stick = true;
|
||
}
|
||
|
||
$('photoBtn').addEventListener('click', () => $('file').click());
|
||
$('file').addEventListener('change', () => {
|
||
const f = $('file').files[0];
|
||
$('file').value = '';
|
||
if (f) sendPhoto(f);
|
||
});
|
||
|
||
function openViewer(src) { $('viewer').firstElementChild.src = src; $('viewer').hidden = false; }
|
||
$('viewer').addEventListener('click', () => { $('viewer').hidden = true; });
|
||
addEventListener('keydown', e => { if (e.key === 'Escape') { $('viewer').hidden = true; closeMenu(); cancelReply(); closeSheet(); } });
|
||
|
||
/* ================================================================ replies (quotes) */
|
||
function setReply(id) {
|
||
const m = msgs.get(id);
|
||
if (!m) return;
|
||
replyTo = id;
|
||
$('rName').textContent = 'Reply to ' + (isMine(m) ? 'yourself' : m.nick);
|
||
$('rText').textContent = snippet(m);
|
||
$('replyBar').hidden = false;
|
||
input.focus();
|
||
if (stick) setTimeout(toBottom, 50);
|
||
}
|
||
function cancelReply() { replyTo = null; $('replyBar').hidden = true; }
|
||
$('rCancel').addEventListener('mousedown', e => e.preventDefault());
|
||
$('rCancel').addEventListener('click', cancelReply);
|
||
|
||
function jumpTo(id) {
|
||
const b = log.querySelector('.bubble[data-id="' + id + '"]');
|
||
if (!b) { toast('That message is no longer here'); return; }
|
||
b.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||
b.classList.remove('flash'); void b.offsetWidth; b.classList.add('flash');
|
||
}
|
||
|
||
// message menu: long press (touch), right click (mouse), swipe right = quick reply
|
||
let menuOpen = null, menuAt = 0, swipe = null, swallowClick = false;
|
||
function openMenu(b) {
|
||
const m = msgs.get(+b.dataset.id);
|
||
if (!m) return;
|
||
closeMenu();
|
||
menuOpen = b; menuAt = Date.now();
|
||
b.classList.add('sel');
|
||
if (navigator.vibrate) try { navigator.vibrate(12); } catch (e) {}
|
||
const menu = $('menu');
|
||
menu.querySelector('[data-act="copy"]').hidden = m.type !== 't';
|
||
$('menuBack').hidden = false; menu.hidden = false;
|
||
const r = b.getBoundingClientRect(), mw = menu.offsetWidth, mh = menu.offsetHeight;
|
||
let x = isMine(m) ? r.right - mw : r.left, y = r.bottom + 6;
|
||
if (y + mh > innerHeight - 10) y = r.top - mh - 6;
|
||
menu.style.left = Math.max(8, Math.min(x, innerWidth - mw - 8)) + 'px';
|
||
menu.style.top = Math.max(8, y) + 'px';
|
||
}
|
||
function closeMenu() {
|
||
if (!menuOpen) return;
|
||
menuOpen.classList.remove('sel');
|
||
menuOpen = null;
|
||
$('menu').hidden = true; $('menuBack').hidden = true;
|
||
}
|
||
$('menuBack').addEventListener('click', () => { if (Date.now() - menuAt > 450) closeMenu(); }); // ignore the finger lifting after a long press
|
||
$('menuBack').addEventListener('contextmenu', e => { e.preventDefault(); closeMenu(); });
|
||
$('menu').addEventListener('click', e => {
|
||
const b = e.target.closest('button');
|
||
if (!b || !menuOpen) return;
|
||
const m = msgs.get(+menuOpen.dataset.id);
|
||
closeMenu();
|
||
if (!m) return;
|
||
if (b.dataset.act === 'reply') setReply(m.id);
|
||
if (b.dataset.act === 'copy') copyText(m.text);
|
||
});
|
||
|
||
function copyText(t) {
|
||
const ta = el('textarea');
|
||
ta.value = t; ta.setAttribute('readonly', '');
|
||
ta.style.cssText = 'position:fixed;top:0;left:0;opacity:0';
|
||
document.body.appendChild(ta);
|
||
ta.select(); ta.setSelectionRange(0, t.length);
|
||
let ok = false;
|
||
try { ok = document.execCommand('copy'); } catch (e) {}
|
||
ta.remove();
|
||
if (!ok && navigator.clipboard) navigator.clipboard.writeText(t).then(() => toast('Copied'), () => toast('Copy not supported here'));
|
||
else toast(ok ? 'Copied' : 'Copy not supported here');
|
||
}
|
||
|
||
log.addEventListener('pointerdown', e => {
|
||
const b = e.target.closest('.bubble[data-id]');
|
||
swallowClick = false;
|
||
if (!b || e.button > 0) return;
|
||
swipe = { b, x: e.clientX, y: e.clientY, mode: null, dx: 0,
|
||
timer: e.pointerType === 'mouse' ? 0 : setTimeout(() => {
|
||
if (swipe && !swipe.mode) { swipe.mode = 'press'; swallowClick = true; openMenu(b); }
|
||
}, 480) };
|
||
});
|
||
log.addEventListener('pointermove', e => {
|
||
if (!swipe) return;
|
||
const dx = e.clientX - swipe.x, dy = e.clientY - swipe.y;
|
||
if (!swipe.mode) {
|
||
if (Math.abs(dy) > 10 || dx < -10) return endSwipe();
|
||
if (dx > 14 && e.pointerType !== 'mouse') { swipe.mode = 'swipe'; clearTimeout(swipe.timer); swipe.b.classList.add('swiping'); }
|
||
}
|
||
if (swipe.mode === 'swipe') {
|
||
swipe.dx = Math.max(0, Math.min(90, dx));
|
||
swipe.b.style.transform = 'translateX(' + swipe.dx + 'px)';
|
||
}
|
||
});
|
||
function endSwipe() {
|
||
if (!swipe) return;
|
||
clearTimeout(swipe.timer);
|
||
if (swipe.mode === 'swipe') {
|
||
swipe.b.classList.remove('swiping');
|
||
swipe.b.style.transform = '';
|
||
swallowClick = true;
|
||
if (swipe.dx > 60) setReply(+swipe.b.dataset.id);
|
||
}
|
||
swipe = null;
|
||
}
|
||
log.addEventListener('pointerup', endSwipe);
|
||
log.addEventListener('pointercancel', endSwipe);
|
||
log.addEventListener('contextmenu', e => {
|
||
const b = e.target.closest('.bubble[data-id]');
|
||
if (!b) return;
|
||
e.preventDefault();
|
||
if (!menuOpen) openMenu(b);
|
||
});
|
||
log.addEventListener('click', e => {
|
||
if (swallowClick) { swallowClick = false; e.preventDefault(); e.stopPropagation(); return; }
|
||
const q = e.target.closest('.quote[data-re]');
|
||
if (q) { jumpTo(+q.dataset.re); return; }
|
||
const im = e.target.closest('img.photo');
|
||
if (im && im.closest('.bubble[data-id]')) openViewer(im.src);
|
||
}, true);
|
||
|
||
/* ================================================================ notifications for other chats */
|
||
let toastTimer = 0;
|
||
function toast(t, onClick) {
|
||
const e = $('toast');
|
||
e.textContent = t;
|
||
e.classList.add('show');
|
||
e.classList.toggle('click', !!onClick);
|
||
e.onclick = onClick ? () => { e.classList.remove('show'); onClick(); } : null;
|
||
clearTimeout(toastTimer);
|
||
toastTimer = setTimeout(() => e.classList.remove('show'), onClick ? 4500 : 3200);
|
||
}
|
||
// system notifications: shown while the chat runs in the background (another tab or app,
|
||
// screen on). Without internet there is no push service, so a closed chat can't be woken up.
|
||
// cc.notify: 'all' | 'direct' (private messages and mentions) | 'off'
|
||
let swReg = null;
|
||
const canNotify = () => 'Notification' in window && window.isSecureContext;
|
||
const notifyPref = () => store.get('cc.notify') || 'all';
|
||
function notify(m, inView) {
|
||
const c = convOf(m), where = m.to === ALL ? m.nick + ' in Everyone' : m.nick;
|
||
if (document.hidden || !document.hasFocus()) { sysNotify(m, c, where); return; }
|
||
if (!inView) toast((mentionsMe(m) ? '@ ' : '💬 ') + where + ': ' + snippet(m), () => openConv(c));
|
||
}
|
||
function sysNotify(m, c, where) {
|
||
if (!canNotify() || Notification.permission !== 'granted') return;
|
||
const pref = notifyPref();
|
||
if (pref === 'off' || (pref === 'direct' && m.to === ALL && !mentionsMe(m))) return;
|
||
const at = mentionsMe(m), title = (at ? '@ ' : '') + where;
|
||
// one notification per chat (newest replaces older ones); mentions stay
|
||
const opts = { body: snippet(m), tag: at ? 'cc-at-' + m.id : 'cc-' + c, renotify: true, icon: 'icon-192.png', data: { conv: c } };
|
||
if (swReg) { swReg.showNotification(title, opts).catch(() => {}); return; }
|
||
try {
|
||
const n = new Notification(title, opts);
|
||
n.onclick = () => { focus(); openConv(c); n.close(); };
|
||
} catch (e) {}
|
||
}
|
||
async function askNotify() {
|
||
if (!canNotify()) {
|
||
toast(window.isSecureContext ? 'This browser has no notifications' : 'Notifications need the https:// address');
|
||
return false;
|
||
}
|
||
let p = Notification.permission;
|
||
if (p === 'default') p = await Notification.requestPermission();
|
||
if (p !== 'granted') toast('Notifications are blocked – allow them in the browser’s site settings');
|
||
return p === 'granted';
|
||
}
|
||
if ('serviceWorker' in navigator && window.isSecureContext) {
|
||
navigator.serviceWorker.register('sw.js').then(r => { swReg = r; }).catch(() => {});
|
||
navigator.serviceWorker.addEventListener('message', e => {
|
||
if (e.data && e.data.cc === 'open' && e.data.conv) openConv(e.data.conv);
|
||
});
|
||
}
|
||
|
||
// "install as app": Chrome/Edge/Android offer a prompt, iOS needs Share → Add to Home Screen
|
||
let installPrompt = null;
|
||
addEventListener('beforeinstallprompt', e => { e.preventDefault(); installPrompt = e; });
|
||
const standalone = () => matchMedia('(display-mode: standalone)').matches || navigator.standalone === true;
|
||
const ios = /iPhone|iPad|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
||
|
||
/* ================================================================ emoji */
|
||
const EMOJI = [
|
||
['🕘', ''],
|
||
['😀', '😀 😃 😄 😁 😆 😅 🤣 😂 🙂 🙃 😉 😊 😇 🥰 😍 🤩 😘 😗 😚 😋 😛 😜 🤪 😝 🤑 🤗 🤭 🤫 🤔 🤐 🤨 😐 😑 😶 😏 😒 🙄 😬 🤥 😌 😔 😪 🤤 😴 😷 🤒 🤕 🤢 🤮 🥵 🥶 🥴 😵 🤯 🤠 🥳 😎 🤓 🧐 😕 😟 🙁 😮 😯 😲 😳 🥺 😦 😧 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 🥱 😤 😡 😠 🤬 😈 💀 💩 🤡 👻 👽 🤖'],
|
||
['👍', '👋 🤚 ✋ 🖖 👌 🤏 ✌️ 🤞 🤟 🤘 🤙 👈 👉 👆 👇 ☝️ 👍 👎 ✊ 👊 🤛 🤜 👏 🙌 👐 🤲 🤝 🙏 💪 ❤️ 🧡 💛 💚 💙 💜 🖤 🤍 💔 ❣️ 💕 💞 💓 💗 💖 💘 💝 🙈 🙉 🙊'],
|
||
['✈️', '✈️ 🛫 🛬 🛩️ 💺 🚁 🧳 🛂 🛃 🌍 🌎 🌏 🗺️ 🏝️ 🏖️ 🏔️ 🌋 🗽 🗼 🏰 🚗 🚕 🚌 🚆 🚢 ⛵ 🚀 🛸 🌅 🌄 🌃 🌌 ☁️ ⛅ 🌤️ 🌧️ ⛈️ 🌩️ 🌈 ☀️ 🌙 ⭐ 🌟 ❄️ 🌊'],
|
||
['🍔', '☕ 🍵 🧃 🥤 🍺 🍻 🥂 🍷 🥃 🍸 🍹 🍾 🍔 🍟 🍕 🌭 🥪 🌮 🌯 🥗 🍝 🍜 🍣 🍱 🥟 🍩 🍪 🎂 🍰 🧁 🍫 🍬 🍭 🍿 🥨 🥐 🧀 🍎 🍌 🍇 🍓 🍉 🍒 🥑 🌶️'],
|
||
['🎉', '🎉 🎊 🎈 🎁 🏆 🥇 ⚽ 🏀 🎮 🎲 🎯 🎧 🎵 🎶 🎬 📸 📷 📱 💻 ⌚ 🔋 🔌 💡 📖 ✏️ 📝 📌 🔑 🛏️ 🧸 💤 🎤 🎸 🧩 ♟️'],
|
||
['✅', '✅ ❌ ❓ ❗ 💯 🔥 ✨ 💥 💫 💦 💨 🆗 🆒 🆕 🆘 ⚠️ 🚫 ⛔ 📵 🔇 🔔 ⏰ ⏳ ➡️ ⬅️ ⬆️ ⬇️ 🔁 ➕ ➖ ✖️ 💲 ♻️ 🟢 🟡 🔴']
|
||
];
|
||
let recent = (store.get('cc.recent') || '').split(' ').filter(Boolean);
|
||
let emojiTab = -1;
|
||
|
||
EMOJI.forEach(([icon], i) => {
|
||
const b = el('button', null, icon);
|
||
b.type = 'button';
|
||
b.setAttribute('aria-label', i ? 'Category' : 'Recently used');
|
||
b.addEventListener('click', () => showTab(i));
|
||
etabs.appendChild(b);
|
||
});
|
||
|
||
function showTab(i) {
|
||
emojiTab = i;
|
||
[...etabs.children].forEach((b, j) => b.classList.toggle('on', i === j));
|
||
egrid.textContent = '';
|
||
const list = i === 0 ? recent : EMOJI[i][1].split(' ');
|
||
if (!list.length) egrid.appendChild(el('div', 'enone', 'Emoji you use will show up here'));
|
||
for (const e of list) { const b = el('button', null, e); b.type = 'button'; egrid.appendChild(b); }
|
||
egrid.scrollTop = 0;
|
||
}
|
||
|
||
egrid.addEventListener('mousedown', e => e.preventDefault()); // keep the cursor
|
||
egrid.addEventListener('click', e => {
|
||
const b = e.target.closest('button');
|
||
if (!b) return;
|
||
const em = b.textContent;
|
||
const st = input.selectionStart ?? input.value.length, en = input.selectionEnd ?? st;
|
||
input.setRangeText(em, st, en, 'end');
|
||
updateSend(); onTyping();
|
||
recent = [em, ...recent.filter(x => x !== em)].slice(0, 40);
|
||
store.set('cc.recent', recent.join(' '));
|
||
});
|
||
|
||
function setEmoji(open) {
|
||
emojiPanel.classList.toggle('open', open);
|
||
$('emojiBtn').innerHTML = open ? ICON_KBD : ICON_SMILE;
|
||
$('emojiBtn').setAttribute('aria-label', open ? 'Keyboard' : 'Emoji');
|
||
if (open) {
|
||
if (touch) input.blur();
|
||
if (emojiTab < 0) showTab(recent.length ? 0 : 1);
|
||
}
|
||
setTimeout(() => { if (stick) toBottom(); }, 230);
|
||
}
|
||
$('emojiBtn').innerHTML = ICON_SMILE;
|
||
for (const id of ['emojiBtn', 'photoBtn', 'send']) $(id).addEventListener('mousedown', e => e.preventDefault());
|
||
$('emojiBtn').addEventListener('click', () => {
|
||
const open = !emojiPanel.classList.contains('open');
|
||
setEmoji(open);
|
||
if (!open || !touch) input.focus();
|
||
});
|
||
input.addEventListener('focus', () => { if (touch && emojiPanel.classList.contains('open')) setEmoji(false); });
|
||
|
||
/* ================================================================ composer */
|
||
function updateSend() { sendBtn.disabled = !input.value.trim(); }
|
||
input.addEventListener('input', () => { updateSend(); onTyping(); updateMentions(); });
|
||
$('bar').addEventListener('submit', e => { e.preventDefault(); sendText(); });
|
||
|
||
/* ================================================================ mention picker */
|
||
let pick = null; // {start, end, ids, sel}
|
||
function updateMentions() {
|
||
const pos = input.selectionStart ?? input.value.length;
|
||
const m = /(?:^|\s)@([^@]{0,24})$/.exec(input.value.slice(0, pos));
|
||
if (!m) return hideMentions();
|
||
const q = m[1].toLowerCase();
|
||
const ids = [...users.keys()].filter(id => {
|
||
const n = nickOf(id).toLowerCase();
|
||
return id !== me && n !== '?' && (n.startsWith(q) || n.split(/\s+/).some(w => w.startsWith(q)));
|
||
}).sort((a, b) => (isOnline(b) - isOnline(a)) || (activity(b) - activity(a))).slice(0, 6);
|
||
if (!ids.length) return hideMentions();
|
||
pick = { start: pos - m[1].length - 1, end: pos, ids, sel: 0 };
|
||
drawMentions();
|
||
}
|
||
function drawMentions() {
|
||
const box = $('mentions');
|
||
box.textContent = '';
|
||
pick.ids.forEach((id, i) => {
|
||
const b = el('button', i === pick.sel ? 'on' : '');
|
||
b.type = 'button'; b.dataset.id = id;
|
||
b.append(avatar(id), el('span', null, nickOf(id)));
|
||
box.appendChild(b);
|
||
});
|
||
box.hidden = false;
|
||
}
|
||
function hideMentions() { pick = null; $('mentions').hidden = true; }
|
||
function choose(id) {
|
||
if (!pick) return;
|
||
input.setRangeText('@' + nickOf(id) + ' ', pick.start, pick.end, 'end');
|
||
hideMentions(); updateSend(); onTyping(); input.focus();
|
||
}
|
||
$('mentions').addEventListener('mousedown', e => e.preventDefault());
|
||
$('mentions').addEventListener('click', e => { const b = e.target.closest('button'); if (b) choose(b.dataset.id); });
|
||
input.addEventListener('keydown', e => {
|
||
if (!pick) return;
|
||
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
||
pick.sel = (pick.sel + (e.key === 'ArrowDown' ? 1 : pick.ids.length - 1)) % pick.ids.length;
|
||
drawMentions(); e.preventDefault();
|
||
} else if (e.key === 'Enter' || e.key === 'Tab') { choose(pick.ids[pick.sel]); e.preventDefault(); }
|
||
else if (e.key === 'Escape') { hideMentions(); e.stopPropagation(); }
|
||
});
|
||
input.addEventListener('blur', () => setTimeout(hideMentions, 150));
|
||
|
||
/* ================================================================ login */
|
||
const errMsg = e => /wrong password/.test(e.message) ? 'Wrong password'
|
||
: /expired|invalid link/.test(e.message) ? 'This link has expired or was already used'
|
||
: /fetch|network|load/i.test(e.message) ? 'Can’t reach the chat – are you on the chat WiFi?' : e.message;
|
||
const cleanName = s => clean(s).replace(/@/g, '').slice(0, 24);
|
||
let checkTimer = 0, nameTaken = null;
|
||
|
||
function showLogin(msg) {
|
||
$('modal').hidden = false;
|
||
$('lErr').textContent = msg || '';
|
||
setTimeout(() => ($('nameIn').value ? $('pwIn') : $('nameIn')).focus(), 60);
|
||
}
|
||
function setTaken(t) {
|
||
nameTaken = t;
|
||
$('lHint').textContent = t === true ? 'Welcome back! Enter the password for this name.'
|
||
: t === false ? 'New name: choose a password (at least 4 characters) to keep it yours.'
|
||
: 'Pick a name and a password. Use the same name and password to join from your other devices.';
|
||
$('lBtn').textContent = t === true ? 'Log in' : t === false ? 'Create account' : 'Join the chat';
|
||
$('pwIn').autocomplete = t === false ? 'new-password' : 'current-password';
|
||
}
|
||
$('nameIn').addEventListener('input', () => {
|
||
clearTimeout(checkTimer);
|
||
$('lErr').textContent = '';
|
||
const n = cleanName($('nameIn').value);
|
||
if (!n) return setTaken(null);
|
||
checkTimer = setTimeout(() => fetch('cgi-bin/chat?a=check&n=' + toHex(n), { cache: 'no-store' })
|
||
.then(r => r.ok ? r.text() : '')
|
||
.then(t => { t = t.trim(); if (cleanName($('nameIn').value) === n) setTaken(t === '1' ? true : t === '0' ? false : null); })
|
||
.catch(() => {}), 300);
|
||
});
|
||
$('loginForm').addEventListener('submit', async e => {
|
||
e.preventDefault();
|
||
const n = cleanName($('nameIn').value), pw = $('pwIn').value;
|
||
if (!n) return $('nameIn').focus();
|
||
if (!pw) return $('pwIn').focus();
|
||
if (nameTaken === false && pw.length < 4) { $('lErr').textContent = 'Please use at least 4 characters'; return; }
|
||
$('lBtn').disabled = true;
|
||
try {
|
||
const ok = /^[0-9a-f]{32}$/.test(oldKey || '') ? '&ok=' + oldKey : '';
|
||
const [k, uid] = (await api('login', pw, '&n=' + toHex(n) + ok)).split('\t');
|
||
if (!/^[0-9a-f]{32}$/.test(k)) throw new Error('Unexpected answer from the chat');
|
||
signedIn(k, uid);
|
||
} catch (err) {
|
||
$('lErr').textContent = /wrong password/.test(err.message) ? 'Wrong password for this name' : errMsg(err);
|
||
}
|
||
$('lBtn').disabled = false;
|
||
});
|
||
|
||
function signedIn(k, uid) {
|
||
tok = k; me = uid;
|
||
store.set('cc.tok', k); store.set('cc.me', uid);
|
||
try { localStorage.removeItem('cc.key'); localStorage.removeItem('cc.nick'); } catch (e) {}
|
||
$('modal').hidden = true;
|
||
$('pwIn').value = '';
|
||
if (document.activeElement) document.activeElement.blur();
|
||
loop();
|
||
setTimeout(offerNotify, 2500);
|
||
}
|
||
function signedOut() { // forget this device's session and start over
|
||
tok = '';
|
||
for (const k of ['cc.tok', 'cc.me', 'cc.read', 'cc.conv']) try { localStorage.removeItem(k); } catch (e) {}
|
||
location.replace(location.pathname);
|
||
}
|
||
function offerNotify() { // permission prompts need a tap, so offer one once per device
|
||
if (!canNotify() || Notification.permission !== 'default' || store.get('cc.asked')) return;
|
||
store.set('cc.asked', '1');
|
||
toast('🔔 Tap here to get notifications for new messages', askNotify);
|
||
}
|
||
|
||
// a "link another device" URL: chat/#link=CODE logs this browser in
|
||
async function redeemLink() {
|
||
const m = /^#link=([0-9a-f]{32})$/.exec(location.hash);
|
||
if (!m) return false;
|
||
history.replaceState(null, '', location.pathname + location.search);
|
||
try {
|
||
const [k, uid] = (await api('redeem', undefined, '&c=' + m[1])).split('\t');
|
||
if (!/^[0-9a-f]{32}$/.test(k)) throw new Error('Unexpected answer from the chat');
|
||
if (uid !== me) for (const x of ['cc.read', 'cc.conv']) try { localStorage.removeItem(x); } catch (e) {}
|
||
store.set('cc.tok', k); store.set('cc.me', uid);
|
||
location.replace(location.pathname);
|
||
return true;
|
||
} catch (e) { toast(errMsg(e)); return false; }
|
||
}
|
||
|
||
/* ================================================================ profile */
|
||
const SVG = p => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' + p + '</svg>';
|
||
const ICONS = {
|
||
photo: '<rect x="3" y="5" width="18" height="14" rx="3.5"/><circle cx="12" cy="12" r="3.2"/>',
|
||
nophoto: '<rect x="3" y="5" width="18" height="14" rx="3.5"/><path d="M9 9l6 6M15 9l-6 6"/>',
|
||
link: '<rect x="7" y="2.5" width="10" height="19" rx="2.5"/><path d="M11 18.5h2"/>',
|
||
bell: '<path d="M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z"/><path d="M10 20.5a2.2 2.2 0 0 0 4 0"/>',
|
||
install: '<path d="M12 4v11M7.5 10.5L12 15l4.5-4.5"/><path d="M5 19.5h14"/>',
|
||
key: '<circle cx="8" cy="15" r="4"/><path d="M11 12l8-8M16 7l2.5 2.5"/>',
|
||
out: '<path d="M14 4h4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-4"/><path d="M10 16l-4-4 4-4M6 12h10"/>',
|
||
trash: '<path d="M4 7h16M9 7V4.5h6V7M6.5 7l1 13h9l1-13"/>'
|
||
};
|
||
const CLOSE = SVG('<path d="M6 6l12 12M18 6L6 18"/>');
|
||
let linkTimer = 0;
|
||
|
||
function sheet(build) {
|
||
clearInterval(linkTimer);
|
||
const s = $('sheet');
|
||
s.textContent = '';
|
||
const x = el('button', 'icon xbtn'); x.type = 'button'; x.innerHTML = CLOSE; x.setAttribute('aria-label', 'Close');
|
||
x.addEventListener('click', closeSheet);
|
||
s.appendChild(x);
|
||
build(s);
|
||
$('sheetBack').hidden = false;
|
||
}
|
||
function closeSheet() { clearInterval(linkTimer); $('sheetBack').hidden = true; $('sheet').textContent = ''; }
|
||
$('sheetBack').addEventListener('click', e => { if (e.target === $('sheetBack')) closeSheet(); });
|
||
|
||
function item(icon, label, fn, side, cls) {
|
||
const b = el('button', cls);
|
||
b.type = 'button';
|
||
b.innerHTML = SVG(ICONS[icon]);
|
||
b.appendChild(el('span', null, label));
|
||
if (side) b.appendChild(el('small', null, side));
|
||
b.addEventListener('click', fn);
|
||
return b;
|
||
}
|
||
function notifyLabel() {
|
||
if (!canNotify()) return 'not available';
|
||
if (Notification.permission === 'denied') return 'blocked';
|
||
if (Notification.permission !== 'granted') return 'off';
|
||
return { all: 'all messages', direct: 'private & @me', off: 'off' }[notifyPref()];
|
||
}
|
||
async function cycleNotify() {
|
||
if (!canNotify() || Notification.permission !== 'granted') {
|
||
if (await askNotify()) store.set('cc.notify', 'all');
|
||
} else store.set('cc.notify', { all: 'direct', direct: 'off', off: 'all' }[notifyPref()]);
|
||
profile();
|
||
}
|
||
|
||
function profile() {
|
||
sheet(s => {
|
||
const a = avatar(me);
|
||
a.classList.add('big'); a.title = 'Change profile picture';
|
||
a.addEventListener('click', () => $('avatarFile').click());
|
||
s.append(a, el('h2', null, nickOf(me)));
|
||
const list = el('div', 'items'), has = !!avatarUrl(me);
|
||
list.appendChild(item('photo', has ? 'Change profile picture' : 'Add a profile picture', () => $('avatarFile').click()));
|
||
if (has) list.appendChild(item('nophoto', 'Remove profile picture', setAvatar.bind(null, null)));
|
||
list.appendChild(item('link', 'Link another device', linkDevice));
|
||
list.appendChild(item('bell', 'Notifications', cycleNotify, notifyLabel()));
|
||
if (installPrompt || (ios && !standalone())) list.appendChild(item('install', 'Install as app', install));
|
||
list.appendChild(item('key', 'Change password', changePassword));
|
||
list.appendChild(item('out', 'Log out on this device', () => api('logout').catch(() => {}).then(signedOut)));
|
||
list.appendChild(item('trash', 'Delete account', deleteAccount, null, 'danger'));
|
||
s.appendChild(list);
|
||
});
|
||
}
|
||
$('me').addEventListener('click', profile);
|
||
|
||
async function install() {
|
||
if (installPrompt) {
|
||
installPrompt.prompt();
|
||
try { await installPrompt.userChoice; } catch (e) {}
|
||
installPrompt = null;
|
||
profile();
|
||
} else toast('Tap the Share button, then “Add to Home Screen”');
|
||
}
|
||
|
||
function pwField(ph, ac) {
|
||
const i = el('input'); i.type = 'password'; i.placeholder = ph; i.autocomplete = ac; i.maxLength = 100;
|
||
return i;
|
||
}
|
||
function formSheet(title, text, fields, btn, danger, run) {
|
||
sheet(s => {
|
||
s.appendChild(el('h2', null, title));
|
||
if (text) s.appendChild(el('p', null, text));
|
||
const f = el('form'), user = el('input'), err = el('div', 'err'), b = el('button', 'primary' + (danger ? ' danger' : ''), btn);
|
||
user.autocomplete = 'username'; user.value = nickOf(me); user.hidden = true; // for password managers
|
||
const back = el('button', 'ghost', 'Back'); back.type = 'button'; back.addEventListener('click', profile);
|
||
f.append(user, ...fields, err, b, back);
|
||
f.addEventListener('submit', async e => {
|
||
e.preventDefault();
|
||
err.textContent = ''; b.disabled = true;
|
||
try { await run(err); } catch (x) { err.textContent = errMsg(x); }
|
||
b.disabled = false;
|
||
});
|
||
s.appendChild(f);
|
||
setTimeout(() => fields[0].focus(), 60);
|
||
});
|
||
}
|
||
function changePassword() {
|
||
const o = pwField('Current password', 'current-password'), n1 = pwField('New password', 'new-password'), n2 = pwField('Repeat the new password', 'new-password');
|
||
formSheet('Change password', 'Your other devices stay logged in.', [o, n1, n2], 'Save', false, async err => {
|
||
if (n1.value.length < 4) { err.textContent = 'Please use at least 4 characters'; return; }
|
||
if (n1.value !== n2.value) { err.textContent = 'The new passwords don’t match'; return; }
|
||
await api('passwd', o.value + '\n' + n1.value);
|
||
closeSheet(); toast('Password changed');
|
||
});
|
||
}
|
||
function deleteAccount() {
|
||
const p = pwField('Your password', 'current-password');
|
||
formSheet('Delete account', 'This deletes your account, your profile picture and every message and photo you posted, for everyone, and logs out all your devices. Your name becomes free again.',
|
||
[p], 'Delete my account', true, async () => { await api('delete', p.value); signedOut(); });
|
||
}
|
||
|
||
// profile picture: square crop, 256 px JPEG (~20 kB); null removes it
|
||
async function setAvatar(file) {
|
||
try {
|
||
let ver;
|
||
if (file) {
|
||
const img = await loadImage(file);
|
||
const S = 256, w = img.naturalWidth, h = img.naturalHeight, m = Math.min(w, h);
|
||
const c = document.createElement('canvas'), ctx = c.getContext('2d');
|
||
c.width = c.height = S;
|
||
ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, S, S);
|
||
ctx.drawImage(img, (w - m) / 2, (h - m) / 2, m, m, 0, 0, S, S);
|
||
const blob = await new Promise(r => c.toBlob(r, 'image/jpeg', 0.85));
|
||
if (!blob) throw new Error('Could not process the picture');
|
||
ver = await api('avatar', blob);
|
||
} else ver = await api('noavatar');
|
||
const u = users.get(me);
|
||
if (u) u.ava = ver;
|
||
listSig = ''; refreshUI(); renderConv();
|
||
if (!$('sheetBack').hidden) profile();
|
||
toast(file ? 'Profile picture updated' : 'Profile picture removed');
|
||
} catch (e) { toast(errMsg(e)); }
|
||
}
|
||
$('avatarFile').addEventListener('change', () => {
|
||
const f = $('avatarFile').files[0];
|
||
$('avatarFile').value = '';
|
||
if (f) setAvatar(f);
|
||
});
|
||
|
||
async function linkDevice() {
|
||
let t;
|
||
try { t = await api('link'); } catch (e) { toast(errMsg(e)); return; }
|
||
const [code, ttl] = t.split('\t');
|
||
const url = location.origin + location.pathname + '#link=' + code, until = Date.now() + (+ttl || 600) * 1000;
|
||
sheet(s => {
|
||
s.append(el('h2', null, 'Link another device'),
|
||
el('p', null, 'Scan this code with the other device’s camera or open the link there – it will be logged in as ' + nickOf(me) + '.'));
|
||
const q = qrSvg(url);
|
||
if (q) { const d = el('div'); d.innerHTML = q; d.firstChild.setAttribute('class', 'qr'); s.appendChild(d.firstChild); }
|
||
const copy = el('button', 'ghost', 'Copy link'); copy.type = 'button'; copy.addEventListener('click', () => copyText(url));
|
||
const back = el('button', 'ghost', 'Back'); back.type = 'button'; back.addEventListener('click', profile);
|
||
const note = el('div', 'note');
|
||
s.append(el('div', 'linkbox', url), copy, back, note);
|
||
const tick = () => {
|
||
const left = Math.max(0, Math.round((until - Date.now()) / 1000));
|
||
note.textContent = left ? 'Works once · valid for ' + Math.floor(left / 60) + ':' + String(left % 60).padStart(2, '0') : 'This link has expired.';
|
||
if (!left) clearInterval(linkTimer);
|
||
};
|
||
tick();
|
||
linkTimer = setInterval(tick, 1000);
|
||
});
|
||
}
|
||
|
||
/* ================================================================ QR code */
|
||
// byte mode, error correction level M, versions 1-10 (up to 213 bytes) -> SVG markup
|
||
function qrSvg(text) {
|
||
const RS = [0, [10, 1, 16], [16, 1, 28], [26, 1, 44], [18, 2, 32], [24, 2, 43], [16, 4, 27], [18, 4, 31],
|
||
[22, 2, 38, 2, 39], [22, 3, 36, 2, 37], [26, 4, 43, 1, 44]]; // ec per block, (blocks, data bytes)...
|
||
const AL = [0, [], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50]];
|
||
const data = enc.encode(text);
|
||
let v = 1, cap = 0;
|
||
for (; v <= 10; v++) {
|
||
const t = RS[v]; cap = t[1] * t[2] + (t[3] || 0) * (t[4] || 0);
|
||
if (4 + (v < 10 ? 8 : 16) + data.length * 8 <= cap * 8) break;
|
||
}
|
||
if (v > 10) return '';
|
||
const bits = [], put = (x, n) => { for (let i = n - 1; i >= 0; i--) bits.push(x >>> i & 1); };
|
||
put(4, 4); put(data.length, v < 10 ? 8 : 16);
|
||
for (const b of data) put(b, 8);
|
||
put(0, Math.min(4, cap * 8 - bits.length));
|
||
while (bits.length % 8) bits.push(0);
|
||
const bytes = [];
|
||
for (let i = 0; i < bits.length; i += 8) bytes.push(parseInt(bits.slice(i, i + 8).join(''), 2));
|
||
for (let p = 0xec; bytes.length < cap; p ^= 0xec ^ 0x11) bytes.push(p);
|
||
// Reed-Solomon over GF(256)
|
||
const EXP = [], LOG = [];
|
||
for (let i = 0, x = 1; i < 255; i++) { EXP[i] = EXP[i + 255] = x; LOG[x] = i; x <<= 1; if (x & 256) x ^= 0x11d; }
|
||
const mul = (a, b) => a && b ? EXP[LOG[a] + LOG[b]] : 0;
|
||
const t = RS[v], ecn = t[0];
|
||
let g = [1];
|
||
for (let i = 0; i < ecn; i++) {
|
||
const n = Array(g.length + 1).fill(0);
|
||
g.forEach((c, j) => { n[j] ^= c; n[j + 1] ^= mul(c, EXP[i]); });
|
||
g = n;
|
||
}
|
||
const blocks = [], ecs = [];
|
||
for (let k = 1, pos = 0; k < t.length; k += 2) for (let b = 0; b < t[k]; b++) {
|
||
const blk = bytes.slice(pos, pos += t[k + 1]), r = blk.concat(Array(ecn).fill(0));
|
||
for (let i = 0; i < blk.length; i++) { const c = r[i]; if (c) g.forEach((x, j) => { r[i + j] ^= mul(x, c); }); }
|
||
blocks.push(blk); ecs.push(r.slice(blk.length));
|
||
}
|
||
const cw = [];
|
||
for (let i = 0; i < t[t.length - 1]; i++) for (const b of blocks) if (i < b.length) cw.push(b[i]);
|
||
for (let i = 0; i < ecn; i++) for (const e of ecs) cw.push(e[i]);
|
||
// matrix: M[y][x] dark?, F[y][x] function module?
|
||
const N = v * 4 + 17, M = [], F = [];
|
||
for (let i = 0; i < N; i++) { M.push(Array(N).fill(0)); F.push(Array(N).fill(false)); }
|
||
const set = (x, y, d) => { M[y][x] = d ? 1 : 0; F[y][x] = true; };
|
||
for (const [fx, fy] of [[3, 3], [N - 4, 3], [3, N - 4]])
|
||
for (let dy = -4; dy <= 4; dy++) for (let dx = -4; dx <= 4; dx++) {
|
||
const x = fx + dx, y = fy + dy, d = Math.max(Math.abs(dx), Math.abs(dy));
|
||
if (x >= 0 && y >= 0 && x < N && y < N) set(x, y, d !== 2 && d !== 4);
|
||
}
|
||
for (let i = 8; i < N - 8; i++) { set(6, i, i % 2 === 0); set(i, 6, i % 2 === 0); }
|
||
const al = AL[v], last = al.length - 1;
|
||
al.forEach((ay, i) => al.forEach((ax, j) => {
|
||
if ((i === 0 && j === 0) || (i === 0 && j === last) || (i === last && j === 0)) return;
|
||
for (let dy = -2; dy <= 2; dy++) for (let dx = -2; dx <= 2; dx++) set(ax + dx, ay + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
|
||
}));
|
||
const format = mask => {
|
||
const d = mask; // level M = 00
|
||
let r = d; for (let i = 0; i < 10; i++) r = (r << 1) ^ ((r >>> 9) * 0x537);
|
||
const b = ((d << 10) | r) ^ 0x5412, bit = i => (b >>> i & 1) === 1;
|
||
for (let i = 0; i <= 5; i++) set(8, i, bit(i));
|
||
set(8, 7, bit(6)); set(8, 8, bit(7)); set(7, 8, bit(8));
|
||
for (let i = 9; i < 15; i++) set(14 - i, 8, bit(i));
|
||
for (let i = 0; i < 8; i++) set(N - 1 - i, 8, bit(i));
|
||
for (let i = 8; i < 15; i++) set(8, N - 15 + i, bit(i));
|
||
set(8, N - 8, true);
|
||
};
|
||
format(0);
|
||
if (v >= 7) {
|
||
let r = v; for (let i = 0; i < 12; i++) r = (r << 1) ^ ((r >>> 11) * 0x1f25);
|
||
const b = v << 12 | r;
|
||
for (let i = 0; i < 18; i++) { const d = b >>> i & 1, a = N - 11 + i % 3, c = Math.floor(i / 3); set(a, c, d); set(c, a, d); }
|
||
}
|
||
let k = 0;
|
||
for (let right = N - 1; right >= 1; right -= 2) {
|
||
if (right === 6) right = 5;
|
||
for (let vert = 0; vert < N; vert++) for (let j = 0; j < 2; j++) {
|
||
const x = right - j, y = ((right + 1) & 2) === 0 ? N - 1 - vert : vert;
|
||
if (!F[y][x] && k < cw.length * 8) { M[y][x] = cw[k >>> 3] >>> (7 - (k & 7)) & 1; k++; }
|
||
}
|
||
}
|
||
const MASKS = [(x, y) => (x + y) % 2, (x, y) => y % 2, (x, y) => x % 3, (x, y) => (x + y) % 3,
|
||
(x, y) => (Math.floor(x / 3) + Math.floor(y / 2)) % 2, (x, y) => x * y % 2 + x * y % 3,
|
||
(x, y) => (x * y % 2 + x * y % 3) % 2, (x, y) => ((x + y) % 2 + x * y % 3) % 2];
|
||
const flip = m => { for (let y = 0; y < N; y++) for (let x = 0; x < N; x++) if (!F[y][x] && !MASKS[m](x, y)) M[y][x] ^= 1; };
|
||
const penalty = () => { // the standard's 4 rules, slightly simplified
|
||
let p = 0, dark = 0;
|
||
const line = get => {
|
||
let run = 1, s = '';
|
||
for (let i = 0; i < N; i++) {
|
||
const c = get(i); s += c;
|
||
if (i && c === get(i - 1)) { run++; if (run === 5) p += 3; else if (run > 5) p++; } else run = 1;
|
||
}
|
||
for (const pat of ['10111010000', '00001011101']) for (let i = s.indexOf(pat); i >= 0; i = s.indexOf(pat, i + 1)) p += 40;
|
||
};
|
||
for (let i = 0; i < N; i++) { line(j => M[i][j]); line(j => M[j][i]); }
|
||
for (let y = 0; y < N; y++) for (let x = 0; x < N; x++) {
|
||
dark += M[y][x];
|
||
if (x < N - 1 && y < N - 1) { const c = M[y][x]; if (c === M[y][x + 1] && c === M[y + 1][x] && c === M[y + 1][x + 1]) p += 3; }
|
||
}
|
||
return p + 10 * Math.floor(Math.abs(dark * 20 - N * N * 10) / (N * N));
|
||
};
|
||
let best = 0, bestP = Infinity;
|
||
for (let m = 0; m < 8; m++) { flip(m); format(m); const p = penalty(); if (p < bestP) { bestP = p; best = m; } flip(m); }
|
||
flip(best); format(best);
|
||
let path = '';
|
||
for (let y = 0; y < N; y++) for (let x = 0; x < N; x++) if (M[y][x]) path += 'M' + (x + 4) + ' ' + (y + 4) + 'h1v1h-1z';
|
||
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ' + (N + 8) + ' ' + (N + 8) +
|
||
'" shape-rendering="crispEdges"><rect width="100%" height="100%" fill="#fff"/><path d="' + path + '" fill="#000"/></svg>';
|
||
}
|
||
|
||
fetch('VERSION', { cache: 'no-store' }).then(r => r.ok ? r.text() : '')
|
||
.then(v => { v = v.trim(); if (/^[\w.\-]{1,20}$/.test(v)) $('ver').textContent = 'Cabin Chat v' + v; }).catch(() => {});
|
||
|
||
/* ================================================================ start */
|
||
conv = store.get('cc.conv') || ALL;
|
||
const hc = /^#c=([0-9a-f]{16}|\*)$/.exec(location.hash); // opened from a notification
|
||
if (hc) { conv = hc[1]; history.replaceState(null, '', location.pathname + location.search); }
|
||
renderConv();
|
||
refreshUI();
|
||
setInterval(() => { expire(); refreshUI(); }, 1000); // typing / online state expire on their own
|
||
setInterval(updateAges, 15000);
|
||
redeemLink().then(done => { if (done) return; if (tok) loop(); else showLogin(); });
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|
||
__CABINCHAT_EOF__
|
||
cat > "$STAGE/logo.svg" <<'__CABINCHAT_EOF__'
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||
<defs>
|
||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#3d7bfd"/><stop offset="1" stop-color="#8b5cf6"/></linearGradient>
|
||
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#2f6be6"/><stop offset=".6" stop-color="#6fb3ff"/><stop offset="1" stop-color="#bfe3ff"/></linearGradient>
|
||
<clipPath id="win"><rect x="205" y="146" width="102" height="164" rx="51"/></clipPath>
|
||
</defs>
|
||
<rect width="512" height="512" rx="112" fill="url(#bg)"/>
|
||
<path d="M256 92c-99 0-180 68-180 152 0 46 24 87 63 115l-17 67 76-38c18 5 37 8 58 8 99 0 180-68 180-152S355 92 256 92z" fill="#fff"/>
|
||
<rect x="191" y="132" width="130" height="192" rx="65" fill="#dde6f8"/>
|
||
<rect x="205" y="146" width="102" height="164" rx="51" fill="url(#sky)"/>
|
||
<g clip-path="url(#win)" fill="#fff">
|
||
<circle cx="226" cy="282" r="22"/><circle cx="256" cy="270" r="28"/><circle cx="290" cy="284" r="22"/><rect x="200" y="284" width="112" height="40"/>
|
||
</g>
|
||
</svg>
|
||
__CABINCHAT_EOF__
|
||
cat > "$STAGE/manifest.json" <<'__CABINCHAT_EOF__'
|
||
{
|
||
"name": "Cabin Chat",
|
||
"short_name": "Cabin Chat",
|
||
"description": "Group chat on the travel router - no internet needed",
|
||
"id": "./",
|
||
"start_url": "./",
|
||
"scope": "./",
|
||
"display": "standalone",
|
||
"background_color": "#0e1014",
|
||
"theme_color": "#14171d",
|
||
"icons": [
|
||
{ "src": "icon-192.png", "sizes": "192x192", "type": "image/png" },
|
||
{ "src": "icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" },
|
||
{ "src": "logo.svg", "sizes": "any", "type": "image/svg+xml" }
|
||
]
|
||
}
|
||
__CABINCHAT_EOF__
|
||
cat > "$STAGE/sw.js" <<'__CABINCHAT_EOF__'
|
||
// Cabin Chat service worker: makes the chat installable as an app, opens the
|
||
// app from a notification and shows the last loaded page when the router is out
|
||
// of reach. Network first, so a new version on the router is used right away.
|
||
// Chat data (cgi-bin) and photos are never cached here.
|
||
const CACHE = 'cabinchat';
|
||
|
||
self.addEventListener('install', () => self.skipWaiting());
|
||
self.addEventListener('activate', e => e.waitUntil(self.clients.claim()));
|
||
|
||
self.addEventListener('fetch', e => {
|
||
const req = e.request, url = new URL(req.url);
|
||
if (req.method !== 'GET' || url.origin !== location.origin || /\/(cgi-bin|img)\//.test(url.pathname)) return;
|
||
e.respondWith(fetch(req).then(res => {
|
||
if (res.ok) { const copy = res.clone(); caches.open(CACHE).then(c => c.put(req, copy)); }
|
||
return res;
|
||
}).catch(() => caches.match(req, { ignoreSearch: true })
|
||
.then(r => r || (req.mode === 'navigate' ? caches.match('./') : Response.error()))));
|
||
});
|
||
|
||
self.addEventListener('notificationclick', e => {
|
||
e.notification.close();
|
||
const conv = (e.notification.data || {}).conv || '';
|
||
e.waitUntil(self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(list => {
|
||
for (const c of list) {
|
||
c.postMessage({ cc: 'open', conv });
|
||
return c.focus();
|
||
}
|
||
return self.clients.openWindow('./' + (conv ? '#c=' + conv : ''));
|
||
}));
|
||
});
|
||
__CABINCHAT_EOF__
|
||
cat > "$STAGE/VERSION" <<'__CABINCHAT_EOF__'
|
||
4.0.0
|
||
__CABINCHAT_EOF__
|
||
[ -f "$STAGE/index.html" ] && [ -f "$STAGE/cgi-bin/chat" ] && [ -f "$STAGE/VERSION" ] \
|
||
|| die "installer payload is incomplete"
|
||
}
|
||
|
||
# version 2 lines (6 fields) -> version 3 (8 fields: + recipient "*" and no quote)
|
||
migrate_messages() {
|
||
[ -s "$DATA/messages" ] || return 0
|
||
awk -F '\t' 'BEGIN { OFS = "\t" }
|
||
NF == 6 { print $1, $2, $3, $4, "*", 0, $5, $6; next }
|
||
NF == 8 { print }' "$DATA/messages" > "$DATA/messages.new" &&
|
||
mv "$DATA/messages.new" "$DATA/messages"
|
||
}
|
||
|
||
# ------------------------------------------------------------------ install
|
||
do_install() {
|
||
[ -x /usr/sbin/uhttpd ] || die "uhttpd is not installed.
|
||
With internet access run: opkg update && opkg install uhttpd
|
||
then run this installer again."
|
||
|
||
LANIP=$(uci -q get network.lan.ipaddr | cut -d/ -f1)
|
||
[ -n "$LANIP" ] || die "could not read the LAN IP (network.lan.ipaddr)"
|
||
|
||
OLDVER=
|
||
if [ -f "$APP/VERSION" ]; then
|
||
OLDVER=$(cat "$APP/VERSION")
|
||
elif [ -e "$APP/index.html" ] || uci -q get uhttpd.chat >/dev/null; then
|
||
OLDVER="1.x"
|
||
fi
|
||
OLDPORT=$(configured_port)
|
||
[ -n "$PORT" ] || PORT=${OLDPORT:-$DEFAULT_PORT}
|
||
case $PORT in ''|*[!0-9]*) die "invalid port: $PORT" ;; esac
|
||
if [ "$PORT" != "$OLDPORT" ] && listening "$PORT"; then
|
||
die "port $PORT is already in use - choose another one with -p <port>"
|
||
fi
|
||
|
||
# https unless asked otherwise; once --http was given, upgrades stay on http
|
||
OLDCERT=$(uci -q get uhttpd.chat.cert)
|
||
TLS_ARG=$TLS
|
||
if [ -z "$TLS" ]; then
|
||
TLS=1
|
||
[ -f "$DATA/http-only" ] && TLS=0 && info "staying on plain http as chosen before (use --https to switch)"
|
||
fi
|
||
CERT=; KEY=
|
||
if [ "$TLS" = 1 ]; then
|
||
if [ -n "$CERT_ARG" ]; then
|
||
[ -s "$CERT_ARG" ] && [ -s "$KEY_ARG" ] || die "--cert and --key need two existing files (PEM)"
|
||
elif [ "$OLDCERT" = "$DATA/tls/cert.pem" ] && [ -s "$OLDCERT" ] && [ -s "$DATA/tls/key.pem" ]; then
|
||
CERT=$OLDCERT; KEY=$DATA/tls/key.pem # keep the certificate given last time
|
||
elif ! admin_cert; then
|
||
warn "no certificate of the router's web admin found - using plain http"
|
||
TLS=0
|
||
fi
|
||
if [ "$TLS" = 1 ] && ! have_tls; then
|
||
warn "uhttpd has no TLS support (libustream-ssl missing) - using plain http"
|
||
warn " to get https: opkg update && opkg install libustream-openssl, then run this installer again"
|
||
TLS=0
|
||
fi
|
||
fi
|
||
[ "$TLS" = 1 ] && SCHEME=https || SCHEME=http
|
||
|
||
if [ -n "$OLDVER" ]; then
|
||
info "upgrading Cabin Chat $OLDVER -> $VERSION"
|
||
else
|
||
info "installing Cabin Chat $VERSION"
|
||
fi
|
||
|
||
# unpack first: if anything is wrong with this file, nothing has been touched yet
|
||
extract_payload
|
||
|
||
if [ -n "$OLDVER" ]; then
|
||
info "removing the previous version (messages and photos are kept)"
|
||
fi
|
||
remove_config
|
||
mkdir -p "$APP" || die "cannot create $APP"
|
||
mkdir -p "$DATA"
|
||
# keep the photos aside (version 2 kept them in data/img, version 3 in htdocs/img)
|
||
KEEPIMG=$APP/.img-keep
|
||
mkdir -p "$KEEPIMG"
|
||
for d in "$WEB/img" "$DATA/img"; do
|
||
[ -d "$d" ] && mv "$d"/* "$KEEPIMG"/ 2>/dev/null
|
||
rm -rf "$d"
|
||
done
|
||
for f in "$APP"/* "$APP"/.[!.]*; do
|
||
[ -e "$f" ] || continue
|
||
case $f in "$DATA"|"$KEEPIMG") continue ;; esac
|
||
rm -rf "$f"
|
||
done
|
||
rm -rf /tmp/chat.log /tmp/chat.lock /tmp/cabinchat.lock # leftovers from versions 1 and 2
|
||
migrate_messages
|
||
|
||
info "installing files to $WEB"
|
||
mkdir -p "$WEB"
|
||
cp -R "$STAGE"/* "$WEB"/ || die "copying files failed"
|
||
rm -rf "$STAGE"
|
||
chmod 755 "$WEB"/cgi-bin/*
|
||
mkdir -p "$WEB/img"
|
||
mv "$KEEPIMG"/* "$WEB/img"/ 2>/dev/null
|
||
rm -rf "$KEEPIMG"
|
||
[ -f "$CLOCK" ] || date +%s > "$CLOCK"
|
||
|
||
if [ "$TLS_ARG" = 0 ]; then touch "$DATA/http-only"; elif [ "$TLS" = 1 ]; then rm -f "$DATA/http-only"; fi
|
||
if [ "$TLS" = 1 ] && [ -n "$CERT_ARG" ]; then
|
||
mkdir -p "$DATA/tls"
|
||
cp "$CERT_ARG" "$DATA/tls/cert.pem" && cp "$KEY_ARG" "$DATA/tls/key.pem" || die "cannot copy the certificate"
|
||
chmod 600 "$DATA/tls/key.pem"
|
||
CERT=$DATA/tls/cert.pem; KEY=$DATA/tls/key.pem
|
||
fi
|
||
|
||
info "configuring web server on $SCHEME://$LANIP:$PORT"
|
||
uci set uhttpd.chat=uhttpd
|
||
if [ "$TLS" = 1 ]; then
|
||
info "certificate: $CERT"
|
||
uci add_list uhttpd.chat.listen_https="$LANIP:$PORT"
|
||
uci set uhttpd.chat.cert="$CERT"
|
||
uci set uhttpd.chat.key="$KEY"
|
||
else
|
||
uci add_list uhttpd.chat.listen_http="$LANIP:$PORT"
|
||
fi
|
||
uci set uhttpd.chat.home="$WEB"
|
||
uci set uhttpd.chat.cgi_prefix='/cgi-bin'
|
||
uci set uhttpd.chat.index_page='index.html'
|
||
uci set uhttpd.chat.no_dirlists='1'
|
||
# long polling keeps one request per open chat waiting for up to 25 s
|
||
uci set uhttpd.chat.script_timeout='60'
|
||
uci set uhttpd.chat.network_timeout='60'
|
||
uci set uhttpd.chat.max_requests='100'
|
||
uci set uhttpd.chat.max_connections='100'
|
||
uci commit uhttpd
|
||
/etc/init.d/uhttpd enable
|
||
/etc/init.d/uhttpd restart
|
||
|
||
info "adding DNS name $DNSNAME"
|
||
uci add_list dhcp.@dnsmasq[0].address="/$DNSNAME/$LANIP"
|
||
uci commit dhcp
|
||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||
|
||
touch /etc/sysupgrade.conf
|
||
grep -qx "$APP/" /etc/sysupgrade.conf || echo "$APP/" >> /etc/sysupgrade.conf
|
||
|
||
sleep 1
|
||
listening "$PORT" || die "uhttpd is not listening on port $PORT - check: logread | grep uhttpd"
|
||
if command -v wget >/dev/null; then
|
||
case $(wget -q --no-check-certificate -O - "$SCHEME://$LANIP:$PORT/cgi-bin/chat?a=ping" 2>/dev/null | head -n 1) in
|
||
@cabinchat*) info "self-test passed" ;;
|
||
*) warn "the chat backend did not answer as expected - check: logread | grep uhttpd"
|
||
[ "$TLS" = 1 ] && warn "if https is the problem, run the installer again with --http" ;;
|
||
esac
|
||
fi
|
||
|
||
n=$(grep -c . "$DATA/messages" 2>/dev/null); n=${n:-0}
|
||
a=$(ls "$DATA/accounts" 2>/dev/null | grep -c .); a=${a:-0}
|
||
echo
|
||
info "Cabin Chat $VERSION is running ($a accounts, $n messages from the last 24 h kept)"
|
||
echo " $SCHEME://$LANIP:$PORT"
|
||
echo " $SCHEME://$DNSNAME:$PORT"
|
||
if [ "$TLS" = 1 ] && ! ca_signed "$CERT"; then
|
||
echo " (the certificate looks self-signed: browsers warn once, accept it to continue)"
|
||
elif [ "$TLS" = 1 ]; then
|
||
echo " or https://<the name in the certificate>:$PORT once that name points to $LANIP"
|
||
fi
|
||
}
|
||
|
||
# ------------------------------------------------------------------ uninstall
|
||
do_uninstall() {
|
||
info "removing Cabin Chat"
|
||
remove_config
|
||
rm -rf "$APP" "$CLOCK" "$RUN" /tmp/chat.log /tmp/chat.lock /tmp/cabinchat.lock
|
||
/etc/init.d/uhttpd restart >/dev/null 2>&1
|
||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||
info "done"
|
||
}
|
||
|
||
do_wipe() {
|
||
[ -d "$APP" ] || die "Cabin Chat is not installed"
|
||
rm -rf "$DATA/messages" "$DATA/seq" "$WEB/img"
|
||
mkdir -p "$WEB/img"
|
||
g=$(cat "$DATA/gen" 2>/dev/null); case $g in ''|*[!0-9]*) g=0 ;; esac
|
||
echo $((g + 1)) > "$DATA/gen"
|
||
# wake up waiting browsers so they notice the empty chat
|
||
[ -d "$RUN" ] && echo "wipe.$$" > "$RUN/ev"
|
||
info "all messages and photos deleted (accounts are kept)"
|
||
}
|
||
|
||
# ------------------------------------------------------------------ main
|
||
CMD=install
|
||
PORT=
|
||
TLS=
|
||
CERT_ARG=
|
||
KEY_ARG=
|
||
while [ $# -gt 0 ]; do
|
||
case $1 in
|
||
-p|--port) [ -n "$2" ] || die "-p needs a port number"; PORT=$2; shift 2 ;;
|
||
--http|--no-https) TLS=0; shift ;;
|
||
--https) TLS=1; shift ;;
|
||
--cert) [ -n "$2" ] || die "--cert needs a file"; CERT_ARG=$2; TLS=1; shift 2 ;;
|
||
--key) [ -n "$2" ] || die "--key needs a file"; KEY_ARG=$2; shift 2 ;;
|
||
[0-9]*) PORT=$1; shift ;;
|
||
install|upgrade) CMD=install; shift ;;
|
||
uninstall|remove) CMD=uninstall; shift ;;
|
||
wipe) CMD=wipe; shift ;;
|
||
-h|--help|help) usage; exit 0 ;;
|
||
*) usage; die "unknown argument: $1" ;;
|
||
esac
|
||
done
|
||
|
||
[ "$(id -u)" = "0" ] || die "please run as root"
|
||
command -v uci >/dev/null || die "uci not found - is this OpenWrt?"
|
||
|
||
case $CMD in
|
||
install) do_install ;;
|
||
uninstall) do_uninstall ;;
|
||
wipe) do_wipe ;;
|
||
esac
|