notemend 0.1.8 → 0.1.9
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/.claude-plugin/plugin.json +1 -1
- package/bin/notemend.mjs +14 -14
- package/package.json +1 -1
- package/src/client/anchor.js +1 -0
- package/src/client/boot.js +1 -1
- package/src/client/config.js +1 -1
- package/src/client/field-menu.js +1 -0
- package/src/client/inspect.js +1 -0
- package/src/client/markup.js +1 -0
- package/src/client/notemend.css +1 -1
- package/src/client/run.js +72 -71
- package/src/server/middleware.mjs +1 -1
- package/src/store/cloud.mjs +3 -3
- package/src/store/comments.mjs +3 -3
- package/src/store/thread.mjs +1 -1
- package/thread.d.ts +4 -0
package/src/client/run.js
CHANGED
|
@@ -1,110 +1,111 @@
|
|
|
1
|
-
import{categoryOf as ge}from"../store/categories.mjs";import{stateOf as R,STATE_LABEL as Cs}from"../store/status.mjs";import{agentName as tt,handleOf as Ns,threadOf as Bs,workingOn as Rs}from"../store/thread.mjs";import{api as j,canvasCopy as Is,host as qs,imageUrl as Ds}from"./api";import{DEVTOOLS_DEVICES as Lo}from"../devtools-devices.mjs";import{drawDevice as Os,pageTints as Ps,inkFor as xo}from"./devices";import{recentLogs as Fs}from"./logs";function Ys(v){const I=v.breakpoints,ln=v.categories,fe=(I.find(t=>!Number.isFinite(t.max))??I[0]).id,Mt=t=>I.find(e=>t>=e.min&&t<=e.max)?.id??fe,et=t=>t.breakpoint||fe,Vt=t=>v.devices.find(e=>e.id===t),E=Is,V=(t,e)=>{E||localStorage.setItem(t,e)},he=t=>t.replace(/\/+$/,"")||"/";let K=he(location.pathname);for(const t of document.querySelectorAll(".devtools .dt-icon[title]"))t.dataset.tip=t.title,t.getAttribute("aria-label")||t.setAttribute("aria-label",t.title),t.removeAttribute("title");const dn=document.querySelector(".dt-grid-btn"),Ut=document.querySelector(".dt-grid-overlay"),cn="dt-grid",be=t=>{Ut.hidden=!t,dn.setAttribute("aria-pressed",String(t)),V(cn,t?"1":"0"),O({grid:t})};dn.addEventListener("click",()=>be(Ut.hidden===!0));const un=document.querySelector(".dt-pages-name"),pn=()=>{let t=null;for(const o of document.querySelectorAll(".dt-pages a"))he(new URL(o.href).pathname)===K?(o.setAttribute("aria-current","page"),t=o):o.removeAttribute("aria-current");const e=document.title.split("\u2014").pop()?.trim(),n=t?.querySelector(".dt-menu-label")?.textContent?.trim();un.textContent=n||e||un.textContent};pn();const mn=[...document.querySelectorAll(".devtools details")];let ye=!1;const kt=()=>{const t=mn.filter(e=>e.open);for(const e of t)e.open=!1;return t};document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const[e]=kt();e&&(e.querySelector("summary")?.focus(),t.preventDefault(),t.stopImmediatePropagation())},!0),document.addEventListener("pointerdown",t=>{ye=mn.some(e=>e.open&&!e.contains(t.target))&&kt().length>0},!0),addEventListener("blur",kt);const st=document.querySelector(".dt-pad-overlay"),gn="dt-inspect",To=[".devtools",".dt-pad-overlay",".dt-grid-overlay",".dt-frame",".dt-history",".dt-review",".dt-field-menu",...v.ignore].join(", "),ve=[".devtools",".dt-notes-overlay",".dt-history",".dt-frame",".dt-review",".dt-field-menu",...v.ignore].join(", "),$e={pads:document.querySelector(".dt-pad-btn"),sizes:document.querySelector(".dt-size-btn"),type:document.querySelector(".dt-type-btn")};let pt="",Ee=0;const H=t=>{const e=parseFloat(getComputedStyle(document.documentElement).fontSize)/16,n=t/e;return Math.round(n*10)%10===0?String(Math.round(n)):n.toFixed(1)},U=(t,e,n,o,s,a="p")=>{if(n<=0||o<=0)return"";const c=s!==""?`<span class="dt-pad-chip dt-pad-chip--${a}" style="left:${t+n/2}px;top:${e+o/2}px">${s}</span>`:"";return`<span class="dt-pad-zone dt-pad-zone--${a}" style="left:${t}px;top:${e}px;width:${n}px;height:${o}px"></span>${c}`},Mo=["paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft","columnGap","rowGap"],ko=t=>{let e=t;for(let n=0;e&&n<6;n++,e=e.parentElement){const o=getComputedStyle(e);if(Mo.some(s=>parseFloat(o[s])>=2))return e}return t},Ho=(t,e)=>{const n=parseFloat(e.columnGap)||0,o=parseFloat(e.rowGap)||0;if(!(e.display.includes("flex")||e.display.includes("grid"))||!n&&!o)return"";const s=[...t.children].map(c=>c.getBoundingClientRect()).filter(c=>c.width||c.height);let a="";for(let c=1;c<s.length;c++){const d=s[c-1],r=s[c];if(n&&r.left>=d.right-1){const l=Math.max(d.top,r.top);a+=U(d.right,l,r.left-d.right,Math.min(d.bottom,r.bottom)-l,H(n),"g")}else if(o&&r.top>=d.bottom-1){const l=Math.min(d.left,r.left);a+=U(l,d.bottom,Math.max(d.right,r.right)-l,r.top-d.bottom,H(o),"g")}}return a},we=t=>`<span class="dt-pad-outline" style="left:${t.left}px;top:${t.top}px;width:${t.width}px;height:${t.height}px"></span>`,Se=(t,e,n="")=>`<span class="dt-pad-tag" style="left:${e.left}px;top:${Math.max(2,e.top-22)}px">${t.tagName.toLowerCase()+(t.classList[0]?"."+t.classList[0]:"")}${n}</span>`,Ao=t=>{const e=t.getBoundingClientRect(),n=getComputedStyle(t),o=parseFloat(n.paddingTop),s=parseFloat(n.paddingRight),a=parseFloat(n.paddingBottom),c=parseFloat(n.paddingLeft);let d=we(e);d+=U(e.left,e.top,e.width,o,o>=2?H(o):""),d+=U(e.left,e.bottom-a,e.width,a,a>=2?H(a):""),d+=U(e.left,e.top+o,c,e.height-o-a,c>=2?H(c):""),d+=U(e.right-s,e.top+o,s,e.height-o-a,s>=2?H(s):"");const r=parseFloat(n.marginTop),l=parseFloat(n.marginRight),p=parseFloat(n.marginBottom),b=parseFloat(n.marginLeft);d+=U(e.left,e.top-r,e.width,r,r>=2?H(r):"","m"),d+=U(e.left,e.bottom,e.width,p,p>=2?H(p):"","m"),d+=U(e.left-b,e.top,b,e.height,b>=2?H(b):"","m"),d+=U(e.right,e.top,l,e.height,l>=2?H(l):"","m"),d+=Ho(t,n);const i=parseFloat(n.columnGap)||0,$=parseFloat(n.rowGap)||0,k=(n.display.includes("flex")||n.display.includes("grid"))&&(i||$)?` \xB7 gap ${H(i)}${$&&$!==i?"/"+H($):""}`:"";st.innerHTML=d+Se(t,e,k)},Co=t=>{const e=t.getBoundingClientRect();st.innerHTML=we(e)+`<span class="dt-pad-chip" style="left:${e.left+e.width/2}px;top:${e.top+e.height/2}px">${H(e.width)} \xD7 ${H(e.height)}</span>`+Se(t,e)},fn=t=>{const e=(t.match(/[\d.]+/g)||[]).map(Number);if(e.length<3)return t;const n="#"+e.slice(0,3).map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");return e[3]!==void 0&&e[3]<1?`${n} \xB7 ${Math.round(e[3]*100)}%`:n};let Le=null;const No=()=>{if(Le)return Le;const t=getComputedStyle(document.documentElement),e=document.createElement("span");e.style.display="none",document.body.append(e);const n=[];for(const o of Array.from(t)){if(!o.startsWith("--"))continue;const s=t.getPropertyValue(o).trim();if(!/^(#|rgb|hsl|oklch|lab|color\()/i.test(s))continue;e.style.color="rgb(1, 2, 3)",e.style.color=s;const a=getComputedStyle(e).color;a&&a!=="rgb(1, 2, 3)"&&n.push([a,o])}return e.remove(),n.sort((o,s)=>o[1].length-s[1].length),Le=n,n},Bo=t=>No().find(([e])=>e===t)?.[1]??"",Ro={100:"Thin",200:"Extra Light",300:"Light",400:"Regular",500:"Medium",600:"Semi Bold",700:"Bold",800:"Extra Bold",900:"Black"},hn=t=>(t.match(/[\d.]+/g)??[]).map(Number).concat([1]).slice(0,4),bn=(t,e)=>t.slice(0,3).map((n,o)=>n*t[3]+e[o]*(1-t[3])).concat([1]),Io=t=>{const e=[];for(let n=t;n;n=n.parentElement){const o=getComputedStyle(n);if(o.backgroundImage!=="none")return null;const s=hn(o.backgroundColor);if(s[3]>0&&(e.push(s),s[3]>=1))break}return e.reduceRight((n,o)=>bn(o,n),[255,255,255,1])},yn=t=>{const[e,n,o]=t.slice(0,3).map(s=>(s/=255,s<=.03928?s/12.92:((s+.055)/1.055)**2.4));return .2126*e+.7152*n+.0722*o},qo=(t,e,n)=>{const o=Io(t);if(!o)return["Contrast","<em>on an image</em>"];const s=bn(hn(e.color),o),[a,c]=[yn(s),yn(o)].sort((p,b)=>b-p),d=(a+.05)/(c+.05),r=n>=24||n>=18.66&&Number(e.fontWeight)>=700,l=d>=(r?4.5:7)?"AAA":d>=(r?3:4.5)?"AA":"fails AA";return["Contrast",`${d.toFixed(2)}:1 <em class="${l==="fails AA"?"dt-type-bad":""}">${l}${r?" \xB7 large":""}</em>`]},Do=t=>{const e=t.getBoundingClientRect(),n=getComputedStyle(t),o=parseFloat(n.fontSize),s=n.lineHeight==="normal"?0:parseFloat(n.lineHeight),a=parseFloat(n.letterSpacing)||0,c=Bo(n.color),d=i=>`${(i*100).toFixed(1).replace(/\.0$/,"")}%`,r=[["Font",n.fontFamily.split(",")[0].replace(/["']/g,"")+(n.fontStyle!=="normal"?` ${n.fontStyle}`:"")],["Weight",`${Ro[n.fontWeight]??""} <em>${n.fontWeight}</em>`],["Size",`${H(o)}px`],["Line",s?`${d(s/o)} <em>${H(s)}px</em>`:"normal"],["Letter",a?`${d(a/o)} <em>${a.toFixed(2).replace(/\.?0+$/,"")}px</em>`:"0"],["Color",`<i class="dt-type-sw" style="background:${n.color}"></i>${c?`${c} <em>${fn(n.color)}</em>`:fn(n.color)}`],qo(t,n,o)],p=e.bottom+150<innerHeight?e.bottom+8:Math.max(8,e.top-158),b=Math.min(Math.max(8,e.left),innerWidth-210);st.innerHTML=we(e)+Se(t,e)+`<div class="dt-type-card" style="left:${b}px;top:${p}px">${r.map(([i,$])=>`<span class="dt-type-row"><b>${i}</b><span>${$}</span></span>`).join("")}</div>`},vn=t=>{Ee||(Ee=requestAnimationFrame(()=>{Ee=0,st.hidden=!0;let e=document.elementFromPoint(t.clientX,t.clientY);if(st.hidden=!1,!e||e.closest(To)){st.innerHTML="";return}t.altKey&&e.parentElement&&e.parentElement!==document.body&&(e=e.parentElement),pt==="sizes"?Co(e):pt==="type"?Do(e):Ao(t.altKey?e:ko(e))}))},Yt=t=>{pt=t;for(const[e,n]of Object.entries($e))n.setAttribute("aria-pressed",String(e===t));V(gn,t),O({inspect:t}),st.hidden=!t,st.innerHTML="",t?document.addEventListener("mousemove",vn):document.removeEventListener("mousemove",vn)};for(const[t,e]of Object.entries($e))e.addEventListener("click",()=>{t!==pt&<(!1),Yt(pt===t?"":t)});const $n=document.querySelector(".dt-notes-btn"),xe=[...document.querySelectorAll(".dt-bp")],Jt=document.querySelector(".dt-history-btn"),F=document.querySelector(".dt-history"),Te=document.querySelector(".dt-studio-btn"),S=document.querySelector(".dt-device"),En=document.querySelector(".dt-shell"),Ht=document.querySelector('.dt-chrome[data-at="top"]'),Xt=document.querySelector('.dt-chrome[data-at="bottom"]'),At=document.querySelector(".dt-ruler"),Y=document.querySelector(".dt-devices"),mt=document.querySelector(".dt-notes-hi"),Oo=mt.querySelector(".dt-hi-box"),wn=mt.querySelector(".dt-hi-tag"),Po=[...document.querySelectorAll(".dt-frame-handle")],Sn=document.querySelector(".dt-frame-size"),Me=document.querySelector(".dt-frame-rotate"),Ct=document.querySelector(".dt-frame-bars"),N=document.querySelector(".dt-frame"),L=N.querySelector("iframe"),ke=document.querySelector(".dt-notes-count"),f=document.querySelector(".dt-notes-overlay"),Fo=".devtools, .dt-tab, .dt-notes-overlay, .dt-history, .dt-frame, .dt-review";for(const t of document.querySelectorAll(Fo))for(const e of["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend","click","focusin","focusout"])t.addEventListener(e,n=>n.stopPropagation());const Ln="dt-notes";let h=[],A=!1,y=null,u=null,He=0,W="",at=[],x=null,q=[];const Zt=(t=u)=>!!(t&&(t.text?.trim()||t.images?.length)),z=()=>{u&&Zt()&&q.push(u),u=null};let Nt=null,nt=null;const xn=()=>`dt-draft:${K}${E?":canvas":""}`;let yt=xn(),Qt=0;const Ae=()=>{if(!u&&!q.length&&!W){localStorage.removeItem(yt);return}const t={draft:u,parked:q,reply:W?{for:Nt,text:W}:null};try{localStorage.setItem(yt,JSON.stringify(t))}catch{const e=n=>({...n,images:void 0});try{localStorage.setItem(yt,JSON.stringify({...t,draft:u&&e(u),parked:q.map(e)}))}catch{}}},te=()=>{clearTimeout(Qt),Qt=setTimeout(Ae,200)};addEventListener("pagehide",()=>{clearTimeout(Qt),Ae()});let J=localStorage.getItem("dt-resolved")!=="0";const jo=[[/Edg\/(\d+)/,"Edge"],[/OPR\/(\d+)/,"Opera"],[/Firefox\/(\d+)/,"Firefox"],[/Chrome\/(\d+)/,"Chrome"],[/Version\/(\d+).*Safari/,"Safari"]],Ko=[[/iPhone|iPad/,"iOS"],[/Android/,"Android"],[/Mac OS X/,"macOS"],[/Windows/,"Windows"],[/Linux/,"Linux"]],Wo=()=>{const t=navigator.userAgent,e=a=>a.find(([c])=>c.test(t)),n=e(jo),o=e(Ko),s=n?n[0].exec(t)?.[1]:null;return[n?`${n[1]}${s?" "+s:""}`:"unknown browser",o?.[1]].filter(Boolean).join(" \xB7 ")},rt=()=>Mt(innerWidth),ee=()=>nt??rt(),Bt=()=>{const t=ee();for(const e of xe)e.setAttribute("aria-pressed",String(e.dataset.bp===t))},zo=t=>{const e=[];let n=t;for(;n&&n.tagName!=="HTML"&&e.length<8;){if(n.id){e.unshift("#"+CSS.escape(n.id));break}const o=n.parentElement,s=n.tagName.toLowerCase(),a=o?[...o.children].filter(c=>c.tagName===n.tagName):[];e.unshift(a.length>1?`${s}:nth-of-type(${a.indexOf(n)+1})`:s),n=o}return e.join(">")},Ce=(t,e)=>!e||_(t.textContent||"").slice(0,60)===e,_o=(t,e)=>[t||"*",...(e||[]).map(n=>"."+CSS.escape(n))].join(""),Tn=t=>{try{return[...document.querySelectorAll(_o(t.tag,t.classes))]}catch{return[]}},Mn=t=>{const e=_(t.textContent||"").replace(/\s+/g," ");for(let n=t.parentElement,o=0;n&&n!==document.body&&o<4;n=n.parentElement,o++){const s=_(n.textContent||"").replace(/\s+/g," ");if(s&&s!==e)return s}return""},Go=t=>Mn(t).slice(0,80),Ne=(t,e)=>!e||Mn(t).startsWith(e),X=t=>{let e=null;try{e=document.querySelector(t.selector)}catch{e=null}if(e&&Ce(e,t.label)&&Ne(e,t.ctx))return e;const n=Tn(t),o=_(t.label)?n.filter(a=>Ce(a,t.label)):[];return(o.find(a=>Ne(a,t.ctx))??n.find(a=>t.ctx&&Ne(a,t.ctx)&&!_(t.label)))||o[0]||(e&&Ce(e,t.label)?e:null)||(t.nth!=null?n[t.nth]:null)||n[0]||e},Vo=t=>{let e=null;for(let n=t,o=t.parentElement;o&&o!==document.body&&getComputedStyle(n).position!=="fixed";n=o,o=o.parentElement){const s=getComputedStyle(o);if(s.overflowX==="visible"&&s.overflowY==="visible")continue;const a=o.getBoundingClientRect();e=e?{l:Math.max(e.l,a.left),t:Math.max(e.t,a.top),r:Math.min(e.r,a.right),b:Math.min(e.b,a.bottom)}:{l:a.left,t:a.top,r:a.right,b:a.bottom}}return e},Z=t=>{const e=X(t);if(!e)return null;const n=e.getBoundingClientRect();if(!n.width&&!n.height)return null;const o=n.left+n.width*t.rx,s=n.top+n.height*t.ry,a=Vo(e);if(!a)return{x:o,y:s,off:""};if(a.r-a.l<18||a.b-a.t<18)return null;const c=Math.min(Math.max(o,a.l),a.r-18),d=Math.min(Math.max(s,a.t+18),a.b),r=o<a.l?"l":o>a.r-18?"r":s<a.t+18?"t":s>a.b?"b":"";return{x:c,y:d,off:r}},kn=t=>{for(let e=t;e&&e!==document.body;e=e.parentElement)if(e.getAnimations().some(n=>n.playState==="running"))return!0;return!1};let ne=[];const Be=t=>{for(const e of ne)e.play();ne=[];for(let e=t;e&&e!==document.body;e=e.parentElement)for(const n of e.getAnimations())n.playState==="running"&&(n.pause(),ne.push(n))},Hn=()=>{if(u)return X(u);const t=y!=null?h.find(n=>n.id===y):null;if(!t)return null;const e=Z(t);return e&&!e.off?X(t):null},An=t=>t?new Date(t).toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):"",oe='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4 6h12M8 6V4.2h4V6M6.6 6l.55 9.8h5.7L13.4 6"/></svg>',Uo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M3.5 4.5h13v3h-13zM4.8 7.5v8h10.4v-8M8.2 10.5h3.6"/></svg>',Rt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.8 10.4 8.2 13.8l7-7.6" stroke-linejoin="round"/></svg>',Re='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><path d="M12.6 4.4l3 3-8.4 8.4H4.2v-3z" stroke-linejoin="round"/></svg>',se='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M5.4 5.4l9.2 9.2M14.6 5.4l-9.2 9.2"/></svg>',Yo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M12 5l-5 5 5 5" stroke-linejoin="round"/></svg>',Jo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M8 5l5 5-5 5" stroke-linejoin="round"/></svg>',Xo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.5 8.5h7.5a3.5 3.5 0 0 1 0 7H8.5M7.5 5.5l-3 3 3 3" stroke-linejoin="round"/></svg>',It=t=>`<svg viewBox="0 0 24 24" width="${t}" height="${t}" aria-hidden="true" class="dt-claude"><path d="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"/></svg>`,Cn=()=>{try{return localStorage.getItem("nm-for")??"claude"}catch{return"claude"}},qt=t=>t==="claude"?"#d97757":t?"#0d99ff":"#717171",Nn=(t,e)=>`<label class="dt-field"><span class="dt-field-label">For</span><span class="dt-field-box" style="--cat:${qt(t)}"><select class="dt-for-select"${e?` data-id="${e}"`:""} aria-label="Who this is for">
|
|
2
|
-
<option value="claude" data-c="${
|
|
3
|
-
<option value="" data-c="${
|
|
4
|
-
${(
|
|
5
|
-
</select></span></label>`,
|
|
6
|
-
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="10" r="7.4"/><path d="M10 9.2v4.4M10 6.4v.6"/></svg></span>`:"",
|
|
7
|
-
<textarea class="${t}" rows="1" placeholder="${e}">${
|
|
1
|
+
import{categoryOf as de}from"../store/categories.mjs";import{stateOf as C,STATE_LABEL as ds}from"../store/status.mjs";import{agentName as J,handleOf as cs,held as us,threadOf as ps,workingOn as ms}from"../store/thread.mjs";import{api as B,canvasCopy as gs,host as fs,imageUrl as hs}from"./api";import{DEVTOOLS_DEVICES as co}from"../devtools-devices.mjs";import{drawDevice as bs,pageTints as ys,inkFor as uo}from"./devices";import{recentLogs as vs}from"./logs";import{inspectors as $s}from"./inspect";import{anchors as Es,clean as wt}from"./anchor";import{fieldMenus as ws}from"./field-menu";function Is(b){const I=b.breakpoints,Xe=b.categories,ce=(I.find(t=>!Number.isFinite(t.max))??I[0]).id,St=t=>I.find(e=>t>=e.min&&t<=e.max)?.id??ce,G=t=>t.breakpoint||ce,Wt=t=>b.devices.find(e=>e.id===t),v=gs,_=(t,e)=>{v||localStorage.setItem(t,e)},ue=t=>t.replace(/\/+$/,"")||"/";let K=ue(location.pathname);for(const t of document.querySelectorAll(".devtools .dt-icon[title]"))t.dataset.tip=t.title,t.getAttribute("aria-label")||t.setAttribute("aria-label",t.title),t.removeAttribute("title");const Ze=document.querySelector(".dt-grid-btn"),_t=document.querySelector(".dt-grid-overlay"),Qe="dt-grid",pe=t=>{_t.hidden=!t,Ze.setAttribute("aria-pressed",String(t)),_(Qe,t?"1":"0"),D({grid:t})};Ze.addEventListener("click",()=>pe(_t.hidden===!0));const tn=document.querySelector(".dt-pages-name"),en=()=>{let t=null;for(const o of document.querySelectorAll(".dt-pages a"))ue(new URL(o.href).pathname)===K?(o.setAttribute("aria-current","page"),t=o):o.removeAttribute("aria-current");const e=document.title.split("\u2014").pop()?.trim(),n=t?.querySelector(".dt-menu-label")?.textContent?.trim();tn.textContent=n||e||tn.textContent};en();const nn=[...document.querySelectorAll(".devtools details")];let me=!1;const Lt=()=>{const t=nn.filter(e=>e.open);for(const e of t)e.open=!1;return t};document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const[e]=Lt();e&&(e.querySelector("summary")?.focus(),t.preventDefault(),t.stopImmediatePropagation())},!0),document.addEventListener("pointerdown",t=>{me=nn.some(e=>e.open&&!e.contains(t.target))&&Lt().length>0},!0),addEventListener("blur",Lt);const gt=document.querySelector(".dt-pad-overlay"),on="dt-inspect",po=[".devtools",".dt-pad-overlay",".dt-grid-overlay",".dt-frame",".dt-history",".dt-review",".dt-field-menu",...b.ignore].join(", "),ge=[".devtools",".dt-notes-overlay",".dt-history",".dt-frame",".dt-review",".dt-field-menu",'[aria-modal="true"]',...b.ignore].join(", "),fe={pads:document.querySelector(".dt-pad-btn"),sizes:document.querySelector(".dt-size-btn"),type:document.querySelector(".dt-type-btn")};let lt="",he=0;const{spacer:mo,drawPads:go,drawSize:fo,drawType:ho}=$s(gt),sn=t=>{he||(he=requestAnimationFrame(()=>{he=0,gt.hidden=!0;let e=document.elementFromPoint(t.clientX,t.clientY);if(gt.hidden=!1,!e||e.closest(po)){gt.innerHTML="";return}t.altKey&&e.parentElement&&e.parentElement!==document.body&&(e=e.parentElement),lt==="sizes"?fo(e):lt==="type"?ho(e):go(t.altKey?e:mo(e))}))},zt=t=>{lt=t;for(const[e,n]of Object.entries(fe))n.setAttribute("aria-pressed",String(e===t));_(on,t),D({inspect:t}),gt.hidden=!t,gt.innerHTML="",t?document.addEventListener("mousemove",sn):document.removeEventListener("mousemove",sn)};for(const[t,e]of Object.entries(fe))e.addEventListener("click",()=>{t!==lt&&st(!1),zt(lt===t?"":t)});const an=document.querySelector(".dt-notes-btn"),be=[...document.querySelectorAll(".dt-bp")],Ut=document.querySelector(".dt-history-btn"),P=document.querySelector(".dt-history"),ye=document.querySelector(".dt-studio-btn"),E=document.querySelector(".dt-device"),rn=document.querySelector(".dt-shell"),Tt=document.querySelector('.dt-chrome[data-at="top"]'),Vt=document.querySelector('.dt-chrome[data-at="bottom"]'),xt=document.querySelector(".dt-ruler"),z=document.querySelector(".dt-devices"),dt=document.querySelector(".dt-notes-hi"),bo=dt.querySelector(".dt-hi-box"),ln=dt.querySelector(".dt-hi-tag"),yo=[...document.querySelectorAll(".dt-frame-handle")],dn=document.querySelector(".dt-frame-size"),ve=document.querySelector(".dt-frame-rotate"),Mt=document.querySelector(".dt-frame-bars"),A=document.querySelector(".dt-frame"),w=A.querySelector("iframe"),$e=document.querySelector(".dt-notes-count"),f=document.querySelector(".dt-notes-overlay"),vo=".devtools, .dt-tab, .dt-notes-overlay, .dt-history, .dt-frame, .dt-review";for(const t of document.querySelectorAll(vo))for(const e of["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend","click","focusin","focusout"])t.addEventListener(e,n=>n.stopPropagation());const cn="dt-notes";let h=[],M=!1,y=null,d=null,Ee=0,F="",tt=[],S=null,q=[];const Yt=(t=d)=>!!(t&&(t.text?.trim()||t.images?.length)),W=()=>{d&&Yt()&&q.push(d),d=null};let kt=null,X=null;const un=()=>`dt-draft:${K}${v?":canvas":""}`;let ft=un(),Jt=0;const we=()=>{if(!d&&!q.length&&!F){localStorage.removeItem(ft);return}const t={draft:d,parked:q,reply:F?{for:kt,text:F}:null};try{localStorage.setItem(ft,JSON.stringify(t))}catch{const e=n=>({...n,images:void 0});try{localStorage.setItem(ft,JSON.stringify({...t,draft:d&&e(d),parked:q.map(e)}))}catch{}}},Ht=()=>{clearTimeout(Jt),Jt=setTimeout(we,200)};addEventListener("pagehide",()=>{clearTimeout(Jt),we()});let U=localStorage.getItem("dt-resolved")!=="0";const $o=[[/Edg\/(\d+)/,"Edge"],[/OPR\/(\d+)/,"Opera"],[/Firefox\/(\d+)/,"Firefox"],[/Chrome\/(\d+)/,"Chrome"],[/Version\/(\d+).*Safari/,"Safari"]],Eo=[[/iPhone|iPad/,"iOS"],[/Android/,"Android"],[/Mac OS X/,"macOS"],[/Windows/,"Windows"],[/Linux/,"Linux"]],wo=()=>{const t=navigator.userAgent,e=r=>r.find(([c])=>c.test(t)),n=e($o),o=e(Eo),s=n?n[0].exec(t)?.[1]:null;return[n?`${n[1]}${s?" "+s:""}`:"unknown browser",o?.[1]].filter(Boolean).join(" \xB7 ")},et=()=>St(innerWidth),Gt=()=>X??et(),At=()=>{const t=Gt();for(const e of be)e.setAttribute("aria-pressed",String(e.dataset.bp===t))},{cssPath:So,poolOf:Lo,contextOf:To,resolveEl:Z,anchorOf:V}=Es(),pn=t=>{for(let e=t;e&&e!==document.body;e=e.parentElement)if(e.getAnimations().some(n=>n.playState==="running"))return!0;return!1};let Xt=[];const Se=t=>{for(const e of Xt)e.play();Xt=[];for(let e=t;e&&e!==document.body;e=e.parentElement)for(const n of e.getAnimations())n.playState==="running"&&(n.pause(),Xt.push(n))},mn=()=>{if(d)return Z(d);const t=y!=null?h.find(n=>n.id===y):null;if(!t)return null;const e=V(t);return e&&!e.off?Z(t):null},gn=t=>t?new Date(t).toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):"",Zt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4 6h12M8 6V4.2h4V6M6.6 6l.55 9.8h5.7L13.4 6"/></svg>',xo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M3.5 4.5h13v3h-13zM4.8 7.5v8h10.4v-8M8.2 10.5h3.6"/></svg>',Nt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.8 10.4 8.2 13.8l7-7.6" stroke-linejoin="round"/></svg>',Le='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><path d="M12.6 4.4l3 3-8.4 8.4H4.2v-3z" stroke-linejoin="round"/></svg>',Qt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M5.4 5.4l9.2 9.2M14.6 5.4l-9.2 9.2"/></svg>',Mo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M12 5l-5 5 5 5" stroke-linejoin="round"/></svg>',ko='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M8 5l5 5-5 5" stroke-linejoin="round"/></svg>',Ho='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M11 2.5 4.5 11h5l-1 6.5L15.5 9h-5z" stroke-linejoin="round"/></svg>',Ao='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.5 8.5h7.5a3.5 3.5 0 0 1 0 7H8.5M7.5 5.5l-3 3 3 3" stroke-linejoin="round"/></svg>',Ct=t=>`<svg viewBox="0 0 24 24" width="${t}" height="${t}" aria-hidden="true" class="dt-claude"><path d="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"/></svg>`,fn=()=>{try{return localStorage.getItem("nm-for")??"claude"}catch{return"claude"}},Bt=t=>t==="claude"?"#d97757":t?"#0d99ff":"#717171",hn=(t,e)=>`<label class="dt-field" title="Who it is for"><span class="dt-field-box" style="--cat:${Bt(t)}"><select class="dt-for-select"${e?` data-id="${e}"`:""} aria-label="Who this is for">
|
|
2
|
+
<option value="claude" data-c="${Bt("claude")}"${t==="claude"?" selected":""}>AI agent</option>
|
|
3
|
+
<option value="" data-c="${Bt("")}"${t?"":" selected"}>Anyone</option>
|
|
4
|
+
${(b.team??[]).filter(n=>n.email!==b.me?.email).map(n=>`<option value="${g(n.email)}" data-c="${Bt(n.email)}"${t===n.email?" selected":""}>${g(n.name||n.email)}</option>`).join("")}
|
|
5
|
+
</select></span></label>`,bn=t=>{const e=wt(t?.textContent).replace(/\s+/g," ");return e&&e.length<=2e3?e:""},No=t=>`<div class="dt-suggest dt-suggest--read"><del>${g(t.from)}</del><ins>${g(t.to)}</ins></div>`,yn=t=>wt(t)?`<span class="dt-note-info" data-tip="${g(wt(t))}"
|
|
6
|
+
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="10" r="7.4"/><path d="M10 9.2v4.4M10 6.4v.6"/></svg></span>`:"",vn=(t,e)=>`<label class="dt-field" title="Type"><span class="dt-field-box" style="--cat:${de(t).color}"><select class="dt-cat-select"${e?` data-id="${e}"`:""} aria-label="Type">${Xe.map(n=>`<option value="${n.id}" data-c="${n.color}"${n.id===t?" selected":""}>${n.label}</option>`).join("")}</select></span></label>`,$n=[["urgent","Urgent","#e5484d"],["high","High","#ff5a00"],["normal","Normal","#f5c451"],["low","Low","#4f8f41"]],En=(t,e)=>{const n=t&&t!=="normal"?t:"normal";return`<label class="dt-field" title="Priority"><span class="dt-field-box${n==="normal"?" dt-field-box--unset":""}" style="--cat:${$n.find(o=>o[0]===n)[2]}"><select class="dt-prio-select"${e?` data-id="${e}"`:""} aria-label="Priority">${$n.map(([o,s,r])=>`<option value="${o}" data-c="${r}" data-label="${s}"${o===n?" selected":""}>${o==="normal"&&o===n?"Priority":s}</option>`).join("")}</select></span></label>`},Co='<svg viewBox="0 0 20 20" width="9" height="9" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9"/></svg>',wn=t=>t.startsWith("data:video/")||/\.webm(\?|$)/i.test(t),Sn=(t,e,n=t)=>`<span class="dt-shot${wn(n)?" dt-shot--video":""}">${wn(n)?`<video src="${t}" controls preload="metadata" playsinline></video>`:`<a href="${t}" target="_blank"><img src="${t}" alt="" loading="lazy" /></a>`}${e===void 0?"":`<button class="dt-shot-rm" data-act="unshot" ${e} aria-label="Remove">${Co}</button>`}</span>`,Ln=(t=[],e)=>t.length?`<div class="dt-note-shots">${t.map(n=>{const o=n.split("/").pop(),s=hs(o);return Sn(s,e===void 0?void 0:`data-id="${e}" data-img="${g(o)}"`,o)}).join("")}</div>`:"",Tn=(t=[])=>t.length?`<div class="dt-note-shots">${t.map((e,n)=>Sn(e,`data-i="${n}"`)).join("")}</div>`:"",Bo='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="2.5" y="5.5" width="11" height="9" rx="2"/><path d="m13.5 9 4-2.5v7l-4-2.5"/></svg>',Io='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><path d="M3.5 5.5h8M7.5 5.5v10M11 15.5l5-5 1.5 1.5-5 5H11z" stroke-linejoin="round"/></svg>',qo=!!navigator.mediaDevices?.getDisplayMedia&&typeof MediaRecorder<"u";let ct=null;const Ro=async t=>{if(ct){ct.stop();return}let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:12},audio:!1})}catch{return}const n=await navigator.mediaDevices.getUserMedia({audio:!0}).catch(()=>null),o=new MediaStream([...e.getVideoTracks(),...n?.getAudioTracks()??[]]),s=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(l=>MediaRecorder.isTypeSupported(l));if(!s){for(const l of e.getTracks())l.stop();j("This browser cannot record WebM video.");return}const r=new MediaRecorder(o,{mimeType:s,videoBitsPerSecond:6e5,audioBitsPerSecond:32e3}),c=[],u=!!Number(t?.dataset.id);r.ondataavailable=l=>{l.data.size&&c.push(l.data)};const a=setTimeout(()=>{r.state!=="inactive"&&r.stop()},3e4);r.onstop=async()=>{clearTimeout(a);for(const L of[...e.getTracks(),...n?.getTracks()??[]])L.stop();ct=null;const l=new Blob(c,{type:"video/webm"});if(l.size>32e5){j("That recording is too big to send \u2014 keep it shorter."),m();return}const p=await new Promise(L=>{const i=new FileReader;i.onload=()=>L(String(i.result)),i.readAsDataURL(l)});u?tt.push(p):d&&(d.images??=[]).push(p),m()},e.getVideoTracks()[0]?.addEventListener("ended",()=>{r.state!=="inactive"&&r.stop()}),ct=r,r.start(1e3),m()},Do='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="3" y="4" width="14" height="12" rx="2"/><circle cx="7.5" cy="8.5" r="1.4"/><path d="m3.5 14.5 4-4 3 3 2-2 4 4"/></svg>',xn=(t,e,n,o,s="",r="")=>`<div class="dt-note-foot"><div class="dt-compose">
|
|
7
|
+
<textarea class="${t}" rows="1" placeholder="${e}">${g(n)}</textarea>
|
|
8
8
|
${s}
|
|
9
9
|
<div class="dt-compose-bar">
|
|
10
|
-
<span class="dt-compose-tools"><button class="dt-attach" data-act="attach" title="Attach a screenshot \u2014 or paste or drop one">${
|
|
11
|
-
${
|
|
10
|
+
<span class="dt-compose-tools"><button class="dt-attach" data-act="attach" title="Attach a screenshot \u2014 or paste or drop one">${Do}</button>
|
|
11
|
+
${r}${qo?`<button class="dt-record${ct?" is-on":""}" data-act="record" title="${ct?"Stop recording":"Record the screen, up to 30 seconds"}">${ct?"Stop":Bo}</button>`:""}</span>
|
|
12
12
|
<button class="dt-send${n.trim()?" is-ready":""}" ${o} title="Send (Enter)"
|
|
13
13
|
><svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><path d="M10 15.5v-11M5.5 9 10 4.5 14.5 9"/></svg></button>
|
|
14
14
|
</div>
|
|
15
|
-
</div></div>`,
|
|
16
|
-
title="Resolved by ${
|
|
17
|
-
class="dt-note-resolve${n?" is-on":""}" title="${n?"Reopen":t==="claude"?"Looks right \u2014 mark it resolved":"Resolve"}">${
|
|
18
|
-
style="left:${
|
|
19
|
-
title="${
|
|
20
|
-
style="left:${
|
|
15
|
+
</div></div>`,Te=(t,e)=>(t||"element")+(e?.[0]?"."+e[0]:""),Mn=()=>q.map((t,e)=>({i:e,el:Te(t.tag,t.classes),text:wt(t.text??""),shots:t.images?.length??0,orphan:!V(t)}));let xe=[],kn="";const Oo=(t,e)=>t!=="claude"?"":`<button class="dt-note-state" data-act="reopen" data-id="${e}"
|
|
16
|
+
title="Resolved by ${g(J(h.find(n=>n.id===e)?.doneAgent))} \u2014 click to clear">${Ct(13)}</button>`,Hn=(t,e)=>{const n=t==="done";return`${Oo(t,e)}<button data-act="${n?"reopen":"done"}" data-id="${e}"
|
|
17
|
+
class="dt-note-resolve${n?" is-on":""}" title="${n?"Reopen":t==="claude"?"Looks right \u2014 mark it resolved":"Resolve"}">${Nt}</button>`},Po=(t,e)=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e?{id:t,status:"done",doneBy:"you"}:{id:t,status:"open",doneBy:null})}),nt=async(t,e,n)=>{const o=h,s=Y;h=t(h),Y=t(Y),m();const r=await e().catch(()=>null);if(!r?.ok){h=o,Y=s,m(),j(`${n} did not go through${r?` (${r.status})`:""}.`);return}se()},It=(t,e)=>nt(n=>n.map(o=>o.id===t?{...o,status:e?"done":"open",doneBy:e?"you":null}:o),()=>Po(t,e),e?"Resolving":"Reopening"),jo=t=>nt(e=>e.map(n=>n.id===t?{...n,status:"done",doneBy:n.status==="done"?n.doneBy:"you",archivedAt:new Date().toISOString()}:n),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,archive:!0})}),"Archiving"),An=t=>nt(e=>e.filter(n=>n.id!==t),()=>B(`comments?id=${t}`,{method:"DELETE"}),"Deleting"),g=t=>t.replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""})[e]),Ko=t=>{const e=h.filter(s=>G(s)===t),n=e.filter(s=>C(s)==="open").length,o=e.filter(s=>C(s)==="claude").length;$e.innerHTML=n?String(n):o?Ct(9):"\u2713",$e.dataset.state=n?"open":o?"claude":"done",$e.hidden=e.length===0},m=()=>{if(Ht(),v){const a=Mn(),l=JSON.stringify(a);l!==kn&&(kn=l,parent.postMessage({dt:!0,drafts:a},location.origin))}At(),y!==kt&&(F="",tt=[],kt=y),S&&S.id!==y&&(S=null);const t=Gt();if(Ko(t),!M){f.innerHTML="",Se(null);return}const e=t;let n="";const o=h.filter(a=>G(a)===e&&(U||C(a)!=="done"));for(const a of o){const l=V(a);if(!l&&y!==a.id)continue;const p=C(a),L=p==="done",i=!l,x=l??{x:0,y:0},H=de(a.category),N=ms(a);if(i||(n+=`<button class="dt-pin dt-pin--${p}${N?" dt-pin--working":""}" data-id="${a.id}"${l?.off?` data-off="${l.off}"`:""} aria-label="Comment ${a.id}, ${p==="open"?"open":p==="claude"?`resolved by ${g(J(a.doneAgent))}`:"resolved"}" aria-expanded="${y===a.id}"
|
|
18
|
+
style="left:${x.x}px;top:${x.y}px;--cat:${H.color}"
|
|
19
|
+
title="${g(a.text.slice(0,80))} \xB7 ${H.label}${N?` \xB7 ${g(J(N.agent))} is on it`:""}${p==="claude"?` \xB7 resolved by ${g(J(a.doneAgent))} \u2014 tick to confirm`:p==="done"?" \xB7 resolved":""}">${p==="done"?"\u2713":p==="claude"?Ct(11):""}</button>`),y===a.id){const it=ps(a);n+=`<div class="dt-note${i?" dt-note--orphan":""}" data-id="${a.id}" role="dialog" aria-label="Comment ${a.id}"
|
|
20
|
+
style="left:${x.x}px;top:${x.y}px">
|
|
21
21
|
<div class="dt-note-bar">
|
|
22
|
-
<span class="dt-note-el">${
|
|
23
|
-
${
|
|
22
|
+
<span class="dt-note-el">${b.client?`Comment #${Wo(a)}`:g(Te(a.tag,a.classes))}</span>
|
|
23
|
+
${yn(a.label)}
|
|
24
24
|
<span class="dt-note-tools">
|
|
25
|
-
${
|
|
25
|
+
${!b.client&&p==="open"&&!us(a)?`<button data-act="fixnow" data-id="${a.id}" title="Fix now \u2014 the agent in turbo takes it next, even while paused">${Ho}</button>`:""}
|
|
26
|
+
${Hn(p,a.id)}
|
|
26
27
|
<i class="dt-note-sep"></i>
|
|
27
|
-
${
|
|
28
|
-
<button data-act="rm" data-id="${
|
|
29
|
-
<button data-act="close" data-id="${
|
|
28
|
+
${b.client?"":`<button data-act="archive" data-id="${a.id}" title="Archive \u2014 resolved and put away">${xo}</button>`}
|
|
29
|
+
<button data-act="rm" data-id="${a.id}" title="Delete this thread">${Zt}</button>
|
|
30
|
+
<button data-act="close" data-id="${a.id}" title="Close">${Qt}</button>
|
|
30
31
|
</span>
|
|
31
32
|
</div>
|
|
32
|
-
${
|
|
33
|
+
${N?`<p class="dt-note-working"><i></i>${g(J(N.agent))} is on it</p>`:""}
|
|
33
34
|
${i?'<p class="dt-note-orphan">The element this was pinned to is not on the page right now.</p>':""}
|
|
34
|
-
${(()=>{const T=
|
|
35
|
+
${(()=>{const T=vn(de(a.category).id,a.id)+(b.client?"":hn(a.assignee??"",a.id)+En(a.priority,a.id))+(a.host&&a.host!==location.host?`<span class="dt-note-host" title="Written on ${g(a.host)}">${g(a.host)}</span>`:"");return T?`<div class="dt-note-meta">${T}</div>`:""})()}
|
|
35
36
|
<div class="dt-note-thread">
|
|
36
|
-
${
|
|
37
|
-
<textarea class="dt-note-edit-input" rows="1">${
|
|
38
|
-
${
|
|
37
|
+
${it.map((T,Et)=>{const ro=Et===0?null:T.at??null,Ye=T.author==="you"&&(!T.by||T.by===b.me?.email),io=Ye&&S?.id===a.id&&S.at===ro,Je=T.author==="claude"?null:b.team?.find(Ge=>Ge.email===T.by),ls=T.author==="claude"?J(T.agent):Ye?"You":Je?.name||T.byName||T.by||"You",lo=`<div class="dt-msg-head">${Je?.avatar_url?`<img class="dt-msg-face" src="${g(Je.avatar_url)}" alt="">`:""}<b>${g(ls)}</b><time>${gn(T.at)}</time>${Ye&&!io?`<button class="dt-msg-edit" data-act="edit" data-id="${a.id}" data-at="${g(ro??"")}" title="Edit">${Le}</button>`:""}</div>`;return io?`<div class="dt-msg">${lo}<div class="dt-compose">
|
|
38
|
+
<textarea class="dt-note-edit-input" rows="1">${g(S.text)}</textarea>
|
|
39
|
+
${Ln(T.images.filter(Ge=>!S.drop.includes(Ge.split("/").pop())),a.id)}
|
|
39
40
|
<div class="dt-compose-bar">
|
|
40
41
|
<button class="dt-edit-cancel" data-act="edit-cancel">Cancel</button>
|
|
41
|
-
<button class="dt-send${
|
|
42
|
+
<button class="dt-send${S.text.trim()?" is-ready":""}" data-act="edit-save" title="Save (Enter)">${Nt}</button>
|
|
42
43
|
</div>
|
|
43
|
-
</div></div>`:`<div class="dt-msg" data-msg="${
|
|
44
|
+
</div></div>`:`<div class="dt-msg" data-msg="${a.id}:${g(T.at??"0")}">${lo}<p>${g(T.text)}</p>${Et===0&&a.suggest?No(a.suggest):""}${Ln(T.images)}</div>`}).join("")}
|
|
44
45
|
</div>
|
|
45
|
-
${
|
|
46
|
-
</div>`}}q.forEach((
|
|
47
|
-
style="left:${p.x}px;top:${p.y}px" title="Draft, not sent \u2014 click to finish it">${
|
|
48
|
-
<div class="dt-note${s?"":" dt-note--orphan"}" data-draft style="left:${
|
|
46
|
+
${xn("dt-note-reply-input","Reply",F,`data-act="reply" data-id="${a.id}"`,Tn(tt))}
|
|
47
|
+
</div>`}}q.forEach((a,l)=>{const p=V(a);p&&(n+=`<button class="dt-pin dt-pin--draft" data-parked="${l}" data-act="draft-open" data-i="${l}"
|
|
48
|
+
style="left:${p.x}px;top:${p.y}px" title="Draft, not sent \u2014 click to finish it">${Le}</button>`)});const s=d&&V(d);if(d){const a=s?.x??0,l=s?.y??0;n+=`${s?`<span class="dt-pin dt-pin--draft" data-draft style="left:${a}px;top:${l}px"></span>`:""}
|
|
49
|
+
<div class="dt-note${s?"":" dt-note--orphan"}" data-draft style="left:${a}px;top:${l}px">
|
|
49
50
|
<div class="dt-note-bar">
|
|
50
|
-
<span class="dt-note-el">${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
51
|
+
<span class="dt-note-el">${b.client?"New comment":g(Te(d.tag,d.classes))}</span>
|
|
52
|
+
${yn(d.label)}
|
|
53
|
+
${Yt()?'<span class="dt-note-draft">Draft</span>':""}
|
|
53
54
|
<span class="dt-note-tools">
|
|
54
|
-
<button data-act="discard" title="Discard this draft">${
|
|
55
|
-
<button data-act="cancel" title="Close \u2014 the draft stays">${
|
|
55
|
+
<button data-act="discard" title="Discard this draft">${Zt}</button>
|
|
56
|
+
<button data-act="cancel" title="Close \u2014 the draft stays">${Qt}</button>
|
|
56
57
|
</span>
|
|
57
58
|
</div>
|
|
58
59
|
${s?"":'<p class="dt-note-orphan">The element this was pinned to is not on the page right now.</p>'}
|
|
59
|
-
${(()=>{const p=s?
|
|
60
|
-
<div class="dt-note-meta">${
|
|
61
|
-
${
|
|
62
|
-
<textarea class="dt-suggest-input" rows="2">${
|
|
63
|
-
${
|
|
64
|
-
</div>`}const
|
|
60
|
+
${(()=>{const p=s?Z(d):null,L=p&&h.find(i=>i.id>0&&C(i)==="open"&&Z(i)===p);return L?`<p class="dt-note-twin">Already open here: \u201C${g(L.text.slice(0,60))}${L.text.length>60?"\u2026":""}\u201D <button data-act="twin" data-id="${L.id}">Open it</button></p>`:""})()}
|
|
61
|
+
<div class="dt-note-meta">${vn(d.category)}${b.client?"":hn(d.assignee??fn())+En(d.priority)}</div>
|
|
62
|
+
${d.suggest?`<div class="dt-suggest"><span class="dt-suggest-head">Should read<button data-act="unsuggest" title="No text change">${Qt}</button></span>
|
|
63
|
+
<textarea class="dt-suggest-input" rows="2">${g(d.suggest.to)}</textarea></div>`:""}
|
|
64
|
+
${xn("dt-note-input",d.suggest?"Why (optional)":"Comment",d.text??"",'data-act="save"',Tn(d.images),!d.suggest&&bn(s?Z(d):null)?`<button class="dt-attach" data-act="suggest" title="Suggest the new text">${Io}</button>`:"")}
|
|
65
|
+
</div>`}const r=new Map([...f.querySelectorAll(".dt-note[data-id] .dt-note-thread")].map(a=>[a.closest(".dt-note").dataset.id,{top:a.scrollTop,end:a.scrollTop+a.clientHeight>=a.scrollHeight-4}])),c=new Set([...f.querySelectorAll("[data-msg]")].map(a=>a.dataset.msg));f.innerHTML=n;for(const a of f.querySelectorAll(".dt-note[data-id] .dt-note-thread")){const l=a.closest(".dt-note").dataset.id,p=r.get(l);if(!p)continue;const L=[...a.querySelectorAll("[data-msg]")].filter(i=>!c.has(i.dataset.msg));for(const i of L)i.classList.add("dt-msg--new");a.scrollTop=p.end&&L.length?a.scrollHeight:p.top}for(const a of f.querySelectorAll(".dt-note")){const l=a.getBoundingClientRect();l.bottom>innerHeight-8&&(a.dataset.flip="1"),l.right>innerWidth-8&&(a.dataset.flipx="1")}Nn(e),Se(mn()),ot();for(const a of f.querySelectorAll(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input"))De(a);const u=f.querySelector(".dt-note-input");u&&(u.focus(),u.setSelectionRange(u.value.length,u.value.length))},Fo=()=>{let t=!1;for(const e of f.querySelectorAll(".dt-pin[data-id], .dt-note[data-id]")){if(e.classList.contains("dt-note--orphan"))continue;const n=h.find(s=>s.id===Number(e.dataset.id)),o=n&&V(n);if(!o){e.style.visibility="hidden";continue}e.style.visibility="",e.style.left=`${o.x}px`,e.style.top=`${o.y}px`,e.classList.contains("dt-pin")&&(o.off?e.dataset.off=o.off:delete e.dataset.off),n&&pn(Z(n))&&(t=!0)}for(const e of f.querySelectorAll("[data-draft], [data-parked]")){if(e.classList.contains("dt-note--orphan"))continue;const n=e.dataset.parked?q[Number(e.dataset.parked)]:d,o=n&&V(n);if(!o){e.style.visibility="hidden";continue}e.style.visibility="",e.style.left=`${o.x}px`,e.style.top=`${o.y}px`}if(!Xt.length&&(d||y!=null)){const e=mn();e&&pn(e)&&Se(e)}t&&ot()},Wo=t=>h.filter(e=>G(e)===G(t)).findIndex(e=>e.id===t.id)+1,Nn=t=>{if(P.hidden)return;const e=h.filter(i=>G(i)===t),n=new Map(e.map((i,x)=>[i.id,x+1])),o={open:[],claude:[],done:[]};for(const i of e)o[C(i)].push(i);const s=i=>{const x=(i.replies?.length??0)+(i.note?1:0),H=de(i.category),N=C(i),it=N==="claude",T=!V(i),Et=i.replies?.length?i.replies[i.replies.length-1]:i.note?{author:"claude",text:i.note}:{author:"you",text:i.text};return`<div class="dt-hist-row is-${N}${T?" is-orphan":""}">
|
|
65
66
|
<button class="dt-hist-go" data-go="${i.id}">
|
|
66
|
-
<span class="dt-hist-n" style="--cat:${
|
|
67
|
+
<span class="dt-hist-n" style="--cat:${H.color}">${it?Ct(8):""}</span>
|
|
67
68
|
<span class="dt-hist-body">
|
|
68
|
-
<span class="dt-hist-id">#${n.get(i.id)}<em>${
|
|
69
|
-
<span class="dt-hist-text">${
|
|
70
|
-
<span class="dt-hist-meta">${
|
|
69
|
+
<span class="dt-hist-id">#${n.get(i.id)}<em>${H.label}</em>${it?`<b class="dt-hist-claude" data-unmark="${i.id}" role="button" tabindex="0" title="Resolved by ${g(J(i.doneAgent))} \u2014 click to clear: back to open">${Ct(9)}${g(J(i.doneAgent))}<i aria-hidden="true">\xD7</i></b>`:""}${T?'<b class="dt-hist-orphan" title="The element this was pinned to is not on the page right now">no pin</b>':""}</span>
|
|
70
|
+
<span class="dt-hist-text">${Et.author==="claude"?`<b>${g(J(Et.agent))}:</b> `:""}${g(Et.text)}</span>
|
|
71
|
+
<span class="dt-hist-meta">${gn(i.updatedAt||i.createdAt)}${i.device?` \xB7 ${g(i.device)}`:i.browser?` \xB7 ${g(i.browser)}`:""}${x?` \xB7 ${x} repl${x===1?"y":"ies"}`:""}</span>
|
|
71
72
|
</span>
|
|
72
73
|
</button>
|
|
73
|
-
<span class="dt-note-tools dt-hist-tools">${
|
|
74
|
-
><button data-rm="${i.id}" title="Delete this comment">${
|
|
75
|
-
</div>`},
|
|
76
|
-
title="${i.label}: ${
|
|
77
|
-
><svg viewBox="0 0 20 20" width="11" height="11" aria-hidden="true">${i.icon}</svg><i>${
|
|
74
|
+
<span class="dt-note-tools dt-hist-tools">${Hn(N,i.id)}<i class="dt-note-sep"></i
|
|
75
|
+
><button data-rm="${i.id}" title="Delete this comment">${Zt}</button></span>
|
|
76
|
+
</div>`},r=I.find(i=>i.id===t),c=I.map(i=>{const x=h.filter(H=>G(H)===i.id&&C(H)!=="done");return{band:i,open:x.filter(H=>C(H)==="open").length,total:x.length}}).filter(i=>i.total&&i.band.id!==t),u=c.length?`<i class="dt-hist-sep"></i><div class="dt-hist-bands">${c.map(({band:i,open:x,total:H})=>`<button data-bp="${i.id}" data-state="${x?"open":"claude"}"
|
|
77
|
+
title="${i.label}: ${x} open \xB7 ${H-x} to check"
|
|
78
|
+
><svg viewBox="0 0 20 20" width="11" height="11" aria-hidden="true">${i.icon}</svg><i>${H}</i></button>`).join("")}</div>`:"",l=["open","claude","done"].filter(i=>o[i].length&&(i!=="done"||U)),p=A.hidden?Mn():xe,L=i=>`<div class="dt-hist-row is-draft">
|
|
78
79
|
<button class="dt-hist-go" data-draft-go="${i.i}">
|
|
79
|
-
<span class="dt-hist-n">${
|
|
80
|
+
<span class="dt-hist-n">${Le}</span>
|
|
80
81
|
<span class="dt-hist-body">
|
|
81
|
-
<span class="dt-hist-id">${
|
|
82
|
-
<span class="dt-hist-text">${i.text?
|
|
82
|
+
<span class="dt-hist-id">${g(i.el)}${i.orphan?'<b class="dt-hist-orphan" title="The element this was pinned to is not on the page right now">no pin</b>':""}</span>
|
|
83
|
+
<span class="dt-hist-text">${i.text?g(i.text):`${i.shots} screenshot${i.shots===1?"":"s"}`}</span>
|
|
83
84
|
</span>
|
|
84
85
|
</button>
|
|
85
|
-
<span class="dt-note-tools dt-hist-tools"><button data-draft-rm="${i.i}" title="Discard this draft">${
|
|
86
|
-
</div>`;
|
|
87
|
-
<span class="dt-hist-here" title="${
|
|
88
|
-
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true">${
|
|
86
|
+
<span class="dt-note-tools dt-hist-tools"><button data-draft-rm="${i.i}" title="Discard this draft">${Zt}</button></span>
|
|
87
|
+
</div>`;P.innerHTML=`<div class="dt-hist-head">
|
|
88
|
+
<span class="dt-hist-here" title="${r?.label??t}"
|
|
89
|
+
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true">${r?.icon??""}</svg></span>
|
|
89
90
|
<span class="dt-hist-title">Comments</span>
|
|
90
|
-
${
|
|
91
|
-
${
|
|
91
|
+
${u}
|
|
92
|
+
${ut().length&&!v?`<button class="dt-review-btn" data-review aria-label="Check all ${ut().length} ${ut().length===1?"fix":"fixes"}" data-tip="${ut().length} ${ut().length===1?"fix waits":"fixes wait"} for a look across every page \u2014 walk through them">${Nt}${ut().length}</button>`:""}
|
|
92
93
|
<button class="dt-hist-refresh" data-refresh aria-label="Reload comments from the file">
|
|
93
94
|
<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M16 10a6 6 0 1 1-1.8-4.3"/><path d="M16.3 3.4v3.4h-3.4"/></svg>
|
|
94
95
|
</button>
|
|
95
96
|
<button class="dt-hist-fold" data-fold aria-label="Collapse or expand the panel">
|
|
96
97
|
<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M5.5 8.5 10 12.5l4.5-4"/></svg>
|
|
97
98
|
</button>
|
|
98
|
-
</div>`+(l.length||p.length?`<div class="dt-hist-list">${p.length?`<p class="dt-hist-group">Drafts<em>${p.length}</em></p>${p.map(
|
|
99
|
-
<button class="dt-hist-resolved" data-resolved role="switch" aria-checked="${
|
|
99
|
+
</div>`+(l.length||p.length?`<div class="dt-hist-list">${p.length?`<p class="dt-hist-group">Drafts<em>${p.length}</em></p>${p.map(L).join("")}`:""}${l.map(i=>`<p class="dt-hist-group">${ds[i]}<em>${o[i].length}</em></p>`+o[i].map(s).join("")).join("")}</div>`:`<p class="dt-hist-empty">${o.done.length?"Everything here is resolved.":"No comments at this breakpoint yet. Click anything on the page to leave one."}</p>`)+`<div class="dt-hist-foot">
|
|
100
|
+
<button class="dt-hist-resolved" data-resolved role="switch" aria-checked="${U}"
|
|
100
101
|
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="10" r="7.5"/><path d="M6.8 10.2 9 12.4l4-4.4" stroke-linejoin="round"/></svg
|
|
101
102
|
><span>Show resolved</span><kbd>R</kbd><i class="dt-hist-switch" aria-hidden="true"></i></button>
|
|
102
|
-
</div>`},
|
|
103
|
-
<span class="dt-review-nav"><button data-r="prev" aria-label="Previous fix" data-tip="Previous \xB7 \u2190"${n?"":" disabled"}>${
|
|
103
|
+
</div>`},Me=t=>P.toggleAttribute("data-collapsed",t);P.addEventListener("click",async t=>{const e=t.target.closest("[data-refresh]");if(e){e.dataset.spin="1",await se(),setTimeout(()=>delete e.dataset.spin,500);return}if(P.hasAttribute("data-collapsed")&&t.target.closest(".dt-hist-head")){Me(!1);return}if(t.target.closest("[data-fold]")){Me(!P.hasAttribute("data-collapsed"));return}const n=t.target.closest(".dt-hist-bands [data-bp]");if(n){We(n.dataset.bp);return}const o=t.target.closest("[data-draft-go], [data-draft-rm]");if(o){const l=o.dataset.draftRm!==void 0,p=Number(l?o.dataset.draftRm:o.dataset.draftGo);A.hidden?l?Cn(p):He(p):D(l?{dropDraft:p}:{openDraft:p});return}const s=t.target.closest("[data-unmark]");if(s){t.stopPropagation(),await It(Number(s.dataset.unmark),!1);return}const r=t.target.closest(".dt-hist-tools [data-act]");if(r){await It(Number(r.dataset.id),r.dataset.act==="done");return}const c=t.target.closest("[data-rm]");if(c){y=null,await An(Number(c.dataset.rm));return}if(t.target.closest("[data-review]")){_o();return}if(t.target.closest("[data-resolved]")){Ce(!U);return}const u=t.target.closest("[data-go]");if(!u)return;const a=Number(u.dataset.go);if(!A.hidden){D({open:a});return}ke(a)});const ke=t=>{y=t,W(),m();const e=h.find(o=>o.id===t),n=e&&V(e);n?scrollTo({top:scrollY+n.y-innerHeight/2,behavior:"smooth"}):e&&Z(e)?.scrollIntoView({block:"center",behavior:"smooth"}),f.querySelector(`.dt-pin[data-id="${t}"]`)?.animate([{transform:"scale(1)"},{transform:"scale(1.5)"},{transform:"scale(1)"}],400)},He=t=>{const[e]=q.splice(t,1);if(!e)return;W(),d=e,y=null;const n=V(e);n&&(n.y<0||n.y>innerHeight)&&scrollTo({top:scrollY+n.y-innerHeight/3,behavior:"instant"}),m()},Cn=t=>{q.splice(t,1),m()},Ae="nm-review",te=()=>{try{return JSON.parse(sessionStorage.getItem(Ae)||"null")}catch{return null}},ht=t=>{try{t?sessionStorage.setItem(Ae,JSON.stringify(t)):sessionStorage.removeItem(Ae)}catch{}},R=document.createElement("div");R.className="dt-review",R.setAttribute("role","region"),R.setAttribute("aria-label","Checking fixes"),R.hidden=!0,v||document.body.append(R);const ut=()=>Y.filter(t=>C(t)==="claude"),_o=()=>{const t=ut().sort((e,n)=>+(n.route===K)-+(e.route===K)||String(e.route).localeCompare(String(n.route))||e.id-n.id).map(e=>e.id);t.length&&(ht({ids:t,i:0}),ee())},ee=()=>{const t=te();if(!t||v){R.hidden=!0;return}for(;t.i<t.ids.length&&C(Y.find(o=>o.id===t.ids[t.i])??{status:"done"})!=="claude";)t.i++;if(t.i>=t.ids.length){ht(null),R.hidden=!0,j("Every fix is checked.");return}ht(t);const e=Y.find(o=>o.id===t.ids[t.i]);if(e.route&&e.route!==K){location.assign(e.route+location.search);return}if(M||st(!0),G(e)!==Gt()){We(G(e));for(const o of[600,1500])setTimeout(()=>D({open:e.id}),o)}else ke(e.id);const n=t.ids.slice(0,t.i).some(o=>C(Y.find(s=>s.id===o)??{status:"done"})==="claude");R.innerHTML=`<b><span class="dt-review-dot" aria-hidden="true"></span>Check fixes</b>
|
|
104
|
+
<span class="dt-review-nav"><button data-r="prev" aria-label="Previous fix" data-tip="Previous \xB7 \u2190"${n?"":" disabled"}>${Mo}</button>
|
|
104
105
|
<span class="dt-review-n">${t.i+1} of ${t.ids.length}</span>
|
|
105
|
-
<button data-r="skip" aria-label="Next fix" data-tip="Next \xB7 \u2192">${
|
|
106
|
-
<span class="dt-review-text">${
|
|
107
|
-
<button data-r="ok" class="dt-review-ok" aria-label="Looks right \u2014 mark it resolved" data-tip="Looks right \u2014 resolve it">${
|
|
108
|
-
<button data-r="no" aria-label="Reopen" data-tip="Not yet \u2014 reopen it">${
|
|
109
|
-
<button data-r="stop" aria-label="Stop checking" data-tip="Stop checking">${
|
|
110
|
-
${b}`:""}},Ot=t=>(Array.isArray(t)?t:[]).filter(e=>e&&Number.isInteger(Number(e.id))&&typeof e.text=="string").filter(e=>!v.client||e.by===v.me?.email||e.assignee===v.me?.email).map(e=>({...e,id:Number(e.id),rx:Number(e.rx)||0,ry:Number(e.ry)||0,route:typeof e.route=="string"&&/^\/(?!\/)/.test(e.route)?e.route:"/",replies:Array.isArray(e.replies)?e.replies.filter(n=>typeof n?.text=="string"):[],images:Array.isArray(e.images)?e.images.filter(n=>typeof n=="string"):[]})),ie=async()=>{try{Jn(Ot((await(await j("comments")).json()).comments)),!F.hidden&&!E&&g()}catch{}};let Pt=null,Ft=null;const ht=document.querySelector(".dt-turbo"),We="/notemend:turbo",jt=()=>{const t=!!Pt&&Date.now()-Date.parse(Pt.at)<18e4,e=t?Ft?.paused?"paused":"on":"none",n=t?tt(Pt.agent):"",o=e==="none"?`Turbo is off. Run ${We} in Claude Code and comments for the agent are taken as they land \u2014 click to copy it`:e==="on"?`Turbo on: ${n} takes comments for the agent as they land \u2014 click to pause`:`Turbo paused: ${n} is listening but waits \u2014 click to resume`;ht.dataset.state=e,ht.dataset.tip=o,ht.setAttribute("aria-label",o),ht.setAttribute("aria-checked",String(e==="on")),E&&(ht.hidden=!0)};setInterval(jt,3e4),ht.addEventListener("click",async()=>{const t=ht.dataset.state;if(t==="none"){await navigator.clipboard?.writeText(We).catch(()=>{}),G(`Copied ${We} \u2014 paste it in Claude Code`);return}const e=t==="on"?"off":"on";Ft={paused:e==="off"},jt();try{const n=await j("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({turbo:e})});if(!n.ok)throw new Error(String(n.status));G(e==="off"?"Turbo paused":"Turbo on")}catch{Ft={paused:e==="on"},jt(),G("Could not switch turbo \u2014 try again")}});let le="",ze=!1;const Kt=async()=>{if(!(document.hidden||ze)){ze=!0;try{const t=await j(`comments${le?`?since=${le}`:""}`);if(t.status!==200)return;const e=await t.json();le=e.version??"",Pt=e.listening??null,Ft=e.turbo??null,jt();const n=Ot(e.comments);Jn(n);const o=n.filter(s=>s.route===K);if(JSON.stringify(o)===JSON.stringify(h))return;if(f.contains(document.activeElement)&&document.activeElement.matches("textarea, input")){le="",setTimeout(Kt,5e3);return}h=o,g(),O({reload:!0})}catch{}finally{ze=!1}}},bt=async()=>{try{const e=await(await j(`comments?route=${encodeURIComponent(K)}`)).json();h=Ot(e.comments),Pt=e.listening??null,Ft=e.turbo??null,jt()}catch{h=[]}g()};let _e=0;const Xn=t=>{_e||(_e=requestAnimationFrame(()=>{_e=0;const e=t.target;if(!A||e.closest(ve)){mt.hidden=!0;return}mt.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(mt.hidden=!1,!n)return;const o=n.getBoundingClientRect();Oo.style.cssText=`left:${o.left}px;top:${o.top}px;width:${o.width}px;height:${o.height}px`,wn.textContent=n.tagName.toLowerCase()+([...n.classList].find(s=>!/^(astro|svelte)-/.test(s))?"."+[...n.classList].find(s=>!/^(astro|svelte)-/.test(s)):"")+` ${Math.round(o.width)}\xD7${Math.round(o.height)}`,wn.style.cssText=`left:${o.left}px;top:${Math.max(2,o.top-20)}px`}))},Zn=t=>{if(!(t.key!=="Escape"||t.isComposing)){if(t.preventDefault(),x){x=null,g();return}if(u){z(),g();return}if(y!==null){y=null,g();return}lt(!1)}},Qn=["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend"],to=t=>{t.target.closest?.(ve)||t.stopPropagation()},eo=t=>{if(t.target.closest(ve))return;if(t.preventDefault(),t.stopPropagation(),ye){ye=!1;return}if(!getSelection()?.isCollapsed)return;f.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(f.hidden=!1,!n)return;z();const o=n.getBoundingClientRect(),s=n.tagName.toLowerCase(),a=[...n.classList].filter(c=>!/^(astro|svelte|css)-/.test(c)).slice(0,2);u={selector:zo(n),tag:s,classes:a,nth:Tn({tag:s,classes:a}).indexOf(n),rx:o.width?(t.clientX-o.left)/o.width:.5,ry:o.height?(t.clientY-o.top)/o.height:.5,label:_(n.textContent||"").slice(0,60),ctx:Go(n),category:ln[0].id},y=null,mt.hidden=!0,g()},gs=2200,fs=900*1024,hs=8*1024*1024,G=t=>{const e=document.createElement("div");e.className="dt-toast",e.textContent=t,document.body.append(e),setTimeout(()=>e.remove(),2800)},bs=t=>new Promise(e=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.readAsDataURL(t)}),ys=async t=>{const e=await createImageBitmap(t),n=Math.min(1,gs/Math.max(e.width,e.height));if(n===1&&t.size<=fs)return e.close(),bs(t);const o=document.createElement("canvas");return o.width=Math.round(e.width*n),o.height=Math.round(e.height*n),o.getContext("2d").drawImage(e,0,0,o.width,o.height),e.close(),o.toDataURL("image/jpeg",.85)},Ge=async(t,e)=>{const n=[];for(const o of t){let s;try{s=await ys(o)}catch{G("That image could not be read.");continue}if(s.length>hs){G("Screenshot is too large even after shrinking.");continue}n.push(s)}if(n.length){if(!Number(e?.dataset.id)){u&&((u.images??=[]).push(...n),g());return}at.push(...n),g(),oo(".dt-note-reply-input")}},no=t=>[...t??[]].filter(e=>e.kind==="file"&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(Boolean);f.addEventListener("paste",t=>{const e=no(t.clipboardData?.items);e.length&&(t.preventDefault(),Ge(e,t.target.closest(".dt-note")))}),f.addEventListener("dragover",t=>{t.target.closest(".dt-note")&&(t.preventDefault(),t.target.closest(".dt-note").querySelector(".dt-compose")?.setAttribute("data-drop",""))}),f.addEventListener("dragleave",t=>{t.target.closest(".dt-note")?.querySelector(".dt-compose")?.removeAttribute("data-drop")}),f.addEventListener("drop",t=>{const e=t.target.closest(".dt-note");if(!e)return;t.preventDefault(),e.querySelector(".dt-compose")?.removeAttribute("data-drop");const n=no(t.dataTransfer?.items);n.length&&Ge(n,e)});const oo=t=>{const e=f.querySelector(t);e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},so=()=>{oo(".dt-note-edit-input"),f.querySelector(".dt-msg .dt-compose")?.scrollIntoView({block:"nearest"})},Ve=t=>{t.style.overflowY="hidden",t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.style.overflowY=t.scrollHeight>t.clientHeight?"auto":"hidden"},vs=t=>/(?:^|\s)@([^\s@]*)$/.exec(t.value.slice(0,t.selectionStart??t.value.length)),$s=t=>{t.closest(".dt-compose").querySelector(".dt-mentions")?.remove();const n=vs(t);if(!n||!v.team?.length)return;const o=n[1].toLowerCase(),s=v.team.filter(a=>[a.name,a.nickname,a.email].some(c=>c?.toLowerCase().startsWith(o))).slice(0,5);s.length&&t.insertAdjacentHTML("afterend",`<div class="dt-mentions" role="listbox" aria-label="Mention someone">${s.map((a,c)=>`<button type="button" role="option" aria-selected="${c===0}" data-act="mention" data-handle="${m(Ns(a))}">${m(a.name||a.email)}${a.name?` <span>${m(a.email)}</span>`:""}</button>`).join("")}</div>`)},ao=(t,e)=>{const n=t.selectionStart??t.value.length,o=t.value.slice(0,n).lastIndexOf("@");t.value=`${t.value.slice(0,o)}@${e} ${t.value.slice(n)}`,t.selectionStart=t.selectionEnd=o+e.length+2,t.closest(".dt-compose")?.querySelector(".dt-mentions")?.remove(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()},Es=(t,e)=>{if(!t){u&&(u.category=e),g();return}vt(n=>n.map(o=>o.id===t?{...o,category:e}:o),()=>j("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,category:e})}),"Changing the type")},M=document.createElement("div");M.className="dt-field-menu",M.setAttribute("role","listbox"),M.hidden=!0,document.body.append(M);for(const t of["pointerdown","mousedown","pointerup","mouseup","click","focusin","focusout"])M.addEventListener(t,e=>e.stopPropagation());let Wt=null;const Et=()=>{M.hidden=!0,Wt=null};f.addEventListener("mousedown",t=>{const e=t.target.closest(".dt-cat-select, .dt-for-select");if(!e){M.contains(t.target)||Et();return}if(t.preventDefault(),Wt===e){Et();return}Wt=e,M.innerHTML=[...e.options].map((s,a)=>`<button type="button" role="option" data-i="${a}" aria-selected="${s.selected}"><i style="background:${m(s.dataset.c||"#717171")}"></i><span>${m(s.text)}</span>${s.selected?Rt:""}</button>`).join("");const n=e.parentElement.getBoundingClientRect();M.style.left=`${n.left}px`,M.style.top=`${n.bottom+4}px`,M.style.minWidth=`${n.width}px`,M.hidden=!1;const o=M.getBoundingClientRect();o.bottom>innerHeight-8&&(M.style.top=`${n.top-4-o.height}px`)}),M.addEventListener("click",t=>{const e=t.target.closest("[data-i]");if(!e||!Wt)return;const n=Wt;Et(),n.selectedIndex!==Number(e.dataset.i)&&(n.selectedIndex=Number(e.dataset.i),n.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("keydown",t=>{t.key==="Escape"&&!M.hidden&&(t.stopPropagation(),Et())},!0),document.addEventListener("pointerdown",t=>{!M.hidden&&!M.contains(t.target)&&!t.target.closest?.(".dt-cat-select, .dt-for-select")&&Et()},!0),addEventListener("scroll",t=>{M.contains(t.target)||Et()},!0),f.addEventListener("change",t=>{const e=t.target.closest(".dt-cat-select");if(e){Es(Number(e.dataset.id)||0,e.value);return}const n=t.target.closest(".dt-for-select");if(!n)return;n.parentElement?.style.setProperty("--cat",qt(n.value));const o=Number(n.dataset.id);if(o){const s=n.value||null;vt(a=>a.map(c=>c.id===o?{...c,assignee:s??void 0}:c),()=>j("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,assignee:s})}),"Reassigning");return}if(u){u.assignee=n.value;try{localStorage.setItem("nm-for",n.value)}catch{}te()}}),f.addEventListener("input",t=>{const e=t.target.closest(".dt-suggest-input");if(e&&u?.suggest){u.suggest.to=e.value,te(),Ve(e);return}const n=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");n&&($s(n),n.classList.contains("dt-note-input")?u&&(u.text=n.value):n.classList.contains("dt-note-edit-input")?x&&(x.text=n.value):W=n.value,te(),n.closest(".dt-compose")?.querySelector(".dt-send")?.classList.toggle("is-ready",n.value.trim()!==""),Ve(n))}),f.addEventListener("keydown",t=>{const e=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");if(!e)return;const n=e.closest(".dt-compose")?.querySelector(".dt-mentions button");if(n&&(t.key==="Enter"||t.key==="Tab")&&!t.isComposing){t.preventDefault(),ao(e,n.dataset.handle);return}if(n&&t.key==="Escape"){t.stopPropagation(),n.parentElement.remove();return}t.key!=="Enter"||t.shiftKey||t.isComposing||(t.preventDefault(),e.closest(".dt-compose")?.querySelector(".dt-send")?.click())}),f.addEventListener("click",async t=>{const e=t.target.closest("button");if(!e)return;const n=e.dataset.act,o=Number(e.dataset.id);if(n==="mention"){const s=e.closest(".dt-compose")?.querySelector("textarea");s&&ao(s,e.dataset.handle);return}if(!n){if(y=y===o?null:o,y!=null&&e.dataset.off){const s=h.find(c=>c.id===o);(s&&X(s))?.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}z(),g();return}if(n==="record"){ss(e.closest(".dt-note"));return}if(n==="attach"){const s=Object.assign(document.createElement("input"),{type:"file",accept:"image/*",multiple:!0}),a=e.closest(".dt-note");s.addEventListener("change",()=>{s.files?.length&&Ge([...s.files],a)}),s.click();return}if(n==="unshot"){o?x&&x.drop.push(e.dataset.img):(e.closest("[data-draft]")?u?.images??[]:at).splice(Number(e.dataset.i),1),g(),x&&so();return}if(n==="edit"){const s=h.find(d=>d.id===o),a=e.dataset.at||null,c=a?s?.replies?.find(d=>d.at===a)?.text:s?.text;if(c===void 0)return;x={id:o,at:a,text:c,drop:[]},g(),so();return}if(n==="edit-cancel"){x=null,g();return}if(n==="edit-save"){const s=x;if(!s)return;const a=s.text.trim();if(!a){f.querySelector(".dt-note-edit-input")?.focus();return}x=null;const c=d=>s.drop.includes(d.split("/").pop());await vt(d=>d.map(r=>r.id!==s.id?r:{...r,...s.at==null?{text:a}:{replies:(r.replies??[]).map(l=>l.at===s.at?{...l,text:a}:l)},images:(r.images??[]).filter(l=>!c(l))}),()=>j("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s.id,edit:{at:s.at,text:a},...s.drop.length?{removeImage:s.drop}:{}})}).then(d=>(d.ok||(x=s),d)),"Saving the edit");return}if(n==="cancel"){z(),g();return}if(n==="twin"){z(),y=Number(e.dataset.id),g();return}if(n==="discard"){u=null,g();return}if(n==="draft-open"){Pe(Number(e.dataset.i));return}if(n==="close"){y=null,g();return}if(n==="suggest"&&u){const s=Bn(X(u));u.suggest={from:s,to:s},g();const a=f.querySelector(".dt-suggest-input");a?.focus(),a?.select();return}if(n==="unsuggest"&&u){u.suggest=null,g();return}if(n==="save"){if(!u)return;const s=u.suggest&&u.suggest.to.trim()!==u.suggest.from?{from:u.suggest.from,to:u.suggest.to.trim()}:null,a=f.querySelector(".dt-note-input").value.trim()||(s?"Change the text":"");if(!a){f.querySelector(".dt-note-input")?.focus();return}const c=u,d={...c,route:K,text:a,suggest:s,assignee:v.client?void 0:c.assignee??Cn(),breakpoint:rt(),browser:Wo(),device:E?ro:"",viewport:{w:innerWidth,h:innerHeight},logs:Fs(),host:location.host},r={...c,id:-Date.now(),text:a,route:K,status:"open",note:"",doneBy:null,breakpoint:d.breakpoint,replies:[],images:[],createdAt:new Date().toISOString(),...s?{suggest:s}:{},by:v.me?.email,byName:v.me?.name};h=[...h,r],u=null,g();const l=await j("comments",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)});if(!l.ok){h=h.filter(b=>b!==r),u=c,g(),G(`Comment was not saved (${l.status}).`);return}const p=Ot([await l.json().catch(()=>null)])[0];h=h.map(b=>b===r&&p?p:b),g(),de();return}if(n==="reply"){const s=f.querySelector(".dt-note-reply-input"),a=s.value.trim();if(!a){s.focus();return}const c=at;W="",at=[];const d=h;h=h.map(p=>p.id===o?{...p,replies:[...p.replies??[],{author:"you",text:a,at:new Date().toISOString(),by:v.me?.email}]}:p),g();const r=await j("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,reply:a,images:c})});if(!r.ok){h=d,W=a,at=c,g(),G(`Reply was not sent (${r.status}).`);return}const l=Ot([await r.json().catch(()=>null)])[0];l&&(h=h.map(p=>p.id===l.id?l:p),g()),de();return}y=null,n==="rm"?await zn(o):n==="archive"?await ls(o):await Dt(o,n==="done")});let zt="overlay",wt="",ro="";const O=t=>{N.hidden||L.contentWindow?.postMessage({dt:!0,...t},location.origin)},ws=()=>({notes:A,grid:!Ut.hidden,inspect:pt,resolved:J,scrollbar:zt,device:wt});addEventListener("message",t=>{if(t.origin!==location.origin||!t.data?.dt)return;const e=t.data;if(!E&&t.source===L.contentWindow){if(e.key){yo(e.key[0],e.key[1])?.run();return}if(e.closeMenus){kt();return}if(e.drafts){qe=e.drafts,_n(ee());return}}if(E&&typeof e.openDraft=="number"){Pe(e.openDraft);return}if(E&&typeof e.dropDraft=="number"){Gn(e.dropDraft);return}if(E&&typeof e.device=="string"&&(ro=e.device),E&&e.scrollbar&&document.documentElement.classList.toggle("dt-sb-classic",e.scrollbar==="classic"),e.hello&&t.source===L.contentWindow){O(ws());return}typeof e.notes=="boolean"&&e.notes!==A&<(e.notes,!1),typeof e.open=="number"&&Oe(e.open),typeof e.grid=="boolean"&&e.grid===Ut.hidden&&be(e.grid),typeof e.inspect=="string"&&e.inspect!==pt&&Yt(e.inspect),typeof e.resolved=="boolean"&&e.resolved!==J&&Ke(e.resolved),e.reload&&(bt(),ie())});const de=async()=>{await bt(),ie(),O({reload:!0}),E&&parent.postMessage({dt:!0,reload:!0},location.origin)},lt=(t,e=!0)=>{if(A=t,$n.setAttribute("aria-pressed",String(t)),t?!E&&F.hidden&&localStorage.getItem("dt-history")!=="0"&&(F.hidden=!1,Jt.setAttribute("aria-pressed","true")):(F.hidden=!0,Jt.setAttribute("aria-pressed","false")),V(Ln,t?"1":"0"),O({notes:t}),E&&e&&parent.postMessage({dt:!0,notes:t},location.origin),f.hidden=!t||!N.hidden,document.documentElement.classList.toggle("dt-noting",t),t){Yt(""),document.addEventListener("click",eo,!0);for(const n of Qn)document.addEventListener(n,to,!0);document.addEventListener("keydown",Zn),document.addEventListener("mousemove",Xn),addEventListener("scroll",it,!0),addEventListener("resize",it),Un.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),Yn.observe(document.body),bt()}else{z(),y=null,document.removeEventListener("click",eo,!0);for(const n of Qn)document.removeEventListener(n,to,!0);document.removeEventListener("keydown",Zn),document.removeEventListener("mousemove",Xn),mt.hidden=!0,removeEventListener("scroll",it,!0),removeEventListener("resize",it),Un.disconnect(),Yn.disconnect(),f.innerHTML=""}},ce="dt-w",Ue="dt-canvas",St="dt-device";let dt=localStorage.getItem(Ue)==="1",w=localStorage.getItem(St)||"";w&&!Vt(w)&&(w="",localStorage.setItem(St,""));let C=Number(localStorage.getItem(ce))||0;const io="dt-emu";let P=(()=>{try{return JSON.parse(localStorage.getItem(io)||"null")}catch{return null}})();const ue=()=>P?Lo.find(t=>t.id===P.id)??null:null,Ss=()=>{const t=ue();return t?P.turned?{w:t.h,h:t.w}:{w:t.w,h:t.h}:null};let _t=localStorage.getItem("dt-bars-min")==="1";const Lt=t=>{P=t,V(io,t?JSON.stringify(t):"")},Ye=t=>{Sn.textContent=t,N.style.setProperty("--dt-badge-w",`${Sn.offsetWidth}px`)},lo=t=>{if(!t){At.innerHTML="";return}let e="";for(let n=0;n<=t;n+=50)e+=`<span class="dt-tick${n%200===0?" is-major":""}" style="left:${n}px"></span>`;for(const n of I)for(const o of[n.min,n.max])o>0&&Number.isFinite(o)&&o<=t&&(e+=`<span class="dt-edge" style="left:${o}px" title="${n.label} edge"></span>`);At.innerHTML=e,At.style.width=`${t}px`},Je=()=>{const t=parseFloat(S.style.width)||0,e=parseFloat(S.style.height)||0;if(!t||!e){S.style.transform="",delete S.dataset.scaled;return}const n=w||P?Math.min(1,(innerWidth-80)/t,(innerHeight-120)/e):Math.min(1,(innerWidth-80)/t);S.style.transform=n<1?`scale(${n})`:"",S.dataset.scaled=n<1?String(Math.round(n*100)):""},Ls=t=>Lo.find(e=>e.w===t.w&&e.h===t.h&&e.cutout?.shape==="pill")?.cutout,pe=()=>{try{return L.contentDocument}catch{return null}},co=()=>pe()?.title.split("\u2014").pop()?.trim()||"",Xe=()=>{const t=pe(),e=w?Vt(w):null;if(!t?.body||!e)return;const n=Ps(t),o=e.browser==="chrome-android"?n.theme||"rgb(255, 255, 255)":n.top,s=e.browser==="chrome-android"?"rgb(255, 255, 255)":n.bottom;S.style.setProperty("--dt-top",o),S.style.setProperty("--dt-top-ink",xo(o)),S.style.setProperty("--dt-bottom",s),S.style.setProperty("--dt-bottom-ink",xo(s));const a=Ht.querySelector(".dt-win-tab > span");a&&(a.textContent=co()||location.host)};let Ze=0;L.addEventListener("load",()=>{pe()&&(Xe(),L.contentWindow?.addEventListener("scroll",()=>{Ze||(Ze=requestAnimationFrame(()=>{Ze=0,Xe()}))},{passive:!0}))});for(const t of[Ht,Xt])t.addEventListener("click",e=>{const n=e.target.closest("[data-nav]")?.dataset.nav;if(n)try{const o=L.contentWindow?.navigation;if(!pe()||!o)throw new Error("foreign");n==="back"?o.canGoBack&&o.back():n==="fwd"?o.canGoForward&&o.forward():o.reload()}catch{(n==="reload"||n==="back")&&(L.src=location.href)}});Ct.addEventListener("click",()=>{_t=!_t,V("dt-bars-min",_t?"1":"0"),ot()});const ot=()=>{if(E)return;const t=w?Vt(w)??null:null;if(w&&!t&&(w="",localStorage.setItem(St,"")),!t&&!dt){N.hidden=!0,L.removeAttribute("src"),document.documentElement.classList.remove("dt-framing"),f.hidden=!A,At.innerHTML="",Bt(),Me.hidden=!0,Ct.hidden=!0,nt=null,wt="",qe=[],Bt(),en(),A?bt():g();return}if(N.hidden=!1,document.documentElement.classList.add("dt-framing"),f.hidden=!0,L.src||(L.src=location.href),t){const e=Os(t,{host:location.host,title:co(),now:new Date,min:_t,cutout:Ls(t)}),{screen:n}=e;N.dataset.mode="device",S.dataset.shell=t.shell,S.dataset.browser=t.browser,S.style.width=`${e.footprint.w}px`,S.style.height=`${e.footprint.h}px`,S.style.setProperty("--dt-r",`${n.r}px`),S.style.setProperty("--dt-rb",`${n.rb}px`),En.innerHTML=e.shell;const o=(c,d,r,l)=>{c.innerHTML=l,c.style.cssText=`left:${n.x}px;top:${d}px;width:${n.w}px;height:${r}px`};o(Ht,n.y,e.topH,e.top),o(Xt,n.y+n.h-e.bottomH,e.bottomH,e.bottom);const s=n.h-e.topH-e.bottomH;L.style.position="absolute",L.style.left=`${n.x}px`,L.style.top=`${n.y+e.topH}px`,L.style.width=`${n.w}px`,L.style.height=`${s}px`,At.innerHTML="";const a=_t&&e.canMinimize;zt=e.scrollbar,wt=`${t.label}${a?" \xB7 bars folded":""}`,nt=Mt(t.w),O({notes:A,scrollbar:zt,device:wt}),Ct.hidden=!e.canMinimize,Ct.setAttribute("aria-pressed",String(a)),Ye(`${t.label} \xB7 page ${t.w}\xD7${s} of ${t.w}\xD7${t.h}${a?" \xB7 bars folded":""} \xB7 ${I.find(c=>c.id===nt)?.label??""}`),Xe()}else{const e=Ss();e||Lt(null);const n=e?.w||C||I.find(a=>a.id===rt()).ideal;C=n,N.dataset.mode="canvas",delete S.dataset.shell,delete S.dataset.browser,En.innerHTML=Ht.innerHTML=Xt.innerHTML="",Ht.style.cssText=Xt.style.cssText="",Ct.hidden=!0,zt="overlay",S.style.width=`${n}px`,S.style.height=`${e?.h??innerHeight-84}px`,L.style.position="",L.style.left=L.style.top="",L.style.width="100%",L.style.height="100%",lo(n),O({notes:A});const o=I.find(a=>a.id===Mt(n)),s=ue();wt=s?`${s.label}${P?.turned?" \xB7 landscape":""}`:"",O({scrollbar:zt,device:wt}),Ye(s&&e?`${s.label} \xB7 ${e.w}\xD7${e.h} \xB7 ${o.label}`:`${n}px \xB7 ${o.label}`),nt=Mt(n)}Me.hidden=!(ue()?.rotates&&!t),en(),Je(),Bt(),A?bt():g()},Qe=t=>{const e=I.find(n=>n.id===t);w="",localStorage.setItem(St,""),Lt(null),dt=t!==fe,C=dt?e.ideal:0,nt=dt?t:null,localStorage.setItem(Ue,dt?"1":"0"),localStorage.setItem(ce,String(C)),y=null,z(),ot()};for(const t of xe)t.addEventListener("click",()=>Qe(t.dataset.bp));for(const t of document.querySelectorAll("[data-device]"))t.addEventListener("click",()=>{w=t.dataset.device===w?"":t.dataset.device,localStorage.setItem(St,w),Y.open=!1,ot()});for(const t of document.querySelectorAll("[data-emu]"))t.addEventListener("click",()=>{const e=P?.id===t.dataset.emu&&!w;w="",localStorage.setItem(St,""),Lt(e?null:{id:t.dataset.emu,turned:!1}),dt=!e,C=0,localStorage.setItem(Ue,dt?"1":"0"),nt=null,y=null,z(),Y.open=!1,ot()});Me.addEventListener("click",()=>{P&&(Lt({...P,turned:!P.turned}),y=null,z(),ot())});const uo=[...Y.querySelectorAll("[data-tab]")],xs=[...Y.querySelectorAll("[data-panel]")],po=t=>{for(const e of uo)e.setAttribute("aria-selected",String(e.dataset.tab===t));for(const e of xs)e.hidden=e.dataset.panel!==t;V("dt-devices-tab",t)};for(const t of uo)t.addEventListener("click",()=>po(t.dataset.tab));po(localStorage.getItem("dt-devices-tab")==="devtools"?"devtools":"preview");const tn=Y.querySelector(".dt-emu-search");tn.addEventListener("input",()=>{const t=tn.value.trim().toLowerCase();let e=null,n=!1;const o=()=>{e&&(e.hidden=!n)};for(const s of tn.parentElement.children){if(s.classList.contains("dt-devices-group")){o(),e=s,n=!1;continue}s.dataset.emu&&(s.hidden=!!t&&!s.textContent.toLowerCase().includes(t),n||=!s.hidden)}o()});const Ts=Y.querySelector(".dt-devices-name");function en(){for(const e of Y.querySelectorAll("[data-device]"))e.setAttribute("aria-pressed",String(e.dataset.device===w));const t=!w&&!N.hidden?P?.id:void 0;for(const e of Y.querySelectorAll("[data-emu]"))e.setAttribute("aria-pressed",String(e.dataset.emu===t));Ts.textContent=w&&Vt(w)?.label||t&&ue()?.label||"Device"}const nn=t=>I.find(e=>e.id===t),Ms=t=>{const e=nn(nt??rt());return Math.max(e.min||320,Math.min(Number.isFinite(e.max)?e.max:2560,Math.round(t)))};for(const t of Po){const e=t.dataset.edge==="l"?-1:1;t.addEventListener("pointerdown",n=>{if(w)return;n.preventDefault(),P&&(Lt(null),ot()),t.setPointerCapture(n.pointerId);const o=n.clientX,s=C,a=Number(S.dataset.scaled||100)/100;N.dataset.dragging="1";const c=r=>{C=Ms(s+e*(r.clientX-o)*2/a),S.style.width=`${C}px`,lo(C),Ye(`${C}px \xB7 ${nn(Mt(C)).label}`),Je()},d=()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerup",d),delete N.dataset.dragging,localStorage.setItem(ce,String(C)),ot()};t.addEventListener("pointermove",c),t.addEventListener("pointerup",d)}),t.addEventListener("dblclick",()=>{if(w)return;Lt(null);const n=nn(nt??rt()),o=[n.min||320,Number.isFinite(n.max)?n.max:n.ideal];C=Math.abs(C-o[0])<Math.abs(C-o[1])?o[0]:o[1],localStorage.setItem(ce,String(C)),ot()})}let mo=rt();addEventListener("resize",()=>{Bt(),rt()!==mo&&(mo=rt(),g()),N.hidden||(!w&&!P&&(S.style.height=`${innerHeight-84}px`),Je())});const go="dt-studio",fo=t=>{Te.setAttribute("aria-pressed",String(t)),document.documentElement.classList.toggle("dt-no-studio",!t),V(go,t?"1":"0")};Te.addEventListener("click",()=>fo(Te.getAttribute("aria-pressed")!=="true")),fo(localStorage.getItem(go)!=="0"),$n.addEventListener("click",()=>lt(!A));const xt=document.querySelector(".devtools"),Gt=document.querySelector(".dt-tab"),ho=t=>{xt.toggleAttribute("data-collapsed",t),Gt.toggleAttribute("data-collapsed",t),Gt.setAttribute("aria-expanded",String(!t)),Gt.setAttribute("aria-label",t?"Show the bar":"Hide the bar");for(const e of xt.querySelectorAll(".dt-group"))e.inert=t;t&&kt(),V("dt-collapsed",t?"1":"0")};Gt.addEventListener("click",()=>ho(!xt.hasAttribute("data-collapsed")));const on=document.querySelector(".dt-keys"),ct=t=>()=>xt.querySelector(t)?.click(),bo=t=>()=>{const e=[...document.querySelectorAll(".dt-pages a")];e[e.findIndex(n=>n.hasAttribute("aria-current"))+t]?.click()},me=[{group:"Comments",code:"KeyC",hint:"C",label:"Comment mode",el:".dt-notes-btn",run:ct(".dt-notes-btn")},{group:"Comments",code:"KeyC",shift:!0,hint:"\u21E7C",label:"Comments panel",el:".dt-history-btn",run:ct(".dt-history-btn")},{group:"Comments",code:"KeyR",hint:"R",label:"Show resolved",el:".dt-resolved-btn",run:ct(".dt-resolved-btn")},{group:"Inspect",code:"KeyG",hint:"G",label:"Grid",el:".dt-grid-btn",run:ct(".dt-grid-btn")},{group:"Inspect",code:"KeyP",hint:"P",label:"Spacing",el:".dt-pad-btn",run:ct(".dt-pad-btn")},{group:"Inspect",code:"KeyS",hint:"S",label:"Size",el:".dt-size-btn",run:ct(".dt-size-btn")},{group:"Inspect",code:"KeyT",hint:"T",label:"Typography",el:".dt-type-btn",run:ct(".dt-type-btn")},...v.sanity?[{group:"Inspect",code:"KeyE",hint:"E",label:"Sanity overlay",el:".dt-studio-btn",run:ct(".dt-studio-btn")}]:[],...xe.slice(0,9).map((t,e)=>({group:"Breakpoints",code:`Digit${e+1}`,hint:String(e+1),label:t.dataset.tip??t.title,el:`.dt-bp[data-bp="${t.dataset.bp}"]`,run:()=>t.click()})),{group:"View",code:"KeyD",hint:"D",label:"Devices",run:()=>{Y.open=!Y.open}},{group:"View",code:"BracketLeft",hint:"[",label:"Previous page",run:bo(-1)},{group:"View",code:"BracketRight",hint:"]",label:"Next page",run:bo(1)},{group:"View",code:"Backslash",hint:"\\",label:"Hide the bar",run:()=>Gt.click()},{group:"View",code:"Slash",shift:!0,hint:"?",label:"This list",el:".dt-keys summary",run:()=>{on.open=!on.open}}].filter(t=>!v.client||t.group!=="Inspect"),yo=(t,e)=>me.find(n=>n.code===t&&!n.shift==!e),ks=t=>t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName));if(v.shortcuts){for(const e of me){const n=e.el&&xt.querySelector(e.el);n&&(n.dataset.tip=`${n.dataset.tip??e.label} \xB7 ${e.hint}`,n.setAttribute("aria-keyshortcuts",e.hint.startsWith("\u21E7")?`Shift+${e.hint.slice(1)}`:e.hint))}const t=(e,n)=>`<div class="dt-key-row"><span>${m(e)}</span><kbd>${m(n)}</kbd></div>`;if(on.querySelector(".dt-keys-menu").innerHTML='<p class="dt-menu-note">One key, no modifier, in any keyboard layout. Not while you type.</p>'+[...new Set(me.map(e=>e.group))].map(e=>`<p class="dt-devices-group">${e}</p>`+me.filter(n=>n.group===e).map(n=>t(n.label,n.hint)).join("")).join("")+'<p class="dt-devices-group">In a comment</p>'+t("Send","Enter")+t("New line","\u21E7Enter")+t("Close, cancel, back out","Esc"),document.addEventListener("keydown",e=>{if(e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||ks(e.target))return;const n=yo(e.code,e.shiftKey);n&&(e.preventDefault(),E?parent.postMessage({dt:!0,key:[e.code,e.shiftKey]},location.origin):n.run())}),E){const e=()=>parent.postMessage({dt:!0,closeMenus:!0},location.origin);document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n=>{n.key==="Escape"&&e()})}}if(!E){ho(localStorage.getItem("dt-collapsed")==="1"),requestAnimationFrame(()=>requestAnimationFrame(()=>xt.setAttribute("data-ready",""))),dt||w?ot():en(),be(localStorage.getItem(cn)==="1");const t=localStorage.getItem(gn);t&&t in $e&&Yt(t),lt(localStorage.getItem(Ln)==="1")}const vo=()=>{try{const t=JSON.parse(localStorage.getItem(yt)||"null");q=(t?.parked??[]).filter(e=>Zt(e)),t?.draft&&document.querySelector(t.draft.selector)?(u=t.draft,!A&&!E&<(!0)):Zt(t?.draft)&&q.push(t.draft),t?.reply?.text&&(W=t.reply.text,Nt=y=t.reply.for??null),(u||q.length||W)&&g()}catch{localStorage.removeItem(yt)}};vo();const $o=()=>setTimeout(()=>{const t=he(location.pathname);t!==K&&(clearTimeout(Qt),Ae(),K=t,yt=xn(),u=null,q=[],W="",Nt=null,y=null,x=null,h=[],pn(),vo(),bt())});for(const t of["pushState","replaceState"]){const e=window.history[t];window.history[t]=function(...n){e.apply(this,n),$o()}}addEventListener("popstate",$o),A||bt(),ie().then(()=>{ae()&&re()}),document.addEventListener("visibilitychange",()=>{document.hidden||Kt()}),addEventListener("focus",Kt),addEventListener("notemend:changed",()=>{E||Kt()});let Hs=0;E||setInterval(()=>{(!qs.live||++Hs%6===0)&&Kt()},2e4),E&&parent.postMessage({dt:!0,hello:!0},location.origin)}export{Ys as run};
|
|
106
|
+
<button data-r="skip" aria-label="Next fix" data-tip="Next \xB7 \u2192">${ko}</button></span>
|
|
107
|
+
<span class="dt-review-text">${g(wt(e.text).slice(0,90))}</span>
|
|
108
|
+
<button data-r="ok" class="dt-review-ok" aria-label="Looks right \u2014 mark it resolved" data-tip="Looks right \u2014 resolve it">${Nt}</button>
|
|
109
|
+
<button data-r="no" aria-label="Reopen" data-tip="Not yet \u2014 reopen it">${Ao}</button>
|
|
110
|
+
<button data-r="stop" aria-label="Stop checking" data-tip="Stop checking">${Qt}</button>`,R.hidden=!1};R.addEventListener("click",async t=>{const e=t.target.closest("[data-r]"),n=te();if(!e||!n)return;if(e.dataset.r==="stop"){ht(null),R.hidden=!0;return}if(e.dataset.r==="prev"){Bn();return}const o=n.ids[n.i];ht({...n,i:n.i+1});const s=e.dataset.r==="ok"?It(o,!0):e.dataset.r==="no"?It(o,!1):null;ee(),await s});const Bn=()=>{const t=te();if(t){for(let e=t.i-1;e>=0;e--)if(C(Y.find(n=>n.id===t.ids[e])??{status:"done"})==="claude"){ht({...t,i:e}),ee();return}}};document.addEventListener("keydown",t=>{R.hidden||t.metaKey||t.ctrlKey||t.altKey||t.key!=="ArrowLeft"&&t.key!=="ArrowRight"||t.target.closest?.("input, textarea, select, [contenteditable]")||(t.preventDefault(),t.key==="ArrowLeft"?Bn():R.querySelector('[data-r="skip"]')?.click())});const zo=t=>{P.hidden=!t,Ut.setAttribute("aria-pressed",String(t)),_("dt-history",t?"1":"0"),m()},Ne=document.querySelector(".dt-resolved-btn"),Ce=t=>{U=t,Ne.setAttribute("aria-pressed",String(t)),_("dt-resolved",t?"1":"0"),D({resolved:t}),m(),ne()};Ne.addEventListener("click",()=>Ce(!U)),Ne.setAttribute("aria-pressed",String(U)),Ut.addEventListener("click",()=>{const t=P.hidden===!0;t&&!M&&st(!0),t&&Me(!1),zo(t)});const ot=()=>{Ee||!M||(Ee=requestAnimationFrame(()=>{Ee=0,Fo()}))},In=new MutationObserver(t=>{t.every(e=>e.target.closest?.(".dt-notes-overlay"))||ot()}),qn=new ResizeObserver(()=>ot());let Y=[];const Rn=t=>{Y=t;const e=()=>({open:0,claude:0,done:0}),n={};for(const u of t){const a=C(u),l=n[u.route??""]??={...e(),bands:{}};l[a]++;const p=G(u);(l.bands[p]??=e())[a]++}const o=["open","claude","done"],s={open:"open",claude:"resolved by an agent, to check",done:"resolved"},r=u=>o.map(a=>[a,a==="done"&&!U?0:u[a]]),c=u=>r(u).reduce((a,[,l])=>a+l,0);for(const u of document.querySelectorAll(".dt-pages a")){const a=u.querySelector(".dt-pages-n");if(!a)continue;const l=n[new URL(u.href).pathname.replace(/\/+$/,"")||"/"];for(const i of I){const x=l?.bands[i.id];for(const[H,N]of r(x??e())){const it=a.querySelector(`[data-bp="${i.id}"][data-state="${H}"]`);it.hidden=!N,N&&(it.querySelector("i").textContent=String(N),it.title=`${i.label}: ${N} ${s[H]}`)}}const p=l?c(l):0;a.hidden=!p;const L=l?I.filter(i=>l.bands[i.id]&&c(l.bands[i.id])).map(i=>`${i.label} ${c(l.bands[i.id])}`).join(" \xB7 "):"";a.title=p?`${l.open} open \xB7 ${l.claude} resolved by an agent, to check \xB7 ${l.done} resolved
|
|
111
|
+
${L}`:""}},qt=t=>(Array.isArray(t)?t:[]).filter(e=>e&&Number.isInteger(Number(e.id))&&typeof e.text=="string").filter(e=>!b.client||e.by===b.me?.email||e.assignee===b.me?.email).map(e=>({...e,id:Number(e.id),rx:Number(e.rx)||0,ry:Number(e.ry)||0,route:typeof e.route=="string"&&/^\/(?!\/)/.test(e.route)?e.route:"/",replies:Array.isArray(e.replies)?e.replies.filter(n=>typeof n?.text=="string"):[],images:Array.isArray(e.images)?e.images.filter(n=>typeof n=="string"):[]})),ne=async()=>{try{Rn(qt((await(await B("comments")).json()).comments)),!P.hidden&&!v&&m()}catch{}};let Rt=null,Dt=null;const pt=document.querySelector(".dt-turbo"),Be="/notemend:turbo",Ot=()=>{const t=!!Rt&&Date.now()-Date.parse(Rt.at)<18e4,e=t?Dt?.paused?"paused":"on":"none",n=t?J(Rt.agent):"",o=e==="none"?`Turbo is off. Run ${Be} in Claude Code and comments for the agent are taken as they land \u2014 click to copy it`:e==="on"?`Turbo on: ${n} takes comments for the agent as they land \u2014 click to pause`:`Turbo paused: ${n} is listening but waits \u2014 click to resume`;pt.dataset.state=e,pt.dataset.tip=o,pt.setAttribute("aria-label",o),pt.setAttribute("aria-checked",String(e==="on")),v&&(pt.hidden=!0)};setInterval(Ot,3e4),pt.addEventListener("click",async()=>{const t=pt.dataset.state;if(t==="none"){await navigator.clipboard?.writeText(Be).catch(()=>{}),j(`Copied ${Be} \u2014 paste it in Claude Code`);return}const e=t==="on"?"off":"on";Dt={paused:e==="off"},Ot();try{const n=await B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({turbo:e})});if(!n.ok)throw new Error(String(n.status));j(e==="off"?"Turbo paused":"Turbo on")}catch{Dt={paused:e==="on"},Ot(),j("Could not switch turbo \u2014 try again")}});let oe="",Ie=!1;const Pt=async()=>{if(!(document.hidden||Ie)){Ie=!0;try{const t=await B(`comments${oe?`?since=${oe}`:""}`);if(t.status!==200)return;const e=await t.json();oe=e.version??"",Rt=e.listening??null,Dt=e.turbo??null,Ot();const n=qt(e.comments);Rn(n);const o=n.filter(s=>s.route===K);if(JSON.stringify(o)===JSON.stringify(h))return;if(f.contains(document.activeElement)&&document.activeElement.matches("textarea, input")){oe="",setTimeout(Pt,5e3);return}h=o,m(),D({reload:!0})}catch{}finally{Ie=!1}}},mt=async()=>{try{const e=await(await B(`comments?route=${encodeURIComponent(K)}`)).json();h=qt(e.comments),Rt=e.listening??null,Dt=e.turbo??null,Ot()}catch{h=[]}m()};let qe=0;const Dn=t=>{qe||(qe=requestAnimationFrame(()=>{qe=0;const e=t.target;if(!M||e.closest(ge)){dt.hidden=!0;return}dt.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(dt.hidden=!1,!n)return;const o=n.getBoundingClientRect();bo.style.cssText=`left:${o.left}px;top:${o.top}px;width:${o.width}px;height:${o.height}px`,ln.textContent=n.tagName.toLowerCase()+([...n.classList].find(s=>!/^(astro|svelte)-/.test(s))?"."+[...n.classList].find(s=>!/^(astro|svelte)-/.test(s)):"")+` ${Math.round(o.width)}\xD7${Math.round(o.height)}`,ln.style.cssText=`left:${o.left}px;top:${Math.max(2,o.top-20)}px`}))},On=t=>{if(!(t.key!=="Escape"||t.isComposing)){if(t.preventDefault(),S){S=null,m();return}if(d){W(),m();return}if(y!==null){y=null,m();return}st(!1)}},Pn=["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend"],jn=t=>{t.target.closest?.(ge)||t.stopPropagation()},Kn=t=>{if(t.target.closest(ge))return;if(t.preventDefault(),t.stopPropagation(),me){me=!1;return}if(!getSelection()?.isCollapsed)return;f.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(f.hidden=!1,!n)return;W();const o=n.getBoundingClientRect(),s=n.tagName.toLowerCase(),r=[...n.classList].filter(c=>!/^(astro|svelte|css)-/.test(c)).slice(0,2);d={selector:So(n),tag:s,classes:r,nth:Lo({tag:s,classes:r}).indexOf(n),rx:o.width?(t.clientX-o.left)/o.width:.5,ry:o.height?(t.clientY-o.top)/o.height:.5,label:wt(n.textContent||"").slice(0,60),ctx:To(n),category:Xe[0].id},y=null,dt.hidden=!0,m()},Uo=2200,Vo=900*1024,Yo=8*1024*1024,j=t=>{const e=document.createElement("div");e.className="dt-toast",e.textContent=t,document.body.append(e),setTimeout(()=>e.remove(),2800)},Jo=t=>new Promise(e=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.readAsDataURL(t)}),Go=async t=>{const e=await createImageBitmap(t),n=Math.min(1,Uo/Math.max(e.width,e.height));if(n===1&&t.size<=Vo)return e.close(),Jo(t);const o=document.createElement("canvas");return o.width=Math.round(e.width*n),o.height=Math.round(e.height*n),o.getContext("2d").drawImage(e,0,0,o.width,o.height),e.close(),o.toDataURL("image/jpeg",.85)},Re=async(t,e)=>{const n=[];for(const o of t){let s;try{s=await Go(o)}catch{j("That image could not be read.");continue}if(s.length>Yo){j("Screenshot is too large even after shrinking.");continue}n.push(s)}if(n.length){if(!Number(e?.dataset.id)){d&&((d.images??=[]).push(...n),m());return}tt.push(...n),m(),Wn(".dt-note-reply-input")}},Fn=t=>[...t??[]].filter(e=>e.kind==="file"&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(Boolean);f.addEventListener("paste",t=>{const e=Fn(t.clipboardData?.items);e.length&&(t.preventDefault(),Re(e,t.target.closest(".dt-note")))}),f.addEventListener("dragover",t=>{t.target.closest(".dt-note")&&(t.preventDefault(),t.target.closest(".dt-note").querySelector(".dt-compose")?.setAttribute("data-drop",""))}),f.addEventListener("dragleave",t=>{t.target.closest(".dt-note")?.querySelector(".dt-compose")?.removeAttribute("data-drop")}),f.addEventListener("drop",t=>{const e=t.target.closest(".dt-note");if(!e)return;t.preventDefault(),e.querySelector(".dt-compose")?.removeAttribute("data-drop");const n=Fn(t.dataTransfer?.items);n.length&&Re(n,e)});const Wn=t=>{const e=f.querySelector(t);e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},_n=()=>{Wn(".dt-note-edit-input"),f.querySelector(".dt-msg .dt-compose")?.scrollIntoView({block:"nearest"})},De=t=>{t.style.overflowY="hidden",t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.style.overflowY=t.scrollHeight>t.clientHeight?"auto":"hidden"},Xo=t=>/(?:^|\s)@([^\s@]*)$/.exec(t.value.slice(0,t.selectionStart??t.value.length)),Zo=t=>{t.closest(".dt-compose").querySelector(".dt-mentions")?.remove();const n=Xo(t);if(!n||!b.team?.length)return;const o=n[1].toLowerCase(),s=b.team.filter(r=>[r.name,r.nickname,r.email].some(c=>c?.toLowerCase().startsWith(o))).slice(0,5);s.length&&t.insertAdjacentHTML("afterend",`<div class="dt-mentions" role="listbox" aria-label="Mention someone">${s.map((r,c)=>`<button type="button" role="option" aria-selected="${c===0}" data-act="mention" data-handle="${g(cs(r))}">${g(r.name||r.email)}${r.name?` <span>${g(r.email)}</span>`:""}</button>`).join("")}</div>`)},zn=(t,e)=>{const n=t.selectionStart??t.value.length,o=t.value.slice(0,n).lastIndexOf("@");t.value=`${t.value.slice(0,o)}@${e} ${t.value.slice(n)}`,t.selectionStart=t.selectionEnd=o+e.length+2,t.closest(".dt-compose")?.querySelector(".dt-mentions")?.remove(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()},Qo=(t,e)=>{if(!t){d&&(d.category=e),m();return}nt(n=>n.map(o=>o.id===t?{...o,category:e}:o),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,category:e})}),"Changing the type")};ws(f,g,Nt),f.addEventListener("change",t=>{const e=t.target.closest(".dt-prio-select");if(e){const r=e.value==="normal"?null:e.value,c=Number(e.dataset.id);c?nt(u=>u.map(a=>a.id===c?{...a,priority:r??void 0}:a),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:c,priority:r})}),"Setting the priority"):d&&(d.priority=r??void 0,Ht(),m());return}const n=t.target.closest(".dt-cat-select");if(n){Qo(Number(n.dataset.id)||0,n.value);return}const o=t.target.closest(".dt-for-select");if(!o)return;o.parentElement?.style.setProperty("--cat",Bt(o.value));const s=Number(o.dataset.id);if(s){const r=o.value||null;nt(c=>c.map(u=>u.id===s?{...u,assignee:r??void 0}:u),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,assignee:r})}),"Reassigning");return}if(d){d.assignee=o.value;try{localStorage.setItem("nm-for",o.value)}catch{}Ht()}}),f.addEventListener("input",t=>{const e=t.target.closest(".dt-suggest-input");if(e&&d?.suggest){d.suggest.to=e.value,Ht(),De(e);return}const n=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");n&&(Zo(n),n.classList.contains("dt-note-input")?d&&(d.text=n.value):n.classList.contains("dt-note-edit-input")?S&&(S.text=n.value):F=n.value,Ht(),n.closest(".dt-compose")?.querySelector(".dt-send")?.classList.toggle("is-ready",n.value.trim()!==""),De(n))}),f.addEventListener("keydown",t=>{const e=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");if(!e)return;const n=e.closest(".dt-compose")?.querySelector(".dt-mentions button");if(n&&(t.key==="Enter"||t.key==="Tab")&&!t.isComposing){t.preventDefault(),zn(e,n.dataset.handle);return}if(n&&t.key==="Escape"){t.stopPropagation(),n.parentElement.remove();return}t.key!=="Enter"||t.shiftKey||t.isComposing||(t.preventDefault(),e.closest(".dt-compose")?.querySelector(".dt-send")?.click())}),f.addEventListener("click",async t=>{const e=t.target.closest("button");if(!e)return;const n=e.dataset.act,o=Number(e.dataset.id);if(n==="mention"){const s=e.closest(".dt-compose")?.querySelector("textarea");s&&zn(s,e.dataset.handle);return}if(!n){if(y=y===o?null:o,y!=null&&e.dataset.off){const s=h.find(c=>c.id===o);(s&&Z(s))?.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}W(),m();return}if(n==="record"){Ro(e.closest(".dt-note"));return}if(n==="attach"){const s=Object.assign(document.createElement("input"),{type:"file",accept:"image/*",multiple:!0}),r=e.closest(".dt-note");s.addEventListener("change",()=>{s.files?.length&&Re([...s.files],r)}),s.click();return}if(n==="unshot"){o?S&&S.drop.push(e.dataset.img):(e.closest("[data-draft]")?d?.images??[]:tt).splice(Number(e.dataset.i),1),m(),S&&_n();return}if(n==="edit"){const s=h.find(u=>u.id===o),r=e.dataset.at||null,c=r?s?.replies?.find(u=>u.at===r)?.text:s?.text;if(c===void 0)return;S={id:o,at:r,text:c,drop:[]},m(),_n();return}if(n==="edit-cancel"){S=null,m();return}if(n==="edit-save"){const s=S;if(!s)return;const r=s.text.trim();if(!r){f.querySelector(".dt-note-edit-input")?.focus();return}S=null;const c=u=>s.drop.includes(u.split("/").pop());await nt(u=>u.map(a=>a.id!==s.id?a:{...a,...s.at==null?{text:r}:{replies:(a.replies??[]).map(l=>l.at===s.at?{...l,text:r}:l)},images:(a.images??[]).filter(l=>!c(l))}),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s.id,edit:{at:s.at,text:r},...s.drop.length?{removeImage:s.drop}:{}})}).then(u=>(u.ok||(S=s),u)),"Saving the edit");return}if(n==="cancel"){W(),m();return}if(n==="twin"){W(),y=Number(e.dataset.id),m();return}if(n==="discard"){d=null,m();return}if(n==="draft-open"){He(Number(e.dataset.i));return}if(n==="close"){y=null,m();return}if(n==="suggest"&&d){const s=bn(Z(d));d.suggest={from:s,to:s},m();const r=f.querySelector(".dt-suggest-input");r?.focus(),r?.select();return}if(n==="unsuggest"&&d){d.suggest=null,m();return}if(n==="save"){if(!d)return;const s=d.suggest&&d.suggest.to.trim()!==d.suggest.from?{from:d.suggest.from,to:d.suggest.to.trim()}:null,r=f.querySelector(".dt-note-input").value.trim()||(s?"Change the text":"");if(!r){f.querySelector(".dt-note-input")?.focus();return}const c=d,u={...c,route:K,text:r,suggest:s,assignee:b.client?void 0:c.assignee??fn(),breakpoint:et(),browser:wo(),device:v?Un:"",viewport:{w:innerWidth,h:innerHeight},logs:vs(),host:location.host},a={...c,id:-Date.now(),text:r,route:K,status:"open",note:"",doneBy:null,breakpoint:u.breakpoint,replies:[],images:[],createdAt:new Date().toISOString(),...s?{suggest:s}:{},by:b.me?.email,byName:b.me?.name};h=[...h,a],d=null,m();const l=await B("comments",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u)});if(!l.ok){h=h.filter(L=>L!==a),d=c,m(),j(`Comment was not saved (${l.status}).`);return}const p=qt([await l.json().catch(()=>null)])[0];h=h.map(L=>L===a&&p?p:L),m(),se();return}if(n==="reply"){const s=f.querySelector(".dt-note-reply-input"),r=s.value.trim();if(!r){s.focus();return}const c=tt;F="",tt=[];const u=h;h=h.map(p=>p.id===o?{...p,replies:[...p.replies??[],{author:"you",text:r,at:new Date().toISOString(),by:b.me?.email}]}:p),m();const a=await B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,reply:r,images:c})});if(!a.ok){h=u,F=r,tt=c,m(),j(`Reply was not sent (${a.status}).`);return}const l=qt([await a.json().catch(()=>null)])[0];l&&(h=h.map(p=>p.id===l.id?l:p),m()),se();return}if(n==="fixnow"){nt(s=>s.map(r=>r.id===o?{...r,assignee:"claude"}:r),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,fixNow:!0})}),"Sending it to the agent"),j("Sent to the agent \u2014 it takes it next");return}y=null,n==="rm"?await An(o):n==="archive"?await jo(o):await It(o,n==="done")});let jt="overlay",bt="",Un="";const D=t=>{A.hidden||w.contentWindow?.postMessage({dt:!0,...t},location.origin)},ts=()=>({notes:M,grid:!_t.hidden,inspect:lt,resolved:U,scrollbar:jt,device:bt});addEventListener("message",t=>{if(t.origin!==location.origin||!t.data?.dt)return;const e=t.data;if(!v&&t.source===w.contentWindow){if(e.key){oo(e.key[0],e.key[1])?.run();return}if(e.closeMenus){Lt();return}if(e.drafts){xe=e.drafts,Nn(Gt());return}}if(v&&typeof e.openDraft=="number"){He(e.openDraft);return}if(v&&typeof e.dropDraft=="number"){Cn(e.dropDraft);return}if(v&&typeof e.device=="string"&&(Un=e.device),v&&e.scrollbar&&document.documentElement.classList.toggle("dt-sb-classic",e.scrollbar==="classic"),e.hello&&t.source===w.contentWindow){D(ts());return}typeof e.notes=="boolean"&&e.notes!==M&&st(e.notes,!1),typeof e.open=="number"&&ke(e.open),typeof e.grid=="boolean"&&e.grid===_t.hidden&&pe(e.grid),typeof e.inspect=="string"&&e.inspect!==lt&&zt(e.inspect),typeof e.resolved=="boolean"&&e.resolved!==U&&Ce(e.resolved),e.reload&&(mt(),ne())});const se=async()=>{await mt(),ne(),D({reload:!0}),v&&parent.postMessage({dt:!0,reload:!0},location.origin)},st=(t,e=!0)=>{if(M=t,an.setAttribute("aria-pressed",String(t)),t?!v&&P.hidden&&localStorage.getItem("dt-history")!=="0"&&(P.hidden=!1,Ut.setAttribute("aria-pressed","true")):(P.hidden=!0,Ut.setAttribute("aria-pressed","false")),_(cn,t?"1":"0"),D({notes:t}),v&&e&&parent.postMessage({dt:!0,notes:t},location.origin),f.hidden=!t||!A.hidden,document.documentElement.classList.toggle("dt-noting",t),t){zt(""),document.addEventListener("click",Kn,!0);for(const n of Pn)document.addEventListener(n,jn,!0);document.addEventListener("keydown",On),document.addEventListener("mousemove",Dn),addEventListener("scroll",ot,!0),addEventListener("resize",ot),In.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),qn.observe(document.body),mt()}else{W(),y=null,document.removeEventListener("click",Kn,!0);for(const n of Pn)document.removeEventListener(n,jn,!0);document.removeEventListener("keydown",On),document.removeEventListener("mousemove",Dn),dt.hidden=!0,removeEventListener("scroll",ot,!0),removeEventListener("resize",ot),In.disconnect(),qn.disconnect(),f.innerHTML=""}},ae="dt-w",Oe="dt-canvas",yt="dt-device";let at=localStorage.getItem(Oe)==="1",$=localStorage.getItem(yt)||"";$&&!Wt($)&&($="",localStorage.setItem(yt,""));let k=Number(localStorage.getItem(ae))||0;const Vn="dt-emu";let O=(()=>{try{return JSON.parse(localStorage.getItem(Vn)||"null")}catch{return null}})();const re=()=>O?co.find(t=>t.id===O.id)??null:null,es=()=>{const t=re();return t?O.turned?{w:t.h,h:t.w}:{w:t.w,h:t.h}:null};let Kt=localStorage.getItem("dt-bars-min")==="1";const vt=t=>{O=t,_(Vn,t?JSON.stringify(t):"")},Pe=t=>{dn.textContent=t,A.style.setProperty("--dt-badge-w",`${dn.offsetWidth}px`)},Yn=t=>{if(!t){xt.innerHTML="";return}let e="";for(let n=0;n<=t;n+=50)e+=`<span class="dt-tick${n%200===0?" is-major":""}" style="left:${n}px"></span>`;for(const n of I)for(const o of[n.min,n.max])o>0&&Number.isFinite(o)&&o<=t&&(e+=`<span class="dt-edge" style="left:${o}px" title="${n.label} edge"></span>`);xt.innerHTML=e,xt.style.width=`${t}px`},je=()=>{const t=parseFloat(E.style.width)||0,e=parseFloat(E.style.height)||0;if(!t||!e){E.style.transform="",delete E.dataset.scaled;return}const n=$||O?Math.min(1,(innerWidth-80)/t,(innerHeight-120)/e):Math.min(1,(innerWidth-80)/t);E.style.transform=n<1?`scale(${n})`:"",E.dataset.scaled=n<1?String(Math.round(n*100)):""},ns=t=>co.find(e=>e.w===t.w&&e.h===t.h&&e.cutout?.shape==="pill")?.cutout,ie=()=>{try{return w.contentDocument}catch{return null}},Jn=()=>ie()?.title.split("\u2014").pop()?.trim()||"",Ke=()=>{const t=ie(),e=$?Wt($):null;if(!t?.body||!e)return;const n=ys(t),o=e.browser==="chrome-android"?n.theme||"rgb(255, 255, 255)":n.top,s=e.browser==="chrome-android"?"rgb(255, 255, 255)":n.bottom;E.style.setProperty("--dt-top",o),E.style.setProperty("--dt-top-ink",uo(o)),E.style.setProperty("--dt-bottom",s),E.style.setProperty("--dt-bottom-ink",uo(s));const r=Tt.querySelector(".dt-win-tab > span");r&&(r.textContent=Jn()||location.host)};let Fe=0;w.addEventListener("load",()=>{ie()&&(Ke(),w.contentWindow?.addEventListener("scroll",()=>{Fe||(Fe=requestAnimationFrame(()=>{Fe=0,Ke()}))},{passive:!0}))});for(const t of[Tt,Vt])t.addEventListener("click",e=>{const n=e.target.closest("[data-nav]")?.dataset.nav;if(n)try{const o=w.contentWindow?.navigation;if(!ie()||!o)throw new Error("foreign");n==="back"?o.canGoBack&&o.back():n==="fwd"?o.canGoForward&&o.forward():o.reload()}catch{(n==="reload"||n==="back")&&(w.src=location.href)}});Mt.addEventListener("click",()=>{Kt=!Kt,_("dt-bars-min",Kt?"1":"0"),Q()});const Q=()=>{if(v)return;const t=$?Wt($)??null:null;if($&&!t&&($="",localStorage.setItem(yt,"")),!t&&!at){A.hidden=!0,w.removeAttribute("src"),document.documentElement.classList.remove("dt-framing"),f.hidden=!M,xt.innerHTML="",At(),ve.hidden=!0,Mt.hidden=!0,X=null,bt="",xe=[],At(),ze(),M?mt():m();return}if(A.hidden=!1,document.documentElement.classList.add("dt-framing"),f.hidden=!0,w.src||(w.src=location.href),t){const e=bs(t,{host:location.host,title:Jn(),now:new Date,min:Kt,cutout:ns(t)}),{screen:n}=e;A.dataset.mode="device",E.dataset.shell=t.shell,E.dataset.browser=t.browser,E.style.width=`${e.footprint.w}px`,E.style.height=`${e.footprint.h}px`,E.style.setProperty("--dt-r",`${n.r}px`),E.style.setProperty("--dt-rb",`${n.rb}px`),rn.innerHTML=e.shell;const o=(c,u,a,l)=>{c.innerHTML=l,c.style.cssText=`left:${n.x}px;top:${u}px;width:${n.w}px;height:${a}px`};o(Tt,n.y,e.topH,e.top),o(Vt,n.y+n.h-e.bottomH,e.bottomH,e.bottom);const s=n.h-e.topH-e.bottomH;w.style.position="absolute",w.style.left=`${n.x}px`,w.style.top=`${n.y+e.topH}px`,w.style.width=`${n.w}px`,w.style.height=`${s}px`,xt.innerHTML="";const r=Kt&&e.canMinimize;jt=e.scrollbar,bt=`${t.label}${r?" \xB7 bars folded":""}`,X=St(t.w),D({notes:M,scrollbar:jt,device:bt}),Mt.hidden=!e.canMinimize,Mt.setAttribute("aria-pressed",String(r)),Pe(`${t.label} \xB7 page ${t.w}\xD7${s} of ${t.w}\xD7${t.h}${r?" \xB7 bars folded":""} \xB7 ${I.find(c=>c.id===X)?.label??""}`),Ke()}else{const e=es();e||vt(null);const n=e?.w||k||I.find(r=>r.id===et()).ideal;k=n,A.dataset.mode="canvas",delete E.dataset.shell,delete E.dataset.browser,rn.innerHTML=Tt.innerHTML=Vt.innerHTML="",Tt.style.cssText=Vt.style.cssText="",Mt.hidden=!0,jt="overlay",E.style.width=`${n}px`,E.style.height=`${e?.h??innerHeight-84}px`,w.style.position="",w.style.left=w.style.top="",w.style.width="100%",w.style.height="100%",Yn(n),D({notes:M});const o=I.find(r=>r.id===St(n)),s=re();bt=s?`${s.label}${O?.turned?" \xB7 landscape":""}`:"",D({scrollbar:jt,device:bt}),Pe(s&&e?`${s.label} \xB7 ${e.w}\xD7${e.h} \xB7 ${o.label}`:`${n}px \xB7 ${o.label}`),X=St(n)}ve.hidden=!(re()?.rotates&&!t),ze(),je(),At(),M?mt():m()},We=t=>{const e=I.find(n=>n.id===t);$="",localStorage.setItem(yt,""),vt(null),at=t!==ce,k=at?e.ideal:0,X=at?t:null,localStorage.setItem(Oe,at?"1":"0"),localStorage.setItem(ae,String(k)),y=null,W(),Q()};for(const t of be)t.addEventListener("click",()=>We(t.dataset.bp));for(const t of document.querySelectorAll("[data-device]"))t.addEventListener("click",()=>{$=t.dataset.device===$?"":t.dataset.device,localStorage.setItem(yt,$),z.open=!1,Q()});for(const t of document.querySelectorAll("[data-emu]"))t.addEventListener("click",()=>{const e=O?.id===t.dataset.emu&&!$;$="",localStorage.setItem(yt,""),vt(e?null:{id:t.dataset.emu,turned:!1}),at=!e,k=0,localStorage.setItem(Oe,at?"1":"0"),X=null,y=null,W(),z.open=!1,Q()});ve.addEventListener("click",()=>{O&&(vt({...O,turned:!O.turned}),y=null,W(),Q())});const Gn=[...z.querySelectorAll("[data-tab]")],os=[...z.querySelectorAll("[data-panel]")],Xn=t=>{for(const e of Gn)e.setAttribute("aria-selected",String(e.dataset.tab===t));for(const e of os)e.hidden=e.dataset.panel!==t;_("dt-devices-tab",t)};for(const t of Gn)t.addEventListener("click",()=>Xn(t.dataset.tab));Xn(localStorage.getItem("dt-devices-tab")==="devtools"?"devtools":"preview");const _e=z.querySelector(".dt-emu-search");_e.addEventListener("input",()=>{const t=_e.value.trim().toLowerCase();let e=null,n=!1;const o=()=>{e&&(e.hidden=!n)};for(const s of _e.parentElement.children){if(s.classList.contains("dt-devices-group")){o(),e=s,n=!1;continue}s.dataset.emu&&(s.hidden=!!t&&!s.textContent.toLowerCase().includes(t),n||=!s.hidden)}o()});const ss=z.querySelector(".dt-devices-name");function ze(){for(const e of z.querySelectorAll("[data-device]"))e.setAttribute("aria-pressed",String(e.dataset.device===$));const t=!$&&!A.hidden?O?.id:void 0;for(const e of z.querySelectorAll("[data-emu]"))e.setAttribute("aria-pressed",String(e.dataset.emu===t));ss.textContent=$&&Wt($)?.label||t&&re()?.label||"Device"}const Ue=t=>I.find(e=>e.id===t),as=t=>{const e=Ue(X??et());return Math.max(e.min||320,Math.min(Number.isFinite(e.max)?e.max:2560,Math.round(t)))};for(const t of yo){const e=t.dataset.edge==="l"?-1:1;t.addEventListener("pointerdown",n=>{if($)return;n.preventDefault(),O&&(vt(null),Q()),t.setPointerCapture(n.pointerId);const o=n.clientX,s=k,r=Number(E.dataset.scaled||100)/100;A.dataset.dragging="1";const c=a=>{k=as(s+e*(a.clientX-o)*2/r),E.style.width=`${k}px`,Yn(k),Pe(`${k}px \xB7 ${Ue(St(k)).label}`),je()},u=()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerup",u),delete A.dataset.dragging,localStorage.setItem(ae,String(k)),Q()};t.addEventListener("pointermove",c),t.addEventListener("pointerup",u)}),t.addEventListener("dblclick",()=>{if($)return;vt(null);const n=Ue(X??et()),o=[n.min||320,Number.isFinite(n.max)?n.max:n.ideal];k=Math.abs(k-o[0])<Math.abs(k-o[1])?o[0]:o[1],localStorage.setItem(ae,String(k)),Q()})}let Zn=et();addEventListener("resize",()=>{At(),et()!==Zn&&(Zn=et(),m()),A.hidden||(!$&&!O&&(E.style.height=`${innerHeight-84}px`),je())});const Qn="dt-studio",to=t=>{ye.setAttribute("aria-pressed",String(t)),document.documentElement.classList.toggle("dt-no-studio",!t),_(Qn,t?"1":"0")};ye.addEventListener("click",()=>to(ye.getAttribute("aria-pressed")!=="true")),to(localStorage.getItem(Qn)!=="0"),an.addEventListener("click",()=>st(!M));const $t=document.querySelector(".devtools"),Ft=document.querySelector(".dt-tab"),eo=t=>{$t.toggleAttribute("data-collapsed",t),Ft.toggleAttribute("data-collapsed",t),Ft.setAttribute("aria-expanded",String(!t)),Ft.setAttribute("aria-label",t?"Show the bar":"Hide the bar");for(const e of $t.querySelectorAll(".dt-group"))e.inert=t;t&&Lt(),_("dt-collapsed",t?"1":"0")};Ft.addEventListener("click",()=>eo(!$t.hasAttribute("data-collapsed")));const Ve=document.querySelector(".dt-keys"),rt=t=>()=>$t.querySelector(t)?.click(),no=t=>()=>{const e=[...document.querySelectorAll(".dt-pages a")];e[e.findIndex(n=>n.hasAttribute("aria-current"))+t]?.click()},le=[{group:"Comments",code:"KeyC",hint:"C",label:"Comment mode",el:".dt-notes-btn",run:rt(".dt-notes-btn")},{group:"Comments",code:"KeyC",shift:!0,hint:"\u21E7C",label:"Comments panel",el:".dt-history-btn",run:rt(".dt-history-btn")},{group:"Comments",code:"KeyR",hint:"R",label:"Show resolved",el:".dt-resolved-btn",run:rt(".dt-resolved-btn")},{group:"Inspect",code:"KeyG",hint:"G",label:"Grid",el:".dt-grid-btn",run:rt(".dt-grid-btn")},{group:"Inspect",code:"KeyP",hint:"P",label:"Spacing",el:".dt-pad-btn",run:rt(".dt-pad-btn")},{group:"Inspect",code:"KeyS",hint:"S",label:"Size",el:".dt-size-btn",run:rt(".dt-size-btn")},{group:"Inspect",code:"KeyT",hint:"T",label:"Typography",el:".dt-type-btn",run:rt(".dt-type-btn")},...b.sanity?[{group:"Inspect",code:"KeyE",hint:"E",label:"Sanity overlay",el:".dt-studio-btn",run:rt(".dt-studio-btn")}]:[],...be.slice(0,9).map((t,e)=>({group:"Breakpoints",code:`Digit${e+1}`,hint:String(e+1),label:t.dataset.tip??t.title,el:`.dt-bp[data-bp="${t.dataset.bp}"]`,run:()=>t.click()})),{group:"View",code:"KeyD",hint:"D",label:"Devices",run:()=>{z.open=!z.open}},{group:"View",code:"BracketLeft",hint:"[",label:"Previous page",run:no(-1)},{group:"View",code:"BracketRight",hint:"]",label:"Next page",run:no(1)},{group:"View",code:"Backslash",hint:"\\",label:"Hide the bar",run:()=>Ft.click()},{group:"View",code:"Slash",shift:!0,hint:"?",label:"This list",el:".dt-keys summary",run:()=>{Ve.open=!Ve.open}}].filter(t=>!b.client||t.group!=="Inspect"),oo=(t,e)=>le.find(n=>n.code===t&&!n.shift==!e),rs=t=>t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)||!!t.closest('[role="menu"], [role="listbox"], [role="dialog"][aria-modal="true"], [role="combobox"]'));if(b.shortcuts){for(const e of le){const n=e.el&&$t.querySelector(e.el);n&&(n.dataset.tip=`${n.dataset.tip??e.label} \xB7 ${e.hint}`,n.setAttribute("aria-keyshortcuts",e.hint.startsWith("\u21E7")?`Shift+${e.hint.slice(1)}`:e.hint))}const t=(e,n)=>`<div class="dt-key-row"><span>${g(e)}</span><kbd>${g(n)}</kbd></div>`;if(Ve.querySelector(".dt-keys-menu").innerHTML='<p class="dt-menu-note">One key, no modifier, in any keyboard layout. Not while you type.</p>'+[...new Set(le.map(e=>e.group))].map(e=>`<p class="dt-devices-group">${e}</p>`+le.filter(n=>n.group===e).map(n=>t(n.label,n.hint)).join("")).join("")+'<p class="dt-devices-group">In a comment</p>'+t("Send","Enter")+t("New line","\u21E7Enter")+t("Close, cancel, back out","Esc"),document.addEventListener("keydown",e=>{if(e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||rs(e.target))return;const n=oo(e.code,e.shiftKey);n&&(e.preventDefault(),v?parent.postMessage({dt:!0,key:[e.code,e.shiftKey]},location.origin):n.run())}),v){const e=()=>parent.postMessage({dt:!0,closeMenus:!0},location.origin);document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n=>{n.key==="Escape"&&e()})}}if(!v){eo(localStorage.getItem("dt-collapsed")==="1"),requestAnimationFrame(()=>requestAnimationFrame(()=>$t.setAttribute("data-ready",""))),at||$?Q():ze(),pe(localStorage.getItem(Qe)==="1");const t=localStorage.getItem(on);t&&t in fe&&zt(t),st(localStorage.getItem(cn)==="1")}const so=()=>{try{const t=JSON.parse(localStorage.getItem(ft)||"null");q=(t?.parked??[]).filter(e=>Yt(e)),t?.draft&&document.querySelector(t.draft.selector)?(d=t.draft,!M&&!v&&st(!0)):Yt(t?.draft)&&q.push(t.draft),t?.reply?.text&&(F=t.reply.text,kt=y=t.reply.for??null),(d||q.length||F)&&m()}catch{localStorage.removeItem(ft)}};so();const ao=()=>setTimeout(()=>{const t=ue(location.pathname);t!==K&&(clearTimeout(Jt),we(),K=t,ft=un(),d=null,q=[],F="",kt=null,y=null,S=null,h=[],en(),so(),mt())});for(const t of["pushState","replaceState"]){const e=window.history[t];window.history[t]=function(...n){e.apply(this,n),ao()}}addEventListener("popstate",ao),M||mt(),ne().then(()=>{te()&&ee()}),document.addEventListener("visibilitychange",()=>{document.hidden||Pt()}),addEventListener("focus",Pt),addEventListener("notemend:changed",()=>{v||Pt()});let is=0;v||setInterval(()=>{(!fs.live||++is%6===0)&&Pt()},2e4),v&&parent.postMessage({dt:!0,hello:!0},location.origin)}export{Is as run};
|