chamba 0.8.0 → 0.9.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.
Files changed (59) hide show
  1. package/README.md +7 -1
  2. package/dist/lib/chamba-yaml.js +4 -4
  3. package/package.json +1 -1
  4. package/templates/Dockerfile +3 -3
  5. package/templates/context/baseline.md +2 -2
  6. package/templates/context/web-pane-craft.md +1 -1
  7. package/templates/pane-apps/client/assets/api-BBDf_rzz.js +12 -0
  8. package/templates/pane-apps/client/assets/api-DNLbSBpK.css +1 -0
  9. package/templates/pane-apps/client/assets/bee-B7t97l5B.webp +0 -0
  10. package/templates/pane-apps/client/assets/buzz-CUUsbnXH.mp3 +0 -0
  11. package/templates/pane-apps/client/assets/files-BkmyervY.js +1 -0
  12. package/templates/pane-apps/client/assets/home-3SeGzySM.css +1 -0
  13. package/templates/pane-apps/client/assets/home-Cu9xOd2i.js +1 -0
  14. package/templates/pane-apps/client/assets/pop-D5ZANBC3.mp3 +0 -0
  15. package/templates/pane-apps/client/assets/reviews-DMrGB-kG.js +153 -0
  16. package/templates/pane-apps/client/assets/reviews-nK_yRav9.css +1 -0
  17. package/templates/pane-apps/client/assets/specs-Cabb15F0.js +13 -0
  18. package/templates/pane-apps/client/assets/useNow-BHFKFraS.js +1 -0
  19. package/templates/pane-apps/client/home/index.html +16 -0
  20. package/templates/pane-apps/client/reviews/index.html +6 -4
  21. package/templates/pane-apps/client/specs/index.html +4 -3
  22. package/templates/pane-apps/server/home.mjs +12 -0
  23. package/templates/pane-apps/server/reviews.mjs +19 -18
  24. package/templates/pane-apps/server/specs.mjs +4 -4
  25. package/templates/skills/dx-review/SKILL.md +16 -3
  26. package/templates/skills/dx-review/references/acts.md +86 -15
  27. package/templates/skills/dx-spec/SKILL.md +7 -3
  28. package/templates/skills/dx-spec/references/review-guide.md +2 -2
  29. package/templates/skills/dx-spec/references/spec-guide.md +1 -1
  30. package/templates/skills/dx-spec/references/stages.md +6 -2
  31. package/templates/skills/dx-spec-execute/SKILL.md +73 -7
  32. package/templates/startup.mjs +13 -13
  33. package/templates/tool-helper.sh +4 -2
  34. package/templates/webterm/README.md +34 -13
  35. package/templates/webterm/config.js +20 -0
  36. package/templates/webterm/public/app/alerts.js +92 -11
  37. package/templates/webterm/public/app/composer.js +37 -3
  38. package/templates/webterm/public/app/connection.js +14 -0
  39. package/templates/webterm/public/app/dom.js +1 -0
  40. package/templates/webterm/public/app/frames.js +1 -1
  41. package/templates/webterm/public/app/home-host.js +16 -0
  42. package/templates/webterm/public/app/main.js +4 -2
  43. package/templates/webterm/public/app/pane-shape.js +5 -3
  44. package/templates/webterm/public/app/pane-shell.js +45 -5
  45. package/templates/webterm/public/app/pane.js +8 -2
  46. package/templates/webterm/public/app/reviews-host.js +5 -1
  47. package/templates/webterm/public/app/tool-host.js +19 -3
  48. package/templates/webterm/public/app/workspace-color.js +1 -1
  49. package/templates/webterm/public/index.html +5 -1
  50. package/templates/webterm/public/styles.css +52 -0
  51. package/templates/webterm/tool-document.js +3 -2
  52. package/templates/webterm/tools/home.js +58 -0
  53. package/templates/webterm/tools/index.js +5 -4
  54. package/templates/webterm/tools/reviews.js +7 -3
  55. package/templates/pane-apps/client/assets/files-D0nJgFAA.js +0 -12
  56. package/templates/pane-apps/client/assets/files-h0K1vZyQ.css +0 -1
  57. package/templates/pane-apps/client/assets/reviews-BsoGZ35r.css +0 -1
  58. package/templates/pane-apps/client/assets/reviews-iW0Mbn4e.js +0 -153
  59. package/templates/pane-apps/client/assets/specs-D9z3neR-.js +0 -13
@@ -0,0 +1 @@
1
+ import{A as e,C as t,D as n,E as r,O as i,c as a,i as o,k as s,n as c,r as l,s as u,t as d,y as f}from"./api-BBDf_rzz.js";import{t as p}from"./useNow-BHFKFraS.js";var m=e(),h=i(),g=n();function _(e){return(0,g.jsxs)(`div`,{className:`hm-hbar`,children:[(0,g.jsx)(`span`,{className:`hm-key-name`,title:e.name,children:e.name}),(0,g.jsx)(`div`,{className:`hm-track`,children:(0,g.jsx)(`i`,{style:{width:`${e.width}%`,background:e.colour}})}),(0,g.jsx)(`span`,{className:`hm-value`,children:e.value}),e.note!==void 0&&(0,g.jsx)(`span`,{className:e.note.className,title:e.note.title,children:e.note.said})]})}var v=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function y(e){return e.toLocaleString(`en-GB`)}function b(e,t){return`${y(e)} ${t}${e===1?``:`s`}`}function x(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(t===null)return null;let n=Number(t[2])-1;return n<0||n>11?null:{year:t[1]??``,month:n,date:Number(t[3])}}function S(e){if(e===null)return``;let t=x(e.slice(0,10));return t===null?``:`${t.date} ${v[t.month]} ${t.year}`}function C(e){let t=x(e.slice(0,10));return t===null?``:`${t.date} ${v[t.month]}`}function ee(e,t){let n=x(e.slice(0,10)),r=x(t.slice(0,10));return n===null||r===null?``:n.year===r.year&&n.month===r.month?`${n.date}-${r.date} ${v[n.month]}`:`${C(e)} - ${C(t)}`}function te(e){return e===0?`working tree clean`:`${b(e,`uncommitted change`)}`}function ne(e,t){return`+${y(e)} / -${y(t)}`}var re=`#199e70`;function ie(e,t){if(t===0)return{said:e===0?`quiet`:`new`,up:e>0};let n=Math.round((e-t)/t*100);return{said:`${n>=0?`+`:``}${n}%`,up:n>0}}function ae(e){if(e.areas.length===0)return(0,g.jsx)(`p`,{className:`hm-plain hm-muted`,children:`No commit in the last sixty days.`});let t=Math.max(1,...e.areas.map(e=>e.lines));return(0,g.jsx)(`div`,{className:`hm-areas`,children:e.areas.map(e=>{let n=ie(e.lines,e.before.lines);return(0,g.jsx)(_,{name:e.area,width:e.lines/t*100,colour:re,value:`${y(e.lines)} lines · ${b(e.commits,`commit`)}`,note:{said:n.said,className:n.up?`hm-shift hm-up`:`hm-shift`,title:`${y(e.before.lines)} lines in ${b(e.before.commits,`commit`)} over the thirty days before`}},e.area)})})}var oe=/^[A-Za-z0-9._/-]+$/;function se(e){return oe.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function ce(e){return e===`merged`||e===`squash`||e===`stale`}function le(e,t){return`git branch ${t===`merged`?`-d`:`-D`} -- ${se(e)}`}function ue(e,t){switch(e){case`current`:return`current`;case`default`:return`default`;case`merged`:return`merged`;case`squash`:return`merged (squash)`;case`stale`:return`stale`;default:return`ahead of ${t}`}}function de(e){let t=e.filter(e=>e.state===`merged`||e.state===`squash`).length,n=e.filter(e=>e.state===`stale`).length;return`${y(e.length)} local · ${y(t)} merged, ${y(n)} stale`}function fe(e,t){return e===`stale`?{said:`This branch holds work that is not on ${t}. The command deletes it anyway.`,warn:!0}:e===`squash`?{said:`Squash-merged into ${t}. git cannot see a squash merge, so the force flag is needed. Home checked that the whole change is on ${t}.`,warn:!1}:{said:`Merged into ${t}, so the safe delete works.`,warn:!1}}function pe(e){let t=e.default??`the default branch`,[n,i]=(0,m.useState)(null),a=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(n===null)return;let e=e=>{a.current?.contains(e.target)!==!0&&i(null)};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[n]),(0,g.jsx)(`div`,{className:`hm-list`,children:e.branches.map(o=>{let s=o.ahead>0?` · ${b(o.ahead,`commit`)} ahead of ${t}`:``;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`hm-name`,title:`${o.name}${s}`,children:o.name}),(0,g.jsx)(`span`,{className:`hm-muted`,children:u(o.lastCommit,e.now)}),(0,g.jsx)(`span`,{className:`hm-flag hm-${o.state}`,children:ue(o.state,t)}),(0,g.jsx)(`span`,{className:`hm-pop`,children:ce(o.state)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{type:`button`,className:`hm-del`,title:`Delete this branch`,onClick:e=>{e.stopPropagation(),i(n===o.name?null:o.name)},children:(0,g.jsx)(r,{size:14})}),n===o.name&&(0,g.jsx)(me,{branch:o,into:t,held:a})]})})]},o.name)})})}function me(e){let t=fe(e.branch.state,e.into),n=le(e.branch.name,e.branch.state);return(0,g.jsxs)(`div`,{className:`hm-popover`,ref:e.held,children:[(0,g.jsxs)(`p`,{children:[(0,g.jsx)(`span`,{className:t.warn?`hm-warn-text`:void 0,children:t.said}),` Deletes the local branch alone: a remote branch of the same name is not touched.`]}),(0,g.jsxs)(`div`,{className:`hm-cmd`,children:[(0,g.jsx)(`input`,{readOnly:!0,value:n,"aria-label":`The command that deletes this branch`,onClick:e=>e.currentTarget.select()}),(0,g.jsx)(`span`,{className:`hm-hint`,children:`click selects · copy with the keyboard`})]})]})}function w(e){let{title:t,note:n,state:r,said:i,loaderHeight:a=120}=e;return(0,g.jsxs)(`section`,{className:e.className===void 0?`hm-card`:`hm-card ${e.className}`,children:[t!==void 0&&(0,g.jsxs)(`h3`,{children:[t,r===`read`&&n!==void 0&&(0,g.jsx)(`small`,{children:n})]}),r===`loading`?(0,g.jsx)(`div`,{className:`hm-loader`,style:{height:`${a}px`}}):r===`failed`?(0,g.jsxs)(`p`,{className:`hm-notice`,children:[(0,g.jsx)(`span`,{children:i}),` `,(0,g.jsx)(`span`,{className:`hm-muted`,children:`Press Refresh to try again.`})]}):e.children]})}var he=``+new URL(`bee-B7t97l5B.webp`,import.meta.url).href,ge=``+new URL(`buzz-CUUsbnXH.mp3`,import.meta.url).href,_e=``+new URL(`pop-D5ZANBC3.mp3`,import.meta.url).href,T=[{said:`Simplicity is prerequisite for reliability.`,who:`Edsger W. Dijkstra`},{said:`A system's design mirrors the communication structure of the organization that built it.`,who:`Melvin Conway (Conway's law)`}],ve=640,E=[50,70],ye=6e3,D=[.15,.75],be=[95,125],xe=16,O=[14,32],k=[2.2,3.4],Se=.6,A=[ge,_e];function j(e,t){return e+Math.random()*(t-e)}function M(){return window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}function Ce(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(null),a=(0,m.useRef)(e.sound);a.current=e.sound;let o=(0,m.useRef)(0),s=(0,m.useRef)(!1),c=(0,m.useRef)({x:0,y:0,base:0,amplitude:0,period:3,t:0,direction:1,speed:110,tilt:0,away:j(E[0],E[1]),flying:!1}),l=(0,m.useCallback)(()=>{if(s.current)return;if(s.current=!0,i(o.current%T.length),o.current+=1,a.current)try{let e=new Audio(A[(o.current-1)%A.length]);e.volume=.7,e.play().catch(e=>{console.warn(`[home] the bee could not play its clip:`,e)})}catch(e){console.warn(`[home] the bee could not play its clip:`,e)}let e=t.current;e!==null&&(e.classList.remove(`hm-hop`),e.offsetWidth,e.classList.add(`hm-hop`)),setTimeout(()=>{s.current=!1,i(null)},ye)},[]);(0,m.useEffect)(()=>{let e=t.current;if(e===null)return;let r=()=>Math.round(110*Math.min(1,window.innerWidth/ve));if(M()){e.style.width=`${r()}px`,e.classList.add(`hm-parked`,`hm-here`);return}let i=0,a=0,o=performance.now(),l=()=>{let t=c.current;e.style.transform=`translate(${t.x}px, ${t.y}px) scaleX(${t.direction}) rotate(${t.direction*t.tilt}deg)`},u=t=>{let d=Math.min(.05,(t-o)/1e3);o=t;let f=c.current,p=r();if(p!==i&&(i=p,e.style.width=`${p}px`),f.flying){let t=s.current?xe:f.speed;f.t+=d,f.x+=f.direction*t*d;let n=f.t/f.period*2*Math.PI;f.y=f.base+Math.sin(n)*f.amplitude;let r=Math.cos(n)*f.amplitude*2*Math.PI/f.period;f.tilt=Math.atan2(r,t)*180/Math.PI*Se,(f.x<-p*1.5||f.x>window.innerWidth+p*.5)&&!s.current&&(f.flying=!1,f.away=j(E[0],E[1]),e.classList.remove(`hm-here`))}else{if(f.away-=d,f.away>0){a=requestAnimationFrame(u);return}f.direction=Math.random()<.5?1:-1,f.x=f.direction>0?-p:window.innerWidth,f.amplitude=j(O[0],O[1]);let t=window.innerHeight*D[0]+f.amplitude,n=window.innerHeight*D[1]-f.amplitude;f.base=n>t?j(t,n):(t+n)/2,f.y=f.base,f.tilt=0,f.period=j(k[0],k[1]),f.speed=j(be[0],be[1]),f.t=0,f.flying=!0,e.classList.add(`hm-here`)}l();let m=n.current;m!==null&&(m.style.left=`${Math.min(Math.max(8,c.current.x-110),window.innerWidth-300)}px`,m.style.top=`${Math.max(8,c.current.y-92)}px`),a=requestAnimationFrame(u)};return a=requestAnimationFrame(u),()=>cancelAnimationFrame(a)},[]);let u=r===null?null:T[r];return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{type:`button`,className:`hm-bee`,ref:t,"aria-label":`The bee`,title:`A quote`,onClick:l,children:(0,g.jsx)(`span`,{className:`hm-face`,children:(0,g.jsx)(`img`,{src:he,alt:``})})}),(0,g.jsx)(`div`,{className:u==null?`hm-bubble`:`hm-bubble hm-said`,ref:n,children:u!=null&&(0,g.jsxs)(g.Fragment,{children:[u.said,(0,g.jsxs)(`span`,{className:`hm-who`,children:[`- `,u.who]})]})})]})}var N=10,P=170,we=10,Te=128,F=12,I=60,L=500,R=2e3,z=`Its height follows the lines changed that day, added plus deleted, on a square-root scale so a huge day does not flatten the rest.`,B=`plant-height`,Ee=5,De=.7;function V(e){return e.added+e.deleted}function Oe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)%1e4/1e4}function ke(e,t){let n=Math.min(Math.max((t-L)/(R-L),0),1),r=Math.min(Math.max(n+(Oe(e)-.5)*De,0),1);return Math.round(r*(Ee-1))}function H(e){let[t=0,n=1,r=1]=e.split(`-`).map(Number);return Date.UTC(t,n-1,r)}function U(e,t){return Math.round((H(t)-H(e))/864e5)}function Ae(e,t,n){if(n<=0)return[0,0];let r=t-I,i=t+n+I,a=0;for(;a<e.length&&(e[a]??0)<r;)a+=1;let o=a;for(;o<e.length&&(e[o]??0)<=i;)o+=1;return[a,o]}function je(e,t){let n=[],r=``,i=``;for(let a=0;a<t;a+=1){let t=new Date(H(e)+a*864e5).toISOString().slice(0,10),o=F+a*N;t.slice(0,4)!==i&&(i=t.slice(0,4),n.push({x:o,said:i,year:!0})),t.slice(0,7)!==r&&(r=t.slice(0,7),n.push({x:o,said:C(t).split(` `)[1]??``,year:!1}))}return n}function Me(e){let{at:t,lines:n}=e,r=we+Math.sqrt(n)/e.tallest*Te,i=P-r,a=e.index%2==0?-3:3,o=P-r*.55;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`path`,{className:`hm-stem`,d:`M${t},${P} q${a},${-r/2} 0,${-r}`}),(0,g.jsx)(`ellipse`,{className:`hm-leaf`,cx:t-4,cy:o,rx:4,ry:2,transform:`rotate(-25 ${t-4} ${o})`}),n>=L?(0,g.jsx)(`circle`,{className:`hm-flower hm-shade-${ke(e.date,n)}`,cx:t,cy:i,r:n>=R?5.5:3.5}):(0,g.jsx)(`circle`,{className:`hm-bud`,cx:t,cy:i,r:2})]})}function Ne(e){let{days:t,today:n}=e,r=o({className:`hm-infotip`,side:`top`}),i=(0,m.useRef)(null),a=(0,m.useRef)(null),s=(0,m.useRef)([]),c=(0,m.useRef)([0,0]),[l,u]=(0,m.useState)(!1),d=t[0]?.date??n,p=t[t.length-1]?.date??n,h=Math.max(1,U(d,p>n?p:n)+1),_=h*N+F*2,v=Math.sqrt(Math.max(1,...t.map(V))),y=(0,m.useMemo)(()=>t.filter(e=>V(e)>0).map(e=>({day:e,x:F+U(d,e.date)*N})),[t,d]),x=(0,m.useCallback)(()=>{let e=i.current,t=a.current;if(e===null||t===null)return;let n=t.querySelectorAll(`g.hm-plant`),[r,o]=Ae(s.current,e.scrollLeft,e.clientWidth),[l,d]=c.current;for(let e=l;e<d;e+=1)(e<r||e>=o)&&n[e]?.classList.remove(`hm-sway`);for(let e=r;e<o;e+=1)n[e]?.classList.add(`hm-sway`);c.current=[r,o],u(e.scrollLeft>4)},[]);return(0,m.useEffect)(()=>{let e=i.current;if(e===null)return;s.current=y.map(e=>e.x),c.current=[0,0],e.scrollLeft=e.scrollWidth,x();let t=new ResizeObserver(x);return t.observe(e),()=>t.disconnect()},[x,y]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:l?`hm-garden-wrap hm-more`:`hm-garden-wrap`,children:[l&&(0,g.jsxs)(`div`,{className:`hm-earlier`,children:[(0,g.jsx)(`i`,{children:`‹`}),` earlier`]}),(0,g.jsxs)(`div`,{className:`hm-scroll`,ref:i,onScroll:x,"data-testid":`garden-scroll`,children:[(0,g.jsx)(`svg`,{className:`hm-garden`,ref:a,width:_,height:P,role:`img`,"aria-label":`One plant for each day worked on since ${S(d)}`,children:y.map(({day:t,x:n},r)=>(0,g.jsx)(`g`,{className:`hm-plant`,"data-day":t.date,style:{transformOrigin:`${n}px ${P}px`,animationDelay:`${r%7*-.4}s`},...e.hover(`${S(t.date)} · ${ne(t.added,t.deleted)} · ${b(t.commits,`commit`)}`),children:(0,g.jsx)(Me,{at:n,index:r,date:t.date,lines:V(t),tallest:v})},t.date))}),(0,g.jsx)(`div`,{className:`hm-axis`,style:{width:`${_}px`},children:je(d,h).map(e=>(0,g.jsx)(`span`,{className:e.year?`hm-year`:void 0,style:{left:`${e.x}px`},children:e.said},`${e.said}-${e.x}`))})]})]}),(0,g.jsxs)(`div`,{className:`hm-legend`,children:[(0,g.jsxs)(`span`,{children:[(0,g.jsx)(`b`,{children:`Each plant is one day`}),(0,g.jsxs)(`button`,{type:`button`,className:`hm-info`,"aria-label":`What a plant's height means`,"aria-describedby":B,...r.anchor,children:[(0,g.jsx)(f,{size:13}),(0,g.jsx)(`span`,{className:`visually-hidden`,id:B,children:z}),r.says(z)]})]}),(0,g.jsxs)(`span`,{children:[(0,g.jsx)(`i`,{className:`hm-key hm-bud-key`}),`a bud: a day with a change`]}),(0,g.jsxs)(`span`,{children:[(0,g.jsx)(`i`,{className:`hm-key hm-flower-key`}),`a flower: a day of 500 lines or more`]}),(0,g.jsxs)(`span`,{children:[(0,g.jsx)(`i`,{className:`hm-key hm-big-key`}),`a big flower: a day of 2,000 or more`]})]})]})}function Pe(e){let{repository:t,onTop:n,readAt:r,now:i}=e,a=(0,g.jsx)(Fe,{readAt:r,now:i,onRefresh:e.onRefresh});return t===null?(0,g.jsxs)(`div`,{className:`hm-head`,children:[(0,g.jsx)(`span`,{className:`hm-bar hm-bar-name`}),(0,g.jsx)(`span`,{className:`hm-bar`}),(0,g.jsx)(`span`,{className:`hm-bar`}),a]}):(0,g.jsxs)(`div`,{className:`hm-head`,children:[(0,g.jsx)(`span`,{className:`hm-repo`,children:t.name}),(0,g.jsxs)(`span`,{children:[(0,g.jsx)(`span`,{className:t.changedFiles>0?`hm-dot hm-dirty`:`hm-dot`}),t.detached?`${t.branch}, detached`:t.branch,` ·`,` `,te(t.changedFiles)]}),t.commits>0&&(0,g.jsxs)(g.Fragment,{children:[n===null?(0,g.jsx)(`span`,{children:b(t.commits,`commit`)}):(0,g.jsxs)(`span`,{children:[b(n.count,`commit`),` on top of `,n.base,` · `,y(t.commits),` `,`in total`]}),t.firstCommit!==null&&(0,g.jsxs)(`span`,{children:[`since `,S(t.firstCommit),t.shallow&&(0,g.jsx)(`span`,{className:`hm-muted`,children:` (shallow)`})]}),t.lastCommit!==null&&(0,g.jsxs)(`span`,{children:[`last commit `,u(t.lastCommit,i)]})]}),a]})}function Fe(e){return(0,g.jsxs)(`span`,{className:`hm-read`,children:[e.readAt!==null&&(0,g.jsxs)(`span`,{children:[`read `,u(e.readAt.toISOString(),e.now)]}),(0,g.jsxs)(`button`,{type:`button`,onClick:e.onRefresh,title:`Read the repository again`,children:[(0,g.jsx)(t,{size:13}),`Refresh`]})]})}var Ie=s();function Le(){let e=(0,m.useRef)(null),t=(0,m.useRef)(``);return{hover:(0,m.useCallback)(n=>({onMouseMove(r){t.current=n;let i=e.current;if(i===null)return;i.textContent=n;let a=l({left:r.clientX,top:r.clientY,width:0,height:0},{width:i.offsetWidth,height:i.offsetHeight},{width:window.innerWidth,height:window.innerHeight},`top`);i.style.left=`${a.left}px`,i.style.top=`${a.top}px`,i.classList.add(`hm-tip-on`)},onMouseLeave(){t.current===n&&(t.current=``,e.current?.classList.remove(`hm-tip-on`))}}),[]),node:(0,Ie.createPortal)((0,g.jsx)(`div`,{className:`tip hm-tip`,"aria-hidden":`true`,ref:e}),document.body)}}var W=`none`,G=`-`;function Re(e){let{facts:t,now:n}=e,r=t.longestStreak;return(0,g.jsx)(`div`,{className:`hm-list`,children:[[`First commit`,t.firstCommit===null?W:e.shallow?`${S(t.firstCommit)} (shallow)`:S(t.firstCommit),t.firstCommit===null?G:u(t.firstCommit,n)],[`Commits`,y(e.commits),`${t.commitsPerDay} a day`],[`Longest streak`,r===null?W:b(r.days,`day`),r===null?G:ee(r.from,r.to)],[`Biggest day`,t.biggestDay===null?W:S(t.biggestDay.date),t.biggestDay===null?G:b(t.biggestDay.commits,`commit`)],[`Last tag`,t.lastTag===null?W:t.lastTag.name,t.lastTag===null?G:u(t.lastTag.date,n)],[`Stashes`,y(t.stashes),G]].map(([e,t,n])=>(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{children:e}),(0,g.jsx)(`span`,{className:`hm-muted`,children:t}),(0,g.jsx)(`span`,{className:`hm-muted`,children:n})]},e))})}var K=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],ze=[`0`,`6`,`12`,`18`,`23`];function q(e){let t=Math.max(...e.counts);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:e.wide===!0?`hm-bars hm-bars-wide`:`hm-bars`,children:e.counts.map((n,r)=>(0,g.jsx)(`i`,{className:n===t&&t>0?`hm-tall`:void 0,style:{height:t>0?`${n/t*100}%`:`0%`},...e.hover(e.said(r,n))},r))}),(0,g.jsx)(`div`,{className:`hm-axis-x`,children:e.marks.map(e=>(0,g.jsx)(`span`,{children:e},e))})]})}function Be(e){return(0,g.jsx)(q,{counts:e.counts,marks:ze,hover:e.hover,said:(e,t)=>`${String(e).padStart(2,`0`)}:00 - ${b(t,`commit`)}`})}function Ve(e){return(0,g.jsx)(q,{counts:e.counts,marks:K,wide:!0,hover:e.hover,said:(e,t)=>`${K[e]} - ${b(t,`commit`)}`})}var J=c(`home`);J.receive;var He=J.credentialsReady,Ue=J.onSession;J.openOutside;var We=J.sayWaiting,Ge=J.listen,Ke=1e4,Y=[`#3987e5`,`#8b949e`,`#c98500`,`#199e70`,`#d95926`,`#d55181`,`#4f74d6`];function qe(e,t){if(e===null)return{size:`ignored files not counted yet`,when:``};let n=a(e.bytes),r=e.largest.map(e=>e.path).join(`, `),i=r===``?``:` (${r})`,o=e.atLeast?`the count hit its ${Ke/1e3} s limit · `:``;return{size:`${e.atLeast?`at least ${n}`:n} ignored${i}`,when:`${o}counted ${u(e.countedAt,t)}`}}function Je(e){let t=qe(e.ignored,e.now);return(0,g.jsxs)(`div`,{children:[e.kinds.map((e,t)=>(0,g.jsx)(_,{name:e.kind,width:e.share,colour:Y[t%Y.length]??``,value:`${e.share}%`},e.kind)),(0,g.jsxs)(`div`,{className:`hm-sub`,children:[b(e.tracked.files,`tracked file`),` · `,y(e.tracked.lines),` lines ·`,` `,a(e.tracked.bytes),` tracked · `,(0,g.jsx)(`b`,{children:t.size}),t.when!==``&&` · ${t.when}`]})]})}var X=d({prefix:`home`,label:`Home`,credentialsReady:He});function Ye(){return X.ask(`history`)}function Xe(){return X.ask(`branches`)}function Ze(){return X.ask(`tree`)}var Z={status:`waiting`};function Qe(e){let t=e instanceof Error?e.message:String(e);return t===``?`the Home tool could not read the repository`:t}function $e(){let[e,t]=(0,m.useState)(Z),[n,r]=(0,m.useState)(Z),[i,a]=(0,m.useState)(Z),[o,s]=(0,m.useState)(null),c=(0,m.useRef)(0),l=(0,m.useRef)(!0);return(0,m.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),{history:e,branches:n,tree:i,readAt:o,read:(0,m.useCallback)(()=>{c.current+=1;let e=c.current,n=()=>l.current&&c.current===e;s(new Date);let i=(e,t)=>{t(Z),e().then(e=>{n()&&t({status:`read`,answer:e})},e=>{n()&&t({status:`failed`,said:Qe(e)})})};i(Ye,t),i(Xe,r),i(Ze,a)},[])}}function et(e){let t=(0,m.useRef)(e);t.current=e,(0,m.useEffect)(()=>{let e=!1,n=new ResizeObserver(n=>{let r=(n[n.length-1]?.contentRect.width??0)>0;r&&!e&&t.current(),e=r});return n.observe(document.documentElement),()=>n.disconnect()},[])}function tt(e){return e===1?`active day`:`active days`}var nt=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function rt(e){return{year:e.getFullYear(),month:e.getMonth(),date:e.getDate()}}function it(e,t,n){let r=new Date(e,t,n),i=String(r.getMonth()+1).padStart(2,`0`),a=String(r.getDate()).padStart(2,`0`);return`${r.getFullYear()}-${i}-${a}`}function Q(e,t,n,r){let i=[];for(let a=0;a<r;a++)i.push(it(e,t,n+a));return i}function at(e){return(e.getDay()+6)%7+1}function ot(e,t){return new Date(e,t+1,0).getDate()}function $(e,t){return t.filter(t=>(e.get(t)?.commits??0)>0).length}function st(e,t){let n=0,r=0;for(let i of t){let t=e.get(i);t!==void 0&&(n+=t.added,r+=t.deleted)}return{added:n,deleted:r}}function ct(e,t,n){if(t===0)return e===0?{said:`none on ${n} either`,up:!1}:{said:`none on ${n}`,up:!0};let r=Math.round((e-t)/t*100);return{said:`${r>=0?`+`:``}${r}% on ${n}`,up:r>0}}function lt(e,t){let n=new Map(e.map(e=>[e.date,e])),r=rt(t),i=Q(r.year,r.month,1,r.date),a=r.month===0?{year:r.year-1,month:11}:{year:r.year,month:r.month-1},o=Q(a.year,a.month,1,Math.min(r.date,ot(a.year,a.month))),s=at(t),c=Q(r.year,r.month,r.date-s+1,s),l=Q(r.year,r.month,r.date-s-6,s),u=st(n,c);return{month:{planted:$(n,i),name:nt[r.month]??``,against:ct($(n,i),$(n,o),`the same days of ${nt[a.month]??``}`)},week:{planted:$(n,c),against:ct($(n,c),$(n,l),`the same days last week`)},lines:{added:u.added,deleted:u.deleted,perDay:Math.round((u.added+u.deleted)/s)}}}function ut(e){let t=lt(e.days,e.now);return(0,g.jsxs)(`div`,{className:`hm-tiles`,children:[(0,g.jsxs)(`div`,{className:`hm-card hm-tile`,children:[(0,g.jsxs)(`div`,{className:`hm-big`,children:[y(t.month.planted),` `,(0,g.jsxs)(`span`,{className:`hm-span`,children:[tt(t.month.planted),` in `,t.month.name]})]}),(0,g.jsx)(`div`,{className:`hm-sub`,children:(0,g.jsx)(dt,{...t.month.against})})]}),(0,g.jsxs)(`div`,{className:`hm-card hm-tile`,children:[(0,g.jsxs)(`div`,{className:`hm-big`,children:[y(t.week.planted),` `,(0,g.jsxs)(`span`,{className:`hm-span`,children:[tt(t.week.planted),` since Monday`]})]}),(0,g.jsx)(`div`,{className:`hm-sub`,children:(0,g.jsx)(dt,{...t.week.against})})]}),(0,g.jsxs)(`div`,{className:`hm-card hm-tile`,children:[(0,g.jsxs)(`div`,{className:`hm-big hm-lines`,children:[(0,g.jsxs)(`span`,{className:`hm-added`,children:[`+`,y(t.lines.added)]}),(0,g.jsx)(`span`,{className:`hm-slash`,children:` / `}),(0,g.jsxs)(`span`,{className:`hm-deleted`,children:[`-`,y(t.lines.deleted)]})]}),(0,g.jsxs)(`div`,{className:`hm-sub`,children:[`lines since Monday · `,y(t.lines.perDay),` a day on average`]})]})]})}function dt(e){return(0,g.jsx)(`span`,{className:e.up?`hm-up`:void 0,children:e.said})}function ft(e){if(e===null||e.default===null)return null;let t=e.branches.find(e=>e.current);return t===void 0||t.name===e.default?null:{count:t.ahead,base:e.default}}function pt(){let e=$e(),n=p(!0),r=Le(),[i,a]=(0,m.useState)(!0);(0,m.useEffect)(()=>Ue(e=>a(e.sound)),[]);let o=M();et(e.read),(0,m.useEffect)(()=>{We(0,!0)},[]);let s=e.history,c=s.status===`read`?s.answer:null,l=c===null?null:c.repository;if(c!==null&&c.repository===null)return(0,g.jsx)(`div`,{className:`hm-page`,children:(0,g.jsx)(`div`,{className:`hm-column`,children:(0,g.jsx)(`p`,{className:`hm-plain`,children:`This workspace holds no git repository, so there is no pulse to show.`})})});let u=l===null?`loading`:`read`,d=e.branches,f=e.tree,h=e=>e.status===`read`?`read`:e.status===`failed`?`failed`:`loading`,_=e=>e.status===`failed`?e.said:void 0,v=d.status===`read`&&d.answer.repository!==null?d.answer:null,y=f.status===`read`&&f.answer.repository!==null?f.answer:null,b=c!==null&&c.repository!==null?c:null,x=l!==null&&l.commits===0,S=(0,g.jsx)(w,{title:`Branches`,note:v===null?void 0:de(v.branches),state:h(d),said:_(d),loaderHeight:130,children:v!==null&&(0,g.jsx)(pe,{branches:v.branches,default:v.default,now:n})}),C=(0,g.jsx)(w,{title:`The tree`,note:`what the workspace is made of`,state:h(f),said:_(f),loaderHeight:130,children:y!==null&&(0,g.jsx)(Je,{kinds:y.kinds,tracked:y.tracked,ignored:y.ignored,now:n})});return s.status===`failed`?(0,g.jsxs)(`div`,{className:o?`hm-page hm-still`:`hm-page`,children:[(0,g.jsxs)(`div`,{className:`hm-column`,children:[(0,g.jsxs)(`div`,{className:`hm-failed`,children:[(0,g.jsx)(`span`,{children:s.said}),` `,(0,g.jsx)(`span`,{className:`hm-muted`,children:`Press Refresh to try again.`}),(0,g.jsx)(`span`,{className:`hm-read`,children:(0,g.jsxs)(`button`,{type:`button`,onClick:e.read,title:`Read the repository again`,children:[(0,g.jsx)(t,{size:13}),`Refresh`]})})]}),(0,g.jsxs)(`div`,{className:`hm-grid`,children:[S,C]})]}),r.node,(0,g.jsx)(Ce,{sound:i})]}):(0,g.jsxs)(`div`,{className:o?`hm-page hm-still`:`hm-page`,children:[(0,g.jsxs)(`div`,{className:`hm-column`,children:[(0,g.jsx)(Pe,{repository:l,onTop:ft(v),readAt:e.readAt,now:n,onRefresh:e.read}),x?(0,g.jsx)(`p`,{className:`hm-plain`,children:`This repository has no commit yet. The page fills in as the work starts.`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(w,{state:u,loaderHeight:192,className:`hm-garden-card`,children:[b!==null&&(0,g.jsx)(Ne,{days:b.days,today:b.readAt.slice(0,10),hover:r.hover}),b?.repository.cut===!0&&(0,g.jsx)(`p`,{className:`hm-cut`,children:`The full history was too large to walk, so this garden is the last two years alone.`})]}),b===null?(0,g.jsxs)(`div`,{className:`hm-tiles`,children:[(0,g.jsx)(`div`,{className:`hm-card hm-tile`,children:(0,g.jsx)(`div`,{className:`hm-loader`,style:{height:`46px`}})}),(0,g.jsx)(`div`,{className:`hm-card hm-tile`,children:(0,g.jsx)(`div`,{className:`hm-loader`,style:{height:`46px`}})}),(0,g.jsx)(`div`,{className:`hm-card hm-tile`,children:(0,g.jsx)(`div`,{className:`hm-loader`,style:{height:`46px`}})})]}):(0,g.jsx)(ut,{days:b.days,now:n}),(0,g.jsxs)(`div`,{className:`hm-grid`,children:[(0,g.jsx)(w,{title:`Rhythm`,note:`commits by hour, author time`,state:u,loaderHeight:84,children:b!==null&&(0,g.jsx)(Be,{counts:b.hours,hover:r.hover})}),(0,g.jsx)(w,{title:`Rhythm`,note:`commits by weekday`,state:u,loaderHeight:84,children:b!==null&&(0,g.jsx)(Ve,{counts:b.weekdays,hover:r.hover})})]}),(0,g.jsxs)(`div`,{className:`hm-grid`,children:[S,(0,g.jsx)(w,{title:`Where the work goes`,note:`lines changed in the last 30 days, against the 30 before`,state:u,loaderHeight:130,children:b!==null&&(0,g.jsx)(ae,{areas:b.areas})})]}),(0,g.jsxs)(`div`,{className:`hm-grid`,children:[C,(0,g.jsx)(w,{title:`Milestones`,state:u,loaderHeight:130,children:b!==null&&(0,g.jsx)(Re,{facts:b.milestones,commits:b.repository.commits,now:n,shallow:b.repository.shallow})})]})]})]}),r.node,(0,g.jsx)(Ce,{sound:i})]})}Ge();var mt=document.getElementById(`root`);mt&&(0,h.createRoot)(mt).render((0,g.jsx)(m.StrictMode,{children:(0,g.jsx)(pt,{})}));