notemend 0.1.9 → 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 +85 -73
- 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,111 +1,123 @@
|
|
|
1
|
-
import{categoryOf as de}from"../store/categories.mjs";import{stateOf as C,STATE_LABEL as ds}from"../store/status.mjs";import{agentName as J,handleOf as cs,held as us,threadOf as ps,workingOn as ms}from"../store/thread.mjs";import{api as B,canvasCopy as gs,host as fs,imageUrl as hs}from"./api";import{DEVTOOLS_DEVICES as co}from"../devtools-devices.mjs";import{drawDevice as bs,pageTints as ys,inkFor as uo}from"./devices";import{recentLogs as vs}from"./logs";import{inspectors as $s}from"./inspect";import{anchors as Es,clean as wt}from"./anchor";import{fieldMenus as ws}from"./field-menu";function Is(b){const I=b.breakpoints,Xe=b.categories,ce=(I.find(t=>!Number.isFinite(t.max))??I[0]).id,St=t=>I.find(e=>t>=e.min&&t<=e.max)?.id??ce,G=t=>t.breakpoint||ce,Wt=t=>b.devices.find(e=>e.id===t),v=gs,_=(t,e)=>{v||localStorage.setItem(t,e)},ue=t=>t.replace(/\/+$/,"")||"/";let K=ue(location.pathname);for(const t of document.querySelectorAll(".devtools .dt-icon[title]"))t.dataset.tip=t.title,t.getAttribute("aria-label")||t.setAttribute("aria-label",t.title),t.removeAttribute("title");const Ze=document.querySelector(".dt-grid-btn"),_t=document.querySelector(".dt-grid-overlay"),Qe="dt-grid",pe=t=>{_t.hidden=!t,Ze.setAttribute("aria-pressed",String(t)),_(Qe,t?"1":"0"),D({grid:t})};Ze.addEventListener("click",()=>pe(_t.hidden===!0));const tn=document.querySelector(".dt-pages-name"),en=()=>{let t=null;for(const o of document.querySelectorAll(".dt-pages a"))ue(new URL(o.href).pathname)===K?(o.setAttribute("aria-current","page"),t=o):o.removeAttribute("aria-current");const e=document.title.split("\u2014").pop()?.trim(),n=t?.querySelector(".dt-menu-label")?.textContent?.trim();tn.textContent=n||e||tn.textContent};en();const nn=[...document.querySelectorAll(".devtools details")];let me=!1;const Lt=()=>{const t=nn.filter(e=>e.open);for(const e of t)e.open=!1;return t};document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const[e]=Lt();e&&(e.querySelector("summary")?.focus(),t.preventDefault(),t.stopImmediatePropagation())},!0),document.addEventListener("pointerdown",t=>{me=nn.some(e=>e.open&&!e.contains(t.target))&&Lt().length>0},!0),addEventListener("blur",Lt);const gt=document.querySelector(".dt-pad-overlay"),on="dt-inspect",po=[".devtools",".dt-pad-overlay",".dt-grid-overlay",".dt-frame",".dt-history",".dt-review",".dt-field-menu",...b.ignore].join(", "),ge=[".devtools",".dt-notes-overlay",".dt-history",".dt-frame",".dt-review",".dt-field-menu",'[aria-modal="true"]',...b.ignore].join(", "),fe={pads:document.querySelector(".dt-pad-btn"),sizes:document.querySelector(".dt-size-btn"),type:document.querySelector(".dt-type-btn")};let lt="",he=0;const{spacer:mo,drawPads:go,drawSize:fo,drawType:ho}=$s(gt),sn=t=>{he||(he=requestAnimationFrame(()=>{he=0,gt.hidden=!0;let e=document.elementFromPoint(t.clientX,t.clientY);if(gt.hidden=!1,!e||e.closest(po)){gt.innerHTML="";return}t.altKey&&e.parentElement&&e.parentElement!==document.body&&(e=e.parentElement),lt==="sizes"?fo(e):lt==="type"?ho(e):go(t.altKey?e:mo(e))}))},zt=t=>{lt=t;for(const[e,n]of Object.entries(fe))n.setAttribute("aria-pressed",String(e===t));_(on,t),D({inspect:t}),gt.hidden=!t,gt.innerHTML="",t?document.addEventListener("mousemove",sn):document.removeEventListener("mousemove",sn)};for(const[t,e]of Object.entries(fe))e.addEventListener("click",()=>{t!==lt&&st(!1),zt(lt===t?"":t)});const an=document.querySelector(".dt-notes-btn"),be=[...document.querySelectorAll(".dt-bp")],Ut=document.querySelector(".dt-history-btn"),P=document.querySelector(".dt-history"),ye=document.querySelector(".dt-studio-btn"),E=document.querySelector(".dt-device"),rn=document.querySelector(".dt-shell"),Tt=document.querySelector('.dt-chrome[data-at="top"]'),Vt=document.querySelector('.dt-chrome[data-at="bottom"]'),xt=document.querySelector(".dt-ruler"),z=document.querySelector(".dt-devices"),dt=document.querySelector(".dt-notes-hi"),bo=dt.querySelector(".dt-hi-box"),ln=dt.querySelector(".dt-hi-tag"),yo=[...document.querySelectorAll(".dt-frame-handle")],dn=document.querySelector(".dt-frame-size"),ve=document.querySelector(".dt-frame-rotate"),Mt=document.querySelector(".dt-frame-bars"),A=document.querySelector(".dt-frame"),w=A.querySelector("iframe"),$e=document.querySelector(".dt-notes-count"),f=document.querySelector(".dt-notes-overlay"),vo=".devtools, .dt-tab, .dt-notes-overlay, .dt-history, .dt-frame, .dt-review";for(const t of document.querySelectorAll(vo))for(const e of["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend","click","focusin","focusout"])t.addEventListener(e,n=>n.stopPropagation());const cn="dt-notes";let h=[],M=!1,y=null,d=null,Ee=0,F="",tt=[],S=null,q=[];const Yt=(t=d)=>!!(t&&(t.text?.trim()||t.images?.length)),W=()=>{d&&Yt()&&q.push(d),d=null};let kt=null,X=null;const un=()=>`dt-draft:${K}${v?":canvas":""}`;let ft=un(),Jt=0;const we=()=>{if(!d&&!q.length&&!F){localStorage.removeItem(ft);return}const t={draft:d,parked:q,reply:F?{for:kt,text:F}:null};try{localStorage.setItem(ft,JSON.stringify(t))}catch{const e=n=>({...n,images:void 0});try{localStorage.setItem(ft,JSON.stringify({...t,draft:d&&e(d),parked:q.map(e)}))}catch{}}},Ht=()=>{clearTimeout(Jt),Jt=setTimeout(we,200)};addEventListener("pagehide",()=>{clearTimeout(Jt),we()});let U=localStorage.getItem("dt-resolved")!=="0";const $o=[[/Edg\/(\d+)/,"Edge"],[/OPR\/(\d+)/,"Opera"],[/Firefox\/(\d+)/,"Firefox"],[/Chrome\/(\d+)/,"Chrome"],[/Version\/(\d+).*Safari/,"Safari"]],Eo=[[/iPhone|iPad/,"iOS"],[/Android/,"Android"],[/Mac OS X/,"macOS"],[/Windows/,"Windows"],[/Linux/,"Linux"]],wo=()=>{const t=navigator.userAgent,e=r=>r.find(([c])=>c.test(t)),n=e($o),o=e(Eo),s=n?n[0].exec(t)?.[1]:null;return[n?`${n[1]}${s?" "+s:""}`:"unknown browser",o?.[1]].filter(Boolean).join(" \xB7 ")},et=()=>St(innerWidth),Gt=()=>X??et(),At=()=>{const t=Gt();for(const e of be)e.setAttribute("aria-pressed",String(e.dataset.bp===t))},{cssPath:So,poolOf:Lo,contextOf:To,resolveEl:Z,anchorOf:V}=Es(),pn=t=>{for(let e=t;e&&e!==document.body;e=e.parentElement)if(e.getAnimations().some(n=>n.playState==="running"))return!0;return!1};let Xt=[];const Se=t=>{for(const e of Xt)e.play();Xt=[];for(let e=t;e&&e!==document.body;e=e.parentElement)for(const n of e.getAnimations())n.playState==="running"&&(n.pause(),Xt.push(n))},mn=()=>{if(d)return Z(d);const t=y!=null?h.find(n=>n.id===y):null;if(!t)return null;const e=V(t);return e&&!e.off?Z(t):null},gn=t=>t?new Date(t).toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):"",Zt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4 6h12M8 6V4.2h4V6M6.6 6l.55 9.8h5.7L13.4 6"/></svg>',xo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M3.5 4.5h13v3h-13zM4.8 7.5v8h10.4v-8M8.2 10.5h3.6"/></svg>',Nt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.8 10.4 8.2 13.8l7-7.6" stroke-linejoin="round"/></svg>',Le='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><path d="M12.6 4.4l3 3-8.4 8.4H4.2v-3z" stroke-linejoin="round"/></svg>',Qt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M5.4 5.4l9.2 9.2M14.6 5.4l-9.2 9.2"/></svg>',Mo='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M12 5l-5 5 5 5" stroke-linejoin="round"/></svg>',ko='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M8 5l5 5-5 5" stroke-linejoin="round"/></svg>',Ho='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M11 2.5 4.5 11h5l-1 6.5L15.5 9h-5z" stroke-linejoin="round"/></svg>',Ao='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.5 8.5h7.5a3.5 3.5 0 0 1 0 7H8.5M7.5 5.5l-3 3 3 3" stroke-linejoin="round"/></svg>',Ct=t=>`<svg viewBox="0 0 24 24" width="${t}" height="${t}" aria-hidden="true" class="dt-claude"><path d="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"/></svg>`,fn=()=>{try{return localStorage.getItem("nm-for")??"claude"}catch{return"claude"}},Bt=t=>t==="claude"?"#d97757":t?"#0d99ff":"#717171",hn=(t,e)=>`<label class="dt-field" title="Who it is for"><span class="dt-field-box" style="--cat:${Bt(t)}"><select class="dt-for-select"${e?` data-id="${e}"`:""} aria-label="Who this is for">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
${
|
|
5
|
-
|
|
6
|
-
|
|
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">
|
|
7
13
|
<textarea class="${t}" rows="1" placeholder="${e}">${g(n)}</textarea>
|
|
8
14
|
${s}
|
|
9
15
|
<div class="dt-compose-bar">
|
|
10
|
-
<span class="dt-compose-tools"><button class="dt-attach" data-act="attach" title="Attach a screenshot \u2014 or paste or drop one">${
|
|
11
|
-
${
|
|
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>
|
|
12
18
|
<button class="dt-send${n.trim()?" is-ready":""}" ${o} title="Send (Enter)"
|
|
13
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>
|
|
14
20
|
</div>
|
|
15
|
-
</div></div>`,
|
|
16
|
-
title="Resolved by ${g(
|
|
17
|
-
class="dt-note-resolve${n?" is-on":""}" title="${n?"Reopen":t==="claude"?"Looks right \u2014 mark it resolved":"Resolve"}">${
|
|
18
|
-
style="left:${
|
|
19
|
-
title="${g(a.text.slice(0,80))} \xB7 ${
|
|
20
|
-
style="left:${
|
|
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}"
|
|
26
|
+
style="left:${T.x}px;top:${T.y}px">
|
|
21
27
|
<div class="dt-note-bar">
|
|
22
|
-
<span class="dt-note-el">${
|
|
23
|
-
${
|
|
28
|
+
<span class="dt-note-el">${m.client?`Comment #${As(a)}`:g(Re(a.tag,a.classes))}</span>
|
|
29
|
+
${Nn(a.label)}
|
|
24
30
|
<span class="dt-note-tools">
|
|
25
|
-
${!
|
|
26
|
-
${
|
|
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)}
|
|
27
33
|
<i class="dt-note-sep"></i>
|
|
28
|
-
${
|
|
29
|
-
|
|
30
|
-
<button data-act="
|
|
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>
|
|
37
|
+
<button data-act="close" data-id="${a.id}" title="Close">${se}</button>
|
|
31
38
|
</span>
|
|
32
39
|
</div>
|
|
33
|
-
${
|
|
34
|
-
${
|
|
35
|
-
${(()=>{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>`:""})()}
|
|
36
43
|
<div class="dt-note-thread">
|
|
37
|
-
${
|
|
38
|
-
<textarea class="dt-note-edit-input" rows="1">${g(
|
|
39
|
-
${
|
|
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)}
|
|
40
47
|
<div class="dt-compose-bar">
|
|
41
48
|
<button class="dt-edit-cancel" data-act="edit-cancel">Cancel</button>
|
|
42
|
-
<button class="dt-send${
|
|
49
|
+
<button class="dt-send${x.text.trim()?" is-ready":""}" data-act="edit-save" title="Save (Enter)">${Ot}</button>
|
|
43
50
|
</div>
|
|
44
|
-
</div></div>`:`<div class="dt-msg" data-msg="${a.id}:${g(
|
|
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("")}
|
|
45
52
|
</div>
|
|
46
|
-
${
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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">
|
|
50
58
|
<div class="dt-note-bar">
|
|
51
|
-
<span class="dt-note-el">${
|
|
52
|
-
${
|
|
53
|
-
${
|
|
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>':""}
|
|
54
62
|
<span class="dt-note-tools">
|
|
55
|
-
|
|
56
|
-
<button data-act="
|
|
63
|
+
${m.client?"":In(d.shared)}
|
|
64
|
+
<button data-act="discard" title="Discard this draft">${Dt}</button>
|
|
65
|
+
<button data-act="cancel" title="Close \u2014 the draft stays">${se}</button>
|
|
57
66
|
</span>
|
|
58
67
|
</div>
|
|
59
68
|
${s?"":'<p class="dt-note-orphan">The element this was pinned to is not on the page right now.</p>'}
|
|
60
|
-
${(()=>{const p=s?
|
|
61
|
-
<div class="dt-note-meta">${
|
|
62
|
-
${d.suggest?`<div class="dt-suggest"><span class="dt-suggest-head">
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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>
|
|
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>
|
|
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>
|
|
74
|
+
<span class="dt-suggest-hint">Change the words in the box \u2014 the agent puts in exactly what you write.</span></div>`:""}
|
|
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>
|
|
68
80
|
<span class="dt-hist-body">
|
|
69
|
-
<span class="dt-hist-id">#${n.get(
|
|
70
|
-
<span class="dt-hist-text">${
|
|
71
|
-
<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>
|
|
72
84
|
</span>
|
|
73
85
|
</button>
|
|
74
|
-
<span class="dt-note-tools dt-hist-tools">${
|
|
75
|
-
><button data-rm="${
|
|
76
|
-
</div>`},
|
|
77
|
-
title="${
|
|
78
|
-
><svg viewBox="0 0 20 20" width="11" height="11" aria-hidden="true">${
|
|
79
|
-
<button class="dt-hist-go" data-draft-go="${
|
|
80
|
-
<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>
|
|
81
93
|
<span class="dt-hist-body">
|
|
82
|
-
<span class="dt-hist-id">${g(
|
|
83
|
-
<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>
|
|
84
96
|
</span>
|
|
85
97
|
</button>
|
|
86
|
-
<span class="dt-note-tools dt-hist-tools"><button data-draft-rm="${
|
|
87
|
-
</div>`;
|
|
88
|
-
<span class="dt-hist-here" title="${
|
|
89
|
-
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true">${
|
|
98
|
+
<span class="dt-note-tools dt-hist-tools"><button data-draft-rm="${l.i}" title="Discard this draft">${Dt}</button></span>
|
|
99
|
+
</div>`;K.innerHTML=`<div class="dt-hist-head">
|
|
100
|
+
<span class="dt-hist-here" title="${i?.label??t}"
|
|
101
|
+
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true">${i?.icon??""}</svg></span>
|
|
90
102
|
<span class="dt-hist-title">Comments</span>
|
|
91
103
|
${u}
|
|
92
|
-
${
|
|
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>`:""}
|
|
93
105
|
<button class="dt-hist-refresh" data-refresh aria-label="Reload comments from the file">
|
|
94
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>
|
|
95
107
|
</button>
|
|
96
108
|
<button class="dt-hist-fold" data-fold aria-label="Collapse or expand the panel">
|
|
97
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>
|
|
98
110
|
</button>
|
|
99
|
-
</div>`+(
|
|
100
|
-
<button class="dt-hist-resolved" data-resolved role="switch" aria-checked="${
|
|
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">
|
|
112
|
+
<button class="dt-hist-resolved" data-resolved role="switch" aria-checked="${J}"
|
|
101
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
|
|
102
114
|
><span>Show resolved</span><kbd>R</kbd><i class="dt-hist-switch" aria-hidden="true"></i></button>
|
|
103
|
-
</div>`},
|
|
104
|
-
<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>
|
|
105
117
|
<span class="dt-review-n">${t.i+1} of ${t.ids.length}</span>
|
|
106
|
-
<button data-r="skip" aria-label="Next fix" data-tip="Next \xB7 \u2192">${
|
|
107
|
-
<span class="dt-review-text">${g(
|
|
108
|
-
<button data-r="ok" class="dt-review-ok" aria-label="Looks right \u2014 mark it resolved" data-tip="Looks right \u2014 resolve it">${
|
|
109
|
-
<button data-r="no" aria-label="Reopen" data-tip="Not yet \u2014 reopen it">${
|
|
110
|
-
<button data-r="stop" aria-label="Stop checking" data-tip="Stop checking">${
|
|
111
|
-
${L}`:""}},qt=t=>(Array.isArray(t)?t:[]).filter(e=>e&&Number.isInteger(Number(e.id))&&typeof e.text=="string").filter(e=>!b.client||e.by===b.me?.email||e.assignee===b.me?.email).map(e=>({...e,id:Number(e.id),rx:Number(e.rx)||0,ry:Number(e.ry)||0,route:typeof e.route=="string"&&/^\/(?!\/)/.test(e.route)?e.route:"/",replies:Array.isArray(e.replies)?e.replies.filter(n=>typeof n?.text=="string"):[],images:Array.isArray(e.images)?e.images.filter(n=>typeof n=="string"):[]})),ne=async()=>{try{Rn(qt((await(await B("comments")).json()).comments)),!P.hidden&&!v&&m()}catch{}};let Rt=null,Dt=null;const pt=document.querySelector(".dt-turbo"),Be="/notemend:turbo",Ot=()=>{const t=!!Rt&&Date.now()-Date.parse(Rt.at)<18e4,e=t?Dt?.paused?"paused":"on":"none",n=t?J(Rt.agent):"",o=e==="none"?`Turbo is off. Run ${Be} in Claude Code and comments for the agent are taken as they land \u2014 click to copy it`:e==="on"?`Turbo on: ${n} takes comments for the agent as they land \u2014 click to pause`:`Turbo paused: ${n} is listening but waits \u2014 click to resume`;pt.dataset.state=e,pt.dataset.tip=o,pt.setAttribute("aria-label",o),pt.setAttribute("aria-checked",String(e==="on")),v&&(pt.hidden=!0)};setInterval(Ot,3e4),pt.addEventListener("click",async()=>{const t=pt.dataset.state;if(t==="none"){await navigator.clipboard?.writeText(Be).catch(()=>{}),j(`Copied ${Be} \u2014 paste it in Claude Code`);return}const e=t==="on"?"off":"on";Dt={paused:e==="off"},Ot();try{const n=await B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({turbo:e})});if(!n.ok)throw new Error(String(n.status));j(e==="off"?"Turbo paused":"Turbo on")}catch{Dt={paused:e==="on"},Ot(),j("Could not switch turbo \u2014 try again")}});let oe="",Ie=!1;const Pt=async()=>{if(!(document.hidden||Ie)){Ie=!0;try{const t=await B(`comments${oe?`?since=${oe}`:""}`);if(t.status!==200)return;const e=await t.json();oe=e.version??"",Rt=e.listening??null,Dt=e.turbo??null,Ot();const n=qt(e.comments);Rn(n);const o=n.filter(s=>s.route===K);if(JSON.stringify(o)===JSON.stringify(h))return;if(f.contains(document.activeElement)&&document.activeElement.matches("textarea, input")){oe="",setTimeout(Pt,5e3);return}h=o,m(),D({reload:!0})}catch{}finally{Ie=!1}}},mt=async()=>{try{const e=await(await B(`comments?route=${encodeURIComponent(K)}`)).json();h=qt(e.comments),Rt=e.listening??null,Dt=e.turbo??null,Ot()}catch{h=[]}m()};let qe=0;const Dn=t=>{qe||(qe=requestAnimationFrame(()=>{qe=0;const e=t.target;if(!M||e.closest(ge)){dt.hidden=!0;return}dt.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(dt.hidden=!1,!n)return;const o=n.getBoundingClientRect();bo.style.cssText=`left:${o.left}px;top:${o.top}px;width:${o.width}px;height:${o.height}px`,ln.textContent=n.tagName.toLowerCase()+([...n.classList].find(s=>!/^(astro|svelte)-/.test(s))?"."+[...n.classList].find(s=>!/^(astro|svelte)-/.test(s)):"")+` ${Math.round(o.width)}\xD7${Math.round(o.height)}`,ln.style.cssText=`left:${o.left}px;top:${Math.max(2,o.top-20)}px`}))},On=t=>{if(!(t.key!=="Escape"||t.isComposing)){if(t.preventDefault(),S){S=null,m();return}if(d){W(),m();return}if(y!==null){y=null,m();return}st(!1)}},Pn=["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend"],jn=t=>{t.target.closest?.(ge)||t.stopPropagation()},Kn=t=>{if(t.target.closest(ge))return;if(t.preventDefault(),t.stopPropagation(),me){me=!1;return}if(!getSelection()?.isCollapsed)return;f.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(f.hidden=!1,!n)return;W();const o=n.getBoundingClientRect(),s=n.tagName.toLowerCase(),r=[...n.classList].filter(c=>!/^(astro|svelte|css)-/.test(c)).slice(0,2);d={selector:So(n),tag:s,classes:r,nth:Lo({tag:s,classes:r}).indexOf(n),rx:o.width?(t.clientX-o.left)/o.width:.5,ry:o.height?(t.clientY-o.top)/o.height:.5,label:wt(n.textContent||"").slice(0,60),ctx:To(n),category:Xe[0].id},y=null,dt.hidden=!0,m()},Uo=2200,Vo=900*1024,Yo=8*1024*1024,j=t=>{const e=document.createElement("div");e.className="dt-toast",e.textContent=t,document.body.append(e),setTimeout(()=>e.remove(),2800)},Jo=t=>new Promise(e=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.readAsDataURL(t)}),Go=async t=>{const e=await createImageBitmap(t),n=Math.min(1,Uo/Math.max(e.width,e.height));if(n===1&&t.size<=Vo)return e.close(),Jo(t);const o=document.createElement("canvas");return o.width=Math.round(e.width*n),o.height=Math.round(e.height*n),o.getContext("2d").drawImage(e,0,0,o.width,o.height),e.close(),o.toDataURL("image/jpeg",.85)},Re=async(t,e)=>{const n=[];for(const o of t){let s;try{s=await Go(o)}catch{j("That image could not be read.");continue}if(s.length>Yo){j("Screenshot is too large even after shrinking.");continue}n.push(s)}if(n.length){if(!Number(e?.dataset.id)){d&&((d.images??=[]).push(...n),m());return}tt.push(...n),m(),Wn(".dt-note-reply-input")}},Fn=t=>[...t??[]].filter(e=>e.kind==="file"&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(Boolean);f.addEventListener("paste",t=>{const e=Fn(t.clipboardData?.items);e.length&&(t.preventDefault(),Re(e,t.target.closest(".dt-note")))}),f.addEventListener("dragover",t=>{t.target.closest(".dt-note")&&(t.preventDefault(),t.target.closest(".dt-note").querySelector(".dt-compose")?.setAttribute("data-drop",""))}),f.addEventListener("dragleave",t=>{t.target.closest(".dt-note")?.querySelector(".dt-compose")?.removeAttribute("data-drop")}),f.addEventListener("drop",t=>{const e=t.target.closest(".dt-note");if(!e)return;t.preventDefault(),e.querySelector(".dt-compose")?.removeAttribute("data-drop");const n=Fn(t.dataTransfer?.items);n.length&&Re(n,e)});const Wn=t=>{const e=f.querySelector(t);e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},_n=()=>{Wn(".dt-note-edit-input"),f.querySelector(".dt-msg .dt-compose")?.scrollIntoView({block:"nearest"})},De=t=>{t.style.overflowY="hidden",t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.style.overflowY=t.scrollHeight>t.clientHeight?"auto":"hidden"},Xo=t=>/(?:^|\s)@([^\s@]*)$/.exec(t.value.slice(0,t.selectionStart??t.value.length)),Zo=t=>{t.closest(".dt-compose").querySelector(".dt-mentions")?.remove();const n=Xo(t);if(!n||!b.team?.length)return;const o=n[1].toLowerCase(),s=b.team.filter(r=>[r.name,r.nickname,r.email].some(c=>c?.toLowerCase().startsWith(o))).slice(0,5);s.length&&t.insertAdjacentHTML("afterend",`<div class="dt-mentions" role="listbox" aria-label="Mention someone">${s.map((r,c)=>`<button type="button" role="option" aria-selected="${c===0}" data-act="mention" data-handle="${g(cs(r))}">${g(r.name||r.email)}${r.name?` <span>${g(r.email)}</span>`:""}</button>`).join("")}</div>`)},zn=(t,e)=>{const n=t.selectionStart??t.value.length,o=t.value.slice(0,n).lastIndexOf("@");t.value=`${t.value.slice(0,o)}@${e} ${t.value.slice(n)}`,t.selectionStart=t.selectionEnd=o+e.length+2,t.closest(".dt-compose")?.querySelector(".dt-mentions")?.remove(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()},Qo=(t,e)=>{if(!t){d&&(d.category=e),m();return}nt(n=>n.map(o=>o.id===t?{...o,category:e}:o),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,category:e})}),"Changing the type")};ws(f,g,Nt),f.addEventListener("change",t=>{const e=t.target.closest(".dt-prio-select");if(e){const r=e.value==="normal"?null:e.value,c=Number(e.dataset.id);c?nt(u=>u.map(a=>a.id===c?{...a,priority:r??void 0}:a),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:c,priority:r})}),"Setting the priority"):d&&(d.priority=r??void 0,Ht(),m());return}const n=t.target.closest(".dt-cat-select");if(n){Qo(Number(n.dataset.id)||0,n.value);return}const o=t.target.closest(".dt-for-select");if(!o)return;o.parentElement?.style.setProperty("--cat",Bt(o.value));const s=Number(o.dataset.id);if(s){const r=o.value||null;nt(c=>c.map(u=>u.id===s?{...u,assignee:r??void 0}:u),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,assignee:r})}),"Reassigning");return}if(d){d.assignee=o.value;try{localStorage.setItem("nm-for",o.value)}catch{}Ht()}}),f.addEventListener("input",t=>{const e=t.target.closest(".dt-suggest-input");if(e&&d?.suggest){d.suggest.to=e.value,Ht(),De(e);return}const n=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");n&&(Zo(n),n.classList.contains("dt-note-input")?d&&(d.text=n.value):n.classList.contains("dt-note-edit-input")?S&&(S.text=n.value):F=n.value,Ht(),n.closest(".dt-compose")?.querySelector(".dt-send")?.classList.toggle("is-ready",n.value.trim()!==""),De(n))}),f.addEventListener("keydown",t=>{const e=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");if(!e)return;const n=e.closest(".dt-compose")?.querySelector(".dt-mentions button");if(n&&(t.key==="Enter"||t.key==="Tab")&&!t.isComposing){t.preventDefault(),zn(e,n.dataset.handle);return}if(n&&t.key==="Escape"){t.stopPropagation(),n.parentElement.remove();return}t.key!=="Enter"||t.shiftKey||t.isComposing||(t.preventDefault(),e.closest(".dt-compose")?.querySelector(".dt-send")?.click())}),f.addEventListener("click",async t=>{const e=t.target.closest("button");if(!e)return;const n=e.dataset.act,o=Number(e.dataset.id);if(n==="mention"){const s=e.closest(".dt-compose")?.querySelector("textarea");s&&zn(s,e.dataset.handle);return}if(!n){if(y=y===o?null:o,y!=null&&e.dataset.off){const s=h.find(c=>c.id===o);(s&&Z(s))?.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}W(),m();return}if(n==="record"){Ro(e.closest(".dt-note"));return}if(n==="attach"){const s=Object.assign(document.createElement("input"),{type:"file",accept:"image/*",multiple:!0}),r=e.closest(".dt-note");s.addEventListener("change",()=>{s.files?.length&&Re([...s.files],r)}),s.click();return}if(n==="unshot"){o?S&&S.drop.push(e.dataset.img):(e.closest("[data-draft]")?d?.images??[]:tt).splice(Number(e.dataset.i),1),m(),S&&_n();return}if(n==="edit"){const s=h.find(u=>u.id===o),r=e.dataset.at||null,c=r?s?.replies?.find(u=>u.at===r)?.text:s?.text;if(c===void 0)return;S={id:o,at:r,text:c,drop:[]},m(),_n();return}if(n==="edit-cancel"){S=null,m();return}if(n==="edit-save"){const s=S;if(!s)return;const r=s.text.trim();if(!r){f.querySelector(".dt-note-edit-input")?.focus();return}S=null;const c=u=>s.drop.includes(u.split("/").pop());await nt(u=>u.map(a=>a.id!==s.id?a:{...a,...s.at==null?{text:r}:{replies:(a.replies??[]).map(l=>l.at===s.at?{...l,text:r}:l)},images:(a.images??[]).filter(l=>!c(l))}),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s.id,edit:{at:s.at,text:r},...s.drop.length?{removeImage:s.drop}:{}})}).then(u=>(u.ok||(S=s),u)),"Saving the edit");return}if(n==="cancel"){W(),m();return}if(n==="twin"){W(),y=Number(e.dataset.id),m();return}if(n==="discard"){d=null,m();return}if(n==="draft-open"){He(Number(e.dataset.i));return}if(n==="close"){y=null,m();return}if(n==="suggest"&&d){const s=bn(Z(d));d.suggest={from:s,to:s},m();const r=f.querySelector(".dt-suggest-input");r?.focus(),r?.select();return}if(n==="unsuggest"&&d){d.suggest=null,m();return}if(n==="save"){if(!d)return;const s=d.suggest&&d.suggest.to.trim()!==d.suggest.from?{from:d.suggest.from,to:d.suggest.to.trim()}:null,r=f.querySelector(".dt-note-input").value.trim()||(s?"Change the text":"");if(!r){f.querySelector(".dt-note-input")?.focus();return}const c=d,u={...c,route:K,text:r,suggest:s,assignee:b.client?void 0:c.assignee??fn(),breakpoint:et(),browser:wo(),device:v?Un:"",viewport:{w:innerWidth,h:innerHeight},logs:vs(),host:location.host},a={...c,id:-Date.now(),text:r,route:K,status:"open",note:"",doneBy:null,breakpoint:u.breakpoint,replies:[],images:[],createdAt:new Date().toISOString(),...s?{suggest:s}:{},by:b.me?.email,byName:b.me?.name};h=[...h,a],d=null,m();const l=await B("comments",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u)});if(!l.ok){h=h.filter(L=>L!==a),d=c,m(),j(`Comment was not saved (${l.status}).`);return}const p=qt([await l.json().catch(()=>null)])[0];h=h.map(L=>L===a&&p?p:L),m(),se();return}if(n==="reply"){const s=f.querySelector(".dt-note-reply-input"),r=s.value.trim();if(!r){s.focus();return}const c=tt;F="",tt=[];const u=h;h=h.map(p=>p.id===o?{...p,replies:[...p.replies??[],{author:"you",text:r,at:new Date().toISOString(),by:b.me?.email}]}:p),m();const a=await B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,reply:r,images:c})});if(!a.ok){h=u,F=r,tt=c,m(),j(`Reply was not sent (${a.status}).`);return}const l=qt([await a.json().catch(()=>null)])[0];l&&(h=h.map(p=>p.id===l.id?l:p),m()),se();return}if(n==="fixnow"){nt(s=>s.map(r=>r.id===o?{...r,assignee:"claude"}:r),()=>B("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,fixNow:!0})}),"Sending it to the agent"),j("Sent to the agent \u2014 it takes it next");return}y=null,n==="rm"?await An(o):n==="archive"?await jo(o):await It(o,n==="done")});let jt="overlay",bt="",Un="";const D=t=>{A.hidden||w.contentWindow?.postMessage({dt:!0,...t},location.origin)},ts=()=>({notes:M,grid:!_t.hidden,inspect:lt,resolved:U,scrollbar:jt,device:bt});addEventListener("message",t=>{if(t.origin!==location.origin||!t.data?.dt)return;const e=t.data;if(!v&&t.source===w.contentWindow){if(e.key){oo(e.key[0],e.key[1])?.run();return}if(e.closeMenus){Lt();return}if(e.drafts){xe=e.drafts,Nn(Gt());return}}if(v&&typeof e.openDraft=="number"){He(e.openDraft);return}if(v&&typeof e.dropDraft=="number"){Cn(e.dropDraft);return}if(v&&typeof e.device=="string"&&(Un=e.device),v&&e.scrollbar&&document.documentElement.classList.toggle("dt-sb-classic",e.scrollbar==="classic"),e.hello&&t.source===w.contentWindow){D(ts());return}typeof e.notes=="boolean"&&e.notes!==M&&st(e.notes,!1),typeof e.open=="number"&&ke(e.open),typeof e.grid=="boolean"&&e.grid===_t.hidden&&pe(e.grid),typeof e.inspect=="string"&&e.inspect!==lt&&zt(e.inspect),typeof e.resolved=="boolean"&&e.resolved!==U&&Ce(e.resolved),e.reload&&(mt(),ne())});const se=async()=>{await mt(),ne(),D({reload:!0}),v&&parent.postMessage({dt:!0,reload:!0},location.origin)},st=(t,e=!0)=>{if(M=t,an.setAttribute("aria-pressed",String(t)),t?!v&&P.hidden&&localStorage.getItem("dt-history")!=="0"&&(P.hidden=!1,Ut.setAttribute("aria-pressed","true")):(P.hidden=!0,Ut.setAttribute("aria-pressed","false")),_(cn,t?"1":"0"),D({notes:t}),v&&e&&parent.postMessage({dt:!0,notes:t},location.origin),f.hidden=!t||!A.hidden,document.documentElement.classList.toggle("dt-noting",t),t){zt(""),document.addEventListener("click",Kn,!0);for(const n of Pn)document.addEventListener(n,jn,!0);document.addEventListener("keydown",On),document.addEventListener("mousemove",Dn),addEventListener("scroll",ot,!0),addEventListener("resize",ot),In.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),qn.observe(document.body),mt()}else{W(),y=null,document.removeEventListener("click",Kn,!0);for(const n of Pn)document.removeEventListener(n,jn,!0);document.removeEventListener("keydown",On),document.removeEventListener("mousemove",Dn),dt.hidden=!0,removeEventListener("scroll",ot,!0),removeEventListener("resize",ot),In.disconnect(),qn.disconnect(),f.innerHTML=""}},ae="dt-w",Oe="dt-canvas",yt="dt-device";let at=localStorage.getItem(Oe)==="1",$=localStorage.getItem(yt)||"";$&&!Wt($)&&($="",localStorage.setItem(yt,""));let k=Number(localStorage.getItem(ae))||0;const Vn="dt-emu";let O=(()=>{try{return JSON.parse(localStorage.getItem(Vn)||"null")}catch{return null}})();const re=()=>O?co.find(t=>t.id===O.id)??null:null,es=()=>{const t=re();return t?O.turned?{w:t.h,h:t.w}:{w:t.w,h:t.h}:null};let Kt=localStorage.getItem("dt-bars-min")==="1";const vt=t=>{O=t,_(Vn,t?JSON.stringify(t):"")},Pe=t=>{dn.textContent=t,A.style.setProperty("--dt-badge-w",`${dn.offsetWidth}px`)},Yn=t=>{if(!t){xt.innerHTML="";return}let e="";for(let n=0;n<=t;n+=50)e+=`<span class="dt-tick${n%200===0?" is-major":""}" style="left:${n}px"></span>`;for(const n of I)for(const o of[n.min,n.max])o>0&&Number.isFinite(o)&&o<=t&&(e+=`<span class="dt-edge" style="left:${o}px" title="${n.label} edge"></span>`);xt.innerHTML=e,xt.style.width=`${t}px`},je=()=>{const t=parseFloat(E.style.width)||0,e=parseFloat(E.style.height)||0;if(!t||!e){E.style.transform="",delete E.dataset.scaled;return}const n=$||O?Math.min(1,(innerWidth-80)/t,(innerHeight-120)/e):Math.min(1,(innerWidth-80)/t);E.style.transform=n<1?`scale(${n})`:"",E.dataset.scaled=n<1?String(Math.round(n*100)):""},ns=t=>co.find(e=>e.w===t.w&&e.h===t.h&&e.cutout?.shape==="pill")?.cutout,ie=()=>{try{return w.contentDocument}catch{return null}},Jn=()=>ie()?.title.split("\u2014").pop()?.trim()||"",Ke=()=>{const t=ie(),e=$?Wt($):null;if(!t?.body||!e)return;const n=ys(t),o=e.browser==="chrome-android"?n.theme||"rgb(255, 255, 255)":n.top,s=e.browser==="chrome-android"?"rgb(255, 255, 255)":n.bottom;E.style.setProperty("--dt-top",o),E.style.setProperty("--dt-top-ink",uo(o)),E.style.setProperty("--dt-bottom",s),E.style.setProperty("--dt-bottom-ink",uo(s));const r=Tt.querySelector(".dt-win-tab > span");r&&(r.textContent=Jn()||location.host)};let Fe=0;w.addEventListener("load",()=>{ie()&&(Ke(),w.contentWindow?.addEventListener("scroll",()=>{Fe||(Fe=requestAnimationFrame(()=>{Fe=0,Ke()}))},{passive:!0}))});for(const t of[Tt,Vt])t.addEventListener("click",e=>{const n=e.target.closest("[data-nav]")?.dataset.nav;if(n)try{const o=w.contentWindow?.navigation;if(!ie()||!o)throw new Error("foreign");n==="back"?o.canGoBack&&o.back():n==="fwd"?o.canGoForward&&o.forward():o.reload()}catch{(n==="reload"||n==="back")&&(w.src=location.href)}});Mt.addEventListener("click",()=>{Kt=!Kt,_("dt-bars-min",Kt?"1":"0"),Q()});const Q=()=>{if(v)return;const t=$?Wt($)??null:null;if($&&!t&&($="",localStorage.setItem(yt,"")),!t&&!at){A.hidden=!0,w.removeAttribute("src"),document.documentElement.classList.remove("dt-framing"),f.hidden=!M,xt.innerHTML="",At(),ve.hidden=!0,Mt.hidden=!0,X=null,bt="",xe=[],At(),ze(),M?mt():m();return}if(A.hidden=!1,document.documentElement.classList.add("dt-framing"),f.hidden=!0,w.src||(w.src=location.href),t){const e=bs(t,{host:location.host,title:Jn(),now:new Date,min:Kt,cutout:ns(t)}),{screen:n}=e;A.dataset.mode="device",E.dataset.shell=t.shell,E.dataset.browser=t.browser,E.style.width=`${e.footprint.w}px`,E.style.height=`${e.footprint.h}px`,E.style.setProperty("--dt-r",`${n.r}px`),E.style.setProperty("--dt-rb",`${n.rb}px`),rn.innerHTML=e.shell;const o=(c,u,a,l)=>{c.innerHTML=l,c.style.cssText=`left:${n.x}px;top:${u}px;width:${n.w}px;height:${a}px`};o(Tt,n.y,e.topH,e.top),o(Vt,n.y+n.h-e.bottomH,e.bottomH,e.bottom);const s=n.h-e.topH-e.bottomH;w.style.position="absolute",w.style.left=`${n.x}px`,w.style.top=`${n.y+e.topH}px`,w.style.width=`${n.w}px`,w.style.height=`${s}px`,xt.innerHTML="";const r=Kt&&e.canMinimize;jt=e.scrollbar,bt=`${t.label}${r?" \xB7 bars folded":""}`,X=St(t.w),D({notes:M,scrollbar:jt,device:bt}),Mt.hidden=!e.canMinimize,Mt.setAttribute("aria-pressed",String(r)),Pe(`${t.label} \xB7 page ${t.w}\xD7${s} of ${t.w}\xD7${t.h}${r?" \xB7 bars folded":""} \xB7 ${I.find(c=>c.id===X)?.label??""}`),Ke()}else{const e=es();e||vt(null);const n=e?.w||k||I.find(r=>r.id===et()).ideal;k=n,A.dataset.mode="canvas",delete E.dataset.shell,delete E.dataset.browser,rn.innerHTML=Tt.innerHTML=Vt.innerHTML="",Tt.style.cssText=Vt.style.cssText="",Mt.hidden=!0,jt="overlay",E.style.width=`${n}px`,E.style.height=`${e?.h??innerHeight-84}px`,w.style.position="",w.style.left=w.style.top="",w.style.width="100%",w.style.height="100%",Yn(n),D({notes:M});const o=I.find(r=>r.id===St(n)),s=re();bt=s?`${s.label}${O?.turned?" \xB7 landscape":""}`:"",D({scrollbar:jt,device:bt}),Pe(s&&e?`${s.label} \xB7 ${e.w}\xD7${e.h} \xB7 ${o.label}`:`${n}px \xB7 ${o.label}`),X=St(n)}ve.hidden=!(re()?.rotates&&!t),ze(),je(),At(),M?mt():m()},We=t=>{const e=I.find(n=>n.id===t);$="",localStorage.setItem(yt,""),vt(null),at=t!==ce,k=at?e.ideal:0,X=at?t:null,localStorage.setItem(Oe,at?"1":"0"),localStorage.setItem(ae,String(k)),y=null,W(),Q()};for(const t of be)t.addEventListener("click",()=>We(t.dataset.bp));for(const t of document.querySelectorAll("[data-device]"))t.addEventListener("click",()=>{$=t.dataset.device===$?"":t.dataset.device,localStorage.setItem(yt,$),z.open=!1,Q()});for(const t of document.querySelectorAll("[data-emu]"))t.addEventListener("click",()=>{const e=O?.id===t.dataset.emu&&!$;$="",localStorage.setItem(yt,""),vt(e?null:{id:t.dataset.emu,turned:!1}),at=!e,k=0,localStorage.setItem(Oe,at?"1":"0"),X=null,y=null,W(),z.open=!1,Q()});ve.addEventListener("click",()=>{O&&(vt({...O,turned:!O.turned}),y=null,W(),Q())});const Gn=[...z.querySelectorAll("[data-tab]")],os=[...z.querySelectorAll("[data-panel]")],Xn=t=>{for(const e of Gn)e.setAttribute("aria-selected",String(e.dataset.tab===t));for(const e of os)e.hidden=e.dataset.panel!==t;_("dt-devices-tab",t)};for(const t of Gn)t.addEventListener("click",()=>Xn(t.dataset.tab));Xn(localStorage.getItem("dt-devices-tab")==="devtools"?"devtools":"preview");const _e=z.querySelector(".dt-emu-search");_e.addEventListener("input",()=>{const t=_e.value.trim().toLowerCase();let e=null,n=!1;const o=()=>{e&&(e.hidden=!n)};for(const s of _e.parentElement.children){if(s.classList.contains("dt-devices-group")){o(),e=s,n=!1;continue}s.dataset.emu&&(s.hidden=!!t&&!s.textContent.toLowerCase().includes(t),n||=!s.hidden)}o()});const ss=z.querySelector(".dt-devices-name");function ze(){for(const e of z.querySelectorAll("[data-device]"))e.setAttribute("aria-pressed",String(e.dataset.device===$));const t=!$&&!A.hidden?O?.id:void 0;for(const e of z.querySelectorAll("[data-emu]"))e.setAttribute("aria-pressed",String(e.dataset.emu===t));ss.textContent=$&&Wt($)?.label||t&&re()?.label||"Device"}const Ue=t=>I.find(e=>e.id===t),as=t=>{const e=Ue(X??et());return Math.max(e.min||320,Math.min(Number.isFinite(e.max)?e.max:2560,Math.round(t)))};for(const t of yo){const e=t.dataset.edge==="l"?-1:1;t.addEventListener("pointerdown",n=>{if($)return;n.preventDefault(),O&&(vt(null),Q()),t.setPointerCapture(n.pointerId);const o=n.clientX,s=k,r=Number(E.dataset.scaled||100)/100;A.dataset.dragging="1";const c=a=>{k=as(s+e*(a.clientX-o)*2/r),E.style.width=`${k}px`,Yn(k),Pe(`${k}px \xB7 ${Ue(St(k)).label}`),je()},u=()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerup",u),delete A.dataset.dragging,localStorage.setItem(ae,String(k)),Q()};t.addEventListener("pointermove",c),t.addEventListener("pointerup",u)}),t.addEventListener("dblclick",()=>{if($)return;vt(null);const n=Ue(X??et()),o=[n.min||320,Number.isFinite(n.max)?n.max:n.ideal];k=Math.abs(k-o[0])<Math.abs(k-o[1])?o[0]:o[1],localStorage.setItem(ae,String(k)),Q()})}let Zn=et();addEventListener("resize",()=>{At(),et()!==Zn&&(Zn=et(),m()),A.hidden||(!$&&!O&&(E.style.height=`${innerHeight-84}px`),je())});const Qn="dt-studio",to=t=>{ye.setAttribute("aria-pressed",String(t)),document.documentElement.classList.toggle("dt-no-studio",!t),_(Qn,t?"1":"0")};ye.addEventListener("click",()=>to(ye.getAttribute("aria-pressed")!=="true")),to(localStorage.getItem(Qn)!=="0"),an.addEventListener("click",()=>st(!M));const $t=document.querySelector(".devtools"),Ft=document.querySelector(".dt-tab"),eo=t=>{$t.toggleAttribute("data-collapsed",t),Ft.toggleAttribute("data-collapsed",t),Ft.setAttribute("aria-expanded",String(!t)),Ft.setAttribute("aria-label",t?"Show the bar":"Hide the bar");for(const e of $t.querySelectorAll(".dt-group"))e.inert=t;t&&Lt(),_("dt-collapsed",t?"1":"0")};Ft.addEventListener("click",()=>eo(!$t.hasAttribute("data-collapsed")));const Ve=document.querySelector(".dt-keys"),rt=t=>()=>$t.querySelector(t)?.click(),no=t=>()=>{const e=[...document.querySelectorAll(".dt-pages a")];e[e.findIndex(n=>n.hasAttribute("aria-current"))+t]?.click()},le=[{group:"Comments",code:"KeyC",hint:"C",label:"Comment mode",el:".dt-notes-btn",run:rt(".dt-notes-btn")},{group:"Comments",code:"KeyC",shift:!0,hint:"\u21E7C",label:"Comments panel",el:".dt-history-btn",run:rt(".dt-history-btn")},{group:"Comments",code:"KeyR",hint:"R",label:"Show resolved",el:".dt-resolved-btn",run:rt(".dt-resolved-btn")},{group:"Inspect",code:"KeyG",hint:"G",label:"Grid",el:".dt-grid-btn",run:rt(".dt-grid-btn")},{group:"Inspect",code:"KeyP",hint:"P",label:"Spacing",el:".dt-pad-btn",run:rt(".dt-pad-btn")},{group:"Inspect",code:"KeyS",hint:"S",label:"Size",el:".dt-size-btn",run:rt(".dt-size-btn")},{group:"Inspect",code:"KeyT",hint:"T",label:"Typography",el:".dt-type-btn",run:rt(".dt-type-btn")},...b.sanity?[{group:"Inspect",code:"KeyE",hint:"E",label:"Sanity overlay",el:".dt-studio-btn",run:rt(".dt-studio-btn")}]:[],...be.slice(0,9).map((t,e)=>({group:"Breakpoints",code:`Digit${e+1}`,hint:String(e+1),label:t.dataset.tip??t.title,el:`.dt-bp[data-bp="${t.dataset.bp}"]`,run:()=>t.click()})),{group:"View",code:"KeyD",hint:"D",label:"Devices",run:()=>{z.open=!z.open}},{group:"View",code:"BracketLeft",hint:"[",label:"Previous page",run:no(-1)},{group:"View",code:"BracketRight",hint:"]",label:"Next page",run:no(1)},{group:"View",code:"Backslash",hint:"\\",label:"Hide the bar",run:()=>Ft.click()},{group:"View",code:"Slash",shift:!0,hint:"?",label:"This list",el:".dt-keys summary",run:()=>{Ve.open=!Ve.open}}].filter(t=>!b.client||t.group!=="Inspect"),oo=(t,e)=>le.find(n=>n.code===t&&!n.shift==!e),rs=t=>t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)||!!t.closest('[role="menu"], [role="listbox"], [role="dialog"][aria-modal="true"], [role="combobox"]'));if(b.shortcuts){for(const e of le){const n=e.el&&$t.querySelector(e.el);n&&(n.dataset.tip=`${n.dataset.tip??e.label} \xB7 ${e.hint}`,n.setAttribute("aria-keyshortcuts",e.hint.startsWith("\u21E7")?`Shift+${e.hint.slice(1)}`:e.hint))}const t=(e,n)=>`<div class="dt-key-row"><span>${g(e)}</span><kbd>${g(n)}</kbd></div>`;if(Ve.querySelector(".dt-keys-menu").innerHTML='<p class="dt-menu-note">One key, no modifier, in any keyboard layout. Not while you type.</p>'+[...new Set(le.map(e=>e.group))].map(e=>`<p class="dt-devices-group">${e}</p>`+le.filter(n=>n.group===e).map(n=>t(n.label,n.hint)).join("")).join("")+'<p class="dt-devices-group">In a comment</p>'+t("Send","Enter")+t("New line","\u21E7Enter")+t("Close, cancel, back out","Esc"),document.addEventListener("keydown",e=>{if(e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||rs(e.target))return;const n=oo(e.code,e.shiftKey);n&&(e.preventDefault(),v?parent.postMessage({dt:!0,key:[e.code,e.shiftKey]},location.origin):n.run())}),v){const e=()=>parent.postMessage({dt:!0,closeMenus:!0},location.origin);document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n=>{n.key==="Escape"&&e()})}}if(!v){eo(localStorage.getItem("dt-collapsed")==="1"),requestAnimationFrame(()=>requestAnimationFrame(()=>$t.setAttribute("data-ready",""))),at||$?Q():ze(),pe(localStorage.getItem(Qe)==="1");const t=localStorage.getItem(on);t&&t in fe&&zt(t),st(localStorage.getItem(cn)==="1")}const so=()=>{try{const t=JSON.parse(localStorage.getItem(ft)||"null");q=(t?.parked??[]).filter(e=>Yt(e)),t?.draft&&document.querySelector(t.draft.selector)?(d=t.draft,!M&&!v&&st(!0)):Yt(t?.draft)&&q.push(t.draft),t?.reply?.text&&(F=t.reply.text,kt=y=t.reply.for??null),(d||q.length||F)&&m()}catch{localStorage.removeItem(ft)}};so();const ao=()=>setTimeout(()=>{const t=ue(location.pathname);t!==K&&(clearTimeout(Jt),we(),K=t,ft=un(),d=null,q=[],F="",kt=null,y=null,S=null,h=[],en(),so(),mt())});for(const t of["pushState","replaceState"]){const e=window.history[t];window.history[t]=function(...n){e.apply(this,n),ao()}}addEventListener("popstate",ao),M||mt(),ne().then(()=>{te()&&ee()}),document.addEventListener("visibilitychange",()=>{document.hidden||Pt()}),addEventListener("focus",Pt),addEventListener("notemend:changed",()=>{v||Pt()});let is=0;v||setInterval(()=>{(!fs.live||++is%6===0)&&Pt()},2e4),v&&parent.postMessage({dt:!0,hello:!0},location.origin)}export{Is as run};
|
|
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};
|