@xauyxau/hnch 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +16 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Terminal client for hnch (pointing poker for agile teams). Speaks the same Yjs-o
|
|
|
17
17
|
|
|
18
18
|
## Default relay
|
|
19
19
|
|
|
20
|
-
`
|
|
20
|
+
`https://hnch.dev`. Override with the `HNCH_RELAY_URL` env var or `hnch config --relay-url <url>`.
|
|
21
21
|
|
|
22
22
|
## License
|
|
23
23
|
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import As from'yargs';import {hideBin}from'yargs/helpers';import Wt,{useState,useEffect,useCallback,useMemo,useRef}from'react';import {render,useApp,useInput,Box,Text}from'ink';import*as De from'yjs';import {Awareness}from'y-protocols/awareness';import {mkdirSync,chmodSync,writeFileSync,unlinkSync,existsSync,readFileSync}from'fs';import {homedir}from'os';import {join}from'path';import {randomUUID}from'crypto';import {createInterface}from'readline';import {WebsocketProvider}from'y-websocket';import bi from'ws';import Qo from'clipboardy';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var Yr="https://hnch.dev";function nt(){let t=process.env.XDG_CONFIG_HOME||join(homedir(),".config");return join(t,"hnch")}function an(){return join(nt(),"config.json")}function jn(){let e=nt();existsSync(e)||mkdirSync(e,{recursive:true});}function Ne(){let e=an();if(!existsSync(e))return {};try{return JSON.parse(readFileSync(e,"utf-8"))}catch{return {}}}function G(e){jn();let n={...Ne(),...e};writeFileSync(an(),JSON.stringify(n,null,2)+`
|
|
3
|
-
|
|
4
|
-
`,"utf-8");}var vt="hnch_abstain";function fe(e){return e===vt}var Wr={"unknown-room":4001,"wrong-password":4002,"invalid-invite":4003,"expired-invite":4004,"invite-already-redeemed":4005,"room-full":4006,"malformed-credentials":4010},_n=new Map(Object.entries(Wr).map(([e,t])=>[t,e]));function Pe(e){return e.role??"voter"}function W(e){let{revealedAt:t,skippedAt:n}=e;return t===void 0&&n===void 0?null:t===void 0?"skipped":n===void 0||t<=n?"revealed":"skipped"}var Ct={id:"fibonacci",cards:["0","1","2","3","5","8","13","21"]},Fn={id:"t-shirt",cards:["XS","S","M","L","XL"]},Vn={id:"powers-of-2",cards:["1","2","4","8","16","32","64"]},Yn={id:"linear",cards:["1","2","3","4","5","6","7","8","9","10"]},Jn={id:"risk",cards:["Low","Medium","High","Critical"]},ae={[Ct.id]:Ct,[Fn.id]:Fn,[Vn.id]:Vn,[Yn.id]:Yn,[Jn.id]:Jn},Gn={fibonacci:"Fibonacci","t-shirt":"T-shirt","powers-of-2":"Powers of 2",linear:"Linear (1\u201310)",risk:"Risk"};function Wn(e){return e in Gn?Gn[e]:e.length===0?e:(e.startsWith("custom-")?e.slice(7):e).split("-").map(n=>n.length===0?n:n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}var Ie="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",It=Ie.length,dn=Math.floor(It/2);function rt(e){let t=Ie.indexOf(e);if(t===-1)throw new Error(`fractional-index: invalid character '${e}'`);return t}function qn(e,t){return e.length>=t?e:e+"0".repeat(t-e.length)}function qr(e){let t=e.length-1;for(;t>0&&e[t]==="0";)t--;return e.slice(0,t+1)}function Kr(e,t){let n=e.length,o=Array.from({length:n+1}).fill(0),r=0;for(let s=n-1;s>=0;s--){let l=e[s]+t[s]+r;o[s+1]=l%It,r=Math.floor(l/It);}o[0]=r;let i=Array.from({length:n+1}).fill(0),a=0;for(let s=0;s<=n;s++){let l=o[s]+a*It;i[s]=Math.floor(l/2),a=l%2;}return i.slice(1)}function cn(e,t){let n=Ie[dn];if(e===null&&t===null)return n+n;if(t===null)return e+n+n+n+n;if(e===null)return zr(t);if(e>=t)throw new Error(`keyBetween: a must be < b (a='${e}', b='${t}')`);return Xr(e,t)}function zr(e){for(let t=e.length-1;t>=0;t--){let n=rt(e[t]);if(n>0)return e.slice(0,t)+Ie[n-1]+Ie[dn]}if(e.length>1)return e.slice(0,-1);throw new Error(`keyBetween: cannot generate key before '${e}' \u2014 use keyBetween(null, null) for the initial key`)}function Xr(e,t){let n=Math.max(e.length,t.length),o=qn(e,n).split("").map(l=>rt(l)),r=qn(t,n).split("").map(l=>rt(l)),a=Kr(o,r).map(l=>Ie[l]).join(""),s=qr(a);return s>e&&s<t?s:a>e&&a<t?a:Qr(e,t)}function Qr(e,t){for(let n=0;n<t.length;n++){let o=n<e.length?rt(e[n]):0;if(rt(t[n])===o+1)return (n<e.length?e.slice(0,n+1):e+Ie[0])+Ie[dn]}throw new Error(`keyBetween: space exhausted between '${e}' and '${t}'`)}var Zr="meta",it="settings",ei="participants",ti="rounds",ni="agenda",oi=["roomUuid","createdAt","createdBy","sessionEndedAt"],ri=["name","defaultScale","hostParticipantId"],ii=["displayName","joinedAt","role","leftAt","removedBy"],si=["id","title","description","ticketId","state","source","externalId","sortKey","createdAt","consumedAt","consumedByRoundId"],ai=["id","title","description","ticketId","parentRoundId","scale","timerStartedAt","revealedAt","skippedAt","createdBy","createdAt","agendaItemId"];function bt(e){return e.getMap(Zr)}function Tt(e){return e.getMap(it)}function Rt(e){return e.getMap(ei)}function ln(e){return e.getArray(ti)}function At(e){return e.getArray(ni)}function st(e,t){let n={};for(let o of t){let r=e.get(o);r!==void 0&&(n[o]=r);}return n}function di(e){return st(bt(e),oi)}function ci(e){return st(Tt(e),ri)}function li(e){let t=Rt(e),n=[];return t.forEach((o,r)=>{let i=st(o,ii);n.push({id:r,...i});}),n.sort((o,r)=>o.joinedAt-r.joinedAt||o.id.localeCompare(r.id)),n}function ui(e){let t={};return e.forEach((n,o)=>{t[o]=n;}),t}function pi(e){let t=st(e,ai),n=e.get("votes"),o=n?ui(n):{};return {...t,votes:o}}function mi(e){let t=ln(e),n=[];return t.forEach(o=>{n.push(pi(o));}),n}function fi(e){return st(e,si)}function gi(e){let t=At(e),n=[];return t.forEach(o=>{n.push(fi(o));}),n.sort((o,r)=>o.sortKey.localeCompare(r.sortKey)),n}function q(e){return {meta:di(e),settings:ci(e),participants:li(e),rounds:mi(e),agenda:gi(e)}}function Kn(e,t){if(bt(e).has("roomUuid"))throw new Error("initDoc: doc already seeded");e.transact(()=>{let n=bt(e);n.set("roomUuid",t.roomUuid),n.set("createdAt",t.createdAt),n.set("createdBy",t.participantId);let o=Tt(e);t.sessionName!==void 0&&o.set("name",t.sessionName),o.set("defaultScale",t.defaultScale),o.set("hostParticipantId",t.participantId);let r=new De.Map;r.set("displayName",t.displayName),r.set("joinedAt",t.createdAt),Rt(e).set(t.participantId,r);});}function Ye(e,t){e.transact(()=>{let n=Rt(e),o=n.get(t.participantId),r=o??new De.Map;r.set("displayName",t.displayName),o===void 0&&r.set("joinedAt",Date.now()),r.delete("leftAt"),r.delete("removedBy"),o===void 0&&n.set(t.participantId,r);});}function Je(e,t){e.transact(()=>{let n=Tt(e);for(let[o,r]of Object.entries(t))r===void 0?n.delete(o):n.set(o,r);});}function un(e,t,n){e.transact(()=>{let o=Rt(e),r=o.get(t),i=r??new De.Map;i.set("displayName",n.displayName),i.set("joinedAt",n.joinedAt),n.role!==void 0&&i.set("role",n.role),r===void 0&&o.set(t,i);});}function pn(e,t){let n=t.scale??Tt(e).get("defaultScale");if(!n)throw new Error("appendRound: no scale (settings.defaultScale missing)");return e.transact(()=>{let o=new De.Map;o.set("id",t.id),o.set("createdAt",t.createdAt),o.set("createdBy",t.createdBy),o.set("scale",n),t.title!==void 0&&o.set("title",t.title),t.description!==void 0&&o.set("description",t.description),t.ticketId!==void 0&&o.set("ticketId",t.ticketId),t.parentRoundId!==void 0&&o.set("parentRoundId",t.parentRoundId),t.agendaItemId!==void 0&&o.set("agendaItemId",t.agendaItemId),o.set("timerStartedAt",t.createdAt),o.set("votes",new De.Map),ln(e).push([o]);}),t.id}function zn(e,t,n){let o=at(e,t);if(!o)throw new Error(`patchRoundDescriptor: round ${t} not found`);e.transact(()=>{n.title!==void 0&&o.set("title",n.title),n.description!==void 0&&o.set("description",n.description);});}function at(e,t){let n=ln(e);for(let o=0;o<n.length;o+=1){let r=n.get(o);if(r.get("id")===t)return r}}function Xn(e,t,n,o){let r=at(e,t);if(!r)throw new Error(`castVote: round ${t} not found`);r.get("revealedAt")===void 0&&e.transact(()=>{r.get("votes").set(n,o);});}function Qn(e,t,n){let o=at(e,t);if(!o)throw new Error(`clearVote: round ${t} not found`);o.get("revealedAt")===void 0&&e.transact(()=>{o.get("votes").delete(n);});}function mn(e,t,n){let o=at(e,t);if(!o)throw new Error(`revealRound: round ${t} not found`);if(o.get("skippedAt")!==void 0)throw new Error(`revealRound: round ${t} already skipped`);e.transact(()=>{o.set("revealedAt",n);});}function Zn(e,t,n){let o=at(e,t);if(!o)throw new Error(`skipRound: round ${t} not found`);if(o.get("revealedAt")!==void 0)throw new Error(`skipRound: round ${t} already revealed`);if(o.get("skippedAt")!==void 0)throw new Error(`skipRound: round ${t} already skipped`);e.transact(()=>{o.set("skippedAt",n);});}function eo(e){e.transact(()=>{bt(e).set("sessionEndedAt",Date.now());});}function te(e){let{rounds:t}=e;if(t.length===0)return null;for(let n=t.length-1;n>=0;n-=1){let o=t[n];if(o.revealedAt===void 0)return o}return t.at(-1)}function to(e){let t=Object.values(e.votes);return t.length<2?false:t.every(n=>n===t[0])}function no(e,t){let n=At(e);for(let o=0;o<n.length;o++){let r=n.get(o);if(r.get("id")===t)return r}}function Et(e,t){if(!t.title?.trim()&&!t.ticketId?.trim())throw new Error("appendAgendaItem: at least one of {title, ticketId} is required");let n=crypto.randomUUID(),o=At(e),r=null;o.forEach(a=>{if(a.get("state")==="pending"){let s=a.get("sortKey");s!==void 0&&(r===null||s>r)&&(r=s);}});let i=cn(r,null);return e.transact(()=>{let a=new De.Map;a.set("id",n),a.set("state","pending"),a.set("source",t.source??"manual"),a.set("sortKey",i),a.set("createdAt",t.createdAt),t.title!==void 0&&a.set("title",t.title),t.description!==void 0&&a.set("description",t.description),t.ticketId!==void 0&&a.set("ticketId",t.ticketId),t.externalId!==void 0&&a.set("externalId",t.externalId),At(e).push([a]);}),n}function kt(e,t,n,o={}){let r=no(e,t);if(!r)throw new Error(`setAgendaItemState: item ${t} not found`);let i=r.get("state");if(!(i===n&&n==="consumed")){if(i!=="pending")throw new Error(`setAgendaItemState: invalid transition '${i}' \u2192 '${n}' for item ${t}`);e.transact(()=>{r.set("state",n),n==="consumed"&&(r.set("consumedAt",o.timestamp??Date.now()),o.consumedByRoundId!==void 0&&r.set("consumedByRoundId",o.consumedByRoundId));});}}function oo(e,t,n,o){kt(e,t,"consumed",{consumedByRoundId:n,timestamp:o});}function ro(e,t,n,o){let r=no(e,t);if(!r)throw new Error(`reorderAgendaItem: item ${t} not found`);let i=r.get("state");if(i!=="pending")throw new Error(`reorderAgendaItem: item ${t} is ${i}; only pending items may be reordered`);let a=cn(n??null,o??null);e.transact(()=>{r.set("sortKey",a);});}function Ge(e){for(let t of e.agenda)if(t.state==="pending")return t;return null}function io(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),o=t%60;return `${n}:${o.toString().padStart(2,"0")}`}function so(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return false}}function ao(e,t){let n=new Map;for(let d of t)n.set(d.id,d);let o=n.get(e);if(o===void 0||o.parentRoundId===void 0)return null;let r=new Set([o.id]),i=o,a=1;for(;i.parentRoundId!==void 0;){let d=n.get(i.parentRoundId);if(d===void 0||r.has(d.id))return null;r.add(d.id),i=d,a+=1;}let s=i,l=new Map;for(let d of t){if(d.parentRoundId===void 0)continue;let p=l.get(d.parentRoundId);p===void 0?l.set(d.parentRoundId,[d]):p.push(d);}let u=0,c=[s];for(;c.length>0;){let d=c.shift();u+=1;let p=l.get(d.id);p!==void 0&&c.push(...p);}return {chainRoot:s,depth:a,total:u}}var co="PBKDF2",hi="SHA-256",lo=new TextEncoder;function Si(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Oe(e,t){let n=await crypto.subtle.importKey("raw",lo.encode(e),co,false,["deriveBits"]),o=await crypto.subtle.deriveBits({name:co,salt:lo.encode(t),iterations:1e5,hash:hi},n,256);return Si(o)}var uo="ABCDEFGHJKMNPQRSTUVWXYZ23456789";if(uo.length!==31)throw new Error(`Room code alphabet must be 31 characters, got ${uo.length}`);function fn(e){return e.trim().replaceAll(/-/g,"").toUpperCase()}function po(e,t=true){let n=fn(e);return !t||n.length!==6?n:`${n.slice(0,3)}-${n.slice(3)}`}function xi(e,t){let n=new Map;t.forEach((i,a)=>n.set(i,a));let o=[...new Set(e.filter(i=>!n.has(i)))].toSorted(),r=new Map;return o.forEach((i,a)=>r.set(i,t.length+a)),i=>n.get(i)??r.get(i)??Number.MAX_SAFE_INTEGER}function gn(e,t){let n=new Map;for(let a of e)n.set(a,(n.get(a)??0)+1);let o=null,r=0,i=[...n.keys()].toSorted((a,s)=>t(a)-t(s));for(let a of i){let s=n.get(a);s>r&&(r=s,o=a);}return o}function mo(e,t){let n=Object.values(e);if(n.length===0)return null;let o=xi(n,t.cards);if(t.cards.every(a=>Number.isFinite(parseFloat(a)))){let a=n.map(parseFloat).filter(Number.isFinite);if(a.length===0)return {kind:"categorical",mode:gn(n,o)};let s=a.reduce((b,E)=>b+E,0)/a.length,l=[...a].toSorted((b,E)=>b-E),u=Math.floor(l.length/2),c=l.length%2===1?l[u]:(l[u-1]+l[u])/2,d=gn(n,o),p;if(new Set(n).size===1)p="unanimous";else {let b=n.map(A=>o(A)),E=Math.min(...b);p=Math.max(...b)-E<=1?"close":"spread";}return {kind:"numeric",mean:s,median:c,mode:d,spread:p}}return {kind:"categorical",mode:gn(n,o)}}function fo(e){return e.replaceAll(/\|/g,"\\|")}function wi(e){return e.replaceAll(/\\/g,"\\\\").replaceAll(/]/g,"\\]")}function yi(e){let n=(e.match(/`+/g)??[]).reduce((o,r)=>Math.max(o,r.length),0);return "`".repeat(n+1)}function hn(e){if(!e)return "";if(so(e))return ` ([${wi(e)}](<${e}>))`;let t=yi(e);return ` (${t}${e}${t})`}function vi(e){return e instanceof Map?e:new Map(Object.entries(e))}function Ci(e){let t=new Map;for(let r of e)t.set(r.id,r);function n(r){if(!r.parentRoundId)return r;let i=t.get(r.parentRoundId);return i?n(i):r}let o=new Map;for(let r of e){let i=n(r),a=o.get(i.id);a?a.push(r):o.set(i.id,[r]);}return o}function go(e,t){let n=new Map;e.scale.cards.forEach((a,s)=>n.set(a,s));let o=new Map;for(let[a,s]of Object.entries(e.votes)){let l=t.get(a)??a,u=o.get(s);u?u.push(l):o.set(s,[l]);}let r=[...o.entries()].map(([a,s])=>({card:a,scaleIndex:n.get(a)??Number.MAX_SAFE_INTEGER,voters:[...s].toSorted().map(fo)}));return r.sort((a,s)=>{let l=s.voters.length-a.voters.length;return l!==0?l:a.scaleIndex-s.scaleIndex}),["| Vote | Voters |","|------|--------|",...r.map(a=>`| ${fo(a.card)} | ${a.voters.join(", ")} |`)].join(`
|
|
5
|
-
`)}function ho(e){let t=mo(e.votes,e.scale),n=e.timerStartedAt!=null&&e.revealedAt!=null?io(e.revealedAt-e.timerStartedAt):null,o=[];return t?.kind==="numeric"?o.push(`Avg ${t.mean.toFixed(1)} \xB7 Med ${t.median}`):t?.kind==="categorical"&&o.push(`Most common: ${t.mode}`),n!=null&&o.push(`Elapsed ${n}`),o.join(" \xB7 ")}function So(e){let{rounds:t}=e,n=vi(e.participants),o=new Map;for(let[c,d]of n)o.set(c,d.displayName);let r=t.filter(c=>c.revealedAt!=null);if(r.length===0)return "";let i=new Map;t.forEach((c,d)=>i.set(c.id,d+1));let a=Ci(r),s=new Set,l=[];for(let c of r)for(let[d,p]of a)if(p.includes(c)&&!s.has(d)){s.add(d),l.push(d);break}let u=[];for(let c of l){let d=a.get(c),p=d.find(f=>f.id===c),b=d.filter(f=>f.id!==c),E=i.get(p.id)??0,R=p.title?`## Round ${E} \u2014 ${p.title}${hn(p.ticketId)}`:`## Round ${E}${hn(p.ticketId)}`,A=go(p,o),H=ho(p),m=H?`${R}
|
|
2
|
+
import ea from'yargs';import {hideBin}from'yargs/helpers';import Qt,{useState,useEffect,useCallback,useMemo,useRef}from'react';import {render,useApp,useInput,Box,Text}from'ink';import*as $e from'yjs';import {Awareness}from'y-protocols/awareness';import {existsSync,readFileSync,writeFileSync,unlinkSync,mkdirSync,chmodSync}from'fs';import {homedir}from'os';import {join}from'path';import {randomUUID}from'crypto';import {createInterface}from'readline';import {WebsocketProvider}from'y-websocket';import es from'ws';import Cr from'clipboardy';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var It="hnch_abstain";function W(e){return e===It}var pi={"unknown-room":4001,"wrong-password":4002,"invalid-invite":4003,"expired-invite":4004,"invite-already-redeemed":4005,"room-full":4006,"malformed-credentials":4010},Qn=new Map(Object.entries(pi).map(([e,t])=>[t,e]));function Ie(e){return e.role??"voter"}function Tt(e){return e.leftAt===void 0}function _(e){let{revealedAt:t,skippedAt:n,discardedAt:o}=e;if(t===void 0&&n===void 0&&o===void 0)return null;let r=[];t!==void 0&&r.push({kind:"revealed",at:t}),n!==void 0&&r.push({kind:"skipped",at:n}),o!==void 0&&r.push({kind:"discarded",at:o});let i={revealed:0,skipped:1,discarded:2};return r.sort((s,a)=>s.at-a.at||i[s.kind]-i[a.kind]),r[0].kind}var Rt={id:"fibonacci",cards:["0","1","2","3","5","8","13","21"]},Zn={id:"t-shirt",cards:["XS","S","M","L","XL"]},eo={id:"powers-of-2",cards:["1","2","4","8","16","32","64"]},to={id:"linear",cards:["1","2","3","4","5","6","7","8","9","10"]},no={id:"risk",cards:["Low","Medium","High","Critical"]},de={[Rt.id]:Rt,[Zn.id]:Zn,[eo.id]:eo,[to.id]:to,[no.id]:no},oo={fibonacci:"Fibonacci","t-shirt":"T-shirt","powers-of-2":"Powers of 2",linear:"Linear (1\u201310)",risk:"Risk"};function ro(e){return e in oo?oo[e]:e.length===0?e:(e.startsWith("custom-")?e.slice(7):e).split("-").map(n=>n.length===0?n:n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function io(e,t,n){if(!e||_(e)!==null)return false;let o=new Set(t.filter(d=>Tt(d)&&n.has(d.id)&&Ie(d)!=="viewer").map(d=>d.id));if(o.size===0)return false;let r=Object.entries(e.votes).filter(([d])=>o.has(d)),i=r.filter(([,d])=>W(d)).length,s=r.length-i,a=o.size-i;return a<=0?false:s>=a}var ze={"racing-green":{base:"#0B3D2E",soft:"rgba(11,61,46,0.14)",ink:"#fff",label:"Racing Green"},dijon:{base:"#C9A227",soft:"rgba(201,162,39,0.18)",ink:"#000",label:"Dijon"},blue:{base:"#0A84FF",soft:"rgba(10,132,255,0.14)",ink:"#fff",label:"Blue"},indigo:{base:"#5E5CE6",soft:"rgba(94,92,230,0.14)",ink:"#fff",label:"Indigo"},violet:{base:"#BF5AF2",soft:"rgba(191,90,242,0.14)",ink:"#fff",label:"Violet"},pink:{base:"#FF375F",soft:"rgba(255,55,95,0.14)",ink:"#fff",label:"Pink"},red:{base:"#FF453A",soft:"rgba(255,69,58,0.14)",ink:"#fff",label:"Red"},orange:{base:"#FF9F0A",soft:"rgba(255,159,10,0.16)",ink:"#000",label:"Orange"},amber:{base:"#FFD60A",soft:"rgba(255,214,10,0.18)",ink:"#000",label:"Amber"},green:{base:"#30D158",soft:"rgba(48,209,88,0.14)",ink:"#000",label:"Green"},teal:{base:"#40C8E0",soft:"rgba(64,200,224,0.14)",ink:"#000",label:"Teal"},graphite:{base:"#1C1C1E",soft:"rgba(28,28,30,0.10)",ink:"#fff",label:"Graphite"}};var at=["racing-green","dijon","blue","indigo","violet","pink","red","orange","amber","green","teal","graphite"],fi=/^#[0-9a-fA-F]{6}$/;function mi(e){return Object.hasOwn(ze,e)}function Me(e){return e?mi(e)?ze[e].base:fi.test(e)?e.toLowerCase():null:null}function so(e){let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o)|0;let n=Math.abs(t)%at.length;return at[n]}var Re="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Et=Re.length,un=Math.floor(Et/2);function dt(e){let t=Re.indexOf(e);if(t===-1)throw new Error(`fractional-index: invalid character '${e}'`);return t}function ao(e,t){return e.length>=t?e:e+"0".repeat(t-e.length)}function gi(e){let t=e.length-1;for(;t>0&&e[t]==="0";)t--;return e.slice(0,t+1)}function hi(e,t){let n=e.length,o=Array.from({length:n+1}).fill(0),r=0;for(let a=n-1;a>=0;a--){let d=e[a]+t[a]+r;o[a+1]=d%Et,r=Math.floor(d/Et);}o[0]=r;let i=Array.from({length:n+1}).fill(0),s=0;for(let a=0;a<=n;a++){let d=o[a]+s*Et;i[a]=Math.floor(d/2),s=d%2;}return i.slice(1)}function pn(e,t){let n=Re[un];if(e===null&&t===null)return n+n;if(t===null)return e+n+n+n+n;if(e===null)return Si(t);if(e>=t)throw new Error(`keyBetween: a must be < b (a='${e}', b='${t}')`);return wi(e,t)}function Si(e){for(let t=e.length-1;t>=0;t--){let n=dt(e[t]);if(n>0)return e.slice(0,t)+Re[n-1]+Re[un]}if(e.length>1)return e.slice(0,-1);throw new Error(`keyBetween: cannot generate key before '${e}' \u2014 use keyBetween(null, null) for the initial key`)}function wi(e,t){let n=Math.max(e.length,t.length),o=ao(e,n).split("").map(d=>dt(d)),r=ao(t,n).split("").map(d=>dt(d)),s=hi(o,r).map(d=>Re[d]).join(""),a=gi(s);return a>e&&a<t?a:s>e&&s<t?s:xi(e,t)}function xi(e,t){for(let n=0;n<t.length;n++){let o=n<e.length?dt(e[n]):0;if(dt(t[n])===o+1)return (n<e.length?e.slice(0,n+1):e+Re[0])+Re[un]}throw new Error(`keyBetween: space exhausted between '${e}' and '${t}'`)}var yi="meta",Pt="settings",vi="participants",Ci="rounds",bi="agenda",Ai=["roomUuid","createdAt","createdBy","sessionEndedAt"],Ii=["name","defaultScale","hostParticipantId"],Ri=["displayName","joinedAt","role","leftAt","removedBy","avatarColor"],Ti=["id","title","description","ticketId","state","source","externalId","sortKey","createdAt","consumedAt","consumedByRoundId"],Ei=["id","title","description","ticketId","parentRoundId","scale","timerStartedAt","revealedAt","skippedAt","discardedAt","discardedBy","createdBy","createdAt","agendaItemId"];function kt(e){return e.getMap(yi)}function Dt(e){return e.getMap(Pt)}function Ot(e){return e.getMap(vi)}function fn(e){return e.getArray(Ci)}function Nt(e){return e.getArray(bi)}function ct(e,t){let n={};for(let o of t){let r=e.get(o);r!==void 0&&(n[o]=r);}return n}function ki(e){return ct(kt(e),Ai)}function Ni(e){return ct(Dt(e),Ii)}function Pi(e){let t=Ot(e),n=[];return t.forEach((o,r)=>{let i=ct(o,Ri);n.push({id:r,...i});}),n.sort((o,r)=>o.joinedAt-r.joinedAt||o.id.localeCompare(r.id)),n}function Di(e){let t={};return e.forEach((n,o)=>{t[o]=n;}),t}function Oi(e){let t=ct(e,Ei),n=e.get("votes"),o=n?Di(n):{};return {...t,votes:o}}function Mi(e){let t=fn(e),n=[];return t.forEach(o=>{n.push(Oi(o));}),n}function $i(e){return ct(e,Ti)}function Ui(e){let t=Nt(e),n=[];return t.forEach(o=>{n.push($i(o));}),n.sort((o,r)=>o.sortKey.localeCompare(r.sortKey)),n}function j(e){return {meta:ki(e),settings:Ni(e),participants:Pi(e),rounds:Mi(e),agenda:Ui(e)}}function co(e,t){if(kt(e).has("roomUuid"))throw new Error("initDoc: doc already seeded");e.transact(()=>{let n=kt(e);n.set("roomUuid",t.roomUuid),n.set("createdAt",t.createdAt),n.set("createdBy",t.participantId);let o=Dt(e);t.sessionName!==void 0&&o.set("name",t.sessionName),o.set("defaultScale",t.defaultScale),o.set("hostParticipantId",t.participantId);let r=new $e.Map;r.set("displayName",t.displayName),r.set("joinedAt",t.createdAt),t.avatarColor!==void 0&&r.set("avatarColor",t.avatarColor),Ot(e).set(t.participantId,r);});}function Xe(e,t){e.transact(()=>{let n=Ot(e),o=n.get(t.participantId),r=o??new $e.Map;r.set("displayName",t.displayName),o===void 0&&r.set("joinedAt",Date.now()),t.avatarColor!==void 0&&r.set("avatarColor",t.avatarColor),r.delete("leftAt"),r.delete("removedBy"),o===void 0&&n.set(t.participantId,r);});}function Qe(e,t){e.transact(()=>{let n=Dt(e);for(let[o,r]of Object.entries(t))r===void 0?n.delete(o):n.set(o,r);});}function mn(e,t,n){e.transact(()=>{let o=Ot(e),r=o.get(t),i=r??new $e.Map;i.set("displayName",n.displayName),i.set("joinedAt",n.joinedAt),n.role!==void 0&&i.set("role",n.role),n.avatarColor!==void 0&&i.set("avatarColor",n.avatarColor),r===void 0&&o.set(t,i);});}function gn(e,t){let n=t.scale??Dt(e).get("defaultScale");if(!n)throw new Error("appendRound: no scale (settings.defaultScale missing)");if(t.parentRoundId!==void 0){let o=Ue(e,t.parentRoundId);if(o!==void 0&&o.get("discardedAt")!==void 0)throw new Error(`appendRound: parentRoundId ${t.parentRoundId} points at a discarded round`)}return e.transact(()=>{let o=new $e.Map;o.set("id",t.id),o.set("createdAt",t.createdAt),o.set("createdBy",t.createdBy),o.set("scale",n),t.title!==void 0&&o.set("title",t.title),t.description!==void 0&&o.set("description",t.description),t.ticketId!==void 0&&o.set("ticketId",t.ticketId),t.parentRoundId!==void 0&&o.set("parentRoundId",t.parentRoundId),t.agendaItemId!==void 0&&o.set("agendaItemId",t.agendaItemId),o.set("timerStartedAt",t.createdAt),o.set("votes",new $e.Map),fn(e).push([o]);}),t.id}function lo(e,t,n){let o=Ue(e,t);if(!o)throw new Error(`patchRoundDescriptor: round ${t} not found`);e.transact(()=>{n.title!==void 0&&o.set("title",n.title),n.description!==void 0&&o.set("description",n.description);});}function Ue(e,t){let n=fn(e);for(let o=0;o<n.length;o+=1){let r=n.get(o);if(r.get("id")===t)return r}}function uo(e,t,n,o){let r=Ue(e,t);if(!r)throw new Error(`castVote: round ${t} not found`);r.get("revealedAt")===void 0&&e.transact(()=>{r.get("votes").set(n,o);});}function po(e,t,n){let o=Ue(e,t);if(!o)throw new Error(`clearVote: round ${t} not found`);o.get("revealedAt")===void 0&&e.transact(()=>{o.get("votes").delete(n);});}function fo(e,t,n,o){let r=t.get("agendaItemId");if(r===void 0)return;let i=Sn(e,r);i!==void 0&&i.get("state")==="pending"&&(i.set("state","consumed"),i.set("consumedAt",o),i.set("consumedByRoundId",n));}function hn(e,t,n){let o=Ue(e,t);if(!o)throw new Error(`revealRound: round ${t} not found`);if(o.get("skippedAt")!==void 0)throw new Error(`revealRound: round ${t} already skipped`);if(o.get("discardedAt")!==void 0)throw new Error(`revealRound: round ${t} already discarded`);e.transact(()=>{o.set("revealedAt",n),fo(e,o,t,n);});}function mo(e,t,n){let o=Ue(e,t);if(!o)throw new Error(`skipRound: round ${t} not found`);if(o.get("revealedAt")!==void 0)throw new Error(`skipRound: round ${t} already revealed`);if(o.get("skippedAt")!==void 0)throw new Error(`skipRound: round ${t} already skipped`);if(o.get("discardedAt")!==void 0)throw new Error(`skipRound: round ${t} already discarded`);e.transact(()=>{o.set("skippedAt",n),fo(e,o,t,n);});}function go(e,t,n,o){let r=Ue(e,t);if(!r)throw new Error(`discardRound: round ${t} not found`);if(r.get("revealedAt")!==void 0)throw new Error(`discardRound: round ${t} already revealed`);if(r.get("skippedAt")!==void 0)throw new Error(`discardRound: round ${t} already skipped`);if(r.get("discardedAt")!==void 0)throw new Error(`discardRound: round ${t} already discarded`);e.transact(()=>{r.set("discardedAt",n),r.set("discardedBy",o);});}function ho(e){e.transact(()=>{kt(e).set("sessionEndedAt",Date.now());});}function q(e){let{rounds:t}=e;if(t.length===0)return null;for(let n=t.length-1;n>=0;n-=1){let o=t[n];if(o.revealedAt===void 0&&o.skippedAt===void 0&&o.discardedAt===void 0)return o}for(let n=t.length-1;n>=0;n-=1){let o=t[n];if(o.discardedAt===void 0)return o}return null}function So(e){let t=Object.values(e.votes);return t.length<2?false:t.every(n=>n===t[0])}function Sn(e,t){let n=Nt(e);for(let o=0;o<n.length;o++){let r=n.get(o);if(r.get("id")===t)return r}}function Mt(e,t){if(!t.title?.trim()&&!t.ticketId?.trim())throw new Error("appendAgendaItem: at least one of {title, ticketId} is required");let n=crypto.randomUUID(),o=Nt(e),r=null;o.forEach(s=>{if(s.get("state")==="pending"){let a=s.get("sortKey");a!==void 0&&(r===null||a>r)&&(r=a);}});let i=pn(r,null);return e.transact(()=>{let s=new $e.Map;s.set("id",n),s.set("state","pending"),s.set("source",t.source??"manual"),s.set("sortKey",i),s.set("createdAt",t.createdAt),t.title!==void 0&&s.set("title",t.title),t.description!==void 0&&s.set("description",t.description),t.ticketId!==void 0&&s.set("ticketId",t.ticketId),t.externalId!==void 0&&s.set("externalId",t.externalId),Nt(e).push([s]);}),n}function wn(e,t,n,o={}){let r=Sn(e,t);if(!r)throw new Error(`setAgendaItemState: item ${t} not found`);let i=r.get("state");if(!(i===n&&n==="consumed")){if(i!=="pending")throw new Error(`setAgendaItemState: invalid transition '${i}' \u2192 '${n}' for item ${t}`);e.transact(()=>{r.set("state",n),n==="consumed"&&(r.set("consumedAt",o.timestamp??Date.now()),o.consumedByRoundId!==void 0&&r.set("consumedByRoundId",o.consumedByRoundId));});}}function wo(e,t,n,o){let r=Sn(e,t);if(!r)throw new Error(`reorderAgendaItem: item ${t} not found`);let i=r.get("state");if(i!=="pending")throw new Error(`reorderAgendaItem: item ${t} is ${i}; only pending items may be reordered`);let s=pn(n??null,o??null);e.transact(()=>{r.set("sortKey",s);});}function Ze(e){for(let t of e.agenda)if(t.state==="pending")return t;return null}var xo=5e3;function yo(e,t){let n=new Set;for(let o of e.participants)t.has(o.id)&&Tt(o)&&n.add(o.id);return n}function vo(e,t,n){let o=e.settings.hostParticipantId;return o?yo(e,t).has(o)?{kind:"cancel"}:n.missingHostId!==o?{kind:"start-debounce",hostId:o}:{kind:"none"}:{kind:"none"}}function Co(e,t,n,o){let r=e.settings.hostParticipantId;if(!o||r!==o)return {promote:false};let i=yo(e,t);if(i.has(r))return {promote:false};let s=[...i].toSorted();if(s.length===0)return {promote:false};let a=s[0];return a!==n?{promote:false}:{promote:true,winner:a}}function bo(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),o=t%60;return `${n}:${o.toString().padStart(2,"0")}`}function Ao(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return false}}function xn(e){if(e===null||typeof e!="object"||Array.isArray(e))return {version:2,entries:{}};let t=e;if(t.version===2&&Ro(t.entries)){let n=t.entries,o={};for(let[r,i]of Object.entries(n)){let s=Bi(i);s!==null&&(o[r]=s);}return {version:2,entries:o}}if(typeof t.roomCode=="string"&&typeof t.roomUuid=="string"&&typeof t.lastSeenAt=="number"){let n={roomCode:t.roomCode,roomUuid:t.roomUuid,lastSeenAt:t.lastSeenAt,...typeof t.passwordHash=="string"?{passwordHash:t.passwordHash}:{}};return {version:2,entries:{[n.roomUuid]:n}}}return {version:2,entries:{}}}function Io(e,t,n=864e5){let o={};for(let[r,i]of Object.entries(e.entries))t-i.lastSeenAt>n||(i.lastSeenAt>t?o[r]={...i,lastSeenAt:t}:o[r]=i);return {version:2,entries:o}}function Ro(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Bi(e){if(!Ro(e))return null;let t=e;return typeof t.roomCode!="string"||typeof t.roomUuid!="string"||typeof t.lastSeenAt!="number"?null:{roomCode:t.roomCode,roomUuid:t.roomUuid,lastSeenAt:t.lastSeenAt,...typeof t.passwordHash=="string"?{passwordHash:t.passwordHash}:{}}}function To(e,t){let n=t.filter(p=>p.discardedAt===void 0),o=new Map;for(let p of n)o.set(p.id,p);let r=o.get(e);if(r===void 0||r.parentRoundId===void 0)return null;let i=new Set([r.id]),s=r,a=1;for(;s.parentRoundId!==void 0;){let p=o.get(s.parentRoundId);if(p===void 0||i.has(p.id))return null;i.add(p.id),s=p,a+=1;}let d=s,u=new Map;for(let p of n){if(p.parentRoundId===void 0)continue;let I=u.get(p.parentRoundId);I===void 0?u.set(p.parentRoundId,[p]):I.push(p);}let c=0,l=[d];for(;l.length>0;){let p=l.shift();c+=1;let I=u.get(p.id);I!==void 0&&l.push(...I);}return {chainRoot:d,depth:a,total:c}}var Eo="PBKDF2",Hi="SHA-256",ko=new TextEncoder;function Li(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Be(e,t){let n=await crypto.subtle.importKey("raw",ko.encode(e),Eo,false,["deriveBits"]),o=await crypto.subtle.deriveBits({name:Eo,salt:ko.encode(t),iterations:1e5,hash:Hi},n,256);return Li(o)}var No="ABCDEFGHJKMNPQRSTUVWXYZ23456789";if(No.length!==31)throw new Error(`Room code alphabet must be 31 characters, got ${No.length}`);function yn(e){return e.trim().replaceAll(/-/g,"").toUpperCase()}function Po(e,t=true){let n=yn(e);return !t||n.length!==6?n:`${n.slice(0,3)}-${n.slice(3)}`}function Do(e){let t=new Set(e).size;return t===1?"unanimous":t===2?"close":"spread"}function ji(e,t){let n=new Map;t.forEach((i,s)=>n.set(i,s));let o=[...new Set(e.filter(i=>!n.has(i)))].toSorted(),r=new Map;return o.forEach((i,s)=>r.set(i,t.length+s)),i=>n.get(i)??r.get(i)??Number.MAX_SAFE_INTEGER}function vn(e,t){let n=new Map;for(let s of e)n.set(s,(n.get(s)??0)+1);let o=null,r=0,i=[...n.keys()].toSorted((s,a)=>t(s)-t(a));for(let s of i){let a=n.get(s);a>r&&(r=a,o=s);}return o}function Oo(e,t){let n=Object.values(e);if(n.length===0)return null;let o=ji(n,t.cards);if(t.cards.every(s=>Number.isFinite(parseFloat(s)))){let s=n.map(parseFloat).filter(Number.isFinite);if(s.length===0)return {kind:"categorical",mode:vn(n,o),spread:Do(n)};let a=s.reduce((I,N)=>I+N,0)/s.length,d=[...s].toSorted((I,N)=>I-N),u=Math.floor(d.length/2),c=d.length%2===1?d[u]:(d[u-1]+d[u])/2,l=vn(n,o),p;if(new Set(n).size===1)p="unanimous";else {let I=n.map(T=>o(T)),N=Math.min(...I);p=Math.max(...I)-N<=1?"close":"spread";}return {kind:"numeric",mean:a,median:c,mode:l,spread:p}}return {kind:"categorical",mode:vn(n,o),spread:Do(n)}}function Cn(e){return e.replaceAll(/\|/g,"\\|")}function _i(e){return e.replaceAll(/\\/g,"\\\\").replaceAll(/]/g,"\\]")}function Fi(e){let n=(e.match(/`+/g)??[]).reduce((o,r)=>Math.max(o,r.length),0);return "`".repeat(n+1)}function bn(e){if(!e)return "";if(Ao(e))return ` ([${_i(e)}](<${e}>))`;let t=Fi(e);return ` (${t}${e}${t})`}function Vi(e){return e instanceof Map?e:new Map(Object.entries(e))}function Yi(e){let t=new Map;for(let r of e)t.set(r.id,r);function n(r){if(!r.parentRoundId)return r;let i=t.get(r.parentRoundId);return i?n(i):r}let o=new Map;for(let r of e){let i=n(r),s=o.get(i.id);s?s.push(r):o.set(i.id,[r]);}return o}function Mo(e,t){let n=new Map;e.scale.cards.forEach((a,d)=>n.set(a,d));let o=new Map,r=[];for(let[a,d]of Object.entries(e.votes)){let u=t.get(a)??a;if(W(d)){r.push(u);continue}let c=o.get(d);c?c.push(u):o.set(d,[u]);}let i=[...o.entries()].map(([a,d])=>({card:a,scaleIndex:n.get(a)??Number.MAX_SAFE_INTEGER,voters:[...d].toSorted().map(Cn)}));i.sort((a,d)=>{let u=d.voters.length-a.voters.length;return u!==0?u:a.scaleIndex-d.scaleIndex});let s=i.map(a=>`| ${Cn(a.card)} | ${a.voters.join(", ")} |`);return r.length>0&&s.push(`| Abstained | ${[...r].toSorted().map(Cn).join(", ")} |`),["| Vote | Voters |","|------|--------|",...s].join(`
|
|
3
|
+
`)}function $o(e){let t=Object.fromEntries(Object.entries(e.votes).filter(([,i])=>!W(i))),n=Oo(t,e.scale),o=e.timerStartedAt!=null&&e.revealedAt!=null?bo(e.revealedAt-e.timerStartedAt):null,r=[];return n?.kind==="numeric"?r.push(`Avg ${n.mean.toFixed(1)} \xB7 Med ${n.median}`):n?.kind==="categorical"&&r.push(`Most common: ${n.mode}`),o!=null&&r.push(`Elapsed ${o}`),r.join(" \xB7 ")}function Uo(e){let{rounds:t}=e,n=Vi(e.participants),o=new Map;for(let[c,l]of n)o.set(c,l.displayName);let r=t.filter(c=>c.revealedAt!=null);if(r.length===0)return "";let i=new Map;t.forEach((c,l)=>i.set(c.id,l+1));let s=Yi(r),a=new Set,d=[];for(let c of r)for(let[l,p]of s)if(p.includes(c)&&!a.has(l)){a.add(l),d.push(l);break}let u=[];for(let c of d){let l=s.get(c),p=l.find(h=>h.id===c),I=l.filter(h=>h.id!==c),N=i.get(p.id)??0,R=p.title?`## Round ${N} \u2014 ${p.title}${bn(p.ticketId)}`:`## Round ${N}${bn(p.ticketId)}`,T=Mo(p,o),U=$o(p),f=U?`${R}
|
|
6
4
|
|
|
7
|
-
${
|
|
5
|
+
${T}
|
|
8
6
|
|
|
9
|
-
${
|
|
7
|
+
${U}`:`${R}
|
|
10
8
|
|
|
11
|
-
${
|
|
9
|
+
${T}`;u.push(f);for(let h of I){let y=`### Re-vote ${i.get(h.id)??0}${bn(h.ticketId)}`,O=Mo(h,o),C=$o(h),M=C?`${y}
|
|
12
10
|
|
|
13
|
-
${
|
|
11
|
+
${O}
|
|
14
12
|
|
|
15
|
-
${
|
|
13
|
+
${C}`:`${y}
|
|
16
14
|
|
|
17
|
-
${
|
|
15
|
+
${O}`;u.push(M);}}return u.join(`
|
|
18
16
|
|
|
19
17
|
`)+`
|
|
20
|
-
`}function
|
|
21
|
-
`,{encoding:"utf-8",mode:384}),chmodSync(n,384);}function V(){let e=wn();try{unlinkSync(e);}catch(t){if(t.code!=="ENOENT")throw t}}async function Mt(e){let t=true;try{await e.clearLastSession();}catch(n){t=false,e.logger.error(`Failed to clear cached session: ${n instanceof Error?n.message:String(n)}`);}return t?e.logger.error("Session expired (room no longer exists). Cached session cleared."):e.logger.error("Session expired. Could not delete ~/.config/hnch/last-session.json \u2014 please remove it manually."),e.exit(1)}function $t(e){let t=e.doc.getMap("meta"),n=null,o=false;function r(){if(o)return;let i=t.get("sessionEndedAt");if(i==null||i===n)return;n=i;let a=t.get("createdBy"),s=a===e.localParticipantId,l=e.doc.getMap("participants"),u=e.doc.getMap("settings").get("hostParticipantId")??a,c="host";if(u){let p=l.get(u)?.get("displayName");typeof p=="string"&&p.length>0&&(c=p);}setImmediate(()=>{o||e.onEnded({isLocal:s,hostName:c,timestamp:i});});}return t.observe(r),r(),()=>{o=true,t.unobserve(r);}}var Mi="@xauyxau/hnch";function Ut(e){return po(e)}function Bt(e){return `${process.env.HNCH_SHARE_ORIGIN??"https://hnch.dev"}/join?code=${e}`}function Ht(e){return `npx ${Mi} join ${e}`}function yn(e){let t=e.trim();return t===""?void 0:t}function Lt(e){return e?{title:e.title??"",ticketId:e.ticketId??"",agendaItemId:e.id}:{title:"",ticketId:"",agendaItemId:void 0}}function Ro(e,t,n){return [e,yn(t),n]}var $i={connecting:"yellow",connected:"green",disconnected:"red"};function No({roomCode:e,sessionName:t,status:n,isHost:o}){let r=t?`${e} \xB7 ${t}`:e;return jsxs(Box,{borderStyle:"single",borderColor:"gray",paddingX:1,justifyContent:"space-between",children:[jsxs(Text,{bold:true,children:["hnch \xB7 ",r]}),jsxs(Box,{gap:2,children:[o&&jsx(Text,{color:"yellow",children:"[host]"}),jsx(Text,{color:$i[n],children:n})]})]})}function he({items:e,onSelect:t,onClose:n,title:o}){if(e.length===0)return jsxs(Box,{flexDirection:"column",gap:1,children:[o&&jsx(Text,{bold:true,children:o}),jsx(Text,{dimColor:true,children:"(no items)"})]});let r=e.findIndex(s=>!s.disabled),[i,a]=useState(Math.max(r,0));return useInput((s,l)=>{if(l.upArrow)a(u=>{let c=(u-1+e.length)%e.length,d=0;for(;e[c]?.disabled&&d<e.length;)c=(c-1+e.length)%e.length,d++;return c});else if(l.downArrow)a(u=>{let c=(u+1)%e.length,d=0;for(;e[c]?.disabled&&d<e.length;)c=(c+1)%e.length,d++;return c});else if(l.return){let u=e[i];u&&!u.disabled&&t(u.value);}else l.escape&&n?.();}),jsxs(Box,{flexDirection:"column",gap:1,children:[o&&jsx(Text,{bold:true,children:o}),jsx(Box,{flexDirection:"column",children:e.map((s,l)=>{let u=l===i,c=s.disabled??false;return jsxs(Box,{gap:1,children:[jsx(Text,{...u&&{color:"cyan"},dimColor:c,children:u?">":" "}),jsx(Text,{bold:u,dimColor:c,children:s.label}),s.detail&&jsx(Text,{dimColor:true,children:s.detail})]},s.value)})}),jsx(Text,{dimColor:true,children:"\u2191\u2193 select \u23CE confirm esc close"})]})}function Y({value:e,onChange:t,onSubmit:n,onCancel:o,placeholder:r,isActive:i=true,mask:a=false}){useInput((c,d)=>{d.escape?o?.():d.return?n(e):d.backspace||d.delete?t(e.slice(0,-1)):c&&!d.ctrl&&!d.meta&&t(e+c);},{isActive:i});let s=a&&e.length>0?"*".repeat(e.length):e,l=s.length>0?s:r??"",u=e.length===0&&r!==void 0;return jsxs(Text,{children:[jsx(Text,{dimColor:u,children:l}),jsx(Text,{inverse:true,children:" "})]})}function Mo({mode:e,password:t,onModeChange:n,onPasswordChange:o,onClose:r}){let[i,a]=useState(e==="open"?0:1),[s,l]=useState(false);return useEffect(()=>{a(e==="open"?0:1);},[e]),useInput((u,c)=>{if(c.leftArrow)a(d=>Math.max(0,d-1));else if(c.rightArrow)a(d=>Math.min(1,d+1));else if(c.return){let d=i===0?"open":"password";d!==e&&n(d),d==="password"&&l(true);}else c.escape&&r?.();},{isActive:!s}),jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Box,{gap:1,children:["open","password"].map((u,c)=>{let d=c===i,p=u===e,b=u==="open"?"Open":"Password";return jsx(Text,{inverse:d,bold:p,...p&&{color:"cyan"},children:p?`[${b}]`:` ${b} `},u)})}),e==="password"&&jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{children:"Password: "}),jsx(Y,{value:t,onChange:o,onSubmit:()=>l(false),onCancel:()=>l(false),placeholder:"(required to join)",isActive:s,mask:true}),!s&&jsx(Text,{dimColor:true,children:"\u23CE edit \u2190 \u2192 switch mode esc close"}),s&&jsx(Text,{dimColor:true,children:"\u23CE done esc cancel"})]}),e==="open"&&jsx(Text,{dimColor:true,children:"\u2190\u2192 toggle \u23CE confirm esc close"})]})}function Bo({scaleId:e,cards:t,disabledIndices:n,onOverrideChange:o,onClose:r}){let i=useMemo(()=>new Set(n),[n]),[a,s]=useState(0),l=u=>{let c=new Set(i);if(c.has(u))c.delete(u);else {if(c.size>=t.length-1)return;c.add(u);}let d=Array.from(c).toSorted((p,b)=>p-b);o(e,d);};return useInput((u,c)=>{c.leftArrow?s(d=>Math.max(0,d-1)):c.rightArrow?s(d=>Math.min(t.length-1,d+1)):u===" "?l(a):(c.return||c.escape)&&r();}),jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Box,{gap:1,children:t.map((u,c)=>{let d=c===a,p=i.has(c);return jsx(Text,{inverse:d,bold:!p,...!p&&{color:"cyan"},strikethrough:p,dimColor:p,children:u},u)})}),jsx(Text,{dimColor:true,children:" \u2190\u2192 navigate space toggle \u23CE/esc done"})]})}function En({initialName:e="",initialCards:t=[],onSave:n,onCancel:o}){let r=e.length>0,[i,a]=useState(e),[s,l]=useState(t.length>0?t:[""]),[u,c]=useState(0),[d,p]=useState("editing-name"),[b,E]=useState(""),R=()=>{let m=i.trim();if(m.length===0||m.length>40){E("Name must be 1-40 characters");return}a(m),E(""),p("editing-cards");},A=()=>{let m=i.trim();if(m.length===0||m.length>40){E("Name must be 1-40 characters");return}let f=s.map(v=>v.trim()).filter(v=>v.length>0),y=Array.from(new Set(f));if(y.length<2){E("Need at least 2 unique non-empty cards");return}E(""),n(m,y);};return useInput((m,f)=>{if(d==="editing-cards"){if(f.leftArrow)c(y=>Math.max(0,y-1));else if(f.rightArrow)c(y=>{let v=y+1;return v>=s.length&&s.length<25?(l(N=>[...N,""]),v):Math.min(v,s.length-1)});else if(f.return)A();else if(f.escape)o();else if(f.tab)p("editing-name");else if(f.backspace){let y=s[u]||"";if(y.length===0){if(s.length>2){let v=s.filter((N,w)=>w!==u);l(v),c(Math.max(0,u-1));}}else {let v=[...s];v[u]=y.slice(0,-1),l(v);}}else if(m&&!f.ctrl&&!f.meta){let y=s[u]||"";if(y.length<10){let v=[...s];v[u]=y+m,l(v);}}}},{isActive:d==="editing-cards"}),jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:r?"\u2500\u2500 Edit Custom Scale \u2500\u2500":"\u2500\u2500 Create Custom Scale \u2500\u2500"}),jsxs(Box,{flexDirection:"column",gap:0,children:[jsx(Text,{children:"Name:"}),jsx(Y,{value:i,onChange:a,onSubmit:R,onCancel:o,placeholder:"Scale name",isActive:d==="editing-name"})]}),d==="editing-cards"&&jsxs(Box,{flexDirection:"column",gap:0,children:[jsx(Text,{children:"Cards:"}),jsx(Box,{gap:1,flexWrap:"wrap",children:s.map((m,f)=>{let y=f===u;return jsx(Text,{inverse:y,...!y&&{color:"cyan"},children:m.length>0?m:"\xB7"},f)})})]}),b&&jsx(Text,{color:"red",children:b}),jsx(Text,{dimColor:true,children:d==="editing-name"?"\u23CE next esc cancel":"\u2190\u2192 navigate typing adds card bsp delete \u23CE save tab name esc cancel"})]})}function Ft({scales:e,selectedScaleId:t,presetOverrides:n,customScales:o=[],onSelect:r,onOverrideChange:i,onCustomScaleCreate:a,onCustomScaleEdit:s,onCustomScaleDelete:l,onClose:u,showNoneOption:c=false}){let[d,p]=useState(0),[b,E]=useState(null),[R,A]=useState("browsing"),[H,m]=useState(null),[f,y]=useState(null),v=a?[...e,{id:"__create-custom__",cards:[]}]:e,N=v.length;if(useInput((w,D)=>{if(R==="browsing"){if(D.escape){u();return}if(N===0)return;if(D.upArrow)p(S=>(S-1+N)%N);else if(D.downArrow)p(S=>(S+1)%N);else if(D.return){let S=v[d];if(!S)return;if(S.id==="__create-custom__"){A("creating");return}S.id in ae?E(b===S.id?null:S.id):r(S.id);}else if(w===" "){let S=v[d];S&&S.id!=="__create-custom__"&&r(S.id);}else if(w==="e"||w==="E"){let S=v[d];s&&S?.id.startsWith("custom-")&&(m(S.id),A("editing"));}else if(w==="d"||w==="D"){let S=v[d];l&&S?.id.startsWith("custom-")&&(y(S.id),A("confirming-delete"));}}else R==="confirming-delete"&&(w==="y"||w==="Y"?(f&&l&&l(f),y(null),A("browsing")):(w==="n"||w==="N"||D.escape)&&(y(null),A("browsing")));},{isActive:R==="browsing"&&b===null||R==="confirming-delete"}),R==="creating")return jsx(En,{onSave:(w,D)=>{a&&a(w,D),A("browsing");},onCancel:()=>A("browsing")});if(R==="editing"&&H){let w=o?.find(S=>S.id===H);if(e.find(S=>S.id===H)&&w)return jsx(En,{initialName:w.label,initialCards:w.cards,onSave:(S,_)=>{s&&s(H,S,_),m(null),A("browsing");},onCancel:()=>{m(null),A("browsing");}})}if(R==="confirming-delete"&&f){let w=v.find(S=>S.id===f),D=w?Me(w.id,o):"Unknown";return jsxs(Box,{flexDirection:"column",gap:1,children:[jsxs(Text,{children:["Delete ",D,"? "]}),jsx(Text,{children:"[y] yes [n] no esc cancel"})]})}return v.length===0?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{dimColor:true,children:"(no scales available)"}),jsx(Text,{dimColor:true,children:"esc back"})]}):jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Box,{flexDirection:"column",children:v.map((w,D)=>{let S=D===d,_=w.id===t,pe=b===w.id,oe=w.id in ae,re=w.id==="__create-custom__",J=w.cards.join(", "),I=c&&w.id==="",T=I?"(none)":re?"[+ Create custom scale]":Me(w.id,o);return jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{...S&&{color:"cyan"},children:S?">":" "}),jsx(Text,{bold:S,children:T}),!I&&!re&&jsx(Text,{dimColor:true,children:J}),_&&jsx(Text,{color:"cyan",children:"[current]"})]}),pe&&!I&&!re&&jsx(Box,{paddingLeft:2,children:oe?jsx(Bo,{scaleId:w.id,cards:ae[w.id]?.cards??[],disabledIndices:n?.[w.id]??[],onOverrideChange:i,onClose:()=>E(null)}):null})]},w.id||"none")})}),jsx(Text,{dimColor:true,children:(()=>{let w=d<v.length?v[d]:null;return w?.id.startsWith("custom-")?`\u2191\u2193 navigate space select${s?" [e] edit":""}${l?" [d] delete":""} esc back`:w&&w.id in ae?"\u2191\u2193 navigate \u23CE customize space select esc back":"\u2191\u2193 navigate \u23CE/space select esc back"})()})]})}function Ki(e,t){return t?[...e]:e.filter(n=>n.value==="display-name")}function Ho({sessionName:e,displayName:t,currentScale:n,accessMode:o,presetOverrides:r,customScales:i,isHost:a=true,onChangeName:s,onChangeScale:l,onChangeDisplayName:u,onChangeAccess:c,onClose:d}){let[p,b]=useState(r??{}),E=useMemo(()=>Pt(p,i),[p,i]),[R,A]=useState("main-menu"),[H,m]=useState(e??""),[f,y]=useState(t),[v,N]=useState(o==="password"?"password":"open"),[w,D]=useState(""),[S,_]=useState(false),pe=[{label:"Room name",value:"room-name",detail:`[${e??"(none)"}]`},{label:"Scale",value:"scale",detail:`[${Me(n.id,i)}]`},{label:"Access",value:"access",detail:`[${o==="open"?"Open":"Password"}]`},{label:"Display name",value:"display-name",detail:`[${t}]`}],oe=Ki(pe,a);function re(M){!a&&M!=="display-name"||(M==="room-name"?(m(e??""),A("editing-room-name")):M==="scale"?A("picking-scale"):M==="access"?A("picking-access"):M==="display-name"&&(y(t),A("editing-display-name")));}function J(M){let L=M.trim()===""?void 0:M.trim();s(L),A("main-menu");}function I(M){let L=M.trim();L.length>0&&(u(L),process.nextTick(()=>G({displayName:L}))),A("main-menu");}function T(M){let L=E.find(z=>z.id===M);L&&l(L),A("main-menu");}function O(M,L){let z={...p};L.length===0?delete z[M]:z[M]=L,b(z),G({presetOverrides:Object.keys(z).length>0?z:void 0});}async function F(M,L){_(true);try{await c(M,L),N(M),D(M==="password"?L??"":"");}catch(z){console.error(`Failed to update access: ${z}`);}finally{_(false),A("main-menu");}}return R==="main-menu"?jsx(he,{title:"\u2500\u2500 Settings \u2500\u2500",items:oe,onSelect:re,onClose:d}):R==="editing-room-name"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),jsx(Text,{children:"Room name: "}),jsx(Y,{value:H,onChange:m,onSubmit:J,onCancel:()=>A("main-menu"),placeholder:"(leave empty to remove)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]}):R==="editing-display-name"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),jsx(Text,{children:"Display name: "}),jsx(Y,{value:f,onChange:y,onSubmit:I,onCancel:()=>A("main-menu"),placeholder:"(required)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]}):R==="picking-scale"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),jsx(Ft,{scales:E,selectedScaleId:n.id,presetOverrides:p,onSelect:T,onOverrideChange:O,onClose:()=>A("main-menu")})]}):R==="picking-access"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),S&&jsx(Text,{dimColor:true,children:"Updating access..."}),!S&&jsx(Mo,{mode:v,password:w,onModeChange:M=>{M==="open"&&F("open");},onPasswordChange:D,onClose:()=>A("main-menu")})]}):jsx(Box,{})}function Jt({participants:e,onlineIds:t,hostId:n,votes:o,revealed:r,participantId:i}){return jsxs(Box,{flexDirection:"column",children:[jsxs(Text,{bold:true,children:["Participants (",e.length,")"]}),e.map(a=>{let s=t.has(a.id),l=s?"\u25CF":"\u25CB",u=s?"green":"gray",c=a.id===n,d=Pe(a)==="viewer",p=a.id===i,b=a.id in o,E=d?" (viewer)":r?o[a.id]?` \u2192 ${o[a.id]}`:"":b?" \u2713":" \xB7",R=p&&!d&&!(r&&o[a.id]);return jsxs(Box,{gap:1,children:[jsx(Text,{color:u,children:l}),jsxs(Text,{children:[a.displayName,c?" (host)":""]}),R?jsx(Text,{color:"cyan",children:"(voter)"}):jsx(Text,{color:d?"gray":b?"green":"gray",children:E})]},a.id)})]})}var zi=[{label:"End session for everyone",value:"end-session",detail:"Disconnects all participants. Cannot be undone."}];function jo({onPick:e,onClose:t}){return jsx(he,{title:"Host Actions",items:zi,onSelect:e,onClose:t})}function Gt({roomCode:e,onPick:t,onClose:n}){let o=[{label:"Copy code",value:"code",detail:Ut(e)},{label:"Copy share link",value:"url",detail:Bt(e)},{label:"Copy npx command",value:"npx",detail:Ht(e)}];return jsx(he,{title:"Share",items:o,onSelect:r=>t(r),onClose:n})}function Zi(e){let t=e.rounds.filter(o=>W(o)!==null),n=Object.fromEntries(e.participants.map(o=>[o.id,o]));return So({rounds:t,participants:n})}async function _o(e,t,n){let o=Zi(e);try{await t(o),n("Results copied to clipboard");}catch{n("Clipboard write failed");}}function Fo(e,t,n){let o=ao(e.id,n);return o===null?`Round ${t}`:`Round ${o.depth}/${o.total} [re-vote]`}function Vo(e,t,n){let o=Fo(e,t,n),r=e.title?` \u2014 ${e.title}`:"",i=e.ticketId?` [${e.ticketId}]`:"",a=W(e)==="skipped"?" \u2014 Skipped":" \u2014 Results";return `${o}${r}${i}${a}`}function Yo(e){let t=Object.values(e).filter(c=>!fe(c)).map(c=>parseFloat(c)).filter(c=>!isNaN(c)).toSorted((c,d)=>c-d);if(t.length===0)return {average:"-",median:"-",agreement:"-"};let o=t.reduce((c,d)=>c+d,0)/t.length,r=Math.floor(t.length/2),i=t.length%2===0?(t[r-1]+t[r])/2:t[r],a=Object.values(e).filter(c=>!fe(c)),s=new Map;for(let c of a)s.set(c,(s.get(c)??0)+1);let l=Math.max(...s.values()),u=a.length>0?Math.round(l/a.length*100):0;return {average:o.toFixed(1),median:i.toFixed(1),agreement:`${u}%`}}function Nn(e,t){let n=Math.floor((t-e)/1e3),o=Math.floor(n/60),r=n%60;return `${o}:${r.toString().padStart(2,"0")}`}function Jo(e,t,n=[]){let o=Fo(e,t,n);if(W(e)==="skipped"){let d=e.title?` ${e.title}`:"",p=e.ticketId?` [${e.ticketId}]`:"";return `${o}:${d}${p} \u2014 Skipped`}let r=new Map;for(let d of Object.values(e.votes))fe(d)||r.set(d,(r.get(d)??0)+1);let i=[...r.entries()].toSorted((d,p)=>p[1]-d[1]||d[0].localeCompare(p[0])).map(([d,p])=>`${d}\xD7${p}`).join(", "),a=Object.values(e.votes).filter(fe).length,s=a>0?` (${a} abstained)`:"",l=e.title?` ${e.title}`:"",u=e.ticketId?` [${e.ticketId}]`:"",c=e.timerStartedAt!==void 0&&e.revealedAt!==void 0?` \u2014 ${Nn(e.timerStartedAt,e.revealedAt)}`:"";return `${o}:${l}${u} \u2014 ${i||"(no votes)"}${s}${c}`}function Go({projection:e,onlineIds:t,isHost:n,participantId:o,rounds:r,currentRound:i,settingsOpen:a,onStartRound:s,onNewRound:l,onRevote:u,onOpenSettings:c,onHandoffHost:d,onEndSession:p,onShare:b,shareOpen:E,onSetShareOpen:R,roomCode:A,confirmingQuit:H,myRole:m,onToggleRole:f,roundTitlePromptActive:y,roundTitleInput:v,onRoundTitleChange:N,onRoundTitleSubmit:w,onRoundTitleCancel:D,roundTicketIdPromptActive:S,roundTicketIdInput:_,onRoundTicketIdChange:pe,onRoundTicketIdSubmit:oe,onRoundTicketIdCancel:re,descriptorPromptActive:J,descriptorInput:I,onDescriptorChange:T,onDescriptorSubmit:O,onDescriptorCancel:F,onEditDescriptor:M,canExport:L,onExportResults:z,onAgendaAdd:Qe,agendaAddPromptActive:Te,agendaAddTitleInput:Ze,onAgendaAddTitleChange:tn,onAgendaAddTitleSubmit:je,onAgendaAddTitleCancel:St,agendaAddTicketIdPromptActive:ye,agendaAddTicketIdInput:nn,onAgendaAddTicketIdChange:_e,onAgendaAddTicketIdSubmit:Fe,onAgendaAddTicketIdCancel:Re}){let[Q,Z]=Wt.useState("idle"),[ge,ve]=Wt.useState(null),[et,ie]=Wt.useState(false),[me,Ee]=Wt.useState(false);useEffect(()=>{n||(Z("idle"),ve(null),ie(false),Ee(false));},[n]),useInput(x=>{if(x==="c"||x==="C"){R(true);return}if(x==="w"||x==="W"){f();return}if((x==="x"||x==="X")&&L){z();return}if(n){if(x==="a"||x==="A"){Qe();return}(x==="e"||x==="E")&&c(),(x==="s"||x==="S")&&s(),(x==="h"||x==="H")&&Z("picking"),(x==="m"||x==="M")&&ie(true),i!==null&&W(i)!==null&&((x==="n"||x==="N")&&l(),(x==="v"||x==="V")&&W(i)!=="skipped"&&u(),(x==="t"||x==="T")&&M());}},{isActive:!a&&!H&&Q==="idle"&&!y&&!S&&!et&&!me&&!E&&!J&&!Te&&!ye}),useInput((x,ee)=>{x==="y"||x==="Y"?(p(),Ee(false)):(x==="n"||x==="N"||ee.escape)&&Ee(false);},{isActive:me});let Ce=e.participants.filter(x=>x.id!==o&&t.has(x.id));useInput(x=>{if(Q==="picking"){let ee=parseInt(x,10);!isNaN(ee)&&ee>=1&&ee<=Ce.length?(ve(Ce[ee-1].id),Z("confirming")):(x==="Escape"||x==="q"||x==="Q")&&Z("idle");}},{isActive:Q==="picking"}),useInput(x=>{Q==="confirming"&&ge&&(x==="y"||x==="Y"?(d(ge),Z("idle"),ve(null)):(x==="n"||x==="N"||x==="Escape")&&(Z("idle"),ve(null)));},{isActive:Q==="confirming"});let ke=r.length>0,xt=r.filter(x=>W(x)!==null),tt=i!==null?xt.slice(0,-1):xt;return et?jsx(jo,{onPick:x=>{ie(false),x==="end-session"&&Ee(true);},onClose:()=>ie(false)}):E?jsx(Gt,{roomCode:A,onPick:x=>{R(false),b(x);},onClose:()=>R(false)}):jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:ke?"Session":"Waiting for participants..."}),!ke&&jsx(Text,{dimColor:true,children:"No rounds started yet."}),jsx(Jt,{participants:e.participants,onlineIds:t,hostId:e.settings.hostParticipantId,votes:{},revealed:false,participantId:o}),e.agenda.length>0&&jsx(rs,{items:e.agenda,nextPending:Ge(e)}),i!==null&&W(i)!==null&&jsx(ts,{projection:e,round:i,rounds:r}),tt.length>0&&jsxs(Box,{flexDirection:"column",children:[jsx(Text,{dimColor:true,children:"\u2500\u2500 History \u2500\u2500"}),tt.map(x=>{let ee=r.indexOf(x)+1;return jsx(Text,{dimColor:true,children:Jo(x,ee,r)},x.id)})]}),Q==="picking"&&Ce.length>0&&jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{children:"Hand off to:"}),Ce.map((x,ee)=>jsxs(Text,{children:["[",ee+1,"] ",x.displayName]},x.id)),jsx(Text,{dimColor:true,children:"[q] Cancel"})]}),Q==="picking"&&Ce.length===0&&jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{dimColor:true,children:"No other online participants"}),jsx(Text,{dimColor:true,children:"[q] Cancel"})]}),Q==="confirming"&&ge&&jsx(Box,{flexDirection:"column",children:jsxs(Text,{children:["Hand off to ",e.participants.find(x=>x.id===ge)?.displayName,"? [y/n]"]})}),y&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Round title (optional, Enter to skip):"}),jsx(Y,{value:v,onChange:N,onSubmit:w,onCancel:D,placeholder:"Enter to skip",isActive:y})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),S&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Ticket ID (optional, Enter to skip):"}),jsx(Y,{value:_,onChange:pe,onSubmit:oe,onCancel:re,placeholder:"e.g. PROJ-1234",isActive:S})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),J&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Edit round title:"}),jsx(Y,{value:I,onChange:T,onSubmit:O,onCancel:F,placeholder:"Enter to save",isActive:J})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel \xB7 empty submit cancels"})]}),me&&jsxs(Box,{children:[jsx(Text,{color:"red",children:"End session for everyone? This cannot be undone. "}),jsx(Text,{dimColor:true,children:"y/n [Esc] Cancel"})]}),Te&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Agenda title (optional, Enter to skip):"}),jsx(Y,{value:Ze,onChange:tn,onSubmit:je,onCancel:St,placeholder:"Enter to skip",isActive:Te})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),ye&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Agenda ticket ID (optional, Enter to skip):"}),jsx(Y,{value:nn,onChange:_e,onSubmit:Fe,onCancel:Re,placeholder:"e.g. PROJ-1234",isActive:ye})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),Q==="idle"&&!y&&!S&&!J&&!me&&!Te&&!ye&&jsxs(Box,{gap:2,children:[n?jsx(Fragment,{children:i!==null&&W(i)!==null?jsxs(Fragment,{children:[W(i)!=="skipped"&&jsx(Text,{color:"yellow",children:"[v] Revote"}),jsx(Text,{color:"yellow",children:"[n] Next"}),jsx(Text,{color:"yellow",children:"[t] Edit title"}),jsx(Text,{color:"yellow",children:"[h] Handoff"}),jsx(Text,{color:"yellow",children:"[e] Settings"}),jsx(Text,{color:"yellow",children:"[c] Share"}),L&&jsx(Text,{color:"yellow",children:"[x] Export"}),jsxs(Text,{color:"yellow",children:["[w] ",m==="viewer"?"Vote":"Observe"]}),jsx(Text,{color:"yellow",children:"[m] Menu"})]}):jsxs(Fragment,{children:[jsx(Text,{color:"yellow",children:"[s] Start round"}),jsx(Text,{color:"yellow",children:"[a] Agenda"}),jsx(Text,{color:"yellow",children:"[h] Handoff"}),jsx(Text,{color:"yellow",children:"[e] Settings"}),jsx(Text,{color:"yellow",children:"[c] Share"}),L&&jsx(Text,{color:"yellow",children:"[x] Export"}),jsxs(Text,{color:"yellow",children:["[w] ",m==="viewer"?"Vote":"Observe"]}),jsx(Text,{color:"yellow",children:"[m] Menu"})]})}):jsxs(Fragment,{children:[jsx(Text,{dimColor:true,children:"Waiting for host to start a round..."}),jsx(Text,{children:"[c] Share"}),L&&jsx(Text,{color:"yellow",children:"[x] Export"}),jsxs(Text,{color:"yellow",children:["[w] ",m==="viewer"?"Vote":"Observe"]})]}),jsx(Text,{children:"[q] Quit"})]})]})}function ts({projection:e,round:t,rounds:n}){let o=n.indexOf(t)+1,r=Vo(t,o,n);if(W(t)==="skipped")return jsx(Box,{flexDirection:"column",gap:1,children:jsx(Text,{bold:true,children:r})});let i=Yo(t.votes),a=new Map(e.participants.map(p=>[p.id,p.displayName])),s=t.timerStartedAt!==void 0&&t.revealedAt!==void 0?Nn(t.timerStartedAt,t.revealedAt):null,l=Object.entries(t.votes),u=l.filter(([,p])=>!fe(p)),c=l.filter(([,p])=>fe(p)).map(([p])=>p),d=u[0]?.[1];return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:r}),to(t)&&d!==void 0&&jsxs(Text,{bold:true,color:"green",children:["Consensus! Everyone voted ",d]}),jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:2,children:[jsx(Text,{bold:true,underline:true,children:"Name".padEnd(20)}),jsx(Text,{bold:true,underline:true,children:"Estimate".padEnd(10)})]}),u.map(([p,b])=>jsxs(Box,{gap:2,children:[jsx(Text,{children:(a.get(p)??p).padEnd(20)}),jsx(Text,{color:"cyan",bold:true,children:b.padEnd(10)})]},p)),c.map(p=>jsxs(Box,{gap:2,children:[jsx(Text,{dimColor:true,children:(a.get(p)??p).padEnd(20)}),jsx(Text,{dimColor:true,children:"(abstained)".padEnd(10)})]},p)),e.participants.filter(p=>!(p.id in t.votes)).map(p=>jsxs(Box,{gap:2,children:[jsx(Text,{dimColor:true,children:p.displayName.padEnd(20)}),jsx(Text,{dimColor:true,children:"(no vote)".padEnd(10)})]},p.id))]}),jsxs(Box,{gap:2,children:[jsxs(Text,{children:["Avg: ",jsx(Text,{bold:true,children:i.average})]}),jsxs(Text,{children:["Med: ",jsx(Text,{bold:true,children:i.median})]}),jsxs(Text,{children:["Agreement: ",jsx(Text,{bold:true,children:i.agreement})]}),s!==null&&jsxs(Text,{dimColor:true,children:["\u23F1 ",s]})]})]})}var ns={pending:"\u2022",consumed:"\u2713",skipped:"~",cancelled:"\u2717"},os={consumed:"green",skipped:"yellow",cancelled:"red"};function rs({items:e,nextPending:t}){let n=e.filter(o=>o.state!=="cancelled");return jsxs(Box,{flexDirection:"column",children:[jsx(Text,{dimColor:true,children:"\u2500\u2500 Agenda \u2500\u2500"}),n.map(o=>{let r=ns[o.state]??"?",i=os[o.state],a=t!==null&&o.id===t.id,s=[o.ticketId?`[${o.ticketId}]`:"",o.title??""].filter(Boolean).join(" ").trim()||o.id;return jsxs(Box,{gap:1,children:[i!==void 0?jsx(Text,{color:i,children:r}):jsx(Text,{children:r}),i!==void 0?jsx(Text,{color:i,children:s}):jsx(Text,{children:s}),a&&jsx(Text,{color:"cyan",children:"(next)"})]},o.id)}),n.length===0&&jsx(Text,{dimColor:true,children:"No pending items."})]})}function Ko({scale:e,selected:t,onSelect:n,onClear:o,disabled:r}){let[i,a]=useState(0);return useInput((s,l)=>{if(!r)if(l.leftArrow)a(u=>Math.max(0,u-1));else if(l.rightArrow)a(u=>Math.min(e.cards.length-1,u+1));else if(l.return){let u=e.cards[i];u===t?o():n(u);}else (l.backspace||l.delete)&&o();}),jsxs(Box,{flexDirection:"column",gap:0,children:[jsx(Box,{gap:1,children:e.cards.map((s,l)=>{let u=l===i,c=s===t;return jsx(Text,{inverse:u,bold:c,...c&&{color:"cyan"},children:c?`[${s}]`:` ${s} `},s)})}),jsx(Text,{dimColor:true,children:" \u2190\u2192 navigate \u23CE select \u232B clear"})]})}function cs(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),o=t%60;return `${n}:${o.toString().padStart(2,"0")}`}function zo({projection:e,round:t,onlineIds:n,isHost:o,myId:r,myRole:i,elapsedMs:a,roomCode:s,shareOpen:l,settingsOpen:u,onVote:c,onClearVote:d,onReveal:p,onSkip:b,onToggleRole:E,onShare:R,onSetShareOpen:A,onOpenSettings:H,confirmingQuit:m}){let f=t.votes[r],y=f!==void 0&&fe(f);if(useInput(S=>{if(S==="e"||S==="E"){H();return}if(S==="c"||S==="C"){A(true);return}if(i==="voter"&&(S==="a"||S==="A")){y?d():c(vt);return}o&&(S==="r"||S==="R")&&p(),o&&(S==="s"||S==="S")&&b(),(S==="w"||S==="W")&&E();},{isActive:!m&&!u&&!l}),l)return jsx(Gt,{roomCode:s,onPick:S=>{A(false),R(S);},onClose:()=>A(false)});let v=f,N=e.rounds.indexOf(t)+1,w=t.title?` \u2014 ${t.title}`:"",D=t.ticketId?` [${t.ticketId}]`:"";return jsxs(Box,{flexDirection:"column",gap:1,children:[jsxs(Box,{gap:2,children:[jsxs(Text,{bold:true,children:["Round ",N,w,D]}),a!==void 0&&jsxs(Text,{dimColor:true,children:["\u23F1 ",cs(a)]})]}),jsxs(Box,{gap:4,children:[jsx(Jt,{participants:e.participants,onlineIds:n,hostId:e.settings.hostParticipantId,votes:t.votes,revealed:false}),i==="viewer"?jsx(Box,{flexDirection:"column",children:jsx(Text,{dimColor:true,children:"You're observing"})}):jsxs(Box,{flexDirection:"column",gap:1,children:[y&&jsx(Text,{dimColor:true,children:"(abstaining this round \u2014 press [a] to vote)"}),jsx(Ko,{scale:t.scale,selected:y?void 0:v,onSelect:c,onClear:d,disabled:m||y})]})]}),jsxs(Box,{gap:2,children:[o&&jsx(Text,{color:"yellow",children:"[r] Reveal"}),o&&jsx(Text,{color:"yellow",children:"[s] Skip"}),i==="voter"&&jsxs(Text,{color:"yellow",children:["[a] ",y?"Vote":"Abstain"]}),jsxs(Text,{color:"yellow",children:["[w] ",i==="viewer"?"Vote":"Observe"]}),jsx(Text,{children:"[e] Settings"}),jsx(Text,{children:"[c] Share"}),jsx(Text,{children:"[q] Quit"})]})]})}var ms=3e3;function zt(e=ms){let[t,n]=useState(null),o=useRef(null),r=useCallback(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null);},[]),i=useCallback(s=>{r(),n(s),o.current=setTimeout(()=>{n(null),o.current=null;},e);},[r,e]),a=useCallback(()=>{r(),n(null);},[r]);return useEffect(()=>()=>{r();},[r]),{notice:t,show:i,dismiss:a}}function hs(e){let t=te(e);return !t||W(t)!==null?"lobby":"voting"}function Qt({session:e,participantId:t,displayName:n,accessMode:o,presetOverrides:r,customScales:i}){let{exit:a}=useApp(),[s,l]=useState(e.projection()),[u,c]=useState("connecting"),[d,p]=useState(e.onlineIds()),[b,E]=useState(),[R,A]=useState(false),[H,m]=useState(o==="password"?"password":"open"),[f,y]=useState(n),[v,N]=useState(false),[w,D]=useState(false),[S,_]=useState(""),[pe,oe]=useState(false),[re,J]=useState(""),[I,T]=useState(),[O,F]=useState(false),[M,L]=useState(""),[z,Qe]=useState(null),[Te,Ze]=useState(false),[tn,je]=useState(""),[St,ye]=useState(false),[nn,_e]=useState(""),[Fe,Re]=useState(),[Q,Z]=useState(),ge=zt(3e3),[ve,et]=useState(false),ie=zt(3e3),me=zt(3e3);useEffect(()=>{let C=e.onChange(()=>{l(e.projection()),p(e.onlineIds());}),U=e.onStatusChange(c),Ve=e.onHostChange(wt=>{let Ur=e.projection().participants.find(Hr=>Hr.id===wt),Br=wt===t?"You are now the host":`${Ur?.displayName||"Unknown"} is now the host`;ge.show(Br);}),rn=setInterval(()=>{p(e.onlineIds());let wt=e.projection(),yt=te(wt);yt?.timerStartedAt!==void 0&&yt.revealedAt===void 0?E(Date.now()-yt.timerStartedAt):E(void 0);},1e3);return ()=>{C(),U(),Ve(),clearInterval(rn);}},[e,t,ge.show]),useInput(C=>{(C==="q"||C==="Q")&&N(true);},{isActive:!R&&!v&&!w&&!pe&&!O&&!ve&&!Te&&!St}),useInput((C,U)=>{C==="y"||C==="Y"?(e.disconnect(),a()):(C==="n"||C==="N"||U.escape)&&N(false);},{isActive:v});let Ee=hs(s),Ce=te(s),ke=s.settings.hostParticipantId===t,xt=s.participants.find(C=>C.id===t),tt=Pe(xt??{}),x=useCallback(()=>{let C=Lt(Ge(s));_(C.title),Z(C.agendaItemId),D(true);},[s]),ee=useCallback(C=>{D(false),_(""),T(yn(C));let U=Lt(Ge(s));J(U.ticketId),oe(true);},[s]),cr=useCallback(()=>{D(false),_(""),T(void 0),Z(void 0);},[]),lr=useCallback(C=>{oe(false),J("");let[U,Ve,rn]=Ro(I,C,Q);e.newRound(U,Ve,rn),T(void 0),Z(void 0);},[e,I,Q]),ur=useCallback(()=>{oe(false),J(""),T(void 0),Z(void 0);},[]),pr=useCallback(()=>{let C=e.current();!C||C.revealedAt===void 0||(Qe(C.id),L(C.title??""),F(true));},[e]),mr=useCallback(C=>{let U=z;if(F(false),Qe(null),!U)return;let Ve=C.trim();Ve!==""&&e.updateRoundDescriptor(U,{title:Ve});},[e,z]),fr=useCallback(()=>{F(false),Qe(null);},[]),gr=useCallback(C=>{e.vote(C);},[e]),hr=useCallback(()=>{e.unvote();},[e]),Sr=useCallback(()=>{e.reveal();},[e]),xr=useCallback(()=>{e.skip();},[e]),wr=useCallback(()=>{let C=Lt(Ge(s));_(C.title),Z(C.agendaItemId),D(true);},[s]),yr=useCallback(()=>{e.revote();},[e]),$n=useCallback(()=>{e.toggleRole();},[e]),vr=useCallback(C=>{e.updateName(C);},[e]),Cr=useCallback(C=>{e.updateScale(C);},[e]),Ir=useCallback(C=>{e.updateDisplayName(C),y(C);},[e]),br=useCallback(async(C,U)=>{await e.updateAccess(C,U),m(C);},[e]),Ar=useCallback(C=>{try{e.handoffHost(C);}catch(U){console.error(`Handoff failed: ${U instanceof Error?U.message:String(U)}`);}},[e]),Un=useCallback(()=>{A(true);},[]),Tr=useCallback(()=>{A(false);},[]),Rr=useCallback(()=>{e.endSessionForEveryone();},[e]),Bn=useCallback(async C=>{let U=C==="code"?Ut(e.roomCode):C==="url"?Bt(e.roomCode):Ht(e.roomCode);try{await Qo.write(U),ie.show("Copied!");}catch{ie.show(`Copy failed \u2014 ${U}`);}},[e.roomCode,ie]),on=s.rounds.filter(C=>W(C)!==null),Er=on.length>0?on.at(-1):null,kr=on.length>0,Nr=useCallback(()=>_o(s,C=>Qo.write(C),me.show),[s,me.show]),Pr=useCallback(()=>{je(""),Ze(true);},[]),Dr=useCallback(C=>{Ze(false),je("");let U=C.trim()===""?void 0:C.trim();Re(U),_e(""),ye(true);},[]),Or=useCallback(()=>{Ze(false),je(""),Re(void 0);},[]),Mr=useCallback(C=>{ye(false),_e("");let U=C.trim()===""?void 0:C.trim();if(!Fe&&!U){Re(void 0);return}Et(e.doc,{...Fe!==void 0&&{title:Fe},...U!==void 0&&{ticketId:U},createdAt:Date.now()}),Re(void 0);},[e.doc,Fe]),$r=useCallback(()=>{ye(false),_e(""),Re(void 0);},[]);return jsxs(Box,{flexDirection:"column",children:[jsx(No,{roomCode:e.roomCode,sessionName:s.settings.name,status:u,isHost:ke}),ge.notice&&jsx(Box,{paddingX:1,children:jsx(Text,{color:"yellow",children:ge.notice})}),ie.notice&&jsx(Box,{paddingX:1,children:jsx(Text,{color:ie.notice.startsWith("Copy failed")?"red":"green",children:ie.notice})}),me.notice&&jsx(Box,{paddingX:1,children:jsx(Text,{color:me.notice.startsWith("Clipboard write failed")?"red":"green",children:me.notice})}),R?jsx(Ho,{sessionName:s.settings.name,displayName:f,currentScale:s.settings.defaultScale,accessMode:H,presetOverrides:r,customScales:i,isHost:ke,onChangeName:vr,onChangeScale:Cr,onChangeDisplayName:Ir,onChangeAccess:br,onClose:Tr}):Ee==="lobby"?jsx(Go,{projection:s,onlineIds:d,isHost:ke,participantId:t,rounds:s.rounds,currentRound:Er,settingsOpen:R,onStartRound:x,onNewRound:wr,roundTitlePromptActive:w,roundTitleInput:S,onRoundTitleChange:_,onRoundTitleSubmit:ee,onRoundTitleCancel:cr,roundTicketIdPromptActive:pe,roundTicketIdInput:re,onRoundTicketIdChange:J,onRoundTicketIdSubmit:lr,onRoundTicketIdCancel:ur,onRevote:yr,onOpenSettings:Un,onHandoffHost:Ar,onEndSession:Rr,onShare:Bn,shareOpen:ve,onSetShareOpen:et,roomCode:e.roomCode,confirmingQuit:v,myRole:tt,onToggleRole:$n,descriptorPromptActive:O,descriptorInput:M,onDescriptorChange:L,onDescriptorSubmit:mr,onDescriptorCancel:fr,onEditDescriptor:pr,canExport:kr,onExportResults:Nr,onAgendaAdd:Pr,agendaAddPromptActive:Te,agendaAddTitleInput:tn,onAgendaAddTitleChange:je,onAgendaAddTitleSubmit:Dr,onAgendaAddTitleCancel:Or,agendaAddTicketIdPromptActive:St,agendaAddTicketIdInput:nn,onAgendaAddTicketIdChange:_e,onAgendaAddTicketIdSubmit:Mr,onAgendaAddTicketIdCancel:$r}):Ee==="voting"&&Ce?jsx(zo,{projection:s,round:Ce,onlineIds:d,isHost:ke,myId:t,myRole:tt,elapsedMs:b,onVote:gr,onClearVote:hr,onReveal:Sr,onSkip:xr,onToggleRole:$n,onShare:Bn,onSetShareOpen:et,shareOpen:ve,settingsOpen:R,onOpenSettings:Un,roomCode:e.roomCode,confirmingQuit:v}):null,v&&jsx(Box,{children:jsx(Text,{dimColor:true,children:"Leave session? y/n"})})]})}function Zo({presetOverrides:e,customScales:t}){let{exit:n}=useApp(),[o,r]=useState("main-menu"),[i,a]=useState(Ne()),[s,l]=useState(i.displayName??""),[u,c]=useState(i.relayUrl??""),[d,p]=useState(i.defaultSessionName??""),[b,E]=useState(t??[]),[R,A]=useState(e??{});useInput(I=>{(I==="q"||I==="Q")&&n();},{isActive:o==="main-menu"});let H=useMemo(()=>Pt(R,b),[R,b]),m=i.defaultScale,f=m?H.find(I=>I.id===m):void 0,y=[{label:"Display name",value:"display-name",detail:`[${i.displayName??"(none)"}]`},{label:"Relay URL",value:"relay-url",detail:`[${i.relayUrl??"(none)"}]`},{label:"Default scale",value:"default-scale",detail:`[${f?Me(f.id,b):"(none)"}]`},{label:"Default session name",value:"default-session-name",detail:`[${i.defaultSessionName??"(none)"}]`},{label:"Default password",value:"default-password",detail:`[${i.defaultPassword?"on":"off"}]`}];function v(I){I==="display-name"?(l(i.displayName??""),r("editing-display-name")):I==="relay-url"?(c(i.relayUrl??""),r("editing-relay-url")):I==="default-scale"?r("picking-scale"):I==="default-session-name"?(p(i.defaultSessionName??""),r("editing-session-name")):I==="default-password"&&r("picking-default-password");}function N(I){let T=I.trim();if(T.length>0){let O={...i,displayName:T};a(O),G({displayName:T});}r("main-menu");}function w(I){let T=I.trim();if(T.length>0){let O={...i,relayUrl:T};a(O),G({relayUrl:T});}r("main-menu");}function D(I){let T=I.trim(),O=T.length>0?{...i,defaultSessionName:T}:{...i};T.length===0?(delete O.defaultSessionName,a(O),ot({defaultSessionName:""})):(a(O),G({defaultSessionName:T})),r("main-menu");}function S(I){let T=I.length>0?{...i,defaultScale:I}:{...i};I.length===0?(delete T.defaultScale,a(T),ot({defaultScale:""})):(a(T),G({defaultScale:I})),r("main-menu");}function _(I,T){let O={...R};T.length===0?delete O[I]:O[I]=T,A(O),G({presetOverrides:Object.keys(O).length>0?O:void 0});}function pe(I){let T=I==="on",O={...i,defaultPassword:T};a(O),G({defaultPassword:T}),r("main-menu");}function oe(I,T){let O=`custom-${randomUUID()}`,F=[...b,{id:O,label:I,cards:T}];E(F),a({...i,customScales:F}),G({customScales:F});}function re(I,T,O){let F=b.map(M=>M.id===I?{id:I,label:T,cards:O}:M);E(F),a({...i,customScales:F}),G({customScales:F});}function J(I){let T=b.filter(F=>F.id!==I);E(T);let O={...i,customScales:T};i.defaultScale===I?(O.defaultScale="fibonacci",G({customScales:T,defaultScale:"fibonacci"})):G({customScales:T}),a(O);}if(o==="main-menu")return jsx(he,{title:"\u2500\u2500 Config Settings \u2500\u2500",items:y,onSelect:v,onClose:()=>n()});if(o==="editing-display-name")return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Text,{children:"Display name: "}),jsx(Y,{value:s,onChange:l,onSubmit:N,onCancel:()=>r("main-menu"),placeholder:"(required)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]});if(o==="editing-relay-url")return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Text,{children:"Relay URL: "}),jsx(Y,{value:u,onChange:c,onSubmit:w,onCancel:()=>r("main-menu"),placeholder:"(required)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]});if(o==="editing-session-name")return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Text,{children:"Default session name: "}),jsx(Y,{value:d,onChange:p,onSubmit:D,onCancel:()=>r("main-menu"),placeholder:"(leave empty to clear)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]});if(o==="picking-scale"){let I=[{id:"",cards:[]},...H];return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Ft,{scales:I,selectedScaleId:m??"",presetOverrides:R,customScales:b,onSelect:S,onOverrideChange:_,onCustomScaleCreate:oe,onCustomScaleEdit:re,onCustomScaleDelete:J,onClose:()=>r("main-menu"),showNoneOption:true})]})}if(o==="picking-default-password"){let I=[{label:"On",value:"on",detail:i.defaultPassword?"[current]":void 0},{label:"Off",value:"off",detail:i.defaultPassword?void 0:"[current]"}];return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(he,{title:"Default password:",items:I,onSelect:pe,onClose:()=>r("main-menu")})]})}return jsx(Box,{})}var Is={pending:"\u2022",consumed:"\u2713",skipped:"~",cancelled:"\u2717"};function bs(e){let t=Is[e.state]??"?",n=[];e.ticketId&&n.push(`[${e.ticketId}]`),e.title&&n.push(e.title);let o=n.join(" ")||e.id;return `${t} ${o}`}async function gt(e){let t=new De.Doc,n=new Awareness(t);Ye(t,{participantId:e.participantId,displayName:e.displayName}),n.setLocalStateField("participantId",e.participantId);let o=We({doc:t,awareness:n,roomCode:e.roomCode,roomUuid:e.roomUuid,participantId:e.participantId,relayUrl:e.relayUrl,...e.passwordHash!==void 0&&{passwordHash:e.passwordHash}});return await new Promise(r=>{let i=setTimeout(r,2e3),a=o.onStatusChange(s=>{s==="connected"&&setTimeout(()=>{clearTimeout(i),a(),r();},200);});}),{doc:t,disconnect:()=>o.disconnect()}}async function ht(){let e=Dt();return e||(console.error("No active session. Join a room first with: hnch join <code>"),process.exit(1)),{roomCode:e.roomCode,roomUuid:e.roomUuid,...e.passwordHash!==void 0&&{passwordHash:e.passwordHash}}}async function tr(e){!e.title?.trim()&&!e.ticket?.trim()&&(console.error("At least one of --title or --ticket is required"),process.exit(1));let t=await se(),n=await ht();try{await de(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await gt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{let i=Et(o,{...e.title?.trim()?{title:e.title.trim()}:{},...e.ticket?.trim()?{ticketId:e.ticket.trim()}:{},...e.description?.trim()?{description:e.description.trim()}:{},createdAt:Date.now()});await new Promise(a=>{setTimeout(a,300);}),console.log(`Added agenda item: ${i}`);}finally{r();}}async function nr(){let e=await se(),t=await ht();try{await de(e.relayUrl,t.roomCode);}catch{console.error(`Room ${t.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:n,disconnect:o}=await gt({relayUrl:e.relayUrl,participantId:e.participantId,displayName:e.displayName,roomCode:t.roomCode,roomUuid:t.roomUuid,...t.passwordHash!==void 0&&{passwordHash:t.passwordHash}});try{let i=q(n).agenda;if(i.length===0){console.log("No agenda items.");return}i.forEach((a,s)=>{console.log(`${String(s+1).padStart(2)}. ${bs(a)}`);});}finally{o();}}async function or(e){let t=await se(),n=await ht();try{await de(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await gt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{kt(o,e.id,"skipped",{timestamp:Date.now()}),await new Promise(i=>{setTimeout(i,300);}),console.log(`Skipped agenda item: ${e.id}`);}catch(i){console.error(`Skip failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1);}finally{r();}}async function rr(e){let t=await se(),n=await ht();try{await de(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await gt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{kt(o,e.id,"cancelled",{timestamp:Date.now()}),await new Promise(i=>{setTimeout(i,300);}),console.log(`Cancelled agenda item: ${e.id}`);}catch(i){console.error(`Cancel failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1);}finally{r();}}async function ir(e){let t=await se(),n=await ht();try{await de(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await gt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{ro(o,e.id,e.before,e.after),await new Promise(i=>{setTimeout(i,300);}),console.log(`Reordered agenda item: ${e.id}`);}catch(i){console.error(`Move failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1);}finally{r();}}async function Mn(){return new Promise(e=>{let t=createInterface({input:process.stdin,output:process.stderr});process.stderr.write("Password: "),t.question("",n=>{t.close(),e(n);});})}async function Es(e){let t=await se(),n=e.scale??t.defaultScale??"fibonacci",o=e.name??t.defaultSessionName,r=e.password??t.defaultPassword??false,i;r&&(i=await Mn());let a=Nt(n,t.presetOverrides,t.customScales);if(!a){let d=Object.keys(ae).join(", ");console.error(`Unknown or fully-disabled scale: "${n}". Builtin IDs: ${d}`),process.exit(1);}let s=await Io({participantId:t.participantId,displayName:t.displayName,relayUrl:t.relayUrl,sessionName:o,password:i,defaultScale:a}),l;i&&(l=await Oe(i,s.roomUuid)),Ot({roomCode:s.roomCode,roomUuid:s.roomUuid,passwordHash:l,lastSeenAt:Date.now()}),console.error(`Room created: ${s.roomCode}`),console.error(`Share: hnch join ${s.roomCode}`),console.error("");let{waitUntilExit:u,unmount:c}=render(Wt.createElement(Qt,{session:s,participantId:t.participantId,displayName:t.displayName,accessMode:i?"password":"open",presetOverrides:t.presetOverrides,customScales:t.customScales}));$t({doc:s.doc,localParticipantId:t.participantId,onEnded:async d=>{console.error(d.isLocal?"Session ended.":`Session ended by ${d.hostName}.`),c();try{await V();}catch(p){console.error(`Failed to clear cached session: ${p instanceof Error?p.message:String(p)}`);}s.disconnect(),process.exit(0);}}),await u(),s.disconnect(),V(),process.exit(0);}async function ks(e){let t=await se(),n=Ao(e.code);n===null&&(console.error("invalid room code"),process.exit(1));let o;e.password&&(o=await Mn());let r=await de(t.relayUrl,n),i;r.accessMode==="password"&&!e.password?i=await Mn():e.password&&(i=o);let a,s=false,l=await bo({participantId:t.participantId,displayName:t.displayName,relayUrl:t.relayUrl,roomCode:n,password:i,onRejection(d){if(d==="unknown-room"){Mt({clearLastSession:V,logger:console,exit:process.exit});return}d==="room-full"&&(s=true,a?.());}}),u;i&&(u=await Oe(i,l.roomUuid)),Ot({roomCode:l.roomCode,roomUuid:l.roomUuid,passwordHash:u,lastSeenAt:Date.now()}),console.error(`Joined room: ${l.roomCode}`),console.error("");let c=render(Wt.createElement(Qt,{session:l,participantId:t.participantId,displayName:t.displayName,accessMode:r.accessMode,presetOverrides:t.presetOverrides,customScales:t.customScales}));a=c.unmount,$t({doc:l.doc,localParticipantId:t.participantId,onEnded:async d=>{console.error(d.isLocal?"Session ended.":`Session ended by ${d.hostName}.`),a?.();try{await V();}catch(p){console.error(`Failed to clear cached session: ${p instanceof Error?p.message:String(p)}`);}l.disconnect(),process.exit(0);}}),await c.waitUntilExit(),s&&(console.error("This room is full (max 20 participants)."),l.disconnect(),V(),process.exit(1)),l.disconnect(),V(),process.exit(0);}async function Ns(){let e=await se(),t=Dt();t||(console.error("No recent session to resume."),process.exit(0));let n;try{n=await de(e.relayUrl,t.roomCode);}catch(c){if((c instanceof Error?c.message:String(c)).includes("Room not found"))return await Mt({clearLastSession:V,logger:console,exit:process.exit});console.error("Could not reach relay \u2014 try again later."),process.exit(0);}n.accessMode==="password"&&!t.passwordHash&&(console.error(`Password changed \u2014 rejoin with: hnch join ${t.roomCode} --password`),V(),process.exit(0)),console.error(`Rejoining room ${t.roomCode}\u2026`),console.error("");let o=new De.Doc,r=new Awareness(o);Ye(o,{participantId:e.participantId,displayName:e.displayName}),r.setLocalStateField("participantId",e.participantId);let i=false,a=false,s,l=We({doc:o,awareness:r,roomCode:t.roomCode,roomUuid:t.roomUuid,participantId:e.participantId,relayUrl:e.relayUrl,passwordHash:t.passwordHash,onRejection(c){if(c==="unknown-room"){Mt({clearLastSession:V,logger:console,exit:process.exit});return}c==="wrong-password"&&(i=true,s?.()),c==="room-full"&&(a=true,s?.());}});Ot({roomCode:l.roomCode,roomUuid:l.roomUuid,passwordHash:t.passwordHash,lastSeenAt:Date.now()});let u=render(Wt.createElement(Qt,{session:l,participantId:e.participantId,displayName:e.displayName,accessMode:n.accessMode,presetOverrides:e.presetOverrides,customScales:e.customScales}));s=u.unmount,$t({doc:l.doc,localParticipantId:e.participantId,onEnded:async c=>{console.error(c.isLocal?"Session ended.":`Session ended by ${c.hostName}.`),s?.();try{await V();}catch(d){console.error(`Failed to clear cached session: ${d instanceof Error?d.message:String(d)}`);}l.disconnect(),process.exit(0);}}),await u.waitUntilExit(),a&&(console.error("This room is full (max 20 participants)."),V(),process.exit(1)),i&&(console.error(`Password changed \u2014 rejoin with: hnch join ${t.roomCode} --password`),V(),process.exit(0)),l.disconnect(),V(),process.exit(0);}async function Ps(e){if(!(e.name!==void 0||e.relayUrl!==void 0||e.scale!==void 0||e.sessionName!==void 0||e.password!==void 0)){let o=await se(),{waitUntilExit:r}=render(Wt.createElement(Zo,{presetOverrides:o.presetOverrides,customScales:o.customScales}));await r(),process.exit(0);}let n={};if(e.name!==void 0&&(n.displayName=e.name),e.relayUrl!==void 0&&(n.relayUrl=e.relayUrl),e.scale!==void 0){if(e.scale!==""){let o=Ne();if(!Nt(e.scale,o.presetOverrides,o.customScales)){console.error(`Unknown scale: "${e.scale}". Builtin IDs: ${Object.keys(ae).join(", ")}`);return}}n.defaultScale=e.scale;}e.sessionName!==void 0&&(n.defaultSessionName=e.sessionName),e.password!==void 0&&(n.defaultPassword=e.password),ot(n),console.log("Config updated.");}var dr=As(hideBin(process.argv)).scriptName("hnch").usage("$0 <command> \u2014 terminal pointing poker").command("create","Create a new room",e=>e.option("name",{type:"string",describe:"Session name"}).option("password",{type:"boolean",describe:"Protect room with a password"}).option("scale",{type:"string",describe:"Estimation scale ID (fibonacci, t-shirt, powers-of-2, linear, risk, or custom-<id>)"}),e=>{Es(e).catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("join <code>","Join an existing room",e=>e.positional("code",{type:"string",demandOption:true,describe:"6-character room code"}).option("password",{type:"boolean",describe:"Room requires a password",default:false}),e=>{ks(e).catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("resume","Rejoin your last session",e=>e,()=>{Ns().catch(e=>{console.error(e instanceof Error?e.message:e),process.exit(1);});}).command("config","View or update CLI config",e=>e.option("name",{type:"string",describe:"Set display name"}).option("relay-url",{type:"string",describe:"Set relay URL"}).option("scale",{type:"string",describe:"Set default estimation scale ID (empty string clears)"}).option("session-name",{type:"string",describe:"Set default session name (empty string clears)"}).option("password",{type:"boolean",describe:"Set default password prompt on (--password) or off (--no-password)"}),e=>{Ps(e).catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("agenda","Manage the pre-session story agenda",e=>e.command("add","Add an agenda item",t=>t.option("title",{type:"string",describe:"Story title"}).option("ticket",{type:"string",describe:"Issue tracker reference (e.g. PROJ-123)"}).option("description",{type:"string",describe:"Story description"}).check(n=>{if(!n.title?.trim()&&!n.ticket?.trim())throw new Error("At least one of --title or --ticket is required");return true}),t=>{tr(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).command("list","List agenda items in order",t=>t,()=>{nr().catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("skip <id>","Mark an agenda item as skipped",t=>t.positional("id",{type:"string",demandOption:true,describe:"Agenda item ID"}),t=>{or(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).command("cancel <id>","Soft-delete (cancel) an agenda item",t=>t.positional("id",{type:"string",demandOption:true,describe:"Agenda item ID"}),t=>{rr(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).command("mv <id>","Reorder an agenda item (--before <id> | --after <id>)",t=>t.positional("id",{type:"string",demandOption:true,describe:"Agenda item ID to move"}).option("before",{type:"string",describe:"sortKey of item that should come before the moved item"}).option("after",{type:"string",describe:"sortKey of item that should come after the moved item"}).check(n=>{if(n.before!==void 0&&n.after!==void 0)throw new Error("--before and --after are mutually exclusive");if(n.before===void 0&&n.after===void 0)throw new Error("Specify either --before <id> or --after <id>");return true}),t=>{ir(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).demandCommand(1,"Specify an agenda subcommand: add, list, skip, cancel, mv").strict().help(),()=>{}).demandCommand(1,"Specify a command: create, join, resume, config, or agenda").strict().help(),On=hideBin(process.argv);(On.length===0||On.length===1&&On[0]==="--")&&(dr.showHelp(),process.exit(0));dr.parse();
|
|
18
|
+
`}function $t(e,t,n){if(e.startsWith("custom-")){let r=(n??[]).find(i=>i.id===e);return r?{id:r.id,cards:r.cards}:void 0}let o=de[e];if(o){let r=(t??{})[e]??[];if(r.length===0)return o;let i=o.cards.filter((s,a)=>!r.includes(a));return i.length===0?void 0:{id:e,cards:i}}}function Ut(e,t){let n=Object.keys(de).map(r=>$t(r,e,t)).filter(r=>r!==void 0),o=(t??[]).map(r=>({id:r.id,cards:r.cards}));return [...n,...o]}function He(e,t){if(e.startsWith("custom-")){let n=(t??[]).find(o=>o.id===e);if(n&&n.label.trim().length>0)return n.label}return ro(e)}var zi="https://hnch.dev";function lt(){let t=process.env.XDG_CONFIG_HOME||join(homedir(),".config");return join(t,"hnch")}function In(){return join(lt(),"config.json")}function Lo(){let e=lt();existsSync(e)||mkdirSync(e,{recursive:true});}function Le(){let e=In();if(!existsSync(e))return {};try{return JSON.parse(readFileSync(e,"utf-8"))}catch{return {}}}function V(e){Lo();let n={...Le(),...e};writeFileSync(In(),JSON.stringify(n,null,2)+`
|
|
19
|
+
`,"utf-8");}async function Xi(e){let t=createInterface({input:process.stdin,output:process.stderr});return new Promise(n=>{t.question(e,o=>{t.close(),n(o.trim());});})}function Qi(e){return e.startsWith("wss://")?"https://"+e.slice(6):e.startsWith("ws://")?"http://"+e.slice(5):e}async function ce(){let e=Le(),t=false;if(e.participantId||(e.participantId=randomUUID(),t=true),!e.displayName){let o=await Xi("Enter your display name: ");e.displayName=o||`user-${e.participantId.slice(0,6)}`,t=true;}e.relayUrl||(e.relayUrl=zi,t=true),(!e.avatarColor||Me(e.avatarColor)===null)&&(e.avatarColor=so(e.participantId),t=true),t&&V(e);let n=process.env.HNCH_RELAY_URL||e.relayUrl;return n=Qi(n),{participantId:e.participantId,displayName:e.displayName,relayUrl:n,defaultScale:e.defaultScale,defaultSessionName:e.defaultSessionName,defaultPassword:e.defaultPassword,presetOverrides:e.presetOverrides,customScales:e.customScales,avatarColor:e.avatarColor}}function ut(e){Lo();let n={...Le()};for(let[o,r]of Object.entries(e))r===""?delete n[o]:r!==void 0&&(n[o]=r);writeFileSync(In(),JSON.stringify(n,null,2)+`
|
|
20
|
+
`,"utf-8");}async function jo(e,t){let n=await fetch(`${e}/rooms`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});if(!n.ok)throw new Error(`POST /rooms failed: ${n.status}`);return await n.json()}async function le(e,t){let n=await fetch(`${e}/rooms/${encodeURIComponent(t)}`);if(n.status===404){let o=await n.json().catch(()=>null);throw new Error(`Room not found: ${o?.reason??"unknown-room"}`)}if(!n.ok)throw new Error(`GET /rooms/:code failed: ${n.status}`);return await n.json()}async function Rn(e,t,n){let o=await fetch(`${e}/rooms/${t}/access`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({passwordHash:n})});if(!o.ok)throw new Error(`PATCH /rooms/:uuid/access failed: ${o.status}`)}function _o(e){let n=`${e.wsBaseUrl.replace(/^http/,"ws")}/ws`,o={did:e.deviceId};e.passwordHash!==void 0&&(o.pw=e.passwordHash);let r=new WebsocketProvider(n,e.roomUuid,e.doc,{params:o,connect:true,...e.awareness!==void 0&&{awareness:e.awareness},WebSocketPolyfill:es}),i=u=>{e.onStatusChange?.(u.status);},s=u=>{if(u===null)return;let c=Qn.get(u.code);c!==void 0&&(e.onRejection?.(c),r.shouldConnect=false,r.disconnect());};r.on("status",i),r.on("connection-close",s);let a=false,d=e.passwordHash;return {doc:e.doc,awareness:r.awareness,updateCredentials(u){if(u.passwordHash===d)return;d=u.passwordHash??void 0,r.shouldConnect=false,r.disconnect();let l={did:r.params.did??""};d!==void 0&&(l.pw=d),r.params=l,r.connect();},disconnect(){a||(a=true,r.off("status",i),r.off("connection-close",s),r.shouldConnect=false,r.disconnect(),r.destroy());}}}function Fo(e,t,n){let o=null,r=null;function i(){let u=new Set;return t.getStates().forEach(c=>{let l=c.participantId;typeof l=="string"&&u.add(l);}),u}function s(){r!==null&&(clearTimeout(r),r=null),o=null;}function a(){r=null;let u=o;o=null;let c=Co(j(e),i(),n,u);c.promote&&Qe(e,{hostParticipantId:c.winner});}function d(){let u=vo(j(e),i(),{missingHostId:o});switch(u.kind){case "cancel":s();break;case "start-debounce":s(),o=u.hostId,r=setTimeout(a,xo);break;}}return t.on("change",d),e.getMap(Pt).observe(d),d(),{stop(){s(),t.off("change",d),e.getMap(Pt).unobserve(d);}}}async function Jo(e){let t,n=await jo(e.relayUrl);e.password&&(t=await Be(e.password,n.uuid),await Rn(e.relayUrl,n.uuid,t));let o=new $e.Doc,r=new Awareness(o),i=Date.now();return co(o,{roomUuid:n.uuid,createdAt:i,participantId:e.participantId,displayName:e.displayName,defaultScale:e.defaultScale??Rt,...e.sessionName!==void 0&&{sessionName:e.sessionName},...e.avatarColor!==void 0&&{avatarColor:e.avatarColor}}),r.setLocalStateField("participantId",e.participantId),et({doc:o,awareness:r,roomCode:n.code,roomUuid:n.uuid,participantId:e.participantId,relayUrl:e.relayUrl,passwordHash:t})}async function Wo(e){let t=await le(e.relayUrl,e.roomCode),n;if(t.accessMode==="password"){if(!e.password)throw new Error("Room requires a password");n=await Be(e.password,t.uuid);}let o=new $e.Doc,r=new Awareness(o);return Xe(o,{participantId:e.participantId,displayName:e.displayName,...e.avatarColor!==void 0&&{avatarColor:e.avatarColor}}),r.setLocalStateField("participantId",e.participantId),et({doc:o,awareness:r,roomCode:e.roomCode,roomUuid:t.uuid,participantId:e.participantId,relayUrl:e.relayUrl,passwordHash:n,onRejection:e.onRejection})}function et(e){let{doc:t,awareness:n,participantId:o,relayUrl:r,roomUuid:i}=e,s=new Set,a=new Set,d=new Set,u=_o({wsBaseUrl:e.relayUrl,roomUuid:e.roomUuid,doc:t,deviceId:o,passwordHash:e.passwordHash,awareness:n,onStatusChange(f){s.forEach(h=>h(f));},onRejection(f){console.error(`Connection rejected: ${f}`),e.onRejection?.(f);}}),c=Fo(t,n,o),l=()=>{a.forEach(f=>f());};t.getMap("meta").observeDeep(l),t.getMap("settings").observeDeep(l),t.getMap("participants").observeDeep(l),t.getArray("rounds").observeDeep(l);function p(){let f=new Set;return n.getStates().forEach(h=>{let b=h.participantId;typeof b=="string"&&f.add(b);}),f}let I=new Set,N=setInterval(()=>{let f=j(t),h=q(f);!h||I.has(h.id)||io(h,f.participants,p())&&(I.add(h.id),hn(t,h.id,Date.now()));},250),R=t.getMap("settings").get("hostParticipantId"),T=()=>{let f=t.getMap("settings").get("hostParticipantId");f!==R&&f!==void 0&&d.forEach(h=>h(f)),R=f;};t.getMap("settings").observe(T);let U=false;return {doc:t,awareness:n,roomCode:e.roomCode,roomUuid:e.roomUuid,projection(){return j(t)},current(){return q(j(t))},isHost(){return j(t).settings.hostParticipantId===o},onlineIds:p,vote(f){let h=q(j(t));h&&uo(t,h.id,o,f);},unvote(){let f=q(j(t));f&&po(t,f.id,o);},reveal(){let f=q(j(t));f&&hn(t,f.id,Date.now());},skip(){let f=q(j(t));f&&mo(t,f.id,Date.now());},newRound(f,h,b){let y=randomUUID(),O=Date.now();return gn(t,{id:y,createdAt:O,createdBy:o,...f!==void 0&&{title:f},...h!==void 0&&{ticketId:h},...b!==void 0&&{agendaItemId:b}}),y},discardCurrentRound(){let f=q(j(t));f&&go(t,f.id,Date.now(),o);},revote(){let f=q(j(t)),h=randomUUID();return gn(t,{id:h,createdAt:Date.now(),createdBy:o,...f?.id!==void 0&&{parentRoundId:f.id},...f?.title!==void 0&&{title:f.title},...f?.description!==void 0&&{description:f.description},...f?.ticketId!==void 0&&{ticketId:f.ticketId},...f?.agendaItemId!==void 0&&{agendaItemId:f.agendaItemId}}),h},updateRoundDescriptor(f,h){lo(t,f,h);},updateName(f){Qe(t,{name:f});},updateScale(f){Qe(t,{defaultScale:f});},updateDisplayName(f){let y=j(t).participants.find(O=>O.id===o)?.joinedAt??Date.now();mn(t,o,{displayName:f,joinedAt:y});},async updateAccess(f,h){let b=null;if(f==="password"){if(!h)throw new Error("Password required for password mode");b=await Be(h,i);}await Rn(r,i,b),u.updateCredentials({passwordHash:b});},handoffHost(f){if(!this.isHost())throw new Error("Only the current host can hand off");if(!p().has(f))throw new Error("Target participant is not online");if(!j(t).participants.some(O=>O.id===f))throw new Error("Target participant does not exist");Qe(t,{hostParticipantId:f});},toggleRole(){let h=j(t).participants.find(C=>C.id===o),y=Ie(h??{})==="viewer"?"voter":"viewer",O=h?.joinedAt??Date.now();mn(t,o,{displayName:h?.displayName??"",joinedAt:O,role:y});},endSessionForEveryone(){if(!this.isHost())throw new Error("Only the current host can end the session");ho(t);},onChange(f){return a.add(f),()=>a.delete(f)},onStatusChange(f){return s.add(f),()=>s.delete(f)},onHostChange(f){return d.add(f),()=>d.delete(f)},disconnect(){U||(U=true,clearInterval(N),c.stop(),t.getMap("meta").unobserveDeep(l),t.getMap("settings").unobserveDeep(l),t.getMap("settings").unobserve(T),t.getMap("participants").unobserveDeep(l),t.getArray("rounds").unobserveDeep(l),u.disconnect());}}}function Ko(e){let t=yn(e);return t===""?null:t}function je(){return join(lt(),"last-session.json")}function is(e,t){let n=lt();mkdirSync(n,{recursive:true,mode:448}),chmodSync(n,448),writeFileSync(e,t,{encoding:"utf-8",mode:384}),chmodSync(e,384);}function En(){let e=je();try{unlinkSync(e);}catch(t){if(t.code!=="ENOENT")throw t}}function kn(){let e=je();if(!existsSync(e))return {};try{let t=JSON.parse(readFileSync(e,"utf-8"));return {...xn(t).entries}}catch{return {}}}function Nn(e){let t={version:2,entries:e};is(je(),JSON.stringify(t,null,2)+`
|
|
21
|
+
`);}function Ht(e){let t=Date.now();if(!existsSync(je()))return [];let n;try{n=JSON.parse(readFileSync(je(),"utf-8"));}catch{return []}let o=xn(n),r=Io(o,t),i=Object.values(r.entries);return i.length===0?(En(),[]):i.toSorted((s,a)=>a.lastSeenAt-s.lastSeenAt)}function ss(e,t){return e!==void 0?{passwordHash:e}:t!==void 0?{passwordHash:t}:{}}function Pn(e){let t=Date.now(),n=kn(),o=n[e.roomUuid];n[e.roomUuid]={roomCode:e.roomCode,roomUuid:e.roomUuid,lastSeenAt:e.lastSeenAt??t,...ss(e.passwordHash,o?.passwordHash)};let r=Object.keys(n);if(r.length>5){let i=r.toSorted((s,a)=>(n[s]?.lastSeenAt??0)-(n[a]?.lastSeenAt??0)).slice(0,r.length-5);for(let s of i)delete n[s];}Nn(n);}function pt(e){if(!existsSync(je()))return;let t=kn();if(delete t[e],Object.keys(t).length===0){En();return}Nn(t);}function as(){En();}function Dn(e){if(!existsSync(je()))return;let t=kn(),n=t[e];if(!n)return;let{passwordHash:o,...r}=n;t[e]=r,Nn(t);}function On(e){Pn(e);}function Se(){as();}async function Lt(e){let t=true;try{await e.clearLastSession();}catch(n){t=false,e.logger.error(`Failed to clear cached session: ${n instanceof Error?n.message:String(n)}`);}return t?e.logger.error("Session expired (room no longer exists). Cached session cleared."):e.logger.error("Session expired. Could not delete ~/.config/hnch/last-session.json \u2014 please remove it manually."),e.exit(1)}function jt(e){let t=e.doc.getMap("meta"),n=null,o=false;function r(){if(o)return;let i=t.get("sessionEndedAt");if(i==null||i===n)return;n=i;let s=t.get("createdBy"),a=s===e.localParticipantId,d=e.doc.getMap("participants"),u=e.doc.getMap("settings").get("hostParticipantId")??s,c="host";if(u){let p=d.get(u)?.get("displayName");typeof p=="string"&&p.length>0&&(c=p);}setImmediate(()=>{o||e.onEnded({isLocal:a,hostName:c,timestamp:i});});}return t.observe(r),r(),()=>{o=true,t.unobserve(r);}}var ds="@xauyxau/hnch";function _t(e){return Po(e)}function Ft(e){return `${process.env.HNCH_SHARE_ORIGIN??"https://hnch.dev"}/join?code=${e}`}function Vt(e){return `npx ${ds} join ${e}`}function Mn(e){let t=e.trim();return t===""?void 0:t}function Yt(e){return e?{title:e.title??"",ticketId:e.ticketId??"",agendaItemId:e.id}:{title:"",ticketId:"",agendaItemId:void 0}}function Xo(e,t,n){return [e,Mn(t),n]}var cs={connecting:"yellow",connected:"green",disconnected:"red"};function er({roomCode:e,sessionName:t,status:n,isHost:o}){let r=t?`${e} \xB7 ${t}`:e;return jsxs(Box,{borderStyle:"single",borderColor:"gray",paddingX:1,justifyContent:"space-between",children:[jsxs(Text,{bold:true,children:["hnch \xB7 ",r]}),jsxs(Box,{gap:2,children:[o&&jsx(Text,{color:"yellow",children:"[host]"}),jsx(Text,{color:cs[n],children:n})]})]})}function me({items:e,onSelect:t,onClose:n,title:o}){if(e.length===0)return jsxs(Box,{flexDirection:"column",gap:1,children:[o&&jsx(Text,{bold:true,children:o}),jsx(Text,{dimColor:true,children:"(no items)"})]});let r=e.findIndex(a=>!a.disabled),[i,s]=useState(Math.max(r,0));return useInput((a,d)=>{if(d.upArrow)s(u=>{let c=(u-1+e.length)%e.length,l=0;for(;e[c]?.disabled&&l<e.length;)c=(c-1+e.length)%e.length,l++;return c});else if(d.downArrow)s(u=>{let c=(u+1)%e.length,l=0;for(;e[c]?.disabled&&l<e.length;)c=(c+1)%e.length,l++;return c});else if(d.return){let u=e[i];u&&!u.disabled&&t(u.value);}else d.escape&&n?.();}),jsxs(Box,{flexDirection:"column",gap:1,children:[o&&jsx(Text,{bold:true,children:o}),jsx(Box,{flexDirection:"column",children:e.map((a,d)=>{let u=d===i,c=a.disabled??false;return jsxs(Box,{gap:1,children:[jsx(Text,{...u&&{color:"cyan"},dimColor:c,children:u?">":" "}),jsx(Text,{bold:u,dimColor:c,children:a.label}),a.detail&&jsx(Text,{dimColor:true,children:a.detail})]},a.value)})}),jsx(Text,{dimColor:true,children:"\u2191\u2193 select \u23CE confirm esc close"})]})}function F({value:e,onChange:t,onSubmit:n,onCancel:o,placeholder:r,isActive:i=true,mask:s=false}){useInput((c,l)=>{l.escape?o?.():l.return?n(e):l.backspace||l.delete?t(e.slice(0,-1)):c&&!l.ctrl&&!l.meta&&t(e+c);},{isActive:i});let a=s&&e.length>0?"*".repeat(e.length):e,d=a.length>0?a:r??"",u=e.length===0&&r!==void 0;return jsxs(Text,{children:[jsx(Text,{dimColor:u,children:d}),jsx(Text,{inverse:true,children:" "})]})}function rr({mode:e,password:t,onModeChange:n,onPasswordChange:o,onClose:r}){let[i,s]=useState(e==="open"?0:1),[a,d]=useState(false);return useEffect(()=>{s(e==="open"?0:1);},[e]),useInput((u,c)=>{if(c.leftArrow)s(l=>Math.max(0,l-1));else if(c.rightArrow)s(l=>Math.min(1,l+1));else if(c.return){let l=i===0?"open":"password";l!==e&&n(l),l==="password"&&d(true);}else c.escape&&r?.();},{isActive:!a}),jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Box,{gap:1,children:["open","password"].map((u,c)=>{let l=c===i,p=u===e,I=u==="open"?"Open":"Password";return jsx(Text,{inverse:l,bold:p,...p&&{color:"cyan"},children:p?`[${I}]`:` ${I} `},u)})}),e==="password"&&jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{children:"Password: "}),jsx(F,{value:t,onChange:o,onSubmit:()=>d(false),onCancel:()=>d(false),placeholder:"(required to join)",isActive:a,mask:true}),!a&&jsx(Text,{dimColor:true,children:"\u23CE edit \u2190 \u2192 switch mode esc close"}),a&&jsx(Text,{dimColor:true,children:"\u23CE done esc cancel"})]}),e==="open"&&jsx(Text,{dimColor:true,children:"\u2190\u2192 toggle \u23CE confirm esc close"})]})}function ar({scaleId:e,cards:t,disabledIndices:n,onOverrideChange:o,onClose:r}){let i=useMemo(()=>new Set(n),[n]),[s,a]=useState(0),d=u=>{let c=new Set(i);if(c.has(u))c.delete(u);else {if(c.size>=t.length-1)return;c.add(u);}let l=Array.from(c).toSorted((p,I)=>p-I);o(e,l);};return useInput((u,c)=>{c.leftArrow?a(l=>Math.max(0,l-1)):c.rightArrow?a(l=>Math.min(t.length-1,l+1)):u===" "?d(s):(c.return||c.escape)&&r();}),jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Box,{gap:1,children:t.map((u,c)=>{let l=c===s,p=i.has(c);return jsx(Text,{inverse:l,bold:!p,...!p&&{color:"cyan"},strikethrough:p,dimColor:p,children:u},u)})}),jsx(Text,{dimColor:true,children:" \u2190\u2192 navigate space toggle \u23CE/esc done"})]})}function Fn({initialName:e="",initialCards:t=[],onSave:n,onCancel:o}){let r=e.length>0,[i,s]=useState(e),[a,d]=useState(t.length>0?t:[""]),[u,c]=useState(0),[l,p]=useState("editing-name"),[I,N]=useState(""),R=()=>{let f=i.trim();if(f.length===0||f.length>40){N("Name must be 1-40 characters");return}s(f),N(""),p("editing-cards");},T=()=>{let f=i.trim();if(f.length===0||f.length>40){N("Name must be 1-40 characters");return}let h=a.map(y=>y.trim()).filter(y=>y.length>0),b=Array.from(new Set(h));if(b.length<2){N("Need at least 2 unique non-empty cards");return}N(""),n(f,b);};return useInput((f,h)=>{if(l==="editing-cards"){if(h.leftArrow)c(b=>Math.max(0,b-1));else if(h.rightArrow)c(b=>{let y=b+1;return y>=a.length&&a.length<25?(d(O=>[...O,""]),y):Math.min(y,a.length-1)});else if(h.return)T();else if(h.escape)o();else if(h.tab)p("editing-name");else if(h.backspace){let b=a[u]||"";if(b.length===0){if(a.length>2){let y=a.filter((O,C)=>C!==u);d(y),c(Math.max(0,u-1));}}else {let y=[...a];y[u]=b.slice(0,-1),d(y);}}else if(f&&!h.ctrl&&!h.meta){let b=a[u]||"";if(b.length<10){let y=[...a];y[u]=b+f,d(y);}}}},{isActive:l==="editing-cards"}),jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:r?"\u2500\u2500 Edit Custom Scale \u2500\u2500":"\u2500\u2500 Create Custom Scale \u2500\u2500"}),jsxs(Box,{flexDirection:"column",gap:0,children:[jsx(Text,{children:"Name:"}),jsx(F,{value:i,onChange:s,onSubmit:R,onCancel:o,placeholder:"Scale name",isActive:l==="editing-name"})]}),l==="editing-cards"&&jsxs(Box,{flexDirection:"column",gap:0,children:[jsx(Text,{children:"Cards:"}),jsx(Box,{gap:1,flexWrap:"wrap",children:a.map((f,h)=>{let b=h===u;return jsx(Text,{inverse:b,...!b&&{color:"cyan"},children:f.length>0?f:"\xB7"},h)})})]}),I&&jsx(Text,{color:"red",children:I}),jsx(Text,{dimColor:true,children:l==="editing-name"?"\u23CE next esc cancel":"\u2190\u2192 navigate typing adds card bsp delete \u23CE save tab name esc cancel"})]})}function Kt({scales:e,selectedScaleId:t,presetOverrides:n,customScales:o=[],onSelect:r,onOverrideChange:i,onCustomScaleCreate:s,onCustomScaleEdit:a,onCustomScaleDelete:d,onClose:u,showNoneOption:c=false}){let[l,p]=useState(0),[I,N]=useState(null),[R,T]=useState("browsing"),[U,f]=useState(null),[h,b]=useState(null),y=s?[...e,{id:"__create-custom__",cards:[]}]:e,O=y.length;if(useInput((C,M)=>{if(R==="browsing"){if(M.escape){u();return}if(O===0)return;if(M.upArrow)p(A=>(A-1+O)%O);else if(M.downArrow)p(A=>(A+1)%O);else if(M.return){let A=y[l];if(!A)return;if(A.id==="__create-custom__"){T("creating");return}A.id in de?N(I===A.id?null:A.id):r(A.id);}else if(C===" "){let A=y[l];A&&A.id!=="__create-custom__"&&r(A.id);}else if(C==="e"||C==="E"){let A=y[l];a&&A?.id.startsWith("custom-")&&(f(A.id),T("editing"));}else if(C==="d"||C==="D"){let A=y[l];d&&A?.id.startsWith("custom-")&&(b(A.id),T("confirming-delete"));}}else R==="confirming-delete"&&(C==="y"||C==="Y"?(h&&d&&d(h),b(null),T("browsing")):(C==="n"||C==="N"||M.escape)&&(b(null),T("browsing")));},{isActive:R==="browsing"&&I===null||R==="confirming-delete"}),R==="creating")return jsx(Fn,{onSave:(C,M)=>{s&&s(C,M),T("browsing");},onCancel:()=>T("browsing")});if(R==="editing"&&U){let C=o?.find(A=>A.id===U);if(e.find(A=>A.id===U)&&C)return jsx(Fn,{initialName:C.label,initialCards:C.cards,onSave:(A,P)=>{a&&a(U,A,P),f(null),T("browsing");},onCancel:()=>{f(null),T("browsing");}})}if(R==="confirming-delete"&&h){let C=y.find(A=>A.id===h),M=C?He(C.id,o):"Unknown";return jsxs(Box,{flexDirection:"column",gap:1,children:[jsxs(Text,{children:["Delete ",M,"? "]}),jsx(Text,{children:"[y] yes [n] no esc cancel"})]})}return y.length===0?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{dimColor:true,children:"(no scales available)"}),jsx(Text,{dimColor:true,children:"esc back"})]}):jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Box,{flexDirection:"column",children:y.map((C,M)=>{let A=M===l,P=C.id===t,ue=I===C.id,ie=C.id in de,se=C.id==="__create-custom__",Y=C.cards.join(", "),X=c&&C.id==="",Q=X?"(none)":se?"[+ Create custom scale]":He(C.id,o);return jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{...A&&{color:"cyan"},children:A?">":" "}),jsx(Text,{bold:A,children:Q}),!X&&!se&&jsx(Text,{dimColor:true,children:Y}),P&&jsx(Text,{color:"cyan",children:"[current]"})]}),ue&&!X&&!se&&jsx(Box,{paddingLeft:2,children:ie?jsx(ar,{scaleId:C.id,cards:de[C.id]?.cards??[],disabledIndices:n?.[C.id]??[],onOverrideChange:i,onClose:()=>N(null)}):null})]},C.id||"none")})}),jsx(Text,{dimColor:true,children:(()=>{let C=l<y.length?y[l]:null;return C?.id.startsWith("custom-")?`\u2191\u2193 navigate space select${a?" [e] edit":""}${d?" [d] delete":""} esc back`:C&&C.id in de?"\u2191\u2193 navigate \u23CE customize space select esc back":"\u2191\u2193 navigate \u23CE/space select esc back"})()})]})}function bs(e,t){return t?[...e]:e.filter(n=>n.value==="display-name")}function dr({sessionName:e,displayName:t,currentScale:n,accessMode:o,presetOverrides:r,customScales:i,isHost:s=true,onChangeName:a,onChangeScale:d,onChangeDisplayName:u,onChangeAccess:c,onClose:l}){let[p,I]=useState(r??{}),N=useMemo(()=>Ut(p,i),[p,i]),[R,T]=useState("main-menu"),[U,f]=useState(e??""),[h,b]=useState(t),[y,O]=useState(o==="password"?"password":"open"),[C,M]=useState(""),[A,P]=useState(false),ue=[{label:"Room name",value:"room-name",detail:`[${e??"(none)"}]`},{label:"Scale",value:"scale",detail:`[${He(n.id,i)}]`},{label:"Access",value:"access",detail:`[${o==="open"?"Open":"Password"}]`},{label:"Display name",value:"display-name",detail:`[${t}]`}],ie=bs(ue,s);function se(m){!s&&m!=="display-name"||(m==="room-name"?(f(e??""),T("editing-room-name")):m==="scale"?T("picking-scale"):m==="access"?T("picking-access"):m==="display-name"&&(b(t),T("editing-display-name")));}function Y(m){let w=m.trim()===""?void 0:m.trim();a(w),T("main-menu");}function X(m){let w=m.trim();w.length>0&&(u(w),process.nextTick(()=>V({displayName:w}))),T("main-menu");}function Q(m){let w=N.find(E=>E.id===m);w&&d(w),T("main-menu");}function ve(m,w){let E={...p};w.length===0?delete E[m]:E[m]=w,I(E),V({presetOverrides:Object.keys(E).length>0?E:void 0});}async function ge(m,w){P(true);try{await c(m,w),O(m),M(m==="password"?w??"":"");}catch(E){console.error(`Failed to update access: ${E}`);}finally{P(false),T("main-menu");}}return R==="main-menu"?jsx(me,{title:"\u2500\u2500 Settings \u2500\u2500",items:ie,onSelect:se,onClose:l}):R==="editing-room-name"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),jsx(Text,{children:"Room name: "}),jsx(F,{value:U,onChange:f,onSubmit:Y,onCancel:()=>T("main-menu"),placeholder:"(leave empty to remove)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]}):R==="editing-display-name"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),jsx(Text,{children:"Display name: "}),jsx(F,{value:h,onChange:b,onSubmit:X,onCancel:()=>T("main-menu"),placeholder:"(required)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]}):R==="picking-scale"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),jsx(Kt,{scales:N,selectedScaleId:n.id,presetOverrides:p,onSelect:Q,onOverrideChange:ve,onClose:()=>T("main-menu")})]}):R==="picking-access"?jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Settings \u2500\u2500"}),A&&jsx(Text,{dimColor:true,children:"Updating access..."}),!A&&jsx(rr,{mode:y,password:C,onModeChange:m=>{m==="open"&&ge("open");},onPasswordChange:M,onClose:()=>T("main-menu")})]}):jsx(Box,{})}function zt({participants:e,onlineIds:t,hostId:n,votes:o,revealed:r,participantId:i}){return jsxs(Box,{flexDirection:"column",children:[jsxs(Text,{bold:true,children:["Participants (",e.length,")"]}),e.map(s=>{let a=t.has(s.id),d=a?"\u25CF":"\u25CB",u=a?"green":"gray",c=s.id===n,l=Ie(s)==="viewer",p=s.id===i,I=s.id in o,N=l?" (viewer)":r?o[s.id]?` \u2192 ${o[s.id]}`:"":I?" \u2713":" \xB7",R=p&&!l&&!(r&&o[s.id]);return jsxs(Box,{gap:1,children:[jsx(Text,{color:u,children:d}),jsxs(Text,{children:[s.displayName,c?" (host)":""]}),R?jsx(Text,{color:"cyan",children:"(voter)"}):jsx(Text,{color:l?"gray":I?"green":"gray",children:N})]},s.id)})]})}var As=[{label:"End session for everyone",value:"end-session",detail:"Disconnects all participants. Cannot be undone."}];function lr({onPick:e,onClose:t}){return jsx(me,{title:"Host Actions",items:As,onSelect:e,onClose:t})}function Xt({roomCode:e,onPick:t,onClose:n}){let o=[{label:"Copy code",value:"code",detail:_t(e)},{label:"Copy share link",value:"url",detail:Ft(e)},{label:"Copy npx command",value:"npx",detail:Vt(e)}];return jsx(me,{title:"Share",items:o,onSelect:r=>t(r),onClose:n})}function Ts(e){let t=e.rounds.filter(o=>_(o)!==null),n=Object.fromEntries(e.participants.map(o=>[o.id,o]));return Uo({rounds:t,participants:n})}async function ur(e,t,n){let o=Ts(e);try{await t(o),n("Results copied to clipboard");}catch{n("Clipboard write failed");}}function pr(e,t,n){let o=To(e.id,n);return o===null?`Round ${t}`:`Round ${o.depth}/${o.total} [re-vote]`}function fr(e,t,n){let o=pr(e,t,n),r=e.title?` \u2014 ${e.title}`:"",i=e.ticketId?` [${e.ticketId}]`:"",s=_(e)==="skipped"?" \u2014 Skipped":" \u2014 Results";return `${o}${r}${i}${s}`}function mr(e){let t=Object.values(e).filter(c=>!W(c)).map(c=>parseFloat(c)).filter(c=>!isNaN(c)).toSorted((c,l)=>c-l);if(t.length===0)return {average:"-",median:"-",agreement:"-"};let o=t.reduce((c,l)=>c+l,0)/t.length,r=Math.floor(t.length/2),i=t.length%2===0?(t[r-1]+t[r])/2:t[r],s=Object.values(e).filter(c=>!W(c)),a=new Map;for(let c of s)a.set(c,(a.get(c)??0)+1);let d=Math.max(...a.values()),u=s.length>0?Math.round(d/s.length*100):0;return {average:o.toFixed(1),median:i.toFixed(1),agreement:`${u}%`}}function Yn(e,t){let n=Math.floor((t-e)/1e3),o=Math.floor(n/60),r=n%60;return `${o}:${r.toString().padStart(2,"0")}`}function gr(e,t,n=[]){let o=pr(e,t,n);if(_(e)==="skipped"){let l=e.title?` ${e.title}`:"",p=e.ticketId?` [${e.ticketId}]`:"";return `${o}:${l}${p} \u2014 Skipped`}let r=new Map;for(let l of Object.values(e.votes))W(l)||r.set(l,(r.get(l)??0)+1);let i=[...r.entries()].toSorted((l,p)=>p[1]-l[1]||l[0].localeCompare(p[0])).map(([l,p])=>`${l}\xD7${p}`).join(", "),s=Object.values(e.votes).filter(W).length,a=s>0?` (${s} abstained)`:"",d=e.title?` ${e.title}`:"",u=e.ticketId?` [${e.ticketId}]`:"",c=e.timerStartedAt!==void 0&&e.revealedAt!==void 0?` \u2014 ${Yn(e.timerStartedAt,e.revealedAt)}`:"";return `${o}:${d}${u} \u2014 ${i||"(no votes)"}${a}${c}`}function hr({projection:e,onlineIds:t,isHost:n,participantId:o,rounds:r,currentRound:i,settingsOpen:s,onStartRound:a,onNewRound:d,onRevote:u,onOpenSettings:c,onHandoffHost:l,onEndSession:p,onShare:I,shareOpen:N,onSetShareOpen:R,roomCode:T,confirmingQuit:U,myRole:f,onToggleRole:h,roundTitlePromptActive:b,roundTitleInput:y,onRoundTitleChange:O,onRoundTitleSubmit:C,onRoundTitleCancel:M,roundTicketIdPromptActive:A,roundTicketIdInput:P,onRoundTicketIdChange:ue,onRoundTicketIdSubmit:ie,onRoundTicketIdCancel:se,descriptorPromptActive:Y,descriptorInput:X,onDescriptorChange:Q,onDescriptorSubmit:ve,onDescriptorCancel:ge,onEditDescriptor:m,canExport:w,onExportResults:E,onAgendaAdd:J,agendaAddPromptActive:pe,agendaAddTitleInput:rt,onAgendaAddTitleChange:an,onAgendaAddTitleSubmit:We,onAgendaAddTitleCancel:vt,agendaAddTicketIdPromptActive:Ce,agendaAddTicketIdInput:dn,onAgendaAddTicketIdChange:Ke,onAgendaAddTicketIdSubmit:Ge,onAgendaAddTicketIdCancel:Pe}){let[Z,ee]=Qt.useState("idle"),[he,be]=Qt.useState(null),[it,ae]=Qt.useState(false),[fe,De]=Qt.useState(false);useEffect(()=>{n||(ee("idle"),be(null),ae(false),De(false));},[n]),useInput(x=>{if(x==="c"||x==="C"){R(true);return}if(x==="w"||x==="W"){h();return}if((x==="x"||x==="X")&&w){E();return}if(n){if(x==="a"||x==="A"){J();return}(x==="e"||x==="E")&&c(),(x==="s"||x==="S")&&a(),(x==="h"||x==="H")&&ee("picking"),(x==="m"||x==="M")&&ae(true),i!==null&&_(i)!==null&&((x==="n"||x==="N")&&d(),(x==="v"||x==="V")&&_(i)!=="skipped"&&u(),(x==="t"||x==="T")&&m());}},{isActive:!s&&!U&&Z==="idle"&&!b&&!A&&!it&&!fe&&!N&&!Y&&!pe&&!Ce}),useInput((x,te)=>{x==="y"||x==="Y"?(p(),De(false)):(x==="n"||x==="N"||te.escape)&&De(false);},{isActive:fe});let Ae=e.participants.filter(x=>x.id!==o&&t.has(x.id));useInput(x=>{if(Z==="picking"){let te=parseInt(x,10);!isNaN(te)&&te>=1&&te<=Ae.length?(be(Ae[te-1].id),ee("confirming")):(x==="Escape"||x==="q"||x==="Q")&&ee("idle");}},{isActive:Z==="picking"}),useInput(x=>{Z==="confirming"&&he&&(x==="y"||x==="Y"?(l(he),ee("idle"),be(null)):(x==="n"||x==="N"||x==="Escape")&&(ee("idle"),be(null)));},{isActive:Z==="confirming"});let Oe=r.length>0,Ct=r.filter(x=>_(x)!==null),st=i!==null?Ct.slice(0,-1):Ct;return it?jsx(lr,{onPick:x=>{ae(false),x==="end-session"&&De(true);},onClose:()=>ae(false)}):N?jsx(Xt,{roomCode:T,onPick:x=>{R(false),I(x);},onClose:()=>R(false)}):jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:Oe?"Session":"Waiting for participants..."}),!Oe&&jsx(Text,{dimColor:true,children:"No rounds started yet."}),jsx(zt,{participants:e.participants,onlineIds:t,hostId:e.settings.hostParticipantId,votes:{},revealed:false,participantId:o}),e.agenda.length>0&&jsx(Ds,{items:e.agenda,nextPending:Ze(e)}),i!==null&&_(i)!==null&&jsx(ks,{projection:e,round:i,rounds:r}),st.length>0&&jsxs(Box,{flexDirection:"column",children:[jsx(Text,{dimColor:true,children:"\u2500\u2500 History \u2500\u2500"}),st.map(x=>{let te=r.indexOf(x)+1;return jsx(Text,{dimColor:true,children:gr(x,te,r)},x.id)})]}),Z==="picking"&&Ae.length>0&&jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{children:"Hand off to:"}),Ae.map((x,te)=>jsxs(Text,{children:["[",te+1,"] ",x.displayName]},x.id)),jsx(Text,{dimColor:true,children:"[q] Cancel"})]}),Z==="picking"&&Ae.length===0&&jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{dimColor:true,children:"No other online participants"}),jsx(Text,{dimColor:true,children:"[q] Cancel"})]}),Z==="confirming"&&he&&jsx(Box,{flexDirection:"column",children:jsxs(Text,{children:["Hand off to ",e.participants.find(x=>x.id===he)?.displayName,"? [y/n]"]})}),b&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Round title (optional, Enter to skip):"}),jsx(F,{value:y,onChange:O,onSubmit:C,onCancel:M,placeholder:"Enter to skip",isActive:b})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),A&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Ticket ID (optional, Enter to skip):"}),jsx(F,{value:P,onChange:ue,onSubmit:ie,onCancel:se,placeholder:"e.g. PROJ-1234",isActive:A})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),Y&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Edit round title:"}),jsx(F,{value:X,onChange:Q,onSubmit:ve,onCancel:ge,placeholder:"Enter to save",isActive:Y})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel \xB7 empty submit cancels"})]}),fe&&jsxs(Box,{children:[jsx(Text,{color:"red",children:"End session for everyone? This cannot be undone. "}),jsx(Text,{dimColor:true,children:"y/n [Esc] Cancel"})]}),pe&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Agenda title (optional, Enter to skip):"}),jsx(F,{value:rt,onChange:an,onSubmit:We,onCancel:vt,placeholder:"Enter to skip",isActive:pe})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),Ce&&jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:1,children:[jsx(Text,{children:"Agenda ticket ID (optional, Enter to skip):"}),jsx(F,{value:dn,onChange:Ke,onSubmit:Ge,onCancel:Pe,placeholder:"e.g. PROJ-1234",isActive:Ce})]}),jsx(Text,{dimColor:true,children:"[Esc] Cancel"})]}),Z==="idle"&&!b&&!A&&!Y&&!fe&&!pe&&!Ce&&jsxs(Box,{gap:2,children:[n?jsx(Fragment,{children:i!==null&&_(i)!==null?jsxs(Fragment,{children:[_(i)!=="skipped"&&jsx(Text,{color:"yellow",children:"[v] Revote"}),jsx(Text,{color:"yellow",children:"[n] Next"}),jsx(Text,{color:"yellow",children:"[t] Edit title"}),jsx(Text,{color:"yellow",children:"[h] Handoff"}),jsx(Text,{color:"yellow",children:"[e] Settings"}),jsx(Text,{color:"yellow",children:"[c] Share"}),w&&jsx(Text,{color:"yellow",children:"[x] Export"}),jsxs(Text,{color:"yellow",children:["[w] ",f==="viewer"?"Vote":"Observe"]}),jsx(Text,{color:"yellow",children:"[m] Menu"})]}):jsxs(Fragment,{children:[jsx(Text,{color:"yellow",children:"[s] Start round"}),jsx(Text,{color:"yellow",children:"[a] Agenda"}),jsx(Text,{color:"yellow",children:"[h] Handoff"}),jsx(Text,{color:"yellow",children:"[e] Settings"}),jsx(Text,{color:"yellow",children:"[c] Share"}),w&&jsx(Text,{color:"yellow",children:"[x] Export"}),jsxs(Text,{color:"yellow",children:["[w] ",f==="viewer"?"Vote":"Observe"]}),jsx(Text,{color:"yellow",children:"[m] Menu"})]})}):jsxs(Fragment,{children:[jsx(Text,{dimColor:true,children:"Waiting for host to start a round..."}),jsx(Text,{children:"[c] Share"}),w&&jsx(Text,{color:"yellow",children:"[x] Export"}),jsxs(Text,{color:"yellow",children:["[w] ",f==="viewer"?"Vote":"Observe"]})]}),jsx(Text,{children:"[q] Quit"})]})]})}function ks({projection:e,round:t,rounds:n}){let o=n.indexOf(t)+1,r=fr(t,o,n);if(_(t)==="skipped")return jsx(Box,{flexDirection:"column",gap:1,children:jsx(Text,{bold:true,children:r})});let i=mr(t.votes),s=new Map(e.participants.map(p=>[p.id,p.displayName])),a=t.timerStartedAt!==void 0&&t.revealedAt!==void 0?Yn(t.timerStartedAt,t.revealedAt):null,d=Object.entries(t.votes),u=d.filter(([,p])=>!W(p)),c=d.filter(([,p])=>W(p)).map(([p])=>p),l=u[0]?.[1];return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:r}),So(t)&&l!==void 0&&jsxs(Text,{bold:true,color:"green",children:["Consensus! Everyone voted ",l]}),jsxs(Box,{flexDirection:"column",children:[jsxs(Box,{gap:2,children:[jsx(Text,{bold:true,underline:true,children:"Name".padEnd(20)}),jsx(Text,{bold:true,underline:true,children:"Estimate".padEnd(10)})]}),u.map(([p,I])=>jsxs(Box,{gap:2,children:[jsx(Text,{children:(s.get(p)??p).padEnd(20)}),jsx(Text,{color:"cyan",bold:true,children:I.padEnd(10)})]},p)),c.map(p=>jsxs(Box,{gap:2,children:[jsx(Text,{dimColor:true,children:(s.get(p)??p).padEnd(20)}),jsx(Text,{dimColor:true,children:"(abstained)".padEnd(10)})]},p)),e.participants.filter(p=>!(p.id in t.votes)).map(p=>jsxs(Box,{gap:2,children:[jsx(Text,{dimColor:true,children:p.displayName.padEnd(20)}),jsx(Text,{dimColor:true,children:"(no vote)".padEnd(10)})]},p.id))]}),jsxs(Box,{gap:2,children:[jsxs(Text,{children:["Avg: ",jsx(Text,{bold:true,children:i.average})]}),jsxs(Text,{children:["Med: ",jsx(Text,{bold:true,children:i.median})]}),jsxs(Text,{children:["Agreement: ",jsx(Text,{bold:true,children:i.agreement})]}),a!==null&&jsxs(Text,{dimColor:true,children:["\u23F1 ",a]})]})]})}var Ns={pending:"\u2022",consumed:"\u2713",skipped:"~",cancelled:"\u2717"},Ps={consumed:"green",skipped:"yellow",cancelled:"red"};function Ds({items:e,nextPending:t}){let n=e.filter(o=>o.state!=="cancelled");return jsxs(Box,{flexDirection:"column",children:[jsx(Text,{dimColor:true,children:"\u2500\u2500 Agenda \u2500\u2500"}),n.map(o=>{let r=Ns[o.state]??"?",i=Ps[o.state],s=t!==null&&o.id===t.id,a=[o.ticketId?`[${o.ticketId}]`:"",o.title??""].filter(Boolean).join(" ").trim()||o.id;return jsxs(Box,{gap:1,children:[i!==void 0?jsx(Text,{color:i,children:r}):jsx(Text,{children:r}),i!==void 0?jsx(Text,{color:i,children:a}):jsx(Text,{children:a}),s&&jsx(Text,{color:"cyan",children:"(next)"})]},o.id)}),n.length===0&&jsx(Text,{dimColor:true,children:"No pending items."})]})}function xr({scale:e,selected:t,onSelect:n,onClear:o,disabled:r}){let[i,s]=useState(0);return useInput((a,d)=>{if(!r)if(d.leftArrow)s(u=>Math.max(0,u-1));else if(d.rightArrow)s(u=>Math.min(e.cards.length-1,u+1));else if(d.return){let u=e.cards[i];u===t?o():n(u);}else (d.backspace||d.delete)&&o();}),jsxs(Box,{flexDirection:"column",gap:0,children:[jsx(Box,{gap:1,children:e.cards.map((a,d)=>{let u=d===i,c=a===t;return jsx(Text,{inverse:u,bold:c,...c&&{color:"cyan"},children:c?`[${a}]`:` ${a} `},a)})}),jsx(Text,{dimColor:true,children:" \u2190\u2192 navigate \u23CE select \u232B clear"})]})}function Bs(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),o=t%60;return `${n}:${o.toString().padStart(2,"0")}`}function yr({projection:e,round:t,onlineIds:n,isHost:o,myId:r,myRole:i,elapsedMs:s,roomCode:a,shareOpen:d,settingsOpen:u,onVote:c,onClearVote:l,onReveal:p,onSkip:I,onDiscard:N,onToggleRole:R,onShare:T,onSetShareOpen:U,onOpenSettings:f,confirmingQuit:h}){let b=t.votes[r],y=b!==void 0&&W(b);if(useInput(P=>{if(P==="e"||P==="E"){f();return}if(P==="c"||P==="C"){U(true);return}if(i==="voter"&&(P==="a"||P==="A")){y?l():c(It);return}o&&(P==="r"||P==="R")&&p(),o&&(P==="s"||P==="S")&&I(),o&&(P==="d"||P==="D")&&N(),(P==="w"||P==="W")&&R();},{isActive:!h&&!u&&!d}),d)return jsx(Xt,{roomCode:a,onPick:P=>{U(false),T(P);},onClose:()=>U(false)});let O=b,C=e.rounds.indexOf(t)+1,M=t.title?` \u2014 ${t.title}`:"",A=t.ticketId?` [${t.ticketId}]`:"";return jsxs(Box,{flexDirection:"column",gap:1,children:[jsxs(Box,{gap:2,children:[jsxs(Text,{bold:true,children:["Round ",C,M,A]}),s!==void 0&&jsxs(Text,{dimColor:true,children:["\u23F1 ",Bs(s)]})]}),jsxs(Box,{gap:4,children:[jsx(zt,{participants:e.participants,onlineIds:n,hostId:e.settings.hostParticipantId,votes:t.votes,revealed:false}),i==="viewer"?jsx(Box,{flexDirection:"column",children:jsx(Text,{dimColor:true,children:"You're observing"})}):jsxs(Box,{flexDirection:"column",gap:1,children:[y&&jsx(Text,{dimColor:true,children:"(abstaining this round \u2014 press [a] to vote)"}),jsx(xr,{scale:t.scale,selected:y?void 0:O,onSelect:c,onClear:l,disabled:h||y})]})]}),jsxs(Box,{gap:2,children:[o&&jsx(Text,{color:"yellow",children:"[r] Reveal"}),o&&jsx(Text,{color:"yellow",children:"[s] Skip"}),o&&jsx(Text,{color:"yellow",children:"[d] Discard"}),i==="voter"&&jsxs(Text,{color:"yellow",children:["[a] ",y?"Vote":"Abstain"]}),jsxs(Text,{color:"yellow",children:["[w] ",i==="viewer"?"Vote":"Observe"]}),jsx(Text,{children:"[e] Settings"}),jsx(Text,{children:"[c] Share"}),jsx(Text,{children:"[q] Quit"})]})]})}var _s=3e3;function tn(e=_s){let[t,n]=useState(null),o=useRef(null),r=useCallback(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null);},[]),i=useCallback(a=>{r(),n(a),o.current=setTimeout(()=>{n(null),o.current=null;},e);},[r,e]),s=useCallback(()=>{r(),n(null);},[r]);return useEffect(()=>()=>{r();},[r]),{notice:t,show:i,dismiss:s}}function Ys(e){let t=q(e);return !t||_(t)!==null?"lobby":"voting"}function on({session:e,participantId:t,displayName:n,accessMode:o,presetOverrides:r,customScales:i}){let{exit:s}=useApp(),[a,d]=useState(e.projection()),[u,c]=useState("connecting"),[l,p]=useState(e.onlineIds()),[I,N]=useState(),[R,T]=useState(false),[U,f]=useState(o==="password"?"password":"open"),[h,b]=useState(n),[y,O]=useState(false),[C,M]=useState(false),[A,P]=useState(""),[ue,ie]=useState(false),[se,Y]=useState(""),[X,Q]=useState(),[ve,ge]=useState(false),[m,w]=useState(""),[E,J]=useState(null),[pe,rt]=useState(false),[an,We]=useState(""),[vt,Ce]=useState(false),[dn,Ke]=useState(""),[Ge,Pe]=useState(),[Z,ee]=useState(),he=tn(3e3),[be,it]=useState(false),ae=tn(3e3),fe=tn(3e3);useEffect(()=>{let v=e.onChange(()=>{d(e.projection()),p(e.onlineIds());}),B=e.onStatusChange(c),qe=e.onHostChange(bt=>{let ci=e.projection().participants.find(ui=>ui.id===bt),li=bt===t?"You are now the host":`${ci?.displayName||"Unknown"} is now the host`;he.show(li);}),ln=setInterval(()=>{p(e.onlineIds());let bt=e.projection(),At=q(bt);At?.timerStartedAt!==void 0&&_(At)===null?N(Date.now()-At.timerStartedAt):N(void 0);},1e3);return ()=>{v(),B(),qe(),clearInterval(ln);}},[e,t,he.show]),useInput(v=>{(v==="q"||v==="Q")&&O(true);},{isActive:!R&&!y&&!C&&!ue&&!ve&&!be&&!pe&&!vt}),useInput((v,B)=>{v==="y"||v==="Y"?(e.disconnect(),s()):(v==="n"||v==="N"||B.escape)&&O(false);},{isActive:y});let De=Ys(a),Ae=q(a),Oe=a.settings.hostParticipantId===t,Ct=a.participants.find(v=>v.id===t),st=Ie(Ct??{}),x=useCallback(()=>{let v=Yt(Ze(a));P(v.title),ee(v.agendaItemId),M(true);},[a]),te=useCallback(v=>{M(false),P(""),Q(Mn(v));let B=Yt(Ze(a));Y(B.ticketId),ie(true);},[a]),$r=useCallback(()=>{M(false),P(""),Q(void 0),ee(void 0);},[]),Ur=useCallback(v=>{ie(false),Y("");let[B,qe,ln]=Xo(X,v,Z);e.newRound(B,qe,ln),Q(void 0),ee(void 0);},[e,X,Z]),Br=useCallback(()=>{ie(false),Y(""),Q(void 0),ee(void 0);},[]),Hr=useCallback(()=>{let v=e.current();!v||v.revealedAt===void 0||(J(v.id),w(v.title??""),ge(true));},[e]),Lr=useCallback(v=>{let B=E;if(ge(false),J(null),!B)return;let qe=v.trim();qe!==""&&e.updateRoundDescriptor(B,{title:qe});},[e,E]),jr=useCallback(()=>{ge(false),J(null);},[]),_r=useCallback(v=>{e.vote(v);},[e]),Fr=useCallback(()=>{e.unvote();},[e]),Vr=useCallback(()=>{e.reveal();},[e]),Yr=useCallback(()=>{e.skip();},[e]),Jr=useCallback(()=>{e.discardCurrentRound();},[e]),Wr=useCallback(()=>{let v=Yt(Ze(a));P(v.title),ee(v.agendaItemId),M(true);},[a]),Kr=useCallback(()=>{e.revote();},[e]),qn=useCallback(()=>{e.toggleRole();},[e]),Gr=useCallback(v=>{e.updateName(v);},[e]),qr=useCallback(v=>{e.updateScale(v);},[e]),zr=useCallback(v=>{e.updateDisplayName(v),b(v);},[e]),Xr=useCallback(async(v,B)=>{await e.updateAccess(v,B),f(v);},[e]),Qr=useCallback(v=>{try{e.handoffHost(v);}catch(B){console.error(`Handoff failed: ${B instanceof Error?B.message:String(B)}`);}},[e]),zn=useCallback(()=>{T(true);},[]),Zr=useCallback(()=>{T(false);},[]),ei=useCallback(()=>{e.endSessionForEveryone();},[e]),Xn=useCallback(async v=>{let B=v==="code"?_t(e.roomCode):v==="url"?Ft(e.roomCode):Vt(e.roomCode);try{await Cr.write(B),ae.show("Copied!");}catch{ae.show(`Copy failed \u2014 ${B}`);}},[e.roomCode,ae]),cn=a.rounds.filter(v=>_(v)!==null),ti=cn.length>0?cn.at(-1):null,ni=cn.length>0,oi=useCallback(()=>ur(a,v=>Cr.write(v),fe.show),[a,fe.show]),ri=useCallback(()=>{We(""),rt(true);},[]),ii=useCallback(v=>{rt(false),We("");let B=v.trim()===""?void 0:v.trim();Pe(B),Ke(""),Ce(true);},[]),si=useCallback(()=>{rt(false),We(""),Pe(void 0);},[]),ai=useCallback(v=>{Ce(false),Ke("");let B=v.trim()===""?void 0:v.trim();if(!Ge&&!B){Pe(void 0);return}Mt(e.doc,{...Ge!==void 0&&{title:Ge},...B!==void 0&&{ticketId:B},createdAt:Date.now()}),Pe(void 0);},[e.doc,Ge]),di=useCallback(()=>{Ce(false),Ke(""),Pe(void 0);},[]);return jsxs(Box,{flexDirection:"column",children:[jsx(er,{roomCode:e.roomCode,sessionName:a.settings.name,status:u,isHost:Oe}),he.notice&&jsx(Box,{paddingX:1,children:jsx(Text,{color:"yellow",children:he.notice})}),ae.notice&&jsx(Box,{paddingX:1,children:jsx(Text,{color:ae.notice.startsWith("Copy failed")?"red":"green",children:ae.notice})}),fe.notice&&jsx(Box,{paddingX:1,children:jsx(Text,{color:fe.notice.startsWith("Clipboard write failed")?"red":"green",children:fe.notice})}),R?jsx(dr,{sessionName:a.settings.name,displayName:h,currentScale:a.settings.defaultScale,accessMode:U,presetOverrides:r,customScales:i,isHost:Oe,onChangeName:Gr,onChangeScale:qr,onChangeDisplayName:zr,onChangeAccess:Xr,onClose:Zr}):De==="lobby"?jsx(hr,{projection:a,onlineIds:l,isHost:Oe,participantId:t,rounds:a.rounds,currentRound:ti,settingsOpen:R,onStartRound:x,onNewRound:Wr,roundTitlePromptActive:C,roundTitleInput:A,onRoundTitleChange:P,onRoundTitleSubmit:te,onRoundTitleCancel:$r,roundTicketIdPromptActive:ue,roundTicketIdInput:se,onRoundTicketIdChange:Y,onRoundTicketIdSubmit:Ur,onRoundTicketIdCancel:Br,onRevote:Kr,onOpenSettings:zn,onHandoffHost:Qr,onEndSession:ei,onShare:Xn,shareOpen:be,onSetShareOpen:it,roomCode:e.roomCode,confirmingQuit:y,myRole:st,onToggleRole:qn,descriptorPromptActive:ve,descriptorInput:m,onDescriptorChange:w,onDescriptorSubmit:Lr,onDescriptorCancel:jr,onEditDescriptor:Hr,canExport:ni,onExportResults:oi,onAgendaAdd:ri,agendaAddPromptActive:pe,agendaAddTitleInput:an,onAgendaAddTitleChange:We,onAgendaAddTitleSubmit:ii,onAgendaAddTitleCancel:si,agendaAddTicketIdPromptActive:vt,agendaAddTicketIdInput:dn,onAgendaAddTicketIdChange:Ke,onAgendaAddTicketIdSubmit:ai,onAgendaAddTicketIdCancel:di}):De==="voting"&&Ae?jsx(yr,{projection:a,round:Ae,onlineIds:l,isHost:Oe,myId:t,myRole:st,elapsedMs:I,onVote:_r,onClearVote:Fr,onReveal:Vr,onSkip:Yr,onDiscard:Jr,onToggleRole:qn,onShare:Xn,onSetShareOpen:it,shareOpen:be,settingsOpen:R,onOpenSettings:zn,roomCode:e.roomCode,confirmingQuit:y}):null,y&&jsx(Box,{children:jsx(Text,{dimColor:true,children:"Leave session? y/n"})})]})}function br({presetOverrides:e,customScales:t}){let{exit:n}=useApp(),[o,r]=useState("main-menu"),[i,s]=useState(Le()),[a,d]=useState(i.displayName??""),[u,c]=useState(i.relayUrl??""),[l,p]=useState(i.defaultSessionName??""),[I,N]=useState(i.avatarColor?.startsWith("#")?i.avatarColor:""),[R,T]=useState(t??[]),[U,f]=useState(e??{});useInput(m=>{(m==="q"||m==="Q")&&n();},{isActive:o==="main-menu"});let h=useMemo(()=>Ut(U,R),[U,R]),b=i.defaultScale,y=b?h.find(m=>m.id===b):void 0,O=[{label:"Display name",value:"display-name",detail:`[${i.displayName??"(none)"}]`},{label:"Relay URL",value:"relay-url",detail:`[${i.relayUrl??"(none)"}]`},{label:"Default scale",value:"default-scale",detail:`[${y?He(y.id,R):"(none)"}]`},{label:"Default session name",value:"default-session-name",detail:`[${i.defaultSessionName??"(none)"}]`},{label:"Default password",value:"default-password",detail:`[${i.defaultPassword?"on":"off"}]`},{label:"Avatar color",value:"avatar-color",detail:`[${zs(i.avatarColor)}]`}];function C(m){m==="display-name"?(d(i.displayName??""),r("editing-display-name")):m==="relay-url"?(c(i.relayUrl??""),r("editing-relay-url")):m==="default-scale"?r("picking-scale"):m==="default-session-name"?(p(i.defaultSessionName??""),r("editing-session-name")):m==="default-password"?r("picking-default-password"):m==="avatar-color"&&r("picking-avatar-color");}function M(m){if(m==="custom-hex"){N(i.avatarColor?.startsWith("#")?i.avatarColor:""),r("editing-avatar-hex");return}if(Me(m)===null){r("main-menu");return}s({...i,avatarColor:m}),V({avatarColor:m}),r("main-menu");}function A(m){let w=m.trim();if(w.length===0){r("picking-avatar-color");return}let E=w.startsWith("#")?w.toLowerCase():`#${w.toLowerCase()}`;Me(E)!==null&&(s({...i,avatarColor:E}),V({avatarColor:E}),r("main-menu"));}function P(m){let w=m.trim();if(w.length>0){let E={...i,displayName:w};s(E),V({displayName:w});}r("main-menu");}function ue(m){let w=m.trim();if(w.length>0){let E={...i,relayUrl:w};s(E),V({relayUrl:w});}r("main-menu");}function ie(m){let w=m.trim(),E=w.length>0?{...i,defaultSessionName:w}:{...i};w.length===0?(delete E.defaultSessionName,s(E),ut({defaultSessionName:""})):(s(E),V({defaultSessionName:w})),r("main-menu");}function se(m){let w=m.length>0?{...i,defaultScale:m}:{...i};m.length===0?(delete w.defaultScale,s(w),ut({defaultScale:""})):(s(w),V({defaultScale:m})),r("main-menu");}function Y(m,w){let E={...U};w.length===0?delete E[m]:E[m]=w,f(E),V({presetOverrides:Object.keys(E).length>0?E:void 0});}function X(m){let w=m==="on",E={...i,defaultPassword:w};s(E),V({defaultPassword:w}),r("main-menu");}function Q(m,w){let E=`custom-${randomUUID()}`,J=[...R,{id:E,label:m,cards:w}];T(J),s({...i,customScales:J}),V({customScales:J});}function ve(m,w,E){let J=R.map(pe=>pe.id===m?{id:m,label:w,cards:E}:pe);T(J),s({...i,customScales:J}),V({customScales:J});}function ge(m){let w=R.filter(J=>J.id!==m);T(w);let E={...i,customScales:w};i.defaultScale===m?(E.defaultScale="fibonacci",V({customScales:w,defaultScale:"fibonacci"})):V({customScales:w}),s(E);}if(o==="main-menu")return jsx(me,{title:"\u2500\u2500 Config Settings \u2500\u2500",items:O,onSelect:C,onClose:()=>n()});if(o==="editing-display-name")return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Text,{children:"Display name: "}),jsx(F,{value:a,onChange:d,onSubmit:P,onCancel:()=>r("main-menu"),placeholder:"(required)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]});if(o==="editing-relay-url")return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Text,{children:"Relay URL: "}),jsx(F,{value:u,onChange:c,onSubmit:ue,onCancel:()=>r("main-menu"),placeholder:"(required)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]});if(o==="editing-session-name")return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Text,{children:"Default session name: "}),jsx(F,{value:l,onChange:p,onSubmit:ie,onCancel:()=>r("main-menu"),placeholder:"(leave empty to clear)",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]});if(o==="picking-scale"){let m=[{id:"",cards:[]},...h];return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Kt,{scales:m,selectedScaleId:b??"",presetOverrides:U,customScales:R,onSelect:se,onOverrideChange:Y,onCustomScaleCreate:Q,onCustomScaleEdit:ve,onCustomScaleDelete:ge,onClose:()=>r("main-menu"),showNoneOption:true})]})}if(o==="picking-avatar-color"){let m=at.map(w=>({label:ze[w].label,value:w,detail:i.avatarColor===w?"[current]":ze[w].base}));return m.push({label:"Custom hex\u2026",value:"custom-hex",detail:i.avatarColor?.startsWith("#")?`[${i.avatarColor}]`:void 0}),jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(me,{title:"Avatar color:",items:m,onSelect:M,onClose:()=>r("main-menu")})]})}if(o==="editing-avatar-hex")return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(Text,{children:"Custom hex color: "}),jsx(F,{value:I,onChange:N,onSubmit:A,onCancel:()=>r("picking-avatar-color"),placeholder:"#rrggbb",isActive:true}),jsx(Text,{dimColor:true,children:"\u23CE confirm esc back"})]});if(o==="picking-default-password"){let m=[{label:"On",value:"on",detail:i.defaultPassword?"[current]":void 0},{label:"Off",value:"off",detail:i.defaultPassword?void 0:"[current]"}];return jsxs(Box,{flexDirection:"column",gap:1,children:[jsx(Text,{bold:true,children:"\u2500\u2500 Config Settings \u2500\u2500"}),jsx(me,{title:"Default password:",items:m,onSelect:X,onClose:()=>r("main-menu")})]})}return jsx(Box,{})}function zs(e){return e?e.startsWith("#")?e:at.includes(e)?ze[e].label:e:"(auto)"}var Qs={pending:"\u2022",consumed:"\u2713",skipped:"~",cancelled:"\u2717"};function Zs(e){let t=Qs[e.state]??"?",n=[];e.ticketId&&n.push(`[${e.ticketId}]`),e.title&&n.push(e.title);let o=n.join(" ")||e.id;return `${t} ${o}`}async function xt(e){let t=new $e.Doc,n=new Awareness(t);Xe(t,{participantId:e.participantId,displayName:e.displayName}),n.setLocalStateField("participantId",e.participantId);let o=et({doc:t,awareness:n,roomCode:e.roomCode,roomUuid:e.roomUuid,participantId:e.participantId,relayUrl:e.relayUrl,...e.passwordHash!==void 0&&{passwordHash:e.passwordHash}});return await new Promise(r=>{let i=setTimeout(r,2e3),s=o.onStatusChange(a=>{a==="connected"&&setTimeout(()=>{clearTimeout(i),s(),r();},200);});}),{doc:t,disconnect:()=>o.disconnect()}}async function yt(){let e=Ht();e.length===0&&(console.error("No active session. Join a room first with: hnch join <code>"),process.exit(1));let t=e[0];return {roomCode:t.roomCode,roomUuid:t.roomUuid,...t.passwordHash!==void 0&&{passwordHash:t.passwordHash}}}async function Ir(e){!e.title?.trim()&&!e.ticket?.trim()&&(console.error("At least one of --title or --ticket is required"),process.exit(1));let t=await ce(),n=await yt();try{await le(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await xt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{let i=Mt(o,{...e.title?.trim()?{title:e.title.trim()}:{},...e.ticket?.trim()?{ticketId:e.ticket.trim()}:{},...e.description?.trim()?{description:e.description.trim()}:{},createdAt:Date.now()});await new Promise(s=>{setTimeout(s,300);}),console.log(`Added agenda item: ${i}`);}finally{r();}}async function Rr(){let e=await ce(),t=await yt();try{await le(e.relayUrl,t.roomCode);}catch{console.error(`Room ${t.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:n,disconnect:o}=await xt({relayUrl:e.relayUrl,participantId:e.participantId,displayName:e.displayName,roomCode:t.roomCode,roomUuid:t.roomUuid,...t.passwordHash!==void 0&&{passwordHash:t.passwordHash}});try{let i=j(n).agenda;if(i.length===0){console.log("No agenda items.");return}i.forEach((s,a)=>{console.log(`${String(a+1).padStart(2)}. ${Zs(s)}`);});}finally{o();}}async function Tr(e){let t=await ce(),n=await yt();try{await le(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await xt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{wn(o,e.id,"skipped",{timestamp:Date.now()}),await new Promise(i=>{setTimeout(i,300);}),console.log(`Skipped agenda item: ${e.id}`);}catch(i){console.error(`Skip failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1);}finally{r();}}async function Er(e){let t=await ce(),n=await yt();try{await le(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await xt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{wn(o,e.id,"cancelled",{timestamp:Date.now()}),await new Promise(i=>{setTimeout(i,300);}),console.log(`Cancelled agenda item: ${e.id}`);}catch(i){console.error(`Cancel failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1);}finally{r();}}async function kr(e){let t=await ce(),n=await yt();try{await le(t.relayUrl,n.roomCode);}catch{console.error(`Room ${n.roomCode} not found on relay \u2014 session may have expired.`),process.exit(1);}let{doc:o,disconnect:r}=await xt({relayUrl:t.relayUrl,participantId:t.participantId,displayName:t.displayName,roomCode:n.roomCode,roomUuid:n.roomUuid,...n.passwordHash!==void 0&&{passwordHash:n.passwordHash}});try{wo(o,e.id,e.before,e.after),await new Promise(i=>{setTimeout(i,300);}),console.log(`Reordered agenda item: ${e.id}`);}catch(i){console.error(`Move failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1);}finally{r();}}async function Gn(){return new Promise(e=>{let t=createInterface({input:process.stdin,output:process.stderr});process.stderr.write("Password: "),t.question("",n=>{t.close(),e(n);});})}async function na(e){let t=await ce(),n=e.scale??t.defaultScale??"fibonacci",o=e.name??t.defaultSessionName,r=e.password??t.defaultPassword??false,i;r&&(i=await Gn());let s=$t(n,t.presetOverrides,t.customScales);if(!s){let l=Object.keys(de).join(", ");console.error(`Unknown or fully-disabled scale: "${n}". Builtin IDs: ${l}`),process.exit(1);}let a=await Jo({participantId:t.participantId,displayName:t.displayName,relayUrl:t.relayUrl,sessionName:o,password:i,defaultScale:s,...t.avatarColor!==void 0&&{avatarColor:t.avatarColor}}),d;i&&(d=await Be(i,a.roomUuid)),On({roomCode:a.roomCode,roomUuid:a.roomUuid,lastSeenAt:Date.now(),...d!==void 0&&{passwordHash:d}}),console.error(`Room created: ${a.roomCode}`),console.error(`Share: hnch join ${a.roomCode}`),console.error("");let{waitUntilExit:u,unmount:c}=render(Qt.createElement(on,{session:a,participantId:t.participantId,displayName:t.displayName,accessMode:i?"password":"open",presetOverrides:t.presetOverrides,customScales:t.customScales}));jt({doc:a.doc,localParticipantId:t.participantId,onEnded:async l=>{console.error(l.isLocal?"Session ended.":`Session ended by ${l.hostName}.`),c();try{await Se();}catch(p){console.error(`Failed to clear cached session: ${p instanceof Error?p.message:String(p)}`);}a.disconnect(),process.exit(0);}}),await u(),a.disconnect(),Se(),process.exit(0);}async function oa(e){let t=await ce(),n=Ko(e.code);n===null&&(console.error("invalid room code"),process.exit(1));let o;e.password&&(o=await Gn());let r=await le(t.relayUrl,n),i;r.accessMode==="password"&&!e.password?i=await Gn():e.password&&(i=o);let s,a=false,d=await Wo({participantId:t.participantId,displayName:t.displayName,relayUrl:t.relayUrl,roomCode:n,password:i,...t.avatarColor!==void 0&&{avatarColor:t.avatarColor},onRejection(l){if(l==="unknown-room"){Lt({clearLastSession:Se,logger:console,exit:process.exit});return}l==="room-full"&&(a=true,s?.());}}),u;i&&(u=await Be(i,d.roomUuid)),On({roomCode:d.roomCode,roomUuid:d.roomUuid,lastSeenAt:Date.now(),...u!==void 0&&{passwordHash:u}}),console.error(`Joined room: ${d.roomCode}`),console.error("");let c=render(Qt.createElement(on,{session:d,participantId:t.participantId,displayName:t.displayName,accessMode:r.accessMode,presetOverrides:t.presetOverrides,customScales:t.customScales}));s=c.unmount,jt({doc:d.doc,localParticipantId:t.participantId,onEnded:async l=>{console.error(l.isLocal?"Session ended.":`Session ended by ${l.hostName}.`),s?.();try{await Se();}catch(p){console.error(`Failed to clear cached session: ${p instanceof Error?p.message:String(p)}`);}d.disconnect(),process.exit(0);}}),await c.waitUntilExit(),a&&(console.error("This room is full (max 20 participants)."),d.disconnect(),Se(),process.exit(1)),d.disconnect(),Se(),process.exit(0);}function ra(e,t=Date.now()){let n=t-e,o=Math.floor(n/6e4);return o<60?`${o}m ago`:`${Math.floor(o/60)}h ago`}async function ia(e){return new Promise((t,n)=>{let o=createInterface({input:process.stdin,output:process.stderr}),r=()=>{process.stderr.write(`Select [1-${e}]: `),o.question("",i=>{let s=parseInt(i.trim(),10);Number.isInteger(s)&&s>=1&&s<=e?(o.close(),t(s)):(process.stderr.write(`Invalid choice \u2014 enter a number between 1 and ${e}.
|
|
22
|
+
`),r());});};o.on("close",()=>n(new Error("stdin closed"))),r();})}async function Nr(e,t){let n;try{n=await le(e.relayUrl,t.roomCode);}catch(c){if((c instanceof Error?c.message:String(c)).includes("Room not found"))return pt(t.roomUuid),await Lt({clearLastSession:Se,logger:console,exit:process.exit});console.error("Could not reach relay \u2014 try again later."),process.exit(0);}n.accessMode==="password"&&!t.passwordHash&&(console.error(`Password changed \u2014 rejoin with: hnch join ${t.roomCode} --password`),Dn(t.roomUuid),process.exit(0)),console.error(`Rejoining room ${t.roomCode}\u2026`),console.error("");let o=new $e.Doc,r=new Awareness(o);Xe(o,{participantId:e.participantId,displayName:e.displayName,...e.avatarColor!==void 0&&{avatarColor:e.avatarColor}}),r.setLocalStateField("participantId",e.participantId);let i=false,s=false,a,d=et({doc:o,awareness:r,roomCode:t.roomCode,roomUuid:t.roomUuid,participantId:e.participantId,relayUrl:e.relayUrl,passwordHash:t.passwordHash,onRejection(c){if(c==="unknown-room"){pt(t.roomUuid),Lt({clearLastSession:Se,logger:console,exit:process.exit});return}c==="wrong-password"&&(i=true,a?.()),c==="room-full"&&(s=true,a?.());}});Pn({roomCode:d.roomCode,roomUuid:d.roomUuid,lastSeenAt:Date.now(),...t.passwordHash!==void 0&&{passwordHash:t.passwordHash}});let u=render(Qt.createElement(on,{session:d,participantId:e.participantId,displayName:e.displayName,accessMode:n.accessMode,presetOverrides:e.presetOverrides,customScales:e.customScales}));a=u.unmount,jt({doc:d.doc,localParticipantId:e.participantId,onEnded:async c=>{console.error(c.isLocal?"Session ended.":`Session ended by ${c.hostName}.`),a?.();try{pt(t.roomUuid);}catch(l){console.error(`Failed to clear cached session: ${l instanceof Error?l.message:String(l)}`);}d.disconnect(),process.exit(0);}}),await u.waitUntilExit(),s&&(console.error("This room is full (max 20 participants)."),d.disconnect(),process.exit(1)),i&&(Dn(t.roomUuid),console.error(`Password changed \u2014 rejoin with: hnch join ${t.roomCode} --password`),d.disconnect(),process.exit(0)),d.disconnect(),pt(t.roomUuid),process.exit(0);}async function sa(){let e=await ce(),t=Ht();if(t.length===0&&(console.error("No recent session to resume."),process.exit(0)),t.length===1)return Nr(e,t[0]);let n=Date.now();process.stderr.write(`Recent rooms:
|
|
23
|
+
`);for(let[r,i]of t.entries()){let s=ra(i.lastSeenAt,n);process.stderr.write(` ${r+1}. ${i.roomCode} (${s})
|
|
24
|
+
`);}process.stderr.write(`
|
|
25
|
+
`);let o;try{o=await ia(t.length);}catch{console.error("No selection made."),process.exit(1);}return Nr(e,t[o-1])}async function aa(e){if(!(e.name!==void 0||e.relayUrl!==void 0||e.scale!==void 0||e.sessionName!==void 0||e.password!==void 0||e.color!==void 0)){let o=await ce(),{waitUntilExit:r}=render(Qt.createElement(br,{presetOverrides:o.presetOverrides,customScales:o.customScales}));await r(),process.exit(0);}let n={};if(e.name!==void 0&&(n.displayName=e.name),e.relayUrl!==void 0&&(n.relayUrl=e.relayUrl),e.scale!==void 0){if(e.scale!==""){let o=Le();if(!$t(e.scale,o.presetOverrides,o.customScales)){console.error(`Unknown scale: "${e.scale}". Builtin IDs: ${Object.keys(de).join(", ")}`);return}}n.defaultScale=e.scale;}if(e.sessionName!==void 0&&(n.defaultSessionName=e.sessionName),e.password!==void 0&&(n.defaultPassword=e.password),e.color!==void 0){let o=e.color.startsWith("#")||e.color===""?e.color:e.color.toLowerCase();o!==""&&Me(o)===null&&(console.error(`Invalid color: "${e.color}". Pass a palette key or #rrggbb hex literal.`),process.exit(1)),n.avatarColor=o;}ut(n),console.log("Config updated.");}var Mr=ea(hideBin(process.argv)).scriptName("hnch").usage("$0 <command> \u2014 terminal pointing poker").command("create","Create a new room",e=>e.option("name",{type:"string",describe:"Session name"}).option("password",{type:"boolean",describe:"Protect room with a password"}).option("scale",{type:"string",describe:"Estimation scale ID (fibonacci, t-shirt, powers-of-2, linear, risk, or custom-<id>)"}),e=>{na(e).catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("join <code>","Join an existing room",e=>e.positional("code",{type:"string",demandOption:true,describe:"6-character room code"}).option("password",{type:"boolean",describe:"Room requires a password",default:false}),e=>{oa(e).catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("resume","Rejoin your last session",e=>e,()=>{sa().catch(e=>{console.error(e instanceof Error?e.message:e),process.exit(1);});}).command("config","View or update CLI config",e=>e.option("name",{type:"string",describe:"Set display name"}).option("relay-url",{type:"string",describe:"Set relay URL"}).option("scale",{type:"string",describe:"Set default estimation scale ID (empty string clears)"}).option("session-name",{type:"string",describe:"Set default session name (empty string clears)"}).option("password",{type:"boolean",describe:"Set default password prompt on (--password) or off (--no-password)"}).option("color",{type:"string",describe:'Set avatar color: a palette key (e.g. "blue", "racing-green") or a #rrggbb hex literal'}),e=>{aa(e).catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("agenda","Manage the pre-session story agenda",e=>e.command("add","Add an agenda item",t=>t.option("title",{type:"string",describe:"Story title"}).option("ticket",{type:"string",describe:"Issue tracker reference (e.g. PROJ-123)"}).option("description",{type:"string",describe:"Story description"}).check(n=>{if(!n.title?.trim()&&!n.ticket?.trim())throw new Error("At least one of --title or --ticket is required");return true}),t=>{Ir(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).command("list","List agenda items in order",t=>t,()=>{Rr().catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1);});}).command("skip <id>","Mark an agenda item as skipped",t=>t.positional("id",{type:"string",demandOption:true,describe:"Agenda item ID"}),t=>{Tr(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).command("cancel <id>","Soft-delete (cancel) an agenda item",t=>t.positional("id",{type:"string",demandOption:true,describe:"Agenda item ID"}),t=>{Er(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).command("mv <id>","Reorder an agenda item (--before <id> | --after <id>)",t=>t.positional("id",{type:"string",demandOption:true,describe:"Agenda item ID to move"}).option("before",{type:"string",describe:"sortKey of item that should come before the moved item"}).option("after",{type:"string",describe:"sortKey of item that should come after the moved item"}).check(n=>{if(n.before!==void 0&&n.after!==void 0)throw new Error("--before and --after are mutually exclusive");if(n.before===void 0&&n.after===void 0)throw new Error("Specify either --before <id> or --after <id>");return true}),t=>{kr(t).catch(n=>{console.error(n instanceof Error?n.message:n),process.exit(1);});}).demandCommand(1,"Specify an agenda subcommand: add, list, skip, cancel, mv").strict().help(),()=>{}).demandCommand(1,"Specify a command: create, join, resume, config, or agenda").strict().help(),Kn=hideBin(process.argv);(Kn.length===0||Kn.length===1&&Kn[0]==="--")&&(Mr.showHelp(),process.exit(0));Mr.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xauyxau/hnch",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Pointing poker CLI for agile teams",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pointing-poker",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"clipboardy": "^4.0.0",
|
|
52
52
|
"ink": "^5.2.0",
|
|
53
53
|
"react": "^18.3.1",
|
|
54
|
-
"ws": "^8.20.
|
|
54
|
+
"ws": "^8.20.1",
|
|
55
55
|
"y-protocols": "^1.0.7",
|
|
56
56
|
"y-websocket": "^3.0.0",
|
|
57
57
|
"yargs": "^17.7.2",
|