notemend 0.1.10 → 0.1.11
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/README.md +3 -3
- package/bin/notemend.mjs +15 -14
- package/package.json +1 -1
- package/src/client/field-menu.js +1 -1
- package/src/client/inspect.js +1 -1
- package/src/client/markup.js +6 -0
- package/src/client/notemend.css +1 -1
- package/src/client/run.js +80 -74
- 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 +18 -1
package/src/client/run.js
CHANGED
|
@@ -1,117 +1,123 @@
|
|
|
1
|
-
import{categoryOf as he}from"../store/categories.mjs";import{stateOf as R,STATE_LABEL as qo}from"../store/status.mjs";import{agentName as et,handleOf as Ro,held as Io,threadOf as Do,workingOn as Oo}from"../store/thread.mjs";import{api as C,canvasCopy as Po,host as jo,imageUrl as Fo}from"./api";import{DEVTOOLS_DEVICES as $s}from"../devtools-devices.mjs";import{drawDevice as Ko,pageTints as Wo,inkFor as ws}from"./devices";import{recentLogs as zo}from"./logs";import{inspectors as _o}from"./inspect";import{anchors as Uo,clean as kt}from"./anchor";import{fieldMenus as Vo}from"./field-menu";function oa(b){const I=b.breakpoints,an=b.categories,ge=(I.find(t=>!Number.isFinite(t.max))??I[0]).id,Ht=t=>I.find(e=>t>=e.min&&t<=e.max)?.id??ge,nt=t=>t.breakpoint||ge,Yt=t=>b.devices.find(e=>e.id===t),$=Po,V=(t,e)=>{$||localStorage.setItem(t,e)},fe=t=>t.replace(/\/+$/,"")||"/";let W=fe(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 rn=document.querySelector(".dt-grid-btn"),Jt=document.querySelector(".dt-grid-overlay"),ln="dt-grid",be=t=>{Jt.hidden=!t,rn.setAttribute("aria-pressed",String(t)),V(ln,t?"1":"0"),P({grid:t})};rn.addEventListener("click",()=>be(Jt.hidden===!0));const dn=document.querySelector(".dt-pages-name"),cn=()=>{let t=null;for(const s of document.querySelectorAll(".dt-pages a"))fe(new URL(s.href).pathname)===W?(s.setAttribute("aria-current","page"),t=s):s.removeAttribute("aria-current");const e=document.title.split("\u2014").pop()?.trim(),n=t?.querySelector(".dt-menu-label")?.textContent?.trim();dn.textContent=n||e||dn.textContent};cn();const un=[...document.querySelectorAll(".devtools details")];let ve=!1;const At=()=>{const t=un.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]=At();e&&(e.querySelector("summary")?.focus(),t.preventDefault(),t.stopImmediatePropagation())},!0),document.addEventListener("pointerdown",t=>{ve=un.some(e=>e.open&&!e.contains(t.target))&&At().length>0},!0),addEventListener("blur",At);const $t=document.querySelector(".dt-pad-overlay"),pn="dt-inspect",Es=[".devtools",".dt-pad-overlay",".dt-grid-overlay",".dt-frame",".dt-history",".dt-review",".dt-field-menu",...b.ignore].join(", "),ye=[".devtools",".dt-notes-overlay",".dt-history",".dt-frame",".dt-review",".dt-field-menu",'[aria-modal="true"]',...b.ignore].join(", "),$e={pads:document.querySelector(".dt-pad-btn"),sizes:document.querySelector(".dt-size-btn"),type:document.querySelector(".dt-type-btn")};let mt="",we=0;const{spacer:Ss,drawPads:Ls,drawSize:Ts,drawType:Ms}=_o($t),mn=t=>{we||(we=requestAnimationFrame(()=>{we=0,$t.hidden=!0;let e=document.elementFromPoint(t.clientX,t.clientY);if($t.hidden=!1,!e||e.closest(Es)){$t.innerHTML="";return}t.altKey&&e.parentElement&&e.parentElement!==document.body&&(e=e.parentElement),mt==="sizes"?Ts(e):mt==="type"?Ms(e):Ls(t.altKey?e:Ss(e))}))},Gt=t=>{mt=t;for(const[e,n]of Object.entries($e))n.setAttribute("aria-pressed",String(e===t));V(pn,t),P({inspect:t}),$t.hidden=!t,$t.innerHTML="",t?document.addEventListener("mousemove",mn):document.removeEventListener("mousemove",mn)};for(const[t,e]of Object.entries($e))e.addEventListener("click",()=>{t!==mt&&dt(!1),Gt(mt===t?"":t)});const hn=document.querySelector(".dt-notes-btn"),Ee=[...document.querySelectorAll(".dt-bp")],Xt=document.querySelector(".dt-history-btn"),K=document.querySelector(".dt-history"),Se=document.querySelector(".dt-studio-btn"),L=document.querySelector(".dt-device"),gn=document.querySelector(".dt-shell"),Nt=document.querySelector('.dt-chrome[data-at="top"]'),Zt=document.querySelector('.dt-chrome[data-at="bottom"]'),Ct=document.querySelector(".dt-ruler"),Y=document.querySelector(".dt-devices"),ht=document.querySelector(".dt-notes-hi"),xs=ht.querySelector(".dt-hi-box"),fn=ht.querySelector(".dt-hi-tag"),ks=[...document.querySelectorAll(".dt-frame-handle")],bn=document.querySelector(".dt-frame-size"),Le=document.querySelector(".dt-frame-rotate"),Bt=document.querySelector(".dt-frame-bars"),B=document.querySelector(".dt-frame"),M=B.querySelector("iframe"),Te=document.querySelector(".dt-notes-count"),g=document.querySelector(".dt-notes-overlay"),Hs=".devtools, .dt-tab, .dt-notes-overlay, .dt-history, .dt-frame, .dt-review";for(const t of document.querySelectorAll(Hs))for(const e of["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend","click","focusin","focusout"])t.addEventListener(e,n=>n.stopPropagation());const vn="dt-notes";let f=[],A=!1,v=null,d=null,Me=0,z="",_=[],x=null,D=[];const Qt=(t=d)=>!!(t&&(t.text?.trim()||t.images?.length)),U=()=>{d&&Qt()&&D.push(d),d=null};let qt=null,st=null;const yn=()=>`dt-draft:${W}${$?":canvas":""}`;let wt=yn(),te=0;const xe=()=>{if(!d&&!D.length&&!z){localStorage.removeItem(wt);return}const t={draft:d,parked:D,reply:z?{for:qt,text:z}:null};try{localStorage.setItem(wt,JSON.stringify(t))}catch{const e=n=>({...n,images:void 0});try{localStorage.setItem(wt,JSON.stringify({...t,draft:d&&e(d),parked:D.map(e)}))}catch{}}},Et=()=>{clearTimeout(te),te=setTimeout(xe,200)};addEventListener("pagehide",()=>{clearTimeout(te),xe()});let J=localStorage.getItem("dt-resolved")!=="0";const As=[[/Edg\/(\d+)/,"Edge"],[/OPR\/(\d+)/,"Opera"],[/Firefox\/(\d+)/,"Firefox"],[/Chrome\/(\d+)/,"Chrome"],[/Version\/(\d+).*Safari/,"Safari"]],Ns=[[/iPhone|iPad/,"iOS"],[/Android/,"Android"],[/Mac OS X/,"macOS"],[/Windows/,"Windows"],[/Linux/,"Linux"]],Cs=()=>{const t=navigator.userAgent,e=i=>i.find(([c])=>c.test(t)),n=e(As),s=e(Ns),o=n?n[0].exec(t)?.[1]:null;return[n?`${n[1]}${o?" "+o:""}`:"unknown browser",s?.[1]].filter(Boolean).join(" \xB7 ")},rt=()=>Ht(innerWidth),ee=()=>st??rt(),Rt=()=>{const t=ee();for(const e of Ee)e.setAttribute("aria-pressed",String(e.dataset.bp===t))},{cssPath:Bs,poolOf:qs,contextOf:Rs,resolveEl:ot,anchorOf:G}=Uo(),$n=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 ke=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))},wn=()=>{if(d)return ot(d);const t=v!=null?f.find(n=>n.id===v):null;if(!t)return null;const e=G(t);return e&&!e.off?ot(t):null},En=t=>t?new Date(t).toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):"",It='<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>',Is='<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>',Dt='<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>',He='<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>',Ds='<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>',Os='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M8 5l5 5-5 5" stroke-linejoin="round"/></svg>',Ps='<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>',js='<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>',Ot=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>`,Sn=()=>{try{return localStorage.getItem("nm-for")??"claude"}catch{return"claude"}},gt=t=>t==="claude"?"#d97757":t?"#0d99ff":"#717171",Ln=(t,e)=>`<label class="dt-field" title="Who it is for"><span class="dt-field-box" style="--cat:${gt(t)}"><select class="dt-for-select"${e?` data-id="${e}"`:""} aria-label="Who this is for">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
${
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
${
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import{categoryOf as be}from"../store/categories.mjs";import{stateOf as q,STATE_LABEL as Ys}from"../store/status.mjs";import{agentLabel as Js,agentName as To,agentOwner as Mo,handleOf as Gs,held as xo,stageOf as ko,threadOf as Xs,toAgent as ve,workingOn as Zs}from"../store/thread.mjs";import{api as H,canvasCopy as Qs,host as ta,imageUrl as ea}from"./api";import{DEVTOOLS_DEVICES as Ao}from"../devtools-devices.mjs";import{drawDevice as na,pageTints as oa,inkFor as Ho}from"./devices";import{recentLogs as sa}from"./logs";import{inspectors as aa}from"./inspect";import{anchors as ia,clean as At}from"./anchor";import{bars as ra,fieldMenus as la}from"./field-menu";function wa(m){const R=m.breakpoints,dn=m.categories,ye=(R.find(t=>!Number.isFinite(t.max))??R[0]).id,Ht=t=>R.find(e=>t>=e.min&&t<=e.max)?.id??ye,ot=t=>t.breakpoint||ye,Jt=t=>m.devices.find(e=>e.id===t),w=Qs,V=(t,e)=>{w||localStorage.setItem(t,e)},we=t=>t.replace(/\/+$/,"")||"/";let W=we(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 cn=document.querySelector(".dt-grid-btn"),Gt=document.querySelector(".dt-grid-overlay"),un="dt-grid",$e=t=>{Gt.hidden=!t,cn.setAttribute("aria-pressed",String(t)),V(un,t?"1":"0"),P({grid:t})};cn.addEventListener("click",()=>$e(Gt.hidden===!0));const pn=document.querySelector(".dt-pages-name"),mn=()=>{let t=null;for(const o of document.querySelectorAll(".dt-pages a"))we(new URL(o.href).pathname)===W?(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();pn.textContent=n||e||pn.textContent};mn();const hn=[...document.querySelectorAll(".devtools details")];let Ee=!1;const Nt=()=>{const t=hn.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]=Nt();e&&(e.querySelector("summary")?.focus(),t.preventDefault(),t.stopImmediatePropagation())},!0),document.addEventListener("pointerdown",t=>{Ee=hn.some(e=>e.open&&!e.contains(t.target))&&Nt().length>0},!0),addEventListener("blur",Nt);const $t=document.querySelector(".dt-pad-overlay"),gn="dt-inspect",No=[".devtools",".dt-pad-overlay",".dt-grid-overlay",".dt-frame",".dt-history",".dt-review",".dt-field-menu",...m.ignore].join(", "),Se=[".devtools",".dt-notes-overlay",".dt-history",".dt-frame",".dt-review",".dt-field-menu",'[aria-modal="true"]',...m.ignore].join(", "),Le={pads:document.querySelector(".dt-pad-btn"),sizes:document.querySelector(".dt-size-btn"),type:document.querySelector(".dt-type-btn"),color:document.querySelector(".dt-color-btn"),border:document.querySelector(".dt-border-btn")};let st="",Te=0;const{spacer:Co,drawPads:Bo,drawSize:Io,drawType:qo,drawColor:Ro,drawBorder:Do}=aa($t),fn=t=>{Te||(Te=requestAnimationFrame(()=>{Te=0,$t.hidden=!0;let e=document.elementFromPoint(t.clientX,t.clientY);if($t.hidden=!1,!e||e.closest(No)){$t.innerHTML="";return}t.altKey&&e.parentElement&&e.parentElement!==document.body&&(e=e.parentElement),st==="sizes"?Io(e):st==="type"?qo(e):st==="color"?Ro(e):st==="border"?Do(e):Bo(t.altKey?e:Co(e))}))},Xt=t=>{st=t;for(const[e,n]of Object.entries(Le))n.setAttribute("aria-pressed",String(e===t));V(gn,t),P({inspect:t}),$t.hidden=!t,$t.innerHTML="",t?document.addEventListener("mousemove",fn):document.removeEventListener("mousemove",fn)};for(const[t,e]of Object.entries(Le))e.addEventListener("click",()=>{t!==st&&ut(!1),Xt(st===t?"":t)});const bn=document.querySelector(".dt-notes-btn"),Me=[...document.querySelectorAll(".dt-bp")],Zt=document.querySelector(".dt-history-btn"),K=document.querySelector(".dt-history"),xe=document.querySelector(".dt-studio-btn"),L=document.querySelector(".dt-device"),vn=document.querySelector(".dt-shell"),Ct=document.querySelector('.dt-chrome[data-at="top"]'),Qt=document.querySelector('.dt-chrome[data-at="bottom"]'),Bt=document.querySelector(".dt-ruler"),Y=document.querySelector(".dt-devices"),ht=document.querySelector(".dt-notes-hi"),Oo=ht.querySelector(".dt-hi-box"),yn=ht.querySelector(".dt-hi-tag"),Po=[...document.querySelectorAll(".dt-frame-handle")],wn=document.querySelector(".dt-frame-size"),ke=document.querySelector(".dt-frame-rotate"),It=document.querySelector(".dt-frame-bars"),B=document.querySelector(".dt-frame"),M=B.querySelector("iframe"),Ae=document.querySelector(".dt-notes-count"),f=document.querySelector(".dt-notes-overlay"),jo=".devtools, .dt-tab, .dt-notes-overlay, .dt-history, .dt-frame, .dt-review";for(const t of document.querySelectorAll(jo))for(const e of["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend","click","focusin","focusout"])t.addEventListener(e,n=>n.stopPropagation());const $n="dt-notes";let b=[],N=!1,y=null,d=null,He=0,z="",_=[],x=null,D=[];const te=(t=d)=>!!(t&&(t.text?.trim()||t.images?.length)),U=()=>{d&&te()&&D.push(d),d=null};let qt=null,at=null;const En=()=>`dt-draft:${W}${w?":canvas":""}`;let Et=En(),ee=0;const Ne=()=>{if(!d&&!D.length&&!z){localStorage.removeItem(Et);return}const t={draft:d,parked:D,reply:z?{for:qt,text:z}:null};try{localStorage.setItem(Et,JSON.stringify(t))}catch{const e=n=>({...n,images:void 0});try{localStorage.setItem(Et,JSON.stringify({...t,draft:d&&e(d),parked:D.map(e)}))}catch{}}},gt=()=>{clearTimeout(ee),ee=setTimeout(Ne,200)};addEventListener("pagehide",()=>{clearTimeout(ee),Ne()});let J=localStorage.getItem("dt-resolved")!=="0";const Fo=[[/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=i=>i.find(([r])=>r.test(t)),n=e(Fo),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 ")},lt=()=>Ht(innerWidth),ne=()=>at??lt(),Rt=()=>{const t=ne();for(const e of Me)e.setAttribute("aria-pressed",String(e.dataset.bp===t))},{cssPath:zo,poolOf:_o,contextOf:Uo,resolveEl:it,anchorOf:G}=ia(),Sn=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 oe=[];const Ce=t=>{for(const e of oe)e.play();oe=[];for(let e=t;e&&e!==document.body;e=e.parentElement)for(const n of e.getAnimations())n.playState==="running"&&(n.pause(),oe.push(n))},Ln=()=>{if(d)return it(d);const t=y!=null?b.find(n=>n.id===y):null;if(!t)return null;const e=G(t);return e&&!e.off?it(t):null},Tn=t=>t?new Date(t).toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):"",Dt='<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>',Vo='<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>',Ot='<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>',Be='<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>',Go='<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>',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>',St=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>`,ft=()=>m.me?`agent:${m.me.email}`:"claude",da={new:["New","#717171"],approved:["Approved for AI","#d97757"],review:["Needs review","#8e4ec6"]},Mn=()=>{try{return localStorage.getItem("nm-stage")??"new"}catch{return"new"}},Zo='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><path d="M2.5 10s2.8-5 7.5-5 7.5 5 7.5 5-2.8 5-7.5 5-7.5-5-7.5-5z" stroke-linejoin="round"/><circle cx="10" cy="10" r="2.2"/></svg>',xn=(t,e)=>{const n=(o,s,i,r,u)=>`<button type="button" class="dt-approve dt-approve--${o}${t===o?" is-on":""}" data-act="stage" data-v="${t===o?"new":o}"${e?` data-id="${e}"`:""} aria-pressed="${t===o}"
|
|
2
|
+
title="${t===o?r:u}">${s}<span>${i}</span></button>`;return`<span class="dt-approves">${n("approved",St(12),"AI","Approved for AI \u2014 click to take it back","Approve for AI \u2014 your Claude takes it")}${n("review",Zo,"Review","Needs review \u2014 click to clear","Needs review \u2014 a person checks it, then closes it")}</span>`},Qo=(t,e)=>{if(!t){if(!d)return;d.stage=e,e==="approved"&&!ve(d.assignee??ae())&&(d.assignee??ae())&&(d.assignee=ft());try{localStorage.setItem("nm-stage",e)}catch{}gt(),h();return}const n=b.find(s=>s.id===t),o=e==="approved"&&n?.assignee&&!ve(n.assignee)?ft():void 0;X(s=>s.map(i=>i.id===t?{...i,stage:e,...o?{assignee:o}:{}}:i),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,stage:e,...o?{assignee:o}:{}})}),e==="approved"?"Approving it for the agent":e==="review"?"Asking for a review":"Setting the status")},ae=()=>{try{return localStorage.getItem("nm-for")??ft()}catch{return ft()}},Pt=t=>ve(t)?"#d97757":t?"#0d99ff":"#717171",kn=t=>t===m.me?.email?"you":m.team?.find(e=>e.email===t)?.name||t.split("@")[0],dt=(t,e)=>Js(t,e,kn),An=(t,e)=>{const n=(r,u)=>`<option value="${g(r)}" data-c="${Pt(r)}"${t===r?" selected":""}>${g(u)}</option>`,o=(m.team??[]).filter(r=>r.email!==m.me?.email),s=o.filter(r=>!m.studio||m.studio.includes(r.email)),i=Mo(t)&&t!==ft()&&!s.some(r=>`agent:${r.email}`===t)?n(t,`${kn(Mo(t))}'s agent`):"";return`<label class="dt-field" title="Who it is for"><span class="dt-field-box" style="--cat:${Pt(t)}"><select class="dt-for-select"${e?` data-id="${e}"`:""} aria-label="Who this is for">
|
|
3
|
+
${m.me?n(ft(),"My agent"):""}
|
|
4
|
+
${n("claude",m.me?"Any agent":"AI agent")}
|
|
5
|
+
${s.map(r=>n(`agent:${r.email}`,`${(r.name||r.email).split(" ")[0]}'s agent`)).join("")}${i}
|
|
6
|
+
${n("","Nobody")}
|
|
7
|
+
${o.map(r=>n(r.email,r.name||r.email)).join("")}
|
|
8
|
+
</select></span></label>`},Hn=t=>{const e=At(t?.textContent).replace(/\s+/g," ");return e&&e.length<=2e3?e:""},ts=t=>`<div class="dt-suggest dt-suggest--read"><del>${g(t.from)}</del><ins>${g(t.to)}</ins></div>`,Nn=t=>At(t)?`<span class="dt-note-info" data-tip="${g(At(t))}"
|
|
9
|
+
><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>`:"",Cn=(t,e)=>`<label class="dt-field" title="Type"><span class="dt-field-box" style="--cat:${be(t).color}"><select class="dt-cat-select"${e?` data-id="${e}"`:""} aria-label="Type">${dn.map(n=>`<option value="${n.id}" data-c="${n.color}"${n.id===t?" selected":""}>${n.label}</option>`).join("")}</select></span></label>`,ie=[["low","Low","#30a46c",1],["normal","Mid","#f5c451",2],["high","High","#ff5a00",3],["urgent","Urgent","#e5484d",4]],Bn=(t,e)=>{const n=Math.max(0,ie.findIndex(u=>u[0]===t)),[,o,s,i]=ie[n],r=ie[(n+1)%ie.length];return`<button type="button" class="dt-prio" style="--cat:${s}" data-act="prio" data-v="${r[0]}"${e?` data-id="${e}"`:""} title="Priority: ${o} \u2014 click for ${r[1]}" aria-label="Priority ${o}">${ra(i,s)}<span>${o}</span></button>`},es='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="6.8" r="3"/><path d="M4.2 16.5c.6-3 3-4.8 5.8-4.8s5.2 1.8 5.8 4.8" stroke-linejoin="round"/></svg>',ns='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="6.8" r="3"/><path d="M4.2 16.5c.6-3 3-4.8 5.8-4.8s5.2 1.8 5.8 4.8" stroke-linejoin="round"/><path d="M3.5 3.5l13 13"/></svg>',In=(t,e)=>`<button type="button" class="dt-share${t?" is-on":""}" data-act="share" data-v="${t?"":"1"}"${e?` data-id="${e}"`:""}
|
|
10
|
+
aria-pressed="${!!t}" title="${t?"Shared with the client \u2014 click to keep it to the team":"Team only \u2014 click to share it with the client"}">${t?es:ns}</button>`,os=()=>(m.team??[]).filter(t=>!m.studio||m.studio.includes(t.email)),ss=t=>{const e=t||m.lead||"",n=os();return n.length?`<label class="dt-field" title="Who it is for"><span class="dt-field-box" style="--cat:${Pt(e||"x@x")}"><select class="dt-for-select" aria-label="Who this is for">
|
|
11
|
+
${n.map(o=>`<option value="${g(o.email)}" data-c="${Pt(o.email)}"${e===o.email?" selected":""}>${g(o.name||o.email)}</option>`).join("")}
|
|
12
|
+
</select></span></label>`:""},qn='<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>',as=!1,is=!1,Rn='<svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M3 1.8v8.4L10 6z"/></svg>',rs='<svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M2.5 1.5h2.5v9H2.5zM7 1.5h2.5v9H7z"/></svg>',ls=t=>`${Math.floor(t/60)}:${String(Math.floor(t%60)).padStart(2,"0")}`,ds=(t,e)=>{const n=t.closest(".dt-voice"),o=n.querySelector("audio"),s=n.querySelector(".dt-voice-play");if(!o.dataset.wired){o.dataset.wired="1";const u=n.querySelector(".dt-voice-track i"),a=n.querySelector(".dt-voice-time"),c=()=>Number.isFinite(o.duration)?o.duration:0;o.addEventListener("timeupdate",()=>{u.style.width=`${c()?Math.min(100,o.currentTime/c()*100):0}%`,a.textContent=ls(o.currentTime)}),o.addEventListener("play",()=>{s.innerHTML=rs,s.setAttribute("aria-label","Pause"),n.classList.add("is-playing")}),o.addEventListener("pause",()=>{s.innerHTML=Rn,s.setAttribute("aria-label","Play the voice note"),n.classList.remove("is-playing")}),o.addEventListener("ended",()=>{o.currentTime=0})}const i=()=>{if(e){const u=n.querySelector(".dt-voice-track").getBoundingClientRect();Number.isFinite(o.duration)&&(o.currentTime=Math.max(0,Math.min(1,(e.clientX-u.left)/u.width))*o.duration);return}if(!o.paused){o.pause();return}f.querySelectorAll(".dt-voice audio").forEach(u=>{u!==o&&u.pause()}),o.play().catch(()=>{})};if(Number.isFinite(o.duration)||o.readyState<1){o.readyState<1?o.addEventListener("loadedmetadata",()=>Number.isFinite(o.duration)?i():r(),{once:!0}):i();return}r();function r(){o.addEventListener("timeupdate",()=>{o.currentTime=0,i()},{once:!0}),o.currentTime=1e9}},Ie=t=>t.startsWith("data:audio/")||/(^|\/)voice-[^/?]*\.(webm|m4a)(\?|$)/i.test(t),Dn=t=>t.startsWith("data:video/")||/\.webm(\?|$)/i.test(t),On=new Map,cs=t=>{if(!t.startsWith("data:"))return t;let e=On.get(t);if(!e){const[n,o]=t.split(",",2);e=URL.createObjectURL(new Blob([Uint8Array.from(atob(o),s=>s.charCodeAt(0))],{type:n.slice(5).split(";")[0]})),On.set(t,e)}return e},us=(t,e)=>`<span class="dt-voice"><button type="button" class="dt-voice-play" data-act="voice" aria-label="Play the voice note">${Rn}</button><button type="button" class="dt-voice-track" data-act="voice-seek" aria-label="Jump"><i></i></button><span class="dt-voice-time">0:00</span><audio src="${cs(t)}" preload="metadata"></audio>${e===void 0?"":`<button class="dt-voice-rm" data-act="voice-write" ${e} aria-label="Write it out" title="Write it out \u2014 its words go in the box">${$s}</button>`}${e===void 0?"":`<button class="dt-voice-rm" data-act="unshot" ${e} aria-label="Remove the recording" title="Remove the recording">${qn}</button>`}</span>`,Pn=(t,e,n=t)=>Ie(n)?us(t,e):`<span class="dt-shot${Dn(n)?" dt-shot--video":""}">${Dn(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">${qn}</button>`}</span>`,jn=(t=[],e)=>t.length?`<div class="dt-note-shots">${t.map(n=>{const o=n.split("/").pop(),s=ea(o);return Pn(s,e===void 0?void 0:`data-id="${e}" data-img="${g(o)}"`,o)}).join("")}</div>`:"",Fn=(t=[])=>t.length?`<div class="dt-note-shots">${t.map((e,n)=>Pn(e,`data-i="${n}"`)).join("")}</div>`:"",ps='<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>',ms='<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>',hs=!!navigator.mediaDevices?.getDisplayMedia&&typeof MediaRecorder<"u";let bt=null;const gs=async t=>{if(bt){bt.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(c=>MediaRecorder.isTypeSupported(c));if(!s){for(const c of e.getTracks())c.stop();I("This browser cannot record WebM video.");return}const i=new MediaRecorder(o,{mimeType:s,videoBitsPerSecond:6e5,audioBitsPerSecond:32e3}),r=[],u=!!Number(t?.dataset.id);i.ondataavailable=c=>{c.data.size&&r.push(c.data)};const a=setTimeout(()=>{i.state!=="inactive"&&i.stop()},3e4);i.onstop=async()=>{clearTimeout(a);for(const S of[...e.getTracks(),...n?.getTracks()??[]])S.stop();bt=null;const c=new Blob(r,{type:"video/webm"});if(c.size>32e5){I("That recording is too big to send \u2014 keep it shorter."),h();return}const p=await new Promise(S=>{const l=new FileReader;l.onload=()=>S(String(l.result)),l.readAsDataURL(c)});u?_.push(p):d&&(d.images??=[]).push(p),h()},e.getVideoTracks()[0]?.addEventListener("ended",()=>{i.state!=="inactive"&&i.stop()}),bt=i,i.start(1e3),h()},fs='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="7.5" y="3" width="5" height="9" rx="2.5"/><path d="M5 9.5a5 5 0 0 0 10 0M10 14.5V17"/></svg>',bs='<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><path d="m5 10.5 3.2 3L15 6.5"/></svg>',vs=90,qe=32,ys=()=>!!m.voice&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u";let re=!1;const ws=async(t,e)=>{if(re||!t)return;const n=Number(t.dataset.id)||0;re=!0,e.classList.add("is-asking"),e.title="Waiting for the microphone \u2014 allow it in the browser";let o;try{o=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(v){re=!1,e.classList.remove("is-asking");const F=v?.name;I(F==="NotAllowedError"?"The microphone is blocked for this site \u2014 allow it from the icon left of the address, then try again.":F==="NotFoundError"?"No microphone found \u2014 plug one in or pick it in the system settings.":F==="NotReadableError"?"The microphone is busy in another app \u2014 close it there and try again.":`The microphone did not start: ${v?.message||F||"unknown error"}`);return}e.classList.remove("is-asking");const s=()=>f.querySelector(n?`.dt-note[data-id="${n}"] .dt-compose`:".dt-note[data-draft] .dt-compose"),i=document.createElement("div");i.className="dt-rec",i.innerHTML=`<button type="button" class="dt-rec-x" title="Discard (Esc)" aria-label="Discard">${Dt}</button><span class="dt-rec-time"><i></i><b>0:00</b></span><span class="dt-rec-wave">${"<i></i>".repeat(qe)}</span><button type="button" class="dt-rec-done" title="Done \u2014 write it out" aria-label="Done">${bs}</button>`;const r=i.querySelector("b"),u=[...i.querySelectorAll(".dt-rec-wave i")],a=new AudioContext,c=a.createAnalyser();c.fftSize=512,a.createMediaStreamSource(o).connect(c);const p=new Uint8Array(c.fftSize),S=[],l=new MediaRecorder(o,{audioBitsPerSecond:32e3}),T=[],A=Date.now();let k=!0;const tt=setInterval(()=>{const v=s();v&&i.parentElement!==v&&v.appendChild(i),c.getByteTimeDomainData(p);let F=0;for(const mt of p)F+=((mt-128)/128)**2;S.push(Math.min(1,Math.sqrt(F/p.length)*4));const et=S.slice(-qe);u.forEach((mt,an)=>{const rn=et[an-(qe-et.length)];mt.style.transform=`scaleY(${Math.max(.1,rn??0).toFixed(2)})`,mt.classList.toggle("is-empty",rn===void 0)});const nt=Math.floor((Date.now()-A)/1e3);r.textContent=`${Math.floor(nt/60)}:${String(nt%60).padStart(2,"0")}`,nt>=vs&&l.state!=="inactive"&&l.stop()},90),$=v=>{k=v,l.state!=="inactive"&&l.stop()};i.querySelector(".dt-rec-x").addEventListener("click",v=>{v.stopPropagation(),$(!1)}),i.querySelector(".dt-rec-done").addEventListener("click",v=>{v.stopPropagation(),$(!0)}),i.addEventListener("keydown",v=>{v.key==="Escape"&&(v.stopPropagation(),$(!1))}),l.ondataavailable=v=>{v.data.size&&T.push(v.data)},l.onstop=async()=>{if(clearInterval(tt),o.getTracks().forEach(et=>et.stop()),a.close().catch(()=>{}),i.remove(),re=!1,!k)return;const v=new Blob(T,{type:l.mimeType||"audio/webm"}),F=await new Promise(et=>{const nt=new FileReader;nt.onload=()=>et(String(nt.result)),nt.readAsDataURL(v)});n?_.push(F):d&&(d.images??=[]).push(F),h(),s()?.querySelector("textarea")?.focus()},l.start(1e3),s()?.appendChild(i),i.querySelector(".dt-rec-done").focus()},Kn="\u{1F3A4} Voice note",$s='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><rect x="2.5" y="4.5" width="15" height="11" rx="2"/><path d="M6 11.5h3M11 11.5h3M6 8.5h8"/></svg>',Es=async t=>{const e=t.closest(".dt-note"),o=(e?.hasAttribute("data-draft")?d?.images??[]:_)[Number(t.dataset.i)];if(!o||t.classList.contains("is-asking"))return;t.classList.add("is-asking");const s=await H("transcribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({audio:o})}).catch(()=>null),i=s?await s.json().catch(()=>({})):{};if(t.classList.remove("is-asking"),!s?.ok||!i.text){I(i.error||(s?.ok?"Didn't hear any words in it.":"Could not make out the words \u2014 try again, or type it."));return}const r=e?.querySelector("textarea.dt-note-input, textarea.dt-note-reply-input");r&&(r.value=r.value.trim()?`${r.value.trimEnd()} ${i.text}`:i.text,r.dispatchEvent(new Event("input",{bubbles:!0})),r.focus())},Ss='<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>',Wn=(t,e,n,o,s="",i="")=>`<div class="dt-note-foot"><div class="dt-compose">
|
|
13
|
+
<textarea class="${t}" rows="1" placeholder="${e}">${g(n)}</textarea>
|
|
14
|
+
${s}
|
|
13
15
|
<div class="dt-compose-bar">
|
|
14
|
-
<span class="dt-compose-tools"><button class="dt-attach" data-act="attach" title="Attach a screenshot \u2014 or paste or drop one">${
|
|
15
|
-
${i}${
|
|
16
|
-
<button class="dt-send${n.trim()?" is-ready":""}" ${
|
|
16
|
+
<span class="dt-compose-tools"><button class="dt-attach" data-act="attach" title="Attach a screenshot \u2014 or paste or drop one">${Ss}</button>
|
|
17
|
+
${i}${is&&hs?`<button class="dt-record${bt?" is-on":""}" data-act="record" title="${bt?"Stop recording":"Record the screen, up to 30 seconds"}">${bt?"Stop":ps}</button>`:""}${ys()?`<button class="dt-attach" data-act="speak" title="Speak \u2014 sent with its words as a voice note">${fs}</button>`:""}</span>
|
|
18
|
+
<button class="dt-send${n.trim()?" is-ready":""}" ${o} title="Send (Enter)"
|
|
17
19
|
><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>
|
|
18
20
|
</div>
|
|
19
|
-
</div></div>`,
|
|
20
|
-
title="Resolved by ${
|
|
21
|
-
class="dt-note-resolve${n?" is-on":""}" title="${n?"Reopen":t==="claude"?"Looks right \u2014 mark it resolved":"Resolve"}">${
|
|
22
|
-
style="left:${T.x}px;top:${T.y}px;--cat:${
|
|
23
|
-
title="${
|
|
21
|
+
</div></div>`,Re=(t,e)=>(t||"element")+(e?.[0]?"."+e[0]:""),zn=()=>D.map((t,e)=>({i:e,el:Re(t.tag,t.classes),text:At(t.text??""),shots:t.images?.length??0,orphan:!G(t)}));let De=[],_n="";const Ls=(t,e)=>t!=="claude"?"":`<button class="dt-note-state" data-act="reopen" data-id="${e}"
|
|
22
|
+
title="Resolved by ${g((n=>dt(n?.doneAgent,n?.doneFor))(b.find(n=>n.id===e)))} \u2014 click to clear">${St(13)}</button>`,Un=(t,e)=>{const n=t==="done";return`${Ls(t,e)}<button data-act="${n?"reopen":"done"}" data-id="${e}"
|
|
23
|
+
class="dt-note-resolve${n?" is-on":""}" title="${n?"Reopen":t==="claude"?"Looks right \u2014 mark it resolved":"Resolve"}">${Ot}</button>`},Ts=(t,e)=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e?{id:t,status:"done",doneBy:"you"}:{id:t,status:"open",doneBy:null})}),X=async(t,e,n)=>{const o=b,s=Z;b=t(b),Z=t(Z),h();const i=await e().catch(()=>null);if(!i?.ok){b=o,Z=s,h(),I(`${n} did not go through${i?` (${i.status})`:""}.`);return}pe()},jt=(t,e)=>X(n=>n.map(o=>o.id===t?{...o,status:e?"done":"open",doneBy:e?"you":null}:o),()=>Ts(t,e),e?"Resolving":"Reopening"),Ms=t=>X(e=>e.map(n=>n.id===t?{...n,status:"done",doneBy:n.status==="done"?n.doneBy:"you",archivedAt:new Date().toISOString()}:n),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,archive:!0})}),"Archiving"),Vn=t=>X(e=>e.filter(n=>n.id!==t),()=>H(`comments?id=${t}`,{method:"DELETE"}),"Deleting"),g=t=>t.replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""})[e]),xs=t=>{const e=b.filter(s=>ot(s)===t),n=e.filter(s=>q(s)==="open").length,o=e.filter(s=>q(s)==="claude").length;Ae.innerHTML=n?String(n):o?St(9):"\u2713",Ae.dataset.state=n?"open":o?"claude":"done",Ae.hidden=e.length===0},h=()=>{if(gt(),w){const a=zn(),c=JSON.stringify(a);c!==_n&&(_n=c,parent.postMessage({dt:!0,drafts:a},location.origin))}Rt(),y!==qt&&(z="",_=[],qt=y),x&&x.id!==y&&(x=null);const t=ne();if(xs(t),!N){f.innerHTML="",Ce(null);return}const e=t;let n="";const o=b.filter(a=>ot(a)===e&&(J||q(a)!=="done"));for(const a of o){const c=G(a);if(!c&&y!==a.id)continue;const p=q(a),S=p==="done",l=!c,T=c??{x:0,y:0},A=be(a.category),k=Zs(a);if(l||(n+=`<button class="dt-pin dt-pin--${p}${k?" dt-pin--working":""}${p==="open"&&ko(a)==="review"?" dt-pin--review":""}" data-id="${a.id}"${c?.off?` data-off="${c.off}"`:""} aria-label="Comment ${a.id}, ${p==="open"?"open":p==="claude"?`resolved by ${g(dt(a.doneAgent,a.doneFor))}`:"resolved"}" aria-expanded="${y===a.id}"
|
|
24
|
+
style="left:${T.x}px;top:${T.y}px;--cat:${A.color}"
|
|
25
|
+
title="${g(a.text.slice(0,80))} \xB7 ${A.label}${k?` \xB7 ${g(dt(k.agent,k.by))} is on it`:""}${p==="claude"?` \xB7 resolved by ${g(dt(a.doneAgent,a.doneFor))} \u2014 tick to confirm`:p==="done"?" \xB7 resolved":""}">${p==="done"?"\u2713":p==="claude"?St(11):""}</button>`),y===a.id){const tt=Xs(a);n+=`<div class="dt-note${l?" dt-note--orphan":""}" data-id="${a.id}" role="dialog" aria-label="Comment ${a.id}"
|
|
24
26
|
style="left:${T.x}px;top:${T.y}px">
|
|
25
27
|
<div class="dt-note-bar">
|
|
26
|
-
<span class="dt-note-el">${
|
|
27
|
-
${
|
|
28
|
+
<span class="dt-note-el">${m.client?`Comment #${As(a)}`:g(Re(a.tag,a.classes))}</span>
|
|
29
|
+
${Nn(a.label)}
|
|
28
30
|
<span class="dt-note-tools">
|
|
29
|
-
${!
|
|
30
|
-
${
|
|
31
|
+
${!m.client&&p==="open"&&!xo(a)?`<button data-act="fixnow" data-id="${a.id}" title="Fix now \u2014 the agent in turbo takes it next, even while paused">${Go}</button>`:""}
|
|
32
|
+
${Un(p,a.id)}
|
|
31
33
|
<i class="dt-note-sep"></i>
|
|
32
|
-
${
|
|
33
|
-
|
|
34
|
+
${m.client?"":`<button data-act="archive" data-id="${a.id}" title="Archive \u2014 resolved and put away">${Vo}</button>`}
|
|
35
|
+
${m.client?"":In(a.shared,a.id)}
|
|
36
|
+
<button data-act="rm" data-id="${a.id}" title="Delete this thread">${Dt}</button>
|
|
34
37
|
<button data-act="close" data-id="${a.id}" title="Close">${se}</button>
|
|
35
38
|
</span>
|
|
36
39
|
</div>
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
${(()=>{const
|
|
40
|
+
${k?`<p class="dt-note-working"><i></i>${g(dt(k.agent,k.by))} is on it</p>`:""}
|
|
41
|
+
${l?'<p class="dt-note-orphan">The element this was pinned to is not on the page right now.</p>':""}
|
|
42
|
+
${(()=>{const $=Cn(be(a.category).id,a.id)+(m.client?"":An(a.assignee??"",a.id))+(a.host&&a.host!==location.host?`<span class="dt-note-host" title="Written on ${g(a.host)}">${g(a.host)}</span>`:"");return $?`<div class="dt-note-meta">${$}</div>`:""})()}
|
|
40
43
|
<div class="dt-note-thread">
|
|
41
|
-
${
|
|
42
|
-
<textarea class="dt-note-edit-input" rows="1">${
|
|
43
|
-
${
|
|
44
|
+
${tt.map(($,v)=>{const F=v===0?null:$.at??null,et=$.author==="you"&&(!$.by||$.by===m.me?.email),nt=et&&x?.id===a.id&&x.at===F,mt=m.team?.find(ln=>ln.email===$.by),an=$.author==="claude"?dt($.agent,$.by):et?"You":mt?.name||$.byName||$.by||"You",Lo=`<div class="dt-msg-head">${mt?.avatar_url?`<img class="dt-msg-face" src="${g(mt.avatar_url)}" alt="">`:""}<b>${g(an)}</b><time>${Tn($.at)}</time>${et&&!nt?`<button class="dt-msg-edit" data-act="edit" data-id="${a.id}" data-at="${g(F??"")}" title="Edit">${Be}</button>`:""}</div>`;return nt?`<div class="dt-msg">${Lo}<div class="dt-compose">
|
|
45
|
+
<textarea class="dt-note-edit-input" rows="1">${g(x.text)}</textarea>
|
|
46
|
+
${jn($.images.filter(ln=>!x.drop.includes(ln.split("/").pop())),a.id)}
|
|
44
47
|
<div class="dt-compose-bar">
|
|
45
48
|
<button class="dt-edit-cancel" data-act="edit-cancel">Cancel</button>
|
|
46
|
-
<button class="dt-send${x.text.trim()?" is-ready":""}" data-act="edit-save" title="Save (Enter)">${
|
|
49
|
+
<button class="dt-send${x.text.trim()?" is-ready":""}" data-act="edit-save" title="Save (Enter)">${Ot}</button>
|
|
47
50
|
</div>
|
|
48
|
-
</div></div>`:`<div class="dt-msg" data-msg="${a.id}:${
|
|
51
|
+
</div></div>`:`<div class="dt-msg" data-msg="${a.id}:${g($.at??"0")}">${Lo}<p>${g($.text)}</p>${v===0&&a.suggest?ts(a.suggest):""}${jn($.images)}</div>`}).join("")}
|
|
49
52
|
</div>
|
|
50
|
-
${
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
${Wn("dt-note-reply-input","Reply",z,`data-act="reply" data-id="${a.id}"`,Fn(_))}
|
|
54
|
+
${m.client?"":`<div class="dt-prio-row">${Bn(a.priority,a.id)}${p==="open"&&!xo(a)?xn(ko(a),a.id):""}</div>`}
|
|
55
|
+
</div>`}}D.forEach((a,c)=>{const p=G(a);p&&(n+=`<button class="dt-pin dt-pin--draft" data-parked="${c}" data-act="draft-open" data-i="${c}"
|
|
56
|
+
style="left:${p.x}px;top:${p.y}px" title="Draft, not sent \u2014 click to finish it">${Be}</button>`)});const s=d&&G(d);if(d){const a=s?.x??0,c=s?.y??0;n+=`${s?`<span class="dt-pin dt-pin--draft" data-draft style="left:${a}px;top:${c}px"></span>`:""}
|
|
57
|
+
<div class="dt-note${s?"":" dt-note--orphan"}" data-draft style="left:${a}px;top:${c}px">
|
|
54
58
|
<div class="dt-note-bar">
|
|
55
|
-
<span class="dt-note-el">${
|
|
56
|
-
${
|
|
57
|
-
${
|
|
59
|
+
<span class="dt-note-el">${m.client?"New comment":g(Re(d.tag,d.classes))}</span>
|
|
60
|
+
${Nn(d.label)}
|
|
61
|
+
${te()?'<span class="dt-note-draft">Draft</span>':""}
|
|
58
62
|
<span class="dt-note-tools">
|
|
59
|
-
|
|
63
|
+
${m.client?"":In(d.shared)}
|
|
64
|
+
<button data-act="discard" title="Discard this draft">${Dt}</button>
|
|
60
65
|
<button data-act="cancel" title="Close \u2014 the draft stays">${se}</button>
|
|
61
66
|
</span>
|
|
62
67
|
</div>
|
|
63
|
-
${
|
|
64
|
-
${(()=>{const p=
|
|
65
|
-
<div class="dt-note-meta">${
|
|
68
|
+
${s?"":'<p class="dt-note-orphan">The element this was pinned to is not on the page right now.</p>'}
|
|
69
|
+
${(()=>{const p=s?it(d):null,S=p&&b.find(l=>l.id>0&&q(l)==="open"&&it(l)===p);return S?`<p class="dt-note-twin">Already open here: \u201C${g(S.text.slice(0,60))}${S.text.length>60?"\u2026":""}\u201D <button data-act="twin" data-id="${S.id}">Open it</button></p>`:""})()}
|
|
70
|
+
<div class="dt-note-meta">${Cn(d.category)}${m.client?ss(d.assignee):An(d.assignee??ae())}</div>
|
|
66
71
|
${d.suggest?`<div class="dt-suggest"><span class="dt-suggest-head">New wording for this text<button data-act="unsuggest" title="Keep the text as it is">${se}</button></span>
|
|
67
|
-
<span class="dt-suggest-was">Now: <del>${
|
|
68
|
-
<textarea class="dt-suggest-input" rows="2" placeholder="Type how it should read" aria-label="How it should read">${
|
|
72
|
+
<span class="dt-suggest-was">Now: <del>${g(d.suggest.from.slice(0,160))}${d.suggest.from.length>160?"\u2026":""}</del></span>
|
|
73
|
+
<textarea class="dt-suggest-input" rows="2" placeholder="Type how it should read" aria-label="How it should read">${g(d.suggest.to)}</textarea>
|
|
69
74
|
<span class="dt-suggest-hint">Change the words in the box \u2014 the agent puts in exactly what you write.</span></div>`:""}
|
|
70
|
-
${
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
${Wn("dt-note-input",d.suggest?"Why (optional)":"Comment",d.text??"",'data-act="save"',Fn(d.images),as&&!d.suggest&&Hn(s?it(d):null)?`<button class="dt-attach" data-act="suggest" title="Rewrite this text: start from its current words and change them">${ms}</button>`:"")}
|
|
76
|
+
${m.client?"":`<div class="dt-prio-row">${Bn(d.priority)}${xn(d.stage??Mn())}</div>`}
|
|
77
|
+
</div>`}const i=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}])),r=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 c=a.closest(".dt-note").dataset.id,p=i.get(c);if(!p)continue;const S=[...a.querySelectorAll("[data-msg]")].filter(l=>!r.has(l.dataset.msg));for(const l of S)l.classList.add("dt-msg--new");a.scrollTop=p.end&&S.length?a.scrollHeight:p.top}for(const a of f.querySelectorAll(".dt-note")){const c=a.getBoundingClientRect();c.bottom>innerHeight-8&&(a.dataset.flip="1"),c.right>innerWidth-8&&(a.dataset.flipx="1")}Yn(e),Ce(Ln()),ct();for(const a of f.querySelectorAll(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input"))Ye(a);const u=f.querySelector(".dt-note-input");u&&(u.focus(),u.setSelectionRange(u.value.length,u.value.length))},ks=()=>{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=b.find(s=>s.id===Number(e.dataset.id)),o=n&&G(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&&Sn(it(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?D[Number(e.dataset.parked)]:d,o=n&&G(n);if(!o){e.style.visibility="hidden";continue}e.style.visibility="",e.style.left=`${o.x}px`,e.style.top=`${o.y}px`}if(!oe.length&&(d||y!=null)){const e=Ln();e&&Sn(e)&&Ce(e)}t&&ct()},As=t=>b.filter(e=>ot(e)===ot(t)).findIndex(e=>e.id===t.id)+1,Yn=t=>{if(K.hidden)return;const e=b.filter(l=>ot(l)===t),n=new Map(e.map((l,T)=>[l.id,T+1])),o={open:[],claude:[],done:[]};for(const l of e)o[q(l)].push(l);const s=l=>{const T=(l.replies?.length??0)+(l.note?1:0),A=be(l.category),k=q(l),tt=k==="claude",$=!G(l),v=l.replies?.length?l.replies[l.replies.length-1]:l.note?{author:"claude",text:l.note}:{author:"you",text:l.text};return`<div class="dt-hist-row is-${k}${$?" is-orphan":""}">
|
|
78
|
+
<button class="dt-hist-go" data-go="${l.id}">
|
|
79
|
+
<span class="dt-hist-n" style="--cat:${A.color}">${tt?St(8):""}</span>
|
|
74
80
|
<span class="dt-hist-body">
|
|
75
|
-
<span class="dt-hist-id">#${n.get(
|
|
76
|
-
<span class="dt-hist-text">${
|
|
77
|
-
<span class="dt-hist-meta">${
|
|
81
|
+
<span class="dt-hist-id">#${n.get(l.id)}<em>${A.label}</em>${tt?`<b class="dt-hist-claude" data-unmark="${l.id}" role="button" tabindex="0" title="Resolved by ${g(dt(l.doneAgent,l.doneFor))} \u2014 click to clear: back to open">${St(9)}${g(To(l.doneAgent))}<i aria-hidden="true">\xD7</i></b>`:""}${$?'<b class="dt-hist-orphan" title="The element this was pinned to is not on the page right now">no pin</b>':""}</span>
|
|
82
|
+
<span class="dt-hist-text">${v.author==="claude"?`<b>${g(dt(v.agent,v.by))}:</b> `:""}${g(v.text)}</span>
|
|
83
|
+
<span class="dt-hist-meta">${Tn(l.updatedAt||l.createdAt)}${l.device?` \xB7 ${g(l.device)}`:l.browser?` \xB7 ${g(l.browser)}`:""}${T?` \xB7 ${T} repl${T===1?"y":"ies"}`:""}</span>
|
|
78
84
|
</span>
|
|
79
85
|
</button>
|
|
80
|
-
<span class="dt-note-tools dt-hist-tools">${
|
|
81
|
-
><button data-rm="${
|
|
82
|
-
</div>`},i=
|
|
83
|
-
title="${
|
|
84
|
-
><svg viewBox="0 0 20 20" width="11" height="11" aria-hidden="true">${
|
|
85
|
-
<button class="dt-hist-go" data-draft-go="${
|
|
86
|
-
<span class="dt-hist-n">${
|
|
86
|
+
<span class="dt-note-tools dt-hist-tools">${Un(k,l.id)}<i class="dt-note-sep"></i
|
|
87
|
+
><button data-rm="${l.id}" title="Delete this comment">${Dt}</button></span>
|
|
88
|
+
</div>`},i=R.find(l=>l.id===t),r=R.map(l=>{const T=b.filter(A=>ot(A)===l.id&&q(A)!=="done");return{band:l,open:T.filter(A=>q(A)==="open").length,total:T.length}}).filter(l=>l.total&&l.band.id!==t),u=r.length?`<i class="dt-hist-sep"></i><div class="dt-hist-bands">${r.map(({band:l,open:T,total:A})=>`<button data-bp="${l.id}" data-state="${T?"open":"claude"}"
|
|
89
|
+
title="${l.label}: ${T} open \xB7 ${A-T} to check"
|
|
90
|
+
><svg viewBox="0 0 20 20" width="11" height="11" aria-hidden="true">${l.icon}</svg><i>${A}</i></button>`).join("")}</div>`:"",c=["open","claude","done"].filter(l=>o[l].length&&(l!=="done"||J)),p=B.hidden?zn():De,S=l=>`<div class="dt-hist-row is-draft">
|
|
91
|
+
<button class="dt-hist-go" data-draft-go="${l.i}">
|
|
92
|
+
<span class="dt-hist-n">${Be}</span>
|
|
87
93
|
<span class="dt-hist-body">
|
|
88
|
-
<span class="dt-hist-id">${
|
|
89
|
-
<span class="dt-hist-text">${
|
|
94
|
+
<span class="dt-hist-id">${g(l.el)}${l.orphan?'<b class="dt-hist-orphan" title="The element this was pinned to is not on the page right now">no pin</b>':""}</span>
|
|
95
|
+
<span class="dt-hist-text">${l.text?g(l.text):`${l.shots} screenshot${l.shots===1?"":"s"}`}</span>
|
|
90
96
|
</span>
|
|
91
97
|
</button>
|
|
92
|
-
<span class="dt-note-tools dt-hist-tools"><button data-draft-rm="${
|
|
98
|
+
<span class="dt-note-tools dt-hist-tools"><button data-draft-rm="${l.i}" title="Discard this draft">${Dt}</button></span>
|
|
93
99
|
</div>`;K.innerHTML=`<div class="dt-hist-head">
|
|
94
100
|
<span class="dt-hist-here" title="${i?.label??t}"
|
|
95
101
|
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true">${i?.icon??""}</svg></span>
|
|
96
102
|
<span class="dt-hist-title">Comments</span>
|
|
97
103
|
${u}
|
|
98
|
-
${
|
|
104
|
+
${vt().length&&!w?`<button class="dt-review-btn" data-review aria-label="Check all ${vt().length} ${vt().length===1?"fix":"fixes"}" data-tip="${vt().length} ${vt().length===1?"fix waits":"fixes wait"} for a look across every page \u2014 walk through them">${Ot}${vt().length}</button>`:""}
|
|
99
105
|
<button class="dt-hist-refresh" data-refresh aria-label="Reload comments from the file">
|
|
100
106
|
<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>
|
|
101
107
|
</button>
|
|
102
108
|
<button class="dt-hist-fold" data-fold aria-label="Collapse or expand the panel">
|
|
103
109
|
<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>
|
|
104
110
|
</button>
|
|
105
|
-
</div>`+(
|
|
111
|
+
</div>`+(c.length||p.length?`<div class="dt-hist-list">${p.length?`<p class="dt-hist-group">Drafts<em>${p.length}</em></p>${p.map(S).join("")}`:""}${c.map(l=>`<p class="dt-hist-group">${Ys[l]}<em>${o[l].length}</em></p>`+o[l].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">
|
|
106
112
|
<button class="dt-hist-resolved" data-resolved role="switch" aria-checked="${J}"
|
|
107
113
|
><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
|
|
108
114
|
><span>Show resolved</span><kbd>R</kbd><i class="dt-hist-switch" aria-hidden="true"></i></button>
|
|
109
|
-
</div>`},
|
|
110
|
-
<span class="dt-review-nav"><button data-r="prev" aria-label="Previous fix" data-tip="Previous \xB7 \u2190"${n?"":" disabled"}>${
|
|
115
|
+
</div>`},Oe=t=>K.toggleAttribute("data-collapsed",t);K.addEventListener("click",async t=>{const e=t.target.closest("[data-refresh]");if(e){e.dataset.spin="1",await pe(),setTimeout(()=>delete e.dataset.spin,500);return}if(K.hasAttribute("data-collapsed")&&t.target.closest(".dt-hist-head")){Oe(!1);return}if(t.target.closest("[data-fold]")){Oe(!K.hasAttribute("data-collapsed"));return}const n=t.target.closest(".dt-hist-bands [data-bp]");if(n){tn(n.dataset.bp);return}const o=t.target.closest("[data-draft-go], [data-draft-rm]");if(o){const c=o.dataset.draftRm!==void 0,p=Number(c?o.dataset.draftRm:o.dataset.draftGo);B.hidden?c?Jn(p):je(p):P(c?{dropDraft:p}:{openDraft:p});return}const s=t.target.closest("[data-unmark]");if(s){t.stopPropagation(),await jt(Number(s.dataset.unmark),!1);return}const i=t.target.closest(".dt-hist-tools [data-act]");if(i){await jt(Number(i.dataset.id),i.dataset.act==="done");return}const r=t.target.closest("[data-rm]");if(r){y=null,await Vn(Number(r.dataset.rm));return}if(t.target.closest("[data-review]")){Hs();return}if(t.target.closest("[data-resolved]")){We(!J);return}const u=t.target.closest("[data-go]");if(!u)return;const a=Number(u.dataset.go);if(!B.hidden){P({open:a});return}Pe(a)});const Pe=t=>{y=t,U(),h();const e=b.find(o=>o.id===t),n=e&&G(e);n?scrollTo({top:scrollY+n.y-innerHeight/2,behavior:"smooth"}):e&&it(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)},je=t=>{const[e]=D.splice(t,1);if(!e)return;U(),d=e,y=null;const n=G(e);n&&(n.y<0||n.y>innerHeight)&&scrollTo({top:scrollY+n.y-innerHeight/3,behavior:"instant"}),h()},Jn=t=>{D.splice(t,1),h()},Fe="nm-review",le=()=>{try{return JSON.parse(sessionStorage.getItem(Fe)||"null")}catch{return null}},Lt=t=>{try{t?sessionStorage.setItem(Fe,JSON.stringify(t)):sessionStorage.removeItem(Fe)}catch{}},O=document.createElement("div");O.className="dt-review",O.setAttribute("role","region"),O.setAttribute("aria-label","Checking fixes"),O.hidden=!0,w||document.body.append(O);const vt=()=>Z.filter(t=>q(t)==="claude"),Hs=()=>{const t=vt().sort((e,n)=>+(n.route===W)-+(e.route===W)||String(e.route).localeCompare(String(n.route))||e.id-n.id).map(e=>e.id);t.length&&(Lt({ids:t,i:0}),de())},de=()=>{const t=le();if(!t||w){O.hidden=!0;return}for(;t.i<t.ids.length&&q(Z.find(o=>o.id===t.ids[t.i])??{status:"done"})!=="claude";)t.i++;if(t.i>=t.ids.length){Lt(null),O.hidden=!0,I("Every fix is checked.");return}Lt(t);const e=Z.find(o=>o.id===t.ids[t.i]);if(e.route&&e.route!==W){location.assign(e.route+location.search);return}if(N||ut(!0),ot(e)!==ne()){tn(ot(e));for(const o of[600,1500])setTimeout(()=>P({open:e.id}),o)}else Pe(e.id);const n=t.ids.slice(0,t.i).some(o=>q(Z.find(s=>s.id===o)??{status:"done"})==="claude");O.innerHTML=`<b><span class="dt-review-dot" aria-hidden="true"></span>Check fixes</b>
|
|
116
|
+
<span class="dt-review-nav"><button data-r="prev" aria-label="Previous fix" data-tip="Previous \xB7 \u2190"${n?"":" disabled"}>${Yo}</button>
|
|
111
117
|
<span class="dt-review-n">${t.i+1} of ${t.ids.length}</span>
|
|
112
|
-
<button data-r="skip" aria-label="Next fix" data-tip="Next \xB7 \u2192">${
|
|
113
|
-
<span class="dt-review-text">${
|
|
114
|
-
<button data-r="ok" class="dt-review-ok" aria-label="Looks right \u2014 mark it resolved" data-tip="Looks right \u2014 resolve it">${
|
|
115
|
-
<button data-r="no" aria-label="Reopen" data-tip="Not yet \u2014 reopen it">${
|
|
116
|
-
<button data-r="stop" aria-label="Stop checking" data-tip="Stop checking">${se}</button>`,O.hidden=!1};O.addEventListener("click",async t=>{const e=t.target.closest("[data-r]"),n=
|
|
117
|
-
${S}`:""}},jt=t=>(Array.isArray(t)?t:[]).filter(e=>e&&Number.isInteger(Number(e.id))&&typeof e.text=="string").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"):[]})),re=async()=>{try{Jn(jt((await(await C("comments")).json()).comments)),!K.hidden&&!$&&h()}catch{}};let Ft=null,Kt=null;const vt=document.querySelector(".dt-turbo"),Fe="/notemend:turbo",Wt=()=>{const t=!!Ft&&Date.now()-Date.parse(Ft.at)<18e4,e=t?Kt?.paused?"paused":"on":"none",n=t?et(Ft.agent):"",s=e==="none"?`Turbo is off. Run ${Fe} 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`;vt.dataset.state=e,vt.dataset.tip=s,vt.setAttribute("aria-label",s),vt.setAttribute("aria-checked",String(e==="on")),$&&(vt.hidden=!0)};setInterval(Wt,3e4),vt.addEventListener("click",async()=>{const t=vt.dataset.state;if(t==="none"){await navigator.clipboard?.writeText(Fe).catch(()=>{}),q(`Copied ${Fe} \u2014 paste it in Claude Code`);return}const e=t==="on"?"off":"on";Kt={paused:e==="off"},Wt();try{const n=await C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({turbo:e})});if(!n.ok)throw new Error(String(n.status));q(e==="off"?"Turbo paused":"Turbo on")}catch{Kt={paused:e==="on"},Wt(),q("Could not switch turbo \u2014 try again")}});let le="",Ke=!1;const zt=async()=>{if(!(document.hidden||Ke)){Ke=!0;try{const t=await C(`comments${le?`?since=${le}`:""}`);if(t.status!==200)return;const e=await t.json();le=e.version??"",Ft=e.listening??null,Kt=e.turbo??null,Wt();const n=jt(e.comments);Jn(n);const s=n.filter(o=>o.route===W);if(JSON.stringify(s)===JSON.stringify(f))return;if(g.contains(document.activeElement)&&document.activeElement.matches("textarea, input")){le="",setTimeout(zt,5e3);return}f=s,h(),P({reload:!0})}catch{}finally{Ke=!1}}},yt=async()=>{try{const e=await(await C(`comments?route=${encodeURIComponent(W)}`)).json();f=jt(e.comments),Ft=e.listening??null,Kt=e.turbo??null,Wt()}catch{f=[]}h()};let We=0;const Gn=t=>{We||(We=requestAnimationFrame(()=>{We=0;const e=t.target;if(!A||e.closest(ye)){ht.hidden=!0;return}ht.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(ht.hidden=!1,!n)return;const s=n.getBoundingClientRect();xs.style.cssText=`left:${s.left}px;top:${s.top}px;width:${s.width}px;height:${s.height}px`,fn.textContent=n.tagName.toLowerCase()+([...n.classList].find(o=>!/^(astro|svelte)-/.test(o))?"."+[...n.classList].find(o=>!/^(astro|svelte)-/.test(o)):"")+` ${Math.round(s.width)}\xD7${Math.round(s.height)}`,fn.style.cssText=`left:${s.left}px;top:${Math.max(2,s.top-20)}px`}))},Xn=t=>{if(!(t.key!=="Escape"||t.isComposing)){if(t.preventDefault(),x){x=null,h();return}if(d){U(),h();return}if(v!==null){v=null,h();return}dt(!1)}},Zn=["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend"],Qn=t=>{t.target.closest?.(ye)||t.stopPropagation()},ts=t=>{if(t.target.closest(ye))return;if(t.preventDefault(),t.stopPropagation(),ve){ve=!1;return}if(!getSelection()?.isCollapsed)return;g.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(g.hidden=!1,!n)return;U();const s=n.getBoundingClientRect(),o=n.tagName.toLowerCase(),i=[...n.classList].filter(c=>!/^(astro|svelte|css)-/.test(c)).slice(0,2);d={selector:Bs(n),tag:o,classes:i,nth:qs({tag:o,classes:i}).indexOf(n),rx:s.width?(t.clientX-s.left)/s.width:.5,ry:s.height?(t.clientY-s.top)/s.height:.5,label:kt(n.textContent||"").slice(0,60),ctx:Rs(n),category:an[0].id},v=null,ht.hidden=!0,h()},vo=2200,yo=900*1024,$o=8*1024*1024,q=t=>{const e=document.createElement("div");e.className="dt-toast",e.textContent=t,document.body.append(e),setTimeout(()=>e.remove(),2800)},wo=t=>new Promise(e=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.readAsDataURL(t)}),Eo=async t=>{const e=await createImageBitmap(t),n=Math.min(1,vo/Math.max(e.width,e.height));if(n===1&&t.size<=yo)return e.close(),wo(t);const s=document.createElement("canvas");return s.width=Math.round(e.width*n),s.height=Math.round(e.height*n),s.getContext("2d").drawImage(e,0,0,s.width,s.height),e.close(),s.toDataURL("image/jpeg",.85)},ze=async(t,e)=>{const n=[];for(const s of t){let o;try{o=await Eo(s)}catch{q("That image could not be read.");continue}if(o.length>$o){q("Screenshot is too large even after shrinking.");continue}n.push(o)}if(n.length){if(!Number(e?.dataset.id)){d&&((d.images??=[]).push(...n),h());return}_.push(...n),h(),ns(".dt-note-reply-input")}},es=t=>[...t??[]].filter(e=>e.kind==="file"&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(Boolean);g.addEventListener("paste",t=>{const e=es(t.clipboardData?.items);e.length&&(t.preventDefault(),ze(e,t.target.closest(".dt-note")))}),g.addEventListener("dragover",t=>{t.target.closest(".dt-note")&&(t.preventDefault(),t.target.closest(".dt-note").querySelector(".dt-compose")?.setAttribute("data-drop",""))}),g.addEventListener("dragleave",t=>{t.target.closest(".dt-note")?.querySelector(".dt-compose")?.removeAttribute("data-drop")}),g.addEventListener("drop",t=>{const e=t.target.closest(".dt-note");if(!e)return;t.preventDefault(),e.querySelector(".dt-compose")?.removeAttribute("data-drop");const n=es(t.dataTransfer?.items);n.length&&ze(n,e)});const ns=t=>{const e=g.querySelector(t);e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},ss=()=>{ns(".dt-note-edit-input"),g.querySelector(".dt-msg .dt-compose")?.scrollIntoView({block:"nearest"})},_e=t=>{t.style.overflowY="hidden",t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.style.overflowY=t.scrollHeight>t.clientHeight?"auto":"hidden"},So=t=>/(?:^|\s)@([^\s@]*)$/.exec(t.value.slice(0,t.selectionStart??t.value.length)),Lo=t=>{t.closest(".dt-compose").querySelector(".dt-mentions")?.remove();const n=So(t);if(!n||!b.team?.length)return;const s=n[1].toLowerCase(),o=b.team.filter(i=>[i.name,i.nickname,i.email].some(c=>c?.toLowerCase().startsWith(s))).slice(0,5);o.length&&t.insertAdjacentHTML("afterend",`<div class="dt-mentions" role="listbox" aria-label="Mention someone">${o.map((i,c)=>`<button type="button" role="option" aria-selected="${c===0}" data-act="mention" data-handle="${m(Ro(i))}">${m(i.name||i.email)}${i.name?` <span>${m(i.email)}</span>`:""}</button>`).join("")}</div>`)},os=(t,e)=>{const n=t.selectionStart??t.value.length,s=t.value.slice(0,n).lastIndexOf("@");t.value=`${t.value.slice(0,s)}@${e} ${t.value.slice(n)}`,t.selectionStart=t.selectionEnd=s+e.length+2,t.closest(".dt-compose")?.querySelector(".dt-mentions")?.remove(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()},To=(t,e)=>{if(!t){d&&(d.category=e),h();return}at(n=>n.map(s=>s.id===t?{...s,category:e}:s),()=>C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,category:e})}),"Changing the type")};Vo(g,m,Dt),g.addEventListener("change",t=>{const e=t.target.closest(".dt-prio-select");if(e){const c=e.value==="normal"?null:e.value,u=Number(e.dataset.id);u?at(a=>a.map(l=>l.id===u?{...l,priority:c??void 0}:l),()=>C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:u,priority:c})}),"Setting the priority"):d&&(d.priority=c??void 0,Et(),h());return}const n=t.target.closest(".dt-share-select");if(n){const c=n.value==="shared",u=Number(n.dataset.id);u?at(a=>a.map(l=>l.id===u?{...l,shared:c||void 0}:l),()=>C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:u,shared:c})}),c?"Sharing with the client":"Keeping it to the team"):d&&(d.shared=c||void 0,Et(),h());return}const s=t.target.closest(".dt-cat-select");if(s){To(Number(s.dataset.id)||0,s.value);return}const o=t.target.closest(".dt-for-select");if(!o)return;o.parentElement?.style.setProperty("--cat",gt(o.value));const i=Number(o.dataset.id);if(i){const c=o.value||null;at(u=>u.map(a=>a.id===i?{...a,assignee:c??void 0}:a),()=>C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:i,assignee:c})}),"Reassigning");return}if(d){d.assignee=o.value;try{localStorage.setItem("nm-for",o.value)}catch{}Et()}}),g.addEventListener("input",t=>{const e=t.target.closest(".dt-suggest-input");if(e&&d?.suggest){d.suggest.to=e.value,Et(),_e(e);return}const n=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");n&&(Lo(n),n.classList.contains("dt-note-input")?d&&(d.text=n.value):n.classList.contains("dt-note-edit-input")?x&&(x.text=n.value):z=n.value,Et(),n.closest(".dt-compose")?.querySelector(".dt-send")?.classList.toggle("is-ready",n.value.trim()!==""),_e(n))}),g.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(),os(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())}),g.addEventListener("click",async t=>{const e=t.target.closest("button");if(!e)return;const n=e.dataset.act,s=Number(e.dataset.id);if(n==="mention"){const o=e.closest(".dt-compose")?.querySelector("textarea");o&&os(o,e.dataset.handle);return}if(!n){if(v=v===s?null:s,v!=null&&e.dataset.off){const o=f.find(c=>c.id===s);(o&&ot(o))?.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}U(),h();return}if(n==="record"){to(e.closest(".dt-note"));return}if(n==="speak"){ao(e.closest(".dt-note"),e);return}if(n==="voice-write"){ro(e);return}if(n==="voice"||n==="voice-seek"){Ys(e,n==="voice-seek"?t:null);return}if(n==="attach"){const o=Object.assign(document.createElement("input"),{type:"file",accept:"image/*",multiple:!0}),i=e.closest(".dt-note");o.addEventListener("change",()=>{o.files?.length&&ze([...o.files],i)}),o.click();return}if(n==="unshot"){s?x&&x.drop.push(e.dataset.img):(e.closest("[data-draft]")?d?.images??[]:_).splice(Number(e.dataset.i),1),h(),x&&ss();return}if(n==="edit"){const o=f.find(u=>u.id===s),i=e.dataset.at||null,c=i?o?.replies?.find(u=>u.at===i)?.text:o?.text;if(c===void 0)return;x={id:s,at:i,text:c,drop:[]},h(),ss();return}if(n==="edit-cancel"){x=null,h();return}if(n==="edit-save"){const o=x;if(!o)return;const i=o.text.trim();if(!i){g.querySelector(".dt-note-edit-input")?.focus();return}x=null;const c=u=>o.drop.includes(u.split("/").pop());await at(u=>u.map(a=>a.id!==o.id?a:{...a,...o.at==null?{text:i}:{replies:(a.replies??[]).map(l=>l.at===o.at?{...l,text:i}:l)},images:(a.images??[]).filter(l=>!c(l))}),()=>C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o.id,edit:{at:o.at,text:i},...o.drop.length?{removeImage:o.drop}:{}})}).then(u=>(u.ok||(x=o),u)),"Saving the edit");return}if(n==="cancel"){U(),h();return}if(n==="twin"){U(),v=Number(e.dataset.id),h();return}if(n==="discard"){d=null,h();return}if(n==="draft-open"){De(Number(e.dataset.i));return}if(n==="close"){v=null,h();return}if(n==="suggest"&&d){const o=Tn(ot(d));d.suggest={from:o,to:o},h();const i=g.querySelector(".dt-suggest-input");i?.focus(),i?.select();return}if(n==="unsuggest"&&d){d.suggest=null,h();return}if(n==="save"){if(!d)return;const o=d.suggest&&d.suggest.to.trim()!==d.suggest.from?{from:d.suggest.from,to:d.suggest.to.trim()}:null,i=g.querySelector(".dt-note-input").value.trim()||(o?"Change the text":"")||(d.images?.some(Ne)?On:"");if(!i){g.querySelector(".dt-note-input")?.focus();return}const c=d,u={...c,route:W,text:i,suggest:o,assignee:b.client?c.assignee||b.lead||void 0:c.assignee??Sn(),shared:b.client?!0:c.shared===!0,breakpoint:rt(),browser:Cs(),device:$?as:"",viewport:{w:innerWidth,h:innerHeight},logs:zo(),host:location.host},a={...c,id:-Date.now(),text:i,route:W,status:"open",note:"",doneBy:null,breakpoint:u.breakpoint,replies:[],images:[],createdAt:new Date().toISOString(),...o?{suggest:o}:{},by:b.me?.email,byName:b.me?.name};f=[...f,a],d=null,h();const l=await C("comments",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u)});if(!l.ok){f=f.filter(S=>S!==a),d=c,h(),q(`Comment was not saved (${l.status}).`);return}const p=jt([await l.json().catch(()=>null)])[0];f=f.map(S=>S===a&&p?p:S),h(),de();return}if(n==="reply"){const o=g.querySelector(".dt-note-reply-input"),i=o.value.trim()||(_.some(Ne)?On:"");if(!i){o.focus();return}const c=_;z="",_=[];const u=f;f=f.map(p=>p.id===s?{...p,replies:[...p.replies??[],{author:"you",text:i,at:new Date().toISOString(),by:b.me?.email}]}:p),h();const a=await C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,reply:i,images:c})});if(!a.ok){f=u,z=i,_=c,h(),q(`Reply was not sent (${a.status}).`);return}const l=jt([await a.json().catch(()=>null)])[0];l&&(f=f.map(p=>p.id===l.id?l:p),h()),de();return}if(n==="fixnow"){at(o=>o.map(i=>i.id===s?{...i,assignee:"claude"}:i),()=>C("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,fixNow:!0})}),"Sending it to the agent"),q("Sent to the agent \u2014 it takes it next");return}v=null,n==="rm"?await Wn(s):n==="archive"?await po(s):await Pt(s,n==="done")});let _t="overlay",Lt="",as="";const P=t=>{B.hidden||M.contentWindow?.postMessage({dt:!0,...t},location.origin)},Mo=()=>({notes:A,grid:!Jt.hidden,inspect:mt,resolved:J,scrollbar:_t,device:Lt});addEventListener("message",t=>{if(t.origin!==location.origin||!t.data?.dt)return;const e=t.data;if(!$&&t.source===M.contentWindow){if(e.key){fs(e.key[0],e.key[1])?.run();return}if(e.closeMenus){At();return}if(e.drafts){qe=e.drafts,zn(ee());return}}if($&&typeof e.openDraft=="number"){De(e.openDraft);return}if($&&typeof e.dropDraft=="number"){_n(e.dropDraft);return}if($&&typeof e.device=="string"&&(as=e.device),$&&e.scrollbar&&document.documentElement.classList.toggle("dt-sb-classic",e.scrollbar==="classic"),e.hello&&t.source===M.contentWindow){P(Mo());return}typeof e.notes=="boolean"&&e.notes!==A&&dt(e.notes,!1),typeof e.open=="number"&&Ie(e.open),typeof e.grid=="boolean"&&e.grid===Jt.hidden&&be(e.grid),typeof e.inspect=="string"&&e.inspect!==mt&&Gt(e.inspect),typeof e.resolved=="boolean"&&e.resolved!==J&&je(e.resolved),e.reload&&(yt(),re())});const de=async()=>{await yt(),re(),P({reload:!0}),$&&parent.postMessage({dt:!0,reload:!0},location.origin)},dt=(t,e=!0)=>{if(A=t,hn.setAttribute("aria-pressed",String(t)),t?!$&&K.hidden&&localStorage.getItem("dt-history")!=="0"&&(K.hidden=!1,Xt.setAttribute("aria-pressed","true")):(K.hidden=!0,Xt.setAttribute("aria-pressed","false")),V(vn,t?"1":"0"),P({notes:t}),$&&e&&parent.postMessage({dt:!0,notes:t},location.origin),g.hidden=!t||!B.hidden,document.documentElement.classList.toggle("dt-noting",t),t){Gt(""),document.addEventListener("click",ts,!0);for(const n of Zn)document.addEventListener(n,Qn,!0);document.addEventListener("keydown",Xn),document.addEventListener("mousemove",Gn),addEventListener("scroll",lt,!0),addEventListener("resize",lt),Vn.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),Yn.observe(document.body),yt()}else{U(),v=null,document.removeEventListener("click",ts,!0);for(const n of Zn)document.removeEventListener(n,Qn,!0);document.removeEventListener("keydown",Xn),document.removeEventListener("mousemove",Gn),ht.hidden=!0,removeEventListener("scroll",lt,!0),removeEventListener("resize",lt),Vn.disconnect(),Yn.disconnect(),g.innerHTML=""}},ce="dt-w",Ue="dt-canvas",Tt="dt-device";let ct=localStorage.getItem(Ue)==="1",E=localStorage.getItem(Tt)||"";E&&!Yt(E)&&(E="",localStorage.setItem(Tt,""));let N=Number(localStorage.getItem(ce))||0;const is="dt-emu";let j=(()=>{try{return JSON.parse(localStorage.getItem(is)||"null")}catch{return null}})();const ue=()=>j?$s.find(t=>t.id===j.id)??null:null,xo=()=>{const t=ue();return t?j.turned?{w:t.h,h:t.w}:{w:t.w,h:t.h}:null};let Ut=localStorage.getItem("dt-bars-min")==="1";const Mt=t=>{j=t,V(is,t?JSON.stringify(t):"")},Ve=t=>{bn.textContent=t,B.style.setProperty("--dt-badge-w",`${bn.offsetWidth}px`)},rs=t=>{if(!t){Ct.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 s of[n.min,n.max])s>0&&Number.isFinite(s)&&s<=t&&(e+=`<span class="dt-edge" style="left:${s}px" title="${n.label} edge"></span>`);Ct.innerHTML=e,Ct.style.width=`${t}px`},Ye=()=>{const t=parseFloat(L.style.width)||0,e=parseFloat(L.style.height)||0;if(!t||!e){L.style.transform="",delete L.dataset.scaled;return}const n=E||j?Math.min(1,(innerWidth-80)/t,(innerHeight-120)/e):Math.min(1,(innerWidth-80)/t);L.style.transform=n<1?`scale(${n})`:"",L.dataset.scaled=n<1?String(Math.round(n*100)):""},ko=t=>$s.find(e=>e.w===t.w&&e.h===t.h&&e.cutout?.shape==="pill")?.cutout,pe=()=>{try{return M.contentDocument}catch{return null}},ls=()=>pe()?.title.split("\u2014").pop()?.trim()||"",Je=()=>{const t=pe(),e=E?Yt(E):null;if(!t?.body||!e)return;const n=Wo(t),s=e.browser==="chrome-android"?n.theme||"rgb(255, 255, 255)":n.top,o=e.browser==="chrome-android"?"rgb(255, 255, 255)":n.bottom;L.style.setProperty("--dt-top",s),L.style.setProperty("--dt-top-ink",ws(s)),L.style.setProperty("--dt-bottom",o),L.style.setProperty("--dt-bottom-ink",ws(o));const i=Nt.querySelector(".dt-win-tab > span");i&&(i.textContent=ls()||location.host)};let Ge=0;M.addEventListener("load",()=>{pe()&&(Je(),M.contentWindow?.addEventListener("scroll",()=>{Ge||(Ge=requestAnimationFrame(()=>{Ge=0,Je()}))},{passive:!0}))});for(const t of[Nt,Zt])t.addEventListener("click",e=>{const n=e.target.closest("[data-nav]")?.dataset.nav;if(n)try{const s=M.contentWindow?.navigation;if(!pe()||!s)throw new Error("foreign");n==="back"?s.canGoBack&&s.back():n==="fwd"?s.canGoForward&&s.forward():s.reload()}catch{(n==="reload"||n==="back")&&(M.src=location.href)}});Bt.addEventListener("click",()=>{Ut=!Ut,V("dt-bars-min",Ut?"1":"0"),it()});const it=()=>{if($)return;const t=E?Yt(E)??null:null;if(E&&!t&&(E="",localStorage.setItem(Tt,"")),!t&&!ct){B.hidden=!0,M.removeAttribute("src"),document.documentElement.classList.remove("dt-framing"),g.hidden=!A,Ct.innerHTML="",Rt(),Le.hidden=!0,Bt.hidden=!0,st=null,Lt="",qe=[],Rt(),Qe(),A?yt():h();return}if(B.hidden=!1,document.documentElement.classList.add("dt-framing"),g.hidden=!0,M.src||(M.src=location.href),t){const e=Ko(t,{host:location.host,title:ls(),now:new Date,min:Ut,cutout:ko(t)}),{screen:n}=e;B.dataset.mode="device",L.dataset.shell=t.shell,L.dataset.browser=t.browser,L.style.width=`${e.footprint.w}px`,L.style.height=`${e.footprint.h}px`,L.style.setProperty("--dt-r",`${n.r}px`),L.style.setProperty("--dt-rb",`${n.rb}px`),gn.innerHTML=e.shell;const s=(c,u,a,l)=>{c.innerHTML=l,c.style.cssText=`left:${n.x}px;top:${u}px;width:${n.w}px;height:${a}px`};s(Nt,n.y,e.topH,e.top),s(Zt,n.y+n.h-e.bottomH,e.bottomH,e.bottom);const o=n.h-e.topH-e.bottomH;M.style.position="absolute",M.style.left=`${n.x}px`,M.style.top=`${n.y+e.topH}px`,M.style.width=`${n.w}px`,M.style.height=`${o}px`,Ct.innerHTML="";const i=Ut&&e.canMinimize;_t=e.scrollbar,Lt=`${t.label}${i?" \xB7 bars folded":""}`,st=Ht(t.w),P({notes:A,scrollbar:_t,device:Lt}),Bt.hidden=!e.canMinimize,Bt.setAttribute("aria-pressed",String(i)),Ve(`${t.label} \xB7 page ${t.w}\xD7${o} of ${t.w}\xD7${t.h}${i?" \xB7 bars folded":""} \xB7 ${I.find(c=>c.id===st)?.label??""}`),Je()}else{const e=xo();e||Mt(null);const n=e?.w||N||I.find(i=>i.id===rt()).ideal;N=n,B.dataset.mode="canvas",delete L.dataset.shell,delete L.dataset.browser,gn.innerHTML=Nt.innerHTML=Zt.innerHTML="",Nt.style.cssText=Zt.style.cssText="",Bt.hidden=!0,_t="overlay",L.style.width=`${n}px`,L.style.height=`${e?.h??innerHeight-84}px`,M.style.position="",M.style.left=M.style.top="",M.style.width="100%",M.style.height="100%",rs(n),P({notes:A});const s=I.find(i=>i.id===Ht(n)),o=ue();Lt=o?`${o.label}${j?.turned?" \xB7 landscape":""}`:"",P({scrollbar:_t,device:Lt}),Ve(o&&e?`${o.label} \xB7 ${e.w}\xD7${e.h} \xB7 ${s.label}`:`${n}px \xB7 ${s.label}`),st=Ht(n)}Le.hidden=!(ue()?.rotates&&!t),Qe(),Ye(),Rt(),A?yt():h()},Xe=t=>{const e=I.find(n=>n.id===t);E="",localStorage.setItem(Tt,""),Mt(null),ct=t!==ge,N=ct?e.ideal:0,st=ct?t:null,localStorage.setItem(Ue,ct?"1":"0"),localStorage.setItem(ce,String(N)),v=null,U(),it()};for(const t of Ee)t.addEventListener("click",()=>Xe(t.dataset.bp));for(const t of document.querySelectorAll("[data-device]"))t.addEventListener("click",()=>{E=t.dataset.device===E?"":t.dataset.device,localStorage.setItem(Tt,E),Y.open=!1,it()});for(const t of document.querySelectorAll("[data-emu]"))t.addEventListener("click",()=>{const e=j?.id===t.dataset.emu&&!E;E="",localStorage.setItem(Tt,""),Mt(e?null:{id:t.dataset.emu,turned:!1}),ct=!e,N=0,localStorage.setItem(Ue,ct?"1":"0"),st=null,v=null,U(),Y.open=!1,it()});Le.addEventListener("click",()=>{j&&(Mt({...j,turned:!j.turned}),v=null,U(),it())});const ds=[...Y.querySelectorAll("[data-tab]")],Ho=[...Y.querySelectorAll("[data-panel]")],cs=t=>{for(const e of ds)e.setAttribute("aria-selected",String(e.dataset.tab===t));for(const e of Ho)e.hidden=e.dataset.panel!==t;V("dt-devices-tab",t)};for(const t of ds)t.addEventListener("click",()=>cs(t.dataset.tab));cs(localStorage.getItem("dt-devices-tab")==="devtools"?"devtools":"preview");const Ze=Y.querySelector(".dt-emu-search");Ze.addEventListener("input",()=>{const t=Ze.value.trim().toLowerCase();let e=null,n=!1;const s=()=>{e&&(e.hidden=!n)};for(const o of Ze.parentElement.children){if(o.classList.contains("dt-devices-group")){s(),e=o,n=!1;continue}o.dataset.emu&&(o.hidden=!!t&&!o.textContent.toLowerCase().includes(t),n||=!o.hidden)}s()});const Ao=Y.querySelector(".dt-devices-name");function Qe(){for(const e of Y.querySelectorAll("[data-device]"))e.setAttribute("aria-pressed",String(e.dataset.device===E));const t=!E&&!B.hidden?j?.id:void 0;for(const e of Y.querySelectorAll("[data-emu]"))e.setAttribute("aria-pressed",String(e.dataset.emu===t));Ao.textContent=E&&Yt(E)?.label||t&&ue()?.label||"Device"}const tn=t=>I.find(e=>e.id===t),No=t=>{const e=tn(st??rt());return Math.max(e.min||320,Math.min(Number.isFinite(e.max)?e.max:2560,Math.round(t)))};for(const t of ks){const e=t.dataset.edge==="l"?-1:1;t.addEventListener("pointerdown",n=>{if(E)return;n.preventDefault(),j&&(Mt(null),it()),t.setPointerCapture(n.pointerId);const s=n.clientX,o=N,i=Number(L.dataset.scaled||100)/100;B.dataset.dragging="1";const c=a=>{N=No(o+e*(a.clientX-s)*2/i),L.style.width=`${N}px`,rs(N),Ve(`${N}px \xB7 ${tn(Ht(N)).label}`),Ye()},u=()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerup",u),delete B.dataset.dragging,localStorage.setItem(ce,String(N)),it()};t.addEventListener("pointermove",c),t.addEventListener("pointerup",u)}),t.addEventListener("dblclick",()=>{if(E)return;Mt(null);const n=tn(st??rt()),s=[n.min||320,Number.isFinite(n.max)?n.max:n.ideal];N=Math.abs(N-s[0])<Math.abs(N-s[1])?s[0]:s[1],localStorage.setItem(ce,String(N)),it()})}let us=rt();addEventListener("resize",()=>{Rt(),rt()!==us&&(us=rt(),h()),B.hidden||(!E&&!j&&(L.style.height=`${innerHeight-84}px`),Ye())});const ps="dt-studio",ms=t=>{Se.setAttribute("aria-pressed",String(t)),document.documentElement.classList.toggle("dt-no-studio",!t),V(ps,t?"1":"0")};Se.addEventListener("click",()=>ms(Se.getAttribute("aria-pressed")!=="true")),ms(localStorage.getItem(ps)!=="0"),hn.addEventListener("click",()=>dt(!A));const xt=document.querySelector(".devtools"),Vt=document.querySelector(".dt-tab"),hs=t=>{xt.toggleAttribute("data-collapsed",t),Vt.toggleAttribute("data-collapsed",t),Vt.setAttribute("aria-expanded",String(!t)),Vt.setAttribute("aria-label",t?"Show the bar":"Hide the bar");for(const e of xt.querySelectorAll(".dt-group"))e.inert=t;t&&At(),V("dt-collapsed",t?"1":"0")};Vt.addEventListener("click",()=>hs(!xt.hasAttribute("data-collapsed")));const en=document.querySelector(".dt-keys"),ut=t=>()=>xt.querySelector(t)?.click(),gs=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:ut(".dt-notes-btn")},{group:"Comments",code:"KeyC",shift:!0,hint:"\u21E7C",label:"Comments panel",el:".dt-history-btn",run:ut(".dt-history-btn")},{group:"Comments",code:"KeyR",hint:"R",label:"Show resolved",el:".dt-resolved-btn",run:ut(".dt-resolved-btn")},{group:"Inspect",code:"KeyG",hint:"G",label:"Grid",el:".dt-grid-btn",run:ut(".dt-grid-btn")},{group:"Inspect",code:"KeyP",hint:"P",label:"Spacing",el:".dt-pad-btn",run:ut(".dt-pad-btn")},{group:"Inspect",code:"KeyS",hint:"S",label:"Size",el:".dt-size-btn",run:ut(".dt-size-btn")},{group:"Inspect",code:"KeyT",hint:"T",label:"Typography",el:".dt-type-btn",run:ut(".dt-type-btn")},...b.sanity?[{group:"Inspect",code:"KeyE",hint:"E",label:"Sanity overlay",el:".dt-studio-btn",run:ut(".dt-studio-btn")}]:[],...Ee.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:gs(-1)},{group:"View",code:"BracketRight",hint:"]",label:"Next page",run:gs(1)},{group:"View",code:"Backslash",hint:"\\",label:"Hide the bar",run:()=>Vt.click()},{group:"View",code:"Slash",shift:!0,hint:"?",label:"This list",el:".dt-keys summary",run:()=>{en.open=!en.open}}].filter(t=>!b.client||t.group!=="Inspect"),fs=(t,e)=>me.find(n=>n.code===t&&!n.shift==!e),Co=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 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(en.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||Co(e.target))return;const n=fs(e.code,e.shiftKey);n&&(e.preventDefault(),$?parent.postMessage({dt:!0,key:[e.code,e.shiftKey]},location.origin):n.run())}),$){const e=()=>parent.postMessage({dt:!0,closeMenus:!0},location.origin);document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n=>{n.key==="Escape"&&e()})}}if(!$){hs(localStorage.getItem("dt-collapsed")==="1"),requestAnimationFrame(()=>requestAnimationFrame(()=>xt.setAttribute("data-ready",""))),ct||E?it():Qe(),be(localStorage.getItem(ln)==="1");const t=localStorage.getItem(pn);t&&t in $e&&Gt(t),dt(localStorage.getItem(vn)==="1")}const bs=()=>{try{const t=JSON.parse(localStorage.getItem(wt)||"null");D=(t?.parked??[]).filter(e=>Qt(e)),t?.draft&&document.querySelector(t.draft.selector)?(d=t.draft,!A&&!$&&dt(!0)):Qt(t?.draft)&&D.push(t.draft),t?.reply?.text&&(z=t.reply.text,qt=v=t.reply.for??null),(d||D.length||z)&&h()}catch{localStorage.removeItem(wt)}};bs();const vs=()=>setTimeout(()=>{const t=fe(location.pathname);t!==W&&(clearTimeout(te),xe(),W=t,wt=yn(),d=null,D=[],z="",qt=null,v=null,x=null,f=[],cn(),bs(),yt())});for(const t of["pushState","replaceState"]){const e=window.history[t];window.history[t]=function(...n){e.apply(this,n),vs()}}addEventListener("popstate",vs),A||yt(),re().then(()=>{ae()&&ie()}),document.addEventListener("visibilitychange",()=>{document.hidden||zt()}),addEventListener("focus",zt),addEventListener("notemend:changed",()=>{$||zt()});let Bo=0;$||setInterval(()=>{(!jo.live||++Bo%6===0)&&zt()},2e4),$&&parent.postMessage({dt:!0,hello:!0},location.origin)}export{oa as run};
|
|
118
|
+
<button data-r="skip" aria-label="Next fix" data-tip="Next \xB7 \u2192">${Jo}</button></span>
|
|
119
|
+
<span class="dt-review-text">${g(At(e.text).slice(0,90))}</span>
|
|
120
|
+
<button data-r="ok" class="dt-review-ok" aria-label="Looks right \u2014 mark it resolved" data-tip="Looks right \u2014 resolve it">${Ot}</button>
|
|
121
|
+
<button data-r="no" aria-label="Reopen" data-tip="Not yet \u2014 reopen it">${Xo}</button>
|
|
122
|
+
<button data-r="stop" aria-label="Stop checking" data-tip="Stop checking">${se}</button>`,O.hidden=!1};O.addEventListener("click",async t=>{const e=t.target.closest("[data-r]"),n=le();if(!e||!n)return;if(e.dataset.r==="stop"){Lt(null),O.hidden=!0;return}if(e.dataset.r==="prev"){Gn();return}const o=n.ids[n.i];Lt({...n,i:n.i+1});const s=e.dataset.r==="ok"?jt(o,!0):e.dataset.r==="no"?jt(o,!1):null;de(),await s});const Gn=()=>{const t=le();if(t){for(let e=t.i-1;e>=0;e--)if(q(Z.find(n=>n.id===t.ids[e])??{status:"done"})==="claude"){Lt({...t,i:e}),de();return}}};document.addEventListener("keydown",t=>{O.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"?Gn():O.querySelector('[data-r="skip"]')?.click())});const Ns=t=>{K.hidden=!t,Zt.setAttribute("aria-pressed",String(t)),V("dt-history",t?"1":"0"),h()},Ke=document.querySelector(".dt-resolved-btn"),We=t=>{J=t,Ke.setAttribute("aria-pressed",String(t)),V("dt-resolved",t?"1":"0"),P({resolved:t}),h(),ce()};Ke.addEventListener("click",()=>We(!J)),Ke.setAttribute("aria-pressed",String(J)),Zt.addEventListener("click",()=>{const t=K.hidden===!0;t&&!N&&ut(!0),t&&Oe(!1),Ns(t)});const ct=()=>{He||!N||(He=requestAnimationFrame(()=>{He=0,ks()}))},Xn=new MutationObserver(t=>{t.every(e=>e.target.closest?.(".dt-notes-overlay"))||ct()}),Zn=new ResizeObserver(()=>ct());let Z=[];const Qn=t=>{Z=t;const e=()=>({open:0,claude:0,done:0}),n={};for(const u of t){const a=q(u),c=n[u.route??""]??={...e(),bands:{}};c[a]++;const p=ot(u);(c.bands[p]??=e())[a]++}const o=["open","claude","done"],s={open:"open",claude:"resolved by an agent, to check",done:"resolved"},i=u=>o.map(a=>[a,a==="done"&&!J?0:u[a]]),r=u=>i(u).reduce((a,[,c])=>a+c,0);for(const u of document.querySelectorAll(".dt-pages a")){const a=u.querySelector(".dt-pages-n");if(!a)continue;const c=n[new URL(u.href).pathname.replace(/\/+$/,"")||"/"];for(const l of R){const T=c?.bands[l.id];for(const[A,k]of i(T??e())){const tt=a.querySelector(`[data-bp="${l.id}"][data-state="${A}"]`);tt.hidden=!k,k&&(tt.querySelector("i").textContent=String(k),tt.title=`${l.label}: ${k} ${s[A]}`)}}const p=c?r(c):0;a.hidden=!p;const S=c?R.filter(l=>c.bands[l.id]&&r(c.bands[l.id])).map(l=>`${l.label} ${r(c.bands[l.id])}`).join(" \xB7 "):"";a.title=p?`${c.open} open \xB7 ${c.claude} resolved by an agent, to check \xB7 ${c.done} resolved
|
|
123
|
+
${S}`:""}},Ft=t=>(Array.isArray(t)?t:[]).filter(e=>e&&Number.isInteger(Number(e.id))&&typeof e.text=="string").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"):[]})),ce=async()=>{try{Qn(Ft((await(await H("comments")).json()).comments)),!K.hidden&&!w&&h()}catch{}};let Kt=null,Wt=null;const yt=document.querySelector(".dt-turbo"),ze="/notemend:turbo",zt=()=>{const t=!!Kt&&Date.now()-Date.parse(Kt.at)<18e4,e=t?Wt?.paused?"paused":"on":"none",n=t?To(Kt.agent):"",o=e==="none"?`Turbo is off. Run ${ze} 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`;yt.dataset.state=e,yt.dataset.tip=o,yt.setAttribute("aria-label",o),yt.setAttribute("aria-checked",String(e==="on")),w&&(yt.hidden=!0)};setInterval(zt,3e4),yt.addEventListener("click",async()=>{const t=yt.dataset.state;if(t==="none"){await navigator.clipboard?.writeText(ze).catch(()=>{}),I(`Copied ${ze} \u2014 paste it in Claude Code`);return}const e=t==="on"?"off":"on";Wt={paused:e==="off"},zt();try{const n=await H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({turbo:e})});if(!n.ok)throw new Error(String(n.status));I(e==="off"?"Turbo paused":"Turbo on")}catch{Wt={paused:e==="on"},zt(),I("Could not switch turbo \u2014 try again")}});let ue="",_e=!1;const _t=async()=>{if(!(document.hidden||_e)){_e=!0;try{const t=await H(`comments${ue?`?since=${ue}`:""}`);if(t.status!==200)return;const e=await t.json();ue=e.version??"",Kt=e.listening??null,Wt=e.turbo??null,zt();const n=Ft(e.comments);Qn(n);const o=n.filter(s=>s.route===W);if(JSON.stringify(o)===JSON.stringify(b))return;if(f.contains(document.activeElement)&&document.activeElement.matches("textarea, input")){ue="",setTimeout(_t,5e3);return}b=o,h(),P({reload:!0})}catch{}finally{_e=!1}}},wt=async()=>{try{const e=await(await H(`comments?route=${encodeURIComponent(W)}`)).json();b=Ft(e.comments),Kt=e.listening??null,Wt=e.turbo??null,zt()}catch{b=[]}h()};let Ue=0;const to=t=>{Ue||(Ue=requestAnimationFrame(()=>{Ue=0;const e=t.target;if(!N||e.closest(Se)){ht.hidden=!0;return}ht.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(ht.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`,yn.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)}`,yn.style.cssText=`left:${o.left}px;top:${Math.max(2,o.top-20)}px`}))},eo=t=>{if(!(t.key!=="Escape"||t.isComposing)){if(t.preventDefault(),x){x=null,h();return}if(d){U(),h();return}if(y!==null){y=null,h();return}ut(!1)}},no=["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend"],oo=t=>{t.target.closest?.(Se)||t.stopPropagation()},so=t=>{if(t.target.closest(Se))return;if(t.preventDefault(),t.stopPropagation(),Ee){Ee=!1;return}if(!getSelection()?.isCollapsed)return;f.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(f.hidden=!1,!n)return;U();const o=n.getBoundingClientRect(),s=n.tagName.toLowerCase(),i=[...n.classList].filter(r=>!/^(astro|svelte|css)-/.test(r)).slice(0,2);d={selector:zo(n),tag:s,classes:i,nth:_o({tag:s,classes:i}).indexOf(n),rx:o.width?(t.clientX-o.left)/o.width:.5,ry:o.height?(t.clientY-o.top)/o.height:.5,label:At(n.textContent||"").slice(0,60),ctx:Uo(n),category:dn[0].id},y=null,ht.hidden=!0,h()},Cs=2200,Bs=900*1024,Is=8*1024*1024,I=t=>{const e=document.createElement("div");e.className="dt-toast",e.textContent=t,document.body.append(e),setTimeout(()=>e.remove(),2800)},qs=t=>new Promise(e=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.readAsDataURL(t)}),Rs=async t=>{const e=await createImageBitmap(t),n=Math.min(1,Cs/Math.max(e.width,e.height));if(n===1&&t.size<=Bs)return e.close(),qs(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)},Ve=async(t,e)=>{const n=[];for(const o of t){let s;try{s=await Rs(o)}catch{I("That image could not be read.");continue}if(s.length>Is){I("Screenshot is too large even after shrinking.");continue}n.push(s)}if(n.length){if(!Number(e?.dataset.id)){d&&((d.images??=[]).push(...n),h());return}_.push(...n),h(),io(".dt-note-reply-input")}},ao=t=>[...t??[]].filter(e=>e.kind==="file"&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(Boolean);f.addEventListener("paste",t=>{const e=ao(t.clipboardData?.items);e.length&&(t.preventDefault(),Ve(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=ao(t.dataTransfer?.items);n.length&&Ve(n,e)});const io=t=>{const e=f.querySelector(t);e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},ro=()=>{io(".dt-note-edit-input"),f.querySelector(".dt-msg .dt-compose")?.scrollIntoView({block:"nearest"})},Ye=t=>{t.style.overflowY="hidden",t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.style.overflowY=t.scrollHeight>t.clientHeight?"auto":"hidden"},Ds=t=>/(?:^|\s)@([^\s@]*)$/.exec(t.value.slice(0,t.selectionStart??t.value.length)),Os=t=>{t.closest(".dt-compose").querySelector(".dt-mentions")?.remove();const n=Ds(t);if(!n||!m.team?.length)return;const o=n[1].toLowerCase(),s=m.team.filter(i=>[i.name,i.nickname,i.email].some(r=>r?.toLowerCase().startsWith(o))).slice(0,5);s.length&&t.insertAdjacentHTML("afterend",`<div class="dt-mentions" role="listbox" aria-label="Mention someone">${s.map((i,r)=>`<button type="button" role="option" aria-selected="${r===0}" data-act="mention" data-handle="${g(Gs(i))}">${g(i.name||i.email)}${i.name?` <span>${g(i.email)}</span>`:""}</button>`).join("")}</div>`)},lo=(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()},Ps=(t,e)=>{if(!t){d&&(d.category=e),h();return}X(n=>n.map(o=>o.id===t?{...o,category:e}:o),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,category:e})}),"Changing the type")};la(f,g,Ot),f.addEventListener("change",t=>{const e=t.target.closest(".dt-cat-select");if(e){Ps(Number(e.dataset.id)||0,e.value);return}const n=t.target.closest(".dt-for-select");if(!n)return;n.parentElement?.style.setProperty("--cat",Pt(n.value));const o=Number(n.dataset.id);if(o){const s=n.value||null;X(i=>i.map(r=>r.id===o?{...r,assignee:s??void 0}:r),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,assignee:s})}),"Reassigning");return}if(d){d.assignee=n.value;try{localStorage.setItem("nm-for",n.value)}catch{}gt()}}),f.addEventListener("input",t=>{const e=t.target.closest(".dt-suggest-input");if(e&&d?.suggest){d.suggest.to=e.value,gt(),Ye(e);return}const n=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");n&&(Os(n),n.classList.contains("dt-note-input")?d&&(d.text=n.value):n.classList.contains("dt-note-edit-input")?x&&(x.text=n.value):z=n.value,gt(),n.closest(".dt-compose")?.querySelector(".dt-send")?.classList.toggle("is-ready",n.value.trim()!==""),Ye(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(),lo(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==="share"){const s=e.dataset.v==="1";o?X(i=>i.map(r=>r.id===o?{...r,shared:s||void 0}:r),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,shared:s})}),s?"Sharing with the client":"Keeping it to the team"):d&&(d.shared=s||void 0,gt(),h());return}if(n==="prio"){const s=e.dataset.v||null;o?X(i=>i.map(r=>r.id===o?{...r,priority:s??void 0}:r),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,priority:s})}),"Setting the priority"):d&&(d.priority=s??void 0,gt(),h());return}if(n==="mention"){const s=e.closest(".dt-compose")?.querySelector("textarea");s&&lo(s,e.dataset.handle);return}if(!n){if(y=y===o?null:o,y!=null&&e.dataset.off){const s=b.find(r=>r.id===o);(s&&it(s))?.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}U(),h();return}if(n==="record"){gs(e.closest(".dt-note"));return}if(n==="speak"){ws(e.closest(".dt-note"),e);return}if(n==="voice-write"){Es(e);return}if(n==="voice"||n==="voice-seek"){ds(e,n==="voice-seek"?t:null);return}if(n==="attach"){const s=Object.assign(document.createElement("input"),{type:"file",accept:"image/*",multiple:!0}),i=e.closest(".dt-note");s.addEventListener("change",()=>{s.files?.length&&Ve([...s.files],i)}),s.click();return}if(n==="unshot"){o?x&&x.drop.push(e.dataset.img):(e.closest("[data-draft]")?d?.images??[]:_).splice(Number(e.dataset.i),1),h(),x&&ro();return}if(n==="edit"){const s=b.find(u=>u.id===o),i=e.dataset.at||null,r=i?s?.replies?.find(u=>u.at===i)?.text:s?.text;if(r===void 0)return;x={id:o,at:i,text:r,drop:[]},h(),ro();return}if(n==="edit-cancel"){x=null,h();return}if(n==="edit-save"){const s=x;if(!s)return;const i=s.text.trim();if(!i){f.querySelector(".dt-note-edit-input")?.focus();return}x=null;const r=u=>s.drop.includes(u.split("/").pop());await X(u=>u.map(a=>a.id!==s.id?a:{...a,...s.at==null?{text:i}:{replies:(a.replies??[]).map(c=>c.at===s.at?{...c,text:i}:c)},images:(a.images??[]).filter(c=>!r(c))}),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s.id,edit:{at:s.at,text:i},...s.drop.length?{removeImage:s.drop}:{}})}).then(u=>(u.ok||(x=s),u)),"Saving the edit");return}if(n==="cancel"){U(),h();return}if(n==="twin"){U(),y=Number(e.dataset.id),h();return}if(n==="discard"){d=null,h();return}if(n==="draft-open"){je(Number(e.dataset.i));return}if(n==="close"){y=null,h();return}if(n==="suggest"&&d){const s=Hn(it(d));d.suggest={from:s,to:s},h();const i=f.querySelector(".dt-suggest-input");i?.focus(),i?.select();return}if(n==="unsuggest"&&d){d.suggest=null,h();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,i=f.querySelector(".dt-note-input").value.trim()||(s?"Change the text":"")||(d.images?.some(Ie)?Kn:"");if(!i){f.querySelector(".dt-note-input")?.focus();return}const r=d,u={...r,route:W,text:i,suggest:s,assignee:m.client?r.assignee||m.lead||void 0:r.assignee??ae(),shared:m.client?!0:r.shared===!0,stage:m.client?"new":r.stage??Mn(),breakpoint:lt(),browser:Wo(),device:w?co:"",viewport:{w:innerWidth,h:innerHeight},logs:sa(),host:location.host},a={...r,id:-Date.now(),text:i,route:W,status:"open",note:"",doneBy:null,breakpoint:u.breakpoint,replies:[],images:[],createdAt:new Date().toISOString(),...s?{suggest:s}:{},by:m.me?.email,byName:m.me?.name};b=[...b,a],d=null,h();const c=await H("comments",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u)});if(!c.ok){b=b.filter(S=>S!==a),d=r,h(),I(`Comment was not saved (${c.status}).`);return}const p=Ft([await c.json().catch(()=>null)])[0];b=b.map(S=>S===a&&p?p:S),h(),pe();return}if(n==="reply"){const s=f.querySelector(".dt-note-reply-input"),i=s.value.trim()||(_.some(Ie)?Kn:"");if(!i){s.focus();return}const r=_;z="",_=[];const u=b;b=b.map(p=>p.id===o?{...p,replies:[...p.replies??[],{author:"you",text:i,at:new Date().toISOString(),by:m.me?.email}]}:p),h();const a=await H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,reply:i,images:r})});if(!a.ok){b=u,z=i,_=r,h(),I(`Reply was not sent (${a.status}).`);return}const c=Ft([await a.json().catch(()=>null)])[0];c&&(b=b.map(p=>p.id===c.id?c:p),h()),pe();return}if(n==="stage"){Qo(o,e.dataset.v);return}if(n==="fixnow"){const s=b.find(r=>r.id===o)?.assignee,i=s&&ve(s)?s:ft();X(r=>r.map(u=>u.id===o?{...u,assignee:i}:u),()=>H("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,fixNow:!0,assignee:i})}),"Sending it to the agent"),I("Sent to the agent \u2014 it takes it next");return}y=null,n==="rm"?await Vn(o):n==="archive"?await Ms(o):await jt(o,n==="done")});let Ut="overlay",Tt="",co="";const P=t=>{B.hidden||M.contentWindow?.postMessage({dt:!0,...t},location.origin)},js=()=>({notes:N,grid:!Gt.hidden,inspect:st,resolved:J,scrollbar:Ut,device:Tt});addEventListener("message",t=>{if(t.origin!==location.origin||!t.data?.dt)return;const e=t.data;if(!w&&t.source===M.contentWindow){if(e.key){$o(e.key[0],e.key[1])?.run();return}if(e.closeMenus){Nt();return}if(e.drafts){De=e.drafts,Yn(ne());return}}if(w&&typeof e.openDraft=="number"){je(e.openDraft);return}if(w&&typeof e.dropDraft=="number"){Jn(e.dropDraft);return}if(w&&typeof e.device=="string"&&(co=e.device),w&&e.scrollbar&&document.documentElement.classList.toggle("dt-sb-classic",e.scrollbar==="classic"),e.hello&&t.source===M.contentWindow){P(js());return}typeof e.notes=="boolean"&&e.notes!==N&&ut(e.notes,!1),typeof e.open=="number"&&Pe(e.open),typeof e.grid=="boolean"&&e.grid===Gt.hidden&&$e(e.grid),typeof e.inspect=="string"&&e.inspect!==st&&Xt(e.inspect),typeof e.resolved=="boolean"&&e.resolved!==J&&We(e.resolved),e.reload&&(wt(),ce())});const pe=async()=>{await wt(),ce(),P({reload:!0}),w&&parent.postMessage({dt:!0,reload:!0},location.origin)},ut=(t,e=!0)=>{if(N=t,bn.setAttribute("aria-pressed",String(t)),t?!w&&K.hidden&&localStorage.getItem("dt-history")!=="0"&&(K.hidden=!1,Zt.setAttribute("aria-pressed","true")):(K.hidden=!0,Zt.setAttribute("aria-pressed","false")),V($n,t?"1":"0"),P({notes:t}),w&&e&&parent.postMessage({dt:!0,notes:t},location.origin),f.hidden=!t||!B.hidden,document.documentElement.classList.toggle("dt-noting",t),t){Xt(""),document.addEventListener("click",so,!0);for(const n of no)document.addEventListener(n,oo,!0);document.addEventListener("keydown",eo),document.addEventListener("mousemove",to),addEventListener("scroll",ct,!0),addEventListener("resize",ct),Xn.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),Zn.observe(document.body),wt()}else{U(),y=null,document.removeEventListener("click",so,!0);for(const n of no)document.removeEventListener(n,oo,!0);document.removeEventListener("keydown",eo),document.removeEventListener("mousemove",to),ht.hidden=!0,removeEventListener("scroll",ct,!0),removeEventListener("resize",ct),Xn.disconnect(),Zn.disconnect(),f.innerHTML=""}},me="dt-w",Je="dt-canvas",Mt="dt-device";let pt=localStorage.getItem(Je)==="1",E=localStorage.getItem(Mt)||"";E&&!Jt(E)&&(E="",localStorage.setItem(Mt,""));let C=Number(localStorage.getItem(me))||0;const uo="dt-emu";let j=(()=>{try{return JSON.parse(localStorage.getItem(uo)||"null")}catch{return null}})();const he=()=>j?Ao.find(t=>t.id===j.id)??null:null,Fs=()=>{const t=he();return t?j.turned?{w:t.h,h:t.w}:{w:t.w,h:t.h}:null};let Vt=localStorage.getItem("dt-bars-min")==="1";const xt=t=>{j=t,V(uo,t?JSON.stringify(t):"")},Ge=t=>{wn.textContent=t,B.style.setProperty("--dt-badge-w",`${wn.offsetWidth}px`)},po=t=>{if(!t){Bt.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 R)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>`);Bt.innerHTML=e,Bt.style.width=`${t}px`},Xe=()=>{const t=parseFloat(L.style.width)||0,e=parseFloat(L.style.height)||0;if(!t||!e){L.style.transform="",delete L.dataset.scaled;return}const n=E||j?Math.min(1,(innerWidth-80)/t,(innerHeight-120)/e):Math.min(1,(innerWidth-80)/t);L.style.transform=n<1?`scale(${n})`:"",L.dataset.scaled=n<1?String(Math.round(n*100)):""},Ks=t=>Ao.find(e=>e.w===t.w&&e.h===t.h&&e.cutout?.shape==="pill")?.cutout,ge=()=>{try{return M.contentDocument}catch{return null}},mo=()=>ge()?.title.split("\u2014").pop()?.trim()||"",Ze=()=>{const t=ge(),e=E?Jt(E):null;if(!t?.body||!e)return;const n=oa(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;L.style.setProperty("--dt-top",o),L.style.setProperty("--dt-top-ink",Ho(o)),L.style.setProperty("--dt-bottom",s),L.style.setProperty("--dt-bottom-ink",Ho(s));const i=Ct.querySelector(".dt-win-tab > span");i&&(i.textContent=mo()||location.host)};let Qe=0;M.addEventListener("load",()=>{ge()&&(Ze(),M.contentWindow?.addEventListener("scroll",()=>{Qe||(Qe=requestAnimationFrame(()=>{Qe=0,Ze()}))},{passive:!0}))});for(const t of[Ct,Qt])t.addEventListener("click",e=>{const n=e.target.closest("[data-nav]")?.dataset.nav;if(n)try{const o=M.contentWindow?.navigation;if(!ge()||!o)throw new Error("foreign");n==="back"?o.canGoBack&&o.back():n==="fwd"?o.canGoForward&&o.forward():o.reload()}catch{(n==="reload"||n==="back")&&(M.src=location.href)}});It.addEventListener("click",()=>{Vt=!Vt,V("dt-bars-min",Vt?"1":"0"),rt()});const rt=()=>{if(w)return;const t=E?Jt(E)??null:null;if(E&&!t&&(E="",localStorage.setItem(Mt,"")),!t&&!pt){B.hidden=!0,M.removeAttribute("src"),document.documentElement.classList.remove("dt-framing"),f.hidden=!N,Bt.innerHTML="",Rt(),ke.hidden=!0,It.hidden=!0,at=null,Tt="",De=[],Rt(),nn(),N?wt():h();return}if(B.hidden=!1,document.documentElement.classList.add("dt-framing"),f.hidden=!0,M.src||(M.src=location.href),t){const e=na(t,{host:location.host,title:mo(),now:new Date,min:Vt,cutout:Ks(t)}),{screen:n}=e;B.dataset.mode="device",L.dataset.shell=t.shell,L.dataset.browser=t.browser,L.style.width=`${e.footprint.w}px`,L.style.height=`${e.footprint.h}px`,L.style.setProperty("--dt-r",`${n.r}px`),L.style.setProperty("--dt-rb",`${n.rb}px`),vn.innerHTML=e.shell;const o=(r,u,a,c)=>{r.innerHTML=c,r.style.cssText=`left:${n.x}px;top:${u}px;width:${n.w}px;height:${a}px`};o(Ct,n.y,e.topH,e.top),o(Qt,n.y+n.h-e.bottomH,e.bottomH,e.bottom);const s=n.h-e.topH-e.bottomH;M.style.position="absolute",M.style.left=`${n.x}px`,M.style.top=`${n.y+e.topH}px`,M.style.width=`${n.w}px`,M.style.height=`${s}px`,Bt.innerHTML="";const i=Vt&&e.canMinimize;Ut=e.scrollbar,Tt=`${t.label}${i?" \xB7 bars folded":""}`,at=Ht(t.w),P({notes:N,scrollbar:Ut,device:Tt}),It.hidden=!e.canMinimize,It.setAttribute("aria-pressed",String(i)),Ge(`${t.label} \xB7 page ${t.w}\xD7${s} of ${t.w}\xD7${t.h}${i?" \xB7 bars folded":""} \xB7 ${R.find(r=>r.id===at)?.label??""}`),Ze()}else{const e=Fs();e||xt(null);const n=e?.w||C||R.find(i=>i.id===lt()).ideal;C=n,B.dataset.mode="canvas",delete L.dataset.shell,delete L.dataset.browser,vn.innerHTML=Ct.innerHTML=Qt.innerHTML="",Ct.style.cssText=Qt.style.cssText="",It.hidden=!0,Ut="overlay",L.style.width=`${n}px`,L.style.height=`${e?.h??innerHeight-84}px`,M.style.position="",M.style.left=M.style.top="",M.style.width="100%",M.style.height="100%",po(n),P({notes:N});const o=R.find(i=>i.id===Ht(n)),s=he();Tt=s?`${s.label}${j?.turned?" \xB7 landscape":""}`:"",P({scrollbar:Ut,device:Tt}),Ge(s&&e?`${s.label} \xB7 ${e.w}\xD7${e.h} \xB7 ${o.label}`:`${n}px \xB7 ${o.label}`),at=Ht(n)}ke.hidden=!(he()?.rotates&&!t),nn(),Xe(),Rt(),N?wt():h()},tn=t=>{const e=R.find(n=>n.id===t);E="",localStorage.setItem(Mt,""),xt(null),pt=t!==ye,C=pt?e.ideal:0,at=pt?t:null,localStorage.setItem(Je,pt?"1":"0"),localStorage.setItem(me,String(C)),y=null,U(),rt()};for(const t of Me)t.addEventListener("click",()=>tn(t.dataset.bp));for(const t of document.querySelectorAll("[data-device]"))t.addEventListener("click",()=>{E=t.dataset.device===E?"":t.dataset.device,localStorage.setItem(Mt,E),Y.open=!1,rt()});for(const t of document.querySelectorAll("[data-emu]"))t.addEventListener("click",()=>{const e=j?.id===t.dataset.emu&&!E;E="",localStorage.setItem(Mt,""),xt(e?null:{id:t.dataset.emu,turned:!1}),pt=!e,C=0,localStorage.setItem(Je,pt?"1":"0"),at=null,y=null,U(),Y.open=!1,rt()});ke.addEventListener("click",()=>{j&&(xt({...j,turned:!j.turned}),y=null,U(),rt())});const ho=[...Y.querySelectorAll("[data-tab]")],Ws=[...Y.querySelectorAll("[data-panel]")],go=t=>{for(const e of ho)e.setAttribute("aria-selected",String(e.dataset.tab===t));for(const e of Ws)e.hidden=e.dataset.panel!==t;V("dt-devices-tab",t)};for(const t of ho)t.addEventListener("click",()=>go(t.dataset.tab));go(localStorage.getItem("dt-devices-tab")==="devtools"?"devtools":"preview");const en=Y.querySelector(".dt-emu-search");en.addEventListener("input",()=>{const t=en.value.trim().toLowerCase();let e=null,n=!1;const o=()=>{e&&(e.hidden=!n)};for(const s of en.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 zs=Y.querySelector(".dt-devices-name");function nn(){for(const e of Y.querySelectorAll("[data-device]"))e.setAttribute("aria-pressed",String(e.dataset.device===E));const t=!E&&!B.hidden?j?.id:void 0;for(const e of Y.querySelectorAll("[data-emu]"))e.setAttribute("aria-pressed",String(e.dataset.emu===t));zs.textContent=E&&Jt(E)?.label||t&&he()?.label||"Device"}const on=t=>R.find(e=>e.id===t),_s=t=>{const e=on(at??lt());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(E)return;n.preventDefault(),j&&(xt(null),rt()),t.setPointerCapture(n.pointerId);const o=n.clientX,s=C,i=Number(L.dataset.scaled||100)/100;B.dataset.dragging="1";const r=a=>{C=_s(s+e*(a.clientX-o)*2/i),L.style.width=`${C}px`,po(C),Ge(`${C}px \xB7 ${on(Ht(C)).label}`),Xe()},u=()=>{t.removeEventListener("pointermove",r),t.removeEventListener("pointerup",u),delete B.dataset.dragging,localStorage.setItem(me,String(C)),rt()};t.addEventListener("pointermove",r),t.addEventListener("pointerup",u)}),t.addEventListener("dblclick",()=>{if(E)return;xt(null);const n=on(at??lt()),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(me,String(C)),rt()})}let fo=lt();addEventListener("resize",()=>{Rt(),lt()!==fo&&(fo=lt(),h()),B.hidden||(!E&&!j&&(L.style.height=`${innerHeight-84}px`),Xe())});const bo="dt-studio",vo=t=>{xe.setAttribute("aria-pressed",String(t)),document.documentElement.classList.toggle("dt-no-studio",!t),V(bo,t?"1":"0")};xe.addEventListener("click",()=>vo(xe.getAttribute("aria-pressed")!=="true")),vo(localStorage.getItem(bo)!=="0"),bn.addEventListener("click",()=>ut(!N));const kt=document.querySelector(".devtools"),Yt=document.querySelector(".dt-tab"),yo=t=>{kt.toggleAttribute("data-collapsed",t),Yt.toggleAttribute("data-collapsed",t),Yt.setAttribute("aria-expanded",String(!t)),Yt.setAttribute("aria-label",t?"Show the bar":"Hide the bar");for(const e of kt.querySelectorAll(".dt-group"))e.inert=t;t&&Nt(),V("dt-collapsed",t?"1":"0")};Yt.addEventListener("click",()=>yo(!kt.hasAttribute("data-collapsed")));const sn=document.querySelector(".dt-keys"),Q=t=>()=>kt.querySelector(t)?.click(),wo=t=>()=>{const e=[...document.querySelectorAll(".dt-pages a")];e[e.findIndex(n=>n.hasAttribute("aria-current"))+t]?.click()},fe=[{group:"Comments",code:"KeyC",hint:"C",label:"Comment mode",el:".dt-notes-btn",run:Q(".dt-notes-btn")},{group:"Comments",code:"KeyC",shift:!0,hint:"\u21E7C",label:"Comments panel",el:".dt-history-btn",run:Q(".dt-history-btn")},{group:"Comments",code:"KeyR",hint:"R",label:"Show resolved",el:".dt-resolved-btn",run:Q(".dt-resolved-btn")},{group:"Inspect",code:"KeyG",hint:"G",label:"Grid",el:".dt-grid-btn",run:Q(".dt-grid-btn")},{group:"Inspect",code:"KeyP",hint:"P",label:"Spacing",el:".dt-pad-btn",run:Q(".dt-pad-btn")},{group:"Inspect",code:"KeyS",hint:"S",label:"Size",el:".dt-size-btn",run:Q(".dt-size-btn")},{group:"Inspect",code:"KeyT",hint:"T",label:"Typography",el:".dt-type-btn",run:Q(".dt-type-btn")},{group:"Inspect",code:"KeyO",hint:"O",label:"Color",el:".dt-color-btn",run:Q(".dt-color-btn")},{group:"Inspect",code:"KeyB",hint:"B",label:"Border & radius",el:".dt-border-btn",run:Q(".dt-border-btn")},...m.sanity?[{group:"Inspect",code:"KeyE",hint:"E",label:"Sanity overlay",el:".dt-studio-btn",run:Q(".dt-studio-btn")}]:[],...Me.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:wo(-1)},{group:"View",code:"BracketRight",hint:"]",label:"Next page",run:wo(1)},{group:"View",code:"Backslash",hint:"\\",label:"Hide the bar",run:()=>Yt.click()},{group:"View",code:"Slash",shift:!0,hint:"?",label:"This list",el:".dt-keys summary",run:()=>{sn.open=!sn.open}}].filter(t=>!m.client||t.group!=="Inspect"),$o=(t,e)=>fe.find(n=>n.code===t&&!n.shift==!e),Us=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(m.shortcuts){for(const e of fe){const n=e.el&&kt.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(sn.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(fe.map(e=>e.group))].map(e=>`<p class="dt-devices-group">${e}</p>`+fe.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||Us(e.target))return;const n=$o(e.code,e.shiftKey);n&&(e.preventDefault(),w?parent.postMessage({dt:!0,key:[e.code,e.shiftKey]},location.origin):n.run())}),w){const e=()=>parent.postMessage({dt:!0,closeMenus:!0},location.origin);document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n=>{n.key==="Escape"&&e()})}}if(!w){yo(localStorage.getItem("dt-collapsed")==="1"),requestAnimationFrame(()=>requestAnimationFrame(()=>kt.setAttribute("data-ready",""))),pt||E?rt():nn(),$e(localStorage.getItem(un)==="1");const t=localStorage.getItem(gn);t&&t in Le&&Xt(t),ut(localStorage.getItem($n)==="1")}const Eo=()=>{try{const t=JSON.parse(localStorage.getItem(Et)||"null");D=(t?.parked??[]).filter(e=>te(e)),t?.draft&&document.querySelector(t.draft.selector)?(d=t.draft,!N&&!w&&ut(!0)):te(t?.draft)&&D.push(t.draft),t?.reply?.text&&(z=t.reply.text,qt=y=t.reply.for??null),(d||D.length||z)&&h()}catch{localStorage.removeItem(Et)}};Eo();const So=()=>setTimeout(()=>{const t=we(location.pathname);t!==W&&(clearTimeout(ee),Ne(),W=t,Et=En(),d=null,D=[],z="",qt=null,y=null,x=null,b=[],mn(),Eo(),wt())});for(const t of["pushState","replaceState"]){const e=window.history[t];window.history[t]=function(...n){e.apply(this,n),So()}}addEventListener("popstate",So),N||wt(),ce().then(()=>{le()&&de()}),document.addEventListener("visibilitychange",()=>{document.hidden||_t()}),addEventListener("focus",_t),addEventListener("notemend:changed",()=>{w||_t()});let Vs=0;w||setInterval(()=>{(!ta.live||++Vs%6===0)&&_t()},2e4),w&&parent.postMessage({dt:!0,hello:!0},location.origin)}export{wa as run};
|