// LinkSpin Help (2026-10-16): the member's support tickets. List, new ticket (same categories as the desk), thread,
// reply; a dot marks a ticket Marty answered that the member has not opened, and the rail badge counts them.
// Server: /api/my/support* in server.js, which proxy to the one shared desk on InstantAdPay (helpdesk.js).
// #t=LS-1042 opens that ticket (the link in reply emails); #new opens the form. Times in US Central.
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc;
const CATS = ['Account & sign-in', 'Wallet & payouts', 'Buying packages', 'Ads & campaigns', 'Earning credits & games', 'Team & referrals', 'Other'];
const STATUS = { open: ['Open', 't'], waiting_on_member: ['Waiting on you', 'warn'], closed: ['Closed', 'dim'] };
const AUTHOR = { member: 'You', admin: 'Marty, LinkSpin support', system: 'LinkSpin' };
const when = ts => ts ? new Date(Number(ts)).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : '';
const linkify = s => esc(s).replace(/(https?:\/\/[^\s<]+[^\s<.,;:!?)\]])/g, '$1');
const st = s => { const x = STATUS[s] || [s, 'dim']; return '' + esc(x[0]) + ''; };
const host = () => $('helpBody');
CR.mount({ active: 'help', title: 'Help', sub: 'support tickets' });
async function list(openNew) {
host().innerHTML = '
loading your tickets
';
let r; try { r = await CR.get('/api/my/support'); } catch (e) { host().innerHTML = '
Could not load your tickets. ' + esc(e.message) + '
'; return; }
const ts = r.tickets || [];
CR.helpBadge(); // the list just refreshed the server's badge count (the rail's first paint may be up to a minute old)
CR.sub(ts.length + ' ticket' + (ts.length === 1 ? '' : 's') + (r.unread ? ' · ' + r.unread + ' new repl' + (r.unread === 1 ? 'y' : 'ies') : ''));
host().innerHTML = '
Help and support
Stuck on something? Send Marty a ticket. He reads every one and replies here, and you get an email when he does. Quick answers to common questions are in the chat bubble on More and in Training.