shapewall 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/agent/package-lock.json +2 -2
  3. package/dist/client/assets/BoardChat-C88k4s-W.js +28 -0
  4. package/dist/client/assets/{BuzzDialog-HWXBy52W.js → BuzzDialog-CZdwIQLF.js} +1 -1
  5. package/dist/client/assets/{ChecksPanel-DTdImWoD.js → ChecksPanel-B54chcLA.js} +1 -1
  6. package/dist/client/assets/{History-CEv6b-av.js → History-CVVuuxUK.js} +1 -1
  7. package/dist/client/assets/LocalSettings-CvlVtNY_.js +1 -0
  8. package/dist/client/assets/{Management-DCfhcEUY.js → Management-DOJkFY_o.js} +1 -1
  9. package/dist/client/assets/QuickConnect-D40mj4Ry.js +1 -0
  10. package/dist/client/assets/{ShareDialog-C_plIto0.js → ShareDialog-CdVAreaw.js} +1 -1
  11. package/dist/client/assets/{app-update-dialog-2hPz_N9G.js → app-update-dialog-Dox9-LWv.js} +1 -1
  12. package/dist/client/assets/{circle-x-BZMPi8Zf.js → circle-x-BmT6vHKl.js} +1 -1
  13. package/dist/client/assets/{index-DweQ8Qtu.js → index-CwvFfwU0.js} +4 -4
  14. package/dist/client/assets/index-UIYSPHoh.css +2 -0
  15. package/dist/client/assets/{refresh-cw-CRow0Nbq.js → refresh-cw-ugt3cWKH.js} +1 -1
  16. package/dist/client/assets/{square-A8EnIYLR.js → square-_KG6tM5A.js} +1 -1
  17. package/dist/client/assets/{ui-CLbws0rx.js → ui-BAGBTB_P.js} +1 -1
  18. package/dist/client/build-info.json +1 -1
  19. package/dist/client/index.html +3 -3
  20. package/dist/client/sw.js +2 -2
  21. package/dist/console/assets/LocalAccountsApp-4MtW1QlZ.js +1 -0
  22. package/dist/console/assets/LocalConsole-CgKqYa8i.js +1 -0
  23. package/dist/console/assets/app-update-dialog-S2Yyc7Pw.js +1 -0
  24. package/dist/console/assets/{console-C7uJLLOn.js → console-BPmBRIoz.js} +3 -3
  25. package/dist/console/assets/console-DgVrGRMD.css +2 -0
  26. package/dist/console/build-info.json +1 -1
  27. package/dist/console/console.html +2 -2
  28. package/docs/agents.md +61 -35
  29. package/docs/design-system.md +10 -7
  30. package/package.json +1 -1
  31. package/src/agent/backends/acp.js +217 -41
  32. package/src/agent/options-cache.js +52 -0
  33. package/src/agent/routes.js +119 -4
  34. package/src/agent/run.js +20 -1
  35. package/src/agent/settings-routes.js +1 -1
  36. package/dist/client/assets/BoardChat-D5SFd8HE.js +0 -28
  37. package/dist/client/assets/LocalSettings-C4vriEVQ.js +0 -1
  38. package/dist/client/assets/QuickConnect-DQGgUsl1.js +0 -1
  39. package/dist/client/assets/index-ByQRKVit.css +0 -2
  40. package/dist/console/assets/LocalAccountsApp-BQCcmj3x.js +0 -1
  41. package/dist/console/assets/LocalConsole-Bb2FUDs7.js +0 -1
  42. package/dist/console/assets/app-update-dialog-DIeYepLZ.js +0 -1
  43. package/dist/console/assets/console-R8IBY3Am.css +0 -2
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app-update-dialog-2hPz_N9G.js","./ui-CLbws0rx.js","./refresh-cw-CRow0Nbq.js","./ChecksPanel-DTdImWoD.js","./square-A8EnIYLR.js","./circle-x-BZMPi8Zf.js","./BoardChat-D5SFd8HE.js","./QuickConnect-DQGgUsl1.js","./History-CEv6b-av.js","./ShareDialog-C_plIto0.js","./LocalSettings-C4vriEVQ.js","./BuzzDialog-HWXBy52W.js","./Management-DCfhcEUY.js"])))=>i.map(i=>d[i]);
2
- import{A as e,At as t,B as n,Bt as r,C as i,Ct as a,D as o,E as s,Et as c,F as l,Ft as u,G as d,Gt as f,H as p,Ht as m,I as h,It as g,J as _,Jt as v,K as y,Kt as b,L as x,Lt as S,M as C,Mt as w,N as T,Nt as E,O as D,Ot as O,P as k,Pt as A,Qt as j,R as M,Rt as N,S as P,St as F,T as ee,Tt as I,U as L,Ut as R,V as z,Vt as B,W as te,Wt as ne,X as re,Xt as ie,Y as ae,Yt as oe,Z as se,_ as ce,_t as V,a as H,at as le,b as ue,bt as de,c as fe,ct as U,d as W,dt as pe,f as me,ft as he,g as ge,gt as _e,h as ve,ht as ye,i as be,it as xe,j as Se,jt as Ce,k as we,kt as Te,l as Ee,lt as De,m as Oe,mt as ke,n as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,qt as Ie,r as Le,rt as Re,s as ze,st as Be,t as Ve,tt as He,u as Ue,ut as We,v as Ge,vt as Ke,w as qe,wt as Je,x as Ye,xt as Xe,y as Ze,yt as Qe,z as $e,zt as et}from"./ui-CLbws0rx.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var tt=ie((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),nt=ie(((e,t)=>{t.exports=tt()})),rt=ie((e=>{var t=nt(),n=oe(),r=v();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var y=null,b=null;function x(e,t,n){return e===n||e===t&&(y=e,!0)}function S(e,t,n){return e===n?(b=e,!1):e===t&&(b!==null&&(y=e),!0)}function C(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function w(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var T=Object.assign,E=Symbol.for(`react.element`),D=Symbol.for(`react.transitional.element`),O=Symbol.for(`react.portal`),k=Symbol.for(`react.fragment`),A=Symbol.for(`react.strict_mode`),j=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),P=Symbol.for(`react.forward_ref`),F=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),I=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),R=Symbol.for(`react.activity`),z=Symbol.for(`react.legacy_hidden`),B=Symbol.for(`react.memo_cache_sentinel`),te=Symbol.for(`react.view_transition`),ne=Symbol.for(`react.recoverable`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case k:return`Fragment`;case j:return`Profiler`;case A:return`StrictMode`;case F:return`Suspense`;case ee:return`SuspenseList`;case R:return`Activity`;case te:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case O:return`Portal`;case N:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case P:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case I:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,V=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ue=[],de=-1;function fe(e){return{current:e}}function U(e){0>de||(e.current=ue[de],ue[de]=null,de--)}function W(e,t){de++,ue[de]=e.current,e.current=t}var pe=fe(null),me=fe(null),he=fe(null),ge=fe(null);function _e(e,t){switch(W(he,t),W(me,e),W(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}U(pe),W(pe,e)}function ve(){U(pe),U(me),U(he)}function ye(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,W(ge,e)),t=pe.current;var n=dp(t,e.type);t!==n&&(W(me,e),W(pe,n))}function be(e){me.current===e&&(U(pe),U(me)),ge.current===e&&(U(ge),sh._currentValue=le)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app-update-dialog-Dox9-LWv.js","./ui-BAGBTB_P.js","./refresh-cw-ugt3cWKH.js","./ChecksPanel-B54chcLA.js","./square-_KG6tM5A.js","./circle-x-BmT6vHKl.js","./BoardChat-C88k4s-W.js","./QuickConnect-D40mj4Ry.js","./History-CVVuuxUK.js","./ShareDialog-CdVAreaw.js","./LocalSettings-CvlVtNY_.js","./BuzzDialog-CZdwIQLF.js","./Management-DOJkFY_o.js"])))=>i.map(i=>d[i]);
2
+ import{A as e,At as t,B as n,Bt as r,C as i,Ct as a,D as o,E as s,Et as c,F as l,Ft as u,G as d,Gt as f,H as p,Ht as m,I as h,It as g,J as _,Jt as v,K as y,Kt as b,L as x,Lt as S,M as C,Mt as w,N as T,Nt as E,O as D,Ot as O,P as k,Pt as A,Qt as j,R as M,Rt as N,S as P,St as F,T as ee,Tt as I,U as L,Ut as R,V as z,Vt as B,W as te,Wt as ne,X as re,Xt as ie,Y as ae,Yt as oe,Z as se,_ as ce,_t as V,a as H,at as le,b as ue,bt as de,c as fe,ct as U,d as W,dt as pe,f as me,ft as he,g as ge,gt as _e,h as ve,ht as ye,i as be,it as xe,j as Se,jt as Ce,k as we,kt as Te,l as Ee,lt as De,m as Oe,mt as ke,n as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,qt as Ie,r as Le,rt as Re,s as ze,st as Be,t as Ve,tt as He,u as Ue,ut as We,v as Ge,vt as Ke,w as qe,wt as Je,x as Ye,xt as Xe,y as Ze,yt as Qe,z as $e,zt as et}from"./ui-BAGBTB_P.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var tt=ie((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),nt=ie(((e,t)=>{t.exports=tt()})),rt=ie((e=>{var t=nt(),n=oe(),r=v();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var y=null,b=null;function x(e,t,n){return e===n||e===t&&(y=e,!0)}function S(e,t,n){return e===n?(b=e,!1):e===t&&(b!==null&&(y=e),!0)}function C(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function w(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var T=Object.assign,E=Symbol.for(`react.element`),D=Symbol.for(`react.transitional.element`),O=Symbol.for(`react.portal`),k=Symbol.for(`react.fragment`),A=Symbol.for(`react.strict_mode`),j=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),P=Symbol.for(`react.forward_ref`),F=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),I=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),R=Symbol.for(`react.activity`),z=Symbol.for(`react.legacy_hidden`),B=Symbol.for(`react.memo_cache_sentinel`),te=Symbol.for(`react.view_transition`),ne=Symbol.for(`react.recoverable`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case k:return`Fragment`;case j:return`Profiler`;case A:return`StrictMode`;case F:return`Suspense`;case ee:return`SuspenseList`;case R:return`Activity`;case te:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case O:return`Portal`;case N:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case P:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case I:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,V=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ue=[],de=-1;function fe(e){return{current:e}}function U(e){0>de||(e.current=ue[de],ue[de]=null,de--)}function W(e,t){de++,ue[de]=e.current,e.current=t}var pe=fe(null),me=fe(null),he=fe(null),ge=fe(null);function _e(e,t){switch(W(he,t),W(me,e),W(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}U(pe),W(pe,e)}function ve(){U(pe),U(me),U(he)}function ye(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,W(ge,e)),t=pe.current;var n=dp(t,e.type);t!==n&&(W(me,e),W(pe,n))}function be(e){me.current===e&&(U(pe),U(me)),ge.current===e&&(U(ge),sh._currentValue=le)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+xe+e+Se}var we=!1;function Te(e,t){if(!e||we)return``;we=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -23,7 +23,7 @@ Error generating stack: `+e.message+`
23
23
  `).map(e=>`> ${e}`.trimEnd()).join(`
24
24
  `);function vS({title:e,threadId:t,messages:n,comment:r=null,boardTitle:i=null,exportedAt:a=new Date}){let o=[`# ${e||gS(t,r)}`,``],s=[i?`Board: ${i}`:null,r?`About comment #${r.id}`:null].filter(Boolean);o.push(`_Exported from Shapewall on ${a.toISOString().slice(0,10)}.${s.length?` ${s.join(`. `)}.`:``}_`,``),r?.body&&o.push(_S(r.body),``);for(let e of n||[]){let t=e.createdAt?` (${String(e.createdAt).slice(0,16).replace(`T`,` `)} UTC)`:``;if(e.role===`user`){o.push(`## You${t}`,``,e.text||`_(images only)_`,``);let n=(e.attachments||[]).map(e=>e.name).filter(Boolean);n.length&&o.push(`Images: ${n.join(`, `)}`,``)}else{o.push(`## Agent${t}`,``);let n=(e.cards||[]).filter(e=>e.label).map(e=>`- ${e.label}${e.detail?`: ${e.detail}`:``}`);n.length&&o.push(`Steps:`,``,...n,``),e.text&&o.push(e.text,``),e.status===`stopped`&&o.push(`_Stopped._`,``),e.error?.message&&o.push(`_Error: ${e.error.message}_`,``)}}return`${o.join(`
25
25
  `).trimEnd()}\n`}function yS(e){return`${String(e||`chat`).toLowerCase().normalize(`NFKD`).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`chat`}.md`}function bS(e){let t=nx(e.id);return t?.state===`waiting`?`waiting`:t?.state===`working`||[`queued`,`working`].includes(e.agentStatus)?`working`:null}function xS({comment:e,onFix:t,onOpenChat:r=null,busy:i,touch:a,className:o}){let s=bS(e),c=(0,G.useContext)(Y_)?.boardId||null,l=!!t&&e.status===`open`,u=Qe(l?`/api/agent/status`:null),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(null);if(!l)return null;if(s)return(0,K.jsxs)(`span`,{className:U(`inline-flex min-w-0 items-center gap-1.5`,o),"data-sw-fix-agent-state":s,children:[(0,K.jsxs)(`span`,{className:U(`inline-flex h-7 min-w-0 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium`,s===`waiting`?`bg-warn/15 text-fg`:`bg-accent/10 text-accent`),role:`status`,children:[s===`waiting`?(0,K.jsx)(Gg,{size:13,className:`shrink-0 text-warn`,"aria-hidden":`true`}):(0,K.jsx)(Gh,{size:13,className:`shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:s===`waiting`?`Agent needs your OK`:`Agent working`})]}),r?(0,K.jsx)(n,{size:a?`touch`:`xs`,variant:s===`waiting`?`default`:`ghost`,onClick:()=>r(e),"data-sw-fix-agent-open":e.id,children:s===`waiting`?`Review`:`View`}):null]});let{name:h,options:g,defaultId:_}=Hx(u.data),v=e.agentStatus===`done`,y=v?`secondary`:`default`,b=a?`touch`:`xs`,x=async n=>{if(m(null),g.length&&c){f(!0);try{let t=Yx(c,nS(e.id)),r=Ux({threadProfile:(await Je.get(t))?.profileId,wanted:n,defaultId:_});r&&await Je.post(`${t}/profile`,{profileId:r})}catch(e){m(e.message);return}finally{f(!1)}}t(e)},S=g.length>0,C=(0,K.jsxs)(n,{size:b,variant:y,className:U(S?`rounded-l-full rounded-r-none pr-2.5 pl-2.5`:`rounded-full pr-3 pl-2.5`,!S&&o),disabled:i||d,onClick:()=>x(`default`),"data-sw-fix-agent":e.id,"data-sw-fix-agent-name":h||void 0,children:[d?(0,K.jsx)(Gh,{size:13,className:`motion-safe:animate-spin`,"aria-hidden":`true`}):(0,K.jsx)(Yg,{size:13,"aria-hidden":`true`}),` `,Wx({again:v,name:h})]}),w=p?(0,K.jsx)(`span`,{className:`min-w-0 text-xs text-bad`,role:`alert`,children:p}):null;return S?(0,K.jsxs)(`span`,{className:U(`inline-flex min-w-0 flex-wrap items-center justify-end gap-1.5`,o),"data-sw-fix-agent-split":e.id,children:[w,(0,K.jsxs)(`span`,{className:`inline-flex min-w-0`,children:[C,(0,K.jsx)(qx,{options:g,value:null,onChoose:e=>x(e===_?`default`:e),heading:`Run this fix once with`,align:`end`,touch:a,children:(0,K.jsx)(n,{size:a?`icon`:`icon-xs`,variant:y,className:U(`rounded-l-none rounded-r-full`,v?`-ml-px`:`border-l border-accent-fg/30`),disabled:i||d,"aria-label":`Fix with another agent`,"data-sw-fix-agent-choose":e.id,children:(0,K.jsx)(R,{size:13,"aria-hidden":`true`})})})]})]}):w?(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 flex-wrap items-center justify-end gap-1.5`,children:[w,C]}):C}var SS=(e,t)=>t?`${e}, ${t}`:e;function CS(e){return e===`viewer`?`Viewers can't reply -- ask an admin for access.`:e===`guest`?`This share link can't reply -- ask the board owner.`:`Replies are off on this board.`}function wS({at:e,editedAt:t}){return(0,K.jsxs)(`span`,{className:`inline-flex shrink-0 items-baseline gap-1 text-xs text-faint`,children:[(0,K.jsx)(p,{content:Py(e),children:(0,K.jsx)(`time`,{dateTime:e,children:De(e)})}),t?(0,K.jsx)(p,{content:`Edited ${Py(t)}`,children:(0,K.jsx)(`span`,{"data-sw-edited":`true`,children:`(edited)`})}):null]})}function TS({author:e,at:t,editedAt:n,children:r,reactions:i,canReact:a,me:o,onReact:s,touch:c,...l}){return(0,K.jsxs)(`li`,{className:`group/message flex gap-2.5 py-2`,...l,children:[(0,K.jsx)(Oy,{...e,size:c?`lg`:`md`,className:`mt-0.5`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-ui`,children:[(0,K.jsx)(Ey,{...e}),(0,K.jsx)(wS,{at:t,editedAt:n})]}),r,(0,K.jsx)(Mx,{reactions:i,canReact:a,me:o,onToggle:s,touch:c})]})]})}function ES({comment:e,busy:t,onSave:r,onCancel:i,touch:a,people:o}){let[s,c]=(0,G.useState)(e.body),l=async t=>{t?.preventDefault();let n=s.trim();if(!n||n===e.body)return i();await r(e,n)&&i()};return(0,K.jsxs)(`form`,{className:`mt-1 space-y-1.5`,onSubmit:l,"data-sw-edit-form":e.id,children:[(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Edit comment `,e.id]}),(0,K.jsx)(Ry,{rows:3,size:a?`touch`:`sm`,value:s,maxLength:yx,onChange:c,people:o,onKeyDown:e=>{bx(e,a)&&(e.preventDefault(),l())},autoFocus:!0})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(n,{size:a?`touch`:`xs`,variant:`ghost`,onClick:i,disabled:t,"data-sw-edit-cancel":e.id,children:`Cancel`}),(0,K.jsx)(n,{size:a?`touch`:`xs`,variant:`default`,type:`submit`,disabled:t||!s.trim(),"data-sw-edit-save":e.id,children:`Save`})]})]})}function DS({comment:e,busy:t,onReply:n,touch:r,people:i,autoFocus:a,askName:o=!1,onSaveName:s=null}){let[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(()=>o&&!pe()),[f,p]=(0,G.useState)(``),m=async r=>{r?.preventDefault();let i=c.trim();if(!i||t)return;let a=u?f.trim():``;a&&(We(a),s?.(a)),await n(e,i)&&(l(``),a&&d(!1))},h=Math.min(6,Math.max(1,c.split(`
26
- `).length));return(0,K.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2 border-t border-line px-3 py-2`,onSubmit:m,"data-sw-reply-form":e.id,children:[u?(0,K.jsxs)(`label`,{className:`flex w-full items-center gap-2 text-xs text-muted`,children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:`Your name`}),(0,K.jsx)(qe,{size:r?`touch`:`xs`,value:f,onChange:e=>p(e.target.value.slice(0,60)),placeholder:`shown on your reply`,className:`flex-1`,"data-sw-reply-author":e.id})]}):null,(0,K.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Reply to comment `,e.id]}),(0,K.jsx)(Ry,{rows:h,size:r?`touch`:`sm`,value:c,maxLength:yx,onChange:l,people:i,className:`resize-none`,placeholder:r?`Reply`:`Reply, @ to mention`,onKeyDown:e=>{bx(e,r)&&(e.preventDefault(),m())},autoFocus:a,"data-sw-reply-input":e.id})]}),(0,K.jsx)(z,{type:`submit`,variant:`default`,size:r?`icon`:`icon-sm`,className:`rounded-full`,disabled:t||!c.trim(),label:`Send reply`,"data-sw-reply-send":e.id,children:(0,K.jsx)(Vm,{size:16,"aria-hidden":`true`})})]})}function OS({comment:t,page:r,title:i,people:a,touch:o,me:s,can:c,busy:l,actions:u,nav:d,beforeAfter:g,onClose:_=null,editingRef:v=null,denial:y=null,role:b=null,hosted:S=null,onSaveName:w=null}){let[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(!1),k=(0,G.useRef)(null);(0,G.useEffect)(()=>{E(!1),O(!1)},[t.id]),v&&(v.current=T?()=>E(!1):null);let A=t.replies?.length||0;(0,G.useEffect)(()=>{let e=k.current;e&&(e.scrollTop=e.scrollHeight)},[t.id,A]);let j=t.status===`resolved`,M=j&&t.agentStatus!==`done`?null:t.agentStatus,N=o?`icon`:`icon-sm`,P=U_(t.viewport,null),F=!!u.onFixAgent&&t.status===`open`,ee=t.reopenCount>0&&!j||!!M,I=t.github?.issue?vy(t.github.issue.url):null,L=[u.onCopyLink?{id:`link`,label:`Copy link`,icon:Uh,run:()=>u.onCopyLink(t),hook:`data-sw-copy-link`}:null,c.edit?{id:`edit`,label:`Edit`,icon:xg,run:()=>E(!0),hook:`data-sw-edit`}:null,u.onAskAgent?{id:`agent`,label:`Ask agent`,icon:f,run:()=>u.onAskAgent(t),hook:`data-sw-ask-agent`}:null,I?{id:`issue`,label:`Open issue #${t.github.issue.number} on GitHub`,icon:Zm,href:I,hook:`data-sw-github-open`}:u.onGithubIssue&&c.resolve?{id:`issue`,label:`Create a GitHub issue`,icon:Zm,run:()=>u.onGithubIssue(t),hook:`data-sw-github-issue`}:null,u.onHistory&&r?{id:`history`,label:`Page history`,icon:Dg,run:()=>u.onHistory(t),hook:`data-sw-comment-history`}:null,r?.url?{id:`page`,label:`Open the page`,icon:dh,href:r.url,hook:`data-sw-open-page`}:null].filter(Boolean);return(0,K.jsxs)(`div`,{className:`flex max-h-[inherit] min-h-0 flex-col`,"data-sw-selected-comment":t.id,"data-sw-thread":t.id,children:[(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-0.5 border-b border-line`,o?`px-2 py-1`:`py-1 pr-1 pl-3`),children:[(0,K.jsx)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-xs text-muted`,"data-sw-thread-title":`true`,children:_?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg tabular`,children:[`#`,t.id]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:i}),P?(0,K.jsx)(p,{content:`${t.viewport[0].toUpperCase()}${t.viewport.slice(1)} capture`,children:(0,K.jsx)(`span`,{className:`inline-flex shrink-0 text-faint`,"aria-label":`${t.viewport} capture`,role:`img`,children:(0,K.jsx)(P,{size:12,"aria-hidden":`true`})})}):(0,K.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`· `,t.viewport]})]}):d?.total>1?(0,K.jsxs)(`span`,{className:`tabular`,children:[d.index+1,` of `,d.total]}):null}),d?.total>1?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(z,{size:N,onClick:d.onPrev,label:SS(`Previous thread`,d.prevNote),tooltip:SS(`Previous thread (Left arrow)`,d.prevNote),"data-sw-thread-prev":`true`,"data-sw-thread-note":d.prevNote||void 0,children:(0,K.jsx)(Ym,{size:16,"aria-hidden":`true`})}),(0,K.jsx)(z,{size:N,onClick:d.onNext,label:SS(`Next thread`,d.nextNote),tooltip:SS(`Next thread (Right arrow)`,d.nextNote),"data-sw-thread-next":`true`,"data-sw-thread-note":d.nextNote||void 0,children:(0,K.jsx)(m,{size:16,"aria-hidden":`true`})})]}):null,c.resolve?(0,K.jsx)(z,{size:N,variant:j?`default`:`ghost`,className:U(`rounded-full`,j&&`bg-ok text-ok-fg hover:bg-ok/90`),disabled:l,"aria-pressed":j,onClick:()=>u.onStatus(t,j?`reopen`:`resolve`),label:j?`Reopen the thread`:`Resolve the thread`,tooltip:j?`Resolved: reopen`:`Resolve`,...j?{"data-sw-reopen":t.id}:{"data-sw-resolve":t.id},children:(0,K.jsx)(ne,{size:16,strokeWidth:2.5,"aria-hidden":`true`})}):j?(0,K.jsxs)(`span`,{className:`mx-1 inline-flex items-center gap-1 rounded-full bg-ok/15 px-2 text-xs leading-6 font-medium text-fg`,children:[(0,K.jsx)(ne,{size:12,"aria-hidden":`true`}),` Resolved`]}):null,L.length||c.delete?(0,K.jsxs)(we,{children:[(0,K.jsx)(p,{content:`More`,children:(0,K.jsx)(x,{asChild:!0,children:(0,K.jsx)(n,{variant:`ghost`,size:N,"aria-label":`More for comment ${t.id}`,"data-sw-thread-menu":t.id,children:(0,K.jsx)(lh,{size:16,"aria-hidden":`true`})})})}),(0,K.jsxs)(e,{align:`end`,children:[L.map(e=>e.href?(0,K.jsx)(C,{asChild:!0,[e.hook]:t.id,children:(0,K.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer noopener`,children:[(0,K.jsx)(e.icon,{size:14,"aria-hidden":`true`}),` `,e.label]})},e.id):(0,K.jsxs)(C,{onSelect:e.run,[e.hook]:t.id,children:[(0,K.jsx)(e.icon,{size:14,"aria-hidden":`true`}),` `,e.label]},e.id)),c.delete?(0,K.jsxs)(K.Fragment,{children:[L.length?(0,K.jsx)(h,{}):null,(0,K.jsxs)(C,{tone:`danger`,onSelect:()=>O(!0),"data-sw-delete":t.id,children:[(0,K.jsx)(a_,{size:14,"aria-hidden":`true`}),` Delete thread`]})]}):null]})]}):null,_?(0,K.jsx)(z,{size:N,onClick:_,label:`Close the thread`,tooltip:`Close (Esc)`,"data-sw-thread-close":`true`,children:(0,K.jsx)(B,{size:16,"aria-hidden":`true`})}):null]}),F||ee?(0,K.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-1.5 border-b border-line px-3 py-1.5`,"data-sw-thread-agent":`true`,children:[(0,K.jsx)(wy,{comment:t}),F&&[`queued`,`working`].includes(M)?null:(0,K.jsx)(Cy,{status:M,at:t.agentStatusAt}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`}),F?(0,K.jsx)(xS,{comment:t,onFix:u.onFixAgent,onOpenChat:u.onAskAgent,busy:l,touch:o}):null]}):null,(0,K.jsxs)(`div`,{ref:k,className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[t.orphanReason?(0,K.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:t.orphanReason}):null,t.imported&&t.agentStatus?(0,K.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:`Imported agent status (history)`}):null,u.onSendToAgent&&t.status===`open`?(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(n,{size:o?`touch`:`sm`,disabled:l||t.dispatchable||t.needsRunApproval&&![`admin`,`owner`].includes(b),onClick:()=>u.onSendToAgent(t),children:t.dispatchable?`Sent to agent`:t.needsRunApproval?[`admin`,`owner`].includes(b)?`Approve agent run`:`Awaiting run approval`:`Send to agent`})}):null,(0,K.jsxs)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Comment ${t.id} and replies`,children:[(0,K.jsxs)(TS,{author:ky(t),at:t.createdAt,editedAt:t.editedAt,reactions:t.reactions,canReact:c.react,me:s,onReact:e=>u.onReact(t,e,null),touch:o,"data-sw-message":`comment`,children:[T?(0,K.jsx)(ES,{comment:t,busy:l,onSave:u.onEdit,onCancel:()=>E(!1),touch:o,people:a}):(0,K.jsx)(Iy,{text:t.body,plain:!!t.authorGuest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}),t.anchor?(0,K.jsx)(p,{content:(0,K.jsx)(`span`,{className:`font-mono text-[11px] break-all`,children:t.anchor.selector}),children:(0,K.jsxs)(`p`,{className:`mt-1.5 inline-flex max-w-full min-w-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[11px] text-muted`,"data-sw-thread-anchor":`true`,tabIndex:0,children:[(0,K.jsx)(ah,{size:11,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`shrink-0`,children:`Pinned to`}),(0,K.jsx)(`span`,{className:`truncate text-fg`,children:Ny(t.anchor)})]})}):null,r?.note?(0,K.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-xs text-faint`,"data-sw-page-note":`true`,children:[(0,K.jsx)(Fh,{size:11,className:`mt-0.5 shrink-0`,"aria-hidden":`true`}),` `,r.note]}):null,t.resolution?(0,K.jsxs)(`p`,{className:`mt-1.5 rounded bg-ok/10 px-2 py-1 text-xs text-fg`,children:[`Fix: `,t.resolution]}):null,(0,K.jsx)(yy,{value:t.fixRef,touch:o}),(0,K.jsx)(xy,{github:t.github,touch:o}),g?(0,K.jsx)(kx,{comment:t,pair:g.pairFor(t),native:g.nativeFor(t),urlFor:g.urlFor,onImageError:g.onImageError,touch:o}):null]}),(t.replies||[]).length?(0,K.jsx)(`li`,{"data-sw-replies":`true`,children:(0,K.jsx)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Replies`,children:t.replies.map(e=>(0,K.jsx)(TS,{author:Ay(e),at:e.createdAt,reactions:e.reactions,canReact:c.react,me:s,onReact:n=>u.onReact(t,n,e.id),touch:o,"data-sw-reply":e.id,children:(0,K.jsx)(Iy,{text:e.body,plain:!!e.guest,className:`block text-ui break-words whitespace-pre-wrap text-fg`})},e.id))})}):null]})]}),D?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-line bg-bad/10 px-3 py-2 text-xs text-fg`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Delete this thread and its replies for good?`}),(0,K.jsx)(n,{size:o?`touch`:`xs`,variant:`ghost`,onClick:()=>O(!1),disabled:l,children:`Cancel`}),(0,K.jsxs)(n,{size:o?`touch`:`xs`,variant:`secondary`,className:`text-bad`,onClick:()=>u.onDelete(t),disabled:l,"data-sw-delete-confirm":t.id,children:[(0,K.jsx)(a_,{size:13,"aria-hidden":`true`}),` Delete`]})]}):null,c.reply?(0,K.jsx)(DS,{comment:t,busy:l,onReply:u.onReply,touch:o,people:a,askName:S===!1,onSaveName:w},t.id):(0,K.jsx)(`p`,{className:`shrink-0 border-t border-line px-3 py-2 text-xs text-muted`,"data-sw-reply-denied":b||`true`,children:y||CS(b)})]})}var kS=`input, textarea, select, [contenteditable="true"]`,AS={top:10,right:10,bottom:60,left:10};function jS(e,t){let n=Wu(),r=(0,G.useRef)(null),i=(0,G.useRef)({selector:e,point:t});return i.current={selector:e,point:t},r.current||={getBoundingClientRect(){let{domNode:e,transform:t}=n.getState(),{selector:r,point:a}=i.current,o=r?e?.querySelector(r):null;if(o)return o.getBoundingClientRect();let s=e?.getBoundingClientRect();if(!s||!a)return new DOMRect(-1e4,-1e4,0,0);let[c,l,u]=t;return new DOMRect(s.left+a.x*u+c,s.top+a.y*u+l,0,0)}},r}function MS(e,t,n){let r=Wu(),[i,a]=(0,G.useState)(`right`);return(0,G.useEffect)(()=>{if(!e)return;let i=()=>{let e=r.getState().domNode?.getBoundingClientRect(),i=t.current.getBoundingClientRect();if(!e)return;let o=(n.current?.offsetWidth||360)+20;a(e.right-i.right>=o?`right`:i.left-e.left>=o?`left`:`bottom`)};i();let o=r.subscribe(i),s=new ResizeObserver(i),c=r.getState().domNode;return c&&s.observe(c),()=>{o(),s.disconnect()}},[e,r,t,n]),i}function NS({open:e,onClose:t,selector:n,point:r,children:i,label:a,onKeyDown:o,onEscape:s,focusContent:c,className:l,...u}){let d=Wu(),f=jS(n,r),p=(0,G.useRef)(null),m=MS(e,f,p);return(0,K.jsxs)(Ze,{open:e,onOpenChange:e=>e?null:t(),children:[(0,K.jsx)(ue,{virtualRef:f}),(0,K.jsx)(Ye,{ref:p,side:m,align:`start`,sideOffset:10,alignOffset:-6,collisionBoundary:d.getState().domNode,collisionPadding:AS,hideWhenDetached:!0,updatePositionStrategy:`always`,"aria-label":a,className:U(`z-30`,l),onOpenAutoFocus:e=>{c&&(e.preventDefault(),p.current?.focus({preventScroll:!0}))},onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>{s?.(e)===!1&&e.preventDefault()},onKeyDown:e=>{p.current?.contains(e.target)&&!e.target?.closest?.(kS)&&o?.(e)},tabIndex:-1,...u,children:i})]})}function PS(e){(document.querySelector(`[data-sw-pin="${CSS.escape(e)}"]`)||[...document.querySelectorAll(`[data-sw-pin-cluster]`)].find(t=>t.getAttribute(`data-sw-pin-cluster`).split(`,`).includes(e)))?.focus({preventScroll:!0})}function FS(e,t,n){e.altKey||e.ctrlKey||e.metaKey||(e.key===`ArrowLeft`||e.key===`ArrowUp`?(e.preventDefault(),t?.()):(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(e.preventDefault(),n?.()))}function IS({comment:e,point:t,onClose:n,onPrev:r,onNext:i,editingRef:a,children:o}){let s=(0,G.useRef)({onPrev:r,onNext:i});return s.current={onPrev:r,onNext:i},(0,G.useEffect)(()=>{let e=e=>{e.defaultPrevented||document.activeElement!==document.body||document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||FS(e,s.current.onPrev,s.current.onNext)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,G.useEffect)(()=>{let t=window.setTimeout(()=>{document.activeElement===document.body&&document.querySelector(`[data-sw-thread-popover="${e.id}"]`)?.focus({preventScroll:!0})},450);return()=>window.clearTimeout(t)},[e.id]),(0,K.jsx)(NS,{open:!0,onClose:n,selector:`[data-sw-pin="${e.id}"]`,point:t,label:`Comment ${e.id}`,focusContent:!0,className:`flex max-h-[min(560px,var(--radix-popover-content-available-height))] w-[360px] flex-col overflow-hidden p-0 outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onEscape:()=>{if(a?.current&&document.activeElement?.closest?.(`[data-sw-edit-form]`))return a.current(),!1;let t=String(e.id);return window.setTimeout(()=>PS(t),0),!0},onKeyDown:e=>FS(e,r,i),"data-sw-thread-popover":e.id,children:o})}function LS({point:e,onClose:t,children:n}){return(0,K.jsx)(NS,{open:!0,onClose:t,selector:`[data-sw-draft-pin]`,point:e,label:`New comment`,className:`w-[340px] p-3`,"data-sw-composer-popover":`true`,children:n})}var RS=600,zS=e=>`shapewall.seen:${typeof window>`u`?``:window.location.pathname}:${e}`;function BS(e){try{let t=JSON.parse(window.localStorage.getItem(zS(e))||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function VS(e,t){try{let n=Object.entries(t).sort((e,t)=>String(t[1]).localeCompare(String(e[1]))).slice(0,RS);window.localStorage.setItem(zS(e),JSON.stringify(Object.fromEntries(n)))}catch{}}function HS(e){let t={at:e.createdAt||``,author:e.author,handle:e.authorHandle||null};for(let n of e.replies||[])String(n.createdAt)>String(t.at)&&(t={at:n.createdAt,author:n.author,handle:n.handle||null});return t}function US(e,t){return t?t.handle&&e.handle?e.handle===t.handle:!!t.name&&String(e.author||``).toLowerCase()===String(t.name).toLowerCase():!1}function WS(e,t,n){let r=HS(e);return!r.at||US(r,n)?!1:!t[e.id]||String(t[e.id])<String(r.at)}function GS(e){let[t,n]=(0,G.useState)(()=>BS(e));(0,G.useEffect)(()=>{n(BS(e));let t=t=>{t.key===zS(e)&&n(BS(e))};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e]);let r=(0,G.useCallback)(t=>{n(n=>{let r=!1,i={...n};for(let e of t){let t=HS(e).at;t&&String(i[e.id]||``)<String(t)&&(i[e.id]=t,r=!0)}return r?(VS(e,i),i):n})},[e]);return{seen:t,markSeen:(0,G.useCallback)(e=>r([e]),[r]),markAllSeen:r}}var KS=[`viewer`,`member`,`admin`,`owner`],qS=(e,t)=>KS.indexOf(e)>=KS.indexOf(t)&&KS.includes(e),JS=({isAuthor:e})=>!!e,YS=({role:e,isAuthor:t})=>qS(e,`member`)&&(!!t||qS(e,`admin`)),XS=`https://shapewall.com/contact`,ZS={version:`0.2.2`,revision:`0466d34bde6c8476e21feb70924c8bf383f357d5`},QS=e=>`v${e?.version||ZS.version}${e?.revision?` · ${e.revision.slice(0,7)}`:``}`,$S=`modulepreload`,eC=function(e,t){return new URL(e,t).href},tC={},nC=function(e){return e.pathname.endsWith(`.css`)},rC=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},iC=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=eC(t,n);let r=s(t),i=nC(r);return rC(tC,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:$S,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},aC=(0,G.lazy)(()=>iC(()=>import(`./app-update-dialog-2hPz_N9G.js`),__vite__mapDeps([0,1,2]),import.meta.url)),oC=`shapewall:open-about`;function sC(e=null){window.dispatchEvent(new CustomEvent(oC,{detail:{opener:e}}))}function cC({transport:e,className:t,placement:r=`menu`,ref:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=e=>{u.current=e||null,c(!0),o(!0)};(0,G.useImperativeHandle)(i,()=>({open:()=>d(document.activeElement)}),[]),(0,G.useEffect)(()=>{let e=e=>d(e.detail?.opener||null);return window.addEventListener(oC,e),()=>window.removeEventListener(oC,e)},[]);let f=()=>o(!1),p=e=>{e.preventDefault(),[u.current,l.current,document.querySelector(`[data-sw-profile-menu]`)].find(e=>e?.isConnected&&e!==document.body)?.focus()},m=`About Shapewall and updates, ${QS(ZS)}, created by Dan Baruch`;return(0,K.jsxs)(K.Fragment,{children:[r===`footer`?(0,K.jsx)(`footer`,{className:U(`flex shrink-0 justify-center border-t border-line bg-surface text-muted`,t),style:{paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`gap-2 rounded-none px-3 text-[10px] font-normal lg:h-6`,onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`footer`,ref:l,children:[(0,K.jsx)(`span`,{children:`Created by Dan Baruch`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{"data-sw-app-version":!0,children:QS(ZS)})]})}):r===`link`?(0,K.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,K.jsx)(n,{asChild:!0,variant:`ghost`,size:`touch`,className:`px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,"data-sw-app-contact":`link`,children:(0,K.jsx)(`a`,{href:XS,target:`_blank`,rel:`noopener noreferrer`,children:`Contact`})}),(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:U(`gap-1.5 px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,t),onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`link`,ref:l,children:[(0,K.jsx)(`span`,{children:`About Shapewall`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`span`,{className:`tabular-nums`,"data-sw-app-version":!0,children:[`v`,ZS.version]})]})]}):null,s?(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Opening About & Updates…`}),children:(0,K.jsx)(aC,{open:a,onClose:f,onCloseAutoFocus:p,transport:e})}):null]})}function lC({demo:t,className:n,children:r,align:i=`start`}){return t.viewAs?(0,K.jsxs)(we,{children:[(0,K.jsx)(x,{asChild:!0,children:r}),(0,K.jsxs)(e,{align:i,className:U(`w-64`,n),children:[(0,K.jsx)(T,{children:`View as (demo)`}),(0,K.jsx)(k,{value:t.viewAs.value,onValueChange:t.viewAs.onChange,children:t.viewAs.options.map(e=>(0,K.jsxs)(l,{value:e.id,"data-sw-view-as":e.id,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,K.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]})]}):r}var uC=()=>(0,K.jsxs)(`span`,{className:`inline-flex h-5 shrink-0 items-center gap-1.5 rounded-full bg-accent/12 px-2 text-caption font-semibold text-accent`,children:[(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),`Demo`]});function dC({variant:e=`strip`,className:t}){let r=E();return r?e===`chip`?(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-0.5 rounded-full border border-line bg-surface-2/60 p-0.5`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":r.role,children:[(0,K.jsx)(lC,{demo:r,align:`end`,children:(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`h-11 gap-1.5 rounded-full px-2 text-ui text-fg lg:h-8`,"aria-label":`Demo, viewing as `+r.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,K.jsx)(uC,{}),(0,K.jsx)(`span`,{className:`hidden max-w-28 truncate font-medium sm:inline`,children:r.roleLabel}),(0,K.jsx)(R,{size:13,className:`text-faint`,"aria-hidden":`true`})]})}),(0,K.jsx)(z,{label:`Reset the demo`,size:`icon`,className:`rounded-full text-muted max-lg:hidden lg:h-8 lg:w-8`,onClick:r.reset,"data-sw-demo-reset":!0,children:(0,K.jsx)(kg,{size:14,"aria-hidden":`true`})}),(0,K.jsx)(fC,{})]}):(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-2 border-b border-line bg-surface px-2 text-ui text-muted sm:px-3 lg:h-9`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":r.role,children:[(0,K.jsx)(uC,{}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`hidden shrink-0 sm:inline`,children:`Viewing as`}),(0,K.jsx)(lC,{demo:r,children:(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`min-w-0 gap-1 px-1.5 text-ui text-fg lg:h-7`,"aria-label":`Viewing as `+r.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,K.jsx)(`span`,{className:`truncate font-semibold`,children:r.roleLabel}),(0,K.jsxs)(`span`,{className:`hidden truncate font-normal text-muted sm:inline`,children:[`(`,r.personaName,`)`]}),(0,K.jsx)(R,{size:13,className:`shrink-0 text-faint`,"aria-hidden":`true`})]})}),(0,K.jsx)(`span`,{className:`hidden truncate text-faint md:inline`,children:`· Changes stay in this browser`})]}),(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`shrink-0 gap-1.5 px-2 text-ui text-muted lg:h-7`,onClick:r.reset,"data-sw-demo-reset":!0,children:[(0,K.jsx)(kg,{size:13,"aria-hidden":`true`}),` Reset`]}),(0,K.jsx)(fC,{})]}):null}function fC(){let e=E();return e?(0,K.jsx)(M,{open:!!e.resetAsked,onClose:e.cancelReset,title:`Reset the demo?`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:`touch`,variant:`ghost`,onClick:e.cancelReset,className:`lg:h-10`,"data-sw-demo-reset-cancel":!0,children:`Cancel`}),(0,K.jsxs)(n,{size:`touch`,className:`border-bad/50 bg-bad text-bad-fg hover:bg-bad/90 lg:h-10`,onClick:e.resetNow,"data-sw-demo-reset-confirm":!0,children:[(0,K.jsx)(kg,{size:14,"aria-hidden":`true`}),` Reset`]})]}),children:(0,K.jsx)(`p`,{className:`px-5 py-4 text-sm text-muted`,children:`Your comments, invites and changes in this browser go back to the start.`})}):null}var pC={unknown:{title:`This share link is not valid`,text:`Check that you have the whole link, or ask whoever shared it for a new one.`},revoked:{title:`This share link was revoked`,text:`Whoever shared it turned it off. Ask them for a new link.`},expired:{title:`This share link has expired`,text:`Share links work for a set time. Ask whoever shared it for a new one.`},off:{title:`This share link is turned off`,text:`The workspace no longer allows share links, or the person who made it can no longer share. Ask them for a new link.`}};function mC({problem:e,onLeave:t}){let r=pC[e?.status]||pC.unknown,i=e?.at?new Date(e.at):null;return(0,K.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,K.jsx)(dC,{}),(0,K.jsx)(`main`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,K.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-line bg-surface p-6 text-center shadow-card sm:p-8`,role:`alert`,"data-sw-share-problem":e?.status||`unknown`,children:[(0,K.jsx)(`span`,{className:`inline-flex h-11 w-11 items-center justify-center rounded-xl bg-bad/10 text-bad`,children:(0,K.jsx)(Vh,{size:20,"aria-hidden":`true`})}),(0,K.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:r.title}),(0,K.jsxs)(`p`,{className:`mt-2 text-sm text-muted`,children:[r.text,i&&Number.isFinite(i.getTime())?(0,K.jsxs)(K.Fragment,{children:[` `,e.status===`revoked`?`Revoked`:`Expired`,` `,i.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`.`]}):null]}),(0,K.jsx)(`p`,{className:`mt-4 text-xs text-muted`,children:`In the demo, share links are made on a project's page in the console.`}),(0,K.jsx)(n,{size:`touch`,variant:`default`,className:`mt-5 lg:h-10`,onClick:t,"data-sw-share-problem-leave":!0,children:`Open the demo board`})]})})]})}async function hC(e,n,r){let i;try{i=await fetch(n,{method:e,credentials:`same-origin`,headers:{...r===void 0?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`},...typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-accounts"]`)&&n.startsWith(`/auth/`)?t():{}},body:r===void 0?void 0:JSON.stringify(r),cache:`no-store`})}catch{throw new Xe(0,`offline`,`Could not reach the server. Check your connection and try again.`)}let a=null;try{a=await i.json()}catch{a=null}if(!i.ok){let e=Number(i.headers.get(`Retry-After`)),t=a?.error?.message||`Request failed (${i.status})`;throw new Xe(i.status,a?.error?.code||`error`,i.status===429&&e>0?_C(t,e):t,{retryAfter:i.status===429&&e>0?e:null})}return a}function gC(e){return e>=5400?`${Math.ceil(e/3600)} hours`:e>=90?`${Math.ceil(e/60)} minutes`:e>60?`2 minutes`:e===1?`1 second`:`${e} seconds`}var _C=(e,t)=>`${e.replace(/\s*Wait (a while|a moment) and try again\.?\s*$/i,``)} Try again in ${gC(t)}.`,vC={get:e=>hC(`GET`,e),post:(e,t={})=>hC(`POST`,e,t),patch:(e,t={})=>hC(`PATCH`,e,t),put:(e,t={})=>hC(`PUT`,e,t),delete:(e,t)=>hC(`DELETE`,e,t)},yC=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t+`===`.slice((t.length+3)%4));return Uint8Array.from(n,e=>e.charCodeAt(0)).buffer},bC=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function xC(e,{mediation:t,signal:n}={}){let r={...e,challenge:yC(e.challenge),allowCredentials:(e.allowCredentials||[]).map(e=>({...e,id:yC(e.id)}))},i=await navigator.credentials.get({publicKey:r,...t?{mediation:t}:{},...n?{signal:n}:{}}),a=i.response;return{id:i.id,rawId:bC(i.rawId),type:i.type,authenticatorAttachment:i.authenticatorAttachment||void 0,clientExtensionResults:i.getClientExtensionResults(),response:{clientDataJSON:bC(a.clientDataJSON),authenticatorData:bC(a.authenticatorData),signature:bC(a.signature),userHandle:a.userHandle?bC(a.userHandle):void 0}}}async function SC(){let{options:e}=await vC.post(`/auth/reauth/options`,{}),t=await xC(e);await vC.post(`/auth/reauth/verify`,{response:t})}function CC({boardId:e}){let[t,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),u=`/api/boards/${encodeURIComponent(e)}/approvals`;(0,G.useEffect)(()=>{let t=!0,n=()=>Je.get(`/api/boards/${encodeURIComponent(e)}/agent-budget`).then(e=>{t&&a(e)}).catch(()=>{}),i=()=>Je.get(u).then(e=>{t&&r(e.approvals)}).catch(()=>{});i(),n();let o=()=>{document.visibilityState===`visible`&&(i(),n())},s=setInterval(o,3e3);return document.addEventListener(`visibilitychange`,o),()=>{t=!1,clearInterval(s),document.removeEventListener(`visibilitychange`,o)}},[u,e]);let d=async(e,t)=>{l(!0),s(null);try{await SC(),await Je.post(`${u}/${e.id}`,{state:t,hash:e.command_hash}),r(t=>t.filter(t=>t.id!==e.id))}catch(e){s(e.message)}finally{l(!1)}};return!t.length&&!o&&!i?.exhausted?null:(0,K.jsxs)(`section`,{"aria-label":`Agent command approvals`,className:`max-h-64 shrink-0 overflow-auto border-b border-line bg-surface p-3 text-sm`,children:[i?.exhausted?(0,K.jsxs)(`p`,{role:`status`,className:`pb-2`,children:[`The agent hit today’s limit: `,i.claims,`/`,i.dailyLimit,` runs, `,i.open,`/`,i.openLimit,` in progress. Change limits in Agent policy in the console.`]}):null,t.map(e=>(0,K.jsxs)(`article`,{className:`space-y-2 pb-3`,children:[(0,K.jsxs)(`p`,{className:`font-semibold`,children:[`Agent asks to run a command for comment #`,e.comment_number]}),(0,K.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words rounded bg-surface-2 p-2`,children:e.command.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}),(0,K.jsx)(`p`,{children:e.reason}),(0,K.jsx)(n,{size:`touch`,variant:`default`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`approved`),children:`Approve once with passkey`}),` `,(0,K.jsx)(n,{size:`touch`,variant:`danger`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`denied`),children:`Deny`})]},e.id)),o?(0,K.jsx)(`p`,{role:`alert`,className:`text-bad`,children:o}):null]})}var wC={share:{title:`This link was revoked`,body:`Or it expired. The board stops updating and you cannot comment. Ask whoever shared it for a new link.`,href:null},signed_out:{title:`You were signed out`,body:`Sign in again to keep working on this board.`,href:`signin`},removed:{title:`You don't have access to this board any more`,body:`You may have been removed from the workspace. Ask an admin to invite you again.`,href:`home`}};function TC(){let[e,t]=(0,G.useState)(null);if((0,G.useEffect)(()=>{let e=e=>t(t=>t||e.detail?.kind||null);return window.addEventListener(de,e),()=>window.removeEventListener(de,e)},[]),!e)return null;let n=wC[e],r=encodeURIComponent(window.location.pathname+window.location.search);return(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-bad/30 bg-bad/10 px-4 py-2 text-sm text-fg`,role:`alert`,"data-sw-access-lost":e,children:[e===`share`?(0,K.jsx)(Vh,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}):(0,K.jsx)(Yh,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`font-medium`,children:n.title}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:n.body}),n.href===`signin`?(0,K.jsx)(`a`,{href:`/signin?next=${r}`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Sign in`}):n.href===`home`?(0,K.jsx)(`a`,{href:`/`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Your workspaces`}):null]})}var EC=`You're a viewer. Ask an admin for member access to comment.`;function DC({compact:e=!1}){return(0,K.jsx)(p,{content:EC,side:`bottom`,children:(0,K.jsxs)(`span`,{role:`note`,tabIndex:0,"aria-label":EC,className:U(`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface-2 text-xs font-medium whitespace-nowrap text-muted outline-none focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11 px-2.5`:`h-8 px-2.5`),"data-sw-viewer-note":!0,children:[(0,K.jsx)(ph,{size:14,"aria-hidden":`true`}),` Viewer`]})})}function OC({project:e}){return(0,K.jsx)(p,{content:`Back to ${e.name}`,side:`bottom`,align:`start`,children:(0,K.jsx)(`a`,{href:e.url,className:`block max-w-full min-w-0 truncate rounded-sm px-2.5 text-[11px] leading-3.5 font-medium text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-project-crumb":!0,children:e.name})})}var kC={includes:e=>typeof e==`string`&&(e===`all`||/^[a-z][a-z0-9-]{0,31}$/.test(e))};function AC({enabled:e,boardId:t,canvasRef:n,flow:r,selection:i,mode:a,onMode:o,onInvalidate:s}){let[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)(0),[f,p]=(0,G.useState)(`offline`),[m,h]=(0,G.useState)(null),g=(0,G.useRef)({cursor:null});g.current={...g.current,selection:i,mode:a,onMode:o,onInvalidate:s};let _=(0,G.useRef)(null);return $p({onChange:e?()=>_.current?.():void 0}),(0,G.useEffect)(()=>{_.current?.()},[i,a]),(0,G.useEffect)(()=>{if(!e){l([]),d(0),h(null);return}let i=!1,a;return iC(async()=>{let{connectPresence:e}=await import(`./runtime-Bft6x_6E.js`);return{connectPresence:e}},[],import.meta.url).then(({connectPresence:e})=>{i||(a=e({boardId:t,canvasRef:n,flow:r,latest:g,sendRef:_,setPeers:l,setCount:d,setFollowing:h,setStatus:p}))}).catch(()=>{i||p(`offline`)}),()=>{i=!0,a?.()}},[e,t,n,r]),(0,G.useEffect)(()=>{if(m===null)return;let e=c.find(e=>e.id===m);if(!e){h(null);return}let t=e.viewport;if(!t||![t.x,t.y,t.zoom].every(Number.isFinite)||!kC.includes(e.mode))return;g.current.mode!==e.mode&&g.current.onMode?.(e.mode);let n=window.requestAnimationFrame(()=>{let e=r.getViewport();(Math.abs(e.x-t.x)>.01||Math.abs(e.y-t.y)>.01||Math.abs(e.zoom-t.zoom)>.001)&&r.setViewport(t,{duration:0})});return()=>window.cancelAnimationFrame(n)},[m,c,r]),{peers:c,count:u,status:f,following:m,follow:h,stopFollowing:()=>h(null)}}function jC({touch:e,...t}){let n=AC(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(FC,{presence:n}),(0,K.jsx)(PC,{presence:n,touch:e})]})}var MC=e=>`${e.id}|${e.name}|${e.color}|${+!!e.viewport}`;function NC(e,t){let n=e.presence,r=t.presence;return e.touch===t.touch&&n.status===r.status&&n.count===r.count&&n.following===r.following&&n.peers.length===r.peers.length&&n.peers.every((e,t)=>MC(e)===MC(r.peers[t]))}var PC=(0,G.memo)(function({presence:e,touch:t}){if(e.status!==`online`)return null;let r=e.peers.find(t=>t.id===e.following);return(0,K.jsxs)(`div`,{className:`absolute top-14 right-2 z-30 flex max-w-[calc(100%-1rem)] flex-wrap items-center justify-end gap-1 rounded-xl border border-line bg-surface/95 p-1 shadow-pop`,"aria-label":`Who is viewing`,"data-sw-presence":`true`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 text-xs text-muted`,"data-sw-presence-count":e.count,children:[(0,K.jsx)(p_,{size:13,"aria-hidden":`true`}),e.count,` viewing`]}),e.peers.slice(0,5).map(r=>(0,K.jsx)(p,{content:`${r.name}${r.viewport?`: follow their view`:``}`,children:(0,K.jsx)(n,{size:t?`icon`:`icon-sm`,variant:e.following===r.id?`default`:`ghost`,"aria-label":`Follow ${r.name}`,"aria-pressed":e.following===r.id,disabled:!r.viewport,"data-sw-presence-peer":r.id,onClick:()=>e.follow(e.following===r.id?null:r.id),children:(0,K.jsx)(le,{person:!0,name:r.name,color:r.color,size:`sm`})})},r.id)),e.peers.length>5?(0,K.jsxs)(`span`,{className:`px-1 text-xs text-muted`,children:[`+`,e.peers.length-5]}):null,r?(0,K.jsxs)(n,{size:t?`touch`:`xs`,variant:`secondary`,onClick:e.stopFollowing,"data-sw-stop-follow":`true`,children:[`Stop following `,r.name]}):null]})},NC);function FC({presence:e}){let t=e.peers.filter(e=>e.cursor&&Number.isFinite(e.cursor.x)&&Number.isFinite(e.cursor.y));return(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-20 overflow-hidden`,"aria-hidden":`true`,"data-sw-presence-cursors":`true`,children:t.length?(0,K.jsx)(IC,{peers:t}):null})}function IC({peers:e}){let{x:t,y:n,zoom:r}=Zp();return e.map(e=>(0,K.jsxs)(`div`,{className:`absolute top-0 left-0`,style:{transform:`translate(${e.cursor.x*r+t}px, ${e.cursor.y*r+n}px)`,color:e.color},"data-sw-presence-cursor":e.id,"data-sw-cursor-x":e.cursor.x,"data-sw-cursor-y":e.cursor.y,children:[(0,K.jsx)(hg,{size:18,fill:`currentColor`,stroke:`white`,strokeWidth:1.5}),(0,K.jsx)(`span`,{className:`ml-3 block max-w-36 truncate rounded px-1.5 py-0.5 text-[10px] text-white shadow-sm`,style:{background:e.color},children:e.name})]},e.id))}var LC=`shapewall.appearance`,RC=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],zC=[{id:`default`,label:`Default`},{id:`ocean`,label:`Ocean`},{id:`forest`,label:`Forest`},{id:`contrast`,label:`High contrast`}],BC={mode:`system`,theme:`default`};function VC(e){return{mode:RC.some(t=>t.id===e?.mode)?e.mode:BC.mode,theme:zC.some(t=>t.id===e?.theme)?e.theme:BC.theme}}var HC=(e,t)=>e===`system`?t?`dark`:`light`:e,UC=typeof window<`u`,WC=()=>UC&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null;function GC(){try{return VC(JSON.parse(window.localStorage.getItem(`shapewall.appearance`)||`null`))}catch{return{...BC}}}var KC=UC?GC():{...BC},qC=new Set;function JC(){let e=getComputedStyle(document.documentElement).getPropertyValue(`--surface`).trim();if(e)for(let t of document.querySelectorAll(`meta[name="theme-color"]`))t.removeAttribute(`media`),t.setAttribute(`content`,e)}function YC(e=KC){if(!UC)return;let t=document.documentElement;t.setAttribute(`data-mode`,HC(e.mode,!!WC()?.matches)),t.setAttribute(`data-theme`,e.theme),JC()}function XC(){return KC}function ZC(e){KC=VC({...KC,...e});try{window.localStorage.setItem(LC,JSON.stringify(KC))}catch{}YC(),qC.forEach(e=>e())}UC&&(YC(),WC()?.addEventListener?.(`change`,()=>{KC.mode===`system`&&(YC(),qC.forEach(e=>e()))}),window.addEventListener(`storage`,e=>{e.key===`shapewall.appearance`&&(KC=GC(),YC(),qC.forEach(e=>e()))}));var QC=e=>(qC.add(e),()=>qC.delete(e));function $C(){return[(0,G.useSyncExternalStore)(QC,XC,XC),ZC]}var ew=()=>UC?HC(KC.mode,!!WC()?.matches):`light`;function tw(){return(0,G.useSyncExternalStore)(QC,ew,ew)}var nw=`shapewall.demo.try`;function rw(){try{return window.localStorage.getItem(nw)===`1`}catch{return!1}}function iw(e){let[t,n]=(0,G.useState)(()=>e&&!rw());return[e&&t,()=>{n(!1);try{window.localStorage.setItem(nw,`1`)}catch{}}]}function aw({touch:e,done:t,onOpenComment:r,onComment:i,onAgent:a,onClose:o}){let[s,c]=(0,G.useState)(!0),l=[{id:`open`,icon:ag,label:`Open a comment`,hint:e?`Tap a pin on a page`:`Click a pin on a page`,run:r},i&&{id:`comment`,icon:rg,label:e?`Pin your own comment`:`Press C to comment`,hint:e?`The comment button, then a page`:`Then click anywhere on a page`,run:i},a?{id:`agent`,icon:f,label:`Ask the agent`,hint:e?`In the ... menu`:`It reads the open comments`,run:a}:null].filter(Boolean),u=l.filter(e=>t.has(e.id)).length,d=e?`bottom-16 left-2`:`bottom-16 left-3`;return s?(0,K.jsxs)(`button`,{type:`button`,className:U(`pointer-events-auto absolute z-30 inline-flex items-center gap-2 rounded-full border border-line bg-surface/95 pr-3 pl-2 text-[13px] font-medium text-fg shadow-pop backdrop-blur outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11`:`h-9`,d),onClick:()=>c(!1),"aria-expanded":`false`,"aria-label":`Try this: ${u} of ${l.length} done. Show the tips`,"data-sw-try-this":`folded`,children:[(0,K.jsx)(Yg,{size:15,className:`text-accent`,"aria-hidden":`true`}),` Try this`,(0,K.jsxs)(`span`,{className:`tabular text-xs text-muted`,children:[u,`/`,l.length]})]}):(0,K.jsxs)(`section`,{className:U(`pointer-events-auto absolute z-30 animate-pop-in rounded-xl border border-line bg-surface/95 p-3 text-fg shadow-pop backdrop-blur`,e?`inset-x-2 bottom-16`:`bottom-16 left-3 w-72`),"aria-label":`Try this`,"data-sw-try-this":`true`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,K.jsx)(Yg,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,K.jsxs)(`h2`,{className:`min-w-0 flex-1 text-sm font-semibold`,children:[`Try this`,` `,(0,K.jsxs)(`span`,{className:`tabular text-xs font-medium text-muted`,children:[u,`/`,l.length]})]}),(0,K.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:()=>c(!0),label:`Fold the tips away`,"aria-expanded":`true`,"data-sw-try-fold":`true`,children:(0,K.jsx)(R,{size:14,"aria-hidden":`true`})}),(0,K.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:o,label:`Close the tips for good`,"data-sw-try-close":`true`,children:(0,K.jsx)(B,{size:14,"aria-hidden":`true`})})]}),(0,K.jsx)(`ol`,{className:`flex flex-col gap-1`,children:l.map(r=>{let i=t.has(r.id),a=i?ne:r.icon;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(n,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:r.run,"data-sw-try-step":r.id,"data-sw-try-done":i?`true`:void 0,children:[(0,K.jsx)(`span`,{className:U(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-ok/15 text-ok`:`bg-accent/10 text-accent`),"aria-hidden":`true`,children:(0,K.jsx)(a,{size:13})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:U(`block text-[13px] font-medium text-fg`,i&&`text-muted line-through decoration-faint`),children:r.label}),(0,K.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:r.hint})]})]})},r.id)})}),(0,K.jsx)(`p`,{className:`mt-2 border-t border-line px-2 pt-2 text-xs text-muted`,"data-sw-try-nav":`true`,children:e?`Drag to move around, pinch to zoom.`:`Scroll to move, Ctrl+scroll or pinch to zoom, Space+drag to pan.`})]})}var ow=new Map,sw=10;function cw(e,t,n,r){let i=n*t*4;for(let n=0;n<t;n+=1){let t=i+n*4;if(Math.abs(e[t]-r[0])>sw||Math.abs(e[t+1]-r[1])>sw||Math.abs(e[t+2]-r[2])>sw)return!0}return!1}function lw(e,t,n){if(!t||!n)return 1;let r=(n-1)*t*4,i=[e[r],e[r+1],e[r+2]];for(let r=n-1;r>=0;--r)if(cw(e,t,r,i))return Math.min(1,(r+1)/n);return 1}function uw(e){if(!e||typeof document>`u`)return Promise.resolve(1);if(ow.has(e))return ow.get(e);let t=new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=Math.min(n.naturalWidth,200),r=Math.round(n.naturalHeight*e/n.naturalWidth),i=document.createElement(`canvas`);i.width=e,i.height=r;let a=i.getContext(`2d`,{willReadFrequently:!0});a.drawImage(n,0,0,e,r),t(lw(a.getImageData(0,0,e,r).data,e,r))}catch{t(1)}},n.onerror=()=>t(1),n.src=e});return ow.set(e,t),t}var dw=()=>typeof window<`u`&&!!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,fw=e=>dw()?0:e,pw=()=>dw()?`auto`:`smooth`,mw=.02,hw={padding:.16};function gw(e,t,n,r=92){if(!t?.width||!t?.height)return e;let i=Math.min(t.width/e.width,t.height/e.height)/(1+2*n),a=r/Math.max(i,.01);return{...e,y:e.y-a,height:e.height+a}}function _w(e){let t=String(e||``).split(`,`).map(Number);return t.length!==3||t.some(e=>!Number.isFinite(e))||t[2]<=0?null:{x:t[0],y:t[1],zoom:t[2]}}function vw(e,t,n,{phoneCompare:r,shotUrls:i}){let a=t.frames[0];if(r&&a&&n?.width){let r=Math.min(4,(n.width-16)/t.w);e.setViewport({x:8-t.x*r,y:70-(t.y+a.y)*r,zoom:r},{duration:fw(450)});return}let o=r=>e.fitBounds(gw({x:t.x,y:t.y,width:t.w,height:Math.min(t.h,(a?a.y+a.h*r:t.h)+16)},n,.12),{padding:.12,duration:fw(450)});!a||!i.length?o(1):Promise.all(i.map(e=>uw(e))).then(e=>o(Math.max(.2,...e))).catch(()=>o(1))}function yw(e,t,n,r=24){let i=n.map(n=>e.x+t.x+t.w*n.spot.x/100),a=n.map(n=>e.y+t.y+t.h*n.spot.y/100);return{x:Math.min(...i)-r,y:Math.min(...a)-r,width:Math.max(...i)-Math.min(...i)+r*2,height:Math.max(...a)-Math.min(...a)+r*2}}var bw=.34,xw=12,Sw=.75,Cw=72,ww=40;function Tw(e,t,n=hw.padding){if(!t?.width||!t?.height||!e?.length)return null;let r=e.filter(e=>e.type===`groupFrame`),i=Ew(r.length?r:e);if(!i)return null;let a=Math.min(t.width/(i.width*(1+2*n)),t.height/(i.height*(1+2*n))),o=e.filter(e=>e.type!==`groupFrame`).length;if(a>=.34||!r.length||o<=xw)return null;let s=[...r].sort((e,t)=>e.position.y-t.position.y||e.position.x-t.position.x)[0],c=s.width??s.style?.width??0,l=s.height??s.style?.height??0,u=Math.min((t.width-80)/c,(t.height-Cw-24)/l),d=Math.max(a,bw,Math.min(Sw,u));return{x:ww-s.position.x*d,y:Cw-s.position.y*d,zoom:d}}function Ew(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=a.width??a.style?.width??0,o=a.height??a.style?.height??0;t=Math.min(t,a.position.x),n=Math.min(n,a.position.y),r=Math.max(r,a.position.x+e),i=Math.max(i,a.position.y+o)}return Number.isFinite(t)?{x:t,y:n,width:r-t,height:i-n}:null}function Dw(e){let t=Wu(),[n,r]=(0,G.useState)(null),i=(0,G.useRef)(null),a=(0,G.useCallback)(e=>{i.current=e,r(e)},[]);return(0,G.useEffect)(()=>{if(!e)return;let n=null,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>a(t.getState().transform[2]),300)};r();let o=t.getState().transform[2],s=t.subscribe(e=>{let t=e.transform[2];t!==o&&(o=t,i.current!==null&&t<i.current*.8&&a(t),r())});return()=>{window.clearTimeout(n),s()}},[e,a,t]),[n,a]}var Ow=`shapewall.minimap`;function kw(){try{let e=window.localStorage.getItem(Ow);return e===`on`||e!==`off`&&null}catch{return null}}function Aw(e){return e>=30}var jw=`shapewall.tip.board`;function Mw(){try{return window.localStorage.getItem(jw)===`1`}catch{return!1}}function Nw(e){try{window.localStorage.setItem(Ow,e?`on`:`off`)}catch{}}function Pw(){try{window.localStorage.setItem(jw,`1`)}catch{}}var Fw=`shapewall.rail.`;function Iw(e){try{let t=Number(window.localStorage.getItem(Fw+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}}function Lw(e,t){try{t==null?window.localStorage.removeItem(Fw+e):window.localStorage.setItem(Fw+e,String(Math.round(t)))}catch{}}var Rw=8;function zw({groups:e,onPick:t}){let[r,i]=(0,G.useState)(``),a=r.trim().toLowerCase(),o=e.flatMap(e=>e.pages.map(t=>({...t,group:e.group}))),s=a?o.filter(e=>`${e.title} ${e.path||``} ${e.group}`.toLowerCase().includes(a)):o.slice(0,Rw);return(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-page-finder":`true`,children:[(0,K.jsx)(qe,{size:`touch`,icon:Lg,value:r,onChange:e=>i(e.target.value.slice(0,80)),placeholder:`Search ${o.length} pages`,"aria-label":`Search pages`,"data-sw-page-search":`true`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(n,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>t(e.id),"data-sw-page-pick":e.id,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:e.group})]})},e.id))}),s.length?null:(0,K.jsxs)(`p`,{className:`px-1 text-sm text-muted`,children:[`No page matches "`,r.trim(),`".`]}),!a&&o.length>Rw?(0,K.jsxs)(`p`,{className:`px-1 text-xs text-faint`,children:[o.length-Rw,` more: type to find them.`]}):null]})}var Bw=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``),Vw=Bw?`⌘K`:`Ctrl K`,Hw=60,Uw=6,Ww=e=>String(e||``).toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``);function Gw(e,...t){let n=0;for(let[r,i]of t.entries()){let t=Ww(i);if(!t)continue;let a=r===0?1:.5;t.startsWith(e)?n=Math.max(n,3*a):t.includes(` ${e}`)||t.includes(`/${e}`)?n=Math.max(n,2*a):t.includes(e)&&(n=Math.max(n,1*a))}return n}var Kw=e=>e.filter(e=>e.score>0).sort((e,t)=>t.score-e.score).map(e=>e.entry);function qw({query:e,groups:t,journeys:n,canEditJourneys:r,comments:i,actions:a,titleOf:o}){let s=Ww(e.trim()),c=t.flatMap(e=>e.pages.map(t=>({id:t.id,kind:`page`,icon:_h,title:t.title,detail:t.path||``,meta:e.group,run:{type:`page`,id:t.id}}))),l=n.map(e=>({id:`journey:${e.id}`,kind:`journey`,icon:Ng,title:e.name,detail:e.description||``,meta:e.branching?`${e.paths?.length||2} paths`:`${e.steps.length} steps`,run:{type:`journey`,id:e.id}}));r&&l.push({id:`journey:__new`,kind:`journey`,icon:Cg,title:`New journey`,detail:`Click pages in the order people visit them`,meta:``,run:{type:`new-journey`}});let u=a.map(e=>({id:`action:${e.id}`,kind:`action`,icon:e.icon||__,title:e.label,detail:e.detail||``,meta:e.keys||``,run:{type:`action`,run:e.run}}));if(!s)return[l.length?{id:`journeys`,label:`Journeys`,items:l}:null,{id:`pages`,label:`Pages`,items:c.slice(0,Hw),more:Math.max(0,c.length-Hw)},u.length?{id:`actions`,label:`Actions`,items:u}:null].filter(Boolean);let d=/^#?(\d{1,7})$/.exec(s)?.[1],f=e=>({id:`comment:${e.id}`,kind:`comment`,icon:ag,title:`#${e.id} ${String(e.body||``).split(`
26
+ `).length));return(0,K.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2 border-t border-line px-3 py-2`,onSubmit:m,"data-sw-reply-form":e.id,children:[u?(0,K.jsxs)(`label`,{className:`flex w-full items-center gap-2 text-xs text-muted`,children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:`Your name`}),(0,K.jsx)(qe,{size:r?`touch`:`xs`,value:f,onChange:e=>p(e.target.value.slice(0,60)),placeholder:`shown on your reply`,className:`flex-1`,"data-sw-reply-author":e.id})]}):null,(0,K.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`sr-only`,children:[`Reply to comment `,e.id]}),(0,K.jsx)(Ry,{rows:h,size:r?`touch`:`sm`,value:c,maxLength:yx,onChange:l,people:i,className:`resize-none`,placeholder:r?`Reply`:`Reply, @ to mention`,onKeyDown:e=>{bx(e,r)&&(e.preventDefault(),m())},autoFocus:a,"data-sw-reply-input":e.id})]}),(0,K.jsx)(z,{type:`submit`,variant:`default`,size:r?`icon`:`icon-sm`,className:`rounded-full`,disabled:t||!c.trim(),label:`Send reply`,"data-sw-reply-send":e.id,children:(0,K.jsx)(Vm,{size:16,"aria-hidden":`true`})})]})}function OS({comment:t,page:r,title:i,people:a,touch:o,me:s,can:c,busy:l,actions:u,nav:d,beforeAfter:g,onClose:_=null,editingRef:v=null,denial:y=null,role:b=null,hosted:S=null,onSaveName:w=null}){let[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(!1),k=(0,G.useRef)(null);(0,G.useEffect)(()=>{E(!1),O(!1)},[t.id]),v&&(v.current=T?()=>E(!1):null);let A=t.replies?.length||0;(0,G.useEffect)(()=>{let e=k.current;e&&(e.scrollTop=e.scrollHeight)},[t.id,A]);let j=t.status===`resolved`,M=j&&t.agentStatus!==`done`?null:t.agentStatus,N=o?`icon`:`icon-sm`,P=U_(t.viewport,null),F=!!u.onFixAgent&&t.status===`open`,ee=t.reopenCount>0&&!j||!!M,I=t.github?.issue?vy(t.github.issue.url):null,L=[u.onCopyLink?{id:`link`,label:`Copy link`,icon:Uh,run:()=>u.onCopyLink(t),hook:`data-sw-copy-link`}:null,c.edit?{id:`edit`,label:`Edit`,icon:xg,run:()=>E(!0),hook:`data-sw-edit`}:null,u.onAskAgent?{id:`agent`,label:`Ask agent`,icon:f,run:()=>u.onAskAgent(t),hook:`data-sw-ask-agent`}:null,I?{id:`issue`,label:`Open issue #${t.github.issue.number} on GitHub`,icon:Zm,href:I,hook:`data-sw-github-open`}:u.onGithubIssue&&c.resolve?{id:`issue`,label:`Create a GitHub issue`,icon:Zm,run:()=>u.onGithubIssue(t),hook:`data-sw-github-issue`}:null,u.onHistory&&r?{id:`history`,label:`Page history`,icon:Dg,run:()=>u.onHistory(t),hook:`data-sw-comment-history`}:null,r?.url?{id:`page`,label:`Open the page`,icon:dh,href:r.url,hook:`data-sw-open-page`}:null].filter(Boolean);return(0,K.jsxs)(`div`,{className:`flex max-h-[inherit] min-h-0 flex-col`,"data-sw-selected-comment":t.id,"data-sw-thread":t.id,children:[(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-0.5 border-b border-line`,o?`px-2 py-1`:`py-1 pr-1 pl-3`),children:[(0,K.jsx)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-xs text-muted`,"data-sw-thread-title":`true`,children:_?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg tabular`,children:[`#`,t.id]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:i}),P?(0,K.jsx)(p,{content:`${t.viewport[0].toUpperCase()}${t.viewport.slice(1)} capture`,children:(0,K.jsx)(`span`,{className:`inline-flex shrink-0 text-faint`,"aria-label":`${t.viewport} capture`,role:`img`,children:(0,K.jsx)(P,{size:12,"aria-hidden":`true`})})}):(0,K.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`· `,t.viewport]})]}):d?.total>1?(0,K.jsxs)(`span`,{className:`tabular`,children:[d.index+1,` of `,d.total]}):null}),d?.total>1?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(z,{size:N,onClick:d.onPrev,label:SS(`Previous thread`,d.prevNote),tooltip:SS(`Previous thread (Left arrow)`,d.prevNote),"data-sw-thread-prev":`true`,"data-sw-thread-note":d.prevNote||void 0,children:(0,K.jsx)(Ym,{size:16,"aria-hidden":`true`})}),(0,K.jsx)(z,{size:N,onClick:d.onNext,label:SS(`Next thread`,d.nextNote),tooltip:SS(`Next thread (Right arrow)`,d.nextNote),"data-sw-thread-next":`true`,"data-sw-thread-note":d.nextNote||void 0,children:(0,K.jsx)(m,{size:16,"aria-hidden":`true`})})]}):null,c.resolve?(0,K.jsx)(z,{size:N,variant:j?`default`:`ghost`,className:U(`rounded-full`,j&&`bg-ok text-ok-fg hover:bg-ok/90`),disabled:l,"aria-pressed":j,onClick:()=>u.onStatus(t,j?`reopen`:`resolve`),label:j?`Reopen the thread`:`Resolve the thread`,tooltip:j?`Resolved: reopen`:`Resolve`,...j?{"data-sw-reopen":t.id}:{"data-sw-resolve":t.id},children:(0,K.jsx)(ne,{size:16,strokeWidth:2.5,"aria-hidden":`true`})}):j?(0,K.jsxs)(`span`,{className:`mx-1 inline-flex items-center gap-1 rounded-full bg-ok/15 px-2 text-xs leading-6 font-medium text-fg`,children:[(0,K.jsx)(ne,{size:12,"aria-hidden":`true`}),` Resolved`]}):null,L.length||c.delete?(0,K.jsxs)(we,{children:[(0,K.jsx)(p,{content:`More`,children:(0,K.jsx)(x,{asChild:!0,children:(0,K.jsx)(n,{variant:`ghost`,size:N,"aria-label":`More for comment ${t.id}`,"data-sw-thread-menu":t.id,children:(0,K.jsx)(lh,{size:16,"aria-hidden":`true`})})})}),(0,K.jsxs)(e,{align:`end`,children:[L.map(e=>e.href?(0,K.jsx)(C,{asChild:!0,[e.hook]:t.id,children:(0,K.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer noopener`,children:[(0,K.jsx)(e.icon,{size:14,"aria-hidden":`true`}),` `,e.label]})},e.id):(0,K.jsxs)(C,{onSelect:e.run,[e.hook]:t.id,children:[(0,K.jsx)(e.icon,{size:14,"aria-hidden":`true`}),` `,e.label]},e.id)),c.delete?(0,K.jsxs)(K.Fragment,{children:[L.length?(0,K.jsx)(h,{}):null,(0,K.jsxs)(C,{tone:`danger`,onSelect:()=>O(!0),"data-sw-delete":t.id,children:[(0,K.jsx)(a_,{size:14,"aria-hidden":`true`}),` Delete thread`]})]}):null]})]}):null,_?(0,K.jsx)(z,{size:N,onClick:_,label:`Close the thread`,tooltip:`Close (Esc)`,"data-sw-thread-close":`true`,children:(0,K.jsx)(B,{size:16,"aria-hidden":`true`})}):null]}),F||ee?(0,K.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-1.5 border-b border-line px-3 py-1.5`,"data-sw-thread-agent":`true`,children:[(0,K.jsx)(wy,{comment:t}),F&&[`queued`,`working`].includes(M)?null:(0,K.jsx)(Cy,{status:M,at:t.agentStatusAt}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`}),F?(0,K.jsx)(xS,{comment:t,onFix:u.onFixAgent,onOpenChat:u.onAskAgent,busy:l,touch:o}):null]}):null,(0,K.jsxs)(`div`,{ref:k,className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[t.orphanReason?(0,K.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:t.orphanReason}):null,t.imported&&t.agentStatus?(0,K.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:`Imported agent status (history)`}):null,u.onSendToAgent&&t.status===`open`?(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(n,{size:o?`touch`:`sm`,disabled:l||t.dispatchable||t.needsRunApproval&&![`admin`,`owner`].includes(b),onClick:()=>u.onSendToAgent(t),children:t.dispatchable?`Sent to agent`:t.needsRunApproval?[`admin`,`owner`].includes(b)?`Approve agent run`:`Awaiting run approval`:`Send to agent`})}):null,(0,K.jsxs)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Comment ${t.id} and replies`,children:[(0,K.jsxs)(TS,{author:ky(t),at:t.createdAt,editedAt:t.editedAt,reactions:t.reactions,canReact:c.react,me:s,onReact:e=>u.onReact(t,e,null),touch:o,"data-sw-message":`comment`,children:[T?(0,K.jsx)(ES,{comment:t,busy:l,onSave:u.onEdit,onCancel:()=>E(!1),touch:o,people:a}):(0,K.jsx)(Iy,{text:t.body,plain:!!t.authorGuest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}),t.anchor?(0,K.jsx)(p,{content:(0,K.jsx)(`span`,{className:`font-mono text-[11px] break-all`,children:t.anchor.selector}),children:(0,K.jsxs)(`p`,{className:`mt-1.5 inline-flex max-w-full min-w-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[11px] text-muted`,"data-sw-thread-anchor":`true`,tabIndex:0,children:[(0,K.jsx)(ah,{size:11,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`shrink-0`,children:`Pinned to`}),(0,K.jsx)(`span`,{className:`truncate text-fg`,children:Ny(t.anchor)})]})}):null,r?.note?(0,K.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-xs text-faint`,"data-sw-page-note":`true`,children:[(0,K.jsx)(Fh,{size:11,className:`mt-0.5 shrink-0`,"aria-hidden":`true`}),` `,r.note]}):null,t.resolution?(0,K.jsxs)(`p`,{className:`mt-1.5 rounded bg-ok/10 px-2 py-1 text-xs text-fg`,children:[`Fix: `,t.resolution]}):null,(0,K.jsx)(yy,{value:t.fixRef,touch:o}),(0,K.jsx)(xy,{github:t.github,touch:o}),g?(0,K.jsx)(kx,{comment:t,pair:g.pairFor(t),native:g.nativeFor(t),urlFor:g.urlFor,onImageError:g.onImageError,touch:o}):null]}),(t.replies||[]).length?(0,K.jsx)(`li`,{"data-sw-replies":`true`,children:(0,K.jsx)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Replies`,children:t.replies.map(e=>(0,K.jsx)(TS,{author:Ay(e),at:e.createdAt,reactions:e.reactions,canReact:c.react,me:s,onReact:n=>u.onReact(t,n,e.id),touch:o,"data-sw-reply":e.id,children:(0,K.jsx)(Iy,{text:e.body,plain:!!e.guest,className:`block text-ui break-words whitespace-pre-wrap text-fg`})},e.id))})}):null]})]}),D?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-line bg-bad/10 px-3 py-2 text-xs text-fg`,role:`alert`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Delete this thread and its replies for good?`}),(0,K.jsx)(n,{size:o?`touch`:`xs`,variant:`ghost`,onClick:()=>O(!1),disabled:l,children:`Cancel`}),(0,K.jsxs)(n,{size:o?`touch`:`xs`,variant:`secondary`,className:`text-bad`,onClick:()=>u.onDelete(t),disabled:l,"data-sw-delete-confirm":t.id,children:[(0,K.jsx)(a_,{size:13,"aria-hidden":`true`}),` Delete`]})]}):null,c.reply?(0,K.jsx)(DS,{comment:t,busy:l,onReply:u.onReply,touch:o,people:a,askName:S===!1,onSaveName:w},t.id):(0,K.jsx)(`p`,{className:`shrink-0 border-t border-line px-3 py-2 text-xs text-muted`,"data-sw-reply-denied":b||`true`,children:y||CS(b)})]})}var kS=`input, textarea, select, [contenteditable="true"]`,AS={top:10,right:10,bottom:60,left:10};function jS(e,t){let n=Wu(),r=(0,G.useRef)(null),i=(0,G.useRef)({selector:e,point:t});return i.current={selector:e,point:t},r.current||={getBoundingClientRect(){let{domNode:e,transform:t}=n.getState(),{selector:r,point:a}=i.current,o=r?e?.querySelector(r):null;if(o)return o.getBoundingClientRect();let s=e?.getBoundingClientRect();if(!s||!a)return new DOMRect(-1e4,-1e4,0,0);let[c,l,u]=t;return new DOMRect(s.left+a.x*u+c,s.top+a.y*u+l,0,0)}},r}function MS(e,t,n){let r=Wu(),[i,a]=(0,G.useState)(`right`);return(0,G.useEffect)(()=>{if(!e)return;let i=()=>{let e=r.getState().domNode?.getBoundingClientRect(),i=t.current.getBoundingClientRect();if(!e)return;let o=(n.current?.offsetWidth||360)+20;a(e.right-i.right>=o?`right`:i.left-e.left>=o?`left`:`bottom`)};i();let o=r.subscribe(i),s=new ResizeObserver(i),c=r.getState().domNode;return c&&s.observe(c),()=>{o(),s.disconnect()}},[e,r,t,n]),i}function NS({open:e,onClose:t,selector:n,point:r,children:i,label:a,onKeyDown:o,onEscape:s,focusContent:c,className:l,...u}){let d=Wu(),f=jS(n,r),p=(0,G.useRef)(null),m=MS(e,f,p);return(0,K.jsxs)(Ze,{open:e,onOpenChange:e=>e?null:t(),children:[(0,K.jsx)(ue,{virtualRef:f}),(0,K.jsx)(Ye,{ref:p,side:m,align:`start`,sideOffset:10,alignOffset:-6,collisionBoundary:d.getState().domNode,collisionPadding:AS,hideWhenDetached:!0,updatePositionStrategy:`always`,"aria-label":a,className:U(`z-30`,l),onOpenAutoFocus:e=>{c&&(e.preventDefault(),p.current?.focus({preventScroll:!0}))},onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>{s?.(e)===!1&&e.preventDefault()},onKeyDown:e=>{p.current?.contains(e.target)&&!e.target?.closest?.(kS)&&o?.(e)},tabIndex:-1,...u,children:i})]})}function PS(e){(document.querySelector(`[data-sw-pin="${CSS.escape(e)}"]`)||[...document.querySelectorAll(`[data-sw-pin-cluster]`)].find(t=>t.getAttribute(`data-sw-pin-cluster`).split(`,`).includes(e)))?.focus({preventScroll:!0})}function FS(e,t,n){e.altKey||e.ctrlKey||e.metaKey||(e.key===`ArrowLeft`||e.key===`ArrowUp`?(e.preventDefault(),t?.()):(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(e.preventDefault(),n?.()))}function IS({comment:e,point:t,onClose:n,onPrev:r,onNext:i,editingRef:a,children:o}){let s=(0,G.useRef)({onPrev:r,onNext:i});return s.current={onPrev:r,onNext:i},(0,G.useEffect)(()=>{let e=e=>{e.defaultPrevented||document.activeElement!==document.body||document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||FS(e,s.current.onPrev,s.current.onNext)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,G.useEffect)(()=>{let t=window.setTimeout(()=>{document.activeElement===document.body&&document.querySelector(`[data-sw-thread-popover="${e.id}"]`)?.focus({preventScroll:!0})},450);return()=>window.clearTimeout(t)},[e.id]),(0,K.jsx)(NS,{open:!0,onClose:n,selector:`[data-sw-pin="${e.id}"]`,point:t,label:`Comment ${e.id}`,focusContent:!0,className:`flex max-h-[min(560px,var(--radix-popover-content-available-height))] w-[360px] flex-col overflow-hidden p-0 outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onEscape:()=>{if(a?.current&&document.activeElement?.closest?.(`[data-sw-edit-form]`))return a.current(),!1;let t=String(e.id);return window.setTimeout(()=>PS(t),0),!0},onKeyDown:e=>FS(e,r,i),"data-sw-thread-popover":e.id,children:o})}function LS({point:e,onClose:t,children:n}){return(0,K.jsx)(NS,{open:!0,onClose:t,selector:`[data-sw-draft-pin]`,point:e,label:`New comment`,className:`w-[340px] p-3`,"data-sw-composer-popover":`true`,children:n})}var RS=600,zS=e=>`shapewall.seen:${typeof window>`u`?``:window.location.pathname}:${e}`;function BS(e){try{let t=JSON.parse(window.localStorage.getItem(zS(e))||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function VS(e,t){try{let n=Object.entries(t).sort((e,t)=>String(t[1]).localeCompare(String(e[1]))).slice(0,RS);window.localStorage.setItem(zS(e),JSON.stringify(Object.fromEntries(n)))}catch{}}function HS(e){let t={at:e.createdAt||``,author:e.author,handle:e.authorHandle||null};for(let n of e.replies||[])String(n.createdAt)>String(t.at)&&(t={at:n.createdAt,author:n.author,handle:n.handle||null});return t}function US(e,t){return t?t.handle&&e.handle?e.handle===t.handle:!!t.name&&String(e.author||``).toLowerCase()===String(t.name).toLowerCase():!1}function WS(e,t,n){let r=HS(e);return!r.at||US(r,n)?!1:!t[e.id]||String(t[e.id])<String(r.at)}function GS(e){let[t,n]=(0,G.useState)(()=>BS(e));(0,G.useEffect)(()=>{n(BS(e));let t=t=>{t.key===zS(e)&&n(BS(e))};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e]);let r=(0,G.useCallback)(t=>{n(n=>{let r=!1,i={...n};for(let e of t){let t=HS(e).at;t&&String(i[e.id]||``)<String(t)&&(i[e.id]=t,r=!0)}return r?(VS(e,i),i):n})},[e]);return{seen:t,markSeen:(0,G.useCallback)(e=>r([e]),[r]),markAllSeen:r}}var KS=[`viewer`,`member`,`admin`,`owner`],qS=(e,t)=>KS.indexOf(e)>=KS.indexOf(t)&&KS.includes(e),JS=({isAuthor:e})=>!!e,YS=({role:e,isAuthor:t})=>qS(e,`member`)&&(!!t||qS(e,`admin`)),XS=`https://shapewall.com/contact`,ZS={version:`0.2.3`,revision:`d75d0acee17ca5e2b921a6d1309140b69c891e5c`},QS=e=>`v${e?.version||ZS.version}${e?.revision?` · ${e.revision.slice(0,7)}`:``}`,$S=`modulepreload`,eC=function(e,t){return new URL(e,t).href},tC={},nC=function(e){return e.pathname.endsWith(`.css`)},rC=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},iC=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=eC(t,n);let r=s(t),i=nC(r);return rC(tC,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:$S,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},aC=(0,G.lazy)(()=>iC(()=>import(`./app-update-dialog-Dox9-LWv.js`),__vite__mapDeps([0,1,2]),import.meta.url)),oC=`shapewall:open-about`;function sC(e=null){window.dispatchEvent(new CustomEvent(oC,{detail:{opener:e}}))}function cC({transport:e,className:t,placement:r=`menu`,ref:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=e=>{u.current=e||null,c(!0),o(!0)};(0,G.useImperativeHandle)(i,()=>({open:()=>d(document.activeElement)}),[]),(0,G.useEffect)(()=>{let e=e=>d(e.detail?.opener||null);return window.addEventListener(oC,e),()=>window.removeEventListener(oC,e)},[]);let f=()=>o(!1),p=e=>{e.preventDefault(),[u.current,l.current,document.querySelector(`[data-sw-profile-menu]`)].find(e=>e?.isConnected&&e!==document.body)?.focus()},m=`About Shapewall and updates, ${QS(ZS)}, created by Dan Baruch`;return(0,K.jsxs)(K.Fragment,{children:[r===`footer`?(0,K.jsx)(`footer`,{className:U(`flex shrink-0 justify-center border-t border-line bg-surface text-muted`,t),style:{paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`gap-2 rounded-none px-3 text-[10px] font-normal lg:h-6`,onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`footer`,ref:l,children:[(0,K.jsx)(`span`,{children:`Created by Dan Baruch`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{"data-sw-app-version":!0,children:QS(ZS)})]})}):r===`link`?(0,K.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,K.jsx)(n,{asChild:!0,variant:`ghost`,size:`touch`,className:`px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,"data-sw-app-contact":`link`,children:(0,K.jsx)(`a`,{href:XS,target:`_blank`,rel:`noopener noreferrer`,children:`Contact`})}),(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:U(`gap-1.5 px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,t),onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`link`,ref:l,children:[(0,K.jsx)(`span`,{children:`About Shapewall`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`span`,{className:`tabular-nums`,"data-sw-app-version":!0,children:[`v`,ZS.version]})]})]}):null,s?(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Opening About & Updates…`}),children:(0,K.jsx)(aC,{open:a,onClose:f,onCloseAutoFocus:p,transport:e})}):null]})}function lC({demo:t,className:n,children:r,align:i=`start`}){return t.viewAs?(0,K.jsxs)(we,{children:[(0,K.jsx)(x,{asChild:!0,children:r}),(0,K.jsxs)(e,{align:i,className:U(`w-64`,n),children:[(0,K.jsx)(T,{children:`View as (demo)`}),(0,K.jsx)(k,{value:t.viewAs.value,onValueChange:t.viewAs.onChange,children:t.viewAs.options.map(e=>(0,K.jsxs)(l,{value:e.id,"data-sw-view-as":e.id,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,K.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]})]}):r}var uC=()=>(0,K.jsxs)(`span`,{className:`inline-flex h-5 shrink-0 items-center gap-1.5 rounded-full bg-accent/12 px-2 text-caption font-semibold text-accent`,children:[(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),`Demo`]});function dC({variant:e=`strip`,className:t}){let r=E();return r?e===`chip`?(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-0.5 rounded-full border border-line bg-surface-2/60 p-0.5`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":r.role,children:[(0,K.jsx)(lC,{demo:r,align:`end`,children:(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`h-11 gap-1.5 rounded-full px-2 text-ui text-fg lg:h-8`,"aria-label":`Demo, viewing as `+r.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,K.jsx)(uC,{}),(0,K.jsx)(`span`,{className:`hidden max-w-28 truncate font-medium sm:inline`,children:r.roleLabel}),(0,K.jsx)(R,{size:13,className:`text-faint`,"aria-hidden":`true`})]})}),(0,K.jsx)(z,{label:`Reset the demo`,size:`icon`,className:`rounded-full text-muted max-lg:hidden lg:h-8 lg:w-8`,onClick:r.reset,"data-sw-demo-reset":!0,children:(0,K.jsx)(kg,{size:14,"aria-hidden":`true`})}),(0,K.jsx)(fC,{})]}):(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-2 border-b border-line bg-surface px-2 text-ui text-muted sm:px-3 lg:h-9`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":r.role,children:[(0,K.jsx)(uC,{}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`hidden shrink-0 sm:inline`,children:`Viewing as`}),(0,K.jsx)(lC,{demo:r,children:(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`min-w-0 gap-1 px-1.5 text-ui text-fg lg:h-7`,"aria-label":`Viewing as `+r.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,K.jsx)(`span`,{className:`truncate font-semibold`,children:r.roleLabel}),(0,K.jsxs)(`span`,{className:`hidden truncate font-normal text-muted sm:inline`,children:[`(`,r.personaName,`)`]}),(0,K.jsx)(R,{size:13,className:`shrink-0 text-faint`,"aria-hidden":`true`})]})}),(0,K.jsx)(`span`,{className:`hidden truncate text-faint md:inline`,children:`· Changes stay in this browser`})]}),(0,K.jsxs)(n,{variant:`ghost`,size:`touch`,className:`shrink-0 gap-1.5 px-2 text-ui text-muted lg:h-7`,onClick:r.reset,"data-sw-demo-reset":!0,children:[(0,K.jsx)(kg,{size:13,"aria-hidden":`true`}),` Reset`]}),(0,K.jsx)(fC,{})]}):null}function fC(){let e=E();return e?(0,K.jsx)(M,{open:!!e.resetAsked,onClose:e.cancelReset,title:`Reset the demo?`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:`touch`,variant:`ghost`,onClick:e.cancelReset,className:`lg:h-10`,"data-sw-demo-reset-cancel":!0,children:`Cancel`}),(0,K.jsxs)(n,{size:`touch`,className:`border-bad/50 bg-bad text-bad-fg hover:bg-bad/90 lg:h-10`,onClick:e.resetNow,"data-sw-demo-reset-confirm":!0,children:[(0,K.jsx)(kg,{size:14,"aria-hidden":`true`}),` Reset`]})]}),children:(0,K.jsx)(`p`,{className:`px-5 py-4 text-sm text-muted`,children:`Your comments, invites and changes in this browser go back to the start.`})}):null}var pC={unknown:{title:`This share link is not valid`,text:`Check that you have the whole link, or ask whoever shared it for a new one.`},revoked:{title:`This share link was revoked`,text:`Whoever shared it turned it off. Ask them for a new link.`},expired:{title:`This share link has expired`,text:`Share links work for a set time. Ask whoever shared it for a new one.`},off:{title:`This share link is turned off`,text:`The workspace no longer allows share links, or the person who made it can no longer share. Ask them for a new link.`}};function mC({problem:e,onLeave:t}){let r=pC[e?.status]||pC.unknown,i=e?.at?new Date(e.at):null;return(0,K.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,K.jsx)(dC,{}),(0,K.jsx)(`main`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,K.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-line bg-surface p-6 text-center shadow-card sm:p-8`,role:`alert`,"data-sw-share-problem":e?.status||`unknown`,children:[(0,K.jsx)(`span`,{className:`inline-flex h-11 w-11 items-center justify-center rounded-xl bg-bad/10 text-bad`,children:(0,K.jsx)(Vh,{size:20,"aria-hidden":`true`})}),(0,K.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:r.title}),(0,K.jsxs)(`p`,{className:`mt-2 text-sm text-muted`,children:[r.text,i&&Number.isFinite(i.getTime())?(0,K.jsxs)(K.Fragment,{children:[` `,e.status===`revoked`?`Revoked`:`Expired`,` `,i.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`.`]}):null]}),(0,K.jsx)(`p`,{className:`mt-4 text-xs text-muted`,children:`In the demo, share links are made on a project's page in the console.`}),(0,K.jsx)(n,{size:`touch`,variant:`default`,className:`mt-5 lg:h-10`,onClick:t,"data-sw-share-problem-leave":!0,children:`Open the demo board`})]})})]})}async function hC(e,n,r){let i;try{i=await fetch(n,{method:e,credentials:`same-origin`,headers:{...r===void 0?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`},...typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-accounts"]`)&&n.startsWith(`/auth/`)?t():{}},body:r===void 0?void 0:JSON.stringify(r),cache:`no-store`})}catch{throw new Xe(0,`offline`,`Could not reach the server. Check your connection and try again.`)}let a=null;try{a=await i.json()}catch{a=null}if(!i.ok){let e=Number(i.headers.get(`Retry-After`)),t=a?.error?.message||`Request failed (${i.status})`;throw new Xe(i.status,a?.error?.code||`error`,i.status===429&&e>0?_C(t,e):t,{retryAfter:i.status===429&&e>0?e:null})}return a}function gC(e){return e>=5400?`${Math.ceil(e/3600)} hours`:e>=90?`${Math.ceil(e/60)} minutes`:e>60?`2 minutes`:e===1?`1 second`:`${e} seconds`}var _C=(e,t)=>`${e.replace(/\s*Wait (a while|a moment) and try again\.?\s*$/i,``)} Try again in ${gC(t)}.`,vC={get:e=>hC(`GET`,e),post:(e,t={})=>hC(`POST`,e,t),patch:(e,t={})=>hC(`PATCH`,e,t),put:(e,t={})=>hC(`PUT`,e,t),delete:(e,t)=>hC(`DELETE`,e,t)},yC=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t+`===`.slice((t.length+3)%4));return Uint8Array.from(n,e=>e.charCodeAt(0)).buffer},bC=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function xC(e,{mediation:t,signal:n}={}){let r={...e,challenge:yC(e.challenge),allowCredentials:(e.allowCredentials||[]).map(e=>({...e,id:yC(e.id)}))},i=await navigator.credentials.get({publicKey:r,...t?{mediation:t}:{},...n?{signal:n}:{}}),a=i.response;return{id:i.id,rawId:bC(i.rawId),type:i.type,authenticatorAttachment:i.authenticatorAttachment||void 0,clientExtensionResults:i.getClientExtensionResults(),response:{clientDataJSON:bC(a.clientDataJSON),authenticatorData:bC(a.authenticatorData),signature:bC(a.signature),userHandle:a.userHandle?bC(a.userHandle):void 0}}}async function SC(){let{options:e}=await vC.post(`/auth/reauth/options`,{}),t=await xC(e);await vC.post(`/auth/reauth/verify`,{response:t})}function CC({boardId:e}){let[t,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),u=`/api/boards/${encodeURIComponent(e)}/approvals`;(0,G.useEffect)(()=>{let t=!0,n=()=>Je.get(`/api/boards/${encodeURIComponent(e)}/agent-budget`).then(e=>{t&&a(e)}).catch(()=>{}),i=()=>Je.get(u).then(e=>{t&&r(e.approvals)}).catch(()=>{});i(),n();let o=()=>{document.visibilityState===`visible`&&(i(),n())},s=setInterval(o,3e3);return document.addEventListener(`visibilitychange`,o),()=>{t=!1,clearInterval(s),document.removeEventListener(`visibilitychange`,o)}},[u,e]);let d=async(e,t)=>{l(!0),s(null);try{await SC(),await Je.post(`${u}/${e.id}`,{state:t,hash:e.command_hash}),r(t=>t.filter(t=>t.id!==e.id))}catch(e){s(e.message)}finally{l(!1)}};return!t.length&&!o&&!i?.exhausted?null:(0,K.jsxs)(`section`,{"aria-label":`Agent command approvals`,className:`max-h-64 shrink-0 overflow-auto border-b border-line bg-surface p-3 text-sm`,children:[i?.exhausted?(0,K.jsxs)(`p`,{role:`status`,className:`pb-2`,children:[`The agent hit today’s limit: `,i.claims,`/`,i.dailyLimit,` runs, `,i.open,`/`,i.openLimit,` in progress. Change limits in Agent policy in the console.`]}):null,t.map(e=>(0,K.jsxs)(`article`,{className:`space-y-2 pb-3`,children:[(0,K.jsxs)(`p`,{className:`font-semibold`,children:[`Agent asks to run a command for comment #`,e.comment_number]}),(0,K.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words rounded bg-surface-2 p-2`,children:e.command.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}),(0,K.jsx)(`p`,{children:e.reason}),(0,K.jsx)(n,{size:`touch`,variant:`default`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`approved`),children:`Approve once with passkey`}),` `,(0,K.jsx)(n,{size:`touch`,variant:`danger`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`denied`),children:`Deny`})]},e.id)),o?(0,K.jsx)(`p`,{role:`alert`,className:`text-bad`,children:o}):null]})}var wC={share:{title:`This link was revoked`,body:`Or it expired. The board stops updating and you cannot comment. Ask whoever shared it for a new link.`,href:null},signed_out:{title:`You were signed out`,body:`Sign in again to keep working on this board.`,href:`signin`},removed:{title:`You don't have access to this board any more`,body:`You may have been removed from the workspace. Ask an admin to invite you again.`,href:`home`}};function TC(){let[e,t]=(0,G.useState)(null);if((0,G.useEffect)(()=>{let e=e=>t(t=>t||e.detail?.kind||null);return window.addEventListener(de,e),()=>window.removeEventListener(de,e)},[]),!e)return null;let n=wC[e],r=encodeURIComponent(window.location.pathname+window.location.search);return(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-bad/30 bg-bad/10 px-4 py-2 text-sm text-fg`,role:`alert`,"data-sw-access-lost":e,children:[e===`share`?(0,K.jsx)(Vh,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}):(0,K.jsx)(Yh,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`font-medium`,children:n.title}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:n.body}),n.href===`signin`?(0,K.jsx)(`a`,{href:`/signin?next=${r}`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Sign in`}):n.href===`home`?(0,K.jsx)(`a`,{href:`/`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Your workspaces`}):null]})}var EC=`You're a viewer. Ask an admin for member access to comment.`;function DC({compact:e=!1}){return(0,K.jsx)(p,{content:EC,side:`bottom`,children:(0,K.jsxs)(`span`,{role:`note`,tabIndex:0,"aria-label":EC,className:U(`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface-2 text-xs font-medium whitespace-nowrap text-muted outline-none focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11 px-2.5`:`h-8 px-2.5`),"data-sw-viewer-note":!0,children:[(0,K.jsx)(ph,{size:14,"aria-hidden":`true`}),` Viewer`]})})}function OC({project:e}){return(0,K.jsx)(p,{content:`Back to ${e.name}`,side:`bottom`,align:`start`,children:(0,K.jsx)(`a`,{href:e.url,className:`block max-w-full min-w-0 truncate rounded-sm px-2.5 text-[11px] leading-3.5 font-medium text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-project-crumb":!0,children:e.name})})}var kC={includes:e=>typeof e==`string`&&(e===`all`||/^[a-z][a-z0-9-]{0,31}$/.test(e))};function AC({enabled:e,boardId:t,canvasRef:n,flow:r,selection:i,mode:a,onMode:o,onInvalidate:s}){let[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)(0),[f,p]=(0,G.useState)(`offline`),[m,h]=(0,G.useState)(null),g=(0,G.useRef)({cursor:null});g.current={...g.current,selection:i,mode:a,onMode:o,onInvalidate:s};let _=(0,G.useRef)(null);return $p({onChange:e?()=>_.current?.():void 0}),(0,G.useEffect)(()=>{_.current?.()},[i,a]),(0,G.useEffect)(()=>{if(!e){l([]),d(0),h(null);return}let i=!1,a;return iC(async()=>{let{connectPresence:e}=await import(`./runtime-Bft6x_6E.js`);return{connectPresence:e}},[],import.meta.url).then(({connectPresence:e})=>{i||(a=e({boardId:t,canvasRef:n,flow:r,latest:g,sendRef:_,setPeers:l,setCount:d,setFollowing:h,setStatus:p}))}).catch(()=>{i||p(`offline`)}),()=>{i=!0,a?.()}},[e,t,n,r]),(0,G.useEffect)(()=>{if(m===null)return;let e=c.find(e=>e.id===m);if(!e){h(null);return}let t=e.viewport;if(!t||![t.x,t.y,t.zoom].every(Number.isFinite)||!kC.includes(e.mode))return;g.current.mode!==e.mode&&g.current.onMode?.(e.mode);let n=window.requestAnimationFrame(()=>{let e=r.getViewport();(Math.abs(e.x-t.x)>.01||Math.abs(e.y-t.y)>.01||Math.abs(e.zoom-t.zoom)>.001)&&r.setViewport(t,{duration:0})});return()=>window.cancelAnimationFrame(n)},[m,c,r]),{peers:c,count:u,status:f,following:m,follow:h,stopFollowing:()=>h(null)}}function jC({touch:e,...t}){let n=AC(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(FC,{presence:n}),(0,K.jsx)(PC,{presence:n,touch:e})]})}var MC=e=>`${e.id}|${e.name}|${e.color}|${+!!e.viewport}`;function NC(e,t){let n=e.presence,r=t.presence;return e.touch===t.touch&&n.status===r.status&&n.count===r.count&&n.following===r.following&&n.peers.length===r.peers.length&&n.peers.every((e,t)=>MC(e)===MC(r.peers[t]))}var PC=(0,G.memo)(function({presence:e,touch:t}){if(e.status!==`online`)return null;let r=e.peers.find(t=>t.id===e.following);return(0,K.jsxs)(`div`,{className:`absolute top-14 right-2 z-30 flex max-w-[calc(100%-1rem)] flex-wrap items-center justify-end gap-1 rounded-xl border border-line bg-surface/95 p-1 shadow-pop`,"aria-label":`Who is viewing`,"data-sw-presence":`true`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 text-xs text-muted`,"data-sw-presence-count":e.count,children:[(0,K.jsx)(p_,{size:13,"aria-hidden":`true`}),e.count,` viewing`]}),e.peers.slice(0,5).map(r=>(0,K.jsx)(p,{content:`${r.name}${r.viewport?`: follow their view`:``}`,children:(0,K.jsx)(n,{size:t?`icon`:`icon-sm`,variant:e.following===r.id?`default`:`ghost`,"aria-label":`Follow ${r.name}`,"aria-pressed":e.following===r.id,disabled:!r.viewport,"data-sw-presence-peer":r.id,onClick:()=>e.follow(e.following===r.id?null:r.id),children:(0,K.jsx)(le,{person:!0,name:r.name,color:r.color,size:`sm`})})},r.id)),e.peers.length>5?(0,K.jsxs)(`span`,{className:`px-1 text-xs text-muted`,children:[`+`,e.peers.length-5]}):null,r?(0,K.jsxs)(n,{size:t?`touch`:`xs`,variant:`secondary`,onClick:e.stopFollowing,"data-sw-stop-follow":`true`,children:[`Stop following `,r.name]}):null]})},NC);function FC({presence:e}){let t=e.peers.filter(e=>e.cursor&&Number.isFinite(e.cursor.x)&&Number.isFinite(e.cursor.y));return(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-20 overflow-hidden`,"aria-hidden":`true`,"data-sw-presence-cursors":`true`,children:t.length?(0,K.jsx)(IC,{peers:t}):null})}function IC({peers:e}){let{x:t,y:n,zoom:r}=Zp();return e.map(e=>(0,K.jsxs)(`div`,{className:`absolute top-0 left-0`,style:{transform:`translate(${e.cursor.x*r+t}px, ${e.cursor.y*r+n}px)`,color:e.color},"data-sw-presence-cursor":e.id,"data-sw-cursor-x":e.cursor.x,"data-sw-cursor-y":e.cursor.y,children:[(0,K.jsx)(hg,{size:18,fill:`currentColor`,stroke:`white`,strokeWidth:1.5}),(0,K.jsx)(`span`,{className:`ml-3 block max-w-36 truncate rounded px-1.5 py-0.5 text-[10px] text-white shadow-sm`,style:{background:e.color},children:e.name})]},e.id))}var LC=`shapewall.appearance`,RC=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],zC=[{id:`default`,label:`Default`},{id:`ocean`,label:`Ocean`},{id:`forest`,label:`Forest`},{id:`contrast`,label:`High contrast`}],BC={mode:`system`,theme:`default`};function VC(e){return{mode:RC.some(t=>t.id===e?.mode)?e.mode:BC.mode,theme:zC.some(t=>t.id===e?.theme)?e.theme:BC.theme}}var HC=(e,t)=>e===`system`?t?`dark`:`light`:e,UC=typeof window<`u`,WC=()=>UC&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null;function GC(){try{return VC(JSON.parse(window.localStorage.getItem(`shapewall.appearance`)||`null`))}catch{return{...BC}}}var KC=UC?GC():{...BC},qC=new Set;function JC(){let e=getComputedStyle(document.documentElement).getPropertyValue(`--surface`).trim();if(e)for(let t of document.querySelectorAll(`meta[name="theme-color"]`))t.removeAttribute(`media`),t.setAttribute(`content`,e)}function YC(e=KC){if(!UC)return;let t=document.documentElement;t.setAttribute(`data-mode`,HC(e.mode,!!WC()?.matches)),t.setAttribute(`data-theme`,e.theme),JC()}function XC(){return KC}function ZC(e){KC=VC({...KC,...e});try{window.localStorage.setItem(LC,JSON.stringify(KC))}catch{}YC(),qC.forEach(e=>e())}UC&&(YC(),WC()?.addEventListener?.(`change`,()=>{KC.mode===`system`&&(YC(),qC.forEach(e=>e()))}),window.addEventListener(`storage`,e=>{e.key===`shapewall.appearance`&&(KC=GC(),YC(),qC.forEach(e=>e()))}));var QC=e=>(qC.add(e),()=>qC.delete(e));function $C(){return[(0,G.useSyncExternalStore)(QC,XC,XC),ZC]}var ew=()=>UC?HC(KC.mode,!!WC()?.matches):`light`;function tw(){return(0,G.useSyncExternalStore)(QC,ew,ew)}var nw=`shapewall.demo.try`;function rw(){try{return window.localStorage.getItem(nw)===`1`}catch{return!1}}function iw(e){let[t,n]=(0,G.useState)(()=>e&&!rw());return[e&&t,()=>{n(!1);try{window.localStorage.setItem(nw,`1`)}catch{}}]}function aw({touch:e,done:t,onOpenComment:r,onComment:i,onAgent:a,onClose:o}){let[s,c]=(0,G.useState)(!0),l=[{id:`open`,icon:ag,label:`Open a comment`,hint:e?`Tap a pin on a page`:`Click a pin on a page`,run:r},i&&{id:`comment`,icon:rg,label:e?`Pin your own comment`:`Press C to comment`,hint:e?`The comment button, then a page`:`Then click anywhere on a page`,run:i},a?{id:`agent`,icon:f,label:`Ask the agent`,hint:e?`In the ... menu`:`It reads the open comments`,run:a}:null].filter(Boolean),u=l.filter(e=>t.has(e.id)).length,d=e?`bottom-16 left-2`:`bottom-16 left-3`;return s?(0,K.jsxs)(`button`,{type:`button`,className:U(`pointer-events-auto absolute z-30 inline-flex items-center gap-2 rounded-full border border-line bg-surface/95 pr-3 pl-2 text-[13px] font-medium text-fg shadow-pop backdrop-blur outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11`:`h-9`,d),onClick:()=>c(!1),"aria-expanded":`false`,"aria-label":`Try this: ${u} of ${l.length} done. Show the tips`,"data-sw-try-this":`folded`,children:[(0,K.jsx)(Yg,{size:15,className:`text-accent`,"aria-hidden":`true`}),` Try this`,(0,K.jsxs)(`span`,{className:`tabular text-xs text-muted`,children:[u,`/`,l.length]})]}):(0,K.jsxs)(`section`,{className:U(`pointer-events-auto absolute z-30 animate-pop-in rounded-xl border border-line bg-surface/95 p-3 text-fg shadow-pop backdrop-blur`,e?`inset-x-2 bottom-16`:`bottom-16 left-3 w-72`),"aria-label":`Try this`,"data-sw-try-this":`true`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,K.jsx)(Yg,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,K.jsxs)(`h2`,{className:`min-w-0 flex-1 text-sm font-semibold`,children:[`Try this`,` `,(0,K.jsxs)(`span`,{className:`tabular text-xs font-medium text-muted`,children:[u,`/`,l.length]})]}),(0,K.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:()=>c(!0),label:`Fold the tips away`,"aria-expanded":`true`,"data-sw-try-fold":`true`,children:(0,K.jsx)(R,{size:14,"aria-hidden":`true`})}),(0,K.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:o,label:`Close the tips for good`,"data-sw-try-close":`true`,children:(0,K.jsx)(B,{size:14,"aria-hidden":`true`})})]}),(0,K.jsx)(`ol`,{className:`flex flex-col gap-1`,children:l.map(r=>{let i=t.has(r.id),a=i?ne:r.icon;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(n,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:r.run,"data-sw-try-step":r.id,"data-sw-try-done":i?`true`:void 0,children:[(0,K.jsx)(`span`,{className:U(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-ok/15 text-ok`:`bg-accent/10 text-accent`),"aria-hidden":`true`,children:(0,K.jsx)(a,{size:13})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:U(`block text-[13px] font-medium text-fg`,i&&`text-muted line-through decoration-faint`),children:r.label}),(0,K.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:r.hint})]})]})},r.id)})}),(0,K.jsx)(`p`,{className:`mt-2 border-t border-line px-2 pt-2 text-xs text-muted`,"data-sw-try-nav":`true`,children:e?`Drag to move around, pinch to zoom.`:`Scroll to move, Ctrl+scroll or pinch to zoom, Space+drag to pan.`})]})}var ow=new Map,sw=10;function cw(e,t,n,r){let i=n*t*4;for(let n=0;n<t;n+=1){let t=i+n*4;if(Math.abs(e[t]-r[0])>sw||Math.abs(e[t+1]-r[1])>sw||Math.abs(e[t+2]-r[2])>sw)return!0}return!1}function lw(e,t,n){if(!t||!n)return 1;let r=(n-1)*t*4,i=[e[r],e[r+1],e[r+2]];for(let r=n-1;r>=0;--r)if(cw(e,t,r,i))return Math.min(1,(r+1)/n);return 1}function uw(e){if(!e||typeof document>`u`)return Promise.resolve(1);if(ow.has(e))return ow.get(e);let t=new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=Math.min(n.naturalWidth,200),r=Math.round(n.naturalHeight*e/n.naturalWidth),i=document.createElement(`canvas`);i.width=e,i.height=r;let a=i.getContext(`2d`,{willReadFrequently:!0});a.drawImage(n,0,0,e,r),t(lw(a.getImageData(0,0,e,r).data,e,r))}catch{t(1)}},n.onerror=()=>t(1),n.src=e});return ow.set(e,t),t}var dw=()=>typeof window<`u`&&!!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,fw=e=>dw()?0:e,pw=()=>dw()?`auto`:`smooth`,mw=.02,hw={padding:.16};function gw(e,t,n,r=92){if(!t?.width||!t?.height)return e;let i=Math.min(t.width/e.width,t.height/e.height)/(1+2*n),a=r/Math.max(i,.01);return{...e,y:e.y-a,height:e.height+a}}function _w(e){let t=String(e||``).split(`,`).map(Number);return t.length!==3||t.some(e=>!Number.isFinite(e))||t[2]<=0?null:{x:t[0],y:t[1],zoom:t[2]}}function vw(e,t,n,{phoneCompare:r,shotUrls:i}){let a=t.frames[0];if(r&&a&&n?.width){let r=Math.min(4,(n.width-16)/t.w);e.setViewport({x:8-t.x*r,y:70-(t.y+a.y)*r,zoom:r},{duration:fw(450)});return}let o=r=>e.fitBounds(gw({x:t.x,y:t.y,width:t.w,height:Math.min(t.h,(a?a.y+a.h*r:t.h)+16)},n,.12),{padding:.12,duration:fw(450)});!a||!i.length?o(1):Promise.all(i.map(e=>uw(e))).then(e=>o(Math.max(.2,...e))).catch(()=>o(1))}function yw(e,t,n,r=24){let i=n.map(n=>e.x+t.x+t.w*n.spot.x/100),a=n.map(n=>e.y+t.y+t.h*n.spot.y/100);return{x:Math.min(...i)-r,y:Math.min(...a)-r,width:Math.max(...i)-Math.min(...i)+r*2,height:Math.max(...a)-Math.min(...a)+r*2}}var bw=.34,xw=12,Sw=.75,Cw=72,ww=40;function Tw(e,t,n=hw.padding){if(!t?.width||!t?.height||!e?.length)return null;let r=e.filter(e=>e.type===`groupFrame`),i=Ew(r.length?r:e);if(!i)return null;let a=Math.min(t.width/(i.width*(1+2*n)),t.height/(i.height*(1+2*n))),o=e.filter(e=>e.type!==`groupFrame`).length;if(a>=.34||!r.length||o<=xw)return null;let s=[...r].sort((e,t)=>e.position.y-t.position.y||e.position.x-t.position.x)[0],c=s.width??s.style?.width??0,l=s.height??s.style?.height??0,u=Math.min((t.width-80)/c,(t.height-Cw-24)/l),d=Math.max(a,bw,Math.min(Sw,u));return{x:ww-s.position.x*d,y:Cw-s.position.y*d,zoom:d}}function Ew(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=a.width??a.style?.width??0,o=a.height??a.style?.height??0;t=Math.min(t,a.position.x),n=Math.min(n,a.position.y),r=Math.max(r,a.position.x+e),i=Math.max(i,a.position.y+o)}return Number.isFinite(t)?{x:t,y:n,width:r-t,height:i-n}:null}function Dw(e){let t=Wu(),[n,r]=(0,G.useState)(null),i=(0,G.useRef)(null),a=(0,G.useCallback)(e=>{i.current=e,r(e)},[]);return(0,G.useEffect)(()=>{if(!e)return;let n=null,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>a(t.getState().transform[2]),300)};r();let o=t.getState().transform[2],s=t.subscribe(e=>{let t=e.transform[2];t!==o&&(o=t,i.current!==null&&t<i.current*.8&&a(t),r())});return()=>{window.clearTimeout(n),s()}},[e,a,t]),[n,a]}var Ow=`shapewall.minimap`;function kw(){try{let e=window.localStorage.getItem(Ow);return e===`on`||e!==`off`&&null}catch{return null}}function Aw(e){return e>=30}var jw=`shapewall.tip.board`;function Mw(){try{return window.localStorage.getItem(jw)===`1`}catch{return!1}}function Nw(e){try{window.localStorage.setItem(Ow,e?`on`:`off`)}catch{}}function Pw(){try{window.localStorage.setItem(jw,`1`)}catch{}}var Fw=`shapewall.rail.`;function Iw(e){try{let t=Number(window.localStorage.getItem(Fw+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}}function Lw(e,t){try{t==null?window.localStorage.removeItem(Fw+e):window.localStorage.setItem(Fw+e,String(Math.round(t)))}catch{}}var Rw=8;function zw({groups:e,onPick:t}){let[r,i]=(0,G.useState)(``),a=r.trim().toLowerCase(),o=e.flatMap(e=>e.pages.map(t=>({...t,group:e.group}))),s=a?o.filter(e=>`${e.title} ${e.path||``} ${e.group}`.toLowerCase().includes(a)):o.slice(0,Rw);return(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-page-finder":`true`,children:[(0,K.jsx)(qe,{size:`touch`,icon:Lg,value:r,onChange:e=>i(e.target.value.slice(0,80)),placeholder:`Search ${o.length} pages`,"aria-label":`Search pages`,"data-sw-page-search":`true`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(n,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>t(e.id),"data-sw-page-pick":e.id,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:e.group})]})},e.id))}),s.length?null:(0,K.jsxs)(`p`,{className:`px-1 text-sm text-muted`,children:[`No page matches "`,r.trim(),`".`]}),!a&&o.length>Rw?(0,K.jsxs)(`p`,{className:`px-1 text-xs text-faint`,children:[o.length-Rw,` more: type to find them.`]}):null]})}var Bw=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``),Vw=Bw?`⌘K`:`Ctrl K`,Hw=60,Uw=6,Ww=e=>String(e||``).toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``);function Gw(e,...t){let n=0;for(let[r,i]of t.entries()){let t=Ww(i);if(!t)continue;let a=r===0?1:.5;t.startsWith(e)?n=Math.max(n,3*a):t.includes(` ${e}`)||t.includes(`/${e}`)?n=Math.max(n,2*a):t.includes(e)&&(n=Math.max(n,1*a))}return n}var Kw=e=>e.filter(e=>e.score>0).sort((e,t)=>t.score-e.score).map(e=>e.entry);function qw({query:e,groups:t,journeys:n,canEditJourneys:r,comments:i,actions:a,titleOf:o}){let s=Ww(e.trim()),c=t.flatMap(e=>e.pages.map(t=>({id:t.id,kind:`page`,icon:_h,title:t.title,detail:t.path||``,meta:e.group,run:{type:`page`,id:t.id}}))),l=n.map(e=>({id:`journey:${e.id}`,kind:`journey`,icon:Ng,title:e.name,detail:e.description||``,meta:e.branching?`${e.paths?.length||2} paths`:`${e.steps.length} steps`,run:{type:`journey`,id:e.id}}));r&&l.push({id:`journey:__new`,kind:`journey`,icon:Cg,title:`New journey`,detail:`Click pages in the order people visit them`,meta:``,run:{type:`new-journey`}});let u=a.map(e=>({id:`action:${e.id}`,kind:`action`,icon:e.icon||__,title:e.label,detail:e.detail||``,meta:e.keys||``,run:{type:`action`,run:e.run}}));if(!s)return[l.length?{id:`journeys`,label:`Journeys`,items:l}:null,{id:`pages`,label:`Pages`,items:c.slice(0,Hw),more:Math.max(0,c.length-Hw)},u.length?{id:`actions`,label:`Actions`,items:u}:null].filter(Boolean);let d=/^#?(\d{1,7})$/.exec(s)?.[1],f=e=>({id:`comment:${e.id}`,kind:`comment`,icon:ag,title:`#${e.id} ${String(e.body||``).split(`
27
27
  `)[0]}`,detail:[o(e.pageId),e.viewport].filter(Boolean).join(` · `),meta:e.status===`resolved`?`Resolved`:``,run:{type:`comment`,comment:e}}),p=d?i.find(e=>String(e.id)===d):null,m=[p,...(s.length>=2&&!d?Kw(i.map(e=>({entry:e,score:Gw(s,e.body,e.author)}))):[]).filter(e=>e!==p)].filter(Boolean).slice(0,Uw).map(f),h=Kw(c.map(e=>({entry:e,score:Gw(s,e.title,e.detail,e.meta)}))),g=Kw(l.map(e=>({entry:e,score:Gw(s,e.title,e.detail)}))),_=Kw(u.map(e=>({entry:e,score:Gw(s,e.title,e.detail)})));return[d&&p?{id:`comments`,label:`Comments`,items:m}:null,h.length?{id:`pages`,label:`Pages`,items:h.slice(0,Hw)}:null,g.length?{id:`journeys`,label:`Journeys`,items:g}:null,!d&&m.length?{id:`comments`,label:`Comments`,items:m}:null,_.length?{id:`actions`,label:`Actions`,items:_}:null].filter(Boolean)}function Jw({onOpen:e,compact:t=!1,className:n,...r}){return(0,K.jsxs)(`button`,{type:`button`,...r,onClick:e,className:U(`inline-flex h-8 shrink-0 items-center gap-2 rounded-md border border-line bg-surface-2/60 text-[13px] text-muted outline-none hover:border-faint/40 hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,t?`w-8 justify-center`:`w-60 px-2.5`,n),"aria-label":`Go to a page, journey or comment`,"aria-haspopup":`dialog`,"aria-keyshortcuts":Bw?`Meta+K`:`Control+K`,"data-sw-page-jump":`true`,"data-sw-palette-trigger":`true`,children:[(0,K.jsx)(Lg,{size:14,"aria-hidden":`true`,className:`shrink-0`}),t?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:`Go to page or journey`}),(0,K.jsx)(i,{className:`shrink-0`,children:Vw})]})]})}function Yw({open:e,onOpenChange:t,groups:n,journeys:r=[],canEditJourneys:i=!1,comments:a=[],actions:o=[],titleOf:s=e=>e,onPage:c,onJourney:l,onNewJourney:u,onComment:d,onCloseAutoFocus:f}){return V(e,()=>t(!1)),(0,K.jsx)(_,{open:e,onOpenChange:t,children:(0,K.jsxs)(re,{children:[(0,K.jsx)($e,{}),(0,K.jsxs)(ae,{className:`fixed top-[12dvh] left-1/2 z-50 flex max-h-[min(560px,76dvh)] w-[min(640px,calc(100vw-1.5rem))] -translate-x-1/2 animate-pop-in flex-col overflow-hidden rounded-xl border border-line bg-surface text-fg shadow-pop outline-none`,"aria-describedby":void 0,onCloseAutoFocus:f,"data-sw-palette":`true`,children:[(0,K.jsx)(se,{className:`sr-only`,children:`Go to a page, journey or comment`}),e?(0,K.jsx)(Xw,{groups:n,journeys:r,canEditJourneys:i,comments:a,actions:o,titleOf:s,onRun:e=>{t(!1),e.type===`page`?c(e.id):e.type===`journey`?l(e.id):e.type===`new-journey`?u?.():e.type===`comment`?d?.(e.comment):e.type===`action`&&e.run()}}):null]})]})})}function Xw({groups:e,journeys:t,canEditJourneys:n,comments:r,actions:a,titleOf:o,onRun:s}){let[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(0),f=(0,G.useRef)(null),p=(0,G.useMemo)(()=>qw({query:c,groups:e,journeys:t,canEditJourneys:n,comments:r,actions:a,titleOf:o}),[c,e,t,n,r,a,o]),m=(0,G.useMemo)(()=>p.flatMap(e=>e.items),[p]),h=m[Math.min(u,m.length-1)]||null;(0,G.useEffect)(()=>d(0),[c]),(0,G.useEffect)(()=>{h&&f.current?.querySelector(`[data-sw-option="${CSS.escape(h.id)}"]`)?.scrollIntoView({block:`nearest`})},[h]);let g=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!m.length)return;let t=e.key===`ArrowDown`?1:-1;d(e=>(Math.min(e,m.length-1)+t+m.length)%m.length)}else e.key===`Home`&&e.ctrlKey?d(0):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),h&&s(h.run))},_=e=>`sw-palette-${e.id.replace(/[^\w-]/g,`_`)}`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4`,children:[(0,K.jsx)(Lg,{size:17,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,K.jsx)(`input`,{autoFocus:!0,value:c,onChange:e=>l(e.target.value.slice(0,120)),onKeyDown:g,placeholder:`Go to a page, journey or #comment...`,className:`h-13 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-faint lg:h-12 lg:text-[15px]`,role:`combobox`,"aria-expanded":`true`,"aria-controls":`sw-palette-list`,"aria-activedescendant":h?_(h):void 0,"aria-autocomplete":`list`,"aria-label":`Search the board`,"data-sw-palette-input":`true`}),(0,K.jsx)(i,{className:`hidden shrink-0 lg:inline-flex`,children:`Esc`})]}),(0,K.jsxs)(`div`,{ref:f,id:`sw-palette-list`,role:`listbox`,"aria-label":`Results`,className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:[p.map(e=>(0,K.jsxs)(`div`,{role:`presentation`,className:`pb-1`,children:[(0,K.jsx)(`p`,{role:`presentation`,className:`px-2.5 pt-2 pb-1 text-[11px] font-medium tracking-wide text-faint uppercase`,children:e.label}),e.items.map(e=>{let t=e===h,n=e.icon;return(0,K.jsxs)(`div`,{id:_(e),role:`option`,"aria-selected":t,className:U(`flex min-h-11 cursor-default items-center gap-3 rounded-lg px-2.5 py-1.5 select-none lg:min-h-10`,t?`bg-accent/10 text-fg`:`text-fg`),onMouseMove:()=>{let t=m.indexOf(e);t!==u&&d(t)},onClick:()=>s(e.run),"data-sw-option":e.id,children:[(0,K.jsx)(`span`,{className:U(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,t?`border-accent/30 bg-surface text-accent`:`border-line bg-surface-2 text-muted`),"aria-hidden":`true`,children:(0,K.jsx)(n,{size:14})}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.title}),e.detail?(0,K.jsx)(`span`,{className:U(`block truncate text-xs text-muted`,e.kind===`page`&&`font-mono text-[11px]`),children:e.detail}):null]}),e.meta?(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.meta}):null,t?(0,K.jsx)(rh,{size:14,className:`hidden shrink-0 text-muted lg:block`,"aria-hidden":`true`}):null]},e.id)}),e.more?(0,K.jsxs)(`p`,{role:`presentation`,className:`px-2.5 py-1 text-xs text-faint`,children:[e.more,` more pages: type to find them.`]}):null]},e.id)),m.length?null:(0,K.jsxs)(`p`,{className:`px-3 py-8 text-center text-sm text-muted`,"data-sw-palette-empty":`true`,children:[`Nothing matches "`,c.trim(),`".`]})]}),(0,K.jsxs)(`div`,{className:`hidden items-center gap-4 border-t border-line bg-surface-2/50 px-4 py-2 text-xs text-muted lg:flex`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(i,{children:`↑`}),(0,K.jsx)(i,{children:`↓`}),` to move`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(i,{children:`↵`}),` to open`]}),(0,K.jsx)(`span`,{className:`ml-auto`,children:`#12 finds comment 12`})]})]})}var Zw=Object.freeze({id:null,pinned:!1,via:null,swap:!1});function Qw({onChange:e,openDelay:t=150,closeDelay:n=250,setTimer:r=(e,t)=>setTimeout(e,t),clearTimer:i=e=>clearTimeout(e)}={}){let a=Zw,o=null,s=()=>{o!==null&&i(o),o=null},c=(e,t)=>{s(),o=r(()=>{o=null,e()},t)},l=t=>{a=t,e?.(a)},u=()=>{s(),a.id!==null&&l(Zw)};return{get state(){return a},enterIcon(e){a.pinned||(s(),a.id!==e&&(a.id===null?c(()=>l({id:e,pinned:!1,via:`hover`,swap:!1}),t):l({id:e,pinned:!1,via:`hover`,swap:!0})))},leave(){a.pinned||(a.id===null?s():c(u,n))},enterPanel(){a.pinned||s()},toggle(e,t=`click`){s(),a.id===e&&a.pinned?u():l({id:e,pinned:!0,via:t,swap:!1})},close:u,dispose:s}}function $w({anchorTop:e,viewportHeight:t,margin:n=8,minHeight:r=320}){let i=Math.max(0,t-n*2),a=t-Math.max(e,n)-n;return Math.round(Math.min(i,Math.max(a,Math.min(r,i))))}var eT=`shapewall.lastBoard`,tT=`shapewall.sidebar`,nT=`shapewall.sidebarWidth`,rT=208,iT=420,aT=16,oT=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``)?`⌘B`:`Ctrl B`;function sT(e){try{typeof e==`string`&&e.startsWith(`/`)&&window.localStorage.setItem(eT,e)}catch{}}function cT(e){try{let t=window.localStorage.getItem(tT);return t===`expanded`||t!==`collapsed`&&e}catch{return e}}function lT(e){let t=Math.max(rT,Math.min(iT,Math.floor(window.innerWidth*.4)));return Math.min(t,Math.max(rT,Math.round(e)))}function uT(){try{let e=Number(window.localStorage.getItem(nT));return Number.isFinite(e)&&e>0?lT(e):256}catch{return 256}}function dT(e){try{e===256?window.localStorage.removeItem(nT):window.localStorage.setItem(nT,String(e))}catch{}}function fT(){let[e,t]=(0,G.useState)(uT),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=()=>t(e=>lT(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let a=e=>{let n=lT(e);t(n),dT(n)},o={onPointerDown:t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i.current={x:t.clientX,width:e},r(!0))},onPointerMove:e=>{i.current&&t(lT(i.current.width+e.clientX-i.current.x))},onPointerUp:e=>{i.current&&(a(i.current.width+e.clientX-i.current.x),i.current=null,r(!1))},onDoubleClick:()=>a(256),onKeyDown:t=>{let n=t.shiftKey?64:aT;if(t.key===`ArrowRight`)a(e+n);else if(t.key===`ArrowLeft`)a(e-n);else if(t.key===`Home`)a(256);else return;t.preventDefault()}};return o.onPointerCancel=o.onPointerUp,{width:e,dragging:n,handle:o}}var pT=e=>!!(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)||e.closest?.(`[contenteditable="true"]`)));function mT(e=!0,t=!0){let[n,r]=(0,G.useState)(()=>cT(t)),i=(0,G.useCallback)(()=>r(e=>{try{window.localStorage.setItem(tT,e?`collapsed`:`expanded`)}catch{}return!e}),[]);return(0,G.useEffect)(()=>{if(!e)return;let t=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`b`||pT(e.target)||document.querySelector(`[role="dialog"]:not([data-sw-rail-flyout])`)||(e.preventDefault(),i())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,i]),[n,i,r]}function hT(e,t){return U(`relative flex items-center rounded-md outline-none transition-colors focus-visible:outline-2 focus-visible:outline-accent`,e?`h-8 w-full gap-2.5 px-2.5 text-left text-[13px] font-medium`:`h-10 w-10 justify-center rounded-lg`,t?`bg-accent/10 text-fg`:`text-muted hover:bg-surface-2 hover:text-fg`)}function gT({item:e,expanded:t,link:n,flyouts:r}){let{id:a,label:o,icon:s,href:c,to:l,onSelect:u,active:d,count:f,shortcut:m,flyout:h,...g}=e;if(!t&&h&&r)return(0,K.jsx)(bT,{item:e,flyouts:r});let _=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(s,{size:t?16:19,"aria-hidden":`true`,className:U(`shrink-0`,d&&`text-accent`)}),t?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o}):null,t&&f?(0,K.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-faint tabular`,children:f}):null]}),v={className:hT(t,d),"aria-label":t?void 0:o,"aria-current":d?`page`:void 0,"data-sw-rail-item":a,...g},y=l&&n?(0,K.jsx)(n,{to:l,...v,children:_}):c?(0,K.jsx)(`a`,{href:c,...v,children:_}):(0,K.jsx)(`button`,{type:`button`,onClick:u,...v,children:_});return(0,K.jsx)(`li`,{children:t?y:(0,K.jsx)(p,{content:m?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[o,(0,K.jsx)(i,{children:m})]}):o,side:`right`,children:y})})}var _T=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,vT=e=>[...e.querySelectorAll(_T)].filter(e=>e.getClientRects().length>0);function yT(e,t){let n=vT(document).filter(e=>!t?.contains(e));(n[n.indexOf(e)+1]||e).focus()}function bT({item:e,flyouts:t}){let{id:n,label:r,icon:i,active:a,flyout:o}=e,{state:s,intent:c,width:l}=t,u=Object.fromEntries(Object.entries(e).filter(([e])=>e.startsWith(`data-`))),f=(0,G.useId)(),p=(0,G.useRef)(null),m=(0,G.useRef)(null),h=s.id===n,[g,_]=(0,G.useState)(null);(0,G.useLayoutEffect)(()=>{if(!h)return;let e=()=>{let e=p.current?.getBoundingClientRect().top??0;_($w({anchorTop:e,viewportHeight:window.innerHeight}))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[h]),(0,G.useEffect)(()=>{if(!h)return;let e=e=>{m.current?.contains(e.target)||p.current?.contains(e.target)||c.close()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[h,c]);let v=h&&s.pinned;(0,G.useEffect)(()=>{if(!v)return;let e=requestAnimationFrame(()=>{let e=m.current;e&&!e.contains(document.activeElement)&&(vT(e)[0]||e).focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[v]);let b=(0,G.useCallback)(()=>{let e=!!m.current?.contains(document.activeElement);c.close(),e&&p.current?.focus({preventScroll:!0})},[c]),x=e=>t=>{t.pointerType!==`touch`&&e()},S=e=>{if(e.key!==`Tab`||e.defaultPrevented)return;let t=vT(m.current);t.length&&(e.shiftKey&&document.activeElement===t[0]?(e.preventDefault(),p.current?.focus()):!e.shiftKey&&document.activeElement===t[t.length-1]&&(e.preventDefault(),c.close(),yT(p.current,m.current)))};return(0,K.jsx)(`li`,{children:(0,K.jsxs)(te,{open:h,onOpenChange:e=>{e||c.close()},children:[(0,K.jsx)(d,{asChild:!0,children:(0,K.jsx)(`button`,{ref:p,type:`button`,className:hT(!1,a||h),"aria-label":r,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":h?f:void 0,"aria-current":a?`page`:void 0,"data-sw-rail-item":n,"data-sw-rail-flyout-trigger":n,"data-state":h?s.pinned?`pinned`:`open`:`closed`,...u,onPointerEnter:x(()=>c.enterIcon(n)),onPointerLeave:x(()=>c.leave()),onClick:e=>c.toggle(n,e.detail===0?`key`:`click`),onKeyDown:e=>{e.key===`ArrowRight`&&(e.preventDefault(),v||c.toggle(n,`key`))},children:(0,K.jsx)(i,{size:19,"aria-hidden":`true`,className:U(`shrink-0`,a&&`text-accent`)})})}),(0,K.jsx)(Fe,{children:(0,K.jsx)(y,{ref:m,id:f,side:`right`,align:`start`,sideOffset:12,collisionPadding:8,"aria-label":r,tabIndex:-1,className:U(`sw-rail-flyout z-40 flex flex-col overflow-y-auto overscroll-contain rounded-lg border border-line bg-surface p-2 text-fg shadow-pop outline-none`,`[&_[data-sw-pages-sidebar]]:border-t-0 [&_[data-sw-pages-sidebar]]:pt-0`,s.swap&&`sw-rail-flyout-swap`),style:{width:l,maxHeight:g??void 0},"data-sw-rail-flyout":n,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:e=>{e.preventDefault();let t=s.pinned||m.current?.contains(document.activeElement);c.close(),t&&p.current?.focus({preventScroll:!0})},onInteractOutside:e=>{p.current?.contains(e.target)&&e.preventDefault()},onPointerEnter:x(()=>c.enterPanel()),onPointerLeave:x(()=>c.leave()),onKeyDown:S,children:o({close:b})})})]})})}function xT({items:e,expanded:t,link:n,label:r,flyouts:i,flush:a}){return e.length?(0,K.jsxs)(`div`,{className:U(`w-full`,!a&&`border-t border-line pt-2`),children:[t&&r?(0,K.jsx)(`p`,{className:`px-2.5 pb-1 text-xs font-semibold text-faint`,children:r}):null,(0,K.jsx)(`ul`,{className:U(`flex flex-col`,t?`gap-0.5`:`items-center gap-1`),children:e.map(e=>(0,K.jsx)(gT,{item:e,expanded:t,link:n,flyouts:i},e.id))})]}):null}function ST(e,t){let[n,r]=(0,G.useState)(()=>({id:null,pinned:!1,via:null,swap:!1})),i=(0,G.useRef)(null);return i.current||=Qw({onChange:r}),(0,G.useEffect)(()=>()=>i.current.dispose(),[]),(0,G.useEffect)(()=>{e&&i.current.close()},[e]),{state:n,intent:i.current,width:t}}function CT({expanded:e,onToggle:t,home:n,homeTo:r,homeLabel:a=`Shapewall`,title:o,logo:s,items:c=[],sections:l=[],sectionsLabel:u,link:d,profile:f,children:m,className:h}){let g=r&&d?d:`a`,_=r&&d?{to:r}:{href:n},v=e?`Collapse sidebar`:`Expand sidebar`,{width:y,dragging:b,handle:x}=fT(),S=ST(e,y),C=e?[]:l.filter(e=>!e.flyout),w=C.length?c.find(e=>e.active):null,T=w?c.map(e=>e===w?{...e,flyout:({close:t})=>(0,K.jsx)(`div`,{onClick:e=>{e.target.closest?.(`[data-sw-rail-item]`)&&setTimeout(t,0)},children:(0,K.jsx)(xT,{items:C,expanded:!0,link:d,label:u||e.label,flush:!0})})}:e):c,E=w?l.filter(e=>e.flyout):l;return(0,K.jsxs)(`div`,{className:U(`relative flex shrink-0`,h),children:[(0,K.jsxs)(`nav`,{"aria-label":`Shapewall`,className:U(`flex flex-col gap-2 overflow-hidden border-r border-line bg-surface py-2`,e?`px-2`:`w-[52px] items-center`),style:e?{width:y}:void 0,"data-sw-app-rail":e?`expanded`:`collapsed`,children:[(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-1`,e?`h-10`:`flex-col`),children:[(0,K.jsx)(p,{content:e?null:a,side:`right`,children:(0,K.jsx)(g,{..._,className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":a,"data-sw-rail-home":`true`,children:s})}),e?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,"data-sw-rail-title":`true`,children:o||`Shapewall`}):null,(0,K.jsx)(p,{content:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[v,(0,K.jsx)(i,{children:oT})]}),side:`right`,children:(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted outline-none hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":v,"aria-expanded":e,"data-sw-sidebar-toggle":`true`,children:e?(0,K.jsx)(_g,{size:17,"aria-hidden":`true`}):(0,K.jsx)(yg,{size:17,"aria-hidden":`true`})})})]}),(0,K.jsx)(xT,{items:T,expanded:e,link:d,flyouts:S}),(0,K.jsxs)(`div`,{className:U(`flex min-h-0 flex-1 flex-col gap-2`,e?`overflow-y-auto in-[.sw-scrollbars]:mr-[calc(-1*var(--scrollbar-size))]`:`w-full`),children:[(0,K.jsx)(xT,{items:E,expanded:e,link:d,label:u,flyouts:S}),e?m:null]}),f?(0,K.jsx)(`div`,{className:U(`w-full shrink-0 border-t border-line pt-2`,!e&&`flex justify-center`),children:f(e)}):null]}),e?(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":y,"aria-valuemin":rT,"aria-valuemax":iT,tabIndex:0,"aria-description":`Drag or use the arrow keys to resize. Double-click or press Home to reset.`,className:`group absolute inset-y-0 -right-1.5 z-20 w-3 cursor-col-resize touch-none outline-none`,"data-sw-sidebar-handle":`true`,...x,children:(0,K.jsx)(`span`,{"aria-hidden":`true`,className:U(`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-accent opacity-0 transition-opacity group-hover:opacity-60 group-focus-visible:opacity-100`,b&&`opacity-100`)})}):null,b?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null]})}function wT({count:e,corner:t=!1}){return e?(0,K.jsxs)(`span`,{className:U(`inline-flex min-w-5 items-center justify-center rounded-full bg-bad px-1.5 text-[11px] leading-5 font-semibold text-bad-fg tabular`,t?`pointer-events-none absolute -top-1.5 -right-1.5`:`ml-1`),"data-sw-broken-links-badge":e,children:[e,(0,K.jsxs)(`span`,{className:`sr-only`,children:[` broken link`,e===1?``:`s`]})]}):null}var TT=e=>e.status?String(e.status):`No answer`;function ET({items:e}){let[t,n]=(0,G.useState)(!1),r=e.length;return(0,K.jsx)(`div`,{className:`absolute top-2 left-2 z-30 max-w-[calc(100%-1rem)] max-lg:top-[4.75rem]`,"data-sw-broken-links":`true`,children:(0,K.jsxs)(Ze,{open:t,onOpenChange:n,children:[(0,K.jsx)(P,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:U(`inline-flex h-9 max-w-full items-center gap-2 rounded-full border border-bad/40 bg-surface pr-2.5 pl-2 text-xs font-medium text-fg shadow-pop transition-colors hover:bg-surface-2`,`focus-visible:outline-2 focus-visible:outline-accent [@media(pointer:coarse)]:h-11`),"aria-expanded":t,"data-sw-broken-links-toggle":`true`,children:[(0,K.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-bad/10 text-bad`,children:(0,K.jsx)(Vh,{size:12,"aria-hidden":`true`})}),(0,K.jsxs)(`span`,{className:`truncate`,children:[r,` broken link`,r===1?``:`s`]}),(0,K.jsx)(`span`,{className:`hidden shrink-0 font-normal text-muted sm:inline`,children:`from the last capture`}),(0,K.jsx)(R,{size:13,className:U(`shrink-0 text-faint transition-transform`,t&&`rotate-180`),"aria-hidden":`true`})]})}),(0,K.jsxs)(Ye,{align:`start`,className:`w-[min(26rem,calc(100vw-1.5rem))] p-0`,"aria-label":`Broken links`,children:[(0,K.jsxs)(`div`,{className:`border-b border-line px-3 py-2.5`,children:[(0,K.jsxs)(`p`,{className:`text-[13px] font-semibold text-fg`,children:[r,` link`,r===1?``:`s`,` lead`,r===1?`s`:``,` to an error`]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:`Found on the pages of the last capture. Fix the link or publish the page.`})]}),(0,K.jsx)(`ul`,{className:`max-h-72 divide-y divide-line overflow-auto`,children:e.slice(0,100).map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2`,"data-sw-broken-link":e.path??e.url,children:[(0,K.jsx)(`span`,{className:`mt-0.5 inline-flex h-5 shrink-0 items-center rounded bg-bad/10 px-1.5 font-mono text-[11px] font-semibold text-bad tabular`,children:TT(e)}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate font-mono text-xs text-fg`,children:e.path??e.url}),(e.from||[]).length?(0,K.jsxs)(`span`,{className:`mt-0.5 block text-[11px] text-muted`,children:[`Linked from `,(e.from||[]).join(`, `)]}):null]})]},e.url))}),r>100?(0,K.jsx)(`p`,{className:`border-t border-line px-3 py-2 text-[11px] text-faint`,children:`Showing the first 100.`}):null]})]})})}function DT({label:e,keys:t}){return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,t.map(e=>(0,K.jsx)(i,{children:e},e))]})}function OT({data:e,capture:t}){let n=e?.manifest?.capturedAt,r=!t?.running&&t?.state===`failed`&&t.error,i=t?.running?`Capturing${t.total?` ${t.done||0} of ${t.total}`:``}`:n?`Captured ${De(n)}`:`Not captured yet`;return(0,K.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs whitespace-nowrap text-muted`,"data-sw-captured":`true`,children:t?.running?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[(0,K.jsx)(fe,{size:12}),(0,K.jsx)(`span`,{className:`tabular`,children:t.total?`${t.done||0}/${t.total}`:`Capturing`}),(0,K.jsx)(`span`,{className:`sr-only`,children:i})]}):r?(0,K.jsx)(p,{content:`Last capture failed: ${t.error}`,side:`bottom`,children:(0,K.jsxs)(`span`,{tabIndex:0,className:`inline-flex h-6 items-center gap-1.5 rounded-full bg-bad/10 px-2 font-medium text-bad outline-none focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-capture-failed":`true`,children:[(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bad`,"aria-hidden":`true`}),` Capture failed`]})}):(0,K.jsx)(p,{content:i,side:`bottom`,children:(0,K.jsx)(`span`,{tabIndex:0,role:`img`,"aria-label":i,className:`inline-flex h-6 w-4 items-center justify-center rounded-full outline-none focus-visible:outline-2 focus-visible:outline-accent`,children:(0,K.jsx)(`span`,{className:U(`h-2 w-2 rounded-full`,n?`bg-ok`:`bg-faint`),"aria-hidden":`true`})})})})}function kT({data:e,capture:t}){let n=e?.manifest?.capturedAt;return(0,K.jsxs)(`p`,{className:`text-xs whitespace-nowrap text-muted`,"data-sw-captured":`true`,children:[t?.running?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(fe,{size:12}),` Capturing`,t.total?` ${t.done||0}/${t.total}`:``]}):n?`Captured ${De(n)}`:`Not captured yet`,!t?.running&&t?.state===`failed`&&t.error?(0,K.jsxs)(`span`,{className:`ml-2 text-bad`,children:[`Last capture failed: `,t.error]}):null]})}var AT=e=>e.preventDefault(),jT={light:t_,dark:pg,system:dg},MT=`h-11 justify-center gap-1.5 rounded-md border border-transparent px-1 text-xs lg:h-9 data-[state=checked]:border-accent data-[state=checked]:bg-accent/10 data-[state=checked]:text-fg`;function NT({name:t,avatarUrl:r=null,detail:i=null,items:a=[],workspaces:o=null,viewAs:s=null,showName:c=!1,label:u=`Profile and appearance`,about:d=!0,triggerClassName:f,side:p=`bottom`,align:m=`end`,...g}){let[_,v]=$C(),y=(0,G.useRef)(null);return(0,K.jsxs)(we,{children:[(0,K.jsx)(x,{asChild:!0,children:(0,K.jsxs)(n,{ref:y,variant:`ghost`,size:`touch`,className:U(`shrink-0 gap-2 px-1.5 lg:h-10`,f),"aria-label":t?`${u}: ${t}`:u,"data-sw-profile-menu":!0,...g,children:[(0,K.jsx)(le,{name:t||`?`,src:r,className:`h-8 w-8`}),c&&t?(0,K.jsx)(`span`,{className:`hidden max-w-40 truncate text-sm text-fg md:inline`,children:t}):null]})}),(0,K.jsxs)(e,{className:`w-72`,side:p,align:m,"data-sw-profile-content":!0,children:[t||i?(0,K.jsxs)(T,{className:`normal-case`,children:[t?(0,K.jsx)(`span`,{className:`block truncate text-[13px] font-medium tracking-normal text-fg`,children:t}):null,i?(0,K.jsx)(`span`,{className:`block truncate text-xs font-normal tracking-normal text-muted`,children:i}):null]}):null,a.length?(0,K.jsxs)(K.Fragment,{children:[t||i?(0,K.jsx)(h,{}):null,(0,K.jsx)(Se,{children:a.map(({id:e,label:t,icon:n,onSelect:r,tone:i,hint:a,...o})=>(0,K.jsxs)(G.Fragment,{children:[(0,K.jsxs)(C,{onSelect:r,tone:i,"data-sw-profile-item":e,"aria-describedby":a?`sw-profile-hint-`+e:void 0,...o,children:[n?(0,K.jsx)(n,{size:14,"aria-hidden":`true`}):null,` `,t]}),a?(0,K.jsx)(`p`,{id:`sw-profile-hint-`+e,className:`px-2 pb-1.5 text-xs text-muted`,"data-sw-profile-hint":e,children:a}):null]},e))})]}):null,o?.list?.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(h,{}),(0,K.jsx)(T,{children:`Workspace`}),o.list.map(e=>(0,K.jsxs)(C,{onSelect:()=>o.onPick(e.id),"data-sw-profile-workspace":e.id,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.roleLabel?(0,K.jsx)(`span`,{className:`text-xs text-faint`,children:e.roleLabel}):null,e.id===o.current?(0,K.jsx)(ne,{size:14,className:`!text-accent`,"aria-label":`Current`}):null]},e.id))]}):null,s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(h,{}),(0,K.jsx)(T,{children:`View as (demo)`}),(0,K.jsx)(k,{value:s.value,onValueChange:s.onChange,children:s.options.map(e=>(0,K.jsxs)(l,{value:e.id,"data-sw-view-as":e.id,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,K.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]}):null,(0,K.jsx)(h,{}),(0,K.jsx)(T,{children:`Appearance`}),(0,K.jsx)(k,{value:_.mode,onValueChange:e=>v({mode:e}),className:`grid grid-cols-3 gap-1 px-1 pb-1`,"aria-label":`Mode`,children:RC.map(e=>{let t=jT[e.id];return(0,K.jsxs)(l,{value:e.id,indicator:!1,className:MT,onSelect:AT,"data-sw-appearance-mode":e.id,children:[(0,K.jsx)(t,{size:14,"aria-hidden":`true`}),` `,e.label]},e.id)})}),(0,K.jsx)(k,{value:_.theme,onValueChange:e=>v({theme:e}),className:`grid grid-cols-2 gap-1 px-1 pb-1`,"aria-label":`Theme`,children:zC.map(e=>(0,K.jsxs)(l,{value:e.id,indicator:!1,className:U(MT,`justify-start px-2`),onSelect:AT,"data-sw-theme-option":e.id,children:[(0,K.jsx)(`span`,{className:U(`h-4 w-4 shrink-0 rounded-full ring-1 ring-line`,`sw-swatch-${e.id}`),"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))}),d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(h,{}),(0,K.jsxs)(C,{onSelect:()=>sC(y.current),"data-sw-app-about":`menu`,children:[(0,K.jsx)(Fh,{size:14,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`About Shapewall and updates`}),(0,K.jsxs)(`span`,{className:`text-caption text-faint tabular-nums`,"data-sw-app-version":!0,children:[`v`,ZS.version]})]}),(0,K.jsx)(C,{asChild:!0,"data-sw-app-contact":`menu`,children:(0,K.jsxs)(`a`,{href:XS,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(Zh,{size:14,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Contact`})]})})]}):null]})]})}function PT(e){return e?.public?`Visitor, public board (view only)`:e?.guest?`Guest, through a share link`:e?.hosted?[e.user?.handle?`@${e.user.handle}`:null,FT(e.role)].filter(Boolean).join(` · `):`A board on this machine`}var FT=e=>e?e[0].toUpperCase()+e.slice(1):null;function IT({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,side:c,align:l,showName:u,triggerClassName:d}){return(0,K.jsx)(NT,{name:e?.user?.name||t||null,avatarUrl:e?.user?.avatarUrl,detail:PT(e),items:[...e?.buzzAvailable===!0?[{id:`buzz`,label:`Existing Buzz conversation`,icon:Vg,onSelect:n,"data-sw-buzz-open":`true`}]:[],...i?[{id:`account`,label:`Account and security`,icon:d_,onSelect:()=>ke(`/account`)},{id:`console`,label:`Workspace Console`,icon:Um,onSelect:()=>ke(`/console`)}]:a?[{id:`settings`,label:`Settings`,icon:Vg,onSelect:o,"data-sw-settings-open":`profile`}]:[],...e?.shareEnabled?[{id:`share`,label:`Share with your team...`,icon:Um,onSelect:()=>s(!0)}]:[],...e?.consoleUrl&&!e?.guest?[{id:`console`,label:`Workspace Console`,icon:Um,onSelect:()=>ke(e.consoleUrl)}]:[],...e?.public&&typeof e.reportUrl==`string`&&e.reportUrl.startsWith(`mailto:`)?[{id:`report`,label:`Report this board`,icon:xh,onSelect:()=>ke(e.reportUrl)}]:[],...r?[r.resetItem]:[]],viewAs:r?.viewAs||null,side:c,align:l,showName:u,triggerClassName:d})}var LT=[`full`,`search`,`panels`,`view`,`viewport`,`tight`],RT={pad:12,gap:6,zoneGap:20,tightGap:4,tightZoneGap:12,search:{min:240,max:320,icon:32},name:[200,176,152,128,104,104]};function zT(e){let t=t=>e>=LT.indexOf(t);return{search:t(`search`),panels:t(`panels`),view:t(`view`),viewport:t(`viewport`),comment:t(`tight`),tight:t(`tight`)}}function BT(e,t,n=zT(t).tight?RT.tightGap:RT.gap){let r=e.filter(Boolean);if(!r.length)return 0;let i=zT(t);return r.reduce((e,t)=>e+(t.at&&i[t.at]?t.compact:t.full),0)+n*(r.length-1)}function VT({text:e,title:t,viewports:n=[],capture:r=!1,status:i={kind:`dot`},viewer:a=!1,comment:o=!1,panels:s={comments:0,agent:!1,checks:!1},settings:c=!1}){let l=(t,n)=>Math.ceil(e(String(t),n))+1,u={left:[],right:[]};n.length>1&&u.left.push({id:`viewport`,full:6+n.reduce((e,t)=>e+20+l(t,`xs`),0),compact:6+n.length*30,at:`viewport`}),u.left.push({id:`view`,full:41+l(`View`,`ui`),compact:32,at:`view`}),r&&u.left.push({id:`capture`,full:32}),u.left.push({id:`capture-status`,full:i.kind===`running`?18+l(i.progress||`Capturing`,`xs`):i.kind===`failed`?28+l(`Capture failed`,`xs`):16}),a&&u.right.push({id:`viewer`,full:40+l(`Viewer`,`xs`)}),o&&u.right.push({id:`comment`,full:45+l(`Comment`,`ui`),compact:32,at:`comment`});let d=12+l(s.comments,`count`),f=[{full:46+l(`Comments`,`ui`)+d,compact:40+d}];s.agent&&f.push({full:40+l(`Agent`,`ui`),compact:34}),s.checks&&f.push({full:40+l(`Checks`,`ui`),compact:34});let p=2*(f.length-1);return u.right.push({id:`panels`,full:f.reduce((e,t)=>e+t.full,p),compact:f.reduce((e,t)=>e+t.compact,p),at:`panels`}),c&&u.right.push({id:`settings`,full:32}),{name:40+l(t,`name`),left:u.left,right:u.right}}function HT({width:e,name:t,left:n=[],right:r=[],config:i=RT}){let a=Math.max(0,e-2*i.pad),o=LT.length-1,s=e=>{let a=zT(e).tight,o=a?i.tightGap:i.gap,s=BT(n,e,o);return{left:Math.min(t,i.name[e])+(s?o+s:0),right:BT(r,e,o),zoneGap:a?i.tightZoneGap:i.zoneGap}};for(let e=0;e<=o;e+=1){let t=s(e),n=a-2*(Math.max(t.left,t.right)+t.zoneGap);if(e===0){if(n>=i.search.min)return{step:e,centred:!0,search:Math.min(i.search.max,n)}}else if(n>=i.search.icon)return{step:e,centred:!0,search:0}}return{step:o,centred:!1,search:0}}var UT={name:`600 14px`,ui:`500 13px`,xs:`500 12px`,count:`600 11px`},WT;function GT(e,t){return typeof document>`u`||(WT||=document.createElement(`canvas`).getContext(`2d`),!WT)?e.length*8:(WT.font=`${UT[t]} ${getComputedStyle(document.body).fontFamily}`,WT.measureText(e).width)}function KT(e,t){let[n,r]=(0,G.useState)(()=>typeof window>`u`?1280:window.innerWidth);return(0,G.useLayoutEffect)(()=>{let n=e.current;if(!t||!n)return;let i=()=>r(Math.round(n.getBoundingClientRect().width));if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(n),()=>a.disconnect()},[e,t]),n}function qT({showLinks:t,toggleLinks:r,linksTip:i,brokenLinks:a,canCompare:o,comparePair:s,toggleCompare:c,minimapOn:l,toggleMinimap:u,compact:d}){let f=[t,!!s].filter(Boolean).length,m=`pr-2`,g=e=>(0,K.jsx)(`span`,{className:U(`ml-auto inline-flex h-4 w-4 items-center justify-center`,e?`!text-accent`:`opacity-0`),children:(0,K.jsx)(ne,{size:14,className:`!text-accent`,"aria-hidden":`true`})});return(0,K.jsxs)(we,{children:[(0,K.jsx)(p,{content:`View options: links between pages, compare, minimap`,side:`bottom`,children:(0,K.jsx)(x,{asChild:!0,children:(0,K.jsxs)(n,{variant:`ghost`,className:U(`relative h-8 shrink-0 text-[13px] text-fg`,d?`w-8 px-0`:`px-2.5`,f&&`text-accent`),"aria-label":f?`View options, ${f} on`:`View options`,"data-sw-view-menu":`true`,children:[(0,K.jsx)(ph,{size:15,"aria-hidden":`true`}),d?null:`View`,f?(0,K.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-accent ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-view-on":f}):null,(0,K.jsx)(wT,{count:a.length,corner:!0})]})})}),(0,K.jsxs)(e,{align:`center`,className:`w-72`,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-sw-canvas]`)?.focus({preventScroll:!0})},children:[(0,K.jsx)(T,{children:`View`}),(0,K.jsxs)(C,{className:m,role:`menuitemcheckbox`,"aria-checked":t,onSelect:r,"data-sw-links-toggle":`true`,children:[(0,K.jsx)(h_,{size:15,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block`,children:`Links between pages`}),a.length?(0,K.jsxs)(`span`,{className:`block text-xs text-bad`,children:[a.length,` `,a.length===1?`link leads`:`links lead`,` to an error`]}):null]}),g(t)]}),o?(0,K.jsxs)(C,{className:m,role:`menuitemcheckbox`,"aria-checked":!!s,onSelect:c,"data-sw-compare-toggle":`true`,children:[(0,K.jsx)(Ch,{size:15,"aria-hidden":`true`}),` Compare environments`,g(!!s)]}):null,(0,K.jsxs)(C,{className:m,role:`menuitemcheckbox`,"aria-checked":l,onSelect:u,children:[(0,K.jsx)($h,{size:15,"aria-hidden":`true`}),` Minimap`,g(l)]}),(0,K.jsx)(h,{}),(0,K.jsxs)(`p`,{className:`px-2 py-1.5 text-xs text-muted`,children:[i,`.`]})]})]})}function JT({labels:e,allOpen:t,panelHidden:n,chatAvailable:r,chatThread:i,reopenChat:a,checksOpen:o,canChecks:s,openChecks:c,closeChecks:l,updateParams:u}){let d=!n&&!i&&!o,m=`h-8 text-ui`;return(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`Side panel`,children:[(0,K.jsx)(p,{content:`${d?`Hide`:`Show`} comments (${t} open)`,side:`bottom`,children:(0,K.jsxs)(Ae,{variant:`flat`,className:m,pressed:d,onPressedChange:()=>u({panel:n||i||o?null:`off`,chat:null,checks:null,cv:null}),"aria-label":`Comments, ${t} open`,"data-sw-panel-toggle":`true`,children:[(0,K.jsx)(ag,{size:14,"aria-hidden":`true`}),e?`Comments`:null,(0,K.jsx)(`span`,{className:`tabular rounded-full bg-fg/[0.07] px-1.5 text-[11px] leading-4 font-semibold text-fg`,"aria-hidden":`true`,children:t})]})}),r?(0,K.jsx)(p,{content:i?`Close the agent chat`:`Chat with your agent about this board`,side:`bottom`,children:(0,K.jsxs)(Ae,{variant:`flat`,className:m,pressed:!!i,"aria-label":`Agent`,onPressedChange:()=>i?u({chat:null}):a(),"data-sw-chat-toggle":`true`,children:[(0,K.jsx)(f,{size:14,"aria-hidden":`true`}),e?`Agent`:null]})}):null,s?(0,K.jsx)(p,{content:o?`Close the checks`:`Page checks: performance, accessibility, SEO`,side:`bottom`,align:`end`,children:(0,K.jsxs)(Ae,{variant:`flat`,className:m,pressed:!!o,"aria-label":`Checks`,onPressedChange:()=>o?l():c(),"data-sw-checks-toggle":`true`,children:[(0,K.jsx)(xh,{size:14,"aria-hidden":`true`}),e?`Checks`:null]})}):null]})}function YT({wide:e,info:t,boardId:r,boards:i,data:a,localProjects:o,projectsError:s,localName:c,onPickBoard:l,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:m,openSettings:h,setShareOpen:g,modes:_,mode:v,setMode:y,viewportNotice:b,canComment:x,comparePair:S,commentMode:C,setCommentMode:w,openPalette:T,setMenuOpen:E,showLinks:D,toggleLinks:O,linksTip:k,brokenLinks:A,canCompare:j,toggleCompare:M,minimapOn:N,toggleMinimap:P,capture:F,busy:ee,canCapture:I,setCaptureConfirm:L,chatAvailable:R,chatThread:B,reopenChat:te,updateParams:ne,panelHidden:re,checksOpen:ie,allOpen:ae,canChecks:oe,openChecks:se,closeChecks:V,setSheetOpen:H,sidebarTitled:le}){let ue=i.find(e=>e.id===r)?.title||a?.board?.title||r,de=t?.hosted&&t?.project?.url&&t.role!==`guest`?t.project:null,fe=!x&&t?.hosted&&t?.role===`viewer`,pe=x&&!S,he=(0,G.useRef)(null),_e=KT(he,e),ye=F?.running?`running`:F?.state===`failed`&&F.error?`failed`:`dot`,be=F?.running&&F.total?`${F.done||0}/${F.total}`:`Capturing`,xe=_.map(e=>e.label).join(`
28
28
  `),Se=(0,G.useMemo)(()=>HT({width:_e,...VT({text:GT,title:ue,viewports:xe?xe.split(`
29
- `):[],capture:!!I,status:{kind:ye,progress:be},viewer:fe,comment:pe,panels:{comments:ae,agent:!!R,checks:!!oe},settings:!!m})}),[_e,ue,xe,I,ye,be,fe,pe,ae,R,oe,m]),Ce=zT(Se.step),we=(0,K.jsx)(IT,{info:t,localName:c,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:m,openSettings:h,setShareOpen:g}),Te=(0,K.jsxs)(Ue,{value:r,onValueChange:e=>{if(!e.startsWith(`project/`))return l(e);let t=o.find(t=>`project/${t.id}`===e);t?.url&&t.running&&ke(t.url)},children:[(0,K.jsx)(ge,{size:e?`sm`:`touch`,className:e?U(`max-w-72 min-w-0 border-transparent bg-transparent px-2.5 text-sm font-semibold shadow-none hover:bg-surface-2 data-[state=open]:bg-surface-2`,de&&`h-6`):`min-w-0 flex-1 border-transparent bg-transparent px-2 text-[15px] font-semibold shadow-none`,"aria-label":`Board: ${ue}`,"data-sw-picker":`true`,children:(0,K.jsx)(ce,{children:(0,K.jsx)(`span`,{className:`block truncate`,children:ue})})}),(0,K.jsxs)(W,{children:[(0,K.jsxs)(me,{children:[o.length>1||de?(0,K.jsx)(Oe,{children:de?de.name:`This project`}):null,i.map(t=>(0,K.jsx)(Ne,{value:t.id,children:e?`${t.title} · ${t.pageCount} pages`:t.title},t.id))]}),o.length>1?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ve,{}),(0,K.jsxs)(me,{children:[(0,K.jsx)(Oe,{children:`Local projects`}),o.map(e=>(0,K.jsxs)(Ne,{value:`project/${e.id}`,disabled:e.current||!e.running,"data-sw-local-project":e.id,children:[e.title,e.current?` (current)`:e.running?``:` (not running)`]},e.id))]}),o.some(e=>!e.running&&!e.current)?(0,K.jsx)(`p`,{className:`max-w-72 px-2 py-1.5 text-xs text-muted`,children:`Start a stopped project with shapewall serve in its folder.`}):null]}):null,s?(0,K.jsx)(`p`,{className:`max-w-72 px-2 py-1.5 text-xs text-bad`,children:`Could not load local projects. Check the terminal for your project index.`}):null]})]});if(!e)return(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b border-line bg-surface px-2 py-1.5`,"data-sw-toolbar":`compact`,children:[(0,K.jsx)(`h1`,{className:`sr-only`,children:`Shapewall`}),Te,x&&!S?(0,K.jsx)(z,{size:`icon`,variant:C?`default`:`ghost`,className:U(`shrink-0`,!C&&`text-fg`),"aria-pressed":C,onClick:()=>w(e=>!e),label:C?`Stop commenting`:`Comment: tap a page to pin`,"data-sw-comment-mode":`true`,children:(0,K.jsx)(rg,{size:19,"aria-hidden":`true`})}):null,fe?(0,K.jsx)(DC,{compact:!0}):null,(0,K.jsxs)(n,{size:`touch`,variant:`ghost`,className:`shrink-0 gap-1.5 px-2.5 text-fg`,onClick:()=>{V(),H(!0)},"aria-label":`Comments, ${ae} open`,"data-sw-panel-toggle":`true`,children:[(0,K.jsx)(ag,{size:18,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`tabular text-[13px] font-semibold`,children:ae})]}),(0,K.jsx)(z,{size:`icon`,variant:`ghost`,className:`shrink-0 text-fg`,onClick:()=>E(!0),label:R?`More: agent, pages, journeys, screen size`:`More: pages, journeys, screen size`,"data-sw-menu":`true`,children:(0,K.jsx)(lh,{size:19,"aria-hidden":`true`})}),we]});let Ee=_.map(e=>{let t=e.id===`all`?Fg:U_(e.id);return{id:e.id,tooltip:Ce.viewport?e.label:null,label:Ce.viewport?(0,K.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,K.jsx)(t,{size:14,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:e.label})]}):e.label}}),De=(0,K.jsx)(OT,{data:a,capture:F}),Ae=Ce.tight?`gap-1`:`gap-1.5`;return(0,K.jsxs)(`header`,{ref:he,className:U(`grid h-14 shrink-0 items-center border-b border-line bg-surface px-3`,Ce.tight?`gap-x-3`:`gap-x-5`,Se.centred?`grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]`:`grid-cols-[auto_auto_minmax(0,1fr)]`),"data-sw-toolbar":`full`,"data-sw-toolbar-fit":LT[Se.step],"data-sw-toolbar-centred":Se.centred?`true`:`false`,children:[(0,K.jsxs)(`h1`,{className:`sr-only`,children:[`Shapewall: `,ue]}),(0,K.jsxs)(`div`,{className:U(`flex min-w-0 items-center`,Ae),"data-sw-toolbar-zone":`left`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center`,style:Se.centred?void 0:{maxWidth:RT.name.at(-1)},children:[de&&!le?(0,K.jsx)(OC,{project:de}):null,Te]}),I?null:De,_.length>1?(0,K.jsx)(`span`,{className:U(`shrink-0 rounded-md`,b&&`animate-flash`),"data-sw-viewport-flash":b?b.to:void 0,children:(0,K.jsx)(Ve,{label:`Screen size`,options:Ee,value:v,onChange:y,itemClassName:Ce.viewport?`px-2`:void 0})},b?.at||`still`):null,(0,K.jsx)(qT,{showLinks:D,toggleLinks:O,linksTip:k,brokenLinks:A,canCompare:j,comparePair:S,toggleCompare:M,minimapOn:N,toggleMinimap:P,compact:Ce.view}),I?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(z,{variant:`ghost`,className:`shrink-0 text-fg`,disabled:F?.running||ee,onClick:()=>L(!0),label:`Capture now`,tooltip:`Recapture every page`,side:`bottom`,"data-sw-capture":`true`,children:(0,K.jsx)(Gm,{size:16,"aria-hidden":`true`})}),De]}):null]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center`,"data-sw-toolbar-zone":`center`,children:(0,K.jsx)(p,{content:(0,K.jsx)(DT,{label:`Go to a page, journey or comment`,keys:[Vw]}),side:`bottom`,children:(0,K.jsx)(Jw,{onOpen:T,compact:Ce.search,style:Ce.search?void 0:{width:Se.search}})})}),(0,K.jsxs)(`div`,{className:U(`flex min-w-0 items-center justify-end`,Ae),"data-sw-toolbar-zone":`right`,children:[fe?(0,K.jsx)(DC,{}):null,pe?(0,K.jsx)(p,{content:(0,K.jsx)(DT,{label:C?`Stop commenting`:`Click a page to pin a comment`,keys:C?[`C`,`Esc`]:[`C`]}),side:`bottom`,children:(0,K.jsxs)(n,{variant:`default`,className:U(`h-8 shrink-0 text-[13px]`,Ce.comment?`w-8 px-0`:`px-3`,C&&`bg-accent/90 shadow-[inset_0_1px_3px_rgb(0_0_0/0.25)] ring-2 ring-accent/30`),"aria-pressed":C,onClick:()=>w(e=>!e),"data-sw-comment-mode":`true`,children:[(0,K.jsx)(rg,{size:15,"aria-hidden":`true`}),Ce.comment?(0,K.jsx)(`span`,{className:`sr-only`,children:`Comment`}):`Comment`]})}):null,(0,K.jsx)(JT,{labels:!Ce.panels,allOpen:ae,panelHidden:re,chatAvailable:R,chatThread:B,reopenChat:te,checksOpen:ie,canChecks:oe,openChecks:se,closeChecks:V,updateParams:ne}),m?(0,K.jsx)(z,{variant:`ghost`,className:`shrink-0 text-fg`,onClick:h,label:`Agent settings`,tooltip:`Agent settings: which agent the chat uses`,side:`bottom`,"data-sw-settings-open":`true`,children:(0,K.jsx)(Vg,{size:16,"aria-hidden":`true`})}):null]})]})}function XT({menuOpen:e,setMenuOpen:t,data:r,chatAvailable:i,chatThread:a,reopenChat:o,groupedPages:s,jumpToPage:c,modes:l,mode:u,setMode:d,journeys:p,journey:m,canEditJourneys:h,openJourney:g,startBuilder:_,canChecks:v,openChecks:y,showLinks:b,toggleLinks:x,brokenLinks:S,canCompare:C,comparePair:w,toggleCompare:T,settingsAvailable:E,openSettings:D,capture:O,canCapture:k,busy:A,setCaptureConfirm:j}){let N=`mb-1.5 flex items-center gap-1 text-[11px] font-medium tracking-wide text-faint uppercase`;return(0,K.jsx)(M,{open:e,onClose:()=>t(!1),title:r?.board?.title||`Board`,children:(0,K.jsxs)(`div`,{className:`space-y-5 p-5`,children:[l.length>1?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:N,children:`Screen size`}),(0,K.jsx)(Ve,{label:`Screen size`,options:l,value:u,onChange:e=>{d(e),t(!1)},large:!0})]}):null,i?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:a?`default`:`secondary`,onClick:()=>{t(!1),o()},"data-sw-chat-toggle":`true`,children:[(0,K.jsx)(f,{size:16,"aria-hidden":`true`}),` Chat with your agent`]}):null,(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:N,children:[(0,K.jsx)(qh,{size:12,"aria-hidden":`true`}),` Go to a page`]}),(0,K.jsx)(zw,{groups:s,onPick:e=>{t(!1),c(e)}})]}),p.length||h?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:N,children:`Journeys`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-sw-journey-menu":`true`,children:[p.map(e=>(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:m?.id===e.id?`default`:`secondary`,onClick:()=>{t(!1),g(e.id)},"data-sw-journey-open":e.id,children:[(0,K.jsx)(Ng,{size:15,"aria-hidden":`true`}),` `,(0,K.jsx)(`span`,{className:`truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`ml-auto text-xs opacity-70`,children:e.branching?`${e.paths?.length||2} paths`:`${e.steps.length} steps`})]},e.id)),h?(0,K.jsxs)(n,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{t(!1),_()},children:[(0,K.jsx)(Cg,{size:15,"aria-hidden":`true`}),` New journey`]}):null]})]}):null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`p`,{className:N,children:`View`}),v?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),y()},"data-sw-checks-toggle":`true`,children:[(0,K.jsx)(xh,{size:16,"aria-hidden":`true`}),`Checks`]}):null,(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,"aria-pressed":b,variant:b?`default`:`secondary`,onClick:()=>{t(!1),x()},"data-sw-links-toggle":`true`,children:[(0,K.jsx)(h_,{size:15,"aria-hidden":`true`}),` `,b?`Hide links between pages`:`Show links between pages`,(0,K.jsx)(wT,{count:S.length})]}),C?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,"aria-pressed":!!w,variant:w?`default`:`secondary`,onClick:()=>{t(!1),T()},"data-sw-compare-toggle":`true`,children:[(0,K.jsx)(Ch,{size:15,"aria-hidden":`true`}),` `,w?`Leave compare mode`:`Compare environments`]}):null,E?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),D()},"data-sw-settings-open":`true`,children:[(0,K.jsx)(Vg,{size:15,"aria-hidden":`true`}),` Agent settings`]}):null]}),(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-line pt-4`,children:[(0,K.jsx)(kT,{data:r,capture:O}),k?(0,K.jsxs)(n,{size:`touch`,className:`w-full`,disabled:O?.running||A,onClick:()=>{t(!1),j(!0)},"data-sw-capture":`true`,children:[(0,K.jsx)(Gm,{size:15,"aria-hidden":`true`}),` Capture now`]}):null]})]})})}function ZT({wide:e,commentMode:t,canComment:r,readyKeys:i,setCommentMode:a,showLinks:o,activePage:s,shownSteps:c,data:l,presentPages:u,hiddenLinkTargets:d,showAllLinks:f,targetTitle:p,updateParams:m,tipOpen:h,tryOpen:g,journey:_,builder:v,viewportNotice:y,dismissTip:b,modes:x,setMode:S,comparePair:C}){let w=e=>x.find(t=>t.id===e)?.label||e,T=e?`Scroll or drag to move, Ctrl+scroll or pinch to zoom. Click a page for its actions${r&&!C?`, or press C to comment`:``}.`:`Pinch to zoom. Tap a page for its actions${r&&!C?`, or the comment button to pin a note`:``}.`;return(0,K.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-30 flex flex-col items-center gap-1.5 px-2`,"data-sw-canvas-notes":`true`,children:[t&&r?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-full bg-accent py-0.5 pr-0.5 pl-3 text-xs font-medium text-accent-fg shadow-pop`,role:`status`,"data-sw-comment-hint":i.size?`element`:`page`,children:[(0,K.jsx)(rg,{size:13,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0`,children:i.size?e?`Click an element on the live page to comment on it.`:`Tap an element on the live page to comment on it.`:e?`Click a page to comment. Zoom in until the page goes live to pin it to an element.`:`Tap a page to pin a comment.`}),(0,K.jsxs)(n,{size:e?`xs`:`touch`,variant:`inverse`,className:`shrink-0 rounded-full`,onClick:()=>a(!1),"data-sw-comment-hint-done":`true`,children:[`Done`,e?` (Esc)`:``]})]}):null,o&&!s&&!c&&w_(l?.links,u,d)>150?(0,K.jsx)(`p`,{className:`w-max max-w-full rounded-full bg-surface px-3 py-1 text-xs font-medium text-muted shadow-pop`,"data-sw-links-hint":`true`,children:e?`Hover or select a page to see its links`:`Tap a page to see its links`}):null,o&&(d?.size||f)?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs text-muted shadow-pop`,"data-sw-links-global":f?`shown`:`hidden`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:f?`Showing every link, the nav and footer ones too.`:`Hiding the nav and footer links (to ${[...d].slice(0,3).map(e=>p(e)).join(`, `)}${d.size>3?` and ${d.size-3} more`:``}).`}),(0,K.jsx)(n,{size:e?`xs`:`touch`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:()=>m({la:f?null:`1`}),"data-sw-links-global-toggle":`true`,children:f?`Hide them`:`Show them`})]}):null,h&&!g&&l&&!t&&!o&&!_&&!v&&!y?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-1.5 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs text-fg shadow-pop`,role:`note`,"data-sw-tip":`true`,children:[(0,K.jsx)(zh,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0`,children:T}),(0,K.jsx)(z,{size:e?`icon-xs`:`icon`,variant:`ghost`,className:`shrink-0 rounded-full shadow-none`,onClick:b,label:`Dismiss the tip`,"data-sw-tip-dismiss":`true`,children:(0,K.jsx)(B,{size:14,"aria-hidden":`true`})})]}):null,y?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-lg border border-line bg-surface py-1 pr-1 pl-3 text-xs text-fg shadow-pop`,role:`status`,"data-sw-viewport-notice":y.to,children:[(0,K.jsxs)(`span`,{className:`min-w-0`,children:[`Showing `,w(y.to),`: comment #`,y.id,` is on the `,y.to,` capture.`]}),(0,K.jsxs)(n,{size:e?`xs`:`touch`,variant:`secondary`,className:`shrink-0`,onClick:()=>S(y.from),"data-sw-viewport-notice-back":`true`,children:[`Back to `,w(y.from)]})]}):null]})}function QT(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{e||r(!1)},[e]),(0,G.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>t(t=>t===e?null:t),6e3);return()=>window.clearTimeout(r)},[e,n]),[e,t,r]}function $T({toast:e,setToast:t,onHold:r,wide:i,raised:a}){return e?(0,K.jsxs)(`div`,{onMouseEnter:()=>r?.(!0),onMouseLeave:()=>r?.(!1),onFocus:()=>r?.(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r?.(!1)},className:U(`absolute inset-x-0 z-[80] mx-auto flex w-max max-w-[calc(100%-1rem)] animate-pop-in items-center gap-2 rounded-lg bg-fg py-1 pr-1 pl-3 text-xs font-medium text-surface shadow-pop`,a?i?`bottom-28`:`bottom-44`:i?`bottom-4`:`bottom-16`),role:`status`,"data-sw-toast":`true`,children:[(0,K.jsx)(`span`,{className:`min-w-0`,children:e.text}),e.undo?(0,K.jsx)(n,{size:i?`xs`:`touch`,variant:`inverse`,onClick:()=>{e.undo(),t(null)},"data-sw-toast-undo":`true`,children:`Undo`}):null,(0,K.jsx)(z,{size:i?`icon-xs`:`icon`,variant:`inverse`,onClick:()=>t(null),label:`Dismiss`,children:(0,K.jsx)(B,{size:13,"aria-hidden":`true`})})]},e.at):null}function eE({notice:e,setNotice:t,wide:r}){return e?(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-3 border-b border-line px-4 py-2 text-xs`,e.tone===`bad`?`bg-bad/10 text-bad`:`bg-accent/10 text-fg`),role:e.tone===`bad`?`alert`:`status`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text}),(0,K.jsx)(n,{variant:`ghost`,size:r?`xs`:`touch`,onClick:()=>t(null),children:`Dismiss`})]}):null}var tE=(0,G.lazy)(()=>iC(()=>import(`./ChecksPanel-DTdImWoD.js`),__vite__mapDeps([3,1,2,4,5]),import.meta.url)),nE=(0,G.lazy)(()=>iC(()=>import(`./BoardChat-D5SFd8HE.js`),__vite__mapDeps([6,1,7,5,2,4]),import.meta.url));function rE({wide:e,checksOpen:t,checksProps:n,chatThread:r,chatProps:i,panelHidden:a,panelProps:o,updateParams:s}){return e&&t?(0,K.jsx)(lE,{panel:`checks`,defaultWidth:384,"aria-label":`Checks`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`p`,{className:`p-4 text-sm text-muted`,children:`Loading checks…`}),children:(0,K.jsx)(tE,{...n})})},`checks`):e&&r?(0,K.jsx)(lE,{panel:`agent`,defaultWidth:384,"aria-label":`Agent`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(b_,{}),children:(0,K.jsx)(nE,{...i,onClose:()=>s({chat:null})})})},`agent`):e&&!a?(0,K.jsx)(lE,{panel:`comments`,defaultWidth:384,id:`sw-comments`,tabIndex:-1,className:`outline-none`,"aria-label":`Comments`,children:(0,K.jsx)(lx,{...o,onClose:()=>s({panel:`off`})})},`comments`):null}var iE=280,aE=.6,oE=16,sE=`side`;function cE(e){let t=Math.max(iE,Math.floor(window.innerWidth*aE));return Math.min(t,Math.max(iE,Math.round(e)))}function lE({panel:e,defaultWidth:t,className:n,children:r,...i}){let[a,o]=(0,G.useState)(()=>cE(Iw(sE)??t)),[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=()=>o(e=>cE(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let u=e=>{let n=cE(e);o(n),Lw(sE,n===t?null:n)},d=e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),l.current={x:e.clientX,width:a},c(!0))},f=e=>{l.current&&o(cE(l.current.width+l.current.x-e.clientX))},p=e=>{l.current&&(u(l.current.width+l.current.x-e.clientX),l.current=null,c(!1))},m=e=>{let n=e.shiftKey?64:oE;if(e.key===`ArrowLeft`)u(a+n);else if(e.key===`ArrowRight`)u(a-n);else if(e.key===`Home`)u(t);else return;e.preventDefault()};return(0,K.jsxs)(`aside`,{className:U(`relative flex shrink-0 flex-col border-l border-line bg-surface`,n),style:{width:a},"data-sw-rail":e,...i,children:[(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,"aria-valuenow":a,"aria-valuemin":iE,"aria-valuemax":Math.max(iE,Math.floor(window.innerWidth*aE)),"aria-description":`Drag or use the arrow keys to resize. Double-click or press Home to reset.`,tabIndex:0,className:`group absolute inset-y-0 -left-1.5 z-20 w-3 cursor-col-resize touch-none outline-none`,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onDoubleClick:()=>u(t),onKeyDown:m,"data-sw-rail-handle":`true`,children:(0,K.jsx)(`span`,{"aria-hidden":`true`,className:U(`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-accent opacity-0 transition-opacity group-hover:opacity-60 group-focus-visible:opacity-100`,s&&`opacity-100`)})}),s?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null,r]})}function uE({checksOpen:e,closeChecks:t,checksProps:n,chatAvailable:r,chatThread:i,chatProps:a,updateParams:o,sheetOpen:s,setSheetOpen:c,panelProps:l,threadSheet:u,threadProps:d,closeThread:f,selectedComment:p,targetTitle:m,draft:h,busy:g,setDraft:_,draftDescription:v,composerProps:y}){return(0,K.jsxs)(K.Fragment,{children:[e?(0,K.jsx)(M,{open:!0,onClose:t,title:`Checks`,size:`md`,children:(0,K.jsx)(`div`,{className:`flex h-[78dvh] min-h-0 flex-col`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`p`,{children:`Loading checks…`}),children:(0,K.jsx)(tE,{...n})})})}):null,r?(0,K.jsx)(M,{open:!!i,onClose:()=>o({chat:null}),title:`Agent`,size:`md`,children:(0,K.jsx)(`div`,{className:`flex h-[78dvh] flex-col`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(b_,{heading:!1}),children:(0,K.jsx)(nE,{...a,heading:!1})})})}):null,(0,K.jsx)(M,{open:s&&!e,onClose:()=>c(!1),title:`Comments`,size:`md`,children:(0,K.jsx)(`div`,{className:`flex max-h-[70dvh] flex-col`,children:(0,K.jsx)(lx,{...l,heading:!1})})}),(0,K.jsx)(M,{open:u&&!!d&&!e,onClose:f,title:p?`#${p.id} · ${m(p.pageId)}`:`Comment`,description:p?`${p.viewport} capture`:void 0,size:`md`,children:d?(0,K.jsx)(`div`,{className:`flex max-h-[72dvh] flex-col outline-none`,tabIndex:-1,"data-autofocus":!0,"data-sw-thread-sheet":p.id,children:(0,K.jsx)(OS,{...d})}):null}),(0,K.jsx)(M,{open:!!h&&!e,onClose:()=>g?null:_(null),title:`New comment`,description:v,children:(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsx)(xx,{...y,touch:!0})})})]})}function dE({groups:e,journeys:t,comments:n,activePage:r,journeyId:i,onPage:a,onJourney:o}){let[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(()=>new Set),d=s.trim().toLowerCase(),f=(0,G.useMemo)(()=>{let e=new Map;for(let t of n||[])t.status===`open`&&e.set(t.pageId,(e.get(t.pageId)||0)+1);return e},[n]),p=e.map(e=>({...e,pages:d?e.pages.filter(t=>`${t.title} ${t.path||``} ${e.group}`.toLowerCase().includes(d)):e.pages})).filter(e=>e.pages.length),m=d?t.filter(e=>String(e.name||``).toLowerCase().includes(d)):t,h=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),g=e.reduce((e,t)=>e+t.pages.length,0);return(0,K.jsxs)(`div`,{className:`flex w-full flex-col border-t border-line pt-2`,"data-sw-pages-sidebar":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Pages `,(0,K.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:g})]}),(0,K.jsx)(`div`,{className:`pb-2`,children:(0,K.jsx)(qe,{size:`sm`,icon:Lg,value:s,onChange:e=>c(e.target.value.slice(0,80)),placeholder:`Filter pages and journeys`,"aria-label":`Filter pages and journeys`,"data-sw-pages-filter":`true`})}),(0,K.jsxs)(`div`,{className:`pb-2`,children:[p.map(e=>{let t=l.has(e.group)&&!d;return(0,K.jsxs)(`section`,{className:`mb-1`,"data-sw-pages-group":e.group,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1 rounded-md px-2.5 text-xs font-semibold text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"aria-expanded":!t,onClick:()=>h(e.group),children:[(0,K.jsx)(R,{size:13,"aria-hidden":`true`,className:U(`transition-transform`,t&&`-rotate-90`)}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.group}),(0,K.jsx)(`span`,{className:`ml-auto font-normal text-faint tabular`,children:e.pages.length})]}),t?null:(0,K.jsx)(`ul`,{className:`ml-4`,children:e.pages.map((t,n)=>{let i=f.get(t.id)||0,o=t.id===r,s=n===e.pages.length-1;return(0,K.jsx)(`li`,{className:U(`relative pl-3 before:pointer-events-none before:absolute before:top-0 before:left-0 before:h-4 before:w-2.5 before:rounded-bl-md before:border-b before:border-l`,o?`before:border-accent/60`:`before:border-line-strong/70`,!s&&`after:pointer-events-none after:absolute after:inset-y-0 after:left-0 after:border-l after:border-line-strong/70`),"data-sw-pages-wire":`true`,children:(0,K.jsxs)(`button`,{type:`button`,className:U(`flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`,o?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),"aria-current":o?`true`:void 0,onClick:()=>a(t.id),"data-sw-pages-item":t.id,children:[(0,K.jsx)(_h,{size:14,"aria-hidden":`true`,className:U(`shrink-0`,o?`text-accent`:`text-faint`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),i?(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-muted tabular`,"aria-label":`${i} open`,children:i}):null]})},t.id)})})]},e.group)}),m.length?(0,K.jsxs)(`section`,{className:`mt-2 border-t border-line pt-2`,"data-sw-pages-journeys":`true`,children:[(0,K.jsx)(`h3`,{className:`flex h-7 items-center px-2.5 text-xs font-semibold text-muted`,children:`Journeys`}),(0,K.jsx)(`ul`,{children:m.map(e=>{let t=e.id===i;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:U(`flex h-8 w-full items-center gap-2 rounded-md px-2.5 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`,t?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),"aria-current":t?`true`:void 0,onClick:()=>o(t?null:e.id),"data-sw-pages-journey":e.id,children:[(0,K.jsx)(Ng,{size:14,"aria-hidden":`true`,className:U(`shrink-0`,t?`text-accent`:`text-faint`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id})]})},e.id)})})]}):null,d&&!p.length&&!m.length?(0,K.jsxs)(`p`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`Nothing matches "`,s.trim(),`".`]}):null]})]})}function fE({info:e,localSettingsAvailable:t,setShareOpen:n}){let r=[{id:`board`,label:`Board`,icon:Lh,href:`./`,active:!0}],i=e?.consoleUrl&&!e?.guest?e.consoleUrl:null;return i?r.push({id:`workspace`,label:`Workspace`,icon:Um,href:i}):t&&r.push({id:`workspace`,label:`Workspace`,icon:Um,href:`/console`}),e?.shareEnabled&&r.push({id:`share`,label:`Share with your team`,icon:Ug,onSelect:()=>n(!0)}),r}function pE({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,expanded:c,onToggle:l,pages:u}){let d=!!e&&!e.guest&&!e.public&&!e.share,f=typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`);(0,G.useEffect)(()=>{d&&sT(window.location.pathname+(f?`?board=`+encodeURIComponent(f):``))},[d,f]);let p=fE({info:e,localSettingsAvailable:i,setShareOpen:s}),m=!c&&u?[{id:`pages`,label:`Pages and journeys`,icon:yh,flyout:({close:e})=>(0,K.jsx)(dE,{...u,onPage:t=>{e(),u.onPage(t)},onJourney:t=>{e(),u.onJourney(t)}})}]:[];return(0,K.jsx)(CT,{expanded:c,onToggle:l,home:`./`,homeLabel:`Shapewall`,title:e?.project?.name||e?.title,logo:(0,K.jsx)(`img`,{src:`./favicon.svg`,alt:``,className:`h-7 w-7`}),items:p,sections:m,profile:c=>(0,K.jsx)(IT,{info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,side:`right`,align:`end`,showName:c,triggerClassName:c?`w-full justify-start`:`w-10 min-w-10 px-0`}),children:u?(0,K.jsx)(dE,{...u}):null})}var mE=(0,G.lazy)(()=>iC(()=>import(`./QuickConnect-DQGgUsl1.js`).then(e=>e.a).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([7,1,5,2]),import.meta.url)),hE=(0,G.lazy)(()=>iC(()=>import(`./History-CEv6b-av.js`),__vite__mapDeps([8,1]),import.meta.url)),gE=(0,G.lazy)(()=>iC(()=>import(`./ShareDialog-C_plIto0.js`).then(e=>({default:e.ShareDialog})),__vite__mapDeps([9,1]),import.meta.url)),_E=(0,G.lazy)(()=>iC(()=>import(`./LocalSettings-C4vriEVQ.js`),__vite__mapDeps([10,1,7,5,2]),import.meta.url));function vE({info:e,boardId:t,boards:r,wide:i,shareOpen:a,setShareOpen:o,refetchView:s,settingsAvailable:l,settingsOpen:u,updateParams:d,onInfoChanged:f,generalSettingsOpen:p,updates:m,historyPage:h,closeHistory:g,historyViewport:_,historyPageId:v,data:y,comments:b,filter:x,focusComment:S,onImageError:C,captureConfirm:w,setCaptureConfirm:T,busy:E,focusedPage:D,findPage:O,startCapture:k}){let A=_e(a),j=_e(u);return(0,K.jsxs)(K.Fragment,{children:[e?.shareEnabled&&A?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(gE,{open:a,onClose:()=>o(!1),boardId:t,onMoved:s})}):null,l&&j?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(mE,{open:u,onClose:()=>d({settings:null}),onSaved:f,touch:!i,buzz:e?.buzzAvailable===!0})}):null,p?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(_E,{open:!0,onClose:()=>d({settings:null}),info:e,boardCount:r.length,onSaved:f,touch:!i,onOpenUpdates:()=>{d({settings:null}),m.current?.open()}})}):null,h?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(hE,{open:!!h,onClose:g,page:h,viewport:_,data:y,comments:b.filter(e=>e.pageId===v&&e.viewport===_),urlFor:(e,n)=>c(t,e.kind,n?e.thumb:e.file,e.version),onPickComment:e=>{g(),d({filter:e.status===`resolved`&&x===`open`?`all`:null}),S(e)},touch:!i,onImageError:C})}):null,(0,K.jsx)(M,{open:w,onClose:()=>E?null:T(!1),title:`Capture every page now?`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:i?`md`:`touch`,onClick:()=>T(!1),disabled:E,children:`Cancel`}),D&&O(D)?(0,K.jsxs)(n,{size:i?`md`:`touch`,onClick:()=>k(null,[D]),disabled:E,"data-sw-capture-only":D,children:[`Only `,O(D).title]}):null,(0,K.jsx)(n,{size:i?`md`:`touch`,variant:`default`,onClick:()=>k(),disabled:E,"data-sw-capture-confirm":`true`,children:`Capture all`})]}),children:(0,K.jsxs)(`p`,{className:`p-5 text-sm text-muted`,children:[`Shapewall captures all `,y?.board?.pages.length||``,` pages at every viewport`,D&&O(D)?` (or only ${O(D).title}, the selected page)`:``,`. Comments stay where they are; pins on live pages follow their elements. The board updates when it finishes.`]})})]})}var yE=2;function bE(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function xE({canvasRef:e,flow:t,targets:n,viewports:r,settledZoom:i,setSettledZoom:a,comparePair:o,captures:s,variantsById:c}){let l=(0,G.useRef)(null),[u,d]=(0,G.useState)(()=>new Set),[f,p]=(0,G.useState)(()=>new Set),m=(0,G.useCallback)((e,t)=>{p(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),h=(0,G.useCallback)((e,t)=>o?null:e.startsWith(`variant:`)?c.get(e)?.files?.[t]?.live||null:s?.[e]?.[t]?.live||null,[o,s,c]),g=(0,G.useCallback)(()=>{let a=e.current?.getBoundingClientRect();if(!a?.width||!i){d(e=>e.size?new Set:e);return}let{x:o,y:s,zoom:c}=t.getViewport(),u=[];for(let[e,t]of Object.entries(n))for(let n of t.frames){if(!h(e,n.viewport))continue;let i=(t.x+n.x)*c+o,d=(t.y+n.y)*c+s,f=n.w*c,p=n.h*c;if(i>a.width||d>a.height||i+f<0||d+p<0)continue;let m=`${e}|${n.viewport}`,g=l.current===m,_=Math.min((r[n.viewport]?.width||1440)*.4,a.width*.5);f<(g?_/2:_)||u.push({key:m,rank:g?-1:Math.hypot(i+f/2-a.width/2,d+p/2-a.height/2)})}u.sort((e,t)=>e.rank-t.rank);let f=new Set(u.slice(0,yE).map(e=>e.key));l.current&&!f.has(l.current)&&(l.current=null),d(e=>bE(e,f)?e:f)},[e,t,n,h,i,r]);return(0,G.useEffect)(()=>{g()},[g]),{liveKeys:u,readyKeys:f,setLiveReady:m,liveFileFor:h,recomputeLive:g,openLive:(0,G.useCallback)((r,i)=>{let o=n[r],s=o?.frames.find(e=>e.viewport===i),c=e.current?.getBoundingClientRect();s&&c?.width&&(l.current=`${r}|${i}`,a(null),t.fitBounds({x:o.x+s.x,y:o.y+s.y,width:s.w,height:Math.min(s.h,s.w*(c.height/c.width))},{padding:.04,duration:fw(450)}))},[e,t,n,a])}}function SE({journey:e,builder:t,goStep:n,step:r,closeJourney:i}){(0,G.useEffect)(()=>{if(!e||t)return;let a=e=>{if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||document.querySelector(`[role="dialog"]`))return;let t=e.target;t?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(t?.tagName)||t?.closest?.(`[role="listbox"], [role="menu"]`)||((e.key===`ArrowRight`||e.key===`ArrowLeft`)&&(e.preventDefault(),n(r+(e.key===`ArrowRight`?1:-1))),e.key===`Escape`&&!document.querySelector(`[data-sw-thread-popover], [data-sw-composer-popover]`)&&(e.preventDefault(),i()))};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[t,i,n,e,r])}function CE({commentMode:e,setCommentMode:t,canComment:n,comparePair:r,setDraft:i}){(0,G.useEffect)(()=>{if(!e)return;let n=e=>{e.key!==`Escape`||Wb(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||t(!1)};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),(0,G.useEffect)(()=>{if(!n||r)return;let e=e=>{if(e.defaultPrevented&&!Ge(e)||e.altKey||e.ctrlKey||e.metaKey||e.repeat||e.key!==`c`&&e.key!==`C`)return;let n=e.target;n?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(n?.tagName)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`)||(e.preventDefault(),i(null),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r,t,i])}function wE(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&Array.isArray(e.branches)}function TE(e){let t=new Set,n=e=>{for(let r of e||[])if(typeof r==`string`)t.add(r);else if(wE(r))for(let e of r.branches)n(e.steps)};return n(e),[...t]}function EE(e){let t=[],n=[],r=(e,i,a)=>{let o=a;return e.forEach((e,a)=>{let s=i?`${i}:${a}`:String(a);if(typeof e==`string`){t.push({key:s,pageId:e});for(let e of o)n.push({from:e.key,to:s,label:e.label||null,branch:e.branch||null});o=[{key:s}];return}if(!wE(e))return;let c=[];e.branches.forEach((e,t)=>{let n=o.map(t=>({key:t.key,label:e.label,branch:e.id})),i=r(e.steps,`${s}:${t}`,n);e.end||c.push(...i)}),o=c}),o};return r(e||[],``,[]),{nodes:t,edges:n}}function DE(e,t=[]){let n=[],r=[],i=!1,a=(e,o,s)=>{for(let c=0;c<e.length;c+=1){if(i)return;let l=e[c],u=o?`${o}:${c}`:String(c);if(typeof l==`string`){n.push({key:u,pageId:l,branch:s});continue}if(!wE(l)||!l.branches.length)continue;let d=t[r.length],f=Math.max(0,l.branches.findIndex(e=>e.id===d)),p=l.branches[f];r.push({afterStep:n.length,options:l.branches.map(e=>({id:e.id,label:e.label,end:!!e.end})),chosen:p.id}),a(p.steps,`${u}:${f}`,p.label),p.end&&(i=!0)}};return a(e||[],``,null),{steps:n,forks:r,ended:i}}function OE(e,t,n){return[...e.forks.slice(0,t).map(e=>e.chosen),n]}function kE({boardId:e,view:t,updateParams:n,clearFocus:r,setCommentMode:i,journey:a,route:o,routePages:s,step:c,builder:l,setBuilder:u,busy:d,setBusy:f,setNotice:p,flow:m,targets:h,nodesReady:g,mode:_,comparePair:v,setSettledZoom:y}){let b=(0,G.useCallback)(e=>{r(),n({j:e||null,step:e?1:null,jc:null,jb:null})},[r,n]),x=(0,G.useCallback)(()=>n({j:null,step:null,jc:null,jb:null}),[n]),S=(0,G.useCallback)(e=>{s&&n({step:D_(e,s.length)})},[s,n]),C=(0,G.useCallback)((e,t)=>{o&&n({jb:OE(o,e,t).join(`,`)})},[o,n]),w=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!a||!g||l){a||(w.current=null);return}let e=s[c-1],t=`${a.id}:${c}:${e}:${_}:${v}`;if(w.current===t)return;let n=h[e];n&&(w.current=t,y(null),m.fitBounds({x:n.x,y:n.y-48,width:n.w,height:n.h+48},{padding:.18,duration:fw(450)}))},[l,v,m,a,h,_,g,s,y,c]),SE({journey:a,builder:l,goStep:S,step:c,closeJourney:x});let T=(0,G.useCallback)((e=null)=>{i(!1),r(),u(e?{id:e.id,name:e.name,steps:structuredClone(e.steps),into:null}:{id:null,name:``,steps:[],into:null})},[r,u,i]),E=(0,G.useCallback)(e=>{u(t=>{if(!t||TE(t.steps).length>=50)return t;let n=structuredClone(t.steps),r=(t.into?n[t.into.fork]:null)?.branches?.[t.into.branch]?.steps||n;return r[r.length-1]===e?t:(r.push(e),{...t,steps:n})})},[u]),D=`/api/boards/${encodeURIComponent(e)}/journeys`;return{openJourney:b,closeJourney:x,goStep:S,chooseJourneyBranch:C,startBuilder:T,addBuilderStep:E,saveBuilder:async()=>{if(l&&!d){f(!0);try{let e={name:l.name,steps:l.steps},n=l.id?await Je.patch(`${D}/${encodeURIComponent(l.id)}`,e):await Je.post(D,e);await t.refetch(),u(null),w.current=null,b(n.journey.id)}catch(e){p({tone:`bad`,text:e.message||`The journey was not saved.`})}finally{f(!1)}}},removeJourney:async()=>{if(a&&!d){f(!0);try{await Je.delete(`${D}/${encodeURIComponent(a.id)}`),x(),t.refetch()}catch(e){p({tone:`bad`,text:e.message||`The journey was not deleted.`})}finally{f(!1)}}}}}function AE({boardId:e,commentsQuery:t,view:n,info:r,localName:i,authorName:a,setBusy:o,setNotice:s,setToast:c,setDeletingIds:l,selectedCommentId:u,closeThread:d,wide:f,filter:p,allowed:m}){let h=(0,G.useRef)(new Map),g=(e,r=!1,{counts:i=!0}={})=>{t.setData(t=>{let n=Array.isArray(t?.comments)?t.comments:[];return r?{comments:n.filter(t=>t.id!==e.id)}:{comments:n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n]}}),i&&n.refetch()},_=`/api/boards/${encodeURIComponent(e)}/comments`,v=async(e,t)=>{o(!0);try{let n=await Je.post(`${_}/${e.id}/${t}`,{author:a()||void 0});g(n.comment),f&&t===`resolve`&&p===`open`&&d(),t===`resolve`&&m(`resolve`)&&c({at:Date.now(),text:`Resolved comment #${e.id}.`,undo:()=>v(n.comment,`reopen`)})}catch(e){s({tone:`bad`,text:e.message||`That did not save.`})}finally{o(!1)}},y=async(e,t)=>{o(!0);try{let n=await Je.post(`${_}/${e.id}/replies`,{body:t,author:a()||void 0});return g(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That reply did not save.`}),!1}finally{o(!1)}},b=async(e,t)=>{o(!0);try{let n=await Je.patch(`${_}/${e.id}`,{body:t});return g(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That edit did not save.`}),!1}finally{o(!1)}},x=async(e,t,n=null)=>{try{let a=await Je.post(`${_}/${e.id}/reactions`,{emoji:t,...n?{replyId:n}:{},...r?.hosted?{}:{author:i||void 0}});g(a.comment,!1,{counts:!1})}catch(e){s({tone:`bad`,text:e.message||`That reaction did not save.`})}},S=async e=>{let t=new URL(window.location.href);t.searchParams.set(`c`,String(e.id)),t.searchParams.delete(`v`);try{await navigator.clipboard.writeText(t.href),s({tone:`info`,text:`Copied the link to comment #${e.id}.`})}catch{s({tone:`info`,text:`Link to comment #${e.id}: ${t.href}`})}},C=async e=>{o(!0);try{let t=await Je.post(`${_}/${e.id}/github/issue`,{});g(t.comment),s({tone:`info`,text:`${t.created?`Opened`:`Already has`} GitHub issue #${t.issue.number}.`})}catch(e){s({tone:`bad`,text:e.message||`The GitHub issue was not created.`})}finally{o(!1)}},w=e=>{h.current.delete(e),l(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},T=async e=>{let t=h.current.get(e.id);if(t){window.clearTimeout(t.timer);try{await Je.delete(`${_}/${e.id}`),g(e,!0)}catch(e){s({tone:`bad`,text:e.message||`That did not delete.`})}finally{w(e.id)}}},E=(0,G.useRef)(T);return E.current=T,(0,G.useEffect)(()=>{let e=()=>{for(let{comment:e}of[...h.current.values()])E.current(e)};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),e()}},[]),{commentsUrl:_,applyComment:g,setStatus:v,replyTo:y,editComment:b,reactTo:x,copyLink:S,githubIssue:C,removeComment:async e=>{u===e.id&&d(),l(t=>new Set(t).add(e.id));let t=window.setTimeout(()=>E.current(e),6e3);h.current.set(e.id,{comment:e,timer:t}),c({at:Date.now(),text:`Deleted comment #${e.id}.`,undo:()=>{window.clearTimeout(t),w(e.id)}})},sendToAgent:async e=>{let{dispatchHash:n}=e,i=!!(e.needsRunApproval&&[`admin`,`owner`].includes(r.role));o(!0);try{i&&await SC();let t=await Je.post(`${_}/${e.id}/send-to-agent`,{dispatchHash:n,approve:i});g(t.comment)}catch(e){e.code===`comment_changed`?(t.refetch(),s({tone:`bad`,text:`This comment changed while you were approving it. Read it again, then send it.`})):s({tone:`bad`,text:e.message})}finally{o(!1)}}}}function jE(e){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!1),[o,s]=(0,G.useState)(()=>new Set),c=Qe(`/api/boards/${encodeURIComponent(e)}`,{pollMs:r||t?2e3:a?0:3e4}),l=Qe(`/api/boards/${encodeURIComponent(e)}/comments`,{pollMs:a?0:t?1e3:2e4}),u=c.data,d=u?.capture;return(0,G.useEffect)(()=>{i(!!d?.running)},[d?.running]),{view:c,commentsQuery:l,data:u,capture:d,comments:(0,G.useMemo)(()=>{let e=Array.isArray(l.data?.comments)?l.data.comments:[];return o.size?e.filter(e=>!o.has(e.id)):e},[l.data,o]),fixRequest:t,setFixRequest:n,setPolling:i,deletingIds:o,setDeletingIds:s}}function ME({params:e,data:t,builder:n}){let r=(0,G.useMemo)(()=>Array.isArray(t?.journeys)?t.journeys:[],[t?.journeys]),i=n?null:r.find(t=>t.id===e.get(`j`))||null,a=e.get(`jb`)||``,o=(0,G.useMemo)(()=>i?DE(i.steps,a.split(`,`).filter(Boolean)):null,[i,a]),s=(0,G.useMemo)(()=>i?EE(i.steps):null,[i]),c=(0,G.useMemo)(()=>o?o.steps.map(e=>e.pageId):null,[o]);return{journeys:r,journey:i,route:o,routeGraph:s,routePages:c,step:D_(e.get(`step`),c?.length||0),journeyComments:!!i&&e.get(`jc`)===`1`}}var NE=40;function PE({pendingFocus:e,setPendingFocus:t,targets:n,viewports:r,flow:i,canvasRef:a,wide:o,setSettledZoom:s}){(0,G.useEffect)(()=>{if(!e)return;let c=_v(n,e);if(!c){n[e.pageId]&&r[e.viewport]||t(null);return}t(null),s(null);let l=Math.max(i.getZoom(),1.2),u=a.current?.getBoundingClientRect(),d=n[e.pageId];if(o||!u?.width||!d){i.setCenter(c.x,c.y,{zoom:l,duration:fw(450)});return}let f=u.height*.28-c.y*l;d.y*l+f<NE&&(f=Math.min(NE-d.y*l,u.height*.45-c.y*l)),i.setViewport({x:u.width/2-c.x*l,y:f,zoom:l},{duration:fw(450)})},[a,i,n,e,t,s,r,o])}function FE({wide:e,nodesReady:t,initialCamera:n,selectedCommentId:r,canvasRef:i,nodes:a,flow:o,setSettledZoom:s}){let c=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(e||c.current||!t||(c.current=!0,n.current||r))return;let l=i.current?.getBoundingClientRect(),u=a.find(e=>e.type===`groupFrame`),d=u&&a.find(e=>e.type===`page`&&e.data?.page?.group===u.data.group);if(!l?.width||!u||!d){o.fitView(hw);return}let f=Math.min(u.width,d.width*2+72+2*(d.position.x-u.position.x)),p=Math.min(1.5,Math.max(.05,(l.width-16)/f)),m=12+44*Math.max(p,.45);s(null),o.setViewport({x:8-u.position.x*p,y:m-u.position.y*p,zoom:p})},[i,o,n,a,t,r,s,e])}function IE({mode:e,pendingFocus:t,shapeKey:n,clearFocus:r,fitBoard:i}){let a=(0,G.useRef)(e);(0,G.useEffect)(()=>{if(a.current===e||(a.current=e,r(),t))return;let n=window.setTimeout(i,60);return()=>window.clearTimeout(n)},[r,i,e,t]);let o=(0,G.useRef)(n);(0,G.useEffect)(()=>{if(o.current===n)return;o.current=n,r();let e=window.setTimeout(i,60);return()=>window.clearTimeout(e)},[r,i,n])}function LE({nodesReady:e,data:t,commentsLoaded:n,selectedCommentId:r,selectedComment:i,initialCamera:a,focusComment:o,deletingIds:s,setNotice:c,updateParams:l}){let u=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!u.current&&e&&t&&(!r||n)&&(u.current=!0,i&&!a.current&&o(i))},[n,t,o,a,e,i,r]);let d=(0,G.useRef)(null);(0,G.useEffect)(()=>{r&&n&&!i&&!s.has(r)&&d.current!==r&&(d.current=r,c({tone:`bad`,text:`Comment #${r} was not found on this board. It may have been deleted.`}),l({c:null}))},[n,s,i,r,c,l])}function RE({selectedComment:e,visibleComments:t,focusComment:n,mode:r,viewports:i,modes:a}){let o=(0,G.useMemo)(()=>e&&!t.some(t=>t.id===e.id)?[e,...t]:t,[e,t]),s=e?o.findIndex(t=>t.id===e.id):-1;return{threadList:o,threadIndex:s,stepThread:e=>{o.length<2||s<0||n(o[(s+e+o.length)%o.length])},neighborNote:e=>{if(o.length<2||s<0||r===`all`)return null;let t=o[(s+e+o.length)%o.length];return t.viewport===r||!i[t.viewport]?null:`switches to ${a.find(e=>e.id===t.viewport)?.label||t.viewport}`}}}var zE=[`issues`,`pages`,`seo`,`performance`,`history`],BE=e=>zE.includes(e)&&e!==`issues`?e:null;function VE({boardId:e,info:t,params:n,updateParams:r,pages:i}){let o=!!t?.checksAvailable,s=o&&!!n.get(`checks`),c=i?.some(e=>e.id===n.get(`checks`))?n.get(`checks`):null,l=n.get(`cv`)||null,u=zE.includes(n.get(`ct`))?n.get(`ct`):`issues`,d=/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.get(`ce`)||``)?n.get(`ce`):null,f=`/api/boards/${encodeURIComponent(e)}/checks`,p=d?`?env=${encodeURIComponent(d)}`:``,m=Qe(o?`${f}${p}`:null,{pollMs:a?0:3e4}),h=Qe(o&&s&&!a?`${f}/seo${p}`:null),g=o&&!a&&!t?.hosted,[_,v]=(0,G.useState)(!1),y=Qe(g&&s?`${f}/run`:null,{pollMs:_?1500:0}),b=y.data?.run||null,x=b?.state===`running`;(0,G.useEffect)(()=>v(x),[x]);let S=(0,G.useRef)(!1),{refetch:C}=m,{refetch:w}=h;(0,G.useEffect)(()=>{S.current&&!x&&(C(),w()),S.current=x},[x,C,w]);let[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(!1),k=(0,G.useCallback)(async({pages:e=null,seo:t=!0}={})=>{O(!0),E(null);try{return await Je.post(`${f}/run`,{seo:t,...e?{pages:e}:{},...d?{env:d}:{}}),v(!0),await y.refetch(),!0}catch(e){return E(e.message||`The checks run did not start.`),y.refetch(),!1}finally{O(!1)}},[f,d,y]),[A,j]=(0,G.useState)(!1),M=(0,G.useCallback)(async()=>{j(!0),E(null);try{await Je.delete(`${f}/run`)}catch(e){E(e.message||`The checks run could not be stopped.`)}finally{j(!1),y.refetch()}},[f,y]),N=(0,G.useCallback)((e=null,t=null,n=null)=>r({checks:e||`all`,cv:t,chat:null,...n?{ct:BE(n)}:{}}),[r]),P=(0,G.useCallback)(e=>r({ct:BE(e)}),[r]),F=(0,G.useCallback)(()=>r({checks:null,cv:null,ct:null}),[r]),ee=(0,G.useMemo)(()=>{let e=new Map;for(let t of m.data?.views||[]){if([`stale`,`failed`].includes(t.state))continue;let n=t.runs?.reduce((e,t)=>e+(t.state===`stale`?0:t.actionable),0)??t.actionable;e.set(t.pageId,(e.get(t.pageId)||0)+n)}return e},[m.data]),I=g?{loading:y.loading,canRun:!!y.data?.canRun,reason:y.data?.reason||null,limit:y.data?.limit||100,privatePages:y.data?.privatePages||[],seoDefault:y.data?.seoDefault!==!1,run:b,starting:D,error:T,start:k,stop:M,stopping:A}:null,L=[`shapewall checks run`,`--board ${e}`,c?`--only ${c}`:null,d?`--env ${d}`:null,u===`seo`?`--seo`:null,`--limit 100`].filter(Boolean).join(` `);return{canChecks:o,checksOpen:s,checksPage:c,checksViewport:l,checksEnvironment:d,checksTab:u,setChecksTab:P,checksQuery:m,seoQuery:h,checksRun:I,checksPanelProps:{tab:u,onTab:P,seo:h.error?null:h.data,run:I,command:L},openChecks:N,closeChecks:F,checksCounts:ee}}function HE({boardId:e,info:t,params:n,updateParams:r}){let i=!a&&!!t?.agent&&!(t?.remote?.noRemoteChat&&t?.remote?.kind!==`host`),o=n.get(`chat`)||``,s=i?cS(o):null,c=!!(t?.agent?.settingsEditable||t?.agent?.settingsReadonly),l=!a&&!Ce&&!t?.consoleUrl&&!t?.workspace&&!t?.hosted&&!t?.guest,u=l&&n.get(`settings`)===`general`,d=c&&n.get(`settings`)===`agent`,f=(0,G.useCallback)(()=>r({settings:`agent`}),[r]);return(0,G.useEffect)(()=>{s&&dS(e,sS(s))},[e,s]),{chatAvailable:i,chatThread:s,reopenChat:(0,G.useCallback)(()=>r({chat:fS(e),checks:null,cv:null}),[e,r]),settingsAvailable:c,localSettingsAvailable:l,generalSettingsOpen:u,settingsOpen:d,openSettings:f,openChat:(0,G.useCallback)(e=>{r({chat:sS(e),checks:null,cv:null})},[r])}}function UE({boardId:e,params:t,updateParams:n,environmentList:r,setCommentMode:i,pageCount:a=0}){let o=(0,G.useMemo)(()=>Array.isArray(r)?r:[],[r]),s=(0,G.useMemo)(()=>{let[e,n]=String(t.get(`cmp`)||``).split(`_`),r=o.map(e=>e.id);return e&&n&&e!==n&&r.includes(e)&&r.includes(n)?[e,n]:null},[t.get(`cmp`),o]),c=t.get(`changed`),l=a>=30,u=!!s&&(c===`1`||c!==`0`&&l),d=e=>n({changed:e===l?null:e?`1`:`0`}),f=t.get(`diff`)!==`off`,p=Qe(s?`/api/boards/${encodeURIComponent(e)}/compare?a=${s[0]}&b=${s[1]}`:null),m=s&&p.data?.a===s[0]&&p.data?.b===s[1]?p.data:null,h=(0,G.useMemo)(()=>{if(!s)return null;let[e,t]=s,n=new Map(o.map(e=>[e.id,e])),r=o.find(e=>e.default)?.id;return{a:e,b:t,files:m?.files||{},failures:m?.failures||{},pages:m?.pages||{},showDiff:f,kindOf:e=>e===r?`captures`:`envs/${e}`,versionOf:e=>n.get(e)?.capturedAt||`none`,titleOf:e=>n.get(e)?.title||e,diffKind:`diffs/${e}_${t}`,diffVersion:`${n.get(e)?.capturedAt}|${n.get(t)?.capturedAt}`}},[m,s,o,f]),g=e=>{i(!1),n({cmp:e?e.join(`_`):null,changed:e?t.get(`changed`):null,diff:e?t.get(`diff`):null})};return{environments:o,comparePair:s,changedOnly:u,setChangedOnly:d,showDiff:f,compareQuery:p,compareData:m,compareView:h,setCompare:g,canCompare:o.length>1,toggleCompare:()=>g(s?null:[o[0].id,o[1].id])}}function WE({comments:e,query:t,stateFilter:n,mentionFilter:r,titleOfPage:i,filter:a,journey:o,journeyComments:s}){let c=(0,G.useMemo)(()=>R_(e,{query:t,state:n,mention:r,titleOf:i}),[e,r,t,n,i]),l=(0,G.useMemo)(()=>{let e=s?new Set(o.pages||TE(o.steps)):null;return c.filter(t=>(a===`all`||t.status===a)&&(!e||e.has(t.pageId)))},[c,a,o,s]);return{narrowedComments:c,visibleComments:l,pinsByTarget:(0,G.useMemo)(()=>{let e=new Map;for(let t of l){let n=`${t.pageId}|${t.viewport}`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[l]),counts:{open:c.filter(e=>e.status===`open`).length,resolved:c.filter(e=>e.status===`resolved`).length}}}function GE({targets:e,layoutEdges:t,links:n,showLinks:r,showAllLinks:i,activePage:a,builder:o,route:s,routeGraph:c,routePages:l,step:u,journey:d,targetTitle:f}){let p=(0,G.useMemo)(()=>new Set(Object.keys(e).filter(e=>!e.startsWith(`variant:`))),[e]),m=(0,G.useMemo)(()=>o?DE(o.steps).steps.map(e=>e.pageId):null,[o]),h=o?m:l,g=(0,G.useMemo)(()=>r&&!i?T_(n,p):null,[n,p,i,r]),_=(0,G.useMemo)(()=>o||!s?null:{graph:c,path:s.steps.map(e=>e.key)},[o,s,c]),v=(0,G.useMemo)(()=>[...t,...E_({links:n||{},showLinks:r,activePage:a,journeySteps:o?m:null,journeyRoute:_,currentStep:o?0:u,present:p,hideTargets:g}).map(e=>({...e,ariaLabel:e.id.startsWith(`link:`)?`Link from ${f(e.source)} to ${f(e.target)}`:`Journey${e.data?.label?` step ${e.data.label}`:``}: ${f(e.source)} to ${f(e.target)}`}))],[a,o,m,n,g,_,t,p,r,u,f]),y=(0,G.useMemo)(()=>{if(o||!d||!l)return null;let e=new Set(l);return new Set((d.pages||TE(d.steps)).filter(t=>!e.has(t)))},[o,d,l]);return{presentPages:p,shownSteps:h,hiddenLinkTargets:g,edges:v,journeyView:(0,G.useMemo)(()=>h?{steps:C_(h),offPath:y,currentStep:o?null:u,currentPage:o?null:h[u-1]}:null,[o,y,h,u])}}var KE=[];function qE(e){let t=(0,G.useRef)(e);t.current=e;let{boardId:n,data:r,viewports:i,journeyView:o,compareView:s,commentMode:l,canComment:u,wide:d,hosted:f,imageVersion:p,pinsByTarget:m,me:h,checksCounts:g,canChecks:_,agentFocus:v,agentWorkingPages:y,setLiveReady:b,focusedKey:x,selectingKey:S,settledZoom:C,selectedComment:w,draftSpot:T,unread:E,liveKeys:D}=e,[k]=(0,G.useState)(()=>tb({focusedKey:x,selectingKey:S,settledZoom:C,selectedComment:w,draftSpot:T,unread:E,liveKeys:D}));(0,G.useLayoutEffect)(()=>{k.set({focusedKey:x,selectingKey:S,settledZoom:C,selectedComment:w,draftSpot:T,unread:E,liveKeys:D})},[k,x,S,C,w,T,E,D]);let A=(0,G.useMemo)(()=>{let e=()=>t.current;return{onFocusFrame:(t,n)=>{let{selectedCommentId:r,closeThread:i,builder:a,addBuilderStep:o,layout:s,flow:c,setSettledZoom:l,canvasRef:u,setFocusedKey:d}=e();if(r&&i(),a){t.startsWith(`variant:`)||o(t);return}let f=s.targets[t],p=f?.frames.find(e=>e.viewport===n);f&&p&&sv(p,c.getZoom())&&(l(null),c.fitBounds(gw({x:f.x+p.x,y:f.y,width:p.w,height:p.y+p.h},u.current?.getBoundingClientRect(),.08),{padding:.08,duration:fw(450)})),d(`${t}|${n}`)},onPin:t=>{let n=e(),{layout:r,flow:i,canvasRef:a}=n;n.selectedCommentId&&n.closeThread();let o=r.targets[t.pageId],s=o?.frames.find(e=>e.viewport===t.viewport),c=a.current?.getBoundingClientRect();if(!n.wide&&s&&c?.width&&s.w*i.getZoom()<c.width*.6){n.setSettledZoom(null);let e=Math.min(4,(c.width-16)/s.w),r=o.y+s.y+s.h*t.y/100;i.setViewport({x:8-(o.x+s.x)*e,y:c.height*.35-r*e,zoom:e},{duration:fw(450)}),n.setToast({at:Date.now(),text:`Zoomed in: tap the spot again to pin your comment.`})}else n.setDraft(e=>({...t,body:e?.body||n.checkDraft||``,author:e?.author??n.authorName()})),n.setCheckDraft(``)},onSelectComment:t=>e().selectComment(t),onHoverComment:e=>k.set({hoveredId:e}),onOpenCluster:(t,n,r)=>e().openCluster(t,n,r),onChecks:(...t)=>e().openChecks(...t),onHistory:(t,n=null)=>e().openHistory(t,n),onShowViewport:t=>e().updateParams({vp:t===e().defaultMode?null:t}),onImageError:()=>e().onImageError()}},[k]);return{board:(0,G.useMemo)(()=>({boardId:n,captures:r?.captures||{},manifest:r?.manifest||null,counts:r?.commentCounts||{},viewports:i,journey:o,compare:s,commentMode:l&&u&&!s,touch:!d,imageUrl:(e,t,r)=>c(n,e,t,r||p),liveUrl:(e,t,r)=>O(n,e,t,r||p),elementsUrl:(e,t,r)=>I(n,e,t,r||p),domFallback:!a&&!Ce&&!f,setLiveReady:b,pinsFor:(e,t)=>s?KE:m.get(`${e}|${t}`)||KE,me:h,checksCount:e=>g.get(e)||0,historyCount:e=>F_(r?.versions,e),agentWorking:v,agentWorkingPages:y,onFocusFrame:A.onFocusFrame,onPin:A.onPin,onSelectComment:A.onSelectComment,onHoverComment:d?A.onHoverComment:null,onOpenCluster:A.onOpenCluster,onChecks:_?A.onChecks:null,onHistory:A.onHistory,onShowViewport:A.onShowViewport,onImageError:A.onImageError}),[A,v,y,n,_,u,g,l,s,r?.captures,r?.commentCounts,r?.manifest,r?.versions,f,p,o,h,m,b,i,d]),view:k}}function JE({boardId:e,view:t,setBusy:n,setNotice:r,setPolling:i}){let[a,o]=(0,G.useState)(!1);return{captureConfirm:a,setCaptureConfirm:o,startCapture:async(a=null,s=null)=>{n(!0);try{r({tone:`info`,text:(await Je.post(`/api/boards/${encodeURIComponent(e)}/capture`,{...a?{env:a}:{},...s?{pages:s}:{}})).message||`Capture started.`}),i(!0),t.refetch()}catch(e){r({tone:`bad`,text:e.message||`The capture did not start.`})}finally{n(!1),o(!1)}}}}function YE({draft:e,setDraft:t,busy:n,setBusy:r,commentsUrl:i,applyComment:a,markSeen:o,setLocalName:s,setNotice:c,updateParams:l,wide:u,filter:d,targetTitle:f,people:p,info:m}){return{draftDescription:e?`${f(e.pageId)} · ${e.viewport} · ${e.anchor?`on "${e.anchor.text||e.anchor.selector.split(` > `).pop()}"`:`${Math.round(e.x)}% across, ${Math.round(e.y)}% down`}`:``,composerProps:{draft:e,onChange:e=>t(t=>t&&{...t,...e}),onSubmit:async()=>{if(e?.body.trim()&&!n){r(!0);try{let n=(e.author||``).trim();We(n);let{comment:r}=await Je.post(i,{pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y,body:e.body,author:n,...e.anchor?{anchor:e.anchor}:{}});t(null),s(n),a(r),o(r),l({c:u?r.id:null,filter:d===`all`?`all`:null})}catch(e){c({tone:`bad`,text:e.message||`The comment was not saved.`})}finally{r(!1)}}},onCancel:()=>t(null),busy:n,people:p,hosted:!!m?.hosted,signedInAs:m?.user?.name||null}}}function XE({canComment:e,comparePair:t,commentMode:n,markPicked:r,setDraft:i,setCommentMode:a,showLinks:o,toggleLinks:s,canCompare:c,toggleCompare:l,wide:u,fitBoard:d,minimapOn:p,toggleMinimap:m,chatAvailable:h,reopenChat:g,canChecks:_,openChecks:v}){return[e&&!t?{id:`comment`,label:n?`Stop commenting`:`Comment on a page`,icon:rg,keys:`C`,run:()=>{r(),i(null),a(e=>!e)}}:null,{id:`links`,label:o?`Hide links between pages`:`Show links between pages`,icon:h_,run:s},c?{id:`compare`,label:t?`Leave compare mode`:`Compare environments`,icon:Ch,run:l}:null,u?{id:`fit`,label:`Fit the whole board`,icon:tg,keys:`Shift 1`,run:d}:null,u?{id:`minimap`,label:p?`Hide the minimap`:`Show the minimap`,icon:$h,run:m}:null,h?{id:`agent`,label:`Chat with your agent`,icon:f,run:g}:null,_?{id:`checks`,label:`Open page checks`,icon:xh,run:()=>v()}:null].filter(Boolean)}var ZE=30,QE=28,$E=240;function eD(e){let t=1/e;return{"--sw-zoom":e.toFixed(4),"--sw-inv":t.toFixed(4),"--sw-title-scale":Math.min(t,96/ZE).toFixed(4),"--sw-title-fade":Math.max(0,Math.min(1,(e-.16)*25)).toFixed(3),"--sw-group-scale":Math.min(t,$E/QE).toFixed(4),"--sw-label-scale":Math.min(t,1.6).toFixed(4),"--sw-chip-scale":Math.min(t,1).toFixed(4)}}function tD(){let e=Wu();return(0,G.useEffect)(()=>{let t=null,n=e=>{let n=e.transform[2],r=e.domNode;if(r&&n!==t){t=n;for(let[e,t]of Object.entries(eD(n)))r.style.setProperty(e,t)}};return n(e.getState()),e.subscribe(n)},[e]),null}function nD({fitBoard:e,zoomTo:t}){let n=Vd();(0,G.useEffect)(()=>{let r=r=>{if(!(r.defaultPrevented||r.altKey||r.ctrlKey||r.metaKey||Wb(r.target))&&!document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)){if(r.shiftKey&&r.code===`Digit1`)e();else if(r.shiftKey&&r.code===`Digit0`)t(1);else if(!r.shiftKey&&(r.key===`=`||r.key===`+`))n.zoomIn({duration:fw(200)});else if(!r.shiftKey&&r.key===`-`)n.zoomOut({duration:fw(200)});else return;r.preventDefault()}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,n,t])}function rD({wide:t,clearFocus:n,setSettledZoom:r,minimapOn:a,liveKeys:o,toggleMinimap:s,hideFit:c,hideMinimap:l=!1,fitBoard:u}){let d=Vd(),f=Z(e=>Math.round(e.transform[2]*100)),m=e=>{n(),r(null);let{x:t,y:i,zoom:a}=d.getViewport(),o=document.querySelector(`[data-sw-canvas]`)?.getBoundingClientRect(),s=(o?.width||0)/2,c=(o?.height||0)/2,l=e/a;d.setViewport({x:s-(s-t)*l,y:c-(c-i)*l,zoom:e},{duration:fw(250)})};if(nD({fitBoard:u,zoomTo:m}),!t)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tD,{}),(0,K.jsx)($u,{position:`bottom-left`,className:U(`!m-2`,c&&`hidden`),children:(0,K.jsx)(z,{size:`icon`,variant:`secondary`,className:`bg-surface/95 shadow-pop backdrop-blur`,onClick:u,label:`Fit the whole board`,"data-sw-fit":`true`,children:(0,K.jsx)(tg,{size:17,"aria-hidden":`true`})})})]});let g=a&&!o.size&&!l,_=a&&o.size?`Minimap: hidden while a page is live`:a?`Hide the minimap`:`Show the minimap`,v=`h-8 w-8 rounded-md text-muted shadow-none hover:bg-surface-2 hover:text-fg`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tD,{}),(0,K.jsx)($u,{position:`bottom-left`,className:`!m-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-line bg-surface/95 p-0.5 shadow-pop backdrop-blur`,role:`group`,"aria-label":`Zoom`,"data-sw-zoom-controls":`true`,children:[(0,K.jsx)(z,{className:U(v,`react-flow__controls-zoomout`),onClick:()=>d.zoomOut({duration:fw(200)}),label:`Zoom out`,tooltip:(0,K.jsx)(DT,{label:`Zoom out`,keys:[`-`]}),children:(0,K.jsx)(sg,{size:15,"aria-hidden":`true`})}),(0,K.jsxs)(we,{children:[(0,K.jsx)(p,{content:`Zoom level`,children:(0,K.jsxs)(x,{className:`tabular h-8 min-w-12 rounded-md px-1.5 text-xs font-medium text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":`Zoom ${f}%`,"data-sw-zoom-level":f,children:[f,`%`]})}),(0,K.jsxs)(e,{side:`top`,align:`start`,className:`min-w-52`,children:[(0,K.jsxs)(C,{onSelect:()=>d.zoomIn({duration:fw(200)}),children:[`Zoom in `,(0,K.jsx)(i,{className:`ml-auto`,children:`+`})]}),(0,K.jsxs)(C,{onSelect:()=>d.zoomOut({duration:fw(200)}),children:[`Zoom out `,(0,K.jsx)(i,{className:`ml-auto`,children:`-`})]}),(0,K.jsx)(h,{}),(0,K.jsx)(C,{onSelect:()=>m(.5),children:`Zoom to 50%`}),(0,K.jsxs)(C,{onSelect:()=>m(1),children:[`Zoom to 100% `,(0,K.jsx)(i,{className:`ml-auto`,children:`Shift 0`})]}),(0,K.jsx)(C,{onSelect:()=>m(2),children:`Zoom to 200%`}),(0,K.jsx)(h,{}),(0,K.jsxs)(C,{onSelect:u,children:[`Fit the whole board `,(0,K.jsx)(i,{className:`ml-auto`,children:`Shift 1`})]})]})]}),(0,K.jsx)(z,{className:U(v,`react-flow__controls-zoomin`),onClick:()=>d.zoomIn({duration:fw(200)}),label:`Zoom in`,tooltip:(0,K.jsx)(DT,{label:`Zoom in`,keys:[`+`]}),children:(0,K.jsx)(Cg,{size:15,"aria-hidden":`true`})}),(0,K.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),(0,K.jsx)(z,{className:U(v,`react-flow__controls-fitview`),onClick:u,label:`Fit the whole board`,tooltip:(0,K.jsx)(DT,{label:`Fit the whole board`,keys:[`Shift`,`1`]}),children:(0,K.jsx)(tg,{size:14,"aria-hidden":`true`})}),(0,K.jsx)(z,{className:U(v,a&&`text-accent hover:text-accent`),"aria-pressed":a,onClick:s,label:a?`Hide the minimap`:`Show the minimap`,tooltip:_,"data-sw-minimap-toggle":a?o.size?`auto-hidden`:`on`:`off`,children:(0,K.jsx)($h,{size:14,"aria-hidden":`true`})})]})}),g?(0,K.jsx)(Pm,{pannable:!0,zoomable:!0,position:`bottom-right`,className:`!m-3 overflow-hidden !rounded-lg shadow-pop`,style:{width:168,height:104},bgColor:`color-mix(in srgb, var(--surface) 88%, transparent)`,maskColor:`color-mix(in srgb, var(--sunken) 55%, transparent)`,maskStrokeColor:`var(--accent)`,maskStrokeWidth:2,nodeBorderRadius:6,nodeColor:e=>e.type===`groupFrame`?`color-mix(in srgb, var(--fg) 5%, transparent)`:`color-mix(in srgb, var(--fg) 28%, transparent)`,nodeStrokeWidth:0,ariaLabel:`Minimap`,"data-sw-minimap":`true`}):null]})}function iD(e,t,n=8){return t?e.left<t.right+n&&e.left+e.width>t.left-n&&e.top<t.bottom+n&&e.top+e.height>t.top-n:!1}function aD(e,t){let n=null;for(let r of e||[]){if(!r||r.width<=0||r.height<=0)continue;let e=r.left-t.left,i=r.top-t.top,a=e+r.width,o=i+r.height;n=n?{left:Math.min(n.left,e),top:Math.min(n.top,i),right:Math.max(n.right,a),bottom:Math.max(n.bottom,o)}:{left:e,top:i,right:a,bottom:o}}return n}function oD({card:e,canvas:t,bar:n,avoid:r=null,gap:i=8,zoom:a=1,toggleSize:o=44}){let{width:s,height:c}=t,l=r?r.bottom+i:i,u=e=>Math.max(i,Math.min(c-n.height-i,e)),d=(e,t=n)=>!iD({...e,width:t.width,height:t.height},r,i),f=t=>{let r={left:t,top:u(e.top)};if(d(r))return r;let a={left:t,top:l};return a.top+n.height+i<=c?a:null},p=null;if(e.titleTop-n.height-i>=i){let t={left:Math.max(i,Math.min(e.right-n.width,s-n.width-i)),top:e.titleTop-n.height-i};d(t)&&(p=t)}!p&&e.right+i+n.width<=s-i&&(p=f(e.right+i)),!p&&e.left-i-n.width>=i&&(p=f(e.left-i-n.width));let m=e.titleTop>=i&&a>.2?{top:Math.max(i,e.titleTop-7),left:Math.max(i,Math.min(s-52,e.right-44-Math.min(140,(e.right-e.left)*.3)))}:{top:i,left:i};d(m,{width:o,height:o})||(m={...m,top:l});let h={left:i,top:d({left:i,top:i})?i:l};return{place:p,toggle:m,fallback:h}}var sD=30;function cD({focused:e,target:t,frame:r,title:i,hasLive:a,live:o,ready:s,selecting:c,touch:l,href:u,onOpenLive:d,onToggleSelect:f,onClose:m,history:h=0,onHistory:g=null,onChecks:_=null,onCapture:v=null,captureBusy:y=!1}){let b=Z(e=>e.transform),x=Z(e=>e.width),S=Z(e=>e.height),C=Z(e=>e.domNode),[w,T]=(0,G.useState)(null),E=w===e;(0,G.useEffect)(()=>{e||T(null)},[e]);let[D,O]=(0,G.useState)(null);if((0,G.useLayoutEffect)(()=>{let t=e&&C?C.closest(`[data-sw-canvas]`)?.querySelector(`[data-sw-canvas-notes]`):null,n=()=>{let e=t?aD(Array.from(t.children).map(e=>e.getBoundingClientRect()),C.getBoundingClientRect()):null;O(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)};if(n(),!t)return;let r=new MutationObserver(n);r.observe(t,{childList:!0,subtree:!0,characterData:!0});let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),()=>{r.disconnect(),i?.disconnect()}},[e,C,x,S]),!e||!t||!r)return null;let[k,A,j]=b,M=(t.x+r.x)*j+k,N=(t.y+r.y)*j+A,P=t.y*j+A-(j>.2?sD:0),F=M+r.w*j,ee=N+r.h*j;if(F<0||M>x||ee<0||N>S||sv(r,j))return null;let I=l?54:40,L=(l?236:340)+(g?l?56:90:0)+(v?l?56:120:0)+(_?l?48:90:0),{place:R,toggle:te,fallback:ne}=oD({card:{left:M,top:N,right:F,bottom:ee,titleTop:P},canvas:{width:x,height:S},bar:{width:L,height:I},avoid:D,gap:8,zoom:j}),re=l?`touch`:`sm`,ie=`text-fg shadow-none`,ae=l&&`text-[13px]`;if(!R&&!E)return(0,K.jsx)(z,{size:`icon`,variant:`secondary`,style:te,className:`nodrag nopan absolute z-20 rounded-full bg-surface/95 text-fg shadow-pop`,onClick:t=>{t.stopPropagation(),T(e)},label:`${i} actions`,side:`bottom`,"data-sw-frame-bar-toggle":e,children:(0,K.jsx)(lh,{size:18,"aria-hidden":`true`})});let oe=R?{left:R.left,top:R.top,width:Math.min(L,x-16)}:{left:ne.left,top:ne.top,width:Math.min(L,x-16)};return(0,K.jsxs)(`div`,{className:`nodrag nopan nowheel absolute z-20 flex items-center flex-wrap justify-end gap-1 rounded-lg border border-line bg-surface/95 p-1 shadow-pop backdrop-blur`,style:oe,role:`toolbar`,"aria-label":`${i} actions`,"data-sw-frame-bar":e,onClick:e=>e.stopPropagation(),children:[l?null:(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate px-1.5 text-xs font-medium text-muted`,children:[i,` · `,r.viewport]}),a&&!o?(0,K.jsxs)(n,{size:re,variant:`default`,className:U(`shadow-none`,ae),onClick:d,"data-sw-open-live":e,children:[(0,K.jsx)(lg,{size:15,"aria-hidden":`true`}),` Open live`]}):null,o?(0,K.jsxs)(n,{size:re,variant:c?`default`:`ghost`,className:U(`shadow-none`,ae,!c&&`text-fg`),"aria-pressed":c,disabled:!s,onClick:f,"data-sw-select-text":e,children:[(0,K.jsx)(Zg,{size:15,"aria-hidden":`true`}),` `,c?`Done`:`Select text`]}):null,_?(0,K.jsxs)(n,{size:re,variant:`ghost`,className:ie,onClick:_,"aria-label":`Page checks`,"data-sw-frame-checks":e,children:[(0,K.jsx)(xh,{size:15,"aria-hidden":`true`}),l?null:`Checks`]}):null,g?(0,K.jsx)(p,{content:`Page history: ${h+1} captures`,children:(0,K.jsxs)(n,{size:re,variant:`ghost`,className:ie,onClick:g,"aria-label":`Page history: ${h+1} captures`,"data-sw-frame-history":e,children:[(0,K.jsx)(Dg,{size:15,"aria-hidden":`true`}),` `,l?null:`History`]})}):null,v?(0,K.jsx)(p,{content:`Recapture this page at every screen size`,children:(0,K.jsxs)(n,{size:re,variant:`ghost`,className:ie,disabled:y,onClick:v,"aria-label":`Capture this page`,"data-sw-frame-capture":e,children:[(0,K.jsx)(Gm,{size:15,"aria-hidden":`true`}),` `,l?null:`Capture`]})}):null,u?(0,K.jsx)(z,{asChild:!0,size:l?`icon`:`icon-sm`,className:ie,label:`Open the page in a new tab`,children:(0,K.jsx)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,children:(0,K.jsx)(dh,{size:15,"aria-hidden":`true`})})}):null,(0,K.jsx)(z,{size:l?`icon`:`icon-sm`,onClick:R?m:()=>T(null),label:R?`Close`:`Collapse`,"data-sw-frame-bar-close":`true`,children:(0,K.jsx)(B,{size:15,"aria-hidden":`true`})})]})}function lD({onChecks:e,onHistory:t,historyCountFor:n,focusedKey:r,layout:i,data:a,liveKeys:o,readyKeys:s,selectingKey:c,touch:l,liveFileFor:u,onOpenLive:d,onToggleSelect:f,onClose:p,onCapture:m,captureBusy:h}){if(!r)return null;let g=r.lastIndexOf(`|`),_=r.slice(0,g),v=r.slice(g+1),y=i.targets[_],b=y?.frames.find(e=>e.viewport===v);if(!b)return null;let x=_.startsWith(`variant:`)?a?.variants?.find(e=>`variant:${e.id}`===_):null,S=x?null:a?.board?.pages.find(e=>e.id===_);return(0,K.jsx)(cD,{focused:r,target:y,frame:b,title:x?x.title:S?.title||_,hasLive:!!u(_,v),live:o.has(r),ready:s.has(r),selecting:c===r,touch:l,href:S?.url||(x?.source&&/^https?:/.test(x.source)?x.source:null),onOpenLive:()=>d(_,v),onToggleSelect:()=>f(r),onClose:p,history:S&&a?.versions?.[S.id]?.[v]?.length||0,onChecks:S&&e?()=>e(S.id,v):null,onHistory:S&&n(S.id)?()=>t(S.id,v):null,onCapture:S&&m?()=>m(S.id):null,captureBusy:h})}var uD=(0,G.lazy)(()=>iC(()=>import(`./ShareDialog-C_plIto0.js`).then(e=>({default:e.MigrationBanner})),__vite__mapDeps([9,1]),import.meta.url)),dD=()=>{},fD=new Set;function pD(e,t){let n=new Map;for(let r of e||[])n.has(t(r))||n.set(t(r),r);return n}function mD({boardId:e,boards:t,info:n,onPickBoard:r,onInfoChanged:i,onOpenBuzz:o}){let s=ye(`(min-width: 1024px)`),l=ye(`(max-width: 640px)`),u=Vd(),d=E(),f=tw(),[p,m]=Ke(),[h,g]=(0,G.useState)(!1),_=!n?.readOnly&&(!a||F),v=_&&!a&&!n?.hosted,y=_&&n?.allowCapture,b=e=>n?.permissions?.[e]!==!1,{view:x,commentsQuery:C,data:w,capture:T,comments:D,fixRequest:O,setFixRequest:k,setPolling:j,deletingIds:M,setDeletingIds:N}=jE(e),P=Qe(n?.localProjectsEnabled?`/api/local-projects`:null,{pollMs:3e4}),ee=P.data?.projects||[],I=(0,G.useMemo)(()=>w?.viewports||{},[w?.viewports]),L=Object.keys(I),R=(0,G.useMemo)(()=>{let e=L.map(e=>({id:e,label:W_(e)}));return e.length>1&&e.push({id:`all`,label:e.length===2?`Both`:`All`}),e},[L.join(`,`)]),z=l&&L.includes(`phone`)?`phone`:L[0]||`desktop`,B=R.some(e=>e.id===p.get(`vp`))?p.get(`vp`):z,te=ax.some(e=>e.id===p.get(`filter`))?p.get(`filter`):`open`,ne=Number(p.get(`c`))||null,re=(p.get(`q`)||``).slice(0,120),ie=I_.some(e=>e.id===p.get(`st`))?p.get(`st`):null,ae=/^[a-z][\w.-]{0,39}$/.test(p.get(`m`)||``)?p.get(`m`):null,oe=p.get(`panel`)===`off`,{canChecks:se,checksOpen:ce,checksPage:H,checksViewport:le,checksQuery:ue,openChecks:de,closeChecks:W,checksCounts:me,checksPanelProps:he,checksRun:ge}=VE({boardId:e,info:n,params:p,updateParams:m,pages:w?.board?.pages}),[_e,ve]=(0,G.useState)(``),{chatAvailable:be,chatThread:xe,settingsAvailable:Se,localSettingsAvailable:we,generalSettingsOpen:Te,settingsOpen:Ee,openSettings:De,openChat:Oe,reopenChat:ke}=HE({boardId:e,info:n,params:p,updateParams:m}),Ae=(0,G.useRef)(null),je=(0,G.useRef)(_w(p.get(`v`))),Me=(0,G.useRef)(null),[Ne,Pe]=(0,G.useState)(!1),[Fe,Ie]=(0,G.useState)(null),[Le,Re]=(0,G.useState)(!1),[ze,Be]=(0,G.useState)(!1),Ve=n?.localUser?.name||``,[He,Ue]=(0,G.useState)(()=>pe()),We=He||Ve,Ge=(0,G.useCallback)(()=>pe()||Ve,[Ve]),qe=(0,G.useRef)(null),[Je,Ye]=(0,G.useState)(!1),[Xe,Ze]=(0,G.useState)(null),[$e,et,tt]=QT(),[nt,rt]=(0,G.useState)(()=>kw()),it=nt??Aw(w?.board?.pages?.length||0),[at,ot]=(0,G.useState)(!1),st=rx(e),ct=st&&[`working`,`waiting`].includes(st.state)&&Number(st.commentId)||null,lt=(0,G.useMemo)(()=>ct?new Set([ct]):fD,[ct]),[ut,dt]=(0,G.useState)(!1),[ft,pt]=(0,G.useState)(null),[mt,ht]=(0,G.useState)(null),[gt,_t]=(0,G.useState)(null),[vt,yt]=(0,G.useState)(null),[bt,xt]=(0,G.useState)(()=>!Mw()),[St,Ct]=iw(!!d),[wt,Tt]=(0,G.useState)(()=>new Set),Et=(0,G.useCallback)(e=>Tt(t=>t.has(e)?t:new Set(t).add(e)),[]),Dt=(0,G.useCallback)(()=>{xt(!1),Pw()},[]),Ot=()=>{Ct(),Dt()},kt=p.get(`hist`),At=p.get(`hv`),{journeys:jt,journey:Mt,route:Nt,routeGraph:Pt,routePages:Ft,step:It,journeyComments:Lt}=ME({params:p,data:w,builder:gt}),q=p.get(`links`)===`1`,Rt=Array.isArray(w?.brokenLinks)?w.brokenLinks:[],zt=Rt.length?`Arrows for the links between pages; ${Rt.length} ${Rt.length===1?`link leads`:`links lead`} to an error`:`Arrows for the links between pages`,{environments:Bt,comparePair:Vt,changedOnly:Ht,showDiff:Ut,compareQuery:Wt,compareData:Gt,compareView:Kt,setCompare:qt,canCompare:Jt,toggleCompare:Yt,setChangedOnly:Xt}=UE({boardId:e,params:p,updateParams:m,environmentList:w?.environments,setCommentMode:Pe,pageCount:w?.board?.pages?.length||0}),Zt=(0,G.useMemo)(()=>{let e=w?.board?.pages||[];return!Ht||!Gt?e:e.filter(e=>(j_(Gt,e.id)||0)>0)},[Ht,Gt,w?.board?.pages]),Qt=(0,G.useMemo)(()=>w?.board&&L.length?pv({pages:Zt,groups:w.board.groups,variants:Vt?[]:w.variants,viewports:I,mode:B,compare:Vt}):{nodes:[],edges:[],targets:{}},[w?.board,w?.variants,Zt,I,B,Vt]),[$t,en,tn]=Qp(Qt.nodes);(0,G.useEffect)(()=>{en(Qt.nodes)},[Qt.nodes,en]);let nn=tm(),[rn,an]=Dw(nn),[on,sn]=(0,G.useState)(null),[cn,ln]=(0,G.useState)(null),un=(0,G.useCallback)(()=>{sn(null),ln(null)},[]),dn=(0,G.useCallback)(()=>{un(),an(null),u.fitView({...hw,duration:fw(400)})},[un,u,an]);IE({mode:B,pendingFocus:ft,shapeKey:`${Vt?.join(`_`)||``}|${Ht&&Gt?Zt.length:`all`}`,clearFocus:un,fitBoard:dn});let fn=(0,G.useMemo)(()=>pD(w?.board?.pages,e=>e.id),[w?.board?.pages]),pn=(0,G.useMemo)(()=>pD(w?.variants,e=>`variant:${e.id}`),[w?.variants]),{visibleComments:mn,pinsByTarget:hn,counts:gn}=WE({comments:D,query:re,stateFilter:ie,mentionFilter:ae,titleOfPage:(0,G.useCallback)(e=>String(e).startsWith(`variant:`)?pn.get(e)?.title||``:fn.get(e)?.title||``,[fn,pn]),filter:te,journey:Mt,journeyComments:Lt}),_n=(0,G.useMemo)(()=>S(D),[D]),vn=(0,G.useMemo)(()=>({name:n?.user?.name||We||``,handle:n?.user?.handle||null}),[n?.user?.name,n?.user?.handle,We]),yn=_&&!w?.migratedTo?.readOnly&&b(`comment`),bn=e=>{let t=!!vn.handle&&e.authorHandle===vn.handle;return{reply:_&&!w?.migratedTo?.readOnly&&b(`reply`),resolve:_&&!w?.migratedTo?.readOnly&&b(`resolve`),react:_&&!w?.migratedTo?.readOnly&&b(`react`),edit:_&&!w?.migratedTo?.readOnly&&b(`edit`)&&(!n?.hosted||JS({isAuthor:t})),delete:_&&!w?.migratedTo?.readOnly&&b(`delete`)&&(!n?.hosted||YS({role:n.role,isAuthor:t}))}},{seen:xn,markSeen:Sn,markAllSeen:Cn}=GS(e),wn=(0,G.useMemo)(()=>new Set(D.filter(e=>WS(e,xn,vn)).map(e=>e.id)),[D,vn,xn]),Tn=D.find(e=>e.id===ne)||null,En=(0,G.useMemo)(()=>{let e=new Set;for(let t of D)t.status!==`resolved`&&(t.agentStatus===`working`||lt.has(t.id))&&e.add(t.pageId);return e},[lt,D]),Dn=(0,G.useCallback)(e=>fn.get(e)||null,[fn]),On=(0,G.useCallback)(e=>{if(e.startsWith(`variant:`)){let t=pn.get(e);return t?`Variant: ${t.title}`:`Removed variant`}return Dn(e)?.title||e},[pn,Dn]),kn=w?.manifest?.capturedAt||`none`,An=(0,G.useRef)(null),{refetch:jn}=x,{refetch:Mn}=C,{refetch:Nn}=Wt,Pn=(0,G.useCallback)(()=>{let e=`${kn}|${w?.environments?.map(e=>e.capturedAt).join(`,`)||``}`;An.current!==e&&(An.current=e,jn(),Mn(),Nn())},[w?.environments,kn,Mn,Nn,jn]),Fn=(0,G.useRef)(!1),In=(0,G.useCallback)(e=>{Fn.current=!1,Ie(null),m({c:e.id}),s||(Re(!1),Be(!0))},[m,s]),Ln=(0,G.useCallback)(()=>{Be(!1),m({c:null}),Fn.current&&!s&&Re(!0),Fn.current=!1},[m,s]),Rn=(0,G.useCallback)(e=>{let t=B!==`all`&&e.viewport!==B&&!!I[e.viewport];Ie(null),pt(e),m({c:e.id,...t?{vp:e.viewport===z?null:e.viewport}:{}}),t&&yt({from:B,to:e.viewport,id:e.id,at:Date.now()}),s||(Re(!1),Be(!0))},[z,B,m,I,s]);(0,G.useEffect)(()=>{if(!vt)return;let e=window.setTimeout(()=>yt(null),6e3);return()=>window.clearTimeout(e)},[vt]),PE({pendingFocus:ft,setPendingFocus:pt,targets:Qt.targets,viewports:I,flow:u,canvasRef:Me,wide:s,setSettledZoom:an}),FE({wide:s,nodesReady:nn,initialCamera:je,selectedCommentId:ne,canvasRef:Me,nodes:Qt.nodes,flow:u,setSettledZoom:an});let zn=(0,G.useRef)(!je.current&&!ne&&!p.get(`j`)),Bn=(0,G.useRef)(!je.current&&!!ne),[Vn,Hn]=(0,G.useState)(()=>!s||!zn.current);(0,G.useEffect)(()=>{if(!zn.current||!nn||!Qt.nodes.length)return;if(zn.current=!1,!s){Hn(!0);return}let e=Tw(Qt.nodes,Me.current?.getBoundingClientRect());an(null);let t=e?u.setViewport(e):u.fitView(hw);Promise.resolve(t).finally(()=>Hn(!0))},[u,Qt.nodes,nn,an,s]);let Un=(0,G.useRef)(!1),Wn=()=>{Un.current=!0},Gn=(0,G.useCallback)(e=>{Un.current&&(Un.current=!1,e.preventDefault(),Me.current?.focus({preventScroll:!0}))},[]),{liveKeys:Kn,readyKeys:qn,setLiveReady:Jn,liveFileFor:Yn,recomputeLive:Xn,openLive:Zn}=xE({canvasRef:Me,flow:u,targets:Qt.targets,viewports:I,settledZoom:rn,setSettledZoom:an,comparePair:Vt,captures:w?.captures,variantsById:pn});(0,G.useEffect)(()=>{cn&&!Kn.has(cn)&&ln(null)},[Kn,cn]);let{openJourney:Qn,closeJourney:$n,goStep:er,chooseJourneyBranch:tr,startBuilder:nr,addBuilderStep:rr,saveBuilder:ir,removeJourney:ar}=kE({boardId:e,view:x,updateParams:m,clearFocus:un,setCommentMode:Pe,journey:Mt,route:Nt,routePages:Ft,step:It,builder:gt,setBuilder:_t,busy:ut,setBusy:dt,setNotice:Ze,flow:u,targets:Qt.targets,nodesReady:nn,mode:B,comparePair:Vt,setSettledZoom:an}),or=on&&!on.startsWith(`variant:`)?G_(on):null,sr=or?.targetId||null,cr=mt||sr,lr=p.get(`la`)===`1`,{presentPages:ur,shownSteps:dr,hiddenLinkTargets:fr,edges:pr,journeyView:mr}=GE({targets:Qt.targets,layoutEdges:Qt.edges,links:w?.links,showLinks:q,showAllLinks:lr,activePage:cr,builder:gt,route:Nt,routeGraph:Pt,routePages:Ft,step:It,journey:Mt,targetTitle:On}),hr=(0,G.useCallback)((e,t=null)=>{if(!e||String(e).startsWith(`variant:`))return;let n=B===`all`?L[0]:B;m({hist:e,hv:t&&t!==n?t:null})},[B,m,L.join(`,`)]),gr=kt&&w?.board?.pages.find(e=>e.id===kt)||null,_r=At&&I[At]?At:B===`all`?L[0]:B,vr=(0,G.useCallback)(()=>m({hist:null,hv:null}),[m]),yr=t=>{let n=Qt.targets[t];if(!n)return;an(null);let r=n.frames[0],i=n.frames.map(e=>w?.captures?.[t]?.[e.viewport]).filter(e=>e?.thumb||e?.file);vw(u,n,Me.current?.getBoundingClientRect(),{phoneCompare:!!Vt&&!s,shotUrls:i.map(t=>c(e,`captures`,t.thumb||t.file,kn))}),r&&sn(`${t}|${r.viewport}`)},br=(0,G.useMemo)(()=>{let e=Zt;return[...new Set(e.map(e=>e.group))].map(t=>({group:t,pages:e.filter(e=>e.group===t)}))},[Zt]),xr=(0,G.useMemo)(()=>Fe?{pageId:Fe.pageId,viewport:Fe.viewport,x:Fe.x,y:Fe.y,anchor:Fe.anchor}:null,[Fe?.pageId,Fe?.viewport,Fe?.x,Fe?.y,Fe?.anchor]),Sr=(0,G.useCallback)((e,t,n)=>{let r=Qt.targets[e],i=r?.frames.find(e=>e.viewport===t);i&&(u.getZoom()>=3.9?In(n[0].comment):(an(null),u.fitBounds(yw(r,i,n),{padding:.3,duration:fw(450)})))},[u,Qt.targets,In,an]),{board:Cr,view:wr}=qE({boardId:e,data:w,viewports:I,journeyView:mr,compareView:Kt,commentMode:Ne,canComment:yn,wide:s,hosted:n?.hosted,imageVersion:kn,pinsByTarget:hn,me:vn,checksCounts:me,canChecks:se,agentFocus:lt,agentWorkingPages:En,setLiveReady:Jn,focusedKey:on,selectingKey:cn,settledZoom:rn,selectedComment:Tn,draftSpot:xr,unread:wn,liveKeys:Kn,selectedCommentId:ne,closeThread:Ln,builder:gt,addBuilderStep:rr,layout:Qt,flow:u,canvasRef:Me,setSettledZoom:an,setFocusedKey:sn,setToast:et,setDraft:Ie,checkDraft:_e,setCheckDraft:ve,authorName:Ge,selectComment:In,openCluster:Sr,openChecks:de,openHistory:hr,updateParams:m,defaultMode:z,onImageError:Pn}),{commentsUrl:Tr,applyComment:Er,setStatus:Dr,replyTo:Or,editComment:kr,reactTo:Ar,copyLink:jr,githubIssue:Mr,removeComment:Nr,sendToAgent:Pr}=AE({boardId:e,commentsQuery:C,view:x,info:n,localName:We,authorName:Ge,setBusy:dt,setNotice:Ze,setToast:et,setDeletingIds:N,selectedCommentId:ne,closeThread:Ln,wide:s,filter:te,allowed:b}),{draftDescription:Fr,composerProps:Ir}=YE({draft:Fe,setDraft:Ie,busy:ut,setBusy:dt,commentsUrl:Tr,applyComment:Er,markSeen:Sn,setLocalName:Ue,setNotice:Ze,updateParams:m,wide:s,filter:te,targetTitle:On,people:_n,info:n}),{captureConfirm:Lr,setCaptureConfirm:Rr,startCapture:zr}=JE({boardId:e,view:x,setBusy:dt,setNotice:Ze,setPolling:j}),Br=(0,G.useCallback)(e=>{m({v:`${Math.round(e.x)},${Math.round(e.y)},${e.zoom.toFixed(3)}`}),an(e.zoom),Xn()},[Xn,an,m]),Vr=Kb({canvasRef:Me,flow:u,minZoom:mw,maxZoom:4,onRest:Br}),Hr=(0,G.useCallback)((e,t)=>{Vr.moving()||Br(t)},[Br,Vr]);V(!!on,un),(0,G.useEffect)(()=>{on&&bt&&Dt()},[Dt,on,bt]),V(Ne,()=>Pe(!1)),V(!!Mt,$n),V(!!gt,()=>_t(null)),CE({commentMode:Ne,setCommentMode:Pe,canComment:yn,comparePair:Vt,setDraft:Ie});let[Ur,Wr]=mT(s,!1);(0,G.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`k`||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]):not([data-sw-palette])`)||(e.preventDefault(),ot(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,G.useEffect)(()=>{Ne||Ie(e=>e&&!e.body.trim()?null:e)},[Ne]),(0,G.useEffect)(()=>{Tn&&Sn(Tn)},[Sn,Tn]),(0,G.useEffect)(()=>{Tn&&Et(`open`),Ne&&Et(`comment`),xe&&Et(`agent`)},[xe,Ne,Et,Tn]),LE({nodesReady:nn,data:w,commentsLoaded:C.data,selectedCommentId:ne,selectedComment:Tn,initialCamera:je,focusComment:Rn,deletingIds:M,setNotice:Ze,updateParams:m});let{threadList:Gr,threadIndex:Kr,stepThread:qr,neighborNote:Jr}=RE({selectedComment:Tn,visibleComments:mn,focusComment:Rn,mode:B,viewports:I,modes:R});(0,G.useEffect)(()=>{let e=null,t=wr.subscribe(()=>{let{hoveredId:t}=wr.get(),n=t===null?null:Me.current?.querySelector(`[data-sw-pin="${t}"]`)||null;n!==e&&(e?.removeAttribute(`data-sw-pin-hover`),n?.setAttribute(`data-sw-pin-hover`,`true`),e=n)});return()=>{t(),e?.removeAttribute(`data-sw-pin-hover`)}},[wr]);let Yr=e=>{yt(null),m({vp:e===z?null:e})},Xr=D.filter(e=>e.status===`open`).length,Zr={comments:mn,filter:te,counts:gn,onFilter:e=>m({filter:e===`open`?null:e}),selectedId:ne,onHover:Cr.onHoverComment,onFocus:e=>{Fn.current=!s,Rn(e)},unread:wn,onMarkAllRead:()=>Cn(D),people:_n,narrow:{query:re,state:ie,mention:ae,onQuery:e=>m({q:e||null}),onState:e=>m({st:e}),onMention:e=>m({m:e}),onClear:()=>m({q:null,st:null,m:null})},canAct:yn,targetTitle:On,touch:!s,onResetBrowserComments:F?()=>{A(e),m({c:null}),C.refetch(),x.refetch()}:null,journeyFilter:Mt?{name:Mt.name,on:Lt,onToggle:()=>m({jc:Lt?null:`1`})}:null},Qr=Tn?{comment:Tn,page:Dn(Tn.pageId),title:On(Tn.pageId),people:_n,me:vn,can:bn(Tn),role:n?.guest?`guest`:n?.role||null,hosted:!!n?.hosted,onSaveName:Ue,busy:ut,touch:!s,editingRef:qe,actions:{onReply:Or,onSendToAgent:n?.hosted&&w?.agentDispatch&&!Tn.authorGuest&&!Tn.authorAgent?Pr:null,onStatus:Dr,onEdit:kr,onDelete:Nr,onReact:Ar,onCopyLink:jr,onFixAgent:be&&!w?.migratedTo?.readOnly&&n?.agent?.fixWithAgent&&n?.agent?.configured?e=>{k({commentId:e.id,nonce:Date.now()}),s||Be(!1),Oe(nS(e.id))}:null,onAskAgent:be?e=>{s||Be(!1),Oe(nS(e.id))}:null,onGithubIssue:!a&&n?.github?.ready?Mr:null,onHistory:e=>{s||Be(!1),hr(e.pageId,e.viewport)}},nav:{index:Kr,total:Gr.length,onPrev:()=>qr(-1),onNext:()=>qr(1),prevNote:Jr(-1),nextNote:Jr(1)},beforeAfter:w?{pairFor:e=>k_(e,{manifest:w.manifest,captures:w.captures,versions:w.versions}),nativeFor:e=>{let t=String(e.pageId).startsWith(`variant:`)?pn.get(e.pageId):null,n=fn.get(t?t.pageId:e.pageId);return uv(I,e.viewport,n?.frameHeight)||null},urlFor:t=>c(e,t.kind,t.file,t.version),onImageError:Pn}:null}:null,$r={boardId:e,fixRequest:O,onFixDone:()=>{k(null),x.refetch(),C.refetch()},agent:n?.agent,threadId:xe||`board`,onThread:Oe,comments:D,pages:w?.board?.pages||[],captures:w?.captures||{},imageVersion:kn,defaultViewport:B===`all`?z:B,focused:or?{pageId:or.targetId,viewport:or.viewport}:null,touch:!s,onOpenSettings:Se?De:null,settingsLocked:!!(be&&!Se&&n?.agent?.settingsLocked),onAgentChanged:i,people:_n,onRunChecks:ge?async()=>{let e=await ge.start({seo:ge.seoDefault});return de(),e}:null,journeys:jt,checksCounts:se?me:null,onBoardChanged:()=>{x.refetch(),C.refetch()},onNavigate:e=>{if(!s&&e.kind!==`check`&&m({chat:null}),e.kind===`comment`){let t=D.find(t=>t.id===e.id);t&&Rn(t)}else e.kind===`page`?yr(e.id):e.kind===`journey`?Qn(e.id):e.kind===`check`&&de(e.id)},onRecapture:y&&!Vt?e=>e?zr(null,Array.isArray(e)?e:[e]):Rr(!0):Ce?()=>Ze({tone:`info`,text:`The demo does not take new captures. On your own board this recaptures the changed pages.`}):null},ei=()=>m({links:q?null:`1`}),ti=()=>{let e=!it;rt(e),Nw(e)},ni=!!gr||Ee||Te||Lr||!s&&ce,ri={data:ue.data,error:ue.error,loading:ue.loading,pages:w?.board?.pages||[],pageId:H,viewport:le,onSelect:de,onClose:W,onRefresh:ue.refetch,onEnvironment:e=>m({ce:e}),canComment:yn,local:!a&&!n?.hosted,onView:(e,t)=>{W(),m({vp:t,page:e}),pt({pageId:e,viewport:t,x:50,y:50})},onDraft:(e,t,n)=>{ve(`${n.title}\n\n${n.observation}\n${n.nextAction}\n\nCheck report ${t.id} (${e.viewport}, ${t.auditedAt}). Separately sampled; review before sending to an agent.`.slice(0,1800)),W(),m({vp:e.viewport}),pt({pageId:e.pageId,viewport:e.viewport,x:50,y:50}),Re(!1),Pe(!0),et({at:Date.now(),text:`Choose a pin on the page, then review and save your comment.`})},...he},ii=e=>{e.preventDefault(),W(),s?((oe||xe)&&m({panel:null,chat:null}),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>document.getElementById(`sw-comments`)?.focus()))):Re(!0)},ai=e=>qb(e,e=>{let t=Qt.targets[e]?.frames[0];t&&Cr.onFocusFrame(e,t.viewport)}),oi=XE({canComment:yn,comparePair:Vt,commentMode:Ne,markPicked:Wn,setDraft:Ie,setCommentMode:Pe,showLinks:q,toggleLinks:ei,canCompare:Jt,toggleCompare:Yt,wide:s,fitBoard:dn,minimapOn:it,toggleMinimap:ti,chatAvailable:be,reopenChat:ke,canChecks:se,openChecks:de}),si={setMenuOpen:Ye,data:w,chatAvailable:be,chatThread:xe,reopenChat:ke,updateParams:m,groupedPages:br,jumpToPage:yr,modes:R,mode:B,setMode:Yr,journeys:jt,journey:Mt,canEditJourneys:v,openJourney:Qn,startBuilder:nr,canChecks:se,openChecks:de,showLinks:q,toggleLinks:ei,brokenLinks:Rt,canCompare:Jt,comparePair:Vt,toggleCompare:Yt,settingsAvailable:Se,openSettings:De,capture:T,canCapture:y,busy:ut,setCaptureConfirm:Rr};return(0,K.jsxs)(hD,{board:Cr,view:wr,people:_n,children:[(0,K.jsxs)(`div`,{className:`flex h-full flex-col`,"data-sw-board":e,style:{paddingTop:`env(safe-area-inset-top, 0px)`},children:[(0,K.jsx)(dC,{}),(0,K.jsx)(TC,{}),n?.hosted&&w?.agentApprove?(0,K.jsx)(CC,{boardId:e}):null,(0,K.jsx)(`a`,{href:`#sw-comments`,className:`sr-only z-[80] rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg focus:not-sr-only focus:absolute focus:top-2 focus:left-2`,onClick:ii,"data-sw-skip-comments":`true`,children:`Skip to comments`}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[s?(0,K.jsx)(pE,{...si,info:n,localName:We,onOpenBuzz:o,demo:d,localSettingsAvailable:we,setShareOpen:g,expanded:Ur,onToggle:Wr,pages:w?{groups:br,journeys:jt,comments:D,activePage:cr,journeyId:Mt?.id||null,onPage:yr,onJourney:Qn}:null}):null,(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(YT,{...si,wide:s,info:n,boardId:e,boards:t,localProjects:ee,projectsError:P.error,localName:We,onPickBoard:r,onOpenBuzz:o,demo:d,localSettingsAvailable:we,setShareOpen:g,viewportNotice:vt,canComment:yn,commentMode:Ne,setCommentMode:Pe,openPalette:()=>ot(!0),minimapOn:it,toggleMinimap:ti,linksTip:zt,panelHidden:oe,checksOpen:ce,allOpen:Xr,closeChecks:W,setSheetOpen:Re,sidebarTitled:s&&Ur}),!n?.hosted&&w?.migratedTo?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(uD,{marker:w.migratedTo,boardId:e,editable:!!n?.shareEnabled,onChange:x.refetch})}):null,(0,K.jsx)(eE,{notice:Xe,setNotice:Ze,wide:s}),Vt?(0,K.jsx)(vx,{environments:Bt,pair:Vt,loading:Wt.loading||!Gt,error:Wt.error?Wt.error.message:null,changedPages:Gt?.changedPages??0,totalPages:w?.board?.pages?.length||0,changedOnly:Ht,showDiff:Ut,canCapture:y,captureBusy:ut||!!T?.running,touch:!s,onPair:e=>qt(e),onChangedOnly:Xt,onShowDiff:e=>m({diff:e?null:`off`}),onCapture:e=>zr(e),onClose:()=>qt(null)}):null,(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,K.jsxs)(`div`,{ref:Me,tabIndex:-1,className:U(`relative min-w-0 flex-1 outline-none`,Ne&&yn&&`sw-commenting`),onKeyDown:ai,"data-sw-canvas":`true`,children:[q&&Rt.length?(0,K.jsx)(ET,{items:Rt}):null,(0,K.jsx)(ZT,{wide:s,commentMode:Ne,canComment:yn,readyKeys:qn,setCommentMode:Pe,showLinks:q,activePage:cr,shownSteps:dr,data:w,presentPages:ur,hiddenLinkTargets:fr,showAllLinks:lr,targetTitle:On,updateParams:m,tipOpen:bt,tryOpen:St,journey:Mt,builder:gt,viewportNotice:vt,dismissTip:Dt,modes:R,setMode:Yr,comparePair:Vt}),!w&&x.error?(0,K.jsx)(S_,{error:x.error,onRetry:x.refetch}):w?(0,K.jsxs)(qp,{nodes:$t,edges:pr,edgeTypes:Pb,onNodeMouseEnter:q?(e,t)=>ht(t.type===`page`?t.id:null):void 0,onNodeMouseLeave:q?()=>ht(null):void 0,onNodesChange:tn,onNodeClick:dD,nodeTypes:kb,colorMode:f,defaultViewport:je.current||void 0,fitView:Bn.current,style:Vn?void 0:{opacity:0},edgesFocusable:!1,fitViewOptions:hw,minZoom:mw,maxZoom:4,panOnScroll:!1,zoomOnScroll:!1,panActivationKeyCode:null,zoomActivationKeyCode:null,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,zoomOnDoubleClick:!Ne,onMoveEnd:Hr,onPaneClick:()=>{un(),ne&&Ln()},proOptions:{hideAttribution:!0},children:[(0,K.jsx)(lm,{gap:40,size:1}),(0,K.jsx)(lD,{onChecks:se?de:null,onHistory:hr,historyCountFor:e=>F_(w?.versions,e),focusedKey:on,layout:Qt,data:w,liveKeys:Kn,readyKeys:qn,selectingKey:cn,touch:!s,liveFileFor:Yn,onOpenLive:Zn,onToggleSelect:e=>ln(t=>t===e?null:e),onClose:un,onCapture:y&&!Vt?e=>zr(null,[e]):null,captureBusy:ut||!!T?.running}),s&&Fe&&!ni?(0,K.jsx)(LS,{point:_v(Qt.targets,Fe),onClose:()=>ut?null:Ie(null),children:(0,K.jsx)(xx,{...Ir,touch:!1,description:Fr})}):null,s&&Qr&&!Fe&&!ni?(0,K.jsx)(IS,{comment:Tn,point:_v(Qt.targets,Tn),onClose:Ln,onPrev:()=>qr(-1),onNext:()=>qr(1),editingRef:qe,children:(0,K.jsx)(OS,{...Qr,onClose:Ln})}):null,(0,K.jsx)(rD,{wide:s,clearFocus:un,setSettledZoom:an,minimapOn:it,liveKeys:Kn,toggleMinimap:ti,hideFit:!!(Mt||gt),hideMinimap:!!(Mt||gt),fitBoard:dn})]}):(0,K.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted`,children:[(0,K.jsx)(fe,{}),` Loading board`]}),n?.hosted&&!Ce?(0,K.jsx)(jC,{touch:!s,enabled:!!w&&!a,boardId:e,canvasRef:Me,flow:u,selection:ne,mode:B,onMode:e=>m({vp:e}),onInvalidate:()=>{C.refetch(),x.refetch()}}):null,St&&w&&!Mt&&!gt&&(!Ne||s)?(0,K.jsx)(aw,{touch:!s,done:wt,onOpenComment:()=>{let e=mn.filter(e=>e.status===`open`),t=e.find(e=>B===`all`||e.viewport===B)||e[0]||mn[0];t&&Rn(t)},onComment:yn&&!Vt?()=>{Ie(null),Pe(!0)}:null,onAgent:be?ke:null,onClose:Ot}):null,(0,K.jsx)($T,{toast:$e,setToast:et,onHold:tt,wide:s,raised:!!(Mt||gt)}),Vt&&Ht&&Gt&&!Zt.length?(0,K.jsx)(`p`,{className:`absolute inset-x-0 top-1/3 mx-auto w-max max-w-[90%] rounded-lg bg-surface px-4 py-3 text-sm text-muted shadow-pop`,children:`No visual changes between these two environments.`}):null,gt?(0,K.jsx)(px,{draft:gt,pages:w?.board?.pages||[],onChange:_t,onSave:ir,onCancel:()=>_t(null),pageTitle:e=>Dn(e)?.title||e,busy:ut,touch:!s}):Mt?(0,K.jsx)(fx,{journey:Mt,route:Nt,step:It,pageTitle:e=>Dn(e)?.title||e,onStep:er,onChoose:tr,onClose:$n,onEdit:()=>nr(Mt),onDelete:ar,canEdit:v&&Mt.source===`board`,busy:ut,touch:!s},Mt.id):null]}),(0,K.jsx)(rE,{wide:s,checksOpen:ce,checksProps:ri,chatThread:xe,chatProps:$r,panelHidden:oe,panelProps:Zr,updateParams:m})]})]})]}),(0,K.jsx)(cC,{ref:Ae})]}),s?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(uE,{checksOpen:ce,closeChecks:W,checksProps:ri,chatAvailable:be,chatThread:xe,chatProps:$r,updateParams:m,sheetOpen:Le,setSheetOpen:Re,panelProps:Zr,threadSheet:ze,threadProps:Qr,closeThread:Ln,selectedComment:Tn,targetTitle:On,draft:Fe,busy:ut,setDraft:Ie,draftDescription:Fr,composerProps:Ir}),(0,K.jsx)(XT,{...si,menuOpen:Je})]}),(0,K.jsx)(vE,{info:n,boardId:e,boards:t,wide:s,shareOpen:h,setShareOpen:g,refetchView:jn,settingsAvailable:Se,settingsOpen:Ee,updateParams:m,onInfoChanged:i,generalSettingsOpen:Te,updates:Ae,historyPage:gr,closeHistory:vr,historyViewport:_r,historyPageId:kt,data:w,comments:D,filter:te,focusComment:Rn,onImageError:Pn,captureConfirm:Lr,setCaptureConfirm:Rr,busy:ut,focusedPage:sr,findPage:Dn,startCapture:zr}),(0,K.jsx)(Yw,{open:at,onOpenChange:ot,groups:br,journeys:jt,canEditJourneys:v,comments:D,titleOf:On,actions:oi,onPage:e=>{Wn(),yr(e)},onJourney:e=>{Wn(),Qn(e)},onNewJourney:()=>{Wn(),nr()},onComment:e=>{Wn(),Rn(e)},onCloseAutoFocus:Gn})]})}function hD({board:e,view:t,people:n,children:r}){return(0,K.jsx)(Y_.Provider,{value:e,children:(0,K.jsx)(rb.Provider,{value:t,children:(0,K.jsx)(Fy.Provider,{value:n,children:r})})})}function gD(){let[e,t]=(0,G.useState)(``),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(``);(0,G.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await Je.get(`/api/pairing`);if(!e)return;i(t),(t.pairing.state===`approved`||[`host`,`device`,`identity`].includes(t.access))&&window.location.reload()}catch(t){e&&o(t.message)}};t();let n=setInterval(t,2e3);return()=>{e=!1,clearInterval(n)}},[]);let s=async t=>{t.preventDefault(),o(``);try{let t=await Je.post(`/api/pairing`,{name:e});i(e=>({...e,pairing:t}))}catch(e){o(e.message)}},c=r?.pairing,l=c?.code,u=/iPad|iPhone|iPod/.test(navigator.userAgent),d=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone;return(0,K.jsxs)(`main`,{className:`mx-auto flex min-h-dvh max-w-lg flex-col justify-center gap-5 p-6`,"data-sw-pairing":!0,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:`Shapewall`}),(0,K.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:`Pair this device`})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`This board belongs to the person running Shapewall. Match the code and approve this device on that computer.`}),c?.state===`pending`?(0,K.jsxs)(`section`,{className:`space-y-3 rounded-lg border border-line p-4`,"aria-live":`polite`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-fg`,children:[`Waiting for approval: `,c.name]}),(0,K.jsxs)(`p`,{className:`font-mono text-3xl tracking-widest text-fg`,"data-sw-pairing-code":!0,children:[l.slice(0,4),`-`,l.slice(4)]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Expires in five minutes. On the host, open Devices or run `,(0,K.jsxs)(`code`,{children:[`shapewall devices approve `,l]}),`.`]})]}):(0,K.jsxs)(`form`,{className:`space-y-3`,onSubmit:s,children:[[`denied`,`expired`].includes(c?.state)?(0,K.jsxs)(`p`,{className:`text-sm text-warn`,role:`status`,children:[c.state===`denied`?`The host denied this request.`:`This request expired.`,` You can request again.`]}):null,(0,K.jsx)(`label`,{htmlFor:`device-name`,className:`block text-sm text-fg`,children:`Device name`}),(0,K.jsx)(qe,{id:`device-name`,required:!0,maxLength:80,placeholder:`My phone`,value:e,onChange:e=>t(e.target.value)}),(0,K.jsx)(n,{type:`submit`,children:`Request pairing`})]}),a?(0,K.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:a}):null,r?.secure?null:(0,K.jsx)(`p`,{className:`rounded-lg border border-warn/30 p-3 text-xs text-warn`,children:`Plain HTTP on Wi-Fi exposes your device cookie to sniffing and replay. Use Tailscale for private HTTPS, or configure a TLS certificate. Without HTTPS this board installs only as a bookmark.`}),u&&!d?(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Installing on your iPhone? Add the board to your Home Screen first, then pair from inside that app. Its cookies are separate from Safari.`}):null]})}function _D({info:e}){let[t,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(``),c=e?.remote,l=!!c?.manage;(0,G.useEffect)(()=>{if(!l)return;let e=!0,t=async()=>{try{let t=await Je.get(`/api/devices`);e&&a(t)}catch(t){e&&s(t.message)}};t();let n=setInterval(t,4e3);return()=>{e=!1,clearInterval(n)}},[l]);let u=async(e,t)=>{try{await Je[e](t),l?a(await Je.get(`/api/devices`)):window.location.reload()}catch(e){s(e.message)}};if(!c||!l&&!c.device)return null;let d=i?.pending||[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed bottom-3 left-3 z-30 rounded-lg border border-line bg-surface p-1 shadow-lg lg:bottom-16 lg:left-[64px]`,children:(0,K.jsx)(n,{size:`sm`,variant:`ghost`,onClick:()=>r(!0),"data-sw-devices-open":!0,children:l?`Devices${d.length?` (${d.length} waiting)`:``}`:c.device.name})}),(0,K.jsx)(M,{open:t,onClose:()=>r(!1),title:l?`Your devices`:`This device`,children:(0,K.jsxs)(`div`,{className:`max-h-[70dvh] space-y-4 overflow-auto p-5`,"data-sw-devices":!0,children:[o?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-bad`,children:o}):null,l?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`Approve only your own devices, after matching the code shown on them. Paired devices can comment, capture and drive your connected agent.`}),d.map(e=>(0,K.jsxs)(`section`,{className:`space-y-2 rounded border border-line p-3`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,K.jsxs)(`p`,{className:`break-all text-xs text-muted`,children:[e.browser,` · `,e.ip]}),(0,K.jsxs)(`p`,{className:`font-mono text-lg text-fg`,children:[e.code.slice(0,4),`-`,e.code.slice(4)]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(n,{size:`sm`,onClick:()=>u(`post`,`/api/devices/${e.code}/approve`),children:`Approve`}),(0,K.jsx)(n,{size:`sm`,variant:`secondary`,onClick:()=>u(`post`,`/api/devices/${e.code}/deny`),children:`Deny`})]})]},e.id)),(i?.devices||[]).map(e=>(0,K.jsxs)(`section`,{className:`flex items-center justify-between gap-2 rounded border border-line p-3`,children:[(0,K.jsxs)(`p`,{className:`min-w-0 break-words text-sm text-fg`,children:[e.name,(0,K.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Last seen `,new Date(e.lastSeenAt).toLocaleDateString()]})]}),(0,K.jsx)(n,{size:`sm`,variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${e.id}`),children:`Revoke`})]},e.id)),!d.length&&!i?.devices?.length?(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`No paired devices or requests yet.`}):null]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Paired as `,c.device.name,`. Settings and other devices are managed on the host computer.`]}),(0,K.jsx)(n,{variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${c.device.id}`),children:`Revoke this device`})]})]})})]})}var vD=(0,G.lazy)(()=>iC(()=>import(`./BuzzDialog-HWXBy52W.js`),__vite__mapDeps([11,1]),import.meta.url)),yD=!Ce&&typeof document<`u`&&!!document.querySelector(`meta[name="shapewall-remote"]`);function bD(){let[e,t]=(0,G.useState)(!1),[r,i]=(0,G.useState)(!1),a=_e(r);(0,G.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`shapewall:pairing-required`,e),()=>window.removeEventListener(`shapewall:pairing-required`,e)},[]);let o=Qe(yD?`/api/pairing`:null),s=!yD||[`host`,`device`,`identity`].includes(o.data?.access),c=Qe(s?`/api/info`:null),l=E(),u=Qe(s?`/api/boards`:null),[d,f]=Ke(),p=Array.isArray(u.data?.boards)?u.data.boards:[],m=d.get(`board`),h=p.find(e=>e.id===m)||p[0];he(c.data?.fixturesAt);let g=Ce?l?.shareProblem:null;xD(g?`Share link`:h?.title);let _=Ce&&d.has(`share`);return(0,G.useEffect)(()=>{_&&f({share:null})},[_,f]),yD&&!o.loading&&!s||e||c.error?.code===`pairing_required`||u.error?.code===`pairing_required`?(0,K.jsx)(gD,{}):g?(0,K.jsx)(mC,{problem:g,onLeave:l.leaveShare}):u.loading||c.loading?(0,K.jsx)(y_,{}):u.error?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(S_,{error:u.error,onRetry:()=>Promise.all([u.refetch(),c.error?c.refetch():null]),extra:Ce?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{asChild:!0,size:`touch`,variant:`secondary`,className:`lg:h-10`,children:(0,K.jsx)(`a`,{href:`console.html#/signin`,children:`Sign in to the demo`})}),(0,K.jsx)(n,{size:`touch`,variant:`ghost`,className:`lg:h-10`,onClick:()=>l?.reset(),children:`Reset the demo`})]}):null}),Ce?(0,K.jsx)(fC,{}):null]}):h?(0,K.jsxs)(L,{children:[(0,K.jsx)(_D,{info:c.data}),c.data?.buzzAvailable===!0&&a?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(vD,{open:r,onClose:()=>i(!1),boardId:h.id},h.id)}):null,(0,K.jsx)(Up,{children:(0,K.jsx)(mD,{boardId:h.id,boards:p,info:c.data,onInfoChanged:c.refetch,onOpenBuzz:()=>i(!0),onPickBoard:e=>f({board:e,c:null,v:null})})},h.id)]}):(0,K.jsx)(`div`,{className:`flex h-full bg-sunken`,children:(0,K.jsx)(D,{size:`lg`,icon:Lh,title:`No boards yet`,children:c.data?.hosted?(0,K.jsxs)(K.Fragment,{children:[`Capture your site locally, then run `,(0,K.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall push`}),` with a project token.`]}):(0,K.jsxs)(K.Fragment,{children:[`Add pages to `,(0,K.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall.config.json`}),`, then run`,` `,(0,K.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall capture`}),`.`]})})})}function xD(e){(0,G.useEffect)(()=>{if(!Ce||!e)return;let t=String(e).replace(/\s*\(demo\)$/i,``);document.title=t===`Share link`?`Share link · Shapewall demo`:`${t} board · Shapewall demo`},[e])}function SD(){typeof navigator<`u`&&`serviceWorker`in navigator&&window.isSecureContext&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`./sw.js`,{scope:`./`}).catch(()=>{})})}var CD=900;function wD(){try{let e=document.createElement(`div`);e.style.cssText=`position:absolute;top:-999px;width:100px;height:100px;overflow:scroll;visibility:hidden`,document.documentElement.appendChild(e);let t=e.offsetWidth-e.clientWidth>0;return e.remove(),t}catch{return!1}}function TD(){let e=new WeakMap;document.addEventListener(`scroll`,t=>{let n=t.target===document?document.documentElement:t.target;n instanceof Element&&(n.hasAttribute(`data-scrolling`)||n.setAttribute(`data-scrolling`,``),clearTimeout(e.get(n)),e.set(n,setTimeout(()=>n.removeAttribute(`data-scrolling`),CD)))},{capture:!0,passive:!0})}typeof document<`u`&&wD()&&(document.documentElement.classList.add(`sw-scrollbars`),TD()),document.querySelector(`meta[name="shapewall-agent-settings"]`)?iC(async()=>{let{default:e}=await import(`./Management-DCfhcEUY.js`);return{default:e}},__vite__mapDeps([12,7,1,5,2]),import.meta.url).then(({default:e})=>(0,at.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(e,{}))):((0,at.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(bD,{})})),SD());export{zh as $,Sx as A,Gg as B,Ix as C,Rx as D,Nx as E,l_ as F,Dg as G,Lg as H,s_ as I,ag as J,Tg as K,a_ as L,Jb as M,P_ as N,zx as O,p_ as P,Gh as Q,$g as R,Lx as S,Fx as T,Ng as U,zg as V,kg as W,Yh as X,rg as Y,qh as Z,eS as _,ZS as a,dh as at,Gx as b,hS as c,th as ct,oS as d,Vm as dt,Fh as et,aS as f,Qx as g,Xx as h,$C as i,_h as it,ex as j,Vx as k,iS as l,Zm as lt,$x as m,RC as n,jh as nt,QS as o,lh as ot,vS as p,xg as q,zC as r,xh as rt,gS as s,ah as st,pw as t,Nh as tt,yS as u,Ym as ut,Yx as v,Px as w,qx as x,tS as y,Yg as z};
29
+ `):[],capture:!!I,status:{kind:ye,progress:be},viewer:fe,comment:pe,panels:{comments:ae,agent:!!R,checks:!!oe},settings:!!m})}),[_e,ue,xe,I,ye,be,fe,pe,ae,R,oe,m]),Ce=zT(Se.step),we=(0,K.jsx)(IT,{info:t,localName:c,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:m,openSettings:h,setShareOpen:g}),Te=(0,K.jsxs)(Ue,{value:r,onValueChange:e=>{if(!e.startsWith(`project/`))return l(e);let t=o.find(t=>`project/${t.id}`===e);t?.url&&t.running&&ke(t.url)},children:[(0,K.jsx)(ge,{size:e?`sm`:`touch`,className:e?U(`max-w-72 min-w-0 border-transparent bg-transparent px-2.5 text-sm font-semibold shadow-none hover:bg-surface-2 data-[state=open]:bg-surface-2`,de&&`h-6`):`min-w-0 flex-1 border-transparent bg-transparent px-2 text-[15px] font-semibold shadow-none`,"aria-label":`Board: ${ue}`,"data-sw-picker":`true`,children:(0,K.jsx)(ce,{children:(0,K.jsx)(`span`,{className:`block truncate`,children:ue})})}),(0,K.jsxs)(W,{children:[(0,K.jsxs)(me,{children:[o.length>1||de?(0,K.jsx)(Oe,{children:de?de.name:`This project`}):null,i.map(t=>(0,K.jsx)(Ne,{value:t.id,children:e?`${t.title} · ${t.pageCount} pages`:t.title},t.id))]}),o.length>1?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ve,{}),(0,K.jsxs)(me,{children:[(0,K.jsx)(Oe,{children:`Local projects`}),o.map(e=>(0,K.jsxs)(Ne,{value:`project/${e.id}`,disabled:e.current||!e.running,"data-sw-local-project":e.id,children:[e.title,e.current?` (current)`:e.running?``:` (not running)`]},e.id))]}),o.some(e=>!e.running&&!e.current)?(0,K.jsx)(`p`,{className:`max-w-72 px-2 py-1.5 text-xs text-muted`,children:`Start a stopped project with shapewall serve in its folder.`}):null]}):null,s?(0,K.jsx)(`p`,{className:`max-w-72 px-2 py-1.5 text-xs text-bad`,children:`Could not load local projects. Check the terminal for your project index.`}):null]})]});if(!e)return(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b border-line bg-surface px-2 py-1.5`,"data-sw-toolbar":`compact`,children:[(0,K.jsx)(`h1`,{className:`sr-only`,children:`Shapewall`}),Te,x&&!S?(0,K.jsx)(z,{size:`icon`,variant:C?`default`:`soft`,className:`shrink-0`,"aria-pressed":C,onClick:()=>w(e=>!e),label:C?`Stop commenting`:`Comment: tap a page to pin`,"data-sw-comment-mode":`true`,children:(0,K.jsx)(rg,{size:19,"aria-hidden":`true`})}):null,fe?(0,K.jsx)(DC,{compact:!0}):null,(0,K.jsxs)(n,{size:`touch`,variant:`ghost`,className:`shrink-0 gap-1.5 px-2.5 text-fg`,onClick:()=>{V(),H(!0)},"aria-label":`Comments, ${ae} open`,"data-sw-panel-toggle":`true`,children:[(0,K.jsx)(ag,{size:18,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`tabular text-[13px] font-semibold`,children:ae})]}),(0,K.jsx)(z,{size:`icon`,variant:`ghost`,className:`shrink-0 text-fg`,onClick:()=>E(!0),label:R?`More: agent, pages, journeys, screen size`:`More: pages, journeys, screen size`,"data-sw-menu":`true`,children:(0,K.jsx)(lh,{size:19,"aria-hidden":`true`})}),we]});let Ee=_.map(e=>{let t=e.id===`all`?Fg:U_(e.id);return{id:e.id,tooltip:Ce.viewport?e.label:null,label:Ce.viewport?(0,K.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,K.jsx)(t,{size:14,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:e.label})]}):e.label}}),De=(0,K.jsx)(OT,{data:a,capture:F}),Ae=Ce.tight?`gap-1`:`gap-1.5`;return(0,K.jsxs)(`header`,{ref:he,className:U(`grid h-14 shrink-0 items-center border-b border-line bg-surface px-3`,Ce.tight?`gap-x-3`:`gap-x-5`,Se.centred?`grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]`:`grid-cols-[auto_auto_minmax(0,1fr)]`),"data-sw-toolbar":`full`,"data-sw-toolbar-fit":LT[Se.step],"data-sw-toolbar-centred":Se.centred?`true`:`false`,children:[(0,K.jsxs)(`h1`,{className:`sr-only`,children:[`Shapewall: `,ue]}),(0,K.jsxs)(`div`,{className:U(`flex min-w-0 items-center`,Ae),"data-sw-toolbar-zone":`left`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center`,style:Se.centred?void 0:{maxWidth:RT.name.at(-1)},children:[de&&!le?(0,K.jsx)(OC,{project:de}):null,Te]}),I?null:De,_.length>1?(0,K.jsx)(`span`,{className:U(`shrink-0 rounded-md`,b&&`animate-flash`),"data-sw-viewport-flash":b?b.to:void 0,children:(0,K.jsx)(Ve,{label:`Screen size`,options:Ee,value:v,onChange:y,itemClassName:Ce.viewport?`px-2`:void 0})},b?.at||`still`):null,(0,K.jsx)(qT,{showLinks:D,toggleLinks:O,linksTip:k,brokenLinks:A,canCompare:j,comparePair:S,toggleCompare:M,minimapOn:N,toggleMinimap:P,compact:Ce.view}),I?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(z,{variant:`ghost`,className:`shrink-0 text-fg`,disabled:F?.running||ee,onClick:()=>L(!0),label:`Capture now`,tooltip:`Recapture every page`,side:`bottom`,"data-sw-capture":`true`,children:(0,K.jsx)(Gm,{size:16,"aria-hidden":`true`})}),De]}):null]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center`,"data-sw-toolbar-zone":`center`,children:(0,K.jsx)(p,{content:(0,K.jsx)(DT,{label:`Go to a page, journey or comment`,keys:[Vw]}),side:`bottom`,children:(0,K.jsx)(Jw,{onOpen:T,compact:Ce.search,style:Ce.search?void 0:{width:Se.search}})})}),(0,K.jsxs)(`div`,{className:U(`flex min-w-0 items-center justify-end`,Ae),"data-sw-toolbar-zone":`right`,children:[fe?(0,K.jsx)(DC,{}):null,pe?(0,K.jsx)(p,{content:(0,K.jsx)(DT,{label:C?`Stop commenting`:`Click a page to pin a comment`,keys:C?[`C`,`Esc`]:[`C`]}),side:`bottom`,children:(0,K.jsxs)(n,{variant:C?`default`:`soft`,className:U(`h-8 shrink-0 text-[13px]`,Ce.comment?`w-8 px-0`:`px-3`,C&&`ring-2 ring-accent/30`),"aria-pressed":C,onClick:()=>w(e=>!e),"data-sw-comment-mode":`true`,children:[(0,K.jsx)(rg,{size:15,"aria-hidden":`true`}),Ce.comment?(0,K.jsx)(`span`,{className:`sr-only`,children:`Comment`}):`Comment`]})}):null,(0,K.jsx)(JT,{labels:!Ce.panels,allOpen:ae,panelHidden:re,chatAvailable:R,chatThread:B,reopenChat:te,checksOpen:ie,canChecks:oe,openChecks:se,closeChecks:V,updateParams:ne}),m?(0,K.jsx)(z,{variant:`ghost`,className:`shrink-0 text-fg`,onClick:h,label:`Agent settings`,tooltip:`Agent settings: which agent the chat uses`,side:`bottom`,"data-sw-settings-open":`true`,children:(0,K.jsx)(Vg,{size:16,"aria-hidden":`true`})}):null]})]})}function XT({menuOpen:e,setMenuOpen:t,data:r,chatAvailable:i,chatThread:a,reopenChat:o,groupedPages:s,jumpToPage:c,modes:l,mode:u,setMode:d,journeys:p,journey:m,canEditJourneys:h,openJourney:g,startBuilder:_,canChecks:v,openChecks:y,showLinks:b,toggleLinks:x,brokenLinks:S,canCompare:C,comparePair:w,toggleCompare:T,settingsAvailable:E,openSettings:D,capture:O,canCapture:k,busy:A,setCaptureConfirm:j}){let N=`mb-1.5 flex items-center gap-1 text-[11px] font-medium tracking-wide text-faint uppercase`;return(0,K.jsx)(M,{open:e,onClose:()=>t(!1),title:r?.board?.title||`Board`,children:(0,K.jsxs)(`div`,{className:`space-y-5 p-5`,children:[l.length>1?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:N,children:`Screen size`}),(0,K.jsx)(Ve,{label:`Screen size`,options:l,value:u,onChange:e=>{d(e),t(!1)},large:!0})]}):null,i?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:a?`default`:`secondary`,onClick:()=>{t(!1),o()},"data-sw-chat-toggle":`true`,children:[(0,K.jsx)(f,{size:16,"aria-hidden":`true`}),` Chat with your agent`]}):null,(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:N,children:[(0,K.jsx)(qh,{size:12,"aria-hidden":`true`}),` Go to a page`]}),(0,K.jsx)(zw,{groups:s,onPick:e=>{t(!1),c(e)}})]}),p.length||h?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:N,children:`Journeys`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-sw-journey-menu":`true`,children:[p.map(e=>(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:m?.id===e.id?`default`:`secondary`,onClick:()=>{t(!1),g(e.id)},"data-sw-journey-open":e.id,children:[(0,K.jsx)(Ng,{size:15,"aria-hidden":`true`}),` `,(0,K.jsx)(`span`,{className:`truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`ml-auto text-xs opacity-70`,children:e.branching?`${e.paths?.length||2} paths`:`${e.steps.length} steps`})]},e.id)),h?(0,K.jsxs)(n,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{t(!1),_()},children:[(0,K.jsx)(Cg,{size:15,"aria-hidden":`true`}),` New journey`]}):null]})]}):null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`p`,{className:N,children:`View`}),v?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),y()},"data-sw-checks-toggle":`true`,children:[(0,K.jsx)(xh,{size:16,"aria-hidden":`true`}),`Checks`]}):null,(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,"aria-pressed":b,variant:b?`default`:`secondary`,onClick:()=>{t(!1),x()},"data-sw-links-toggle":`true`,children:[(0,K.jsx)(h_,{size:15,"aria-hidden":`true`}),` `,b?`Hide links between pages`:`Show links between pages`,(0,K.jsx)(wT,{count:S.length})]}),C?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,"aria-pressed":!!w,variant:w?`default`:`secondary`,onClick:()=>{t(!1),T()},"data-sw-compare-toggle":`true`,children:[(0,K.jsx)(Ch,{size:15,"aria-hidden":`true`}),` `,w?`Leave compare mode`:`Compare environments`]}):null,E?(0,K.jsxs)(n,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),D()},"data-sw-settings-open":`true`,children:[(0,K.jsx)(Vg,{size:15,"aria-hidden":`true`}),` Agent settings`]}):null]}),(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-line pt-4`,children:[(0,K.jsx)(kT,{data:r,capture:O}),k?(0,K.jsxs)(n,{size:`touch`,className:`w-full`,disabled:O?.running||A,onClick:()=>{t(!1),j(!0)},"data-sw-capture":`true`,children:[(0,K.jsx)(Gm,{size:15,"aria-hidden":`true`}),` Capture now`]}):null]})]})})}function ZT({wide:e,commentMode:t,canComment:r,readyKeys:i,setCommentMode:a,showLinks:o,activePage:s,shownSteps:c,data:l,presentPages:u,hiddenLinkTargets:d,showAllLinks:f,targetTitle:p,updateParams:m,tipOpen:h,tryOpen:g,journey:_,builder:v,viewportNotice:y,dismissTip:b,modes:x,setMode:S,comparePair:C}){let w=e=>x.find(t=>t.id===e)?.label||e,T=e?`Scroll or drag to move, Ctrl+scroll or pinch to zoom. Click a page for its actions${r&&!C?`, or press C to comment`:``}.`:`Pinch to zoom. Tap a page for its actions${r&&!C?`, or the comment button to pin a note`:``}.`;return(0,K.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-30 flex flex-col items-center gap-1.5 px-2`,"data-sw-canvas-notes":`true`,children:[t&&r?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-full bg-accent py-0.5 pr-0.5 pl-3 text-xs font-medium text-accent-fg shadow-pop`,role:`status`,"data-sw-comment-hint":i.size?`element`:`page`,children:[(0,K.jsx)(rg,{size:13,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0`,children:i.size?e?`Click an element on the live page to comment on it.`:`Tap an element on the live page to comment on it.`:e?`Click a page to comment. Zoom in until the page goes live to pin it to an element.`:`Tap a page to pin a comment.`}),(0,K.jsxs)(n,{size:e?`xs`:`touch`,variant:`inverse`,className:`shrink-0 rounded-full`,onClick:()=>a(!1),"data-sw-comment-hint-done":`true`,children:[`Done`,e?` (Esc)`:``]})]}):null,o&&!s&&!c&&w_(l?.links,u,d)>150?(0,K.jsx)(`p`,{className:`w-max max-w-full rounded-full bg-surface px-3 py-1 text-xs font-medium text-muted shadow-pop`,"data-sw-links-hint":`true`,children:e?`Hover or select a page to see its links`:`Tap a page to see its links`}):null,o&&(d?.size||f)?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs text-muted shadow-pop`,"data-sw-links-global":f?`shown`:`hidden`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:f?`Showing every link, the nav and footer ones too.`:`Hiding the nav and footer links (to ${[...d].slice(0,3).map(e=>p(e)).join(`, `)}${d.size>3?` and ${d.size-3} more`:``}).`}),(0,K.jsx)(n,{size:e?`xs`:`touch`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:()=>m({la:f?null:`1`}),"data-sw-links-global-toggle":`true`,children:f?`Hide them`:`Show them`})]}):null,h&&!g&&l&&!t&&!o&&!_&&!v&&!y?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-1.5 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs text-fg shadow-pop`,role:`note`,"data-sw-tip":`true`,children:[(0,K.jsx)(zh,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0`,children:T}),(0,K.jsx)(z,{size:e?`icon-xs`:`icon`,variant:`ghost`,className:`shrink-0 rounded-full shadow-none`,onClick:b,label:`Dismiss the tip`,"data-sw-tip-dismiss":`true`,children:(0,K.jsx)(B,{size:14,"aria-hidden":`true`})})]}):null,y?(0,K.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-lg border border-line bg-surface py-1 pr-1 pl-3 text-xs text-fg shadow-pop`,role:`status`,"data-sw-viewport-notice":y.to,children:[(0,K.jsxs)(`span`,{className:`min-w-0`,children:[`Showing `,w(y.to),`: comment #`,y.id,` is on the `,y.to,` capture.`]}),(0,K.jsxs)(n,{size:e?`xs`:`touch`,variant:`secondary`,className:`shrink-0`,onClick:()=>S(y.from),"data-sw-viewport-notice-back":`true`,children:[`Back to `,w(y.from)]})]}):null]})}function QT(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{e||r(!1)},[e]),(0,G.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>t(t=>t===e?null:t),6e3);return()=>window.clearTimeout(r)},[e,n]),[e,t,r]}function $T({toast:e,setToast:t,onHold:r,wide:i,raised:a}){return e?(0,K.jsxs)(`div`,{onMouseEnter:()=>r?.(!0),onMouseLeave:()=>r?.(!1),onFocus:()=>r?.(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r?.(!1)},className:U(`absolute inset-x-0 z-[80] mx-auto flex w-max max-w-[calc(100%-1rem)] animate-pop-in items-center gap-2 rounded-lg bg-fg py-1 pr-1 pl-3 text-xs font-medium text-surface shadow-pop`,a?i?`bottom-28`:`bottom-44`:i?`bottom-4`:`bottom-16`),role:`status`,"data-sw-toast":`true`,children:[(0,K.jsx)(`span`,{className:`min-w-0`,children:e.text}),e.undo?(0,K.jsx)(n,{size:i?`xs`:`touch`,variant:`inverse`,onClick:()=>{e.undo(),t(null)},"data-sw-toast-undo":`true`,children:`Undo`}):null,(0,K.jsx)(z,{size:i?`icon-xs`:`icon`,variant:`inverse`,onClick:()=>t(null),label:`Dismiss`,children:(0,K.jsx)(B,{size:13,"aria-hidden":`true`})})]},e.at):null}function eE({notice:e,setNotice:t,wide:r}){return e?(0,K.jsxs)(`div`,{className:U(`flex shrink-0 items-center gap-3 border-b border-line px-4 py-2 text-xs`,e.tone===`bad`?`bg-bad/10 text-bad`:`bg-accent/10 text-fg`),role:e.tone===`bad`?`alert`:`status`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text}),(0,K.jsx)(n,{variant:`ghost`,size:r?`xs`:`touch`,onClick:()=>t(null),children:`Dismiss`})]}):null}var tE=(0,G.lazy)(()=>iC(()=>import(`./ChecksPanel-B54chcLA.js`),__vite__mapDeps([3,1,2,4,5]),import.meta.url)),nE=(0,G.lazy)(()=>iC(()=>import(`./BoardChat-C88k4s-W.js`),__vite__mapDeps([6,1,7,5,2,4]),import.meta.url));function rE({wide:e,checksOpen:t,checksProps:n,chatThread:r,chatProps:i,panelHidden:a,panelProps:o,updateParams:s}){return e&&t?(0,K.jsx)(lE,{panel:`checks`,defaultWidth:384,"aria-label":`Checks`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`p`,{className:`p-4 text-sm text-muted`,children:`Loading checks…`}),children:(0,K.jsx)(tE,{...n})})},`checks`):e&&r?(0,K.jsx)(lE,{panel:`agent`,defaultWidth:384,"aria-label":`Agent`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(b_,{}),children:(0,K.jsx)(nE,{...i,onClose:()=>s({chat:null})})})},`agent`):e&&!a?(0,K.jsx)(lE,{panel:`comments`,defaultWidth:384,id:`sw-comments`,tabIndex:-1,className:`outline-none`,"aria-label":`Comments`,children:(0,K.jsx)(lx,{...o,onClose:()=>s({panel:`off`})})},`comments`):null}var iE=280,aE=.6,oE=16,sE=`side`;function cE(e){let t=Math.max(iE,Math.floor(window.innerWidth*aE));return Math.min(t,Math.max(iE,Math.round(e)))}function lE({panel:e,defaultWidth:t,className:n,children:r,...i}){let[a,o]=(0,G.useState)(()=>cE(Iw(sE)??t)),[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=()=>o(e=>cE(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let u=e=>{let n=cE(e);o(n),Lw(sE,n===t?null:n)},d=e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),l.current={x:e.clientX,width:a},c(!0))},f=e=>{l.current&&o(cE(l.current.width+l.current.x-e.clientX))},p=e=>{l.current&&(u(l.current.width+l.current.x-e.clientX),l.current=null,c(!1))},m=e=>{let n=e.shiftKey?64:oE;if(e.key===`ArrowLeft`)u(a+n);else if(e.key===`ArrowRight`)u(a-n);else if(e.key===`Home`)u(t);else return;e.preventDefault()};return(0,K.jsxs)(`aside`,{className:U(`relative flex shrink-0 flex-col border-l border-line bg-surface`,n),style:{width:a},"data-sw-rail":e,...i,children:[(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,"aria-valuenow":a,"aria-valuemin":iE,"aria-valuemax":Math.max(iE,Math.floor(window.innerWidth*aE)),"aria-description":`Drag or use the arrow keys to resize. Double-click or press Home to reset.`,tabIndex:0,className:`group absolute inset-y-0 -left-1.5 z-20 w-3 cursor-col-resize touch-none outline-none`,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onDoubleClick:()=>u(t),onKeyDown:m,"data-sw-rail-handle":`true`,children:(0,K.jsx)(`span`,{"aria-hidden":`true`,className:U(`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-accent opacity-0 transition-opacity group-hover:opacity-60 group-focus-visible:opacity-100`,s&&`opacity-100`)})}),s?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null,r]})}function uE({checksOpen:e,closeChecks:t,checksProps:n,chatAvailable:r,chatThread:i,chatProps:a,updateParams:o,sheetOpen:s,setSheetOpen:c,panelProps:l,threadSheet:u,threadProps:d,closeThread:f,selectedComment:p,targetTitle:m,draft:h,busy:g,setDraft:_,draftDescription:v,composerProps:y}){return(0,K.jsxs)(K.Fragment,{children:[e?(0,K.jsx)(M,{open:!0,onClose:t,title:`Checks`,size:`md`,children:(0,K.jsx)(`div`,{className:`flex h-[78dvh] min-h-0 flex-col`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`p`,{children:`Loading checks…`}),children:(0,K.jsx)(tE,{...n})})})}):null,r?(0,K.jsx)(M,{open:!!i,onClose:()=>o({chat:null}),title:`Agent`,size:`md`,children:(0,K.jsx)(`div`,{className:`flex h-[78dvh] flex-col`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(b_,{heading:!1}),children:(0,K.jsx)(nE,{...a,heading:!1})})})}):null,(0,K.jsx)(M,{open:s&&!e,onClose:()=>c(!1),title:`Comments`,size:`md`,children:(0,K.jsx)(`div`,{className:`flex max-h-[70dvh] flex-col`,children:(0,K.jsx)(lx,{...l,heading:!1})})}),(0,K.jsx)(M,{open:u&&!!d&&!e,onClose:f,title:p?`#${p.id} · ${m(p.pageId)}`:`Comment`,description:p?`${p.viewport} capture`:void 0,size:`md`,children:d?(0,K.jsx)(`div`,{className:`flex max-h-[72dvh] flex-col outline-none`,tabIndex:-1,"data-autofocus":!0,"data-sw-thread-sheet":p.id,children:(0,K.jsx)(OS,{...d})}):null}),(0,K.jsx)(M,{open:!!h&&!e,onClose:()=>g?null:_(null),title:`New comment`,description:v,children:(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsx)(xx,{...y,touch:!0})})})]})}var dE=e=>String(e).replace(/\/w\/[^/#?]+.*$/,`/account`);function fE({groups:e,journeys:t,comments:n,activePage:r,journeyId:i,onPage:a,onJourney:o}){let[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(()=>new Set),d=s.trim().toLowerCase(),f=(0,G.useMemo)(()=>{let e=new Map;for(let t of n||[])t.status===`open`&&e.set(t.pageId,(e.get(t.pageId)||0)+1);return e},[n]),p=e.map(e=>({...e,pages:d?e.pages.filter(t=>`${t.title} ${t.path||``} ${e.group}`.toLowerCase().includes(d)):e.pages})).filter(e=>e.pages.length),m=d?t.filter(e=>String(e.name||``).toLowerCase().includes(d)):t,h=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),g=e.reduce((e,t)=>e+t.pages.length,0);return(0,K.jsxs)(`div`,{className:`flex w-full flex-col border-t border-line pt-2`,"data-sw-pages-sidebar":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Pages `,(0,K.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:g})]}),(0,K.jsx)(`div`,{className:`pb-2`,children:(0,K.jsx)(qe,{size:`sm`,icon:Lg,value:s,onChange:e=>c(e.target.value.slice(0,80)),placeholder:`Filter pages and journeys`,"aria-label":`Filter pages and journeys`,"data-sw-pages-filter":`true`})}),(0,K.jsxs)(`div`,{className:`pb-2`,children:[p.map(e=>{let t=l.has(e.group)&&!d;return(0,K.jsxs)(`section`,{className:`mb-1`,"data-sw-pages-group":e.group,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1 rounded-md px-2.5 text-xs font-semibold text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"aria-expanded":!t,onClick:()=>h(e.group),children:[(0,K.jsx)(R,{size:13,"aria-hidden":`true`,className:U(`transition-transform`,t&&`-rotate-90`)}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.group}),(0,K.jsx)(`span`,{className:`ml-auto font-normal text-faint tabular`,children:e.pages.length})]}),t?null:(0,K.jsx)(`ul`,{className:`ml-4`,children:e.pages.map((t,n)=>{let i=f.get(t.id)||0,o=t.id===r,s=n===e.pages.length-1;return(0,K.jsx)(`li`,{className:U(`relative pl-3 before:pointer-events-none before:absolute before:top-0 before:left-0 before:h-4 before:w-2.5 before:rounded-bl-md before:border-b before:border-l`,o?`before:border-accent/60`:`before:border-line-strong/70`,!s&&`after:pointer-events-none after:absolute after:inset-y-0 after:left-0 after:border-l after:border-line-strong/70`),"data-sw-pages-wire":`true`,children:(0,K.jsxs)(`button`,{type:`button`,className:U(`flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`,o?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),"aria-current":o?`true`:void 0,onClick:()=>a(t.id),"data-sw-pages-item":t.id,children:[(0,K.jsx)(_h,{size:14,"aria-hidden":`true`,className:U(`shrink-0`,o?`text-accent`:`text-faint`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),i?(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-muted tabular`,"aria-label":`${i} open`,children:i}):null]})},t.id)})})]},e.group)}),m.length?(0,K.jsxs)(`section`,{className:`mt-2 border-t border-line pt-2`,"data-sw-pages-journeys":`true`,children:[(0,K.jsx)(`h3`,{className:`flex h-7 items-center px-2.5 text-xs font-semibold text-muted`,children:`Journeys`}),(0,K.jsx)(`ul`,{children:m.map(e=>{let t=e.id===i;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:U(`flex h-8 w-full items-center gap-2 rounded-md px-2.5 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`,t?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),"aria-current":t?`true`:void 0,onClick:()=>o(t?null:e.id),"data-sw-pages-journey":e.id,children:[(0,K.jsx)(Ng,{size:14,"aria-hidden":`true`,className:U(`shrink-0`,t?`text-accent`:`text-faint`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id})]})},e.id)})})]}):null,d&&!p.length&&!m.length?(0,K.jsxs)(`p`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`Nothing matches "`,s.trim(),`".`]}):null]})]})}function pE({info:e,localSettingsAvailable:t,setShareOpen:n}){let r=[{id:`board`,label:`Board`,icon:Lh,href:`./`,active:!0}],i=e?.consoleUrl&&!e?.guest?e.consoleUrl:null;return i?(r.push({id:`workspace`,label:`Workspace`,icon:Um,href:i}),r.push({id:`account`,label:`Account and security`,icon:d_,href:dE(i)})):t&&(r.push({id:`workspace`,label:`Workspace`,icon:Um,href:`/console`}),r.push({id:`account`,label:`Account and security`,icon:d_,href:`/account`})),e?.shareEnabled&&r.push({id:`share`,label:`Share with your team`,icon:Ug,onSelect:()=>n(!0)}),r}function mE({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,expanded:c,onToggle:l,pages:u}){let d=!!e&&!e.guest&&!e.public&&!e.share,f=typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`);(0,G.useEffect)(()=>{d&&sT(window.location.pathname+(f?`?board=`+encodeURIComponent(f):``))},[d,f]);let p=pE({info:e,localSettingsAvailable:i,setShareOpen:s}),m=!c&&u?[{id:`pages`,label:`Pages and journeys`,icon:yh,flyout:({close:e})=>(0,K.jsx)(fE,{...u,onPage:t=>{e(),u.onPage(t)},onJourney:t=>{e(),u.onJourney(t)}})}]:[];return(0,K.jsx)(CT,{expanded:c,onToggle:l,home:`./`,homeLabel:`Shapewall`,title:e?.project?.name||e?.title,logo:(0,K.jsx)(`img`,{src:`./favicon.svg`,alt:``,className:`h-7 w-7`}),items:p,sections:m,profile:c=>(0,K.jsx)(IT,{info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,side:`right`,align:`end`,showName:c,triggerClassName:c?`w-full justify-start`:`w-10 min-w-10 px-0`}),children:u?(0,K.jsx)(fE,{...u}):null})}var hE=(0,G.lazy)(()=>iC(()=>import(`./QuickConnect-D40mj4Ry.js`).then(e=>e.a).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([7,1,5,2]),import.meta.url)),gE=(0,G.lazy)(()=>iC(()=>import(`./History-CVVuuxUK.js`),__vite__mapDeps([8,1]),import.meta.url)),_E=(0,G.lazy)(()=>iC(()=>import(`./ShareDialog-CdVAreaw.js`).then(e=>({default:e.ShareDialog})),__vite__mapDeps([9,1]),import.meta.url)),vE=(0,G.lazy)(()=>iC(()=>import(`./LocalSettings-CvlVtNY_.js`),__vite__mapDeps([10,1,7,5,2]),import.meta.url));function yE({info:e,boardId:t,boards:r,wide:i,shareOpen:a,setShareOpen:o,refetchView:s,settingsAvailable:l,settingsOpen:u,updateParams:d,onInfoChanged:f,generalSettingsOpen:p,updates:m,historyPage:h,closeHistory:g,historyViewport:_,historyPageId:v,data:y,comments:b,filter:x,focusComment:S,onImageError:C,captureConfirm:w,setCaptureConfirm:T,busy:E,focusedPage:D,findPage:O,startCapture:k}){let A=_e(a),j=_e(u);return(0,K.jsxs)(K.Fragment,{children:[e?.shareEnabled&&A?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(_E,{open:a,onClose:()=>o(!1),boardId:t,onMoved:s})}):null,l&&j?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(hE,{open:u,onClose:()=>d({settings:null}),onSaved:f,touch:!i,buzz:e?.buzzAvailable===!0})}):null,p?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(vE,{open:!0,onClose:()=>d({settings:null}),info:e,boardCount:r.length,onSaved:f,touch:!i,onOpenUpdates:()=>{d({settings:null}),m.current?.open()}})}):null,h?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(gE,{open:!!h,onClose:g,page:h,viewport:_,data:y,comments:b.filter(e=>e.pageId===v&&e.viewport===_),urlFor:(e,n)=>c(t,e.kind,n?e.thumb:e.file,e.version),onPickComment:e=>{g(),d({filter:e.status===`resolved`&&x===`open`?`all`:null}),S(e)},touch:!i,onImageError:C})}):null,(0,K.jsx)(M,{open:w,onClose:()=>E?null:T(!1),title:`Capture every page now?`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:i?`md`:`touch`,onClick:()=>T(!1),disabled:E,children:`Cancel`}),D&&O(D)?(0,K.jsxs)(n,{size:i?`md`:`touch`,onClick:()=>k(null,[D]),disabled:E,"data-sw-capture-only":D,children:[`Only `,O(D).title]}):null,(0,K.jsx)(n,{size:i?`md`:`touch`,variant:`default`,onClick:()=>k(),disabled:E,"data-sw-capture-confirm":`true`,children:`Capture all`})]}),children:(0,K.jsxs)(`p`,{className:`p-5 text-sm text-muted`,children:[`Shapewall captures all `,y?.board?.pages.length||``,` pages at every viewport`,D&&O(D)?` (or only ${O(D).title}, the selected page)`:``,`. Comments stay where they are; pins on live pages follow their elements. The board updates when it finishes.`]})})]})}var bE=2;function xE(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function SE({canvasRef:e,flow:t,targets:n,viewports:r,settledZoom:i,setSettledZoom:a,comparePair:o,captures:s,variantsById:c}){let l=(0,G.useRef)(null),[u,d]=(0,G.useState)(()=>new Set),[f,p]=(0,G.useState)(()=>new Set),m=(0,G.useCallback)((e,t)=>{p(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),h=(0,G.useCallback)((e,t)=>o?null:e.startsWith(`variant:`)?c.get(e)?.files?.[t]?.live||null:s?.[e]?.[t]?.live||null,[o,s,c]),g=(0,G.useCallback)(()=>{let a=e.current?.getBoundingClientRect();if(!a?.width||!i){d(e=>e.size?new Set:e);return}let{x:o,y:s,zoom:c}=t.getViewport(),u=[];for(let[e,t]of Object.entries(n))for(let n of t.frames){if(!h(e,n.viewport))continue;let i=(t.x+n.x)*c+o,d=(t.y+n.y)*c+s,f=n.w*c,p=n.h*c;if(i>a.width||d>a.height||i+f<0||d+p<0)continue;let m=`${e}|${n.viewport}`,g=l.current===m,_=Math.min((r[n.viewport]?.width||1440)*.4,a.width*.5);f<(g?_/2:_)||u.push({key:m,rank:g?-1:Math.hypot(i+f/2-a.width/2,d+p/2-a.height/2)})}u.sort((e,t)=>e.rank-t.rank);let f=new Set(u.slice(0,bE).map(e=>e.key));l.current&&!f.has(l.current)&&(l.current=null),d(e=>xE(e,f)?e:f)},[e,t,n,h,i,r]);return(0,G.useEffect)(()=>{g()},[g]),{liveKeys:u,readyKeys:f,setLiveReady:m,liveFileFor:h,recomputeLive:g,openLive:(0,G.useCallback)((r,i)=>{let o=n[r],s=o?.frames.find(e=>e.viewport===i),c=e.current?.getBoundingClientRect();s&&c?.width&&(l.current=`${r}|${i}`,a(null),t.fitBounds({x:o.x+s.x,y:o.y+s.y,width:s.w,height:Math.min(s.h,s.w*(c.height/c.width))},{padding:.04,duration:fw(450)}))},[e,t,n,a])}}function CE({journey:e,builder:t,goStep:n,step:r,closeJourney:i}){(0,G.useEffect)(()=>{if(!e||t)return;let a=e=>{if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||document.querySelector(`[role="dialog"]`))return;let t=e.target;t?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(t?.tagName)||t?.closest?.(`[role="listbox"], [role="menu"]`)||((e.key===`ArrowRight`||e.key===`ArrowLeft`)&&(e.preventDefault(),n(r+(e.key===`ArrowRight`?1:-1))),e.key===`Escape`&&!document.querySelector(`[data-sw-thread-popover], [data-sw-composer-popover]`)&&(e.preventDefault(),i()))};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[t,i,n,e,r])}function wE({commentMode:e,setCommentMode:t,canComment:n,comparePair:r,setDraft:i}){(0,G.useEffect)(()=>{if(!e)return;let n=e=>{e.key!==`Escape`||Wb(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||t(!1)};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),(0,G.useEffect)(()=>{if(!n||r)return;let e=e=>{if(e.defaultPrevented&&!Ge(e)||e.altKey||e.ctrlKey||e.metaKey||e.repeat||e.key!==`c`&&e.key!==`C`)return;let n=e.target;n?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(n?.tagName)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`)||(e.preventDefault(),i(null),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r,t,i])}function TE(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&Array.isArray(e.branches)}function EE(e){let t=new Set,n=e=>{for(let r of e||[])if(typeof r==`string`)t.add(r);else if(TE(r))for(let e of r.branches)n(e.steps)};return n(e),[...t]}function DE(e){let t=[],n=[],r=(e,i,a)=>{let o=a;return e.forEach((e,a)=>{let s=i?`${i}:${a}`:String(a);if(typeof e==`string`){t.push({key:s,pageId:e});for(let e of o)n.push({from:e.key,to:s,label:e.label||null,branch:e.branch||null});o=[{key:s}];return}if(!TE(e))return;let c=[];e.branches.forEach((e,t)=>{let n=o.map(t=>({key:t.key,label:e.label,branch:e.id})),i=r(e.steps,`${s}:${t}`,n);e.end||c.push(...i)}),o=c}),o};return r(e||[],``,[]),{nodes:t,edges:n}}function OE(e,t=[]){let n=[],r=[],i=!1,a=(e,o,s)=>{for(let c=0;c<e.length;c+=1){if(i)return;let l=e[c],u=o?`${o}:${c}`:String(c);if(typeof l==`string`){n.push({key:u,pageId:l,branch:s});continue}if(!TE(l)||!l.branches.length)continue;let d=t[r.length],f=Math.max(0,l.branches.findIndex(e=>e.id===d)),p=l.branches[f];r.push({afterStep:n.length,options:l.branches.map(e=>({id:e.id,label:e.label,end:!!e.end})),chosen:p.id}),a(p.steps,`${u}:${f}`,p.label),p.end&&(i=!0)}};return a(e||[],``,null),{steps:n,forks:r,ended:i}}function kE(e,t,n){return[...e.forks.slice(0,t).map(e=>e.chosen),n]}function AE({boardId:e,view:t,updateParams:n,clearFocus:r,setCommentMode:i,journey:a,route:o,routePages:s,step:c,builder:l,setBuilder:u,busy:d,setBusy:f,setNotice:p,flow:m,targets:h,nodesReady:g,mode:_,comparePair:v,setSettledZoom:y}){let b=(0,G.useCallback)(e=>{r(),n({j:e||null,step:e?1:null,jc:null,jb:null})},[r,n]),x=(0,G.useCallback)(()=>n({j:null,step:null,jc:null,jb:null}),[n]),S=(0,G.useCallback)(e=>{s&&n({step:D_(e,s.length)})},[s,n]),C=(0,G.useCallback)((e,t)=>{o&&n({jb:kE(o,e,t).join(`,`)})},[o,n]),w=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!a||!g||l){a||(w.current=null);return}let e=s[c-1],t=`${a.id}:${c}:${e}:${_}:${v}`;if(w.current===t)return;let n=h[e];n&&(w.current=t,y(null),m.fitBounds({x:n.x,y:n.y-48,width:n.w,height:n.h+48},{padding:.18,duration:fw(450)}))},[l,v,m,a,h,_,g,s,y,c]),CE({journey:a,builder:l,goStep:S,step:c,closeJourney:x});let T=(0,G.useCallback)((e=null)=>{i(!1),r(),u(e?{id:e.id,name:e.name,steps:structuredClone(e.steps),into:null}:{id:null,name:``,steps:[],into:null})},[r,u,i]),E=(0,G.useCallback)(e=>{u(t=>{if(!t||EE(t.steps).length>=50)return t;let n=structuredClone(t.steps),r=(t.into?n[t.into.fork]:null)?.branches?.[t.into.branch]?.steps||n;return r[r.length-1]===e?t:(r.push(e),{...t,steps:n})})},[u]),D=`/api/boards/${encodeURIComponent(e)}/journeys`;return{openJourney:b,closeJourney:x,goStep:S,chooseJourneyBranch:C,startBuilder:T,addBuilderStep:E,saveBuilder:async()=>{if(l&&!d){f(!0);try{let e={name:l.name,steps:l.steps},n=l.id?await Je.patch(`${D}/${encodeURIComponent(l.id)}`,e):await Je.post(D,e);await t.refetch(),u(null),w.current=null,b(n.journey.id)}catch(e){p({tone:`bad`,text:e.message||`The journey was not saved.`})}finally{f(!1)}}},removeJourney:async()=>{if(a&&!d){f(!0);try{await Je.delete(`${D}/${encodeURIComponent(a.id)}`),x(),t.refetch()}catch(e){p({tone:`bad`,text:e.message||`The journey was not deleted.`})}finally{f(!1)}}}}}function jE({boardId:e,commentsQuery:t,view:n,info:r,localName:i,authorName:a,setBusy:o,setNotice:s,setToast:c,setDeletingIds:l,selectedCommentId:u,closeThread:d,wide:f,filter:p,allowed:m}){let h=(0,G.useRef)(new Map),g=(e,r=!1,{counts:i=!0}={})=>{t.setData(t=>{let n=Array.isArray(t?.comments)?t.comments:[];return r?{comments:n.filter(t=>t.id!==e.id)}:{comments:n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n]}}),i&&n.refetch()},_=`/api/boards/${encodeURIComponent(e)}/comments`,v=async(e,t)=>{o(!0);try{let n=await Je.post(`${_}/${e.id}/${t}`,{author:a()||void 0});g(n.comment),f&&t===`resolve`&&p===`open`&&d(),t===`resolve`&&m(`resolve`)&&c({at:Date.now(),text:`Resolved comment #${e.id}.`,undo:()=>v(n.comment,`reopen`)})}catch(e){s({tone:`bad`,text:e.message||`That did not save.`})}finally{o(!1)}},y=async(e,t)=>{o(!0);try{let n=await Je.post(`${_}/${e.id}/replies`,{body:t,author:a()||void 0});return g(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That reply did not save.`}),!1}finally{o(!1)}},b=async(e,t)=>{o(!0);try{let n=await Je.patch(`${_}/${e.id}`,{body:t});return g(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That edit did not save.`}),!1}finally{o(!1)}},x=async(e,t,n=null)=>{try{let a=await Je.post(`${_}/${e.id}/reactions`,{emoji:t,...n?{replyId:n}:{},...r?.hosted?{}:{author:i||void 0}});g(a.comment,!1,{counts:!1})}catch(e){s({tone:`bad`,text:e.message||`That reaction did not save.`})}},S=async e=>{let t=new URL(window.location.href);t.searchParams.set(`c`,String(e.id)),t.searchParams.delete(`v`);try{await navigator.clipboard.writeText(t.href),s({tone:`info`,text:`Copied the link to comment #${e.id}.`})}catch{s({tone:`info`,text:`Link to comment #${e.id}: ${t.href}`})}},C=async e=>{o(!0);try{let t=await Je.post(`${_}/${e.id}/github/issue`,{});g(t.comment),s({tone:`info`,text:`${t.created?`Opened`:`Already has`} GitHub issue #${t.issue.number}.`})}catch(e){s({tone:`bad`,text:e.message||`The GitHub issue was not created.`})}finally{o(!1)}},w=e=>{h.current.delete(e),l(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},T=async e=>{let t=h.current.get(e.id);if(t){window.clearTimeout(t.timer);try{await Je.delete(`${_}/${e.id}`),g(e,!0)}catch(e){s({tone:`bad`,text:e.message||`That did not delete.`})}finally{w(e.id)}}},E=(0,G.useRef)(T);return E.current=T,(0,G.useEffect)(()=>{let e=()=>{for(let{comment:e}of[...h.current.values()])E.current(e)};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),e()}},[]),{commentsUrl:_,applyComment:g,setStatus:v,replyTo:y,editComment:b,reactTo:x,copyLink:S,githubIssue:C,removeComment:async e=>{u===e.id&&d(),l(t=>new Set(t).add(e.id));let t=window.setTimeout(()=>E.current(e),6e3);h.current.set(e.id,{comment:e,timer:t}),c({at:Date.now(),text:`Deleted comment #${e.id}.`,undo:()=>{window.clearTimeout(t),w(e.id)}})},sendToAgent:async e=>{let{dispatchHash:n}=e,i=!!(e.needsRunApproval&&[`admin`,`owner`].includes(r.role));o(!0);try{i&&await SC();let t=await Je.post(`${_}/${e.id}/send-to-agent`,{dispatchHash:n,approve:i});g(t.comment)}catch(e){e.code===`comment_changed`?(t.refetch(),s({tone:`bad`,text:`This comment changed while you were approving it. Read it again, then send it.`})):s({tone:`bad`,text:e.message})}finally{o(!1)}}}}function ME(e){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!1),[o,s]=(0,G.useState)(()=>new Set),c=Qe(`/api/boards/${encodeURIComponent(e)}`,{pollMs:r||t?2e3:a?0:3e4}),l=Qe(`/api/boards/${encodeURIComponent(e)}/comments`,{pollMs:a?0:t?1e3:2e4}),u=c.data,d=u?.capture;return(0,G.useEffect)(()=>{i(!!d?.running)},[d?.running]),{view:c,commentsQuery:l,data:u,capture:d,comments:(0,G.useMemo)(()=>{let e=Array.isArray(l.data?.comments)?l.data.comments:[];return o.size?e.filter(e=>!o.has(e.id)):e},[l.data,o]),fixRequest:t,setFixRequest:n,setPolling:i,deletingIds:o,setDeletingIds:s}}function NE({params:e,data:t,builder:n}){let r=(0,G.useMemo)(()=>Array.isArray(t?.journeys)?t.journeys:[],[t?.journeys]),i=n?null:r.find(t=>t.id===e.get(`j`))||null,a=e.get(`jb`)||``,o=(0,G.useMemo)(()=>i?OE(i.steps,a.split(`,`).filter(Boolean)):null,[i,a]),s=(0,G.useMemo)(()=>i?DE(i.steps):null,[i]),c=(0,G.useMemo)(()=>o?o.steps.map(e=>e.pageId):null,[o]);return{journeys:r,journey:i,route:o,routeGraph:s,routePages:c,step:D_(e.get(`step`),c?.length||0),journeyComments:!!i&&e.get(`jc`)===`1`}}var PE=40;function FE({pendingFocus:e,setPendingFocus:t,targets:n,viewports:r,flow:i,canvasRef:a,wide:o,setSettledZoom:s}){(0,G.useEffect)(()=>{if(!e)return;let c=_v(n,e);if(!c){n[e.pageId]&&r[e.viewport]||t(null);return}t(null),s(null);let l=Math.max(i.getZoom(),1.2),u=a.current?.getBoundingClientRect(),d=n[e.pageId];if(o||!u?.width||!d){i.setCenter(c.x,c.y,{zoom:l,duration:fw(450)});return}let f=u.height*.28-c.y*l;d.y*l+f<PE&&(f=Math.min(PE-d.y*l,u.height*.45-c.y*l)),i.setViewport({x:u.width/2-c.x*l,y:f,zoom:l},{duration:fw(450)})},[a,i,n,e,t,s,r,o])}function IE({wide:e,nodesReady:t,initialCamera:n,selectedCommentId:r,canvasRef:i,nodes:a,flow:o,setSettledZoom:s}){let c=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(e||c.current||!t||(c.current=!0,n.current||r))return;let l=i.current?.getBoundingClientRect(),u=a.find(e=>e.type===`groupFrame`),d=u&&a.find(e=>e.type===`page`&&e.data?.page?.group===u.data.group);if(!l?.width||!u||!d){o.fitView(hw);return}let f=Math.min(u.width,d.width*2+72+2*(d.position.x-u.position.x)),p=Math.min(1.5,Math.max(.05,(l.width-16)/f)),m=12+44*Math.max(p,.45);s(null),o.setViewport({x:8-u.position.x*p,y:m-u.position.y*p,zoom:p})},[i,o,n,a,t,r,s,e])}function LE({mode:e,pendingFocus:t,shapeKey:n,clearFocus:r,fitBoard:i}){let a=(0,G.useRef)(e);(0,G.useEffect)(()=>{if(a.current===e||(a.current=e,r(),t))return;let n=window.setTimeout(i,60);return()=>window.clearTimeout(n)},[r,i,e,t]);let o=(0,G.useRef)(n);(0,G.useEffect)(()=>{if(o.current===n)return;o.current=n,r();let e=window.setTimeout(i,60);return()=>window.clearTimeout(e)},[r,i,n])}function RE({nodesReady:e,data:t,commentsLoaded:n,selectedCommentId:r,selectedComment:i,initialCamera:a,focusComment:o,deletingIds:s,setNotice:c,updateParams:l}){let u=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!u.current&&e&&t&&(!r||n)&&(u.current=!0,i&&!a.current&&o(i))},[n,t,o,a,e,i,r]);let d=(0,G.useRef)(null);(0,G.useEffect)(()=>{r&&n&&!i&&!s.has(r)&&d.current!==r&&(d.current=r,c({tone:`bad`,text:`Comment #${r} was not found on this board. It may have been deleted.`}),l({c:null}))},[n,s,i,r,c,l])}function zE({selectedComment:e,visibleComments:t,focusComment:n,mode:r,viewports:i,modes:a}){let o=(0,G.useMemo)(()=>e&&!t.some(t=>t.id===e.id)?[e,...t]:t,[e,t]),s=e?o.findIndex(t=>t.id===e.id):-1;return{threadList:o,threadIndex:s,stepThread:e=>{o.length<2||s<0||n(o[(s+e+o.length)%o.length])},neighborNote:e=>{if(o.length<2||s<0||r===`all`)return null;let t=o[(s+e+o.length)%o.length];return t.viewport===r||!i[t.viewport]?null:`switches to ${a.find(e=>e.id===t.viewport)?.label||t.viewport}`}}}var BE=[`issues`,`pages`,`seo`,`performance`,`history`],VE=e=>BE.includes(e)&&e!==`issues`?e:null;function HE({boardId:e,info:t,params:n,updateParams:r,pages:i}){let o=!!t?.checksAvailable,s=o&&!!n.get(`checks`),c=i?.some(e=>e.id===n.get(`checks`))?n.get(`checks`):null,l=n.get(`cv`)||null,u=BE.includes(n.get(`ct`))?n.get(`ct`):`issues`,d=/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.get(`ce`)||``)?n.get(`ce`):null,f=`/api/boards/${encodeURIComponent(e)}/checks`,p=d?`?env=${encodeURIComponent(d)}`:``,m=Qe(o?`${f}${p}`:null,{pollMs:a?0:3e4}),h=Qe(o&&s&&!a?`${f}/seo${p}`:null),g=o&&!a&&!t?.hosted,[_,v]=(0,G.useState)(!1),y=Qe(g&&s?`${f}/run`:null,{pollMs:_?1500:0}),b=y.data?.run||null,x=b?.state===`running`;(0,G.useEffect)(()=>v(x),[x]);let S=(0,G.useRef)(!1),{refetch:C}=m,{refetch:w}=h;(0,G.useEffect)(()=>{S.current&&!x&&(C(),w()),S.current=x},[x,C,w]);let[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(!1),k=(0,G.useCallback)(async({pages:e=null,seo:t=!0}={})=>{O(!0),E(null);try{return await Je.post(`${f}/run`,{seo:t,...e?{pages:e}:{},...d?{env:d}:{}}),v(!0),await y.refetch(),!0}catch(e){return E(e.message||`The checks run did not start.`),y.refetch(),!1}finally{O(!1)}},[f,d,y]),[A,j]=(0,G.useState)(!1),M=(0,G.useCallback)(async()=>{j(!0),E(null);try{await Je.delete(`${f}/run`)}catch(e){E(e.message||`The checks run could not be stopped.`)}finally{j(!1),y.refetch()}},[f,y]),N=(0,G.useCallback)((e=null,t=null,n=null)=>r({checks:e||`all`,cv:t,chat:null,...n?{ct:VE(n)}:{}}),[r]),P=(0,G.useCallback)(e=>r({ct:VE(e)}),[r]),F=(0,G.useCallback)(()=>r({checks:null,cv:null,ct:null}),[r]),ee=(0,G.useMemo)(()=>{let e=new Map;for(let t of m.data?.views||[]){if([`stale`,`failed`].includes(t.state))continue;let n=t.runs?.reduce((e,t)=>e+(t.state===`stale`?0:t.actionable),0)??t.actionable;e.set(t.pageId,(e.get(t.pageId)||0)+n)}return e},[m.data]),I=g?{loading:y.loading,canRun:!!y.data?.canRun,reason:y.data?.reason||null,limit:y.data?.limit||100,privatePages:y.data?.privatePages||[],seoDefault:y.data?.seoDefault!==!1,run:b,starting:D,error:T,start:k,stop:M,stopping:A}:null,L=[`shapewall checks run`,`--board ${e}`,c?`--only ${c}`:null,d?`--env ${d}`:null,u===`seo`?`--seo`:null,`--limit 100`].filter(Boolean).join(` `);return{canChecks:o,checksOpen:s,checksPage:c,checksViewport:l,checksEnvironment:d,checksTab:u,setChecksTab:P,checksQuery:m,seoQuery:h,checksRun:I,checksPanelProps:{tab:u,onTab:P,seo:h.error?null:h.data,run:I,command:L},openChecks:N,closeChecks:F,checksCounts:ee}}function UE({boardId:e,info:t,params:n,updateParams:r}){let i=!a&&!!t?.agent&&!(t?.remote?.noRemoteChat&&t?.remote?.kind!==`host`),o=n.get(`chat`)||``,s=i?cS(o):null,c=!!(t?.agent?.settingsEditable||t?.agent?.settingsReadonly),l=!a&&!Ce&&!t?.consoleUrl&&!t?.workspace&&!t?.hosted&&!t?.guest,u=l&&n.get(`settings`)===`general`,d=c&&n.get(`settings`)===`agent`,f=(0,G.useCallback)(()=>r({settings:`agent`}),[r]);return(0,G.useEffect)(()=>{s&&dS(e,sS(s))},[e,s]),{chatAvailable:i,chatThread:s,reopenChat:(0,G.useCallback)(()=>r({chat:fS(e),checks:null,cv:null}),[e,r]),settingsAvailable:c,localSettingsAvailable:l,generalSettingsOpen:u,settingsOpen:d,openSettings:f,openChat:(0,G.useCallback)(e=>{r({chat:sS(e),checks:null,cv:null})},[r])}}function WE({boardId:e,params:t,updateParams:n,environmentList:r,setCommentMode:i,pageCount:a=0}){let o=(0,G.useMemo)(()=>Array.isArray(r)?r:[],[r]),s=(0,G.useMemo)(()=>{let[e,n]=String(t.get(`cmp`)||``).split(`_`),r=o.map(e=>e.id);return e&&n&&e!==n&&r.includes(e)&&r.includes(n)?[e,n]:null},[t.get(`cmp`),o]),c=t.get(`changed`),l=a>=30,u=!!s&&(c===`1`||c!==`0`&&l),d=e=>n({changed:e===l?null:e?`1`:`0`}),f=t.get(`diff`)!==`off`,p=Qe(s?`/api/boards/${encodeURIComponent(e)}/compare?a=${s[0]}&b=${s[1]}`:null),m=s&&p.data?.a===s[0]&&p.data?.b===s[1]?p.data:null,h=(0,G.useMemo)(()=>{if(!s)return null;let[e,t]=s,n=new Map(o.map(e=>[e.id,e])),r=o.find(e=>e.default)?.id;return{a:e,b:t,files:m?.files||{},failures:m?.failures||{},pages:m?.pages||{},showDiff:f,kindOf:e=>e===r?`captures`:`envs/${e}`,versionOf:e=>n.get(e)?.capturedAt||`none`,titleOf:e=>n.get(e)?.title||e,diffKind:`diffs/${e}_${t}`,diffVersion:`${n.get(e)?.capturedAt}|${n.get(t)?.capturedAt}`}},[m,s,o,f]),g=e=>{i(!1),n({cmp:e?e.join(`_`):null,changed:e?t.get(`changed`):null,diff:e?t.get(`diff`):null})};return{environments:o,comparePair:s,changedOnly:u,setChangedOnly:d,showDiff:f,compareQuery:p,compareData:m,compareView:h,setCompare:g,canCompare:o.length>1,toggleCompare:()=>g(s?null:[o[0].id,o[1].id])}}function GE({comments:e,query:t,stateFilter:n,mentionFilter:r,titleOfPage:i,filter:a,journey:o,journeyComments:s}){let c=(0,G.useMemo)(()=>R_(e,{query:t,state:n,mention:r,titleOf:i}),[e,r,t,n,i]),l=(0,G.useMemo)(()=>{let e=s?new Set(o.pages||EE(o.steps)):null;return c.filter(t=>(a===`all`||t.status===a)&&(!e||e.has(t.pageId)))},[c,a,o,s]);return{narrowedComments:c,visibleComments:l,pinsByTarget:(0,G.useMemo)(()=>{let e=new Map;for(let t of l){let n=`${t.pageId}|${t.viewport}`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[l]),counts:{open:c.filter(e=>e.status===`open`).length,resolved:c.filter(e=>e.status===`resolved`).length}}}function KE({targets:e,layoutEdges:t,links:n,showLinks:r,showAllLinks:i,activePage:a,builder:o,route:s,routeGraph:c,routePages:l,step:u,journey:d,targetTitle:f}){let p=(0,G.useMemo)(()=>new Set(Object.keys(e).filter(e=>!e.startsWith(`variant:`))),[e]),m=(0,G.useMemo)(()=>o?OE(o.steps).steps.map(e=>e.pageId):null,[o]),h=o?m:l,g=(0,G.useMemo)(()=>r&&!i?T_(n,p):null,[n,p,i,r]),_=(0,G.useMemo)(()=>o||!s?null:{graph:c,path:s.steps.map(e=>e.key)},[o,s,c]),v=(0,G.useMemo)(()=>[...t,...E_({links:n||{},showLinks:r,activePage:a,journeySteps:o?m:null,journeyRoute:_,currentStep:o?0:u,present:p,hideTargets:g}).map(e=>({...e,ariaLabel:e.id.startsWith(`link:`)?`Link from ${f(e.source)} to ${f(e.target)}`:`Journey${e.data?.label?` step ${e.data.label}`:``}: ${f(e.source)} to ${f(e.target)}`}))],[a,o,m,n,g,_,t,p,r,u,f]),y=(0,G.useMemo)(()=>{if(o||!d||!l)return null;let e=new Set(l);return new Set((d.pages||EE(d.steps)).filter(t=>!e.has(t)))},[o,d,l]);return{presentPages:p,shownSteps:h,hiddenLinkTargets:g,edges:v,journeyView:(0,G.useMemo)(()=>h?{steps:C_(h),offPath:y,currentStep:o?null:u,currentPage:o?null:h[u-1]}:null,[o,y,h,u])}}var qE=[];function JE(e){let t=(0,G.useRef)(e);t.current=e;let{boardId:n,data:r,viewports:i,journeyView:o,compareView:s,commentMode:l,canComment:u,wide:d,hosted:f,imageVersion:p,pinsByTarget:m,me:h,checksCounts:g,canChecks:_,agentFocus:v,agentWorkingPages:y,setLiveReady:b,focusedKey:x,selectingKey:S,settledZoom:C,selectedComment:w,draftSpot:T,unread:E,liveKeys:D}=e,[k]=(0,G.useState)(()=>tb({focusedKey:x,selectingKey:S,settledZoom:C,selectedComment:w,draftSpot:T,unread:E,liveKeys:D}));(0,G.useLayoutEffect)(()=>{k.set({focusedKey:x,selectingKey:S,settledZoom:C,selectedComment:w,draftSpot:T,unread:E,liveKeys:D})},[k,x,S,C,w,T,E,D]);let A=(0,G.useMemo)(()=>{let e=()=>t.current;return{onFocusFrame:(t,n)=>{let{selectedCommentId:r,closeThread:i,builder:a,addBuilderStep:o,layout:s,flow:c,setSettledZoom:l,canvasRef:u,setFocusedKey:d}=e();if(r&&i(),a){t.startsWith(`variant:`)||o(t);return}let f=s.targets[t],p=f?.frames.find(e=>e.viewport===n);f&&p&&sv(p,c.getZoom())&&(l(null),c.fitBounds(gw({x:f.x+p.x,y:f.y,width:p.w,height:p.y+p.h},u.current?.getBoundingClientRect(),.08),{padding:.08,duration:fw(450)})),d(`${t}|${n}`)},onPin:t=>{let n=e(),{layout:r,flow:i,canvasRef:a}=n;n.selectedCommentId&&n.closeThread();let o=r.targets[t.pageId],s=o?.frames.find(e=>e.viewport===t.viewport),c=a.current?.getBoundingClientRect();if(!n.wide&&s&&c?.width&&s.w*i.getZoom()<c.width*.6){n.setSettledZoom(null);let e=Math.min(4,(c.width-16)/s.w),r=o.y+s.y+s.h*t.y/100;i.setViewport({x:8-(o.x+s.x)*e,y:c.height*.35-r*e,zoom:e},{duration:fw(450)}),n.setToast({at:Date.now(),text:`Zoomed in: tap the spot again to pin your comment.`})}else n.setDraft(e=>({...t,body:e?.body||n.checkDraft||``,author:e?.author??n.authorName()})),n.setCheckDraft(``)},onSelectComment:t=>e().selectComment(t),onHoverComment:e=>k.set({hoveredId:e}),onOpenCluster:(t,n,r)=>e().openCluster(t,n,r),onChecks:(...t)=>e().openChecks(...t),onHistory:(t,n=null)=>e().openHistory(t,n),onShowViewport:t=>e().updateParams({vp:t===e().defaultMode?null:t}),onImageError:()=>e().onImageError()}},[k]);return{board:(0,G.useMemo)(()=>({boardId:n,captures:r?.captures||{},manifest:r?.manifest||null,counts:r?.commentCounts||{},viewports:i,journey:o,compare:s,commentMode:l&&u&&!s,touch:!d,imageUrl:(e,t,r)=>c(n,e,t,r||p),liveUrl:(e,t,r)=>O(n,e,t,r||p),elementsUrl:(e,t,r)=>I(n,e,t,r||p),domFallback:!a&&!Ce&&!f,setLiveReady:b,pinsFor:(e,t)=>s?qE:m.get(`${e}|${t}`)||qE,me:h,checksCount:e=>g.get(e)||0,historyCount:e=>F_(r?.versions,e),agentWorking:v,agentWorkingPages:y,onFocusFrame:A.onFocusFrame,onPin:A.onPin,onSelectComment:A.onSelectComment,onHoverComment:d?A.onHoverComment:null,onOpenCluster:A.onOpenCluster,onChecks:_?A.onChecks:null,onHistory:A.onHistory,onShowViewport:A.onShowViewport,onImageError:A.onImageError}),[A,v,y,n,_,u,g,l,s,r?.captures,r?.commentCounts,r?.manifest,r?.versions,f,p,o,h,m,b,i,d]),view:k}}function YE({boardId:e,view:t,setBusy:n,setNotice:r,setPolling:i}){let[a,o]=(0,G.useState)(!1);return{captureConfirm:a,setCaptureConfirm:o,startCapture:async(a=null,s=null)=>{n(!0);try{r({tone:`info`,text:(await Je.post(`/api/boards/${encodeURIComponent(e)}/capture`,{...a?{env:a}:{},...s?{pages:s}:{}})).message||`Capture started.`}),i(!0),t.refetch()}catch(e){r({tone:`bad`,text:e.message||`The capture did not start.`})}finally{n(!1),o(!1)}}}}function XE({draft:e,setDraft:t,busy:n,setBusy:r,commentsUrl:i,applyComment:a,markSeen:o,setLocalName:s,setNotice:c,updateParams:l,wide:u,filter:d,targetTitle:f,people:p,info:m}){return{draftDescription:e?`${f(e.pageId)} · ${e.viewport} · ${e.anchor?`on "${e.anchor.text||e.anchor.selector.split(` > `).pop()}"`:`${Math.round(e.x)}% across, ${Math.round(e.y)}% down`}`:``,composerProps:{draft:e,onChange:e=>t(t=>t&&{...t,...e}),onSubmit:async()=>{if(e?.body.trim()&&!n){r(!0);try{let n=(e.author||``).trim();We(n);let{comment:r}=await Je.post(i,{pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y,body:e.body,author:n,...e.anchor?{anchor:e.anchor}:{}});t(null),s(n),a(r),o(r),l({c:u?r.id:null,filter:d===`all`?`all`:null})}catch(e){c({tone:`bad`,text:e.message||`The comment was not saved.`})}finally{r(!1)}}},onCancel:()=>t(null),busy:n,people:p,hosted:!!m?.hosted,signedInAs:m?.user?.name||null}}}function ZE({canComment:e,comparePair:t,commentMode:n,markPicked:r,setDraft:i,setCommentMode:a,showLinks:o,toggleLinks:s,canCompare:c,toggleCompare:l,wide:u,fitBoard:d,minimapOn:p,toggleMinimap:m,chatAvailable:h,reopenChat:g,canChecks:_,openChecks:v}){return[e&&!t?{id:`comment`,label:n?`Stop commenting`:`Comment on a page`,icon:rg,keys:`C`,run:()=>{r(),i(null),a(e=>!e)}}:null,{id:`links`,label:o?`Hide links between pages`:`Show links between pages`,icon:h_,run:s},c?{id:`compare`,label:t?`Leave compare mode`:`Compare environments`,icon:Ch,run:l}:null,u?{id:`fit`,label:`Fit the whole board`,icon:tg,keys:`Shift 1`,run:d}:null,u?{id:`minimap`,label:p?`Hide the minimap`:`Show the minimap`,icon:$h,run:m}:null,h?{id:`agent`,label:`Chat with your agent`,icon:f,run:g}:null,_?{id:`checks`,label:`Open page checks`,icon:xh,run:()=>v()}:null].filter(Boolean)}var QE=30,$E=28,eD=240;function tD(e){let t=1/e;return{"--sw-zoom":e.toFixed(4),"--sw-inv":t.toFixed(4),"--sw-title-scale":Math.min(t,96/QE).toFixed(4),"--sw-title-fade":Math.max(0,Math.min(1,(e-.16)*25)).toFixed(3),"--sw-group-scale":Math.min(t,eD/$E).toFixed(4),"--sw-label-scale":Math.min(t,1.6).toFixed(4),"--sw-chip-scale":Math.min(t,1).toFixed(4)}}function nD(){let e=Wu();return(0,G.useEffect)(()=>{let t=null,n=e=>{let n=e.transform[2],r=e.domNode;if(r&&n!==t){t=n;for(let[e,t]of Object.entries(tD(n)))r.style.setProperty(e,t)}};return n(e.getState()),e.subscribe(n)},[e]),null}function rD({fitBoard:e,zoomTo:t}){let n=Vd();(0,G.useEffect)(()=>{let r=r=>{if(!(r.defaultPrevented||r.altKey||r.ctrlKey||r.metaKey||Wb(r.target))&&!document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)){if(r.shiftKey&&r.code===`Digit1`)e();else if(r.shiftKey&&r.code===`Digit0`)t(1);else if(!r.shiftKey&&(r.key===`=`||r.key===`+`))n.zoomIn({duration:fw(200)});else if(!r.shiftKey&&r.key===`-`)n.zoomOut({duration:fw(200)});else return;r.preventDefault()}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,n,t])}function iD({wide:t,clearFocus:n,setSettledZoom:r,minimapOn:a,liveKeys:o,toggleMinimap:s,hideFit:c,hideMinimap:l=!1,fitBoard:u}){let d=Vd(),f=Z(e=>Math.round(e.transform[2]*100)),m=e=>{n(),r(null);let{x:t,y:i,zoom:a}=d.getViewport(),o=document.querySelector(`[data-sw-canvas]`)?.getBoundingClientRect(),s=(o?.width||0)/2,c=(o?.height||0)/2,l=e/a;d.setViewport({x:s-(s-t)*l,y:c-(c-i)*l,zoom:e},{duration:fw(250)})};if(rD({fitBoard:u,zoomTo:m}),!t)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(nD,{}),(0,K.jsx)($u,{position:`bottom-left`,className:U(`!m-2`,c&&`hidden`),children:(0,K.jsx)(z,{size:`icon`,variant:`secondary`,className:`bg-surface/95 shadow-pop backdrop-blur`,onClick:u,label:`Fit the whole board`,"data-sw-fit":`true`,children:(0,K.jsx)(tg,{size:17,"aria-hidden":`true`})})})]});let g=a&&!o.size&&!l,_=a&&o.size?`Minimap: hidden while a page is live`:a?`Hide the minimap`:`Show the minimap`,v=`h-8 w-8 rounded-md text-muted shadow-none hover:bg-surface-2 hover:text-fg`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(nD,{}),(0,K.jsx)($u,{position:`bottom-left`,className:`!m-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-line bg-surface/95 p-0.5 shadow-pop backdrop-blur`,role:`group`,"aria-label":`Zoom`,"data-sw-zoom-controls":`true`,children:[(0,K.jsx)(z,{className:U(v,`react-flow__controls-zoomout`),onClick:()=>d.zoomOut({duration:fw(200)}),label:`Zoom out`,tooltip:(0,K.jsx)(DT,{label:`Zoom out`,keys:[`-`]}),children:(0,K.jsx)(sg,{size:15,"aria-hidden":`true`})}),(0,K.jsxs)(we,{children:[(0,K.jsx)(p,{content:`Zoom level`,children:(0,K.jsxs)(x,{className:`tabular h-8 min-w-12 rounded-md px-1.5 text-xs font-medium text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":`Zoom ${f}%`,"data-sw-zoom-level":f,children:[f,`%`]})}),(0,K.jsxs)(e,{side:`top`,align:`start`,className:`min-w-52`,children:[(0,K.jsxs)(C,{onSelect:()=>d.zoomIn({duration:fw(200)}),children:[`Zoom in `,(0,K.jsx)(i,{className:`ml-auto`,children:`+`})]}),(0,K.jsxs)(C,{onSelect:()=>d.zoomOut({duration:fw(200)}),children:[`Zoom out `,(0,K.jsx)(i,{className:`ml-auto`,children:`-`})]}),(0,K.jsx)(h,{}),(0,K.jsx)(C,{onSelect:()=>m(.5),children:`Zoom to 50%`}),(0,K.jsxs)(C,{onSelect:()=>m(1),children:[`Zoom to 100% `,(0,K.jsx)(i,{className:`ml-auto`,children:`Shift 0`})]}),(0,K.jsx)(C,{onSelect:()=>m(2),children:`Zoom to 200%`}),(0,K.jsx)(h,{}),(0,K.jsxs)(C,{onSelect:u,children:[`Fit the whole board `,(0,K.jsx)(i,{className:`ml-auto`,children:`Shift 1`})]})]})]}),(0,K.jsx)(z,{className:U(v,`react-flow__controls-zoomin`),onClick:()=>d.zoomIn({duration:fw(200)}),label:`Zoom in`,tooltip:(0,K.jsx)(DT,{label:`Zoom in`,keys:[`+`]}),children:(0,K.jsx)(Cg,{size:15,"aria-hidden":`true`})}),(0,K.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),(0,K.jsx)(z,{className:U(v,`react-flow__controls-fitview`),onClick:u,label:`Fit the whole board`,tooltip:(0,K.jsx)(DT,{label:`Fit the whole board`,keys:[`Shift`,`1`]}),children:(0,K.jsx)(tg,{size:14,"aria-hidden":`true`})}),(0,K.jsx)(z,{className:U(v,a&&`text-accent hover:text-accent`),"aria-pressed":a,onClick:s,label:a?`Hide the minimap`:`Show the minimap`,tooltip:_,"data-sw-minimap-toggle":a?o.size?`auto-hidden`:`on`:`off`,children:(0,K.jsx)($h,{size:14,"aria-hidden":`true`})})]})}),g?(0,K.jsx)(Pm,{pannable:!0,zoomable:!0,position:`bottom-right`,className:`!m-3 overflow-hidden !rounded-lg shadow-pop`,style:{width:168,height:104},bgColor:`color-mix(in srgb, var(--surface) 88%, transparent)`,maskColor:`color-mix(in srgb, var(--sunken) 55%, transparent)`,maskStrokeColor:`var(--accent)`,maskStrokeWidth:2,nodeBorderRadius:6,nodeColor:e=>e.type===`groupFrame`?`color-mix(in srgb, var(--fg) 5%, transparent)`:`color-mix(in srgb, var(--fg) 28%, transparent)`,nodeStrokeWidth:0,ariaLabel:`Minimap`,"data-sw-minimap":`true`}):null]})}function aD(e,t,n=8){return t?e.left<t.right+n&&e.left+e.width>t.left-n&&e.top<t.bottom+n&&e.top+e.height>t.top-n:!1}function oD(e,t){let n=null;for(let r of e||[]){if(!r||r.width<=0||r.height<=0)continue;let e=r.left-t.left,i=r.top-t.top,a=e+r.width,o=i+r.height;n=n?{left:Math.min(n.left,e),top:Math.min(n.top,i),right:Math.max(n.right,a),bottom:Math.max(n.bottom,o)}:{left:e,top:i,right:a,bottom:o}}return n}function sD({card:e,canvas:t,bar:n,avoid:r=null,gap:i=8,zoom:a=1,toggleSize:o=44}){let{width:s,height:c}=t,l=r?r.bottom+i:i,u=e=>Math.max(i,Math.min(c-n.height-i,e)),d=(e,t=n)=>!aD({...e,width:t.width,height:t.height},r,i),f=t=>{let r={left:t,top:u(e.top)};if(d(r))return r;let a={left:t,top:l};return a.top+n.height+i<=c?a:null},p=null;if(e.titleTop-n.height-i>=i){let t={left:Math.max(i,Math.min(e.right-n.width,s-n.width-i)),top:e.titleTop-n.height-i};d(t)&&(p=t)}!p&&e.right+i+n.width<=s-i&&(p=f(e.right+i)),!p&&e.left-i-n.width>=i&&(p=f(e.left-i-n.width));let m=e.titleTop>=i&&a>.2?{top:Math.max(i,e.titleTop-7),left:Math.max(i,Math.min(s-52,e.right-44-Math.min(140,(e.right-e.left)*.3)))}:{top:i,left:i};d(m,{width:o,height:o})||(m={...m,top:l});let h={left:i,top:d({left:i,top:i})?i:l};return{place:p,toggle:m,fallback:h}}var cD=30;function lD({focused:e,target:t,frame:r,title:i,hasLive:a,live:o,ready:s,selecting:c,touch:l,href:u,onOpenLive:d,onToggleSelect:f,onClose:m,history:h=0,onHistory:g=null,onChecks:_=null,onCapture:v=null,captureBusy:y=!1}){let b=Z(e=>e.transform),x=Z(e=>e.width),S=Z(e=>e.height),C=Z(e=>e.domNode),[w,T]=(0,G.useState)(null),E=w===e;(0,G.useEffect)(()=>{e||T(null)},[e]);let[D,O]=(0,G.useState)(null);if((0,G.useLayoutEffect)(()=>{let t=e&&C?C.closest(`[data-sw-canvas]`)?.querySelector(`[data-sw-canvas-notes]`):null,n=()=>{let e=t?oD(Array.from(t.children).map(e=>e.getBoundingClientRect()),C.getBoundingClientRect()):null;O(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)};if(n(),!t)return;let r=new MutationObserver(n);r.observe(t,{childList:!0,subtree:!0,characterData:!0});let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),()=>{r.disconnect(),i?.disconnect()}},[e,C,x,S]),!e||!t||!r)return null;let[k,A,j]=b,M=(t.x+r.x)*j+k,N=(t.y+r.y)*j+A,P=t.y*j+A-(j>.2?cD:0),F=M+r.w*j,ee=N+r.h*j;if(F<0||M>x||ee<0||N>S||sv(r,j))return null;let I=l?54:40,L=(l?236:340)+(g?l?56:90:0)+(v?l?56:120:0)+(_?l?48:90:0),{place:R,toggle:te,fallback:ne}=sD({card:{left:M,top:N,right:F,bottom:ee,titleTop:P},canvas:{width:x,height:S},bar:{width:L,height:I},avoid:D,gap:8,zoom:j}),re=l?`touch`:`sm`,ie=`text-fg shadow-none`,ae=l&&`text-[13px]`;if(!R&&!E)return(0,K.jsx)(z,{size:`icon`,variant:`secondary`,style:te,className:`nodrag nopan absolute z-20 rounded-full bg-surface/95 text-fg shadow-pop`,onClick:t=>{t.stopPropagation(),T(e)},label:`${i} actions`,side:`bottom`,"data-sw-frame-bar-toggle":e,children:(0,K.jsx)(lh,{size:18,"aria-hidden":`true`})});let oe=R?{left:R.left,top:R.top,width:Math.min(L,x-16)}:{left:ne.left,top:ne.top,width:Math.min(L,x-16)};return(0,K.jsxs)(`div`,{className:`nodrag nopan nowheel absolute z-20 flex items-center flex-wrap justify-end gap-1 rounded-lg border border-line bg-surface/95 p-1 shadow-pop backdrop-blur`,style:oe,role:`toolbar`,"aria-label":`${i} actions`,"data-sw-frame-bar":e,onClick:e=>e.stopPropagation(),children:[l?null:(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate px-1.5 text-xs font-medium text-muted`,children:[i,` · `,r.viewport]}),a&&!o?(0,K.jsxs)(n,{size:re,variant:`default`,className:U(`shadow-none`,ae),onClick:d,"data-sw-open-live":e,children:[(0,K.jsx)(lg,{size:15,"aria-hidden":`true`}),` Open live`]}):null,o?(0,K.jsxs)(n,{size:re,variant:c?`default`:`ghost`,className:U(`shadow-none`,ae,!c&&`text-fg`),"aria-pressed":c,disabled:!s,onClick:f,"data-sw-select-text":e,children:[(0,K.jsx)(Zg,{size:15,"aria-hidden":`true`}),` `,c?`Done`:`Select text`]}):null,_?(0,K.jsxs)(n,{size:re,variant:`ghost`,className:ie,onClick:_,"aria-label":`Page checks`,"data-sw-frame-checks":e,children:[(0,K.jsx)(xh,{size:15,"aria-hidden":`true`}),l?null:`Checks`]}):null,g?(0,K.jsx)(p,{content:`Page history: ${h+1} captures`,children:(0,K.jsxs)(n,{size:re,variant:`ghost`,className:ie,onClick:g,"aria-label":`Page history: ${h+1} captures`,"data-sw-frame-history":e,children:[(0,K.jsx)(Dg,{size:15,"aria-hidden":`true`}),` `,l?null:`History`]})}):null,v?(0,K.jsx)(p,{content:`Recapture this page at every screen size`,children:(0,K.jsxs)(n,{size:re,variant:`ghost`,className:ie,disabled:y,onClick:v,"aria-label":`Capture this page`,"data-sw-frame-capture":e,children:[(0,K.jsx)(Gm,{size:15,"aria-hidden":`true`}),` `,l?null:`Capture`]})}):null,u?(0,K.jsx)(z,{asChild:!0,size:l?`icon`:`icon-sm`,className:ie,label:`Open the page in a new tab`,children:(0,K.jsx)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,children:(0,K.jsx)(dh,{size:15,"aria-hidden":`true`})})}):null,(0,K.jsx)(z,{size:l?`icon`:`icon-sm`,onClick:R?m:()=>T(null),label:R?`Close`:`Collapse`,"data-sw-frame-bar-close":`true`,children:(0,K.jsx)(B,{size:15,"aria-hidden":`true`})})]})}function uD({onChecks:e,onHistory:t,historyCountFor:n,focusedKey:r,layout:i,data:a,liveKeys:o,readyKeys:s,selectingKey:c,touch:l,liveFileFor:u,onOpenLive:d,onToggleSelect:f,onClose:p,onCapture:m,captureBusy:h}){if(!r)return null;let g=r.lastIndexOf(`|`),_=r.slice(0,g),v=r.slice(g+1),y=i.targets[_],b=y?.frames.find(e=>e.viewport===v);if(!b)return null;let x=_.startsWith(`variant:`)?a?.variants?.find(e=>`variant:${e.id}`===_):null,S=x?null:a?.board?.pages.find(e=>e.id===_);return(0,K.jsx)(lD,{focused:r,target:y,frame:b,title:x?x.title:S?.title||_,hasLive:!!u(_,v),live:o.has(r),ready:s.has(r),selecting:c===r,touch:l,href:S?.url||(x?.source&&/^https?:/.test(x.source)?x.source:null),onOpenLive:()=>d(_,v),onToggleSelect:()=>f(r),onClose:p,history:S&&a?.versions?.[S.id]?.[v]?.length||0,onChecks:S&&e?()=>e(S.id,v):null,onHistory:S&&n(S.id)?()=>t(S.id,v):null,onCapture:S&&m?()=>m(S.id):null,captureBusy:h})}var dD=(0,G.lazy)(()=>iC(()=>import(`./ShareDialog-CdVAreaw.js`).then(e=>({default:e.MigrationBanner})),__vite__mapDeps([9,1]),import.meta.url)),fD=()=>{},pD=new Set;function mD(e,t){let n=new Map;for(let r of e||[])n.has(t(r))||n.set(t(r),r);return n}function hD({boardId:e,boards:t,info:n,onPickBoard:r,onInfoChanged:i,onOpenBuzz:o}){let s=ye(`(min-width: 1024px)`),l=ye(`(max-width: 640px)`),u=Vd(),d=E(),f=tw(),[p,m]=Ke(),[h,g]=(0,G.useState)(!1),_=!n?.readOnly&&(!a||F),v=_&&!a&&!n?.hosted,y=_&&n?.allowCapture,b=e=>n?.permissions?.[e]!==!1,{view:x,commentsQuery:C,data:w,capture:T,comments:D,fixRequest:O,setFixRequest:k,setPolling:j,deletingIds:M,setDeletingIds:N}=ME(e),P=Qe(n?.localProjectsEnabled?`/api/local-projects`:null,{pollMs:3e4}),ee=P.data?.projects||[],I=(0,G.useMemo)(()=>w?.viewports||{},[w?.viewports]),L=Object.keys(I),R=(0,G.useMemo)(()=>{let e=L.map(e=>({id:e,label:W_(e)}));return e.length>1&&e.push({id:`all`,label:e.length===2?`Both`:`All`}),e},[L.join(`,`)]),z=l&&L.includes(`phone`)?`phone`:L[0]||`desktop`,B=R.some(e=>e.id===p.get(`vp`))?p.get(`vp`):z,te=ax.some(e=>e.id===p.get(`filter`))?p.get(`filter`):`open`,ne=Number(p.get(`c`))||null,re=(p.get(`q`)||``).slice(0,120),ie=I_.some(e=>e.id===p.get(`st`))?p.get(`st`):null,ae=/^[a-z][\w.-]{0,39}$/.test(p.get(`m`)||``)?p.get(`m`):null,oe=p.get(`panel`)===`off`,{canChecks:se,checksOpen:ce,checksPage:H,checksViewport:le,checksQuery:ue,openChecks:de,closeChecks:W,checksCounts:me,checksPanelProps:he,checksRun:ge}=HE({boardId:e,info:n,params:p,updateParams:m,pages:w?.board?.pages}),[_e,ve]=(0,G.useState)(``),{chatAvailable:be,chatThread:xe,settingsAvailable:Se,localSettingsAvailable:we,generalSettingsOpen:Te,settingsOpen:Ee,openSettings:De,openChat:Oe,reopenChat:ke}=UE({boardId:e,info:n,params:p,updateParams:m}),Ae=(0,G.useRef)(null),je=(0,G.useRef)(_w(p.get(`v`))),Me=(0,G.useRef)(null),[Ne,Pe]=(0,G.useState)(!1),[Fe,Ie]=(0,G.useState)(null),[Le,Re]=(0,G.useState)(!1),[ze,Be]=(0,G.useState)(!1),Ve=n?.localUser?.name||``,[He,Ue]=(0,G.useState)(()=>pe()),We=He||Ve,Ge=(0,G.useCallback)(()=>pe()||Ve,[Ve]),qe=(0,G.useRef)(null),[Je,Ye]=(0,G.useState)(!1),[Xe,Ze]=(0,G.useState)(null),[$e,et,tt]=QT(),[nt,rt]=(0,G.useState)(()=>kw()),it=nt??Aw(w?.board?.pages?.length||0),[at,ot]=(0,G.useState)(!1),st=rx(e),ct=st&&[`working`,`waiting`].includes(st.state)&&Number(st.commentId)||null,lt=(0,G.useMemo)(()=>ct?new Set([ct]):pD,[ct]),[ut,dt]=(0,G.useState)(!1),[ft,pt]=(0,G.useState)(null),[mt,ht]=(0,G.useState)(null),[gt,_t]=(0,G.useState)(null),[vt,yt]=(0,G.useState)(null),[bt,xt]=(0,G.useState)(()=>!Mw()),[St,Ct]=iw(!!d),[wt,Tt]=(0,G.useState)(()=>new Set),Et=(0,G.useCallback)(e=>Tt(t=>t.has(e)?t:new Set(t).add(e)),[]),Dt=(0,G.useCallback)(()=>{xt(!1),Pw()},[]),Ot=()=>{Ct(),Dt()},kt=p.get(`hist`),At=p.get(`hv`),{journeys:jt,journey:Mt,route:Nt,routeGraph:Pt,routePages:Ft,step:It,journeyComments:Lt}=NE({params:p,data:w,builder:gt}),q=p.get(`links`)===`1`,Rt=Array.isArray(w?.brokenLinks)?w.brokenLinks:[],zt=Rt.length?`Arrows for the links between pages; ${Rt.length} ${Rt.length===1?`link leads`:`links lead`} to an error`:`Arrows for the links between pages`,{environments:Bt,comparePair:Vt,changedOnly:Ht,showDiff:Ut,compareQuery:Wt,compareData:Gt,compareView:Kt,setCompare:qt,canCompare:Jt,toggleCompare:Yt,setChangedOnly:Xt}=WE({boardId:e,params:p,updateParams:m,environmentList:w?.environments,setCommentMode:Pe,pageCount:w?.board?.pages?.length||0}),Zt=(0,G.useMemo)(()=>{let e=w?.board?.pages||[];return!Ht||!Gt?e:e.filter(e=>(j_(Gt,e.id)||0)>0)},[Ht,Gt,w?.board?.pages]),Qt=(0,G.useMemo)(()=>w?.board&&L.length?pv({pages:Zt,groups:w.board.groups,variants:Vt?[]:w.variants,viewports:I,mode:B,compare:Vt}):{nodes:[],edges:[],targets:{}},[w?.board,w?.variants,Zt,I,B,Vt]),[$t,en,tn]=Qp(Qt.nodes);(0,G.useEffect)(()=>{en(Qt.nodes)},[Qt.nodes,en]);let nn=tm(),[rn,an]=Dw(nn),[on,sn]=(0,G.useState)(null),[cn,ln]=(0,G.useState)(null),un=(0,G.useCallback)(()=>{sn(null),ln(null)},[]),dn=(0,G.useCallback)(()=>{un(),an(null),u.fitView({...hw,duration:fw(400)})},[un,u,an]);LE({mode:B,pendingFocus:ft,shapeKey:`${Vt?.join(`_`)||``}|${Ht&&Gt?Zt.length:`all`}`,clearFocus:un,fitBoard:dn});let fn=(0,G.useMemo)(()=>mD(w?.board?.pages,e=>e.id),[w?.board?.pages]),pn=(0,G.useMemo)(()=>mD(w?.variants,e=>`variant:${e.id}`),[w?.variants]),{visibleComments:mn,pinsByTarget:hn,counts:gn}=GE({comments:D,query:re,stateFilter:ie,mentionFilter:ae,titleOfPage:(0,G.useCallback)(e=>String(e).startsWith(`variant:`)?pn.get(e)?.title||``:fn.get(e)?.title||``,[fn,pn]),filter:te,journey:Mt,journeyComments:Lt}),_n=(0,G.useMemo)(()=>S(D),[D]),vn=(0,G.useMemo)(()=>({name:n?.user?.name||We||``,handle:n?.user?.handle||null}),[n?.user?.name,n?.user?.handle,We]),yn=_&&!w?.migratedTo?.readOnly&&b(`comment`),bn=e=>{let t=!!vn.handle&&e.authorHandle===vn.handle;return{reply:_&&!w?.migratedTo?.readOnly&&b(`reply`),resolve:_&&!w?.migratedTo?.readOnly&&b(`resolve`),react:_&&!w?.migratedTo?.readOnly&&b(`react`),edit:_&&!w?.migratedTo?.readOnly&&b(`edit`)&&(!n?.hosted||JS({isAuthor:t})),delete:_&&!w?.migratedTo?.readOnly&&b(`delete`)&&(!n?.hosted||YS({role:n.role,isAuthor:t}))}},{seen:xn,markSeen:Sn,markAllSeen:Cn}=GS(e),wn=(0,G.useMemo)(()=>new Set(D.filter(e=>WS(e,xn,vn)).map(e=>e.id)),[D,vn,xn]),Tn=D.find(e=>e.id===ne)||null,En=(0,G.useMemo)(()=>{let e=new Set;for(let t of D)t.status!==`resolved`&&(t.agentStatus===`working`||lt.has(t.id))&&e.add(t.pageId);return e},[lt,D]),Dn=(0,G.useCallback)(e=>fn.get(e)||null,[fn]),On=(0,G.useCallback)(e=>{if(e.startsWith(`variant:`)){let t=pn.get(e);return t?`Variant: ${t.title}`:`Removed variant`}return Dn(e)?.title||e},[pn,Dn]),kn=w?.manifest?.capturedAt||`none`,An=(0,G.useRef)(null),{refetch:jn}=x,{refetch:Mn}=C,{refetch:Nn}=Wt,Pn=(0,G.useCallback)(()=>{let e=`${kn}|${w?.environments?.map(e=>e.capturedAt).join(`,`)||``}`;An.current!==e&&(An.current=e,jn(),Mn(),Nn())},[w?.environments,kn,Mn,Nn,jn]),Fn=(0,G.useRef)(!1),In=(0,G.useCallback)(e=>{Fn.current=!1,Ie(null),m({c:e.id}),s||(Re(!1),Be(!0))},[m,s]),Ln=(0,G.useCallback)(()=>{Be(!1),m({c:null}),Fn.current&&!s&&Re(!0),Fn.current=!1},[m,s]),Rn=(0,G.useCallback)(e=>{let t=B!==`all`&&e.viewport!==B&&!!I[e.viewport];Ie(null),pt(e),m({c:e.id,...t?{vp:e.viewport===z?null:e.viewport}:{}}),t&&yt({from:B,to:e.viewport,id:e.id,at:Date.now()}),s||(Re(!1),Be(!0))},[z,B,m,I,s]);(0,G.useEffect)(()=>{if(!vt)return;let e=window.setTimeout(()=>yt(null),6e3);return()=>window.clearTimeout(e)},[vt]),FE({pendingFocus:ft,setPendingFocus:pt,targets:Qt.targets,viewports:I,flow:u,canvasRef:Me,wide:s,setSettledZoom:an}),IE({wide:s,nodesReady:nn,initialCamera:je,selectedCommentId:ne,canvasRef:Me,nodes:Qt.nodes,flow:u,setSettledZoom:an});let zn=(0,G.useRef)(!je.current&&!ne&&!p.get(`j`)),Bn=(0,G.useRef)(!je.current&&!!ne),[Vn,Hn]=(0,G.useState)(()=>!s||!zn.current);(0,G.useEffect)(()=>{if(!zn.current||!nn||!Qt.nodes.length)return;if(zn.current=!1,!s){Hn(!0);return}let e=Tw(Qt.nodes,Me.current?.getBoundingClientRect());an(null);let t=e?u.setViewport(e):u.fitView(hw);Promise.resolve(t).finally(()=>Hn(!0))},[u,Qt.nodes,nn,an,s]);let Un=(0,G.useRef)(!1),Wn=()=>{Un.current=!0},Gn=(0,G.useCallback)(e=>{Un.current&&(Un.current=!1,e.preventDefault(),Me.current?.focus({preventScroll:!0}))},[]),{liveKeys:Kn,readyKeys:qn,setLiveReady:Jn,liveFileFor:Yn,recomputeLive:Xn,openLive:Zn}=SE({canvasRef:Me,flow:u,targets:Qt.targets,viewports:I,settledZoom:rn,setSettledZoom:an,comparePair:Vt,captures:w?.captures,variantsById:pn});(0,G.useEffect)(()=>{cn&&!Kn.has(cn)&&ln(null)},[Kn,cn]);let{openJourney:Qn,closeJourney:$n,goStep:er,chooseJourneyBranch:tr,startBuilder:nr,addBuilderStep:rr,saveBuilder:ir,removeJourney:ar}=AE({boardId:e,view:x,updateParams:m,clearFocus:un,setCommentMode:Pe,journey:Mt,route:Nt,routePages:Ft,step:It,builder:gt,setBuilder:_t,busy:ut,setBusy:dt,setNotice:Ze,flow:u,targets:Qt.targets,nodesReady:nn,mode:B,comparePair:Vt,setSettledZoom:an}),or=on&&!on.startsWith(`variant:`)?G_(on):null,sr=or?.targetId||null,cr=mt||sr,lr=p.get(`la`)===`1`,{presentPages:ur,shownSteps:dr,hiddenLinkTargets:fr,edges:pr,journeyView:mr}=KE({targets:Qt.targets,layoutEdges:Qt.edges,links:w?.links,showLinks:q,showAllLinks:lr,activePage:cr,builder:gt,route:Nt,routeGraph:Pt,routePages:Ft,step:It,journey:Mt,targetTitle:On}),hr=(0,G.useCallback)((e,t=null)=>{if(!e||String(e).startsWith(`variant:`))return;let n=B===`all`?L[0]:B;m({hist:e,hv:t&&t!==n?t:null})},[B,m,L.join(`,`)]),gr=kt&&w?.board?.pages.find(e=>e.id===kt)||null,_r=At&&I[At]?At:B===`all`?L[0]:B,vr=(0,G.useCallback)(()=>m({hist:null,hv:null}),[m]),yr=t=>{let n=Qt.targets[t];if(!n)return;an(null);let r=n.frames[0],i=n.frames.map(e=>w?.captures?.[t]?.[e.viewport]).filter(e=>e?.thumb||e?.file);vw(u,n,Me.current?.getBoundingClientRect(),{phoneCompare:!!Vt&&!s,shotUrls:i.map(t=>c(e,`captures`,t.thumb||t.file,kn))}),r&&sn(`${t}|${r.viewport}`)},br=(0,G.useMemo)(()=>{let e=Zt;return[...new Set(e.map(e=>e.group))].map(t=>({group:t,pages:e.filter(e=>e.group===t)}))},[Zt]),xr=(0,G.useMemo)(()=>Fe?{pageId:Fe.pageId,viewport:Fe.viewport,x:Fe.x,y:Fe.y,anchor:Fe.anchor}:null,[Fe?.pageId,Fe?.viewport,Fe?.x,Fe?.y,Fe?.anchor]),Sr=(0,G.useCallback)((e,t,n)=>{let r=Qt.targets[e],i=r?.frames.find(e=>e.viewport===t);i&&(u.getZoom()>=3.9?In(n[0].comment):(an(null),u.fitBounds(yw(r,i,n),{padding:.3,duration:fw(450)})))},[u,Qt.targets,In,an]),{board:Cr,view:wr}=JE({boardId:e,data:w,viewports:I,journeyView:mr,compareView:Kt,commentMode:Ne,canComment:yn,wide:s,hosted:n?.hosted,imageVersion:kn,pinsByTarget:hn,me:vn,checksCounts:me,canChecks:se,agentFocus:lt,agentWorkingPages:En,setLiveReady:Jn,focusedKey:on,selectingKey:cn,settledZoom:rn,selectedComment:Tn,draftSpot:xr,unread:wn,liveKeys:Kn,selectedCommentId:ne,closeThread:Ln,builder:gt,addBuilderStep:rr,layout:Qt,flow:u,canvasRef:Me,setSettledZoom:an,setFocusedKey:sn,setToast:et,setDraft:Ie,checkDraft:_e,setCheckDraft:ve,authorName:Ge,selectComment:In,openCluster:Sr,openChecks:de,openHistory:hr,updateParams:m,defaultMode:z,onImageError:Pn}),{commentsUrl:Tr,applyComment:Er,setStatus:Dr,replyTo:Or,editComment:kr,reactTo:Ar,copyLink:jr,githubIssue:Mr,removeComment:Nr,sendToAgent:Pr}=jE({boardId:e,commentsQuery:C,view:x,info:n,localName:We,authorName:Ge,setBusy:dt,setNotice:Ze,setToast:et,setDeletingIds:N,selectedCommentId:ne,closeThread:Ln,wide:s,filter:te,allowed:b}),{draftDescription:Fr,composerProps:Ir}=XE({draft:Fe,setDraft:Ie,busy:ut,setBusy:dt,commentsUrl:Tr,applyComment:Er,markSeen:Sn,setLocalName:Ue,setNotice:Ze,updateParams:m,wide:s,filter:te,targetTitle:On,people:_n,info:n}),{captureConfirm:Lr,setCaptureConfirm:Rr,startCapture:zr}=YE({boardId:e,view:x,setBusy:dt,setNotice:Ze,setPolling:j}),Br=(0,G.useCallback)(e=>{m({v:`${Math.round(e.x)},${Math.round(e.y)},${e.zoom.toFixed(3)}`}),an(e.zoom),Xn()},[Xn,an,m]),Vr=Kb({canvasRef:Me,flow:u,minZoom:mw,maxZoom:4,onRest:Br}),Hr=(0,G.useCallback)((e,t)=>{Vr.moving()||Br(t)},[Br,Vr]);V(!!on,un),(0,G.useEffect)(()=>{on&&bt&&Dt()},[Dt,on,bt]),V(Ne,()=>Pe(!1)),V(!!Mt,$n),V(!!gt,()=>_t(null)),wE({commentMode:Ne,setCommentMode:Pe,canComment:yn,comparePair:Vt,setDraft:Ie});let[Ur,Wr]=mT(s,!1);(0,G.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`k`||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]):not([data-sw-palette])`)||(e.preventDefault(),ot(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,G.useEffect)(()=>{Ne||Ie(e=>e&&!e.body.trim()?null:e)},[Ne]),(0,G.useEffect)(()=>{Tn&&Sn(Tn)},[Sn,Tn]),(0,G.useEffect)(()=>{Tn&&Et(`open`),Ne&&Et(`comment`),xe&&Et(`agent`)},[xe,Ne,Et,Tn]),RE({nodesReady:nn,data:w,commentsLoaded:C.data,selectedCommentId:ne,selectedComment:Tn,initialCamera:je,focusComment:Rn,deletingIds:M,setNotice:Ze,updateParams:m});let{threadList:Gr,threadIndex:Kr,stepThread:qr,neighborNote:Jr}=zE({selectedComment:Tn,visibleComments:mn,focusComment:Rn,mode:B,viewports:I,modes:R});(0,G.useEffect)(()=>{let e=null,t=wr.subscribe(()=>{let{hoveredId:t}=wr.get(),n=t===null?null:Me.current?.querySelector(`[data-sw-pin="${t}"]`)||null;n!==e&&(e?.removeAttribute(`data-sw-pin-hover`),n?.setAttribute(`data-sw-pin-hover`,`true`),e=n)});return()=>{t(),e?.removeAttribute(`data-sw-pin-hover`)}},[wr]);let Yr=e=>{yt(null),m({vp:e===z?null:e})},Xr=D.filter(e=>e.status===`open`).length,Zr={comments:mn,filter:te,counts:gn,onFilter:e=>m({filter:e===`open`?null:e}),selectedId:ne,onHover:Cr.onHoverComment,onFocus:e=>{Fn.current=!s,Rn(e)},unread:wn,onMarkAllRead:()=>Cn(D),people:_n,narrow:{query:re,state:ie,mention:ae,onQuery:e=>m({q:e||null}),onState:e=>m({st:e}),onMention:e=>m({m:e}),onClear:()=>m({q:null,st:null,m:null})},canAct:yn,targetTitle:On,touch:!s,onResetBrowserComments:F?()=>{A(e),m({c:null}),C.refetch(),x.refetch()}:null,journeyFilter:Mt?{name:Mt.name,on:Lt,onToggle:()=>m({jc:Lt?null:`1`})}:null},Qr=Tn?{comment:Tn,page:Dn(Tn.pageId),title:On(Tn.pageId),people:_n,me:vn,can:bn(Tn),role:n?.guest?`guest`:n?.role||null,hosted:!!n?.hosted,onSaveName:Ue,busy:ut,touch:!s,editingRef:qe,actions:{onReply:Or,onSendToAgent:n?.hosted&&w?.agentDispatch&&!Tn.authorGuest&&!Tn.authorAgent?Pr:null,onStatus:Dr,onEdit:kr,onDelete:Nr,onReact:Ar,onCopyLink:jr,onFixAgent:be&&!w?.migratedTo?.readOnly&&n?.agent?.fixWithAgent&&n?.agent?.configured?e=>{k({commentId:e.id,nonce:Date.now()}),s||Be(!1),Oe(nS(e.id))}:null,onAskAgent:be?e=>{s||Be(!1),Oe(nS(e.id))}:null,onGithubIssue:!a&&n?.github?.ready?Mr:null,onHistory:e=>{s||Be(!1),hr(e.pageId,e.viewport)}},nav:{index:Kr,total:Gr.length,onPrev:()=>qr(-1),onNext:()=>qr(1),prevNote:Jr(-1),nextNote:Jr(1)},beforeAfter:w?{pairFor:e=>k_(e,{manifest:w.manifest,captures:w.captures,versions:w.versions}),nativeFor:e=>{let t=String(e.pageId).startsWith(`variant:`)?pn.get(e.pageId):null,n=fn.get(t?t.pageId:e.pageId);return uv(I,e.viewport,n?.frameHeight)||null},urlFor:t=>c(e,t.kind,t.file,t.version),onImageError:Pn}:null}:null,$r={boardId:e,fixRequest:O,onFixDone:()=>{k(null),x.refetch(),C.refetch()},agent:n?.agent,threadId:xe||`board`,onThread:Oe,comments:D,pages:w?.board?.pages||[],captures:w?.captures||{},imageVersion:kn,defaultViewport:B===`all`?z:B,focused:or?{pageId:or.targetId,viewport:or.viewport}:null,touch:!s,onOpenSettings:Se?De:null,settingsLocked:!!(be&&!Se&&n?.agent?.settingsLocked),onAgentChanged:i,people:_n,onRunChecks:ge?async()=>{let e=await ge.start({seo:ge.seoDefault});return de(),e}:null,journeys:jt,checksCounts:se?me:null,onBoardChanged:()=>{x.refetch(),C.refetch()},onNavigate:e=>{if(!s&&e.kind!==`check`&&m({chat:null}),e.kind===`comment`){let t=D.find(t=>t.id===e.id);t&&Rn(t)}else e.kind===`page`?yr(e.id):e.kind===`journey`?Qn(e.id):e.kind===`check`&&de(e.id)},onRecapture:y&&!Vt?e=>e?zr(null,Array.isArray(e)?e:[e]):Rr(!0):Ce?()=>Ze({tone:`info`,text:`The demo does not take new captures. On your own board this recaptures the changed pages.`}):null},ei=()=>m({links:q?null:`1`}),ti=()=>{let e=!it;rt(e),Nw(e)},ni=!!gr||Ee||Te||Lr||!s&&ce,ri={data:ue.data,error:ue.error,loading:ue.loading,pages:w?.board?.pages||[],pageId:H,viewport:le,onSelect:de,onClose:W,onRefresh:ue.refetch,onEnvironment:e=>m({ce:e}),canComment:yn,local:!a&&!n?.hosted,onView:(e,t)=>{W(),m({vp:t,page:e}),pt({pageId:e,viewport:t,x:50,y:50})},onDraft:(e,t,n)=>{ve(`${n.title}\n\n${n.observation}\n${n.nextAction}\n\nCheck report ${t.id} (${e.viewport}, ${t.auditedAt}). Separately sampled; review before sending to an agent.`.slice(0,1800)),W(),m({vp:e.viewport}),pt({pageId:e.pageId,viewport:e.viewport,x:50,y:50}),Re(!1),Pe(!0),et({at:Date.now(),text:`Choose a pin on the page, then review and save your comment.`})},...he},ii=e=>{e.preventDefault(),W(),s?((oe||xe)&&m({panel:null,chat:null}),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>document.getElementById(`sw-comments`)?.focus()))):Re(!0)},ai=e=>qb(e,e=>{let t=Qt.targets[e]?.frames[0];t&&Cr.onFocusFrame(e,t.viewport)}),oi=ZE({canComment:yn,comparePair:Vt,commentMode:Ne,markPicked:Wn,setDraft:Ie,setCommentMode:Pe,showLinks:q,toggleLinks:ei,canCompare:Jt,toggleCompare:Yt,wide:s,fitBoard:dn,minimapOn:it,toggleMinimap:ti,chatAvailable:be,reopenChat:ke,canChecks:se,openChecks:de}),si={setMenuOpen:Ye,data:w,chatAvailable:be,chatThread:xe,reopenChat:ke,updateParams:m,groupedPages:br,jumpToPage:yr,modes:R,mode:B,setMode:Yr,journeys:jt,journey:Mt,canEditJourneys:v,openJourney:Qn,startBuilder:nr,canChecks:se,openChecks:de,showLinks:q,toggleLinks:ei,brokenLinks:Rt,canCompare:Jt,comparePair:Vt,toggleCompare:Yt,settingsAvailable:Se,openSettings:De,capture:T,canCapture:y,busy:ut,setCaptureConfirm:Rr};return(0,K.jsxs)(gD,{board:Cr,view:wr,people:_n,children:[(0,K.jsxs)(`div`,{className:`flex h-full flex-col`,"data-sw-board":e,style:{paddingTop:`env(safe-area-inset-top, 0px)`},children:[(0,K.jsx)(dC,{}),(0,K.jsx)(TC,{}),n?.hosted&&w?.agentApprove?(0,K.jsx)(CC,{boardId:e}):null,(0,K.jsx)(`a`,{href:`#sw-comments`,className:`sr-only z-[80] rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg focus:not-sr-only focus:absolute focus:top-2 focus:left-2`,onClick:ii,"data-sw-skip-comments":`true`,children:`Skip to comments`}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[s?(0,K.jsx)(mE,{...si,info:n,localName:We,onOpenBuzz:o,demo:d,localSettingsAvailable:we,setShareOpen:g,expanded:Ur,onToggle:Wr,pages:w?{groups:br,journeys:jt,comments:D,activePage:cr,journeyId:Mt?.id||null,onPage:yr,onJourney:Qn}:null}):null,(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(YT,{...si,wide:s,info:n,boardId:e,boards:t,localProjects:ee,projectsError:P.error,localName:We,onPickBoard:r,onOpenBuzz:o,demo:d,localSettingsAvailable:we,setShareOpen:g,viewportNotice:vt,canComment:yn,commentMode:Ne,setCommentMode:Pe,openPalette:()=>ot(!0),minimapOn:it,toggleMinimap:ti,linksTip:zt,panelHidden:oe,checksOpen:ce,allOpen:Xr,closeChecks:W,setSheetOpen:Re,sidebarTitled:s&&Ur}),!n?.hosted&&w?.migratedTo?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(dD,{marker:w.migratedTo,boardId:e,editable:!!n?.shareEnabled,onChange:x.refetch})}):null,(0,K.jsx)(eE,{notice:Xe,setNotice:Ze,wide:s}),Vt?(0,K.jsx)(vx,{environments:Bt,pair:Vt,loading:Wt.loading||!Gt,error:Wt.error?Wt.error.message:null,changedPages:Gt?.changedPages??0,totalPages:w?.board?.pages?.length||0,changedOnly:Ht,showDiff:Ut,canCapture:y,captureBusy:ut||!!T?.running,touch:!s,onPair:e=>qt(e),onChangedOnly:Xt,onShowDiff:e=>m({diff:e?null:`off`}),onCapture:e=>zr(e),onClose:()=>qt(null)}):null,(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,K.jsxs)(`div`,{ref:Me,tabIndex:-1,className:U(`relative min-w-0 flex-1 outline-none`,Ne&&yn&&`sw-commenting`),onKeyDown:ai,"data-sw-canvas":`true`,children:[q&&Rt.length?(0,K.jsx)(ET,{items:Rt}):null,(0,K.jsx)(ZT,{wide:s,commentMode:Ne,canComment:yn,readyKeys:qn,setCommentMode:Pe,showLinks:q,activePage:cr,shownSteps:dr,data:w,presentPages:ur,hiddenLinkTargets:fr,showAllLinks:lr,targetTitle:On,updateParams:m,tipOpen:bt,tryOpen:St,journey:Mt,builder:gt,viewportNotice:vt,dismissTip:Dt,modes:R,setMode:Yr,comparePair:Vt}),!w&&x.error?(0,K.jsx)(S_,{error:x.error,onRetry:x.refetch}):w?(0,K.jsxs)(qp,{nodes:$t,edges:pr,edgeTypes:Pb,onNodeMouseEnter:q?(e,t)=>ht(t.type===`page`?t.id:null):void 0,onNodeMouseLeave:q?()=>ht(null):void 0,onNodesChange:tn,onNodeClick:fD,nodeTypes:kb,colorMode:f,defaultViewport:je.current||void 0,fitView:Bn.current,style:Vn?void 0:{opacity:0},edgesFocusable:!1,fitViewOptions:hw,minZoom:mw,maxZoom:4,panOnScroll:!1,zoomOnScroll:!1,panActivationKeyCode:null,zoomActivationKeyCode:null,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,zoomOnDoubleClick:!Ne,onMoveEnd:Hr,onPaneClick:()=>{un(),ne&&Ln()},proOptions:{hideAttribution:!0},children:[(0,K.jsx)(lm,{gap:40,size:1}),(0,K.jsx)(uD,{onChecks:se?de:null,onHistory:hr,historyCountFor:e=>F_(w?.versions,e),focusedKey:on,layout:Qt,data:w,liveKeys:Kn,readyKeys:qn,selectingKey:cn,touch:!s,liveFileFor:Yn,onOpenLive:Zn,onToggleSelect:e=>ln(t=>t===e?null:e),onClose:un,onCapture:y&&!Vt?e=>zr(null,[e]):null,captureBusy:ut||!!T?.running}),s&&Fe&&!ni?(0,K.jsx)(LS,{point:_v(Qt.targets,Fe),onClose:()=>ut?null:Ie(null),children:(0,K.jsx)(xx,{...Ir,touch:!1,description:Fr})}):null,s&&Qr&&!Fe&&!ni?(0,K.jsx)(IS,{comment:Tn,point:_v(Qt.targets,Tn),onClose:Ln,onPrev:()=>qr(-1),onNext:()=>qr(1),editingRef:qe,children:(0,K.jsx)(OS,{...Qr,onClose:Ln})}):null,(0,K.jsx)(iD,{wide:s,clearFocus:un,setSettledZoom:an,minimapOn:it,liveKeys:Kn,toggleMinimap:ti,hideFit:!!(Mt||gt),hideMinimap:!!(Mt||gt),fitBoard:dn})]}):(0,K.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted`,children:[(0,K.jsx)(fe,{}),` Loading board`]}),n?.hosted&&!Ce?(0,K.jsx)(jC,{touch:!s,enabled:!!w&&!a,boardId:e,canvasRef:Me,flow:u,selection:ne,mode:B,onMode:e=>m({vp:e}),onInvalidate:()=>{C.refetch(),x.refetch()}}):null,St&&w&&!Mt&&!gt&&(!Ne||s)?(0,K.jsx)(aw,{touch:!s,done:wt,onOpenComment:()=>{let e=mn.filter(e=>e.status===`open`),t=e.find(e=>B===`all`||e.viewport===B)||e[0]||mn[0];t&&Rn(t)},onComment:yn&&!Vt?()=>{Ie(null),Pe(!0)}:null,onAgent:be?ke:null,onClose:Ot}):null,(0,K.jsx)($T,{toast:$e,setToast:et,onHold:tt,wide:s,raised:!!(Mt||gt)}),Vt&&Ht&&Gt&&!Zt.length?(0,K.jsx)(`p`,{className:`absolute inset-x-0 top-1/3 mx-auto w-max max-w-[90%] rounded-lg bg-surface px-4 py-3 text-sm text-muted shadow-pop`,children:`No visual changes between these two environments.`}):null,gt?(0,K.jsx)(px,{draft:gt,pages:w?.board?.pages||[],onChange:_t,onSave:ir,onCancel:()=>_t(null),pageTitle:e=>Dn(e)?.title||e,busy:ut,touch:!s}):Mt?(0,K.jsx)(fx,{journey:Mt,route:Nt,step:It,pageTitle:e=>Dn(e)?.title||e,onStep:er,onChoose:tr,onClose:$n,onEdit:()=>nr(Mt),onDelete:ar,canEdit:v&&Mt.source===`board`,busy:ut,touch:!s},Mt.id):null]}),(0,K.jsx)(rE,{wide:s,checksOpen:ce,checksProps:ri,chatThread:xe,chatProps:$r,panelHidden:oe,panelProps:Zr,updateParams:m})]})]})]}),(0,K.jsx)(cC,{ref:Ae})]}),s?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(uE,{checksOpen:ce,closeChecks:W,checksProps:ri,chatAvailable:be,chatThread:xe,chatProps:$r,updateParams:m,sheetOpen:Le,setSheetOpen:Re,panelProps:Zr,threadSheet:ze,threadProps:Qr,closeThread:Ln,selectedComment:Tn,targetTitle:On,draft:Fe,busy:ut,setDraft:Ie,draftDescription:Fr,composerProps:Ir}),(0,K.jsx)(XT,{...si,menuOpen:Je})]}),(0,K.jsx)(yE,{info:n,boardId:e,boards:t,wide:s,shareOpen:h,setShareOpen:g,refetchView:jn,settingsAvailable:Se,settingsOpen:Ee,updateParams:m,onInfoChanged:i,generalSettingsOpen:Te,updates:Ae,historyPage:gr,closeHistory:vr,historyViewport:_r,historyPageId:kt,data:w,comments:D,filter:te,focusComment:Rn,onImageError:Pn,captureConfirm:Lr,setCaptureConfirm:Rr,busy:ut,focusedPage:sr,findPage:Dn,startCapture:zr}),(0,K.jsx)(Yw,{open:at,onOpenChange:ot,groups:br,journeys:jt,canEditJourneys:v,comments:D,titleOf:On,actions:oi,onPage:e=>{Wn(),yr(e)},onJourney:e=>{Wn(),Qn(e)},onNewJourney:()=>{Wn(),nr()},onComment:e=>{Wn(),Rn(e)},onCloseAutoFocus:Gn})]})}function gD({board:e,view:t,people:n,children:r}){return(0,K.jsx)(Y_.Provider,{value:e,children:(0,K.jsx)(rb.Provider,{value:t,children:(0,K.jsx)(Fy.Provider,{value:n,children:r})})})}function _D(){let[e,t]=(0,G.useState)(``),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(``);(0,G.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await Je.get(`/api/pairing`);if(!e)return;i(t),(t.pairing.state===`approved`||[`host`,`device`,`identity`].includes(t.access))&&window.location.reload()}catch(t){e&&o(t.message)}};t();let n=setInterval(t,2e3);return()=>{e=!1,clearInterval(n)}},[]);let s=async t=>{t.preventDefault(),o(``);try{let t=await Je.post(`/api/pairing`,{name:e});i(e=>({...e,pairing:t}))}catch(e){o(e.message)}},c=r?.pairing,l=c?.code,u=/iPad|iPhone|iPod/.test(navigator.userAgent),d=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone;return(0,K.jsxs)(`main`,{className:`mx-auto flex min-h-dvh max-w-lg flex-col justify-center gap-5 p-6`,"data-sw-pairing":!0,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:`Shapewall`}),(0,K.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:`Pair this device`})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`This board belongs to the person running Shapewall. Match the code and approve this device on that computer.`}),c?.state===`pending`?(0,K.jsxs)(`section`,{className:`space-y-3 rounded-lg border border-line p-4`,"aria-live":`polite`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-fg`,children:[`Waiting for approval: `,c.name]}),(0,K.jsxs)(`p`,{className:`font-mono text-3xl tracking-widest text-fg`,"data-sw-pairing-code":!0,children:[l.slice(0,4),`-`,l.slice(4)]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Expires in five minutes. On the host, open Devices or run `,(0,K.jsxs)(`code`,{children:[`shapewall devices approve `,l]}),`.`]})]}):(0,K.jsxs)(`form`,{className:`space-y-3`,onSubmit:s,children:[[`denied`,`expired`].includes(c?.state)?(0,K.jsxs)(`p`,{className:`text-sm text-warn`,role:`status`,children:[c.state===`denied`?`The host denied this request.`:`This request expired.`,` You can request again.`]}):null,(0,K.jsx)(`label`,{htmlFor:`device-name`,className:`block text-sm text-fg`,children:`Device name`}),(0,K.jsx)(qe,{id:`device-name`,required:!0,maxLength:80,placeholder:`My phone`,value:e,onChange:e=>t(e.target.value)}),(0,K.jsx)(n,{type:`submit`,children:`Request pairing`})]}),a?(0,K.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:a}):null,r?.secure?null:(0,K.jsx)(`p`,{className:`rounded-lg border border-warn/30 p-3 text-xs text-warn`,children:`Plain HTTP on Wi-Fi exposes your device cookie to sniffing and replay. Use Tailscale for private HTTPS, or configure a TLS certificate. Without HTTPS this board installs only as a bookmark.`}),u&&!d?(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Installing on your iPhone? Add the board to your Home Screen first, then pair from inside that app. Its cookies are separate from Safari.`}):null]})}function vD({info:e}){let[t,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(``),c=e?.remote,l=!!c?.manage;(0,G.useEffect)(()=>{if(!l)return;let e=!0,t=async()=>{try{let t=await Je.get(`/api/devices`);e&&a(t)}catch(t){e&&s(t.message)}};t();let n=setInterval(t,4e3);return()=>{e=!1,clearInterval(n)}},[l]);let u=async(e,t)=>{try{await Je[e](t),l?a(await Je.get(`/api/devices`)):window.location.reload()}catch(e){s(e.message)}};if(!c||!l&&!c.device)return null;let d=i?.pending||[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed bottom-3 left-3 z-30 rounded-lg border border-line bg-surface p-1 shadow-lg lg:bottom-16 lg:left-[64px]`,children:(0,K.jsx)(n,{size:`sm`,variant:`ghost`,onClick:()=>r(!0),"data-sw-devices-open":!0,children:l?`Devices${d.length?` (${d.length} waiting)`:``}`:c.device.name})}),(0,K.jsx)(M,{open:t,onClose:()=>r(!1),title:l?`Your devices`:`This device`,children:(0,K.jsxs)(`div`,{className:`max-h-[70dvh] space-y-4 overflow-auto p-5`,"data-sw-devices":!0,children:[o?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-bad`,children:o}):null,l?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`Approve only your own devices, after matching the code shown on them. Paired devices can comment, capture and drive your connected agent.`}),d.map(e=>(0,K.jsxs)(`section`,{className:`space-y-2 rounded border border-line p-3`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,K.jsxs)(`p`,{className:`break-all text-xs text-muted`,children:[e.browser,` · `,e.ip]}),(0,K.jsxs)(`p`,{className:`font-mono text-lg text-fg`,children:[e.code.slice(0,4),`-`,e.code.slice(4)]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(n,{size:`sm`,onClick:()=>u(`post`,`/api/devices/${e.code}/approve`),children:`Approve`}),(0,K.jsx)(n,{size:`sm`,variant:`secondary`,onClick:()=>u(`post`,`/api/devices/${e.code}/deny`),children:`Deny`})]})]},e.id)),(i?.devices||[]).map(e=>(0,K.jsxs)(`section`,{className:`flex items-center justify-between gap-2 rounded border border-line p-3`,children:[(0,K.jsxs)(`p`,{className:`min-w-0 break-words text-sm text-fg`,children:[e.name,(0,K.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Last seen `,new Date(e.lastSeenAt).toLocaleDateString()]})]}),(0,K.jsx)(n,{size:`sm`,variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${e.id}`),children:`Revoke`})]},e.id)),!d.length&&!i?.devices?.length?(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`No paired devices or requests yet.`}):null]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Paired as `,c.device.name,`. Settings and other devices are managed on the host computer.`]}),(0,K.jsx)(n,{variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${c.device.id}`),children:`Revoke this device`})]})]})})]})}var yD=(0,G.lazy)(()=>iC(()=>import(`./BuzzDialog-CZdwIQLF.js`),__vite__mapDeps([11,1]),import.meta.url)),bD=!Ce&&typeof document<`u`&&!!document.querySelector(`meta[name="shapewall-remote"]`);function xD(){let[e,t]=(0,G.useState)(!1),[r,i]=(0,G.useState)(!1),a=_e(r);(0,G.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`shapewall:pairing-required`,e),()=>window.removeEventListener(`shapewall:pairing-required`,e)},[]);let o=Qe(bD?`/api/pairing`:null),s=!bD||[`host`,`device`,`identity`].includes(o.data?.access),c=Qe(s?`/api/info`:null),l=E(),u=Qe(s?`/api/boards`:null),[d,f]=Ke(),p=Array.isArray(u.data?.boards)?u.data.boards:[],m=d.get(`board`),h=p.find(e=>e.id===m)||p[0];he(c.data?.fixturesAt);let g=Ce?l?.shareProblem:null;SD(g?`Share link`:h?.title);let _=Ce&&d.has(`share`);return(0,G.useEffect)(()=>{_&&f({share:null})},[_,f]),bD&&!o.loading&&!s||e||c.error?.code===`pairing_required`||u.error?.code===`pairing_required`?(0,K.jsx)(_D,{}):g?(0,K.jsx)(mC,{problem:g,onLeave:l.leaveShare}):u.loading||c.loading?(0,K.jsx)(y_,{}):u.error?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(S_,{error:u.error,onRetry:()=>Promise.all([u.refetch(),c.error?c.refetch():null]),extra:Ce?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{asChild:!0,size:`touch`,variant:`secondary`,className:`lg:h-10`,children:(0,K.jsx)(`a`,{href:`console.html#/signin`,children:`Sign in to the demo`})}),(0,K.jsx)(n,{size:`touch`,variant:`ghost`,className:`lg:h-10`,onClick:()=>l?.reset(),children:`Reset the demo`})]}):null}),Ce?(0,K.jsx)(fC,{}):null]}):h?(0,K.jsxs)(L,{children:[(0,K.jsx)(vD,{info:c.data}),c.data?.buzzAvailable===!0&&a?(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(yD,{open:r,onClose:()=>i(!1),boardId:h.id},h.id)}):null,(0,K.jsx)(Up,{children:(0,K.jsx)(hD,{boardId:h.id,boards:p,info:c.data,onInfoChanged:c.refetch,onOpenBuzz:()=>i(!0),onPickBoard:e=>f({board:e,c:null,v:null})})},h.id)]}):(0,K.jsx)(`div`,{className:`flex h-full bg-sunken`,children:(0,K.jsx)(D,{size:`lg`,icon:Lh,title:`No boards yet`,children:c.data?.hosted?(0,K.jsxs)(K.Fragment,{children:[`Capture your site locally, then run `,(0,K.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall push`}),` with a project token.`]}):(0,K.jsxs)(K.Fragment,{children:[`Add pages to `,(0,K.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall.config.json`}),`, then run`,` `,(0,K.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall capture`}),`.`]})})})}function SD(e){(0,G.useEffect)(()=>{if(!Ce||!e)return;let t=String(e).replace(/\s*\(demo\)$/i,``);document.title=t===`Share link`?`Share link · Shapewall demo`:`${t} board · Shapewall demo`},[e])}function CD(){typeof navigator<`u`&&`serviceWorker`in navigator&&window.isSecureContext&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`./sw.js`,{scope:`./`}).catch(()=>{})})}var wD=900;function TD(){try{let e=document.createElement(`div`);e.style.cssText=`position:absolute;top:-999px;width:100px;height:100px;overflow:scroll;visibility:hidden`,document.documentElement.appendChild(e);let t=e.offsetWidth-e.clientWidth>0;return e.remove(),t}catch{return!1}}function ED(){let e=new WeakMap;document.addEventListener(`scroll`,t=>{let n=t.target===document?document.documentElement:t.target;n instanceof Element&&(n.hasAttribute(`data-scrolling`)||n.setAttribute(`data-scrolling`,``),clearTimeout(e.get(n)),e.set(n,setTimeout(()=>n.removeAttribute(`data-scrolling`),wD)))},{capture:!0,passive:!0})}typeof document<`u`&&TD()&&(document.documentElement.classList.add(`sw-scrollbars`),ED()),document.querySelector(`meta[name="shapewall-agent-settings"]`)?iC(async()=>{let{default:e}=await import(`./Management-DOJkFY_o.js`);return{default:e}},__vite__mapDeps([12,7,1,5,2]),import.meta.url).then(({default:e})=>(0,at.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(e,{}))):((0,at.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(xD,{})})),CD());export{zh as $,Sx as A,Gg as B,Ix as C,Rx as D,Nx as E,l_ as F,Dg as G,Lg as H,s_ as I,ag as J,Tg as K,a_ as L,Jb as M,P_ as N,zx as O,p_ as P,Gh as Q,$g as R,Lx as S,Fx as T,Ng as U,zg as V,kg as W,Yh as X,rg as Y,qh as Z,eS as _,ZS as a,dh as at,Gx as b,hS as c,th as ct,oS as d,Vm as dt,Fh as et,aS as f,Qx as g,Xx as h,$C as i,_h as it,ex as j,Vx as k,iS as l,Zm as lt,$x as m,RC as n,jh as nt,QS as o,lh as ot,vS as p,xg as q,zC as r,xh as rt,gS as s,ah as st,pw as t,Nh as tt,yS as u,Ym as ut,Yx as v,Px as w,qx as x,tS as y,Yg as z};