shapewall 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/README.md +5 -2
- package/bin/shapewall.js +2 -1
- package/dist/agent/package-lock.json +2 -2
- package/dist/client/assets/BoardChat-BawjlTc7.js +27 -0
- package/dist/client/assets/ChecksPanel-DRFcFhCj.js +1 -0
- package/dist/client/assets/{History-C_NAxaRl.js → History-FzpzGmXZ.js} +1 -1
- package/dist/client/assets/{LocalSettings-W5Ze9ks7.js → LocalSettings-BGFl4VKr.js} +1 -1
- package/dist/client/assets/{Management-CXGSi6gI.js → Management-BGdmGtby.js} +1 -1
- package/dist/client/assets/QuickConnect-CiVmxi0l.js +1 -0
- package/dist/client/assets/{app-update-dialog-DNL0kP9U.js → app-update-dialog-BQxVHa5e.js} +1 -1
- package/dist/client/assets/index-B_m65HWT.css +2 -0
- package/dist/client/assets/{index-DTXjDgcg.js → index-C1ZwriJU.js} +19 -19
- package/dist/client/build-info.json +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/sw.js +2 -2
- package/dist/console/assets/{LocalAccountsApp-Z0gEJ74C.js → LocalAccountsApp-ntQzkgTS.js} +1 -1
- package/dist/console/assets/{LocalConsole-DzHNISE9.js → LocalConsole-Rg-MTvSJ.js} +1 -1
- package/dist/console/assets/{app-update-dialog-CQsUPrMX.js → app-update-dialog-CEhV7th4.js} +1 -1
- package/dist/console/assets/app-version-BiMzvHaD.js +1 -0
- package/dist/console/assets/console-BD5_Gha1.js +11 -0
- package/dist/console/assets/console-PWt8SxrJ.css +2 -0
- package/dist/console/assets/local-agents-UprGVyLj.js +6 -0
- package/dist/console/assets/{tailnet-C2QPbIIC.js → tailnet-Cqtbptzq.js} +2 -2
- package/dist/console/assets/{usage-BDt6IQh1.js → usage-BCIwgDP9.js} +2 -2
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +5 -5
- package/docs/README.md +64 -0
- package/docs/agent-hardening.md +3 -3
- package/docs/agent-recipes.md +3 -3
- package/docs/agent-workflow.md +6 -4
- package/docs/agents.md +25 -16
- package/docs/architecture.md +6 -1
- package/docs/config.md +53 -25
- package/docs/deployment.md +2 -2
- package/docs/github.md +1 -1
- package/docs/hosted.md +265 -70
- package/docs/local-accounts.md +1 -1
- package/docs/performance.md +3 -2
- package/docs/pull-requests.md +1 -1
- package/docs/starter-agent.md +4 -4
- package/docs/where-to-run.md +1 -1
- package/package.json +3 -2
- package/src/agent/backends/acp.js +39 -9
- package/src/capture/capture.js +35 -5
- package/src/capture/destination.js +67 -0
- package/src/capture/load-errors.js +82 -0
- package/src/checks/cli.js +41 -5
- package/src/cli/args.js +1 -0
- package/src/cli/capture.js +5 -0
- package/src/cli/comments.js +41 -3
- package/src/cli/help.js +4 -1
- package/src/cli/init.js +8 -4
- package/src/cli/misc.js +3 -3
- package/src/cli/serve.js +34 -6
- package/src/comment-fields.js +5 -0
- package/src/comments-cli.js +26 -5
- package/src/config-keys.js +191 -0
- package/src/config-reload.js +4 -1
- package/src/config.js +33 -2
- package/src/doctor.js +188 -39
- package/src/hosted/auth.js +14 -8
- package/src/hosted/db.js +50 -0
- package/src/hosted/pages.js +5 -1
- package/src/missing-package.js +11 -0
- package/src/ports.js +35 -0
- package/src/serve-state.js +16 -0
- package/src/watch.js +6 -0
- package/dist/client/assets/BoardChat-DG08cvD0.js +0 -27
- package/dist/client/assets/ChecksPanel-BD7GniTp.js +0 -1
- package/dist/client/assets/QuickConnect-Cta4dT3n.js +0 -1
- package/dist/client/assets/index-CBrmVq4n.css +0 -2
- package/dist/console/assets/app-version-CP0o1L1_.js +0 -1
- package/dist/console/assets/console-DIWY1goy.css +0 -2
- package/dist/console/assets/console-DYqhjwPS.js +0 -11
- package/dist/console/assets/local-agents-D7Jd9P7A.js +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app-update-dialog-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app-update-dialog-BQxVHa5e.js","./rolldown-runtime-XKyaHtl9.js","./ui-CogdFhRH.js","./refresh-cw-TbGHlgDq.js","./ChecksPanel-DRFcFhCj.js","./circle-x-Dxsku6s6.js","./play-vJhLsLhL.js","./BoardChat-BawjlTc7.js","./QuickConnect-CiVmxi0l.js","./History-FzpzGmXZ.js","./ShareDialog-D0tmOGcQ.js","./LocalSettings-BGFl4VKr.js","./BuzzDialog-DnjF36OB.js","./Management-BGdmGtby.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{$t as n,A as r,At as i,B as a,Bt as o,C as s,Cn as c,Ct as l,D as u,E as d,En as f,F as p,Ft as m,G as h,Gt as g,H as _,Ht as v,I as y,It as b,J as x,Jt as S,K as C,Kt as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,P as ee,Pt as M,R as N,Rt as P,S as F,Sn as I,T as L,Tn as R,U as z,Ut as te,V as B,Vt as V,W as ne,Wt as H,X as U,Xt as re,Y as ie,Yt as ae,Z as W,Zt as G,_ as oe,_n as se,_t as ce,a as le,an as ue,at as de,b as fe,bn as pe,c as me,cn as he,ct as ge,d as _e,dn as ve,en as ye,f as be,fn as xe,g as Se,gn as Ce,h as we,hn as Te,i as Ee,in as De,it as Oe,j as ke,jt as Ae,k as je,l as K,ln as Me,m as Ne,mn as Pe,mt as Fe,n as Ie,nn as Le,o as Re,on as ze,ot as Be,p as q,pn as Ve,q as He,qt as Ue,r as We,rn as Ge,rt as Ke,s as qe,sn as Je,st as Ye,t as Xe,tn as Ze,tt as Qe,u as $e,un as et,v as tt,vn as nt,vt as rt,w as it,wn as at,x as ot,xn as st,xt as ct,y as lt,yn as ut,z as dt,zt as ft}from"./ui-CogdFhRH.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 pt=t((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}}}})),mt=t(((e,t)=>{t.exports=pt()})),ht=t((e=>{var t=mt(),n=f(),r=R();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 p(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)&&p(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function m(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 h(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 g(e){var t=[null,null],n=m(e);return n===null||_(t,e,n.child,{foundSelf:!1}),t}function _(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)&&_(e,t,n.child,r))return!0;n=n.sibling}return!1}function v(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`),ee=Symbol.for(`react.consumer`),M=Symbol.for(`react.context`),N=Symbol.for(`react.forward_ref`),P=Symbol.for(`react.suspense`),F=Symbol.for(`react.suspense_list`),I=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),z=Symbol.for(`react.activity`),te=Symbol.for(`react.legacy_hidden`),B=Symbol.for(`react.memo_cache_sentinel`),V=Symbol.for(`react.view_transition`),ne=Symbol.for(`react.recoverable`),H=Symbol.iterator;function U(e){return typeof e!=`object`||!e?null:(e=H&&e[H]||e[`@@iterator`],typeof e==`function`?e:null)}var re=Symbol.for(`react.client.reference`);function ie(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===re?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 P:return`Suspense`;case F:return`SuspenseList`;case z:return`Activity`;case V:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case O:return`Portal`;case M:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case N: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?ie(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return ie(e(t))}catch{}}return null}var ae=Array.isArray,W=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},se=[],ce=-1;function le(e){return{current:e}}function ue(e){0>ce||(e.current=se[ce],se[ce]=null,ce--)}function de(e,t){ce++,se[ce]=e.current,e.current=t}var fe=le(null),pe=le(null),me=le(null),he=le(null);function ge(e,t){switch(de(me,t),de(pe,e),de(fe,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}}ue(fe),de(fe,e)}function _e(){ue(fe),ue(pe),ue(me)}function ve(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,de(he,e)),t=fe.current;var n=dp(t,e.type);t!==n&&(de(pe,e),de(fe,n))}function ye(e){pe.current===e&&(ue(fe),ue(pe)),he.current===e&&(ue(he),sh._currentValue=oe)}var be,xe;function Se(e){if(be===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);be=t&&t[1]||``,xe=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+be+e+xe}var Ce=!1;function we(e,t){if(!e||Ce)return``;Ce=!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(`
|
|
@@ -13,25 +13,25 @@ Error generating stack: `+e.message+`
|
|
|
13
13
|
`,`
|
|
14
14
|
+`).split(`
|
|
15
15
|
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,J.useEffect)(()=>{let n=t?.target??Ad,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&il(e))return!1;let n=Nd(e.code,s);if(a.current.add(e[n]),Md(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Nd(e.code,s);Md(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Md(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Nd(e,t){return t.includes(e)?`code`:`key`}var Pd=()=>{let e=rd();return(0,J.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=Wc(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return zc(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Bc(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Fd(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Id(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Id(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function Ld(e,t){return Fd(e,t)}function Rd(e,t){return Fd(e,t)}function zd(e,t){return{id:e,type:`select`,selected:t}}function Bd(e,t=new Set){let n=[];for(let[r,i]of e){let e=t.has(r);(i.selected!==void 0||e)&&i.selected!==e&&n.push(zd(i.id,e))}return n}function Vd({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function Hd(e){return{id:e.id,type:`remove`}}var Ud=Lc(`React Flow`,`https://reactflow.dev/`);function Wd(e,t,n={}){return _l(e,t,{...n,onError:n.onError??Ud})}var Gd=e=>dc(e),Kd=e=>uc(e);function qd(e){return(0,J.forwardRef)(e)}var Jd=typeof window<`u`?J.useLayoutEffect:J.useEffect;function Yd(e){let[t,n]=(0,J.useState)(BigInt(0)),[r]=(0,J.useState)(()=>Xd(()=>n(e=>e+BigInt(1))));return Jd(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Xd(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Zd=(0,J.createContext)(null);function Qd({children:e}){let t=rd(),n=Yd((0,J.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Vd({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=Yd((0,J.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Vd({items:s,lookup:o}))},[])),i=(0,J.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,Y.jsx)(Zd.Provider,{value:i,children:e})}function $d(){let e=(0,J.useContext)(Zd);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var ef=e=>!!e.panZoom;function tf(){let e=Pd(),t=rd(),n=$d(),r=$(ef),i=(0,J.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Gd(e)?e:n.get(e.id),a=i.parentId?Yc(i.position,i.measured,i.parentId,n,r):i.position;return Ac({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height},i.parentId?void 0:r)},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Gd(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Kd(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await xc({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Hd);o?.(f),c(e)}if(m){let e=d.map(Hd);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Fc(e),o=i?e:a(e),s=r!==void 0;if(!o)return[];let{nodeOrigin:c}=t.getState();return(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let l=Ac(s?r:a,c),u=Pc(l,o);return n&&u>0||u>=l.width*l.height||u>=o.width*o.height})},isNodeIntersecting:(e,t,n=!0)=>{let r=Fc(e)?e:a(e);if(!r)return!1;let i=Pc(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return mc(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??Zc();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,J.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var nf=e=>e.selected,rf=typeof window<`u`?window:void 0;function af({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=rd(),{deleteElements:r}=tf(),i=jd(e,{actInsideInputWithModifier:!1}),a=jd(t,{target:rf});(0,J.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(nf),edges:e.filter(nf)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,J.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function of(e){let t=rd();(0,J.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=tl(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,$s.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t.disconnect()}}},[])}var sf={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},cf=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function lf({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=ic.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=rd(),C=(0,J.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=$(cf,Qu),D=jd(p),O=(0,J.useRef)();of(C);let k=(0,J.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,J.useEffect)(()=>{if(C.current){O.current=Du({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,J.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,c,D,m,_,w,g,T,k,E,x,b]),(0,Y.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:sf,children:h})}var uf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function df(){let{userSelectionActive:e,userSelectionRect:t}=$(uf,Qu);return e&&t?(0,Y.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var ff=(e,t)=>n=>{n.target===t.current&&e?.(n)},pf=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function mf({isSelecting:e,selectionKeyPressed:t,selectionMode:n=ac.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,J.useRef)(0),_=rd(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=$(pf,Qu),C=y&&(e||v),w=(0,J.useRef)(null),T=(0,J.useRef)(),E=(0,J.useRef)(new Set),D=(0,J.useRef)(new Set),O=(0,J.useRef)(!1),k=(0,J.useRef)(!1),A=(0,J.useRef)({x:0,y:0}),j=(0,J.useRef)(!1),ee=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}let{connectionClickStartHandle:t,connection:n,onClickConnectEnd:r,resetSelectedElements:i}=_.getState();if(t){let t=structuredClone(n);delete t.inProgress,t.toPosition=t.toHandle?t.toHandle.position:null,r?.(e.nativeEvent,t),_.setState({connectionClickStartHandle:null})}l?.(e),i(),_.setState({nodesSelectionActive:!1})},M=e=>{Array.isArray(r)&&r?.includes(2)?e.preventDefault():u?.(e)},N=d?e=>d(e):void 0,P=e=>{k.current&&=(e.stopPropagation(),!1)},F=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=_.getState();if(T.current=i?.getBoundingClientRect(),!T.current)return;let s=n.target===w.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:c,y:l}=ol(n.nativeEvent,T.current),u=zc({x:c,y:l},a);_.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function I(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Bc(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(gc(a,m,i,n===ac.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}Xc(h,E.current)||c(Bd(a,E.current)),Xc(g,D.current)||l(Bd(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!i||!T.current)return;let[e,t]=Ec(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(L);return}let{x:t,y:n}=A.current;I(t,n),g.current=requestAnimationFrame(L)})}let R=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,J.useEffect)(()=>()=>R(),[]);let z=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=ol(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Bc({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(L(),!0),I(o,c)},te=e=>{C?e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&ee?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),R()):e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0)},B=e=>{e.target?.releasePointerCapture?.(e.pointerId),R()},V=r===!0||Array.isArray(r)&&r.includes(0);return(0,Y.jsxs)(`div`,{className:vt([`react-flow__pane`,{draggable:V,dragging:b,selection:e}]),onClick:C?void 0:ff(ee,w),onContextMenu:ff(M,w),onWheel:ff(N,w),onPointerEnter:C?void 0:f,onPointerMove:C?z:p,onPointerUp:te,onPointerCancel:C?B:void 0,onPointerDownCapture:C?F:void 0,onClickCapture:C?P:void 0,onPointerLeave:m,ref:w,style:sf,children:[h,(0,Y.jsx)(df,{})]})}function hf({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);l?(t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])):c?.(`012`,$s.error012(e))}function gf({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=rd(),[c,l]=(0,J.useState)(!1),u=(0,J.useRef)();return(0,J.useEffect)(()=>{if(!t)return u.current=nu({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{hf({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,J.useEffect)(()=>{!t&&e.current&&u.current&&u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var _f=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function vf(){let e=rd();return(0,J.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=_f(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=Rc(t,i));let{position:a,positionAbsolute:s}=bc({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var yf=(0,J.createContext)(null),bf=yf.Provider;yf.Consumer;var xf=()=>(0,J.useContext)(yf),Sf=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Cf=(0,J.createContext)(null);function wf({children:e}){let t=$(Sf,Qu);return(0,Y.jsx)(Cf.Provider,{value:t,children:e})}function Tf(){let e=(0,J.useContext)(Cf);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Ef={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Df=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Ef;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===rc.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Of({type:e=`source`,position:t=Q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=rd(),_=xf(),{connectOnClick:v,noPanClassName:y,rfId:b}=Tf(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=$(Df(_,m,e),Qu);_||g.getState().onError?.(`010`,$s.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(Wd(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=al(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();fu.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,Y.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:vt([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=nl(t.target),h=n||c,{connection:v,isValid:y}=fu.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var kf=(0,J.memo)(qd(Of));function Af({data:e,isConnectable:t,sourcePosition:n=Q.Bottom}){return(0,Y.jsxs)(Y.Fragment,{children:[e?.label,(0,Y.jsx)(kf,{type:`source`,position:n,isConnectable:t})]})}function jf({data:e,isConnectable:t,targetPosition:n=Q.Top,sourcePosition:r=Q.Bottom}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(kf,{type:`target`,position:n,isConnectable:t}),e?.label,(0,Y.jsx)(kf,{type:`source`,position:r,isConnectable:t})]})}function Mf(){return null}function Nf({data:e,isConnectable:t,targetPosition:n=Q.Top}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(kf,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Pf={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ff={input:Af,default:jf,output:Nf,group:Mf};function If(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Lf=e=>{let{width:t,height:n,x:r,y:i}=hc(e.nodeLookup,{filter:e=>!!e.selected});return{width:Ic(t)?t:null,height:Ic(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Rf({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=rd(),{width:i,height:a,transformString:o,userSelectionActive:s}=$(Lf,Qu),c=vf(),l=(0,J.useRef)(null);(0,J.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(gf({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,Y.jsx)(`div`,{className:vt([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,Y.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Pf,e.key)&&(e.preventDefault(),c({direction:Pf[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var zf=typeof window<`u`?window:void 0,Bf=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Vf({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:ee,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:P,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=$(Bf,Qu),R=jd(l,{target:zf}),z=jd(h,{target:zf}),te=z||w,B=z||b,V=u&&te!==!0,ne=R||L||V;return af({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,Y.jsx)(lf,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:B,panActivationKeyPressed:z,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&te,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:ee,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:V,children:(0,Y.jsxs)(mf,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:te,autoPanOnSelection:T,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:V,children:[e,I&&(0,Y.jsx)(Rf,{onSelectionContextMenu:j,noPanClassName:M,disableKeyboardA11y:N})]})})}Vf.displayName=`FlowRenderer`;var Hf=(0,J.memo)(Vf),Uf=e=>t=>e?gc(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Wf(e){return $((0,J.useCallback)(Uf(e),[e]),Qu)}var Gf=e=>e.updateNodeInternals;function Kf(){let e=$(Gf),[t]=(0,J.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,J.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function qf({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=rd(),a=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useRef)(e.sourcePosition),c=(0,J.useRef)(e.targetPosition),l=(0,J.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,J.useEffect)(()=>{!a.current||e.hidden||u&&o.current===a.current||(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,J.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,J.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Jf({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=$(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},Qu),S=y.type||`default`,C=g?.[S]||Ff[S];C===void 0&&(v?.(`003`,$s.error003(S)),S=`default`,C=g?.default||Ff.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=rd(),k=Jc(y),A=qf({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=gf({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),ee=vf();if(y.hidden)return null;let M=qc(y),N=If(y),P=T||w||t||n||r||i,F=n?e=>n(e,{...b.userNode}):void 0,I=r?e=>r(e,{...b.userNode}):void 0,L=i?e=>i(e,{...b.userNode}):void 0,R=a?e=>a(e,{...b.userNode}):void 0,z=o?e=>o(e,{...b.userNode}):void 0,te=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&hf({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},B=t=>{if(!(il(t.nativeEvent)||m)){if(tc.includes(t.key)&&T){let n=t.key===`Escape`;hf({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Pf,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),ee({direction:Pf[t.key],factor:t.shiftKey?4:1})}}},V=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(gc(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+M.width/2,y.position.y+M.height/2,{zoom:t[2]}))};return(0,Y.jsx)(`div`,{className:vt([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:P?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...N},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:F,onMouseMove:I,onMouseLeave:L,onContextMenu:R,onClick:te,onDoubleClick:z,onKeyDown:D?B:void 0,tabIndex:D?0:void 0,onFocus:D?V:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${od}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,Y.jsx)(bf,{value:e,children:(0,Y.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...M})})})}var Yf=(0,J.memo)(Jf),Xf=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Zf(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=$(Xf,Qu),a=Wf(e.onlyRenderVisibleElements),o=Kf();return(0,Y.jsx)(`div`,{className:`react-flow__nodes`,style:sf,children:a.map(a=>(0,Y.jsx)(Yf,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Zf.displayName=`NodeRenderer`;var Qf=(0,J.memo)(Zf);function $f(e){return $((0,J.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&ml({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),Qu)}var ep=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,Y.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},tp=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,Y.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},np={[cc.Arrow]:ep,[cc.ArrowClosed]:tp};function rp(e){let t=rd();return(0,J.useMemo)(()=>Object.prototype.hasOwnProperty.call(np,e)?np[e]:(t.getState().onError?.(`009`,$s.error009(e)),null),[e])}var ip=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=rp(t);return c?(0,Y.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,Y.jsx)(c,{color:n,strokeWidth:o})}):null},ap=({defaultColor:e,rfId:t})=>{let n=$(e=>e.edges),r=$(e=>e.defaultEdgeOptions),i=(0,J.useMemo)(()=>Ml(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,Y.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,Y.jsx)(`defs`,{children:i.map(e=>(0,Y.jsx)(ip,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};ap.displayName=`MarkerDefinitions`;var op=(0,J.memo)(ap);function sp({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,J.useState)({x:1,y:0,width:0,height:0}),p=vt([`react-flow__edge-textwrapper`,l]),m=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,Y.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,Y.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,Y.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}sp.displayName=`EdgeText`;var cp=(0,J.memo)(sp);function lp({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`path`,{...u,d:e,fill:`none`,className:vt([`react-flow__edge-path`,u.className])}),l?(0,Y.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Ic(t)&&Ic(n)?(0,Y.jsx)(cp,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function up({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Q.Left||e===Q.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function dp({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top}){let[o,s]=up({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=up({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=cl({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function fp(e){return(0,J.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=dp({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,Y.jsx)(lp,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var pp=fp({isInternal:!1}),mp=fp({isInternal:!0});pp.displayName=`SimpleBezierEdge`,mp.displayName=`SimpleBezierEdgeInternal`;function hp(e){return(0,J.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Q.Bottom,targetPosition:m=Q.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Tl({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,Y.jsx)(lp,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var gp=hp({isInternal:!1}),_p=hp({isInternal:!0});gp.displayName=`SmoothStepEdge`,_p.displayName=`SmoothStepEdgeInternal`;function vp(e){return(0,J.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,Y.jsx)(gp,{...n,id:r,pathOptions:(0,J.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var yp=vp({isInternal:!1}),bp=vp({isInternal:!0});yp.displayName=`StepEdge`,bp.displayName=`StepEdgeInternal`;function xp(e){return(0,J.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=vl({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,Y.jsx)(lp,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var Sp=xp({isInternal:!1}),Cp=xp({isInternal:!0});Sp.displayName=`StraightEdge`,Cp.displayName=`StraightEdgeInternal`;function wp(e){return(0,J.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Q.Bottom,targetPosition:s=Q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=dl({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,Y.jsx)(lp,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var Tp=wp({isInternal:!1}),Ep=wp({isInternal:!0});Tp.displayName=`BezierEdge`,Ep.displayName=`BezierEdgeInternal`;var Dp={default:Ep,straight:Cp,step:bp,smoothstep:_p,simplebezier:mp},Op={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},kp=(e,t,n)=>n===Q.Left?e-t:n===Q.Right?e+t:e,Ap=(e,t,n)=>n===Q.Top?e-t:n===Q.Bottom?e+t:e,jp=`react-flow__edgeupdater`;function Mp({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,Y.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:vt([jp,`${jp}-${s}`]),cx:kp(t,r,e),cy:Ap(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Np({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=rd(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;fu.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(e===!0||e===`source`)&&(0,Y.jsx)(Mp,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,Y.jsx)(Mp,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Pp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=$(t=>t.edgeLookup.get(e)),b=$(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||Dp[x];S===void 0&&(_?.(`011`,$s.error011(x)),x=`default`,S=h?.default||Dp.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,J.useRef)(null),[D,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)(!1),j=rd(),{zIndex:ee=y.zIndex,sourceX:M,sourceY:N,targetX:P,targetY:F,sourcePosition:I,targetPosition:L}=$((0,J.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return Op;let i=Dl({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=pl({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||Op,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),Qu),R=(0,J.useMemo)(()=>y.markerStart?`url('#${jl(y.markerStart,m)}')`:void 0,[y.markerStart,m]),z=(0,J.useMemo)(()=>y.markerEnd?`url('#${jl(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||M===null||N===null||P===null||F===null)return null;let te=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},B=a?e=>{a(e,{...y})}:void 0,V=o?e=>{o(e,{...y})}:void 0,ne=s?e=>{s(e,{...y})}:void 0,H=c?e=>{c(e,{...y})}:void 0,U=l?e=>{l(e,{...y})}:void 0;return(0,Y.jsx)(`svg`,{style:{zIndex:ee},children:(0,Y.jsxs)(`g`,{className:vt([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:te,onDoubleClick:B,onContextMenu:V,onMouseEnter:ne,onMouseMove:H,onMouseLeave:U,onKeyDown:C?t=>{if(!v&&tc.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${sd}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,Y.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:M,sourceY:N,targetX:P,targetY:F,sourcePosition:I,targetPosition:L,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:R,markerEnd:z,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,Y.jsx)(Np,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:M,sourceY:N,targetX:P,targetY:F,sourcePosition:I,targetPosition:L,setUpdateHover:O,setReconnecting:A})]})})}var Fp=(0,J.memo)(Pp),Ip=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Lp({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=$(Ip,Qu),b=$f(t);return(0,Y.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,Y.jsx)(op,{defaultColor:e,rfId:n}),b.map(e=>(0,Y.jsx)(Fp,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Lp.displayName=`EdgeRenderer`;var Rp=(0,J.memo)(Lp),zp=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Bp({children:e}){let t=rd(),n=(0,J.useRef)(null),[r]=(0,J.useState)(()=>t.getState().transform);return Jd(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=zp(r)))};return r(),t.subscribe(r)},[t]),(0,Y.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:zp(r)},children:e})}function Vp(e){let t=tf(),n=(0,J.useRef)(!1);(0,J.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Hp=e=>e.panZoom?.syncViewport;function Up(e){let t=$(Hp),n=rd();return(0,J.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Wp(e){return e.connection.inProgress?{...e.connection,to:zc(e.connection.to,e.transform)}:{...e.connection}}function Gp(e){return e?t=>e(Wp(t)):Wp}function Kp(e){return $(Gp(e),Qu)}var qp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Jp({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=$(qp,Qu);return a&&i&&c?(0,Y.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,Y.jsx)(`g`,{className:vt([`react-flow__connection`,$c(s)]),children:(0,Y.jsx)(Yp,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var Yp=({style:e,type:t=sc.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Kp();if(!i)return;if(n)return(0,Y.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:$c(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case sc.Bezier:[m]=dl(h);break;case sc.SimpleBezier:[m]=dp(h);break;case sc.Step:[m]=Tl({...h,borderRadius:0});break;case sc.SmoothStep:[m]=Tl(h);break;default:[m]=vl(h)}return(0,Y.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};Yp.displayName=`ConnectionLine`;var Xp={};function Zp(e=Xp){(0,J.useRef)(e),rd(),(0,J.useEffect)(()=>{},[e])}function Qp(){rd(),(0,J.useRef)(!1),(0,J.useEffect)(()=>{},[])}function $p({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:ee,zoomOnScroll:M,zoomOnPinch:N,panOnScroll:P,panOnScrollSpeed:F,panOnScrollMode:I,zoomOnDoubleClick:L,panOnDrag:R,autoPanOnSelection:z,onPaneClick:te,onPaneMouseEnter:B,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneScroll:H,onPaneContextMenu:U,paneClickDistance:re,nodeClickDistance:ie,onEdgeContextMenu:ae,onEdgeMouseEnter:W,onEdgeMouseMove:G,onEdgeMouseLeave:oe,reconnectRadius:se,onReconnect:ce,onReconnectStart:le,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,nodeExtent:he,rfId:ge,viewport:_e,onViewportChange:ve,nodesDraggable:ye}){return Zp(e),Zp(t),Qp(),Vp(n),Up(_e),(0,Y.jsx)(Hf,{onPaneClick:te,onPaneMouseEnter:B,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneContextMenu:U,onPaneScroll:H,paneClickDistance:re,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:M,zoomOnPinch:N,zoomOnDoubleClick:L,panOnScroll:P,panOnScrollSpeed:F,panOnScrollMode:I,panOnDrag:R,autoPanOnSelection:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,onViewportChange:ve,isControlledViewport:!!_e,children:(0,Y.jsxs)(Bp,{children:[(0,Y.jsx)(Rp,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ce,onReconnectStart:le,onReconnectEnd:ue,onlyRenderVisibleElements:T,onEdgeContextMenu:ae,onEdgeMouseEnter:W,onEdgeMouseMove:G,onEdgeMouseLeave:oe,reconnectRadius:se,defaultMarkerColor:ee,noPanClassName:pe,disableKeyboardA11y:me,rfId:ge}),(0,Y.jsx)(Jp,{style:h,type:m,component:g,containerStyle:_}),(0,Y.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,Y.jsx)(Qf,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ie,onlyRenderVisibleElements:T,noPanClassName:pe,noDragClassName:de,disableKeyboardA11y:me,nodeExtent:he,rfId:ge,nodesDraggable:ye}),(0,Y.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}$p.displayName=`GraphView`;var em=(0,J.memo)($p),tm=Lc(`React Flow`,`https://reactflow.dev/`),nm=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??ec;Xl(h,g,_);let{nodesInitialized:x}=Vl(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=Wc(hc(p,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:ec,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:rc.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...oc},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:tm,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:nc,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},rm=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Zu((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await yc({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...nm({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=Vl(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();Xl(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=ql(e,n,r,i,a,o,l);d&&(Rl(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=kl(e,o.fromHandle,Q.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=Kl(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Ld(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(Rd(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?i(e.map(e=>zd(e,!0))):(i(Bd(r,new Set([...e]))),a(Bd(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?a(e.map(e=>zd(e,!0))):(a(Bd(n,new Set([...e]))),i(Bd(r,new Set)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s)e.selected&&l.push(zd(e.id,!1));let u=[];for(let e of c)e.selected&&u.push(zd(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,zd(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,zd(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(Vl(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return Jl({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...oc}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...nm()})}},Object.is);function im({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,J.useState)(()=>rm({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,Y.jsx)(td,{value:m,children:(0,Y.jsx)(Qd,{children:(0,Y.jsx)(wf,{children:p})})})}function am({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,J.useContext)(ed)?(0,Y.jsx)(Y.Fragment,{children:e}):(0,Y.jsx)(im,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var om={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function sm({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:ee,onSelectionContextMenu:M,onSelectionStart:N,onSelectionEnd:P,onBeforeDelete:F,connectionMode:I,connectionLineType:L=sc.Bezier,connectionLineStyle:R,connectionLineComponent:z,connectionLineContainerStyle:te,deleteKeyCode:B=`Backspace`,selectionKeyCode:V=`Shift`,selectionOnDrag:ne=!1,selectionMode:H=ac.Full,panActivationKeyCode:U=`Space`,multiSelectionKeyCode:re=Gc()?`Meta`:`Control`,zoomActivationKeyCode:ie=Gc()?`Meta`:`Control`,snapToGrid:ae,snapGrid:W,onlyRenderVisibleElements:G=!1,selectNodesOnDrag:oe,nodesDraggable:se,autoPanOnNodeFocus:ce,nodesConnectable:le,nodesFocusable:ue,nodeOrigin:de=Sd,edgesFocusable:fe,edgesReconnectable:pe,elementsSelectable:me=!0,defaultViewport:he=Cd,minZoom:ge=.5,maxZoom:_e=2,translateExtent:ve=ec,preventScrolling:ye=!0,nodeExtent:be,defaultMarkerColor:xe=`#b1b1b7`,zoomOnScroll:Se=!0,zoomOnPinch:Ce=!0,panOnScroll:we=!1,panOnScrollSpeed:Te=.5,panOnScrollMode:Ee=ic.Free,zoomOnDoubleClick:De=!0,panOnDrag:Oe=!0,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:K,onPaneScroll:Me,onPaneContextMenu:Ne,paneClickDistance:Pe=1,nodeClickDistance:Fe=0,children:Ie,onReconnect:Le,onReconnectStart:Re,onReconnectEnd:ze,onEdgeContextMenu:Be,onEdgeDoubleClick:q,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We=10,onNodesChange:Ge,onEdgesChange:Ke,noDragClassName:qe=`nodrag`,noWheelClassName:Je=`nowheel`,noPanClassName:Ye=`nopan`,fitView:Xe,fitViewOptions:Ze,connectOnClick:Qe,attributionPosition:$e,proOptions:et,defaultEdgeOptions:tt,elevateNodesOnSelect:nt=!0,elevateEdgesOnSelect:rt=!1,disableKeyboardA11y:it=!1,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanOnSelection:st=!0,autoPanSpeed:ct,connectionRadius:lt,isValidConnection:ut,onError:dt,style:ft,id:pt,nodeDragThreshold:mt,connectionDragThreshold:ht,viewport:gt,onViewportChange:_t,width:yt,height:bt,colorMode:xt=`light`,debug:St,onScroll:Ct,ariaLabelConfig:wt,zIndexMode:Tt=`basic`,...Et},Dt){let Ot=pt||`1`,kt=kd(xt),At=(0,J.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Ct?.(e)},[Ct]);return(0,Y.jsx)(`div`,{"data-testid":`rf__wrapper`,...Et,onScroll:At,style:{...ft,...om},ref:Dt,className:vt([`react-flow`,i,kt]),id:pt,role:`application`,children:(0,Y.jsxs)(am,{nodes:e,edges:t,width:yt,height:bt,fitView:Xe,fitViewOptions:Ze,minZoom:ge,maxZoom:_e,nodeOrigin:de,nodeExtent:be,zIndexMode:Tt,children:[(0,Y.jsx)(Dd,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:se,autoPanOnNodeFocus:ce,nodesConnectable:le,nodesFocusable:ue,edgesFocusable:fe,edgesReconnectable:pe,elementsSelectable:me,elevateNodesOnSelect:nt,elevateEdgesOnSelect:rt,minZoom:ge,maxZoom:_e,nodeExtent:be,onNodesChange:Ge,onEdgesChange:Ke,snapToGrid:ae,snapGrid:W,connectionMode:I,translateExtent:ve,connectOnClick:Qe,defaultEdgeOptions:tt,fitView:Xe,fitViewOptions:Ze,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:ee,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ye,nodeOrigin:de,rfId:Ot,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanSpeed:ct,onError:dt,connectionRadius:lt,isValidConnection:ut,selectNodesOnDrag:oe,nodeDragThreshold:mt,connectionDragThreshold:ht,onBeforeDelete:F,debug:St,ariaLabelConfig:wt,zIndexMode:Tt}),(0,Y.jsx)(em,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:L,connectionLineStyle:R,connectionLineComponent:z,connectionLineContainerStyle:te,selectionKeyCode:V,selectionOnDrag:ne,selectionMode:H,deleteKeyCode:B,multiSelectionKeyCode:re,panActivationKeyCode:U,zoomActivationKeyCode:ie,onlyRenderVisibleElements:G,defaultViewport:he,translateExtent:ve,minZoom:ge,maxZoom:_e,preventScrolling:ye,zoomOnScroll:Se,zoomOnPinch:Ce,zoomOnDoubleClick:De,panOnScroll:we,panOnScrollSpeed:Te,panOnScrollMode:Ee,panOnDrag:Oe,autoPanOnSelection:st,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:K,onPaneScroll:Me,onPaneContextMenu:Ne,paneClickDistance:Pe,nodeClickDistance:Fe,onSelectionContextMenu:M,onSelectionStart:N,onSelectionEnd:P,onReconnect:Le,onReconnectStart:Re,onReconnectEnd:ze,onEdgeContextMenu:Be,onEdgeDoubleClick:q,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We,defaultMarkerColor:xe,noDragClassName:qe,noWheelClassName:Je,noPanClassName:Ye,rfId:Ot,disableKeyboardA11y:it,nodeExtent:be,viewport:gt,onViewportChange:_t,nodesDraggable:se}),(0,Y.jsx)(xd,{onSelectionChange:k}),Ie,(0,Y.jsx)(hd,{proOptions:et,position:$e}),(0,Y.jsx)(fd,{rfId:Ot,disableKeyboardA11y:it})]})})}var cm=qd(sm),lm=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function um({children:e}){let t=$(lm);return t?(0,$u.createPortal)(e,t):null}var dm=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function fm(){return $(dm,Qu)}function pm(e){let[t,n]=(0,J.useState)(e);return[t,n,(0,J.useCallback)(e=>n(t=>Ld(e,t)),[])]}function mm({onStart:e,onChange:t,onEnd:n}){let r=rd();(0,J.useEffect)(()=>{r.setState({onViewportChangeStart:e})},[e]),(0,J.useEffect)(()=>{r.setState({onViewportChange:t})},[t]),(0,J.useEffect)(()=>{r.setState({onViewportChangeEnd:n})},[n])}var hm=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(let[,{internals:e}]of t.nodeLookup)if(e.handleBounds===void 0||!Jc(e.userNode))return!1;return!0};function gm(e={includeHiddenNodes:!1}){return $(hm(e))}$s.error014();function _m(e){return $((0,J.useCallback)(t=>t.nodeLookup.get(e),[e]),Qu)}function vm({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,Y.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:vt([`react-flow__background-pattern`,n,r])})}function ym({radius:e,className:t}){return(0,Y.jsx)(`circle`,{cx:e,cy:e,r:e,className:vt([`react-flow__background-pattern`,`dots`,t])})}var bm;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(bm||={});var xm={[bm.Dots]:1,[bm.Lines]:1,[bm.Cross]:6},Sm=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Cm({id:e,variant:t=bm.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,J.useRef)(null),{transform:f,patternId:p}=$(Sm,Qu),m=r||xm[t],h=t===bm.Dots,g=t===bm.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]+x[0]/2,b[1]*f[2]+x[1]/2],C=`${p}${e||``}`;return(0,Y.jsxs)(`svg`,{className:vt([`react-flow__background`,l]),style:{...c,...sf,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,Y.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,Y.jsx)(ym,{radius:y/2,className:u}):(0,Y.jsx)(vm,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,Y.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}Cm.displayName=`Background`;var wm=(0,J.memo)(Cm);function Tm(){return(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,Y.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function Em(){return(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,Y.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Dm(){return(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,Y.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function Om(){return(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,Y.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function km(){return(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,Y.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function Am({children:e,className:t,...n}){return(0,Y.jsx)(`button`,{type:`button`,className:vt([`react-flow__controls-button`,t]),...n,children:e})}var jm=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Mm({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=rd(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=$(jm,Qu),{zoomIn:y,zoomOut:b,fitView:x}=tf();return(0,Y.jsxs)(pd,{className:vt([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Am,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,Y.jsx)(Tm,{})}),(0,Y.jsx)(Am,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,Y.jsx)(Em,{})})]}),n&&(0,Y.jsx)(Am,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,Y.jsx)(Dm,{})}),r&&(0,Y.jsx)(Am,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,Y.jsx)(km,{}):(0,Y.jsx)(Om,{})}),u]})}Mm.displayName=`Controls`,(0,J.memo)(Mm);function Nm({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,Y.jsx)(`rect`,{className:vt([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var Pm=(0,J.memo)(Nm),Fm=e=>e.nodes.map(e=>e.id),Im=e=>e instanceof Function?e:()=>e;function Lm({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=Pm,onClick:o}){let s=$(Fm,Qu),c=Im(t),l=Im(e),u=Im(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,Y.jsx)(Y.Fragment,{children:s.map(e=>(0,Y.jsx)(zm,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Rm({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=$(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=qc(r);return{node:r,x:i,y:a,width:o,height:s}},Qu);return!l||l.hidden||!Jc(l)?null:(0,Y.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var zm=(0,J.memo)(Rm),Bm=(0,J.memo)(Lm),Vm=200,Hm=150,Um=e=>!e.hidden,Wm=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Mc(hc(e.nodeLookup,{filter:Um}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Gm=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Km=(e,t)=>Gm(e.viewBB,t.viewBB)&&Gm(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,qm=`react-flow__minimap-desc`;function Jm({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=rd(),S=(0,J.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=$(Wm,Km),j=e?.width??Vm,ee=e?.height??Hm,M=C.width/j,N=C.height/ee,P=Math.max(M,N),F=P*j,I=P*ee,L=b*P,R=C.x-(F-C.width)/2-L,z=C.y-(I-C.height)/2-L,te=F+L*2,B=I+L*2,V=`${qm}-${E}`,ne=(0,J.useRef)(0),H=(0,J.useRef)();ne.current=P,(0,J.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return H.current=pu({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>ne.current}),()=>{H.current?.destroy()}},[w]),(0,J.useEffect)(()=>{H.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let U=p?e=>{let[t,n]=H.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,re=(0,J.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),ie=m?re:void 0,ae=_??A[`minimap.ariaLabel`];return(0,Y.jsx)(pd,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*P:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:vt([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,Y.jsxs)(`svg`,{width:j,height:ee,viewBox:`${R} ${z} ${te} ${B}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":V,ref:S,onClick:U,children:[ae&&(0,Y.jsx)(`title`,{id:V,children:ae}),(0,Y.jsx)(Bm,{onClick:ie,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,Y.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${R-L},${z-L}h${te+L*2}v${B+L*2}h${-te-L*2}z
|
|
16
|
-
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Jm.displayName=`MiniMap`;var Ym=(0,J.memo)(Jm),Xm=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Zm={[Ou.Line]:`right`,[Ou.Handle]:`bottom-right`};function Qm({nodeId:e,position:t,variant:n=Ou.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=xf(),y=typeof e==`string`?e:v,b=rd(),x=(0,J.useRef)(null),S=n===Ou.Handle,C=$((0,J.useCallback)(Xm(S&&p),[S,p]),Qu),w=(0,J.useRef)(null),T=t??Zm[n];(0,J.useEffect)(()=>{if(x.current&&y)return w.current||=zu({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Kl([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Yc({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,Y.jsx)(`div`,{className:vt([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,J.memo)(Qm);var $m={name:`arrow-left-right`,size:24,node:[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]};$m.node;var eh=c($m),th={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};th.node;var nh=c(th),rh={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};rh.node;var ih=c(rh),ah={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};ah.node;var oh=c(ah),sh={name:`brush`,size:24,node:[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]};sh.node;var ch=c(sh),lh={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};lh.node;var uh=c(lh),dh={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};dh.node;var fh=c(dh),ph={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};ph.node;var mh=c(ph),hh={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};hh.node;var gh=c(hh),_h={name:`circle-dot`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};_h.node;var vh=c(_h),yh={name:`circle-slash`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]};yh.node;var bh=c(yh),xh={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};xh.node;var Sh=c(xh),Ch={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ch.node;var wh=c(Ch),Th={name:`columns-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]],aliases:[`columns`]};Th.node;var Eh=c(Th),Dh={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};Dh.node;var Oh=c(Dh),kh={name:`crosshair`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]};kh.node;var Ah=c(kh),jh={name:`diff`,size:24,node:[[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 10h14`,key:`elsbfy`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};jh.node;var Mh=c(jh),Nh={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Nh.node;var Ph=c(Nh),Fh={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};Fh.node;var Ih=c(Fh),Lh={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Lh.node;var Rh=c(Lh),zh={name:`face-slightly-smiling`,size:24,node:[[`path`,{d:`M15 10V9`,key:`4dkmfx`}],[`path`,{d:`M16.472 15a6 6 0 01-8.943 0`,key:`7qomzy`}],[`path`,{d:`M9 10V9`,key:`1lazqi`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`smile`]};zh.node;var Bh=c(zh),Vh={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Vh.node;var Hh=c(Vh),Uh={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};Uh.node;var Wh=c(Uh),Gh={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};Gh.node;var Kh=c(Gh),qh={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};qh.node;var Jh=c(qh),Yh={name:`git-compare`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]};Yh.node;var Xh=c(Yh),Zh={name:`git-fork`,size:24,node:[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]};Zh.node;var Qh=c(Zh),$h={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};$h.node;var eg=c($h),tg={name:`git-pull-request-closed`,size:24,node:[[`path`,{d:`m15.5 3.5 5 5`,key:`1kmx7t`}],[`path`,{d:`m15.5 8.5 5-5`,key:`saftza`}],[`path`,{d:`M18 11.62V15`,key:`1greaj`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}]]};tg.node;var ng=c(tg),rg={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};rg.node;var ig=c(rg),ag={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};ag.node;var og=c(ag),sg={name:`image-off`,size:24,node:[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]};sg.node;var cg=c(sg),lg={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};lg.node;var ug=c(lg),dg={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};dg.node;var fg=c(dg),pg={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};pg.node;var mg=c(pg),hg={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};hg.node;var gg=c(hg),_g={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};_g.node;var vg=c(_g),yg={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};yg.node;var bg=c(yg),xg={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};xg.node;var Sg=c(xg),Cg={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};Cg.node;var wg=c(Cg),Tg={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};Tg.node;var Eg=c(Tg),Dg={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Dg.node;var Og=c(Dg),kg={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};kg.node;var Ag=c(kg),jg={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};jg.node;var Mg=c(jg),Ng={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};Ng.node;var Pg=c(Ng),Fg={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Fg.node;var Ig=c(Fg),Lg={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};Lg.node;var Rg=c(Lg),zg={name:`message-square-off`,size:24,node:[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]};zg.node;var Bg=c(zg),Vg={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};Vg.node;var Hg=c(Vg),Ug={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};Ug.node;var Wg=c(Ug),Gg={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Gg.node;var Kg=c(Gg),qg={name:`monitor-play`,size:24,node:[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]};qg.node;var Jg=c(qg),Yg={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Yg.node;var Xg=c(Yg),Zg={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Zg.node;var Qg=c(Zg),$g={name:`mouse-pointer-2`,size:24,node:[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]};$g.node;var e_=c($g),t_={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};t_.node;var n_=c(t_),r_={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};r_.node;var i_=c(r_),a_={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};a_.node;var o_=c(a_),s_={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};s_.node;var c_=c(s_),l_={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};l_.node;var u_=c(l_),d_={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};d_.node;var f_=c(d_),p_={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};p_.node;var m_=c(p_),h_={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};h_.node;var g_=c(h_),__={name:`route`,size:24,node:[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]};__.node;var v_=c(__),y_={name:`rows-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]],aliases:[`rows`]};y_.node;var b_=c(y_),x_={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};x_.node;var S_=c(x_),C_={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};C_.node;var w_=c(C_),T_={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};T_.node;var E_=c(T_),D_={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};D_.node;var O_=c(D_),k_={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};k_.node;var A_=c(k_),j_={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};j_.node;var M_=c(j_),N_={name:`shield-question-mark`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`shield-question`]};N_.node;var P_=c(N_),F_={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};F_.node;var I_=c(F_),L_={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};L_.node;var R_=c(L_),z_={name:`square-dashed-text`,size:24,node:[[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 14v1`,key:`169vum`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h6`,key:`1vyc9m`}],[`path`,{d:`M7 8h8`,key:`1jbsf9`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M9 3h1`,key:`1yesri`}]],aliases:[`text-selection`,`text-select`]};z_.node;var B_=c(z_),V_={name:`square-split-horizontal`,size:24,node:[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3`,key:`saxlbk`}],[`path`,{d:`M8 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3`,key:`m1vog4`}]],aliases:[`split-square-horizontal`]};V_.node;var H_=c(V_),U_={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};U_.node;var W_=c(U_),G_={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};G_.node;var K_=c(G_),q_={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};q_.node;var J_=c(q_),Y_={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Y_.node;var X_=c(Y_),Z_={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Z_.node;var Q_=c(Z_),$_={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};$_.node;var ev=c($_),tv={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};tv.node;var nv=c(tv),rv={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};rv.node;var iv=c(rv),av={name:`waypoints`,size:24,node:[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]};av.node;var ov=c(av),sv={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};sv.node;var cv=c(sv),lv=[[`left-[4%] top-[8%]`,4,2],[`left-[38%] top-[8%]`,2,1],[`left-[4%] top-[50%]`,4,2],[`left-[38%] top-[42%]`,4,2]];function uv(){return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col bg-sunken`,"data-sw-board-loading":!0,children:[(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Loading the board`}),Ge?(0,Y.jsxs)(`div`,{className:`flex h-[2.8125rem] shrink-0 items-center gap-2 border-b border-line bg-surface px-2 sm:px-3 lg:h-9`,"aria-hidden":`true`,"data-sw-board-loading-demo":!0,children:[(0,Y.jsx)(K,{className:`h-5 w-14 rounded-full`}),(0,Y.jsx)(K,{className:`h-3.5 w-40 max-sm:w-24`}),(0,Y.jsx)(K,{className:`ml-auto h-3.5 w-14`})]}):null,(0,Y.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 border-b border-line bg-surface px-3 lg:px-4`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`h-8 w-8 rounded-lg`}),(0,Y.jsx)(K,{className:`hidden h-4 w-24 sm:block`}),(0,Y.jsx)(K,{className:`h-8 w-40 max-sm:flex-1`}),(0,Y.jsx)(`div`,{className:`hidden flex-1 items-center justify-center gap-2 lg:flex`,children:(0,Y.jsx)(K,{className:`h-8 w-56`})}),(0,Y.jsx)(K,{className:`hidden h-8 w-24 lg:block`}),(0,Y.jsx)(K,{className:`hidden h-8 w-48 lg:block`}),(0,Y.jsx)(K,{className:`h-8 w-8 rounded-full`})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`relative min-w-0 flex-1 overflow-hidden`,"aria-hidden":`true`,children:[lv.map(([e,t,n],r)=>(0,Y.jsxs)(`div`,{className:`absolute ${e} rounded-xl border border-line-strong/60 bg-surface/40 p-3 max-sm:hidden`,children:[(0,Y.jsx)(K,{className:`mb-3 h-3 w-20`}),(0,Y.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(${t}, 3.5rem)`},children:Array.from({length:t*n},(e,t)=>(0,Y.jsx)(K,{className:`h-24 rounded-md shadow-thumb`},t))})]},r)),(0,Y.jsx)(`div`,{className:`flex flex-col gap-4 p-4 sm:hidden`,children:[3,2].map((e,t)=>(0,Y.jsxs)(`div`,{className:`rounded-xl border border-line-strong/60 bg-surface/40 p-3`,children:[(0,Y.jsx)(K,{className:`mb-3 h-3 w-20`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:Array.from({length:e},(e,t)=>(0,Y.jsx)(K,{className:`h-28 rounded-md shadow-thumb`},t))})]},t))})]}),(0,Y.jsxs)(`div`,{className:`hidden w-80 shrink-0 flex-col gap-4 border-l border-line bg-surface p-4 lg:flex`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`h-5 w-28`}),(0,Y.jsx)(K,{className:`h-9 w-full`}),[0,1,2,3].map(e=>(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Y.jsx)(K,{className:`h-8 w-8 shrink-0 rounded-full`}),(0,Y.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Y.jsx)(K,{className:`h-3 w-1/2`}),(0,Y.jsx)(K,{className:`h-3 w-full`}),(0,Y.jsx)(K,{className:`h-3 w-3/4`})]})]},e))]})]})]})}function dv({heading:e=!0}){return(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-sw-chat-loading":!0,children:[(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Loading chat`}),e?(0,Y.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-line px-3`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`h-4 w-16`}),(0,Y.jsx)(K,{className:`h-5 w-28 rounded-full`}),(0,Y.jsx)(K,{className:`ml-auto h-7 w-7`})]}):null,(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-hidden p-3`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`ml-auto h-9 w-3/5 rounded-2xl`}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(K,{className:`h-6 w-6 shrink-0 rounded-full`}),(0,Y.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Y.jsx)(K,{className:`h-10 w-full rounded-lg`}),(0,Y.jsx)(K,{className:`h-3 w-full`}),(0,Y.jsx)(K,{className:`h-3 w-5/6`}),(0,Y.jsx)(K,{className:`h-3 w-2/3`})]})]})]}),(0,Y.jsx)(`div`,{className:`shrink-0 p-3`,"aria-hidden":`true`,children:(0,Y.jsx)(K,{className:`h-24 w-full rounded-xl`})})]})}function fv(e){let t=e?.status;return t===401||t===403?`You may need to sign in again, or ask for access to this board.`:t===404?`This board may have moved or been removed.`:typeof navigator<`u`&&navigator.onLine===!1?`You seem to be offline. Check your connection, then retry.`:`Shapewall could not fetch this board's data. That is usually temporary, so try again in a moment.`}function pv({error:e,onRetry:t,extra:n=null}){let[r,i]=(0,J.useState)(!1),o=async()=>{i(!0);try{await t?.()}finally{i(!1)}},s=[e?.message,e?.status?`Status ${e.status}`:null].filter(Boolean).join(`
|
|
17
|
-
`);return(0,Y.jsx)(`div`,{className:`flex h-full overflow-y-auto bg-sunken`,role:`alert`,"data-sw-board-error":!0,children:(0,Y.jsx)(j,{size:`lg`,tone:`bad`,icon:wh,title:`This board did not load`,details:s||null,action:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(a,{size:`touch`,variant:`default`,className:`lg:h-10`,onClick:o,disabled:r,"data-sw-board-retry":!0,children:[r?(0,Y.jsx)(me,{}):(0,Y.jsx)(
|
|
18
|
-
`).toLowerCase();return a.every(e=>t.includes(e))})}var Mv=[`responses`,`http4xx`,`http5xx`,`apiErrors`,`rateLimited`,`apiRateLimited`,`failedRequests`];function Nv(e){return!e||e.schemaVersion!==1||e.window!==`navigation-through-screenshot`||typeof e.capped!=`boolean`||Mv.some(t=>!Number.isInteger(e[t])||e[t]<0||e[t]>1e4)||e.responses+e.failedRequests>1e4||e.http4xx+e.http5xx>e.responses||e.apiErrors>e.http4xx+e.http5xx||e.rateLimited>e.http4xx||e.apiRateLimited>Math.min(e.rateLimited,e.apiErrors)?null:{schemaVersion:1,window:`navigation-through-screenshot`,...Object.fromEntries(Mv.map(t=>[t,e[t]])),capped:e.capped}}function Pv(e){let t=Nv(e);if(!t)return``;let n=[];t.rateLimited&&n.push(`${t.rateLimited} HTTP 429${t.apiRateLimited?` (${t.apiRateLimited} API)`:``}`);let r=t.http4xx+t.http5xx-t.rateLimited;return r&&n.push(`${r} other HTTP error${r===1?``:`s`}`),t.failedRequests&&n.push(`${t.failedRequests} failed request${t.failedRequests===1?``:`s`}`),t.capped&&n.push(`observation limit reached`),n.join(`; `)}var Fv={desktop:Xg,tablet:J_,phone:I_},Iv=(e,t=Xg)=>Fv[e]||Fv[String(e).split(`-`)[0]]||t,Lv=e=>e[0].toUpperCase()+e.slice(1).replace(/-/g,` `);function Rv(e){let t=e.lastIndexOf(`|`);return{targetId:e.slice(0,t),viewport:e.slice(t+1)}}function zv({pageId:e,title:t,entries:n,viewports:r}){let[i,a]=(0,J.useState)(!1),o=r.map(e=>({name:e,text:n?.[e]?.status===`ok`?Pv(n[e].networkSummary):``})).filter(e=>e.text);return o.length?(0,Y.jsxs)(lt,{open:i,onOpenChange:a,children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`nodrag nopan relative inline-flex h-5 items-center gap-1 rounded-full bg-warn/15 px-1.5 text-[10px] font-medium text-fg transition-colors hover:bg-warn/25 focus-visible:outline-2 focus-visible:outline-accent [@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:-inset-3 [@media(pointer:coarse)]:before:content-['']`,"aria-label":`Capture network warnings for ${t}`,"data-sw-capture-warning":e,onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(Q_,{size:10,className:`shrink-0 text-warn`,"aria-hidden":`true`}),`Network`]})}),(0,Y.jsxs)(ot,{className:`w-80 max-w-[calc(100vw-1.5rem)] p-0 text-xs`,"aria-label":`Capture network warnings`,"data-sw-capture-warning-details":!0,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-line py-2 pr-1.5 pl-3`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-warn/15 text-warn`,children:(0,Y.jsx)(Q_,{size:13,"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h3`,{className:`text-[13px] font-semibold text-fg`,children:`Capture network warnings`}),(0,Y.jsx)(`p`,{className:`mt-0.5 truncate text-muted`,children:t})]}),(0,Y.jsx)(B,{size:`icon-sm`,className:`[@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11`,label:`Close`,tooltip:``,onClick:()=>a(!1),children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2.5 px-3 py-2.5`,children:[(0,Y.jsx)(`p`,{className:`text-muted`,children:`Screenshots were saved. These requests had problems during capture.`}),(0,Y.jsx)(`ul`,{className:`divide-y divide-line rounded-md border border-line`,children:o.map(e=>{let t=Iv(e.name);return(0,Y.jsxs)(`li`,{className:`flex items-start gap-2 px-2.5 py-2`,children:[(0,Y.jsx)(t,{size:13,className:`mt-0.5 shrink-0 text-faint`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block font-medium text-fg capitalize`,children:e.name}),(0,Y.jsx)(`span`,{className:`block break-words text-muted`,children:e.text})]})]},e.name)})}),(0,Y.jsx)(`p`,{className:`text-faint`,children:`Counts only requests that failed before the screenshot. Normal page redirects aren’t counted; failed API calls are.`})]})]})]}):null}var Bv=400;function Vv({content:e,side:t=`top`,align:n=`center`,children:r}){let[i,a]=(0,J.useState)(!1),o=(0,J.useRef)(null),s=(0,J.useRef)(0);if((0,J.useEffect)(()=>()=>window.clearTimeout(s.current),[]),!e)return r;let c=e=>{window.clearTimeout(s.current),s.current=window.setTimeout(()=>a(!0),e)},l=()=>{window.clearTimeout(s.current),a(!1)},u=r.props,d=(0,J.cloneElement)(r,{ref:e=>{o.current=e,typeof u.ref==`function`?u.ref(e):u.ref&&(u.ref.current=e)},onPointerEnter:e=>{u.onPointerEnter?.(e),e.pointerType!==`touch`&&c(Bv)},onPointerLeave:e=>{u.onPointerLeave?.(e),l()},onPointerDown:e=>{u.onPointerDown?.(e),l()},onFocus:e=>{u.onFocus?.(e),e.target.matches?.(`:focus-visible`)&&c(0)},onBlur:e=>{u.onBlur?.(e),l()}});return(0,Y.jsxs)(Y.Fragment,{children:[d,i?(0,Y.jsxs)(lt,{open:!0,onOpenChange:e=>e?null:l(),history:!1,children:[(0,Y.jsx)(fe,{virtualRef:o}),(0,Y.jsx)(ot,{role:`tooltip`,side:t,align:n,sideOffset:6,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),className:`pointer-events-none z-[70] max-w-64 animate-fade-in rounded-md border-0 bg-fg px-2 py-1 text-xs font-medium text-surface select-none`,"data-sw-card-tip":`true`,children:e})]}):null]})}var Hv=(0,J.createContext)(null),Uv=8,Wv=26,Gv=12,Kv=72,qv=112,Jv=72,Yv=260,Xv=64,Zv=40,Qv=4,$v=160;function ey(e,t){return Math.max(e.w,e.h)*t<$v}function ty(e,t){let n=Object.keys(t);return e===`all`?n:[n.includes(e)?e:n[0]]}function ny(e,t,n=null){let r=ty(e,t),i=Array.isArray(n)&&n.length?n.filter(e=>t[e]):null;if(!i?.length)return r;let a=r.filter(e=>i.includes(e));return a.length?a:[Object.keys(t).find(e=>i.includes(e))]}function ry(e,t,n=null){let r=e[t],i=n?.[t];return r&&i&&i!==r.height?{...r,height:i}:r}function iy(e,t,n=null,r=null,i=null){let a=Uv,o=ny(e,t,r),s=n||e===`all`&&Object.keys(t).length>1?Wv:Uv,c=o.flatMap(e=>{let r=ry(t,e,i),o=r.frameScale||.25;return(n||[null]).map(n=>{let i={viewport:e,x:a,y:s,w:Math.round(r.width*o),h:Math.round(r.height*o)};return r!==t[e]&&(i.native=r),n&&(i.env=n),a+=i.w+Gv,i})});return{frames:c,width:a-Gv+Uv,height:s+Math.max(...c.map(e=>e.h))+Uv}}function ay(e,t,n,r,i=null){let a=e.files&&typeof e.files==`object`?Object.keys(e.files).filter(e=>n[e]):null;if(!a?.length)return{frames:r.frames,width:r.width,height:r.height,only:null};let o=ty(t,n).filter(e=>a.includes(e));if(!o.length)return{frames:[],width:r.width,height:52,only:a};let s=iy(t,n,null,o,i);return{frames:s.frames,width:s.width,height:s.height,only:null}}function oy({pages:e,groups:t,variants:n,viewports:r,mode:i,compare:a=null}){let{width:o}=iy(i,r,a),s=new Map,c=e=>`${(e.viewports||[]).join(`,`)}|${JSON.stringify(e.frameHeight||null)}`,l=e=>{let t=c(e);return s.has(t)||s.set(t,iy(i,r,a,e.viewports,e.frameHeight)),s.get(t)},u=new Map,d=e=>{if(!a)return l(e);let t=c(e);return u.has(t)||u.set(t,iy(i,r,null,e.viewports,e.frameHeight)),u.get(t)},f=new Map;for(let e of n||[])f.has(e.pageId)||f.set(e.pageId,[]),f.get(e.pageId).push(e);let p=[...new Set([...t||[],...e.map(e=>e.group)])],m=[],h=[],g={},_=Qv*(o+Kv),v=[];for(let t of p){let n=e.filter(e=>e.group===t);if(!n.length)continue;let a=[],o=0,s=0,c=0,u=0;for(let e of n){let t=l(e),n=(f.get(e.id)||[]).map(t=>({variant:t,shape:ay(t,i,r,d(e),e.frameHeight)})),p=n.reduce((e,t)=>e+t.shape.width+Jv,t.width);o>0&&o+p>_&&(o=0,s+=u+qv,u=0),a.push({page:e,shape:t,beside:n,x:o+Xv,y:s+Xv+Zv}),o+=p+Kv,c=Math.max(c,o-Kv),u=Math.max(u,t.height)}v.push({group:t,placed:a,width:c+128,height:s+u+Zv+128})}let y=v.reduce((e,t)=>e+(t.width+Yv)*(t.height+Yv),0),b=Math.max(...v.map(e=>e.width),Math.sqrt(y*1.6)),x=0,S=0,C=0;for(let e of v)x>0&&x+e.width>b&&(x=0,S+=C+Yv,C=0),e.x=x,e.y=S,x+=e.width+Yv,C=Math.max(C,e.height);for(let e of v){m.push({id:`group:${e.group}`,type:`groupFrame`,position:{x:e.x,y:e.y},data:{group:e.group,count:e.placed.length},style:{width:e.width,height:e.height},width:e.width,height:e.height,selectable:!1,draggable:!1,focusable:!1,zIndex:-1});for(let{page:t,shape:n,beside:r,x:i,y:a}of e.placed){let{frames:o,width:s,height:c}=n,l=Math.round(e.x+i),u=Math.round(e.y+a);m.push({id:t.id,type:`page`,position:{x:l,y:u},data:{page:t,frames:o},style:{width:s,height:c},width:s,height:c,ariaLabel:`${t.title}, ${t.group} page. Arrow keys: its comments and buttons. Enter: its actions.`}),g[t.id]={x:l,y:u,w:s,h:c,frames:o,nodeId:t.id};let d=l+s+Jv;r.forEach(({variant:e,shape:n},i)=>{let a=`variant:${e.id}`;m.push({id:a,type:`variant`,position:{x:d,y:u},data:{variant:e,frames:n.frames,only:n.only},ariaLabel:`Variant: ${e.title}. Arrow keys: its comments and buttons. Enter: its actions.`,style:{width:n.width,height:n.height},width:n.width,height:n.height}),g[a]={x:d,y:u,w:n.width,h:n.height,frames:n.frames,nodeId:a},h.push({id:`edge:${a}`,source:i===0?t.id:`variant:${r[i-1].variant.id}`,sourceHandle:`right`,target:a,targetHandle:`left`,type:`straight`,className:`sw-edge-variant`,style:{strokeDasharray:`6 6`},ariaLabel:`Variant of ${t.title}: ${e.title}`}),d+=n.width+Jv})}}return{nodes:m,edges:h,targets:g}}var sy=5;function cy(e){let t=e.anchor;if(!t||!(t.w>0)||!(t.h>0))return null;let n=e.x-t.dx*t.w*100,r=e.y-t.dy*t.h*100;return{left:n,top:r,right:n+t.w*100,bottom:r+t.h*100}}function ly(e,t=null){let n=t?.box||cy(e);if(!n)return{x:t?t.x:e.x,y:t?t.y:e.y,flipX:!1,flipY:!1};let r=e=>Math.max(0,Math.min(100,e)),i=n.right>95,a=i&&n.left>=sy?n.left:n.right,o=n.top<sy,s=o&&n.bottom<=95?n.bottom:n.top;return{x:r(a),y:r(s),flipX:i,flipY:o}}function uy(e,t=null){return!t||!e?.env||e.env===t.a}function dy(e,t){let n=e[t.pageId];if(!n)return null;let r=n.frames.find(e=>e.viewport===t.viewport);return r?{x:n.x+r.x+r.w*t.x/100,y:n.y+r.y+r.h*t.y/100,nodeId:n.nodeId}:null}var fy={elements:8e3,bytes:3145728,text:80,attr:200,selector:600,size:1e4},py=`a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"], [role="menuitem"], img`,my=String.raw`(?:[A-Za-z0-9_\u0080-\uffff-]|\\[0-9a-fA-F]{6} ?|\\[0-9a-fA-F]{1,5}(?![0-9a-fA-F]) ?|\\[^0-9a-fA-F\n\r\f])+`,hy=String.raw`(?:[^"\\\n]|\\.){0,200}`,gy=String.raw`(?:#${my}|[a-z][a-z0-9-]{0,40}(?:\[(?:data-testid|aria-label)="${hy}"\]|:nth-of-type\([1-9][0-9]{0,4}\)))`,_y=RegExp(`^${gy}(?: > ${gy}){0,79}$`),vy=RegExp(`^${gy}$`),yy=/^[a-z][a-z0-9-]{0,40}$/;function by(e){let t=document,n=t.documentElement,r=t.body,i=Math.round(innerWidth),a=Math.round(innerHeight);if(!r)return{v:1,width:i,height:a,elements:[]};let o=e=>{let t=e.innerText||e.textContent||e.getAttribute(`aria-label`)||e.getAttribute(`alt`)||e.getAttribute(`placeholder`)||``;return String(t).replace(/\s+/g,` `).trim()},s=e=>String(e).replace(/["\\]/g,`\\$&`),c=e=>{try{return t.querySelectorAll(e).length===1}catch{return!1}},l=e=>Math.round(e*10)/10,u=e=>!!(e&&e.width&&e.height),d=[r,...Array.from(r.querySelectorAll(`*`))],f=new Map,p=new Set;for(let e of d){let t=e.getBoundingClientRect();if(f.set(e,t),!(!u(t)||t.right<=0||t.bottom<=0||t.left>=i||t.top>=a))for(let t=e;t&&t!==n&&!p.has(t);t=t.parentElement)p.add(t)}let m=d.filter(e=>p.has(e)),h=m.slice(0,e.elements),g=new Map(h.map((e,t)=>[e,t])),_=new Map,v=e=>{let t=_.get(e);return t||(t=getComputedStyle(e),_.set(e,t)),t},y=e=>{let t=0,r=0;for(let i=e;i&&i!==n;i=i.parentElement){let e=v(i);if(e.position!==`static`){r=1;let n=parseInt(e.zIndex,10);Number.isFinite(n)&&(t=n)}}return[t,r]},b=(e,t)=>{let r=t.left,i=t.top,a=t.right,o=t.bottom;if(v(e).position===`fixed`)return null;for(let t=e.parentElement;t&&t!==n;t=t.parentElement){let e=v(t);if(e.overflowX!==`visible`||e.overflowY!==`visible`){let e=f.get(t)||t.getBoundingClientRect();r=Math.max(r,e.left),i=Math.max(i,e.top),a=Math.min(a,e.right),o=Math.min(o,e.bottom)}if(e.position===`fixed`)break}return r===t.left&&i===t.top&&a===t.right&&o===t.bottom?null:[l(r),l(i),l(Math.max(0,a-r)),l(Math.max(0,o-i))]},x=[],S=[];h.forEach((t,n)=>{let i=t.tagName.toLowerCase(),a=f.get(t),d=1,p=t;for(;p=p.previousElementSibling;)p.tagName===t.tagName&&(d+=1);let m={t:i,n:d,p:t===r?-1:g.get(t.parentElement),b:[l(a.left),l(a.top),l(a.width),l(a.height)]},h=t.id,_=t.getAttribute(`data-testid`),C=t.getAttribute(`aria-label`);h&&c(`#${CSS.escape(h)}`)?m.h=`#${CSS.escape(h)}`:_&&c(`${i}[data-testid="${s(_)}"]`)?m.h=`${i}[data-testid="${s(_)}"]`:C&&C.length<=80&&c(`${i}[aria-label="${s(C)}"]`)&&(m.h=`${i}[aria-label="${s(C)}"]`),h&&h.length<=e.attr&&(m.i=h),_&&_.length<=e.attr&&(m.d=_),C&&C.length<=e.attr&&(m.r=C);let w=o(t);w&&(m.x=w.slice(0,e.text),w.length>e.text&&(m.l=1));let T=v(t);if(t!==r&&u(a)&&T.visibility===`visible`&&T.pointerEvents!==`none`){S.push({position:n,key:y(t)});let r=b(t,a);r&&(m.c=r);let i=t.closest(e.preferred)||t;i!==t&&(m.a=g.has(i)&&u(f.get(i))?g.get(i):-1)}x.push(m)}),S.sort((e,t)=>e.key[0]-t.key[0]||e.key[1]-t.key[1]||e.position-t.position),S.forEach((e,t)=>{x[e.position].z=t});let C={v:1,width:i,height:a,elements:x};return m.length>h.length&&(C.truncated=!0),C}`${by.toString()}${JSON.stringify({elements:fy.elements,text:fy.text,attr:fy.attr,preferred:py})}`;var xy=class extends Error{},Sy=/[\u0000-\u001f\u007f]/,Cy=1e5;function wy(e,t){if(!Array.isArray(e)||e.length!==4)throw new xy(`${t}: a box is four numbers`);let n=e.map(e=>{if(typeof e!=`number`||!Number.isFinite(e)||Math.abs(e)>Cy)throw new xy(`${t}: a box is four numbers`);return Math.round(e*10)/10});if(n[2]<0||n[3]<0)throw new xy(`${t}: a box has no negative size`);return n}function Ty(e,t,n){if(typeof e!=`string`||!e||e.length>t||Sy.test(e))throw new xy(`${n}: up to ${t} printable characters`);return e}function Ey(e){let t=fy;if(!e||typeof e!=`object`||Array.isArray(e))throw new xy(`an element map is an object`);if(e.v!==1)throw new xy(`unknown element map version`);let n=(e,n)=>{if(!Number.isInteger(e)||e<1||e>t.size)throw new xy(`${n}: 1 to ${t.size}`);return e},r=n(e.width,`width`),i=n(e.height,`height`);if(!Array.isArray(e.elements)||e.elements.length>t.elements)throw new xy(`elements: a list of at most ${t.elements}`);let a=e.elements.length,o=new Set,s={v:1,width:r,height:i,elements:e.elements.map((e,n)=>{let r=`elements[${n}]`;if(!e||typeof e!=`object`||Array.isArray(e))throw new xy(`${r}: an object`);if(typeof e.t!=`string`||!yy.test(e.t))throw new xy(`${r}.t: a tag name`);if(!Number.isInteger(e.n)||e.n<1||e.n>99999)throw new xy(`${r}.n: 1 to 99999`);if(!Number.isInteger(e.p)||e.p>=n||e.p<-1||e.p===-1!=(n===0))throw new xy(`${r}.p: an earlier element`);let i={t:e.t,n:e.n,p:e.p,b:wy(e.b,`${r}.b`)};if(e.h!==void 0){if(typeof e.h!=`string`||e.h.length>t.selector||!vy.test(e.h))throw new xy(`${r}.h: one selector step`);i.h=e.h}for(let n of[`i`,`d`,`r`])e[n]!==void 0&&(i[n]=Ty(e[n],t.attr,`${r}.${n}`));if(e.x!==void 0&&(i.x=Ty(e.x,t.text,`${r}.x`)),e.l!==void 0){if(e.l!==1||i.x===void 0)throw new xy(`${r}.l: 1 with a text`);i.l=1}if(e.z!==void 0){if(!Number.isInteger(e.z)||e.z<0||e.z>=a||o.has(e.z))throw new xy(`${r}.z: a distinct rank`);o.add(e.z),i.z=e.z}if(e.c!==void 0&&(i.c=wy(e.c,`${r}.c`)),e.a!==void 0){if(!Number.isInteger(e.a)||e.a<-1||e.a>=a)throw new xy(`${r}.a: an element or -1`);i.a=e.a}return i})};return e.truncated===!0&&(s.truncated=!0),s}var Dy=(e,t)=>e.length>t?`${e.slice(0,t-3)}...`:e;function Oy(e,t){let n=[],r=t,i=0;for(;r>=0&&i<1e4;){let t=e.elements[r];if(!t)break;if(t.h){n.unshift(t.h);break}n.unshift(`${t.t}:nth-of-type(${t.n})`),r=t.p,i+=1}let a=n.join(` > `);for(;a.length>fy.selector&&n.length>1;)n.shift(),a=n.join(` > `);return a.length>fy.selector?``:a}function ky(e,t,n){let r=-1,i=-1,a=e?.elements||[];for(let e=0;e<a.length;e+=1){let o=a[e];if(o.z===void 0||o.z<=i)continue;let[s,c,l,u]=o.c||o.b;t>=s&&t<s+l&&n>=c&&n<c+u&&(r=e,i=o.z)}if(r<0)return-1;let o=a[r].a;return o===void 0?r:o}var Ay={h1:`Heading`,h2:`Heading`,h3:`Heading`,h4:`Heading`,h5:`Heading`,h6:`Heading`,a:`Link`,button:`Button`,summary:`Button`,img:`Image`,picture:`Image`,svg:`Image`,video:`Video`,input:`Field`,textarea:`Field`,select:`Field`,label:`Label`,li:`List item`,ul:`List`,ol:`List`,table:`Table`,form:`Form`,nav:`Navigation`,header:`Header`,footer:`Footer`,section:`Section`,article:`Section`,main:`Section`,aside:`Section`,div:`Section`};function jy(e){let t=String(e||``).split(` > `).pop(),n=/^([a-z][a-z0-9-]*)/.exec(t);return n?n[1]:``}function My(e,t=``,{large:n=!1,max:r=32}={}){let i=String(t||``).trim(),a=Ay[e]||(i?`Text`:`Element`);return n&&a===`Section`&&(a=`Whole section`),i?`${a}: ${Dy(i,r)}`:a}function Ny(e,t,n){let r=e.elements[t],i=Oy(e,t),a=i?i.split(` > `).pop():r.t,o=r.x||``,[s,c,l,u]=r.b,d=(n?.width&&n?.height?l*u/(n.width*n.height):0)>.2;return{name:My(r.t,o,{large:d}),label:`${Dy(a,48)}${o?` "${Dy(o,28)}"`:``}`,large:d,rect:{left:s,top:c,width:l,height:u}}}function Py(e,t,n,r=null){let i=ky(e,t,n);if(i<0)return null;let a=e.elements[i],[o,s,c,l]=a.b;if(!c||!l)return null;let u=Oy(e,i);if(!u||!_y.test(u))return null;let d=e=>Math.max(0,Math.min(1,e)),f=e=>Math.round(d(e)*1e4)/1e4;return{selector:u,text:a.x||``,dx:f((t-o)/c),dy:f((n-s)/l),...r?.width&&r?.height?{w:f(c/r.width),h:f(l/r.height)}:{}}}function Fy(e){return e.replace(/\\(?:([0-9a-fA-F]{1,6}) ?|([^\n\r\f]))/g,(e,t,n)=>{if(t===void 0)return n;let r=parseInt(t,16);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}var Iy={id:RegExp(`#(${my})`,`y`),tag:/([a-z][a-z0-9-]{0,40})/y,attr:RegExp(`\\[(data-testid|aria-label)="(${hy})"\\]`,`y`),nth:/:nth-of-type\(([1-9][0-9]{0,4})\)/y,join:/ > /y};function Ly(e){if(typeof e!=`string`||!_y.test(e))return null;let t=[],n=0,r=t=>{t.lastIndex=n;let r=t.exec(e);return r&&(n=t.lastIndex),r};for(;n<e.length;){if(t.length&&!r(Iy.join))return null;let e=r(Iy.id);if(e){t.push({id:Fy(e[1])});continue}if(e=r(Iy.tag),!e)return null;let n=e[1];if(e=r(Iy.attr),e)t.push({tag:n,[e[1]===`data-testid`?`testId`:`label`]:Fy(e[2])});else{if(e=r(Iy.nth),!e)return null;t.push({tag:n,nth:Number(e[1])})}}return t}function Ry(e,t){return t.id===void 0?e.t===t.tag?t.testId===void 0?t.label===void 0?e.n===t.nth:e.r===t.label:e.d===t.testId:!1:e.i===t.id}function zy(e,t,n=1/0){let r=[],i=Ly(t);if(!i?.length)return r;let a=e?.elements||[],o=i[i.length-1];for(let e=0;e<a.length&&r.length<n;e+=1){if(!Ry(a[e],o))continue;let t=a[e].p,n=!0;for(let e=i.length-2;e>=0;--e){if(t<0||!Ry(a[t],i[e])){n=!1;break}t=a[t].p}n&&r.push(e)}return r}var By=(e,t)=>zy(e,t,1)[0]??-1;function Vy(e){let t=String(e).split(`>`).pop().trim(),n=/^([a-z][a-z0-9-]*)/i.exec(t);return n?n[1].toLowerCase():null}function Hy(e,t,n){if(!e?.elements?.length||!t?.selector||!n||!_y.test(t.selector))return null;let r=String(t.text||``),i=e.elements,a=By(e,t.selector);a>=0&&r&&!(i[a].x||``).startsWith(r)&&(a=-1);let o=Vy(t.selector);if(a<0&&r&&o){let e=1/0;for(let t=0;t<i.length;t+=1){let n=i[t];if(n.t!==o||n.l||n.x!==r)continue;let s=n.b[2]*n.b[3];s>0&&s<e&&(a=t,e=s)}}if(a<0)return null;let[s,c,l,u]=i[a].b;if(!l&&!u)return null;let d=(e,t)=>Math.max(0,Math.min(100,e/t*100)),f=Number.isFinite(t.dx)?t.dx:.5,p=Number.isFinite(t.dy)?t.dy:.5;return{x:d(s+f*l,n.width),y:d(c+p*u,n.height),box:{left:d(s,n.width),top:d(c,n.height),right:d(s+l,n.width),bottom:d(c+u,n.height)}}}var Uy=typeof Document>`u`?null:Document.prototype,Wy=e=>Uy?Object.getOwnPropertyDescriptor(Uy,e)?.get:null,Gy={documentElement:Wy(`documentElement`),body:Wy(`body`),defaultView:Wy(`defaultView`)},Ky=typeof Node>`u`?null:Object.getOwnPropertyDescriptor(Node.prototype,`nodeType`)?.get;function qy(e){if(!Uy||!Ky||!e||typeof e!=`object`)return!1;try{return Ky.call(e)===9}catch{return!1}}var Jy={documentElement:e=>qy(e)?Gy.documentElement.call(e):null,body:e=>qy(e)?Gy.body.call(e):null,defaultView:e=>qy(e)?Gy.defaultView.call(e):null,querySelector:(e,t)=>Uy.querySelector.call(e,t),querySelectorAll:(e,t)=>Uy.querySelectorAll.call(e,t),elementFromPoint:(e,t,n)=>qy(e)?Uy.elementFromPoint.call(e,t,n):null,addEventListener:(e,...t)=>EventTarget.prototype.addEventListener.call(e,...t),removeEventListener:(e,...t)=>EventTarget.prototype.removeEventListener.call(e,...t)},Yy=600,Xy=2e3,Zy=String.raw`(?:#(?:[A-Za-z0-9_\u0080--]|\\[0-9a-fA-F]{6} ?|\\[0-9a-fA-F]{1,5}(?![0-9a-fA-F]) ?|\\[^0-9a-fA-F\n\r\f])+|[a-z][a-z0-9-]{0,40}(?:\[(?:data-testid|aria-label)="(?:[^"\\\n]|\\.){0,200}"\]|:nth-of-type\([1-9][0-9]{0,4}\)))`,Qy=RegExp(`^${Zy}(?: > ${Zy}){0,79}$`),$y=80,eb=`a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"], [role="menuitem"], img`;function tb(e){if(!e)return``;let t=e.innerText||e.textContent||e.getAttribute?.(`aria-label`)||e.getAttribute?.(`alt`)||e.getAttribute?.(`placeholder`)||``;return String(t).replace(/\s+/g,` `).trim()}function nb(e,t){let n=typeof CSS<`u`?CSS:null;return n?.escape?n.escape(t):String(t).replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function rb(e){return String(e).replace(/["\\]/g,`\\$&`)}function ib(e,t){try{return Jy.querySelectorAll(e,t).length===1}catch{return!1}}function ab(e,t){let n=[],r=t,i=Jy.documentElement(e);for(;r&&r.nodeType===1&&r!==i;){let t=r.tagName.toLowerCase();if(r.id&&ib(e,`#${nb(e,r.id)}`)){n.unshift(`#${nb(e,r.id)}`);break}let i=r.getAttribute(`data-testid`);if(i&&ib(e,`${t}[data-testid="${rb(i)}"]`)){n.unshift(`${t}[data-testid="${rb(i)}"]`);break}let a=r.getAttribute(`aria-label`);if(a&&a.length<=80&&ib(e,`${t}[aria-label="${rb(a)}"]`)){n.unshift(`${t}[aria-label="${rb(a)}"]`);break}let o=1,s=r;for(;s=s.previousElementSibling;)s.tagName===r.tagName&&(o+=1);n.unshift(`${t}:nth-of-type(${o})`),r=r.parentElement}let a=n.join(` > `);for(;a.length>Yy&&n.length>1;)n.shift(),a=n.join(` > `);return a.length>Yy?``:a}function ob(e,t,n){let r=Jy.elementFromPoint(e,t,n);if(!r||r===Jy.documentElement(e)||r===Jy.body(e))return null;let i=r.closest?.(eb)||r,a=i.getBoundingClientRect();return a.width&&a.height?i:null}var sb=(e,t)=>e.length>t?`${e.slice(0,t-3)}...`:e;function cb(e,t,n){let r=ab(e,t),i=r?r.split(` > `).pop():t.tagName.toLowerCase(),a=tb(t),o=t.getBoundingClientRect(),s=(n?.width&&n?.height?o.width*o.height/(n.width*n.height):0)>.2;return{name:My(t.tagName.toLowerCase(),a,{large:s}),label:`${sb(i,48)}${a?` "${sb(a,28)}"`:``}`,large:s,rect:{left:o.left,top:o.top,width:o.width,height:o.height}}}function lb(e,t,n,r=null){let i=ob(e,t,n);if(!i)return null;let a=i.getBoundingClientRect(),o=e=>Math.max(0,Math.min(1,e)),s=ab(e,i);if(!s||!Qy.test(s))return null;let c=e=>Math.round(o(e)*1e4)/1e4;return{selector:s,text:tb(i).slice(0,$y),dx:c((t-a.left)/a.width),dy:c((n-a.top)/a.height),...r?.width&&r?.height?{w:c(a.width/r.width),h:c(a.height/r.height)}:{}}}function ub(e){let t=String(e).split(`>`).pop().trim(),n=/^([a-z][a-z0-9-]*)/i.exec(t);return n?n[1].toLowerCase():null}function db(e,t,n){let r=Jy.body(e);if(!r||!t?.selector||!n||!Qy.test(t.selector))return null;let i=String(t.text||``),a=e=>{if(!i)return!0;let t=tb(e);return t===i||t.startsWith(i)},o=null;try{o=Jy.querySelector(e,t.selector)}catch{o=null}o&&!a(o)&&(o=null);let s=ub(t.selector);if(!o&&i&&s){let e=null,t=1/0,n=Element.prototype.getElementsByTagName.call(r,s);for(let r=0;r<n.length&&r<Xy;r+=1){let a=n[r];if(tb(a)!==i)continue;let o=a.getBoundingClientRect(),s=o.width*o.height;s>0&&s<t&&(e=a,t=s)}o=e}if(!o)return null;let c=o.getBoundingClientRect();if(!c.width&&!c.height)return null;let l=(e,t)=>Math.max(0,Math.min(100,e/t*100));return{x:l(c.left+t.dx*c.width,n.width),y:l(c.top+t.dy*c.height,n.height),box:{left:l(c.left,n.width),top:l(c.top,n.height),right:l(c.right,n.width),bottom:l(c.bottom,n.height)}}}var fb=12,pb=new Map;function mb(e){if(pb.has(e)){let t=pb.get(e);return pb.delete(e),pb.set(e,t),t}let t=fetch(e,{headers:{Accept:`application/json`},credentials:`same-origin`}).then(e=>e.ok?e.json():null).then(e=>e?Ey(e):null).catch(()=>null);for(t.then(t=>{t||pb.delete(e)}),pb.set(e,t);pb.size>fb;)pb.delete(pb.keys().next().value);return t}function hb(e){let[t,n]=(0,J.useState)({url:null,map:null,state:`off`});return(0,J.useEffect)(()=>{if(!e)return;let t=!0;return mb(e).then(r=>{t&&n({url:e,map:r,state:r?`ready`:`failed`})}),()=>{t=!1}},[e]),e?t.url===e?t:{map:null,state:`loading`}:{map:null,state:`off`}}function gb(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)?t.href:null}catch{return null}}function _b({value:e,touch:t}){if(!e)return null;let n=gb(e);return(0,Y.jsxs)(`p`,{className:`mt-1 flex min-w-0 items-center gap-1 text-xs text-muted`,"data-sw-fix-ref":`true`,children:[(0,Y.jsx)(ig,{size:12,className:`shrink-0`,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Fixed in`}),` `,n?(0,Y.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer noopener`,className:O(`truncate text-accent hover:underline`,t&&`py-2`),children:e}):(0,Y.jsx)(`code`,{className:`truncate font-mono text-[11px] text-fg`,children:e})]})}var vb={open:ig,merged:eg,closed:ng};function yb({github:e,touch:t}){let n=e?.issue,r=e?.pulls||[];if(!n&&!r.length)return null;let i=O(`inline-flex min-w-0 items-center gap-1 text-accent hover:underline`,t&&`min-h-11`);return(0,Y.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-muted`,"data-sw-github":`true`,children:[n&&gb(n.url)?(0,Y.jsxs)(`a`,{href:gb(n.url),target:`_blank`,rel:`noreferrer noopener`,className:i,"data-sw-github-issue-link":n.number,children:[(0,Y.jsx)(vh,{size:12,className:`shrink-0`,"aria-hidden":`true`}),` Issue #`,n.number]}):null,r.map(e=>{let t=vb[e.state]||ig,n=gb(e.url);return n?(0,Y.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer noopener`,className:i,"aria-label":e.title?`PR #${e.number} ${e.state}: ${e.title}`:void 0,"data-sw-github-pull":e.number,"data-sw-github-pull-state":e.state,children:[(0,Y.jsx)(t,{size:12,className:`shrink-0`,"aria-hidden":`true`}),` PR #`,e.number,(0,Y.jsx)(`span`,{className:`text-faint`,children:e.state})]},e.number):null})]})}var bb={queued:{label:`Queued`,tone:`neutral`},working:{label:`Agent working`,tone:`accent`},done:{label:`Agent done`,tone:`ok`},"needs-human":{label:`Needs a person`,tone:`warn`},"branch-ready":{label:`Fix ready on branch`,tone:`warn`}};function xb({status:e,at:t=null,branch:n=null}){let r=bb[e];if(!r)return null;let i=e===`branch-ready`&&n,a=i?`${r.label} ${n}`:r.label;return(0,Y.jsxs)(Qe,{tone:r.tone,"aria-label":t?`Agent status: ${a} (${A(t)})`:`Agent status: ${a}`,"data-sw-agent-status":e,className:i?`max-w-full`:void 0,children:[(0,Y.jsx)(I,{size:10,"aria-hidden":`true`}),` `,i?(0,Y.jsxs)(Y.Fragment,{children:[r.label,` `,(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:n})]}):a]})}function Sb({comment:e}){return e.status!==`open`||!e.reopenCount?null:(0,Y.jsxs)(Qe,{tone:`bad`,"data-sw-reopened":e.reopenCount,children:[(0,Y.jsx)(m_,{size:10,"aria-hidden":`true`}),` Reopened`,e.reopenCount>1?` ${e.reopenCount}x`:``]})}function Cb({name:e,handle:t,agent:n}){return n===!0||n===void 0&&!t&&/agent|bot/i.test(e||``)}function wb({name:e,handle:t,agent:n,className:r}){let i=Cb({name:e,handle:t,agent:n});return(0,Y.jsxs)(`span`,{className:O(`inline-flex min-w-0 items-center gap-1`,r),children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold text-fg`,"data-sw-author":i?`agent`:`person`,children:e}),t?(0,Y.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`@`,t]}):null,n===!0?(0,Y.jsx)(Qe,{shape:`tag`,className:`bg-line text-fg`,children:`agent`}):null]})}var Tb=({name:e,handle:t})=>String(e||t||``).toLowerCase();function Eb({name:e,handle:t,agent:n,agentId:r=null,size:i=`md`,className:a}){return(0,Y.jsx)(de,{person:!0,agent:Cb({name:e,handle:t,agent:n}),agentId:r,name:e,colorKey:Tb({name:e,handle:t}),size:i,className:a})}var Db=e=>({name:e.author,handle:e.authorHandle,agent:e.authorAgent}),Ob=e=>({name:e.author,handle:e.handle,agent:e.agent,agentId:e.agentId||null}),kb=e=>`${e} ${e===1?`reply`:`replies`}`,Ab={a:`link`,button:`button`,input:`field`,textarea:`text box`,select:`menu`,img:`image`,svg:`icon`,h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,p:`text`,li:`list item`,label:`label`,nav:`navigation`,table:`table`,th:`column header`,td:`table cell`,form:`form`,header:`header`,footer:`footer`};function jb(e){if(!e)return null;let t=String(e.selector||``).split(` > `).pop(),n=Ab[/^([a-z][a-z0-9-]*)/i.exec(t)?.[1]?.toLowerCase()||``]||`element`,r=String(e.text||``).replace(/\s+/g,` `).trim();if(r){let e=r.length>48?`${r.slice(0,47)}…`:r;return n===`text`||n===`element`?`“${e}”`:`the “${e}” ${n}`}let i=(/\[(?:data-testid|aria-label|name|id)="([^"]+)"\]/.exec(t)?.[1]||/#([\w-]+)/.exec(t)?.[1]||``).replace(/[-_]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase().trim();return i?`the ${i} ${n}`:`a ${n}`}function Mb(e){let t=new Date(E(e));return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}):``}var Nb=(0,J.createContext)([]);function Pb({text:e,className:t,plain:n=!1}){let r=(0,J.useContext)(Nb),i=(0,J.useMemo)(()=>n?[{text:String(e??``)}]:Ce(e),[e,n]);return(0,Y.jsx)(`span`,{className:t,children:i.map((e,t)=>e.handle&&Te(e.handle,r)?(0,Y.jsxs)(`span`,{className:O(`inline-flex items-baseline gap-0.5 rounded px-1 font-medium`,Pe(e.handle)?`bg-warn/15 text-fg`:`bg-accent/10 text-accent`),"data-sw-mention":e.handle,children:[Pe(e.handle)?(0,Y.jsx)(I,{size:11,className:`self-center`,"aria-hidden":`true`}):null,e.text]},t):(0,Y.jsx)(`span`,{children:e.text},t))})}function Fb(e,t){let n=/(^|[^\w@.])@([\w.-]{0,40})$/.exec(e.slice(0,t));return n?{query:n[2].toLowerCase(),start:t-n[2].length-1}:null}function Ib({value:e,onChange:t,people:n,className:r,onKeyDown:i,size:a,...o}){let s=(0,J.useRef)(null),c=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let t=s.current,n=c.current;t&&n!==null&&t.value===e&&(c.current=null,t.focus(),t.setSelectionRange(n,n))},[e]);let l=(0,J.useId)(),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(0),m=(0,J.useMemo)(()=>{if(!u)return[];let{query:e}=u,t=e=>[e.handle,...e.aliases||[]],r=n.filter(e=>e.known!==!1).filter(n=>t(n).some(t=>t.startsWith(e))||n.name.toLowerCase().includes(e)).map(n=>({...n,exact:!!e&&t(n).includes(e)}));return[...r.filter(e=>e.exact),...r.filter(e=>!e.exact)].slice(0,6)},[n,u]),h=m.length>0,g=e=>{let t=Fb(e.value,e.selectionStart??e.value.length);d(t),p(0)},_=n=>{let r=s.current;if(!r||!u)return;let i=r.selectionStart??e.length,a=`@${n.handle} `;t(`${e.slice(0,u.start)}${a}${e.slice(i)}`),d(null),c.current=u.start+a.length};return(0,Y.jsxs)(lt,{open:h,onOpenChange:e=>e?null:d(null),history:!1,children:[(0,Y.jsx)(fe,{asChild:!0,children:(0,Y.jsx)(We,{ref:s,size:a,value:e,onChange:e=>{t(e.target.value),g(e.target)},onClick:e=>g(e.currentTarget),onBlur:()=>window.setTimeout(()=>d(null),150),onKeyDown:e=>{if(h&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),p(t=>(t+(e.key===`ArrowDown`?1:m.length-1))%m.length);return}if(e.key===`Enter`&&f===0&&m[0].exact)d(null);else if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),_(m[f]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation?.(),d(null);return}}i?.(e)},className:r,"aria-autocomplete":`list`,"aria-expanded":h,"aria-controls":h?l:void 0,"aria-activedescendant":h?`${l}-${f}`:void 0,...o})}),(0,Y.jsx)(ot,{id:l,role:`listbox`,"aria-label":`Mention someone`,side:`bottom`,className:`max-h-56 w-[var(--radix-popover-trigger-width)] overflow-y-auto`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{e.target===s.current&&e.preventDefault()},"data-sw-mention-list":`true`,children:m.map((e,t)=>(0,Y.jsx)(`div`,{id:`${l}-${t}`,role:`option`,"aria-selected":t===f,children:(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,onMouseDown:t=>{t.preventDefault(),_(e)},className:O(`flex w-full min-w-0 items-center gap-2 rounded-md px-2 text-left text-[13px]`,`h-11 lg:h-8`,t===f?`bg-accent/10 text-fg`:`text-muted hover:bg-surface-2`,`transition-colors`),"data-sw-mention-option":e.handle,children:[(0,Y.jsx)(de,{person:!0,agent:!!e.agent,name:e.name,colorKey:Tb(e),size:`sm`,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium text-fg`,children:e.agent?`@`+e.handle:e.name}),(0,Y.jsx)(`span`,{className:`min-w-0 shrink truncate text-xs text-faint`,children:e.agent?e.name===e.handle?`agent`:e.name:`@`+e.handle})]})},e.handle))})]})}var Lb={"false,false":`rounded-bl-none`,"true,false":`rounded-br-none`,"false,true":`rounded-tl-none`,"true,true":`rounded-tr-none`},Rb=`[@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:-inset-2 [@media(pointer:coarse)]:before:content-['']`;function zb(e,t,n,r,i=!1){let a=e=>Math.round(e*8)/8,o=t*e;if(o<150&&!i)return`dot:${a(Math.min(60,1/e))}`;let s=n?28:Math.max(18,Math.min(28,o/14));return`full:${a(Math.min(r,Math.max(.3,s/28/e)))||.125}`}function Bb(e){return e.status===`resolved`?`resolved`:e.agentStatus||(e.reopenCount?`reopened`:`open`)}var Vb={resolved:`border-ok`,"needs-human":`border-warn`,"branch-ready":`border-accent`,reopened:`border-bad`};function Hb(e,t,n=1){return{left:`${e.x}%`,top:`${e.y}%`,transform:`translate(${e.flipX?`-100%`:`0`}, ${e.flipY?`0`:`-100%`}) scale(${t*n})`,transformOrigin:`${e.flipY?`top`:`bottom`} ${e.flipX?`right`:`left`}`}}var Ub=e=>String(e||``).split(`
|
|
19
|
-
`)[0];function Wb({comment:e,moved:t}){let n=Db(e),r=e.replies?.length||0;return(0,Y.jsxs)(`div`,{"data-sw-pin-preview":e.id,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(Eb,{...n,size:`sm`}),(0,Y.jsx)(wb,{...n}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:A(e.createdAt)})]}),(0,Y.jsx)(Pb,{text:Ub(Me(e)),plain:!!e.authorGuest,className:`mt-1.5 line-clamp-2 block text-ui break-words text-fg`}),(0,Y.jsxs)(`p`,{className:`mt-1.5 flex flex-wrap items-center gap-x-2 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{children:r?kb(r):`No replies yet`}),e.status===`resolved`?(0,Y.jsx)(`span`,{className:`text-fg`,children:`Resolved`}):null,t?(0,Y.jsx)(`span`,{className:`text-fg`,children:`Its element is not on the page anymore`}):null]})]})}function Gb({dot:e=!1}){return(0,Y.jsx)(`span`,{className:O(`pointer-events-none absolute rounded-full ring-2 ring-accent motion-safe:animate-breathe`,e?`-inset-1`:`-inset-1.5`),"aria-hidden":`true`,"data-sw-pin-working":`true`})}function Kb({comment:e,spot:t,scale:n,selected:r,unread:i,working:a,onSelect:o,onHover:s,touch:c,label:l,landed:u=!1}){let d=Db(e),f=Cb(d);return(0,Y.jsx)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan absolute z-10 h-2.5 w-2.5 rounded-full border border-white shadow-card`,c&&`pointer-events-none`,e.status===`resolved`&&!r&&`opacity-60`,r?`z-20 ring-2 ring-accent`:i?`ring-2 ring-accent/70`:null,`data-[sw-pin-hover=true]:z-20 data-[sw-pin-hover=true]:ring-2 data-[sw-pin-hover=true]:ring-accent/60`),style:{left:`${t.x}%`,top:`${t.y}%`,transform:`translate(-50%, -50%) scale(${n})`,background:f?Oe:Ye(d.name)},onClick:t=>{t.stopPropagation(),o(e)},onMouseEnter:s?()=>s(e.id):void 0,onMouseLeave:s?()=>s(null):void 0,"aria-label":l,"aria-pressed":r,"data-sw-pin":e.id,"data-sw-pin-landed":u?`true`:void 0,"data-sw-pin-look":`dot`,"data-sw-pin-state":Bb(e),"data-sw-pin-unread":i?`true`:void 0,children:a?(0,Y.jsx)(Gb,{dot:!0}):null})}function qb({comment:e,position:t,scale:n,compact:r=!1,selected:i,unread:a,working:o=!1,landed:s=!1,onSelect:c,onHover:l,touch:f}){let p=ly(e,t),m=!!t?.moved,h=Db(e),g=Cb(h),_=Bb(e),v=1+(e.replies?.length||0),y=e.status===`resolved`,b=p.flipX?`-left-1.5`:`-right-1.5`,x=p.flipY?`-bottom-1.5`:`-top-1.5`,S=p.flipX?`-right-0.5`:`-left-0.5`,C=`Comment ${e.id} by ${h.name}${v>1?`, ${kb(v-1)}`:``}${y?`, resolved`:``}${a?`, unread`:``}${m?` (its element moved)`:``}${o?`, an agent is working on it`:``}: ${Me(e).slice(0,60)}`,w=r?(0,Y.jsx)(Kb,{comment:e,spot:p,scale:n,selected:i,unread:a,working:o,onSelect:c,onHover:l,touch:f,label:C,landed:s}):(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan absolute z-10 flex h-7 w-7 items-center justify-center rounded-full border-2 border-white text-[11px] leading-none font-semibold text-white shadow-pop transition-[box-shadow,opacity] select-none`,Lb[`${p.flipX},${p.flipY}`],Vb[_],Rb,m&&`outline-2 outline-offset-2 outline-warn outline-dashed`,y&&!i&&`opacity-75`,i?`z-20 ring-[3px] ring-accent`:`data-[sw-pin-hover=true]:z-20 data-[sw-pin-hover=true]:ring-[3px] data-[sw-pin-hover=true]:ring-accent/60`),style:{...Hb(p,n,i?1.15:1),background:g?Oe:Ye(h.name)},onClick:t=>{t.stopPropagation(),c(e)},onMouseEnter:l?()=>l(e.id):void 0,onMouseLeave:l?()=>l(null):void 0,"aria-label":C,"aria-pressed":i,"data-sw-pin":e.id,"data-sw-pin-landed":s?`true`:void 0,"data-sw-pin-state":_,"data-sw-pin-anchor":e.anchor?t?m?`moved`:`element`:`xy`:`none`,"data-sw-pin-unread":a?`true`:void 0,"data-sw-pin-count":v,"data-sw-pin-look":`full`,children:[o?(0,Y.jsx)(Gb,{}):null,g?(0,Y.jsx)(I,{size:14,"aria-hidden":`true`}):(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:Be(h.name)}),y?(0,Y.jsx)(`span`,{className:O(`absolute flex h-4 w-4 items-center justify-center rounded-full border border-white bg-ok text-ok-fg`,b,x),"aria-hidden":`true`,children:(0,Y.jsx)(st,{size:10,strokeWidth:3})}):v>1?(0,Y.jsx)(`span`,{className:O(`absolute flex h-4 min-w-4 items-center justify-center rounded-full border border-white bg-fg px-1 text-[9px] font-bold text-surface tabular`,b,x),"aria-hidden":`true`,children:v}):null,a?(0,Y.jsx)(`span`,{className:O(`absolute h-2.5 w-2.5 rounded-full border-2 border-white bg-accent`,S,p.flipY?`-bottom-0.5`:`-top-0.5`),"aria-hidden":`true`,"data-sw-pin-dot":`true`}):null]});return f||i?w:(0,Y.jsxs)(L,{children:[(0,Y.jsx)(u,{asChild:!0,children:w}),(0,Y.jsx)(d,{side:p.flipX?`left`:`right`,align:`start`,"data-sw-pin-preview":e.id,children:(0,Y.jsx)(Wb,{comment:e,moved:m})})]})}function Jb({items:e,scale:t,compact:n=!1,touch:r=!1,working:i=!1,onOpen:a}){let o=e[0].spot,s=e.some(e=>e.unread);return n?(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`tabular nodrag nopan absolute z-10 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border border-white bg-fg px-0.5 text-[8px] leading-none font-bold text-surface shadow-card`,r&&`pointer-events-none`,s&&`ring-2 ring-accent/70`),style:{left:`${o.x}%`,top:`${o.y}%`,transform:`translate(-50%, -50%) scale(${t})`},onClick:t=>{t.stopPropagation(),a(e)},"aria-label":`${e.length} comments here${s?`, some unread`:``}: zoom in`,"data-sw-pin-cluster":e.map(e=>e.comment.id).join(`,`),"data-sw-pin-look":`dot`,children:[e.length,i?(0,Y.jsx)(Gb,{dot:!0}):null]}):(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan absolute z-10 flex h-8 min-w-8 items-center justify-center rounded-full border-2 border-white bg-fg px-1.5 text-xs font-bold text-surface shadow-pop tabular`,Lb[`${o.flipX},${o.flipY}`],Rb),style:Hb(o,t),onClick:t=>{t.stopPropagation(),a(e)},"aria-label":`${e.length} comments here${s?`, some unread`:``}: zoom in`,"data-sw-pin-cluster":e.map(e=>e.comment.id).join(`,`),children:[e.length,i?(0,Y.jsx)(Gb,{}):null,s?(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -left-0.5 h-2.5 w-2.5 rounded-full border-2 border-white bg-accent`,"aria-hidden":`true`}):null]})}function Yb(e,t,n,r=null,i=30){let a=[];for(let o of e){let e=o.spot.x/100*t.w*n,s=o.spot.y/100*t.h*n;if(o.comment.id===r){a.push({items:[o],px:e,py:s,alone:!0});continue}let c=a.find(t=>!t.alone&&Math.hypot(t.px-e,t.py-s)<i);c?c.items.push(o):a.push({items:[o],px:e,py:s,alone:!1})}return a}function Xb({draft:e,scale:t,name:n,colorKey:r}){let i=ly(e);return(0,Y.jsx)(`span`,{className:O(`pointer-events-none absolute z-20 flex h-7 w-7 items-center justify-center rounded-full border-2 border-white text-[11px] font-semibold text-white shadow-pop ring-[3px] ring-accent`,Lb[`${i.flipX},${i.flipY}`]),style:{...Hb(i,t),background:Ye(r||n||`you`)},"aria-hidden":`true`,"data-sw-draft-pin":`true`,children:Be(n||`You`)})}var Zb=new Set,Qb={focusedKey:null,selectingKey:null,readingKey:null,settledZoom:null,selectedComment:null,draftSpot:null,unread:Zb,liveKeys:Zb,hoveredId:null,landedId:null,commentTargetKey:null};function $b(e=null){let t={...Qb,...e},n=new Set;return{get:()=>t,set(e){let r=null;for(let n of Object.keys(e))Object.is(t[n],e[n])||(r||={...t},r[n]=e[n]);if(r){t=r;for(let e of[...n])e()}},subscribe(e){return n.add(e),()=>n.delete(e)}}}var ex=$b(),tx=(0,J.createContext)(ex),nx=()=>(0,J.useContext)(tx);function rx(e){let t=(0,J.useContext)(tx),n=(0,J.useCallback)(()=>e(t.get()),[t,e]);return(0,J.useSyncExternalStore)(t.subscribe,n,n)}var ix=[];function ax(e,t){return t.agentStatus===`working`||!!e.agentWorking?.has(t.id)}function ox(e,t,n,r=!0){let i=rx(e=>{let i=e.selectedComment;return r&&i&&i.pageId===t&&i.viewport===n?i:null}),a=r?e.pinsFor(t,n):ix;return{pins:(0,J.useMemo)(()=>i&&!a.includes(i)?[...a,i]:a,[a,i]),openHere:i,selectedCommentId:i?.id??null}}function sx(e,t,{active:n=!0,drafting:r=!1}={}){let i=e.touch?50:6,a=$(a=>n?zb(a.transform[2],t.w,e.touch,i,r):`full:1`);return{pinScale:Number(a.slice(a.indexOf(`:`)+1)),compactPins:a.startsWith(`dot:`)}}function cx({pins:e,positions:t=null,frame:n,compact:r=!1,selectedCommentId:i=null}){let a=rx(t=>e.length?e.filter(e=>t.unread.has(e.id)).map(e=>e.id).join(`,`):``),o=$(t=>e.length>1?Math.round(t.transform[2]*20)/20:1);return(0,J.useMemo)(()=>{let s=new Set(a?a.split(`,`):[]);return Yb(e.map(e=>{let n=t?.get(e.id)||null;return{comment:e,position:n,spot:ly(e,n),unread:s.has(String(e.id))}}),n,o,i,r?12:void 0)},[e,t,a,n,o,i,r])}function lx(e){return rx(t=>t.landedId!==null&&e.some(e=>e.id===t.landedId)?t.landedId:null)}function ux({targetId:e,viewport:t,clusters:n,scale:r,compact:i=!1,selectedCommentId:a=null,landedId:o=null}){let s=(0,J.useContext)(Hv);return n.map(n=>n.items.length===1?(0,Y.jsx)(qb,{comment:n.items[0].comment,position:n.items[0].position,scale:r,compact:i,selected:a===n.items[0].comment.id,unread:n.items[0].unread,working:ax(s,n.items[0].comment),landed:o===n.items[0].comment.id,onSelect:s.onSelectComment,onHover:s.onHoverComment,touch:s.touch},n.items[0].comment.id):(0,Y.jsx)(Jb,{items:n.items,compact:i,touch:s.touch,working:n.items.some(e=>ax(s,e.comment)),scale:r,onOpen:n=>s.onOpenCluster(e,t,n)},`cluster-${n.items[0].comment.id}`))}function dx({label:e,keys:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,t.map(e=>(0,Y.jsx)(s,{children:e},e))]})}var fx=5242880,px=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`],mx=1600;function hx(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}async function gx(e,t,n=null){let r=await hx(e);return{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:t,mediaType:e.type,data:r.split(`,`)[1],preview:r,source:n}}function _x(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error(`The image could not be loaded.`)),r.src=e})}function vx(e,t,n,r=`image/png`){let i=Math.min(1,n/Math.max(t.width,t.height)),a=document.createElement(`canvas`);return a.width=Math.max(1,Math.round(t.width*i)),a.height=Math.max(1,Math.round(t.height*i)),a.getContext(`2d`).drawImage(e,t.x,t.y,t.width,t.height,0,0,a.width,a.height),new Promise((e,t)=>a.toBlob(n=>n?e(n):t(Error(`Could not crop the screenshot.`)),r,.9))}async function yx(e){let t=e.name||`That image`;if(!px.includes(e.type))throw Error(`${t} is not a PNG, JPEG, WebP or GIF image.`);if(e.size<=fx)return gx(e,e.name||`pasted-image.png`);let n=URL.createObjectURL(e);try{let r=await _x(n),i=await vx(r,{x:0,y:0,width:r.naturalWidth,height:r.naturalHeight},2048,`image/jpeg`);if(i.size>fx)throw Error(`${t} is larger than 5 MB.`);return gx(i,`${(e.name||`image`).replace(/\.\w+$/,``)}.jpg`)}finally{URL.revokeObjectURL(n)}}async function bx(e,{name:t,point:n=null,source:r}){let i=await _x(e),a=i.naturalWidth,o=i.naturalHeight,s={x:0,y:0,width:a,height:o};if(n){let e=Math.min(a,900),t=Math.min(o,700),r=n.x/100*a,i=n.y/100*o;s={x:Math.round(Math.min(Math.max(0,r-e/2),a-e)),y:Math.round(Math.min(Math.max(0,i-t/2),o-t)),width:e,height:t}}return gx(await vx(i,s,n?900:mx,n?`image/png`:`image/jpeg`),t,r)}function xx(e){return[...e||[]].filter(e=>e.type?.startsWith(`image/`))}var Sx=Object.keys(he).join(`,`),Cx=Je/1048576,wx=2560;async function Tx(e){let t=await createImageBitmap(e,{imageOrientation:`from-image`});try{let n=Math.min(1,wx/Math.max(t.width,t.height)),r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t.width*n)),r.height=Math.max(1,Math.round(t.height*n)),r.getContext(`2d`).drawImage(t,0,0,r.width,r.height);let i=await new Promise((e,t)=>r.toBlob(n=>n?e(n):t(Error(`The photo could not be read.`)),`image/jpeg`,.9));return new File([i],e.name||`photo.jpg`,{type:`image/jpeg`})}finally{t.close?.()}}async function Ex(e){let t=e.name?`"${e.name}"`:`That image`;if(!he[e.type])throw Error(`${t} is not a PNG, JPEG, WebP or GIF image.`);let n=e;if(e.type===`image/jpeg`&&typeof createImageBitmap==`function`)try{n=await Tx(e)}catch{throw Error(`${t} could not be read as an image.`)}let r=await yx(n).catch(e=>{throw Error(e.message?.includes(`5 MB`)?`${t} is larger than ${Cx} MB.`:e.message||`${t} could not be read.`)});if(r.data.length*3/4>5242880)throw Error(`${t} is larger than ${Cx} MB.`);return r}var Dx=e=>e.filter(e=>e.state===`ready`).map(({name:e,mediaType:t,data:n})=>({name:e,mediaType:t,data:n}));function Ox({enabled:e=!0,max:t=4,initial:n=null}={}){let[r,i]=(0,J.useState)(()=>e&&n?n.slice(0,t):[]),[a,o]=(0,J.useState)(null),s=(0,J.useRef)(0);return s.current=r.length,{images:r,error:a,setError:o,add:(0,J.useCallback)(async n=>{let r=[...n||[]];if(!e||!r.length)return;let a=t-s.current;if(a<=0)o(`A comment holds at most ${t} images.`);else{o(r.length>a?`Only ${a===1?`one more image fits`:`${a} more images fit`}: a comment holds ${t}.`:null);for(let e of r.slice(0,a)){let t=`img-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;s.current+=1,i(n=>[...n,{id:t,name:e.name||`pasted image`,preview:null,state:`reading`}]);try{let n=await Ex(e);i(e=>e.map(e=>e.id===t?{...n,id:t,state:`ready`}:e))}catch(e){--s.current,i(e=>e.filter(e=>e.id!==t)),o(e.message)}}}},[e,t]),remove:(0,J.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e)),o(null)},[]),clear:(0,J.useCallback)(()=>{i([]),o(null)},[]),reading:r.some(e=>e.state===`reading`)}}function kx(e){return[...e?.files||[]].filter(e=>e.type?.startsWith(`image/`))}var Ax=[`accent`,`bad`,`warn`],jx=2e3,Mx=8e-4;function Nx([e,t],[n,r],[i,a]){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0,u=n+l*o-e,d=r+l*s-t;return Math.sqrt(u*u+d*d)}function Px(e,t=Mx){if(e.length<=2)return e.slice();let n=new Uint8Array(e.length);n[0]=1,n[e.length-1]=1;let r=[[0,e.length-1]];for(;r.length;){let[i,a]=r.pop(),o=-1,s=-1;for(let t=i+1;t<a;t+=1){let n=Nx(e[t],e[i],e[a]);n>o&&(o=n,s=t)}s!==-1&&o>t&&(n[s]=1,r.push([i,s],[s,a]))}let i=e.filter((e,t)=>n[t]);return i.filter((e,t)=>t===0||e[0]!==i[t-1][0]||e[1]!==i[t-1][1])}function Fx(e){let t=1,n=1,r=0,i=0;for(let a of e?.shapes||[])for(let[e,o]of a.points)t=Math.min(t,e),n=Math.min(n,o),r=Math.max(r,e),i=Math.max(i,o);return r<t||i<n?null:{x:t,y:n,width:r-t,height:i-n}}var Ix={accent:`Accent`,bad:`Red`,warn:`Orange`},Lx=.004,Rx=null,zx=new Set,Bx=()=>zx.forEach(e=>e()),Vx={get:()=>Rx,start(e,t,n=[]){(Rx?.key!==e||Rx.owner!==t)&&(Rx={key:e,owner:t,tool:null,ink:Ax[0],shapes:n.slice(0,40)},Bx())},moveTo(e,t){Rx?.owner===t&&(Rx.key!==e&&(Rx={...Rx,key:e,shapes:[]}),Bx())},set(e){Rx&&(Rx={...Rx,...e},Bx())},add(e){!Rx||Rx.shapes.length>=40||(Rx={...Rx,shapes:[...Rx.shapes,e]},Bx())},undo(){Rx?.shapes.length&&(Rx={...Rx,shapes:Rx.shapes.slice(0,-1)},Bx())},clear(){Rx?.shapes.length&&(Rx={...Rx,shapes:[]},Bx())},end(e){Rx&&(!e||Rx.owner===e)&&(Rx=null,Bx())},subscribe(e){return zx.add(e),()=>zx.delete(e)}};function Hx(e=e=>e){return(0,J.useSyncExternalStore)(Vx.subscribe,()=>e(Rx),()=>e(null))}function Ux(e){return e?.length?{shapes:e}:void 0}var Wx=e=>Math.min(1,Math.max(0,e)),Gx=e=>Math.round(e*1e4)/1e4,Kx=(e,t)=>[Gx(Wx((t.clientX-e.left)/e.width)),Gx(Wx((t.clientY-e.top)/e.height))];function qx(e,t,n){if(!n.length)return null;if(e===`pen`){let r=Px(n.slice(0,jx));return r.length<2?null:{tool:e,ink:t,width:4,points:r}}let[r,i]=[n[0],n.at(-1)];return Math.hypot(i[0]-r[0],i[1]-r[1])<Lx?null:{tool:e,ink:t,width:4,points:[r,i]}}function Jx(e,t,n){let r=e.points.map(([e,r])=>[e*t,r*n]);if(e.tool===`box`){let[[e,t],[n,i]]=r;return[`M${e} ${t}H${n}V${i}H${e}Z`]}let i=`M${r.map(([e,t])=>`${e} ${t}`).join(`L`)}`;if(e.tool!==`arrow`)return[i];let[[a,o],[s,c]]=r,l=Math.atan2(c-o,s-a),u=Math.max(10,e.width*5),d=e=>`${s+Math.cos(l+e)*u} ${c+Math.sin(l+e)*u}`;return[i,`M${d(Math.PI*.82)}L${s} ${c}L${d(-Math.PI*.82)}`]}function Yx(e,t){let n=[],r=0;for(let i of[e,...e?.replies||[]]){if(!i?.drawing?.shapes?.length)continue;let e=i.drawing.captureVersion;!e||!t||e===t?n.push(...i.drawing.shapes):r+=1}return{shapes:n,previous:r}}var Xx=e=>[e,...e?.replies||[]].some(e=>e?.drawing?.shapes?.length),Zx=[{id:`box`,label:`Box`,start:`Draw a box on the page`,icon:W_},{id:`arrow`,label:`Arrow`,start:`Draw an arrow on the page`,icon:ih},{id:`pen`,label:`Pen`,start:`Draw freehand on the page`,icon:ch}],Qx={accent:`bg-accent`,bad:`bg-bad`,warn:`bg-warn`},$x={accent:`var(--accent)`,bad:`var(--bad)`,warn:`var(--warn)`};function eS({shapes:e,width:t,height:n,crop:r=null,className:i,...a}){if(!e?.length)return null;let o=r?`${r.left} ${r.top} ${r.width} ${r.height}`:`0 0 ${t} ${n}`;return(0,Y.jsx)(`svg`,{className:O(`pointer-events-none absolute inset-0 h-full w-full`,r?`overflow-hidden`:`overflow-visible`,i),viewBox:o,preserveAspectRatio:`none`,"aria-hidden":`true`,...a,children:e.map((e,r)=>Jx(e,t,n).map((t,n)=>(0,Y.jsx)(`path`,{d:t,fill:`none`,stroke:$x[e.ink]||$x.accent,strokeWidth:e.width,strokeLinecap:`round`,strokeLinejoin:`round`},`${r}-${n}`)))})}function tS({tool:e,ink:t,width:n,height:r,className:i,children:a}){let[o,s]=(0,J.useState)(null),c=(0,J.useRef)([]),l=(0,J.useRef)(null),u=e=>Kx(l.current.getBoundingClientRect(),e);(0,J.useEffect)(()=>()=>Vx.set({stroking:!1}),[]);let d=(n,r)=>{if(!c.current.length)return;Vx.set({stroking:!1}),n.currentTarget.releasePointerCapture?.(n.pointerId);let i=r?qx(e,t,c.current):null;c.current=[],s(null),i&&Vx.add(i)};return(0,Y.jsxs)(`div`,{ref:l,className:O(`nodrag nopan absolute inset-0 z-[25] cursor-crosshair touch-none select-none`,i),onPointerDown:n=>{n.button===0&&(n.preventDefault(),n.stopPropagation(),n.currentTarget.setPointerCapture?.(n.pointerId),Vx.set({stroking:!0}),c.current=[u(n)],s({tool:e,ink:t,width:4,points:[c.current[0],c.current[0]]}))},onPointerMove:n=>{if(!c.current.length)return;n.stopPropagation();let r=u(n);e===`pen`?c.current.push(r):c.current=[c.current[0],r],s({tool:e,ink:t,width:4,points:e===`pen`?[...c.current]:c.current})},onPointerUp:e=>d(e,!0),onPointerCancel:e=>d(e,!1),onClick:e=>e.stopPropagation(),"data-sw-draw-input":e,children:[a,o?(0,Y.jsx)(eS,{shapes:[o],width:n,height:r}):null]})}function nS({frameKey:e,native:t,shown:n}){let r=Hx(t=>t?.key===e?t:null);return!r&&!n?.shapes.length?null:(0,Y.jsxs)(Y.Fragment,{children:[n?.shapes.length?(0,Y.jsx)(eS,{shapes:n.shapes,width:t.width,height:t.height,className:`z-[6]`,"data-sw-drawing":n.id}):null,r?(0,Y.jsx)(eS,{shapes:r.shapes,width:t.width,height:t.height,className:`z-[6]`,"data-sw-drawing":`draft`}):null,r?.tool?(0,Y.jsx)(tS,{tool:r.tool,ink:r.ink,width:t.width,height:t.height}):null]})}function rS(e){(0,J.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),Vx.set({tool:null}))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e])}function iS({touch:e,label:t,tooltip:n,narrow:r,className:i,...o}){return e?(0,Y.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":t,className:i,...o}):(0,Y.jsx)(B,{size:`icon-sm`,label:t,tooltip:n,className:O(r?`w-6`:`w-7`,i),...o})}var aS=({touch:e})=>(0,Y.jsx)(`span`,{className:O(`h-4 w-px shrink-0 bg-line`,e?`mx-1`:`mx-0.5`),"aria-hidden":`true`});function oS({owner:e,touch:t,onTool:n=null,leading:r=null,compact:i=!1,showCount:a=!0,bar:o=!1,className:s}){let c=Hx(t=>t?.owner===e?t:null);rS(!!c?.tool);let l=c?.shapes.length||0,u=!i||!!c?.tool||l>0;return(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-center`,t?`flex-wrap gap-y-0.5`:`flex-nowrap`,s),role:`group`,"aria-label":`Draw on the page`,"data-sw-draw-tools":e,children:[r?(0,Y.jsxs)(Y.Fragment,{children:[r,(0,Y.jsx)(aS,{touch:t})]}):null,i&&!u?(0,Y.jsx)(`span`,{className:`shrink-0 pr-1 pl-0.5 text-caption text-faint`,"aria-hidden":`true`,"data-sw-draw-label":`true`,children:`Draw`}):null,Zx.map(e=>{let r=c?.tool===e.id;return(0,Y.jsx)(iS,{touch:t,variant:r?`soft`:`ghost`,"aria-pressed":r,className:O(r&&`ring-1 ring-accent/50`),label:r?`${e.label}: on. Draw on the page, Esc stops`:e.start,tooltip:o||r?e.label:e.start,onClick:()=>{Vx.set({tool:r?null:e.id}),r||n?.(e.id)},"data-sw-draw-tool":e.id,children:(0,Y.jsx)(e.icon,{size:15,"aria-hidden":`true`})},e.id)}),u?(0,Y.jsxs)(Y.Fragment,{children:[t?(0,Y.jsx)(`span`,{className:`h-0 basis-full`,"aria-hidden":`true`,"data-sw-draw-tools-break":`true`}):(0,Y.jsx)(aS,{touch:t}),Ax.map(e=>{let n=(c?.ink||Ax[0])===e;return(0,Y.jsx)(iS,{touch:t,narrow:!0,"aria-pressed":n,label:`${Ix[e]} ink`,tooltip:`${Ix[e]} ink`,onClick:()=>Vx.set({ink:e}),"data-sw-draw-ink":e,children:(0,Y.jsx)(`span`,{className:O(`block h-3.5 w-3.5 rounded-full`,Qx[e],n?`ring-2 ring-fg ring-offset-1 ring-offset-surface`:``),"aria-hidden":`true`})},e)}),(0,Y.jsx)(aS,{touch:t}),(0,Y.jsx)(iS,{touch:t,label:`Undo the last shape`,tooltip:`Undo`,disabled:!l,onClick:()=>Vx.undo(),"data-sw-draw-undo":`true`,children:(0,Y.jsx)(ev,{size:15,"aria-hidden":`true`})}),(0,Y.jsx)(iS,{touch:t,label:`Clear the drawing`,tooltip:`Clear`,disabled:!l,onClick:()=>Vx.clear(),"data-sw-draw-clear":`true`,children:(0,Y.jsx)(X_,{size:15,"aria-hidden":`true`})})]}):null,a&&l?(0,Y.jsx)(sS,{count:l,className:`ml-auto pl-1`}):null]})}function sS({count:e,className:t}){return(0,Y.jsxs)(`span`,{className:O(`shrink-0 text-caption whitespace-nowrap text-faint tabular-nums`,t),"aria-live":`polite`,"data-sw-draw-count":e,children:[e,` `,e===1?`shape`:`shapes`]})}function cS({owner:e,title:t}){let n=e===`composer`?`your comment`:`your reply`,r=Hx(e=>!!e?.stroking);return(0,Y.jsxs)(`div`,{className:O(`pointer-events-none flex max-w-full items-center gap-2 rounded-xl border border-accent/50 bg-surface py-1 pr-1 pl-3 shadow-pop ring-2 ring-accent/15 transition-opacity duration-(--motion-fast) motion-reduce:transition-none`,r?`opacity-25 [&_button]:pointer-events-none`:`[&_button]:pointer-events-auto`),"data-sw-draw-bar-stroking":r?`true`:void 0,role:`toolbar`,"aria-label":t?`Drawing on ${t}`:`Drawing on the page`,"data-sw-draw-bar":e,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-xs font-semibold text-fg`,"data-sw-draw-bar-title":`true`,children:[(0,Y.jsx)(ch,{size:14,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t?`Drawing on ${t}`:`Drawing on the page`})]}),(0,Y.jsx)(`span`,{className:`h-5 w-px shrink-0 bg-line`,"aria-hidden":`true`}),(0,Y.jsx)(oS,{owner:e,touch:!1,bar:!0}),(0,Y.jsx)(_,{content:(0,Y.jsx)(dx,{label:`Back to ${n}`,keys:[`Esc`]}),side:`top`,children:(0,Y.jsx)(a,{size:`xs`,variant:`default`,className:`ml-1 shrink-0 px-3`,onClick:()=>Vx.set({tool:null}),"aria-label":`Done drawing: back to ${n}`,"data-sw-draw-bar-done":`true`,children:`Done`})})]})}function lS({open:e,onClose:t,owner:n,src:r,native:i,title:o}){let s=Hx(e=>e?.owner===n?e:null);if((0,J.useEffect)(()=>{e&&s&&!s.tool&&Vx.set({tool:`box`})},[e,!!s]),!i)return null;let c=()=>{Vx.set({tool:null}),t()};return(0,Y.jsxs)(N,{open:e,onClose:c,title:`Draw on the page`,description:o,size:`lg`,className:`max-h-[100dvh] rounded-none sm:rounded-xl`,footer:(0,Y.jsxs)(`div`,{className:`flex w-full items-center gap-3 sm:w-auto`,children:[s?.shapes.length?(0,Y.jsx)(sS,{count:s.shapes.length}):null,(0,Y.jsx)(a,{size:`touch`,className:`flex-1 sm:flex-none`,onClick:c,"data-sw-draw-done":`true`,children:`Done`})]}),children:[(0,Y.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-line bg-surface px-2 py-1`,children:(0,Y.jsx)(oS,{owner:n,touch:!0,showCount:!1})}),(0,Y.jsx)(`div`,{className:`p-3`,children:(0,Y.jsxs)(`div`,{className:`relative w-full overflow-hidden rounded-md border border-line bg-surface-2`,style:{aspectRatio:`${i.width} / ${i.height}`},"data-sw-draw-sheet":`true`,children:[r?(0,Y.jsx)(`img`,{src:r,alt:`The page this comment is on`,className:`block h-full w-full object-cover object-top select-none`,draggable:!1}):null,(0,Y.jsx)(eS,{shapes:s?.shapes,width:i.width,height:i.height}),s?.tool?(0,Y.jsx)(tS,{tool:s.tool,ink:s.ink,width:i.width,height:i.height}):null]})})]})}function uS({draft:e,touch:t,disabled:n}){let r=(0,J.useRef)(null),i=e.images.length>=4;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{size:t?`icon`:`icon-sm`,className:t?void 0:`w-7`,label:i?`Attach an image (4 is the most)`:`Attach an image`,tooltip:i?`4 images is the most`:`Attach an image (or paste one)`,disabled:n||i,onClick:()=>r.current?.click(),"data-sw-attach-image":`true`,children:(0,Y.jsx)(ug,{size:16,"aria-hidden":`true`})}),(0,Y.jsx)(`input`,{ref:r,type:`file`,accept:Sx,multiple:!0,hidden:!0,tabIndex:-1,"aria-hidden":`true`,onChange:t=>{e.add(t.target.files),t.target.value=``},"data-sw-attach-input":`true`})]})}function dS(e,t){return t?{onPaste:t=>{let n=kx(t.clipboardData);n.length&&(t.preventDefault(),e.add(n))},onDragOver:e=>{[...e.dataTransfer?.types||[]].includes(`Files`)&&e.preventDefault()},onDrop:t=>{let n=kx(t.dataTransfer);n.length&&(t.preventDefault(),e.add(n))}}:{}}function fS({draft:e,touch:t,id:n}){return!e.images.length&&!e.error?null:(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[e.images.length?(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":`Images to attach`,"data-sw-composer-images":e.images.length,children:e.images.map(n=>(0,Y.jsxs)(`li`,{className:O(`relative overflow-hidden rounded-md border border-line bg-surface-2`,t?`h-16 w-16`:`h-14 w-14`),"data-sw-composer-image":n.state,children:[n.preview?(0,Y.jsx)(`img`,{src:n.preview,alt:n.name,className:`h-full w-full object-cover`,draggable:!1}):(0,Y.jsx)(`span`,{className:`flex h-full w-full items-center justify-center text-faint`,role:`status`,"aria-label":`Reading ${n.name}`,children:(0,Y.jsx)(Og,{size:16,className:`animate-spin motion-reduce:animate-none`,"aria-hidden":`true`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.remove(n.id),className:O(`absolute top-0 right-0 flex items-center justify-center rounded-bl-md bg-black/60 text-white outline-none hover:bg-black/75 focus-visible:ring-2 focus-visible:ring-accent`,t?`h-7 w-7`:`h-5 w-5`),"aria-label":`Remove ${n.name}`,"data-sw-composer-image-remove":n.id,children:(0,Y.jsx)(se,{size:t?14:12,"aria-hidden":`true`})})]},n.id))}):null,e.error?(0,Y.jsx)(`p`,{id:n,className:`text-xs text-bad`,role:`alert`,"data-sw-image-error":`true`,children:e.error}):null]})}function pS({boardId:e,images:t,touch:n,label:r}){let[i,a]=(0,J.useState)(null);if((0,J.useEffect)(()=>{if(i===null)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),a(null))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[i]),!t?.length)return null;let o=i===null?null:t[i],s=e=>a(n=>(n+e+t.length)%t.length);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`ul`,{className:`mt-1.5 flex flex-wrap gap-1.5`,"aria-label":`${r}: images`,"data-sw-message-images":t.length,children:t.map((r,i)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(i),className:O(`block overflow-hidden rounded-md border border-line bg-surface-2 outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-accent`,n?`h-16 w-16`:`h-14 w-14`),"aria-label":`Open image ${i+1} of ${t.length}: ${r.name}`,"data-sw-message-image":r.file,children:(0,Y.jsx)(`img`,{src:ae(e,r.file),alt:``,className:`h-full w-full object-cover`,loading:`lazy`,draggable:!1})})},r.file))}),(0,Y.jsx)(N,{open:o!==null,onClose:()=>a(null),title:o?.name||`Image`,description:o?`Image ${i+1} of ${t.length}${o.width?`, ${o.width} by ${o.height} pixels`:``}`:``,size:`lg`,children:o?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-4`,onKeyDown:e=>{if(!(t.length<2)){if(e.key===`ArrowRight`)s(1);else if(e.key===`ArrowLeft`)s(-1);else return;e.preventDefault()}},"data-sw-lightbox":o.file,children:[(0,Y.jsx)(`img`,{src:ae(e,o.file),alt:o.name,className:`max-h-[70dvh] max-w-full rounded-md border border-line bg-surface-2 object-contain`,draggable:!1}),t.length>1?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(B,{size:n?`icon`:`icon-sm`,label:`Previous image`,onClick:()=>s(-1),"data-sw-lightbox-prev":`true`,children:(0,Y.jsx)(ut,{size:16,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`text-caption text-muted tabular-nums`,children:[i+1,` of `,t.length]}),(0,Y.jsx)(B,{size:n?`icon`:`icon-sm`,label:`Next image`,onClick:()=>s(1),"data-sw-lightbox-next":`true`,children:(0,Y.jsx)(nt,{size:16,"aria-hidden":`true`})})]}):null]}):null})]})}var mS=typeof window<`u`?Math.min(window.devicePixelRatio||1,2):1;function hS(e,t,n){return!t||!n?!1:e.w*t*mS>n.width*(n.thumbScale||.25)*1.05}function gS({src:e,viewport:t,native:n,frame:r,selecting:i,opaque:a,onReady:o,onLeave:s}){let c=r.w/n.width,l=(0,J.useRef)(null),[u,d]=(0,J.useState)(!1);return(0,J.useEffect)(()=>()=>o(null),[o]),(0,Y.jsx)(`iframe`,{ref:l,src:e,title:`Live ${t} page`,sandbox:a?``:`allow-same-origin`,referrerPolicy:`no-referrer`,tabIndex:i?0:-1,onLoad:()=>{if(a){d(!0),o(!0);return}let e=l.current?.contentDocument;if(!e)return;let t=e=>e.preventDefault();Jy.addEventListener(e,`click`,t,!0),Jy.addEventListener(e,`submit`,t,!0),Jy.addEventListener(e,`auxclick`,t,!0),d(!0),o(e)},onMouseLeave:i?s:void 0,className:O(`absolute top-0 left-0 origin-top-left border-0 bg-white transition-opacity duration-(--motion-base)`,u?`opacity-100`:`opacity-0`,i?`nodrag nopan nowheel`:`pointer-events-none`),style:{width:n.width,height:n.height,transform:`scale(${c})`},"data-sw-live-frame":t})}function _S({targetId:e,frame:t,image:n,kind:r,version:i,emptyText:a,note:o}){let s=(0,J.useContext)(Hv),c=t.native||s.viewports[t.viewport],{viewport:l}=t,u=`${e}|${l}`,d=!!s.compare,{pins:f,openHere:p,selectedCommentId:m}=ox(s,e,l),h=rx(e=>d||e.hoveredId===null?null:f.find(t=>t.id===e.hoveredId&&Xx(t))||null),g=p&&Xx(p)?p:h,_=(0,J.useMemo)(()=>{if(!g)return null;let t=String(e).startsWith(`variant:`)?null:yv(s.manifest?.pages?.[e]?.[l],s.manifest);return{id:g.id,...Yx(g,t)}},[g,e,l,s.manifest]),v=rx(t=>{let n=t.draftSpot;return n&&n.pageId===e&&n.viewport===l?n:null}),y=rx(e=>!!n?.live&&e.liveKeys.has(u)),{pinScale:b,compactPins:x}=sx(s,t,{active:f.length>0||!!v||s.commentMode&&y,drafting:!!v}),S=rx(e=>e.selectingKey===u)&&y&&!s.commentMode,C=rx(e=>e.readingKey===u)&&S,{onReading:w}=s;(0,J.useEffect)(()=>{if(S)return()=>w(null)},[S,w]),(0,J.useEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&w(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,w]);let T=rx(e=>e.focusedKey===u),E=n?.live&&n.elements||null,D=!!E||!s.domFallback,{map:k,state:A}=hb(y&&E?s.elementsUrl(r,E,i):null),[j,ee]=(0,J.useState)(!1),[M,N]=(0,J.useState)(null),[P,F]=(0,J.useState)(0),I=y&&(D?j&&A!==`loading`:!!M),L=y&&D?k:null,R=(0,J.useMemo)(()=>{if(!y||!(L||M))return null;let e=new Map;for(let t of f){if(!t.anchor)continue;let n=L?Hy(L,t.anchor,c):db(M,t.anchor,c);e.set(t.id,n||{x:t.x,y:t.y,moved:!0})}return e},[y,L,M,f,c,P]),z=lx(f),te=cx({pins:f,positions:R,frame:t,compact:x,selectedCommentId:m});(0,J.useEffect)(()=>{let e=Jy.defaultView(M);if(!e)return;let t=()=>F(e=>e+1);Jy.addEventListener(e,`resize`,t);let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(Jy.documentElement(M)),()=>{Jy.removeEventListener(e,`resize`,t),n?.disconnect()}},[M]);let{setLiveReady:B}=s,V=(0,J.useCallback)(e=>{ee(!!e),N(e&&e!==!0?e:null)},[]);(0,J.useEffect)(()=>{B(u,I)},[u,I,B]),(0,J.useEffect)(()=>()=>B(u,!1),[u,B]);let ne=rx(e=>hS(t,e.settledZoom,c)),H=!n?.thumb||y||ne,U=n?s.imageUrl(r,H?n.file:n.thumb,i):null,re=rx(yS),ie=Hx(bS),ae=Hx(e=>!!e?.tool&&e.key===u),W=s.commentMode&&!re&&!ie,[G,oe]=(0,J.useState)(null),se=(0,J.useRef)(0),ce=W&&y&&!!(L||M)&&!s.touch;(0,J.useEffect)(()=>{ce||oe(null)},[ce]),(0,J.useEffect)(()=>()=>window.cancelAnimationFrame(se.current),[]);let le=e=>{if(!ce)return;let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*c.width,r=(e.clientY-t.top)/t.height*c.height;window.cancelAnimationFrame(se.current),se.current=window.requestAnimationFrame(()=>{if(L){let e=ky(L,n,r);oe(e>=0?Ny(L,e,c):null);return}let e=ob(M,n,r);oe(e?cb(M,e,c):null)})},ue=n=>{n.stopPropagation(),S?C||w(u):s.commentMode?de(n.currentTarget.getBoundingClientRect(),n.clientX,n.clientY):s.onFocusFrame(e,t.viewport)},de=(n,r,i,a=!0)=>{let o=(r-n.left)/n.width,l=(i-n.top)/n.height,u={pageId:e,viewport:t.viewport,x:Math.max(0,Math.min(100,o*100)),y:Math.max(0,Math.min(100,l*100))};if(a&&y&&(L||M)){let e=o*c.width,t=l*c.height,n=L?Py(L,e,t,c):lb(M,e,t,c);n&&(u.anchor=n,u.target=My(L?L.elements[ky(L,e,t)]?.t:ob(M,e,t)?.tagName.toLowerCase(),n.text))}oe(null),s.onPin(u)},fe=rx(e=>e.commentTargetKey===u)&&W,pe=e=>{if(e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),n=e.currentTarget.closest(`[data-sw-canvas]`)?.getBoundingClientRect()||t,r=Math.min(24,t.width*.04,t.height*.04),i=Math.min(t.right-r,Math.max(t.left,n.left)+r),a=Math.min(t.bottom-r,Math.max(t.top,n.top)+r);de(t,i,a,!1)};return(0,Y.jsxs)(Y.Fragment,{children:[t.y>12?(0,Y.jsxs)(vS,{frame:t,children:[t.viewport,y?(0,Y.jsx)(`span`,{className:`text-accent`,children:` · live`}):null]}):null,(0,Y.jsxs)(`div`,{className:O(`absolute rounded-sm border border-line bg-surface-2`,W&&`nodrag nopan cursor-crosshair`,S&&!C&&`cursor-text`,y&&`border-accent/60`,T&&!ae&&`outline-2 outline-offset-2 outline-accent`,fe&&`focus-visible:outline-4`,ae&&`outline-solid outline-accent`),style:{left:t.x,top:t.y,width:t.w,height:t.h,...ae?{outlineWidth:3*b,outlineOffset:2*b}:null},onClick:ue,tabIndex:fe?0:void 0,role:fe?`group`:void 0,"aria-label":fe?`The ${t.viewport} page: press Enter to comment at its top left, or click where the comment goes`:void 0,onKeyDown:fe?pe:void 0,"data-sw-comment-target":fe?`true`:void 0,onMouseMove:ce?le:void 0,onMouseLeave:ce?()=>oe(null):void 0,"data-sw-frame":`${e}:${t.viewport}`,"data-sw-image":U?H?`full`:`thumb`:`none`,"data-sw-live":y?I?`ready`:`loading`:`off`,"data-sw-live-anchors":y?D?L?`map`:`none`:`dom`:void 0,"data-sw-draw-surface":ae?`true`:void 0,"data-sw-select-text-state":S?C?`reading`:`armed`:void 0,children:[(0,Y.jsxs)(`div`,{className:`absolute inset-0 overflow-hidden rounded-sm`,"data-sw-frame-clip":`true`,children:[U?(0,Y.jsx)(`img`,{src:U,alt:`${t.viewport} screenshot`,loading:`lazy`,decoding:`async`,draggable:!1,onError:s.onImageError,className:`pointer-events-none block h-full w-full object-cover object-top select-none`}):(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center`,children:[(0,Y.jsx)(cg,{size:22,className:`text-faint`,"aria-hidden":`true`}),(0,Y.jsx)(`p`,{className:`text-[11px] leading-4 text-muted`,children:a})]}),y?(0,Y.jsx)(gS,{src:s.liveUrl(r,n.live,i),viewport:t.viewport,native:c,frame:t,selecting:C,opaque:D,onReady:V,onLeave:()=>w(null)},D?`opaque`:`dom`):null,o&&!y?(0,Y.jsxs)(`p`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-start gap-1 bg-surface/90 px-1.5 py-1 text-[9.5px] leading-[13px] text-muted`,"data-sw-page-note":`true`,children:[(0,Y.jsx)(mg,{size:10,className:`mt-px shrink-0`,"aria-hidden":`true`}),` `,o]}):null,G&&ce?(0,Y.jsx)(CS,{hover:G,native:c,scale:b}):null,v?.anchor&&!ie?(0,Y.jsx)(xS,{draft:v,scale:b}):null,p?.anchor?(0,Y.jsx)(SS,{comment:p,box:R?.get(p.id)?.box||null}):null,d?null:(0,Y.jsx)(nS,{frameKey:u,native:c,shown:_})]}),(0,Y.jsx)(ux,{targetId:e,viewport:l,clusters:te,scale:b,compact:x,selectedCommentId:m,landedId:z}),v?(0,Y.jsx)(Xb,{draft:v,scale:b,name:s.me?.name,colorKey:s.me?.name}):null]})]})}function vS({frame:e,children:t}){return(0,Y.jsx)(`span`,{className:`pointer-events-none absolute z-10 flex origin-bottom-left items-center gap-1 truncate text-[10.5px] leading-4 font-semibold tracking-wide text-muted uppercase`,style:{left:e.x,top:e.y-19,width:`calc(${e.w}px / var(--sw-label-scale, 1))`,transform:`scale(var(--sw-label-scale, 1))`},"data-sw-frame-label":e.env?`${e.viewport}:${e.env}`:e.viewport,children:t})}var yS=e=>!!e.draftSpot,bS=e=>!!e?.tool;function xS({draft:e,scale:t}){let{anchor:n}=e;return!n.w||!n.h?null:(0,Y.jsx)(`div`,{className:`pointer-events-none absolute z-[5] rounded-[2px] border-solid border-accent`,style:{left:`${e.x-n.dx*n.w*100}%`,top:`${e.y-n.dy*n.h*100}%`,width:`${n.w*100}%`,height:`${n.h*100}%`,borderWidth:2*t},"data-sw-picked-outline":`true`})}function SS({comment:e,box:t}){let{anchor:n}=e;if(!t&&(!n.w||!n.h))return null;let r=t?{left:`${t.left}%`,top:`${t.top}%`,width:`${t.right-t.left}%`,height:`${t.bottom-t.top}%`}:{left:`${e.x-n.dx*n.w*100}%`,top:`${e.y-n.dy*n.h*100}%`,width:`${n.w*100}%`,height:`${n.h*100}%`};return(0,Y.jsx)(`div`,{className:`pointer-events-none absolute`,style:r,"aria-hidden":`true`,"data-sw-thread-target":e.id})}function CS({hover:e,native:t,scale:n}){let{rect:r}=e,i=(e,t)=>`${e/t*100}%`,a=r.top/t.height<.04;return(0,Y.jsx)(`div`,{className:O(`pointer-events-none absolute z-[5] rounded-[2px] border-accent bg-accent/5`,e.large?`border-dashed`:`border-solid`),style:{left:i(r.left,t.width),top:i(r.top,t.height),width:i(r.width,t.width),height:i(r.height,t.height),borderWidth:2*n},"data-sw-hover-outline":e.large?`large`:`element`,children:(0,Y.jsx)(`span`,{className:`absolute left-0 max-w-[320px] truncate rounded-sm bg-accent px-1.5 text-[11px] leading-[18px] font-medium whitespace-nowrap text-accent-fg`,style:{[a?`top`:`bottom`]:`100%`,transform:`scale(${n})`,transformOrigin:a?`top left`:`bottom left`,marginTop:a?2*n:0,marginBottom:a?0:2*n},"data-sw-hover-label":`true`,"data-sw-hover-selector":e.label,children:e.name})})}function wS({pageId:e,frame:t}){let n=(0,J.useContext)(Hv),{compare:r}=n,{viewport:i}=t,a=t.native||n.viewports[i],{pins:o,openHere:s,selectedCommentId:c}=ox(n,e,i,uy(t,r)),{pinScale:l,compactPins:u}=sx(n,t,{active:o.length>0}),d=lx(o),f=cx({pins:o,frame:t,compact:u,selectedCommentId:c}),p=r.files?.[t.env]?.[e]?.[t.viewport],m=rx(e=>hS(t,e.settledZoom,a)),h=p&&(!p.thumb||m),g=p?n.imageUrl(r.kindOf(t.env),h?p.file:p.thumb,r.versionOf(t.env)):null,_=r.pages?.[e]?.[t.viewport],v=p?null:r.failures?.[t.env]?.[e]?.[t.viewport]||null,y=t.env===r.b,b=y&&r.showDiff&&_?.status===`ok`&&_.percent>0?_.diff:null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(vS,{frame:t,children:[t.viewport,` · `,r.titleOf(t.env),y&&_?.status===`ok`?(0,Y.jsxs)(`span`,{className:`text-accent`,children:[` · `,_.percent,`% changed`]}):null]}),(0,Y.jsxs)(`div`,{className:`absolute rounded-sm border border-line bg-surface-2`,style:{left:t.x,top:t.y,width:t.w,height:t.h},"data-sw-frame":`${e}:${t.viewport}:${t.env}`,"data-sw-image":g?h?`full`:`thumb`:`none`,children:[(0,Y.jsxs)(`div`,{className:`absolute inset-0 overflow-hidden rounded-sm`,"data-sw-frame-clip":`true`,children:[g?(0,Y.jsx)(`img`,{src:g,alt:`${t.viewport} screenshot, ${r.titleOf(t.env)}`,loading:`lazy`,decoding:`async`,draggable:!1,onError:n.onImageError,className:`pointer-events-none block h-full w-full object-cover object-top select-none`}):(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center`,children:[(0,Y.jsx)(cg,{size:22,className:`text-faint`,"aria-hidden":`true`}),(0,Y.jsx)(`p`,{className:`text-[11px] leading-4 text-muted`,"data-sw-compare-failed":v?`true`:void 0,children:v?`Capture failed: ${v}`:`Not captured in ${r.titleOf(t.env)} yet.`})]}),b?(0,Y.jsx)(`img`,{src:n.imageUrl(r.diffKind,b,r.diffVersion),alt:``,draggable:!1,className:`pointer-events-none absolute inset-0 block h-full w-full object-cover object-top opacity-80 select-none`,"data-sw-diff-overlay":`true`}):null,s?.anchor?(0,Y.jsx)(SS,{comment:s,box:null}):null]}),(0,Y.jsx)(ux,{targetId:e,viewport:i,clusters:f,scale:l,compact:u,selectedCommentId:c,landedId:d})]})]})}var TS=`[@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:-inset-3 [@media(pointer:coarse)]:before:content-['']`;function ES(){return(0,Y.jsxs)(`span`,{className:`inline-flex h-4 shrink-0 items-center gap-1 rounded-full bg-accent/10 px-1.5 text-[10px] leading-4 font-semibold text-accent`,"data-sw-live-chip":`true`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only @min-[260px]:not-sr-only`,children:`Live`})]})}function DS(e,t,n){let r=t.length===1&&!t[0].env&&!(t[0].y>12)&&n?.[t[0].viewport]?.live?`${e}|${t[0].viewport}`:null;return rx(e=>r!==null&&e.liveKeys.has(r))}function OS({change:e,named:t}){if(!e)return null;let{percent:n,viewport:r}=e,i=n>0?`${n}%${t?` ${r}`:``}`:`Same`;return(0,Y.jsx)(Vv,{content:n>0?`Most changed: the ${r} capture, ${n}% of its pixels`:`No visual change`,children:(0,Y.jsxs)(`span`,{tabIndex:-1,className:O(Ke({shape:`count`}),`tabular pointer-events-auto absolute -top-2.5 -right-2.5 z-20 origin-top-right shadow-pop`,n>0?`bg-accent text-accent-fg`:`bg-surface-2 text-muted`),style:{transform:`scale(min(var(--sw-inv, 1), 14))`},"data-sw-change":n,"data-sw-change-viewport":r,children:[(0,Y.jsx)(Mh,{size:10,"aria-hidden":`true`}),` `,i]})})}function kS({steps:e,current:t}){return e?.length?(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-sw-steps":e.join(`,`),children:e.map(e=>(0,Y.jsx)(`span`,{className:O(`tabular inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-1 text-[10.5px] leading-none font-bold`,e===t?`bg-accent text-accent-fg ring-2 ring-accent/30`:`bg-fg text-surface`),children:e},e))}):null}function AS(){return(0,Y.jsx)(Vv,{content:`An agent is working on a comment here`,children:(0,Y.jsxs)(`span`,{tabIndex:-1,className:`pointer-events-auto inline-flex h-5 items-center gap-1 rounded-full bg-accent/10 px-1.5 text-[11px] font-semibold text-accent`,"data-sw-card-agent-working":`true`,children:[(0,Y.jsxs)(`span`,{className:`relative flex h-2 w-2`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 motion-safe:animate-ping`}),(0,Y.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full bg-accent`})]}),(0,Y.jsx)(I,{size:12,"aria-label":`Agent working`})]})})}function jS({count:e}){if(!e?.open)return null;let t=`${e.open} open comment${e.open===1?``:`s`}`;return(0,Y.jsx)(Vv,{content:t,children:(0,Y.jsxs)(`span`,{tabIndex:-1,className:`tabular pointer-events-auto inline-flex h-5 items-center gap-1 rounded-full px-1 text-[11px] font-semibold text-fg`,children:[(0,Y.jsx)(Wg,{size:12,className:`text-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{"aria-label":t,children:e.open})]})})}function MS({pageId:e,title:t}){let n=(0,J.useContext)(Hv),r=n.onChecks?n.checksCount(e):0;if(!r)return null;let i=`${r} check${r===1?``:`s`} need attention`;return(0,Y.jsx)(Vv,{content:i,children:(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`tabular nodrag nopan pointer-events-auto relative inline-flex h-5 items-center gap-1 rounded-full px-1 text-[11px] font-semibold text-fg hover:bg-surface-2`,TS),"aria-label":`${r} checks need attention across captured screen sizes for ${t}`,onClick:t=>{t.stopPropagation(),n.onChecks(e)},"data-sw-checks-badge":e,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-warn`,"aria-hidden":`true`}),` `,r]})})}function NS({pageId:e}){let t=(0,J.useContext)(Hv),n=t.historyCount(e);return!n||t.compare?null:(0,Y.jsx)(Vv,{content:`${n+1} captures: open the page history`,children:(0,Y.jsxs)(`button`,{type:`button`,className:O(`tabular nodrag nopan pointer-events-auto relative inline-flex h-5 items-center gap-1 rounded-full px-1 text-[11px] font-semibold text-muted hover:bg-surface-2 hover:text-fg`,TS),tabIndex:-1,onClick:n=>{n.stopPropagation(),t.onHistory(e)},"aria-label":`Page history, ${n} earlier capture${n===1?``:`s`}`,"data-sw-history-badge":e,children:[(0,Y.jsx)(f_,{size:12,"aria-hidden":`true`}),` `,n+1]})})}var PS=`var(--sw-title-scale, 1)`;function FS({title:e,path:t,note:n}){return(0,Y.jsxs)(`span`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`block font-semibold`,children:e}),t?(0,Y.jsx)(`span`,{className:`block font-mono text-[11px] opacity-80`,children:t}):null,n?(0,Y.jsx)(`span`,{className:`mt-0.5 block font-normal opacity-80`,children:n}):null]})}function IS({width:e,title:t,tip:n,path:r,steps:i,current:a,only:o,tag:s,badges:c,onTitle:l,accent:u=!1}){return(0,Y.jsx)(`div`,{className:`@container pointer-events-none absolute bottom-full left-0 z-10 origin-bottom-left pb-1`,style:{width:`calc(${e}px / ${PS})`,transform:`scale(${PS})`,opacity:`var(--sw-title-fade, 1)`},"data-sw-card-header":`true`,children:(0,Y.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(kS,{steps:i,current:a}),(0,Y.jsx)(Vv,{content:n,side:`top`,align:`start`,children:(0,Y.jsxs)(`p`,{className:O(`nodrag nopan pointer-events-auto min-w-0 shrink cursor-default truncate text-[12.5px] leading-6 font-semibold`,u?`text-accent`:`text-fg`),onClick:l,"data-sw-card-title":`true`,children:[t,r?(0,Y.jsx)(`span`,{className:`ml-1.5 hidden font-mono text-[11px] font-normal text-faint group-hover/card:@min-[200px]:inline`,children:r}):null]})}),o?(0,Y.jsx)(`span`,{className:`hidden shrink-0 rounded bg-surface-2 px-1 text-[10px] leading-4 font-medium text-muted @min-[150px]:block`,"data-sw-only":!0,children:o}):null,s?(0,Y.jsx)(`span`,{className:`hidden shrink-0 rounded bg-surface-2 px-1 text-[10px] leading-4 font-medium text-muted @min-[200px]:block`,children:s}):null,(0,Y.jsx)(`span`,{className:`ml-auto hidden shrink-0 items-center gap-0.5 @min-[130px]:flex`,"data-sw-card-badges":`true`,children:c})]})})}var LS=`!h-1 !w-1 !min-w-0 !border-0 !bg-transparent`;function RS(e,t,n){return t?.[n]?.status===`failed`?`Capture failed: ${t[n].error}`:e.manifest?`No capture for this screen size.`:e.domFallback?`Not captured yet. Run "shapewall capture".`:`Not captured yet.`}function zS(e,t){let n=Object.keys(t||{});if(!Array.isArray(e)||!e.length||n.every(t=>e.includes(t)))return null;let r=n.filter(t=>e.includes(t)).map(e=>e.replace(/-/g,` `)).join(` and `);return`${r.charAt(0).toUpperCase()}${r.slice(1)} only`}var BS={page:(0,J.memo)(function({data:e,width:t}){let n=(0,J.useContext)(Hv),{page:r,frames:i}=e,a=n.captures[r.id]||{},o=n.manifest?.pages?.[r.id],s=n.journey?.steps.get(r.id)||null,c=!s&&!!n.journey?.offPath?.has(r.id),l=!!n.journey&&!s&&!c,u=n.journey?.currentPage===r.id,d=zS(r.viewports,n.viewports),f=n.compare?Tv(n.compare,r.id):null,p=f?.percent>0,m=!!n.compare&&f&&!p,h=n.agentWorkingPages?.has(r.id),g=DS(r.id,i,a),_=e=>{e.stopPropagation(),i[0]&&!i[0].env&&n.onFocusFrame(r.id,i[0].viewport)};return(0,Y.jsxs)(`div`,{className:O(`group/card relative h-full w-full rounded-lg border border-line bg-surface shadow-card transition-[opacity,outline-color] duration-(--motion-base)`,l&&`opacity-25`,c&&`opacity-60 outline-2 outline-offset-4 outline-faint/60 outline-dashed`,s&&`outline-offset-4 outline-accent/40`,u&&`outline-accent`,p&&`outline-offset-2 outline-accent`,m&&`opacity-50`),style:{...s||p?{outlineWidth:`calc(${u?3:2}px * min(var(--sw-inv, 1), 12))`,outlineStyle:`solid`}:null,...h?{boxShadow:`0 0 0 calc(4px * min(var(--sw-inv, 1), 12)) color-mix(in srgb, var(--accent) 35%, transparent)`}:null},"data-sw-node":r.id,"data-sw-faded":l?`true`:void 0,"data-sw-off-path":c?`true`:void 0,"data-sw-current-step":u?`true`:void 0,"data-sw-changed":n.compare?p?`true`:`false`:void 0,"data-sw-agent-working":h?`true`:void 0,children:[(0,Y.jsx)(kf,{type:`source`,position:Q.Right,id:`right`,className:LS,isConnectable:!1}),(0,Y.jsx)(kf,{type:`target`,position:Q.Left,id:`left`,className:LS,isConnectable:!1}),n.compare?(0,Y.jsx)(OS,{change:f,named:Object.keys(n.viewports||{}).length>1}):null,(0,Y.jsx)(IS,{width:t||i.reduce((e,t)=>Math.max(e,t.x+t.w),0)+8,title:r.title,tip:(0,Y.jsx)(FS,{title:r.title,path:r.path,note:r.note}),path:r.path,steps:s,current:n.journey?.currentStep,only:d,accent:u,onTitle:_,badges:(0,Y.jsxs)(Y.Fragment,{children:[g?(0,Y.jsx)(ES,{}):null,h?(0,Y.jsx)(AS,{}):null,(0,Y.jsx)(jS,{count:n.counts[r.id]}),(0,Y.jsx)(MS,{pageId:r.id,title:r.title}),(0,Y.jsx)(`span`,{className:`pointer-events-auto inline-flex`,children:(0,Y.jsx)(zv,{pageId:r.id,title:r.title,entries:o,viewports:Object.keys(n.viewports)})}),(0,Y.jsx)(NS,{pageId:r.id}),r.url?(0,Y.jsx)(Vv,{content:`Open the page in a new tab`,children:(0,Y.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,tabIndex:-1,className:O(`nodrag nopan pointer-events-auto relative hidden h-5 w-5 items-center justify-center rounded-full text-muted hover:bg-surface-2 hover:text-fg @min-[200px]:inline-flex`,TS),"aria-label":`Open ${r.title} in a new tab`,children:(0,Y.jsx)(Ih,{size:12})})}):null]})}),i.map(e=>e.env?n.compare?(0,Y.jsx)(wS,{pageId:r.id,frame:e},`${e.viewport}:${e.env}`):null:(0,Y.jsx)(_S,{targetId:r.id,frame:e,kind:`captures`,image:a[e.viewport],note:r.note,emptyText:RS(n,o,e.viewport)},e.viewport))]})}),variant:(0,J.memo)(function({data:e,width:t}){let n=(0,J.useContext)(Hv),{variant:r,frames:i,only:a}=e,o=`variant:${r.id}`,s=DS(o,i,r.files);return(0,Y.jsxs)(`div`,{className:O(`group/card relative h-full w-full rounded-lg border border-dashed border-faint/60 bg-surface shadow-card transition-opacity duration-(--motion-base)`,n.journey&&`opacity-25`),"data-sw-node":o,children:[(0,Y.jsx)(kf,{type:`target`,position:Q.Left,id:`left`,className:LS,isConnectable:!1}),(0,Y.jsx)(kf,{type:`source`,position:Q.Right,id:`right`,className:LS,isConnectable:!1}),(0,Y.jsx)(IS,{width:t||200,title:(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(bg,{size:12,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r.title})]}),tip:(0,Y.jsx)(FS,{title:`Variant: ${r.title}`,path:r.source,note:r.note}),tag:`Variant`,badges:(0,Y.jsxs)(Y.Fragment,{children:[s?(0,Y.jsx)(ES,{}):null,(0,Y.jsx)(jS,{count:n.counts[o]})]}),onTitle:e=>{e.stopPropagation(),i[0]&&n.onFocusFrame(o,i[0].viewport)}}),a?(0,Y.jsxs)(`div`,{className:`flex h-11 items-center gap-2 px-2.5 text-[11px] text-muted`,"data-sw-variant-collapsed":a.join(`,`),children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[a.map(e=>e[0].toUpperCase()+e.slice(1)).join(` and `),` only`]}),n.onShowViewport?(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan relative rounded px-1.5 py-0.5 font-semibold text-accent hover:bg-surface-2`,TS),onClick:e=>{e.stopPropagation(),n.onShowViewport(a[0])},"data-sw-variant-show":a[0],children:[`Show `,a[0]]}):null]}):null,i.map(e=>(0,Y.jsx)(_S,{targetId:o,frame:e,kind:`variants`,version:r.createdAt,image:r.files?.[e.viewport],emptyText:`No ${e.viewport} version of this variant.`},e.viewport))]})}),groupFrame:(0,J.memo)(function({data:e,width:t}){let n=`var(--sw-group-scale, 1)`;return(0,Y.jsx)(`div`,{className:`pointer-events-none relative h-full w-full rounded-2xl border border-fg/10 bg-fg/[0.025]`,"data-sw-group":e.group,children:(0,Y.jsxs)(`p`,{className:`@container absolute bottom-full left-0 flex origin-bottom-left items-baseline gap-1.5 pb-1.5 pl-1 text-ui font-semibold whitespace-nowrap text-fg`,style:{width:`calc(${t||600}px / ${n})`,transform:`scale(${n})`},"data-sw-group-label":`true`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.group}),(0,Y.jsxs)(`span`,{className:`tabular hidden shrink-0 text-xs font-medium text-faint @min-[120px]:inline`,children:[e.count,` page`,e.count===1?``:`s`]})]})})})},VS=(e,t,n,r)=>({x:(1-r)*(1-r)*e.x+2*(1-r)*r*t.x+r*r*n.x,y:(1-r)*(1-r)*e.y+2*(1-r)*r*t.y+r*r*n.y});function HS(e,t,n,{inset:r=30,fade:i=110,steps:a=48}={}){let[o,s,c]=t;if(!n?.width||!n?.height||!c)return null;let l=(e,t)=>{let r=e.x*c+o,i=e.y*c+s;return r>=t&&r<=n.width-t&&i>=t&&i<=n.height-t};if(l(e.end,0))return null;for(let t=a-1;t>=1;--t){let n=t/a,o=VS(e.start,e.control,e.end,n);if(!l(o,r))continue;let s=t;for(;s>0;){let t=VS(e.start,e.control,e.end,(s-1)/a);if(Math.hypot((t.x-o.x)*c,(t.y-o.y)*c)>i)break;--s}return{t:n,point:o,from:VS(e.start,e.control,e.end,s/a)}}return null}function US(e,t){let{start:n,control:r}=e,i={x:n.x+(r.x-n.x)*t,y:n.y+(r.y-n.y)*t},a=VS(n,r,e.end,t);return`M ${n.x} ${n.y} Q ${i.x} ${i.y} ${a.x} ${a.y}`}function WS(e,t,n){let r=e.x+e.w/2,i=e.y+e.h/2,a=t-r,o=n-i;if(!a&&!o)return{x:r,y:i};let s=Math.min(a?e.w/2/Math.abs(a):1/0,o?e.h/2/Math.abs(o):1/0);return{x:r+a*s,y:i+o*s}}function GS(e){if(!e)return null;let{x:t,y:n}=e.internals.positionAbsolute,r=e.measured?.width??e.width??0,i=e.measured?.height??e.height??0;return r&&i?{x:t,y:n,w:r,h:i}:null}function KS(e,t,{bend:n=.12,gap:r=6}={}){let i={x:e.x+e.w/2,y:e.y+e.h/2},a={x:t.x+t.w/2,y:t.y+t.h/2},o=WS(e,a.x,a.y),s=WS(t,i.x,i.y),c=s.x-o.x,l=s.y-o.y,u=Math.hypot(c,l)||1,d=c/u,f=l/u,p={x:s.x-d*r,y:s.y-f*r},m={x:(o.x+p.x)/2+f*u*n,y:(o.y+p.y)/2-d*u*n},h={x:(o.x+2*m.x+p.x)/4,y:(o.y+2*m.y+p.y)/4},g=p.x-m.x,_=p.y-m.y,v=Math.hypot(g,_)||1;return{path:`M ${o.x} ${o.y} Q ${m.x} ${m.y} ${p.x} ${p.y}`,end:p,dir:{x:g/v,y:_/v},mid:h,curve:{start:o,control:m,end:p}}}var qS={idle:{stroke:`var(--faint)`,width:1.25,opacity:.35},out:{stroke:`var(--accent)`,width:2,opacity:.95},in:{stroke:`var(--muted)`,width:1.5,opacity:.7},journey:{stroke:`var(--accent)`,width:3,opacity:.95},done:{stroke:`var(--accent)`,width:2.5,opacity:.45},alt:{stroke:`var(--faint)`,width:2,opacity:.6,dash:3}},JS={flow:(0,J.memo)(function({id:e,source:t,target:n,data:r}){let i=_m(t),a=_m(n),o=$(e=>Math.min(40,Math.max(.25,Math.round(1/e.transform[2]*8)/8))),s=(0,J.useContext)(Hv),c=GS(i),l=GS(a),u=qS[r?.tone]||qS.idle,d=c&&l?KS(c,l,{bend:r?.bend??.12,gap:4*o}):null,f=r?.tone===`journey`||r?.tone===`done`,p=$(e=>{if(!f||!d)return``;let t=HS(d.curve,e.transform,{width:e.width,height:e.height}),n=e=>Math.round(e*10)/10;return t?[t.t,n(t.point.x),n(t.point.y),n(t.from.x),n(t.from.y)].join(`,`):``});if(!d)return null;let{path:m,end:h,dir:g,mid:_,curve:v}=d;if(p){let[t,n,i,a,c]=p.split(`,`).map(Number),l=`sw-edge-fade-${String(e).replace(/[^a-zA-Z0-9_-]/g,`-`)}`,d=`Continues to step ${r.label}${r.toTitle?`: ${r.toTitle}`:``}`;return(0,Y.jsxs)(`g`,{className:`sw-flow-edge`,"data-sw-edge":e,"data-sw-edge-tone":r.tone,"data-sw-edge-leaves":`true`,style:{opacity:u.opacity},children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsxs)(`linearGradient`,{id:l,gradientUnits:`userSpaceOnUse`,x1:a,y1:c,x2:n,y2:i,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:u.stroke,stopOpacity:`1`}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:u.stroke,stopOpacity:`0`})]})}),(0,Y.jsx)(`path`,{d:US(v,t),fill:`none`,stroke:`url(#${l})`,strokeWidth:u.width*o,strokeLinecap:`round`}),(0,Y.jsx)(um,{children:(0,Y.jsxs)(`button`,{type:`button`,className:`nodrag nopan pointer-events-auto absolute flex h-6 items-center gap-0.5 rounded-full border-2 border-surface bg-accent pr-1.5 pl-1 text-[11px] font-bold text-accent-fg shadow-pop outline-none hover:bg-accent/90 focus-visible:ring-2 focus-visible:ring-accent/50 [@media(pointer:coarse)]:after:absolute [@media(pointer:coarse)]:after:-inset-2.5 [@media(pointer:coarse)]:after:content-['']`,style:{transform:`translate(-50%, -50%) translate(${n}px, ${i}px) scale(${Math.min(o,2)})`},title:d,"aria-label":d,tabIndex:-1,onClick:e=>{e.stopPropagation(),s?.onJourneyStep?.(Number(r.label))},"data-sw-edge-continues":r.label,children:[(0,Y.jsx)(nh,{size:12,"aria-hidden":`true`}),r.label]})})]})}let y=(u.width*2.5+5)*o,b=-g.y,x=g.x,S=[`${h.x},${h.y}`,`${h.x-g.x*y+b*y*.55},${h.y-g.y*y+x*y*.55}`,`${h.x-g.x*y-b*y*.55},${h.y-g.y*y-x*y*.55}`].join(` `);return(0,Y.jsxs)(`g`,{className:`sw-flow-edge`,"data-sw-edge":e,"data-sw-edge-tone":r?.tone||`idle`,style:{opacity:u.opacity},children:[(0,Y.jsx)(`path`,{d:m,fill:`none`,stroke:u.stroke,strokeWidth:u.width*o,strokeLinecap:`round`,strokeDasharray:u.dash?`${u.dash*u.width*o} ${u.dash*u.width*o}`:void 0}),(0,Y.jsx)(`polygon`,{points:S,fill:u.stroke}),r?.label||r?.branch?(0,Y.jsx)(um,{children:(0,Y.jsxs)(`span`,{className:`nodrag nopan pointer-events-none absolute flex items-center gap-1`,style:{transform:`translate(-50%, -50%) translate(${_.x}px, ${_.y}px) scale(${Math.min(o,2)})`},children:[r.label?(0,Y.jsx)(`span`,{className:`flex h-6 min-w-6 items-center justify-center rounded-full border-2 border-surface bg-accent px-1 text-[11px] font-bold text-accent-fg shadow-pop`,"data-sw-edge-label":r.label,children:r.label}):null,r.branch?(0,Y.jsx)(`span`,{className:O(`flex h-6 max-w-48 items-center truncate rounded-full border-2 px-2 text-[11px] font-semibold whitespace-nowrap shadow-pop`,r.tone===`alt`?`border-line bg-surface text-muted`:`border-surface bg-accent text-accent-fg`),"data-sw-edge-branch":r.branch,children:r.branch}):null]})}):null]})})};function YS({hasTarget:e,known:t,changedOnly:n,pageChanged:r}){if(e)return null;if(!t)return{gone:!0};let i=!(!n||r);return i?{showAllPages:i}:{gone:!0}}function XS(e){return e.length<2?e[0]||``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}var ZS=e=>e.charAt(0).toLowerCase()+e.slice(1);function QS(e,t=e=>e,{compact:n=!1}={}){if(!e?.changes?.length)return null;let r=[],i=[],a=[];for(let n of e.changes)n===`viewport`&&(r.push(`Showing ${t(e.to)}`),i.push(`the ${e.to} capture`),a.push(t(e.from))),n===`changed`&&(r.push(`Showing all pages`),i.push(`a page "Changed pages only" leaves out`),a.push(`changed pages only`));let o=r.map((e,t)=>t===0?e:ZS(e)).join(`, `);return n?{text:`${o} for comment #${e.id}.`,back:`Back`}:{text:`${o}: comment #${e.id} is on ${i.join(`, and on `)}.`,back:`Back to ${XS(a)}`}}var $S={top:76,bottom:108,left:24,right:24},eC=1.2,tC=.28,nC=.45;function rC(e){return Math.min(2,Math.max(eC,Number.isFinite(e)&&e>0?e:eC))}function iC(e,t=null){return Number.isFinite(t)?Math.max(56,Math.min(t,e.height)-64):e.height*nC}function aC(e,t,n=null){if(!e?.width||!e?.height)return null;if(!t)return{x:e.width/2,y:Math.min(e.height*tC,iC(e,n))};let r=$S.left,i=Math.max(r+1,e.width-$S.right),a=$S.top,o=Math.max(a+1,e.height-$S.bottom),s=i-r;return{x:s>608?r+(s-380)/2:r+s/2,y:a+(o-a)/2}}function oC({point:e,box:t,wide:n,zoom:r,cardTop:i=null,sheetTop:a=null}){let o=rC(r),s=aC(t,n,a);if(!s)return null;let c=s.x-e.x*o,l=s.y-e.y*o;return!n&&Number.isFinite(i)&&i*o+l<40&&(l=Math.min(40-i*o,iC(t,a)-e.y*o)),n||(l=Math.max(l,56-e.y*o)),{x:c,y:l,zoom:o}}function sC(e,t){return!e||!t?!1:Math.abs(e.x-t.x)<1.5&&Math.abs(e.y-t.y)<1.5&&Math.abs(e.zoom-t.zoom)<.005}var cC=120,lC=.62;function uC({windowHeight:e,canvasTop:t=null}){if(!(e>0))return null;let n=Math.round(e*lC);if(!Number.isFinite(t))return n;let r=Math.round(e-Math.max(0,t)-cC-80);return Math.max(200,Math.min(n,r))}function dC({windowHeight:e,canvasTop:t=null}){let n=uC({windowHeight:e,canvasTop:t});return n===null?null:n+80}var fC=.02,pC=16,mC=(e,t,n)=>Math.min(n,Math.max(t,e));function hC({deltaX:e=0,deltaY:t=0,deltaMode:n=0},r=800){let i=n===1?pC:n===2?r:1;return{dx:e*i,dy:t*i}}function gC(e,t,n,{minZoom:r,maxZoom:i}){let a=mC(e.zoom*n,r,i),o=a/e.zoom;return{x:t.x-(t.x-e.x)*o,y:t.y-(t.y-e.y)*o,zoom:a}}function _C(e,t,n,{minZoom:r,maxZoom:i,pageHeight:a}={}){let{dx:o,dy:s}=hC(t,a);if(t.ctrlKey||t.metaKey){if(!s)return null;let t=gC(e,n,2**(-mC(s,-20,20)*fC),{minZoom:r,maxZoom:i});return t.zoom===e.zoom?null:t}return t.shiftKey&&Math.abs(s)>Math.abs(o)&&(o=s,s=0),!o&&!s?null:{x:e.x-o,y:e.y-s,zoom:e.zoom}}function vC(e,t,n){return{x:e.x+t,y:e.y+n,zoom:e.zoom}}var yC=new Set([``,`text`,`search`,`email`,`url`,`tel`,`password`,`number`,`date`,`time`,`datetime-local`,`month`,`week`]),bC=`button, a[href], select, summary, [role="button"], [role="link"], [role="menuitem"], [role="menuitemradio"], [role="option"], [role="tab"], [role="checkbox"], [role="radio"], [role="switch"], [role="slider"]`;function xC(e){if(!e||e.nodeType!==1)return!1;if(e.isContentEditable)return!0;let t=e.tagName;return t===`TEXTAREA`||t===`SELECT`||t===`INPUT`&&yC.has((e.getAttribute(`type`)||``).toLowerCase())}function SC(e,{clicked:t=null}={}){return!e||e.nodeType!==1?!0:xC(e)||e.closest?.(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`)?!1:!e.matches?.(bC)||e===t}function CC({canvasRef:e,flow:t,minZoom:n,maxZoom:r,onRest:i,enabled:a=!0,handRef:o=null}){let s=(0,J.useRef)({moving:!1}),c=(0,J.useRef)(i);return(0,J.useEffect)(()=>{c.current=i},[i]),(0,J.useEffect)(()=>{let i=e.current;if(!a||!i||!t)return;let l=s.current,u=0,d=!1,f=!1,p=null,m=!1,h=0,g=1,_=null,v=0,y=e=>!!e?.closest?.(`.react-flow__renderer`),b=e=>{let t=i.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},x=()=>{window.clearTimeout(u),l.moving=!1,c.current?.(t.getViewport())},S=()=>{window.clearTimeout(u),u=window.setTimeout(x,150)},C=e=>{l.moving=!0,t.setViewport(e)},w=e=>{d=e,i.classList.toggle(`sw-space-pan`,e)},T=e=>{if(e.target?.closest?.(`.nowheel`)){(e.ctrlKey||e.metaKey)&&e.preventDefault();return}if(!y(e.target)&&!(e.ctrlKey||e.metaKey))return;e.preventDefault(),e.stopPropagation();let a=_C(t.getViewport(),e,b(e),{minZoom:n,maxZoom:r,pageHeight:i.clientHeight});a&&(C(a),S())},E=e=>{h||(e.preventDefault(),g=1)},D=e=>{if(h||!y(e.target))return;e.preventDefault();let i=e.scale/g;g=e.scale,!Number.isFinite(i)||i<=0||(C(gC(t.getViewport(),b(e),i,{minZoom:n,maxZoom:r})),S())},O=e=>{h=e.touches.length},k=e=>{e.code!==`Space`&&e.key!==` `||e.altKey||e.ctrlKey||e.metaKey||(d?e.preventDefault():!e.repeat&&f&&SC(e.target,{clicked:_})&&(e.preventDefault(),w(!0)))},A=e=>{(e.code===`Space`||e.key===` `)&&d&&(e.preventDefault(),w(!1))},j=()=>{w(!1),p&&N()},ee=e=>{if(e.pointerType!==`mouse`)return;let n=e.button===1;if((n||e.button===0&&(d||o?.current))&&y(e.target)){e.preventDefault(),e.stopPropagation(),window.clearTimeout(u),p={id:e.pointerId,x:e.clientX,y:e.clientY,start:t.getViewport(),moved:!1,middle:n},m=!1;try{i.setPointerCapture(e.pointerId)}catch{}i.classList.add(`sw-panning`)}},M=e=>{if(f=!0,!p||e.pointerId!==p.id)return;e.preventDefault(),e.stopPropagation();let t=e.clientX-p.x,n=e.clientY-p.y;!p.moved&&Math.abs(t)+Math.abs(n)<2||(p.moved=!0,C(vC(p.start,t,n)))},N=()=>{let e=p;if(p=null,i.classList.remove(`sw-panning`),e){try{i.hasPointerCapture(e.id)&&i.releasePointerCapture(e.id)}catch{}m=!0,window.setTimeout(()=>m=!1,0),e.moved&&x()}},P=e=>{p&&e.pointerId===p.id&&(e.preventDefault(),e.stopPropagation(),N())},F=e=>{m&&(m=!1,e.preventDefault(),e.stopPropagation())},I=()=>{v=Date.now()},L=e=>{_=Date.now()-v<500?e.target:null},R=()=>{f=!0},z=()=>{p||(f=!1)},te=e=>{(e.ctrlKey||e.metaKey)&&e.target?.closest?.(`[data-sw-thread-popover], [data-sw-composer-popover]`)&&e.preventDefault()},B={capture:!0},V={capture:!0,passive:!1};return window.addEventListener(`wheel`,te,V),i.addEventListener(`wheel`,T,V),i.addEventListener(`gesturestart`,E,V),i.addEventListener(`gesturechange`,D,V),i.addEventListener(`touchstart`,O,{capture:!0,passive:!0}),i.addEventListener(`touchend`,O,{capture:!0,passive:!0}),i.addEventListener(`touchcancel`,O,{capture:!0,passive:!0}),i.addEventListener(`pointerdown`,ee,B),i.addEventListener(`pointermove`,M,B),i.addEventListener(`pointerup`,P,B),i.addEventListener(`pointercancel`,P,B),i.addEventListener(`pointerenter`,R),i.addEventListener(`pointerleave`,z),window.addEventListener(`click`,F,B),window.addEventListener(`auxclick`,F,B),window.addEventListener(`keydown`,k,B),window.addEventListener(`keyup`,A,B),window.addEventListener(`blur`,j),window.addEventListener(`pointerdown`,I,B),window.addEventListener(`focusin`,L,B),()=>{window.clearTimeout(u),l.moving&&x(),w(!1),i.classList.remove(`sw-panning`),window.removeEventListener(`wheel`,te,V),i.removeEventListener(`wheel`,T,V),i.removeEventListener(`gesturestart`,E,V),i.removeEventListener(`gesturechange`,D,V),i.removeEventListener(`touchstart`,O,{capture:!0}),i.removeEventListener(`touchend`,O,{capture:!0}),i.removeEventListener(`touchcancel`,O,{capture:!0}),i.removeEventListener(`pointerdown`,ee,B),i.removeEventListener(`pointermove`,M,B),i.removeEventListener(`pointerup`,P,B),i.removeEventListener(`pointercancel`,P,B),i.removeEventListener(`pointerenter`,R),i.removeEventListener(`pointerleave`,z),window.removeEventListener(`click`,F,B),window.removeEventListener(`auxclick`,F,B),window.removeEventListener(`keydown`,k,B),window.removeEventListener(`keyup`,A,B),window.removeEventListener(`blur`,j),window.removeEventListener(`pointerdown`,I,B),window.removeEventListener(`focusin`,L,B)}},[e,a,t,o,r,n]),(0,J.useMemo)(()=>({moving:()=>s.current.moving}),[])}function wC(e,t){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=e.target.closest?.(`.react-flow__node`);if(!n||n.classList.contains(`react-flow__node-groupFrame`))return;let r=e.target===n,i=[...n.querySelectorAll(`button, a[href]`)].filter(e=>!e.disabled&&e.getClientRects().length);if([`ArrowRight`,`ArrowDown`,`ArrowLeft`,`ArrowUp`].includes(e.key)){if(!i.length)return;e.preventDefault();let t=e.key===`ArrowRight`||e.key===`ArrowDown`,n=i.indexOf(e.target);i[r||n<0?t?0:i.length-1:(n+(t?1:-1)+i.length)%i.length].focus()}else e.key===`Escape`&&!r?(e.preventDefault(),n.focus()):(e.key===`Enter`||e.key===` `)&&r&&(e.preventDefault(),t(n.getAttribute(`data-id`)))}function TC({icon:e,title:t,onClose:n,closeLabel:r,closeProps:i,className:a,children:o}){return(0,Y.jsxs)(`div`,{className:O(`flex h-12 shrink-0 items-center gap-1.5 px-3`,a),children:[(0,Y.jsxs)(`h2`,{className:`flex shrink-0 items-center gap-1.5 text-sm font-semibold text-fg`,children:[e?(0,Y.jsx)(e,{size:15,className:`text-muted`,"aria-hidden":`true`}):null,t]}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:o}),n?(0,Y.jsx)(B,{label:r,onClick:n,...i,children:(0,Y.jsx)(se,{size:15,"aria-hidden":`true`})}):null]})}var EC=6e3,DC=new Map,OC=new Set,kC=new Map;function AC(){for(let e of OC)e()}function jC(e,t,n){if(!e)return;if(window.clearTimeout(kC.get(e)),kC.delete(e),t==null||!n){if(!DC.has(e))return;DC.delete(e),AC();return}let r=DC.get(e);if(r?.commentId===t&&r.state===n)return;let i={commentId:t,state:n,since:r?.commentId===t?r.since:Date.now()};DC.set(e,i),AC(),(n===`done`||n===`stopped`)&&kC.set(e,window.setTimeout(()=>{DC.get(e)===i&&jC(e,null,null)},EC))}function MC(e){return OC.add(e),()=>OC.delete(e)}function NC(e){return(0,J.useSyncExternalStore)(MC,()=>{for(let t of DC.values())if(t.commentId===e)return t;return null},()=>null)}function PC(e,t=void 0){let n=(0,J.useSyncExternalStore)(MC,()=>DC.get(e)||null,()=>null);return t===void 0||n&&n.commentId===t?n:null}var FC=new Set,IC=new Set,LC=null,RC=null,zC=2e3,BC=6e4;function VC(e=`event`){for(let t of[...FC])try{t(e)}catch{}}function HC(){document.visibilityState!==`visible`||RC||(RC=window.setTimeout(()=>{RC=null,VC(`shown`),tw(null)},50))}function UC(){return typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-console"]`)?`/api/agent/events`:`api/agent/events`}var WC=null,GC=!1;function KC(e){let t=e===!0;t!==WC&&(WC=t,GC&&qC())}function qC(){JC(),WC!==!0||Ge||Ue||typeof window.fetch!=`function`||typeof window.TextDecoder!=`function`||Object.keys(Ze()).length&&(LC={controller:null,timer:null,delay:zC},ZC(LC))}function JC(){LC&&(window.clearTimeout(LC.timer),LC.controller?.abort()),LC=null}function YC(){GC=!0,window.addEventListener(`focus`,HC),document.addEventListener(`visibilitychange`,HC),qC()}function XC(e){let t=`message`,n=``;for(let r of e.split(`
|
|
20
|
-
`))r.startsWith(`event:`)?t=r.slice(6).trim():r.startsWith(`data:`)&&(n+=r.slice(5).trim());if(t===`agents`&&
|
|
16
|
+
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Jm.displayName=`MiniMap`;var Ym=(0,J.memo)(Jm),Xm=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Zm={[Ou.Line]:`right`,[Ou.Handle]:`bottom-right`};function Qm({nodeId:e,position:t,variant:n=Ou.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=xf(),y=typeof e==`string`?e:v,b=rd(),x=(0,J.useRef)(null),S=n===Ou.Handle,C=$((0,J.useCallback)(Xm(S&&p),[S,p]),Qu),w=(0,J.useRef)(null),T=t??Zm[n];(0,J.useEffect)(()=>{if(x.current&&y)return w.current||=zu({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Kl([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Yc({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,Y.jsx)(`div`,{className:vt([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,J.memo)(Qm);var $m={name:`arrow-left-right`,size:24,node:[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]};$m.node;var eh=c($m),th={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};th.node;var nh=c(th),rh={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};rh.node;var ih=c(rh),ah={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};ah.node;var oh=c(ah),sh={name:`brush`,size:24,node:[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]};sh.node;var ch=c(sh),lh={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};lh.node;var uh=c(lh),dh={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};dh.node;var fh=c(dh),ph={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};ph.node;var mh=c(ph),hh={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};hh.node;var gh=c(hh),_h={name:`circle-dot`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};_h.node;var vh=c(_h),yh={name:`circle-slash`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]};yh.node;var bh=c(yh),xh={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};xh.node;var Sh=c(xh),Ch={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ch.node;var wh=c(Ch),Th={name:`columns-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]],aliases:[`columns`]};Th.node;var Eh=c(Th),Dh={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};Dh.node;var Oh=c(Dh),kh={name:`corner-down-right`,size:24,node:[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]};kh.node;var Ah=c(kh),jh={name:`crosshair`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]};jh.node;var Mh=c(jh),Nh={name:`diff`,size:24,node:[[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 10h14`,key:`elsbfy`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};Nh.node;var Ph=c(Nh),Fh={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Fh.node;var Ih=c(Fh),Lh={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};Lh.node;var Rh=c(Lh),zh={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};zh.node;var Bh=c(zh),Vh={name:`face-slightly-smiling`,size:24,node:[[`path`,{d:`M15 10V9`,key:`4dkmfx`}],[`path`,{d:`M16.472 15a6 6 0 01-8.943 0`,key:`7qomzy`}],[`path`,{d:`M9 10V9`,key:`1lazqi`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`smile`]};Vh.node;var Hh=c(Vh),Uh={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Uh.node;var Wh=c(Uh),Gh={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};Gh.node;var Kh=c(Gh),qh={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};qh.node;var Jh=c(qh),Yh={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};Yh.node;var Xh=c(Yh),Zh={name:`git-compare`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]};Zh.node;var Qh=c(Zh),$h={name:`git-fork`,size:24,node:[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]};$h.node;var eg=c($h),tg={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};tg.node;var ng=c(tg),rg={name:`git-pull-request-closed`,size:24,node:[[`path`,{d:`m15.5 3.5 5 5`,key:`1kmx7t`}],[`path`,{d:`m15.5 8.5 5-5`,key:`saftza`}],[`path`,{d:`M18 11.62V15`,key:`1greaj`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}]]};rg.node;var ig=c(rg),ag={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};ag.node;var og=c(ag),sg={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};sg.node;var cg=c(sg),lg={name:`image-off`,size:24,node:[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]};lg.node;var ug=c(lg),dg={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};dg.node;var fg=c(dg),pg={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};pg.node;var mg=c(pg),hg={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};hg.node;var gg=c(hg),_g={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};_g.node;var vg=c(_g),yg={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};yg.node;var bg=c(yg),xg={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};xg.node;var Sg=c(xg),Cg={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};Cg.node;var wg=c(Cg),Tg={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};Tg.node;var Eg=c(Tg),Dg={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};Dg.node;var Og=c(Dg),kg={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};kg.node;var Ag=c(kg),jg={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};jg.node;var Mg=c(jg),Ng={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Ng.node;var Pg=c(Ng),Fg={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};Fg.node;var Ig=c(Fg),Lg={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Lg.node;var Rg=c(Lg),zg={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};zg.node;var Bg=c(zg),Vg={name:`message-square-off`,size:24,node:[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]};Vg.node;var Hg=c(Vg),Ug={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};Ug.node;var Wg=c(Ug),Gg={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};Gg.node;var Kg=c(Gg),qg={name:`mic`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]};qg.node;var Jg=c(qg),Yg={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Yg.node;var Xg=c(Yg),Zg={name:`monitor-play`,size:24,node:[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]};Zg.node;var Qg=c(Zg),$g={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};$g.node;var e_=c($g),t_={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};t_.node;var n_=c(t_),r_={name:`mouse-pointer-2`,size:24,node:[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]};r_.node;var i_=c(r_),a_={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};a_.node;var o_=c(a_),s_={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};s_.node;var c_=c(s_),l_={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};l_.node;var u_=c(l_),d_={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};d_.node;var f_=c(d_),p_={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};p_.node;var m_=c(p_),h_={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};h_.node;var g_=c(h_),__={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};__.node;var v_=c(__),y_={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};y_.node;var b_=c(y_),x_={name:`route`,size:24,node:[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]};x_.node;var S_=c(x_),C_={name:`rows-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]],aliases:[`rows`]};C_.node;var w_=c(C_),T_={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};T_.node;var E_=c(T_),D_={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};D_.node;var O_=c(D_),k_={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};k_.node;var A_=c(k_),j_={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};j_.node;var M_=c(j_),N_={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};N_.node;var P_=c(N_),F_={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};F_.node;var I_=c(F_),L_={name:`shield-question-mark`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`shield-question`]};L_.node;var R_=c(L_),z_={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};z_.node;var B_=c(z_),V_={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};V_.node;var H_=c(V_),U_={name:`square-dashed-text`,size:24,node:[[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 14v1`,key:`169vum`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h6`,key:`1vyc9m`}],[`path`,{d:`M7 8h8`,key:`1jbsf9`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M9 3h1`,key:`1yesri`}]],aliases:[`text-selection`,`text-select`]};U_.node;var W_=c(U_),G_={name:`square-split-horizontal`,size:24,node:[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3`,key:`saxlbk`}],[`path`,{d:`M8 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3`,key:`m1vog4`}]],aliases:[`split-square-horizontal`]};G_.node;var K_=c(G_),q_={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};q_.node;var J_=c(q_),Y_={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Y_.node;var X_=c(Y_),Z_={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};Z_.node;var Q_=c(Z_),$_={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};$_.node;var ev=c($_),tv={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};tv.node;var nv=c(tv),rv={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};rv.node;var iv=c(rv),av={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};av.node;var ov=c(av),sv={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};sv.node;var cv=c(sv),lv={name:`waypoints`,size:24,node:[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]};lv.node;var uv=c(lv),dv={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};dv.node;var fv=c(dv),pv=[[`left-[4%] top-[8%]`,4,2],[`left-[38%] top-[8%]`,2,1],[`left-[4%] top-[50%]`,4,2],[`left-[38%] top-[42%]`,4,2]];function mv(){return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col bg-sunken`,"data-sw-board-loading":!0,children:[(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Loading the board`}),Ge?(0,Y.jsxs)(`div`,{className:`flex h-[2.8125rem] shrink-0 items-center gap-2 border-b border-line bg-surface px-2 sm:px-3 lg:h-9`,"aria-hidden":`true`,"data-sw-board-loading-demo":!0,children:[(0,Y.jsx)(K,{className:`h-5 w-14 rounded-full`}),(0,Y.jsx)(K,{className:`h-3.5 w-40 max-sm:w-24`}),(0,Y.jsx)(K,{className:`ml-auto h-3.5 w-14`})]}):null,(0,Y.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 border-b border-line bg-surface px-3 lg:px-4`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`h-8 w-8 rounded-lg`}),(0,Y.jsx)(K,{className:`hidden h-4 w-24 sm:block`}),(0,Y.jsx)(K,{className:`h-8 w-40 max-sm:flex-1`}),(0,Y.jsx)(`div`,{className:`hidden flex-1 items-center justify-center gap-2 lg:flex`,children:(0,Y.jsx)(K,{className:`h-8 w-56`})}),(0,Y.jsx)(K,{className:`hidden h-8 w-24 lg:block`}),(0,Y.jsx)(K,{className:`hidden h-8 w-48 lg:block`}),(0,Y.jsx)(K,{className:`h-8 w-8 rounded-full`})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`relative min-w-0 flex-1 overflow-hidden`,"aria-hidden":`true`,children:[pv.map(([e,t,n],r)=>(0,Y.jsxs)(`div`,{className:`absolute ${e} rounded-xl border border-line-strong/60 bg-surface/40 p-3 max-sm:hidden`,children:[(0,Y.jsx)(K,{className:`mb-3 h-3 w-20`}),(0,Y.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(${t}, 3.5rem)`},children:Array.from({length:t*n},(e,t)=>(0,Y.jsx)(K,{className:`h-24 rounded-md shadow-thumb`},t))})]},r)),(0,Y.jsx)(`div`,{className:`flex flex-col gap-4 p-4 sm:hidden`,children:[3,2].map((e,t)=>(0,Y.jsxs)(`div`,{className:`rounded-xl border border-line-strong/60 bg-surface/40 p-3`,children:[(0,Y.jsx)(K,{className:`mb-3 h-3 w-20`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:Array.from({length:e},(e,t)=>(0,Y.jsx)(K,{className:`h-28 rounded-md shadow-thumb`},t))})]},t))})]}),(0,Y.jsxs)(`div`,{className:`hidden w-80 shrink-0 flex-col gap-4 border-l border-line bg-surface p-4 lg:flex`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`h-5 w-28`}),(0,Y.jsx)(K,{className:`h-9 w-full`}),[0,1,2,3].map(e=>(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Y.jsx)(K,{className:`h-8 w-8 shrink-0 rounded-full`}),(0,Y.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Y.jsx)(K,{className:`h-3 w-1/2`}),(0,Y.jsx)(K,{className:`h-3 w-full`}),(0,Y.jsx)(K,{className:`h-3 w-3/4`})]})]},e))]})]})]})}function hv({heading:e=!0}){return(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-sw-chat-loading":!0,children:[(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Loading chat`}),e?(0,Y.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-line px-3`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`h-4 w-16`}),(0,Y.jsx)(K,{className:`h-5 w-28 rounded-full`}),(0,Y.jsx)(K,{className:`ml-auto h-7 w-7`})]}):null,(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-hidden p-3`,"aria-hidden":`true`,children:[(0,Y.jsx)(K,{className:`ml-auto h-9 w-3/5 rounded-2xl`}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(K,{className:`h-6 w-6 shrink-0 rounded-full`}),(0,Y.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Y.jsx)(K,{className:`h-10 w-full rounded-lg`}),(0,Y.jsx)(K,{className:`h-3 w-full`}),(0,Y.jsx)(K,{className:`h-3 w-5/6`}),(0,Y.jsx)(K,{className:`h-3 w-2/3`})]})]})]}),(0,Y.jsx)(`div`,{className:`shrink-0 p-3`,"aria-hidden":`true`,children:(0,Y.jsx)(K,{className:`h-24 w-full rounded-xl`})})]})}function gv(e){let t=e?.status;return t===401||t===403?`You may need to sign in again, or ask for access to this board.`:t===404?`This board may have moved or been removed.`:typeof navigator<`u`&&navigator.onLine===!1?`You seem to be offline. Check your connection, then retry.`:`Shapewall could not fetch this board's data. That is usually temporary, so try again in a moment.`}function _v({error:e,onRetry:t,extra:n=null}){let[r,i]=(0,J.useState)(!1),o=async()=>{i(!0);try{await t?.()}finally{i(!1)}},s=[e?.message,e?.status?`Status ${e.status}`:null].filter(Boolean).join(`
|
|
17
|
+
`);return(0,Y.jsx)(`div`,{className:`flex h-full overflow-y-auto bg-sunken`,role:`alert`,"data-sw-board-error":!0,children:(0,Y.jsx)(j,{size:`lg`,tone:`bad`,icon:wh,title:`This board did not load`,details:s||null,action:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(a,{size:`touch`,variant:`default`,className:`lg:h-10`,onClick:o,disabled:r,"data-sw-board-retry":!0,children:[r?(0,Y.jsx)(me,{}):(0,Y.jsx)(b_,{size:15,"aria-hidden":`true`}),` Retry`]}),n]}),children:gv(e)})})}function vv(e){let t=new Map;return(e||[]).forEach((e,n)=>{t.has(e)||t.set(e,[]),t.get(e).push(n+1)}),t}function yv(e,t,n=null){let r=0;for(let[i,a]of Object.entries(e||{}))t.has(i)&&(r+=a.filter(e=>t.has(e)&&!n?.has(e)).length);return r}function bv(e,t){let n=Object.entries(e||{}).filter(([e,n])=>t.has(e)&&n.some(e=>t.has(e)));if(n.length<3)return new Set;let r=new Map;for(let[e,i]of n)for(let n of new Set(i))n!==e&&t.has(n)&&r.set(n,(r.get(n)||0)+1);let i=Math.max(3,Math.ceil(n.length*.5));return new Set([...r].filter(([,e])=>e>=i).map(([e])=>e))}function xv({links:e={},showLinks:t=!1,activePage:n=null,journeySteps:r=null,journeyRoute:i=null,currentStep:a=0,present:o,idleMax:s=150,hideTargets:c=null}){let l=[],u=[],d=e=>o.has(e),f=new Set;if(i){let e=new Map(i.graph.nodes.map(e=>[e.key,e.pageId])),t=new Map;i.path.forEach((e,n)=>{n&&t.set(`${i.path[n-1]}>${e}`,n)});let n=[];for(let r of i.graph.edges){let i=e.get(r.from),o=e.get(r.to);if(i===o||!d(i)||!d(o))continue;let s=t.get(`${r.from}>${r.to}`);f.add(`${i}>${o}`);let c={source:i,target:o,sourceHandle:`right`,targetHandle:`left`,type:`flow`};s===void 0?n.push({...c,id:`journey-alt:${r.from}>${r.to}`,data:{tone:`alt`,...r.label?{branch:r.label}:{},bend:.22}}):l.push({...c,id:`journey:${s}`,data:{tone:a&&s+1<=a?`done`:`journey`,label:String(s+1),...r.label?{branch:r.label}:{},bend:.16}})}l.unshift(...n)}else if(r?.length)for(let e=0;e<r.length-1;e+=1){let t=r[e],n=r[e+1];t!==n&&d(t)&&d(n)&&(f.add(`${t}>${n}`),l.push({id:`journey:${e+1}`,source:t,target:n,sourceHandle:`right`,targetHandle:`left`,type:`flow`,data:{tone:a&&e+2<=a?`done`:`journey`,label:String(e+2),bend:.16}}))}if(t&&(n||yv(e,o,c)<=s)){for(let[t,r]of Object.entries(e))if(d(t))for(let e of r){if(!d(e)||f.has(`${t}>${e}`)||c?.has(e))continue;let r=`idle`;if(n){if(t===n)r=`out`;else if(e===n)r=`in`;else continue}u.push({id:`link:${t}>${e}`,source:t,target:e,sourceHandle:`right`,targetHandle:`left`,type:`flow`,data:{tone:r}})}}return[...u,...l]}function Sv(e,t){let n=Math.round(Number(e));return t?!Number.isFinite(n)||n<1?1:Math.min(n,t):0}function Cv(e,t){if(e?.status!==`ok`)return null;if(typeof e.version==`string`)return e.version;let n=Date.parse(t?.capturedAt||``);return Number.isFinite(n)?new Date(n).toISOString().replace(/[-:]/g,``).replace(/\.(\d{3})Z$/,`$1Z`):null}function wv(e,t){return[e,...e.replies||[]].filter(e=>e?.drawing?.shapes?.length&&e.drawing.captureVersion===t).flatMap(e=>e.drawing.shapes)}function Tv(e,t){return[e,...e.replies||[]].filter(e=>e?.drawing?.shapes?.length&&e.drawing.captureVersion&&e.drawing.captureVersion!==t).map(e=>e.drawing.captureVersion).sort().at(-1)||null}function Ev(e,{manifest:t,captures:n,versions:r}){if(!e||String(e.pageId).startsWith(`variant:`))return null;let{pageId:i,viewport:a}=e,o=t?.pages?.[i]?.[a],s=Cv(o,t),c=e.status===`resolved`||e.agentStatus===`done`,l=Tv(e,s),u=c?e.captureVersion:l;if(!u)return null;let d=n?.[i]?.[a]?.file||null,f=d?{kind:`captures`,file:d,version:s||`current`}:null;if(u===s)return{before:f,after:null,reason:`not-recaptured`};let p=(r?.[i]?.[a]||[]).find(e=>e.version===u),m=wv(e,u);return{before:p?{kind:`versions`,file:p.file,version:p.version}:null,after:f,reason:p?null:`pruned`,...m.length?{drawn:m}:{}}}function Dv(e,t,n,{minWidth:r=320,share:i=.45,aspect:a=.66}={}){let o=Math.min(e.width,Math.max(r,Math.round(e.width*i))),s=Math.min(e.height,Math.round(o*a)),c=e.width*t/100,l=e.height*n/100;return{left:Math.round(Math.max(0,Math.min(e.width-o,c-o/2))),top:Math.round(Math.max(0,Math.min(e.height-s,l-s/2))),width:o,height:s}}function Ov(e,t){let n=e?.pages?.[t];if(!n)return null;let r=Object.values(n).filter(e=>e.status===`ok`).map(e=>e.percent);return r.length?Math.max(...r):null}function kv(e,t){let n=e?.pages?.[t];if(!n)return null;let r=null;for(let[e,t]of Object.entries(n))t?.status===`ok`&&(!r||t.percent>r.percent)&&(r={viewport:e,percent:t.percent});return r}function Av(e){let t=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(\d{3})Z/.exec(String(e||``));if(!t)return null;let[,n,r,i,a,o,s,c]=t,l=Date.UTC(Number(n),Number(r)-1,Number(i),Number(a),Number(o),Number(s),Number(c));return Number.isFinite(l)?new Date(l).toISOString():null}function jv({pageId:e,viewport:t,manifest:n,captures:r,versions:i}){let a=[],o=r?.[e]?.[t],s=n?.pages?.[e]?.[t];if(o?.file){let e=Cv(s,n)||`current`;a.push({version:e,kind:`captures`,file:o.file,thumb:o.thumb||o.file,current:!0,at:s?.capturedAt||Av(e)||n?.capturedAt||null})}for(let n of i?.[e]?.[t]||[])n.file&&!a.some(e=>e.version===n.version)&&a.push({version:n.version,kind:`versions`,file:n.file,thumb:n.thumb||n.file,current:!1,at:Av(n.version)});return a}function Mv(e,t){let n=e?.[t];return n?Math.max(0,...Object.values(n).map(e=>e.length)):0}var Nv=[{id:`agent-queued`,label:`Agent queued`},{id:`agent-working`,label:`Agent working`},{id:`agent-done`,label:`Agent done`},{id:`agent-branch`,label:`Fix ready on branch`},{id:`needs-human`,label:`Needs a person`},{id:`reopened`,label:`Reopened`},{id:`replies`,label:`With replies`},{id:`unanchored`,label:`Pinned by position`}];function Pv(e,t){switch(t){case`agent-queued`:return e.agentStatus===`queued`;case`agent-working`:return e.agentStatus===`working`;case`agent-done`:return e.agentStatus===`done`;case`agent-branch`:return e.agentStatus===`branch-ready`;case`needs-human`:return e.agentStatus===`needs-human`;case`reopened`:return e.status===`open`&&e.reopenCount>0;case`replies`:return(e.replies?.length||0)>0;case`unanchored`:return!e.anchor;default:return!0}}function Fv(e,{query:t=``,state:n=null,mention:r=null,titleOf:i=()=>``}={}){let a=String(t||``).toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if(n&&!Pv(e,n)||r&&!(e.mentions||[]).includes(r))return!1;if(!a.length)return!0;let t=[`#${e.id}`,e.body,e.author,e.viewport,i(e.pageId),e.resolution,e.fixRef,...(e.replies||[]).flatMap(e=>[e.body,e.author])].filter(Boolean).join(`
|
|
18
|
+
`).toLowerCase();return a.every(e=>t.includes(e))})}var Iv=[`responses`,`http4xx`,`http5xx`,`apiErrors`,`rateLimited`,`apiRateLimited`,`failedRequests`];function Lv(e){return!e||e.schemaVersion!==1||e.window!==`navigation-through-screenshot`||typeof e.capped!=`boolean`||Iv.some(t=>!Number.isInteger(e[t])||e[t]<0||e[t]>1e4)||e.responses+e.failedRequests>1e4||e.http4xx+e.http5xx>e.responses||e.apiErrors>e.http4xx+e.http5xx||e.rateLimited>e.http4xx||e.apiRateLimited>Math.min(e.rateLimited,e.apiErrors)?null:{schemaVersion:1,window:`navigation-through-screenshot`,...Object.fromEntries(Iv.map(t=>[t,e[t]])),capped:e.capped}}function Rv(e){let t=Lv(e);if(!t)return``;let n=[];t.rateLimited&&n.push(`${t.rateLimited} HTTP 429${t.apiRateLimited?` (${t.apiRateLimited} API)`:``}`);let r=t.http4xx+t.http5xx-t.rateLimited;return r&&n.push(`${r} other HTTP error${r===1?``:`s`}`),t.failedRequests&&n.push(`${t.failedRequests} failed request${t.failedRequests===1?``:`s`}`),t.capped&&n.push(`observation limit reached`),n.join(`; `)}var zv={desktop:e_,tablet:Q_,phone:B_},Bv=(e,t=e_)=>zv[e]||zv[String(e).split(`-`)[0]]||t,Vv=e=>e[0].toUpperCase()+e.slice(1).replace(/-/g,` `);function Hv(e){let t=e.lastIndexOf(`|`);return{targetId:e.slice(0,t),viewport:e.slice(t+1)}}var Uv=400;function Wv({content:e,side:t=`top`,align:n=`center`,children:r}){let[i,a]=(0,J.useState)(!1),o=(0,J.useRef)(null),s=(0,J.useRef)(0);if((0,J.useEffect)(()=>()=>window.clearTimeout(s.current),[]),!e)return r;let c=e=>{window.clearTimeout(s.current),s.current=window.setTimeout(()=>a(!0),e)},l=()=>{window.clearTimeout(s.current),a(!1)},u=r.props,d=(0,J.cloneElement)(r,{ref:e=>{o.current=e,typeof u.ref==`function`?u.ref(e):u.ref&&(u.ref.current=e)},onPointerEnter:e=>{u.onPointerEnter?.(e),e.pointerType!==`touch`&&c(Uv)},onPointerLeave:e=>{u.onPointerLeave?.(e),l()},onPointerDown:e=>{u.onPointerDown?.(e),l()},onFocus:e=>{u.onFocus?.(e),e.target.matches?.(`:focus-visible`)&&c(0)},onBlur:e=>{u.onBlur?.(e),l()}});return(0,Y.jsxs)(Y.Fragment,{children:[d,i?(0,Y.jsxs)(lt,{open:!0,onOpenChange:e=>e?null:l(),history:!1,children:[(0,Y.jsx)(fe,{virtualRef:o}),(0,Y.jsx)(ot,{role:`tooltip`,side:t,align:n,sideOffset:6,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),className:`pointer-events-none z-[70] max-w-64 animate-fade-in rounded-md border-0 bg-fg px-2 py-1 text-xs font-medium text-surface select-none`,"data-sw-card-tip":`true`,children:e})]}):null]})}function Gv({pageId:e,title:t,entries:n,viewports:r}){let[i,a]=(0,J.useState)(!1),o=r.map(e=>({name:e,text:n?.[e]?.status===`ok`?Rv(n[e].networkSummary):``})).filter(e=>e.text);return o.length?(0,Y.jsxs)(lt,{open:i,onOpenChange:a,children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`nodrag nopan relative inline-flex h-5 items-center gap-1 rounded-full bg-warn/15 px-1.5 text-[10px] font-medium text-fg transition-colors hover:bg-warn/25 focus-visible:outline-2 focus-visible:outline-accent [@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:-inset-3 [@media(pointer:coarse)]:before:content-['']`,"aria-label":`Capture network warnings for ${t}`,"data-sw-capture-warning":e,onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(nv,{size:10,className:`shrink-0 text-warn`,"aria-hidden":`true`}),`Network`]})}),(0,Y.jsxs)(ot,{className:`w-80 max-w-[calc(100vw-1.5rem)] p-0 text-xs`,"aria-label":`Capture network warnings`,"data-sw-capture-warning-details":!0,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-line py-2 pr-1.5 pl-3`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-warn/15 text-warn`,children:(0,Y.jsx)(nv,{size:13,"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h3`,{className:`text-[13px] font-semibold text-fg`,children:`Capture network warnings`}),(0,Y.jsx)(`p`,{className:`mt-0.5 truncate text-muted`,children:t})]}),(0,Y.jsx)(B,{size:`icon-sm`,className:`[@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11`,label:`Close`,tooltip:``,onClick:()=>a(!1),children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2.5 px-3 py-2.5`,children:[(0,Y.jsx)(`p`,{className:`text-muted`,children:`Screenshots were saved. These requests had problems during capture.`}),(0,Y.jsx)(`ul`,{className:`divide-y divide-line rounded-md border border-line`,children:o.map(e=>{let t=Bv(e.name);return(0,Y.jsxs)(`li`,{className:`flex items-start gap-2 px-2.5 py-2`,children:[(0,Y.jsx)(t,{size:13,className:`mt-0.5 shrink-0 text-faint`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block font-medium text-fg capitalize`,children:e.name}),(0,Y.jsx)(`span`,{className:`block break-words text-muted`,children:e.text})]})]},e.name)})}),(0,Y.jsx)(`p`,{className:`text-faint`,children:`Counts only requests that failed before the screenshot. Normal page redirects aren’t counted; failed API calls are.`})]})]})]}):null}var Kv=e=>{try{let t=new URL(e.finalUrl),n=new URL(e.url);return t.origin===n.origin?t.pathname+t.search:t.origin+t.pathname}catch{return``}};function qv({pageId:e,title:t,entries:n,viewports:r}){let i=r.filter(e=>n?.[e]?.status===`ok`&&n[e].redirected).map(e=>e+` landed on `+(Kv(n[e])||`another page`));if(!i.length)return null;let a=i.join(`; `)+`. The screenshot shows that page under the title `+t+`. A sign-in redirect? Record a login (Auth in the config docs).`;return(0,Y.jsx)(Wv,{content:a,children:(0,Y.jsxs)(`span`,{role:`img`,tabIndex:0,className:`nodrag nopan pointer-events-auto inline-flex h-5 items-center gap-1 rounded-full bg-warn/15 px-1.5 text-[10px] font-medium text-fg focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":a,"data-sw-capture-landed":e,children:[(0,Y.jsx)(Ah,{size:10,className:`shrink-0 text-warn`,"aria-hidden":`true`}),`Redirected`]})})}var Jv=(0,J.createContext)(null),Yv=8,Xv=26,Zv=12,Qv=72,$v=112,ey=72,ty=260,ny=64,ry=40,iy=4,ay=160;function oy(e,t){return Math.max(e.w,e.h)*t<ay}function sy(e,t){let n=Object.keys(t);return e===`all`?n:[n.includes(e)?e:n[0]]}function cy(e,t,n=null){let r=sy(e,t),i=Array.isArray(n)&&n.length?n.filter(e=>t[e]):null;if(!i?.length)return r;let a=r.filter(e=>i.includes(e));return a.length?a:[Object.keys(t).find(e=>i.includes(e))]}function ly(e,t,n=null){let r=e[t],i=n?.[t];return r&&i&&i!==r.height?{...r,height:i}:r}function uy(e,t,n=null,r=null,i=null){let a=Yv,o=cy(e,t,r),s=n||e===`all`&&Object.keys(t).length>1?Xv:Yv,c=o.flatMap(e=>{let r=ly(t,e,i),o=r.frameScale||.25;return(n||[null]).map(n=>{let i={viewport:e,x:a,y:s,w:Math.round(r.width*o),h:Math.round(r.height*o)};return r!==t[e]&&(i.native=r),n&&(i.env=n),a+=i.w+Zv,i})});return{frames:c,width:a-Zv+Yv,height:s+Math.max(...c.map(e=>e.h))+Yv}}function dy(e,t,n,r,i=null){let a=e.files&&typeof e.files==`object`?Object.keys(e.files).filter(e=>n[e]):null;if(!a?.length)return{frames:r.frames,width:r.width,height:r.height,only:null};let o=sy(t,n).filter(e=>a.includes(e));if(!o.length)return{frames:[],width:r.width,height:52,only:a};let s=uy(t,n,null,o,i);return{frames:s.frames,width:s.width,height:s.height,only:null}}function fy({pages:e,groups:t,variants:n,viewports:r,mode:i,compare:a=null}){let{width:o}=uy(i,r,a),s=new Map,c=e=>`${(e.viewports||[]).join(`,`)}|${JSON.stringify(e.frameHeight||null)}`,l=e=>{let t=c(e);return s.has(t)||s.set(t,uy(i,r,a,e.viewports,e.frameHeight)),s.get(t)},u=new Map,d=e=>{if(!a)return l(e);let t=c(e);return u.has(t)||u.set(t,uy(i,r,null,e.viewports,e.frameHeight)),u.get(t)},f=new Map;for(let e of n||[])f.has(e.pageId)||f.set(e.pageId,[]),f.get(e.pageId).push(e);let p=[...new Set([...t||[],...e.map(e=>e.group)])],m=[],h=[],g={},_=iy*(o+Qv),v=[];for(let t of p){let n=e.filter(e=>e.group===t);if(!n.length)continue;let a=[],o=0,s=0,c=0,u=0;for(let e of n){let t=l(e),n=(f.get(e.id)||[]).map(t=>({variant:t,shape:dy(t,i,r,d(e),e.frameHeight)})),p=n.reduce((e,t)=>e+t.shape.width+ey,t.width);o>0&&o+p>_&&(o=0,s+=u+$v,u=0),a.push({page:e,shape:t,beside:n,x:o+ny,y:s+ny+ry}),o+=p+Qv,c=Math.max(c,o-Qv),u=Math.max(u,t.height)}v.push({group:t,placed:a,width:c+128,height:s+u+ry+128})}let y=v.reduce((e,t)=>e+(t.width+ty)*(t.height+ty),0),b=Math.max(...v.map(e=>e.width),Math.sqrt(y*1.6)),x=0,S=0,C=0;for(let e of v)x>0&&x+e.width>b&&(x=0,S+=C+ty,C=0),e.x=x,e.y=S,x+=e.width+ty,C=Math.max(C,e.height);for(let e of v){m.push({id:`group:${e.group}`,type:`groupFrame`,position:{x:e.x,y:e.y},data:{group:e.group,count:e.placed.length},style:{width:e.width,height:e.height},width:e.width,height:e.height,selectable:!1,draggable:!1,focusable:!1,zIndex:-1});for(let{page:t,shape:n,beside:r,x:i,y:a}of e.placed){let{frames:o,width:s,height:c}=n,l=Math.round(e.x+i),u=Math.round(e.y+a);m.push({id:t.id,type:`page`,position:{x:l,y:u},data:{page:t,frames:o},style:{width:s,height:c},width:s,height:c,ariaLabel:`${t.title}, ${t.group} page. Arrow keys: its comments and buttons. Enter: its actions.`}),g[t.id]={x:l,y:u,w:s,h:c,frames:o,nodeId:t.id};let d=l+s+ey;r.forEach(({variant:e,shape:n},i)=>{let a=`variant:${e.id}`;m.push({id:a,type:`variant`,position:{x:d,y:u},data:{variant:e,frames:n.frames,only:n.only},ariaLabel:`Variant: ${e.title}. Arrow keys: its comments and buttons. Enter: its actions.`,style:{width:n.width,height:n.height},width:n.width,height:n.height}),g[a]={x:d,y:u,w:n.width,h:n.height,frames:n.frames,nodeId:a},h.push({id:`edge:${a}`,source:i===0?t.id:`variant:${r[i-1].variant.id}`,sourceHandle:`right`,target:a,targetHandle:`left`,type:`straight`,className:`sw-edge-variant`,style:{strokeDasharray:`6 6`},ariaLabel:`Variant of ${t.title}: ${e.title}`}),d+=n.width+ey})}}return{nodes:m,edges:h,targets:g}}var py=5;function my(e){let t=e.anchor;if(!t||!(t.w>0)||!(t.h>0))return null;let n=e.x-t.dx*t.w*100,r=e.y-t.dy*t.h*100;return{left:n,top:r,right:n+t.w*100,bottom:r+t.h*100}}function hy(e,t=null){let n=t?.box||my(e);if(!n)return{x:t?t.x:e.x,y:t?t.y:e.y,flipX:!1,flipY:!1};let r=e=>Math.max(0,Math.min(100,e)),i=n.right>95,a=i&&n.left>=py?n.left:n.right,o=n.top<py,s=o&&n.bottom<=95?n.bottom:n.top;return{x:r(a),y:r(s),flipX:i,flipY:o}}function gy(e,t=null){return!t||!e?.env||e.env===t.a}function _y(e,t){let n=e[t.pageId];if(!n)return null;let r=n.frames.find(e=>e.viewport===t.viewport);return r?{x:n.x+r.x+r.w*t.x/100,y:n.y+r.y+r.h*t.y/100,nodeId:n.nodeId}:null}var vy={elements:8e3,bytes:3145728,text:80,attr:200,selector:600,size:1e4},yy=`a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"], [role="menuitem"], img`,by=String.raw`(?:[A-Za-z0-9_\u0080-\uffff-]|\\[0-9a-fA-F]{6} ?|\\[0-9a-fA-F]{1,5}(?![0-9a-fA-F]) ?|\\[^0-9a-fA-F\n\r\f])+`,xy=String.raw`(?:[^"\\\n]|\\.){0,200}`,Sy=String.raw`(?:#${by}|[a-z][a-z0-9-]{0,40}(?:\[(?:data-testid|aria-label)="${xy}"\]|:nth-of-type\([1-9][0-9]{0,4}\)))`,Cy=RegExp(`^${Sy}(?: > ${Sy}){0,79}$`),wy=RegExp(`^${Sy}$`),Ty=/^[a-z][a-z0-9-]{0,40}$/;function Ey(e){let t=document,n=t.documentElement,r=t.body,i=Math.round(innerWidth),a=Math.round(innerHeight);if(!r)return{v:1,width:i,height:a,elements:[]};let o=e=>{let t=e.innerText||e.textContent||e.getAttribute(`aria-label`)||e.getAttribute(`alt`)||e.getAttribute(`placeholder`)||``;return String(t).replace(/\s+/g,` `).trim()},s=e=>String(e).replace(/["\\]/g,`\\$&`),c=e=>{try{return t.querySelectorAll(e).length===1}catch{return!1}},l=e=>Math.round(e*10)/10,u=e=>!!(e&&e.width&&e.height),d=[r,...Array.from(r.querySelectorAll(`*`))],f=new Map,p=new Set;for(let e of d){let t=e.getBoundingClientRect();if(f.set(e,t),!(!u(t)||t.right<=0||t.bottom<=0||t.left>=i||t.top>=a))for(let t=e;t&&t!==n&&!p.has(t);t=t.parentElement)p.add(t)}let m=d.filter(e=>p.has(e)),h=m.slice(0,e.elements),g=new Map(h.map((e,t)=>[e,t])),_=new Map,v=e=>{let t=_.get(e);return t||(t=getComputedStyle(e),_.set(e,t)),t},y=e=>{let t=0,r=0;for(let i=e;i&&i!==n;i=i.parentElement){let e=v(i);if(e.position!==`static`){r=1;let n=parseInt(e.zIndex,10);Number.isFinite(n)&&(t=n)}}return[t,r]},b=(e,t)=>{let r=t.left,i=t.top,a=t.right,o=t.bottom;if(v(e).position===`fixed`)return null;for(let t=e.parentElement;t&&t!==n;t=t.parentElement){let e=v(t);if(e.overflowX!==`visible`||e.overflowY!==`visible`){let e=f.get(t)||t.getBoundingClientRect();r=Math.max(r,e.left),i=Math.max(i,e.top),a=Math.min(a,e.right),o=Math.min(o,e.bottom)}if(e.position===`fixed`)break}return r===t.left&&i===t.top&&a===t.right&&o===t.bottom?null:[l(r),l(i),l(Math.max(0,a-r)),l(Math.max(0,o-i))]},x=[],S=[];h.forEach((t,n)=>{let i=t.tagName.toLowerCase(),a=f.get(t),d=1,p=t;for(;p=p.previousElementSibling;)p.tagName===t.tagName&&(d+=1);let m={t:i,n:d,p:t===r?-1:g.get(t.parentElement),b:[l(a.left),l(a.top),l(a.width),l(a.height)]},h=t.id,_=t.getAttribute(`data-testid`),C=t.getAttribute(`aria-label`);h&&c(`#${CSS.escape(h)}`)?m.h=`#${CSS.escape(h)}`:_&&c(`${i}[data-testid="${s(_)}"]`)?m.h=`${i}[data-testid="${s(_)}"]`:C&&C.length<=80&&c(`${i}[aria-label="${s(C)}"]`)&&(m.h=`${i}[aria-label="${s(C)}"]`),h&&h.length<=e.attr&&(m.i=h),_&&_.length<=e.attr&&(m.d=_),C&&C.length<=e.attr&&(m.r=C);let w=o(t);w&&(m.x=w.slice(0,e.text),w.length>e.text&&(m.l=1));let T=v(t);if(t!==r&&u(a)&&T.visibility===`visible`&&T.pointerEvents!==`none`){S.push({position:n,key:y(t)});let r=b(t,a);r&&(m.c=r);let i=t.closest(e.preferred)||t;i!==t&&(m.a=g.has(i)&&u(f.get(i))?g.get(i):-1)}x.push(m)}),S.sort((e,t)=>e.key[0]-t.key[0]||e.key[1]-t.key[1]||e.position-t.position),S.forEach((e,t)=>{x[e.position].z=t});let C={v:1,width:i,height:a,elements:x};return m.length>h.length&&(C.truncated=!0),C}`${Ey.toString()}${JSON.stringify({elements:vy.elements,text:vy.text,attr:vy.attr,preferred:yy})}`;var Dy=class extends Error{},Oy=/[\u0000-\u001f\u007f]/,ky=1e5;function Ay(e,t){if(!Array.isArray(e)||e.length!==4)throw new Dy(`${t}: a box is four numbers`);let n=e.map(e=>{if(typeof e!=`number`||!Number.isFinite(e)||Math.abs(e)>ky)throw new Dy(`${t}: a box is four numbers`);return Math.round(e*10)/10});if(n[2]<0||n[3]<0)throw new Dy(`${t}: a box has no negative size`);return n}function jy(e,t,n){if(typeof e!=`string`||!e||e.length>t||Oy.test(e))throw new Dy(`${n}: up to ${t} printable characters`);return e}function My(e){let t=vy;if(!e||typeof e!=`object`||Array.isArray(e))throw new Dy(`an element map is an object`);if(e.v!==1)throw new Dy(`unknown element map version`);let n=(e,n)=>{if(!Number.isInteger(e)||e<1||e>t.size)throw new Dy(`${n}: 1 to ${t.size}`);return e},r=n(e.width,`width`),i=n(e.height,`height`);if(!Array.isArray(e.elements)||e.elements.length>t.elements)throw new Dy(`elements: a list of at most ${t.elements}`);let a=e.elements.length,o=new Set,s={v:1,width:r,height:i,elements:e.elements.map((e,n)=>{let r=`elements[${n}]`;if(!e||typeof e!=`object`||Array.isArray(e))throw new Dy(`${r}: an object`);if(typeof e.t!=`string`||!Ty.test(e.t))throw new Dy(`${r}.t: a tag name`);if(!Number.isInteger(e.n)||e.n<1||e.n>99999)throw new Dy(`${r}.n: 1 to 99999`);if(!Number.isInteger(e.p)||e.p>=n||e.p<-1||e.p===-1!=(n===0))throw new Dy(`${r}.p: an earlier element`);let i={t:e.t,n:e.n,p:e.p,b:Ay(e.b,`${r}.b`)};if(e.h!==void 0){if(typeof e.h!=`string`||e.h.length>t.selector||!wy.test(e.h))throw new Dy(`${r}.h: one selector step`);i.h=e.h}for(let n of[`i`,`d`,`r`])e[n]!==void 0&&(i[n]=jy(e[n],t.attr,`${r}.${n}`));if(e.x!==void 0&&(i.x=jy(e.x,t.text,`${r}.x`)),e.l!==void 0){if(e.l!==1||i.x===void 0)throw new Dy(`${r}.l: 1 with a text`);i.l=1}if(e.z!==void 0){if(!Number.isInteger(e.z)||e.z<0||e.z>=a||o.has(e.z))throw new Dy(`${r}.z: a distinct rank`);o.add(e.z),i.z=e.z}if(e.c!==void 0&&(i.c=Ay(e.c,`${r}.c`)),e.a!==void 0){if(!Number.isInteger(e.a)||e.a<-1||e.a>=a)throw new Dy(`${r}.a: an element or -1`);i.a=e.a}return i})};return e.truncated===!0&&(s.truncated=!0),s}var Ny=(e,t)=>e.length>t?`${e.slice(0,t-3)}...`:e;function Py(e,t){let n=[],r=t,i=0;for(;r>=0&&i<1e4;){let t=e.elements[r];if(!t)break;if(t.h){n.unshift(t.h);break}n.unshift(`${t.t}:nth-of-type(${t.n})`),r=t.p,i+=1}let a=n.join(` > `);for(;a.length>vy.selector&&n.length>1;)n.shift(),a=n.join(` > `);return a.length>vy.selector?``:a}function Fy(e,t,n){let r=-1,i=-1,a=e?.elements||[];for(let e=0;e<a.length;e+=1){let o=a[e];if(o.z===void 0||o.z<=i)continue;let[s,c,l,u]=o.c||o.b;t>=s&&t<s+l&&n>=c&&n<c+u&&(r=e,i=o.z)}if(r<0)return-1;let o=a[r].a;return o===void 0?r:o}var Iy={h1:`Heading`,h2:`Heading`,h3:`Heading`,h4:`Heading`,h5:`Heading`,h6:`Heading`,a:`Link`,button:`Button`,summary:`Button`,img:`Image`,picture:`Image`,svg:`Image`,video:`Video`,input:`Field`,textarea:`Field`,select:`Field`,label:`Label`,li:`List item`,ul:`List`,ol:`List`,table:`Table`,form:`Form`,nav:`Navigation`,header:`Header`,footer:`Footer`,section:`Section`,article:`Section`,main:`Section`,aside:`Section`,div:`Section`};function Ly(e){let t=String(e||``).split(` > `).pop(),n=/^([a-z][a-z0-9-]*)/.exec(t);return n?n[1]:``}function Ry(e,t=``,{large:n=!1,max:r=32}={}){let i=String(t||``).trim(),a=Iy[e]||(i?`Text`:`Element`);return n&&a===`Section`&&(a=`Whole section`),i?`${a}: ${Ny(i,r)}`:a}function zy(e,t,n){let r=e.elements[t],i=Py(e,t),a=i?i.split(` > `).pop():r.t,o=r.x||``,[s,c,l,u]=r.b,d=(n?.width&&n?.height?l*u/(n.width*n.height):0)>.2;return{name:Ry(r.t,o,{large:d}),label:`${Ny(a,48)}${o?` "${Ny(o,28)}"`:``}`,large:d,rect:{left:s,top:c,width:l,height:u}}}function By(e,t,n,r=null){let i=Fy(e,t,n);if(i<0)return null;let a=e.elements[i],[o,s,c,l]=a.b;if(!c||!l)return null;let u=Py(e,i);if(!u||!Cy.test(u))return null;let d=e=>Math.max(0,Math.min(1,e)),f=e=>Math.round(d(e)*1e4)/1e4;return{selector:u,text:a.x||``,dx:f((t-o)/c),dy:f((n-s)/l),...r?.width&&r?.height?{w:f(c/r.width),h:f(l/r.height)}:{}}}function Vy(e){return e.replace(/\\(?:([0-9a-fA-F]{1,6}) ?|([^\n\r\f]))/g,(e,t,n)=>{if(t===void 0)return n;let r=parseInt(t,16);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}var Hy={id:RegExp(`#(${by})`,`y`),tag:/([a-z][a-z0-9-]{0,40})/y,attr:RegExp(`\\[(data-testid|aria-label)="(${xy})"\\]`,`y`),nth:/:nth-of-type\(([1-9][0-9]{0,4})\)/y,join:/ > /y};function Uy(e){if(typeof e!=`string`||!Cy.test(e))return null;let t=[],n=0,r=t=>{t.lastIndex=n;let r=t.exec(e);return r&&(n=t.lastIndex),r};for(;n<e.length;){if(t.length&&!r(Hy.join))return null;let e=r(Hy.id);if(e){t.push({id:Vy(e[1])});continue}if(e=r(Hy.tag),!e)return null;let n=e[1];if(e=r(Hy.attr),e)t.push({tag:n,[e[1]===`data-testid`?`testId`:`label`]:Vy(e[2])});else{if(e=r(Hy.nth),!e)return null;t.push({tag:n,nth:Number(e[1])})}}return t}function Wy(e,t){return t.id===void 0?e.t===t.tag?t.testId===void 0?t.label===void 0?e.n===t.nth:e.r===t.label:e.d===t.testId:!1:e.i===t.id}function Gy(e,t,n=1/0){let r=[],i=Uy(t);if(!i?.length)return r;let a=e?.elements||[],o=i[i.length-1];for(let e=0;e<a.length&&r.length<n;e+=1){if(!Wy(a[e],o))continue;let t=a[e].p,n=!0;for(let e=i.length-2;e>=0;--e){if(t<0||!Wy(a[t],i[e])){n=!1;break}t=a[t].p}n&&r.push(e)}return r}var Ky=(e,t)=>Gy(e,t,1)[0]??-1;function qy(e){let t=String(e).split(`>`).pop().trim(),n=/^([a-z][a-z0-9-]*)/i.exec(t);return n?n[1].toLowerCase():null}function Jy(e,t,n){if(!e?.elements?.length||!t?.selector||!n||!Cy.test(t.selector))return null;let r=String(t.text||``),i=e.elements,a=Ky(e,t.selector);a>=0&&r&&!(i[a].x||``).startsWith(r)&&(a=-1);let o=qy(t.selector);if(a<0&&r&&o){let e=1/0;for(let t=0;t<i.length;t+=1){let n=i[t];if(n.t!==o||n.l||n.x!==r)continue;let s=n.b[2]*n.b[3];s>0&&s<e&&(a=t,e=s)}}if(a<0)return null;let[s,c,l,u]=i[a].b;if(!l&&!u)return null;let d=(e,t)=>Math.max(0,Math.min(100,e/t*100)),f=Number.isFinite(t.dx)?t.dx:.5,p=Number.isFinite(t.dy)?t.dy:.5;return{x:d(s+f*l,n.width),y:d(c+p*u,n.height),box:{left:d(s,n.width),top:d(c,n.height),right:d(s+l,n.width),bottom:d(c+u,n.height)}}}var Yy=typeof Document>`u`?null:Document.prototype,Xy=e=>Yy?Object.getOwnPropertyDescriptor(Yy,e)?.get:null,Zy={documentElement:Xy(`documentElement`),body:Xy(`body`),defaultView:Xy(`defaultView`)},Qy=typeof Node>`u`?null:Object.getOwnPropertyDescriptor(Node.prototype,`nodeType`)?.get;function $y(e){if(!Yy||!Qy||!e||typeof e!=`object`)return!1;try{return Qy.call(e)===9}catch{return!1}}var eb={documentElement:e=>$y(e)?Zy.documentElement.call(e):null,body:e=>$y(e)?Zy.body.call(e):null,defaultView:e=>$y(e)?Zy.defaultView.call(e):null,querySelector:(e,t)=>Yy.querySelector.call(e,t),querySelectorAll:(e,t)=>Yy.querySelectorAll.call(e,t),elementFromPoint:(e,t,n)=>$y(e)?Yy.elementFromPoint.call(e,t,n):null,addEventListener:(e,...t)=>EventTarget.prototype.addEventListener.call(e,...t),removeEventListener:(e,...t)=>EventTarget.prototype.removeEventListener.call(e,...t)},tb=600,nb=2e3,rb=String.raw`(?:#(?:[A-Za-z0-9_\u0080--]|\\[0-9a-fA-F]{6} ?|\\[0-9a-fA-F]{1,5}(?![0-9a-fA-F]) ?|\\[^0-9a-fA-F\n\r\f])+|[a-z][a-z0-9-]{0,40}(?:\[(?:data-testid|aria-label)="(?:[^"\\\n]|\\.){0,200}"\]|:nth-of-type\([1-9][0-9]{0,4}\)))`,ib=RegExp(`^${rb}(?: > ${rb}){0,79}$`),ab=80,ob=`a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"], [role="menuitem"], img`;function sb(e){if(!e)return``;let t=e.innerText||e.textContent||e.getAttribute?.(`aria-label`)||e.getAttribute?.(`alt`)||e.getAttribute?.(`placeholder`)||``;return String(t).replace(/\s+/g,` `).trim()}function cb(e,t){let n=typeof CSS<`u`?CSS:null;return n?.escape?n.escape(t):String(t).replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function lb(e){return String(e).replace(/["\\]/g,`\\$&`)}function ub(e,t){try{return eb.querySelectorAll(e,t).length===1}catch{return!1}}function db(e,t){let n=[],r=t,i=eb.documentElement(e);for(;r&&r.nodeType===1&&r!==i;){let t=r.tagName.toLowerCase();if(r.id&&ub(e,`#${cb(e,r.id)}`)){n.unshift(`#${cb(e,r.id)}`);break}let i=r.getAttribute(`data-testid`);if(i&&ub(e,`${t}[data-testid="${lb(i)}"]`)){n.unshift(`${t}[data-testid="${lb(i)}"]`);break}let a=r.getAttribute(`aria-label`);if(a&&a.length<=80&&ub(e,`${t}[aria-label="${lb(a)}"]`)){n.unshift(`${t}[aria-label="${lb(a)}"]`);break}let o=1,s=r;for(;s=s.previousElementSibling;)s.tagName===r.tagName&&(o+=1);n.unshift(`${t}:nth-of-type(${o})`),r=r.parentElement}let a=n.join(` > `);for(;a.length>tb&&n.length>1;)n.shift(),a=n.join(` > `);return a.length>tb?``:a}function fb(e,t,n){let r=eb.elementFromPoint(e,t,n);if(!r||r===eb.documentElement(e)||r===eb.body(e))return null;let i=r.closest?.(ob)||r,a=i.getBoundingClientRect();return a.width&&a.height?i:null}var pb=(e,t)=>e.length>t?`${e.slice(0,t-3)}...`:e;function mb(e,t,n){let r=db(e,t),i=r?r.split(` > `).pop():t.tagName.toLowerCase(),a=sb(t),o=t.getBoundingClientRect(),s=(n?.width&&n?.height?o.width*o.height/(n.width*n.height):0)>.2;return{name:Ry(t.tagName.toLowerCase(),a,{large:s}),label:`${pb(i,48)}${a?` "${pb(a,28)}"`:``}`,large:s,rect:{left:o.left,top:o.top,width:o.width,height:o.height}}}function hb(e,t,n,r=null){let i=fb(e,t,n);if(!i)return null;let a=i.getBoundingClientRect(),o=e=>Math.max(0,Math.min(1,e)),s=db(e,i);if(!s||!ib.test(s))return null;let c=e=>Math.round(o(e)*1e4)/1e4;return{selector:s,text:sb(i).slice(0,ab),dx:c((t-a.left)/a.width),dy:c((n-a.top)/a.height),...r?.width&&r?.height?{w:c(a.width/r.width),h:c(a.height/r.height)}:{}}}function gb(e){let t=String(e).split(`>`).pop().trim(),n=/^([a-z][a-z0-9-]*)/i.exec(t);return n?n[1].toLowerCase():null}function _b(e,t,n){let r=eb.body(e);if(!r||!t?.selector||!n||!ib.test(t.selector))return null;let i=String(t.text||``),a=e=>{if(!i)return!0;let t=sb(e);return t===i||t.startsWith(i)},o=null;try{o=eb.querySelector(e,t.selector)}catch{o=null}o&&!a(o)&&(o=null);let s=gb(t.selector);if(!o&&i&&s){let e=null,t=1/0,n=Element.prototype.getElementsByTagName.call(r,s);for(let r=0;r<n.length&&r<nb;r+=1){let a=n[r];if(sb(a)!==i)continue;let o=a.getBoundingClientRect(),s=o.width*o.height;s>0&&s<t&&(e=a,t=s)}o=e}if(!o)return null;let c=o.getBoundingClientRect();if(!c.width&&!c.height)return null;let l=(e,t)=>Math.max(0,Math.min(100,e/t*100));return{x:l(c.left+t.dx*c.width,n.width),y:l(c.top+t.dy*c.height,n.height),box:{left:l(c.left,n.width),top:l(c.top,n.height),right:l(c.right,n.width),bottom:l(c.bottom,n.height)}}}var vb=12,yb=new Map;function bb(e){if(yb.has(e)){let t=yb.get(e);return yb.delete(e),yb.set(e,t),t}let t=fetch(e,{headers:{Accept:`application/json`},credentials:`same-origin`}).then(e=>e.ok?e.json():null).then(e=>e?My(e):null).catch(()=>null);for(t.then(t=>{t||yb.delete(e)}),yb.set(e,t);yb.size>vb;)yb.delete(yb.keys().next().value);return t}function xb(e){let[t,n]=(0,J.useState)({url:null,map:null,state:`off`});return(0,J.useEffect)(()=>{if(!e)return;let t=!0;return bb(e).then(r=>{t&&n({url:e,map:r,state:r?`ready`:`failed`})}),()=>{t=!1}},[e]),e?t.url===e?t:{map:null,state:`loading`}:{map:null,state:`off`}}function Sb(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)?t.href:null}catch{return null}}function Cb({value:e,touch:t}){if(!e)return null;let n=Sb(e);return(0,Y.jsxs)(`p`,{className:`mt-1 flex min-w-0 items-center gap-1 text-xs text-muted`,"data-sw-fix-ref":`true`,children:[(0,Y.jsx)(og,{size:12,className:`shrink-0`,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Fixed in`}),` `,n?(0,Y.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer noopener`,className:O(`truncate text-accent hover:underline`,t&&`py-2`),children:e}):(0,Y.jsx)(`code`,{className:`truncate font-mono text-[11px] text-fg`,children:e})]})}var wb={open:og,merged:ng,closed:ig};function Tb({github:e,touch:t}){let n=e?.issue,r=e?.pulls||[];if(!n&&!r.length)return null;let i=O(`inline-flex min-w-0 items-center gap-1 text-accent hover:underline`,t&&`min-h-11`);return(0,Y.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-muted`,"data-sw-github":`true`,children:[n&&Sb(n.url)?(0,Y.jsxs)(`a`,{href:Sb(n.url),target:`_blank`,rel:`noreferrer noopener`,className:i,"data-sw-github-issue-link":n.number,children:[(0,Y.jsx)(vh,{size:12,className:`shrink-0`,"aria-hidden":`true`}),` Issue #`,n.number]}):null,r.map(e=>{let t=wb[e.state]||og,n=Sb(e.url);return n?(0,Y.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer noopener`,className:i,"aria-label":e.title?`PR #${e.number} ${e.state}: ${e.title}`:void 0,"data-sw-github-pull":e.number,"data-sw-github-pull-state":e.state,children:[(0,Y.jsx)(t,{size:12,className:`shrink-0`,"aria-hidden":`true`}),` PR #`,e.number,(0,Y.jsx)(`span`,{className:`text-faint`,children:e.state})]},e.number):null})]})}var Eb={queued:{label:`Queued`,tone:`neutral`},working:{label:`Agent working`,tone:`accent`},done:{label:`Agent done`,tone:`ok`},"needs-human":{label:`Needs a person`,tone:`warn`},"branch-ready":{label:`Fix ready on branch`,tone:`warn`}};function Db({status:e,at:t=null,branch:n=null}){let r=Eb[e];if(!r)return null;let i=e===`branch-ready`&&n,a=i?`${r.label} ${n}`:r.label;return(0,Y.jsxs)(Qe,{tone:r.tone,"aria-label":t?`Agent status: ${a} (${A(t)})`:`Agent status: ${a}`,"data-sw-agent-status":e,className:i?`max-w-full`:void 0,children:[(0,Y.jsx)(I,{size:10,"aria-hidden":`true`}),` `,i?(0,Y.jsxs)(Y.Fragment,{children:[r.label,` `,(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:n})]}):a]})}function Ob({comment:e}){return e.status!==`open`||!e.reopenCount?null:(0,Y.jsxs)(Qe,{tone:`bad`,"data-sw-reopened":e.reopenCount,children:[(0,Y.jsx)(v_,{size:10,"aria-hidden":`true`}),` Reopened`,e.reopenCount>1?` ${e.reopenCount}x`:``]})}function kb({name:e,handle:t,agent:n}){return n===!0||n===void 0&&!t&&/agent|bot/i.test(e||``)}function Ab({name:e,handle:t,agent:n,className:r}){let i=kb({name:e,handle:t,agent:n});return(0,Y.jsxs)(`span`,{className:O(`inline-flex min-w-0 items-center gap-1`,r),children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold text-fg`,"data-sw-author":i?`agent`:`person`,children:e}),t?(0,Y.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`@`,t]}):null,n===!0?(0,Y.jsx)(Qe,{shape:`tag`,className:`bg-line text-fg`,children:`agent`}):null]})}var jb=({name:e,handle:t})=>String(e||t||``).toLowerCase();function Mb({name:e,handle:t,agent:n,agentId:r=null,size:i=`md`,className:a}){return(0,Y.jsx)(de,{person:!0,agent:kb({name:e,handle:t,agent:n}),agentId:r,name:e,colorKey:jb({name:e,handle:t}),size:i,className:a})}var Nb=e=>({name:e.author,handle:e.authorHandle,agent:e.authorAgent}),Pb=e=>({name:e.author,handle:e.handle,agent:e.agent,agentId:e.agentId||null}),Fb=e=>`${e} ${e===1?`reply`:`replies`}`,Ib={a:`link`,button:`button`,input:`field`,textarea:`text box`,select:`menu`,img:`image`,svg:`icon`,h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,p:`text`,li:`list item`,label:`label`,nav:`navigation`,table:`table`,th:`column header`,td:`table cell`,form:`form`,header:`header`,footer:`footer`},Lb=`a selector the capture did not have`;function Rb(e){if(!e)return null;if(e.unmatched&&!String(e.text||``).trim())return Lb;let t=String(e.selector||``).split(` > `).pop(),n=Ib[/^([a-z][a-z0-9-]*)/i.exec(t)?.[1]?.toLowerCase()||``]||`element`,r=String(e.text||``).replace(/\s+/g,` `).trim();if(r){let e=r.length>48?`${r.slice(0,47)}…`:r;return n===`text`||n===`element`?`“${e}”`:`the “${e}” ${n}`}let i=(/\[(?:data-testid|aria-label|name|id)="([^"]+)"\]/.exec(t)?.[1]||/#([\w-]+)/.exec(t)?.[1]||``).replace(/[-_]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase().trim();return i?`the ${i} ${n}`:`a ${n}`}function zb(e){let t=new Date(E(e));return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}):``}var Bb=(0,J.createContext)([]);function Vb({text:e,className:t,plain:n=!1}){let r=(0,J.useContext)(Bb),i=(0,J.useMemo)(()=>n?[{text:String(e??``)}]:Ce(e),[e,n]);return(0,Y.jsx)(`span`,{className:t,children:i.map((e,t)=>e.handle&&Te(e.handle,r)?(0,Y.jsxs)(`span`,{className:O(`inline-flex items-baseline gap-0.5 rounded px-1 font-medium`,Pe(e.handle)?`bg-warn/15 text-fg`:`bg-accent/10 text-accent`),"data-sw-mention":e.handle,children:[Pe(e.handle)?(0,Y.jsx)(I,{size:11,className:`self-center`,"aria-hidden":`true`}):null,e.text]},t):(0,Y.jsx)(`span`,{children:e.text},t))})}function Hb(e,t){let n=/(^|[^\w@.])@([\w.-]{0,40})$/.exec(e.slice(0,t));return n?{query:n[2].toLowerCase(),start:t-n[2].length-1}:null}function Ub({value:e,onChange:t,people:n,className:r,onKeyDown:i,size:a,inputRef:o=null,...s}){let c=(0,J.useRef)(null),l=(0,J.useCallback)(e=>{c.current=e,o&&(o.current=e)},[o]),u=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let t=c.current,n=u.current;t&&n!==null&&t.value===e&&(u.current=null,t.focus(),t.setSelectionRange(n,n))},[e]);let d=(0,J.useId)(),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(0),g=(0,J.useMemo)(()=>{if(!f)return[];let{query:e}=f,t=e=>[e.handle,...e.aliases||[]],r=n.filter(e=>e.known!==!1).filter(n=>t(n).some(t=>t.startsWith(e))||n.name.toLowerCase().includes(e)).map(n=>({...n,exact:!!e&&t(n).includes(e)}));return[...r.filter(e=>e.exact),...r.filter(e=>!e.exact)].slice(0,6)},[n,f]),_=g.length>0,v=e=>{let t=Hb(e.value,e.selectionStart??e.value.length);p(t),h(0)},y=n=>{let r=c.current;if(!r||!f)return;let i=r.selectionStart??e.length,a=`@${n.handle} `;t(`${e.slice(0,f.start)}${a}${e.slice(i)}`),p(null),u.current=f.start+a.length};return(0,Y.jsxs)(lt,{open:_,onOpenChange:e=>e?null:p(null),history:!1,children:[(0,Y.jsx)(fe,{asChild:!0,children:(0,Y.jsx)(We,{ref:l,size:a,value:e,onChange:e=>{t(e.target.value),v(e.target)},onClick:e=>v(e.currentTarget),onBlur:()=>window.setTimeout(()=>p(null),150),onKeyDown:e=>{if(_&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),h(t=>(t+(e.key===`ArrowDown`?1:g.length-1))%g.length);return}if(e.key===`Enter`&&m===0&&g[0].exact)p(null);else if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),y(g[m]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation?.(),p(null);return}}i?.(e)},className:r,"aria-autocomplete":`list`,"aria-expanded":_,"aria-controls":_?d:void 0,"aria-activedescendant":_?`${d}-${m}`:void 0,...s})}),(0,Y.jsx)(ot,{id:d,role:`listbox`,"aria-label":`Mention someone`,side:`bottom`,className:`max-h-56 w-[var(--radix-popover-trigger-width)] overflow-y-auto`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{e.target===c.current&&e.preventDefault()},"data-sw-mention-list":`true`,children:g.map((e,t)=>(0,Y.jsx)(`div`,{id:`${d}-${t}`,role:`option`,"aria-selected":t===m,children:(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,onMouseDown:t=>{t.preventDefault(),y(e)},className:O(`flex w-full min-w-0 items-center gap-2 rounded-md px-2 text-left text-[13px]`,`h-11 lg:h-8`,t===m?`bg-accent/10 text-fg`:`text-muted hover:bg-surface-2`,`transition-colors`),"data-sw-mention-option":e.handle,children:[(0,Y.jsx)(de,{person:!0,agent:!!e.agent,name:e.name,colorKey:jb(e),size:`sm`,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium text-fg`,children:e.agent?`@`+e.handle:e.name}),(0,Y.jsx)(`span`,{className:`min-w-0 shrink truncate text-xs text-faint`,children:e.agent?e.name===e.handle?`agent`:e.name:`@`+e.handle})]})},e.handle))})]})}var Wb={"false,false":`rounded-bl-none`,"true,false":`rounded-br-none`,"false,true":`rounded-tl-none`,"true,true":`rounded-tr-none`},Gb=`[@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:-inset-2 [@media(pointer:coarse)]:before:content-['']`;function Kb(e,t,n,r,i=!1){let a=e=>Math.round(e*8)/8,o=t*e;if(o<150&&!i)return`dot:${a(Math.min(60,1/e))}`;let s=n?28:Math.max(18,Math.min(28,o/14));return`full:${a(Math.min(r,Math.max(.3,s/28/e)))||.125}`}function qb(e){return e.status===`resolved`?`resolved`:e.agentStatus||(e.reopenCount?`reopened`:`open`)}var Jb={resolved:`border-ok`,"needs-human":`border-warn`,"branch-ready":`border-accent`,reopened:`border-bad`};function Yb(e,t,n=1){return{left:`${e.x}%`,top:`${e.y}%`,transform:`translate(${e.flipX?`-100%`:`0`}, ${e.flipY?`0`:`-100%`}) scale(${t*n})`,transformOrigin:`${e.flipY?`top`:`bottom`} ${e.flipX?`right`:`left`}`}}var Xb=e=>String(e||``).split(`
|
|
19
|
+
`)[0];function Zb({comment:e,moved:t}){let n=Nb(e),r=e.replies?.length||0;return(0,Y.jsxs)(`div`,{"data-sw-pin-preview":e.id,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(Mb,{...n,size:`sm`}),(0,Y.jsx)(Ab,{...n}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:A(e.createdAt)})]}),(0,Y.jsx)(Vb,{text:Xb(Me(e)),plain:!!e.authorGuest,className:`mt-1.5 line-clamp-2 block text-ui break-words text-fg`}),(0,Y.jsxs)(`p`,{className:`mt-1.5 flex flex-wrap items-center gap-x-2 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{children:r?Fb(r):`No replies yet`}),e.status===`resolved`?(0,Y.jsx)(`span`,{className:`text-fg`,children:`Resolved`}):null,t?(0,Y.jsx)(`span`,{className:`text-fg`,children:`Its element is not on the page anymore`}):null]})]})}function Qb({dot:e=!1}){return(0,Y.jsx)(`span`,{className:O(`pointer-events-none absolute rounded-full ring-2 ring-accent motion-safe:animate-breathe`,e?`-inset-1`:`-inset-1.5`),"aria-hidden":`true`,"data-sw-pin-working":`true`})}function $b({comment:e,spot:t,scale:n,selected:r,unread:i,working:a,onSelect:o,onHover:s,touch:c,label:l,landed:u=!1}){let d=Nb(e),f=kb(d);return(0,Y.jsx)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan absolute z-10 h-2.5 w-2.5 rounded-full border border-white shadow-card`,c&&`pointer-events-none`,e.status===`resolved`&&!r&&`opacity-60`,r?`z-20 ring-2 ring-accent`:i?`ring-2 ring-accent/70`:null,`data-[sw-pin-hover=true]:z-20 data-[sw-pin-hover=true]:ring-2 data-[sw-pin-hover=true]:ring-accent/60`),style:{left:`${t.x}%`,top:`${t.y}%`,transform:`translate(-50%, -50%) scale(${n})`,background:f?Oe:Ye(d.name)},onClick:t=>{t.stopPropagation(),o(e)},onMouseEnter:s?()=>s(e.id):void 0,onMouseLeave:s?()=>s(null):void 0,"aria-label":l,"aria-pressed":r,"data-sw-pin":e.id,"data-sw-pin-landed":u?`true`:void 0,"data-sw-pin-look":`dot`,"data-sw-pin-state":qb(e),"data-sw-pin-unread":i?`true`:void 0,children:a?(0,Y.jsx)(Qb,{dot:!0}):null})}function ex({comment:e,position:t,scale:n,compact:r=!1,selected:i,unread:a,working:o=!1,landed:s=!1,onSelect:c,onHover:l,touch:f}){let p=hy(e,t),m=!!t?.moved,h=Nb(e),g=kb(h),_=qb(e),v=1+(e.replies?.length||0),y=e.status===`resolved`,b=p.flipX?`-left-1.5`:`-right-1.5`,x=p.flipY?`-bottom-1.5`:`-top-1.5`,S=p.flipX?`-right-0.5`:`-left-0.5`,C=`Comment ${e.id} by ${h.name}${v>1?`, ${Fb(v-1)}`:``}${y?`, resolved`:``}${a?`, unread`:``}${m?` (its element moved)`:``}${o?`, an agent is working on it`:``}: ${Me(e).slice(0,60)}`,w=r?(0,Y.jsx)($b,{comment:e,spot:p,scale:n,selected:i,unread:a,working:o,onSelect:c,onHover:l,touch:f,label:C,landed:s}):(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan absolute z-10 flex h-7 w-7 items-center justify-center rounded-full border-2 border-white text-[11px] leading-none font-semibold text-white shadow-pop transition-[box-shadow,opacity] select-none`,Wb[`${p.flipX},${p.flipY}`],Jb[_],Gb,m&&`outline-2 outline-offset-2 outline-warn outline-dashed`,y&&!i&&`opacity-75`,i?`z-20 ring-[3px] ring-accent`:`data-[sw-pin-hover=true]:z-20 data-[sw-pin-hover=true]:ring-[3px] data-[sw-pin-hover=true]:ring-accent/60`),style:{...Yb(p,n,i?1.15:1),background:g?Oe:Ye(h.name)},onClick:t=>{t.stopPropagation(),c(e)},onMouseEnter:l?()=>l(e.id):void 0,onMouseLeave:l?()=>l(null):void 0,"aria-label":C,"aria-pressed":i,"data-sw-pin":e.id,"data-sw-pin-landed":s?`true`:void 0,"data-sw-pin-state":_,"data-sw-pin-anchor":e.anchor?t?m?`moved`:`element`:`xy`:`none`,"data-sw-pin-unread":a?`true`:void 0,"data-sw-pin-count":v,"data-sw-pin-look":`full`,children:[o?(0,Y.jsx)(Qb,{}):null,g?(0,Y.jsx)(I,{size:14,"aria-hidden":`true`}):(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:Be(h.name)}),y?(0,Y.jsx)(`span`,{className:O(`absolute flex h-4 w-4 items-center justify-center rounded-full border border-white bg-ok text-ok-fg`,b,x),"aria-hidden":`true`,children:(0,Y.jsx)(st,{size:10,strokeWidth:3})}):v>1?(0,Y.jsx)(`span`,{className:O(`absolute flex h-4 min-w-4 items-center justify-center rounded-full border border-white bg-fg px-1 text-[9px] font-bold text-surface tabular`,b,x),"aria-hidden":`true`,children:v}):null,a?(0,Y.jsx)(`span`,{className:O(`absolute h-2.5 w-2.5 rounded-full border-2 border-white bg-accent`,S,p.flipY?`-bottom-0.5`:`-top-0.5`),"aria-hidden":`true`,"data-sw-pin-dot":`true`}):null]});return f||i?w:(0,Y.jsxs)(L,{children:[(0,Y.jsx)(u,{asChild:!0,children:w}),(0,Y.jsx)(d,{side:p.flipX?`left`:`right`,align:`start`,"data-sw-pin-preview":e.id,children:(0,Y.jsx)(Zb,{comment:e,moved:m})})]})}function tx({items:e,scale:t,compact:n=!1,touch:r=!1,working:i=!1,onOpen:a}){let o=e[0].spot,s=e.some(e=>e.unread);return n?(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`tabular nodrag nopan absolute z-10 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border border-white bg-fg px-0.5 text-[8px] leading-none font-bold text-surface shadow-card`,r&&`pointer-events-none`,s&&`ring-2 ring-accent/70`),style:{left:`${o.x}%`,top:`${o.y}%`,transform:`translate(-50%, -50%) scale(${t})`},onClick:t=>{t.stopPropagation(),a(e)},"aria-label":`${e.length} comments here${s?`, some unread`:``}: zoom in`,"data-sw-pin-cluster":e.map(e=>e.comment.id).join(`,`),"data-sw-pin-look":`dot`,children:[e.length,i?(0,Y.jsx)(Qb,{dot:!0}):null]}):(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan absolute z-10 flex h-8 min-w-8 items-center justify-center rounded-full border-2 border-white bg-fg px-1.5 text-xs font-bold text-surface shadow-pop tabular`,Wb[`${o.flipX},${o.flipY}`],Gb),style:Yb(o,t),onClick:t=>{t.stopPropagation(),a(e)},"aria-label":`${e.length} comments here${s?`, some unread`:``}: zoom in`,"data-sw-pin-cluster":e.map(e=>e.comment.id).join(`,`),children:[e.length,i?(0,Y.jsx)(Qb,{}):null,s?(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -left-0.5 h-2.5 w-2.5 rounded-full border-2 border-white bg-accent`,"aria-hidden":`true`}):null]})}function nx(e,t,n,r=null,i=30){let a=[];for(let o of e){let e=o.spot.x/100*t.w*n,s=o.spot.y/100*t.h*n;if(o.comment.id===r){a.push({items:[o],px:e,py:s,alone:!0});continue}let c=a.find(t=>!t.alone&&Math.hypot(t.px-e,t.py-s)<i);c?c.items.push(o):a.push({items:[o],px:e,py:s,alone:!1})}return a}function rx({draft:e,scale:t,name:n,colorKey:r}){let i=hy(e);return(0,Y.jsx)(`span`,{className:O(`pointer-events-none absolute z-20 flex h-7 w-7 items-center justify-center rounded-full border-2 border-white text-[11px] font-semibold text-white shadow-pop ring-[3px] ring-accent`,Wb[`${i.flipX},${i.flipY}`]),style:{...Yb(i,t),background:Ye(r||n||`you`)},"aria-hidden":`true`,"data-sw-draft-pin":`true`,children:Be(n||`You`)})}var ix=new Set,ax={focusedKey:null,selectingKey:null,readingKey:null,settledZoom:null,selectedComment:null,draftSpot:null,unread:ix,liveKeys:ix,hoveredId:null,landedId:null,commentTargetKey:null};function ox(e=null){let t={...ax,...e},n=new Set;return{get:()=>t,set(e){let r=null;for(let n of Object.keys(e))Object.is(t[n],e[n])||(r||={...t},r[n]=e[n]);if(r){t=r;for(let e of[...n])e()}},subscribe(e){return n.add(e),()=>n.delete(e)}}}var sx=ox(),cx=(0,J.createContext)(sx),lx=()=>(0,J.useContext)(cx);function ux(e){let t=(0,J.useContext)(cx),n=(0,J.useCallback)(()=>e(t.get()),[t,e]);return(0,J.useSyncExternalStore)(t.subscribe,n,n)}var dx=[];function fx(e,t){return t.agentStatus===`working`||!!e.agentWorking?.has(t.id)}function px(e,t,n,r=!0){let i=ux(e=>{let i=e.selectedComment;return r&&i&&i.pageId===t&&i.viewport===n?i:null}),a=r?e.pinsFor(t,n):dx;return{pins:(0,J.useMemo)(()=>i&&!a.includes(i)?[...a,i]:a,[a,i]),openHere:i,selectedCommentId:i?.id??null}}function mx(e,t,{active:n=!0,drafting:r=!1}={}){let i=e.touch?50:6,a=$(a=>n?Kb(a.transform[2],t.w,e.touch,i,r):`full:1`);return{pinScale:Number(a.slice(a.indexOf(`:`)+1)),compactPins:a.startsWith(`dot:`)}}function hx({pins:e,positions:t=null,frame:n,compact:r=!1,selectedCommentId:i=null}){let a=ux(t=>e.length?e.filter(e=>t.unread.has(e.id)).map(e=>e.id).join(`,`):``),o=$(t=>e.length>1?Math.round(t.transform[2]*20)/20:1);return(0,J.useMemo)(()=>{let s=new Set(a?a.split(`,`):[]);return nx(e.map(e=>{let n=t?.get(e.id)||null;return{comment:e,position:n,spot:hy(e,n),unread:s.has(String(e.id))}}),n,o,i,r?12:void 0)},[e,t,a,n,o,i,r])}function gx(e){return ux(t=>t.landedId!==null&&e.some(e=>e.id===t.landedId)?t.landedId:null)}function _x({targetId:e,viewport:t,clusters:n,scale:r,compact:i=!1,selectedCommentId:a=null,landedId:o=null}){let s=(0,J.useContext)(Jv);return n.map(n=>n.items.length===1?(0,Y.jsx)(ex,{comment:n.items[0].comment,position:n.items[0].position,scale:r,compact:i,selected:a===n.items[0].comment.id,unread:n.items[0].unread,working:fx(s,n.items[0].comment),landed:o===n.items[0].comment.id,onSelect:s.onSelectComment,onHover:s.onHoverComment,touch:s.touch},n.items[0].comment.id):(0,Y.jsx)(tx,{items:n.items,compact:i,touch:s.touch,working:n.items.some(e=>fx(s,e.comment)),scale:r,onOpen:n=>s.onOpenCluster(e,t,n)},`cluster-${n.items[0].comment.id}`))}function vx({label:e,keys:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,t.map(e=>(0,Y.jsx)(s,{children:e},e))]})}var yx=5242880,bx=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`],xx=1600;function Sx(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}async function Cx(e,t,n=null){let r=await Sx(e);return{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:t,mediaType:e.type,data:r.split(`,`)[1],preview:r,source:n}}function wx(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error(`The image could not be loaded.`)),r.src=e})}function Tx(e,t,n,r=`image/png`){let i=Math.min(1,n/Math.max(t.width,t.height)),a=document.createElement(`canvas`);return a.width=Math.max(1,Math.round(t.width*i)),a.height=Math.max(1,Math.round(t.height*i)),a.getContext(`2d`).drawImage(e,t.x,t.y,t.width,t.height,0,0,a.width,a.height),new Promise((e,t)=>a.toBlob(n=>n?e(n):t(Error(`Could not crop the screenshot.`)),r,.9))}async function Ex(e){let t=e.name||`That image`;if(!bx.includes(e.type))throw Error(`${t} is not a PNG, JPEG, WebP or GIF image.`);if(e.size<=yx)return Cx(e,e.name||`pasted-image.png`);let n=URL.createObjectURL(e);try{let r=await wx(n),i=await Tx(r,{x:0,y:0,width:r.naturalWidth,height:r.naturalHeight},2048,`image/jpeg`);if(i.size>yx)throw Error(`${t} is larger than 5 MB.`);return Cx(i,`${(e.name||`image`).replace(/\.\w+$/,``)}.jpg`)}finally{URL.revokeObjectURL(n)}}async function Dx(e,{name:t,point:n=null,source:r}){let i=await wx(e),a=i.naturalWidth,o=i.naturalHeight,s={x:0,y:0,width:a,height:o};if(n){let e=Math.min(a,900),t=Math.min(o,700),r=n.x/100*a,i=n.y/100*o;s={x:Math.round(Math.min(Math.max(0,r-e/2),a-e)),y:Math.round(Math.min(Math.max(0,i-t/2),o-t)),width:e,height:t}}return Cx(await Tx(i,s,n?900:xx,n?`image/png`:`image/jpeg`),t,r)}function Ox(e){return[...e||[]].filter(e=>e.type?.startsWith(`image/`))}var kx=Object.keys(he).join(`,`),Ax=Je/1048576,jx=2560;async function Mx(e){let t=await createImageBitmap(e,{imageOrientation:`from-image`});try{let n=Math.min(1,jx/Math.max(t.width,t.height)),r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t.width*n)),r.height=Math.max(1,Math.round(t.height*n)),r.getContext(`2d`).drawImage(t,0,0,r.width,r.height);let i=await new Promise((e,t)=>r.toBlob(n=>n?e(n):t(Error(`The photo could not be read.`)),`image/jpeg`,.9));return new File([i],e.name||`photo.jpg`,{type:`image/jpeg`})}finally{t.close?.()}}async function Nx(e){let t=e.name?`"${e.name}"`:`That image`;if(!he[e.type])throw Error(`${t} is not a PNG, JPEG, WebP or GIF image.`);let n=e;if(e.type===`image/jpeg`&&typeof createImageBitmap==`function`)try{n=await Mx(e)}catch{throw Error(`${t} could not be read as an image.`)}let r=await Ex(n).catch(e=>{throw Error(e.message?.includes(`5 MB`)?`${t} is larger than ${Ax} MB.`:e.message||`${t} could not be read.`)});if(r.data.length*3/4>5242880)throw Error(`${t} is larger than ${Ax} MB.`);return r}var Px=e=>e.filter(e=>e.state===`ready`).map(({name:e,mediaType:t,data:n})=>({name:e,mediaType:t,data:n}));function Fx({enabled:e=!0,max:t=4,initial:n=null}={}){let[r,i]=(0,J.useState)(()=>e&&n?n.slice(0,t):[]),[a,o]=(0,J.useState)(null),s=(0,J.useRef)(0);return s.current=r.length,{images:r,error:a,setError:o,add:(0,J.useCallback)(async n=>{let r=[...n||[]];if(!e||!r.length)return;let a=t-s.current;if(a<=0)o(`A comment holds at most ${t} images.`);else{o(r.length>a?`Only ${a===1?`one more image fits`:`${a} more images fit`}: a comment holds ${t}.`:null);for(let e of r.slice(0,a)){let t=`img-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;s.current+=1,i(n=>[...n,{id:t,name:e.name||`pasted image`,preview:null,state:`reading`}]);try{let n=await Nx(e);i(e=>e.map(e=>e.id===t?{...n,id:t,state:`ready`}:e))}catch(e){--s.current,i(e=>e.filter(e=>e.id!==t)),o(e.message)}}}},[e,t]),remove:(0,J.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e)),o(null)},[]),clear:(0,J.useCallback)(()=>{i([]),o(null)},[]),reading:r.some(e=>e.state===`reading`)}}function Ix(e){return[...e?.files||[]].filter(e=>e.type?.startsWith(`image/`))}var Lx=[`accent`,`bad`,`warn`],Rx=2e3,zx=8e-4;function Bx([e,t],[n,r],[i,a]){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0,u=n+l*o-e,d=r+l*s-t;return Math.sqrt(u*u+d*d)}function Vx(e,t=zx){if(e.length<=2)return e.slice();let n=new Uint8Array(e.length);n[0]=1,n[e.length-1]=1;let r=[[0,e.length-1]];for(;r.length;){let[i,a]=r.pop(),o=-1,s=-1;for(let t=i+1;t<a;t+=1){let n=Bx(e[t],e[i],e[a]);n>o&&(o=n,s=t)}s!==-1&&o>t&&(n[s]=1,r.push([i,s],[s,a]))}let i=e.filter((e,t)=>n[t]);return i.filter((e,t)=>t===0||e[0]!==i[t-1][0]||e[1]!==i[t-1][1])}function Hx(e){let t=1,n=1,r=0,i=0;for(let a of e?.shapes||[])for(let[e,o]of a.points)t=Math.min(t,e),n=Math.min(n,o),r=Math.max(r,e),i=Math.max(i,o);return r<t||i<n?null:{x:t,y:n,width:r-t,height:i-n}}var Ux={accent:`Accent`,bad:`Red`,warn:`Orange`},Wx=.004,Gx=null,Kx=new Set,qx=()=>Kx.forEach(e=>e()),Jx={get:()=>Gx,start(e,t,n=[]){(Gx?.key!==e||Gx.owner!==t)&&(Gx={key:e,owner:t,tool:null,ink:Lx[0],shapes:n.slice(0,40)},qx())},moveTo(e,t){Gx?.owner===t&&(Gx.key!==e&&(Gx={...Gx,key:e,shapes:[]}),qx())},set(e){Gx&&(Gx={...Gx,...e},qx())},add(e){!Gx||Gx.shapes.length>=40||(Gx={...Gx,shapes:[...Gx.shapes,e]},qx())},undo(){Gx?.shapes.length&&(Gx={...Gx,shapes:Gx.shapes.slice(0,-1)},qx())},clear(){Gx?.shapes.length&&(Gx={...Gx,shapes:[]},qx())},end(e){Gx&&(!e||Gx.owner===e)&&(Gx=null,qx())},subscribe(e){return Kx.add(e),()=>Kx.delete(e)}};function Yx(e=e=>e){return(0,J.useSyncExternalStore)(Jx.subscribe,()=>e(Gx),()=>e(null))}function Xx(e){return e?.length?{shapes:e}:void 0}var Zx=e=>Math.min(1,Math.max(0,e)),Qx=e=>Math.round(e*1e4)/1e4,$x=(e,t)=>[Qx(Zx((t.clientX-e.left)/e.width)),Qx(Zx((t.clientY-e.top)/e.height))];function eS(e,t,n){if(!n.length)return null;if(e===`pen`){let r=Vx(n.slice(0,Rx));return r.length<2?null:{tool:e,ink:t,width:4,points:r}}let[r,i]=[n[0],n.at(-1)];return Math.hypot(i[0]-r[0],i[1]-r[1])<Wx?null:{tool:e,ink:t,width:4,points:[r,i]}}function tS(e,t,n){let r=e.points.map(([e,r])=>[e*t,r*n]);if(e.tool===`box`){let[[e,t],[n,i]]=r;return[`M${e} ${t}H${n}V${i}H${e}Z`]}let i=`M${r.map(([e,t])=>`${e} ${t}`).join(`L`)}`;if(e.tool!==`arrow`)return[i];let[[a,o],[s,c]]=r,l=Math.atan2(c-o,s-a),u=Math.max(10,e.width*5),d=e=>`${s+Math.cos(l+e)*u} ${c+Math.sin(l+e)*u}`;return[i,`M${d(Math.PI*.82)}L${s} ${c}L${d(-Math.PI*.82)}`]}function nS(e,t){let n=[],r=0;for(let i of[e,...e?.replies||[]]){if(!i?.drawing?.shapes?.length)continue;let e=i.drawing.captureVersion;!e||!t||e===t?n.push(...i.drawing.shapes):r+=1}return{shapes:n,previous:r}}var rS=e=>[e,...e?.replies||[]].some(e=>e?.drawing?.shapes?.length),iS=[{id:`box`,label:`Box`,start:`Draw a box on the page`,icon:J_},{id:`arrow`,label:`Arrow`,start:`Draw an arrow on the page`,icon:ih},{id:`pen`,label:`Pen`,start:`Draw freehand on the page`,icon:ch}],aS={accent:`bg-accent`,bad:`bg-bad`,warn:`bg-warn`},oS={accent:`var(--accent)`,bad:`var(--bad)`,warn:`var(--warn)`};function sS({shapes:e,width:t,height:n,crop:r=null,className:i,...a}){if(!e?.length)return null;let o=r?`${r.left} ${r.top} ${r.width} ${r.height}`:`0 0 ${t} ${n}`;return(0,Y.jsx)(`svg`,{className:O(`pointer-events-none absolute inset-0 h-full w-full`,r?`overflow-hidden`:`overflow-visible`,i),viewBox:o,preserveAspectRatio:`none`,"aria-hidden":`true`,...a,children:e.map((e,r)=>tS(e,t,n).map((t,n)=>(0,Y.jsx)(`path`,{d:t,fill:`none`,stroke:oS[e.ink]||oS.accent,strokeWidth:e.width,strokeLinecap:`round`,strokeLinejoin:`round`},`${r}-${n}`)))})}function cS({tool:e,ink:t,width:n,height:r,className:i,children:a}){let[o,s]=(0,J.useState)(null),c=(0,J.useRef)([]),l=(0,J.useRef)(null),u=e=>$x(l.current.getBoundingClientRect(),e);(0,J.useEffect)(()=>()=>Jx.set({stroking:!1}),[]);let d=(n,r)=>{if(!c.current.length)return;Jx.set({stroking:!1}),n.currentTarget.releasePointerCapture?.(n.pointerId);let i=r?eS(e,t,c.current):null;c.current=[],s(null),i&&Jx.add(i)};return(0,Y.jsxs)(`div`,{ref:l,className:O(`nodrag nopan absolute inset-0 z-[25] cursor-crosshair touch-none select-none`,i),onPointerDown:n=>{n.button===0&&(n.preventDefault(),n.stopPropagation(),n.currentTarget.setPointerCapture?.(n.pointerId),Jx.set({stroking:!0}),c.current=[u(n)],s({tool:e,ink:t,width:4,points:[c.current[0],c.current[0]]}))},onPointerMove:n=>{if(!c.current.length)return;n.stopPropagation();let r=u(n);e===`pen`?c.current.push(r):c.current=[c.current[0],r],s({tool:e,ink:t,width:4,points:e===`pen`?[...c.current]:c.current})},onPointerUp:e=>d(e,!0),onPointerCancel:e=>d(e,!1),onClick:e=>e.stopPropagation(),"data-sw-draw-input":e,children:[a,o?(0,Y.jsx)(sS,{shapes:[o],width:n,height:r}):null]})}function lS({frameKey:e,native:t,shown:n}){let r=Yx(t=>t?.key===e?t:null);return!r&&!n?.shapes.length?null:(0,Y.jsxs)(Y.Fragment,{children:[n?.shapes.length?(0,Y.jsx)(sS,{shapes:n.shapes,width:t.width,height:t.height,className:`z-[6]`,"data-sw-drawing":n.id}):null,r?(0,Y.jsx)(sS,{shapes:r.shapes,width:t.width,height:t.height,className:`z-[6]`,"data-sw-drawing":`draft`}):null,r?.tool?(0,Y.jsx)(cS,{tool:r.tool,ink:r.ink,width:t.width,height:t.height}):null]})}function uS(e){(0,J.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),Jx.set({tool:null}))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e])}function dS({touch:e,label:t,tooltip:n,narrow:r,className:i,...o}){return e?(0,Y.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":t,className:i,...o}):(0,Y.jsx)(B,{size:`icon-sm`,label:t,tooltip:n,className:O(r?`w-6`:`w-7`,i),...o})}var fS=({touch:e})=>(0,Y.jsx)(`span`,{className:O(`h-4 w-px shrink-0 bg-line`,e?`mx-1`:`mx-0.5`),"aria-hidden":`true`});function pS({owner:e,touch:t,onTool:n=null,leading:r=null,compact:i=!1,showCount:a=!0,bar:o=!1,className:s}){let c=Yx(t=>t?.owner===e?t:null);uS(!!c?.tool);let l=c?.shapes.length||0,u=!i||!!c?.tool||l>0;return(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-center`,t?`flex-wrap gap-y-0.5`:`flex-nowrap`,s),role:`group`,"aria-label":`Draw on the page`,"data-sw-draw-tools":e,children:[r?(0,Y.jsxs)(Y.Fragment,{children:[r,(0,Y.jsx)(fS,{touch:t})]}):null,i&&!u?(0,Y.jsx)(`span`,{className:`shrink-0 pr-1 pl-0.5 text-caption text-faint`,"aria-hidden":`true`,"data-sw-draw-label":`true`,children:`Draw`}):null,iS.map(e=>{let r=c?.tool===e.id;return(0,Y.jsx)(dS,{touch:t,variant:r?`soft`:`ghost`,"aria-pressed":r,className:O(r&&`ring-1 ring-accent/50`),label:r?`${e.label}: on. Draw on the page, Esc stops`:e.start,tooltip:o||r?e.label:e.start,onClick:()=>{Jx.set({tool:r?null:e.id}),r||n?.(e.id)},"data-sw-draw-tool":e.id,children:(0,Y.jsx)(e.icon,{size:15,"aria-hidden":`true`})},e.id)}),u?(0,Y.jsxs)(Y.Fragment,{children:[t?(0,Y.jsx)(`span`,{className:`h-0 basis-full`,"aria-hidden":`true`,"data-sw-draw-tools-break":`true`}):(0,Y.jsx)(fS,{touch:t}),Lx.map(e=>{let n=(c?.ink||Lx[0])===e;return(0,Y.jsx)(dS,{touch:t,narrow:!0,"aria-pressed":n,label:`${Ux[e]} ink`,tooltip:`${Ux[e]} ink`,onClick:()=>Jx.set({ink:e}),"data-sw-draw-ink":e,children:(0,Y.jsx)(`span`,{className:O(`block h-3.5 w-3.5 rounded-full`,aS[e],n?`ring-2 ring-fg ring-offset-1 ring-offset-surface`:``),"aria-hidden":`true`})},e)}),(0,Y.jsx)(fS,{touch:t}),(0,Y.jsx)(dS,{touch:t,label:`Undo the last shape`,tooltip:`Undo`,disabled:!l,onClick:()=>Jx.undo(),"data-sw-draw-undo":`true`,children:(0,Y.jsx)(iv,{size:15,"aria-hidden":`true`})}),(0,Y.jsx)(dS,{touch:t,label:`Clear the drawing`,tooltip:`Clear`,disabled:!l,onClick:()=>Jx.clear(),"data-sw-draw-clear":`true`,children:(0,Y.jsx)(ev,{size:15,"aria-hidden":`true`})})]}):null,a&&l?(0,Y.jsx)(mS,{count:l,className:`ml-auto pl-1`}):null]})}function mS({count:e,className:t}){return(0,Y.jsxs)(`span`,{className:O(`shrink-0 text-caption whitespace-nowrap text-faint tabular-nums`,t),"aria-live":`polite`,"data-sw-draw-count":e,children:[e,` `,e===1?`shape`:`shapes`]})}function hS({owner:e,title:t}){let n=e===`composer`?`your comment`:`your reply`,r=Yx(e=>!!e?.stroking);return(0,Y.jsxs)(`div`,{className:O(`pointer-events-none flex max-w-full items-center gap-2 rounded-xl border border-accent/50 bg-surface py-1 pr-1 pl-3 shadow-pop ring-2 ring-accent/15 transition-opacity duration-(--motion-fast) motion-reduce:transition-none`,r?`opacity-25 [&_button]:pointer-events-none`:`[&_button]:pointer-events-auto`),"data-sw-draw-bar-stroking":r?`true`:void 0,role:`toolbar`,"aria-label":t?`Drawing on ${t}`:`Drawing on the page`,"data-sw-draw-bar":e,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-xs font-semibold text-fg`,"data-sw-draw-bar-title":`true`,children:[(0,Y.jsx)(ch,{size:14,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t?`Drawing on ${t}`:`Drawing on the page`})]}),(0,Y.jsx)(`span`,{className:`h-5 w-px shrink-0 bg-line`,"aria-hidden":`true`}),(0,Y.jsx)(pS,{owner:e,touch:!1,bar:!0}),(0,Y.jsx)(_,{content:(0,Y.jsx)(vx,{label:`Back to ${n}`,keys:[`Esc`]}),side:`top`,children:(0,Y.jsx)(a,{size:`xs`,variant:`default`,className:`ml-1 shrink-0 px-3`,onClick:()=>Jx.set({tool:null}),"aria-label":`Done drawing: back to ${n}`,"data-sw-draw-bar-done":`true`,children:`Done`})})]})}function gS({open:e,onClose:t,owner:n,src:r,native:i,title:o}){let s=Yx(e=>e?.owner===n?e:null);if((0,J.useEffect)(()=>{e&&s&&!s.tool&&Jx.set({tool:`box`})},[e,!!s]),!i)return null;let c=()=>{Jx.set({tool:null}),t()};return(0,Y.jsxs)(N,{open:e,onClose:c,title:`Draw on the page`,description:o,size:`lg`,className:`max-h-[100dvh] rounded-none sm:rounded-xl`,footer:(0,Y.jsxs)(`div`,{className:`flex w-full items-center gap-3 sm:w-auto`,children:[s?.shapes.length?(0,Y.jsx)(mS,{count:s.shapes.length}):null,(0,Y.jsx)(a,{size:`touch`,className:`flex-1 sm:flex-none`,onClick:c,"data-sw-draw-done":`true`,children:`Done`})]}),children:[(0,Y.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-line bg-surface px-2 py-1`,children:(0,Y.jsx)(pS,{owner:n,touch:!0,showCount:!1})}),(0,Y.jsx)(`div`,{className:`p-3`,children:(0,Y.jsxs)(`div`,{className:`relative w-full overflow-hidden rounded-md border border-line bg-surface-2`,style:{aspectRatio:`${i.width} / ${i.height}`},"data-sw-draw-sheet":`true`,children:[r?(0,Y.jsx)(`img`,{src:r,alt:`The page this comment is on`,className:`block h-full w-full object-cover object-top select-none`,draggable:!1}):null,(0,Y.jsx)(sS,{shapes:s?.shapes,width:i.width,height:i.height}),s?.tool?(0,Y.jsx)(cS,{tool:s.tool,ink:s.ink,width:i.width,height:i.height}):null]})})]})}function _S({draft:e,touch:t,disabled:n}){let r=(0,J.useRef)(null),i=e.images.length>=4;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{size:t?`icon`:`icon-sm`,className:t?void 0:`w-7`,label:i?`Attach an image (4 is the most)`:`Attach an image`,tooltip:i?`4 images is the most`:`Attach an image (or paste one)`,disabled:n||i,onClick:()=>r.current?.click(),"data-sw-attach-image":`true`,children:(0,Y.jsx)(fg,{size:16,"aria-hidden":`true`})}),(0,Y.jsx)(`input`,{ref:r,type:`file`,accept:kx,multiple:!0,hidden:!0,tabIndex:-1,"aria-hidden":`true`,onChange:t=>{e.add(t.target.files),t.target.value=``},"data-sw-attach-input":`true`})]})}function vS(e,t){return t?{onPaste:t=>{let n=Ix(t.clipboardData);n.length&&(t.preventDefault(),e.add(n))},onDragOver:e=>{[...e.dataTransfer?.types||[]].includes(`Files`)&&e.preventDefault()},onDrop:t=>{let n=Ix(t.dataTransfer);n.length&&(t.preventDefault(),e.add(n))}}:{}}function yS({draft:e,touch:t,id:n}){return!e.images.length&&!e.error?null:(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[e.images.length?(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":`Images to attach`,"data-sw-composer-images":e.images.length,children:e.images.map(n=>(0,Y.jsxs)(`li`,{className:O(`relative overflow-hidden rounded-md border border-line bg-surface-2`,t?`h-16 w-16`:`h-14 w-14`),"data-sw-composer-image":n.state,children:[n.preview?(0,Y.jsx)(`img`,{src:n.preview,alt:n.name,className:`h-full w-full object-cover`,draggable:!1}):(0,Y.jsx)(`span`,{className:`flex h-full w-full items-center justify-center text-faint`,role:`status`,"aria-label":`Reading ${n.name}`,children:(0,Y.jsx)(Ag,{size:16,className:`animate-spin motion-reduce:animate-none`,"aria-hidden":`true`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.remove(n.id),className:O(`absolute top-0 right-0 flex items-center justify-center rounded-bl-md bg-black/60 text-white outline-none hover:bg-black/75 focus-visible:ring-2 focus-visible:ring-accent`,t?`h-7 w-7`:`h-5 w-5`),"aria-label":`Remove ${n.name}`,"data-sw-composer-image-remove":n.id,children:(0,Y.jsx)(se,{size:t?14:12,"aria-hidden":`true`})})]},n.id))}):null,e.error?(0,Y.jsx)(`p`,{id:n,className:`text-xs text-bad`,role:`alert`,"data-sw-image-error":`true`,children:e.error}):null]})}function bS({boardId:e,images:t,touch:n,label:r}){let[i,a]=(0,J.useState)(null);if((0,J.useEffect)(()=>{if(i===null)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),a(null))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[i]),!t?.length)return null;let o=i===null?null:t[i],s=e=>a(n=>(n+e+t.length)%t.length);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`ul`,{className:`mt-1.5 flex flex-wrap gap-1.5`,"aria-label":`${r}: images`,"data-sw-message-images":t.length,children:t.map((r,i)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(i),className:O(`block overflow-hidden rounded-md border border-line bg-surface-2 outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-accent`,n?`h-16 w-16`:`h-14 w-14`),"aria-label":`Open image ${i+1} of ${t.length}: ${r.name}`,"data-sw-message-image":r.file,children:(0,Y.jsx)(`img`,{src:ae(e,r.file),alt:``,className:`h-full w-full object-cover`,loading:`lazy`,draggable:!1})})},r.file))}),(0,Y.jsx)(N,{open:o!==null,onClose:()=>a(null),title:o?.name||`Image`,description:o?`Image ${i+1} of ${t.length}${o.width?`, ${o.width} by ${o.height} pixels`:``}`:``,size:`lg`,children:o?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-4`,onKeyDown:e=>{if(!(t.length<2)){if(e.key===`ArrowRight`)s(1);else if(e.key===`ArrowLeft`)s(-1);else return;e.preventDefault()}},"data-sw-lightbox":o.file,children:[(0,Y.jsx)(`img`,{src:ae(e,o.file),alt:o.name,className:`max-h-[70dvh] max-w-full rounded-md border border-line bg-surface-2 object-contain`,draggable:!1}),t.length>1?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(B,{size:n?`icon`:`icon-sm`,label:`Previous image`,onClick:()=>s(-1),"data-sw-lightbox-prev":`true`,children:(0,Y.jsx)(ut,{size:16,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`text-caption text-muted tabular-nums`,children:[i+1,` of `,t.length]}),(0,Y.jsx)(B,{size:n?`icon`:`icon-sm`,label:`Next image`,onClick:()=>s(1),"data-sw-lightbox-next":`true`,children:(0,Y.jsx)(nt,{size:16,"aria-hidden":`true`})})]}):null]}):null})]})}var xS=typeof window<`u`?Math.min(window.devicePixelRatio||1,2):1;function SS(e,t,n){return!t||!n?!1:e.w*t*xS>n.width*(n.thumbScale||.25)*1.05}function CS({src:e,viewport:t,native:n,frame:r,selecting:i,opaque:a,onReady:o,onLeave:s}){let c=r.w/n.width,l=(0,J.useRef)(null),[u,d]=(0,J.useState)(!1);return(0,J.useEffect)(()=>()=>o(null),[o]),(0,Y.jsx)(`iframe`,{ref:l,src:e,title:`Live ${t} page`,sandbox:a?``:`allow-same-origin`,referrerPolicy:`no-referrer`,tabIndex:i?0:-1,onLoad:()=>{if(a){d(!0),o(!0);return}let e=l.current?.contentDocument;if(!e)return;let t=e=>e.preventDefault();eb.addEventListener(e,`click`,t,!0),eb.addEventListener(e,`submit`,t,!0),eb.addEventListener(e,`auxclick`,t,!0),d(!0),o(e)},onMouseLeave:i?s:void 0,className:O(`absolute top-0 left-0 origin-top-left border-0 bg-white transition-opacity duration-(--motion-base)`,u?`opacity-100`:`opacity-0`,i?`nodrag nopan nowheel`:`pointer-events-none`),style:{width:n.width,height:n.height,transform:`scale(${c})`},"data-sw-live-frame":t})}function wS({targetId:e,frame:t,image:n,kind:r,version:i,emptyText:a,note:o}){let s=(0,J.useContext)(Jv),c=t.native||s.viewports[t.viewport],{viewport:l}=t,u=`${e}|${l}`,d=!!s.compare,{pins:f,openHere:p,selectedCommentId:m}=px(s,e,l),h=ux(e=>d||e.hoveredId===null?null:f.find(t=>t.id===e.hoveredId&&rS(t))||null),g=p&&rS(p)?p:h,_=(0,J.useMemo)(()=>{if(!g)return null;let t=String(e).startsWith(`variant:`)?null:Cv(s.manifest?.pages?.[e]?.[l],s.manifest);return{id:g.id,...nS(g,t)}},[g,e,l,s.manifest]),v=ux(t=>{let n=t.draftSpot;return n&&n.pageId===e&&n.viewport===l?n:null}),y=ux(e=>!!n?.live&&e.liveKeys.has(u)),{pinScale:b,compactPins:x}=mx(s,t,{active:f.length>0||!!v||s.commentMode&&y,drafting:!!v}),S=ux(e=>e.selectingKey===u)&&y&&!s.commentMode,C=ux(e=>e.readingKey===u)&&S,{onReading:w}=s;(0,J.useEffect)(()=>{if(S)return()=>w(null)},[S,w]),(0,J.useEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&w(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,w]);let T=ux(e=>e.focusedKey===u),E=n?.live&&n.elements||null,D=!!E||!s.domFallback,{map:k,state:A}=xb(y&&E?s.elementsUrl(r,E,i):null),[j,ee]=(0,J.useState)(!1),[M,N]=(0,J.useState)(null),[P,F]=(0,J.useState)(0),I=y&&(D?j&&A!==`loading`:!!M),L=y&&D?k:null,R=(0,J.useMemo)(()=>{if(!y||!(L||M))return null;let e=new Map;for(let t of f){if(!t.anchor)continue;let n=L?Jy(L,t.anchor,c):_b(M,t.anchor,c);e.set(t.id,n||{x:t.x,y:t.y,moved:!0})}return e},[y,L,M,f,c,P]),z=gx(f),te=hx({pins:f,positions:R,frame:t,compact:x,selectedCommentId:m});(0,J.useEffect)(()=>{let e=eb.defaultView(M);if(!e)return;let t=()=>F(e=>e+1);eb.addEventListener(e,`resize`,t);let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(eb.documentElement(M)),()=>{eb.removeEventListener(e,`resize`,t),n?.disconnect()}},[M]);let{setLiveReady:B}=s,V=(0,J.useCallback)(e=>{ee(!!e),N(e&&e!==!0?e:null)},[]);(0,J.useEffect)(()=>{B(u,I)},[u,I,B]),(0,J.useEffect)(()=>()=>B(u,!1),[u,B]);let ne=ux(e=>SS(t,e.settledZoom,c)),H=!n?.thumb||y||ne,U=n?s.imageUrl(r,H?n.file:n.thumb,i):null,re=ux(ES),ie=Yx(DS),ae=Yx(e=>!!e?.tool&&e.key===u),W=s.commentMode&&!re&&!ie,[G,oe]=(0,J.useState)(null),se=(0,J.useRef)(0),ce=W&&y&&!!(L||M)&&!s.touch;(0,J.useEffect)(()=>{ce||oe(null)},[ce]),(0,J.useEffect)(()=>()=>window.cancelAnimationFrame(se.current),[]);let le=e=>{if(!ce)return;let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*c.width,r=(e.clientY-t.top)/t.height*c.height;window.cancelAnimationFrame(se.current),se.current=window.requestAnimationFrame(()=>{if(L){let e=Fy(L,n,r);oe(e>=0?zy(L,e,c):null);return}let e=fb(M,n,r);oe(e?mb(M,e,c):null)})},ue=n=>{n.stopPropagation(),S?C||w(u):s.commentMode?de(n.currentTarget.getBoundingClientRect(),n.clientX,n.clientY):s.onFocusFrame(e,t.viewport)},de=(n,r,i,a=!0)=>{let o=(r-n.left)/n.width,l=(i-n.top)/n.height,u={pageId:e,viewport:t.viewport,x:Math.max(0,Math.min(100,o*100)),y:Math.max(0,Math.min(100,l*100))};if(a&&y&&(L||M)){let e=o*c.width,t=l*c.height,n=L?By(L,e,t,c):hb(M,e,t,c);n&&(u.anchor=n,u.target=Ry(L?L.elements[Fy(L,e,t)]?.t:fb(M,e,t)?.tagName.toLowerCase(),n.text))}oe(null),s.onPin(u)},fe=ux(e=>e.commentTargetKey===u)&&W,pe=e=>{if(e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),n=e.currentTarget.closest(`[data-sw-canvas]`)?.getBoundingClientRect()||t,r=Math.min(24,t.width*.04,t.height*.04),i=Math.min(t.right-r,Math.max(t.left,n.left)+r),a=Math.min(t.bottom-r,Math.max(t.top,n.top)+r);de(t,i,a,!1)};return(0,Y.jsxs)(Y.Fragment,{children:[t.y>12?(0,Y.jsxs)(TS,{frame:t,children:[t.viewport,y?(0,Y.jsx)(`span`,{className:`text-accent`,children:` · live`}):null]}):null,(0,Y.jsxs)(`div`,{className:O(`absolute rounded-sm border border-line bg-surface-2`,W&&`nodrag nopan cursor-crosshair`,S&&!C&&`cursor-text`,y&&`border-accent/60`,T&&!ae&&`outline-2 outline-offset-2 outline-accent`,fe&&`focus-visible:outline-4`,ae&&`outline-solid outline-accent`),style:{left:t.x,top:t.y,width:t.w,height:t.h,...ae?{outlineWidth:3*b,outlineOffset:2*b}:null},onClick:ue,tabIndex:fe?0:void 0,role:fe?`group`:void 0,"aria-label":fe?`The ${t.viewport} page: press Enter to comment at its top left, or click where the comment goes`:void 0,onKeyDown:fe?pe:void 0,"data-sw-comment-target":fe?`true`:void 0,onMouseMove:ce?le:void 0,onMouseLeave:ce?()=>oe(null):void 0,"data-sw-frame":`${e}:${t.viewport}`,"data-sw-image":U?H?`full`:`thumb`:`none`,"data-sw-live":y?I?`ready`:`loading`:`off`,"data-sw-live-anchors":y?D?L?`map`:`none`:`dom`:void 0,"data-sw-draw-surface":ae?`true`:void 0,"data-sw-select-text-state":S?C?`reading`:`armed`:void 0,children:[(0,Y.jsxs)(`div`,{className:`absolute inset-0 overflow-hidden rounded-sm`,"data-sw-frame-clip":`true`,children:[U?(0,Y.jsx)(`img`,{src:U,alt:`${t.viewport} screenshot`,loading:`lazy`,decoding:`async`,draggable:!1,onError:s.onImageError,className:`pointer-events-none block h-full w-full object-cover object-top select-none`}):(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center`,children:[(0,Y.jsx)(ug,{size:22,className:`text-faint`,"aria-hidden":`true`}),(0,Y.jsx)(`p`,{className:`text-[11px] leading-4 text-muted`,children:a})]}),y?(0,Y.jsx)(CS,{src:s.liveUrl(r,n.live,i),viewport:t.viewport,native:c,frame:t,selecting:C,opaque:D,onReady:V,onLeave:()=>w(null)},D?`opaque`:`dom`):null,o&&!y?(0,Y.jsxs)(`p`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-start gap-1 bg-surface/90 px-1.5 py-1 text-[9.5px] leading-[13px] text-muted`,"data-sw-page-note":`true`,children:[(0,Y.jsx)(gg,{size:10,className:`mt-px shrink-0`,"aria-hidden":`true`}),` `,o]}):null,G&&ce?(0,Y.jsx)(AS,{hover:G,native:c,scale:b}):null,v?.anchor&&!ie?(0,Y.jsx)(OS,{draft:v,scale:b}):null,p?.anchor?(0,Y.jsx)(kS,{comment:p,box:R?.get(p.id)?.box||null}):null,d?null:(0,Y.jsx)(lS,{frameKey:u,native:c,shown:_})]}),(0,Y.jsx)(_x,{targetId:e,viewport:l,clusters:te,scale:b,compact:x,selectedCommentId:m,landedId:z}),v?(0,Y.jsx)(rx,{draft:v,scale:b,name:s.me?.name,colorKey:s.me?.name}):null]})]})}function TS({frame:e,children:t}){return(0,Y.jsx)(`span`,{className:`pointer-events-none absolute z-10 flex origin-bottom-left items-center gap-1 truncate text-[10.5px] leading-4 font-semibold tracking-wide text-muted uppercase`,style:{left:e.x,top:e.y-19,width:`calc(${e.w}px / var(--sw-label-scale, 1))`,transform:`scale(var(--sw-label-scale, 1))`},"data-sw-frame-label":e.env?`${e.viewport}:${e.env}`:e.viewport,children:t})}var ES=e=>!!e.draftSpot,DS=e=>!!e?.tool;function OS({draft:e,scale:t}){let{anchor:n}=e;return!n.w||!n.h?null:(0,Y.jsx)(`div`,{className:`pointer-events-none absolute z-[5] rounded-[2px] border-solid border-accent`,style:{left:`${e.x-n.dx*n.w*100}%`,top:`${e.y-n.dy*n.h*100}%`,width:`${n.w*100}%`,height:`${n.h*100}%`,borderWidth:2*t},"data-sw-picked-outline":`true`})}function kS({comment:e,box:t}){let{anchor:n}=e;if(!t&&(!n.w||!n.h))return null;let r=t?{left:`${t.left}%`,top:`${t.top}%`,width:`${t.right-t.left}%`,height:`${t.bottom-t.top}%`}:{left:`${e.x-n.dx*n.w*100}%`,top:`${e.y-n.dy*n.h*100}%`,width:`${n.w*100}%`,height:`${n.h*100}%`};return(0,Y.jsx)(`div`,{className:`pointer-events-none absolute`,style:r,"aria-hidden":`true`,"data-sw-thread-target":e.id})}function AS({hover:e,native:t,scale:n}){let{rect:r}=e,i=(e,t)=>`${e/t*100}%`,a=r.top/t.height<.04;return(0,Y.jsx)(`div`,{className:O(`pointer-events-none absolute z-[5] rounded-[2px] border-accent bg-accent/5`,e.large?`border-dashed`:`border-solid`),style:{left:i(r.left,t.width),top:i(r.top,t.height),width:i(r.width,t.width),height:i(r.height,t.height),borderWidth:2*n},"data-sw-hover-outline":e.large?`large`:`element`,children:(0,Y.jsx)(`span`,{className:`absolute left-0 max-w-[320px] truncate rounded-sm bg-accent px-1.5 text-[11px] leading-[18px] font-medium whitespace-nowrap text-accent-fg`,style:{[a?`top`:`bottom`]:`100%`,transform:`scale(${n})`,transformOrigin:a?`top left`:`bottom left`,marginTop:a?2*n:0,marginBottom:a?0:2*n},"data-sw-hover-label":`true`,"data-sw-hover-selector":e.label,children:e.name})})}function jS({pageId:e,frame:t}){let n=(0,J.useContext)(Jv),{compare:r}=n,{viewport:i}=t,a=t.native||n.viewports[i],{pins:o,openHere:s,selectedCommentId:c}=px(n,e,i,gy(t,r)),{pinScale:l,compactPins:u}=mx(n,t,{active:o.length>0}),d=gx(o),f=hx({pins:o,frame:t,compact:u,selectedCommentId:c}),p=r.files?.[t.env]?.[e]?.[t.viewport],m=ux(e=>SS(t,e.settledZoom,a)),h=p&&(!p.thumb||m),g=p?n.imageUrl(r.kindOf(t.env),h?p.file:p.thumb,r.versionOf(t.env)):null,_=r.pages?.[e]?.[t.viewport],v=p?null:r.failures?.[t.env]?.[e]?.[t.viewport]||null,y=t.env===r.b,b=y&&r.showDiff&&_?.status===`ok`&&_.percent>0?_.diff:null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(TS,{frame:t,children:[t.viewport,` · `,r.titleOf(t.env),y&&_?.status===`ok`?(0,Y.jsxs)(`span`,{className:`text-accent`,children:[` · `,_.percent,`% changed`]}):null]}),(0,Y.jsxs)(`div`,{className:`absolute rounded-sm border border-line bg-surface-2`,style:{left:t.x,top:t.y,width:t.w,height:t.h},"data-sw-frame":`${e}:${t.viewport}:${t.env}`,"data-sw-image":g?h?`full`:`thumb`:`none`,children:[(0,Y.jsxs)(`div`,{className:`absolute inset-0 overflow-hidden rounded-sm`,"data-sw-frame-clip":`true`,children:[g?(0,Y.jsx)(`img`,{src:g,alt:`${t.viewport} screenshot, ${r.titleOf(t.env)}`,loading:`lazy`,decoding:`async`,draggable:!1,onError:n.onImageError,className:`pointer-events-none block h-full w-full object-cover object-top select-none`}):(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center`,children:[(0,Y.jsx)(ug,{size:22,className:`text-faint`,"aria-hidden":`true`}),(0,Y.jsx)(`p`,{className:`text-[11px] leading-4 text-muted`,"data-sw-compare-failed":v?`true`:void 0,children:v?`Capture failed: ${v}`:`Not captured in ${r.titleOf(t.env)} yet.`})]}),b?(0,Y.jsx)(`img`,{src:n.imageUrl(r.diffKind,b,r.diffVersion),alt:``,draggable:!1,className:`pointer-events-none absolute inset-0 block h-full w-full object-cover object-top opacity-80 select-none`,"data-sw-diff-overlay":`true`}):null,s?.anchor?(0,Y.jsx)(kS,{comment:s,box:null}):null]}),(0,Y.jsx)(_x,{targetId:e,viewport:i,clusters:f,scale:l,compact:u,selectedCommentId:c,landedId:d})]})]})}var MS=`[@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:-inset-3 [@media(pointer:coarse)]:before:content-['']`;function NS(){return(0,Y.jsxs)(`span`,{className:`inline-flex h-4 shrink-0 items-center gap-1 rounded-full bg-accent/10 px-1.5 text-[10px] leading-4 font-semibold text-accent`,"data-sw-live-chip":`true`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only @min-[260px]:not-sr-only`,children:`Live`})]})}function PS(e,t,n){let r=t.length===1&&!t[0].env&&!(t[0].y>12)&&n?.[t[0].viewport]?.live?`${e}|${t[0].viewport}`:null;return ux(e=>r!==null&&e.liveKeys.has(r))}function FS({change:e,named:t}){if(!e)return null;let{percent:n,viewport:r}=e,i=n>0?`${n}%${t?` ${r}`:``}`:`Same`;return(0,Y.jsx)(Wv,{content:n>0?`Most changed: the ${r} capture, ${n}% of its pixels`:`No visual change`,children:(0,Y.jsxs)(`span`,{tabIndex:-1,className:O(Ke({shape:`count`}),`tabular pointer-events-auto absolute -top-2.5 -right-2.5 z-20 origin-top-right shadow-pop`,n>0?`bg-accent text-accent-fg`:`bg-surface-2 text-muted`),style:{transform:`scale(min(var(--sw-inv, 1), 14))`},"data-sw-change":n,"data-sw-change-viewport":r,children:[(0,Y.jsx)(Ph,{size:10,"aria-hidden":`true`}),` `,i]})})}function IS({steps:e,current:t}){return e?.length?(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center gap-0.5`,"data-sw-steps":e.join(`,`),children:e.map(e=>(0,Y.jsx)(`span`,{className:O(`tabular inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-1 text-[10.5px] leading-none font-bold`,e===t?`bg-accent text-accent-fg ring-2 ring-accent/30`:`bg-fg text-surface`),children:e},e))}):null}function LS(){return(0,Y.jsx)(Wv,{content:`An agent is working on a comment here`,children:(0,Y.jsxs)(`span`,{tabIndex:-1,className:`pointer-events-auto inline-flex h-5 items-center gap-1 rounded-full bg-accent/10 px-1.5 text-[11px] font-semibold text-accent`,"data-sw-card-agent-working":`true`,children:[(0,Y.jsxs)(`span`,{className:`relative flex h-2 w-2`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 motion-safe:animate-ping`}),(0,Y.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full bg-accent`})]}),(0,Y.jsx)(I,{size:12,"aria-label":`Agent working`})]})})}function RS({count:e}){if(!e?.open)return null;let t=`${e.open} open comment${e.open===1?``:`s`}`;return(0,Y.jsx)(Wv,{content:t,children:(0,Y.jsxs)(`span`,{tabIndex:-1,className:`tabular pointer-events-auto inline-flex h-5 items-center gap-1 rounded-full px-1 text-[11px] font-semibold text-fg`,children:[(0,Y.jsx)(Kg,{size:12,className:`text-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{"aria-label":t,children:e.open})]})})}function zS({pageId:e,title:t}){let n=(0,J.useContext)(Jv),r=n.onChecks?n.checksCount(e):0;if(!r)return null;let i=`${r} check${r===1?``:`s`} need attention`;return(0,Y.jsx)(Wv,{content:i,children:(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`tabular nodrag nopan pointer-events-auto relative inline-flex h-5 items-center gap-1 rounded-full px-1 text-[11px] font-semibold text-fg hover:bg-surface-2`,MS),"aria-label":`${r} checks need attention across captured screen sizes for ${t}`,onClick:t=>{t.stopPropagation(),n.onChecks(e)},"data-sw-checks-badge":e,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-warn`,"aria-hidden":`true`}),` `,r]})})}function BS({pageId:e}){let t=(0,J.useContext)(Jv),n=t.historyCount(e);return!n||t.compare?null:(0,Y.jsx)(Wv,{content:`${n+1} captures: open the page history`,children:(0,Y.jsxs)(`button`,{type:`button`,className:O(`tabular nodrag nopan pointer-events-auto relative inline-flex h-5 items-center gap-1 rounded-full px-1 text-[11px] font-semibold text-muted hover:bg-surface-2 hover:text-fg`,MS),tabIndex:-1,onClick:n=>{n.stopPropagation(),t.onHistory(e)},"aria-label":`Page history, ${n} earlier capture${n===1?``:`s`}`,"data-sw-history-badge":e,children:[(0,Y.jsx)(g_,{size:12,"aria-hidden":`true`}),` `,n+1]})})}var VS=`var(--sw-title-scale, 1)`;function HS({title:e,path:t,note:n}){return(0,Y.jsxs)(`span`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`block font-semibold`,children:e}),t?(0,Y.jsx)(`span`,{className:`block font-mono text-[11px] opacity-80`,children:t}):null,n?(0,Y.jsx)(`span`,{className:`mt-0.5 block font-normal opacity-80`,children:n}):null]})}function US({width:e,title:t,tip:n,path:r,steps:i,current:a,only:o,tag:s,badges:c,onTitle:l,accent:u=!1}){return(0,Y.jsx)(`div`,{className:`@container pointer-events-none absolute bottom-full left-0 z-10 origin-bottom-left pb-1`,style:{width:`calc(${e}px / ${VS})`,transform:`scale(${VS})`,opacity:`var(--sw-title-fade, 1)`},"data-sw-card-header":`true`,children:(0,Y.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(IS,{steps:i,current:a}),(0,Y.jsx)(Wv,{content:n,side:`top`,align:`start`,children:(0,Y.jsxs)(`p`,{className:O(`nodrag nopan pointer-events-auto min-w-0 shrink cursor-default truncate text-[12.5px] leading-6 font-semibold`,u?`text-accent`:`text-fg`),onClick:l,"data-sw-card-title":`true`,children:[t,r?(0,Y.jsx)(`span`,{className:`ml-1.5 hidden font-mono text-[11px] font-normal text-faint group-hover/card:@min-[200px]:inline`,children:r}):null]})}),o?(0,Y.jsx)(`span`,{className:`hidden shrink-0 rounded bg-surface-2 px-1 text-[10px] leading-4 font-medium text-muted @min-[150px]:block`,"data-sw-only":!0,children:o}):null,s?(0,Y.jsx)(`span`,{className:`hidden shrink-0 rounded bg-surface-2 px-1 text-[10px] leading-4 font-medium text-muted @min-[200px]:block`,children:s}):null,(0,Y.jsx)(`span`,{className:`ml-auto hidden shrink-0 items-center gap-0.5 @min-[130px]:flex`,"data-sw-card-badges":`true`,children:c})]})})}var WS=`!h-1 !w-1 !min-w-0 !border-0 !bg-transparent`;function GS(e,t,n){return t?.[n]?.status===`failed`?`Capture failed: ${t[n].error}`:e.manifest?`No capture for this screen size.`:e.domFallback?`Not captured yet. Run "shapewall capture".`:`Not captured yet.`}function KS(e,t){let n=Object.keys(t||{});if(!Array.isArray(e)||!e.length||n.every(t=>e.includes(t)))return null;let r=n.filter(t=>e.includes(t)).map(e=>e.replace(/-/g,` `)).join(` and `);return`${r.charAt(0).toUpperCase()}${r.slice(1)} only`}var qS={page:(0,J.memo)(function({data:e,width:t}){let n=(0,J.useContext)(Jv),{page:r,frames:i}=e,a=n.captures[r.id]||{},o=n.manifest?.pages?.[r.id],s=n.journey?.steps.get(r.id)||null,c=!s&&!!n.journey?.offPath?.has(r.id),l=!!n.journey&&!s&&!c,u=n.journey?.currentPage===r.id,d=KS(r.viewports,n.viewports),f=n.compare?kv(n.compare,r.id):null,p=f?.percent>0,m=!!n.compare&&f&&!p,h=n.agentWorkingPages?.has(r.id),g=PS(r.id,i,a),_=e=>{e.stopPropagation(),i[0]&&!i[0].env&&n.onFocusFrame(r.id,i[0].viewport)};return(0,Y.jsxs)(`div`,{className:O(`group/card relative h-full w-full rounded-lg border border-line bg-surface shadow-card transition-[opacity,outline-color] duration-(--motion-base)`,l&&`opacity-25`,c&&`opacity-60 outline-2 outline-offset-4 outline-faint/60 outline-dashed`,s&&`outline-offset-4 outline-accent/40`,u&&`outline-accent`,p&&`outline-offset-2 outline-accent`,m&&`opacity-50`),style:{...s||p?{outlineWidth:`calc(${u?3:2}px * min(var(--sw-inv, 1), 12))`,outlineStyle:`solid`}:null,...h?{boxShadow:`0 0 0 calc(4px * min(var(--sw-inv, 1), 12)) color-mix(in srgb, var(--accent) 35%, transparent)`}:null},"data-sw-node":r.id,"data-sw-faded":l?`true`:void 0,"data-sw-off-path":c?`true`:void 0,"data-sw-current-step":u?`true`:void 0,"data-sw-changed":n.compare?p?`true`:`false`:void 0,"data-sw-agent-working":h?`true`:void 0,children:[(0,Y.jsx)(kf,{type:`source`,position:Q.Right,id:`right`,className:WS,isConnectable:!1}),(0,Y.jsx)(kf,{type:`target`,position:Q.Left,id:`left`,className:WS,isConnectable:!1}),n.compare?(0,Y.jsx)(FS,{change:f,named:Object.keys(n.viewports||{}).length>1}):null,(0,Y.jsx)(US,{width:t||i.reduce((e,t)=>Math.max(e,t.x+t.w),0)+8,title:r.title,tip:(0,Y.jsx)(HS,{title:r.title,path:r.path,note:r.note}),path:r.path,steps:s,current:n.journey?.currentStep,only:d,accent:u,onTitle:_,badges:(0,Y.jsxs)(Y.Fragment,{children:[g?(0,Y.jsx)(NS,{}):null,h?(0,Y.jsx)(LS,{}):null,(0,Y.jsx)(RS,{count:n.counts[r.id]}),(0,Y.jsx)(zS,{pageId:r.id,title:r.title}),(0,Y.jsx)(`span`,{className:`pointer-events-auto inline-flex`,children:(0,Y.jsx)(Gv,{pageId:r.id,title:r.title,entries:o,viewports:Object.keys(n.viewports)})}),(0,Y.jsx)(qv,{pageId:r.id,title:r.title,entries:o,viewports:Object.keys(n.viewports)}),(0,Y.jsx)(BS,{pageId:r.id}),r.url?(0,Y.jsx)(Wv,{content:`Open the page in a new tab`,children:(0,Y.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,tabIndex:-1,className:O(`nodrag nopan pointer-events-auto relative hidden h-5 w-5 items-center justify-center rounded-full text-muted hover:bg-surface-2 hover:text-fg @min-[200px]:inline-flex`,MS),"aria-label":`Open ${r.title} in a new tab`,children:(0,Y.jsx)(Rh,{size:12})})}):null]})}),i.map(e=>e.env?n.compare?(0,Y.jsx)(jS,{pageId:r.id,frame:e},`${e.viewport}:${e.env}`):null:(0,Y.jsx)(wS,{targetId:r.id,frame:e,kind:`captures`,image:a[e.viewport],note:r.note,emptyText:GS(n,o,e.viewport)},e.viewport))]})}),variant:(0,J.memo)(function({data:e,width:t}){let n=(0,J.useContext)(Jv),{variant:r,frames:i,only:a}=e,o=`variant:${r.id}`,s=PS(o,i,r.files);return(0,Y.jsxs)(`div`,{className:O(`group/card relative h-full w-full rounded-lg border border-dashed border-faint/60 bg-surface shadow-card transition-opacity duration-(--motion-base)`,n.journey&&`opacity-25`),"data-sw-node":o,children:[(0,Y.jsx)(kf,{type:`target`,position:Q.Left,id:`left`,className:WS,isConnectable:!1}),(0,Y.jsx)(kf,{type:`source`,position:Q.Right,id:`right`,className:WS,isConnectable:!1}),(0,Y.jsx)(US,{width:t||200,title:(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(Sg,{size:12,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r.title})]}),tip:(0,Y.jsx)(HS,{title:`Variant: ${r.title}`,path:r.source,note:r.note}),tag:`Variant`,badges:(0,Y.jsxs)(Y.Fragment,{children:[s?(0,Y.jsx)(NS,{}):null,(0,Y.jsx)(RS,{count:n.counts[o]})]}),onTitle:e=>{e.stopPropagation(),i[0]&&n.onFocusFrame(o,i[0].viewport)}}),a?(0,Y.jsxs)(`div`,{className:`flex h-11 items-center gap-2 px-2.5 text-[11px] text-muted`,"data-sw-variant-collapsed":a.join(`,`),children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[a.map(e=>e[0].toUpperCase()+e.slice(1)).join(` and `),` only`]}),n.onShowViewport?(0,Y.jsxs)(`button`,{type:`button`,tabIndex:-1,className:O(`nodrag nopan relative rounded px-1.5 py-0.5 font-semibold text-accent hover:bg-surface-2`,MS),onClick:e=>{e.stopPropagation(),n.onShowViewport(a[0])},"data-sw-variant-show":a[0],children:[`Show `,a[0]]}):null]}):null,i.map(e=>(0,Y.jsx)(wS,{targetId:o,frame:e,kind:`variants`,version:r.createdAt,image:r.files?.[e.viewport],emptyText:`No ${e.viewport} version of this variant.`},e.viewport))]})}),groupFrame:(0,J.memo)(function({data:e,width:t}){let n=`var(--sw-group-scale, 1)`;return(0,Y.jsx)(`div`,{className:`pointer-events-none relative h-full w-full rounded-2xl border border-fg/10 bg-fg/[0.025]`,"data-sw-group":e.group,children:(0,Y.jsxs)(`p`,{className:`@container absolute bottom-full left-0 flex origin-bottom-left items-baseline gap-1.5 pb-1.5 pl-1 text-ui font-semibold whitespace-nowrap text-fg`,style:{width:`calc(${t||600}px / ${n})`,transform:`scale(${n})`},"data-sw-group-label":`true`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.group}),(0,Y.jsxs)(`span`,{className:`tabular hidden shrink-0 text-xs font-medium text-faint @min-[120px]:inline`,children:[e.count,` page`,e.count===1?``:`s`]})]})})})},JS=(e,t,n,r)=>({x:(1-r)*(1-r)*e.x+2*(1-r)*r*t.x+r*r*n.x,y:(1-r)*(1-r)*e.y+2*(1-r)*r*t.y+r*r*n.y});function YS(e,t,n,{inset:r=30,fade:i=110,steps:a=48}={}){let[o,s,c]=t;if(!n?.width||!n?.height||!c)return null;let l=(e,t)=>{let r=e.x*c+o,i=e.y*c+s;return r>=t&&r<=n.width-t&&i>=t&&i<=n.height-t};if(l(e.end,0))return null;for(let t=a-1;t>=1;--t){let n=t/a,o=JS(e.start,e.control,e.end,n);if(!l(o,r))continue;let s=t;for(;s>0;){let t=JS(e.start,e.control,e.end,(s-1)/a);if(Math.hypot((t.x-o.x)*c,(t.y-o.y)*c)>i)break;--s}return{t:n,point:o,from:JS(e.start,e.control,e.end,s/a)}}return null}function XS(e,t){let{start:n,control:r}=e,i={x:n.x+(r.x-n.x)*t,y:n.y+(r.y-n.y)*t},a=JS(n,r,e.end,t);return`M ${n.x} ${n.y} Q ${i.x} ${i.y} ${a.x} ${a.y}`}function ZS(e,t,n){let r=e.x+e.w/2,i=e.y+e.h/2,a=t-r,o=n-i;if(!a&&!o)return{x:r,y:i};let s=Math.min(a?e.w/2/Math.abs(a):1/0,o?e.h/2/Math.abs(o):1/0);return{x:r+a*s,y:i+o*s}}function QS(e){if(!e)return null;let{x:t,y:n}=e.internals.positionAbsolute,r=e.measured?.width??e.width??0,i=e.measured?.height??e.height??0;return r&&i?{x:t,y:n,w:r,h:i}:null}function $S(e,t,{bend:n=.12,gap:r=6}={}){let i={x:e.x+e.w/2,y:e.y+e.h/2},a={x:t.x+t.w/2,y:t.y+t.h/2},o=ZS(e,a.x,a.y),s=ZS(t,i.x,i.y),c=s.x-o.x,l=s.y-o.y,u=Math.hypot(c,l)||1,d=c/u,f=l/u,p={x:s.x-d*r,y:s.y-f*r},m={x:(o.x+p.x)/2+f*u*n,y:(o.y+p.y)/2-d*u*n},h={x:(o.x+2*m.x+p.x)/4,y:(o.y+2*m.y+p.y)/4},g=p.x-m.x,_=p.y-m.y,v=Math.hypot(g,_)||1;return{path:`M ${o.x} ${o.y} Q ${m.x} ${m.y} ${p.x} ${p.y}`,end:p,dir:{x:g/v,y:_/v},mid:h,curve:{start:o,control:m,end:p}}}var eC={idle:{stroke:`var(--faint)`,width:1.25,opacity:.35},out:{stroke:`var(--accent)`,width:2,opacity:.95},in:{stroke:`var(--muted)`,width:1.5,opacity:.7},journey:{stroke:`var(--accent)`,width:3,opacity:.95},done:{stroke:`var(--accent)`,width:2.5,opacity:.45},alt:{stroke:`var(--faint)`,width:2,opacity:.6,dash:3}},tC={flow:(0,J.memo)(function({id:e,source:t,target:n,data:r}){let i=_m(t),a=_m(n),o=$(e=>Math.min(40,Math.max(.25,Math.round(1/e.transform[2]*8)/8))),s=(0,J.useContext)(Jv),c=QS(i),l=QS(a),u=eC[r?.tone]||eC.idle,d=c&&l?$S(c,l,{bend:r?.bend??.12,gap:4*o}):null,f=r?.tone===`journey`||r?.tone===`done`,p=$(e=>{if(!f||!d)return``;let t=YS(d.curve,e.transform,{width:e.width,height:e.height}),n=e=>Math.round(e*10)/10;return t?[t.t,n(t.point.x),n(t.point.y),n(t.from.x),n(t.from.y)].join(`,`):``});if(!d)return null;let{path:m,end:h,dir:g,mid:_,curve:v}=d;if(p){let[t,n,i,a,c]=p.split(`,`).map(Number),l=`sw-edge-fade-${String(e).replace(/[^a-zA-Z0-9_-]/g,`-`)}`,d=`Continues to step ${r.label}${r.toTitle?`: ${r.toTitle}`:``}`;return(0,Y.jsxs)(`g`,{className:`sw-flow-edge`,"data-sw-edge":e,"data-sw-edge-tone":r.tone,"data-sw-edge-leaves":`true`,style:{opacity:u.opacity},children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsxs)(`linearGradient`,{id:l,gradientUnits:`userSpaceOnUse`,x1:a,y1:c,x2:n,y2:i,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:u.stroke,stopOpacity:`1`}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:u.stroke,stopOpacity:`0`})]})}),(0,Y.jsx)(`path`,{d:XS(v,t),fill:`none`,stroke:`url(#${l})`,strokeWidth:u.width*o,strokeLinecap:`round`}),(0,Y.jsx)(um,{children:(0,Y.jsxs)(`button`,{type:`button`,className:`nodrag nopan pointer-events-auto absolute flex h-6 items-center gap-0.5 rounded-full border-2 border-surface bg-accent pr-1.5 pl-1 text-[11px] font-bold text-accent-fg shadow-pop outline-none hover:bg-accent/90 focus-visible:ring-2 focus-visible:ring-accent/50 [@media(pointer:coarse)]:after:absolute [@media(pointer:coarse)]:after:-inset-2.5 [@media(pointer:coarse)]:after:content-['']`,style:{transform:`translate(-50%, -50%) translate(${n}px, ${i}px) scale(${Math.min(o,2)})`},title:d,"aria-label":d,tabIndex:-1,onClick:e=>{e.stopPropagation(),s?.onJourneyStep?.(Number(r.label))},"data-sw-edge-continues":r.label,children:[(0,Y.jsx)(nh,{size:12,"aria-hidden":`true`}),r.label]})})]})}let y=(u.width*2.5+5)*o,b=-g.y,x=g.x,S=[`${h.x},${h.y}`,`${h.x-g.x*y+b*y*.55},${h.y-g.y*y+x*y*.55}`,`${h.x-g.x*y-b*y*.55},${h.y-g.y*y-x*y*.55}`].join(` `);return(0,Y.jsxs)(`g`,{className:`sw-flow-edge`,"data-sw-edge":e,"data-sw-edge-tone":r?.tone||`idle`,style:{opacity:u.opacity},children:[(0,Y.jsx)(`path`,{d:m,fill:`none`,stroke:u.stroke,strokeWidth:u.width*o,strokeLinecap:`round`,strokeDasharray:u.dash?`${u.dash*u.width*o} ${u.dash*u.width*o}`:void 0}),(0,Y.jsx)(`polygon`,{points:S,fill:u.stroke}),r?.label||r?.branch?(0,Y.jsx)(um,{children:(0,Y.jsxs)(`span`,{className:`nodrag nopan pointer-events-none absolute flex items-center gap-1`,style:{transform:`translate(-50%, -50%) translate(${_.x}px, ${_.y}px) scale(${Math.min(o,2)})`},children:[r.label?(0,Y.jsx)(`span`,{className:`flex h-6 min-w-6 items-center justify-center rounded-full border-2 border-surface bg-accent px-1 text-[11px] font-bold text-accent-fg shadow-pop`,"data-sw-edge-label":r.label,children:r.label}):null,r.branch?(0,Y.jsx)(`span`,{className:O(`flex h-6 max-w-48 items-center truncate rounded-full border-2 px-2 text-[11px] font-semibold whitespace-nowrap shadow-pop`,r.tone===`alt`?`border-line bg-surface text-muted`:`border-surface bg-accent text-accent-fg`),"data-sw-edge-branch":r.branch,children:r.branch}):null]})}):null]})})};function nC({hasTarget:e,known:t,changedOnly:n,pageChanged:r}){if(e)return null;if(!t)return{gone:!0};let i=!(!n||r);return i?{showAllPages:i}:{gone:!0}}function rC(e){return e.length<2?e[0]||``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}var iC=e=>e.charAt(0).toLowerCase()+e.slice(1);function aC(e,t=e=>e,{compact:n=!1}={}){if(!e?.changes?.length)return null;let r=[],i=[],a=[];for(let n of e.changes)n===`viewport`&&(r.push(`Showing ${t(e.to)}`),i.push(`the ${e.to} capture`),a.push(t(e.from))),n===`changed`&&(r.push(`Showing all pages`),i.push(`a page "Changed pages only" leaves out`),a.push(`changed pages only`));let o=r.map((e,t)=>t===0?e:iC(e)).join(`, `);return n?{text:`${o} for comment #${e.id}.`,back:`Back`}:{text:`${o}: comment #${e.id} is on ${i.join(`, and on `)}.`,back:`Back to ${rC(a)}`}}var oC={top:76,bottom:108,left:24,right:24},sC=1.2,cC=.28,lC=.45;function uC(e){return Math.min(2,Math.max(sC,Number.isFinite(e)&&e>0?e:sC))}function dC(e,t=null){return Number.isFinite(t)?Math.max(56,Math.min(t,e.height)-64):e.height*lC}function fC(e,t,n=null){if(!e?.width||!e?.height)return null;if(!t)return{x:e.width/2,y:Math.min(e.height*cC,dC(e,n))};let r=oC.left,i=Math.max(r+1,e.width-oC.right),a=oC.top,o=Math.max(a+1,e.height-oC.bottom),s=i-r;return{x:s>608?r+(s-380)/2:r+s/2,y:a+(o-a)/2}}function pC({point:e,box:t,wide:n,zoom:r,cardTop:i=null,sheetTop:a=null}){let o=uC(r),s=fC(t,n,a);if(!s)return null;let c=s.x-e.x*o,l=s.y-e.y*o;return!n&&Number.isFinite(i)&&i*o+l<40&&(l=Math.min(40-i*o,dC(t,a)-e.y*o)),n||(l=Math.max(l,56-e.y*o)),{x:c,y:l,zoom:o}}function mC(e,t){return!e||!t?!1:Math.abs(e.x-t.x)<1.5&&Math.abs(e.y-t.y)<1.5&&Math.abs(e.zoom-t.zoom)<.005}var hC=120,gC=.62;function _C({windowHeight:e,canvasTop:t=null}){if(!(e>0))return null;let n=Math.round(e*gC);if(!Number.isFinite(t))return n;let r=Math.round(e-Math.max(0,t)-hC-80);return Math.max(200,Math.min(n,r))}function vC({windowHeight:e,canvasTop:t=null}){let n=_C({windowHeight:e,canvasTop:t});return n===null?null:n+80}var yC=.02,bC=16,xC=(e,t,n)=>Math.min(n,Math.max(t,e));function SC({deltaX:e=0,deltaY:t=0,deltaMode:n=0},r=800){let i=n===1?bC:n===2?r:1;return{dx:e*i,dy:t*i}}function CC(e,t,n,{minZoom:r,maxZoom:i}){let a=xC(e.zoom*n,r,i),o=a/e.zoom;return{x:t.x-(t.x-e.x)*o,y:t.y-(t.y-e.y)*o,zoom:a}}function wC(e,t,n,{minZoom:r,maxZoom:i,pageHeight:a}={}){let{dx:o,dy:s}=SC(t,a);if(t.ctrlKey||t.metaKey){if(!s)return null;let t=CC(e,n,2**(-xC(s,-20,20)*yC),{minZoom:r,maxZoom:i});return t.zoom===e.zoom?null:t}return t.shiftKey&&Math.abs(s)>Math.abs(o)&&(o=s,s=0),!o&&!s?null:{x:e.x-o,y:e.y-s,zoom:e.zoom}}function TC(e,t,n){return{x:e.x+t,y:e.y+n,zoom:e.zoom}}var EC=new Set([``,`text`,`search`,`email`,`url`,`tel`,`password`,`number`,`date`,`time`,`datetime-local`,`month`,`week`]),DC=`button, a[href], select, summary, [role="button"], [role="link"], [role="menuitem"], [role="menuitemradio"], [role="option"], [role="tab"], [role="checkbox"], [role="radio"], [role="switch"], [role="slider"]`;function OC(e){if(!e||e.nodeType!==1)return!1;if(e.isContentEditable)return!0;let t=e.tagName;return t===`TEXTAREA`||t===`SELECT`||t===`INPUT`&&EC.has((e.getAttribute(`type`)||``).toLowerCase())}function kC(e,{clicked:t=null}={}){return!e||e.nodeType!==1?!0:OC(e)||e.closest?.(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`)?!1:!e.matches?.(DC)||e===t}function AC({canvasRef:e,flow:t,minZoom:n,maxZoom:r,onRest:i,enabled:a=!0,handRef:o=null}){let s=(0,J.useRef)({moving:!1}),c=(0,J.useRef)(i);return(0,J.useEffect)(()=>{c.current=i},[i]),(0,J.useEffect)(()=>{let i=e.current;if(!a||!i||!t)return;let l=s.current,u=0,d=!1,f=!1,p=null,m=!1,h=0,g=1,_=null,v=0,y=e=>!!e?.closest?.(`.react-flow__renderer`),b=e=>{let t=i.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},x=()=>{window.clearTimeout(u),l.moving=!1,c.current?.(t.getViewport())},S=()=>{window.clearTimeout(u),u=window.setTimeout(x,150)},C=e=>{l.moving=!0,t.setViewport(e)},w=e=>{d=e,i.classList.toggle(`sw-space-pan`,e)},T=e=>{if(e.target?.closest?.(`.nowheel`)){(e.ctrlKey||e.metaKey)&&e.preventDefault();return}if(!y(e.target)&&!(e.ctrlKey||e.metaKey))return;e.preventDefault(),e.stopPropagation();let a=wC(t.getViewport(),e,b(e),{minZoom:n,maxZoom:r,pageHeight:i.clientHeight});a&&(C(a),S())},E=e=>{h||(e.preventDefault(),g=1)},D=e=>{if(h||!y(e.target))return;e.preventDefault();let i=e.scale/g;g=e.scale,!Number.isFinite(i)||i<=0||(C(CC(t.getViewport(),b(e),i,{minZoom:n,maxZoom:r})),S())},O=e=>{h=e.touches.length},k=e=>{e.code!==`Space`&&e.key!==` `||e.altKey||e.ctrlKey||e.metaKey||(d?e.preventDefault():!e.repeat&&f&&kC(e.target,{clicked:_})&&(e.preventDefault(),w(!0)))},A=e=>{(e.code===`Space`||e.key===` `)&&d&&(e.preventDefault(),w(!1))},j=()=>{w(!1),p&&N()},ee=e=>{if(e.pointerType!==`mouse`)return;let n=e.button===1;if((n||e.button===0&&(d||o?.current))&&y(e.target)){e.preventDefault(),e.stopPropagation(),window.clearTimeout(u),p={id:e.pointerId,x:e.clientX,y:e.clientY,start:t.getViewport(),moved:!1,middle:n},m=!1;try{i.setPointerCapture(e.pointerId)}catch{}i.classList.add(`sw-panning`)}},M=e=>{if(f=!0,!p||e.pointerId!==p.id)return;e.preventDefault(),e.stopPropagation();let t=e.clientX-p.x,n=e.clientY-p.y;!p.moved&&Math.abs(t)+Math.abs(n)<2||(p.moved=!0,C(TC(p.start,t,n)))},N=()=>{let e=p;if(p=null,i.classList.remove(`sw-panning`),e){try{i.hasPointerCapture(e.id)&&i.releasePointerCapture(e.id)}catch{}m=!0,window.setTimeout(()=>m=!1,0),e.moved&&x()}},P=e=>{p&&e.pointerId===p.id&&(e.preventDefault(),e.stopPropagation(),N())},F=e=>{m&&(m=!1,e.preventDefault(),e.stopPropagation())},I=()=>{v=Date.now()},L=e=>{_=Date.now()-v<500?e.target:null},R=()=>{f=!0},z=()=>{p||(f=!1)},te=e=>{(e.ctrlKey||e.metaKey)&&e.target?.closest?.(`[data-sw-thread-popover], [data-sw-composer-popover]`)&&e.preventDefault()},B={capture:!0},V={capture:!0,passive:!1};return window.addEventListener(`wheel`,te,V),i.addEventListener(`wheel`,T,V),i.addEventListener(`gesturestart`,E,V),i.addEventListener(`gesturechange`,D,V),i.addEventListener(`touchstart`,O,{capture:!0,passive:!0}),i.addEventListener(`touchend`,O,{capture:!0,passive:!0}),i.addEventListener(`touchcancel`,O,{capture:!0,passive:!0}),i.addEventListener(`pointerdown`,ee,B),i.addEventListener(`pointermove`,M,B),i.addEventListener(`pointerup`,P,B),i.addEventListener(`pointercancel`,P,B),i.addEventListener(`pointerenter`,R),i.addEventListener(`pointerleave`,z),window.addEventListener(`click`,F,B),window.addEventListener(`auxclick`,F,B),window.addEventListener(`keydown`,k,B),window.addEventListener(`keyup`,A,B),window.addEventListener(`blur`,j),window.addEventListener(`pointerdown`,I,B),window.addEventListener(`focusin`,L,B),()=>{window.clearTimeout(u),l.moving&&x(),w(!1),i.classList.remove(`sw-panning`),window.removeEventListener(`wheel`,te,V),i.removeEventListener(`wheel`,T,V),i.removeEventListener(`gesturestart`,E,V),i.removeEventListener(`gesturechange`,D,V),i.removeEventListener(`touchstart`,O,{capture:!0}),i.removeEventListener(`touchend`,O,{capture:!0}),i.removeEventListener(`touchcancel`,O,{capture:!0}),i.removeEventListener(`pointerdown`,ee,B),i.removeEventListener(`pointermove`,M,B),i.removeEventListener(`pointerup`,P,B),i.removeEventListener(`pointercancel`,P,B),i.removeEventListener(`pointerenter`,R),i.removeEventListener(`pointerleave`,z),window.removeEventListener(`click`,F,B),window.removeEventListener(`auxclick`,F,B),window.removeEventListener(`keydown`,k,B),window.removeEventListener(`keyup`,A,B),window.removeEventListener(`blur`,j),window.removeEventListener(`pointerdown`,I,B),window.removeEventListener(`focusin`,L,B)}},[e,a,t,o,r,n]),(0,J.useMemo)(()=>({moving:()=>s.current.moving}),[])}function jC(e,t){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=e.target.closest?.(`.react-flow__node`);if(!n||n.classList.contains(`react-flow__node-groupFrame`))return;let r=e.target===n,i=[...n.querySelectorAll(`button, a[href]`)].filter(e=>!e.disabled&&e.getClientRects().length);if([`ArrowRight`,`ArrowDown`,`ArrowLeft`,`ArrowUp`].includes(e.key)){if(!i.length)return;e.preventDefault();let t=e.key===`ArrowRight`||e.key===`ArrowDown`,n=i.indexOf(e.target);i[r||n<0?t?0:i.length-1:(n+(t?1:-1)+i.length)%i.length].focus()}else e.key===`Escape`&&!r?(e.preventDefault(),n.focus()):(e.key===`Enter`||e.key===` `)&&r&&(e.preventDefault(),t(n.getAttribute(`data-id`)))}function MC({icon:e,title:t,onClose:n,closeLabel:r,closeProps:i,className:a,children:o}){return(0,Y.jsxs)(`div`,{className:O(`flex h-12 shrink-0 items-center gap-1.5 px-3`,a),children:[(0,Y.jsxs)(`h2`,{className:`flex shrink-0 items-center gap-1.5 text-sm font-semibold text-fg`,children:[e?(0,Y.jsx)(e,{size:15,className:`text-muted`,"aria-hidden":`true`}):null,t]}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:o}),n?(0,Y.jsx)(B,{label:r,onClick:n,...i,children:(0,Y.jsx)(se,{size:15,"aria-hidden":`true`})}):null]})}var NC=6e3,PC=new Map,FC=new Set,IC=new Map;function LC(){for(let e of FC)e()}function RC(e,t,n){if(!e)return;if(window.clearTimeout(IC.get(e)),IC.delete(e),t==null||!n){if(!PC.has(e))return;PC.delete(e),LC();return}let r=PC.get(e);if(r?.commentId===t&&r.state===n)return;let i={commentId:t,state:n,since:r?.commentId===t?r.since:Date.now()};PC.set(e,i),LC(),(n===`done`||n===`stopped`)&&IC.set(e,window.setTimeout(()=>{PC.get(e)===i&&RC(e,null,null)},NC))}function zC(e){return FC.add(e),()=>FC.delete(e)}function BC(e){return(0,J.useSyncExternalStore)(zC,()=>{for(let t of PC.values())if(t.commentId===e)return t;return null},()=>null)}function VC(e,t=void 0){let n=(0,J.useSyncExternalStore)(zC,()=>PC.get(e)||null,()=>null);return t===void 0||n&&n.commentId===t?n:null}var HC=new Set,UC=new Set,WC=null,GC=null,KC=2e3,qC=6e4;function JC(e=`event`){for(let t of[...HC])try{t(e)}catch{}}function YC(){document.visibilityState!==`visible`||GC||(GC=window.setTimeout(()=>{GC=null,JC(`shown`),cw(null)},50))}function XC(){return typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-console"]`)?`/api/agent/events`:`api/agent/events`}var ZC=null,QC=!1;function $C(e){let t=e===!0;t!==ZC&&(ZC=t,QC&&ew())}function ew(){tw(),ZC!==!0||Ge||Ue||typeof window.fetch!=`function`||typeof window.TextDecoder!=`function`||Object.keys(Ze()).length&&(WC={controller:null,timer:null,delay:KC},iw(WC))}function tw(){WC&&(window.clearTimeout(WC.timer),WC.controller?.abort()),WC=null}function nw(){QC=!0,window.addEventListener(`focus`,YC),document.addEventListener(`visibilitychange`,YC),ew()}function rw(e){let t=`message`,n=``;for(let r of e.split(`
|
|
20
|
+
`))r.startsWith(`event:`)?t=r.slice(6).trim():r.startsWith(`data:`)&&(n+=r.slice(5).trim());if(t===`agents`&&JC(`event`),t===`batch`)try{cw(JSON.parse(n).board)}catch{}}async function iw(e){let t=new AbortController;e.controller=t;let n=Date.now(),r=!1;try{let e=await window.fetch(XC(),{headers:{Accept:`text/event-stream`,...Ze()},credentials:`same-origin`,cache:`no-store`,signal:t.signal});if(!e.ok||!e.body||!/text\/event-stream/.test(e.headers.get(`content-type`)||``)){r=e.status!==503;return}let n=e.body.getReader(),i=new window.TextDecoder,a=``;for(;;){let{value:e,done:t}=await n.read();if(t)break;a+=i.decode(e,{stream:!0}).replace(/\r\n?/g,`
|
|
21
21
|
`);let r;for(;(r=a.indexOf(`
|
|
22
22
|
|
|
23
|
-
`))>=0;)
|
|
23
|
+
`))>=0;)rw(a.slice(0,r)),a=a.slice(r+2)}}catch{}finally{WC===e&&!t.signal.aborted&&!r&&(e.delay=Date.now()-n>qC?KC:Math.min(e.delay*2,qC),e.timer=window.setTimeout(()=>WC===e&&iw(e),e.delay))}}function aw(){QC=!1,window.removeEventListener(`focus`,YC),document.removeEventListener(`visibilitychange`,YC),GC&&window.clearTimeout(GC),GC=null,tw()}var ow=()=>HC.size+UC.size;function sw(e){return typeof window>`u`?()=>{}:(HC.add(e),ow()===1&&nw(),()=>{HC.delete(e)&&ow()===0&&aw()})}function cw(e){for(let t of[...UC])try{t(e)}catch{}}function lw(e,t,n=!0){let r=(0,J.useRef)(t);r.current=t,(0,J.useEffect)(()=>{if(!n||typeof window>`u`)return;let t=t=>{(t===e||t===null)&&r.current?.()};return UC.add(t),ow()===1&&nw(),()=>{UC.delete(t),ow()===0&&aw()}},[e,n])}function uw(e,t=!0){let n=(0,J.useRef)(e);n.current=e,(0,J.useEffect)(()=>{if(t)return sw(e=>n.current?.(e))},[t])}var dw=encodeURIComponent,fw=(e,t)=>`api/agent/boards/${dw(e)}/threads/${dw(t)}`,pw=(e,t)=>Ge?De.get(t)||mw:`api/agent/boards/${dw(e)}/files/${dw(t)}`,mw=`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22160%22%20height%3D%22100%22%3E%3Crect%20width%3D%22160%22%20height%3D%22100%22%20fill%3D%22%238885%22%2F%3E%3C%2Fsvg%3E`,hw=1e3,gw=Math.ceil(Le/hw),_w=`Waiting for the connection test to finish`,vw=(e,t)=>new Promise((n,r)=>{let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(t.reason||new DOMException(`Aborted`,`AbortError`))},{once:!0})});async function yw(e,t,n,{onEvent:r,signal:i}={}){let a;for(let o=0;a=await fetch(`${fw(e,t)}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`,...Ze()},body:JSON.stringify(n),cache:`no-store`,signal:i}),!(a.ok&&String(a.headers.get(`content-type`)).includes(`text/event-stream`));o+=1){let e=null;try{e=await a.json()}catch{e=null}if(a.status===409&&e?.error?.code===`test_running`&&o<gw)o===0&&r?.(`status`,{text:_w}),await vw(hw,i);else throw ye(a.status,e)}await bw(a,r)}async function bw(e,t){let n=e.body.getReader(),r=new TextDecoder,i=``;for(;;){let{value:e,done:a}=await n.read();if(a)break;i+=r.decode(e,{stream:!0});let o;for(;(o=i.indexOf(`
|
|
24
24
|
|
|
25
|
-
`))>=0;){let e=i.slice(0,o);i=i.slice(o+2);let n=/^event: (.*)$/m.exec(e)?.[1],r=/^data: (.*)$/m.exec(e)?.[1];if(!n||r===void 0)continue;let a;try{a=JSON.parse(r)}catch{continue}t?.(n,a,Number(/^id: (\d+)$/m.exec(e)?.[1])||null)}}}var
|
|
26
|
-
`):[];return(0,Y.jsxs)(`div`,{className:`mt-1.5 space-y-1`,"data-sw-chat-diff":e.path||`diff`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] text-muted`,children:[(0,Y.jsx)(_,{content:e.path||null,children:(0,Y.jsx)(`span`,{className:O(`min-w-0 font-mono`,e.outside?`break-all`:`truncate`),children:e.path||`Changes`})}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-ok`,children:[`+`,e.added]}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-bad`,children:[`-`,e.removed]}),e.created?(0,Y.jsx)(`span`,{className:`shrink-0`,children:`(new file)`}):null]}),e.outside?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warn`,"data-sw-chat-diff-outside":`true`,children:[(0,Y.jsx)(
|
|
27
|
-
`).map(e=>e.trim()).find(Boolean)||`No text`;function jw({open:e,onClose:t,ids:n,comments:r,max:i,agentName:o,targetTitle:s,onStart:c,busy:l,error:u,touch:d}){let f=(0,J.useMemo)(()=>new Map(r.map(e=>[e.id,e])),[r]),p=n.slice(0,i),m=n.length-p.length;return(0,Y.jsx)(N,{open:e,onClose:t,title:`Fix ${p.length} ${p.length===1?`comment`:`comments`} with ${o}`,description:`One at a time, in this order. Each is a normal fix you can review and undo.`,wrapDescription:!0,size:`md`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{variant:`secondary`,size:d?`touch`:`sm`,onClick:t,children:`Cancel`}),(0,Y.jsxs)(a,{variant:`default`,size:d?`touch`:`sm`,disabled:l||!p.length,onClick:()=>c(n),"data-sw-batch-start":`true`,children:[l?(0,Y.jsx)(Og,{size:14,className:`motion-safe:animate-spin`,"aria-hidden":`true`}):(0,Y.jsx)(R_,{size:14,"aria-hidden":`true`}),` `,`Start`]})]}),children:(0,Y.jsxs)(`div`,{className:`space-y-3`,"data-sw-batch-confirm":p.length,children:[m>0?(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-warn/40 bg-warn/10 px-3 py-2 text-xs text-fg`,role:`note`,"data-sw-batch-over":m,children:[(0,Y.jsx)(Q_,{size:14,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[`You chose `,n.length,`. Only the first `,i,` will run; the batch limit is set in Agents.`]})]}):null,(0,Y.jsx)(`ol`,{className:`max-h-72 divide-y divide-line overflow-y-auto rounded-md border border-line`,children:p.map((e,t)=>{let n=f.get(e);return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2.5 px-3 py-2 text-ui`,"data-sw-batch-confirm-item":e,children:[(0,Y.jsxs)(`span`,{className:`w-5 shrink-0 text-right text-xs text-faint tabular-nums`,children:[t+1,`.`]}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`block truncate text-fg`,"data-sw-batch-confirm-title":e,children:[(0,Y.jsxs)(`span`,{className:`text-muted tabular-nums`,children:[`#`,e]}),` `,Aw(Me(n))]}),(0,Y.jsx)(`span`,{className:`block truncate text-xs text-muted`,children:n?s(n.pageId):`comment`})]})]},e)})}),u?(0,Y.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-batch-error":`true`,children:u}):null]})})}var Mw={waiting:{label:`Waiting`,tone:`neutral`,icon:Sh},running:{label:`Running`,tone:`accent`,icon:Og},fixed:{label:`Fixed`,tone:`ok`,icon:st},failed:{label:`Failed`,tone:`bad`,icon:Q_},skipped:{label:`Skipped`,tone:`neutral`,icon:bh}};function Nw(e){let t=e.items.length,n=e.items.filter(e=>![`waiting`,`running`].includes(e.state)).length;if(e.state===`waiting`)return`Waiting for your OK on #${e.waiting?.commentId}`;if(e.state===`running`)return`Fixing ${Math.min(n+1,t)} of ${t}`;let{fixed:r=0,failed:i=0,skipped:a=0}=e.counts||{},o=[`${r} fixed`,i?`${i} failed`:null,a?`${a} skipped`:null].filter(Boolean).join(`, `);return e.state===`cancelled`?`Cancelled: ${o}`:e.state===`stopped`?e.stopReason===`failures`?`Stopped after 2 failures in a row: ${o}`:`Stopped: ${o}`:`Done: ${o}`}function Pw({batch:e,boardId:t,comments:n=[],onOpenThread:r,onCancel:i,onDismiss:o,touch:s=!1,compact:c=!1,className:l}){let[u,d]=(0,J.useState)(!c),f=(0,J.useMemo)(()=>new Map((n||[]).map(e=>[e.id,Me(e)])),[n]),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null);if(!e)return null;let _=Ew(e),v=s?`touch`:`xs`,y=e.items.length,b=e.items.filter(e=>![`waiting`,`running`].includes(e.state)).length,x=async n=>{if(e.waiting){m(n??`deny`),g(null);try{await mw(t,e.waiting.threadId,e.waiting.card.id,n)}catch(e){g(e.message)}finally{m(null)}}},S=(e.waiting?.card?.options||[]).filter(e=>e&&e.optionId);return(0,Y.jsxs)(`section`,{className:O(`space-y-2`,l),"aria-label":`Batch of fixes`,"data-sw-batch":e.state,"data-sw-batch-compact":c?`true`:void 0,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[_?e.state===`waiting`?(0,Y.jsx)(P_,{size:15,className:`shrink-0 text-warn`,"aria-hidden":`true`}):(0,Y.jsx)(Og,{size:15,className:`shrink-0 text-accent motion-safe:animate-spin`,"aria-hidden":`true`}):(0,Y.jsx)(gg,{size:15,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-ui font-semibold text-fg`,role:`status`,"data-sw-batch-headline":`true`,children:Nw(e)}),c?(0,Y.jsx)(a,{variant:`ghost`,size:v,className:`text-fg`,onClick:()=>d(e=>!e),"aria-expanded":u,"data-sw-batch-toggle":`true`,children:u?`Hide`:`Show`}):null,_?(0,Y.jsx)(a,{variant:`secondary`,size:v,onClick:i,disabled:e.cancelling,"data-sw-batch-cancel":`true`,children:`Cancel`}):o?(0,Y.jsx)(a,{variant:`ghost`,size:s?`icon`:`icon-xs`,onClick:o,"aria-label":`Close the summary`,"data-sw-batch-dismiss":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})}):null]}),(0,Y.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-2`,role:`progressbar`,"aria-label":`Fixes finished`,"aria-valuemin":0,"aria-valuemax":y,"aria-valuenow":b,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-(--motion-base)`,style:{width:`${b/Math.max(1,y)*100}%`}})}),e.state===`waiting`&&e.waiting?(0,Y.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-warn/40 bg-warn/10 px-2.5 py-2`,"data-sw-batch-waiting":e.waiting.commentId,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-fg`,children:[`The agent asks before it goes on: `,(0,Y.jsx)(`span`,{className:`font-medium`,children:e.waiting.card.label||`an action`}),`. The batch waits for your answer.`]}),e.waiting.card.detail?(0,Y.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded bg-surface px-2 py-1.5 font-mono text-[11px] whitespace-pre-wrap text-fg`,"data-sw-batch-waiting-detail":`true`,children:e.waiting.card.detail}):null,e.waiting.card.diff?(0,Y.jsx)(xw,{diff:e.waiting.card.diff}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[S.map(e=>(0,Y.jsx)(a,{size:v,variant:/reject|deny/i.test(e.kind||``)?`secondary`:`default`,disabled:!!p,onClick:()=>x(e.optionId),"data-sw-batch-answer":e.optionId,children:e.name||e.optionId},e.optionId)),S.length?null:(0,Y.jsx)(a,{size:v,variant:`secondary`,onClick:()=>r?.(e.waiting.commentId),children:`Review in the chat`})]}),h?(0,Y.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,children:h}):null]}):null,u?(0,Y.jsx)(`ol`,{className:`divide-y divide-line rounded-md border border-line bg-surface`,"data-sw-batch-items":y,children:e.items.map(e=>{let t=Mw[e.state]||Mw.waiting,n=t.icon;return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2 py-1`,"data-sw-batch-item":e.commentId,"data-sw-batch-item-state":e.state,children:[(0,Y.jsxs)(a,{variant:`link`,size:v,className:`shrink-0 px-1 shadow-none tabular-nums`,onClick:()=>r?.(e.commentId),"aria-label":`Open comment #${e.commentId}`,"data-sw-batch-open":e.commentId,children:[`#`,e.commentId]}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,"data-sw-batch-item-title":e.commentId,children:[f.has(e.commentId)?(0,Y.jsx)(`span`,{className:`text-fg`,children:Aw(f.get(e.commentId))}):null,e.message?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[f.has(e.commentId)?` · `:``,e.message]}):null]}),(0,Y.jsxs)(Qe,{tone:t.tone,className:`shrink-0`,children:[(0,Y.jsx)(n,{size:10,className:e.state===`running`?`motion-safe:animate-spin`:void 0,"aria-hidden":`true`}),` `,t.label]})]},e.commentId)})}):null,!_&&e.requested>y?(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[e.requested-y,` more `,e.requested-y===1?`was`:`were`,` chosen but not run (the limit is `,e.max,`).`]}):null]})}var Fw=`__any`,Iw=[{id:`open`,label:`Open`},{id:`resolved`,label:`Resolved`},{id:`all`,label:`All`}];function Lw(e){let t=[...e.reactions||[],...(e.replies||[]).flatMap(e=>e.reactions||[])],n=new Map;for(let e of t)n.set(e.emoji,(n.get(e.emoji)||0)+e.count);return[...n.entries()].slice(0,3)}function Rw({comment:e}){let t=NC(e.id);return e.status===`resolved`?(0,Y.jsxs)(Qe,{tone:`ok`,"data-sw-comment-state":`resolved`,children:[(0,Y.jsx)(st,{size:10,"aria-hidden":`true`}),` Resolved`]}):t?.state===`working`||t?.state===`waiting`?(0,Y.jsxs)(Qe,{tone:t.state===`waiting`?`warn`:`accent`,"data-sw-agent-live":t.state,children:[(0,Y.jsx)(Og,{size:10,className:`motion-safe:animate-spin`,"aria-hidden":`true`}),t.state===`waiting`?`Needs your OK`:`Agent working`]}):e.agentStatus?(0,Y.jsx)(xb,{status:e.agentStatus,at:e.agentStatusAt}):(0,Y.jsx)(Sb,{comment:e})}function zw({comment:e,title:t,selected:n,unread:r,touch:i,onFocus:a,onHover:o,pick:s=null}){let c=rx(t=>t.hoveredId===e.id),l=Db(e),u=e.replies?.length||0,d=Lw(e),f=[e,...e.replies||[]],p=f.reduce((e,t)=>e+(t.images?.length||0),0),m=f.some(e=>e.drawing?.shapes?.length),h=Iv(e.viewport);return(0,Y.jsxs)(`li`,{className:O(`relative`,n?`bg-accent/10 shadow-[inset_3px_0_0_var(--accent)]`:c?`bg-surface-2`:``,e.status===`resolved`&&!n&&`opacity-80`,s&&`flex items-start`),"data-sw-batch-row":s?e.id:void 0,children:[s?(0,Y.jsx)(`span`,{className:O(`flex shrink-0 items-center`,i?`pt-1.5 pl-1`:`pt-3 pl-1.5`),children:(0,Y.jsx)(kw,{checked:s.checked,onChange:s.onChange,disabled:s.disabled,touch:i,label:`Select comment #${e.id}`,"data-sw-batch-select":e.id})}):null,(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e),onMouseEnter:o?()=>o(e.id):void 0,onMouseLeave:o?()=>o(null):void 0,onFocus:o?()=>o(e.id):void 0,onBlur:o?()=>o(null):void 0,"aria-current":n?`true`:void 0,className:O(`sw-gutter-pad flex w-full gap-2.5 px-3 py-3 text-left transition-colors hover:bg-surface-2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,i&&`min-h-11`,s&&`min-w-0 flex-1 pl-1.5`),"data-sw-comment":e.id,"data-sw-comment-unread":r?`true`:void 0,"data-sw-comment-selected":n?`true`:void 0,children:[(0,Y.jsx)(Eb,{...l,size:i?`lg`:`md`,className:`mt-0.5`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-ui`,children:[(0,Y.jsx)(`span`,{className:O(`min-w-0 truncate text-fg`,r?`font-bold`:`font-semibold`),children:l.name}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:A(e.createdAt)}),(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,Y.jsx)(Rw,{comment:e}),r?(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-accent`,"aria-label":`Unread`,role:`img`,"data-sw-unread-dot":`true`}):null]})]}),(0,Y.jsx)(Pb,{text:Me(e),plain:!!e.authorGuest,className:`mt-0.5 line-clamp-2 block text-ui break-words text-fg`}),(0,Y.jsxs)(`span`,{className:`mt-1.5 flex min-w-0 items-center gap-2 text-xs text-muted`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex h-5 min-w-0 items-center gap-1 rounded bg-surface-2 px-1.5 text-[11px] text-muted`,"data-sw-comment-page":`true`,children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg/70 tabular`,children:[`#`,e.id]}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Y.jsx)(h,{size:11,className:`shrink-0 text-faint`,"aria-label":e.viewport,role:`img`})]}),u?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 tabular`,"aria-label":`${u} ${u===1?`reply`:`replies`}`,children:[(0,Y.jsx)(Wg,{size:11,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:u})]}):null,p?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 tabular`,"aria-label":`${p} ${p===1?`image`:`images`}`,"data-sw-comment-images":p,children:[(0,Y.jsx)(fg,{size:11,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:p})]}):null,m?(0,Y.jsx)(`span`,{className:`inline-flex shrink-0 items-center`,"aria-label":`Has a drawing`,role:`img`,"data-sw-comment-drawn":`true`,children:(0,Y.jsx)(ch,{size:11,"aria-hidden":`true`})}):null,d.map(([e,t])=>(0,Y.jsxs)(`span`,{className:`shrink-0`,"aria-label":`${t} ${e}`,children:[e,t>1?(0,Y.jsx)(`span`,{className:`ml-0.5 tabular`,children:t}):null]},e)),e.agentStatus&&e.reopenCount>0&&e.status===`open`?(0,Y.jsx)(Sb,{comment:e}):null]}),e.orphanReason?(0,Y.jsx)(`span`,{className:`mt-1 block text-xs text-muted`,children:e.orphanReason}):null,e.imported&&e.agentStatus?(0,Y.jsx)(`span`,{className:`mt-1 block text-xs text-faint`,children:`Imported history`}):null]})]})]})}function Bw({comments:e,filter:t,counts:n,onFilter:r,selectedId:i=null,onFocus:o,onHover:s=null,unread:c=new Set,onMarkAllRead:l=null,canAct:u,targetTitle:d,touch:f,journeyFilter:p=null,heading:m=!0,onClose:h=null,onResetBrowserComments:g=null,people:_=[],narrow:v=null,batch:y=null}){let b=(0,J.useRef)(null);(0,J.useEffect)(()=>{i!==null&&(b.current?.querySelector(`[data-sw-comment="${i}"]`))?.scrollIntoView?.({block:`nearest`})},[i,e.length]);let x=nx();(0,J.useEffect)(()=>{if(f)return;let e=x.get().hoveredId;return x.subscribe(()=>{let{hoveredId:t}=x.get();t!==e&&(e=t,t!==null&&b.current?.querySelector(`[data-sw-comment="${t}"]`)?.scrollIntoView?.({block:`nearest`}))})},[f,x]);let S=!!(v&&(v.query||v.state||v.mention)),C=e.filter(e=>c.has(e.id)).length,w=!!y?.offered,T=w&&y.selecting,E=T?e.filter(Dw):[],D=T?y.selected.filter(e=>E.some(t=>t.id===e)):[],k=f?`touch`:`xs`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-line`,children:[m?(0,Y.jsx)(TC,{icon:Wg,title:`Comments`,onClose:h,closeLabel:`Close comments`,closeProps:{"data-sw-comments-close":`true`}}):null,(0,Y.jsx)(`div`,{className:O(`px-3 pb-2.5`,m?``:`pt-2.5`),children:(0,Y.jsx)(Xe,{label:`Show comments`,value:t,onChange:r,large:f,className:`w-full`,options:Iw.map(e=>({...e,count:e.id===`all`?n.open+n.resolved:n[e.id]}))})})]}),v?(0,Y.jsxs)(`div`,{className:`space-y-1.5 border-b border-line px-3 py-2`,"data-sw-comment-narrow":`true`,children:[(0,Y.jsx)(it,{type:`search`,icon:S_,size:f?`touch`:`xs`,value:v.query,onChange:e=>v.onQuery(e.target.value.slice(0,120)),placeholder:`Search text, people, pages, #id`,"aria-label":`Search comments`,"data-sw-comment-search":`true`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsxs)($e,{value:v.state||Fw,onValueChange:e=>v.onState(e===Fw?null:e),children:[(0,Y.jsx)(Se,{size:f?`touch`:`xs`,className:`flex-1`,"aria-label":`Comment state`,"data-sw-comment-state":`true`,children:(0,Y.jsx)(oe,{})}),(0,Y.jsxs)(_e,{children:[(0,Y.jsx)(q,{value:Fw,children:`Any state`}),(0,Y.jsx)(we,{}),kv.map(e=>(0,Y.jsx)(q,{value:e.id,children:e.label},e.id))]})]}),(0,Y.jsxs)($e,{value:v.mention||Fw,onValueChange:e=>v.onMention(e===Fw?null:e),children:[(0,Y.jsx)(Se,{size:f?`touch`:`xs`,className:`flex-1`,"aria-label":`Mentioning`,"data-sw-comment-mention":`true`,children:(0,Y.jsx)(oe,{})}),(0,Y.jsxs)(_e,{children:[(0,Y.jsx)(q,{value:Fw,children:`Anyone mentioned`}),_.length?(0,Y.jsx)(we,{}):null,_.map(e=>(0,Y.jsxs)(q,{value:e.handle,children:[`@`,e.handle]},e.handle))]})]}),S?(0,Y.jsx)(B,{size:f?`icon`:`icon-xs`,onClick:v.onClear,label:`Clear search and filters`,"data-sw-comment-narrow-clear":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})}):null]})]}):null,g?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line bg-surface-2/60 px-3 py-2 text-xs text-muted`,"data-sw-browser-comments":`true`,children:[(0,Y.jsx)(mg,{size:13,className:`shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Demo: comments you add stay in this browser.`}),(0,Y.jsx)(a,{variant:`ghost`,size:f?`touch`:`xs`,className:`text-fg`,onClick:g,"data-sw-browser-comments-reset":`true`,children:`Reset`})]}):null,p?(0,Y.jsx)(`div`,{className:`border-b border-line px-3 py-2`,children:(0,Y.jsxs)(Ie,{variant:`pill`,size:f?`touch`:`xs`,pressed:p.on,onPressedChange:p.onToggle,"data-sw-journey-filter":p.on?`on`:`off`,children:[(0,Y.jsx)(v_,{size:12,className:`shrink-0 text-warn`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`Only `,p.name]})]})}):null,w&&t!==`resolved`?(0,Y.jsx)(`div`,{className:O(`flex flex-wrap items-center gap-1.5 border-b border-line px-3 py-1.5 text-xs text-muted`,T&&`bg-accent/5`),"data-sw-batch-bar":T?`selecting`:`off`,children:T?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-nowrap tabular-nums`,role:`status`,"data-sw-batch-count":D.length,children:[D.length,` selected`]}),(0,Y.jsxs)(a,{variant:`ghost`,size:k,className:`text-fg`,disabled:!E.length,onClick:()=>y.setSelected(E.slice(0,y.max).map(e=>e.id)),"data-sw-batch-select-all":`true`,children:[`Select all`,E.length>y.max?` (first ${y.max})`:``]}),(0,Y.jsx)(a,{variant:`ghost`,size:k,className:`text-fg`,onClick:()=>y.setSelecting(!1),"data-sw-batch-select-done":`true`,children:`Cancel`}),D.length>y.max?(0,Y.jsxs)(`p`,{className:`basis-full text-xs text-fg`,"data-sw-batch-over":`true`,children:[`Only the first `,y.max,` will run (the limit on the Agents page).`]}):null,(0,Y.jsxs)(a,{variant:`default`,size:k,className:`w-full`,disabled:!D.length||Ew(y.batch),onClick:()=>y.onConfirm(D),"data-sw-batch-fix":D.length,children:[(0,Y.jsx)(R_,{size:13,"aria-hidden":`true`}),` Fix `,D.length||``,` with `,y.agentName]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Fix several open comments in one go.`}),(0,Y.jsxs)(a,{variant:`ghost`,size:k,className:`text-fg`,disabled:Ew(y.batch),onClick:()=>y.setSelecting(!0),"data-sw-batch-select-mode":`true`,children:[(0,Y.jsx)(Eg,{size:13,"aria-hidden":`true`}),` Select`]})]})}):null,w&&y.batch?(0,Y.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-line bg-surface px-3 py-2`,"data-sw-batch-strip":`true`,children:(0,Y.jsx)(Pw,{batch:y.batch,boardId:y.boardId,comments:e,compact:!0,touch:f,onOpenThread:y.onOpenThread,onCancel:y.cancel,onDismiss:y.dismiss})}):null,C&&l?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-1.5 text-xs text-muted`,"data-sw-unread-bar":`true`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[C,` with new activity`]}),(0,Y.jsxs)(a,{variant:`ghost`,size:f?`touch`:`xs`,className:`text-fg`,onClick:l,"data-sw-mark-all-read":`true`,children:[(0,Y.jsx)(gh,{size:13,"aria-hidden":`true`}),` Mark all read`]})]}):null,(0,Y.jsx)(`ul`,{ref:b,className:`min-h-0 flex-1 divide-y divide-line overflow-y-auto`,"data-sw-comment-list":`true`,children:e.length?e.map(e=>(0,Y.jsx)(zw,{comment:e,title:d(e.pageId),selected:i===e.id,unread:c.has(e.id),touch:f,onFocus:o,onHover:s,pick:T&&e.status===`open`?{checked:D.includes(e.id),disabled:!Dw(e),onChange:()=>y.toggle(e.id)}:null},e.id)):(0,Y.jsx)(`li`,{children:S?(0,Y.jsx)(j,{icon:S_,title:`No comments match`,children:(0,Y.jsx)(a,{variant:`link`,size:f?`touch`:`xs`,className:`shadow-none`,onClick:v.onClear,children:`Clear the search and filters`})}):(0,Y.jsx)(j,{icon:Wg,title:t===`resolved`?`Nothing resolved yet`:t===`open`?`No open comments`:`No comments yet`,children:u?f?`Tap a page and then Comment, or the Comment tool at the bottom of the board, then tap the page to pin a note.`:`Click a page and press Comment, or pick the Comment tool at the bottom of the board (C), then click the page to pin a note.`:`This board is read-only.`})})})]})}function Vw({label:e,keyName:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,` `,(0,Y.jsx)(s,{children:t})]})}function Hw({route:e,step:t,pageTitle:n,onStep:r,touch:i}){let a=new Map(e.forks.map((e,t)=>[e.afterStep,{...e,index:t}])),o=i?`h-11 min-w-11`:`h-6 min-w-6`;return(0,Y.jsxs)(`ol`,{className:O(`flex max-w-full min-w-0 items-center overflow-x-auto py-1`,i?`px-0.5`:`gap-0.5`),"aria-label":`Steps`,"data-sw-journey-rail":`true`,children:[e.steps.map((e,s)=>{let c=s+1,l=a.get(c),u=c===t,d=c<t;return(0,Y.jsxs)(J.Fragment,{children:[s>0?(0,Y.jsx)(`li`,{"aria-hidden":`true`,className:O(`h-0.5 shrink-0 rounded-full`,i?`-mx-1.5 w-3`:`w-3`,c<=t?`bg-accent/60`:`bg-line`)}):null,(0,Y.jsx)(`li`,{className:`shrink-0`,children:(0,Y.jsx)(_,{content:(0,Y.jsxs)(`span`,{children:[`Step `,c,`: `,n(e.pageId),e.branch?(0,Y.jsxs)(`span`,{className:`opacity-75`,children:[` (`,e.branch,`)`]}):null]}),side:`top`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(c),className:O(`group/dot inline-flex items-center justify-center rounded-full outline-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent`,o),"aria-current":u?`step`:void 0,"aria-label":`Step ${c}: ${n(e.pageId)}${e.branch?` (${e.branch})`:``}`,"data-sw-journey-dot":c,children:(0,Y.jsx)(`span`,{className:O(`tabular inline-flex items-center justify-center rounded-full px-1 text-[11px] leading-none font-semibold`,i?`h-7 min-w-7`:`h-6 min-w-6`,u?`bg-accent text-accent-fg shadow-card ring-4 ring-accent/20`:d?`bg-accent/15 text-accent group-hover/dot:bg-accent/25`:`border border-line bg-surface text-muted group-hover/dot:border-faint group-hover/dot:text-fg`,e.branch&&!u&&`border-dashed`),"aria-hidden":`true`,children:c})})})}),l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`li`,{"aria-hidden":`true`,className:O(`h-0.5 w-2 shrink-0 rounded-full`,c<t?`bg-accent/60`:`bg-line`)}),(0,Y.jsx)(`li`,{className:`shrink-0`,children:(0,Y.jsx)(_,{content:`The journey forks here: ${l.options.map(e=>e.label).join(` or `)}`,side:`top`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(c),className:O(`inline-flex items-center gap-1 rounded-full border px-1.5 text-[11px] font-medium outline-none focus-visible:outline-2 focus-visible:outline-accent`,i?`h-11 min-w-11 justify-center`:`h-6`,c===t?`border-accent bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),"aria-label":`Fork after step ${c}: ${l.options.find(e=>e.id===l.chosen)?.label||``} taken`,"data-sw-journey-rail-fork":l.index,children:[(0,Y.jsx)(Qh,{size:12,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`max-w-24 truncate`,children:l.options.find(e=>e.id===l.chosen)?.label})]})})})]}):null]},e.key||s)}),e.ended?(0,Y.jsx)(`li`,{className:`ml-1 shrink-0 text-[11px] font-medium text-faint`,"data-sw-journey-rail-end":`true`,children:`ends`}):null]})}function Uw({journey:e,route:t,step:n,pageTitle:r,onStep:i,onChoose:o,onClose:s,onEdit:c,onDelete:l,canEdit:u,busy:d,touch:f}){let[p,m]=(0,J.useState)(!1),h=t.steps.length,g=t.steps[n-1],v=t.forks.findIndex(e=>e.afterStep===n),y=v>=0?t.forks[v]:null,b=f?`touch`:`sm`,x=(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[13px] font-semibold text-fg`,children:[(0,Y.jsx)(v_,{size:14,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]});return(0,Y.jsxs)(`div`,{className:O(`pointer-events-auto relative z-30 flex flex-col gap-1.5 rounded-xl border border-line bg-surface/95 shadow-pop backdrop-blur`,f?`w-full p-2`:`w-max max-w-[min(760px,100%)] min-w-[min(440px,100%)] px-3 py-2`),role:`region`,"aria-label":`Journey: ${e.name}`,"data-sw-journey-bar":e.id,"data-sw-journey-path":t.forks.map(e=>e.chosen).join(`,`),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 px-0.5`,children:[e.description&&!f?(0,Y.jsx)(_,{content:e.description,side:`top`,align:`start`,children:(0,Y.jsx)(`span`,{tabIndex:0,className:`block min-w-0 rounded outline-none focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-journey-description":`true`,children:x})}):x,(0,Y.jsxs)(`p`,{className:`truncate text-xs text-muted`,"aria-live":`polite`,"data-sw-journey-step":n,children:[(0,Y.jsxs)(`span`,{className:`tabular font-medium text-fg`,children:[`Step `,n,` of `,h]}),g?.branch?(0,Y.jsxs)(`span`,{"data-sw-journey-branch-now":g.branch,children:[` (`,g.branch,`)`]}):null,`:`,` `,r(g?.pageId),t.ended&&n===h?`, where this branch ends`:``]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Y.jsx)(_,{content:f?null:(0,Y.jsx)(Vw,{label:`Previous step`,keyName:`←`}),children:(0,Y.jsx)(a,{size:f?`icon`:`icon-sm`,disabled:n<=1,onClick:()=>i(n-1),"aria-label":`Previous step`,"data-sw-journey-prev":`true`,children:(0,Y.jsx)(ut,{size:16,"aria-hidden":`true`})})}),(0,Y.jsx)(_,{content:f?null:(0,Y.jsx)(Vw,{label:`Next step`,keyName:`→`}),children:(0,Y.jsxs)(a,{size:f?`touch`:`sm`,variant:`default`,className:`px-2.5`,disabled:n>=h,onClick:()=>i(n+1),"aria-label":`Next step`,"data-sw-journey-next":`true`,children:[`Next `,(0,Y.jsx)(nt,{size:16,"aria-hidden":`true`})]})}),u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),c?(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,onClick:c,disabled:d,label:`Edit this journey`,children:(0,Y.jsx)(o_,{size:14,"aria-hidden":`true`})}):null,p?(0,Y.jsxs)(a,{size:b,variant:`danger`,disabled:d,onClick:l,"data-sw-journey-delete-confirm":`true`,children:[(0,Y.jsx)(X_,{size:14,"aria-hidden":`true`}),` Delete`]}):(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,disabled:d,onClick:()=>m(!0),label:`Delete this journey`,children:(0,Y.jsx)(X_,{size:14,"aria-hidden":`true`})})]}):null,(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,onClick:s,label:`Close the journey`,tooltip:f?null:(0,Y.jsx)(Vw,{label:`Close the journey`,keyName:`Esc`}),"data-sw-journey-close":`true`,children:(0,Y.jsx)(se,{size:16,"aria-hidden":`true`})})]})]}),(0,Y.jsx)(Hw,{route:t,step:n,pageTitle:r,onStep:i,touch:f}),y?(0,Y.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-1.5 border-t border-line pt-2`,role:`group`,"aria-label":`The journey forks here. Which way?`,"data-sw-journey-fork":v,children:[(0,Y.jsxs)(`span`,{className:O(`flex items-center gap-1 text-xs font-medium text-muted`,f&&`w-full px-1`),children:[(0,Y.jsx)(Qh,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),` Which way?`]}),y.options.map(e=>{let t=e.id===y.chosen;return(0,Y.jsxs)(a,{size:b,variant:t?`default`:`secondary`,className:O(`max-w-full min-w-0`,f&&`flex-1`),"aria-pressed":t,onClick:()=>o(v,e.id),"data-sw-journey-branch":e.id,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.label}),e.end?(0,Y.jsx)(`span`,{className:`text-[11px] opacity-75`,children:`(ends)`}):null]},e.id)})]}):null]})}function Ww({draft:e,onChange:t,onSave:n,onCancel:r,pageTitle:i,busy:o,touch:s}){let c=s?`touch`:`sm`,l=e.steps,u=e.into||null,d=Kw(l),f=Jw(l),p=e.name.trim()&&d>=2&&!f&&!o,m=l[l.length-1],h=n=>{let r=structuredClone(l),i=n(r);t({...e,steps:r,into:i===void 0?u:i})};return(0,Y.jsxs)(`div`,{className:O(`pointer-events-auto relative z-30 flex max-h-[60dvh] flex-col gap-2 overflow-y-auto rounded-xl border border-accent/50 bg-surface/95 p-3 shadow-pop backdrop-blur`,s?`w-full`:`w-[min(680px,100%)]`),role:`region`,"aria-label":e.id?`Edit journey`:`New journey`,"data-sw-journey-builder":`true`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(v_,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`Journey name`}),(0,Y.jsx)(it,{size:s?`touch`:`sm`,value:e.name,onChange:n=>t({...e,name:n.target.value.slice(0,120)}),placeholder:`Name this journey, e.g. Sign up`,"data-sw-journey-name":`true`})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-journey-into":u?`${u.fork}:${u.branch}`:`main`,children:[s?`Tap`:`Click`,` pages in the order people visit them`,u?(0,Y.jsxs)(Y.Fragment,{children:[` `,`-- adding to `,(0,Y.jsx)(`span`,{className:`font-semibold text-fg`,children:l[u.fork]?.branches?.[u.branch]?.label||`the branch`}),`.`]}):`.`]}),(0,Y.jsxs)(`ol`,{className:`flex flex-wrap items-start gap-1.5`,"data-sw-journey-draft":qw(l),children:[l.map((n,r)=>typeof n==`string`?(0,Y.jsx)(Gw,{number:r+1,title:i(n),touch:s,onRemove:()=>h(e=>(e.splice(r,1),null))},`${n}-${r}`):(0,Y.jsxs)(`li`,{className:`w-full rounded-lg border border-line bg-surface-2/50 p-2`,"data-sw-journey-draft-fork":r,children:[(0,Y.jsxs)(`p`,{className:`mb-1.5 flex items-center gap-1 text-xs font-medium text-muted`,children:[(0,Y.jsx)(Qh,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),` Fork: which way?`]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:n.branches.map((o,c)=>{let l=u?.fork===r&&u?.branch===c;return(0,Y.jsxs)(`div`,{className:O(`flex flex-wrap items-center gap-1.5 rounded-md p-1`,l&&`bg-accent/10 ring-1 ring-accent/50`),"data-sw-journey-draft-branch":c,children:[(0,Y.jsx)(it,{size:s?`touch`:`xs`,className:`w-36`,value:o.label,"aria-label":`Branch ${c+1} name`,onChange:e=>h(t=>{t[r].branches[c].label=e.target.value.slice(0,60)})}),o.steps.map((e,t)=>typeof e==`string`?(0,Y.jsx)(Gw,{title:i(e),touch:s,onRemove:()=>h(e=>{e[r].branches[c].steps.splice(t,1)})},`${e}-${t}`):(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:`(a nested fork, edit it in the config)`},`nested-`+t)),(0,Y.jsx)(a,{size:s?`touch`:`xs`,variant:l?`default`:`ghost`,"aria-pressed":l,onClick:()=>t({...e,into:{fork:r,branch:c}}),"data-sw-journey-fill-branch":c,children:l?`Adding here`:`Add pages here`}),(0,Y.jsx)(a,{size:s?`touch`:`xs`,variant:o.end?`default`:`ghost`,"aria-pressed":!!o.end,onClick:()=>h(e=>{e[r].branches[c].end?delete e[r].branches[c].end:e[r].branches[c].end=!0}),"data-sw-journey-branch-end":c,children:o.end?`Ends here`:`Rejoins`}),n.branches.length>2?(0,Y.jsx)(B,{className:O(`rounded-full`,s?`h-11 w-11`:`h-6 w-6`),onClick:()=>h(e=>(e[r].branches.splice(c,1),u?.fork===r?{fork:r,branch:0}:u)),label:`Remove branch ${c+1}`,tooltip:`Remove the branch`,children:(0,Y.jsx)(se,{size:12,"aria-hidden":`true`})}):null]},c)})}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[n.branches.length<6?(0,Y.jsxs)(a,{size:s?`touch`:`xs`,variant:`ghost`,onClick:()=>h(e=>(e[r].branches.push({label:`Branch ${e[r].branches.length+1}`,steps:[]}),{fork:r,branch:e[r].branches.length-1})),"data-sw-journey-add-branch":`true`,children:[(0,Y.jsx)(c_,{size:13,"aria-hidden":`true`}),` Branch`]}):null,u?.fork===r?(0,Y.jsx)(a,{size:s?`touch`:`xs`,variant:`ghost`,onClick:()=>t({...e,into:null}),"data-sw-journey-main":`true`,children:`Back to the main line`}):null]})]},`fork-${r}`)),l.length?null:(0,Y.jsx)(`li`,{className:`text-xs text-faint`,children:`No steps yet.`})]}),f?(0,Y.jsx)(`p`,{className:`text-xs text-warn`,"data-sw-journey-problem":`true`,children:f}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Y.jsx)(_,{content:s?null:`Split the journey here into branches`,children:(0,Y.jsxs)(a,{size:c,variant:`ghost`,className:`mr-auto`,disabled:typeof m!=`string`||o,onClick:()=>h(e=>(e.push({branches:[{label:`Branch 1`,steps:[]},{label:`Branch 2`,steps:[]}]}),{fork:e.length-1,branch:0})),"data-sw-journey-fork-add":`true`,children:[(0,Y.jsx)(Qh,{size:14,"aria-hidden":`true`}),` Fork here`]})}),(0,Y.jsxs)(a,{size:c,variant:`ghost`,disabled:!l.length||o,onClick:()=>h(e=>{let t=u?e[u.fork]?.branches?.[u.branch]?.steps:e;return t?.length?(t.pop(),u):u?e[u.fork].branches.every(e=>!e.steps.length)?(e.splice(u.fork,1),null):u:null}),children:[(0,Y.jsx)(ev,{size:14,"aria-hidden":`true`}),` Undo`]}),(0,Y.jsx)(a,{size:c,onClick:r,disabled:o,children:`Cancel`}),(0,Y.jsx)(a,{size:c,variant:`default`,onClick:n,disabled:!p,"data-sw-journey-save":`true`,children:o?`Saving...`:`Save journey`})]})]})}function Gw({number:e,title:t,touch:n,onRemove:r}){return(0,Y.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-full bg-accent/10 py-0.5 pr-0.5 pl-2 text-xs font-medium text-fg`,children:[e?(0,Y.jsx)(`span`,{className:`font-bold text-accent`,children:e}):null,` `,t,(0,Y.jsx)(B,{className:O(`rounded-full`,n?`h-9 w-9`:`h-5 w-5`),onClick:r,label:e?`Remove step ${e}`:`Remove ${t}`,tooltip:`Remove`,children:(0,Y.jsx)(se,{size:12,"aria-hidden":`true`})})]})}function Kw(e){return e.reduce((e,t)=>e+(typeof t==`string`?1:t.branches.reduce((e,t)=>e+t.steps.length,0)),0)}function qw(e){return e.map(e=>typeof e==`string`?e:`[${e.branches.map(e=>`${e.label}:${e.steps.join(`+`)}${e.end?`!`:``}`).join(`|`)}]`).join(`,`)}function Jw(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(typeof n==`string`)continue;let r=t<e.length-1,i=new Set;for(let e of n.branches){let t=e.label.trim();if(!t)return`Every branch needs a name.`;if(i.has(t.toLowerCase()))return`Two branches are called "${t}".`;if(i.add(t.toLowerCase()),!e.steps.length&&(e.end||!r))return`"${t}" has no pages: add some, or add a step after the fork for it to skip to.`}if(n.branches.every(e=>e.end)&&r)return`Every branch ends, so nothing can follow the fork.`}return null}var Yw=`No new comments while comparing`,Xw=`A comment belongs to a page, not to one environment. Leave compare to add one; replies and resolving work here.`;function Zw({environments:e,pair:t,loading:n,error:r,changedPages:i,totalPages:o=0,changedOnly:s,showDiff:c,canComment:l=!1,canCapture:u,captureBusy:d,touch:f,onPair:p,onChangedOnly:m,onShowDiff:h,onCapture:g,onClose:v}){let[y,b]=t,x=(t,n,r,i,a=null)=>(0,Y.jsxs)(`span`,{className:O(`flex min-w-0 items-center gap-1 text-xs text-muted`,f&&`min-w-28 flex-1`),children:[f||!a?null:(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:a}),(0,Y.jsxs)($e,{value:t,onValueChange:n,children:[(0,Y.jsx)(Se,{size:f?`touch`:`sm`,className:f?`flex-1`:`max-w-48`,"aria-label":r,"data-sw-compare-env":i,children:(0,Y.jsx)(oe,{})}),(0,Y.jsx)(_e,{children:e.map(e=>(0,Y.jsx)(q,{value:e.id,children:e.title},e.id))})]})]}),S=e.filter(e=>t.includes(e.id)&&!e.capturedAt);return(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-2`,role:`region`,"aria-label":`Compare environments`,"data-sw-compare-bar":t.join(`_`),children:[(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 pr-1 text-[13px] font-semibold text-fg`,children:[(0,Y.jsx)(Xh,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),f?null:`Compare`]}),x(y,e=>p(e===b?[e,y]:[e,b]),`Compare`,`a`),(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,onClick:()=>p([b,y]),label:`Swap the environments`,children:(0,Y.jsx)(eh,{size:14,"aria-hidden":`true`})}),x(b,e=>p(e===y?[b,e]:[y,e]),`with`,`b`,`with`),(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,className:O(`ml-auto`,!f&&`order-last`),onClick:v,label:`Leave compare mode`,"data-sw-compare-close":`true`,children:(0,Y.jsx)(se,{size:16,"aria-hidden":`true`})}),(0,Y.jsx)(Ie,{size:f?`touch`:`sm`,pressed:c,onPressedChange:h,children:`Diff overlay`}),(0,Y.jsx)(Ie,{size:f?`touch`:`sm`,pressed:s,onPressedChange:m,"data-sw-changed-only":s?`on`:`off`,children:`Changed pages only`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted`,"aria-live":`polite`,"data-sw-compare-status":n?`loading`:`ready`,children:n?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(me,{size:12}),` Comparing`]}):r?(0,Y.jsx)(`span`,{className:`text-bad`,children:r}):(0,Y.jsxs)(`span`,{className:O(`tabular inline-flex h-6 items-center rounded-full px-2 font-medium`,i?`bg-accent/10 text-accent`:`bg-surface-2 text-muted`),children:[i,o?` of ${o}`:``,` page`,(o||i)===1?``:`s`,` changed`]})}),l?(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-xs text-muted`,"data-sw-compare-no-comments":`true`,children:[(0,Y.jsx)(Bg,{size:13,className:`shrink-0`,"aria-hidden":`true`}),f?(0,Y.jsx)(`span`,{className:`min-w-0`,children:Yw}):(0,Y.jsx)(_,{content:Xw,children:(0,Y.jsx)(`span`,{className:`min-w-0 cursor-help underline decoration-dotted underline-offset-2`,tabIndex:0,children:Yw})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:Xw})]}):null,u?S.map(e=>(0,Y.jsxs)(a,{size:f?`touch`:`sm`,disabled:d,onClick:()=>g(e.id),children:[(0,Y.jsx)(fh,{size:14,"aria-hidden":`true`}),` Capture `,e.title]},e.id)):null]})}var Qw=2e3,$w=(e,t)=>e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&!t;function eT({draft:e,onChange:t,onSubmit:n,onCancel:r,busy:i,people:o,touch:c,hosted:l,signedInAs:u,description:d,media:f,discard:p=null,startDraw:m=!1}){let h=e?.body||``,g=Math.min(8,Math.max(c?3:2,h.split(`
|
|
28
|
-
`).length)),[_,v]=(0,J.useState)(!1),y=!!(c&&f?.draw&&f?.page);(0,J.useEffect)(()=>{m&&y&&v(!0)},[m,y]);let b=Hx(e=>e?.owner===`composer`?e.shapes.length:0),x=f?.images,S=!!(f?.attach&&x),C=!!f?.draw,w=!!x?.reading;return(0,Y.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),n()},...dS(x,S),"data-sw-composer":`true`,children:[d?(0,Y.jsx)(`p`,{className:O(`truncate text-xs text-muted`,!c&&`-mx-3 -mt-3 cursor-grab touch-none px-3 pt-3 select-none`),title:c?void 0:`Drag to move`,"data-sw-composer-target":`true`,"data-sw-card-drag-handle":c?void 0:`true`,children:d}):null,(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`Comment`}),(0,Y.jsx)(Ib,{size:c?`touch`:`sm`,rows:g,value:h,people:o,className:`resize-none`,onChange:e=>t({body:e.slice(0,Qw)}),onKeyDown:e=>{$w(e,c)&&(e.preventDefault(),n())},autoFocus:!0,placeholder:`Add a comment. @ to mention someone or @agent`,"aria-describedby":x?.error?`sw-composer-image-error`:void 0,"data-sw-comment-input":`true`})]}),S?(0,Y.jsx)(fS,{draft:x,touch:c,id:`sw-composer-image-error`}):null,S||C||f?.attachNote?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5`,"data-sw-composer-media":`true`,children:[C&&!c?(0,Y.jsx)(oS,{owner:`composer`,touch:!1,compact:!0,className:`flex-1`,leading:S?(0,Y.jsx)(uS,{draft:x,touch:!1,disabled:i}):null}):S?(0,Y.jsx)(uS,{draft:x,touch:c,disabled:i}):null,C&&c&&f.page?(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,onClick:()=>v(!0),"data-sw-draw-open":`true`,children:[(0,Y.jsx)(ch,{size:16,"aria-hidden":`true`}),` `,b?`Drawing (${b})`:`Draw on the page`]}):null,f?.attachNote?(0,Y.jsx)(`p`,{className:`w-full text-caption text-faint`,"data-sw-attach-note":`true`,children:f.attachNote}):null]}):null,c&&C&&f.page?(0,Y.jsx)(lS,{open:_,onClose:()=>v(!1),owner:`composer`,src:f.page.src,native:f.page.native,title:f.pageTitle}):null,l?null:(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Your name`}),(0,Y.jsx)(it,{size:c?`touch`:`xs`,value:e?.author||``,onChange:e=>t({author:e.target.value.slice(0,60)}),placeholder:`optional`,className:`flex-1`,"data-sw-comment-author":`true`})]}),p?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-warn/40 bg-warn/10 py-1 pr-1 pl-2.5 text-xs text-fg`,role:`alertdialog`,"aria-label":`Discard this comment?`,"data-sw-composer-discard":`true`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 font-medium`,children:`Discard this comment?`}),(0,Y.jsx)(a,{size:`xs`,variant:`danger`,onClick:p.onDiscard,autoFocus:!0,"data-sw-composer-discard-yes":`true`,children:`Discard`}),(0,Y.jsx)(a,{size:`xs`,variant:`secondary`,onClick:p.onKeep,"data-sw-composer-discard-keep":`true`,children:`Keep`})]}):c?null:(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 overflow-hidden text-[11px] whitespace-nowrap text-faint`,"data-sw-composer-keys":`true`,children:[(0,Y.jsx)(s,{children:`Enter`}),` posts, `,(0,Y.jsx)(s,{children:`Shift`}),`+`,(0,Y.jsx)(s,{children:`Enter`}),` new line, `,(0,Y.jsx)(s,{children:`Esc`}),` cancels`]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[11px] text-faint`,children:h.length>1800?(0,Y.jsxs)(`span`,{className:`tabular`,children:[h.length,`/`,Qw]}):l&&u?`As ${u}`:null}),(0,Y.jsx)(a,{size:c?`touch`:`xs`,variant:`ghost`,onClick:r,disabled:i,"data-sw-composer-cancel":`true`,children:`Cancel`}),(0,Y.jsx)(a,{size:c?`touch`:`xs`,variant:`default`,type:`submit`,disabled:i||w||!h.trim()&&!b&&!x?.images.length,"data-sw-save-comment":`true`,children:i?x?.images.length?`Uploading...`:`Posting...`:`Post`})]})]})}function tT({before:e,after:t,label:n=`Before and after`,beforeLabel:r=`Before`,afterLabel:i=`After`,start:a=50,className:o,children:s,...c}){let[l,u]=(0,J.useState)(a),d=(0,J.useRef)(null),f=(0,J.useRef)(!1),p=e=>{let t=d.current?.getBoundingClientRect();t?.width&&u(Math.min(100,Math.max(0,(e-t.left)/t.width*100)))};return(0,Y.jsxs)(`div`,{ref:d,className:O(`relative touch-pan-y overflow-hidden select-none`,o),onPointerDown:e=>{e.button===0&&(f.current=!0,e.currentTarget.setPointerCapture?.(e.pointerId),p(e.clientX))},onPointerMove:e=>f.current&&p(e.clientX),onPointerUp:()=>{f.current=!1},onPointerCancel:()=>{f.current=!1},"data-sw-compare-slider":Math.round(l),...c,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 z-[1]`,style:{clipPath:`inset(0 ${100-l}% 0 0)`},children:e}),t,(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[2]`,children:s}),(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-1.5 left-1.5 z-[3] rounded bg-black/60 px-1.5 text-[10px] leading-4 font-medium text-white`,children:r}),(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-1.5 right-1.5 z-[3] rounded bg-black/60 px-1.5 text-[10px] leading-4 font-medium text-white`,children:i}),(0,Y.jsxs)(`div`,{role:`slider`,tabIndex:0,"aria-label":n,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l),"aria-valuetext":`${Math.round(l)}% ${r.toLowerCase()}`,onKeyDown:e=>{let t=e.shiftKey?20:5;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)u(e=>Math.max(0,e-t));else if(e.key===`ArrowRight`||e.key===`ArrowUp`)u(e=>Math.min(100,e+t));else if(e.key===`Home`)u(0);else if(e.key===`End`)u(100);else return;e.preventDefault(),e.stopPropagation()},className:`group absolute inset-y-0 z-[3] w-8 -translate-x-1/2 cursor-ew-resize outline-none`,style:{left:`${l}%`},"data-sw-compare-handle":`true`,children:[(0,Y.jsx)(`span`,{className:`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-white shadow-[0_0_0_1px_rgb(0_0_0/0.25)]`}),(0,Y.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex h-7 w-7 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-line bg-surface text-muted shadow-pop group-focus-visible:ring-2 group-focus-visible:ring-accent`,children:(0,Y.jsx)(H_,{size:13,"aria-hidden":`true`})})]})]})}function nT({url:e,native:t,crop:n,label:r,comment:i,onImageError:a,shapes:o=null}){let s=n||{left:0,top:0,width:t.width,height:t.height};if(!e)return(0,Y.jsx)(`div`,{className:`h-full w-full bg-surface-2`});let c=o?.length?(0,Y.jsx)(eS,{shapes:o,width:t.width,height:t.height,crop:n,className:`z-[1]`,"data-sw-before-drawing":`true`}):null;if(c&&!n)return(0,Y.jsxs)(`div`,{className:`relative w-full`,children:[(0,Y.jsx)(nT,{url:e,native:t,crop:null,label:r,comment:i,onImageError:a}),c]});let l=(0,Y.jsx)(`img`,{src:e,alt:`${r}: ${i.viewport} capture`,draggable:!1,onError:a,className:O(`block max-w-none select-none`,n?`absolute`:`w-full`),style:n?{width:`${t.width/s.width*100}%`,left:`${-s.left/s.width*100}%`,top:`${-s.top/s.height*100}%`}:void 0});return c?(0,Y.jsxs)(Y.Fragment,{children:[l,c]}):l}function rT({native:e,crop:t,comment:n}){if(!t)return null;let r=(e.width*n.x/100-t.left)/t.width,i=(e.height*n.y/100-t.top)/t.height;return r<0||r>1||i<0||i>1?null:(0,Y.jsx)(`span`,{className:`pointer-events-none absolute h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-accent shadow-pop`,style:{left:`${r*100}%`,top:`${i*100}%`},"aria-hidden":`true`})}function iT({url:e,native:t,crop:n,comment:r,label:i,onImageError:a,shapes:o=null}){let s=n||{left:0,top:0,width:t.width,height:t.height};return(0,Y.jsxs)(`figure`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`figcaption`,{className:`mb-1 text-[11px] font-medium tracking-wide text-faint uppercase`,children:i}),(0,Y.jsxs)(`div`,{className:O(`relative w-full overflow-hidden rounded-md border border-line bg-surface-2`,!n&&`max-h-80 overflow-y-auto`),style:n?{aspectRatio:`${s.width} / ${s.height}`}:void 0,children:[(0,Y.jsx)(nT,{url:e,native:t,crop:n,label:i,comment:r,onImageError:a,shapes:o}),(0,Y.jsx)(rT,{native:t,crop:n,comment:r})]})]})}var aT=[{id:`near`,label:`Near the pin`},{id:`whole`,label:`Whole frame`}],oT=[{id:`near`,label:`Near the drawing`},{id:`whole`,label:`Whole frame`}],sT=[{id:`slider`,label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(H_,{size:13,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Slider`})]})},{id:`split`,label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Eh,{size:13,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Side by side`})]})}],cT=[{id:`before`,label:`Before`},{id:`after`,label:`After`}];function lT({comment:e,pair:t,native:n,urlFor:r,touch:i,onImageError:a}){let[o,s]=(0,J.useState)(`near`),[c,l]=(0,J.useState)(`slider`),u=t?.drawn||null,[d,f]=(0,J.useState)(u?`before`:`after`),p=(0,J.useRef)(null);if(!t||!n||!t.before&&!t.after)return null;if(!t.after||!t.before)return(0,Y.jsx)(`p`,{className:`mt-2 rounded-md bg-surface-2 px-2 py-1.5 text-xs text-muted`,"data-sw-before-after":t.reason,children:t.reason===`not-recaptured`?`Not recaptured since this comment. Recapture the page to see before and after.`:`The capture this comment was made on is no longer kept, so there is no before to show.`});let m=u?Fx({shapes:u}):null,h=m?[(m.x+m.width/2)*100,(m.y+m.height/2)*100]:[e.x,e.y],g=o===`near`?Cv(n,h[0],h[1]):null,_=g||{left:0,top:0,width:n.width,height:n.height},v={native:n,crop:g,comment:e,onImageError:a},y=u?(0,Y.jsx)(`p`,{className:`text-xs text-muted`,"data-sw-drawn-previous":`true`,children:`The drawing shows on Before, over the page as it was.`}):null,b=(0,Y.jsx)(Xe,{label:`Zoom`,options:m?oT:aT,value:o,onChange:s,large:i,className:i?`flex-1`:``});if(!i)return(0,Y.jsxs)(`div`,{className:`mt-2.5 space-y-2`,"data-sw-before-after":`ready`,children:[y,(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,(0,Y.jsx)(`span`,{className:`flex-1`}),(0,Y.jsx)(Xe,{label:`Layout`,options:sT,value:c,onChange:l,itemClassName:`px-2`})]}),c===`slider`?(0,Y.jsx)(`div`,{className:O(`rounded-md border border-line bg-surface-2`,!g&&`max-h-80 overflow-y-auto`),children:(0,Y.jsx)(tT,{start:u?85:50,className:`w-full`,style:g?{aspectRatio:`${_.width} / ${_.height}`}:void 0,label:`Before and after comment ${e.id}`,before:(0,Y.jsx)(`div`,{className:`relative h-full w-full bg-surface-2`,children:(0,Y.jsx)(nT,{url:r(t.before),label:`Before`,...v,shapes:u})}),after:(0,Y.jsx)(`div`,{className:O(`relative w-full bg-surface-2`,g&&`h-full`),children:(0,Y.jsx)(nT,{url:r(t.after),label:`After`,...v})}),children:(0,Y.jsx)(rT,{native:n,crop:g,comment:e})},u?`drawn`:`plain`)}):(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(iT,{url:r(t.before),label:`Before`,...v,shapes:u}),(0,Y.jsx)(iT,{url:r(t.after),label:`After`,...v})]})]});let x=(0,Y.jsx)(iT,{url:r(t.before),label:`Before`,...v,shapes:u}),S=(0,Y.jsx)(iT,{url:r(t.after),label:`After`,...v});return(0,Y.jsxs)(Ee,{value:d,onValueChange:f,className:`mt-2.5 space-y-2`,"data-sw-before-after":`ready`,children:[y,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Re,{"aria-label":`Show`,className:`flex-1`,children:cT.map(e=>(0,Y.jsx)(qe,{value:e.id,large:!0,children:e.label},e.id))}),b]}),(0,Y.jsxs)(`div`,{onTouchStart:e=>{p.current=e.touches[0]?.clientX??null},onTouchEnd:e=>{let t=p.current,n=e.changedTouches[0]?.clientX;p.current=null,t===null||n===void 0||Math.abs(n-t)<40||f(n<t?`after`:`before`)},"data-sw-before-after-side":d,children:[(0,Y.jsx)(le,{value:`before`,children:x}),(0,Y.jsx)(le,{value:`after`,children:S})]})]})}var uT=new Map,dT=(e,t)=>`${e||``}#${t}`,fT={body:``,shapes:[],images:[]},pT={get:e=>uT.get(e)||fT,save(e,t){let n={...uT.get(e)||fT,...t};n.body||n.shapes.length||n.images.length?uT.set(e,n):uT.delete(e)},clear:e=>uT.delete(e)};function mT(e,t){return t?e.by.some(e=>t.handle&&e.handle?e.handle===t.handle:String(e.name).toLowerCase()===String(t.name||`anonymous`).toLowerCase()):!1}function hT(e,t){let n=xe[e.emoji]||e.emoji;if(!e.by.length)return`${e.count} ${e.count===1?`person`:`people`} reacted with ${n}`;let r=e.by.map(e=>mT({by:[e]},t)?`You`:e.name);return`${r.length>1?`${r.slice(0,-1).join(`, `)} and ${r.at(-1)}`:r[0]} reacted with ${n}`}function gT({reactions:e=[],canReact:t,me:n,onToggle:r,touch:i}){let[a,o]=(0,J.useState)(!1);if(!e.length&&!t)return null;let s=O(`inline-flex items-center gap-1 rounded-full border px-1.5 text-xs leading-none tabular`,i?`h-11 min-w-11 justify-center`:`h-6`);return(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,"data-sw-reactions":`true`,children:[e.map(e=>{let i=mT(e,n),a=hT(e,n);return(0,Y.jsx)(_,{content:a,children:t?(0,Y.jsxs)(`button`,{type:`button`,className:O(s,`transition-colors focus-visible:outline-2 focus-visible:outline-accent`,i?`border-accent/35 bg-accent/5 text-fg hover:border-accent/60`:`border-line bg-surface-2 text-fg hover:border-faint`),"aria-pressed":i,"aria-label":`${a}. ${i?`Remove your reaction`:`Add yours`}`,onClick:()=>r(e.emoji),"data-sw-reaction":e.emoji,"data-sw-reaction-mine":i?`true`:`false`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:e.emoji}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`font-medium`,children:e.count})]}):(0,Y.jsxs)(`span`,{className:O(s,`border-line bg-surface-2 text-fg`),"aria-label":a,role:`img`,"data-sw-reaction":e.emoji,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:e.emoji}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`font-medium`,children:e.count})]})},e.emoji)}),t?(0,Y.jsxs)(lt,{open:a,onOpenChange:o,children:[(0,Y.jsx)(_,{content:`Add a reaction`,children:(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,className:O(s,i?`px-0`:`w-6 justify-center px-0`,`border-transparent text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,!i&&!e.length&&`opacity-0 group-focus-within/message:opacity-100 group-hover/message:opacity-100`,a&&`opacity-100`),"aria-label":`Add a reaction`,"data-sw-reaction-add":`true`,children:(0,Y.jsx)(Bh,{size:15,"aria-hidden":`true`})})})}),(0,Y.jsx)(ot,{side:i?`bottom`:`right`,align:`start`,sideOffset:6,collisionPadding:12,className:`flex gap-0.5 p-1`,"aria-label":`Reactions`,"data-sw-reaction-picker":`true`,children:ve.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:O(`inline-flex items-center justify-center rounded-md text-lg hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,i?`h-11 w-11`:`h-8 w-8`),"aria-label":`React with ${xe[e]}`,onClick:()=>{o(!1),r(e)},"data-sw-reaction-pick":e,children:e},e))})]}):null]})}function _T({label:e,state:t=`ready`,size:n=`md`,icon:r=null,tint:i=null,logo:a=null,className:o}){return(0,Y.jsxs)(`span`,{className:O(`relative inline-flex shrink-0`,o),"aria-hidden":`true`,children:[(0,Y.jsx)(ge,{label:e,icon:r,tint:i,logo:a,size:n===`sm`?`sm`:`md`}),(0,Y.jsx)(`span`,{className:O(`absolute -right-0.5 -bottom-0.5 rounded-full ring-2 ring-surface`,n===`sm`?`h-1.5 w-1.5`:`h-2 w-2`,Fe[t]||Fe.ready)})]})}function vT({text:e}){return String(e).split(/(`[^`]+`)/).map((e,t)=>e.startsWith("`")&&e.endsWith("`")?(0,Y.jsx)(`code`,{className:`font-mono text-[10.5px] text-fg`,children:e.slice(1,-1)},t):e)}function yT({options:e,value:t=null,onChoose:n,onConnect:i=null,settingsHref:a=null,disabledReason:o=null,heading:s=null,align:c=`start`,touch:u=!1,children:d,...f}){let m=(0,Y.jsx)(T,{asChild:!0,"aria-disabled":o?`true`:void 0,onPointerDown:o?e=>e.preventDefault():void 0,onKeyDown:o?e=>[`Enter`,` `,`ArrowDown`,`ArrowUp`].includes(e.key)&&e.preventDefault():void 0,children:d});return(0,Y.jsxs)(je,{modal:!1,children:[o?(0,Y.jsx)(_,{content:o,children:m}):m,(0,Y.jsxs)(r,{align:c,className:O(`w-[min(20rem,calc(100vw-1.5rem))]`,u&&`p-1.5`),"data-sw-agent-menu":`true`,...f,children:[s?(0,Y.jsx)(k,{className:`normal-case tracking-normal`,children:s}):null,(0,Y.jsx)(ee,{value:t??``,onValueChange:e=>n?.(e),children:e.map(e=>(0,Y.jsxs)(p,{value:e.id,disabled:!e.configured,textValue:e.label,className:`h-auto min-h-11 items-start py-2 lg:h-auto lg:min-h-11`,"aria-label":`${e.label}${e.isDefault?`, default`:``}, ${l(e)}`,"data-sw-agent-option":e.id,"data-sw-agent-state":e.state,children:[(0,Y.jsx)(_T,{label:e.label,state:e.state,icon:e.icon,tint:e.tint,logo:e.logo,className:`mt-0.5`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.isDefault?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-line px-1.5 text-[10px] leading-4 font-medium text-muted`,"data-sw-agent-default":`true`,children:`Default`}):null]}),(0,Y.jsx)(`span`,{className:O(`line-clamp-2 text-[11.5px] leading-4 font-normal`,e.state===`login`?`text-fg`:e.state===`not-responding`?`text-bad`:`text-muted`),children:(0,Y.jsx)(vT,{text:l(e)})})]})]},e.id))}),i||a?(0,Y.jsx)(y,{}):null,i?(0,Y.jsxs)(D,{onSelect:i,"data-sw-agent-connect":`true`,children:[(0,Y.jsx)(u_,{size:14,"aria-hidden":`true`}),` Connect another agent...`]}):null,a?(0,Y.jsx)(D,{asChild:!0,children:(0,Y.jsxs)(`a`,{href:a,"data-sw-agent-settings":`true`,children:[(0,Y.jsx)(E_,{size:14,"aria-hidden":`true`}),` Agent settings`]})}):null]})]})}var bT={online:`ready`,busy:`starting`,offline:`unavailable`};function xT(e,{relative:t=A}={}){if(!e)return``;if(e.state===`busy`){let t=e.working||[],n=e.elsewhere?.working||0;if(t.length===1&&!n)return`Working on #${t[0]}`;let r=t.length+n;return r>1?`Working on ${r} comments`:`Working`}if(e.state===`online`)return`Online`;let n=e.lastSeenAt?t(e.lastSeenAt):``;return n?`Offline, last seen ${n}`:`Offline, never connected`}var ST=(e,t)=>t&&(e||[]).find(e=>e.id===t)||null;function CT(e,t={}){return[...e?.agents||[]].sort((e,t)=>Number(t.isDefault)-Number(e.isDefault)).map(e=>({id:e.id,label:e.name,icon:e.icon||null,tint:e.tint||null,logo:e.logo||null,state:e.state,mark:bT[e.state]||`unavailable`,line:e.canSend?xT(e,t):e.reason||`You cannot send work to this agent.`,isDefault:!!e.isDefault,disabled:!e.canSend,reason:e.canSend?null:e.reason||null}))}function wT(e){let t=ST(e?.agents,e?.defaultAgentId);return t?.canSend?{agentId:t.id,label:`Send to ${t.name}`}:{agentId:null,label:`Send to agent`}}function TT(e,t,n={}){if(!e?.dispatchable)return null;let r=t?.agents||[],i=r.find(t=>(t.working||[]).includes(e.id))||null;if(i)return{kind:`working`,agent:i,text:`${i.name} is working on this`,canRelease:!1};if(e.agentStatus)return null;let a=ST(r,e.agentId);if(a&&a.state===`offline`)return{kind:`waiting`,agent:a,text:`Waiting for ${a.name} (${ET(xT(a,n))})`,canRelease:!0};if(a)return{kind:`sent`,agent:a,text:`Sent to ${a.name}. It picks this up next.`,canRelease:r.length>1};let o=r.filter(e=>e.state!==`offline`);return{kind:`any`,agent:null,text:r.length?o.length?`Sent to any agent: the first one free takes it.`:`Sent to any agent. None is online right now, so it waits until one is.`:`Sent to any agent. No agent is connected to this project yet, so it waits until one is.`,canRelease:!1}}var ET=e=>e.charAt(0).toLowerCase()+e.slice(1),DT=`No agent is connected: comments wait until one is`,OT=`No agent is online: comments wait until one is`;function kT(e){let t=e?.agents||[];if(!t.length)return DT;if(!t.filter(e=>e.state!==`offline`).length)return OT;let n={online:`online`,busy:`working`,offline:`offline`},r=t.slice(0,3).map(e=>`${e.name} ${n[e.state]||e.state}`);return t.length>3?`${r.join(`, `)} and ${t.length-3} more`:r.join(`, `)}var AT=e=>e?(e.agents||[]).some(e=>e.state!==`offline`):null,jT=e=>e?.link?.connected&&e.edits?.text?e.edits.text:``;function MT(e,t=null){let n=e?.agents||[],r=[ST(n,t?.agentId),ST(n,e?.defaultAgentId),...n].filter(Boolean),i=e=>r.find(t=>e.includes(t))||null,a=n.filter(e=>e.edits?.fix?.ok===!0);if(!a.length){let e=n.filter(e=>e.link?.connected&&e.edits?.fix?.reason),t=i(e.filter(e=>e.edits.mode!==`none`))||i(e);return{agent:null,options:[],reason:t?t.edits.fix.reason:null}}let o=i(a);return{agent:o,options:a.length>1?[o,...a.filter(e=>e!==o)].map(e=>({id:e.id,label:e.name,configured:!0,state:bT[e.state]||`ready`,line:[jT(e)||xT(e),e.machine].filter(Boolean).join(` · `),isDefault:!!e.isDefault,icon:e.icon||null,tint:e.tint||null,logo:e.logo||null})):[],reason:null}}var NT=[`admin`,`owner`];function PT({comment:e,list:t,onChoose:n,touch:i,align:a=`end`,heading:o,children:s}){let c=CT(t);return(0,Y.jsxs)(je,{modal:!1,children:[(0,Y.jsx)(T,{asChild:!0,children:s}),(0,Y.jsxs)(r,{align:a,className:O(`w-[min(20rem,calc(100vw-1.5rem))]`,i&&`p-1.5`),"data-sw-send-agent-menu":e.id,children:[(0,Y.jsx)(k,{className:`tracking-normal normal-case`,children:o}),c.map(e=>(0,Y.jsxs)(D,{disabled:e.disabled,textValue:e.label,onSelect:()=>n(e.id),className:`h-auto min-h-11 items-start py-2 data-[disabled]:opacity-100 lg:h-auto lg:min-h-11`,"aria-label":`${e.label}${e.isDefault?`, default`:``}, ${e.line}`,"data-sw-send-agent-option":e.id,"data-sw-send-agent-name":e.label,"data-sw-agent-state":e.state,"data-sw-send-agent-blocked":e.disabled?`true`:void 0,children:[(0,Y.jsx)(_T,{label:e.label,state:e.mark,icon:e.icon,tint:e.tint,logo:e.logo,className:O(`mt-0.5`,e.disabled&&`opacity-50`)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:O(`truncate font-medium`,e.disabled?`text-muted`:`text-fg`),children:e.label}),e.isDefault?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-line px-1.5 text-[10px] leading-4 font-medium text-muted`,"data-sw-agent-default":`true`,children:`Default`}):null]}),(0,Y.jsx)(`span`,{className:`line-clamp-3 text-[11.5px] leading-4 font-normal text-muted`,"data-sw-send-agent-line":!0,children:e.line})]})]},e.id)),c.length?(0,Y.jsx)(y,{}):null,(0,Y.jsxs)(D,{onSelect:()=>n(null),className:`h-auto min-h-11 items-start py-2 lg:h-auto lg:min-h-11`,"data-sw-send-agent-option":`any`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-line bg-surface-2 text-muted`,children:(0,Y.jsx)(iv,{size:14,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-fg`,children:`Any agent`}),(0,Y.jsx)(`span`,{className:`block text-[11.5px] leading-4 font-normal text-muted`,children:`The first one that is free takes it.`})]})]})]})]})}function FT({comment:e,list:t=null,role:n=null,busy:r=!1,touch:i=!1,onSend:o,onRelease:s}){let c=i?`touch`:`sm`,l=NT.includes(n),u=TT(e,t),d=!!t,f=!!t?.agents?.length;if(e.needsRunApproval&&!e.dispatchable){let n=(t?.agents||[]).find(t=>t.id===e.agentId)||null;return(0,Y.jsxs)(`div`,{className:`space-y-1.5 py-2`,"data-sw-send-agent-block":e.id,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(a,{size:c,disabled:r||!l,onClick:()=>o(e),"data-sw-send-agent":e.id,children:l?`Approve agent run`:`Awaiting run approval`}),l&&f?(0,Y.jsx)(PT,{comment:e,list:t,onChoose:t=>o(e,t),touch:i,align:`start`,heading:`Approve it and send it to`,children:(0,Y.jsxs)(a,{size:c,variant:`ghost`,disabled:r,"data-sw-send-agent-choose":e.id,children:[`Choose another `,(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})]})}):null]}),d?(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-send-agent-asked":n?n.id:`any`,children:[n?`Asked for ${n.name}.`:`Asked for any agent.`,n&&!n.canSend&&l?` ${n.reason}`:``]}):null]})}if(e.dispatchable)return u?(0,Y.jsxs)(`div`,{className:`space-y-1.5 py-2`,"data-sw-send-agent-block":e.id,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-start gap-2 text-xs text-fg`,role:`status`,"data-sw-sent-agent":u.kind,children:[u.agent?(0,Y.jsx)(ge,{label:u.agent.name,icon:u.agent.icon,tint:u.agent.tint,logo:u.agent.logo,size:`sm`}):(0,Y.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[5px] border border-line bg-surface-2 text-muted`,children:(0,Y.jsx)(iv,{size:11,"aria-hidden":`true`})}),(0,Y.jsx)(`span`,{className:O(`min-w-0 pt-0.5`,u.kind===`waiting`?`text-fg`:`text-muted`),children:u.text})]}),u.kind!==`working`&&(u.canRelease||f)?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[u.canRelease&&s?(0,Y.jsx)(a,{size:c,variant:u.kind===`waiting`?`default`:`secondary`,disabled:r,onClick:()=>s(e),"data-sw-release-agent":e.id,children:`Let any agent take it`}):null,f?(0,Y.jsx)(PT,{comment:e,list:t,onChoose:t=>o(e,t),touch:i,align:`start`,heading:`Send it to`,children:(0,Y.jsxs)(a,{size:c,variant:`ghost`,disabled:r,"data-sw-send-agent-choose":e.id,children:[`Choose another `,(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})]})}):null]}):null]}):null;let p=wT(t);return!d||!f?(0,Y.jsxs)(`div`,{className:`py-2`,"data-sw-send-agent-block":e.id,children:[(0,Y.jsxs)(a,{size:c,disabled:r,onClick:()=>o(e),"data-sw-send-agent":e.id,children:[(0,Y.jsx)(w_,{size:13,"aria-hidden":`true`}),` Send to agent`]}),d?(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs text-muted`,role:`status`,"data-sw-no-agent-listening":`true`,children:`No agent is connected to this project yet: a comment sent to an agent waits until one is (shapewall watch --remote).`}):null]}):(0,Y.jsx)(`div`,{className:`py-2`,"data-sw-send-agent-block":e.id,children:(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full`,"data-sw-send-agent-split":e.id,children:[(0,Y.jsxs)(a,{size:c,className:`min-w-0 rounded-r-none pr-2.5`,disabled:r,onClick:()=>o(e,p.agentId),"data-sw-send-agent":e.id,"data-sw-send-agent-target":p.agentId||`any`,children:[(0,Y.jsx)(w_,{size:13,className:`shrink-0`,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`truncate`,children:p.label})]}),(0,Y.jsx)(PT,{comment:e,list:t,onChoose:t=>o(e,t),touch:i,heading:`Send this comment to`,children:(0,Y.jsx)(a,{size:c,className:`-ml-px rounded-l-none px-2`,disabled:r,"aria-label":`Send to another agent`,"data-sw-send-agent-choose":e.id,children:(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})})})]})})}var IT=e=>`comment-${e}`,LT=/^chat-[a-z0-9]{16}$/,RT=e=>LT.test(String(e||``)),zT=e=>e===`board`?`board`:String(e||``).startsWith(`comment-`)?`comment`:`chat`;function BT(){let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),`chat-${[...e].map(e=>`abcdefghijklmnopqrstuvwxyz0123456789`[e%36]).join(``)}`}var VT=e=>e===`board`?`board`:RT(e)?e:`c${String(e).slice(8)}`;function HT(e){return e===`board`?`board`:/^c[1-9]\d{0,8}$/.test(e||``)?IT(e.slice(1)):RT(e)?e:null}var UT=new Map,WT=e=>`shapewall.lastChat.${e||``}`;function GT(e,t){if(HT(t)){UT.set(e||``,t);try{globalThis.sessionStorage?.setItem(WT(e),t)}catch{}}}function KT(e){let t=UT.get(e||``);if(!t)try{t=globalThis.sessionStorage?.getItem(WT(e))||``}catch{t=``}return HT(t)?t:`board`}var qT=864e5,JT=e=>{let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()};function YT(e,{now:t=Date.now(),timeOf:n=e=>new Date(e).getTime()}={}){let r=JT(t),i=[{id:`today`,label:`Today`,items:[]},{id:`yesterday`,label:`Yesterday`,items:[]},{id:`earlier`,label:`Earlier`,items:[]}];for(let t of e){let e=n(t.updatedAt);i[Number.isFinite(e)&&e>=r?0:Number.isFinite(e)&&e>=r-qT?1:2].items.push(t)}return i.filter(e=>e.items.length)}function XT(e,t=null){let n=zT(e);return n===`comment`?Me(t).replace(/\s+/g,` `).trim().slice(0,60)||`Comment chat`:n===`board`?`Board chat`:`New chat`}var ZT=e=>String(e||``).split(`
|
|
25
|
+
`))>=0;){let e=i.slice(0,o);i=i.slice(o+2);let n=/^event: (.*)$/m.exec(e)?.[1],r=/^data: (.*)$/m.exec(e)?.[1];if(!n||r===void 0)continue;let a;try{a=JSON.parse(r)}catch{continue}t?.(n,a,Number(/^id: (\d+)$/m.exec(e)?.[1])||null)}}}var xw=(e,t,n,r,i=void 0)=>S.post(`${fw(e,t)}/permissions/${dw(n)}`,{optionId:r,...i?{hash:i}:{}}),Sw=(e,t)=>S.post(`${fw(e,t)}/stop`,{}),Cw=(e,t,n)=>S.post(`${fw(e,t)}/messages/${dw(n)}/undo`,{}),ww=(e,t)=>S.post(`/api/agent/branches/${dw(e)}/${t}`,{}),Tw={"+":`bg-ok/10 text-fg`,"-":`bg-bad/10 text-fg`,"@":`text-faint`,"-file":`font-medium text-fg`},Ew=/… \[line cut: \d+ characters in all\]$/;function Dw({line:e}){let t=e.match(Ew);return t?(0,Y.jsxs)(Y.Fragment,{children:[e.slice(0,t.index),(0,Y.jsx)(`span`,{className:`text-warn italic`,"data-sw-chat-diff-cut":`true`,children:t[0]})]}):e||` `}function Ow({diff:e}){let[t,n]=(0,J.useState)(!1);if(typeof e?.preview!=`string`)return null;let r=t&&e.full?e.full:e.preview,i=r?r.split(`
|
|
26
|
+
`):[];return(0,Y.jsxs)(`div`,{className:`mt-1.5 space-y-1`,"data-sw-chat-diff":e.path||`diff`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] text-muted`,children:[(0,Y.jsx)(_,{content:e.path||null,children:(0,Y.jsx)(`span`,{className:O(`min-w-0 font-mono`,e.outside?`break-all`:`truncate`),children:e.path||`Changes`})}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-ok`,children:[`+`,e.added]}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-bad`,children:[`-`,e.removed]}),e.created?(0,Y.jsx)(`span`,{className:`shrink-0`,children:`(new file)`}):null]}),e.outside?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warn`,"data-sw-chat-diff-outside":`true`,children:[(0,Y.jsx)(nv,{size:12,className:`shrink-0`,"aria-hidden":`true`}),`Outside the project: check the whole path above.`]}):null,i.length?(0,Y.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-md border border-line bg-sunken py-1 font-mono text-[11px] leading-4`,"data-sw-chat-diff-lines":i.length,children:i.map((e,t)=>{let n=e.startsWith(`--- `)?Tw[`-file`]:Tw[e[0]];return(0,Y.jsx)(`div`,{className:O(`px-2 whitespace-pre-wrap break-all`,n||`text-muted`),children:(0,Y.jsx)(Dw,{line:e})},t)})}):(0,Y.jsx)(`p`,{className:`text-[11px] text-faint`,children:`No change to the text.`}),e.full?(0,Y.jsx)(a,{variant:`ghost`,size:`xs`,className:`-ml-2 font-normal text-muted`,"aria-expanded":t,onClick:()=>n(e=>!e),"data-sw-chat-diff-expand":`true`,children:t?`Show less`:`Show the whole diff`}):null,t&&e.truncated?(0,Y.jsx)(`p`,{className:`text-[11px] text-faint`,children:`The diff is cut here: it is too long to show in full.`}):null]})}function kw({card:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md border border-warn/40 bg-warn/10 px-2 py-1.5 text-xs text-fg`,"data-sw-chat-card":`note`,children:[(0,Y.jsx)(gg,{size:13,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]})}var Aw=encodeURIComponent,jw=e=>`api/agent/boards/${Aw(e)}/batch`,Mw=new Set([`running`,`waiting`]),Nw=e=>!!(e&&Mw.has(e.state)),Pw=e=>e.status===`open`&&![`queued`,`working`,`branch-ready`].includes(e.agentStatus)&&!e.authorGuest;function Fw({boardId:e,enabled:t,onProgress:n=null}){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)([]),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(!1),p=(0,J.useRef)(n);p.current=n;let m=(0,J.useRef)(null),h=(0,J.useCallback)(async()=>{if(t)try{let t=await S.get(jw(e));i(t);let n=t?.batch?.updatedAt||null;n!==m.current&&(m.current=n,t?.batch&&p.current?.())}catch{i(null)}},[e,t]);(0,J.useEffect)(()=>{h()},[h]),lw(e,h,t),uw(h,t);let g=Nw(r?.batch);(0,J.useEffect)(()=>{if(!g)return;let e=window.setInterval(h,3e3);return()=>window.clearInterval(e)},[g,h]);let _=r?.settings||null,v=!!(t&&_?.enabled);return(0,J.useEffect)(()=>{v||(o(!1),c([]))},[v]),{offered:v,max:_?.max||5,batch:t&&r?.batch||null,running:g,selecting:a,setSelecting:e=>{o(e),e||c([])},selected:s,setSelected:c,toggle:e=>c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),start:async t=>{f(!0),u(null);try{let n=await S.post(jw(e),{commentIds:t});return i(e=>({...e||{},batch:n.batch})),o(!1),c([]),p.current?.(),!0}catch(e){return u(e.message||`The batch did not start.`),!1}finally{f(!1)}},cancel:async()=>{u(null);try{let t=await S.post(`${jw(e)}/cancel`,{});i(e=>({...e||{},batch:t.batch}))}catch(e){u(e.message||`Not cancelled.`),h()}},dismiss:async()=>{try{await S.delete(jw(e)),i(e=>({...e||{},batch:null}))}catch{h()}},error:l,setError:u,busy:d,refresh:h}}function Iw({checked:e,onChange:t,label:n,disabled:r=!1,touch:i=!1,...a}){return(0,Y.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":n,disabled:r,onClick:()=>t(!e),className:O(`inline-flex shrink-0 items-center justify-center rounded-md focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent disabled:opacity-40`,i?`size-11`:`size-7`),...a,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`inline-flex size-4.5 items-center justify-center rounded border transition-colors`,e?`border-accent bg-accent text-accent-fg`:`border-line-strong bg-surface`),children:e?(0,Y.jsx)(st,{size:12,strokeWidth:3}):null})})}var Lw=e=>String(e||``).split(`
|
|
27
|
+
`).map(e=>e.trim()).find(Boolean)||`No text`;function Rw({open:e,onClose:t,ids:n,comments:r,max:i,agentName:o,targetTitle:s,onStart:c,busy:l,error:u,touch:d}){let f=(0,J.useMemo)(()=>new Map(r.map(e=>[e.id,e])),[r]),p=n.slice(0,i),m=n.length-p.length;return(0,Y.jsx)(N,{open:e,onClose:t,title:`Fix ${p.length} ${p.length===1?`comment`:`comments`} with ${o}`,description:`One at a time, in this order. Each is a normal fix you can review and undo.`,wrapDescription:!0,size:`md`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{variant:`secondary`,size:d?`touch`:`sm`,onClick:t,children:`Cancel`}),(0,Y.jsxs)(a,{variant:`default`,size:d?`touch`:`sm`,disabled:l||!p.length,onClick:()=>c(n),"data-sw-batch-start":`true`,children:[l?(0,Y.jsx)(Ag,{size:14,className:`motion-safe:animate-spin`,"aria-hidden":`true`}):(0,Y.jsx)(H_,{size:14,"aria-hidden":`true`}),` `,`Start`]})]}),children:(0,Y.jsxs)(`div`,{className:`space-y-3`,"data-sw-batch-confirm":p.length,children:[m>0?(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-warn/40 bg-warn/10 px-3 py-2 text-xs text-fg`,role:`note`,"data-sw-batch-over":m,children:[(0,Y.jsx)(nv,{size:14,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[`You chose `,n.length,`. Only the first `,i,` will run; the batch limit is set in Agents.`]})]}):null,(0,Y.jsx)(`ol`,{className:`max-h-72 divide-y divide-line overflow-y-auto rounded-md border border-line`,children:p.map((e,t)=>{let n=f.get(e);return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2.5 px-3 py-2 text-ui`,"data-sw-batch-confirm-item":e,children:[(0,Y.jsxs)(`span`,{className:`w-5 shrink-0 text-right text-xs text-faint tabular-nums`,children:[t+1,`.`]}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`block truncate text-fg`,"data-sw-batch-confirm-title":e,children:[(0,Y.jsxs)(`span`,{className:`text-muted tabular-nums`,children:[`#`,e]}),` `,Lw(Me(n))]}),(0,Y.jsx)(`span`,{className:`block truncate text-xs text-muted`,children:n?s(n.pageId):`comment`})]})]},e)})}),u?(0,Y.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-batch-error":`true`,children:u}):null]})})}var zw={waiting:{label:`Waiting`,tone:`neutral`,icon:Sh},running:{label:`Running`,tone:`accent`,icon:Ag},fixed:{label:`Fixed`,tone:`ok`,icon:st},failed:{label:`Failed`,tone:`bad`,icon:nv},skipped:{label:`Skipped`,tone:`neutral`,icon:bh}};function Bw(e){let t=e.items.length,n=e.items.filter(e=>![`waiting`,`running`].includes(e.state)).length;if(e.state===`waiting`)return`Waiting for your OK on #${e.waiting?.commentId}`;if(e.state===`running`)return`Fixing ${Math.min(n+1,t)} of ${t}`;let{fixed:r=0,failed:i=0,skipped:a=0}=e.counts||{},o=[`${r} fixed`,i?`${i} failed`:null,a?`${a} skipped`:null].filter(Boolean).join(`, `);return e.state===`cancelled`?`Cancelled: ${o}`:e.state===`stopped`?e.stopReason===`failures`?`Stopped after 2 failures in a row: ${o}`:`Stopped: ${o}`:`Done: ${o}`}function Vw({batch:e,boardId:t,comments:n=[],onOpenThread:r,onCancel:i,onDismiss:o,touch:s=!1,compact:c=!1,className:l}){let[u,d]=(0,J.useState)(!c),f=(0,J.useMemo)(()=>new Map((n||[]).map(e=>[e.id,Me(e)])),[n]),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null);if(!e)return null;let _=Nw(e),v=s?`touch`:`xs`,y=e.items.length,b=e.items.filter(e=>![`waiting`,`running`].includes(e.state)).length,x=async n=>{if(e.waiting){m(n??`deny`),g(null);try{await xw(t,e.waiting.threadId,e.waiting.card.id,n)}catch(e){g(e.message)}finally{m(null)}}},S=(e.waiting?.card?.options||[]).filter(e=>e&&e.optionId);return(0,Y.jsxs)(`section`,{className:O(`space-y-2`,l),"aria-label":`Batch of fixes`,"data-sw-batch":e.state,"data-sw-batch-compact":c?`true`:void 0,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[_?e.state===`waiting`?(0,Y.jsx)(R_,{size:15,className:`shrink-0 text-warn`,"aria-hidden":`true`}):(0,Y.jsx)(Ag,{size:15,className:`shrink-0 text-accent motion-safe:animate-spin`,"aria-hidden":`true`}):(0,Y.jsx)(vg,{size:15,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-ui font-semibold text-fg`,role:`status`,"data-sw-batch-headline":`true`,children:Bw(e)}),c?(0,Y.jsx)(a,{variant:`ghost`,size:v,className:`text-fg`,onClick:()=>d(e=>!e),"aria-expanded":u,"data-sw-batch-toggle":`true`,children:u?`Hide`:`Show`}):null,_?(0,Y.jsx)(a,{variant:`secondary`,size:v,onClick:i,disabled:e.cancelling,"data-sw-batch-cancel":`true`,children:`Cancel`}):o?(0,Y.jsx)(a,{variant:`ghost`,size:s?`icon`:`icon-xs`,onClick:o,"aria-label":`Close the summary`,"data-sw-batch-dismiss":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})}):null]}),(0,Y.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-2`,role:`progressbar`,"aria-label":`Fixes finished`,"aria-valuemin":0,"aria-valuemax":y,"aria-valuenow":b,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-(--motion-base)`,style:{width:`${b/Math.max(1,y)*100}%`}})}),e.state===`waiting`&&e.waiting?(0,Y.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-warn/40 bg-warn/10 px-2.5 py-2`,"data-sw-batch-waiting":e.waiting.commentId,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-fg`,children:[`The agent asks before it goes on: `,(0,Y.jsx)(`span`,{className:`font-medium`,children:e.waiting.card.label||`an action`}),`. The batch waits for your answer.`]}),e.waiting.card.detail?(0,Y.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded bg-surface px-2 py-1.5 font-mono text-[11px] whitespace-pre-wrap text-fg`,"data-sw-batch-waiting-detail":`true`,children:e.waiting.card.detail}):null,e.waiting.card.diff?(0,Y.jsx)(Ow,{diff:e.waiting.card.diff}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[S.map(e=>(0,Y.jsx)(a,{size:v,variant:/reject|deny/i.test(e.kind||``)?`secondary`:`default`,disabled:!!p,onClick:()=>x(e.optionId),"data-sw-batch-answer":e.optionId,children:e.name||e.optionId},e.optionId)),S.length?null:(0,Y.jsx)(a,{size:v,variant:`secondary`,onClick:()=>r?.(e.waiting.commentId),children:`Review in the chat`})]}),h?(0,Y.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,children:h}):null]}):null,u?(0,Y.jsx)(`ol`,{className:`divide-y divide-line rounded-md border border-line bg-surface`,"data-sw-batch-items":y,children:e.items.map(e=>{let t=zw[e.state]||zw.waiting,n=t.icon;return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2 py-1`,"data-sw-batch-item":e.commentId,"data-sw-batch-item-state":e.state,children:[(0,Y.jsxs)(a,{variant:`link`,size:v,className:`shrink-0 px-1 shadow-none tabular-nums`,onClick:()=>r?.(e.commentId),"aria-label":`Open comment #${e.commentId}`,"data-sw-batch-open":e.commentId,children:[`#`,e.commentId]}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,"data-sw-batch-item-title":e.commentId,children:[f.has(e.commentId)?(0,Y.jsx)(`span`,{className:`text-fg`,children:Lw(f.get(e.commentId))}):null,e.message?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[f.has(e.commentId)?` · `:``,e.message]}):null]}),(0,Y.jsxs)(Qe,{tone:t.tone,className:`shrink-0`,children:[(0,Y.jsx)(n,{size:10,className:e.state===`running`?`motion-safe:animate-spin`:void 0,"aria-hidden":`true`}),` `,t.label]})]},e.commentId)})}):null,!_&&e.requested>y?(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[e.requested-y,` more `,e.requested-y===1?`was`:`were`,` chosen but not run (the limit is `,e.max,`).`]}):null]})}var Hw=`__any`,Uw=[{id:`open`,label:`Open`},{id:`resolved`,label:`Resolved`},{id:`all`,label:`All`}];function Ww(e){let t=[...e.reactions||[],...(e.replies||[]).flatMap(e=>e.reactions||[])],n=new Map;for(let e of t)n.set(e.emoji,(n.get(e.emoji)||0)+e.count);return[...n.entries()].slice(0,3)}function Gw({comment:e}){let t=BC(e.id);return e.status===`resolved`?(0,Y.jsxs)(Qe,{tone:`ok`,"data-sw-comment-state":`resolved`,children:[(0,Y.jsx)(st,{size:10,"aria-hidden":`true`}),` Resolved`]}):t?.state===`working`||t?.state===`waiting`?(0,Y.jsxs)(Qe,{tone:t.state===`waiting`?`warn`:`accent`,"data-sw-agent-live":t.state,children:[(0,Y.jsx)(Ag,{size:10,className:`motion-safe:animate-spin`,"aria-hidden":`true`}),t.state===`waiting`?`Needs your OK`:`Agent working`]}):e.agentStatus?(0,Y.jsx)(Db,{status:e.agentStatus,at:e.agentStatusAt}):(0,Y.jsx)(Ob,{comment:e})}function Kw({comment:e,title:t,selected:n,unread:r,touch:i,onFocus:a,onHover:o,pick:s=null}){let c=ux(t=>t.hoveredId===e.id),l=Nb(e),u=e.replies?.length||0,d=Ww(e),f=[e,...e.replies||[]],p=f.reduce((e,t)=>e+(t.images?.length||0),0),m=f.some(e=>e.drawing?.shapes?.length),h=Bv(e.viewport);return(0,Y.jsxs)(`li`,{className:O(`relative`,n?`bg-accent/10 shadow-[inset_3px_0_0_var(--accent)]`:c?`bg-surface-2`:``,e.status===`resolved`&&!n&&`opacity-80`,s&&`flex items-start`),"data-sw-batch-row":s?e.id:void 0,children:[s?(0,Y.jsx)(`span`,{className:O(`flex shrink-0 items-center`,i?`pt-1.5 pl-1`:`pt-3 pl-1.5`),children:(0,Y.jsx)(Iw,{checked:s.checked,onChange:s.onChange,disabled:s.disabled,touch:i,label:`Select comment #${e.id}`,"data-sw-batch-select":e.id})}):null,(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e),onMouseEnter:o?()=>o(e.id):void 0,onMouseLeave:o?()=>o(null):void 0,onFocus:o?()=>o(e.id):void 0,onBlur:o?()=>o(null):void 0,"aria-current":n?`true`:void 0,className:O(`sw-gutter-pad flex w-full gap-2.5 px-3 py-3 text-left transition-colors hover:bg-surface-2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,i&&`min-h-11`,s&&`min-w-0 flex-1 pl-1.5`),"data-sw-comment":e.id,"data-sw-comment-unread":r?`true`:void 0,"data-sw-comment-selected":n?`true`:void 0,children:[(0,Y.jsx)(Mb,{...l,size:i?`lg`:`md`,className:`mt-0.5`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-ui`,children:[(0,Y.jsx)(`span`,{className:O(`min-w-0 truncate text-fg`,r?`font-bold`:`font-semibold`),children:l.name}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:A(e.createdAt)}),(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,Y.jsx)(Gw,{comment:e}),r?(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-accent`,"aria-label":`Unread`,role:`img`,"data-sw-unread-dot":`true`}):null]})]}),(0,Y.jsx)(Vb,{text:Me(e),plain:!!e.authorGuest,className:`mt-0.5 line-clamp-2 block text-ui break-words text-fg`}),(0,Y.jsxs)(`span`,{className:`mt-1.5 flex min-w-0 items-center gap-2 text-xs text-muted`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex h-5 min-w-0 items-center gap-1 rounded bg-surface-2 px-1.5 text-[11px] text-muted`,"data-sw-comment-page":`true`,children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg/70 tabular`,children:[`#`,e.id]}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Y.jsx)(h,{size:11,className:`shrink-0 text-faint`,"aria-label":e.viewport,role:`img`})]}),u?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 tabular`,"aria-label":`${u} ${u===1?`reply`:`replies`}`,children:[(0,Y.jsx)(Kg,{size:11,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:u})]}):null,p?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 tabular`,"aria-label":`${p} ${p===1?`image`:`images`}`,"data-sw-comment-images":p,children:[(0,Y.jsx)(mg,{size:11,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:p})]}):null,m?(0,Y.jsx)(`span`,{className:`inline-flex shrink-0 items-center`,"aria-label":`Has a drawing`,role:`img`,"data-sw-comment-drawn":`true`,children:(0,Y.jsx)(ch,{size:11,"aria-hidden":`true`})}):null,d.map(([e,t])=>(0,Y.jsxs)(`span`,{className:`shrink-0`,"aria-label":`${t} ${e}`,children:[e,t>1?(0,Y.jsx)(`span`,{className:`ml-0.5 tabular`,children:t}):null]},e)),e.agentStatus&&e.reopenCount>0&&e.status===`open`?(0,Y.jsx)(Ob,{comment:e}):null]}),e.orphanReason?(0,Y.jsx)(`span`,{className:`mt-1 block text-xs text-muted`,children:e.orphanReason}):null,e.imported&&e.agentStatus?(0,Y.jsx)(`span`,{className:`mt-1 block text-xs text-faint`,children:`Imported history`}):null]})]})]})}function qw({comments:e,filter:t,counts:n,onFilter:r,selectedId:i=null,onFocus:o,onHover:s=null,unread:c=new Set,onMarkAllRead:l=null,canAct:u,targetTitle:d,touch:f,journeyFilter:p=null,heading:m=!0,onClose:h=null,onResetBrowserComments:g=null,people:_=[],narrow:v=null,batch:y=null}){let b=(0,J.useRef)(null);(0,J.useEffect)(()=>{i!==null&&(b.current?.querySelector(`[data-sw-comment="${i}"]`))?.scrollIntoView?.({block:`nearest`})},[i,e.length]);let x=lx();(0,J.useEffect)(()=>{if(f)return;let e=x.get().hoveredId;return x.subscribe(()=>{let{hoveredId:t}=x.get();t!==e&&(e=t,t!==null&&b.current?.querySelector(`[data-sw-comment="${t}"]`)?.scrollIntoView?.({block:`nearest`}))})},[f,x]);let S=!!(v&&(v.query||v.state||v.mention)),C=e.filter(e=>c.has(e.id)).length,w=!!y?.offered,T=w&&y.selecting,E=T?e.filter(Pw):[],D=T?y.selected.filter(e=>E.some(t=>t.id===e)):[],k=f?`touch`:`xs`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-line`,children:[m?(0,Y.jsx)(MC,{icon:Kg,title:`Comments`,onClose:h,closeLabel:`Close comments`,closeProps:{"data-sw-comments-close":`true`}}):null,(0,Y.jsx)(`div`,{className:O(`px-3 pb-2.5`,m?``:`pt-2.5`),children:(0,Y.jsx)(Xe,{label:`Show comments`,value:t,onChange:r,large:f,className:`w-full`,options:Uw.map(e=>({...e,count:e.id===`all`?n.open+n.resolved:n[e.id]}))})})]}),v?(0,Y.jsxs)(`div`,{className:`space-y-1.5 border-b border-line px-3 py-2`,"data-sw-comment-narrow":`true`,children:[(0,Y.jsx)(it,{type:`search`,icon:E_,size:f?`touch`:`xs`,value:v.query,onChange:e=>v.onQuery(e.target.value.slice(0,120)),placeholder:`Search text, people, pages, #id`,"aria-label":`Search comments`,"data-sw-comment-search":`true`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsxs)($e,{value:v.state||Hw,onValueChange:e=>v.onState(e===Hw?null:e),children:[(0,Y.jsx)(Se,{size:f?`touch`:`xs`,className:`flex-1`,"aria-label":`Comment state`,"data-sw-comment-state":`true`,children:(0,Y.jsx)(oe,{})}),(0,Y.jsxs)(_e,{children:[(0,Y.jsx)(q,{value:Hw,children:`Any state`}),(0,Y.jsx)(we,{}),Nv.map(e=>(0,Y.jsx)(q,{value:e.id,children:e.label},e.id))]})]}),(0,Y.jsxs)($e,{value:v.mention||Hw,onValueChange:e=>v.onMention(e===Hw?null:e),children:[(0,Y.jsx)(Se,{size:f?`touch`:`xs`,className:`flex-1`,"aria-label":`Mentioning`,"data-sw-comment-mention":`true`,children:(0,Y.jsx)(oe,{})}),(0,Y.jsxs)(_e,{children:[(0,Y.jsx)(q,{value:Hw,children:`Anyone mentioned`}),_.length?(0,Y.jsx)(we,{}):null,_.map(e=>(0,Y.jsxs)(q,{value:e.handle,children:[`@`,e.handle]},e.handle))]})]}),S?(0,Y.jsx)(B,{size:f?`icon`:`icon-xs`,onClick:v.onClear,label:`Clear search and filters`,"data-sw-comment-narrow-clear":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})}):null]})]}):null,g?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line bg-surface-2/60 px-3 py-2 text-xs text-muted`,"data-sw-browser-comments":`true`,children:[(0,Y.jsx)(gg,{size:13,className:`shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Demo: comments you add stay in this browser.`}),(0,Y.jsx)(a,{variant:`ghost`,size:f?`touch`:`xs`,className:`text-fg`,onClick:g,"data-sw-browser-comments-reset":`true`,children:`Reset`})]}):null,p?(0,Y.jsx)(`div`,{className:`border-b border-line px-3 py-2`,children:(0,Y.jsxs)(Ie,{variant:`pill`,size:f?`touch`:`xs`,pressed:p.on,onPressedChange:p.onToggle,"data-sw-journey-filter":p.on?`on`:`off`,children:[(0,Y.jsx)(S_,{size:12,className:`shrink-0 text-warn`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`Only `,p.name]})]})}):null,w&&t!==`resolved`?(0,Y.jsx)(`div`,{className:O(`flex flex-wrap items-center gap-1.5 border-b border-line px-3 py-1.5 text-xs text-muted`,T&&`bg-accent/5`),"data-sw-batch-bar":T?`selecting`:`off`,children:T?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-nowrap tabular-nums`,role:`status`,"data-sw-batch-count":D.length,children:[D.length,` selected`]}),(0,Y.jsxs)(a,{variant:`ghost`,size:k,className:`text-fg`,disabled:!E.length,onClick:()=>y.setSelected(E.slice(0,y.max).map(e=>e.id)),"data-sw-batch-select-all":`true`,children:[`Select all`,E.length>y.max?` (first ${y.max})`:``]}),(0,Y.jsx)(a,{variant:`ghost`,size:k,className:`text-fg`,onClick:()=>y.setSelecting(!1),"data-sw-batch-select-done":`true`,children:`Cancel`}),D.length>y.max?(0,Y.jsxs)(`p`,{className:`basis-full text-xs text-fg`,"data-sw-batch-over":`true`,children:[`Only the first `,y.max,` will run (the limit on the Agents page).`]}):null,(0,Y.jsxs)(a,{variant:`default`,size:k,className:`w-full`,disabled:!D.length||Nw(y.batch),onClick:()=>y.onConfirm(D),"data-sw-batch-fix":D.length,children:[(0,Y.jsx)(H_,{size:13,"aria-hidden":`true`}),` Fix `,D.length||``,` with `,y.agentName]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Fix several open comments in one go.`}),(0,Y.jsxs)(a,{variant:`ghost`,size:k,className:`text-fg`,disabled:Nw(y.batch),onClick:()=>y.setSelecting(!0),"data-sw-batch-select-mode":`true`,children:[(0,Y.jsx)(Og,{size:13,"aria-hidden":`true`}),` Select`]})]})}):null,w&&y.batch?(0,Y.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-line bg-surface px-3 py-2`,"data-sw-batch-strip":`true`,children:(0,Y.jsx)(Vw,{batch:y.batch,boardId:y.boardId,comments:e,compact:!0,touch:f,onOpenThread:y.onOpenThread,onCancel:y.cancel,onDismiss:y.dismiss})}):null,C&&l?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-1.5 text-xs text-muted`,"data-sw-unread-bar":`true`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[C,` with new activity`]}),(0,Y.jsxs)(a,{variant:`ghost`,size:f?`touch`:`xs`,className:`text-fg`,onClick:l,"data-sw-mark-all-read":`true`,children:[(0,Y.jsx)(gh,{size:13,"aria-hidden":`true`}),` Mark all read`]})]}):null,(0,Y.jsx)(`ul`,{ref:b,className:`min-h-0 flex-1 divide-y divide-line overflow-y-auto`,"data-sw-comment-list":`true`,children:e.length?e.map(e=>(0,Y.jsx)(Kw,{comment:e,title:d(e.pageId),selected:i===e.id,unread:c.has(e.id),touch:f,onFocus:o,onHover:s,pick:T&&e.status===`open`?{checked:D.includes(e.id),disabled:!Pw(e),onChange:()=>y.toggle(e.id)}:null},e.id)):(0,Y.jsx)(`li`,{children:S?(0,Y.jsx)(j,{icon:E_,title:`No comments match`,children:(0,Y.jsx)(a,{variant:`link`,size:f?`touch`:`xs`,className:`shadow-none`,onClick:v.onClear,children:`Clear the search and filters`})}):(0,Y.jsx)(j,{icon:Kg,title:t===`resolved`?`Nothing resolved yet`:t===`open`?`No open comments`:`No comments yet`,children:u?f?`Tap a page and then Comment, or the Comment tool at the bottom of the board, then tap the page to pin a note.`:`Click a page and press Comment, or pick the Comment tool at the bottom of the board (C), then click the page to pin a note.`:`This board is read-only.`})})})]})}function Jw({label:e,keyName:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,` `,(0,Y.jsx)(s,{children:t})]})}function Yw({route:e,step:t,pageTitle:n,onStep:r,touch:i}){let a=new Map(e.forks.map((e,t)=>[e.afterStep,{...e,index:t}])),o=i?`h-11 min-w-11`:`h-6 min-w-6`;return(0,Y.jsxs)(`ol`,{className:O(`flex max-w-full min-w-0 items-center overflow-x-auto py-1`,i?`px-0.5`:`gap-0.5`),"aria-label":`Steps`,"data-sw-journey-rail":`true`,children:[e.steps.map((e,s)=>{let c=s+1,l=a.get(c),u=c===t,d=c<t;return(0,Y.jsxs)(J.Fragment,{children:[s>0?(0,Y.jsx)(`li`,{"aria-hidden":`true`,className:O(`h-0.5 shrink-0 rounded-full`,i?`-mx-1.5 w-3`:`w-3`,c<=t?`bg-accent/60`:`bg-line`)}):null,(0,Y.jsx)(`li`,{className:`shrink-0`,children:(0,Y.jsx)(_,{content:(0,Y.jsxs)(`span`,{children:[`Step `,c,`: `,n(e.pageId),e.branch?(0,Y.jsxs)(`span`,{className:`opacity-75`,children:[` (`,e.branch,`)`]}):null]}),side:`top`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(c),className:O(`group/dot inline-flex items-center justify-center rounded-full outline-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent`,o),"aria-current":u?`step`:void 0,"aria-label":`Step ${c}: ${n(e.pageId)}${e.branch?` (${e.branch})`:``}`,"data-sw-journey-dot":c,children:(0,Y.jsx)(`span`,{className:O(`tabular inline-flex items-center justify-center rounded-full px-1 text-[11px] leading-none font-semibold`,i?`h-7 min-w-7`:`h-6 min-w-6`,u?`bg-accent text-accent-fg shadow-card ring-4 ring-accent/20`:d?`bg-accent/15 text-accent group-hover/dot:bg-accent/25`:`border border-line bg-surface text-muted group-hover/dot:border-faint group-hover/dot:text-fg`,e.branch&&!u&&`border-dashed`),"aria-hidden":`true`,children:c})})})}),l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`li`,{"aria-hidden":`true`,className:O(`h-0.5 w-2 shrink-0 rounded-full`,c<t?`bg-accent/60`:`bg-line`)}),(0,Y.jsx)(`li`,{className:`shrink-0`,children:(0,Y.jsx)(_,{content:`The journey forks here: ${l.options.map(e=>e.label).join(` or `)}`,side:`top`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(c),className:O(`inline-flex items-center gap-1 rounded-full border px-1.5 text-[11px] font-medium outline-none focus-visible:outline-2 focus-visible:outline-accent`,i?`h-11 min-w-11 justify-center`:`h-6`,c===t?`border-accent bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),"aria-label":`Fork after step ${c}: ${l.options.find(e=>e.id===l.chosen)?.label||``} taken`,"data-sw-journey-rail-fork":l.index,children:[(0,Y.jsx)(eg,{size:12,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`max-w-24 truncate`,children:l.options.find(e=>e.id===l.chosen)?.label})]})})})]}):null]},e.key||s)}),e.ended?(0,Y.jsx)(`li`,{className:`ml-1 shrink-0 text-[11px] font-medium text-faint`,"data-sw-journey-rail-end":`true`,children:`ends`}):null]})}function Xw({journey:e,route:t,step:n,pageTitle:r,onStep:i,onChoose:o,onClose:s,onEdit:c,onDelete:l,canEdit:u,busy:d,touch:f}){let[p,m]=(0,J.useState)(!1),h=t.steps.length,g=t.steps[n-1],v=t.forks.findIndex(e=>e.afterStep===n),y=v>=0?t.forks[v]:null,b=f?`touch`:`sm`,x=(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[13px] font-semibold text-fg`,children:[(0,Y.jsx)(S_,{size:14,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]});return(0,Y.jsxs)(`div`,{className:O(`pointer-events-auto relative z-30 flex flex-col gap-1.5 rounded-xl border border-line bg-surface/95 shadow-pop backdrop-blur`,f?`w-full p-2`:`w-max max-w-[min(760px,100%)] min-w-[min(440px,100%)] px-3 py-2`),role:`region`,"aria-label":`Journey: ${e.name}`,"data-sw-journey-bar":e.id,"data-sw-journey-path":t.forks.map(e=>e.chosen).join(`,`),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 px-0.5`,children:[e.description&&!f?(0,Y.jsx)(_,{content:e.description,side:`top`,align:`start`,children:(0,Y.jsx)(`span`,{tabIndex:0,className:`block min-w-0 rounded outline-none focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-journey-description":`true`,children:x})}):x,(0,Y.jsxs)(`p`,{className:`truncate text-xs text-muted`,"aria-live":`polite`,"data-sw-journey-step":n,children:[(0,Y.jsxs)(`span`,{className:`tabular font-medium text-fg`,children:[`Step `,n,` of `,h]}),g?.branch?(0,Y.jsxs)(`span`,{"data-sw-journey-branch-now":g.branch,children:[` (`,g.branch,`)`]}):null,`:`,` `,r(g?.pageId),t.ended&&n===h?`, where this branch ends`:``]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Y.jsx)(_,{content:f?null:(0,Y.jsx)(Jw,{label:`Previous step`,keyName:`←`}),children:(0,Y.jsx)(a,{size:f?`icon`:`icon-sm`,disabled:n<=1,onClick:()=>i(n-1),"aria-label":`Previous step`,"data-sw-journey-prev":`true`,children:(0,Y.jsx)(ut,{size:16,"aria-hidden":`true`})})}),(0,Y.jsx)(_,{content:f?null:(0,Y.jsx)(Jw,{label:`Next step`,keyName:`→`}),children:(0,Y.jsxs)(a,{size:f?`touch`:`sm`,variant:`default`,className:`px-2.5`,disabled:n>=h,onClick:()=>i(n+1),"aria-label":`Next step`,"data-sw-journey-next":`true`,children:[`Next `,(0,Y.jsx)(nt,{size:16,"aria-hidden":`true`})]})}),u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),c?(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,onClick:c,disabled:d,label:`Edit this journey`,children:(0,Y.jsx)(u_,{size:14,"aria-hidden":`true`})}):null,p?(0,Y.jsxs)(a,{size:b,variant:`danger`,disabled:d,onClick:l,"data-sw-journey-delete-confirm":`true`,children:[(0,Y.jsx)(ev,{size:14,"aria-hidden":`true`}),` Delete`]}):(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,disabled:d,onClick:()=>m(!0),label:`Delete this journey`,children:(0,Y.jsx)(ev,{size:14,"aria-hidden":`true`})})]}):null,(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,onClick:s,label:`Close the journey`,tooltip:f?null:(0,Y.jsx)(Jw,{label:`Close the journey`,keyName:`Esc`}),"data-sw-journey-close":`true`,children:(0,Y.jsx)(se,{size:16,"aria-hidden":`true`})})]})]}),(0,Y.jsx)(Yw,{route:t,step:n,pageTitle:r,onStep:i,touch:f}),y?(0,Y.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-1.5 border-t border-line pt-2`,role:`group`,"aria-label":`The journey forks here. Which way?`,"data-sw-journey-fork":v,children:[(0,Y.jsxs)(`span`,{className:O(`flex items-center gap-1 text-xs font-medium text-muted`,f&&`w-full px-1`),children:[(0,Y.jsx)(eg,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),` Which way?`]}),y.options.map(e=>{let t=e.id===y.chosen;return(0,Y.jsxs)(a,{size:b,variant:t?`default`:`secondary`,className:O(`max-w-full min-w-0`,f&&`flex-1`),"aria-pressed":t,onClick:()=>o(v,e.id),"data-sw-journey-branch":e.id,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.label}),e.end?(0,Y.jsx)(`span`,{className:`text-[11px] opacity-75`,children:`(ends)`}):null]},e.id)})]}):null]})}function Zw({draft:e,onChange:t,onSave:n,onCancel:r,pageTitle:i,busy:o,touch:s}){let c=s?`touch`:`sm`,l=e.steps,u=e.into||null,d=$w(l),f=tT(l),p=e.name.trim()&&d>=2&&!f&&!o,m=l[l.length-1],h=n=>{let r=structuredClone(l),i=n(r);t({...e,steps:r,into:i===void 0?u:i})};return(0,Y.jsxs)(`div`,{className:O(`pointer-events-auto relative z-30 flex max-h-[60dvh] flex-col gap-2 overflow-y-auto rounded-xl border border-accent/50 bg-surface/95 p-3 shadow-pop backdrop-blur`,s?`w-full`:`w-[min(680px,100%)]`),role:`region`,"aria-label":e.id?`Edit journey`:`New journey`,"data-sw-journey-builder":`true`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(S_,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`Journey name`}),(0,Y.jsx)(it,{size:s?`touch`:`sm`,value:e.name,onChange:n=>t({...e,name:n.target.value.slice(0,120)}),placeholder:`Name this journey, e.g. Sign up`,"data-sw-journey-name":`true`})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-journey-into":u?`${u.fork}:${u.branch}`:`main`,children:[s?`Tap`:`Click`,` pages in the order people visit them`,u?(0,Y.jsxs)(Y.Fragment,{children:[` `,`-- adding to `,(0,Y.jsx)(`span`,{className:`font-semibold text-fg`,children:l[u.fork]?.branches?.[u.branch]?.label||`the branch`}),`.`]}):`.`]}),(0,Y.jsxs)(`ol`,{className:`flex flex-wrap items-start gap-1.5`,"data-sw-journey-draft":eT(l),children:[l.map((n,r)=>typeof n==`string`?(0,Y.jsx)(Qw,{number:r+1,title:i(n),touch:s,onRemove:()=>h(e=>(e.splice(r,1),null))},`${n}-${r}`):(0,Y.jsxs)(`li`,{className:`w-full rounded-lg border border-line bg-surface-2/50 p-2`,"data-sw-journey-draft-fork":r,children:[(0,Y.jsxs)(`p`,{className:`mb-1.5 flex items-center gap-1 text-xs font-medium text-muted`,children:[(0,Y.jsx)(eg,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),` Fork: which way?`]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:n.branches.map((o,c)=>{let l=u?.fork===r&&u?.branch===c;return(0,Y.jsxs)(`div`,{className:O(`flex flex-wrap items-center gap-1.5 rounded-md p-1`,l&&`bg-accent/10 ring-1 ring-accent/50`),"data-sw-journey-draft-branch":c,children:[(0,Y.jsx)(it,{size:s?`touch`:`xs`,className:`w-36`,value:o.label,"aria-label":`Branch ${c+1} name`,onChange:e=>h(t=>{t[r].branches[c].label=e.target.value.slice(0,60)})}),o.steps.map((e,t)=>typeof e==`string`?(0,Y.jsx)(Qw,{title:i(e),touch:s,onRemove:()=>h(e=>{e[r].branches[c].steps.splice(t,1)})},`${e}-${t}`):(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:`(a nested fork, edit it in the config)`},`nested-`+t)),(0,Y.jsx)(a,{size:s?`touch`:`xs`,variant:l?`default`:`ghost`,"aria-pressed":l,onClick:()=>t({...e,into:{fork:r,branch:c}}),"data-sw-journey-fill-branch":c,children:l?`Adding here`:`Add pages here`}),(0,Y.jsx)(a,{size:s?`touch`:`xs`,variant:o.end?`default`:`ghost`,"aria-pressed":!!o.end,onClick:()=>h(e=>{e[r].branches[c].end?delete e[r].branches[c].end:e[r].branches[c].end=!0}),"data-sw-journey-branch-end":c,children:o.end?`Ends here`:`Rejoins`}),n.branches.length>2?(0,Y.jsx)(B,{className:O(`rounded-full`,s?`h-11 w-11`:`h-6 w-6`),onClick:()=>h(e=>(e[r].branches.splice(c,1),u?.fork===r?{fork:r,branch:0}:u)),label:`Remove branch ${c+1}`,tooltip:`Remove the branch`,children:(0,Y.jsx)(se,{size:12,"aria-hidden":`true`})}):null]},c)})}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[n.branches.length<6?(0,Y.jsxs)(a,{size:s?`touch`:`xs`,variant:`ghost`,onClick:()=>h(e=>(e[r].branches.push({label:`Branch ${e[r].branches.length+1}`,steps:[]}),{fork:r,branch:e[r].branches.length-1})),"data-sw-journey-add-branch":`true`,children:[(0,Y.jsx)(f_,{size:13,"aria-hidden":`true`}),` Branch`]}):null,u?.fork===r?(0,Y.jsx)(a,{size:s?`touch`:`xs`,variant:`ghost`,onClick:()=>t({...e,into:null}),"data-sw-journey-main":`true`,children:`Back to the main line`}):null]})]},`fork-${r}`)),l.length?null:(0,Y.jsx)(`li`,{className:`text-xs text-faint`,children:`No steps yet.`})]}),f?(0,Y.jsx)(`p`,{className:`text-xs text-warn`,"data-sw-journey-problem":`true`,children:f}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Y.jsx)(_,{content:s?null:`Split the journey here into branches`,children:(0,Y.jsxs)(a,{size:c,variant:`ghost`,className:`mr-auto`,disabled:typeof m!=`string`||o,onClick:()=>h(e=>(e.push({branches:[{label:`Branch 1`,steps:[]},{label:`Branch 2`,steps:[]}]}),{fork:e.length-1,branch:0})),"data-sw-journey-fork-add":`true`,children:[(0,Y.jsx)(eg,{size:14,"aria-hidden":`true`}),` Fork here`]})}),(0,Y.jsxs)(a,{size:c,variant:`ghost`,disabled:!l.length||o,onClick:()=>h(e=>{let t=u?e[u.fork]?.branches?.[u.branch]?.steps:e;return t?.length?(t.pop(),u):u?e[u.fork].branches.every(e=>!e.steps.length)?(e.splice(u.fork,1),null):u:null}),children:[(0,Y.jsx)(iv,{size:14,"aria-hidden":`true`}),` Undo`]}),(0,Y.jsx)(a,{size:c,onClick:r,disabled:o,children:`Cancel`}),(0,Y.jsx)(a,{size:c,variant:`default`,onClick:n,disabled:!p,"data-sw-journey-save":`true`,children:o?`Saving...`:`Save journey`})]})]})}function Qw({number:e,title:t,touch:n,onRemove:r}){return(0,Y.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-full bg-accent/10 py-0.5 pr-0.5 pl-2 text-xs font-medium text-fg`,children:[e?(0,Y.jsx)(`span`,{className:`font-bold text-accent`,children:e}):null,` `,t,(0,Y.jsx)(B,{className:O(`rounded-full`,n?`h-9 w-9`:`h-5 w-5`),onClick:r,label:e?`Remove step ${e}`:`Remove ${t}`,tooltip:`Remove`,children:(0,Y.jsx)(se,{size:12,"aria-hidden":`true`})})]})}function $w(e){return e.reduce((e,t)=>e+(typeof t==`string`?1:t.branches.reduce((e,t)=>e+t.steps.length,0)),0)}function eT(e){return e.map(e=>typeof e==`string`?e:`[${e.branches.map(e=>`${e.label}:${e.steps.join(`+`)}${e.end?`!`:``}`).join(`|`)}]`).join(`,`)}function tT(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(typeof n==`string`)continue;let r=t<e.length-1,i=new Set;for(let e of n.branches){let t=e.label.trim();if(!t)return`Every branch needs a name.`;if(i.has(t.toLowerCase()))return`Two branches are called "${t}".`;if(i.add(t.toLowerCase()),!e.steps.length&&(e.end||!r))return`"${t}" has no pages: add some, or add a step after the fork for it to skip to.`}if(n.branches.every(e=>e.end)&&r)return`Every branch ends, so nothing can follow the fork.`}return null}var nT=`No new comments while comparing`,rT=`A comment belongs to a page, not to one environment. Leave compare to add one; replies and resolving work here.`;function iT({environments:e,pair:t,loading:n,error:r,changedPages:i,totalPages:o=0,changedOnly:s,showDiff:c,canComment:l=!1,canCapture:u,captureBusy:d,touch:f,onPair:p,onChangedOnly:m,onShowDiff:h,onCapture:g,onClose:v}){let[y,b]=t,x=(t,n,r,i,a=null)=>(0,Y.jsxs)(`span`,{className:O(`flex min-w-0 items-center gap-1 text-xs text-muted`,f&&`min-w-28 flex-1`),children:[f||!a?null:(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:a}),(0,Y.jsxs)($e,{value:t,onValueChange:n,children:[(0,Y.jsx)(Se,{size:f?`touch`:`sm`,className:f?`flex-1`:`max-w-48`,"aria-label":r,"data-sw-compare-env":i,children:(0,Y.jsx)(oe,{})}),(0,Y.jsx)(_e,{children:e.map(e=>(0,Y.jsx)(q,{value:e.id,children:e.title},e.id))})]})]}),S=e.filter(e=>t.includes(e.id)&&!e.capturedAt);return(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-2`,role:`region`,"aria-label":`Compare environments`,"data-sw-compare-bar":t.join(`_`),children:[(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 pr-1 text-[13px] font-semibold text-fg`,children:[(0,Y.jsx)(Qh,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),f?null:`Compare`]}),x(y,e=>p(e===b?[e,y]:[e,b]),`Compare`,`a`),(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,onClick:()=>p([b,y]),label:`Swap the environments`,children:(0,Y.jsx)(eh,{size:14,"aria-hidden":`true`})}),x(b,e=>p(e===y?[b,e]:[y,e]),`with`,`b`,`with`),(0,Y.jsx)(B,{size:f?`icon`:`icon-sm`,className:O(`ml-auto`,!f&&`order-last`),onClick:v,label:`Leave compare mode`,"data-sw-compare-close":`true`,children:(0,Y.jsx)(se,{size:16,"aria-hidden":`true`})}),(0,Y.jsx)(Ie,{size:f?`touch`:`sm`,pressed:c,onPressedChange:h,children:`Diff overlay`}),(0,Y.jsx)(Ie,{size:f?`touch`:`sm`,pressed:s,onPressedChange:m,"data-sw-changed-only":s?`on`:`off`,children:`Changed pages only`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted`,"aria-live":`polite`,"data-sw-compare-status":n?`loading`:`ready`,children:n?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(me,{size:12}),` Comparing`]}):r?(0,Y.jsx)(`span`,{className:`text-bad`,children:r}):(0,Y.jsxs)(`span`,{className:O(`tabular inline-flex h-6 items-center rounded-full px-2 font-medium`,i?`bg-accent/10 text-accent`:`bg-surface-2 text-muted`),children:[i,o?` of ${o}`:``,` page`,(o||i)===1?``:`s`,` changed`]})}),l?(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-xs text-muted`,"data-sw-compare-no-comments":`true`,children:[(0,Y.jsx)(Hg,{size:13,className:`shrink-0`,"aria-hidden":`true`}),f?(0,Y.jsx)(`span`,{className:`min-w-0`,children:nT}):(0,Y.jsx)(_,{content:rT,children:(0,Y.jsx)(`span`,{className:`min-w-0 cursor-help underline decoration-dotted underline-offset-2`,tabIndex:0,children:nT})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:rT})]}):null,u?S.map(e=>(0,Y.jsxs)(a,{size:f?`touch`:`sm`,disabled:d,onClick:()=>g(e.id),children:[(0,Y.jsx)(fh,{size:14,"aria-hidden":`true`}),` Capture `,e.title]},e.id)):null]})}var aT=2e3,oT=(e,t)=>e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&!t,sT=`shapewall.dictation.seen`;function cT(e){return String(e??``).replace(/\s+/g,` `).trim()}function lT(e,t=0){let n=[],r=[],i=e?Array.from(e):[];for(let e=Math.max(0,t);e<i.length;e+=1){let t=i[e],a=cT(t?.[0]?.transcript);a&&(t.isFinal?n:r).push(a)}return{final:n.join(` `),interim:r.join(` `)}}var uT=({final:e,interim:t})=>cT(`${e} ${t}`);function dT(e){return!e.trim()||/\n[ \t]*$/.test(e)?!0:/[.!?…]["'”’)\]]*\s+$/.test(e)||/[.!?…]["'”’)\]]*$/.test(e)}var fT=e=>e.replace(/^(\P{L}*)(\p{Ll})/u,(e,t,n)=>t+n.toLocaleUpperCase()),pT=/[\s([{"'“‘@#/-]$/,mT=/^[,.!?;:…%)\]}"'”’]/;function hT(e,{start:t,end:n=t},r,i=1/0){let a=String(e??``),o=Math.max(0,Math.min(t??a.length,a.length)),s=Math.max(o,Math.min(n??o,a.length)),c=a.slice(0,o),l=a.slice(s),u=cT(r);if(!u)return{value:a,caret:s};dT(c)&&(u=fT(u));let d=c&&!pT.test(c)&&!mT.test(u)?` `:``,f=l&&!/^\s/.test(l)&&!mT.test(l)?` `:``,p=Math.max(0,i-c.length-l.length),m=`${d}${u}${f}`;return m.length>p&&(m=m.slice(0,p)),{value:c+m+l,caret:c.length+Math.min(m.length,d.length+u.length)}}var gT={status:`idle`,notice:null},_T=e=>e.status===`starting`||e.status===`listening`||e.status===`stopping`;function vT(e,t){switch(typeof t==`string`?t:t?.type){case`press`:return _T(e)?e.status===`stopping`?e:{status:`stopping`,notice:null}:e.status===`asking`?gT:t.seen?{status:`starting`,notice:null}:{status:`asking`,notice:`privacy`};case`consent`:return e.status===`asking`?{status:`starting`,notice:null}:e;case`decline`:return e.status===`asking`?gT:e;case`started`:return e.status===`starting`?{status:`listening`,notice:null}:e;case`error`:return _T(e)?t.code===`aborted`||e.status===`stopping`?{status:`idle`,notice:e.notice}:{status:`idle`,notice:yT[t.code]?t.code:`failed`}:e;case`ended`:return e.status===`stopping`?{status:`idle`,notice:e.notice}:_T(e)?{status:`idle`,notice:`ended`}:e;case`quiet`:return e.status===`listening`?{status:`stopping`,notice:`ended`}:e;case`cancel`:return e.status===`idle`&&!e.notice?e:gT;case`dismiss`:return e.notice&&!_T(e)&&e.status!==`asking`?{...e,notice:null}:e;default:return e}}var yT={privacy:{tone:`info`,text:`Your browser's speech service (Google's, in Chrome) turns your voice into text. Shapewall never receives or stores the audio.`},ended:{tone:`info`,text:`Dictation stopped. Press the microphone to keep going.`},"not-allowed":{tone:`error`,text:`Microphone access is blocked. Allow it for this site in your browser, then try again.`},"service-not-allowed":{tone:`error`,text:`This browser's speech service is not available here. You can still type.`},"audio-capture":{tone:`error`,text:`No microphone was found. Connect one and try again.`},"no-speech":{tone:`error`,text:`No speech was heard. Press the microphone and try again.`},network:{tone:`error`,text:`The browser's speech service could not be reached. Check your connection and try again.`},"language-not-supported":{tone:`error`,text:`Dictation isn't available in your browser's language.`},start:{tone:`error`,text:`The microphone did not start. Check its permission for this site and try again.`},failed:{tone:`error`,text:`Dictation stopped unexpectedly. Try again, or type.`}};function bT({languages:e=[],language:t=``,pageLang:n=``}={}){let r=e=>typeof e==`string`&&/^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i.test(e);return[...e||[],t,n].find(r)||`en-US`}function xT({dictation:e,touch:t,disabled:n=!1}){if(!e.supported)return null;let r=e.active;return(0,Y.jsxs)(B,{size:t?`icon`:`icon-sm`,variant:`ghost`,className:O(`relative`,!t&&`w-7`,r&&`bg-bad/10 text-bad ring-1 ring-bad/40 ring-inset hover:bg-bad/15 hover:text-bad`,e.state.status===`asking`&&`bg-surface-2 text-fg`),label:`Dictate`,tooltip:r?`Stop dictation (Esc)`:`Dictate: speak to type`,"aria-pressed":r,"aria-describedby":e.describedBy,disabled:n&&!r,onMouseDown:e=>e.preventDefault(),onClick:e.toggle,"data-sw-dictate":e.state.status,children:[(0,Y.jsx)(Jg,{size:16,"aria-hidden":`true`}),r?(0,Y.jsx)(`span`,{className:O(`absolute size-1.5 rounded-full bg-bad motion-safe:animate-pulse`,t?`top-2.5 right-2.5`:`top-1 right-0.5`),"aria-hidden":`true`,"data-sw-dictate-dot":`true`}):null]})}function ST({dictation:e,touch:t,id:n,className:r}){if(!e.supported)return null;let{status:i,notice:o}=e.state,s=o?yT[o]:null,c=null;return i===`asking`?c=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 basis-48`,children:yT.privacy.text}),(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,Y.jsx)(a,{size:t?`touch`:`xs`,variant:`ghost`,onClick:e.decline,"data-sw-dictation-decline":`true`,children:`Not now`}),(0,Y.jsx)(a,{size:t?`touch`:`xs`,variant:`secondary`,onClick:e.consent,"data-sw-dictation-start":`true`,children:`Start dictation`})]})]}):i===`listening`?c=(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-bad motion-safe:animate-pulse`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[`Listening. `,t?`Tap the microphone to stop.`:`Press the microphone or Esc to stop.`]})]}):i===`starting`?c=(0,Y.jsx)(`p`,{children:`Starting the microphone...`}):i===`stopping`?c=(0,Y.jsx)(`p`,{children:`Finishing...`}):s&&(c=(0,Y.jsx)(`p`,{className:O(s.tone===`error`&&`text-bad`),children:s.text})),(0,Y.jsx)(`div`,{id:n,role:`status`,"aria-live":`polite`,className:c?O(`text-caption text-muted`,r):`sr-only`,"data-sw-dictation-note":c?o||i:void 0,children:c})}var CT=()=>typeof window>`u`?null:window.SpeechRecognition||window.webkitSpeechRecognition||null,wT=null;function TT(){if(wT!==null)return wT;if(typeof window>`u`||!CT()||!window.isSecureContext)return wT=!1;let e=document.permissionsPolicy||document.featurePolicy;try{wT=!(e?.allowsFeature&&!e.allowsFeature(`microphone`))}catch{wT=!0}return wT}var ET=!1;function DT(){if(ET)return!0;try{return window.localStorage.getItem(sT)===`1`}catch{return!1}}function OT(){ET=!0;try{window.localStorage.setItem(sT,`1`)}catch{}}var kT=15e3,AT=1500,jT=3e4,MT=null;function NT(e){clearTimeout(e.timer),clearTimeout(e.quiet);let{rec:t}=e;t.onstart=t.onresult=t.onerror=t.onend=null;try{t.abort()}catch{}MT===e.cancel&&(MT=null)}function PT({value:e,setValue:t,inputRef:n,max:r=1/0}){let[i,a]=(0,J.useReducer)(vT,gT),o=(0,J.useRef)(null),s=(0,J.useRef)({value:e,setValue:t,max:r});s.current={value:e,setValue:t,max:r};let c=(0,J.useRef)(null),l=_T(i),u=`sw-dictation-${(0,J.useId)().replace(/:/g,``)}`,d=(0,J.useCallback)((e,t)=>{o.current===e&&(o.current=null,NT(e),a(t))},[]),f=e=>{if(!e.stopping){e.stopping=!0,clearTimeout(e.timer),clearTimeout(e.quiet),e.timer=setTimeout(()=>d(e,`ended`),AT);try{e.rec.stop()}catch{d(e,`ended`)}}},p=e=>{clearTimeout(e.quiet),e.quiet=setTimeout(()=>{o.current===e&&(a(`quiet`),f(e))},jT)},m=()=>{MT?.();let e=CT(),t;try{t=new e}catch{return a({type:`error`,code:`start`})}let r=n.current,i=s.current.value,l=r&&r.value===i,u=l?r.selectionStart??i.length:i.length,f={rec:t,base:{value:i,start:u,end:l?r.selectionEnd??u:u},skip:0,seen:0,shown:i,caret:null,timer:null,quiet:null,stopping:!1};f.cancel=()=>d(f,`cancel`),o.current=f,MT=f.cancel,t.lang=bT({languages:navigator.languages,language:navigator.language,pageLang:document.documentElement.lang}),t.continuous=!0,t.interimResults=!0,t.maxAlternatives=1,t.onstart=()=>{o.current===f&&(clearTimeout(f.timer),a(`started`),p(f))},t.onresult=e=>{if(o.current!==f)return;f.seen=e.results.length,f.stopping||p(f);let t=uT(lT(e.results,f.skip));if(!t)return;let n=hT(f.base.value,f.base,t,s.current.max);f.shown=n.value,f.caret=n.caret,c.current=n,s.current.setValue(n.value)},t.onerror=e=>d(f,{type:`error`,code:e.error}),t.onend=()=>d(f,`ended`),f.timer=setTimeout(()=>d(f,{type:`error`,code:`start`}),kT);try{t.start()}catch{d(f,{type:`error`,code:`start`})}},h=()=>{o.current?d(o.current,`cancel`):a(`cancel`)},g=()=>{if(o.current)return a({type:`press`}),f(o.current);if(i.status===`asking`)return a({type:`press`});let e=DT();a({type:`press`,seen:e}),e&&m()},_=()=>{OT(),a(`consent`),m(),n.current?.focus({preventScroll:!0})},v=()=>{a(`decline`),n.current?.focus({preventScroll:!0})},y=e=>{let t=o.current,r=n.current;if(!t)return;let i=r&&r.value===e,a=i?r.selectionStart??e.length:e.length;t.base={value:e,start:a,end:i?r.selectionEnd??a:a},t.skip=t.seen,t.shown=e,t.caret=null,c.current=null},b=e=>{o.current?y(e):i.notice&&i.status===`idle`&&a(`dismiss`)},x=()=>{let e=o.current,t=n.current;if(!e||!t||t.value!==e.shown)return;let{selectionStart:r,selectionEnd:i}=t,a=e.caret??e.base.start,s=e.caret??e.base.end;(r!==a||i!==s)&&y(t.value)};(0,J.useLayoutEffect)(()=>{let e=c.current,t=n.current;e&&t&&t.value===e.value&&(c.current=null,t.setSelectionRange(e.caret,e.caret),e.caret>=e.value.length-1&&(t.scrollTop=t.scrollHeight))},[e,n]);let S=i.status===`asking`;return(0,J.useEffect)(()=>{if(!l&&!S)return;let e=e=>{e.key!==`Escape`||e.isComposing||(e.preventDefault(),e.stopImmediatePropagation(),o.current?d(o.current,`cancel`):a(`decline`))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[l,S,d]),(0,J.useEffect)(()=>{if(!l)return;let e=()=>{document.hidden&&o.current&&d(o.current,`cancel`)},t=()=>o.current&&d(o.current,`cancel`);return document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t)}},[l,d]),(0,J.useEffect)(()=>()=>{let e=o.current;e&&(o.current=null,NT(e))},[]),{supported:TT(),noteId:u,describedBy:TT()&&(i.status!==`idle`||i.notice)?u:void 0,state:i,active:l,toggle:g,consent:_,decline:v,cancel:h,onInput:b,fieldProps:{onMouseUp:x,onKeyUp:x}}}function FT({draft:e,onChange:t,onSubmit:n,onCancel:r,busy:i,people:o,touch:c,hosted:l,signedInAs:u,description:d,media:f,discard:p=null,startDraw:m=!1}){let h=e?.body||``,g=Math.min(8,Math.max(c?3:2,h.split(`
|
|
28
|
+
`).length)),[_,v]=(0,J.useState)(!1),y=!!(c&&f?.draw&&f?.page);(0,J.useEffect)(()=>{m&&y&&v(!0)},[m,y]);let b=Yx(e=>e?.owner===`composer`?e.shapes.length:0),x=f?.images,S=!!(f?.attach&&x),C=!!f?.draw,w=!!x?.reading,T=(0,J.useRef)(null),E=(0,J.useId)(),D=PT({value:h,setValue:e=>t({body:e}),inputRef:T,max:aT}),k=()=>{D.cancel(),n()},A=(0,Y.jsx)(xT,{dictation:D,touch:c,disabled:i}),j=[x?.error?`sw-composer-image-error`:null,D.describedBy].filter(Boolean);return(0,Y.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),k()},...vS(x,S),"data-sw-composer":`true`,children:[d?(0,Y.jsx)(`p`,{className:O(`truncate text-xs text-muted`,!c&&`-mx-3 -mt-3 cursor-grab touch-none px-3 pt-3 select-none`),title:c?void 0:`Drag to move`,"data-sw-composer-target":`true`,"data-sw-card-drag-handle":c?void 0:`true`,children:d}):null,(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`Comment`}),(0,Y.jsx)(Ub,{size:c?`touch`:`sm`,rows:g,value:h,people:o,className:`resize-none`,onChange:e=>{let n=e.slice(0,aT);D.onInput(n),t({body:n})},onKeyDown:e=>{oT(e,c)&&(e.preventDefault(),k())},inputRef:T,...D.fieldProps,autoFocus:!0,placeholder:`Add a comment. @ to mention someone or @agent`,"aria-describedby":j.length?j.join(` `):void 0,"data-sw-comment-input":`true`})]}),(0,Y.jsx)(ST,{dictation:D,touch:c,id:D.noteId}),S?(0,Y.jsx)(yS,{draft:x,touch:c,id:`sw-composer-image-error`}):null,S||C||f?.attachNote||D.supported?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5`,"data-sw-composer-media":`true`,children:[C&&!c?(0,Y.jsx)(pS,{owner:`composer`,touch:!1,compact:!0,className:`flex-1`,leading:S||D.supported?(0,Y.jsxs)(Y.Fragment,{children:[S?(0,Y.jsx)(_S,{draft:x,touch:!1,disabled:i}):null,A]}):null}):(0,Y.jsxs)(Y.Fragment,{children:[S?(0,Y.jsx)(_S,{draft:x,touch:c,disabled:i}):null,A]}),C&&c&&f.page?(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,onClick:()=>v(!0),"data-sw-draw-open":`true`,children:[(0,Y.jsx)(ch,{size:16,"aria-hidden":`true`}),` `,b?`Drawing (${b})`:`Draw on the page`]}):null,f?.attachNote?(0,Y.jsx)(`p`,{className:`w-full text-caption text-faint`,"data-sw-attach-note":`true`,children:f.attachNote}):null]}):null,c&&C&&f.page?(0,Y.jsx)(gS,{open:_,onClose:()=>v(!1),owner:`composer`,src:f.page.src,native:f.page.native,title:f.pageTitle}):null,l?null:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,Y.jsx)(`label`,{className:`shrink-0`,htmlFor:E,children:`Your name`}),(0,Y.jsx)(it,{id:E,size:c?`touch`:`xs`,value:e?.author||``,onChange:e=>t({author:e.target.value.slice(0,60)}),placeholder:`optional`,className:`flex-1`,"data-sw-comment-author":`true`})]}),p?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-warn/40 bg-warn/10 py-1 pr-1 pl-2.5 text-xs text-fg`,role:`alertdialog`,"aria-label":`Discard this comment?`,"data-sw-composer-discard":`true`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 font-medium`,children:`Discard this comment?`}),(0,Y.jsx)(a,{size:`xs`,variant:`danger`,onClick:p.onDiscard,autoFocus:!0,"data-sw-composer-discard-yes":`true`,children:`Discard`}),(0,Y.jsx)(a,{size:`xs`,variant:`secondary`,onClick:p.onKeep,"data-sw-composer-discard-keep":`true`,children:`Keep`})]}):c?null:(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 overflow-hidden text-[11px] whitespace-nowrap text-faint`,"data-sw-composer-keys":`true`,children:[(0,Y.jsx)(s,{children:`Enter`}),` posts, `,(0,Y.jsx)(s,{children:`Shift`}),`+`,(0,Y.jsx)(s,{children:`Enter`}),` new line, `,(0,Y.jsx)(s,{children:`Esc`}),` cancels`]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[11px] text-faint`,children:h.length>1800?(0,Y.jsxs)(`span`,{className:`tabular`,children:[h.length,`/`,aT]}):l&&u?`As ${u}`:null}),(0,Y.jsx)(a,{size:c?`touch`:`xs`,variant:`ghost`,onClick:()=>{D.cancel(),r()},disabled:i,"data-sw-composer-cancel":`true`,children:`Cancel`}),(0,Y.jsx)(a,{size:c?`touch`:`xs`,variant:`default`,type:`submit`,disabled:i||w||!h.trim()&&!b&&!x?.images.length,"data-sw-save-comment":`true`,children:i?x?.images.length?`Uploading...`:`Posting...`:`Post`})]})]})}function IT({before:e,after:t,label:n=`Before and after`,beforeLabel:r=`Before`,afterLabel:i=`After`,start:a=50,className:o,children:s,...c}){let[l,u]=(0,J.useState)(a),d=(0,J.useRef)(null),f=(0,J.useRef)(!1),p=e=>{let t=d.current?.getBoundingClientRect();t?.width&&u(Math.min(100,Math.max(0,(e-t.left)/t.width*100)))};return(0,Y.jsxs)(`div`,{ref:d,className:O(`relative touch-pan-y overflow-hidden select-none`,o),onPointerDown:e=>{e.button===0&&(f.current=!0,e.currentTarget.setPointerCapture?.(e.pointerId),p(e.clientX))},onPointerMove:e=>f.current&&p(e.clientX),onPointerUp:()=>{f.current=!1},onPointerCancel:()=>{f.current=!1},"data-sw-compare-slider":Math.round(l),...c,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 z-[1]`,style:{clipPath:`inset(0 ${100-l}% 0 0)`},children:e}),t,(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[2]`,children:s}),(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-1.5 left-1.5 z-[3] rounded bg-black/60 px-1.5 text-[10px] leading-4 font-medium text-white`,children:r}),(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-1.5 right-1.5 z-[3] rounded bg-black/60 px-1.5 text-[10px] leading-4 font-medium text-white`,children:i}),(0,Y.jsxs)(`div`,{role:`slider`,tabIndex:0,"aria-label":n,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l),"aria-valuetext":`${Math.round(l)}% ${r.toLowerCase()}`,onKeyDown:e=>{let t=e.shiftKey?20:5;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)u(e=>Math.max(0,e-t));else if(e.key===`ArrowRight`||e.key===`ArrowUp`)u(e=>Math.min(100,e+t));else if(e.key===`Home`)u(0);else if(e.key===`End`)u(100);else return;e.preventDefault(),e.stopPropagation()},className:`group absolute inset-y-0 z-[3] w-8 -translate-x-1/2 cursor-ew-resize outline-none`,style:{left:`${l}%`},"data-sw-compare-handle":`true`,children:[(0,Y.jsx)(`span`,{className:`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-white shadow-[0_0_0_1px_rgb(0_0_0/0.25)]`}),(0,Y.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex h-7 w-7 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-line bg-surface text-muted shadow-pop group-focus-visible:ring-2 group-focus-visible:ring-accent`,children:(0,Y.jsx)(K_,{size:13,"aria-hidden":`true`})})]})]})}function LT({url:e,native:t,crop:n,label:r,comment:i,onImageError:a,shapes:o=null}){let s=n||{left:0,top:0,width:t.width,height:t.height};if(!e)return(0,Y.jsx)(`div`,{className:`h-full w-full bg-surface-2`});let c=o?.length?(0,Y.jsx)(sS,{shapes:o,width:t.width,height:t.height,crop:n,className:`z-[1]`,"data-sw-before-drawing":`true`}):null;if(c&&!n)return(0,Y.jsxs)(`div`,{className:`relative w-full`,children:[(0,Y.jsx)(LT,{url:e,native:t,crop:null,label:r,comment:i,onImageError:a}),c]});let l=(0,Y.jsx)(`img`,{src:e,alt:`${r}: ${i.viewport} capture`,draggable:!1,onError:a,className:O(`block max-w-none select-none`,n?`absolute`:`w-full`),style:n?{width:`${t.width/s.width*100}%`,left:`${-s.left/s.width*100}%`,top:`${-s.top/s.height*100}%`}:void 0});return c?(0,Y.jsxs)(Y.Fragment,{children:[l,c]}):l}function RT({native:e,crop:t,comment:n}){if(!t)return null;let r=(e.width*n.x/100-t.left)/t.width,i=(e.height*n.y/100-t.top)/t.height;return r<0||r>1||i<0||i>1?null:(0,Y.jsx)(`span`,{className:`pointer-events-none absolute h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-accent shadow-pop`,style:{left:`${r*100}%`,top:`${i*100}%`},"aria-hidden":`true`})}function zT({url:e,native:t,crop:n,comment:r,label:i,onImageError:a,shapes:o=null}){let s=n||{left:0,top:0,width:t.width,height:t.height};return(0,Y.jsxs)(`figure`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`figcaption`,{className:`mb-1 text-[11px] font-medium tracking-wide text-faint uppercase`,children:i}),(0,Y.jsxs)(`div`,{className:O(`relative w-full overflow-hidden rounded-md border border-line bg-surface-2`,!n&&`max-h-80 overflow-y-auto`),style:n?{aspectRatio:`${s.width} / ${s.height}`}:void 0,children:[(0,Y.jsx)(LT,{url:e,native:t,crop:n,label:i,comment:r,onImageError:a,shapes:o}),(0,Y.jsx)(RT,{native:t,crop:n,comment:r})]})]})}var BT=[{id:`near`,label:`Near the pin`},{id:`whole`,label:`Whole frame`}],VT=[{id:`near`,label:`Near the drawing`},{id:`whole`,label:`Whole frame`}],HT=[{id:`slider`,label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K_,{size:13,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Slider`})]})},{id:`split`,label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Eh,{size:13,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Side by side`})]})}],UT=[{id:`before`,label:`Before`},{id:`after`,label:`After`}];function WT({comment:e,pair:t,native:n,urlFor:r,touch:i,onImageError:a}){let[o,s]=(0,J.useState)(`near`),[c,l]=(0,J.useState)(`slider`),u=t?.drawn||null,[d,f]=(0,J.useState)(u?`before`:`after`),p=(0,J.useRef)(null);if(!t||!n||!t.before&&!t.after)return null;if(!t.after||!t.before)return(0,Y.jsx)(`p`,{className:`mt-2 rounded-md bg-surface-2 px-2 py-1.5 text-xs text-muted`,"data-sw-before-after":t.reason,children:t.reason===`not-recaptured`?`Not recaptured since this comment. Recapture the page to see before and after.`:`The capture this comment was made on is no longer kept, so there is no before to show.`});let m=u?Hx({shapes:u}):null,h=m?[(m.x+m.width/2)*100,(m.y+m.height/2)*100]:[e.x,e.y],g=o===`near`?Dv(n,h[0],h[1]):null,_=g||{left:0,top:0,width:n.width,height:n.height},v={native:n,crop:g,comment:e,onImageError:a},y=u?(0,Y.jsx)(`p`,{className:`text-xs text-muted`,"data-sw-drawn-previous":`true`,children:`The drawing shows on Before, over the page as it was.`}):null,b=(0,Y.jsx)(Xe,{label:`Zoom`,options:m?VT:BT,value:o,onChange:s,large:i,className:i?`flex-1`:``});if(!i)return(0,Y.jsxs)(`div`,{className:`mt-2.5 space-y-2`,"data-sw-before-after":`ready`,children:[y,(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,(0,Y.jsx)(`span`,{className:`flex-1`}),(0,Y.jsx)(Xe,{label:`Layout`,options:HT,value:c,onChange:l,itemClassName:`px-2`})]}),c===`slider`?(0,Y.jsx)(`div`,{className:O(`rounded-md border border-line bg-surface-2`,!g&&`max-h-80 overflow-y-auto`),children:(0,Y.jsx)(IT,{start:u?85:50,className:`w-full`,style:g?{aspectRatio:`${_.width} / ${_.height}`}:void 0,label:`Before and after comment ${e.id}`,before:(0,Y.jsx)(`div`,{className:`relative h-full w-full bg-surface-2`,children:(0,Y.jsx)(LT,{url:r(t.before),label:`Before`,...v,shapes:u})}),after:(0,Y.jsx)(`div`,{className:O(`relative w-full bg-surface-2`,g&&`h-full`),children:(0,Y.jsx)(LT,{url:r(t.after),label:`After`,...v})}),children:(0,Y.jsx)(RT,{native:n,crop:g,comment:e})},u?`drawn`:`plain`)}):(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(zT,{url:r(t.before),label:`Before`,...v,shapes:u}),(0,Y.jsx)(zT,{url:r(t.after),label:`After`,...v})]})]});let x=(0,Y.jsx)(zT,{url:r(t.before),label:`Before`,...v,shapes:u}),S=(0,Y.jsx)(zT,{url:r(t.after),label:`After`,...v});return(0,Y.jsxs)(Ee,{value:d,onValueChange:f,className:`mt-2.5 space-y-2`,"data-sw-before-after":`ready`,children:[y,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Re,{"aria-label":`Show`,className:`flex-1`,children:UT.map(e=>(0,Y.jsx)(qe,{value:e.id,large:!0,children:e.label},e.id))}),b]}),(0,Y.jsxs)(`div`,{onTouchStart:e=>{p.current=e.touches[0]?.clientX??null},onTouchEnd:e=>{let t=p.current,n=e.changedTouches[0]?.clientX;p.current=null,t===null||n===void 0||Math.abs(n-t)<40||f(n<t?`after`:`before`)},"data-sw-before-after-side":d,children:[(0,Y.jsx)(le,{value:`before`,children:x}),(0,Y.jsx)(le,{value:`after`,children:S})]})]})}var GT=new Map,KT=(e,t)=>`${e||``}#${t}`,qT={body:``,shapes:[],images:[]},JT={get:e=>GT.get(e)||qT,save(e,t){let n={...GT.get(e)||qT,...t};n.body||n.shapes.length||n.images.length?GT.set(e,n):GT.delete(e)},clear:e=>GT.delete(e)};function YT(e,t){return t?e.by.some(e=>t.handle&&e.handle?e.handle===t.handle:String(e.name).toLowerCase()===String(t.name||`anonymous`).toLowerCase()):!1}function XT(e,t){let n=xe[e.emoji]||e.emoji;if(!e.by.length)return`${e.count} ${e.count===1?`person`:`people`} reacted with ${n}`;let r=e.by.map(e=>YT({by:[e]},t)?`You`:e.name);return`${r.length>1?`${r.slice(0,-1).join(`, `)} and ${r.at(-1)}`:r[0]} reacted with ${n}`}function ZT({reactions:e=[],canReact:t,me:n,onToggle:r,touch:i}){let[a,o]=(0,J.useState)(!1);if(!e.length&&!t)return null;let s=O(`inline-flex items-center gap-1 rounded-full border px-1.5 text-xs leading-none tabular`,i?`h-11 min-w-11 justify-center`:`h-6`);return(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,"data-sw-reactions":`true`,children:[e.map(e=>{let i=YT(e,n),a=XT(e,n);return(0,Y.jsx)(_,{content:a,children:t?(0,Y.jsxs)(`button`,{type:`button`,className:O(s,`transition-colors focus-visible:outline-2 focus-visible:outline-accent`,i?`border-accent/35 bg-accent/5 text-fg hover:border-accent/60`:`border-line bg-surface-2 text-fg hover:border-faint`),"aria-pressed":i,"aria-label":`${a}. ${i?`Remove your reaction`:`Add yours`}`,onClick:()=>r(e.emoji),"data-sw-reaction":e.emoji,"data-sw-reaction-mine":i?`true`:`false`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:e.emoji}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`font-medium`,children:e.count})]}):(0,Y.jsxs)(`span`,{className:O(s,`border-line bg-surface-2 text-fg`),"aria-label":a,role:`img`,"data-sw-reaction":e.emoji,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:e.emoji}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`font-medium`,children:e.count})]})},e.emoji)}),t?(0,Y.jsxs)(lt,{open:a,onOpenChange:o,children:[(0,Y.jsx)(_,{content:`Add a reaction`,children:(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,className:O(s,i?`px-0`:`w-6 justify-center px-0`,`border-transparent text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,!i&&!e.length&&`opacity-0 group-focus-within/message:opacity-100 group-hover/message:opacity-100`,a&&`opacity-100`),"aria-label":`Add a reaction`,"data-sw-reaction-add":`true`,children:(0,Y.jsx)(Hh,{size:15,"aria-hidden":`true`})})})}),(0,Y.jsx)(ot,{side:i?`bottom`:`right`,align:`start`,sideOffset:6,collisionPadding:12,className:`flex gap-0.5 p-1`,"aria-label":`Reactions`,"data-sw-reaction-picker":`true`,children:ve.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:O(`inline-flex items-center justify-center rounded-md text-lg hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,i?`h-11 w-11`:`h-8 w-8`),"aria-label":`React with ${xe[e]}`,onClick:()=>{o(!1),r(e)},"data-sw-reaction-pick":e,children:e},e))})]}):null]})}function QT({label:e,state:t=`ready`,size:n=`md`,icon:r=null,tint:i=null,logo:a=null,className:o}){return(0,Y.jsxs)(`span`,{className:O(`relative inline-flex shrink-0`,o),"aria-hidden":`true`,children:[(0,Y.jsx)(ge,{label:e,icon:r,tint:i,logo:a,size:n===`sm`?`sm`:`md`}),(0,Y.jsx)(`span`,{className:O(`absolute -right-0.5 -bottom-0.5 rounded-full ring-2 ring-surface`,n===`sm`?`h-1.5 w-1.5`:`h-2 w-2`,Fe[t]||Fe.ready)})]})}function $T({text:e}){return String(e).split(/(`[^`]+`)/).map((e,t)=>e.startsWith("`")&&e.endsWith("`")?(0,Y.jsx)(`code`,{className:`font-mono text-[10.5px] text-fg`,children:e.slice(1,-1)},t):e)}function eE({options:e,value:t=null,onChoose:n,onConnect:i=null,settingsHref:a=null,disabledReason:o=null,heading:s=null,align:c=`start`,touch:u=!1,children:d,...f}){let m=(0,Y.jsx)(T,{asChild:!0,"aria-disabled":o?`true`:void 0,onPointerDown:o?e=>e.preventDefault():void 0,onKeyDown:o?e=>[`Enter`,` `,`ArrowDown`,`ArrowUp`].includes(e.key)&&e.preventDefault():void 0,children:d});return(0,Y.jsxs)(je,{modal:!1,children:[o?(0,Y.jsx)(_,{content:o,children:m}):m,(0,Y.jsxs)(r,{align:c,className:O(`w-[min(20rem,calc(100vw-1.5rem))]`,u&&`p-1.5`),"data-sw-agent-menu":`true`,...f,children:[s?(0,Y.jsx)(k,{className:`normal-case tracking-normal`,children:s}):null,(0,Y.jsx)(ee,{value:t??``,onValueChange:e=>n?.(e),children:e.map(e=>(0,Y.jsxs)(p,{value:e.id,disabled:!e.configured,textValue:e.label,className:`h-auto min-h-11 items-start py-2 lg:h-auto lg:min-h-11`,"aria-label":`${e.label}${e.isDefault?`, default`:``}, ${l(e)}`,"data-sw-agent-option":e.id,"data-sw-agent-state":e.state,children:[(0,Y.jsx)(QT,{label:e.label,state:e.state,icon:e.icon,tint:e.tint,logo:e.logo,className:`mt-0.5`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.isDefault?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-line px-1.5 text-[10px] leading-4 font-medium text-muted`,"data-sw-agent-default":`true`,children:`Default`}):null]}),(0,Y.jsx)(`span`,{className:O(`line-clamp-2 text-[11.5px] leading-4 font-normal`,e.state===`login`?`text-fg`:e.state===`not-responding`?`text-bad`:`text-muted`),children:(0,Y.jsx)($T,{text:l(e)})})]})]},e.id))}),i||a?(0,Y.jsx)(y,{}):null,i?(0,Y.jsxs)(D,{onSelect:i,"data-sw-agent-connect":`true`,children:[(0,Y.jsx)(m_,{size:14,"aria-hidden":`true`}),` Connect another agent...`]}):null,a?(0,Y.jsx)(D,{asChild:!0,children:(0,Y.jsxs)(`a`,{href:a,"data-sw-agent-settings":`true`,children:[(0,Y.jsx)(A_,{size:14,"aria-hidden":`true`}),` Agent settings`]})}):null]})]})}var tE={online:`ready`,busy:`starting`,offline:`unavailable`};function nE(e,{relative:t=A}={}){if(!e)return``;if(e.state===`busy`){let t=e.working||[],n=e.elsewhere?.working||0;if(t.length===1&&!n)return`Working on #${t[0]}`;let r=t.length+n;return r>1?`Working on ${r} comments`:`Working`}if(e.state===`online`)return`Online`;let n=e.lastSeenAt?t(e.lastSeenAt):``;return n?`Offline, last seen ${n}`:`Offline, never connected`}var rE=(e,t)=>t&&(e||[]).find(e=>e.id===t)||null;function iE(e,t={}){return[...e?.agents||[]].sort((e,t)=>Number(t.isDefault)-Number(e.isDefault)).map(e=>({id:e.id,label:e.name,icon:e.icon||null,tint:e.tint||null,logo:e.logo||null,state:e.state,mark:tE[e.state]||`unavailable`,line:e.canSend?nE(e,t):e.reason||`You cannot send work to this agent.`,isDefault:!!e.isDefault,disabled:!e.canSend,reason:e.canSend?null:e.reason||null}))}function aE(e){let t=rE(e?.agents,e?.defaultAgentId);return t?.canSend?{agentId:t.id,label:`Send to ${t.name}`}:{agentId:null,label:`Send to agent`}}function oE(e,t,n={}){if(!e?.dispatchable)return null;let r=t?.agents||[],i=r.find(t=>(t.working||[]).includes(e.id))||null;if(i)return{kind:`working`,agent:i,text:`${i.name} is working on this`,canRelease:!1};if(e.agentStatus)return null;let a=rE(r,e.agentId);if(a&&a.state===`offline`)return{kind:`waiting`,agent:a,text:`Waiting for ${a.name} (${sE(nE(a,n))})`,canRelease:!0};if(a)return{kind:`sent`,agent:a,text:`Sent to ${a.name}. It picks this up next.`,canRelease:r.length>1};let o=r.filter(e=>e.state!==`offline`);return{kind:`any`,agent:null,text:r.length?o.length?`Sent to any agent: the first one free takes it.`:`Sent to any agent. None is online right now, so it waits until one is.`:`Sent to any agent. No agent is connected to this project yet, so it waits until one is.`,canRelease:!1}}var sE=e=>e.charAt(0).toLowerCase()+e.slice(1),cE=`No agent is connected: comments wait until one is`,lE=`No agent is online: comments wait until one is`;function uE(e){let t=e?.agents||[];if(!t.length)return cE;if(!t.filter(e=>e.state!==`offline`).length)return lE;let n={online:`online`,busy:`working`,offline:`offline`},r=t.slice(0,3).map(e=>`${e.name} ${n[e.state]||e.state}`);return t.length>3?`${r.join(`, `)} and ${t.length-3} more`:r.join(`, `)}var dE=e=>e?(e.agents||[]).some(e=>e.state!==`offline`):null,fE=e=>e?.link?.connected&&e.edits?.text?e.edits.text:``;function pE(e,t=null){let n=e?.agents||[],r=[rE(n,t?.agentId),rE(n,e?.defaultAgentId),...n].filter(Boolean),i=e=>r.find(t=>e.includes(t))||null,a=n.filter(e=>e.edits?.fix?.ok===!0);if(!a.length){let e=n.filter(e=>e.link?.connected&&e.edits?.fix?.reason),t=i(e.filter(e=>e.edits.mode!==`none`))||i(e);return{agent:null,options:[],reason:t?t.edits.fix.reason:null}}let o=i(a);return{agent:o,options:a.length>1?[o,...a.filter(e=>e!==o)].map(e=>({id:e.id,label:e.name,configured:!0,state:tE[e.state]||`ready`,line:[fE(e)||nE(e),e.machine].filter(Boolean).join(` · `),isDefault:!!e.isDefault,icon:e.icon||null,tint:e.tint||null,logo:e.logo||null})):[],reason:null}}var mE=[`admin`,`owner`];function hE({comment:e,list:t,onChoose:n,touch:i,align:a=`end`,heading:o,children:s}){let c=iE(t);return(0,Y.jsxs)(je,{modal:!1,children:[(0,Y.jsx)(T,{asChild:!0,children:s}),(0,Y.jsxs)(r,{align:a,className:O(`w-[min(20rem,calc(100vw-1.5rem))]`,i&&`p-1.5`),"data-sw-send-agent-menu":e.id,children:[(0,Y.jsx)(k,{className:`tracking-normal normal-case`,children:o}),c.map(e=>(0,Y.jsxs)(D,{disabled:e.disabled,textValue:e.label,onSelect:()=>n(e.id),className:`h-auto min-h-11 items-start py-2 data-[disabled]:opacity-100 lg:h-auto lg:min-h-11`,"aria-label":`${e.label}${e.isDefault?`, default`:``}, ${e.line}`,"data-sw-send-agent-option":e.id,"data-sw-send-agent-name":e.label,"data-sw-agent-state":e.state,"data-sw-send-agent-blocked":e.disabled?`true`:void 0,children:[(0,Y.jsx)(QT,{label:e.label,state:e.mark,icon:e.icon,tint:e.tint,logo:e.logo,className:O(`mt-0.5`,e.disabled&&`opacity-50`)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:O(`truncate font-medium`,e.disabled?`text-muted`:`text-fg`),children:e.label}),e.isDefault?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-line px-1.5 text-[10px] leading-4 font-medium text-muted`,"data-sw-agent-default":`true`,children:`Default`}):null]}),(0,Y.jsx)(`span`,{className:`line-clamp-3 text-[11.5px] leading-4 font-normal text-muted`,"data-sw-send-agent-line":!0,children:e.line})]})]},e.id)),c.length?(0,Y.jsx)(y,{}):null,(0,Y.jsxs)(D,{onSelect:()=>n(null),className:`h-auto min-h-11 items-start py-2 lg:h-auto lg:min-h-11`,"data-sw-send-agent-option":`any`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-line bg-surface-2 text-muted`,children:(0,Y.jsx)(cv,{size:14,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-fg`,children:`Any agent`}),(0,Y.jsx)(`span`,{className:`block text-[11.5px] leading-4 font-normal text-muted`,children:`The first one that is free takes it.`})]})]})]})]})}function gE({comment:e,list:t=null,role:n=null,busy:r=!1,touch:i=!1,onSend:o,onRelease:s}){let c=i?`touch`:`sm`,l=mE.includes(n),u=oE(e,t),d=!!t,f=!!t?.agents?.length;if(e.needsRunApproval&&!e.dispatchable){let n=(t?.agents||[]).find(t=>t.id===e.agentId)||null;return(0,Y.jsxs)(`div`,{className:`space-y-1.5 py-2`,"data-sw-send-agent-block":e.id,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(a,{size:c,disabled:r||!l,onClick:()=>o(e),"data-sw-send-agent":e.id,children:l?`Approve agent run`:`Awaiting run approval`}),l&&f?(0,Y.jsx)(hE,{comment:e,list:t,onChoose:t=>o(e,t),touch:i,align:`start`,heading:`Approve it and send it to`,children:(0,Y.jsxs)(a,{size:c,variant:`ghost`,disabled:r,"data-sw-send-agent-choose":e.id,children:[`Choose another `,(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})]})}):null]}),d?(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-send-agent-asked":n?n.id:`any`,children:[n?`Asked for ${n.name}.`:`Asked for any agent.`,n&&!n.canSend&&l?` ${n.reason}`:``]}):null]})}if(e.dispatchable)return u?(0,Y.jsxs)(`div`,{className:`space-y-1.5 py-2`,"data-sw-send-agent-block":e.id,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-start gap-2 text-xs text-fg`,role:`status`,"data-sw-sent-agent":u.kind,children:[u.agent?(0,Y.jsx)(ge,{label:u.agent.name,icon:u.agent.icon,tint:u.agent.tint,logo:u.agent.logo,size:`sm`}):(0,Y.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[5px] border border-line bg-surface-2 text-muted`,children:(0,Y.jsx)(cv,{size:11,"aria-hidden":`true`})}),(0,Y.jsx)(`span`,{className:O(`min-w-0 pt-0.5`,u.kind===`waiting`?`text-fg`:`text-muted`),children:u.text})]}),u.kind!==`working`&&(u.canRelease||f)?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[u.canRelease&&s?(0,Y.jsx)(a,{size:c,variant:u.kind===`waiting`?`default`:`secondary`,disabled:r,onClick:()=>s(e),"data-sw-release-agent":e.id,children:`Let any agent take it`}):null,f?(0,Y.jsx)(hE,{comment:e,list:t,onChoose:t=>o(e,t),touch:i,align:`start`,heading:`Send it to`,children:(0,Y.jsxs)(a,{size:c,variant:`ghost`,disabled:r,"data-sw-send-agent-choose":e.id,children:[`Choose another `,(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})]})}):null]}):null]}):null;let p=aE(t);return!d||!f?(0,Y.jsxs)(`div`,{className:`py-2`,"data-sw-send-agent-block":e.id,children:[(0,Y.jsxs)(a,{size:c,disabled:r,onClick:()=>o(e),"data-sw-send-agent":e.id,children:[(0,Y.jsx)(O_,{size:13,"aria-hidden":`true`}),` Send to agent`]}),d?(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs text-muted`,role:`status`,"data-sw-no-agent-listening":`true`,children:`No agent is connected to this project yet: a comment sent to an agent waits until one is (shapewall watch --remote).`}):null]}):(0,Y.jsx)(`div`,{className:`py-2`,"data-sw-send-agent-block":e.id,children:(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full`,"data-sw-send-agent-split":e.id,children:[(0,Y.jsxs)(a,{size:c,className:`min-w-0 rounded-r-none pr-2.5`,disabled:r,onClick:()=>o(e,p.agentId),"data-sw-send-agent":e.id,"data-sw-send-agent-target":p.agentId||`any`,children:[(0,Y.jsx)(O_,{size:13,className:`shrink-0`,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`truncate`,children:p.label})]}),(0,Y.jsx)(hE,{comment:e,list:t,onChoose:t=>o(e,t),touch:i,heading:`Send this comment to`,children:(0,Y.jsx)(a,{size:c,className:`-ml-px rounded-l-none px-2`,disabled:r,"aria-label":`Send to another agent`,"data-sw-send-agent-choose":e.id,children:(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})})})]})})}var _E=e=>`comment-${e}`,vE=/^chat-[a-z0-9]{16}$/,yE=e=>vE.test(String(e||``)),bE=e=>e===`board`?`board`:String(e||``).startsWith(`comment-`)?`comment`:`chat`;function xE(){let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),`chat-${[...e].map(e=>`abcdefghijklmnopqrstuvwxyz0123456789`[e%36]).join(``)}`}var SE=e=>e===`board`?`board`:yE(e)?e:`c${String(e).slice(8)}`;function CE(e){return e===`board`?`board`:/^c[1-9]\d{0,8}$/.test(e||``)?_E(e.slice(1)):yE(e)?e:null}var wE=new Map,TE=e=>`shapewall.lastChat.${e||``}`;function EE(e,t){if(CE(t)){wE.set(e||``,t);try{globalThis.sessionStorage?.setItem(TE(e),t)}catch{}}}function DE(e){let t=wE.get(e||``);if(!t)try{t=globalThis.sessionStorage?.getItem(TE(e))||``}catch{t=``}return CE(t)?t:`board`}var OE=864e5,kE=e=>{let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()};function AE(e,{now:t=Date.now(),timeOf:n=e=>new Date(e).getTime()}={}){let r=kE(t),i=[{id:`today`,label:`Today`,items:[]},{id:`yesterday`,label:`Yesterday`,items:[]},{id:`earlier`,label:`Earlier`,items:[]}];for(let t of e){let e=n(t.updatedAt);i[Number.isFinite(e)&&e>=r?0:Number.isFinite(e)&&e>=r-OE?1:2].items.push(t)}return i.filter(e=>e.items.length)}function jE(e,t=null){let n=bE(e);return n===`comment`?Me(t).replace(/\s+/g,` `).trim().slice(0,60)||`Comment chat`:n===`board`?`Board chat`:`New chat`}var ME=e=>String(e||``).split(`
|
|
29
29
|
`).map(e=>`> ${e}`.trimEnd()).join(`
|
|
30
|
-
`);function
|
|
31
|
-
`).trimEnd()}\n`}function
|
|
32
|
-
`).length)),j=`sw-reply-image-error-${e.id}`;return(0,Y.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2 border-t border-line px-3 py-2`,onSubmit:k,...dS(C,x),"data-sw-reply-form":e.id,children:[h?(0,Y.jsxs)(`label`,{className:`flex w-full items-center gap-2 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Your name`}),(0,Y.jsx)(it,{size:r?`touch`:`xs`,value:_,onChange:e=>v(e.target.value.slice(0,60)),placeholder:`shown on your reply`,className:`flex-1`,"data-sw-reply-author":e.id})]}):null,(0,Y.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Reply to comment `,e.id]}),(0,Y.jsx)(Ib,{rows:A,size:r?`touch`:`sm`,value:d,maxLength:Qw,onChange:p,people:i,className:`resize-none`,placeholder:r?`Reply`:`Reply, @ to mention`,onKeyDown:e=>{$w(e,r)&&(e.preventDefault(),k())},autoFocus:o,"aria-describedby":C.error?j:void 0,"data-sw-reply-input":e.id})]}),(0,Y.jsx)(B,{type:`submit`,variant:`default`,size:r?`icon`:`icon-sm`,className:`rounded-full`,disabled:t||C.reading||!d.trim()&&!D&&!C.images.length,label:t&&C.images.length?`Uploading the reply`:`Send reply`,"data-sw-reply-send":e.id,children:(0,Y.jsx)(oh,{size:16,"aria-hidden":`true`})}),x?(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(fS,{draft:C,touch:r,id:j})}):null,x||S||l?.attachNote?(0,Y.jsxs)(`div`,{className:`-mt-1 -ml-1 flex w-full flex-wrap items-center gap-0.5`,"data-sw-reply-media":e.id,children:[S&&!r?(0,Y.jsx)(oS,{owner:T,touch:!1,compact:!0,className:`flex-1`,leading:x?(0,Y.jsx)(uS,{draft:C,touch:!1,disabled:t}):null}):x?(0,Y.jsx)(uS,{draft:C,touch:r,disabled:t}):null,S&&r&&O?(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,onClick:()=>b(!0),"data-sw-draw-open":`true`,children:[(0,Y.jsx)(ch,{size:16,"aria-hidden":`true`}),` `,D?`Drawing (${D})`:`Draw on the page`]}):null,l?.attachNote?(0,Y.jsx)(`p`,{className:`w-full px-1 text-caption text-faint`,"data-sw-attach-note":`true`,children:l.attachNote}):null]}):null,S&&r&&O?(0,Y.jsx)(lS,{open:y,onClose:()=>b(!1),owner:T,src:O.src,native:O.native,title:l.pageTitle}):null]})}function lE({item:e,currentVersion:t,onShow:n}){if(!e?.drawing?.shapes?.length)return null;let r=!!(e.drawing.captureVersion&&t&&e.drawing.captureVersion!==t),i=e.drawing.shapes.length;return(0,Y.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted`,"data-sw-message-drawing":r?`previous`:`current`,children:[(0,Y.jsx)(ch,{size:11,className:`mr-1 inline-block align-[-1px]`,"aria-hidden":`true`}),r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[`Drawn on the previous capture (`,i===1?`one shape`:`${i} shapes`,`).`]}),` `,n?(0,Y.jsx)(`button`,{type:`button`,className:`rounded text-accent underline-offset-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-accent`,onClick:n,"data-sw-show-drawing":`true`,children:`View it on Before`}):null]}):(0,Y.jsxs)(`span`,{children:[`Drawn on the page (`,i===1?`one shape`:`${i} shapes`,`), shown over the frame.`]})]})}function uE({comment:e,page:t,title:n,people:i,touch:o,me:s,can:c,busy:l,actions:u,nav:d,beforeAfter:f,onClose:p=null,editingRef:m=null,denial:h=null,role:g=null,hosted:v=null,agents:b=null,onSaveName:x=null,media:S=null,notice:C=null}){let[w,E]=(0,J.useState)(!1),[k,A]=(0,J.useState)(!1),j=(0,J.useRef)(null);(0,J.useEffect)(()=>{E(!1),A(!1)},[e.id]),m&&(m.current=w?()=>E(!1):null);let ee=e.replies?.length||0;(0,J.useEffect)(()=>{let e=j.current;e&&(e.scrollTop=e.scrollHeight)},[e.id,ee]);let M=e.status===`resolved`,N=M&&e.agentStatus!==`done`?null:e.agentStatus,P=o?`icon`:`icon-sm`,F=Iv(e.viewport,null),L=!!u.onFixAgent&&e.status===`open`,R=e.reopenCount>0&&!M||!!N,z=e.github?.issue?gb(e.github.issue.url):null,te=S?.currentVersion?.(e)||null,V=()=>{let e=j.current?.querySelector(`[data-sw-before-after]`);e?.scrollIntoView?.({block:`nearest`}),e?.querySelector(`[data-sw-compare-handle], [role="tab"]`)?.focus?.()},ne=[u.onCopyLink?{id:`link`,label:`Copy link`,icon:wg,run:()=>u.onCopyLink(e),hook:`data-sw-copy-link`}:null,c.edit?{id:`edit`,label:`Edit`,icon:o_,run:()=>E(!0),hook:`data-sw-edit`}:null,u.onAskAgent?{id:`agent`,label:`Ask agent`,icon:I,run:()=>u.onAskAgent(e),hook:`data-sw-ask-agent`}:null,z?{id:`issue`,label:`Open issue #${e.github.issue.number} on GitHub`,icon:vh,href:z,hook:`data-sw-github-open`}:u.onGithubIssue&&c.resolve?{id:`issue`,label:`Create a GitHub issue`,icon:vh,run:()=>u.onGithubIssue(e),hook:`data-sw-github-issue`}:null,u.onHistory&&t?{id:`history`,label:`Page history`,icon:f_,run:()=>u.onHistory(e),hook:`data-sw-comment-history`}:null,t?.url?{id:`page`,label:`Open the page`,icon:Ih,href:t.url,hook:`data-sw-open-page`}:null].filter(Boolean);return(0,Y.jsxs)(`div`,{className:`flex max-h-[inherit] min-h-0 flex-col`,"data-sw-selected-comment":e.id,"data-sw-thread":e.id,children:[(0,Y.jsxs)(`div`,{className:O(`flex shrink-0 items-center gap-0.5 border-b border-line`,o?`px-2 py-1`:`cursor-grab touch-none py-1 pr-1 pl-3 select-none`),"data-sw-card-drag-handle":o?void 0:`true`,children:[(0,Y.jsx)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-xs text-muted`,"data-sw-thread-title":`true`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg tabular`,children:[`#`,e.id]}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:n}),F?(0,Y.jsx)(_,{content:`${e.viewport[0].toUpperCase()}${e.viewport.slice(1)} capture`,children:(0,Y.jsx)(`span`,{className:`inline-flex shrink-0 text-faint`,"aria-label":`${e.viewport} capture`,role:`img`,children:(0,Y.jsx)(F,{size:12,"aria-hidden":`true`})})}):(0,Y.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`· `,e.viewport]})]}):null}),d?.total>1?(0,Y.jsxs)(`div`,{className:O(`flex shrink-0 items-center gap-0.5`,p?null:`order-first`),"data-sw-thread-steps":`true`,children:[(0,Y.jsx)(B,{size:P,onClick:d.onPrev,label:rE(`Previous thread`,d.prevNote),tooltip:rE(`Previous thread (Left arrow)`,d.prevNote),"data-sw-thread-prev":`true`,"data-sw-thread-note":d.prevNote||void 0,children:(0,Y.jsx)(ut,{size:16,"aria-hidden":`true`})}),p?null:(0,Y.jsxs)(`span`,{className:`tabular px-0.5 text-xs whitespace-nowrap text-muted`,"data-sw-thread-step-of":`true`,children:[d.index+1,` of `,d.total]}),(0,Y.jsx)(B,{size:P,onClick:d.onNext,label:rE(`Next thread`,d.nextNote),tooltip:rE(`Next thread (Right arrow)`,d.nextNote),"data-sw-thread-next":`true`,"data-sw-thread-note":d.nextNote||void 0,children:(0,Y.jsx)(nt,{size:16,"aria-hidden":`true`})})]}):null,c.resolve?(0,Y.jsx)(B,{size:P,variant:M?`default`:`ghost`,className:O(`rounded-full`,M&&`bg-ok text-ok-fg hover:bg-ok/90`),disabled:l,"aria-pressed":M,onClick:()=>u.onStatus(e,M?`reopen`:`resolve`),label:M?`Reopen the thread`:`Resolve the thread`,tooltip:M?`Resolved: reopen`:`Resolve`,...M?{"data-sw-reopen":e.id}:{"data-sw-resolve":e.id},children:(0,Y.jsx)(st,{size:16,strokeWidth:2.5,"aria-hidden":`true`})}):M?(0,Y.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,Y.jsx)(st,{size:12,"aria-hidden":`true`}),` Resolved`]}):null,ne.length||c.delete?(0,Y.jsxs)(je,{children:[(0,Y.jsx)(_,{content:`More`,children:(0,Y.jsx)(T,{asChild:!0,children:(0,Y.jsx)(a,{variant:`ghost`,size:P,"aria-label":`More for comment ${e.id}`,"data-sw-thread-menu":e.id,children:(0,Y.jsx)(Ph,{size:16,"aria-hidden":`true`})})})}),(0,Y.jsxs)(r,{align:`end`,children:[ne.map(t=>t.href?(0,Y.jsx)(D,{asChild:!0,[t.hook]:e.id,children:(0,Y.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]})},t.id):(0,Y.jsxs)(D,{onSelect:t.run,[t.hook]:e.id,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]},t.id)),c.delete?(0,Y.jsxs)(Y.Fragment,{children:[ne.length?(0,Y.jsx)(y,{}):null,(0,Y.jsxs)(D,{tone:`danger`,onSelect:()=>A(!0),"data-sw-delete":e.id,children:[(0,Y.jsx)(X_,{size:14,"aria-hidden":`true`}),` Delete thread`]})]}):null]})]}):null,p?(0,Y.jsx)(B,{size:P,onClick:p,label:`Close the thread`,tooltip:`Close (Esc)`,"data-sw-thread-close":`true`,children:(0,Y.jsx)(se,{size:16,"aria-hidden":`true`})}):null]}),C?(0,Y.jsx)(`div`,{className:`shrink-0`,children:C}):null,L||R?(0,Y.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,Y.jsx)(Sb,{comment:e}),L&&[`queued`,`working`].includes(N)?null:(0,Y.jsx)(xb,{status:N,at:e.agentStatusAt,branch:e.agentBranch||null}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`}),L?(0,Y.jsx)(tE,{comment:e,onFix:u.onFixAgent,onOpenChat:u.onAskAgent,busy:l,touch:o}):null]}):null,(0,Y.jsxs)(`div`,{ref:j,className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[e.orphanReason?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:e.orphanReason}):null,e.imported&&e.agentStatus?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:`Imported agent status (history)`}):null,u.onHostedFix?(0,Y.jsx)(nE,{comment:e,list:b,busy:l,touch:o,onFix:u.onHostedFix,onOpenChat:u.onAskAgent||null}):null,u.onSendToAgent&&e.status===`open`?(0,Y.jsx)(FT,{comment:e,list:b,role:g,busy:l,touch:o,onSend:u.onSendToAgent,onRelease:u.onReleaseAgent||null}):null,u.onHostedFix?(0,Y.jsx)(nE,{slot:`status`,comment:e,list:b,busy:l,touch:o,onFix:u.onHostedFix,onOpenChat:u.onAskAgent||null}):null,(0,Y.jsxs)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Comment ${e.id} and replies`,children:[(0,Y.jsxs)(oE,{author:Db(e),at:e.createdAt,editedAt:e.editedAt,reactions:e.reactions,canReact:c.react,me:s,onReact:t=>u.onReact(e,t,null),touch:o,"data-sw-message":`comment`,children:[w?(0,Y.jsx)(sE,{comment:e,busy:l,onSave:u.onEdit,onCancel:()=>E(!1),touch:o,people:i}):e.body?(0,Y.jsx)(Pb,{text:e.body,plain:!!e.authorGuest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}):null,(0,Y.jsx)(pS,{boardId:S?.boardId,images:e.images,touch:o,label:`Comment ${e.id}`}),(0,Y.jsx)(lE,{item:e,currentVersion:te,onShow:V}),e.anchor?(0,Y.jsx)(_,{content:(0,Y.jsx)(`span`,{className:`font-mono text-[11px] break-all`,children:e.anchor.selector}),children:(0,Y.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,Y.jsx)(Ah,{size:11,className:`shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Pinned to`}),(0,Y.jsx)(`span`,{className:`truncate text-fg`,children:jb(e.anchor)})]})}):null,t?.note?(0,Y.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-xs text-faint`,"data-sw-page-note":`true`,children:[(0,Y.jsx)(mg,{size:11,className:`mt-0.5 shrink-0`,"aria-hidden":`true`}),` `,t.note]}):null,e.resolution?(0,Y.jsxs)(`p`,{className:`mt-1.5 rounded bg-ok/10 px-2 py-1 text-xs text-fg`,children:[`Fix: `,e.resolution]}):null,(0,Y.jsx)(_b,{value:e.fixRef,touch:o}),(0,Y.jsx)(yb,{github:e.github,touch:o}),f?(0,Y.jsx)(lT,{comment:e,pair:f.pairFor(e),native:f.nativeFor(e),urlFor:f.urlFor,onImageError:f.onImageError,touch:o}):null]}),(e.replies||[]).length?(0,Y.jsx)(`li`,{"data-sw-replies":`true`,children:(0,Y.jsx)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Replies`,children:e.replies.map(t=>(0,Y.jsxs)(oE,{author:Ob(t),at:t.createdAt,reactions:t.reactions,canReact:c.react,me:s,onReact:n=>u.onReact(e,n,t.id),touch:o,"data-sw-reply":t.id,children:[t.body?(0,Y.jsx)(Pb,{text:t.body,plain:!!t.guest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}):null,(0,Y.jsx)(pS,{boardId:S?.boardId,images:t.images,touch:o,label:`Reply ${t.id}`}),(0,Y.jsx)(lE,{item:t,currentVersion:te,onShow:V})]},t.id))})}):null]})]}),k?(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Delete this thread and its replies for good?`}),(0,Y.jsx)(a,{size:o?`touch`:`xs`,variant:`ghost`,onClick:()=>A(!1),disabled:l,children:`Cancel`}),(0,Y.jsxs)(a,{size:o?`touch`:`xs`,variant:`secondary`,className:`text-bad`,onClick:()=>u.onDelete(e),disabled:l,"data-sw-delete-confirm":e.id,children:[(0,Y.jsx)(X_,{size:13,"aria-hidden":`true`}),` Delete`]})]}):null,c.reply?(0,Y.jsx)(cE,{comment:e,busy:l,onReply:u.onReply,touch:o,people:i,askName:v===!1,onSaveName:x,media:S},e.id):(0,Y.jsx)(`p`,{className:`shrink-0 border-t border-line px-3 py-2 text-xs text-muted`,"data-sw-reply-denied":g||`true`,children:h||iE(g)})]})}var dE={top:10,right:10,bottom:60,left:10},fE={...dE,bottom:dE.bottom+40};function pE(e,t,n,r,i=dE){let a=Math.max(t.left+i.left,Math.min(t.right-i.right-n,e.x)),o=Math.max(t.top+i.top,Math.min(t.bottom-i.bottom-r,e.y));return{x:Math.round(a),y:Math.round(o)}}function mE({pin:e,target:t=null,box:n,width:r,height:i,gap:a=10,padding:o=dE}){let s=n.right-o.right-e.right>=r+a,c=e.left-(n.left+o.left)>=r+a,l={side:s?`right`:c?`left`:`bottom`,on:`pin`};return t?s&&t.right<=e.right+a?{side:`right`,on:`pin`}:c&&t.left>=e.left-a?{side:`left`,on:`pin`}:n.bottom-o.bottom-t.bottom>=i+a?{side:`bottom`,on:`target`}:t.top-(n.top+o.top)>=i+a?{side:`top`,on:`target`}:l:l}var hE=`input, textarea, select, [contenteditable="true"]`,gE=()=>!!document.querySelector(`[data-sw-tool-note]`),_E=-6,vE=4,yE=640;function bE(e,t){return!t||e.left<t.right-4||e.left>t.right+yE||e.bottom<t.top||e.top>t.bottom?e:new DOMRect(t.right-4-e.width,e.top,e.width,e.height)}function xE(e,t,n,r){let i=rd(),a=(0,J.useRef)(null),o=(0,J.useRef)({selector:e,point:t,avoid:n});if(o.current={selector:e,point:t,avoid:n},!a.current){let e=()=>i.getState().domNode?.getBoundingClientRect()||null,t=()=>{let{domNode:t,transform:n}=i.getState(),{selector:r,point:a}=o.current,s=e(),c=r?t?.querySelector(r):null;if(c)return bE(c.getBoundingClientRect(),s);if(!s||!a)return new DOMRect(-1e4,-1e4,0,0);let[l,u,d]=n;return bE(new DOMRect(s.left+a.x*d+l,s.top+a.y*d+u,0,0),s)},n=()=>{let{avoid:e}=o.current,t=e?i.getState().domNode?.querySelector(e):null;return t?t.getBoundingClientRect():null};a.current={canvasBox:e,pinRect:t,targetRect:n,getBoundingClientRect(){let{on:i,side:a,width:o,height:s,moved:c,padding:l=dE}=r.current,u=e();if(c&&u){let e=pE(c,u,o,s,l);return new DOMRect(e.x,e.y,0,0)}let d=t(),f=i===`target`?n():null,p=d.left;if(u&&(a===`top`||a===`bottom`)){let e=u.left+dE.left-_E,t=u.right-dE.right-o-_E;p=Math.max(e,Math.min(t,p))}if(!f)return new DOMRect(p,d.top,d.width,d.height);let m=Math.min(f.top,d.top);return new DOMRect(p,m,d.width,Math.max(f.bottom,d.bottom)-m)}}}return a}function SE(e,t,n,r,i){let a=rd(),[o,s]=(0,J.useState)(`right`),[c,l]=(0,J.useState)(dE);return(0,J.useEffect)(()=>{if(!e)return;let o=()=>{let e=t.current.canvasBox();if(!e)return;let a=n.current?.offsetWidth||360,o=n.current?.offsetHeight||240,c=gE()?fE:dE;if(l(c),i){r.current={on:`pin`,side:`bottom`,width:a,height:o,moved:i,padding:c},s(`bottom`);return}let u=mE({pin:t.current.pinRect(),target:t.current.targetRect(),box:e,width:a,height:o,gap:10,padding:c});r.current={...u,width:a,height:o,moved:null,padding:c},s(u.side)};o();let c=a.subscribe(o),u=new ResizeObserver(o),d=a.getState().domNode;d&&u.observe(d),n.current&&u.observe(n.current);let f=window.setInterval(o,250);return()=>{c(),u.disconnect(),window.clearInterval(f)}},[e,a,t,n,r,i]),{side:o,padding:c}}function CE(e,t,n){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1);(0,J.useEffect)(()=>i(null),[n]);let s=(0,J.useRef)(null);return(0,J.useEffect)(()=>()=>s.current?.(),[]),{moved:r,dragging:a,onPointerDown:n=>{if(n.button!==0||!n.target.closest?.(`[data-sw-card-drag-handle]`)||n.target.closest(`button, a, input, textarea, select, [role="button"], [role="menuitem"]`))return;let r=e.current,a=t.current.canvasBox();if(!r||!a)return;let c=r.getBoundingClientRect(),l={x:n.clientX,y:n.clientY},u=!1,d=e=>{let n=e.clientX-l.x,r=e.clientY-l.y;!u&&Math.hypot(n,r)<vE||(u=!0,o(!0),e.preventDefault(),i(pE({x:c.left+n,y:c.top+r},t.current.canvasBox()||a,c.width,c.height,gE()?fE:dE)))},f=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),s.current=null,o(!1)};s.current=f,window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)}}}function wE({open:e,onClose:t,selector:n,point:r,avoid:i=null,resetKey:a=null,children:o,label:s,onKeyDown:c,onEscape:l,focusContent:u,stowed:d,className:f,...p}){let m=rd(),h=(0,J.useRef)({on:`pin`,side:`right`,width:360,height:240,moved:null}),g=xE(n,r,i,h),_=(0,J.useRef)(null),v=CE(_,g,a),{side:y,padding:b}=SE(e,g,_,h,v.moved),x=!!v.moved;return(0,Y.jsxs)(lt,{open:e,onOpenChange:e=>e?null:t(),children:[(0,Y.jsx)(fe,{virtualRef:g}),(0,Y.jsx)(ot,{ref:_,side:y,align:`start`,sideOffset:x?0:10,alignOffset:x?0:_E,avoidCollisions:!x,collisionBoundary:m.getState().domNode,collisionPadding:b,sticky:`always`,hideWhenDetached:!x,updatePositionStrategy:`always`,"aria-label":s,className:O(`z-30`,f,d&&`invisible`,v.dragging&&`cursor-grabbing select-none [&_*]:cursor-grabbing`),"data-sw-stowed":d?`true`:void 0,"data-sw-card-moved":x?`true`:void 0,onPointerDown:v.onPointerDown,onOpenAutoFocus:e=>{u&&(e.preventDefault(),_.current?.focus({preventScroll:!0}))},onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>{l?.(e)===!1&&e.preventDefault()},onKeyDown:e=>{_.current?.contains(e.target)&&!e.target?.closest?.(hE)&&c?.(e)},tabIndex:-1,...p,children:o})]})}function TE(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 EE(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 DE({comment:e,point:t,onClose:n,onPrev:r,onNext:i,editingRef:a,stowed:o,children:s}){let c=(0,J.useRef)({onPrev:r,onNext:i});c.current={onPrev:r,onNext:i},(0,J.useEffect)(()=>{let e=e=>{e.defaultPrevented||document.activeElement!==document.body||document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||EE(e,c.current.onPrev,c.current.onNext)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,J.useEffect)(()=>{let t=window.setTimeout(()=>{let t=document.activeElement;(t===document.body||t?.hasAttribute?.(`data-sw-canvas`))&&document.querySelector(`[data-sw-thread-popover="${e.id}"]`)?.focus({preventScroll:!0})},450);return()=>window.clearTimeout(t)},[e.id]);let l=()=>{if(a?.current&&document.activeElement?.closest?.(`[data-sw-edit-form]`))return a.current(),!1;let t=String(e.id);return window.setTimeout(()=>TE(t),0),!0},u=(0,J.useRef)(null);return u.current={escape:l,onClose:n},(0,J.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&document.querySelector(`[data-sw-pin-preview]`)&&(document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||(e.preventDefault(),e.stopPropagation(),u.current.escape()!==!1&&u.current.onClose()))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Y.jsx)(wE,{open:!0,onClose:n,selector:`[data-sw-pin="${e.id}"]`,avoid:`[data-sw-thread-target="${e.id}"]`,resetKey:e.id,point:t,label:`Comment ${e.id}`,focusContent:!0,stowed:o,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:l,onKeyDown:e=>EE(e,r,i),"data-sw-thread-popover":e.id,children:s})}function OE({point:e,onClose:t,onEscape:n,resetKey:r,stowed:i,children:a}){return(0,Y.jsx)(wE,{open:!0,onClose:t,onEscape:n,resetKey:r,selector:`[data-sw-draft-pin]`,avoid:`[data-sw-picked-outline]`,point:e,label:`New comment`,stowed:i,className:`w-[340px] p-3`,"data-sw-composer-popover":`true`,children:a})}var kE=600,AE=e=>`shapewall.seen:${typeof window>`u`?``:window.location.pathname}:${e}`;function jE(e){try{let t=JSON.parse(window.localStorage.getItem(AE(e))||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function ME(e,t){try{let n=Object.entries(t).sort((e,t)=>String(t[1]).localeCompare(String(e[1]))).slice(0,kE);window.localStorage.setItem(AE(e),JSON.stringify(Object.fromEntries(n)))}catch{}}function NE(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 PE(e,t){return t?t.handle&&e.handle?e.handle===t.handle:!!t.name&&String(e.author||``).toLowerCase()===String(t.name).toLowerCase():!1}function FE(e,t,n){let r=NE(e);return!r.at||PE(r,n)?!1:!t[e.id]||String(t[e.id])<String(r.at)}function IE(e){let[t,n]=(0,J.useState)(()=>jE(e));(0,J.useEffect)(()=>{n(jE(e));let t=t=>{t.key===AE(e)&&n(jE(e))};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e]);let r=(0,J.useCallback)(t=>{n(n=>{let r=!1,i={...n};for(let e of t){let t=NE(e).at;t&&String(i[e.id]||``)<String(t)&&(i[e.id]=t,r=!0)}return r?(ME(e,i),i):n})},[e]);return{seen:t,markSeen:(0,J.useCallback)(e=>r([e]),[r]),markAllSeen:r}}var LE=[`viewer`,`member`,`admin`,`owner`],RE=(e,t)=>LE.indexOf(e)>=LE.indexOf(t)&&LE.includes(e),zE=({isAuthor:e})=>!!e,BE=({role:e,isAuthor:t})=>RE(e,`member`)&&(!!t||RE(e,`admin`)),VE=`https://shapewall.com/contact`,HE={version:`0.8.0`,revision:`d89ef355b30aa13ff386887ce4c06f35761ba469`},UE=e=>`v${e?.version||HE.version}${e?.revision?` · ${e.revision.slice(0,7)}`:``}`,WE=`modulepreload`,GE=function(e,t){return new URL(e,t).href},KE={},qE=function(e){return e.pathname.endsWith(`.css`)},JE=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},YE=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=GE(t,n);let r=s(t),i=qE(r);return JE(KE,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`:WE,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)})},XE=(0,J.lazy)(()=>YE(()=>import(`./app-update-dialog-DNL0kP9U.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)),ZE=`shapewall:open-about`;function QE(e=null){window.dispatchEvent(new CustomEvent(ZE,{detail:{opener:e}}))}function $E({transport:e,className:t,placement:n=`menu`,ref:r}){let[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=e=>{u.current=e||null,c(!0),o(!0)};(0,J.useImperativeHandle)(r,()=>({open:()=>d(document.activeElement)}),[]),(0,J.useEffect)(()=>{let e=e=>d(e.detail?.opener||null);return window.addEventListener(ZE,e),()=>window.removeEventListener(ZE,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, ${UE(HE)}, created by Dan Baruch`;return(0,Y.jsxs)(Y.Fragment,{children:[n===`footer`?(0,Y.jsx)(`footer`,{className:O(`flex shrink-0 justify-center border-t border-line bg-surface text-muted`,t),style:{paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:(0,Y.jsxs)(a,{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,Y.jsx)(`span`,{children:`Created by Dan Baruch`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{"data-sw-app-version":!0,children:UE(HE)})]})}):n===`link`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(a,{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,Y.jsx)(`a`,{href:VE,target:`_blank`,rel:`noopener noreferrer`,children:`Contact`})}),(0,Y.jsxs)(a,{variant:`ghost`,size:`touch`,className:O(`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,Y.jsx)(`span`,{children:`About Shapewall`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,"data-sw-app-version":!0,children:[`v`,HE.version]})]})]}):null,s?(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Opening About & Updates…`}),children:(0,Y.jsx)(XE,{open:i,onClose:f,onCloseAutoFocus:p,transport:e})}):null]})}function eD({demo:e,className:t,children:n,align:i=`start`}){return e.viewAs?(0,Y.jsxs)(je,{children:[(0,Y.jsx)(T,{asChild:!0,children:n}),(0,Y.jsxs)(r,{align:i,className:O(`w-64`,t),children:[(0,Y.jsx)(k,{children:`View as (demo)`}),(0,Y.jsx)(ee,{value:e.viewAs.value,onValueChange:e.viewAs.onChange,children:e.viewAs.options.map(e=>(0,Y.jsxs)(p,{value:e.id,"data-sw-view-as":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]})]}):n}var tD=()=>(0,Y.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,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),`Demo`]});function nD({variant:e=`strip`,className:t}){let n=ue();return n?e===`chip`?(0,Y.jsxs)(`div`,{className:O(`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":n.role,children:[(0,Y.jsx)(eD,{demo:n,align:`end`,children:(0,Y.jsxs)(a,{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 `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(tD,{}),(0,Y.jsx)(`span`,{className:`hidden max-w-28 truncate font-medium sm:inline`,children:n.roleLabel}),(0,Y.jsx)(pe,{size:13,className:`text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(B,{label:`Reset the demo`,size:`icon`,className:`rounded-full text-muted max-lg:hidden lg:h-8 lg:w-8`,onClick:n.reset,"data-sw-demo-reset":!0,children:(0,Y.jsx)(m_,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(rD,{})]}):(0,Y.jsxs)(`div`,{className:O(`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":n.role,children:[(0,Y.jsx)(tD,{}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`hidden shrink-0 sm:inline`,children:`Viewing as`}),(0,Y.jsx)(eD,{demo:n,children:(0,Y.jsxs)(a,{variant:`ghost`,size:`touch`,className:`min-w-0 gap-1 px-1.5 text-ui text-fg lg:h-7`,"aria-label":`Viewing as `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:n.roleLabel}),(0,Y.jsxs)(`span`,{className:`hidden truncate font-normal text-muted sm:inline`,children:[`(`,n.personaName,`)`]}),(0,Y.jsx)(pe,{size:13,className:`shrink-0 text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(`span`,{className:`hidden truncate text-faint md:inline`,children:`· Changes stay in this browser`})]}),(0,Y.jsxs)(a,{variant:`ghost`,size:`touch`,className:`shrink-0 gap-1.5 px-2 text-ui text-muted lg:h-7`,onClick:n.reset,"data-sw-demo-reset":!0,children:[(0,Y.jsx)(m_,{size:13,"aria-hidden":`true`}),` Reset`]}),(0,Y.jsx)(rD,{})]}):null}function rD(){let e=ue();return e?(0,Y.jsx)(N,{open:!!e.resetAsked,onClose:e.cancelReset,title:`Reset the demo?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{size:`touch`,variant:`ghost`,onClick:e.cancelReset,className:`lg:h-10`,"data-sw-demo-reset-cancel":!0,children:`Cancel`}),(0,Y.jsxs)(a,{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,Y.jsx)(m_,{size:14,"aria-hidden":`true`}),` Reset`]})]}),children:(0,Y.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 iD={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 aD({problem:e,onLeave:t}){let n=iD[e?.status]||iD.unknown,r=e?.at?new Date(e.at):null;return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Y.jsx)(nD,{}),(0,Y.jsx)(`main`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,Y.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,Y.jsx)(`span`,{className:`inline-flex h-11 w-11 items-center justify-center rounded-xl bg-bad/10 text-bad`,children:(0,Y.jsx)(Sg,{size:20,"aria-hidden":`true`})}),(0,Y.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:n.title}),(0,Y.jsxs)(`p`,{className:`mt-2 text-sm text-muted`,children:[n.text,r&&Number.isFinite(r.getTime())?(0,Y.jsxs)(Y.Fragment,{children:[` `,e.status===`revoked`?`Revoked`:`Expired`,` `,r.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`.`]}):null]}),(0,Y.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,Y.jsx)(a,{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 oD(e,t,n){let r;try{r=await fetch(t,{method:e,credentials:`same-origin`,headers:{...n===void 0?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`},...typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-accounts"]`)&&t.startsWith(`/auth/`)?Ze():{}},body:n===void 0?void 0:JSON.stringify(n),cache:`no-store`})}catch{throw new g(0,`offline`,`Could not reach the server. Check your connection and try again.`)}let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=Number(r.headers.get(`Retry-After`)),t=i?.error?.message||`Request failed (${r.status})`;throw new g(r.status,i?.error?.code||`error`,r.status===429&&e>0?cD(t,e):t,{retryAfter:r.status===429&&e>0?e:null,stepUp:i?.error?.stepUp||null,details:i?.error?.device||i?.error?.confirm?{...i.error.device?{device:String(i.error.device)}:{},...i.error.confirm?{confirm:String(i.error.confirm),confirms:i.error.confirms||null}:{}}:null})}return i}function sD(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 cD=(e,t)=>`${e.replace(/\s*Wait (a while|a moment) and try again\.?\s*$/i,``)} Try again in ${sD(t)}.`,lD={get:e=>oD(`GET`,e),post:(e,t={})=>oD(`POST`,e,t),patch:(e,t={})=>oD(`PATCH`,e,t),put:(e,t={})=>oD(`PUT`,e,t),delete:(e,t)=>oD(`DELETE`,e,t)},uD=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},dD=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function fD(e,{mediation:t,signal:n}={}){let r={...e,challenge:uD(e.challenge),allowCredentials:(e.allowCredentials||[]).map(e=>({...e,id:uD(e.id)}))},i=await navigator.credentials.get({publicKey:r,...t?{mediation:t}:{},...n?{signal:n}:{}}),a=i.response;return{id:i.id,rawId:dD(i.rawId),type:i.type,authenticatorAttachment:i.authenticatorAttachment||void 0,clientExtensionResults:i.getClientExtensionResults(),response:{clientDataJSON:dD(a.clientDataJSON),authenticatorData:dD(a.authenticatorData),signature:dD(a.signature),userHandle:a.userHandle?dD(a.userHandle):void 0}}}async function pD(){let{options:e}=await lD.post(`/auth/reauth/options`,{}),t=await fD(e);await lD.post(`/auth/reauth/verify`,{response:t})}var mD=`shapewall:hosted-agents`,hD=e=>String(e||``).replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),gD=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n].id&&e.thread===t[n].thread),_D=e=>/^comment-(\d+)$/.test(e||``)?Number(e.slice(8)):null,vD=e=>_D(e)?`comment #${_D(e)}`:`the board chat`;function yD({boardId:e,onRows:t=null,onOpenThread:n=null,openThread:r=null}){let[i,o]=(0,J.useState)([]),[s,c]=(0,J.useState)([]),l=!!n;(0,J.useEffect)(()=>{t?.([...i,...s.map(e=>({id:`card-${e.id}`,chat:!0,commentId:_D(e.thread)}))])},[t,i,s]);let[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),g=`/api/boards/${encodeURIComponent(e)}/approvals`;(0,J.useEffect)(()=>{let t=!0,n=()=>S.get(`/api/boards/${encodeURIComponent(e)}/agent-budget`).then(e=>{t&&d(e)}).catch(()=>{}),r=()=>S.get(g).then(e=>{t&&o(e.approvals)}).catch(()=>{}),i=()=>l?S.get(`/api/agent/boards/${encodeURIComponent(e)}/permissions`).then(e=>{let n=Array.isArray(e?.permissions)?e.permissions:[];t&&c(e=>gD(e,n)?e:n)}).catch(()=>{}):null;r(),i(),n();let a=()=>{document.visibilityState===`visible`&&(r(),i(),n())},s=setInterval(a,3e3);document.addEventListener(`visibilitychange`,a);let u=()=>i();return window.addEventListener(mD,u),()=>{t=!1,clearInterval(s),document.removeEventListener(`visibilitychange`,a),window.removeEventListener(mD,u)}},[g,e,l]);let _=async(e,t)=>{h(!0),p(null);try{let n=()=>S.post(`${g}/${e.id}`,{state:t,hash:e.command_hash});try{await n()}catch(e){if(e?.code!==`reauth_required`)throw e;await pD(),await n()}o(t=>t.filter(t=>t.id!==e.id))}catch(e){p(e.message)}finally{h(!1)}},v=s.filter(e=>e.thread!==r);return!i.length&&!v.length&&!f&&!u?.exhausted?null:(0,Y.jsxs)(`section`,{"aria-label":`Agent approvals`,className:`max-h-64 shrink-0 overflow-auto border-b border-line bg-surface p-3 text-sm`,children:[u?.exhausted?(0,Y.jsxs)(`p`,{role:`status`,className:`pb-2`,children:[`The agent hit today’s limit: `,u.claims,`/`,u.dailyLimit,` runs, `,u.open,`/`,u.openLimit,` in progress. Change limits in Agent policy in the console.`]}):null,v.length?(0,Y.jsx)(`ul`,{className:`space-y-1.5 pb-1`,"aria-label":`Requests waiting for your answer`,"data-sw-hosted-cards":v.length,children:v.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-warn/50 bg-warn/10 px-3 py-2 sm:flex-row sm:items-center`,"data-sw-hosted-card":e.id,"data-sw-hosted-card-thread":e.thread,children:[(0,Y.jsx)(P_,{size:15,className:`hidden shrink-0 text-warn sm:block`,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`p`,{className:`font-medium break-words text-fg`,children:[e.agent?.name||`An agent`,` asks before it acts, on `,vD(e.thread)]}),(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:e.name===`execute`?`Run a command:`:`Edit a file:`}),(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-fg`,children:hD(e.detail||e.label)})]})]}),(0,Y.jsx)(a,{size:`touch`,variant:`default`,className:`shrink-0 lg:h-8`,onClick:()=>n(e.thread),"data-sw-hosted-card-open":e.thread,children:`Review and answer`})]},`${e.thread}/${e.id}`))}):null,i.map(e=>(0,Y.jsxs)(`article`,{className:`space-y-2 pb-3`,children:[(0,Y.jsxs)(`p`,{className:`font-semibold`,children:[`Agent asks to run a command for comment #`,e.comment_number]}),(0,Y.jsx)(`pre`,{className:`overflow-auto rounded bg-surface-2 p-2 break-words whitespace-pre-wrap`,children:hD(e.command)}),(0,Y.jsx)(`p`,{children:e.reason}),(0,Y.jsx)(a,{size:`touch`,variant:`default`,className:`lg:h-8`,disabled:m,onClick:()=>_(e,`approved`),children:`Approve once`}),` `,(0,Y.jsx)(a,{size:`touch`,variant:`danger`,className:`lg:h-8`,disabled:m,onClick:()=>_(e,`denied`),children:`Deny`})]},e.id)),f?(0,Y.jsx)(`p`,{role:`alert`,className:`text-bad`,children:f}):null]})}var bD={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 xD(){let[e,t]=(0,J.useState)(null);if((0,J.useEffect)(()=>{let e=e=>t(t=>t||e.detail?.kind||null);return window.addEventListener(H,e),()=>window.removeEventListener(H,e)},[]),!e)return null;let n=bD[e],r=encodeURIComponent(window.location.pathname+window.location.search);return(0,Y.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,Y.jsx)(Sg,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}):(0,Y.jsx)(Mg,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n.title}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:n.body}),n.href===`signin`?(0,Y.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,Y.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 SD=`You're a viewer. Ask an admin for member access to comment.`;function CD({compact:e=!1}){return(0,Y.jsx)(_,{content:SD,side:`bottom`,children:(0,Y.jsxs)(`span`,{role:`note`,tabIndex:0,"aria-label":SD,className:O(`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,Y.jsx)(Rh,{size:14,"aria-hidden":`true`}),` Viewer`]})})}function wD({project:e}){return(0,Y.jsx)(_,{content:`Back to ${e.name}`,side:`bottom`,align:`start`,children:(0,Y.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 TD={includes:e=>typeof e==`string`&&(e===`all`||/^[a-z][a-z0-9-]{0,31}$/.test(e))};function ED({enabled:e,boardId:t,canvasRef:n,flow:r,selection:i,mode:a,onMode:o,onInvalidate:s}){let[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(`offline`),[m,h]=(0,J.useState)(null),g=(0,J.useRef)({cursor:null});g.current={...g.current,selection:i,mode:a,onMode:o,onInvalidate:s};let _=(0,J.useRef)(null);return mm({onChange:e?()=>_.current?.():void 0}),(0,J.useEffect)(()=>{_.current?.()},[i,a]),(0,J.useEffect)(()=>{if(!e){l([]),d(0),h(null);return}let i=!1,a;return YE(async()=>{let{connectPresence:e}=await import(`./runtime-Bvq10IhH.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,J.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)||!TD.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 DD({touch:e,...t}){let n=ED(t);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(jD,{presence:n}),(0,Y.jsx)(AD,{presence:n,touch:e})]})}var OD=e=>`${e.id}|${e.name}|${e.color}|${+!!e.viewport}`;function kD(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)=>OD(e)===OD(r.peers[t]))}var AD=(0,J.memo)(function({presence:e,touch:t}){if(e.status!==`online`)return null;let n=e.peers.find(t=>t.id===e.following);return(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 text-xs text-muted`,"data-sw-presence-count":e.count,children:[(0,Y.jsx)(iv,{size:13,"aria-hidden":`true`}),e.count,` viewing`]}),e.peers.slice(0,5).map(n=>(0,Y.jsx)(_,{content:`${n.name}${n.viewport?`: follow their view`:``}`,children:(0,Y.jsx)(a,{size:t?`icon`:`icon-sm`,variant:e.following===n.id?`default`:`ghost`,"aria-label":`Follow ${n.name}`,"aria-pressed":e.following===n.id,disabled:!n.viewport,"data-sw-presence-peer":n.id,onClick:()=>e.follow(e.following===n.id?null:n.id),children:(0,Y.jsx)(de,{person:!0,name:n.name,color:n.color,size:`sm`})})},n.id)),e.peers.length>5?(0,Y.jsxs)(`span`,{className:`px-1 text-xs text-muted`,children:[`+`,e.peers.length-5]}):null,n?(0,Y.jsxs)(a,{size:t?`touch`:`xs`,variant:`secondary`,onClick:e.stopFollowing,"data-sw-stop-follow":`true`,children:[`Stop following `,n.name]}):null]})},kD);function jD({presence:e}){let t=e.peers.filter(e=>e.cursor&&Number.isFinite(e.cursor.x)&&Number.isFinite(e.cursor.y));return(0,Y.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,Y.jsx)(MD,{peers:t}):null})}function MD({peers:e}){let{x:t,y:n,zoom:r}=fm();return e.map(e=>(0,Y.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,Y.jsx)(e_,{size:18,fill:`currentColor`,stroke:`white`,strokeWidth:1.5}),(0,Y.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 ND=`shapewall.appearance`,PD=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],FD=[{id:`default`,label:`Default`},{id:`ocean`,label:`Ocean`},{id:`forest`,label:`Forest`},{id:`contrast`,label:`High contrast`}],ID={mode:`system`,theme:`default`};function LD(e){return{mode:PD.some(t=>t.id===e?.mode)?e.mode:ID.mode,theme:FD.some(t=>t.id===e?.theme)?e.theme:ID.theme}}var RD=(e,t)=>e===`system`?t?`dark`:`light`:e,zD=typeof window<`u`,BD=()=>zD&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null;function VD(){try{return LD(JSON.parse(window.localStorage.getItem(`shapewall.appearance`)||`null`))}catch{return{...ID}}}var HD=zD?VD():{...ID},UD=new Set;function WD(){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 GD(e=HD){if(!zD)return;let t=document.documentElement;t.setAttribute(`data-mode`,RD(e.mode,!!BD()?.matches)),t.setAttribute(`data-theme`,e.theme),WD()}function KD(){return HD}function qD(e){HD=LD({...HD,...e});try{window.localStorage.setItem(ND,JSON.stringify(HD))}catch{}GD(),UD.forEach(e=>e())}zD&&(GD(),BD()?.addEventListener?.(`change`,()=>{HD.mode===`system`&&(GD(),UD.forEach(e=>e()))}),window.addEventListener(`storage`,e=>{e.key===`shapewall.appearance`&&(HD=VD(),GD(),UD.forEach(e=>e()))}));var JD=e=>(UD.add(e),()=>UD.delete(e));function YD(){return[(0,J.useSyncExternalStore)(JD,KD,KD),qD]}var XD=()=>zD?RD(HD.mode,!!BD()?.matches):`light`;function ZD(){return(0,J.useSyncExternalStore)(JD,XD,XD)}var QD=`shapewall.demo.try`;function $D(){try{return window.localStorage.getItem(QD)===`1`}catch{return!1}}function eO(e){let[t,n]=(0,J.useState)(()=>e&&!$D());return[e&&t,()=>{n(!1);try{window.localStorage.setItem(QD,`1`)}catch{}}]}function tO({touch:e,chip:t=!1,done:n,onOpenComment:r,onComment:i,onAgent:o,onUsage:s,onClose:c}){let[l,u]=(0,J.useState)(!0),d=[{id:`open`,icon:Wg,label:`Open a comment`,hint:e?`Tap a pin on a page`:`Click a pin on a page`,run:r},i&&{id:`comment`,icon:Hg,label:e?`Pin your own comment`:`Comment on a page`,hint:e?`Tap a page, then Comment`:`Click a page, then Comment (or press C)`,run:i},o?{id:`agent`,icon:I,label:`Ask the agent`,hint:e?`In the ... menu`:`It reads the open comments`,run:o}:null].filter(Boolean),f=s?{id:`usage`,icon:mh,label:`See what the agents did`,hint:`Usage: turns, tokens, charts`,run:s}:null,p=d.filter(e=>n.has(e.id)).length,m=e?`bottom-[calc(4rem+env(safe-area-inset-bottom,0px))] left-2`:`bottom-16 left-3`;return l||t?(0,Y.jsxs)(`button`,{type:`button`,className:O(`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`,m),onClick:()=>u(!1),"aria-expanded":`false`,"aria-label":`Try this: ${p} of ${d.length} done. Show the tips`,"data-sw-try-this":`folded`,children:[(0,Y.jsx)(R_,{size:15,className:`text-accent`,"aria-hidden":`true`}),` Try this`,(0,Y.jsxs)(`span`,{className:`tabular text-xs text-muted`,children:[p,`/`,d.length]})]}):(0,Y.jsxs)(`section`,{className:O(`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-[calc(4rem+env(safe-area-inset-bottom,0px))]`:`bottom-16 left-3 w-72`),"aria-label":`Try this`,"data-sw-try-this":`true`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Y.jsx)(R_,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`h2`,{className:`min-w-0 flex-1 text-sm font-semibold`,children:[`Try this`,` `,(0,Y.jsxs)(`span`,{className:`tabular text-xs font-medium text-muted`,children:[p,`/`,d.length]})]}),(0,Y.jsx)(B,{size:e?`icon`:`icon-xs`,onClick:()=>u(!0),label:`Fold the tips away`,"aria-expanded":`true`,"data-sw-try-fold":`true`,children:(0,Y.jsx)(pe,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(B,{size:e?`icon`:`icon-xs`,onClick:c,label:`Close the tips for good`,"data-sw-try-close":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})})]}),(0,Y.jsxs)(`ol`,{className:`flex flex-col gap-1`,children:[d.map(t=>{let r=n.has(t.id),i=r?st:t.icon;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(a,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:t.run,"data-sw-try-step":t.id,"data-sw-try-done":r?`true`:void 0,children:[(0,Y.jsx)(`span`,{className:O(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,r?`bg-ok/15 text-ok`:`bg-accent/10 text-accent`),"aria-hidden":`true`,children:(0,Y.jsx)(i,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:O(`block text-[13px] font-medium text-fg`,r&&`text-muted line-through decoration-faint`),children:t.label}),(0,Y.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:t.hint})]})]})},t.id)}),f?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(a,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:f.run,"data-sw-try-step":f.id,children:[(0,Y.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-accent/10 text-accent`,"aria-hidden":`true`,children:(0,Y.jsx)(f.icon,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-[13px] font-medium text-fg`,children:f.label}),(0,Y.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:f.hint})]})]})}):null]}),(0,Y.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 nO=new Map,rO=10;function iO(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])>rO||Math.abs(e[t+1]-r[1])>rO||Math.abs(e[t+2]-r[2])>rO)return!0}return!1}function aO(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(iO(e,t,r,i))return Math.min(1,(r+1)/n);return 1}function oO(e){if(!e||typeof document>`u`)return Promise.resolve(1);if(nO.has(e))return nO.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(aO(a.getImageData(0,0,e,r).data,e,r))}catch{t(1)}},n.onerror=()=>t(1),n.src=e});return nO.set(e,t),t}var sO=()=>typeof window<`u`&&!!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,cO=e=>sO()?0:e,lO=()=>sO()?`auto`:`smooth`,uO=.02,dO={padding:.16};function fO(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 pO(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 mO(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:cO(450)});return}let o=r=>e.fitBounds(fO({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:cO(450)});!a||!i.length?o(1):Promise.all(i.map(e=>oO(e))).then(e=>o(Math.max(.2,...e))).catch(()=>o(1))}function hO(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 gO=.34,_O=12,vO=.75,yO=72,bO=40;function xO(e,t,n=dO.padding){if(!t?.width||!t?.height||!e?.length)return null;let r=e.filter(e=>e.type===`groupFrame`),i=SO(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<=_O)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-yO-24)/l),d=Math.max(a,gO,Math.min(vO,u));return{x:bO-s.position.x*d,y:yO-s.position.y*d,zoom:d}}function SO(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}var CO=.35;function wO(e,t,n){if(!e?.width||!e?.height||!n?.width||!n?.height||!t?.zoom)return!0;let r=e.x*t.zoom+t.x,i=e.y*t.zoom+t.y,a=e.width*t.zoom,o=e.height*t.zoom;return a<240?!1:Math.max(0,Math.min(r+a,n.width)-Math.max(r,0))*Math.max(0,Math.min(i+o,n.height)-Math.max(i,0))/Math.min(a*o,n.width*n.height)>=CO}var TO={top:52,bottom:112,side:24},EO=280,DO=2;function OO(e,t,n=.5){if(!t?.width||!t?.height||!e?.width||!e?.height)return null;let{top:r,bottom:i,side:a}=TO,o=Math.max(1,t.width-a*2),s=Math.max(1,t.height-r-i),c=o/e.width,l=Math.min(c,s/e.height),u=Math.min(DO,4,Math.max(l,Math.min(c,EO/e.width))),d=e.width*u,f=e.height*u,p=a+(o-d)/2-e.x*u,m=r+(s-f)/2-e.y*u;if(f>s){m=r-e.y*u;let t=e.y+e.height*Math.min(1,Math.max(0,n));m+t*u>r+s*.8&&(m=Math.max(r+s-(e.y+e.height)*u,r+s/2-t*u))}return{x:p,y:m,zoom:u}}function kO(e){let t=rd(),[n,r]=(0,J.useState)(null),i=(0,J.useRef)(null),a=(0,J.useCallback)(e=>{i.current=e,r(e)},[]);return(0,J.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 AO=`shapewall.minimap`;function jO(){try{let e=window.localStorage.getItem(AO);return e===`on`||e!==`off`&&null}catch{return null}}function MO(e){return e>=30}var NO=`shapewall.tip.board`;function PO(){try{return window.localStorage.getItem(NO)===`1`}catch{return!1}}var FO=`shapewall.tip.pageComment`;function IO(){try{return window.localStorage.getItem(FO)===`1`}catch{return!0}}function LO(){try{window.localStorage.setItem(FO,`1`)}catch{}}function RO(e){try{window.localStorage.setItem(AO,e?`on`:`off`)}catch{}}function zO(){try{window.localStorage.setItem(NO,`1`)}catch{}}var BO=`shapewall.rail.`;function VO(e){try{let t=Number(window.localStorage.getItem(BO+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}}function HO(e,t){try{t==null?window.localStorage.removeItem(BO+e):window.localStorage.setItem(BO+e,String(Math.round(t)))}catch{}}var UO=8;function WO({groups:e,onPick:t}){let[n,r]=(0,J.useState)(``),i=n.trim().toLowerCase(),o=e.flatMap(e=>e.pages.map(t=>({...t,group:e.group}))),s=i?o.filter(e=>`${e.title} ${e.path||``} ${e.group}`.toLowerCase().includes(i)):o.slice(0,UO);return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-page-finder":`true`,children:[(0,Y.jsx)(it,{size:`touch`,icon:S_,value:n,onChange:e=>r(e.target.value.slice(0,80)),placeholder:`Search ${o.length} pages`,"aria-label":`Search pages`,"data-sw-page-search":`true`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>t(e.id),"data-sw-page-pick":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:e.group})]})},e.id))}),s.length?null:(0,Y.jsxs)(`p`,{className:`px-1 text-sm text-muted`,children:[`No page matches "`,n.trim(),`".`]}),!i&&o.length>UO?(0,Y.jsxs)(`p`,{className:`px-1 text-xs text-faint`,children:[o.length-UO,` more: type to find them.`]}):null]})}var GO=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``),KO=GO?`⌘K`:`Ctrl K`,qO=60,JO=6,YO=e=>String(e||``).toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``);function XO(e,...t){let n=0;for(let[r,i]of t.entries()){let t=YO(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 ZO=e=>e.filter(e=>e.score>0).sort((e,t)=>t.score-e.score).map(e=>e.entry);function QO({query:e,groups:t,journeys:n,canEditJourneys:r,comments:i,actions:a,titleOf:o}){let s=YO(e.trim()),c=t.flatMap(e=>e.pages.map(t=>({id:t.id,kind:`page`,icon:Hh,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:v_,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:c_,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||cv,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,qO),more:Math.max(0,c.length-qO)},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:Wg,title:`#${e.id} ${Me(e).split(`
|
|
33
|
-
`)[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?ZO(i.map(e=>({entry:e,score:XO(s,e.body,e.author)}))):[]).filter(e=>e!==p)].filter(Boolean).slice(0,JO).map(f),h=ZO(c.map(e=>({entry:e,score:XO(s,e.title,e.detail,e.meta)}))),g=ZO(l.map(e=>({entry:e,score:XO(s,e.title,e.detail)}))),_=ZO(u.map(e=>({entry:e,score:XO(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,qO)}: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 $O({onOpen:e,compact:t=!1,className:n,...r}){return(0,Y.jsxs)(`button`,{type:`button`,...r,onClick:e,className:O(`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-full px-2.5`,n),"aria-label":`Search pages, journeys and comments`,"aria-haspopup":`dialog`,"aria-keyshortcuts":GO?`Meta+K`:`Control+K`,"data-sw-page-jump":`true`,"data-sw-palette-trigger":`true`,children:[(0,Y.jsx)(S_,{size:14,"aria-hidden":`true`,className:`shrink-0`}),t?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:`Search the board`}),(0,Y.jsx)(s,{className:`shrink-0`,children:KO})]})]})}function ek({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,Y.jsx)(x,{open:e,onOpenChange:t,children:(0,Y.jsxs)(U,{children:[(0,Y.jsx)(dt,{}),(0,Y.jsxs)(ie,{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,Y.jsx)(W,{className:`sr-only`,children:`Go to a page, journey or comment`}),e?(0,Y.jsx)(tk,{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 tk({groups:e,journeys:t,canEditJourneys:n,comments:r,actions:i,titleOf:a,onRun:o}){let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(0),f=(0,J.useRef)(null),p=(0,J.useMemo)(()=>QO({query:c,groups:e,journeys:t,canEditJourneys:n,comments:r,actions:i,titleOf:a}),[c,e,t,n,r,i,a]),m=(0,J.useMemo)(()=>p.flatMap(e=>e.items),[p]),h=m[Math.min(u,m.length-1)]||null;(0,J.useEffect)(()=>d(0),[c]),(0,J.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&&o(h.run))},_=e=>`sw-palette-${e.id.replace(/[^\w-]/g,`_`)}`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4`,children:[(0,Y.jsx)(S_,{size:17,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,Y.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,Y.jsx)(s,{className:`hidden shrink-0 lg:inline-flex`,children:`Esc`})]}),(0,Y.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,Y.jsxs)(`div`,{role:`presentation`,className:`pb-1`,children:[(0,Y.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,Y.jsxs)(`div`,{id:_(e),role:`option`,"aria-selected":t,className:O(`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:()=>o(e.run),"data-sw-option":e.id,children:[(0,Y.jsx)(`span`,{className:O(`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,Y.jsx)(n,{size:14})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.title}),e.detail?(0,Y.jsx)(`span`,{className:O(`block truncate text-xs text-muted`,e.kind===`page`&&`font-mono text-[11px]`),children:e.detail}):null]}),e.meta?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.meta}):null,t?(0,Y.jsx)(Oh,{size:14,className:`hidden shrink-0 text-muted lg:block`,"aria-hidden":`true`}):null]},e.id)}),e.more?(0,Y.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,Y.jsxs)(`p`,{className:`px-3 py-8 text-center text-sm text-muted`,"data-sw-palette-empty":`true`,children:[`Nothing matches "`,c.trim(),`".`]})]}),(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(s,{children:`↑`}),(0,Y.jsx)(s,{children:`↓`}),` to move`]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(s,{children:`↵`}),` to open`]}),(0,Y.jsx)(`span`,{className:`ml-auto`,children:`#12 finds comment 12`})]})]})}var nk=Object.freeze({id:null,pinned:!1,via:null,swap:!1});function rk({onChange:e,openDelay:t=150,closeDelay:n=250,setTimer:r=(e,t)=>setTimeout(e,t),clearTimer:i=e=>clearTimeout(e)}={}){let a=nk,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(nk)};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 ik({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 ak=`shapewall.lastBoard`,ok=`shapewall.sidebar`,sk=`shapewall.sidebarWidth`,ck=208,lk=420,uk=16,dk=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``)?`⌘B`:`Ctrl B`;function fk(e){try{typeof e==`string`&&e.startsWith(`/`)&&window.localStorage.setItem(ak,e)}catch{}}function pk(e){try{let t=window.localStorage.getItem(ok);return t===`expanded`||t!==`collapsed`&&e}catch{return e}}function mk(e){let t=Math.max(ck,Math.min(lk,Math.floor(window.innerWidth*.4)));return Math.min(t,Math.max(ck,Math.round(e)))}function hk(){try{let e=Number(window.localStorage.getItem(sk));return Number.isFinite(e)&&e>0?mk(e):256}catch{return 256}}function gk(e){try{e===256?window.localStorage.removeItem(sk):window.localStorage.setItem(sk,String(e))}catch{}}function _k(){let[e,t]=(0,J.useState)(hk),[n,r]=(0,J.useState)(!1),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=()=>t(e=>mk(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let a=e=>{let n=mk(e);t(n),gk(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(mk(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:uk;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 vk=e=>!!(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)||e.closest?.(`[contenteditable="true"]`)));function yk(e=!0,t=!0){let[n,r]=(0,J.useState)(()=>pk(t)),i=(0,J.useCallback)(()=>r(e=>{try{window.localStorage.setItem(ok,e?`collapsed`:`expanded`)}catch{}return!e}),[]);return(0,J.useEffect)(()=>{if(!e)return;let t=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`b`||vk(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 bk(e,t){return O(`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 xk({item:e,expanded:t,link:n,flyouts:r}){let{id:i,label:a,icon:o,href:c,to:l,onSelect:u,active:d,count:f,shortcut:p,flyout:m,...h}=e;if(!t&&m&&r)return(0,Y.jsx)(Tk,{item:e,flyouts:r});let g=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(o,{size:t?16:19,"aria-hidden":`true`,className:O(`shrink-0`,d&&`text-accent`)}),t?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}):null,t&&f?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-faint tabular`,children:f}):null]}),v={className:bk(t,d),"aria-label":t?void 0:a,"aria-current":d?`page`:void 0,"data-sw-rail-item":i,...h},y=l&&n?(0,Y.jsx)(n,{to:l,...v,children:g}):c?(0,Y.jsx)(`a`,{href:c,...v,children:g}):(0,Y.jsx)(`button`,{type:`button`,onClick:u,...v,children:g});return(0,Y.jsx)(`li`,{children:t?y:(0,Y.jsx)(_,{content:p?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[a,(0,Y.jsx)(s,{children:p})]}):a,side:`right`,children:y})})}var Sk=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,Ck=e=>[...e.querySelectorAll(Sk)].filter(e=>e.getClientRects().length>0);function wk(e,t){let n=Ck(document).filter(e=>!t?.contains(e));(n[n.indexOf(e)+1]||e).focus()}function Tk({item:e,flyouts:t}){let{id:n,label:r,icon:i,active:a,flyout:o,dot:s}=e,{state:c,intent:l,width:u,disabled:d}=t,f=Object.fromEntries(Object.entries(e).filter(([e])=>e.startsWith(`data-`))),p=(0,J.useId)(),m=(0,J.useRef)(null),g=(0,J.useRef)(null),_=c.id===n,[v,y]=(0,J.useState)(null);(0,J.useLayoutEffect)(()=>{if(!_)return;let e=()=>{let e=m.current?.getBoundingClientRect().top??0;y(ik({anchorTop:e,viewportHeight:window.innerHeight}))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_]),(0,J.useEffect)(()=>{if(!_)return;let e=e=>{g.current?.contains(e.target)||m.current?.contains(e.target)||l.close()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[_,l]);let b=_&&c.pinned;(0,J.useEffect)(()=>{if(!b)return;let e=requestAnimationFrame(()=>{let e=g.current;e&&!e.contains(document.activeElement)&&(Ck(e)[0]||e).focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[b]);let x=(0,J.useCallback)(()=>{let e=!!g.current?.contains(document.activeElement);l.close(),e&&m.current?.focus({preventScroll:!0})},[l]),S=e=>t=>{t.pointerType!==`touch`&&e()},w=e=>{if(e.key!==`Tab`||e.defaultPrevented)return;let t=Ck(g.current);t.length&&(e.shiftKey&&document.activeElement===t[0]?(e.preventDefault(),m.current?.focus()):!e.shiftKey&&document.activeElement===t[t.length-1]&&(e.preventDefault(),l.close(),wk(m.current,g.current)))};return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(ne,{open:_,onOpenChange:e=>{e||l.close()},children:[(0,Y.jsx)(h,{asChild:!0,children:(0,Y.jsxs)(`button`,{ref:m,type:`button`,className:bk(!1,a||_),"aria-label":r,"aria-haspopup":`dialog`,"aria-expanded":_,"aria-controls":_?p:void 0,"aria-current":a?`page`:void 0,"data-sw-rail-item":n,"data-sw-rail-flyout-trigger":n,"data-state":_?c.pinned?`pinned`:`open`:`closed`,...f,onPointerEnter:S(()=>!d&&l.enterIcon(n)),onPointerLeave:S(()=>l.leave()),onClick:e=>!d&&l.toggle(n,e.detail===0?`key`:`click`),onKeyDown:e=>{e.key!==`ArrowRight`||d||(e.preventDefault(),b||l.toggle(n,`key`))},children:[(0,Y.jsx)(i,{size:19,"aria-hidden":`true`,className:O(`shrink-0`,a&&`text-accent`)}),s?(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-accent ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-rail-dot":n}):null]})}),(0,Y.jsx)(He,{children:(0,Y.jsx)(C,{ref:g,id:p,side:`right`,align:`start`,sideOffset:12,collisionPadding:8,"aria-label":r,tabIndex:-1,className:O(`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`,c.swap&&`sw-rail-flyout-swap`),style:{width:u,maxHeight:v??void 0},"data-sw-rail-flyout":n,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:e=>{e.preventDefault();let t=c.pinned||g.current?.contains(document.activeElement);l.close(),t&&m.current?.focus({preventScroll:!0})},onInteractOutside:e=>{m.current?.contains(e.target)&&e.preventDefault()},onPointerEnter:S(()=>l.enterPanel()),onPointerLeave:S(()=>l.leave()),onKeyDown:w,children:o({close:x})})})]})})}function Ek({items:e,expanded:t,link:n,label:r,flyouts:i,flush:a}){return e.length?(0,Y.jsxs)(`div`,{className:O(`w-full`,!a&&`border-t border-line pt-2`),children:[t&&r?(0,Y.jsx)(`p`,{className:`px-2.5 pb-1 text-xs font-semibold text-faint`,children:r}):null,(0,Y.jsx)(`ul`,{className:O(`flex flex-col`,t?`gap-0.5`:`items-center gap-1`),children:e.map(e=>(0,Y.jsx)(xk,{item:e,expanded:t,link:n,flyouts:i},e.id))})]}):null}function Dk(e,t,n=!1){let[r,i]=(0,J.useState)(()=>({id:null,pinned:!1,via:null,swap:!1})),a=(0,J.useRef)(null);return a.current||=rk({onChange:i}),(0,J.useEffect)(()=>()=>a.current.dispose(),[]),(0,J.useEffect)(()=>{(e||n)&&a.current.close()},[e,n]),{state:r,intent:a.current,width:t,disabled:n}}function Ok({expanded:e,onToggle:t,home:n,homeTo:r,homeLabel:i=`Shapewall`,title:a,logo:o,items:c=[],sections:l=[],sectionsLabel:u,link:d,profile:f,children:p,className:m,flyoutsDisabled:h=!1}){let g=r&&d?d:`a`,v=r&&d?{to:r}:{href:n},y=e?`Collapse sidebar`:`Expand sidebar`,{width:b,dragging:x,handle:S}=_k(),C=Dk(e,b,h),w=e?[]:l.filter(e=>!e.flyout),T=w.length?c.find(e=>e.active):null,E=T?c.map(e=>e===T?{...e,flyout:({close:t})=>(0,Y.jsx)(`div`,{onClick:e=>{e.target.closest?.(`[data-sw-rail-item]`)&&setTimeout(t,0)},children:(0,Y.jsx)(Ek,{items:w,expanded:!0,link:d,label:u||e.label,flush:!0})})}:e):c,D=T?l.filter(e=>e.flyout):l;return(0,Y.jsxs)(`div`,{className:O(`relative flex shrink-0`,m),children:[(0,Y.jsxs)(`nav`,{"aria-label":`Shapewall`,className:O(`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:b}:void 0,"data-sw-app-rail":e?`expanded`:`collapsed`,children:[(0,Y.jsxs)(`div`,{className:O(`flex shrink-0 items-center gap-1`,e?`h-10`:`flex-col`),children:[(0,Y.jsx)(_,{content:e?null:i,side:`right`,children:(0,Y.jsx)(g,{...v,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":i,"data-sw-rail-home":`true`,children:o})}),e?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,"data-sw-rail-title":`true`,children:a||`Shapewall`}):null,(0,Y.jsx)(_,{content:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[y,(0,Y.jsx)(s,{children:dk})]}),side:`right`,children:(0,Y.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":y,"aria-expanded":e,"data-sw-sidebar-toggle":`true`,children:e?(0,Y.jsx)(n_,{size:17,"aria-hidden":`true`}):(0,Y.jsx)(i_,{size:17,"aria-hidden":`true`})})})]}),(0,Y.jsx)(Ek,{items:E,expanded:e,link:d,flyouts:C}),(0,Y.jsxs)(`div`,{className:O(`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,Y.jsx)(Ek,{items:D,expanded:e,link:d,label:u,flyouts:C}),e?p:null]}),f?(0,Y.jsx)(`div`,{className:O(`w-full shrink-0 border-t border-line pt-2`,!e&&`flex justify-center`),children:f(e)}):null]}),e?(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":b,"aria-valuemin":ck,"aria-valuemax":lk,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`,...S,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`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`,x&&`opacity-100`)})}):null,x?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null]})}function kk({count:e,corner:t=!1}){return e?(0,Y.jsxs)(`span`,{className:O(`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,Y.jsxs)(`span`,{className:`sr-only`,children:[` broken link`,e===1?``:`s`]})]}):null}var Ak=e=>e.status?String(e.status):`No answer`;function jk({items:e,open:t,onOpenChange:n}){let[r,i]=(0,J.useState)(!1),a=t??r,o=n||i,s=e.length;return(0,Y.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,Y.jsxs)(lt,{open:a,onOpenChange:o,children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:O(`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":a,"data-sw-broken-links-toggle":`true`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-bad/10 text-bad`,children:(0,Y.jsx)(Sg,{size:12,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[s,` broken link`,s===1?``:`s`]}),(0,Y.jsx)(`span`,{className:`hidden shrink-0 font-normal text-muted sm:inline`,children:`from the last capture`}),(0,Y.jsx)(pe,{size:13,className:O(`shrink-0 text-faint transition-transform`,a&&`rotate-180`),"aria-hidden":`true`})]})}),(0,Y.jsxs)(ot,{align:`start`,className:`w-[min(26rem,calc(100vw-1.5rem))] p-0`,"aria-label":`Broken links`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-line px-3 py-2.5`,children:[(0,Y.jsxs)(`p`,{className:`text-[13px] font-semibold text-fg`,children:[s,` link`,s===1?``:`s`,` lead`,s===1?`s`:``,` to an error`]}),(0,Y.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,Y.jsx)(`ul`,{className:`max-h-72 divide-y divide-line overflow-auto`,children:e.slice(0,100).map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2`,"data-sw-broken-link":e.path??e.url,children:[(0,Y.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:Ak(e)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-mono text-xs text-fg`,children:e.path??e.url}),(e.from||[]).length?(0,Y.jsxs)(`span`,{className:`mt-0.5 block text-[11px] text-muted`,children:[`Linked from `,(e.from||[]).join(`, `)]}):null]})]},e.url))}),s>100?(0,Y.jsx)(`p`,{className:`border-t border-line px-3 py-2 text-[11px] text-faint`,children:`Showing the first 100.`}):null]})]})})}var Mk=e=>e.status!==`resolved`;function Nk({comments:e=[],focus:t=null,approvals:n=[],titleOf:r=()=>``,listening:i=null,agents:a=null}){let o=new Map(e.map(e=>[Number(e.id),e])),s=e=>{let t=o.get(Number(e)),n=t?r(t.pageId):``;return n?`#${e} ${n}`:`#${e}`},c=new Map,l=new Map,u=new Map,d=(e,t,n)=>{let r=Number(t);r>0&&!e.has(r)&&e.set(r,{id:r,name:s(r),why:n})};for(let e of n)d(l,e.comment_number??e.commentId,`approval`);t?.state===`waiting`&&d(l,t.commentId,`approval`),t?.state===`working`&&d(c,t.commentId,`working`);for(let t of e)Mk(t)&&(t.agentStatus===`working`?d(c,t.id,`working`):t.agentStatus===`needs-human`?d(u,t.id,`needs-human`):t.agentStatus===`branch-ready`&&d(u,t.id,`branch-ready`));for(let e of l.keys())c.delete(e);let f=e=>[...e.values()],p=[...f(l),...f(u).filter(e=>!l.has(e.id))],m=l.size?`waiting`:c.size?`working`:p.length?`waiting`:`idle`,h=m===`working`?c.size:m===`waiting`?l.size?l.size:p.length:0,g=[];l.size===1?g.push(`Agent needs your OK on ${f(l)[0].name}`):l.size&&g.push(`Agents need your OK on ${l.size} comments: ${Fk(f(l))}`),c.size===1?g.push(`Agent working on ${f(c)[0].name}`):c.size&&g.push(`${c.size} agents working: ${Fk(f(c))}`);let _=p.filter(e=>e.why!==`approval`);return _.length===1?g.push(_[0].why===`branch-ready`?a?`Fix ready on a branch for ${_[0].name}`:`Fix ready to apply on ${_[0].name}`:`${_[0].name} needs a person`):_.length&&g.push(`${_.length} comments wait for you: ${Fk(_)}`),a?g.push(kT(a)):i&&g.push(i.online?`Agent online: ${i.name||`agent`}`:Pk),{state:m,listening:a?AT(a):i?!!i.online:null,working:f(c),waiting:p,count:h,text:g.join(`. `),target:l.size===1?f(l)[0].id:!l.size&&p.length===1?p[0].id:null}}var Pk=`No agent is listening: comments wait until one is`;function Fk(e,t=3){let n=e.slice(0,t).map(e=>e.name);return e.length>t?`${n.join(`, `)} and ${e.length-t} more`:n.join(`, `)}var Ik=(e,t)=>(e===`working`||e===`waiting`)&&t===`idle`,Lk=`__none`;function Rk(e){if(e.branching)return`${e.paths?.length||2} paths`;let t=e.steps?.length||0;return`${t} ${t===1?`step`:`steps`}`}function zk({journeys:e=[],journey:t,openJourney:n,closeJourney:i,canEditJourneys:o,startBuilder:c,showLinks:l,toggleLinks:u,linksTip:d,brokenLinks:f,openBrokenLinks:m,canCompare:h,comparePair:g,toggleCompare:v,minimapOn:b,toggleMinimap:x,compact:S,boxed:C=`text-fg`,labelMax:w=160}){let[E,A]=(0,J.useState)(``),j=(0,J.useRef)(null),M=[l,!!g].filter(Boolean).length,N=f.length,P=e.length>8,F=E.trim().toLowerCase(),I=P&&F?e.filter(e=>e.name.toLowerCase().includes(F)):e,L=(0,J.useRef)(null),R=`pr-2`,z=e=>(0,Y.jsx)(`span`,{className:O(`ml-auto inline-flex h-4 w-4 items-center justify-center`,e?`!text-accent`:`opacity-0`),children:(0,Y.jsx)(st,{size:14,className:`!text-accent`,"aria-hidden":`true`})}),te=N?`${N} broken link${N===1?``:`s`}`:null,V=[M?`${M} on`:null,te].filter(Boolean).join(`, `),ne=t?`Journey: ${t.name}. Views`:V?`Views, ${V}`:`Views`,H=t?(0,Y.jsx)(dx,{label:`Journey: ${t.name}. Open Views to switch`,keys:[`J`]}):e.length?(0,Y.jsx)(dx,{label:`Views: journeys, links between pages, compare, minimap`,keys:[`J`]}):`Views: links between pages, compare, minimap`,U=!!t,re=(0,Y.jsxs)(a,{variant:U?`soft`:`ghost`,className:O(`relative h-8 shrink-0 text-[13px]`,S?`w-8 px-0`:`px-2.5`,U?S?``:`rounded-r-none`:C),"aria-label":ne,"data-sw-view-menu":`true`,"data-sw-view-journey":t?.id,children:[U?(0,Y.jsx)(v_,{size:15,"aria-hidden":`true`}):(0,Y.jsx)(Rh,{size:15,"aria-hidden":`true`}),S?null:U?(0,Y.jsx)(`span`,{className:`block truncate`,style:{maxWidth:w},"data-sw-view-journey-name":`true`,children:t.name}):`Views`,N?(0,Y.jsx)(`span`,{className:`pointer-events-none absolute -top-1.5 -right-1.5 inline-flex min-w-4 items-center justify-center rounded-full bg-bad px-1 text-[10px] leading-4 font-semibold text-bad-fg tabular`,"aria-hidden":`true`,"data-sw-broken-links-badge":N,children:N}):U&&S?(0,Y.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":`journey`}):M&&!U?(0,Y.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-muted ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-view-on":M}):null]});return(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center`,"data-sw-views":`true`,children:[(0,Y.jsxs)(je,{onOpenChange:e=>e?null:A(``),children:[(0,Y.jsx)(_,{content:H,side:`bottom`,children:(0,Y.jsx)(T,{asChild:!0,children:re})}),(0,Y.jsxs)(r,{align:`start`,className:`w-80`,onCloseAutoFocus:e=>{e.preventDefault();let t=j.current;j.current=null,t?t():document.querySelector(`[data-sw-canvas]`)?.focus({preventScroll:!0})},"data-sw-views-menu":`true`,children:[e.length||o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(k,{className:`flex items-center gap-2`,children:[`Journeys`,e.length?(0,Y.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 font-normal tracking-normal normal-case`,children:[`Next `,(0,Y.jsx)(s,{children:`J`})]}):null]}),P?(0,Y.jsx)(`div`,{className:`px-1 pb-1`,children:(0,Y.jsx)(it,{size:`xs`,icon:S_,value:E,onChange:e=>A(e.target.value),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-views-filter":`true`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),L.current?.querySelector(`[role="menuitemradio"]`)?.focus()):e.key!==`Escape`&&e.key!==`Tab`&&e.stopPropagation()}})}):null,(0,Y.jsxs)(ee,{ref:L,value:t?.id||Lk,onValueChange:e=>e===Lk?i():n(e),className:P?`max-h-72 overflow-y-auto`:void 0,"aria-label":`Journeys`,"data-sw-views-journeys":e.length,children:[F?null:(0,Y.jsxs)(p,{value:Lk,"data-sw-views-journey":`none`,children:[(0,Y.jsx)(Rh,{size:15,"aria-hidden":`true`}),` None`,(0,Y.jsx)(`span`,{className:`ml-auto text-caption text-faint`,children:`All pages`})]}),I.map(e=>(0,Y.jsxs)(p,{value:e.id,"data-sw-views-journey":e.id,children:[(0,Y.jsx)(v_,{size:15,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-caption text-faint tabular-nums`,children:Rk(e)})]},e.id)),F&&!I.length?(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted`,children:`No journey matches.`}):null]}),o?(0,Y.jsxs)(D,{className:R,onSelect:()=>c(),"data-sw-views-new-journey":`true`,children:[(0,Y.jsx)(c_,{size:15,"aria-hidden":`true`}),` New journey`]}):null,(0,Y.jsx)(y,{})]}):null,(0,Y.jsx)(k,{children:`Show`}),(0,Y.jsxs)(D,{className:R,role:`menuitemcheckbox`,"aria-checked":l,onSelect:u,"data-sw-links-toggle":`true`,children:[(0,Y.jsx)(ov,{size:15,"aria-hidden":`true`}),`Links between pages`,z(l)]}),h?(0,Y.jsxs)(D,{className:R,role:`menuitemcheckbox`,"aria-checked":!!g,onSelect:v,"data-sw-compare-toggle":`true`,children:[(0,Y.jsx)(Xh,{size:15,"aria-hidden":`true`}),` Compare environments`,z(!!g)]}):null,(0,Y.jsxs)(D,{className:R,role:`menuitemcheckbox`,"aria-checked":b,onSelect:x,children:[(0,Y.jsx)(Ig,{size:15,"aria-hidden":`true`}),` Minimap`,z(b)]}),N?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsxs)(D,{className:R,onSelect:()=>{l||u(),j.current=m},"data-sw-broken-links-open":`true`,children:[(0,Y.jsx)(Sg,{size:15,className:`!text-bad`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block`,children:`Broken links`}),(0,Y.jsxs)(`span`,{className:`block text-caption text-muted`,children:[N,` `,N===1?`link leads`:`links lead`,` to an error`]})]}),(0,Y.jsx)(`span`,{className:`ml-auto 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`,children:N})]})]}):null,(0,Y.jsx)(y,{}),(0,Y.jsxs)(`p`,{className:`px-2 py-1.5 text-xs text-muted`,children:[d,`.`]})]})]}),U&&!S?(0,Y.jsx)(B,{variant:`soft`,className:`h-8 w-7 shrink-0 -ml-px rounded-l-none`,onClick:i,label:`Leave journey`,tooltip:(0,Y.jsx)(dx,{label:`Leave the journey`,keys:[`Esc`]}),side:`bottom`,"data-sw-view-journey-clear":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})}):null]})}function Bk({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?`Pages captured ${A(n)}`:`Not captured yet`;return(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[(0,Y.jsx)(me,{size:12}),(0,Y.jsx)(`span`,{className:`tabular`,children:t.total?`${t.done||0}/${t.total}`:`Capturing`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:i})]}):r?(0,Y.jsx)(_,{content:`Last capture failed: ${t.error}`,side:`bottom`,children:(0,Y.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,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bad`,"aria-hidden":`true`}),` Capture failed`]})}):(0,Y.jsx)(_,{content:i,side:`bottom`,children:(0,Y.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,Y.jsx)(`span`,{className:O(`h-2 w-2 rounded-full`,n?`bg-ok`:`bg-faint`),"aria-hidden":`true`})})})})}function Vk({data:e,capture:t}){let n=e?.manifest?.capturedAt;return(0,Y.jsxs)(`p`,{className:`text-xs whitespace-nowrap text-muted`,"data-sw-captured":`true`,children:[t?.running?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(me,{size:12}),` Capturing`,t.total?` ${t.done||0}/${t.total}`:``]}):n?`Captured ${A(n)}`:`Not captured yet`,!t?.running&&t?.state===`failed`&&t.error?(0,Y.jsxs)(`span`,{className:`ml-2 text-bad`,children:[`Last capture failed: `,t.error]}):null]})}var Hk=e=>e.preventDefault(),Uk={light:K_,dark:Qg,system:Xg},Wk=`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 Gk({name:e,avatarUrl:t=null,detail:n=null,items:i=[],workspaces:o=null,viewAs:s=null,showName:c=!1,label:l=`Profile and appearance`,about:u=!0,triggerClassName:d,side:f=`bottom`,align:m=`end`,...h}){let[g,_]=YD(),v=(0,J.useRef)(null);return(0,Y.jsxs)(je,{children:[(0,Y.jsx)(T,{asChild:!0,children:(0,Y.jsxs)(a,{ref:v,variant:`ghost`,size:`touch`,className:O(`shrink-0 gap-2 px-1.5 lg:h-10`,d),"aria-label":e?`${l}: ${e}`:l,"data-sw-profile-menu":!0,...h,children:[(0,Y.jsx)(de,{name:e||`?`,src:t,className:`h-8 w-8`}),c&&e?(0,Y.jsx)(`span`,{className:`hidden max-w-40 truncate text-sm text-fg md:inline`,children:e}):null]})}),(0,Y.jsxs)(r,{className:`w-72`,side:f,align:m,"data-sw-profile-content":!0,children:[e||n?(0,Y.jsxs)(k,{className:`normal-case`,children:[e?(0,Y.jsx)(`span`,{className:`block truncate text-[13px] font-medium tracking-normal text-fg`,children:e}):null,n?(0,Y.jsx)(`span`,{className:`block truncate text-xs font-normal tracking-normal text-muted`,children:n}):null]}):null,i.length?(0,Y.jsxs)(Y.Fragment,{children:[e||n?(0,Y.jsx)(y,{}):null,(0,Y.jsx)(ke,{children:i.map(({id:e,label:t,icon:n,onSelect:r,tone:i,hint:a,...o})=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(D,{onSelect:r,tone:i,"data-sw-profile-item":e,"aria-describedby":a?`sw-profile-hint-`+e:void 0,...o,children:[n?(0,Y.jsx)(n,{size:14,"aria-hidden":`true`}):null,` `,t]}),a?(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsx)(k,{children:`Workspace`}),o.list.map(e=>(0,Y.jsxs)(D,{onSelect:()=>o.onPick(e.id),"data-sw-profile-workspace":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.roleLabel?(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:e.roleLabel}):null,e.id===o.current?(0,Y.jsx)(st,{size:14,className:`!text-accent`,"aria-label":`Current`}):null]},e.id))]}):null,s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsx)(k,{children:`View as (demo)`}),(0,Y.jsx)(ee,{value:s.value,onValueChange:s.onChange,children:s.options.map(e=>(0,Y.jsxs)(p,{value:e.id,"data-sw-view-as":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]}):null,(0,Y.jsx)(y,{}),(0,Y.jsx)(k,{children:`Appearance`}),(0,Y.jsx)(ee,{value:g.mode,onValueChange:e=>_({mode:e}),className:`grid grid-cols-3 gap-1 px-1 pb-1`,"aria-label":`Mode`,children:PD.map(e=>{let t=Uk[e.id];return(0,Y.jsxs)(p,{value:e.id,indicator:!1,className:Wk,onSelect:Hk,"data-sw-appearance-mode":e.id,children:[(0,Y.jsx)(t,{size:14,"aria-hidden":`true`}),` `,e.label]},e.id)})}),(0,Y.jsx)(ee,{value:g.theme,onValueChange:e=>_({theme:e}),className:`grid grid-cols-2 gap-1 px-1 pb-1`,"aria-label":`Theme`,children:FD.map(e=>(0,Y.jsxs)(p,{value:e.id,indicator:!1,className:O(Wk,`justify-start px-2`),onSelect:Hk,"data-sw-theme-option":e.id,children:[(0,Y.jsx)(`span`,{className:O(`h-4 w-4 shrink-0 rounded-full ring-1 ring-line`,`sw-swatch-${e.id}`),"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))}),u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsxs)(D,{onSelect:()=>QE(v.current),"data-sw-app-about":`menu`,children:[(0,Y.jsx)(mg,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`About Shapewall and updates`}),(0,Y.jsxs)(`span`,{className:`text-caption text-faint tabular-nums`,"data-sw-app-version":!0,children:[`v`,HE.version]})]}),(0,Y.jsx)(D,{asChild:!0,"data-sw-app-contact":`menu`,children:(0,Y.jsxs)(`a`,{href:VE,target:`_blank`,rel:`noopener noreferrer`,children:[(0,Y.jsx)(Pg,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Contact`})]})})]}):null]})]})}function Kk(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,qk(e.role)].filter(Boolean).join(` · `):`A board on this machine`}var qk=e=>e?e[0].toUpperCase()+e.slice(1):null;function Jk({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,Y.jsx)(Gk,{name:e?.user?.name||t||null,avatarUrl:e?.user?.avatarUrl,detail:Kk(e),items:[...e?.buzzAvailable===!0?[{id:`buzz`,label:`Existing Buzz conversation`,icon:O_,onSelect:n,"data-sw-buzz-open":`true`}]:[],...i?[{id:`account`,label:`Account and security`,icon:nv,onSelect:()=>P(`/account`)},{id:`console`,label:`Workspace Console`,icon:uh,onSelect:()=>P(`/console`)}]:a?[{id:`settings`,label:`Settings`,icon:O_,onSelect:o,"data-sw-settings-open":`profile`}]:[],...e?.shareEnabled?[{id:`share`,label:`Share with your team...`,icon:uh,onSelect:()=>s(!0)}]:[],...e?.consoleUrl&&!e?.guest?[{id:`console`,label:`Workspace Console`,icon:uh,onSelect:()=>P(e.consoleUrl)}]:[],...e?.public&&typeof e.reportUrl==`string`&&e.reportUrl.startsWith(`mailto:`)?[{id:`report`,label:`Report this board`,icon:Kh,onSelect:()=>P(e.reportUrl)}]:[],...r?[r.resetItem]:[]],viewAs:r?.viewAs||null,side:c,align:l,showName:u,triggerClassName:d})}var Yk=null,Xk=new Set;function Zk(e){e!==Yk&&(Yk=e,Xk.forEach(e=>e()))}var Qk=e=>(Xk.add(e),()=>Xk.delete(e));function $k(){return(0,J.useSyncExternalStore)(Qk,()=>Yk,()=>null)}var eA=[`full`,`panels`,`view`,`viewport`,`tight`],tA={pad:12,gap:6,zoneGap:20,tightGap:4,tightZoneGap:12,name:[200,176,152,128,104],journey:[160,112],journeyMax:240,agentPill:22},nA={width:384,min:368,max:560,share:.4};function rA(e){let t=t=>e>=eA.indexOf(t);return{panels:t(`panels`),view:t(`view`),viewport:t(`viewport`),tight:t(`tight`)}}function iA(e,t,n=rA(t).tight?tA.tightGap:tA.gap){let r=rA(t),i=e.filter(e=>e&&!(e.gone&&r[e.gone]));if(!i.length)return 0;let a=e=>e.at&&r[e.at]?e.compact:Array.isArray(e.full)?e.full[t]:e.full;return i.reduce((e,t)=>e+a(t),0)+n*(i.length-1)}function aA({text:e,title:t,viewports:n=[],capture:r=!1,status:i={kind:`dot`},viewer:a=!1,panels:o={comments:0,agent:!1,checks:!1},settings:s=!1,journey:c=null}){let l=(t,n)=>Math.ceil(e(String(t),n))+1,u={left:[],right:[]};u.left.push((e=>({id:e,full:1,gone:`viewport`}))(`divider`)),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`});let d=c?l(c,`ui`):0,f=e=>Math.min(d,tA.journey[Math.min(e,tA.journey.length-1)]);u.left.push({id:`view`,full:c?eA.map((e,t)=>41+f(t)+27):41+l(`Views`,`ui`),...c?{grow:eA.map((e,t)=>Math.max(0,Math.min(d,tA.journeyMax)-f(t)))}:{},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`)}),s&&u.right.push({id:`settings`,full:32});let p=12+l(o.comments,`count`),m=[{full:46+l(`Comments`,`ui`)+p,compact:36+p}];return o.agent&&m.push({full:40+l(`Agent`,`ui`)+tA.agentPill,compact:30}),o.checks&&m.push({full:40+l(`Checks`,`ui`),compact:30}),u.right.push({id:`panels`,full:m.reduce((e,t)=>e+t.full,6),compact:m.reduce((e,t)=>e+t.compact,6),at:`panels`}),{name:40+l(t,`name`),left:u.left,right:u.right}}function oA(e,t,n){let r=e.find(e=>e.id===`view`&&e.grow);return!r||rA(t).view?0:(Array.isArray(r.full)?r.full[t]-41-27:0)+Math.max(0,Math.min(r.grow[t],Math.floor(n)))}function sA({inner:e,name:t,left:n,right:r,config:i}){for(let a=0;a<eA.length;a+=1){let o=rA(a).tight,s=o?i.tightGap:i.gap,c=iA(n,a,s),l=e-(Math.min(t,i.name[a])+(c?s+c:0))-iA(r,a,s)-(o?i.tightZoneGap:i.zoneGap);if(l>=0)return{step:a,journey:oA(n,a,l)}}return null}function cA({width:e,name:t,left:n=[],right:r=[],panel:i=null,config:a=tA}){let o=Math.max(0,e-2*a.pad),s=eA.length-1,c=i?r.find(e=>e.id===`panels`):null,l=c?i-2*a.pad:0;if(c&&c.full<=l){let e=sA({inner:o,name:t,left:n,right:r.map(e=>e===c?{id:`panels`,full:l+a.pad}:e),config:a});if(e)return{...e,stretched:!0}}return sA({inner:o,name:t,left:n,right:r,config:a})||{step:s,journey:oA(n,s,0)}}var lA={name:`600 14px`,ui:`500 13px`,xs:`500 12px`,count:`600 11px`},uA;function dA(e,t){return typeof document>`u`||(uA||=document.createElement(`canvas`).getContext(`2d`),!uA)?e.length*8:(uA.font=`${lA[t]} ${getComputedStyle(document.body).fontFamily}`,uA.measureText(e).width)}function fA(e,t){let[n,r]=(0,J.useState)(()=>typeof window>`u`?1280:window.innerWidth);return(0,J.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}var pA=`bg-surface-2/60 text-fg ring-1 ring-line ring-inset hover:bg-surface-2`,mA=`flex shrink-0 items-center rounded-md border border-line bg-surface-2 p-0.5`,hA=`h-[26px] text-ui`,gA=()=>(0,Y.jsx)(`span`,{className:`h-5 w-px shrink-0 bg-line`,"aria-hidden":`true`,"data-sw-toolbar-divider":`true`}),_A=4e3;function vA(e){let[t,n]=(0,J.useState)(!1),r=(0,J.useRef)(e.state);return(0,J.useEffect)(()=>{let t=r.current;if(r.current=e.state,!Ik(t,e.state)){e.state!==`idle`&&n(!1);return}n(!0);let i=window.setTimeout(()=>n(!1),_A);return()=>window.clearTimeout(i)},[e.state]),e.state===`idle`&&t?`done`:e.state}var yA={working:`bg-accent text-accent-fg`,waiting:`bg-warn text-warn-fg`,done:`bg-ok text-ok-fg`};function bA({shown:e,count:t}){if(e===`idle`)return null;let n=t>1&&e!==`done`;return(0,Y.jsx)(`span`,{className:O(`tabular inline-flex shrink-0 items-center justify-center rounded-full text-[11px] leading-4 font-semibold`,n?`px-1.5`:`mx-1 h-2 w-2`,yA[e],e===`working`&&`motion-safe:animate-breathe`),"aria-hidden":`true`,"data-sw-agent-activity-mark":e,"data-sw-agent-activity-pulse":e===`working`?`true`:void 0,children:n?t:null})}function xA({shown:e,count:t,touch:n=!1}){if(e===`idle`)return null;let r=t>1&&e!==`done`;return(0,Y.jsx)(`span`,{className:O(`tabular pointer-events-none absolute flex items-center justify-center rounded-full font-semibold ring-2 ring-surface`,n?`top-2 right-2`:`-top-1 -right-1`,r?`h-3.5 min-w-3.5 px-0.5 text-[9px] leading-none`:`h-2 w-2`,yA[e],e===`working`&&`motion-safe:animate-breathe`),"aria-hidden":`true`,"data-sw-agent-activity-mark":e,"data-sw-agent-activity-pulse":e===`working`?`true`:void 0,children:r?t:null})}var SA=(e,t)=>e===`done`?[`Agent done`,t.text].filter(Boolean).join(`. `):t.text;function CA({labels:e,stretched:t,allOpen:n,panelHidden:r,chatAvailable:i,chatThread:a,reopenChat:o,checksOpen:s,canChecks:c,openChecks:l,closeChecks:u,updateParams:d,activity:f,shown:p,openAgentThread:m}){let h=!r&&!a&&!s,g=SA(p,f),v=!i&&!!g,y={"data-sw-agent-activity":p,"data-sw-agent-activity-count":f.count||void 0},b=O(hA,!e&&`px-2`,t&&`flex-1 basis-0`);return(0,Y.jsxs)(`div`,{className:O(mA,t&&`w-full`),role:`group`,"aria-label":`Side panel`,"data-sw-panel-switch":`true`,children:[(0,Y.jsx)(_,{content:`${h?`Hide`:`Show`} comments (${n} open)${v?`. ${g}`:``}`,side:`bottom`,children:(0,Y.jsxs)(Ie,{variant:`segment`,className:b,pressed:h,onPressedChange:()=>d({panel:r||a||s?null:`off`,chat:null,ha:null,checks:null,cv:null}),"aria-label":`Comments, ${n} open${v?`. ${g}`:``}`,"data-sw-panel-toggle":`true`,...i?{}:y,children:[(0,Y.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,Y.jsx)(Wg,{size:14,"aria-hidden":`true`}),v?(0,Y.jsx)(xA,{shown:p,count:f.count}):null]}),e?`Comments`:null,(0,Y.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:n})]})}),i?(0,Y.jsx)(_,{content:g||(a?`Close the agent chat`:`Chat with your agent about this board`),side:`bottom`,children:(0,Y.jsxs)(Ie,{variant:`segment`,className:b,pressed:!!a,"aria-label":g?`Agent. ${g}`:`Agent`,onPressedChange:()=>a?d({chat:null,ha:null}):f.target?m(f.target):o(),"data-sw-chat-toggle":`true`,...y,children:[(0,Y.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,Y.jsx)(I,{size:14,"aria-hidden":`true`}),e?null:(0,Y.jsx)(xA,{shown:p,count:f.count})]}),e?`Agent`:null,e?(0,Y.jsx)(bA,{shown:p,count:f.count}):null]})}):null,c?(0,Y.jsx)(_,{content:s?`Close the checks`:`Page checks: performance, accessibility, SEO`,side:`bottom`,align:`end`,children:(0,Y.jsxs)(Ie,{variant:`segment`,className:b,pressed:!!s,"aria-label":`Checks`,onPressedChange:()=>s?u():l(),"data-sw-checks-toggle":`true`,children:[(0,Y.jsx)(Kh,{size:14,"aria-hidden":`true`}),e?`Checks`:null]})}):null]})}function wA({wide:e,info:t,boardId:n,boards:r,data:i,localProjects:o,projectsError:s,localName:c,onPickBoard:l,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:p,openSettings:m,setShareOpen:h,modes:g,mode:_,setMode:v,viewNotice:y,canComment:b,comparePair:x,setMenuOpen:S,showLinks:C,toggleLinks:w,linksTip:T,brokenLinks:E,canCompare:D,toggleCompare:k,minimapOn:A,toggleMinimap:j,journeys:ee=[],journey:M,openJourney:N,closeJourney:F,canEditJourneys:I,startBuilder:L,openBrokenLinks:R,capture:z,busy:te,canCapture:V,setCaptureConfirm:ne,chatAvailable:H,chatThread:U,reopenChat:re,updateParams:ie,panelHidden:ae,checksOpen:W,allOpen:G,canChecks:se,openChecks:ce,closeChecks:le,setSheetOpen:ue,sidebarTitled:de,activity:fe={state:`idle`,count:0,text:``,target:null},openAgentThread:pe=()=>{}}){let me=vA(fe),he=r.find(e=>e.id===n)?.title||i?.board?.title||n,ge=t?.hosted&&t?.project?.url&&t.role!==`guest`?t.project:null,ve=!b&&t?.hosted&&t?.role===`viewer`,ye=(0,J.useRef)(null),xe=fA(ye,e),Ce=$k(),Te=z?.running?`running`:z?.state===`failed`&&z.error?`failed`:`dot`,Ee=z?.running&&z.total?`${z.done||0}/${z.total}`:`Capturing`,De=g.map(e=>e.label).join(`
|
|
34
|
-
`),Oe=y?.changes?.includes(`viewport`)?y:null,ke=(0,J.useMemo)(()=>
|
|
35
|
-
`):[],capture:!!V,status:{kind:Te,progress:Ee},viewer:ve,panels:{comments:G,agent:!!H,checks:!!se},settings:!!p,journey:M?.name||null})}),[xe,Ce,he,De,V,Te,Ee,ve,G,H,se,p,M?.name]),Ae=rA(ke.step),je=!!(e&&ke.stretched),K=(0,Y.jsx)(Jk,{info:t,localName:c,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:p,openSettings:m,setShareOpen:h}),Me=(0,Y.jsxs)($e,{value:n,onValueChange:e=>{if(!e.startsWith(`project/`))return l(e);let t=o.find(t=>`project/${t.id}`===e);t?.url&&t.running&&P(t.url)},children:[(0,Y.jsx)(Se,{size:e?`sm`:`touch`,className:e?O(`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`,ge&&`h-6`):`min-w-0 flex-1 border-transparent bg-transparent px-2 text-[15px] font-semibold shadow-none`,"aria-label":`Board: ${he}`,"data-sw-picker":`true`,children:(0,Y.jsx)(oe,{children:(0,Y.jsx)(`span`,{className:`block truncate`,children:he})})}),(0,Y.jsxs)(_e,{children:[(0,Y.jsxs)(be,{children:[o.length>1||ge?(0,Y.jsx)(Ne,{children:ge?ge.name:`This project`}):null,r.map(t=>(0,Y.jsx)(q,{value:t.id,children:e?`${t.title} · ${t.pageCount} pages`:t.title},t.id))]}),o.length>1?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(we,{}),(0,Y.jsxs)(be,{children:[(0,Y.jsx)(Ne,{children:`Local projects`}),o.map(e=>(0,Y.jsxs)(q,{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,Y.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,Y.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,Y.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,Y.jsx)(`h1`,{className:`sr-only`,children:`Shapewall`}),Me,ve?(0,Y.jsx)(CD,{compact:!0}):null,(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,className:`shrink-0 gap-1.5 px-2.5 text-fg`,onClick:()=>{le(),ue(!0)},"aria-label":`Comments, ${G} open`,"data-sw-panel-toggle":`true`,children:[(0,Y.jsx)(Wg,{size:18,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`tabular text-[13px] font-semibold`,children:G})]}),(0,Y.jsxs)(B,{size:`icon`,variant:`ghost`,className:`relative shrink-0 text-fg`,onClick:()=>S(!0),label:`${H?`More: agent, pages, views, screen size`:`More: pages, views, screen size`}${me===`idle`?``:`. ${SA(me,fe)}`}`,"data-sw-menu":`true`,"data-sw-agent-activity":me,"data-sw-agent-activity-count":fe.count||void 0,children:[(0,Y.jsx)(xA,{shown:me,count:fe.count,touch:!0}),(0,Y.jsx)(Ph,{size:19,"aria-hidden":`true`})]}),K]});let Pe=g.map(e=>{let t=e.id===`all`?b_:Iv(e.id);return{id:e.id,tooltip:Ae.viewport?e.label:null,label:Ae.viewport?(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(t,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.label})]}):e.label}}),Fe=(0,Y.jsx)(Bk,{data:i,capture:z}),Ie=Ae.tight?`gap-1`:`gap-1.5`;return(0,Y.jsxs)(`header`,{ref:ye,className:O(`grid h-14 shrink-0 items-center border-b border-line bg-surface px-3`,Ae.tight?`gap-x-3`:`gap-x-5`,`grid-cols-[auto_minmax(0,1fr)]`),"data-sw-toolbar":`full`,"data-sw-toolbar-fit":eA[ke.step],children:[(0,Y.jsxs)(`h1`,{className:`sr-only`,children:[`Shapewall: `,he]}),(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-center`,Ie),"data-sw-toolbar-zone":`left`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center`,style:{maxWidth:tA.name[ke.step]},children:[ge&&!de?(0,Y.jsx)(wD,{project:ge}):null,Me]}),V?null:Fe,Ae.viewport?null:(0,Y.jsx)(gA,{}),g.length>1?(0,Y.jsx)(`span`,{className:O(`shrink-0 rounded-md`,Oe&&`animate-flash`),"data-sw-viewport-flash":Oe?Oe.to:void 0,children:(0,Y.jsx)(Xe,{label:`Screen size`,options:Pe,value:_,onChange:v,itemClassName:O(`h-[26px]`,Ae.viewport&&`px-2`)})},Oe?.at||`still`):null,(0,Y.jsx)(zk,{journeys:ee,journey:M,openJourney:N,closeJourney:F,canEditJourneys:I,startBuilder:L,showLinks:C,toggleLinks:w,linksTip:T,brokenLinks:E,openBrokenLinks:R,canCompare:D,comparePair:x,toggleCompare:k,minimapOn:A,toggleMinimap:j,compact:Ae.view,boxed:pA,labelMax:ke.journey||tA.journey[Math.min(ke.step,tA.journey.length-1)]}),V?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{variant:`ghost`,className:O(`shrink-0`,pA),disabled:z?.running||te,onClick:()=>ne(!0),label:`Capture now`,tooltip:`Recapture every page`,side:`bottom`,"data-sw-capture":`true`,children:(0,Y.jsx)(fh,{size:16,"aria-hidden":`true`})}),Fe]}):null]}),(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-center justify-end`,Ie),"data-sw-toolbar-zone":`right`,children:[ve?(0,Y.jsx)(CD,{}):null,p?(0,Y.jsx)(B,{variant:`ghost`,className:O(`shrink-0`,pA),onClick:m,label:`Agent settings`,tooltip:`Agent settings: which agent the chat uses`,side:`bottom`,"data-sw-settings-open":`true`,children:(0,Y.jsx)(O_,{size:16,"aria-hidden":`true`})}):null,(0,Y.jsx)(`div`,{className:O(`shrink-0`,je&&`-mr-3 px-3`),style:je?{width:Ce}:void 0,"data-sw-panel-tabs":je?`stretched`:`compact`,children:(0,Y.jsx)(CA,{labels:je||!Ae.panels,stretched:je,allOpen:G,panelHidden:ae,chatAvailable:H,chatThread:U,reopenChat:re,checksOpen:W,canChecks:se,openChecks:ce,closeChecks:le,updateParams:ie,activity:fe,shown:me,openAgentThread:pe})})]})]})}function TA({menuOpen:e,setMenuOpen:t,data:n,chatAvailable:r,activity:i,chatThread:o,reopenChat:s,groupedPages:c,jumpToPage:l,modes:u,mode:d,setMode:f,journeys:p,journey:m,canEditJourneys:h,openJourney:g,closeJourney:_,startBuilder:v,canChecks:y,openChecks:b,showLinks:x,toggleLinks:S,brokenLinks:C,canCompare:w,comparePair:T,toggleCompare:E,settingsAvailable:D,openSettings:k,capture:A,canCapture:j,busy:ee,setCaptureConfirm:M,hostedAgents:P=null}){let F=`mb-1.5 flex items-center gap-1 text-[11px] font-medium tracking-wide text-faint uppercase`,[L,R]=(0,J.useState)(``),z=p.length>8,te=z?L.trim().toLowerCase():``,B=te?p.filter(e=>e.name.toLowerCase().includes(te)):p,V=e=>{t(!1),e?g(e):_()};return(0,Y.jsx)(N,{open:e,onClose:()=>t(!1),title:n?.board?.title||`Board`,children:(0,Y.jsxs)(`div`,{className:`space-y-5 p-5`,children:[u.length>1?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:F,children:`Screen size`}),(0,Y.jsx)(Xe,{label:`Screen size`,options:u,value:d,onChange:e=>{f(e),t(!1)},large:!0})]}):null,r?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:o?`default`:`secondary`,onClick:()=>{t(!1),s()},"data-sw-chat-toggle":`true`,children:[(0,Y.jsx)(I,{size:16,"aria-hidden":`true`}),` Chat with your agent`]}):null,P?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),P.open()},"data-sw-hosted-agent-open":`true`,children:[(0,Y.jsx)(I,{size:16,"aria-hidden":`true`}),` Agents`,P.list?.agents?.length?(0,Y.jsxs)(`span`,{className:`ml-auto text-xs font-normal text-muted`,children:[P.list.agents.filter(e=>e.state!==`offline`).length,` of `,P.list.agents.length,` online`]}):null]}):null,i?.text?(0,Y.jsxs)(`p`,{className:O(`-mt-1 flex items-start gap-2 text-xs`,i.state===`waiting`?`text-fg`:`text-muted`),role:`status`,"data-sw-agent-activity-line":i.state,children:[(0,Y.jsx)(`span`,{className:O(`mt-1 h-2 w-2 shrink-0 rounded-full`,i.state===`waiting`?`bg-warn`:`bg-accent`),"aria-hidden":`true`}),i.text]}):null,(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{className:F,children:[(0,Y.jsx)(Ag,{size:12,"aria-hidden":`true`}),` Go to a page`]}),(0,Y.jsx)(WO,{groups:c,onPick:e=>{t(!1),l(e)}})]}),p.length||h?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:F,children:`Journeys`}),z?(0,Y.jsx)(it,{size:`touch`,icon:S_,wrapperClassName:`mb-1.5`,value:L,onChange:e=>R(e.target.value),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-views-filter":`true`}):null,(0,Y.jsxs)(`div`,{className:z?`flex max-h-80 flex-col gap-1.5 overflow-y-auto`:`flex flex-col gap-1.5`,role:`radiogroup`,"aria-label":`Journeys`,"data-sw-journey-menu":`true`,children:[p.length&&!te?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,role:`radio`,"aria-checked":!m,variant:m?`secondary`:`default`,onClick:()=>V(null),"data-sw-journey-open":`none`,children:[(0,Y.jsx)(Rh,{size:15,"aria-hidden":`true`}),` None`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs opacity-70`,children:`All pages`})]}):null,B.map(e=>(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,role:`radio`,"aria-checked":m?.id===e.id,variant:m?.id===e.id?`default`:`secondary`,onClick:()=>V(e.id),"data-sw-journey-open":e.id,children:[(0,Y.jsx)(v_,{size:15,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs tabular-nums opacity-70`,children:Rk(e)})]},e.id)),te&&!B.length?(0,Y.jsx)(`p`,{className:`px-1 text-sm text-muted`,children:`No journey matches.`}):null,h?(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{t(!1),v()},children:[(0,Y.jsx)(c_,{size:15,"aria-hidden":`true`}),` New journey`]}):null]})]}):null,(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`p`,{className:F,children:`Show`}),y?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),b()},"data-sw-checks-toggle":`true`,children:[(0,Y.jsx)(Kh,{size:16,"aria-hidden":`true`}),`Checks`]}):null,(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,"aria-pressed":x,variant:x?`default`:`secondary`,onClick:()=>{t(!1),S()},"data-sw-links-toggle":`true`,children:[(0,Y.jsx)(ov,{size:15,"aria-hidden":`true`}),` `,x?`Hide links between pages`:`Show links between pages`,(0,Y.jsx)(kk,{count:C.length})]}),w?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,"aria-pressed":!!T,variant:T?`default`:`secondary`,onClick:()=>{t(!1),E()},"data-sw-compare-toggle":`true`,children:[(0,Y.jsx)(Xh,{size:15,"aria-hidden":`true`}),` `,T?`Leave compare mode`:`Compare environments`]}):null,D?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),k()},"data-sw-settings-open":`true`,children:[(0,Y.jsx)(O_,{size:15,"aria-hidden":`true`}),` Agent settings`]}):null]}),(0,Y.jsxs)(`div`,{className:`space-y-2 border-t border-line pt-4`,children:[(0,Y.jsx)(Vk,{data:n,capture:A}),j?(0,Y.jsxs)(a,{size:`touch`,className:`w-full`,disabled:A?.running||ee,onClick:()=>{t(!1),M(!0)},"data-sw-capture":`true`,children:[(0,Y.jsx)(fh,{size:15,"aria-hidden":`true`}),` Capture now`]}):null]})]})})}function EA({notice:e,onUndo:t,modeLabel:n,compact:r=!1,inSheet:i=!1}){let o=QS(e,n,{compact:r});return o?(0,Y.jsxs)(`div`,{className:O(`flex items-center gap-2 text-xs text-fg`,i?`w-full border-b border-line bg-surface-2 px-4 py-2`:`pointer-events-auto w-max max-w-full rounded-lg border border-line bg-surface py-1 pr-1 pl-3 shadow-pop`),role:`status`,"data-sw-view-notice":e.changes.join(` `),"data-sw-viewport-notice":e.changes.includes(`viewport`)?e.to:void 0,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:o.text}),(0,Y.jsx)(a,{size:r?`touch`:`xs`,variant:`secondary`,className:`shrink-0`,onClick:t,"data-sw-viewport-notice-back":`true`,children:o.back})]}):null}function DA({wide:e,commentMode:t,canComment:n,composing:r=!1,parkedDraft:i=null,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,viewNotice:y,undoViewNotice:b,noticeInSheet:x=!1,covered:S=!1,dismissTip:C,modes:w,comparePair:T}){let E=e=>w.find(t=>t.id===e)?.label||e,D=QS(y,E),O=!!D&&!x;if(!e&&S)return null;let k=e?`Scroll or drag to move, Ctrl+scroll or pinch to zoom. Click a page for its actions${n&&!T?`: Comment is first. Or press C, or use the Comment tool below`:``}.`:`Pinch to zoom. Tap a page for its actions${n&&!T?`: Comment is first. Or use the comment tool below`:``}.`;return(0,Y.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:[o&&!s&&!c&&hv(l?.links,u,d)>150?(0,Y.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,Y.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,Y.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,Y.jsx)(a,{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&&!r&&!o&&!_&&!v&&!D?(0,Y.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,Y.jsx)(bg,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:k}),(0,Y.jsx)(B,{size:e?`icon-xs`:`icon`,variant:`ghost`,className:`shrink-0 rounded-full shadow-none`,onClick:C,label:`Dismiss the tip`,"data-sw-tip-dismiss":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})})]}):null,i?(0,Y.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-1 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs font-medium text-fg shadow-pop`,role:`status`,"data-sw-draft-kept":`true`,children:[(0,Y.jsx)(Hg,{size:13,className:`mr-1 shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Draft kept for `,i.title]}),(0,Y.jsx)(a,{size:`xs`,variant:`soft`,className:`ml-1 shrink-0 rounded-full`,onClick:i.onReopen,"data-sw-draft-reopen":`true`,children:`Reopen`}),(0,Y.jsx)(a,{size:`xs`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:i.onDiscard,"data-sw-draft-discard":`true`,children:`Discard`})]}):null,O?(0,Y.jsx)(EA,{notice:y,onUndo:b,modeLabel:E,compact:!e}):null]})}var OA=e=>e?.tool?`${e.owner}\n${e.key}`:``;function kA(e){let t=Hx(OA);return e&&!!t}function AA({flow:e,canvasRef:t,targets:n,focusFor:r,shotFor:i}){let a=Hx(OA),o=(0,J.useRef)(null),s=(0,J.useRef)({targets:n,focusFor:r,shotFor:i,active:a});return s.current={targets:n,focusFor:r,shotFor:i,active:a},(0,J.useEffect)(()=>{if(!a){o.current&&e.setViewport(o.current,{duration:cO(400)}),o.current=null;return}let[n,r]=a.split(`
|
|
36
|
-
`),{targetId:i,viewport:c}=
|
|
37
|
-
`),{targetId:i,viewport:a}=Rv(r);return(0,Y.jsx)(`div`,{className:`pointer-events-none relative z-30 flex max-w-full justify-center`,"data-sw-drawing-mode":`true`,children:(0,Y.jsx)(cS,{owner:n,title:e?.(i,a)||``})})}var MA=[`select`,`hand`,`comment`,`draw`,`text`],NA=new Set([`select`,`hand`]);function PA({wide:e=!1,commenting:t=!1,draw:n=!1,liveBoard:r=!1,livePage:i=!1}={}){let a={select:!0,hand:e,comment:t,draw:t&&n,text:e&&r&&(t||i)};return MA.filter(e=>a[e])}function FA({drawing:e=!1,commentMode:t=!1,drawArmed:n=!1,selecting:r=!1,hand:i=!1}={}){return e||t&&n?`draw`:t?`comment`:r?`text`:i?`hand`:`select`}function IA(e){return e.includes(`hand`)&&e.some(e=>!NA.has(e))}var LA={v:`select`,h:`hand`};function RA(e,{tools:t=MA,busy:n=!1,handled:r=!1}={}){if(!e||r||n||e.altKey||e.ctrlKey||e.metaKey||e.repeat)return null;let i=LA[String(e.key||``).toLowerCase()];if(!i||!t.includes(i))return null;let a=e.target;return a&&(xC(a)||a.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`,`IFRAME`].includes(a.tagName))?null:i}var zA={select:{label:`Select`,tip:`Select: click a page or a pin`,keys:[`V`],shortcut:`V`,icon:e_},hand:{label:`Hand`,tip:`Hand: drag anywhere to move, opens nothing`,keys:[`H`],shortcut:`H`,icon:og},comment:{label:`Comment`,tip:`Comment: click a page to pin a note`,keys:[`C`],shortcut:`C`,icon:Hg},draw:{label:`Draw`,tip:`Draw on a page: box, arrow or pen`,keys:[],icon:ch},text:{label:`Select text`,tip:`Select text on the selected live page`,keys:[],icon:B_}};function BA({touch:e,children:t}){return(0,Y.jsx)(`div`,{className:O(`pointer-events-none absolute inset-x-0 bottom-0 flex flex-col items-center gap-2`,e?`px-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))]`:`px-3 pb-3`),"data-sw-tool-dock":`true`,children:t})}function VA({tools:e,active:t,onTool:n,touch:r,shift:i=0}){let o=(0,J.useRef)(null),s=IA(e);return(0,Y.jsx)(`div`,{ref:o,className:O(`pointer-events-auto relative z-30 flex items-center gap-0.5 rounded-lg border border-line bg-surface/95 p-0.5 shadow-pop backdrop-blur`,r&&`rounded-xl`),style:i?{transform:`translateX(${i}px)`}:void 0,role:`toolbar`,"aria-label":`Board tools`,"aria-orientation":`horizontal`,onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Array.from(o.current?.querySelectorAll(`button[data-sw-tool]`)||[]),n=t.indexOf(document.activeElement);if(n<0)return;let r=null;e.key===`ArrowRight`||e.key===`ArrowDown`?r=(n+1)%t.length:e.key===`ArrowLeft`||e.key===`ArrowUp`?r=(n-1+t.length)%t.length:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),e.stopPropagation(),t[r].focus())},"data-sw-tools":t,children:e.map(e=>{let i=zA[e],o=e===t,c=o&&NA.has(e),l=(0,Y.jsx)(a,{variant:o&&!c?`default`:`ghost`,size:r?`icon`:`icon-sm`,className:O(`shadow-none focus-visible:outline-offset-1`,r&&`rounded-lg`,!o&&`text-fg/80 hover:text-fg`,c&&`bg-surface-2 text-fg ring-1 ring-line-strong/70 ring-inset hover:bg-surface-2`),"data-sw-tool-look":o?c?`quiet`:`accent`:void 0,"aria-label":i.label,"aria-pressed":o,"aria-keyshortcuts":i.shortcut,tabIndex:o?0:-1,onClick:()=>n(e),"data-sw-tool":e,"data-sw-comment-mode":e===`comment`?`true`:void 0,children:(0,Y.jsx)(i.icon,{size:r?19:16,"aria-hidden":`true`})},e),u=r?l:(0,Y.jsx)(_,{content:(0,Y.jsx)(dx,{label:i.tip,keys:i.keys}),side:`top`,children:l},e);return e===`hand`&&s?(0,Y.jsxs)(J.Fragment,{children:[u,(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px shrink-0 bg-line`,"aria-hidden":`true`,"data-sw-tools-divider":`true`})]},e):u})})}var HA=`pointer-events-auto relative z-30 flex w-max max-w-full items-center gap-2 rounded-[18px] py-0.5 pr-0.5 pl-3 text-xs font-medium shadow-pop`;function UA({wide:e,picking:t=null,composing:n=null,selectText:r=null,onDone:i}){let o=rx(e=>!!e.readingKey);if(n)return(0,Y.jsxs)(`div`,{className:O(HA,`border border-line bg-surface text-fg`),role:`status`,"data-sw-tool-note":`true`,"data-sw-comment-hint":`composing`,children:[(0,Y.jsx)(Hg,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,"data-sw-comment-hint-target":`true`,children:[(0,Y.jsx)(`span`,{className:`text-muted`,children:`Commenting on`}),` `,n.target]}),(0,Y.jsx)(a,{size:`xs`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:n.onCancel,"data-sw-comment-hint-cancel":`true`,children:`Cancel (Esc)`})]});if(t){let n=t.draw?ch:Hg,r=e?`Click`:`Tap`,o=t.draw?null:t.page,s=t.draw?`${r} a page to draw on it. The drawing goes with your comment.`:t.live?`${r} 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.`;return(0,Y.jsxs)(`div`,{className:O(HA,`bg-accent text-accent-fg`),role:`status`,"data-sw-tool-note":`true`,"data-sw-comment-hint":t.draw?`draw`:t.live?`element`:`page`,"data-sw-comment-hint-page":o?o.key:void 0,children:[(0,Y.jsx)(n,{size:13,className:`shrink-0`,"aria-hidden":`true`}),o?(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r,` where the comment goes on `,(0,Y.jsx)(`span`,{className:`font-semibold`,children:o.title}),o.keyboard?`, or press Enter`:null]}):(0,Y.jsx)(`span`,{className:`min-w-0`,children:s}),(0,Y.jsxs)(a,{size:e?`xs`:`touch`,variant:`inverse`,className:`shrink-0 rounded-full`,onClick:i,"data-sw-comment-hint-done":`true`,children:[`Done`,e?` (Esc)`:``]})]})}return r?(0,Y.jsxs)(`div`,{className:O(HA,`border border-line bg-surface text-fg`),role:`status`,"data-sw-tool-note":`true`,"data-sw-select-text-note":o?`reading`:`armed`,children:[(0,Y.jsx)(B_,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:o?`Selecting text on ${r.title}. Move the pointer off the page to scroll and zoom the board again.`:`Select text is on for ${r.title}: click the page, then select and copy.`}),(0,Y.jsx)(a,{size:`xs`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:r.onDone,"data-sw-select-text-done":`true`,children:`Done`})]}):null}function WA(e){let[t,n]=(0,J.useState)(()=>typeof window>`u`?1280:window.innerWidth);return(0,J.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>n(Math.round(t.getBoundingClientRect().width));if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function GA(e,t){let[n,r]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{let n=e.current;if(!t||!n){r(null);return}let i=()=>{let e=Math.round(n.getBoundingClientRect().top),t=window.innerHeight;r(n=>n&&n.canvasTop===e&&n.windowHeight===t?n:{canvasTop:e,windowHeight:t})};i(),window.addEventListener(`resize`,i);let a=typeof ResizeObserver>`u`?null:new ResizeObserver(i);return a?.observe(n),()=>{window.removeEventListener(`resize`,i),a?.disconnect()}},[e,t]),n}function KA(e){let[t,n]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{let t=typeof window>`u`?null:window.visualViewport;if(!e||!t){n(!1);return}let r=()=>n(window.innerHeight-t.height>120);return r(),t.addEventListener(`resize`,r),()=>t.removeEventListener(`resize`,r)},[e]),t}var qA={margin:12,gap:8,zoomFull:197,zoomCompact:122,minimap:168,frame:6,between:2,button:32,touchMargin:8,touchButton:44,fit:44},JA=600+2*(qA.minimap+qA.margin+qA.gap);function YA(e,t=!1,n=!1){return e<=0?0:qA.frame+e*(t?qA.touchButton:qA.button)+(e-1)*qA.between+(n?5+qA.between:0)}function XA({width:e,tools:t,left:n=[],right:r=0,margin:i=qA.margin,gap:a=qA.gap}){let o=(e-t)/2,s=n.length?n:[0],c=[];for(let e of r?[!0,!1]:[!1])s.forEach((t,n)=>{(t||!e||s.length===1)&&c.push({size:t,index:n,keepRight:e})});let l=n=>({min:i+(n.size?n.size+a:0),max:e-i-(n.keepRight?r+a:0)-t});for(let e of c){let{min:t,max:n}=l(e);if(!(t>n))return{shift:Math.round(Math.min(n,Math.max(t,o))-o),compact:e.index,right:e.keepRight}}let u=c[c.length-1];return{shift:Math.round(l(u).min-o),compact:u.index,right:!1}}function ZA(){let e=document.querySelector(`[data-sw-composer-popover]`);e&&(e.setAttribute(`data-sw-composer-nudged`,String(Date.now())),sO()||e.animate?.([{translate:`0`},{translate:`-6px`},{translate:`5px`},{translate:`-3px`},{translate:`0`}],{duration:280,easing:`ease-out`}),e.querySelector(`[data-sw-comment-input]`)?.focus({preventScroll:!0}))}function QA(){let[e,t]=(0,J.useState)(null),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{e||r(!1)},[e]),(0,J.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 $A(e,t){let n=!!e?.untilSheet;(0,J.useEffect)(()=>{if(!n)return;let e=()=>{document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)&&t(e=>e?.untilSheet?null:e)};e();let r=new MutationObserver(e);return r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`]}),()=>r.disconnect()},[n,t])}function ej({toast:e,setToast:t,onHold:n,wide:r}){return $A(e,t),e?(0,Y.jsxs)(`div`,{onMouseEnter:()=>n?.(!0),onMouseLeave:()=>n?.(!1),onFocus:()=>n?.(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||n?.(!1)},className:`pointer-events-auto relative z-[80] flex w-max max-w-full 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`,role:`status`,"data-sw-toast":`true`,children:[(0,Y.jsx)(`span`,{className:`min-w-0`,children:e.text}),e.undo?(0,Y.jsx)(a,{size:r?`xs`:`touch`,variant:`inverse`,onClick:()=>{e.undo(),t(null)},"data-sw-toast-undo":`true`,children:`Undo`}):null,(0,Y.jsx)(B,{size:r?`icon-xs`:`icon`,variant:`inverse`,onClick:()=>t(null),label:`Dismiss`,children:(0,Y.jsx)(se,{size:13,"aria-hidden":`true`})})]},e.at):null}function tj({notice:e,setNotice:t,wide:n}){return e?(0,Y.jsxs)(`div`,{className:O(`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,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text}),(0,Y.jsx)(a,{variant:`ghost`,size:n?`xs`:`touch`,onClick:()=>t(null),children:`Dismiss`})]}):null}var nj=`https://shapewall.com/docs/where-to-run#where-the-work-happens`,rj={approval:`needs your OK`,"needs-human":`needs a person`,"branch-ready":`fix ready on a branch`},ij=`flex min-h-11 w-full items-center gap-2 rounded-md border border-line bg-surface px-2.5 py-1.5 text-left text-sm text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent lg:min-h-9`;function aj({title:e,items:t,tone:n,note:r,onOpen:i,hook:a}){return t.length?(0,Y.jsxs)(`section`,{className:`space-y-1.5`,"data-sw-hosted-agent-list":a,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-semibold text-muted`,children:e}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:t.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:ij,"data-sw-hosted-agent-item":e.id,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${n}`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),r(e)?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:r(e)}):null]})},e.id))})]}):null}function oj({mode:e}){return(0,Y.jsx)(e===`none`?Rh:e===`auto`?M_:Jh,{size:12,className:`mt-0.5 shrink-0`,"aria-hidden":`true`})}function sj({label:e,ids:t,nameOf:n,onOpen:r,hook:i,tone:a}){return t.length?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,"data-sw-hosted-agent-comments":i,children:[(0,Y.jsx)(`span`,{className:`text-[11px] text-muted`,children:e}),t.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:O(`inline-flex min-h-11 max-w-full items-center rounded-full border px-2 text-xs font-medium outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent lg:min-h-6`,a),"data-sw-hosted-agent-comment":e,children:(0,Y.jsx)(`span`,{className:`truncate`,children:n(e)})},e))]}):null}function cj({agent:e,nameOf:t,onOpen:n,onChat:r}){let i=e.state===`offline`&&e.queued.length>0,o=!!(r&&e.link?.connected&&e.link.chats),[s,c]=(0,J.useState)(!1),l=e.edits?.mode||`none`,u=jT(e),d=(e.elsewhere?.working||0)+(e.elsewhere?.queued||0);return(0,Y.jsxs)(`li`,{className:`space-y-1.5 rounded-lg border border-line bg-surface p-2.5`,"data-sw-hosted-agent-row":e.id,"data-sw-hosted-agent-name":e.name,"data-sw-agent-state":e.state,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(_T,{label:e.name,state:bT[e.state],icon:e.icon,tint:e.tint,logo:e.logo,className:`mt-0.5`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-sm`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),e.isDefault?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-line px-1.5 text-[10px] leading-4 font-medium text-muted`,"data-sw-agent-default":`true`,children:`Default`}):null]}),(0,Y.jsxs)(`p`,{className:O(`text-xs`,i?`text-fg`:`text-muted`),"data-sw-hosted-agent-state":!0,children:[xT(e),e.machine?` · ${e.machine}`:``]}),u?(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-start gap-1 text-xs text-muted`,"data-sw-hosted-agent-mode":l,children:[(0,Y.jsx)(oj,{mode:l}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:l===`none`?`${u}. No edits, no commands.`:u})]}):null]}),o?(0,Y.jsxs)(a,{size:`sm`,variant:e.chat?.ok?`default`:`secondary`,className:`min-h-11 shrink-0 lg:min-h-8`,disabled:!e.chat?.ok||s,onClick:async()=>{c(!0);try{await r(e)}finally{c(!1)}},"aria-label":`Chat with ${e.name}`,"data-sw-hosted-agent-chat":e.id,children:[(0,Y.jsx)(Wg,{size:14,"aria-hidden":`true`}),` Chat`]}):null]}),o&&(e.chat?.ok?l!==`none`:e.canSend)?(0,Y.jsx)(`p`,{className:`text-[11px] text-muted`,"data-sw-hosted-agent-chat-note":e.chat?.ok?`ok`:e.chat?.code||`no`,children:e.chat?.ok?`Chat reads the project and answers. A fix starts from a comment: Fix with `+e.name+`.`:e.chat?.code===`agent_offline`?`${e.name} is offline: chat needs it online. A comment sent to it waits.`:e.chat?.reason}):null,(0,Y.jsx)(sj,{label:`Working on`,ids:e.working,nameOf:t,onOpen:n,hook:`working`,tone:`border-accent/40 bg-accent/10 text-fg`}),(0,Y.jsx)(sj,{label:i?`Waiting for it`:`Next`,ids:e.queued,nameOf:t,onOpen:n,hook:`queued`,tone:i?`border-warn/50 bg-warn/10 text-fg`:`border-line bg-surface text-fg`}),d?(0,Y.jsxs)(`p`,{className:`text-[11px] text-muted`,children:[d===1?`1 more comment`:`${d} more comments`,` on other boards of this project.`]}):null,(0,Y.jsxs)(`p`,{className:`text-[11px] text-muted`,"data-sw-hosted-agent-audience":e.audience.kind,children:[e.canSend?`Takes work from: ${lj(e.audience.text)}.`:o?String(e.reason||``).replace(`can send work to`,`can use`):e.reason,e.canSend&&e.audience.inherited?` (As before 0.4.0.)`:``]})]})}var lj=e=>/^(Only|Everyone)/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e;function uj({agents:e=null,listening:t=null,activity:n,approvals:r=0,titleOf:i=()=>``,manageUrl:a=null,onOpenComment:o,onClose:s,heading:c=!0,onChat:l=null,onBoardChat:u=null,admin:d=!1}){let f=e?.agents||[],p=!!e,m=p?f.some(e=>e.state!==`offline`):!!t?.online,h=typeof window>`u`?``:window.location.origin,g=e=>{let t=i(e);return t?`#${e} ${t}`:`#${e}`},_=e?.unassigned||[],v=f.some(e=>e.working.length||e.queued.length)||_.length;return(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-sw-hosted-agent":`true`,children:[c?(0,Y.jsx)(TC,{icon:I,title:`Agents`,onClose:s,closeLabel:`Close the agent panel`,closeProps:{"data-sw-hosted-agent-close":`true`}}):null,(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto border-t border-line p-3`,children:[f.length?(0,Y.jsxs)(`section`,{className:`space-y-1.5`,"data-sw-hosted-agent-listening":m?`online`:`none`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`flex-1 text-xs font-semibold text-muted`,role:`status`,children:m?`Agents of this project`:`No agent is online`}),a?(0,Y.jsxs)(`a`,{href:a,className:`inline-flex min-h-11 items-center gap-1 text-xs font-medium text-accent underline-offset-2 hover:underline lg:min-h-0`,"data-sw-hosted-agent-manage":`true`,children:[(0,Y.jsx)(E_,{size:12,"aria-hidden":`true`}),` Manage`]}):null]}),m?null:(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Comments sent to an agent wait until it is back. Nothing is lost.`}),(0,Y.jsx)(`ul`,{className:`space-y-1.5`,"data-sw-hosted-agent-rows":!0,children:f.map(e=>(0,Y.jsx)(cj,{agent:e,nameOf:g,onOpen:o,onChat:l},e.id))}),u&&f.some(e=>e.link?.connected&&e.link.chats)?(0,Y.jsxs)(`button`,{type:`button`,onClick:u,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-accent underline-offset-2 outline-none hover:underline focus-visible:outline-2 focus-visible:outline-accent lg:min-h-0`,"data-sw-hosted-agent-board-chat":`true`,children:[(0,Y.jsx)(Wg,{size:12,"aria-hidden":`true`}),` Open the board chat (everyone in the workspace reads it)`]}):null]}):(0,Y.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface-2/60 p-3 text-sm`,role:`status`,"data-sw-hosted-agent-listening":m?`online`:`none`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${m?`bg-ok`:`bg-faint`}`,"aria-hidden":`true`}),m?`Agent online: ${t?.name||`agent`}`:`No agent is connected to this project`]}),m?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[`Last heard `,A(t.lastSeenAt),`.`]}):(0,Y.jsxs)(Y.Fragment,{children:[d?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Comments sent to an agent wait until one connects. To chat with your coding agent here, run this in the project's folder, on the machine that has the code:`}),(0,Y.jsxs)(`code`,{className:`mt-1.5 block rounded bg-surface px-2 py-1.5 font-mono text-xs break-all text-fg`,"data-sw-hosted-agent-command":`connect`,children:[`shapewall agent connect --remote `,h]}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs text-muted`,children:`It reads and answers only. For an agent that fixes the comments sent to it, with a project token that may take work, run:`}),(0,Y.jsxs)(`code`,{className:`mt-1.5 block rounded bg-surface px-2 py-1.5 font-mono text-xs break-all text-fg`,"data-sw-hosted-agent-command":`watch`,children:[`shapewall watch --remote `,h]})]}):(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Comments sent to an agent wait until one connects. An admin of this workspace connects one from the machine that has the code.`}),(0,Y.jsxs)(`span`,{className:`mt-1.5 flex flex-wrap gap-x-3`,children:[(0,Y.jsx)(`a`,{href:nj,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center text-xs font-medium text-accent underline-offset-2 hover:underline lg:min-h-0`,"data-sw-hosted-agent-docs":`true`,children:`Where the agent runs`}),a?(0,Y.jsx)(`a`,{href:a,className:`inline-flex min-h-11 items-center text-xs font-medium text-accent underline-offset-2 hover:underline lg:min-h-0`,"data-sw-hosted-agent-manage":`true`,children:`Connect an agent`}):null]})]})]}),_.length?(0,Y.jsxs)(`section`,{className:`space-y-1.5`,"data-sw-hosted-agent-list":`unassigned`,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-semibold text-muted`,children:`Waiting for any agent`}),(0,Y.jsx)(sj,{label:``,ids:_,nameOf:g,onOpen:o,hook:`unassigned`,tone:`border-line bg-surface text-fg`})]}):null,r?(0,Y.jsxs)(`p`,{className:`rounded-lg border border-warn/40 bg-warn/10 px-3 py-2 text-xs text-fg`,"data-sw-hosted-agent-approvals":r,children:[r===1?`A request waits`:`${r} requests wait`,` for your OK: see the strip at the top of the board.`]}):null,(0,Y.jsx)(aj,{title:`Needs you`,hook:`waiting`,items:n.waiting,tone:`bg-warn`,note:e=>rj[e.why]||``,onOpen:o}),p?null:(0,Y.jsx)(aj,{title:`Working`,hook:`working`,items:n.working,tone:`bg-accent`,note:()=>``,onOpen:o}),!n.waiting.length&&!n.working.length&&!v?(0,Y.jsx)(`p`,{className:`text-xs text-muted`,"data-sw-hosted-agent-idle":`true`,children:`Nothing is running, and nothing waits for you. To hand a comment to an agent, open it and choose Send to agent.`}):null]})]})}var dj=(0,J.lazy)(()=>YE(()=>import(`./ChecksPanel-BD7GniTp.js`),__vite__mapDeps([4,1,2,3,5,6]),import.meta.url)),fj=(0,J.lazy)(()=>YE(()=>import(`./BoardChat-DG08cvD0.js`),__vite__mapDeps([7,1,2,8,5,3,6]),import.meta.url));function pj({wide:e,checksOpen:t,checksProps:n,chatThread:r,chatProps:i,panelHidden:a,panelProps:o,updateParams:s,hostedAgent:c=null}){return e&&t?(0,Y.jsx)(Sj,{panel:`checks`,"aria-label":`Checks`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{className:`p-4 text-sm text-muted`,children:`Loading checks…`}),children:(0,Y.jsx)(dj,{...n})})},`checks`):e&&r?(0,Y.jsx)(Sj,{panel:`agent`,"aria-label":`Agent`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(dv,{}),children:(0,Y.jsx)(fj,{...i,onClose:()=>s({chat:null})})})},`agent`):e&&c?(0,Y.jsx)(Sj,{panel:`agent`,"aria-label":`Agent`,children:(0,Y.jsx)(uj,{...c,onClose:()=>s({ha:null})})},`hosted-agent`):e&&!a?(0,Y.jsx)(Sj,{panel:`comments`,id:`sw-comments`,tabIndex:-1,className:`outline-none`,"aria-label":`Comments`,children:(0,Y.jsx)(Bw,{...o,onClose:()=>s({panel:`off`})})},`comments`):null}var{width:mj,min:hj,max:gj,share:_j}=nA,vj=16,yj=`side`,bj=()=>Math.max(hj,Math.min(gj,Math.floor(window.innerWidth*_j)));function xj(e){return Math.min(bj(),Math.max(hj,Math.round(e)))}function Sj({panel:e,defaultWidth:t=mj,className:n,children:r,...i}){let[a,o]=(0,J.useState)(()=>xj(VO(yj)??t)),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>Zk(a),[a]),(0,J.useLayoutEffect)(()=>()=>Zk(null),[]),(0,J.useEffect)(()=>{let e=()=>o(e=>xj(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let u=e=>{let n=xj(e);o(n),HO(yj,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(xj(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:vj;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,Y.jsxs)(`aside`,{className:O(`relative flex shrink-0 flex-col border-l border-line bg-surface`,n),style:{width:a},"data-sw-rail":e,...i,children:[(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,"aria-valuenow":a,"aria-valuemin":hj,"aria-valuemax":bj(),"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,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`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,Y.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null,r]})}function Cj({hostedAgent:e=null,checksOpen:t,closeChecks:n,checksProps:r,chatAvailable:i,chatThread:a,chatProps:o,updateParams:s,sheetOpen:c,setSheetOpen:l,panelProps:u,threadSheet:d,threadProps:f,closeThread:p,selectedComment:m,targetTitle:h,draft:g,busy:_,setDraft:v,draftDescription:y,composerProps:b,viewNotice:x=null,undoViewNotice:S=null,modeLabel:C=e=>e,startDraw:w=!1,threadFromList:T=!1,sheetContentMax:E=null,sheetPanelMax:D=null}){return(0,Y.jsxs)(Y.Fragment,{children:[t?(0,Y.jsx)(N,{open:!0,onClose:n,title:`Checks`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] min-h-0 flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{children:`Loading checks…`}),children:(0,Y.jsx)(dj,{...r})})})}):null,i?(0,Y.jsx)(N,{open:!!a,onClose:()=>s({chat:null}),title:`Agent`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(dv,{heading:!1}),children:(0,Y.jsx)(fj,{...o,heading:!1})})})}):null,e?(0,Y.jsx)(N,{open:!0,onClose:()=>s({ha:null}),title:`Agents`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex max-h-[78dvh] min-h-0 flex-col outline-none`,tabIndex:-1,"data-autofocus":!0,"data-sw-hosted-agent-sheet":`true`,children:(0,Y.jsx)(uj,{...e,heading:!1})})}):null,(0,Y.jsx)(N,{open:c&&!t,onClose:()=>l(!1),title:`Comments`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex max-h-[70dvh] flex-col`,children:(0,Y.jsx)(Bw,{...u,heading:!1})})}),(0,Y.jsx)(N,{open:d&&!!f&&!t,onClose:p,title:m?`#${m.id} · ${h(m.pageId)}`:`Comment`,description:m?`${m.viewport} capture`:void 0,size:`md`,back:T?`Comments`:null,maxHeight:D,children:f?(0,Y.jsx)(`div`,{className:`relative flex max-h-[62dvh] flex-col outline-none`,style:E?{maxHeight:E}:void 0,tabIndex:-1,"data-autofocus":!0,"data-sw-thread-sheet":m.id,children:(0,Y.jsx)(uE,{...f,notice:x&&x.id===m.id?(0,Y.jsx)(EA,{notice:x,onUndo:S,modeLabel:C,compact:!0,inSheet:!0}):null})}):null}),(0,Y.jsx)(N,{open:!!g&&!t,onClose:()=>_?null:v(null),title:`New comment`,description:y,children:(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(eT,{...b,touch:!0,startDraw:w})})})]})}var wj=e=>String(e).replace(/\/w\/[^/#?]+.*$/,`/account`),Tj=`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`;function Ej({journeys:e=[],journeyId:t=null,onJourney:n,canEditJourneys:r=!1,onNewJourney:i=null,bare:a=!1}){let[o,s]=(0,J.useState)(``),c=e.length>8,l=c?o.trim().toLowerCase():``,u=l?e.filter(e=>String(e.name||e.id).toLowerCase().includes(l)):e,d=e=>O(Tj,e?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),f=e=>O(`shrink-0`,e?`text-accent`:`text-faint`);return(0,Y.jsxs)(`div`,{className:O(`flex w-full flex-col`,!a&&`border-t border-line pt-2`),"data-sw-journeys-sidebar":`true`,children:[a?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:e.length})]}),c?(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(it,{size:`sm`,icon:S_,value:o,onChange:e=>s(e.target.value.slice(0,80)),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-journeys-filter":`true`})}):null,(0,Y.jsxs)(`ul`,{className:`pb-2`,"aria-label":`Journeys`,children:[e.length&&!l?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(!t),"aria-current":t?void 0:`true`,onClick:()=>n(null),"data-sw-pages-journey":`none`,children:[(0,Y.jsx)(Rh,{size:14,"aria-hidden":`true`,className:f(!t)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`None`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:`Show all pages`})]})}):null,u.map(e=>{let r=e.id===t;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(r),"aria-current":r?`true`:void 0,onClick:()=>n(r?null:e.id),"data-sw-pages-journey":e.id,children:[(0,Y.jsx)(v_,{size:14,"aria-hidden":`true`,className:f(r)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint tabular`,children:Rk(e)})]})},e.id)}),l&&!u.length?(0,Y.jsxs)(`li`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`No journey matches "`,o.trim(),`".`]}):null,e.length?null:(0,Y.jsx)(`li`,{className:`px-2.5 py-2 text-xs text-muted`,children:`No journeys yet.`}),r&&i?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:O(Tj,`text-muted hover:bg-surface-2 hover:text-fg`),onClick:i,"data-sw-journeys-new":`true`,children:[(0,Y.jsx)(c_,{size:14,"aria-hidden":`true`,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`New journey`})]})}):null]})]})}function Dj({groups:e,comments:t,activePage:n,onPage:r,bare:i=!1,filter:a=!0}){let[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(()=>new Set),u=o.trim().toLowerCase(),d=(0,J.useMemo)(()=>{let e=new Map;for(let n of t||[])n.status===`open`&&e.set(n.pageId,(e.get(n.pageId)||0)+1);return e},[t]),f=e.map(e=>({...e,pages:u?e.pages.filter(t=>`${t.title} ${t.path||``} ${e.group}`.toLowerCase().includes(u)):e.pages})).filter(e=>e.pages.length),p=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),m=e.reduce((e,t)=>e+t.pages.length,0);return(0,Y.jsxs)(`div`,{className:O(`flex w-full flex-col`,!i&&`border-t border-line pt-2`),"data-sw-pages-sidebar":`true`,children:[i?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:m})]}),i||!a?null:(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(it,{size:`sm`,icon:S_,value:o,onChange:e=>s(e.target.value.slice(0,80)),placeholder:`Filter pages`,"aria-label":`Filter pages`,"data-sw-pages-filter":`true`})}),(0,Y.jsxs)(`div`,{className:`pb-2`,children:[f.map(e=>{let t=c.has(e.group)&&!u;return(0,Y.jsxs)(`section`,{className:`mb-1`,"data-sw-pages-group":e.group,children:[(0,Y.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:()=>p(e.group),children:[(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`,className:O(`transition-transform`,t&&`-rotate-90`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.group}),(0,Y.jsx)(`span`,{className:`ml-auto font-normal text-faint tabular`,children:e.pages.length})]}),t?null:(0,Y.jsx)(`ul`,{className:`ml-4`,children:e.pages.map((t,i)=>{let a=d.get(t.id)||0,o=t.id===n,s=i===e.pages.length-1;return(0,Y.jsx)(`li`,{className:O(`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,Y.jsxs)(`button`,{type:`button`,className:O(`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:()=>r(t.id),"data-sw-pages-item":t.id,children:[(0,Y.jsx)(Hh,{size:14,"aria-hidden":`true`,className:O(`shrink-0`,o?`text-accent`:`text-faint`)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),a?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted tabular`,"aria-label":`${a} open`,children:a}):null]})},t.id)})})]},e.group)}),u&&!f.length?(0,Y.jsxs)(`p`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`Nothing matches "`,o.trim(),`".`]}):null]})]})}var Oj=`shapewall.sidebar.nav`,kj=[`pages`,`journeys`];function Aj(){try{let e=window.localStorage.getItem(Oj);return kj.includes(e)?e:`pages`}catch{return`pages`}}function jj({className:e=``}){return(0,Y.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-accent ${e}`,"aria-hidden":`true`,"data-sw-journey-dot":`true`})}function Mj({groups:e,journeys:t=[],comments:n,activePage:r,journeyId:i,onPage:a,onJourney:o,canEditJourneys:s,onNewJourney:c}){let[l,u]=(0,J.useState)(Aj),d=e.reduce((e,t)=>e+t.pages.length,0);if(!t.length&&!s)return(0,Y.jsx)(Dj,{groups:e,comments:n,activePage:r,onPage:a,filter:!1});let f=e=>{u(e);try{window.localStorage.setItem(Oj,e)}catch{}},p=`gap-1`;return(0,Y.jsxs)(Ee,{value:l,onValueChange:f,className:`flex w-full flex-col border-t border-line pt-2`,"data-sw-sidebar-nav":l,children:[(0,Y.jsxs)(Re,{"aria-label":`Pages and journeys`,className:`mb-2`,children:[(0,Y.jsxs)(qe,{value:`pages`,className:p,"data-sw-sidebar-tab":`pages`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:d})]}),(0,Y.jsxs)(qe,{value:`journeys`,className:p,"data-sw-sidebar-tab":`journeys`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:t.length}),i?(0,Y.jsx)(jj,{className:`ml-0.5`}):null]})]}),(0,Y.jsx)(le,{value:`pages`,tabIndex:-1,children:(0,Y.jsx)(Dj,{bare:!0,groups:e,comments:n,activePage:r,onPage:a})}),(0,Y.jsx)(le,{value:`journeys`,tabIndex:-1,children:(0,Y.jsx)(Ej,{bare:!0,journeys:t,journeyId:i,onJourney:o,canEditJourneys:s,onNewJourney:c})})]})}function Nj({info:e,localSettingsAvailable:t,setShareOpen:n}){let r=[{id:`board`,label:`Board`,icon:vg,href:`./`,active:!0}],i=e?.consoleUrl&&!e?.guest?e.consoleUrl:null;return i?(r.push({id:`workspace`,label:`Workspace`,icon:uh,href:i}),r.push({id:`account`,label:`Account and security`,icon:nv,href:wj(i)})):t&&(r.push({id:`workspace`,label:`Workspace`,icon:uh,href:`/console`}),r.push({id:`account`,label:`Account and security`,icon:nv,href:`/account`})),e?.shareEnabled&&r.push({id:`share`,label:`Share with your team`,icon:A_,onSelect:()=>n(!0)}),r}function Pj({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,expanded:c,onToggle:l,pages:u,openPalette:d=null,quiet:f=!1}){let p=!!e&&!e.guest&&!e.public&&!e.share,m=typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`);(0,J.useEffect)(()=>{p&&fk(window.location.pathname+(m?`?board=`+encodeURIComponent(m):``))},[p,m]);let h=Nj({info:e,localSettingsAvailable:i,setShareOpen:s}),g=d&&!c?[h[0],{id:`search`,label:`Search (${KO})`,icon:S_,onSelect:d,"aria-haspopup":`dialog`,"data-sw-page-jump":`true`,"data-sw-palette-trigger":`true`},...h.slice(1)]:h,_=!!u&&(u.journeys?.length>0||u.canEditJourneys),v=(e,t)=>n=>{e(),t?.(n)},y=!c&&u?[{id:`pages`,label:`Pages`,icon:Wh,flyout:({close:e})=>(0,Y.jsx)(Dj,{groups:u.groups,comments:u.comments,activePage:u.activePage,onPage:v(e,u.onPage)})},..._?[{id:`journeys`,label:`Journeys`,icon:v_,dot:!!u.journeyId,"data-sw-rail-journeys":u.journeyId||`none`,flyout:({close:e})=>(0,Y.jsx)(Ej,{journeys:u.journeys,journeyId:u.journeyId,onJourney:v(e,u.onJourney),canEditJourneys:u.canEditJourneys,onNewJourney:u.onNewJourney?()=>v(e,u.onNewJourney)():null})}]:[]]:[];return(0,Y.jsxs)(Ok,{expanded:c,onToggle:l,home:`./`,homeLabel:`Shapewall`,title:e?.project?.name||e?.title,logo:(0,Y.jsx)(`img`,{src:`./favicon.svg`,alt:``,className:`h-7 w-7`}),items:g,sections:y,flyoutsDisabled:f,profile:c=>(0,Y.jsx)(Jk,{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:[d&&c?(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)($O,{onOpen:d})}):null,u?(0,Y.jsx)(Mj,{...u}):null]})}var Fj=(0,J.lazy)(()=>YE(()=>import(`./QuickConnect-Cta4dT3n.js`).then(e=>e.a).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([8,1,2,5,3]),import.meta.url)),Ij=(0,J.lazy)(()=>YE(()=>import(`./History-C_NAxaRl.js`),__vite__mapDeps([9,1,2]),import.meta.url)),Lj=(0,J.lazy)(()=>YE(()=>import(`./ShareDialog-D0tmOGcQ.js`).then(e=>({default:e.ShareDialog})),__vite__mapDeps([10,1,2]),import.meta.url)),Rj=(0,J.lazy)(()=>YE(()=>import(`./LocalSettings-W5Ze9ks7.js`),__vite__mapDeps([11,1,2,8,5,3]),import.meta.url));function zj({info:e,boardId:t,boards:n,wide:r,shareOpen:i,setShareOpen:s,refetchView:c,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=o(i),j=o(u);return(0,Y.jsxs)(Y.Fragment,{children:[e?.shareEnabled&&A?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Lj,{open:i,onClose:()=>s(!1),boardId:t,onMoved:c})}):null,l&&j?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Fj,{open:u,onClose:()=>d({settings:null}),onSaved:f,touch:!r,buzz:e?.buzzAvailable===!0})}):null,p?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Rj,{open:!0,onClose:()=>d({settings:null}),info:e,boardCount:n.length,onSaved:f,touch:!r,onOpenUpdates:()=>{d({settings:null}),m.current?.open()}})}):null,h?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Ij,{open:!!h,onClose:g,page:h,viewport:_,data:y,comments:b.filter(e=>e.pageId===v&&e.viewport===_),urlFor:(e,n)=>G(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:!r,onImageError:C})}):null,(0,Y.jsx)(N,{open:w,onClose:()=>E?null:T(!1),title:`Capture every page now?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{size:r?`md`:`touch`,onClick:()=>T(!1),disabled:E,children:`Cancel`}),D&&O(D)?(0,Y.jsxs)(a,{size:r?`md`:`touch`,onClick:()=>k(null,[D]),disabled:E,"data-sw-capture-only":D,children:[`Only `,O(D).title]}):null,(0,Y.jsx)(a,{size:r?`md`:`touch`,variant:`default`,onClick:()=>k(),disabled:E,"data-sw-capture-confirm":`true`,children:`Capture all`})]}),children:(0,Y.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 Bj=2;function Vj(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Hj({canvasRef:e,flow:t,targets:n,viewports:r,settledZoom:i,setSettledZoom:a,comparePair:o,captures:s,variantsById:c}){let l=(0,J.useRef)(null),[u,d]=(0,J.useState)(()=>new Set),[f,p]=(0,J.useState)(()=>new Set),m=(0,J.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,J.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,J.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,Bj).map(e=>e.key));l.current&&!f.has(l.current)&&(l.current=null),d(e=>Vj(e,f)?e:f)},[e,t,n,h,i,r]);return(0,J.useEffect)(()=>{g()},[g]),{liveKeys:u,readyKeys:f,setLiveReady:m,liveFileFor:h,recomputeLive:g,openLive:(0,J.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:cO(450)}))},[e,t,n,a])}}function Uj({journey:e,builder:t,goStep:n,step:r,closeJourney:i}){(0,J.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 Wj({commentMode:e,setCommentMode:t,canComment:n,comparePair:r,setDraft:i,keepDraft:a}){(0,J.useEffect)(()=>{if(!e)return;let n=e=>{e.key!==`Escape`||xC(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),(0,J.useEffect)(()=>{if(!n||r)return;let e=e=>{if(e.defaultPrevented&&!tt(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(),a?.()||(i(null),t(e=>!e)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r,a,t,i])}function Gj({journeys:e,journey:t,builder:n,openJourney:r,closeJourney:i}){(0,J.useEffect)(()=>{if(!e.length||n)return;let a=n=>{if(n.defaultPrevented&&!tt(n)||n.altKey||n.ctrlKey||n.metaKey||n.repeat||n.key!==`j`&&n.key!==`J`||xC(n.target)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`))return;n.preventDefault();let a=t?e.findIndex(e=>e.id===t.id):-1,o=e.length+1,s=(a+1+(n.shiftKey?-1:1)+o)%o-1;s<0?i():r(e[s].id)};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[n,i,t,e,r])}function Kj(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&Array.isArray(e.branches)}function qj(e){let t=new Set,n=e=>{for(let r of e||[])if(typeof r==`string`)t.add(r);else if(Kj(r))for(let e of r.branches)n(e.steps)};return n(e),[...t]}function Jj(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(!Kj(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 Yj(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(!Kj(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 Xj(e,t,n){return[...e.forks.slice(0,t).map(e=>e.chosen),n]}function Zj({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,onLeave:b=()=>{}}){let x=(0,J.useCallback)(e=>{e&&b(),r(),n({j:e||null,step:e?1:null,jc:null,jb:null})},[r,b,n]),C=(0,J.useCallback)(()=>n({j:null,step:null,jc:null,jb:null}),[n]),w=(0,J.useCallback)(e=>{s&&(b(),n({step:vv(e,s.length)}))},[b,s,n]),T=(0,J.useCallback)((e,t)=>{o&&(b(),n({jb:Xj(o,e,t).join(`,`)}))},[b,o,n]),E=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!a||!g||l){a||(E.current=null);return}let e=s[c-1],t=`${a.id}:${c}:${e}:${_}:${v}`;if(E.current===t)return;let n=h[e];n&&(E.current=t,y(null),m.fitBounds({x:n.x,y:n.y-48,width:n.w,height:n.h+48},{padding:.18,duration:cO(450)}))},[l,v,m,a,h,_,g,s,y,c]),Uj({journey:a,builder:l,goStep:w,step:c,closeJourney:C});let D=(0,J.useCallback)((e=null)=>{b(),i(!1),r(),u(e?{id:e.id,name:e.name,steps:structuredClone(e.steps),into:null}:{id:null,name:``,steps:[],into:null})},[r,b,u,i]),O=(0,J.useCallback)(e=>{u(t=>{if(!t||qj(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]),k=`/api/boards/${encodeURIComponent(e)}/journeys`;return{openJourney:x,closeJourney:C,goStep:w,chooseJourneyBranch:T,startBuilder:D,addBuilderStep:O,saveBuilder:async()=>{if(l&&!d){f(!0);try{let e={name:l.name,steps:l.steps},n=l.id?await S.patch(`${k}/${encodeURIComponent(l.id)}`,e):await S.post(k,e);await t.refetch(),u(null),E.current=null,x(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 S.delete(`${k}/${encodeURIComponent(a.id)}`),C(),t.refetch()}catch(e){p({tone:`bad`,text:e.message||`The journey was not deleted.`})}finally{f(!1)}}}}}function Qj({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,onAgentsChanged:h=null}){let g=(0,J.useRef)(new Map),_=(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()},v=`/api/boards/${encodeURIComponent(e)}/comments`,y=async(e,t)=>{o(!0);try{let n=await S.post(`${v}/${e.id}/${t}`,{author:a()||void 0});_(n.comment),f&&t===`resolve`&&p===`open`&&d(),t===`resolve`&&m(`resolve`)&&c({at:Date.now(),text:`Resolved comment #${e.id}.`,undo:()=>y(n.comment,`reopen`)})}catch(e){s({tone:`bad`,text:e.message||`That did not save.`})}finally{o(!1)}},b=async(e,t,n={})=>{let{onImageError:r,images:i,drawing:c}=n;o(!0);try{let n=await S.post(`${v}/${e.id}/replies`,{body:t,author:a()||void 0,...i?.length?{images:i}:{},...c?{drawing:c}:{}});return _(n.comment),!0}catch(e){return r&&/image/.test(e.code||``)?r(e.message||`An image was not accepted.`):s({tone:`bad`,text:e.message||`That reply did not save.`}),!1}finally{o(!1)}},x=async(e,t)=>{o(!0);try{let n=await S.patch(`${v}/${e.id}`,{body:t});return _(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That edit did not save.`}),!1}finally{o(!1)}},C=async(e,t,n=null)=>{try{let a=await S.post(`${v}/${e.id}/reactions`,{emoji:t,...n?{replyId:n}:{},...r?.hosted?{}:{author:i||void 0}});_(a.comment,!1,{counts:!1})}catch(e){s({tone:`bad`,text:e.message||`That reaction did not save.`})}},w=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}`})}},T=async e=>{o(!0);try{let t=await S.post(`${v}/${e.id}/github/issue`,{});_(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)}},E=e=>{g.current.delete(e),l(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},D=async e=>{let t=g.current.get(e.id);if(t){window.clearTimeout(t.timer);try{await S.delete(`${v}/${e.id}`),_(e,!0)}catch(e){s({tone:`bad`,text:e.message||`That did not delete.`})}finally{E(e.id)}}},O=(0,J.useRef)(D);return O.current=D,(0,J.useEffect)(()=>{let e=()=>{for(let{comment:e}of[...g.current.values()])O.current(e)};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),e()}},[]),{commentsUrl:v,applyComment:_,setStatus:y,replyTo:b,editComment:x,reactTo:C,copyLink:w,githubIssue:T,removeComment:async e=>{u===e.id&&d(),l(t=>new Set(t).add(e.id));let t=window.setTimeout(()=>O.current(e),6e3);g.current.set(e.id,{comment:e,timer:t}),c({at:Date.now(),text:`Deleted comment #${e.id}.`,undo:()=>{window.clearTimeout(t),E(e.id)}})},sendToAgent:async(e,n=void 0)=>{let{dispatchHash:i}=e,a=!!(e.needsRunApproval&&[`admin`,`owner`].includes(r.role));o(!0);try{a&&await pD();let t=await S.post(`${v}/${e.id}/send-to-agent`,{dispatchHash:i,approve:a,...n===void 0?{}:{agentId:n}});_(t.comment),h?.()}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)}},releaseAgent:async e=>{o(!0);try{let t=await S.post(`${v}/${e.id}/release-agent`,{});_(t.comment),h?.()}catch(e){s({tone:`bad`,text:e.message})}finally{o(!1)}}}}function $j(e){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(()=>new Set),s=te(`/api/boards/${encodeURIComponent(e)}`,{pollMs:r||t?2e3:Ue?0:3e4}),c=te(`/api/boards/${encodeURIComponent(e)}/comments`,{pollMs:Ue?0:t?1e3:2e4}),l=s.data,u=l?.capture;return(0,J.useEffect)(()=>{i(!!u?.running)},[u?.running]),{view:s,commentsQuery:c,data:l,capture:u,comments:(0,J.useMemo)(()=>{let e=Array.isArray(c.data?.comments)?c.data.comments:[];return a.size?e.filter(e=>!a.has(e.id)):e},[c.data,a]),fixRequest:t,setFixRequest:n,setPolling:i,deletingIds:a,setDeletingIds:o}}function eM({params:e,data:t,builder:n}){let r=(0,J.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,J.useMemo)(()=>i?Yj(i.steps,a.split(`,`).filter(Boolean)):null,[i,a]),s=(0,J.useMemo)(()=>i?Jj(i.steps):null,[i]),c=(0,J.useMemo)(()=>o?o.steps.map(e=>e.pageId):null,[o]);return{journeys:r,journey:i,route:o,routeGraph:s,routePages:c,step:vv(e.get(`step`),c?.length||0),journeyComments:!!i&&e.get(`jc`)===`1`}}var tM=1600;function nM(e){if(!e)return null;let t=document.querySelector(`[data-sw-thread-sheet]`)?.closest(`[role="dialog"]`)?.offsetHeight;return t?window.innerHeight-t-e.top:null}function rM({pendingFocus:e,setPendingFocus:t,targets:n,viewports:r,mode:i,flow:a,canvasRef:o,wide:s,setSettledZoom:c,onHidden:l=null,onLanded:u=null}){let d=(0,J.useRef)(l);d.current=l;let f=(0,J.useRef)(u);f.current=u;let p=(0,J.useRef)(0);(0,J.useEffect)(()=>()=>window.cancelAnimationFrame(p.current),[]),(0,J.useEffect)(()=>{if(!e)return;let l=dy(n,e);if(!l){if(!n[e.pageId]||!r[e.viewport]){t(null),d.current?.(e);return}if(i!==`all`&&i!==e.viewport)return;let a=window.setTimeout(()=>{t(null),d.current?.(e)},700);return()=>window.clearTimeout(a)}t(null),c(null),window.cancelAnimationFrame(p.current);let u=!s&&e.id!=null,m=0,h=()=>{let t=o.current?.getBoundingClientRect(),r=s?null:nM(t);if(u&&r===null&&m<5){m+=1,p.current=window.requestAnimationFrame(h);return}let i=oC({point:l,box:t,wide:s,zoom:a.getZoom(),cardTop:n[e.pageId]?.y??null,sheetTop:r});i?a.setViewport(i,{duration:sC(a.getViewport(),i)?0:cO(450)}):a.setCenter(l.x,l.y,{zoom:rC(a.getZoom()),duration:cO(450)}),f.current?.(e)};h()},[o,a,i,n,e,t,c,r,s])}function iM({wide:e,nodesReady:t,initialCamera:n,selectedCommentId:r,canvasRef:i,nodes:a,flow:o,setSettledZoom:s}){let c=(0,J.useRef)(!1);(0,J.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(dO);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 aM({mode:e,pendingFocus:t,shapeKey:n,clearFocus:r,fitBoard:i}){let a=(0,J.useRef)(e);(0,J.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,J.useRef)(n);(0,J.useEffect)(()=>{if(o.current===n||(o.current=n,r(),t))return;let e=window.setTimeout(i,60);return()=>window.clearTimeout(e)},[r,i,t,n])}function oM({nodesReady:e,data:t,commentsLoaded:n,selectedCommentId:r,selectedComment:i,initialCamera:a,focusComment:o,deletingIds:s,setNotice:c,updateParams:l}){let u=(0,J.useRef)(!1);(0,J.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,J.useRef)(null);(0,J.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 sM({selectedComment:e,visibleComments:t,focusComment:n,mode:r,viewports:i,modes:a}){let o=(0,J.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 cM=[`issues`,`pages`,`seo`,`performance`,`history`],lM=e=>cM.includes(e)&&e!==`issues`?e:null;function uM({boardId:e,info:t,params:n,updateParams:r,pages:i}){let a=!!t?.checksAvailable,o=a&&!!n.get(`checks`),s=i?.some(e=>e.id===n.get(`checks`))?n.get(`checks`):null,c=n.get(`cv`)||null,l=cM.includes(n.get(`ct`))?n.get(`ct`):`issues`,u=/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.get(`ce`)||``)?n.get(`ce`):null,d=`/api/boards/${encodeURIComponent(e)}/checks`,f=u?`?env=${encodeURIComponent(u)}`:``,p=te(a?`${d}${f}`:null,{pollMs:Ue?0:3e4}),m=te(a&&o&&!Ue?`${d}/seo${f}`:null),h=a&&!Ue&&!t?.hosted,[g,_]=(0,J.useState)(!1),v=te(h&&o?`${d}/run`:null,{pollMs:g?1500:0}),y=v.data?.run||null,b=y?.state===`running`;(0,J.useEffect)(()=>_(b),[b]);let x=(0,J.useRef)(!1),{refetch:C}=p,{refetch:w}=m;(0,J.useEffect)(()=>{x.current&&!b&&(C(),w()),x.current=b},[b,C,w]);let[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!1),k=(0,J.useCallback)(async({pages:e=null,seo:t=!0}={})=>{O(!0),E(null);try{return await S.post(`${d}/run`,{seo:t,...e?{pages:e}:{},...u?{env:u}:{}}),_(!0),await v.refetch(),!0}catch(e){return E(e.message||`The checks run did not start.`),v.refetch(),!1}finally{O(!1)}},[d,u,v]),[A,j]=(0,J.useState)(!1),ee=(0,J.useCallback)(async()=>{j(!0),E(null);try{await S.delete(`${d}/run`)}catch(e){E(e.message||`The checks run could not be stopped.`)}finally{j(!1),v.refetch()}},[d,v]),M=(0,J.useCallback)((e=null,t=null,n=null)=>r({checks:e||`all`,cv:t,chat:null,...n?{ct:lM(n)}:{}}),[r]),N=(0,J.useCallback)(e=>r({ct:lM(e)}),[r]),P=(0,J.useCallback)(()=>r({checks:null,cv:null,ct:null}),[r]),F=(0,J.useMemo)(()=>{let e=new Map;for(let t of p.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},[p.data]),I=h?{loading:v.loading,canRun:!!v.data?.canRun,reason:v.data?.reason||null,limit:v.data?.limit||100,privatePages:v.data?.privatePages||[],seoDefault:v.data?.seoDefault!==!1,run:y,starting:D,error:T,start:k,stop:ee,stopping:A}:null,L=[`shapewall checks run`,`--board ${e}`,s?`--only ${s}`:null,u?`--env ${u}`:null,l===`seo`?`--seo`:null,`--limit 100`].filter(Boolean).join(` `);return{canChecks:a,checksOpen:o,checksPage:s,checksViewport:c,checksEnvironment:u,checksTab:l,setChecksTab:N,checksQuery:p,seoQuery:m,checksRun:I,checksPanelProps:{tab:l,onTab:N,seo:m.error?null:m.data,run:I,command:L},openChecks:M,closeChecks:P,checksCounts:F}}function dM({boardId:e,info:t,params:n,updateParams:r}){let i=!Ue&&!!t?.agent&&!(t?.remote?.noRemoteChat&&t?.remote?.kind!==`host`),a=n.get(`chat`)||``,o=i?HT(a):null,s=!!(t?.agent?.settingsEditable||t?.agent?.settingsReadonly),c=!Ue&&!Ge&&!t?.consoleUrl&&!t?.workspace&&!t?.hosted&&!t?.guest,l=c&&n.get(`settings`)===`general`,u=s&&n.get(`settings`)===`agent`,d=(0,J.useCallback)(()=>r({settings:`agent`}),[r]);return(0,J.useEffect)(()=>{o&>(e,VT(o))},[e,o]),{chatAvailable:i,chatThread:o,reopenChat:(0,J.useCallback)(()=>r({chat:KT(e),checks:null,cv:null}),[e,r]),settingsAvailable:s,localSettingsAvailable:c,generalSettingsOpen:l,settingsOpen:u,openSettings:d,openChat:(0,J.useCallback)(e=>{r({chat:VT(e),checks:null,cv:null})},[r])}}function fM({boardId:e,params:t,updateParams:n,environmentList:r,setCommentMode:i,pageCount:a=0}){let o=(0,J.useMemo)(()=>Array.isArray(r)?r:[],[r]),s=(0,J.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=te(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,J.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 pM({comments:e,query:t,stateFilter:n,mentionFilter:r,titleOfPage:i,filter:a,journey:o,journeyComments:s}){let c=(0,J.useMemo)(()=>jv(e,{query:t,state:n,mention:r,titleOf:i}),[e,r,t,n,i]),l=(0,J.useMemo)(()=>{let e=s?new Set(o.pages||qj(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,J.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 mM({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,J.useMemo)(()=>new Set(Object.keys(e).filter(e=>!e.startsWith(`variant:`))),[e]),m=(0,J.useMemo)(()=>o?Yj(o.steps).steps.map(e=>e.pageId):null,[o]),h=o?m:l,g=(0,J.useMemo)(()=>r&&!i?gv(n,p):null,[n,p,i,r]),_=(0,J.useMemo)(()=>o||!s?null:{graph:c,path:s.steps.map(e=>e.key)},[o,s,c]),v=(0,J.useMemo)(()=>[...t,..._v({links:n||{},showLinks:r,activePage:a,journeySteps:o?m:null,journeyRoute:_,currentStep:o?0:u,present:p,hideTargets:g}).map(e=>({...e,...e.id.startsWith(`journey:`)?{data:{...e.data,toTitle:f(e.target)}}:{},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,J.useMemo)(()=>{if(o||!d||!l)return null;let e=new Set(l);return new Set((d.pages||qj(d.steps)).filter(t=>!e.has(t)))},[o,d,l]);return{presentPages:p,shownSteps:h,hiddenLinkTargets:g,edges:v,journeyView:(0,J.useMemo)(()=>h?{steps:mv(h),offPath:y,currentStep:o?null:u,currentPage:o?null:h[u-1]}:null,[o,y,h,u])}}var hM=[];function gM(e){let t=(0,J.useRef)(e);t.current=e;let{boardId:r,data:i,viewports:a,journeyView:o,compareView:s,commentMode:c,canComment:l,wide:u,hosted:d,imageVersion:f,pinsByTarget:p,me:m,checksCounts:h,canChecks:g,agentFocus:_,agentWorkingPages:v,setLiveReady:y,focusedKey:b,selectingKey:x,settledZoom:S,selectedComment:C,draftSpot:w,unread:T,liveKeys:E,commentTargetKey:D=null}=e,[O]=(0,J.useState)(()=>$b({focusedKey:b,selectingKey:x,settledZoom:S,selectedComment:C,draftSpot:w,unread:T,liveKeys:E,commentTargetKey:D}));(0,J.useLayoutEffect)(()=>{O.set({focusedKey:b,selectingKey:x,settledZoom:S,selectedComment:C,draftSpot:w,unread:T,liveKeys:E,commentTargetKey:D})},[O,b,x,S,C,w,T,E,D]);let k=(0,J.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&&ey(p,c.getZoom())&&(l(null),c.fitBounds(fO({x:f.x+p.x,y:f.y,width:p.w,height:p.y+p.h},u.current?.getBoundingClientRect(),.08),{padding:.08,duration:cO(450)})),d(`${t}|${n}`)},onPin:t=>{let n=e(),{layout:r,flow:i,canvasRef:a}=n;if(n.keepDraft())return;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:cO(450)}),n.setToast({at:Date.now(),text:`Zoomed in: tap the spot again to pin your comment.`,untilSheet:!0})}else n.setDraft(e=>({...t,body:e?.body||n.checkDraft||``,author:e?.author??n.authorName()})),n.setCheckDraft(``)},onSelectComment:t=>e().selectComment(t),onHoverComment:e=>O.set({hoveredId:e}),onReading:e=>O.set({readingKey:e}),onJourneyStep:t=>e().goStep(t),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()}},[O]);return{board:(0,J.useMemo)(()=>({boardId:r,captures:i?.captures||{},manifest:i?.manifest||null,counts:i?.commentCounts||{},viewports:a,journey:o,compare:s,commentMode:c&&l&&!s,touch:!u,imageUrl:(e,t,n)=>G(r,e,t,n||f),liveUrl:(e,t,i)=>n(r,e,t,i||f),elementsUrl:(e,t,n)=>re(r,e,t,n||f),domFallback:!Ue&&!Ge&&!d,setLiveReady:y,pinsFor:(e,t)=>p.get(`${e}|${t}`)||hM,me:m,checksCount:e=>h.get(e)||0,historyCount:e=>Ov(i?.versions,e),agentWorking:_,agentWorkingPages:v,onFocusFrame:k.onFocusFrame,onPin:k.onPin,onSelectComment:k.onSelectComment,onReading:k.onReading,onJourneyStep:k.onJourneyStep,onHoverComment:u?k.onHoverComment:null,onOpenCluster:k.onOpenCluster,onChecks:g?k.onChecks:null,onHistory:k.onHistory,onShowViewport:k.onShowViewport,onImageError:k.onImageError}),[k,_,v,r,g,l,h,c,s,i?.captures,i?.commentCounts,i?.manifest,i?.versions,d,f,o,m,p,y,a,u]),view:O}}function _M({boardId:e,view:t,setBusy:n,setNotice:r,setPolling:i}){let[a,o]=(0,J.useState)(!1);return{captureConfirm:a,setCaptureConfirm:o,startCapture:async(a=null,s=null)=>{n(!0);try{r({tone:`info`,text:(await S.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 vM({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,media:h={attach:!1,draw:!1,attachNote:null},pageImage:g=()=>null}){let _=Ox({enabled:h.attach}),v=e?`${e.pageId}|${e.viewport}`:null;(0,J.useEffect)(()=>{!v||!h.draw?Vx.end(`composer`):Vx.get()?.owner===`composer`?Vx.moveTo(v,`composer`):Vx.start(v,`composer`)},[v,h.draw]);let{clear:y}=_;(0,J.useEffect)(()=>{e||y()},[e,y]),(0,J.useEffect)(()=>()=>Vx.end(`composer`),[]);let b=async()=>{if(!e||n||_.reading)return;let f=Vx.get(),p=f?.owner===`composer`&&f.key===v?f.shapes:[],m=Dx(_.images);if(e.body.trim()||p.length||m.length){r(!0);try{let n=(e.author||``).trim();M(n);let{comment:r}=await S.post(i,{pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y,body:e.body,author:n,...e.anchor?{anchor:e.anchor}:{},...m.length?{images:m}:{},...p.length?{drawing:Ux(p)}:{}});Vx.end(`composer`),t(null),s(n),a(r),o(r),l({c:u?r.id:null,filter:d===`all`?`all`:null})}catch(e){/image/.test(e.code||``)?_.setError(e.message||`An image was not accepted.`):c({tone:`bad`,text:e.message||`The comment was not saved.`})}finally{r(!1)}}},x=e?e.anchor?e.target||My(jy(e.anchor.selector),e.anchor.text):`a spot on ${f(e.pageId)}`:``;return{draftDescription:e?`${f(e.pageId)} · ${Lv(e.viewport)} · ${e.anchor?x:`${Math.round(e.x)}% across, ${Math.round(e.y)}% down`}`:``,draftTarget:x,composerProps:{draft:e,onChange:e=>t(t=>t&&{...t,...e}),onSubmit:b,onCancel:()=>t(null),busy:n,people:p,hosted:!!m?.hosted,signedInAs:m?.user?.name||null,media:{...h,images:_,owner:`composer`,page:e&&h.draw?g(e.pageId,e.viewport):null,pageTitle:e?f(e.pageId):``}}}}function yM({canComment:e,comparePair:t,commentMode:n,markPicked:r,setDraft:i,keepDraft:a,setCommentMode:o,showLinks:s,toggleLinks:c,canCompare:l,toggleCompare:u,wide:d,fitBoard:f,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:Hg,keys:`C`,run:()=>{r(),a()||(i(null),o(e=>!e))}}:null,{id:`links`,label:s?`Hide links between pages`:`Show links between pages`,icon:ov,run:c},l?{id:`compare`,label:t?`Leave compare mode`:`Compare environments`,icon:Xh,run:u}:null,d?{id:`fit`,label:`Fit the whole board`,icon:Rg,keys:`Shift 1`,run:f}:null,d?{id:`minimap`,label:p?`Hide the minimap`:`Show the minimap`,icon:Ig,run:m}:null,h?{id:`agent`,label:`Chat with your agent`,icon:I,run:g}:null,_?{id:`checks`,label:`Open page checks`,icon:Kh,run:()=>v()}:null].filter(Boolean)}var bM=30,xM=28,SM=240;function CM(e){let t=1/e;return{"--sw-zoom":e.toFixed(4),"--sw-inv":t.toFixed(4),"--sw-title-scale":Math.min(t,96/bM).toFixed(4),"--sw-title-fade":Math.max(0,Math.min(1,(e-.16)*25)).toFixed(3),"--sw-group-scale":Math.min(t,SM/xM).toFixed(4),"--sw-label-scale":Math.min(t,1.6).toFixed(4),"--sw-chip-scale":Math.min(t,1).toFixed(4)}}function wM(){let e=rd();return(0,J.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(CM(n)))r.style.setProperty(e,t)}};return n(e.getState()),e.subscribe(n)},[e]),null}function TM({fitBoard:e,zoomTo:t}){let n=tf();(0,J.useEffect)(()=>{let r=r=>{if(!(r.defaultPrevented||r.altKey||r.ctrlKey||r.metaKey||xC(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:cO(200)});else if(!r.shiftKey&&r.key===`-`)n.zoomOut({duration:cO(200)});else return;r.preventDefault()}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,n,t])}function EM({wide:e,clearFocus:t,setSettledZoom:n,minimapOn:i,liveKeys:a,toggleMinimap:o,hideFit:c,hideMinimap:l=!1,compact:u=!1,hideZoom:d=!1,fitBoard:f}){let p=tf(),m=$(e=>Math.round(e.transform[2]*100)),h=e=>{t(),n(null);let{x:r,y:i,zoom:a}=p.getViewport(),o=document.querySelector(`[data-sw-canvas]`)?.getBoundingClientRect(),s=(o?.width||0)/2,c=(o?.height||0)/2,l=e/a;p.setViewport({x:s-(s-r)*l,y:c-(c-i)*l,zoom:e},{duration:cO(250)})};if(TM({fitBoard:f,zoomTo:h}),!e)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wM,{}),(0,Y.jsx)(pd,{position:`bottom-left`,className:O(`!m-2 !mb-[calc(0.5rem+env(safe-area-inset-bottom,0px))]`,c&&`hidden`),children:(0,Y.jsx)(B,{size:`icon`,variant:`secondary`,className:`bg-surface/95 shadow-pop backdrop-blur`,onClick:f,label:`Fit the whole board`,"data-sw-fit":`true`,children:(0,Y.jsx)(Rg,{size:17,"aria-hidden":`true`})})})]});let g=i&&!a.size&&!l,v=i&&a.size?`Minimap: hidden while a page is live`:i?`Hide the minimap`:`Show the minimap`,b=`h-8 w-8 rounded-md text-muted shadow-none hover:bg-surface-2 hover:text-fg`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wM,{}),(0,Y.jsx)(pd,{position:`bottom-left`,className:O(`!m-3`,d&&`hidden`),children:(0,Y.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":u?`compact`:`true`,children:[(0,Y.jsx)(B,{className:O(b,`react-flow__controls-zoomout`),onClick:()=>p.zoomOut({duration:cO(200)}),label:`Zoom out`,tooltip:(0,Y.jsx)(dx,{label:`Zoom out`,keys:[`-`]}),children:(0,Y.jsx)(Kg,{size:15,"aria-hidden":`true`})}),(0,Y.jsxs)(je,{children:[(0,Y.jsx)(_,{content:`Zoom level`,children:(0,Y.jsxs)(T,{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 ${m}%`,"data-sw-zoom-level":m,children:[m,`%`]})}),(0,Y.jsxs)(r,{side:`top`,align:`start`,className:`min-w-52`,children:[(0,Y.jsxs)(D,{onSelect:()=>p.zoomIn({duration:cO(200)}),children:[`Zoom in `,(0,Y.jsx)(s,{className:`ml-auto`,children:`+`})]}),(0,Y.jsxs)(D,{onSelect:()=>p.zoomOut({duration:cO(200)}),children:[`Zoom out `,(0,Y.jsx)(s,{className:`ml-auto`,children:`-`})]}),(0,Y.jsx)(y,{}),(0,Y.jsx)(D,{onSelect:()=>h(.5),children:`Zoom to 50%`}),(0,Y.jsxs)(D,{onSelect:()=>h(1),children:[`Zoom to 100% `,(0,Y.jsx)(s,{className:`ml-auto`,children:`Shift 0`})]}),(0,Y.jsx)(D,{onSelect:()=>h(2),children:`Zoom to 200%`}),(0,Y.jsx)(y,{}),(0,Y.jsxs)(D,{onSelect:f,children:[`Fit the whole board `,(0,Y.jsx)(s,{className:`ml-auto`,children:`Shift 1`})]}),u?(0,Y.jsx)(D,{onSelect:o,"data-sw-minimap-item":`true`,children:i?`Hide the minimap`:`Show the minimap`}):null]})]}),(0,Y.jsx)(B,{className:O(b,`react-flow__controls-zoomin`),onClick:()=>p.zoomIn({duration:cO(200)}),label:`Zoom in`,tooltip:(0,Y.jsx)(dx,{label:`Zoom in`,keys:[`+`]}),children:(0,Y.jsx)(c_,{size:15,"aria-hidden":`true`})}),u?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),(0,Y.jsx)(B,{className:O(b,`react-flow__controls-fitview`),onClick:f,label:`Fit the whole board`,tooltip:(0,Y.jsx)(dx,{label:`Fit the whole board`,keys:[`Shift`,`1`]}),children:(0,Y.jsx)(Rg,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(B,{className:O(b,i&&`text-accent hover:text-accent`),"aria-pressed":i,onClick:o,label:i?`Hide the minimap`:`Show the minimap`,tooltip:v,"data-sw-minimap-toggle":i?a.size?`auto-hidden`:`on`:`off`,children:(0,Y.jsx)(Ig,{size:14,"aria-hidden":`true`})})]})]})}),g?(0,Y.jsx)(Ym,{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 DM(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 OM(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 kM({card:e,canvas:t,bar:n,avoid:r=null,gap:i=8,zoom:a=1,toggleSize:o=44,pin:s=!1}){let{width:c,height:l}=t,u=r?r.bottom+i:i,d=e=>Math.max(i,Math.min(l-n.height-i,e)),f=(e,t=n)=>!DM({...e,width:t.width,height:t.height},r,i),p=t=>{let r={left:t,top:d(e.top)};if(f(r))return r;let a={left:t,top:u};return a.top+n.height+i<=l?a:null},m=null,h=Math.max(i,Math.min(e.right-n.width,c-n.width-i));if(e.titleTop-n.height-i>=i){let t={left:h,top:e.titleTop-n.height-i};f(t)&&(m=t)}if(!m&&e.right+i+n.width<=c-i&&(m=p(e.right+i)),!m&&e.left-i-n.width>=i&&(m=p(e.left-i-n.width)),s){let t=e.right-e.left,r=t>=n.width?e.right-n.width:e.left+(t-n.width)/2,a=Math.round(Math.max(i,Math.min(c-n.width-i,r))),o=f({left:a,top:i})?i:u,s=Math.max(o,e.titleTop-n.height-i);return s=Math.min(s,e.bottom-n.height-i,l-n.height-i),{place:{left:a,top:Math.round(s)},toggle:{left:a,top:o},fallback:{left:a,top:o}}}let g=e.titleTop>=i&&a>.2?{top:Math.max(i,e.titleTop-7),left:Math.max(i,Math.min(c-52,e.right-44-Math.min(140,(e.right-e.left)*.3)))}:{top:i,left:i};f(g,{width:o,height:o})||(g={...g,top:u});let _={left:i,top:f({left:i,top:i})?i:u};return{place:m,toggle:g,fallback:_}}var AM=[`select`,`capture`,`history`,`checks`,`open`],jM=[`open`,`select`,`done`,`checks`,`history`,`capture`],MM={desktop:{icon:32,gap:4,pad:10,divider:6,count:22,title:160,titleMin:88,titleChip:140,label:{comment:100,open:104,select:103,done:74,checks:84,history:88,capture:90}},touch:{icon:44,gap:4,pad:10,divider:6,count:22,title:0,titleMin:0,titleChip:0,label:{comment:108,open:112,select:118,done:82,checks:98,history:102,capture:106}}};function NM({canvasWidth:e,touch:t=!1,items:n={},margin:r=16}){let i=t?MM.touch:MM.desktop,a=Math.max(0,e-r),o=jM.filter(e=>n.live===e||[`checks`,`history`,`capture`].includes(e)&&n[e]),s=e=>i.label[e]+(n[`${e}Count`]?i.count:0),c=(e,r)=>{let a=o.filter(t=>!e.includes(t)),c=n.link?t||e.length?`menu`:`bar`:null,l=e.length>0||c===`menu`,u=[];n.comment&&u.push(i.label.comment);for(let e of a)u.push(s(e));l&&u.push(i.icon),c===`bar`&&u.push(i.icon),u.push(i.icon),r&&u.push(0);let d=u.reduce((e,t)=>e+t,0)+i.gap*(u.length-1)+i.pad+i.divider;return{title:r,bar:a,menu:o.filter(t=>e.includes(t)),link:c,more:l,fixed:d}};if(t){let e=c(o.filter(e=>e!==`done`),!1);return{step:`compact`,title:!1,chip:!1,bar:e.bar,menu:e.menu,link:e.link,more:e.more,width:Math.min(e.fixed,a),fits:e.fixed<=a}}let l=c([],!t),u=Math.min(l.fixed+i.title,a),d=[];t||d.push(l),d.push(c([],!1));let f=[];for(let e of AM)o.includes(e)&&(f.push(e),d.push(c([...f],!1)));let p=e=>e.fixed+(e.title?i.titleMin:0),m=d.find(e=>p(e)<=(e.title?u:a))||d.at(-1),h=p(m)<=(m.title?u:a),g=m.title&&u-m.fixed>=i.titleChip;return{step:m.title?`full`:m.menu.length?`more-${m.menu.length}`:`title`,title:m.title,chip:g,bar:m.bar,menu:m.menu,link:m.link,more:m.more,width:m.title?u:Math.min(m.fixed,a),fits:h}}var PM=30;function FM({focused:e,target:t,frame:n,title:r,hasLive:i,live:o,ready:s,selecting:c,touch:l,href:u,onOpenLive:d,onToggleSelect:f,onClose:p,onComment:m=null,commenting:h=!1,history:g=0,checks:v=0,onHistory:y=null,onChecks:b=null,onCapture:x=null,captureBusy:S=!1}){let C=$(e=>e.transform),w=$(e=>e.width),T=$(e=>e.height),E=$(e=>e.domNode),[D,k]=(0,J.useState)(null),A=D===e;(0,J.useEffect)(()=>{e||k(null)},[e]);let[j,ee]=(0,J.useState)(null),[M,N]=(0,J.useState)(0);if((0,J.useLayoutEffect)(()=>{let t=e&&E?E.closest(`[data-sw-canvas]`):null,n=t?.querySelector(`[data-sw-canvas-notes]`)||null,r=t?.querySelector(`[data-sw-tool-dock]`)||null,i=()=>{let e=E?.getBoundingClientRect(),t=n?OM(Array.from(n.children).map(e=>e.getBoundingClientRect()),e):null;ee(e=>JSON.stringify(e)===JSON.stringify(t)?e:t);let i=r?OM(Array.from(r.children).filter(e=>!e.hasAttribute(`data-sw-toast`)).map(e=>e.getBoundingClientRect()),e):null;N(i?Math.max(0,Math.round(e.height-i.top)):0)};if(i(),!n&&!r)return;let a=new MutationObserver(i),o=typeof ResizeObserver>`u`?null:new ResizeObserver(i);for(let e of[n,r])e&&(a.observe(e,{childList:!0,subtree:!0,characterData:!0}),o?.observe(e));return()=>{a.disconnect(),o?.disconnect()}},[e,E,w,T]),!e||!t||!n)return null;let[P,F,I]=C,L=(t.x+n.x)*I+P,R=(t.y+n.y)*I+F,z=t.y*I+F-(I>.2?PM:0),te=L+n.w*I,V=R+n.h*I;if(te<0||L>w||V<0||R>T||ey(n,I))return null;let ne=l?54:40,H=NM({canvasWidth:w,touch:l,items:{comment:!!m,live:o?c?`done`:`select`:i?`open`:null,checks:!!b,history:!!y,capture:!!x,link:!!u,checksCount:v>0,historyCount:g>0}}),U=H.width,{place:re,toggle:ie,fallback:ae}=kM({card:{left:L,top:R,right:te,bottom:V,titleTop:z},canvas:{width:w,height:Math.max(ne+16,T-M)},bar:{width:U,height:ne},avoid:j,gap:8,zoom:I,pin:l}),W=l?`touch`:`sm`,G=l?`icon`:`icon-sm`;if(!re&&!A)return(0,Y.jsx)(B,{size:`icon`,variant:`secondary`,style:ie,className:`nodrag nopan absolute z-20 rounded-full bg-surface/95 text-fg shadow-pop`,onClick:t=>{t.stopPropagation(),k(e)},label:`${r} actions`,side:`bottom`,"data-sw-frame-bar-toggle":e,children:(0,Y.jsx)(Ph,{size:18,"aria-hidden":`true`})});let oe=re||ae,ce=re&&re.left<L+n.w*I?{right:w-(oe.left+U),top:oe.top,maxWidth:U}:{left:oe.left,top:oe.top,maxWidth:U},le=v?`${v} need${v===1?`s`:``} attention`:null,ue=`Page history: ${g+1} captures`,de={open:{label:`Open live`,name:`Open live`,icon:Jg,tip:`Open the live page: scroll it, click it`,onSelect:d,data:{"data-sw-open-live":e}},select:{label:`Select text`,name:`Select text`,icon:B_,disabled:!s,pressed:!1,onSelect:f,data:{"data-sw-select-text":e}},done:{label:`Done`,name:`Done`,icon:B_,tip:(0,Y.jsx)(dx,{label:`Done selecting text`,keys:[`Esc`]}),disabled:!s,pressed:!0,onSelect:f,data:{"data-sw-select-text":e}},checks:{label:`Checks`,name:`Page checks`,description:le||void 0,icon:Kh,tip:le?`Page checks: ${le}`:null,count:v||null,warn:!0,onSelect:b,data:{"data-sw-frame-checks":e}},history:{label:`History`,name:ue,icon:f_,tip:ue,count:g?g+1:null,onSelect:y,data:{"data-sw-frame-history":e}},capture:{label:`Capture`,name:`Capture this page`,icon:fh,tip:`Recapture this page at every screen size`,disabled:S,onSelect:x,data:{"data-sw-frame-capture":e}}},fe=e=>{let t=de[e],n=(0,Y.jsxs)(a,{size:W,variant:t.pressed?`soft`:`ghost`,className:O(t.pressed?`shadow-none focus-visible:outline-offset-1`:RM,l&&`text-[13px]`),"aria-label":t.name,"aria-description":t.description,"aria-pressed":t.pressed,disabled:t.disabled,onClick:t.onSelect,...t.data,children:[(0,Y.jsx)(t.icon,{size:LM,"aria-hidden":`true`}),t.label,t.count?(0,Y.jsx)(BM,{tone:t.warn?`warn`:`neutral`,children:t.count}):null]},e);return t.tip&&!l?(0,Y.jsx)(_,{content:t.tip,side:`bottom`,children:n},e):n},pe=H.more?`more`:H.link===`bar`?`link`:`close`,me=e=>O(RM,e===pe&&zM);return(0,Y.jsxs)(`div`,{className:O(`nodrag nopan nowheel absolute z-20 flex w-max flex-nowrap items-center gap-1 overflow-hidden rounded-lg border border-line bg-surface/95 p-1 shadow-pop backdrop-blur`,l&&`rounded-xl`),style:ce,role:`toolbar`,"aria-label":`${r} actions`,"data-sw-frame-bar":e,"data-sw-frame-bar-fit":H.step,onClick:e=>e.stopPropagation(),children:[H.title?(0,Y.jsxs)(`span`,{className:`flex min-w-0 shrink items-center gap-2 pr-1 pl-2`,"data-sw-frame-bar-title":`true`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-semibold text-fg`,title:r,children:r}),(0,Y.jsx)(`span`,{className:O(`shrink-0 rounded bg-surface-2 px-1.5 text-[10.5px] leading-[18px] font-medium text-muted`,!H.chip&&`sr-only`),children:Lv(n.viewport)})]}):null,m?(0,Y.jsx)(HM,{focused:e,size:W,touch:l,active:h,onComment:m},e):null,H.bar.map(fe),H.more?(0,Y.jsx)(IM,{focused:e,title:r,size:G,touch:l,className:me(`more`),actions:H.menu.map(e=>({id:e,...de[e]})),view:C.join(`,`),href:H.link===`menu`?u:null}):null,H.link===`bar`?(0,Y.jsx)(B,{asChild:!0,size:G,className:me(`link`),label:`Open the page in a new tab`,side:`bottom`,"data-sw-frame-bar-link":`true`,children:(0,Y.jsx)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,children:(0,Y.jsx)(Ih,{size:LM,"aria-hidden":`true`})})}):null,(0,Y.jsx)(B,{size:G,className:me(`close`),onClick:re?p:()=>k(null),label:re?`Close`:`Collapse`,side:`bottom`,"data-sw-frame-bar-close":`true`,children:(0,Y.jsx)(se,{size:LM,"aria-hidden":`true`})})]})}function IM({focused:e,title:t,size:n,touch:i,className:o,actions:s,href:c,view:l}){let[u,d]=(0,J.useState)(!1);(0,J.useEffect)(()=>d(!1),[l]);let f=(0,Y.jsx)(T,{asChild:!0,children:(0,Y.jsx)(a,{size:n,variant:`ghost`,className:O(o,`data-[state=open]:bg-surface-2 data-[state=open]:text-fg`),"aria-label":`More actions for ${t}`,"data-sw-frame-more":e,children:(0,Y.jsx)(Ph,{size:LM,"aria-hidden":`true`})})});return(0,Y.jsxs)(je,{open:u,onOpenChange:d,modal:!i,children:[i?f:(0,Y.jsx)(_,{content:`More actions`,side:`bottom`,children:f}),(0,Y.jsxs)(r,{side:`bottom`,align:`end`,className:`min-w-52`,"data-sw-frame-more-menu":e,children:[s.map(e=>(0,Y.jsxs)(D,{disabled:e.disabled,onSelect:e.onSelect,"aria-description":e.description,...e.data,children:[(0,Y.jsx)(e.icon,{size:LM,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count?(0,Y.jsx)(BM,{tone:e.warn?`warn`:`neutral`,children:e.count}):null]},e.id)),c?(0,Y.jsxs)(Y.Fragment,{children:[s.length?(0,Y.jsx)(y,{}):null,(0,Y.jsx)(D,{asChild:!0,"data-sw-frame-bar-link":`true`,children:(0,Y.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,children:[(0,Y.jsx)(Ih,{size:LM,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Open in a new tab`})]})})]}):null]})]})}var LM=16,RM=`text-fg/80 shadow-none hover:text-fg focus-visible:outline-offset-1`,zM=`relative ml-1.5 before:pointer-events-none before:absolute before:top-1/2 before:-left-[5.5px] before:h-5 before:w-px before:-translate-y-1/2 before:bg-line before:content-['']`;function BM({tone:e=`neutral`,children:t}){return(0,Y.jsx)(`span`,{className:O(`tabular -mr-0.5 inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-1 text-[10.5px] leading-none font-semibold`,e===`warn`?`bg-warn/15 text-fg`:`bg-surface-2 text-muted`),"aria-hidden":`true`,children:t})}var VM=2600;function HM({focused:e,size:t,touch:n,active:r,onComment:i}){let[o,s]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(IO())return;LO(),s(!0);let e=window.setTimeout(()=>s(!1),VM);return()=>window.clearTimeout(e)},[]);let c=(0,Y.jsxs)(a,{size:t,variant:r?`default`:`soft`,className:O(`shadow-none focus-visible:outline-offset-1`,n&&`text-[13px]`,o&&!r&&`outline-2 outline-offset-2 outline-accent`),"aria-label":`Comment on this page`,"aria-pressed":r,"aria-keyshortcuts":`C`,onClick:i,"data-sw-frame-comment":e,"data-sw-frame-comment-emphasis":o?`true`:void 0,children:[(0,Y.jsx)(Hg,{size:LM,"aria-hidden":`true`}),` Comment`]});return n?c:(0,Y.jsx)(_,{content:(0,Y.jsx)(dx,{label:`Comment on this page`,keys:[`C`]}),side:`bottom`,children:c})}function UM({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,onComment:g=null,commentTargetKey:_=null}){let v=(0,J.useContext)(Hv);if(!r)return null;let y=r.lastIndexOf(`|`),b=r.slice(0,y),x=r.slice(y+1),S=i.targets[b],C=S?.frames.find(e=>e.viewport===x);if(!C)return null;let w=b.startsWith(`variant:`)?a?.variants?.find(e=>`variant:${e.id}`===b):null,T=w?null:a?.board?.pages.find(e=>e.id===b);return(0,Y.jsx)(FM,{focused:r,target:S,frame:C,title:w?w.title:T?.title||b,hasLive:!!u(b,x),live:o.has(r),ready:s.has(r),selecting:c===r,touch:l,href:T?.url||(w?.source&&/^https?:/.test(w.source)?w.source:null),onOpenLive:()=>d(b,x),onToggleSelect:()=>f(r),onClose:p,onComment:g?e=>g(r,e):null,commenting:_===r,history:T&&a?.versions?.[T.id]?.[x]?.length||0,checks:T&&e&&v?.onChecks?v.checksCount(T.id):0,onChecks:T&&e?()=>e(T.id,x):null,onHistory:T&&n(T.id)?()=>t(T.id,x):null,onCapture:T&&m?()=>m(T.id):null,captureBusy:h})}var WM=(0,J.lazy)(()=>YE(()=>import(`./ShareDialog-D0tmOGcQ.js`).then(e=>({default:e.MigrationBanner})),__vite__mapDeps([10,1,2]),import.meta.url)),GM=()=>{},KM=new Set;function qM(e,t){let n=new Map;for(let r of e||[])n.has(t(r))||n.set(t(r),r);return n}function JM({boardId:e,boards:t,info:n,onPickBoard:r,onInfoChanged:i,onOpenBuzz:a}){let o=ft(`(min-width: 1024px)`),s=ft(`(max-width: 640px)`),c=tf(),l=ue(),u=ZD(),[d,f]=v(),p=(0,J.useRef)(d);p.current=d;let h=(0,J.useCallback)(e=>p.current.get(e),[]),[g,_]=(0,J.useState)(!1),y=!n?.readOnly&&(!Ue||w),b=y&&!Ue&&!n?.hosted,x=y&&n?.allowCapture,C=e=>n?.permissions?.[e]!==!1,{view:T,commentsQuery:E,data:D,capture:k,comments:A,fixRequest:j,setFixRequest:ee,setPolling:M,deletingIds:N,setDeletingIds:F}=$j(e),I=te(n?.localProjectsEnabled?`/api/local-projects`:null,{pollMs:3e4}),L=I.data?.projects||[],R=(0,J.useMemo)(()=>D?.viewports||{},[D?.viewports]),z=Object.keys(R),B=(0,J.useMemo)(()=>{let e=z.map(e=>({id:e,label:Lv(e)}));return e.length>1&&e.push({id:`all`,label:e.length===2?`Both`:`All`}),e},[z.join(`,`)]),ne=(0,J.useCallback)(e=>B.find(t=>t.id===e)?.label||e,[B]),H=s&&z.includes(`phone`)?`phone`:z[0]||`desktop`,U=B.some(e=>e.id===d.get(`vp`))?d.get(`vp`):H,re=Iw.some(e=>e.id===d.get(`filter`))?d.get(`filter`):`open`,ie=Number(d.get(`c`))||null,ae=(d.get(`q`)||``).slice(0,120),W=kv.some(e=>e.id===d.get(`st`))?d.get(`st`):null,oe=/^[a-z][\w.-]{0,39}$/.test(d.get(`m`)||``)?d.get(`m`):null,se=d.get(`panel`)===`off`,{canChecks:ce,checksOpen:le,checksPage:de,checksViewport:fe,checksQuery:pe,openChecks:he,closeChecks:ge,checksCounts:_e,checksPanelProps:ve,checksRun:ye}=uM({boardId:e,info:n,params:d,updateParams:f,pages:D?.board?.pages}),[be,xe]=(0,J.useState)(``),{chatAvailable:Se,chatThread:Ce,settingsAvailable:we,localSettingsAvailable:Te,generalSettingsOpen:Ee,settingsOpen:De,openSettings:Oe,openChat:ke,reopenChat:je}=dM({boardId:e,info:n,params:d,updateParams:f}),K=(0,J.useRef)(null),Me=(0,J.useRef)(pO(d.get(`v`))),Ne=(0,J.useRef)(null),[Pe,Fe]=(0,J.useState)(!1),[Ie,Le]=(0,J.useState)(!1);(0,J.useEffect)(()=>{Pe||Le(!1)},[Pe]);let[Re,Be]=(0,J.useState)(null),[q,He]=(0,J.useState)(null),We=(0,J.useRef)(null);We.current=q;let Ke=(0,J.useRef)(0),qe=(0,J.useCallback)(()=>{let e=Vx.get();return!!We.current&&(!!We.current.body.trim()||Ke.current>0||e?.owner===`composer`&&e.shapes.length>0)},[]),Je=(0,J.useRef)(null),Ye=(0,J.useCallback)(()=>qe()?(Je.current?.()||ZA(),!0):!1,[qe]),[Xe,Ze]=(0,J.useState)(!1);(0,J.useEffect)(()=>{q||Ze(!1)},[q]);let Qe=(0,J.useCallback)(()=>{let e=Vx.get();return!!We.current&&(Ke.current>0||e?.owner===`composer`&&e.shapes.length>0)},[]),[$e,et]=(0,J.useState)(!1),[nt,rt]=(0,J.useState)(!1),it=n?.localUser?.name||``,[at,ot]=(0,J.useState)(()=>m()),st=at||it,ct=(0,J.useCallback)(()=>m()||it,[it]),lt=(0,J.useRef)(null),[ut,dt]=(0,J.useState)(!1),[pt,mt]=(0,J.useState)(null),[ht,gt,_t]=QA(),[vt,yt]=(0,J.useState)(()=>jO()),bt=vt??MO(D?.board?.pages?.length||0),[xt,St]=(0,J.useState)(!1),Ct=PC(e),[wt,Tt]=(0,J.useState)([]),Et=Ct&&[`working`,`waiting`].includes(Ct.state)&&Number(Ct.commentId)||null,Dt=(0,J.useMemo)(()=>Et?new Set([Et]):KM,[Et]),[Ot,kt]=(0,J.useState)(!1),[At,jt]=(0,J.useState)(null),[Mt,Nt]=(0,J.useState)(null),[Pt,Ft]=(0,J.useState)(null),[It,Lt]=(0,J.useState)(null),[Rt,zt]=(0,J.useState)(()=>!PO()),[Bt,Vt]=eO(!!l),[Ht,Ut]=(0,J.useState)(()=>new Set),Wt=(0,J.useCallback)(e=>Ut(t=>t.has(e)?t:new Set(t).add(e)),[]),Gt=(0,J.useCallback)(()=>{zt(!1),zO()},[]),Kt=()=>{Vt(),Gt()},qt=d.get(`hist`),Jt=d.get(`hv`),{journeys:Yt,journey:Xt,route:Zt,routeGraph:Qt,routePages:$t,step:en,journeyComments:tn}=eM({params:d,data:D,builder:Pt}),nn=d.get(`links`)===`1`,[rn,an]=(0,J.useState)(!1);(0,J.useEffect)(()=>{nn||an(!1)},[nn]);let on=Array.isArray(D?.brokenLinks)?D.brokenLinks:[],sn=on.length?`Arrows for the links between pages; ${on.length} ${on.length===1?`link leads`:`links lead`} to an error`:`Arrows for the links between pages`,{environments:cn,comparePair:ln,changedOnly:un,showDiff:dn,compareQuery:fn,compareData:pn,compareView:mn,setCompare:hn,canCompare:gn,toggleCompare:_n,setChangedOnly:vn}=fM({boardId:e,params:d,updateParams:f,environmentList:D?.environments,setCommentMode:Fe,pageCount:D?.board?.pages?.length||0}),yn=(0,J.useMemo)(()=>{let e=D?.board?.pages||[];return!un||!pn?e:e.filter(e=>(wv(pn,e.id)||0)>0)},[un,pn,D?.board?.pages]),bn=(0,J.useMemo)(()=>D?.board&&z.length?oy({pages:yn,groups:D.board.groups,variants:D.variants,viewports:R,mode:U,compare:ln}):{nodes:[],edges:[],targets:{}},[D?.board,D?.variants,yn,R,U,ln]),[xn,Sn,Cn]=pm(bn.nodes);(0,J.useEffect)(()=>{Sn(bn.nodes)},[bn.nodes,Sn]);let wn=gm(),[Tn,En]=kO(wn),[Dn,On]=(0,J.useState)(null),[kn,An]=(0,J.useState)(null),jn=(0,J.useCallback)(()=>{On(null),An(null)},[]),Mn=(0,J.useCallback)(()=>{jn(),En(null),c.fitView({...dO,duration:cO(400)})},[jn,c,En]);aM({mode:U,pendingFocus:At,shapeKey:`${ln?.join(`_`)||``}|${un&&pn?yn.length:`all`}`,clearFocus:jn,fitBoard:Mn});let Nn=(0,J.useMemo)(()=>qM(D?.board?.pages,e=>e.id),[D?.board?.pages]),Pn=(0,J.useMemo)(()=>qM(D?.variants,e=>`variant:${e.id}`),[D?.variants]),Fn=(0,J.useCallback)(e=>String(e).startsWith(`variant:`)?Pn.get(e)?.title||``:Nn.get(e)?.title||``,[Nn,Pn]),{visibleComments:In,pinsByTarget:Ln,counts:Rn}=pM({comments:A,query:ae,stateFilter:W,mentionFilter:oe,titleOfPage:Fn,filter:re,journey:Xt,journeyComments:tn}),zn=(0,J.useMemo)(()=>Ve(A),[A]),Bn=(0,J.useMemo)(()=>({name:n?.user?.name||st||``,handle:n?.user?.handle||null}),[n?.user?.name,n?.user?.handle,st]),Vn=y&&!D?.migratedTo?.readOnly&&C(`comment`),Hn=e=>{let t=!!Bn.handle&&e.authorHandle===Bn.handle;return{reply:y&&!D?.migratedTo?.readOnly&&C(`reply`),resolve:y&&!D?.migratedTo?.readOnly&&C(`resolve`),react:y&&!D?.migratedTo?.readOnly&&C(`react`),edit:y&&!D?.migratedTo?.readOnly&&C(`edit`)&&(!n?.hosted||zE({isAuthor:t})),delete:y&&!D?.migratedTo?.readOnly&&C(`delete`)&&(!n?.hosted||BE({role:n.role,isAuthor:t}))}},{seen:Un,markSeen:Wn,markAllSeen:Gn}=IE(e),Kn=(0,J.useMemo)(()=>new Set(A.filter(e=>FE(e,Un,Bn)).map(e=>e.id)),[A,Bn,Un]),qn=A.find(e=>e.id===ie)||null,Jn=kA(o),Yn=(0,J.useMemo)(()=>{let e=new Set;for(let t of A)t.status!==`resolved`&&(t.agentStatus===`working`||Dt.has(t.id))&&e.add(t.pageId);return e},[Dt,A]),Xn=(0,J.useCallback)(e=>Nn.get(e)||null,[Nn]),Zn=(0,J.useCallback)(e=>{if(e.startsWith(`variant:`)){let t=Pn.get(e);return t?`Variant: ${t.title}`:`Removed variant`}return Xn(e)?.title||e},[Pn,Xn]),Qn=D?.manifest?.capturedAt||`none`,$n=(0,J.useRef)(null),{refetch:er}=T,{refetch:tr}=E,{refetch:nr}=fn,rr=(0,J.useCallback)(()=>{let e=`${Qn}|${D?.environments?.map(e=>e.capturedAt).join(`,`)||``}`;$n.current!==e&&($n.current=e,er(),tr(),nr())},[D?.environments,Qn,tr,nr,er]),ir=(0,J.useRef)(!1),[ar,or]=(0,J.useState)(!1),sr=(0,J.useCallback)(e=>{ir.current=e,or(e)},[]),cr=(0,J.useCallback)(e=>{Ye()||(sr(!1),He(null),f({c:e.id}),o||(et(!1),rt(!0)))},[sr,Ye,f,o]),lr=(0,J.useCallback)(()=>{rt(!1),f({c:null}),ir.current&&!o&&et(!0),sr(!1)},[sr,f,o]),[ur,dr]=(0,J.useState)(!1);(0,J.useEffect)(()=>{q||dr(!1)},[q]);let fr=(0,J.useRef)(null);fr.current=ie;let pr=(0,J.useCallback)(()=>{fr.current&&(sr(!1),rt(!1),f({c:null})),o&&We.current&&(qe()?dr(!0):He(null))},[sr,qe,f,o]),mr=(0,J.useCallback)(()=>{let e=We.current;e&&(dr(!1),U!==`all`&&e.viewport!==U&&R[e.viewport]&&f({vp:e.viewport===H?null:e.viewport}),jt({pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y}))},[H,U,f,R]),hr=(0,J.useCallback)(e=>{if(Ye())return;let t=U!==`all`&&e.viewport!==U&&!!R[e.viewport],n=String(e.pageId).startsWith(`variant:`),r=n?Pn.get(e.pageId):null,i=n?r?.pageId:e.pageId,a=!!YS({hasTarget:!!bn.targets[e.pageId],known:!(!i||!Nn.has(i)||n&&!r),changedOnly:un&&!!pn,pageChanged:(wv(pn,i)||0)>0})?.showAllPages;He(null),jt(e),f({c:e.id,...t?{vp:e.viewport===H?null:e.viewport}:{},...a?{changed:`0`}:{}});let s=[...t?[`viewport`]:[],...a?[`changed`]:[]];Lt(s.length?{id:e.id,at:Date.now(),changes:s,from:U,to:e.viewport,back:{...t?{vp:h(`vp`)}:{},...a?{changed:h(`changed`)}:{}}}:null),o||(et(!1),rt(!0))},[un,pn,H,Ye,bn.targets,U,Nn,h,f,Pn,R,o]);(0,J.useEffect)(()=>{if(!It)return;let e=window.setTimeout(()=>Lt(null),6e3);return()=>window.clearTimeout(e)},[It]);let gr=(0,J.useCallback)(()=>{It&&(f(It.back),Lt(null))},[f,It]),_r=(0,J.useCallback)(e=>{e?.id!=null&>({at:Date.now(),text:`Comment #${e.id} is on a page this view is not showing, so the board stayed put.`})},[gt]),vr=(0,J.useRef)(0),yr=(0,J.useRef)(()=>{}),br=(0,J.useCallback)(e=>yr.current(e),[]);(0,J.useEffect)(()=>()=>window.clearTimeout(vr.current),[]),rM({pendingFocus:At,setPendingFocus:jt,targets:bn.targets,viewports:R,mode:U,flow:c,canvasRef:Ne,wide:o,setSettledZoom:En,onHidden:_r,onLanded:br}),iM({wide:o,nodesReady:wn,initialCamera:Me,selectedCommentId:ie,canvasRef:Ne,nodes:bn.nodes,flow:c,setSettledZoom:En});let xr=(0,J.useRef)(!Me.current&&!ie&&!d.get(`j`)),Sr=(0,J.useRef)(!Me.current&&!!ie),[Cr,wr]=(0,J.useState)(()=>!o||!xr.current);(0,J.useEffect)(()=>{if(!xr.current||!wn||!bn.nodes.length)return;if(xr.current=!1,!o){wr(!0);return}let e=xO(bn.nodes,Ne.current?.getBoundingClientRect());En(null);let t=e?c.setViewport(e):c.fitView(dO);Promise.resolve(t).finally(()=>wr(!0))},[c,bn.nodes,wn,En,o]);let Tr=(0,J.useRef)(!1),Er=()=>{Tr.current=!0},Dr=(0,J.useCallback)(e=>{Tr.current&&(Tr.current=!1,e.preventDefault(),Ne.current?.focus({preventScroll:!0}))},[]),{liveKeys:Or,readyKeys:kr,setLiveReady:Ar,liveFileFor:jr,recomputeLive:Mr,openLive:Nr}=Hj({canvasRef:Ne,flow:c,targets:bn.targets,viewports:R,settledZoom:Tn,setSettledZoom:En,comparePair:ln,captures:D?.captures,variantsById:Pn});(0,J.useEffect)(()=>{kn&&!Or.has(kn)&&An(null)},[Or,kn]),(0,J.useEffect)(()=>{Pe&&An(null)},[Pe]);let{openJourney:Pr,closeJourney:Fr,goStep:Ir,chooseJourneyBranch:Lr,startBuilder:Rr,addBuilderStep:zr,saveBuilder:Br,removeJourney:Vr}=Zj({onLeave:pr,boardId:e,view:T,updateParams:f,clearFocus:jn,setCommentMode:Fe,journey:Xt,route:Zt,routePages:$t,step:en,builder:Pt,setBuilder:Ft,busy:Ot,setBusy:kt,setNotice:mt,flow:c,targets:bn.targets,nodesReady:wn,mode:U,comparePair:ln,setSettledZoom:En}),Hr=Dn&&!Dn.startsWith(`variant:`)?Rv(Dn):null,Ur=Hr?.targetId||null,Wr=Mt||Ur,Gr=d.get(`la`)===`1`,{presentPages:Kr,shownSteps:qr,hiddenLinkTargets:Jr,edges:Yr,journeyView:Xr}=mM({targets:bn.targets,layoutEdges:bn.edges,links:D?.links,showLinks:nn,showAllLinks:Gr,activePage:Wr,builder:Pt,route:Zt,routeGraph:Qt,routePages:$t,step:en,journey:Xt,targetTitle:Zn}),Zr=(0,J.useCallback)((e,t=null)=>{if(!e||String(e).startsWith(`variant:`))return;let n=U===`all`?z[0]:U;f({hist:e,hv:t&&t!==n?t:null})},[U,f,z.join(`,`)]),Qr=qt&&D?.board?.pages.find(e=>e.id===qt)||null,$r=Jt&&R[Jt]?Jt:U===`all`?z[0]:U,ei=(0,J.useCallback)(()=>f({hist:null,hv:null}),[f]);Je.current=()=>ur?(mr(),!0):!1;let ti=t=>{let n=bn.targets[t];if(!n)return;pr(),En(null);let r=n.frames[0],i=n.frames.map(e=>D?.captures?.[t]?.[e.viewport]).filter(e=>e?.thumb||e?.file);mO(c,n,Ne.current?.getBoundingClientRect(),{phoneCompare:!!ln&&!o,shotUrls:i.map(t=>G(e,`captures`,t.thumb||t.file,Qn))}),r&&On(`${t}|${r.viewport}`)},ni=(0,J.useMemo)(()=>{let e=yn;return[...new Set(e.map(e=>e.group))].map(t=>({group:t,pages:e.filter(e=>e.group===t)}))},[yn]),ri=(0,J.useMemo)(()=>q?{pageId:q.pageId,viewport:q.viewport,x:q.x,y:q.y,anchor:q.anchor}:null,[q?.pageId,q?.viewport,q?.x,q?.y,q?.anchor]),ii=(0,J.useCallback)((e,t,n)=>{let r=bn.targets[e],i=r?.frames.find(e=>e.viewport===t);i&&(c.getZoom()>=3.9?cr(n[0].comment):(En(null),c.fitBounds(hO(r,i,n),{padding:.3,duration:cO(450)})))},[c,bn.targets,cr,En]),{board:ai,view:oi}=gM({boardId:e,data:D,viewports:R,journeyView:Xr,compareView:mn,commentMode:Pe,canComment:Vn,wide:o,hosted:n?.hosted,imageVersion:Qn,pinsByTarget:Ln,me:Bn,checksCounts:_e,canChecks:ce,agentFocus:Dt,agentWorkingPages:Yn,setLiveReady:Ar,focusedKey:Dn,selectingKey:kn,settledZoom:Tn,selectedComment:qn,draftSpot:ri,unread:Kn,liveKeys:Or,commentTargetKey:Re?.key||null,selectedCommentId:ie,closeThread:lr,builder:Pt,addBuilderStep:zr,goStep:Ir,layout:bn,flow:c,canvasRef:Ne,setSettledZoom:En,setFocusedKey:On,setToast:gt,setDraft:He,keepDraft:Ye,checkDraft:be,setCheckDraft:xe,authorName:ct,selectComment:cr,openCluster:ii,openChecks:he,openHistory:(...e)=>{pr(),Zr(...e)},updateParams:f,defaultMode:H,onImageError:rr});yr.current=e=>{window.clearTimeout(vr.current),oi.set({landedId:e?.id??null}),e?.id!=null&&(vr.current=window.setTimeout(()=>oi.set({landedId:null}),tM))};let si=!!(n?.hosted&&!Ge&&!n?.guest&&n?.role&&e),ci=te(si?`/api/boards/${encodeURIComponent(e)}/agents`:null,{pollMs:15e3}),li=si&&ci.data||null;(0,J.useEffect)(()=>Ae(li?.agents||[]),[li]);let{commentsUrl:ui,applyComment:di,setStatus:fi,replyTo:pi,editComment:mi,reactTo:hi,copyLink:gi,githubIssue:_i,removeComment:vi,sendToAgent:yi,releaseAgent:bi}=Qj({onAgentsChanged:ci.refetch,boardId:e,commentsQuery:E,view:T,info:n,localName:st,authorName:ct,setBusy:kt,setNotice:mt,setToast:gt,setDeletingIds:F,selectedCommentId:ie,closeThread:lr,wide:o,filter:re,allowed:C}),xi=(0,J.useMemo)(()=>({attach:Vn&&!Ue&&!n?.guest,draw:Vn&&!Ue,attachNote:Vn&&!Ue&&n?.guest?`Guests on a share link cannot attach images. You can still draw on the page.`:null}),[Vn,n?.guest]),Si=(0,J.useCallback)((t,n)=>{let r=D?.captures?.[t]?.[n];if(!r?.file)return null;let i=String(t).startsWith(`variant:`)?Pn.get(t):null,a=Nn.get(i?i.pageId:t),o=ry(R,n,a?.frameHeight);return o?{src:G(e,`captures`,r.file,Qn),native:o}:null},[e,D?.captures,Qn,Nn,Pn,R]),{draftDescription:Ci,draftTarget:wi,composerProps:Ti}=vM({draft:q,setDraft:He,busy:Ot,setBusy:kt,commentsUrl:ui,applyComment:di,markSeen:Wn,setLocalName:ot,setNotice:mt,updateParams:f,wide:o,filter:re,targetTitle:Zn,people:zn,info:n,media:xi,pageImage:Si}),[Ei,Di]=(0,J.useState)(!1);(0,J.useEffect)(()=>{q||Di(!1),Ie&&q&&(Le(!1),o?Vx.get()?.owner===`composer`&&Vx.set({tool:`box`}):Di(!0))},[Ie,q,o]);let{captureConfirm:Oi,setCaptureConfirm:ki,startCapture:Ai}=_M({boardId:e,view:T,setBusy:kt,setNotice:mt,setPolling:M}),ji=(0,J.useCallback)(e=>{f({v:`${Math.round(e.x)},${Math.round(e.y)},${e.zoom.toFixed(3)}`}),En(e.zoom),Mr()},[Mr,En,f]),[Mi,Ni]=(0,J.useState)(!1),Pi=(0,J.useRef)(!1),Fi=CC({canvasRef:Ne,flow:c,minZoom:uO,maxZoom:4,onRest:ji,handRef:Pi}),Ii=(0,J.useCallback)((e,t)=>{Fi.moving()||ji(t)},[ji,Fi]);V(!!Dn,jn),(0,J.useEffect)(()=>{Dn&&Rt&&Gt()},[Gt,Dn,Rt]),V(Pe,()=>Fe(!1)),V(!!Xt,Fr),V(!!Pt,()=>Ft(null)),Wj({commentMode:Pe,setCommentMode:Fe,canComment:Vn,comparePair:ln,setDraft:He,keepDraft:Ye}),Gj({journeys:Yt,journey:Xt,builder:Pt,openJourney:Pr,closeJourney:Fr});let[Li,Ri]=yk(o,!1);(0,J.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(),St(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),Ke.current=Ti.media.images.images.length,(0,J.useEffect)(()=>{!Pe&&!qe()&&He(null)},[Pe,qe]),(0,J.useEffect)(()=>{let e=new URLSearchParams(window.location.search);Number(e.get(`c`))&&e.get(`j`)&&f({j:null,step:null,jc:null,jb:null})},[]),(0,J.useEffect)(()=>{qn&&Wn(qn)},[Wn,qn]),(0,J.useEffect)(()=>{qn&&Wt(`open`),Pe&&(Wt(`comment`),LO()),Ce&&Wt(`agent`)},[Ce,Pe,Wt,qn]),oM({nodesReady:wn,data:D,commentsLoaded:E.data,selectedCommentId:ie,selectedComment:qn,initialCamera:Me,focusComment:hr,deletingIds:N,setNotice:mt,updateParams:f});let{threadList:zi,threadIndex:Bi,stepThread:Vi,neighborNote:Hi}=sM({selectedComment:qn,visibleComments:In,focusComment:hr,mode:U,viewports:R,modes:B});(0,J.useEffect)(()=>{let e=null,t=oi.subscribe(()=>{let{hoveredId:t}=oi.get(),n=t===null?null:Ne.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`)}},[oi]);let Ui=e=>{let t=qn||q;t&&e!==`all`&&t.viewport!==e&&pr(),Lt(null),f({vp:e===H?null:e})},Wi=!!(n?.hosted&&!Ge&&D?.agentDispatch),Gi=Wi&&o&&d.get(`ha`)===`1`&&!le,Ki=Wi&&!o&&d.get(`ha`)===`1`&&!le&&!Ce,qi=()=>f({ha:`1`,checks:null,cv:null}),Ji=async t=>{let n=BT();try{await S.post(`/api/agent/boards/${encodeURIComponent(e)}/threads/${n}/profile`,{profileId:t.id}),ke(n)}catch(e){gt({at:Date.now(),text:e.message||`Could not open a chat with ${t.name}.`})}},X=ci.refetch;(0,J.useEffect)(()=>{if(!si)return;let e=e=>{e.detail?.thread||X()};return window.addEventListener(`shapewall:hosted-agents`,e),()=>window.removeEventListener(`shapewall:hosted-agents`,e)},[si,X]);let Yi=A.filter(e=>e.status===`open`).length,Xi=(0,J.useMemo)(()=>Nk({comments:A,focus:Ct,approvals:wt,titleOf:Fn,agents:n?.hosted&&D?.agentDispatch?li:null,listening:n?.hosted&&D?.agentDispatch&&D?.agentListening||null}),[li,wt,A,D?.agentDispatch,D?.agentListening,Ct,n?.hosted,Fn]),Zi=Wi?{agents:li,listening:D?.agentListening||null,activity:Xi,approvals:wt.length,titleOf:e=>Fn(A.find(t=>t.id===e)?.pageId),manageUrl:[`admin`,`owner`].includes(n?.role)&&n?.workspace?.id&&n?.project?.id?`/w/${n.workspace.id}/agents/${n.project.id}`:null,onOpenComment:e=>{let t=A.find(t=>t.id===e);t&&(o||f({ha:null}),hr(t))},onChat:Se?Ji:null,onBoardChat:Se?()=>ke(`board`):null,admin:[`admin`,`owner`].includes(n?.role)}:null,Qi=Ow({boardId:e,enabled:!(!Se||D?.migratedTo?.readOnly||!n?.agent?.fixWithAgent||!n?.agent?.configured||n?.hosted&&!Ge),onProgress:()=>{E.refetch(),T.refetch()}}),[$i,ea]=(0,J.useState)(null),ta=e=>{let t=A.find(t=>t.id===e);t?hr(t):ke(IT(e))},na={...Qi,agentName:n?.agent?.label||`agent`,boardId:e,onOpenThread:ta,onConfirm:e=>ea(e)},ra={batch:na,comments:In,filter:re,counts:Rn,onFilter:e=>f({filter:e===`open`?null:e}),selectedId:ie,onHover:ai.onHoverComment,onFocus:e=>{sr(!o),hr(e)},unread:Kn,onMarkAllRead:()=>Gn(A),people:zn,narrow:{query:ae,state:W,mention:oe,onQuery:e=>f({q:e||null}),onState:e=>f({st:e}),onMention:e=>f({m:e}),onClear:()=>f({q:null,st:null,m:null})},canAct:Vn,targetTitle:Zn,touch:!o,onResetBrowserComments:w?()=>{ze(e),f({c:null}),E.refetch(),T.refetch()}:null,journeyFilter:Xt?{name:Xt.name,on:tn,onToggle:()=>f({jc:tn?null:`1`})}:null},ia=qn?{comment:qn,page:Xn(qn.pageId),title:Zn(qn.pageId),people:zn,me:Bn,can:Hn(qn),role:n?.guest?`guest`:n?.role||null,hosted:!!n?.hosted,agents:n?.hosted&&D?.agentDispatch?li:null,onSaveName:ot,media:{...xi,boardId:e,pageImage:Si,pageTitle:Zn(qn.pageId),currentVersion:e=>String(e.pageId).startsWith(`variant:`)?null:yv(D?.manifest?.pages?.[e.pageId]?.[e.viewport],D?.manifest)},busy:Ot,touch:!o,editingRef:lt,actions:{onReply:pi,onSendToAgent:n?.hosted&&D?.agentDispatch&&!qn.authorGuest&&!qn.authorAgent?yi:null,onReleaseAgent:n?.hosted&&D?.agentDispatch?bi:null,onStatus:fi,onEdit:mi,onDelete:vi,onReact:hi,onCopyLink:gi,onFixAgent:Se&&!D?.migratedTo?.readOnly&&n?.agent?.fixWithAgent&&n?.agent?.configured?e=>{ee({commentId:e.id,nonce:Date.now()}),o||rt(!1),ke(IT(e.id))}:null,onHostedFix:n?.hosted&&!Ge&&Se&&D?.agentDispatch&&!D?.migratedTo?.readOnly&&!qn.authorGuest&&!qn.authorAgent?(e,t)=>{ee({commentId:e.id,nonce:Date.now(),hosted:{agentId:t,dispatchHash:e.dispatchHash}}),o||rt(!1),ke(IT(e.id))}:null,onAskAgent:Se?e=>{o||rt(!1),ke(IT(e.id))}:null,onGithubIssue:!Ue&&n?.github?.ready?_i:null,onHistory:e=>{o||rt(!1),Zr(e.pageId,e.viewport)}},nav:{index:Bi,total:zi.length,onPrev:()=>Vi(-1),onNext:()=>Vi(1),prevNote:Hi(-1),nextNote:Hi(1)},beforeAfter:D?{pairFor:e=>Sv(e,{manifest:D.manifest,captures:D.captures,versions:D.versions}),nativeFor:e=>{let t=String(e.pageId).startsWith(`variant:`)?Pn.get(e.pageId):null,n=Nn.get(t?t.pageId:e.pageId);return ry(R,e.viewport,n?.frameHeight)||null},urlFor:t=>G(e,t.kind,t.file,t.version),onImageError:rr}:null}:null,aa={boardId:e,batch:na,fixRequest:j,onFixDone:()=>{ee(null),ci.refetch(),T.refetch(),E.refetch()},agent:n?.agent,threadId:Ce||`board`,onThread:ke,comments:A,pages:D?.board?.pages||[],captures:D?.captures||{},imageVersion:Qn,defaultViewport:U===`all`?H:U,focused:Hr?{pageId:Hr.targetId,viewport:Hr.viewport}:null,touch:!o,onOpenSettings:we?Oe:null,settingsLocked:!!(Se&&!we&&n?.agent?.settingsLocked),onAgentChanged:i,people:zn,onRunChecks:ye?async()=>{let e=await ye.start({seo:ye.seoDefault});return he(),e}:null,journeys:Yt,checksCounts:ce?_e:null,onBoardChanged:()=>{T.refetch(),E.refetch()},onNavigate:e=>{if(!o&&e.kind!==`check`&&f({chat:null}),e.kind===`comment`){let t=A.find(t=>t.id===e.id);t&&hr(t)}else e.kind===`page`?ti(e.id):e.kind===`journey`?Pr(e.id):e.kind===`check`&&he(e.id)},onRecapture:x&&!ln?e=>e?Ai(null,Array.isArray(e)?e:[e]):ki(!0):Ge?()=>mt({tone:`info`,text:`The demo does not take new captures. On your own board this recaptures the changed pages.`}):null},oa=Jn?`drawing`:q&&o&&!ur?`composing`:Pe&&Vn&&!ln?`picking`:`off`,sa=Vn&&!ln,ca=(0,J.useMemo)(()=>!ln&&(Object.values(D?.captures||{}).some(e=>Object.values(e||{}).some(e=>e?.live))||(D?.variants||[]).some(e=>Object.values(e.files||{}).some(e=>e?.live))),[ln,D?.captures,D?.variants]),la=PA({wide:o,commenting:sa,draw:xi.draw,liveBoard:ca,livePage:Or.size>0||!!kn}),ua=FA({drawing:Jn,commentMode:Pe&&sa,drawArmed:Ie,selecting:!!kn&&o,hand:Mi&&o});Pi.current=ua===`hand`,(0,J.useEffect)(()=>{(Pe||kn||Jn)&&Ni(!1)},[Pe,kn,Jn]);let da=(e,t)=>{sa&&(Pe&&!Ie&&Re?.key===e?Fe(!1):Ye()||(He(null),Le(!1),Fe(!0),Be({key:e,keyboard:t?.detail===0})))},fa=q?`${q.pageId}|${q.viewport}`:null;(0,J.useEffect)(()=>{Re&&(!Pe||Ie||Dn!==Re.key||fa&&fa!==Re.key)&&Be(null)},[Pe,Re,fa,Ie,Dn]);let pa=Re?.keyboard?Re.key:null;(0,J.useEffect)(()=>{if(!pa)return;let{targetId:e,viewport:t}=Rv(pa),n=Ne.current,r=window.requestAnimationFrame(()=>{n?.querySelector(`[data-sw-frame=${JSON.stringify(`${e}:${t}`)}]`)?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(r),window.requestAnimationFrame(()=>{let e=document.activeElement;(!e||e===document.body||e.matches(`[data-sw-frame], .react-flow__node`))&&n?.querySelector(`[data-sw-frame-comment=${JSON.stringify(pa)}]`)?.focus({preventScroll:!0})})}},[pa]);let ma=e=>{let t=Vx.get();e===`select`||e===`hand`?(t?.tool&&Vx.set({tool:null}),An(null),Fe(!1),Ni(e===`hand`),e===`hand`&&jn()):e===`comment`?t?.tool?(Vx.set({tool:null}),Le(!1),Fe(!0)):Pe&&Ie?Le(!1):Fe(e=>!e):e===`draw`?o&&t?Vx.set({tool:t.tool?null:`box`}):Pe&&Ie?Fe(!1):Ye()||(He(null),Fe(!0),Le(!0)):e===`text`&&(kn?An(null):Dn&&Or.has(Dn)&&kr.has(Dn)?(t?.tool&&Vx.set({tool:null}),Fe(!1),An(Dn)):gt({at:Date.now(),text:`Select text works on a live page: click a page, then Open live (or zoom in until it goes live).`}))};(0,J.useEffect)(()=>{if(!kn&&!Mi||Pe)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||xC(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||(e.preventDefault(),An(null),Ni(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[kn,Mi,Pe]);let ha=(0,J.useRef)(ma);ha.current=ma;let ga=la.join(`,`);(0,J.useEffect)(()=>{let e=e=>{let t=RA(e,{tools:ga.split(`,`),busy:!!document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`),handled:e.defaultPrevented&&!tt(e)});t&&(e.preventDefault(),ha.current(t))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ga]);let _a=Jn?`drawing`:oa===`composing`?`composing`:Pe&&sa?`picking`:kn&&o?`text`:null,va=KA(!o),ya=!o&&(!!q||nt||$e||ut||!!le||!!Ce||Ki),ba=!!D&&la.length>1,xa=ba&&!ya&&!va,Sa=WA(Ne),Ca=GA(Ne,!o),wa=Ca?uC(Ca):null,Ta=Ca?dC(Ca):null,Ea=!!_a&&Sa<JA,Da=o&&bt&&!Or.size&&!Xt&&!Pt&&!Ea,Oa=xa?XA(o?{width:Sa,tools:YA(la.length,!1,IA(la)),left:[qA.zoomFull,qA.zoomCompact,0],right:Da?qA.minimap:0}:{width:Sa,tools:YA(la.length,!0),left:Xt||Pt?[]:[qA.fit],margin:qA.touchMargin}):{shift:0,compact:0,right:!0},ka=()=>f({links:nn?null:`1`}),Aa=()=>{let e=!bt;yt(e),RO(e)},ja=!!Qr||De||Ee||Oi||!o&&le,Ma={data:pe.data,error:pe.error,loading:pe.loading,pages:D?.board?.pages||[],pageId:de,viewport:fe,onSelect:he,onClose:ge,onRefresh:pe.refetch,onEnvironment:e=>f({ce:e}),canComment:Vn,local:!Ue&&!n?.hosted,onView:(e,t)=>{ge(),f({vp:t,page:e}),jt({pageId:e,viewport:t,x:50,y:50})},onDraft:(e,t,n)=>{xe(`${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)),ge(),f({vp:e.viewport}),jt({pageId:e.pageId,viewport:e.viewport,x:50,y:50}),et(!1),Fe(!0),gt({at:Date.now(),text:`Choose a pin on the page, then review and save your comment.`})},...ve},Na=e=>{e.preventDefault(),ge(),o?((se||Ce)&&f({panel:null,chat:null}),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>document.getElementById(`sw-comments`)?.focus()))):et(!0)},Pa=e=>wC(e,e=>{let t=bn.targets[e]?.frames[0];t&&ai.onFocusFrame(e,t.viewport)}),Fa=()=>{ln||pr(),_n()},Ia=yM({canComment:Vn,comparePair:ln,commentMode:Pe,markPicked:Er,setDraft:He,keepDraft:Ye,setCommentMode:Fe,showLinks:nn,toggleLinks:ka,canCompare:gn,toggleCompare:Fa,wide:o,fitBoard:Mn,minimapOn:bt,toggleMinimap:Aa,chatAvailable:Se,reopenChat:je,canChecks:ce,openChecks:he}),La={setMenuOpen:dt,data:D,chatAvailable:Se,chatThread:Ce,reopenChat:je,activity:Xi,openAgentThread:e=>ke(IT(e)),updateParams:f,groupedPages:ni,jumpToPage:ti,modes:B,mode:U,setMode:Ui,journeys:Yt,journey:Xt,canEditJourneys:b,openJourney:Pr,closeJourney:Fr,startBuilder:Rr,openBrokenLinks:()=>an(!0),canChecks:ce,openChecks:he,showLinks:nn,toggleLinks:ka,brokenLinks:on,canCompare:gn,comparePair:ln,toggleCompare:Fa,settingsAvailable:we,openSettings:Oe,capture:k,canCapture:x,busy:Ot,setCaptureConfirm:ki};return(0,Y.jsxs)(YM,{board:ai,view:oi,people:zn,children:[(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,"data-sw-board":e,style:{paddingTop:`env(safe-area-inset-top, 0px)`},children:[(0,Y.jsx)(nD,{}),(0,Y.jsx)(xD,{}),n?.hosted&&D?.agentApprove?(0,Y.jsx)(yD,{boardId:e,onRows:Tt,onOpenThread:Se?ke:null,openThread:Ce||null}):null,(0,Y.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:Na,"data-sw-skip-comments":`true`,children:`Skip to comments`}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[o?(0,Y.jsx)(Pj,{...La,info:n,localName:st,onOpenBuzz:a,demo:l,localSettingsAvailable:Te,setShareOpen:_,expanded:Li,onToggle:Ri,openPalette:()=>St(!0),quiet:Jn,pages:D?{groups:ni,journeys:Yt,comments:A,activePage:Wr,journeyId:Xt?.id||null,onPage:ti,onJourney:Pr,canEditJourneys:b,onNewJourney:()=>Rr()}:null}):null,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(wA,{...La,...o&&Wi?{chatAvailable:!0,chatThread:Ce||(Gi?`hosted`:null),reopenChat:qi,openAgentThread:qi}:{},wide:o,info:n,boardId:e,boards:t,localProjects:L,projectsError:I.error,localName:st,onPickBoard:r,onOpenBuzz:a,demo:l,localSettingsAvailable:Te,setShareOpen:_,viewNotice:It,canComment:Vn,minimapOn:bt,toggleMinimap:Aa,linksTip:sn,panelHidden:se,checksOpen:le,allOpen:Yi,closeChecks:ge,setSheetOpen:et,sidebarTitled:o&&Li}),!n?.hosted&&D?.migratedTo?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(WM,{marker:D.migratedTo,boardId:e,editable:!!n?.shareEnabled,onChange:T.refetch})}):null,(0,Y.jsx)(tj,{notice:pt,setNotice:mt,wide:o}),ln?(0,Y.jsx)(Zw,{environments:cn,pair:ln,loading:fn.loading||!pn,error:fn.error?fn.error.message:null,changedPages:pn?.changedPages??0,totalPages:D?.board?.pages?.length||0,changedOnly:un,showDiff:dn,canComment:Vn,canCapture:x,captureBusy:Ot||!!k?.running,touch:!o,onPair:e=>hn(e),onChangedOnly:vn,onShowDiff:e=>f({diff:e?null:`off`}),onCapture:e=>Ai(e),onClose:()=>hn(null)}):null,(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{ref:Ne,tabIndex:-1,className:O(`relative min-w-0 flex-1 outline-none`,oa===`picking`&&`sw-commenting`,ua===`hand`&&`sw-hand`),onKeyDown:Pa,"data-sw-canvas":`true`,"data-sw-comment-flow":oa,children:[nn&&on.length?(0,Y.jsx)(jk,{items:on,open:rn,onOpenChange:an}):null,o&&D?(0,Y.jsx)(AA,{flow:c,canvasRef:Ne,targets:bn.targets,focusFor:e=>((e===`composer`?q?.y:qn?.y)??50)/100,shotFor:(t,n)=>{let r=D.captures?.[t]?.[n];return r?.file?G(e,`captures`,r.thumb||r.file,Qn):null}}):null,Jn?null:(0,Y.jsx)(DA,{wide:o,commentMode:Pe,canComment:Vn,composing:oa===`composing`,parkedDraft:q&&ur?{title:Zn(q.pageId),onReopen:mr,onDiscard:()=>He(null)}:null,showLinks:nn,activePage:Wr,shownSteps:qr,data:D,presentPages:Kr,hiddenLinkTargets:Jr,showAllLinks:Gr,targetTitle:Zn,updateParams:f,tipOpen:Rt,tryOpen:Bt,journey:Xt,builder:Pt,viewNotice:It,undoViewNotice:gr,noticeInSheet:!o&&nt&&It?.id===ie,covered:ya,dismissTip:Gt,modes:B,comparePair:ln}),!D&&T.error?(0,Y.jsx)(pv,{error:T.error,onRetry:T.refetch}):D?(0,Y.jsxs)(cm,{nodes:xn,edges:Yr,edgeTypes:JS,onNodeMouseEnter:nn?(e,t)=>Nt(t.type===`page`?t.id:null):void 0,onNodeMouseLeave:nn?()=>Nt(null):void 0,onNodesChange:Cn,onNodeClick:GM,nodeTypes:BS,colorMode:u,defaultViewport:Me.current||void 0,fitView:Sr.current,style:Cr?void 0:{opacity:0},edgesFocusable:!1,fitViewOptions:dO,minZoom:uO,maxZoom:4,panOnScroll:!1,zoomOnScroll:!1,panActivationKeyCode:null,zoomActivationKeyCode:null,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,zoomOnDoubleClick:!Pe&&ua!==`hand`,onMoveEnd:Ii,onPaneClick:()=>{jn(),ie&&lr()},proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(wm,{gap:40,size:1}),(0,Y.jsx)(UM,{onChecks:ce?he:null,onHistory:(...e)=>{pr(),Zr(...e)},historyCountFor:e=>Ov(D?.versions,e),focusedKey:Jn?null:Dn,layout:bn,data:D,liveKeys:Or,readyKeys:kr,selectingKey:kn,touch:!o,liveFileFor:jr,onOpenLive:Nr,onToggleSelect:e=>An(t=>t===e?null:e),onClose:jn,onCapture:x&&!ln?e=>Ai(null,[e]):null,captureBusy:Ot||!!k?.running,onComment:sa?da:null,commentTargetKey:Pe&&!Ie&&Re?.key||null}),o&&q&&!ur&&!ja?(0,Y.jsx)(OE,{point:dy(bn.targets,q),resetKey:`${q.pageId}|${q.viewport}|${q.x}|${q.y}`,stowed:Jn,onClose:()=>Ot?null:He(null),onEscape:()=>Xe?(Ze(!1),!1):!Qe()||(Ze(!0),!1),children:(0,Y.jsx)(eT,{...Ti,touch:!1,description:Ci,discard:Xe?{onDiscard:()=>He(null),onKeep:()=>Ze(!1)}:null})}):null,o&&ia&&!q&&!ja?(0,Y.jsx)(DE,{comment:qn,point:dy(bn.targets,qn),onClose:lr,stowed:Jn,onPrev:()=>Vi(-1),onNext:()=>Vi(1),editingRef:lt,children:(0,Y.jsx)(uE,{...ia,onClose:lr})}):null,(0,Y.jsx)(EM,{wide:o,clearFocus:jn,setSettledZoom:En,minimapOn:bt,liveKeys:Or,toggleMinimap:Aa,hideFit:!!(Xt||Pt),hideMinimap:!!(Xt||Pt)||Ea||!Oa.right,compact:Oa.compact===1,hideZoom:o&&Oa.compact===2,fitBoard:Mn})]}):(0,Y.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(me,{}),` Loading board`]}),n?.hosted&&!Ge?(0,Y.jsx)(DD,{touch:!o,enabled:!!D&&!Ue,boardId:e,canvasRef:Ne,flow:c,selection:ie,mode:U,onMode:e=>f({vp:e}),onInvalidate:()=>{E.refetch(),T.refetch(),ci.refetch()}}):null,Bt&&D&&!Xt&&!Pt&&!Jn&&(!Pe||o)&&!Ea?(0,Y.jsx)(tO,{touch:!o,chip:!!_a,done:Ht,onOpenComment:()=>{let e=In.filter(e=>e.status===`open`),t=e.find(e=>U===`all`||e.viewport===U)||e[0]||In[0];t&&hr(t)},onComment:Vn&&!ln?()=>{Ye()||(He(null),Fe(!0))}:null,onAgent:Se?je:null,onUsage:l?.usageHref?()=>P(l.usageHref):null,onClose:Kt}):null,ln&&un&&pn&&!yn.length?(0,Y.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,(0,Y.jsxs)(BA,{touch:!o,children:[(0,Y.jsx)(ej,{toast:ht,setToast:gt,onHold:_t,wide:o}),Pt?(0,Y.jsx)(Ww,{draft:Pt,pages:D?.board?.pages||[],onChange:Ft,onSave:Br,onCancel:()=>Ft(null),pageTitle:e=>Xn(e)?.title||e,busy:Ot,touch:!o}):Xt&&!Jn?(0,Y.jsx)(Uw,{journey:Xt,route:Zt,step:en,pageTitle:e=>Xn(e)?.title||e,onStep:Ir,onChoose:Lr,onClose:Fr,onEdit:()=>Rr(Xt),onDelete:Vr,canEdit:b&&Xt.source===`board`,busy:Ot,touch:!o},Xt.id):null,_a===`drawing`?(0,Y.jsx)(jA,{titleFor:(e,t)=>`${Zn(e)} · ${Lv(t)}`}):_a&&!ya?(0,Y.jsx)(UA,{wide:o,composing:_a===`composing`?{target:wi,onCancel:()=>Ot?null:He(null)}:null,picking:_a===`picking`?{live:Re?kr.has(Re.key):kr.size>0,draw:Ie,page:Re?{key:Re.key,title:Zn(Rv(Re.key).targetId),keyboard:Re.keyboard}:null}:null,selectText:_a===`text`?{title:`${Zn(Rv(kn).targetId)} · ${Lv(Rv(kn).viewport)}`,onDone:()=>An(null)}:null,onDone:()=>Fe(!1)}):null,xa?(0,Y.jsx)(VA,{tools:la,active:ua,onTool:ma,touch:!o,shift:Oa.shift}):ba&&!o?(0,Y.jsx)(`div`,{className:`h-[52px] shrink-0`,"aria-hidden":`true`}):null]})]}),(0,Y.jsx)(pj,{wide:o,checksOpen:le,checksProps:Ma,chatThread:Ce,chatProps:aa,panelHidden:se,panelProps:ra,updateParams:f,hostedAgent:Gi?Zi:null})]})]})]}),(0,Y.jsx)($E,{ref:K})]}),o?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Cj,{hostedAgent:Ki?Zi:null,checksOpen:le,closeChecks:ge,checksProps:Ma,chatAvailable:Se,chatThread:Ce,chatProps:aa,updateParams:f,sheetOpen:$e,setSheetOpen:et,panelProps:ra,viewNotice:It,undoViewNotice:gr,modeLabel:ne,threadSheet:nt,threadProps:ia,closeThread:lr,selectedComment:qn,targetTitle:Zn,draft:q,busy:Ot,setDraft:He,draftDescription:Ci,composerProps:Ti,startDraw:Ei,threadFromList:ar,sheetContentMax:wa,sheetPanelMax:Ta}),(0,Y.jsx)(TA,{...La,chatAvailable:!Wi&&Se,menuOpen:ut,hostedAgents:Wi?{open:qi,list:li}:null})]}),Qi.offered?(0,Y.jsx)(jw,{open:!!$i,onClose:()=>{ea(null),Qi.setError(null)},ids:$i||[],comments:A,max:Qi.max,agentName:na.agentName,targetTitle:Zn,busy:Qi.busy,error:Qi.error,touch:!o,onStart:async e=>{await Qi.start(e)&&ea(null)}}):null,(0,Y.jsx)(zj,{info:n,boardId:e,boards:t,wide:o,shareOpen:g,setShareOpen:_,refetchView:er,settingsAvailable:we,settingsOpen:De,updateParams:f,onInfoChanged:i,generalSettingsOpen:Ee,updates:K,historyPage:Qr,closeHistory:ei,historyViewport:$r,historyPageId:qt,data:D,comments:A,filter:re,focusComment:hr,onImageError:rr,captureConfirm:Oi,setCaptureConfirm:ki,busy:Ot,focusedPage:Ur,findPage:Xn,startCapture:Ai}),(0,Y.jsx)(ek,{open:xt,onOpenChange:St,groups:ni,journeys:Yt,canEditJourneys:b,comments:A,titleOf:Zn,actions:Ia,onPage:e=>{Er(),ti(e)},onJourney:e=>{Er(),Pr(e)},onNewJourney:()=>{Er(),Rr()},onComment:e=>{Er(),hr(e)},onCloseAutoFocus:Dr})]})}function YM({board:e,view:t,people:n,children:r}){return(0,Y.jsx)(Hv.Provider,{value:e,children:(0,Y.jsx)(tx.Provider,{value:t,children:(0,Y.jsx)(Nb.Provider,{value:n,children:r})})})}function XM(){let[e,t]=(0,J.useState)(``),[n,r]=(0,J.useState)(null),[i,o]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await S.get(`/api/pairing`);if(!e)return;r(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 S.post(`/api/pairing`,{name:e});r(e=>({...e,pairing:t}))}catch(e){o(e.message)}},c=n?.pairing,l=c?.code,u=/iPad|iPhone|iPod/.test(navigator.userAgent),d=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone;return(0,Y.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,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:`Shapewall`}),(0,Y.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:`Pair this device`})]}),(0,Y.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.`}),n?.ownMachine?(0,Y.jsx)(`p`,{className:`rounded-lg border border-line p-3 text-sm text-muted`,"data-sw-pairing-own-machine":!0,children:`This is the computer that runs Shapewall. Its tailnet address never lets you in by itself, because any program on this computer could ask the same way. Use the private owner link instead: the terminal that started Shapewall printed it, and it opens the board on this computer’s own address.`}):null,c?.state===`pending`?(0,Y.jsxs)(`section`,{className:`space-y-3 rounded-lg border border-line p-4`,"aria-live":`polite`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`Waiting for approval: `,c.name]}),(0,Y.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,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Expires in five minutes. On the host, open Devices or run `,(0,Y.jsxs)(`code`,{children:[`shapewall devices approve `,l]}),`.`]})]}):(0,Y.jsxs)(`form`,{className:`space-y-3`,onSubmit:s,children:[[`denied`,`expired`].includes(c?.state)?(0,Y.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,Y.jsx)(`label`,{htmlFor:`device-name`,className:`block text-sm text-fg`,children:`Device name`}),(0,Y.jsx)(it,{id:`device-name`,required:!0,maxLength:80,placeholder:`My phone`,value:e,onChange:e=>t(e.target.value)}),(0,Y.jsx)(a,{type:`submit`,children:`Request pairing`})]}),i?(0,Y.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:i}):null,n?.secure?null:(0,Y.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,Y.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 ZM({info:e}){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),c=e?.remote,l=!!c?.manage;(0,J.useEffect)(()=>{if(!l)return;let e=!0,t=async()=>{try{let t=await S.get(`/api/devices`);e&&i(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 S[e](t),l?i(await S.get(`/api/devices`)):window.location.reload()}catch(e){s(e.message)}};if(!c||!l&&!c.device)return null;let d=r?.pending||[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(a,{size:`sm`,variant:`ghost`,onClick:()=>n(!0),"data-sw-devices-open":!0,children:l?`Devices${d.length?` (${d.length} waiting)`:``}`:c.device.name})}),(0,Y.jsx)(N,{open:t,onClose:()=>n(!1),title:l?`Your devices`:`This device`,children:(0,Y.jsxs)(`div`,{className:`max-h-[70dvh] space-y-4 overflow-auto p-5`,"data-sw-devices":!0,children:[o?(0,Y.jsx)(`p`,{role:`alert`,className:`text-sm text-bad`,children:o}):null,l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsxs)(`section`,{className:`space-y-2 rounded border border-line p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-muted`,children:[e.browser,` · `,e.ip]}),(0,Y.jsxs)(`p`,{className:`font-mono text-lg text-fg`,children:[e.code.slice(0,4),`-`,e.code.slice(4)]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(a,{size:`sm`,onClick:()=>u(`post`,`/api/devices/${e.code}/approve`),children:`Approve`}),(0,Y.jsx)(a,{size:`sm`,variant:`secondary`,onClick:()=>u(`post`,`/api/devices/${e.code}/deny`),children:`Deny`})]})]},e.id)),(r?.devices||[]).map(e=>(0,Y.jsxs)(`section`,{className:`flex items-center justify-between gap-2 rounded border border-line p-3`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0 break-words text-sm text-fg`,children:[e.name,(0,Y.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Last seen `,new Date(e.lastSeenAt).toLocaleDateString()]})]}),(0,Y.jsx)(a,{size:`sm`,variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${e.id}`),children:`Revoke`})]},e.id)),!d.length&&!r?.devices?.length?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No paired devices or requests yet.`}):null]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Paired as `,c.device.name,`. Settings and other devices are managed on the host computer.`]}),(0,Y.jsx)(a,{variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${c.device.id}`),children:`Revoke this device`})]})]})})]})}var QM=(0,J.lazy)(()=>YE(()=>import(`./BuzzDialog-DnjF36OB.js`),__vite__mapDeps([12,1,2]),import.meta.url)),$M=!Ge&&typeof document<`u`&&!!document.querySelector(`meta[name="shapewall-remote"]`);function eN(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),s=o(n);(0,J.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`shapewall:pairing-required`,e),()=>window.removeEventListener(`shapewall:pairing-required`,e)},[]);let c=te($M?`/api/pairing`:null),l=!$M||[`host`,`device`,`identity`].includes(c.data?.access),u=te(l?`/api/info`:null);rw(u.refetch,!!u.data?.agent);let d=te(l&&u.data?.agent?.configured?`/api/agent/status`:null);rw(d.refetch,!!u.data?.agent?.configured);let f=u.data?.agent?.configured?[u.data.agent,d.data,...d.data?.profiles||[]]:[],p=JSON.stringify(f.map(e=>[e?.label,e?.icon,e?.tint,e?.logo]));(0,J.useEffect)(()=>i(f),[p]);let m=u.data?.agent?.ownerWrites===!0;(0,J.useEffect)(()=>KC(m),[m]);let h=ue(),g=te(l?`/api/boards`:null),[_,y]=v(),x=Array.isArray(g.data?.boards)?g.data.boards:[],S=_.get(`board`),C=x.find(e=>e.id===S)||x[0];b(u.data?.fixturesAt);let w=Ge?h?.shareProblem:null;tN(w?`Share link`:C?.title);let T=Ge&&_.has(`share`);return(0,J.useEffect)(()=>{T&&y({share:null})},[T,y]),$M&&!c.loading&&!l||e||u.error?.code===`pairing_required`||g.error?.code===`pairing_required`?(0,Y.jsx)(XM,{}):w?(0,Y.jsx)(aD,{problem:w,onLeave:h.leaveShare}):g.loading||u.loading?(0,Y.jsx)(uv,{}):g.error?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(pv,{error:g.error,onRetry:()=>Promise.all([g.refetch(),u.error?u.refetch():null]),extra:Ge?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{asChild:!0,size:`touch`,variant:`secondary`,className:`lg:h-10`,children:(0,Y.jsx)(`a`,{href:`console.html#/signin`,children:`Sign in to the demo`})}),(0,Y.jsx)(a,{size:`touch`,variant:`ghost`,className:`lg:h-10`,onClick:()=>h?.reset(),children:`Reset the demo`})]}):null}),Ge?(0,Y.jsx)(rD,{}):null]}):C?(0,Y.jsxs)(z,{children:[(0,Y.jsx)(ZM,{info:u.data}),u.data?.buzzAvailable===!0&&s?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(QM,{open:n,onClose:()=>r(!1),boardId:C.id},C.id)}):null,(0,Y.jsx)(im,{children:(0,Y.jsx)(JM,{boardId:C.id,boards:x,info:u.data,onInfoChanged:u.refetch,onOpenBuzz:()=>r(!0),onPickBoard:e=>y({board:e,c:null,v:null})})},C.id)]}):(0,Y.jsx)(`div`,{className:`flex h-full bg-sunken`,children:(0,Y.jsx)(j,{size:`lg`,icon:vg,title:`No boards yet`,children:u.data?.hosted?(0,Y.jsxs)(Y.Fragment,{children:[`Capture your site locally, then run `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall push`}),` with a project token.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Add pages to `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall.config.json`}),`, then run`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall capture`}),`.`]})})})}function tN(e){(0,J.useEffect)(()=>{if(!Ge||!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 nN(){typeof navigator<`u`&&`serviceWorker`in navigator&&window.isSecureContext&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`./sw.js`,{scope:`./`}).catch(()=>{})})}var rN=/^(?=[A-Za-z0-9_-]*\d)(?=[A-Za-z0-9_-]*[A-Za-z])[A-Za-z0-9_-]{24,}$/;function iN(e){if(typeof e!=`string`)return;let t=e.replace(/[?#][\s\S]*$/,``).match(/^([a-z][a-z0-9+.-]*:\/\/[^/]*)?([\s\S]*)$/i);return(t[1]||``).replace(/^([a-z][a-z0-9+.-]*:\/\/)[^@/]*@/i,`$1`)+t[2].split(`/`).map(e=>rN.test(e)?`[token]`:e).join(`/`)}var aN=new Set([`navigation`,`fetch`,`xhr`]);function oN(e){if(!e||!aN.has(e.category))return null;let t=e.data||{},n={};return e.category===`navigation`?(t.from!==void 0&&(n.from=iN(String(t.from))),t.to!==void 0&&(n.to=iN(String(t.to)))):(t.url!==void 0&&(n.url=iN(String(t.url))),typeof t.method==`string`&&(n.method=t.method),Number.isInteger(t.status_code)&&(n.status_code=t.status_code)),{type:e.type,category:e.category,level:e.level,timestamp:e.timestamp,data:n}}function sN(e){if(e&&Array.isArray(e.frames))for(let t of e.frames)delete t.vars,typeof t.abs_path==`string`&&(t.abs_path=iN(t.abs_path)),typeof t.filename==`string`&&(t.filename=iN(t.filename))}function cN(e){return e.replace(/["“][\s\S]*["”]|["“][\s\S]*$/,`"[redacted]"`)}function lN(e){if(!e||typeof e!=`object`)return e;if(delete e.user,delete e.extra,delete e.server_name,e.request){let t=Object.entries(e.request.headers||{}).find(([e])=>e.toLowerCase()===`user-agent`)?.[1];e.request={...e.request.method?{method:e.request.method}:{},...e.request.url?{url:iN(e.request.url)}:{},...typeof t==`string`?{headers:{"User-Agent":t}}:{}}}typeof e.transaction==`string`&&(e.transaction=iN(e.transaction)),Array.isArray(e.breadcrumbs)&&(e.breadcrumbs=e.breadcrumbs.map(oN).filter(Boolean));for(let t of e.exception?.values||[])sN(t.stacktrace),typeof t.value==`string`&&(t.value=cN(t.value));typeof e.message==`string`&&(e.message=cN(e.message)),e.logentry&&typeof e.logentry.message==`string`&&(e.logentry={message:cN(e.logentry.message)});for(let t of e.threads?.values||[])sN(t.stacktrace);if(e.contexts){if(e.contexts.device){let{type:t,family:n,model:r,arch:i}=e.contexts.device;e.contexts.device=Object.fromEntries(Object.entries({type:t,family:n,model:r,arch:i}).filter(([,e])=>e!==void 0))}delete e.contexts.app?.app_memory,delete e.contexts.culture,delete e.contexts.cloud_resource}return e}var uN=e=>document.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`)?.trim()||``;function dN(){let e=uN(`shapewall-error-dsn`);if(!e)return;let t=uN(`shapewall-error-environment`)||`production`;YE(()=>import(`./error-reports-sdk-COuSIAQO.js`).then(n=>{n.init({dsn:e,environment:t,release:`d89ef35`,sendDefaultPii:!1,tracesSampleRate:0,maxBreadcrumbs:20,integrations:e=>e.filter(e=>![`BrowserSession`,`Breadcrumbs`].includes(e.name)).concat(n.breadcrumbsIntegration({console:!1,dom:!1,fetch:!0,xhr:!0,history:!0,sentry:!1})),beforeSend:e=>lN(e),beforeBreadcrumb:e=>oN(e)})}),[],import.meta.url).catch(()=>{})}var fN=900;function pN(){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 mN(){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`),fN)))},{capture:!0,passive:!0})}typeof document<`u`&&pN()&&(document.documentElement.classList.add(`sw-scrollbars`),mN()),dN(),document.querySelector(`meta[name="shapewall-agent-settings"]`)?YE(async()=>{let{default:e}=await import(`./Management-CXGSi6gI.js`);return{default:e}},__vite__mapDeps([13,8,1,2,5,3]),import.meta.url).then(({default:e})=>(0,_t.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(e,{}))):((0,_t.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(J.StrictMode,{children:(0,Y.jsx)(eN,{})})),nN());export{Hg as $,jC as A,W_ as B,_w as C,aw as D,hw as E,Dv as F,E_ as G,R_ as H,iv as I,m_ as J,S_ as K,ev as L,bx as M,yx as N,gw as O,xx as P,Wg as Q,Q_ as R,ow as S,fw as T,P_ as U,H_ as V,M_ as W,u_ as X,f_ as Y,o_ as Z,tT as _,vh as _t,pD as a,mg as at,Sw as b,XT as c,eg as ct,$T as d,Hh as dt,Mg as et,BT as f,Ih as ft,yT as g,Sh as gt,_T as h,Eh as ht,YD as i,bg as it,TC as j,rw as k,YT as l,Jh as lt,QT as m,Ah as mt,PD as n,Og as nt,HE as o,cg as ot,zT as p,Ph as pt,v_ as q,FD as r,Eg as rt,UE as s,ig as st,lO as t,Ag as tt,RT as u,Kh as ut,Pw as v,oh as vt,pw as w,mw as x,xw as y,X_ as z};
|
|
30
|
+
`);function NE({title:e,threadId:t,messages:n,comment:r=null,boardTitle:i=null,exportedAt:a=new Date}){let o=[`# ${e||jE(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(`. `)}.`:``}_`,``),Me(r)&&o.push(ME(Me(r)),``);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(`
|
|
31
|
+
`).trimEnd()}\n`}function PE(e){return`${String(e||`chat`).toLowerCase().normalize(`NFKD`).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`chat`}.md`}function FE(e){let t=BC(e.id);return t?.state===`waiting`?`waiting`:t?.state===`working`||[`queued`,`working`].includes(e.agentStatus)?`working`:null}function IE({comment:e,onFix:t,onOpenChat:n=null,busy:r,touch:i,className:o}){let s=FE(e),c=(0,J.useContext)(Jv)?.boardId||null,l=!!t&&e.status===`open`,u=te(l?`/api/agent/status`:null);uw(u.refetch,l);let[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null);if(!l)return null;if(!s&&e.agentStatus===`branch-ready`)return n?(0,Y.jsxs)(a,{size:i?`touch`:`xs`,variant:`default`,className:O(`rounded-full pr-3 pl-2.5`,o),onClick:()=>n(e),"data-sw-fix-agent-open":e.id,"data-sw-fix-agent-state":`branch`,children:[(0,Y.jsx)(Xh,{size:13,"aria-hidden":`true`}),` Review branch`]}):null;if(s)return(0,Y.jsxs)(`span`,{className:O(`inline-flex min-w-0 items-center gap-1.5`,o),"data-sw-fix-agent-state":s,children:[(0,Y.jsxs)(`span`,{className:O(`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,Y.jsx)(R_,{size:13,className:`shrink-0 text-warn`,"aria-hidden":`true`}):(0,Y.jsx)(Ag,{size:13,className:`shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:s===`waiting`?`Agent needs your OK`:`Agent working`})]}),n?(0,Y.jsx)(a,{size:i?`touch`:`xs`,variant:s===`waiting`?`default`:`ghost`,onClick:()=>n(e),"data-sw-fix-agent-open":e.id,children:s===`waiting`?`Review`:`View`}):null]});let{name:h,options:g,defaultId:_}=ce(u.data),v=e.agentStatus===`done`,y=v?`secondary`:`default`,b=i?`touch`:`xs`,x=async n=>{if(m(null),g.length&&c){f(!0);try{let t=fw(c,_E(e.id)),r=await S.get(t),i=ct({threadProfile:r?.profileId,wanted:n,defaultId:_});i&&await S.post(`${t}/profile`,{profileId:i})}catch(e){m(e.message);return}finally{f(!1)}}t(e)},C=g.length>0,w=(0,Y.jsxs)(a,{size:b,variant:y,className:O(C?`rounded-l-full rounded-r-none pr-2.5 pl-2.5`:`rounded-full pr-3 pl-2.5`,!C&&o),disabled:r||d,onClick:()=>x(`default`),"data-sw-fix-agent":e.id,"data-sw-fix-agent-name":h||void 0,children:[d?(0,Y.jsx)(Ag,{size:13,className:`motion-safe:animate-spin`,"aria-hidden":`true`}):(0,Y.jsx)(H_,{size:13,"aria-hidden":`true`}),` `,rt({again:v,name:h})]}),T=p?(0,Y.jsx)(`span`,{className:`min-w-0 text-xs text-bad`,role:`alert`,children:p}):null;return C?(0,Y.jsxs)(`span`,{className:O(`inline-flex min-w-0 flex-wrap items-center justify-end gap-1.5`,o),"data-sw-fix-agent-split":e.id,children:[T,(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0`,children:[w,(0,Y.jsx)(eE,{options:g,value:null,onChoose:e=>x(e===_?`default`:e),heading:`Run this fix once with`,align:`end`,touch:i,children:(0,Y.jsx)(a,{size:i?`icon`:`icon-xs`,variant:y,className:O(`rounded-l-none rounded-r-full`,v?`-ml-px`:`border-l border-accent-fg/30`),disabled:r||d,"aria-label":`Fix with another agent`,"data-sw-fix-agent-choose":e.id,children:(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})})})]})]}):T?(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 flex-wrap items-center justify-end gap-1.5`,children:[T,w]}):w}function LE({comment:e,list:t=null,busy:n=!1,touch:r=!1,slot:i=`action`,onFix:o,onOpenChat:s=null}){let c=FE(e),l=BC(e.id);if(!t||e.status!==`open`)return null;let u=r?`touch`:`sm`;if(c||e.agentStatus===`branch-ready`){if(!s||i!==`status`)return null;let n=(t.agents||[]).find(t=>(t.working||[]).includes(e.id))||null;return c&&!l&&!n?.link?.connected?null:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 pb-2`,"data-sw-hosted-fix-block":e.id,children:[c===`waiting`?(0,Y.jsxs)(`span`,{className:`inline-flex min-h-7 min-w-0 items-center gap-1.5 rounded-full bg-warn/15 px-2.5 text-xs font-medium text-fg`,role:`status`,"data-sw-hosted-fix-state":`waiting`,children:[(0,Y.jsx)(R_,{size:13,className:`shrink-0 text-warn`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[n?.name||`The agent`,` asks before it acts`]})]}):null,(0,Y.jsxs)(a,{size:u,variant:c===`working`?`secondary`:`default`,onClick:()=>s(e),"data-sw-hosted-fix-open":e.id,"data-sw-hosted-fix-view":c||`branch`,children:[c?(0,Y.jsx)(I,{size:13,"aria-hidden":`true`}):(0,Y.jsx)(Xh,{size:13,"aria-hidden":`true`}),` `,c===`waiting`?`Review the request`:c?`Watch it work`:`View the fix`]})]})}let{agent:d,options:f,reason:p}=pE(t,e);if(!d)return!p||i!==`status`?null:(0,Y.jsx)(`p`,{className:`pb-2 text-xs text-muted`,role:`note`,"data-sw-hosted-fix-reason":e.id,children:p});if(i!==`action`)return null;let m=e.agentStatus===`done`,h=m?`secondary`:`default`,g=f.length>0;return(0,Y.jsxs)(`div`,{className:`space-y-1 pt-2`,"data-sw-hosted-fix-block":e.id,children:[(0,Y.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0`,"data-sw-hosted-fix-split":g?e.id:void 0,children:[(0,Y.jsxs)(a,{size:u,variant:h,className:O(`min-w-0`,g&&`rounded-r-none pr-2.5`),disabled:n,onClick:()=>o(e,d.id),"data-sw-hosted-fix":e.id,"data-sw-hosted-fix-agent":d.name,children:[(0,Y.jsx)(H_,{size:13,className:`shrink-0`,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`truncate`,children:m?`Fix again with `+d.name:rt({again:!1,name:d.name})})]}),g?(0,Y.jsx)(eE,{options:f,value:null,onChoose:t=>o(e,t),heading:`Fix this comment with`,align:`end`,touch:r,"data-sw-hosted-fix-menu":e.id,children:(0,Y.jsx)(a,{size:u,variant:h,className:O(`rounded-l-none px-2`,m?`-ml-px`:`border-l border-accent-fg/30`),disabled:n,"aria-label":`Fix with another agent`,"data-sw-hosted-fix-choose":e.id,children:(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`})})}):null]}),d.edits?.text?(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-hosted-fix-mode":d.edits.mode,children:[d.edits.text,`. The fix shows in the Agent panel.`]}):null]})}var RE=(e,t)=>t?`${e}, ${t}`:e;function zE(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 BE({at:e,editedAt:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-baseline gap-1 text-xs text-faint`,children:[(0,Y.jsx)(_,{content:zb(e),children:(0,Y.jsx)(`time`,{dateTime:e,children:A(e)})}),t?(0,Y.jsx)(_,{content:`Edited ${zb(t)}`,children:(0,Y.jsx)(`span`,{"data-sw-edited":`true`,children:`(edited)`})}):null]})}function VE({author:e,at:t,editedAt:n,children:r,reactions:i,canReact:a,me:o,onReact:s,touch:c,...l}){return(0,Y.jsxs)(`li`,{className:`group/message flex gap-2.5 py-2`,...l,children:[(0,Y.jsx)(Mb,{...e,size:c?`lg`:`md`,className:`mt-0.5`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-ui`,children:[(0,Y.jsx)(Ab,{...e}),(0,Y.jsx)(BE,{at:t,editedAt:n})]}),r,(0,Y.jsx)(ZT,{reactions:i,canReact:a,me:o,onToggle:s,touch:c})]})]})}function HE({comment:e,busy:t,onSave:n,onCancel:r,touch:i,people:o}){let[s,c]=(0,J.useState)(e.body),l=(0,J.useRef)(null),u=PT({value:s,setValue:c,inputRef:l,max:aT}),d=et(e),f=async t=>{t?.preventDefault(),u.cancel();let i=s.trim();if(!i&&!d||i===e.body)return r();await n(e,i)&&r()};return(0,Y.jsxs)(`form`,{className:`mt-1 space-y-1.5`,onSubmit:f,"data-sw-edit-form":e.id,children:[(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Edit comment `,e.id]}),(0,Y.jsx)(Ub,{rows:3,size:i?`touch`:`sm`,value:s,maxLength:aT,onChange:e=>{u.onInput(e),c(e)},people:o,onKeyDown:e=>{oT(e,i)&&(e.preventDefault(),f())},inputRef:l,...u.fieldProps,"aria-describedby":u.describedBy,autoFocus:!0})]}),(0,Y.jsx)(ST,{dictation:u,touch:i,id:u.noteId}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Y.jsx)(`div`,{className:`mr-auto flex items-center`,children:(0,Y.jsx)(xT,{dictation:u,touch:i,disabled:t})}),(0,Y.jsx)(a,{size:i?`touch`:`xs`,variant:`ghost`,onClick:r,disabled:t,"data-sw-edit-cancel":e.id,children:`Cancel`}),(0,Y.jsx)(a,{size:i?`touch`:`xs`,variant:`default`,type:`submit`,disabled:t||!s.trim()&&!d,"data-sw-edit-save":e.id,children:`Save`})]})]})}function UE({comment:e,busy:t,onReply:n,touch:r,people:i,autoFocus:o,askName:s=!1,onSaveName:c=null,media:l=null}){let u=KT(l?.boardId,e.id),[d,f]=(0,J.useState)(()=>JT.get(u).body),p=e=>{f(e),JT.save(u,{body:e})},[h,g]=(0,J.useState)(()=>s&&!m()),[_,v]=(0,J.useState)(``),y=(0,J.useId)(),[b,x]=(0,J.useState)(!1),S=!!l?.attach,C=!!l?.draw,w=Fx({enabled:S,initial:JT.get(u).images}),T=w.images;(0,J.useEffect)(()=>{JT.save(u,{images:T.filter(e=>e.state===`ready`)})},[u,T]);let E=`reply-${e.id}`,D=`${e.pageId}|${e.viewport}`,O=Yx(e=>e?.owner===E?e.shapes.length:0);(0,J.useEffect)(()=>{if(!C)return;let e=()=>{let e=Jx.get();e?.owner===E&&e.key===D&&JT.save(u,{shapes:e.shapes,drawKey:D})},t=JT.get(u);Jx.start(D,E,t.drawKey===D?t.shapes:[]),e();let n=Jx.subscribe(e);return()=>{n(),Jx.end(E)}},[C,D,E,u]);let k=C&&r?l.pageImage?.(e.pageId,e.viewport):null,A=(0,J.useRef)(null),j=PT({value:d,setValue:p,inputRef:A,max:aT}),ee=(0,Y.jsx)(xT,{dictation:j,touch:r,disabled:t}),N=async r=>{r?.preventDefault(),j.cancel();let i=d.trim(),a=Jx.get(),o=a?.owner===E?a.shapes:[],s=Px(w.images);if(!i&&!o.length&&!s.length||t||w.reading)return;let l=h?_.trim():``;l&&(M(l),c?.(l)),await n(e,i,{...s.length?{images:s}:{},...o.length?{drawing:Xx(o)}:{},onImageError:w.setError})&&(f(``),w.clear(),Jx.set({shapes:[],tool:null}),JT.clear(u),l&&g(!1))},P=Math.min(6,Math.max(1,d.split(`
|
|
32
|
+
`).length)),F=`sw-reply-image-error-${e.id}`,I=[w.error?F:null,j.describedBy].filter(Boolean);return(0,Y.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2 border-t border-line px-3 py-2`,onSubmit:N,...vS(w,S),"data-sw-reply-form":e.id,children:[h?(0,Y.jsxs)(`div`,{className:`flex w-full items-center gap-2 text-xs text-muted`,children:[(0,Y.jsx)(`label`,{className:`shrink-0`,htmlFor:y,children:`Your name`}),(0,Y.jsx)(it,{id:y,size:r?`touch`:`xs`,value:_,onChange:e=>v(e.target.value.slice(0,60)),placeholder:`shown on your reply`,className:`flex-1`,"data-sw-reply-author":e.id})]}):null,(0,Y.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Reply to comment `,e.id]}),(0,Y.jsx)(Ub,{rows:P,size:r?`touch`:`sm`,value:d,maxLength:aT,onChange:e=>{j.onInput(e),p(e)},people:i,className:`resize-none`,placeholder:r?`Reply`:`Reply, @ to mention`,onKeyDown:e=>{oT(e,r)&&(e.preventDefault(),N())},inputRef:A,...j.fieldProps,autoFocus:o,"aria-describedby":I.length?I.join(` `):void 0,"data-sw-reply-input":e.id})]}),(0,Y.jsx)(B,{type:`submit`,variant:`default`,size:r?`icon`:`icon-sm`,className:`rounded-full`,disabled:t||w.reading||!d.trim()&&!O&&!w.images.length,label:t&&w.images.length?`Uploading the reply`:`Send reply`,"data-sw-reply-send":e.id,children:(0,Y.jsx)(oh,{size:16,"aria-hidden":`true`})}),(0,Y.jsx)(ST,{dictation:j,touch:r,id:j.noteId,className:`w-full`}),S?(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(yS,{draft:w,touch:r,id:F})}):null,S||C||l?.attachNote||j.supported?(0,Y.jsxs)(`div`,{className:`-mt-1 -ml-1 flex w-full flex-wrap items-center gap-0.5`,"data-sw-reply-media":e.id,children:[C&&!r?(0,Y.jsx)(pS,{owner:E,touch:!1,compact:!0,className:`flex-1`,leading:S||j.supported?(0,Y.jsxs)(Y.Fragment,{children:[S?(0,Y.jsx)(_S,{draft:w,touch:!1,disabled:t}):null,ee]}):null}):(0,Y.jsxs)(Y.Fragment,{children:[S?(0,Y.jsx)(_S,{draft:w,touch:r,disabled:t}):null,ee]}),C&&r&&k?(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,onClick:()=>x(!0),"data-sw-draw-open":`true`,children:[(0,Y.jsx)(ch,{size:16,"aria-hidden":`true`}),` `,O?`Drawing (${O})`:`Draw on the page`]}):null,l?.attachNote?(0,Y.jsx)(`p`,{className:`w-full px-1 text-caption text-faint`,"data-sw-attach-note":`true`,children:l.attachNote}):null]}):null,C&&r&&k?(0,Y.jsx)(gS,{open:b,onClose:()=>x(!1),owner:E,src:k.src,native:k.native,title:l.pageTitle}):null]})}function WE({item:e,currentVersion:t,onShow:n}){if(!e?.drawing?.shapes?.length)return null;let r=!!(e.drawing.captureVersion&&t&&e.drawing.captureVersion!==t),i=e.drawing.shapes.length;return(0,Y.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted`,"data-sw-message-drawing":r?`previous`:`current`,children:[(0,Y.jsx)(ch,{size:11,className:`mr-1 inline-block align-[-1px]`,"aria-hidden":`true`}),r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[`Drawn on the previous capture (`,i===1?`one shape`:`${i} shapes`,`).`]}),` `,n?(0,Y.jsx)(`button`,{type:`button`,className:`rounded text-accent underline-offset-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-accent`,onClick:n,"data-sw-show-drawing":`true`,children:`View it on Before`}):null]}):(0,Y.jsxs)(`span`,{children:[`Drawn on the page (`,i===1?`one shape`:`${i} shapes`,`), shown over the frame.`]})]})}function GE({comment:e,page:t,title:n,people:i,touch:o,me:s,can:c,busy:l,actions:u,nav:d,beforeAfter:f,onClose:p=null,editingRef:m=null,denial:h=null,role:g=null,hosted:v=null,agents:b=null,onSaveName:x=null,media:S=null,notice:C=null}){let[w,E]=(0,J.useState)(!1),[k,A]=(0,J.useState)(!1),j=(0,J.useRef)(null);(0,J.useEffect)(()=>{E(!1),A(!1)},[e.id]),m&&(m.current=w?()=>E(!1):null);let ee=e.replies?.length||0;(0,J.useEffect)(()=>{let e=j.current;e&&(e.scrollTop=e.scrollHeight)},[e.id,ee]);let M=e.status===`resolved`,N=M&&e.agentStatus!==`done`?null:e.agentStatus,P=o?`icon`:`icon-sm`,F=Bv(e.viewport,null),L=!!u.onFixAgent&&e.status===`open`,R=e.reopenCount>0&&!M||!!N,z=e.github?.issue?Sb(e.github.issue.url):null,te=S?.currentVersion?.(e)||null,V=()=>{let e=j.current?.querySelector(`[data-sw-before-after]`);e?.scrollIntoView?.({block:`nearest`}),e?.querySelector(`[data-sw-compare-handle], [role="tab"]`)?.focus?.()},ne=[u.onCopyLink?{id:`link`,label:`Copy link`,icon:Eg,run:()=>u.onCopyLink(e),hook:`data-sw-copy-link`}:null,c.edit?{id:`edit`,label:`Edit`,icon:u_,run:()=>E(!0),hook:`data-sw-edit`}:null,u.onAskAgent?{id:`agent`,label:`Ask agent`,icon:I,run:()=>u.onAskAgent(e),hook:`data-sw-ask-agent`}:null,z?{id:`issue`,label:`Open issue #${e.github.issue.number} on GitHub`,icon:vh,href:z,hook:`data-sw-github-open`}:u.onGithubIssue&&c.resolve?{id:`issue`,label:`Create a GitHub issue`,icon:vh,run:()=>u.onGithubIssue(e),hook:`data-sw-github-issue`}:null,u.onHistory&&t?{id:`history`,label:`Page history`,icon:g_,run:()=>u.onHistory(e),hook:`data-sw-comment-history`}:null,t?.url?{id:`page`,label:`Open the page`,icon:Rh,href:t.url,hook:`data-sw-open-page`}:null].filter(Boolean);return(0,Y.jsxs)(`div`,{className:`flex max-h-[inherit] min-h-0 flex-col`,"data-sw-selected-comment":e.id,"data-sw-thread":e.id,children:[(0,Y.jsxs)(`div`,{className:O(`flex shrink-0 items-center gap-0.5 border-b border-line`,o?`px-2 py-1`:`cursor-grab touch-none py-1 pr-1 pl-3 select-none`),"data-sw-card-drag-handle":o?void 0:`true`,children:[(0,Y.jsx)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-xs text-muted`,"data-sw-thread-title":`true`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg tabular`,children:[`#`,e.id]}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:n}),F?(0,Y.jsx)(_,{content:`${e.viewport[0].toUpperCase()}${e.viewport.slice(1)} capture`,children:(0,Y.jsx)(`span`,{className:`inline-flex shrink-0 text-faint`,"aria-label":`${e.viewport} capture`,role:`img`,children:(0,Y.jsx)(F,{size:12,"aria-hidden":`true`})})}):(0,Y.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`· `,e.viewport]})]}):null}),d?.total>1?(0,Y.jsxs)(`div`,{className:O(`flex shrink-0 items-center gap-0.5`,p?null:`order-first`),"data-sw-thread-steps":`true`,children:[(0,Y.jsx)(B,{size:P,onClick:d.onPrev,label:RE(`Previous thread`,d.prevNote),tooltip:RE(`Previous thread (Left arrow)`,d.prevNote),"data-sw-thread-prev":`true`,"data-sw-thread-note":d.prevNote||void 0,children:(0,Y.jsx)(ut,{size:16,"aria-hidden":`true`})}),p?null:(0,Y.jsxs)(`span`,{className:`tabular px-0.5 text-xs whitespace-nowrap text-muted`,"data-sw-thread-step-of":`true`,children:[d.index+1,` of `,d.total]}),(0,Y.jsx)(B,{size:P,onClick:d.onNext,label:RE(`Next thread`,d.nextNote),tooltip:RE(`Next thread (Right arrow)`,d.nextNote),"data-sw-thread-next":`true`,"data-sw-thread-note":d.nextNote||void 0,children:(0,Y.jsx)(nt,{size:16,"aria-hidden":`true`})})]}):null,c.resolve?(0,Y.jsx)(B,{size:P,variant:M?`default`:`ghost`,className:O(`rounded-full`,M&&`bg-ok text-ok-fg hover:bg-ok/90`),disabled:l,"aria-pressed":M,onClick:()=>u.onStatus(e,M?`reopen`:`resolve`),label:M?`Reopen the thread`:`Resolve the thread`,tooltip:M?`Resolved: reopen`:`Resolve`,...M?{"data-sw-reopen":e.id}:{"data-sw-resolve":e.id},children:(0,Y.jsx)(st,{size:16,strokeWidth:2.5,"aria-hidden":`true`})}):M?(0,Y.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,Y.jsx)(st,{size:12,"aria-hidden":`true`}),` Resolved`]}):null,ne.length||c.delete?(0,Y.jsxs)(je,{children:[(0,Y.jsx)(_,{content:`More`,children:(0,Y.jsx)(T,{asChild:!0,children:(0,Y.jsx)(a,{variant:`ghost`,size:P,"aria-label":`More for comment ${e.id}`,"data-sw-thread-menu":e.id,children:(0,Y.jsx)(Ih,{size:16,"aria-hidden":`true`})})})}),(0,Y.jsxs)(r,{align:`end`,children:[ne.map(t=>t.href?(0,Y.jsx)(D,{asChild:!0,[t.hook]:e.id,children:(0,Y.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]})},t.id):(0,Y.jsxs)(D,{onSelect:t.run,[t.hook]:e.id,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]},t.id)),c.delete?(0,Y.jsxs)(Y.Fragment,{children:[ne.length?(0,Y.jsx)(y,{}):null,(0,Y.jsxs)(D,{tone:`danger`,onSelect:()=>A(!0),"data-sw-delete":e.id,children:[(0,Y.jsx)(ev,{size:14,"aria-hidden":`true`}),` Delete thread`]})]}):null]})]}):null,p?(0,Y.jsx)(B,{size:P,onClick:p,label:`Close the thread`,tooltip:`Close (Esc)`,"data-sw-thread-close":`true`,children:(0,Y.jsx)(se,{size:16,"aria-hidden":`true`})}):null]}),C?(0,Y.jsx)(`div`,{className:`shrink-0`,children:C}):null,L||R?(0,Y.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,Y.jsx)(Ob,{comment:e}),L&&[`queued`,`working`].includes(N)?null:(0,Y.jsx)(Db,{status:N,at:e.agentStatusAt,branch:e.agentBranch||null}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`}),L?(0,Y.jsx)(IE,{comment:e,onFix:u.onFixAgent,onOpenChat:u.onAskAgent,busy:l,touch:o}):null]}):null,(0,Y.jsxs)(`div`,{ref:j,className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[e.orphanReason?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:e.orphanReason}):null,e.imported&&e.agentStatus?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:`Imported agent status (history)`}):null,u.onHostedFix?(0,Y.jsx)(LE,{comment:e,list:b,busy:l,touch:o,onFix:u.onHostedFix,onOpenChat:u.onAskAgent||null}):null,u.onSendToAgent&&e.status===`open`?(0,Y.jsx)(gE,{comment:e,list:b,role:g,busy:l,touch:o,onSend:u.onSendToAgent,onRelease:u.onReleaseAgent||null}):null,u.onHostedFix?(0,Y.jsx)(LE,{slot:`status`,comment:e,list:b,busy:l,touch:o,onFix:u.onHostedFix,onOpenChat:u.onAskAgent||null}):null,(0,Y.jsxs)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Comment ${e.id} and replies`,children:[(0,Y.jsxs)(VE,{author:Nb(e),at:e.createdAt,editedAt:e.editedAt,reactions:e.reactions,canReact:c.react,me:s,onReact:t=>u.onReact(e,t,null),touch:o,"data-sw-message":`comment`,children:[w?(0,Y.jsx)(HE,{comment:e,busy:l,onSave:u.onEdit,onCancel:()=>E(!1),touch:o,people:i}):e.body?(0,Y.jsx)(Vb,{text:e.body,plain:!!e.authorGuest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}):null,(0,Y.jsx)(bS,{boardId:S?.boardId,images:e.images,touch:o,label:`Comment ${e.id}`}),(0,Y.jsx)(WE,{item:e,currentVersion:te,onShow:V}),e.anchor?(0,Y.jsx)(_,{content:(0,Y.jsx)(`span`,{className:`font-mono text-[11px] break-all`,children:e.anchor.selector}),children:(0,Y.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,Y.jsx)(Mh,{size:11,className:`shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Pinned to`}),(0,Y.jsx)(`span`,{className:`truncate text-fg`,children:Rb(e.anchor)})]})}):null,t?.note?(0,Y.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-xs text-faint`,"data-sw-page-note":`true`,children:[(0,Y.jsx)(gg,{size:11,className:`mt-0.5 shrink-0`,"aria-hidden":`true`}),` `,t.note]}):null,e.resolution?(0,Y.jsxs)(`p`,{className:`mt-1.5 rounded bg-ok/10 px-2 py-1 text-xs text-fg`,children:[`Fix: `,e.resolution]}):null,(0,Y.jsx)(Cb,{value:e.fixRef,touch:o}),(0,Y.jsx)(Tb,{github:e.github,touch:o}),f?(0,Y.jsx)(WT,{comment:e,pair:f.pairFor(e),native:f.nativeFor(e),urlFor:f.urlFor,onImageError:f.onImageError,touch:o}):null]}),(e.replies||[]).length?(0,Y.jsx)(`li`,{"data-sw-replies":`true`,children:(0,Y.jsx)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Replies`,children:e.replies.map(t=>(0,Y.jsxs)(VE,{author:Pb(t),at:t.createdAt,reactions:t.reactions,canReact:c.react,me:s,onReact:n=>u.onReact(e,n,t.id),touch:o,"data-sw-reply":t.id,children:[t.body?(0,Y.jsx)(Vb,{text:t.body,plain:!!t.guest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}):null,(0,Y.jsx)(bS,{boardId:S?.boardId,images:t.images,touch:o,label:`Reply ${t.id}`}),(0,Y.jsx)(WE,{item:t,currentVersion:te,onShow:V})]},t.id))})}):null]})]}),k?(0,Y.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,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Delete this thread and its replies for good?`}),(0,Y.jsx)(a,{size:o?`touch`:`xs`,variant:`ghost`,onClick:()=>A(!1),disabled:l,children:`Cancel`}),(0,Y.jsxs)(a,{size:o?`touch`:`xs`,variant:`secondary`,className:`text-bad`,onClick:()=>u.onDelete(e),disabled:l,"data-sw-delete-confirm":e.id,children:[(0,Y.jsx)(ev,{size:13,"aria-hidden":`true`}),` Delete`]})]}):null,c.reply?(0,Y.jsx)(UE,{comment:e,busy:l,onReply:u.onReply,touch:o,people:i,askName:v===!1,onSaveName:x,media:S},e.id):(0,Y.jsx)(`p`,{className:`shrink-0 border-t border-line px-3 py-2 text-xs text-muted`,"data-sw-reply-denied":g||`true`,children:h||zE(g)})]})}var KE={top:10,right:10,bottom:60,left:10},qE={...KE,bottom:KE.bottom+40};function JE(e,t,n,r,i=KE){let a=Math.max(t.left+i.left,Math.min(t.right-i.right-n,e.x)),o=Math.max(t.top+i.top,Math.min(t.bottom-i.bottom-r,e.y));return{x:Math.round(a),y:Math.round(o)}}function YE({pin:e,target:t=null,box:n,width:r,height:i,gap:a=10,padding:o=KE}){let s=n.right-o.right-e.right>=r+a,c=e.left-(n.left+o.left)>=r+a,l={side:s?`right`:c?`left`:`bottom`,on:`pin`};return t?s&&t.right<=e.right+a?{side:`right`,on:`pin`}:c&&t.left>=e.left-a?{side:`left`,on:`pin`}:n.bottom-o.bottom-t.bottom>=i+a?{side:`bottom`,on:`target`}:t.top-(n.top+o.top)>=i+a?{side:`top`,on:`target`}:l:l}var XE=`input, textarea, select, [contenteditable="true"]`,ZE=()=>!!document.querySelector(`[data-sw-tool-note]`),QE=-6,$E=4,eD=640;function tD(e,t){return!t||e.left<t.right-4||e.left>t.right+eD||e.bottom<t.top||e.top>t.bottom?e:new DOMRect(t.right-4-e.width,e.top,e.width,e.height)}function nD(e,t,n,r){let i=rd(),a=(0,J.useRef)(null),o=(0,J.useRef)({selector:e,point:t,avoid:n});if(o.current={selector:e,point:t,avoid:n},!a.current){let e=()=>i.getState().domNode?.getBoundingClientRect()||null,t=()=>{let{domNode:t,transform:n}=i.getState(),{selector:r,point:a}=o.current,s=e(),c=r?t?.querySelector(r):null;if(c)return tD(c.getBoundingClientRect(),s);if(!s||!a)return new DOMRect(-1e4,-1e4,0,0);let[l,u,d]=n;return tD(new DOMRect(s.left+a.x*d+l,s.top+a.y*d+u,0,0),s)},n=()=>{let{avoid:e}=o.current,t=e?i.getState().domNode?.querySelector(e):null;return t?t.getBoundingClientRect():null};a.current={canvasBox:e,pinRect:t,targetRect:n,getBoundingClientRect(){let{on:i,side:a,width:o,height:s,moved:c,padding:l=KE}=r.current,u=e();if(c&&u){let e=JE(c,u,o,s,l);return new DOMRect(e.x,e.y,0,0)}let d=t(),f=i===`target`?n():null,p=d.left;if(u&&(a===`top`||a===`bottom`)){let e=u.left+KE.left-QE,t=u.right-KE.right-o-QE;p=Math.max(e,Math.min(t,p))}if(!f)return new DOMRect(p,d.top,d.width,d.height);let m=Math.min(f.top,d.top);return new DOMRect(p,m,d.width,Math.max(f.bottom,d.bottom)-m)}}}return a}function rD(e,t,n,r,i){let a=rd(),[o,s]=(0,J.useState)(`right`),[c,l]=(0,J.useState)(KE);return(0,J.useEffect)(()=>{if(!e)return;let o=()=>{let e=t.current.canvasBox();if(!e)return;let a=n.current?.offsetWidth||360,o=n.current?.offsetHeight||240,c=ZE()?qE:KE;if(l(c),i){r.current={on:`pin`,side:`bottom`,width:a,height:o,moved:i,padding:c},s(`bottom`);return}let u=YE({pin:t.current.pinRect(),target:t.current.targetRect(),box:e,width:a,height:o,gap:10,padding:c});r.current={...u,width:a,height:o,moved:null,padding:c},s(u.side)};o();let c=a.subscribe(o),u=new ResizeObserver(o),d=a.getState().domNode;d&&u.observe(d),n.current&&u.observe(n.current);let f=window.setInterval(o,250);return()=>{c(),u.disconnect(),window.clearInterval(f)}},[e,a,t,n,r,i]),{side:o,padding:c}}function iD(e,t,n){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1);(0,J.useEffect)(()=>i(null),[n]);let s=(0,J.useRef)(null);return(0,J.useEffect)(()=>()=>s.current?.(),[]),{moved:r,dragging:a,onPointerDown:n=>{if(n.button!==0||!n.target.closest?.(`[data-sw-card-drag-handle]`)||n.target.closest(`button, a, input, textarea, select, [role="button"], [role="menuitem"]`))return;let r=e.current,a=t.current.canvasBox();if(!r||!a)return;let c=r.getBoundingClientRect(),l={x:n.clientX,y:n.clientY},u=!1,d=e=>{let n=e.clientX-l.x,r=e.clientY-l.y;!u&&Math.hypot(n,r)<$E||(u=!0,o(!0),e.preventDefault(),i(JE({x:c.left+n,y:c.top+r},t.current.canvasBox()||a,c.width,c.height,ZE()?qE:KE)))},f=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),s.current=null,o(!1)};s.current=f,window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)}}}function aD({open:e,onClose:t,selector:n,point:r,avoid:i=null,resetKey:a=null,children:o,label:s,onKeyDown:c,onEscape:l,focusContent:u,stowed:d,className:f,...p}){let m=rd(),h=(0,J.useRef)({on:`pin`,side:`right`,width:360,height:240,moved:null}),g=nD(n,r,i,h),_=(0,J.useRef)(null),v=iD(_,g,a),{side:y,padding:b}=rD(e,g,_,h,v.moved),x=!!v.moved;return(0,Y.jsxs)(lt,{open:e,onOpenChange:e=>e?null:t(),children:[(0,Y.jsx)(fe,{virtualRef:g}),(0,Y.jsx)(ot,{ref:_,side:y,align:`start`,sideOffset:x?0:10,alignOffset:x?0:QE,avoidCollisions:!x,collisionBoundary:m.getState().domNode,collisionPadding:b,sticky:`always`,hideWhenDetached:!x,updatePositionStrategy:`always`,"aria-label":s,className:O(`z-30`,f,d&&`invisible`,v.dragging&&`cursor-grabbing select-none [&_*]:cursor-grabbing`),"data-sw-stowed":d?`true`:void 0,"data-sw-card-moved":x?`true`:void 0,onPointerDown:v.onPointerDown,onOpenAutoFocus:e=>{u&&(e.preventDefault(),_.current?.focus({preventScroll:!0}))},onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>{l?.(e)===!1&&e.preventDefault()},onKeyDown:e=>{_.current?.contains(e.target)&&!e.target?.closest?.(XE)&&c?.(e)},tabIndex:-1,...p,children:o})]})}function oD(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 sD(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 cD({comment:e,point:t,onClose:n,onPrev:r,onNext:i,editingRef:a,stowed:o,children:s}){let c=(0,J.useRef)({onPrev:r,onNext:i});c.current={onPrev:r,onNext:i},(0,J.useEffect)(()=>{let e=e=>{e.defaultPrevented||document.activeElement!==document.body||document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||sD(e,c.current.onPrev,c.current.onNext)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,J.useEffect)(()=>{let t=window.setTimeout(()=>{let t=document.activeElement;(t===document.body||t?.hasAttribute?.(`data-sw-canvas`))&&document.querySelector(`[data-sw-thread-popover="${e.id}"]`)?.focus({preventScroll:!0})},450);return()=>window.clearTimeout(t)},[e.id]);let l=()=>{if(a?.current&&document.activeElement?.closest?.(`[data-sw-edit-form]`))return a.current(),!1;let t=String(e.id);return window.setTimeout(()=>oD(t),0),!0},u=(0,J.useRef)(null);return u.current={escape:l,onClose:n},(0,J.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&document.querySelector(`[data-sw-pin-preview]`)&&(document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||(e.preventDefault(),e.stopPropagation(),u.current.escape()!==!1&&u.current.onClose()))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Y.jsx)(aD,{open:!0,onClose:n,selector:`[data-sw-pin="${e.id}"]`,avoid:`[data-sw-thread-target="${e.id}"]`,resetKey:e.id,point:t,label:`Comment ${e.id}`,focusContent:!0,stowed:o,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:l,onKeyDown:e=>sD(e,r,i),"data-sw-thread-popover":e.id,children:s})}function lD({point:e,onClose:t,onEscape:n,resetKey:r,stowed:i,children:a}){return(0,Y.jsx)(aD,{open:!0,onClose:t,onEscape:n,resetKey:r,selector:`[data-sw-draft-pin]`,avoid:`[data-sw-picked-outline]`,point:e,label:`New comment`,stowed:i,className:`w-[340px] p-3`,"data-sw-composer-popover":`true`,children:a})}var uD=600,dD=e=>`shapewall.seen:${typeof window>`u`?``:window.location.pathname}:${e}`;function fD(e){try{let t=JSON.parse(window.localStorage.getItem(dD(e))||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function pD(e,t){try{let n=Object.entries(t).sort((e,t)=>String(t[1]).localeCompare(String(e[1]))).slice(0,uD);window.localStorage.setItem(dD(e),JSON.stringify(Object.fromEntries(n)))}catch{}}function mD(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 hD(e,t){return t?t.handle&&e.handle?e.handle===t.handle:!!t.name&&String(e.author||``).toLowerCase()===String(t.name).toLowerCase():!1}function gD(e,t,n){let r=mD(e);return!r.at||hD(r,n)?!1:!t[e.id]||String(t[e.id])<String(r.at)}function _D(e){let[t,n]=(0,J.useState)(()=>fD(e));(0,J.useEffect)(()=>{n(fD(e));let t=t=>{t.key===dD(e)&&n(fD(e))};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e]);let r=(0,J.useCallback)(t=>{n(n=>{let r=!1,i={...n};for(let e of t){let t=mD(e).at;t&&String(i[e.id]||``)<String(t)&&(i[e.id]=t,r=!0)}return r?(pD(e,i),i):n})},[e]);return{seen:t,markSeen:(0,J.useCallback)(e=>r([e]),[r]),markAllSeen:r}}var vD=[`viewer`,`member`,`admin`,`owner`],yD=(e,t)=>vD.indexOf(e)>=vD.indexOf(t)&&vD.includes(e),bD=({isAuthor:e})=>!!e,xD=({role:e,isAuthor:t})=>yD(e,`member`)&&(!!t||yD(e,`admin`)),SD=`https://shapewall.com/contact`,CD={version:`0.9.0`,revision:`0b45aa284bdc8ef617e543c686d1df03cddd980c`},wD=e=>`v${e?.version||CD.version}${e?.revision?` · ${e.revision.slice(0,7)}`:``}`,TD=`modulepreload`,ED=function(e,t){return new URL(e,t).href},DD={},OD=function(e){return e.pathname.endsWith(`.css`)},kD=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},AD=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=ED(t,n);let r=s(t),i=OD(r);return kD(DD,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`:TD,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)})},jD=(0,J.lazy)(()=>AD(()=>import(`./app-update-dialog-BQxVHa5e.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)),MD=`shapewall:open-about`;function ND(e=null){window.dispatchEvent(new CustomEvent(MD,{detail:{opener:e}}))}function PD({transport:e,className:t,placement:n=`menu`,ref:r}){let[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=e=>{u.current=e||null,c(!0),o(!0)};(0,J.useImperativeHandle)(r,()=>({open:()=>d(document.activeElement)}),[]),(0,J.useEffect)(()=>{let e=e=>d(e.detail?.opener||null);return window.addEventListener(MD,e),()=>window.removeEventListener(MD,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, ${wD(CD)}, created by Dan Baruch`;return(0,Y.jsxs)(Y.Fragment,{children:[n===`footer`?(0,Y.jsx)(`footer`,{className:O(`flex shrink-0 justify-center border-t border-line bg-surface text-muted`,t),style:{paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:(0,Y.jsxs)(a,{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,Y.jsx)(`span`,{children:`Created by Dan Baruch`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{"data-sw-app-version":!0,children:wD(CD)})]})}):n===`link`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(a,{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,Y.jsx)(`a`,{href:SD,target:`_blank`,rel:`noopener noreferrer`,children:`Contact`})}),(0,Y.jsxs)(a,{variant:`ghost`,size:`touch`,className:O(`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,Y.jsx)(`span`,{children:`About Shapewall`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,"data-sw-app-version":!0,children:[`v`,CD.version]})]})]}):null,s?(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Opening About & Updates…`}),children:(0,Y.jsx)(jD,{open:i,onClose:f,onCloseAutoFocus:p,transport:e})}):null]})}function FD({demo:e,className:t,children:n,align:i=`start`}){return e.viewAs?(0,Y.jsxs)(je,{children:[(0,Y.jsx)(T,{asChild:!0,children:n}),(0,Y.jsxs)(r,{align:i,className:O(`w-64`,t),children:[(0,Y.jsx)(k,{children:`View as (demo)`}),(0,Y.jsx)(ee,{value:e.viewAs.value,onValueChange:e.viewAs.onChange,children:e.viewAs.options.map(e=>(0,Y.jsxs)(p,{value:e.id,"data-sw-view-as":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]})]}):n}var ID=()=>(0,Y.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,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),`Demo`]});function LD({variant:e=`strip`,className:t}){let n=ue();return n?e===`chip`?(0,Y.jsxs)(`div`,{className:O(`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":n.role,children:[(0,Y.jsx)(FD,{demo:n,align:`end`,children:(0,Y.jsxs)(a,{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 `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(ID,{}),(0,Y.jsx)(`span`,{className:`hidden max-w-28 truncate font-medium sm:inline`,children:n.roleLabel}),(0,Y.jsx)(pe,{size:13,className:`text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(B,{label:`Reset the demo`,size:`icon`,className:`rounded-full text-muted max-lg:hidden lg:h-8 lg:w-8`,onClick:n.reset,"data-sw-demo-reset":!0,children:(0,Y.jsx)(v_,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(RD,{})]}):(0,Y.jsxs)(`div`,{className:O(`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":n.role,children:[(0,Y.jsx)(ID,{}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`hidden shrink-0 sm:inline`,children:`Viewing as`}),(0,Y.jsx)(FD,{demo:n,children:(0,Y.jsxs)(a,{variant:`ghost`,size:`touch`,className:`min-w-0 gap-1 px-1.5 text-ui text-fg lg:h-7`,"aria-label":`Viewing as `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:n.roleLabel}),(0,Y.jsxs)(`span`,{className:`hidden truncate font-normal text-muted sm:inline`,children:[`(`,n.personaName,`)`]}),(0,Y.jsx)(pe,{size:13,className:`shrink-0 text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(`span`,{className:`hidden truncate text-faint md:inline`,children:`· Changes stay in this browser`})]}),(0,Y.jsxs)(a,{variant:`ghost`,size:`touch`,className:`shrink-0 gap-1.5 px-2 text-ui text-muted lg:h-7`,onClick:n.reset,"data-sw-demo-reset":!0,children:[(0,Y.jsx)(v_,{size:13,"aria-hidden":`true`}),` Reset`]}),(0,Y.jsx)(RD,{})]}):null}function RD(){let e=ue();return e?(0,Y.jsx)(N,{open:!!e.resetAsked,onClose:e.cancelReset,title:`Reset the demo?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{size:`touch`,variant:`ghost`,onClick:e.cancelReset,className:`lg:h-10`,"data-sw-demo-reset-cancel":!0,children:`Cancel`}),(0,Y.jsxs)(a,{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,Y.jsx)(v_,{size:14,"aria-hidden":`true`}),` Reset`]})]}),children:(0,Y.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 zD={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 BD({problem:e,onLeave:t}){let n=zD[e?.status]||zD.unknown,r=e?.at?new Date(e.at):null;return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Y.jsx)(LD,{}),(0,Y.jsx)(`main`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,Y.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,Y.jsx)(`span`,{className:`inline-flex h-11 w-11 items-center justify-center rounded-xl bg-bad/10 text-bad`,children:(0,Y.jsx)(wg,{size:20,"aria-hidden":`true`})}),(0,Y.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:n.title}),(0,Y.jsxs)(`p`,{className:`mt-2 text-sm text-muted`,children:[n.text,r&&Number.isFinite(r.getTime())?(0,Y.jsxs)(Y.Fragment,{children:[` `,e.status===`revoked`?`Revoked`:`Expired`,` `,r.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`.`]}):null]}),(0,Y.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,Y.jsx)(a,{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 VD(e,t,n){let r;try{r=await fetch(t,{method:e,credentials:`same-origin`,headers:{...n===void 0?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`},...typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-accounts"]`)&&t.startsWith(`/auth/`)?Ze():{}},body:n===void 0?void 0:JSON.stringify(n),cache:`no-store`})}catch{throw new g(0,`offline`,`Could not reach the server. Check your connection and try again.`)}let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=Number(r.headers.get(`Retry-After`)),t=i?.error?.message||`Request failed (${r.status})`;throw new g(r.status,i?.error?.code||`error`,r.status===429&&e>0?UD(t,e):t,{retryAfter:r.status===429&&e>0?e:null,stepUp:i?.error?.stepUp||null,details:i?.error?.device||i?.error?.confirm?{...i.error.device?{device:String(i.error.device)}:{},...i.error.confirm?{confirm:String(i.error.confirm),confirms:i.error.confirms||null}:{}}:null})}return i}function HD(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 UD=(e,t)=>`${e.replace(/\s*Wait (a while|a moment) and try again\.?\s*$/i,``)} Try again in ${HD(t)}.`,WD={get:e=>VD(`GET`,e),post:(e,t={})=>VD(`POST`,e,t),patch:(e,t={})=>VD(`PATCH`,e,t),put:(e,t={})=>VD(`PUT`,e,t),delete:(e,t)=>VD(`DELETE`,e,t)},GD=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},KD=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function qD(e,{mediation:t,signal:n}={}){let r={...e,challenge:GD(e.challenge),allowCredentials:(e.allowCredentials||[]).map(e=>({...e,id:GD(e.id)}))},i=await navigator.credentials.get({publicKey:r,...t?{mediation:t}:{},...n?{signal:n}:{}}),a=i.response;return{id:i.id,rawId:KD(i.rawId),type:i.type,authenticatorAttachment:i.authenticatorAttachment||void 0,clientExtensionResults:i.getClientExtensionResults(),response:{clientDataJSON:KD(a.clientDataJSON),authenticatorData:KD(a.authenticatorData),signature:KD(a.signature),userHandle:a.userHandle?KD(a.userHandle):void 0}}}async function JD(){let{options:e}=await WD.post(`/auth/reauth/options`,{}),t=await qD(e);await WD.post(`/auth/reauth/verify`,{response:t})}var YD=`shapewall:hosted-agents`,XD=e=>String(e||``).replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),ZD=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n].id&&e.thread===t[n].thread),QD=e=>/^comment-(\d+)$/.test(e||``)?Number(e.slice(8)):null,$D=e=>QD(e)?`comment #${QD(e)}`:`the board chat`;function eO({boardId:e,onRows:t=null,onOpenThread:n=null,openThread:r=null}){let[i,o]=(0,J.useState)([]),[s,c]=(0,J.useState)([]),l=!!n;(0,J.useEffect)(()=>{t?.([...i,...s.map(e=>({id:`card-${e.id}`,chat:!0,commentId:QD(e.thread)}))])},[t,i,s]);let[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),g=`/api/boards/${encodeURIComponent(e)}/approvals`;(0,J.useEffect)(()=>{let t=!0,n=()=>S.get(`/api/boards/${encodeURIComponent(e)}/agent-budget`).then(e=>{t&&d(e)}).catch(()=>{}),r=()=>S.get(g).then(e=>{t&&o(e.approvals)}).catch(()=>{}),i=()=>l?S.get(`/api/agent/boards/${encodeURIComponent(e)}/permissions`).then(e=>{let n=Array.isArray(e?.permissions)?e.permissions:[];t&&c(e=>ZD(e,n)?e:n)}).catch(()=>{}):null;r(),i(),n();let a=()=>{document.visibilityState===`visible`&&(r(),i(),n())},s=setInterval(a,3e3);document.addEventListener(`visibilitychange`,a);let u=()=>i();return window.addEventListener(YD,u),()=>{t=!1,clearInterval(s),document.removeEventListener(`visibilitychange`,a),window.removeEventListener(YD,u)}},[g,e,l]);let _=async(e,t)=>{h(!0),p(null);try{let n=()=>S.post(`${g}/${e.id}`,{state:t,hash:e.command_hash});try{await n()}catch(e){if(e?.code!==`reauth_required`)throw e;await JD(),await n()}o(t=>t.filter(t=>t.id!==e.id))}catch(e){p(e.message)}finally{h(!1)}},v=s.filter(e=>e.thread!==r);return!i.length&&!v.length&&!f&&!u?.exhausted?null:(0,Y.jsxs)(`section`,{"aria-label":`Agent approvals`,className:`max-h-64 shrink-0 overflow-auto border-b border-line bg-surface p-3 text-sm`,children:[u?.exhausted?(0,Y.jsxs)(`p`,{role:`status`,className:`pb-2`,children:[`The agent hit today’s limit: `,u.claims,`/`,u.dailyLimit,` runs, `,u.open,`/`,u.openLimit,` in progress. Change limits in Agent policy in the console.`]}):null,v.length?(0,Y.jsx)(`ul`,{className:`space-y-1.5 pb-1`,"aria-label":`Requests waiting for your answer`,"data-sw-hosted-cards":v.length,children:v.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-warn/50 bg-warn/10 px-3 py-2 sm:flex-row sm:items-center`,"data-sw-hosted-card":e.id,"data-sw-hosted-card-thread":e.thread,children:[(0,Y.jsx)(R_,{size:15,className:`hidden shrink-0 text-warn sm:block`,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`p`,{className:`font-medium break-words text-fg`,children:[e.agent?.name||`An agent`,` asks before it acts, on `,$D(e.thread)]}),(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:e.name===`execute`?`Run a command:`:`Edit a file:`}),(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-fg`,children:XD(e.detail||e.label)})]})]}),(0,Y.jsx)(a,{size:`touch`,variant:`default`,className:`shrink-0 lg:h-8`,onClick:()=>n(e.thread),"data-sw-hosted-card-open":e.thread,children:`Review and answer`})]},`${e.thread}/${e.id}`))}):null,i.map(e=>(0,Y.jsxs)(`article`,{className:`space-y-2 pb-3`,children:[(0,Y.jsxs)(`p`,{className:`font-semibold`,children:[`Agent asks to run a command for comment #`,e.comment_number]}),(0,Y.jsx)(`pre`,{className:`overflow-auto rounded bg-surface-2 p-2 break-words whitespace-pre-wrap`,children:XD(e.command)}),(0,Y.jsx)(`p`,{children:e.reason}),(0,Y.jsx)(a,{size:`touch`,variant:`default`,className:`lg:h-8`,disabled:m,onClick:()=>_(e,`approved`),children:`Approve once`}),` `,(0,Y.jsx)(a,{size:`touch`,variant:`danger`,className:`lg:h-8`,disabled:m,onClick:()=>_(e,`denied`),children:`Deny`})]},e.id)),f?(0,Y.jsx)(`p`,{role:`alert`,className:`text-bad`,children:f}):null]})}var tO={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 nO(){let[e,t]=(0,J.useState)(null);if((0,J.useEffect)(()=>{let e=e=>t(t=>t||e.detail?.kind||null);return window.addEventListener(H,e),()=>window.removeEventListener(H,e)},[]),!e)return null;let n=tO[e],r=encodeURIComponent(window.location.pathname+window.location.search);return(0,Y.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,Y.jsx)(wg,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}):(0,Y.jsx)(Pg,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n.title}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:n.body}),n.href===`signin`?(0,Y.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,Y.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 rO=`You're a viewer. Ask an admin for member access to comment.`;function iO({compact:e=!1}){return(0,Y.jsx)(_,{content:rO,side:`bottom`,children:(0,Y.jsxs)(`span`,{role:`note`,tabIndex:0,"aria-label":rO,className:O(`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,Y.jsx)(Bh,{size:14,"aria-hidden":`true`}),` Viewer`]})})}function aO({project:e}){return(0,Y.jsx)(_,{content:`Back to ${e.name}`,side:`bottom`,align:`start`,children:(0,Y.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 oO={includes:e=>typeof e==`string`&&(e===`all`||/^[a-z][a-z0-9-]{0,31}$/.test(e))};function sO({enabled:e,boardId:t,canvasRef:n,flow:r,selection:i,mode:a,onMode:o,onInvalidate:s}){let[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(`offline`),[m,h]=(0,J.useState)(null),g=(0,J.useRef)({cursor:null});g.current={...g.current,selection:i,mode:a,onMode:o,onInvalidate:s};let _=(0,J.useRef)(null);return mm({onChange:e?()=>_.current?.():void 0}),(0,J.useEffect)(()=>{_.current?.()},[i,a]),(0,J.useEffect)(()=>{if(!e){l([]),d(0),h(null);return}let i=!1,a;return AD(async()=>{let{connectPresence:e}=await import(`./runtime-Bvq10IhH.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,J.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)||!oO.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 cO({touch:e,...t}){let n=sO(t);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fO,{presence:n}),(0,Y.jsx)(dO,{presence:n,touch:e})]})}var lO=e=>`${e.id}|${e.name}|${e.color}|${+!!e.viewport}`;function uO(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)=>lO(e)===lO(r.peers[t]))}var dO=(0,J.memo)(function({presence:e,touch:t}){if(e.status!==`online`)return null;let n=e.peers.find(t=>t.id===e.following);return(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 text-xs text-muted`,"data-sw-presence-count":e.count,children:[(0,Y.jsx)(cv,{size:13,"aria-hidden":`true`}),e.count,` viewing`]}),e.peers.slice(0,5).map(n=>(0,Y.jsx)(_,{content:`${n.name}${n.viewport?`: follow their view`:``}`,children:(0,Y.jsx)(a,{size:t?`icon`:`icon-sm`,variant:e.following===n.id?`default`:`ghost`,"aria-label":`Follow ${n.name}`,"aria-pressed":e.following===n.id,disabled:!n.viewport,"data-sw-presence-peer":n.id,onClick:()=>e.follow(e.following===n.id?null:n.id),children:(0,Y.jsx)(de,{person:!0,name:n.name,color:n.color,size:`sm`})})},n.id)),e.peers.length>5?(0,Y.jsxs)(`span`,{className:`px-1 text-xs text-muted`,children:[`+`,e.peers.length-5]}):null,n?(0,Y.jsxs)(a,{size:t?`touch`:`xs`,variant:`secondary`,onClick:e.stopFollowing,"data-sw-stop-follow":`true`,children:[`Stop following `,n.name]}):null]})},uO);function fO({presence:e}){let t=e.peers.filter(e=>e.cursor&&Number.isFinite(e.cursor.x)&&Number.isFinite(e.cursor.y));return(0,Y.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,Y.jsx)(pO,{peers:t}):null})}function pO({peers:e}){let{x:t,y:n,zoom:r}=fm();return e.map(e=>(0,Y.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,Y.jsx)(i_,{size:18,fill:`currentColor`,stroke:`white`,strokeWidth:1.5}),(0,Y.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 mO=`shapewall.appearance`,hO=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],gO=[{id:`default`,label:`Default`},{id:`ocean`,label:`Ocean`},{id:`forest`,label:`Forest`},{id:`contrast`,label:`High contrast`}],_O={mode:`system`,theme:`default`};function vO(e){return{mode:hO.some(t=>t.id===e?.mode)?e.mode:_O.mode,theme:gO.some(t=>t.id===e?.theme)?e.theme:_O.theme}}var yO=(e,t)=>e===`system`?t?`dark`:`light`:e,bO=typeof window<`u`,xO=()=>bO&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null;function SO(){try{return vO(JSON.parse(window.localStorage.getItem(`shapewall.appearance`)||`null`))}catch{return{..._O}}}var CO=bO?SO():{..._O},wO=new Set;function TO(){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 EO(e=CO){if(!bO)return;let t=document.documentElement;t.setAttribute(`data-mode`,yO(e.mode,!!xO()?.matches)),t.setAttribute(`data-theme`,e.theme),TO()}function DO(){return CO}function OO(e){CO=vO({...CO,...e});try{window.localStorage.setItem(mO,JSON.stringify(CO))}catch{}EO(),wO.forEach(e=>e())}bO&&(EO(),xO()?.addEventListener?.(`change`,()=>{CO.mode===`system`&&(EO(),wO.forEach(e=>e()))}),window.addEventListener(`storage`,e=>{e.key===`shapewall.appearance`&&(CO=SO(),EO(),wO.forEach(e=>e()))}));var kO=e=>(wO.add(e),()=>wO.delete(e));function AO(){return[(0,J.useSyncExternalStore)(kO,DO,DO),OO]}var jO=()=>bO?yO(CO.mode,!!xO()?.matches):`light`;function MO(){return(0,J.useSyncExternalStore)(kO,jO,jO)}var NO=`shapewall.demo.try`;function PO(){try{return window.localStorage.getItem(NO)===`1`}catch{return!1}}function FO(e){let[t,n]=(0,J.useState)(()=>e&&!PO());return[e&&t,()=>{n(!1);try{window.localStorage.setItem(NO,`1`)}catch{}}]}function IO({touch:e,chip:t=!1,done:n,onOpenComment:r,onComment:i,onAgent:o,onUsage:s,onClose:c}){let[l,u]=(0,J.useState)(!0),d=[{id:`open`,icon:Kg,label:`Open a comment`,hint:e?`Tap a pin on a page`:`Click a pin on a page`,run:r},i&&{id:`comment`,icon:Wg,label:e?`Pin your own comment`:`Comment on a page`,hint:e?`Tap a page, then Comment`:`Click a page, then Comment (or press C)`,run:i},o?{id:`agent`,icon:I,label:`Ask the agent`,hint:e?`In the ... menu`:`It reads the open comments`,run:o}:null].filter(Boolean),f=s?{id:`usage`,icon:mh,label:`See what the agents did`,hint:`Usage: turns, tokens, charts`,run:s}:null,p=d.filter(e=>n.has(e.id)).length,m=e?`bottom-[calc(4rem+env(safe-area-inset-bottom,0px))] left-2`:`bottom-16 left-3`;return l||t?(0,Y.jsxs)(`button`,{type:`button`,className:O(`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`,m),onClick:()=>u(!1),"aria-expanded":`false`,"aria-label":`Try this: ${p} of ${d.length} done. Show the tips`,"data-sw-try-this":`folded`,children:[(0,Y.jsx)(H_,{size:15,className:`text-accent`,"aria-hidden":`true`}),` Try this`,(0,Y.jsxs)(`span`,{className:`tabular text-xs text-muted`,children:[p,`/`,d.length]})]}):(0,Y.jsxs)(`section`,{className:O(`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-[calc(4rem+env(safe-area-inset-bottom,0px))]`:`bottom-16 left-3 w-72`),"aria-label":`Try this`,"data-sw-try-this":`true`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Y.jsx)(H_,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`h2`,{className:`min-w-0 flex-1 text-sm font-semibold`,children:[`Try this`,` `,(0,Y.jsxs)(`span`,{className:`tabular text-xs font-medium text-muted`,children:[p,`/`,d.length]})]}),(0,Y.jsx)(B,{size:e?`icon`:`icon-xs`,onClick:()=>u(!0),label:`Fold the tips away`,"aria-expanded":`true`,"data-sw-try-fold":`true`,children:(0,Y.jsx)(pe,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(B,{size:e?`icon`:`icon-xs`,onClick:c,label:`Close the tips for good`,"data-sw-try-close":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})})]}),(0,Y.jsxs)(`ol`,{className:`flex flex-col gap-1`,children:[d.map(t=>{let r=n.has(t.id),i=r?st:t.icon;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(a,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:t.run,"data-sw-try-step":t.id,"data-sw-try-done":r?`true`:void 0,children:[(0,Y.jsx)(`span`,{className:O(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,r?`bg-ok/15 text-ok`:`bg-accent/10 text-accent`),"aria-hidden":`true`,children:(0,Y.jsx)(i,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:O(`block text-[13px] font-medium text-fg`,r&&`text-muted line-through decoration-faint`),children:t.label}),(0,Y.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:t.hint})]})]})},t.id)}),f?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(a,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:f.run,"data-sw-try-step":f.id,children:[(0,Y.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-accent/10 text-accent`,"aria-hidden":`true`,children:(0,Y.jsx)(f.icon,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-[13px] font-medium text-fg`,children:f.label}),(0,Y.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:f.hint})]})]})}):null]}),(0,Y.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 LO=new Map,RO=10;function zO(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])>RO||Math.abs(e[t+1]-r[1])>RO||Math.abs(e[t+2]-r[2])>RO)return!0}return!1}function BO(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(zO(e,t,r,i))return Math.min(1,(r+1)/n);return 1}function VO(e){if(!e||typeof document>`u`)return Promise.resolve(1);if(LO.has(e))return LO.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(BO(a.getImageData(0,0,e,r).data,e,r))}catch{t(1)}},n.onerror=()=>t(1),n.src=e});return LO.set(e,t),t}var HO=()=>typeof window<`u`&&!!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,UO=e=>HO()?0:e,WO=()=>HO()?`auto`:`smooth`,GO=.02,KO={padding:.16};function qO(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 JO(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 YO(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:UO(450)});return}let o=r=>e.fitBounds(qO({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:UO(450)});!a||!i.length?o(1):Promise.all(i.map(e=>VO(e))).then(e=>o(Math.max(.2,...e))).catch(()=>o(1))}function XO(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 ZO=.34,QO=12,$O=.75,ek=72,tk=40;function nk(e,t,n=KO.padding){if(!t?.width||!t?.height||!e?.length)return null;let r=e.filter(e=>e.type===`groupFrame`),i=rk(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<=QO)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-ek-24)/l),d=Math.max(a,ZO,Math.min($O,u));return{x:tk-s.position.x*d,y:ek-s.position.y*d,zoom:d}}function rk(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}var ik=.35;function ak(e,t,n){if(!e?.width||!e?.height||!n?.width||!n?.height||!t?.zoom)return!0;let r=e.x*t.zoom+t.x,i=e.y*t.zoom+t.y,a=e.width*t.zoom,o=e.height*t.zoom;return a<240?!1:Math.max(0,Math.min(r+a,n.width)-Math.max(r,0))*Math.max(0,Math.min(i+o,n.height)-Math.max(i,0))/Math.min(a*o,n.width*n.height)>=ik}var ok={top:52,bottom:112,side:24},sk=280,ck=2;function lk(e,t,n=.5){if(!t?.width||!t?.height||!e?.width||!e?.height)return null;let{top:r,bottom:i,side:a}=ok,o=Math.max(1,t.width-a*2),s=Math.max(1,t.height-r-i),c=o/e.width,l=Math.min(c,s/e.height),u=Math.min(ck,4,Math.max(l,Math.min(c,sk/e.width))),d=e.width*u,f=e.height*u,p=a+(o-d)/2-e.x*u,m=r+(s-f)/2-e.y*u;if(f>s){m=r-e.y*u;let t=e.y+e.height*Math.min(1,Math.max(0,n));m+t*u>r+s*.8&&(m=Math.max(r+s-(e.y+e.height)*u,r+s/2-t*u))}return{x:p,y:m,zoom:u}}function uk(e){let t=rd(),[n,r]=(0,J.useState)(null),i=(0,J.useRef)(null),a=(0,J.useCallback)(e=>{i.current=e,r(e)},[]);return(0,J.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 dk=`shapewall.minimap`;function fk(){try{let e=window.localStorage.getItem(dk);return e===`on`||e!==`off`&&null}catch{return null}}function pk(e){return e>=30}var mk=`shapewall.tip.board`;function hk(){try{return window.localStorage.getItem(mk)===`1`}catch{return!1}}var gk=`shapewall.tip.pageComment`;function _k(){try{return window.localStorage.getItem(gk)===`1`}catch{return!0}}function vk(){try{window.localStorage.setItem(gk,`1`)}catch{}}function yk(e){try{window.localStorage.setItem(dk,e?`on`:`off`)}catch{}}function bk(){try{window.localStorage.setItem(mk,`1`)}catch{}}var xk=`shapewall.rail.`;function Sk(e){try{let t=Number(window.localStorage.getItem(xk+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}}function Ck(e,t){try{t==null?window.localStorage.removeItem(xk+e):window.localStorage.setItem(xk+e,String(Math.round(t)))}catch{}}var wk=8;function Tk({groups:e,onPick:t}){let[n,r]=(0,J.useState)(``),i=n.trim().toLowerCase(),o=e.flatMap(e=>e.pages.map(t=>({...t,group:e.group}))),s=i?o.filter(e=>`${e.title} ${e.path||``} ${e.group}`.toLowerCase().includes(i)):o.slice(0,wk);return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-page-finder":`true`,children:[(0,Y.jsx)(it,{size:`touch`,icon:E_,value:n,onChange:e=>r(e.target.value.slice(0,80)),placeholder:`Search ${o.length} pages`,"aria-label":`Search pages`,"data-sw-page-search":`true`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>t(e.id),"data-sw-page-pick":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:e.group})]})},e.id))}),s.length?null:(0,Y.jsxs)(`p`,{className:`px-1 text-sm text-muted`,children:[`No page matches "`,n.trim(),`".`]}),!i&&o.length>wk?(0,Y.jsxs)(`p`,{className:`px-1 text-xs text-faint`,children:[o.length-wk,` more: type to find them.`]}):null]})}var Ek=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``),Dk=Ek?`⌘K`:`Ctrl K`,Ok=60,kk=6,Ak=e=>String(e||``).toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``);function jk(e,...t){let n=0;for(let[r,i]of t.entries()){let t=Ak(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 Mk=e=>e.filter(e=>e.score>0).sort((e,t)=>t.score-e.score).map(e=>e.entry);function Nk({query:e,groups:t,journeys:n,canEditJourneys:r,comments:i,actions:a,titleOf:o}){let s=Ak(e.trim()),c=t.flatMap(e=>e.pages.map(t=>({id:t.id,kind:`page`,icon:Wh,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:S_,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:f_,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||fv,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,Ok),more:Math.max(0,c.length-Ok)},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:Kg,title:`#${e.id} ${Me(e).split(`
|
|
33
|
+
`)[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?Mk(i.map(e=>({entry:e,score:jk(s,e.body,e.author)}))):[]).filter(e=>e!==p)].filter(Boolean).slice(0,kk).map(f),h=Mk(c.map(e=>({entry:e,score:jk(s,e.title,e.detail,e.meta)}))),g=Mk(l.map(e=>({entry:e,score:jk(s,e.title,e.detail)}))),_=Mk(u.map(e=>({entry:e,score:jk(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,Ok)}: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 Pk({onOpen:e,compact:t=!1,className:n,...r}){return(0,Y.jsxs)(`button`,{type:`button`,...r,onClick:e,className:O(`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-full px-2.5`,n),"aria-label":`Search pages, journeys and comments`,"aria-haspopup":`dialog`,"aria-keyshortcuts":Ek?`Meta+K`:`Control+K`,"data-sw-page-jump":`true`,"data-sw-palette-trigger":`true`,children:[(0,Y.jsx)(E_,{size:14,"aria-hidden":`true`,className:`shrink-0`}),t?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:`Search the board`}),(0,Y.jsx)(s,{className:`shrink-0`,children:Dk})]})]})}function Fk({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,Y.jsx)(x,{open:e,onOpenChange:t,children:(0,Y.jsxs)(U,{children:[(0,Y.jsx)(dt,{}),(0,Y.jsxs)(ie,{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,Y.jsx)(W,{className:`sr-only`,children:`Go to a page, journey or comment`}),e?(0,Y.jsx)(Ik,{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 Ik({groups:e,journeys:t,canEditJourneys:n,comments:r,actions:i,titleOf:a,onRun:o}){let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(0),f=(0,J.useRef)(null),p=(0,J.useMemo)(()=>Nk({query:c,groups:e,journeys:t,canEditJourneys:n,comments:r,actions:i,titleOf:a}),[c,e,t,n,r,i,a]),m=(0,J.useMemo)(()=>p.flatMap(e=>e.items),[p]),h=m[Math.min(u,m.length-1)]||null;(0,J.useEffect)(()=>d(0),[c]),(0,J.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&&o(h.run))},_=e=>`sw-palette-${e.id.replace(/[^\w-]/g,`_`)}`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4`,children:[(0,Y.jsx)(E_,{size:17,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,Y.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,Y.jsx)(s,{className:`hidden shrink-0 lg:inline-flex`,children:`Esc`})]}),(0,Y.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,Y.jsxs)(`div`,{role:`presentation`,className:`pb-1`,children:[(0,Y.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,Y.jsxs)(`div`,{id:_(e),role:`option`,"aria-selected":t,className:O(`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:()=>o(e.run),"data-sw-option":e.id,children:[(0,Y.jsx)(`span`,{className:O(`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,Y.jsx)(n,{size:14})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.title}),e.detail?(0,Y.jsx)(`span`,{className:O(`block truncate text-xs text-muted`,e.kind===`page`&&`font-mono text-[11px]`),children:e.detail}):null]}),e.meta?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.meta}):null,t?(0,Y.jsx)(Oh,{size:14,className:`hidden shrink-0 text-muted lg:block`,"aria-hidden":`true`}):null]},e.id)}),e.more?(0,Y.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,Y.jsxs)(`p`,{className:`px-3 py-8 text-center text-sm text-muted`,"data-sw-palette-empty":`true`,children:[`Nothing matches "`,c.trim(),`".`]})]}),(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(s,{children:`↑`}),(0,Y.jsx)(s,{children:`↓`}),` to move`]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(s,{children:`↵`}),` to open`]}),(0,Y.jsx)(`span`,{className:`ml-auto`,children:`#12 finds comment 12`})]})]})}var Lk=Object.freeze({id:null,pinned:!1,via:null,swap:!1});function Rk({onChange:e,openDelay:t=150,closeDelay:n=250,setTimer:r=(e,t)=>setTimeout(e,t),clearTimer:i=e=>clearTimeout(e)}={}){let a=Lk,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(Lk)};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 zk({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 Bk=`shapewall.lastBoard`,Vk=`shapewall.sidebar`,Hk=`shapewall.sidebarWidth`,Uk=208,Wk=420,Gk=16,Kk=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``)?`⌘B`:`Ctrl B`;function qk(e){try{typeof e==`string`&&e.startsWith(`/`)&&window.localStorage.setItem(Bk,e)}catch{}}function Jk(e){try{let t=window.localStorage.getItem(Vk);return t===`expanded`||t!==`collapsed`&&e}catch{return e}}function Yk(e){let t=Math.max(Uk,Math.min(Wk,Math.floor(window.innerWidth*.4)));return Math.min(t,Math.max(Uk,Math.round(e)))}function Xk(){try{let e=Number(window.localStorage.getItem(Hk));return Number.isFinite(e)&&e>0?Yk(e):256}catch{return 256}}function Zk(e){try{e===256?window.localStorage.removeItem(Hk):window.localStorage.setItem(Hk,String(e))}catch{}}function Qk(){let[e,t]=(0,J.useState)(Xk),[n,r]=(0,J.useState)(!1),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=()=>t(e=>Yk(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let a=e=>{let n=Yk(e);t(n),Zk(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(Yk(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:Gk;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 $k=e=>!!(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)||e.closest?.(`[contenteditable="true"]`)));function eA(e=!0,t=!0){let[n,r]=(0,J.useState)(()=>Jk(t)),i=(0,J.useCallback)(()=>r(e=>{try{window.localStorage.setItem(Vk,e?`collapsed`:`expanded`)}catch{}return!e}),[]);return(0,J.useEffect)(()=>{if(!e)return;let t=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`b`||$k(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 tA(e,t){return O(`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 nA({item:e,expanded:t,link:n,flyouts:r}){let{id:i,label:a,icon:o,href:c,to:l,onSelect:u,active:d,count:f,shortcut:p,flyout:m,...h}=e;if(!t&&m&&r)return(0,Y.jsx)(oA,{item:e,flyouts:r});let g=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(o,{size:t?16:19,"aria-hidden":`true`,className:O(`shrink-0`,d&&`text-accent`)}),t?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}):null,t&&f?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-faint tabular`,children:f}):null]}),v={className:tA(t,d),"aria-label":t?void 0:a,"aria-current":d?`page`:void 0,"data-sw-rail-item":i,...h},y=l&&n?(0,Y.jsx)(n,{to:l,...v,children:g}):c?(0,Y.jsx)(`a`,{href:c,...v,children:g}):(0,Y.jsx)(`button`,{type:`button`,onClick:u,...v,children:g});return(0,Y.jsx)(`li`,{children:t?y:(0,Y.jsx)(_,{content:p?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[a,(0,Y.jsx)(s,{children:p})]}):a,side:`right`,children:y})})}var rA=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,iA=e=>[...e.querySelectorAll(rA)].filter(e=>e.getClientRects().length>0);function aA(e,t){let n=iA(document).filter(e=>!t?.contains(e));(n[n.indexOf(e)+1]||e).focus()}function oA({item:e,flyouts:t}){let{id:n,label:r,icon:i,active:a,flyout:o,dot:s}=e,{state:c,intent:l,width:u,disabled:d}=t,f=Object.fromEntries(Object.entries(e).filter(([e])=>e.startsWith(`data-`))),p=(0,J.useId)(),m=(0,J.useRef)(null),g=(0,J.useRef)(null),_=c.id===n,[v,y]=(0,J.useState)(null);(0,J.useLayoutEffect)(()=>{if(!_)return;let e=()=>{let e=m.current?.getBoundingClientRect().top??0;y(zk({anchorTop:e,viewportHeight:window.innerHeight}))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_]),(0,J.useEffect)(()=>{if(!_)return;let e=e=>{g.current?.contains(e.target)||m.current?.contains(e.target)||l.close()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[_,l]);let b=_&&c.pinned;(0,J.useEffect)(()=>{if(!b)return;let e=requestAnimationFrame(()=>{let e=g.current;e&&!e.contains(document.activeElement)&&(iA(e)[0]||e).focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[b]);let x=(0,J.useCallback)(()=>{let e=!!g.current?.contains(document.activeElement);l.close(),e&&m.current?.focus({preventScroll:!0})},[l]),S=e=>t=>{t.pointerType!==`touch`&&e()},w=e=>{if(e.key!==`Tab`||e.defaultPrevented)return;let t=iA(g.current);t.length&&(e.shiftKey&&document.activeElement===t[0]?(e.preventDefault(),m.current?.focus()):!e.shiftKey&&document.activeElement===t[t.length-1]&&(e.preventDefault(),l.close(),aA(m.current,g.current)))};return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(ne,{open:_,onOpenChange:e=>{e||l.close()},children:[(0,Y.jsx)(h,{asChild:!0,children:(0,Y.jsxs)(`button`,{ref:m,type:`button`,className:tA(!1,a||_),"aria-label":r,"aria-haspopup":`dialog`,"aria-expanded":_,"aria-controls":_?p:void 0,"aria-current":a?`page`:void 0,"data-sw-rail-item":n,"data-sw-rail-flyout-trigger":n,"data-state":_?c.pinned?`pinned`:`open`:`closed`,...f,onPointerEnter:S(()=>!d&&l.enterIcon(n)),onPointerLeave:S(()=>l.leave()),onClick:e=>!d&&l.toggle(n,e.detail===0?`key`:`click`),onKeyDown:e=>{e.key!==`ArrowRight`||d||(e.preventDefault(),b||l.toggle(n,`key`))},children:[(0,Y.jsx)(i,{size:19,"aria-hidden":`true`,className:O(`shrink-0`,a&&`text-accent`)}),s?(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-accent ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-rail-dot":n}):null]})}),(0,Y.jsx)(He,{children:(0,Y.jsx)(C,{ref:g,id:p,side:`right`,align:`start`,sideOffset:12,collisionPadding:8,"aria-label":r,tabIndex:-1,className:O(`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`,c.swap&&`sw-rail-flyout-swap`),style:{width:u,maxHeight:v??void 0},"data-sw-rail-flyout":n,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:e=>{e.preventDefault();let t=c.pinned||g.current?.contains(document.activeElement);l.close(),t&&m.current?.focus({preventScroll:!0})},onInteractOutside:e=>{m.current?.contains(e.target)&&e.preventDefault()},onPointerEnter:S(()=>l.enterPanel()),onPointerLeave:S(()=>l.leave()),onKeyDown:w,children:o({close:x})})})]})})}function sA({items:e,expanded:t,link:n,label:r,flyouts:i,flush:a}){return e.length?(0,Y.jsxs)(`div`,{className:O(`w-full`,!a&&`border-t border-line pt-2`),children:[t&&r?(0,Y.jsx)(`p`,{className:`px-2.5 pb-1 text-xs font-semibold text-faint`,children:r}):null,(0,Y.jsx)(`ul`,{className:O(`flex flex-col`,t?`gap-0.5`:`items-center gap-1`),children:e.map(e=>(0,Y.jsx)(nA,{item:e,expanded:t,link:n,flyouts:i},e.id))})]}):null}function cA(e,t,n=!1){let[r,i]=(0,J.useState)(()=>({id:null,pinned:!1,via:null,swap:!1})),a=(0,J.useRef)(null);return a.current||=Rk({onChange:i}),(0,J.useEffect)(()=>()=>a.current.dispose(),[]),(0,J.useEffect)(()=>{(e||n)&&a.current.close()},[e,n]),{state:r,intent:a.current,width:t,disabled:n}}function lA({expanded:e,onToggle:t,home:n,homeTo:r,homeLabel:i=`Shapewall`,title:a,logo:o,items:c=[],sections:l=[],sectionsLabel:u,link:d,profile:f,children:p,className:m,flyoutsDisabled:h=!1}){let g=r&&d?d:`a`,v=r&&d?{to:r}:{href:n},y=e?`Collapse sidebar`:`Expand sidebar`,{width:b,dragging:x,handle:S}=Qk(),C=cA(e,b,h),w=e?[]:l.filter(e=>!e.flyout),T=w.length?c.find(e=>e.active):null,E=T?c.map(e=>e===T?{...e,flyout:({close:t})=>(0,Y.jsx)(`div`,{onClick:e=>{e.target.closest?.(`[data-sw-rail-item]`)&&setTimeout(t,0)},children:(0,Y.jsx)(sA,{items:w,expanded:!0,link:d,label:u||e.label,flush:!0})})}:e):c,D=T?l.filter(e=>e.flyout):l;return(0,Y.jsxs)(`div`,{className:O(`relative flex shrink-0`,m),children:[(0,Y.jsxs)(`nav`,{"aria-label":`Shapewall`,className:O(`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:b}:void 0,"data-sw-app-rail":e?`expanded`:`collapsed`,children:[(0,Y.jsxs)(`div`,{className:O(`flex shrink-0 items-center gap-1`,e?`h-10`:`flex-col`),children:[(0,Y.jsx)(_,{content:e?null:i,side:`right`,children:(0,Y.jsx)(g,{...v,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":i,"data-sw-rail-home":`true`,children:o})}),e?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,"data-sw-rail-title":`true`,children:a||`Shapewall`}):null,(0,Y.jsx)(_,{content:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[y,(0,Y.jsx)(s,{children:Kk})]}),side:`right`,children:(0,Y.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":y,"aria-expanded":e,"data-sw-sidebar-toggle":`true`,children:e?(0,Y.jsx)(o_,{size:17,"aria-hidden":`true`}):(0,Y.jsx)(c_,{size:17,"aria-hidden":`true`})})})]}),(0,Y.jsx)(sA,{items:E,expanded:e,link:d,flyouts:C}),(0,Y.jsxs)(`div`,{className:O(`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,Y.jsx)(sA,{items:D,expanded:e,link:d,label:u,flyouts:C}),e?p:null]}),f?(0,Y.jsx)(`div`,{className:O(`w-full shrink-0 border-t border-line pt-2`,!e&&`flex justify-center`),children:f(e)}):null]}),e?(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":b,"aria-valuemin":Uk,"aria-valuemax":Wk,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`,...S,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`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`,x&&`opacity-100`)})}):null,x?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null]})}function uA({count:e,corner:t=!1}){return e?(0,Y.jsxs)(`span`,{className:O(`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,Y.jsxs)(`span`,{className:`sr-only`,children:[` broken link`,e===1?``:`s`]})]}):null}var dA=e=>e.status?String(e.status):`No answer`;function fA({items:e,open:t,onOpenChange:n}){let[r,i]=(0,J.useState)(!1),a=t??r,o=n||i,s=e.length;return(0,Y.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,Y.jsxs)(lt,{open:a,onOpenChange:o,children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:O(`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":a,"data-sw-broken-links-toggle":`true`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-bad/10 text-bad`,children:(0,Y.jsx)(wg,{size:12,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[s,` broken link`,s===1?``:`s`]}),(0,Y.jsx)(`span`,{className:`hidden shrink-0 font-normal text-muted sm:inline`,children:`from the last capture`}),(0,Y.jsx)(pe,{size:13,className:O(`shrink-0 text-faint transition-transform`,a&&`rotate-180`),"aria-hidden":`true`})]})}),(0,Y.jsxs)(ot,{align:`start`,className:`w-[min(26rem,calc(100vw-1.5rem))] p-0`,"aria-label":`Broken links`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-line px-3 py-2.5`,children:[(0,Y.jsxs)(`p`,{className:`text-[13px] font-semibold text-fg`,children:[s,` link`,s===1?``:`s`,` lead`,s===1?`s`:``,` to an error`]}),(0,Y.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,Y.jsx)(`ul`,{className:`max-h-72 divide-y divide-line overflow-auto`,children:e.slice(0,100).map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2`,"data-sw-broken-link":e.path??e.url,children:[(0,Y.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:dA(e)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-mono text-xs text-fg`,children:e.path??e.url}),(e.from||[]).length?(0,Y.jsxs)(`span`,{className:`mt-0.5 block text-[11px] text-muted`,children:[`Linked from `,(e.from||[]).join(`, `)]}):null]})]},e.url))}),s>100?(0,Y.jsx)(`p`,{className:`border-t border-line px-3 py-2 text-[11px] text-faint`,children:`Showing the first 100.`}):null]})]})})}var pA=e=>e.status!==`resolved`;function mA({comments:e=[],focus:t=null,approvals:n=[],titleOf:r=()=>``,listening:i=null,agents:a=null}){let o=new Map(e.map(e=>[Number(e.id),e])),s=e=>{let t=o.get(Number(e)),n=t?r(t.pageId):``;return n?`#${e} ${n}`:`#${e}`},c=new Map,l=new Map,u=new Map,d=(e,t,n)=>{let r=Number(t);r>0&&!e.has(r)&&e.set(r,{id:r,name:s(r),why:n})};for(let e of n)d(l,e.comment_number??e.commentId,`approval`);t?.state===`waiting`&&d(l,t.commentId,`approval`),t?.state===`working`&&d(c,t.commentId,`working`);for(let t of e)pA(t)&&(t.agentStatus===`working`?d(c,t.id,`working`):t.agentStatus===`needs-human`?d(u,t.id,`needs-human`):t.agentStatus===`branch-ready`&&d(u,t.id,`branch-ready`));for(let e of l.keys())c.delete(e);let f=e=>[...e.values()],p=[...f(l),...f(u).filter(e=>!l.has(e.id))],m=l.size?`waiting`:c.size?`working`:p.length?`waiting`:`idle`,h=m===`working`?c.size:m===`waiting`?l.size?l.size:p.length:0,g=[];l.size===1?g.push(`Agent needs your OK on ${f(l)[0].name}`):l.size&&g.push(`Agents need your OK on ${l.size} comments: ${gA(f(l))}`),c.size===1?g.push(`Agent working on ${f(c)[0].name}`):c.size&&g.push(`${c.size} agents working: ${gA(f(c))}`);let _=p.filter(e=>e.why!==`approval`);return _.length===1?g.push(_[0].why===`branch-ready`?a?`Fix ready on a branch for ${_[0].name}`:`Fix ready to apply on ${_[0].name}`:`${_[0].name} needs a person`):_.length&&g.push(`${_.length} comments wait for you: ${gA(_)}`),a?g.push(uE(a)):i&&g.push(i.online?`Agent online: ${i.name||`agent`}`:hA),{state:m,listening:a?dE(a):i?!!i.online:null,working:f(c),waiting:p,count:h,text:g.join(`. `),target:l.size===1?f(l)[0].id:!l.size&&p.length===1?p[0].id:null}}var hA=`No agent is listening: comments wait until one is`;function gA(e,t=3){let n=e.slice(0,t).map(e=>e.name);return e.length>t?`${n.join(`, `)} and ${e.length-t} more`:n.join(`, `)}var _A=(e,t)=>(e===`working`||e===`waiting`)&&t===`idle`,vA=`__none`;function yA(e){if(e.branching)return`${e.paths?.length||2} paths`;let t=e.steps?.length||0;return`${t} ${t===1?`step`:`steps`}`}function bA({journeys:e=[],journey:t,openJourney:n,closeJourney:i,canEditJourneys:o,startBuilder:c,showLinks:l,toggleLinks:u,linksTip:d,brokenLinks:f,openBrokenLinks:m,canCompare:h,comparePair:g,toggleCompare:v,minimapOn:b,toggleMinimap:x,compact:S,boxed:C=`text-fg`,labelMax:w=160}){let[E,A]=(0,J.useState)(``),j=(0,J.useRef)(null),M=[l,!!g].filter(Boolean).length,N=f.length,P=e.length>8,F=E.trim().toLowerCase(),I=P&&F?e.filter(e=>e.name.toLowerCase().includes(F)):e,L=(0,J.useRef)(null),R=`pr-2`,z=e=>(0,Y.jsx)(`span`,{className:O(`ml-auto inline-flex h-4 w-4 items-center justify-center`,e?`!text-accent`:`opacity-0`),children:(0,Y.jsx)(st,{size:14,className:`!text-accent`,"aria-hidden":`true`})}),te=N?`${N} broken link${N===1?``:`s`}`:null,V=[M?`${M} on`:null,te].filter(Boolean).join(`, `),ne=t?`Journey: ${t.name}. Views`:V?`Views, ${V}`:`Views`,H=t?(0,Y.jsx)(vx,{label:`Journey: ${t.name}. Open Views to switch`,keys:[`J`]}):e.length?(0,Y.jsx)(vx,{label:`Views: journeys, links between pages, compare, minimap`,keys:[`J`]}):`Views: links between pages, compare, minimap`,U=!!t,re=(0,Y.jsxs)(a,{variant:U?`soft`:`ghost`,className:O(`relative h-8 shrink-0 text-[13px]`,S?`w-8 px-0`:`px-2.5`,U?S?``:`rounded-r-none`:C),"aria-label":ne,"data-sw-view-menu":`true`,"data-sw-view-journey":t?.id,children:[U?(0,Y.jsx)(S_,{size:15,"aria-hidden":`true`}):(0,Y.jsx)(Bh,{size:15,"aria-hidden":`true`}),S?null:U?(0,Y.jsx)(`span`,{className:`block truncate`,style:{maxWidth:w},"data-sw-view-journey-name":`true`,children:t.name}):`Views`,N?(0,Y.jsx)(`span`,{className:`pointer-events-none absolute -top-1.5 -right-1.5 inline-flex min-w-4 items-center justify-center rounded-full bg-bad px-1 text-[10px] leading-4 font-semibold text-bad-fg tabular`,"aria-hidden":`true`,"data-sw-broken-links-badge":N,children:N}):U&&S?(0,Y.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":`journey`}):M&&!U?(0,Y.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-muted ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-view-on":M}):null]});return(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center`,"data-sw-views":`true`,children:[(0,Y.jsxs)(je,{onOpenChange:e=>e?null:A(``),children:[(0,Y.jsx)(_,{content:H,side:`bottom`,children:(0,Y.jsx)(T,{asChild:!0,children:re})}),(0,Y.jsxs)(r,{align:`start`,className:`w-80`,onCloseAutoFocus:e=>{e.preventDefault();let t=j.current;j.current=null,t?t():document.querySelector(`[data-sw-canvas]`)?.focus({preventScroll:!0})},"data-sw-views-menu":`true`,children:[e.length||o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(k,{className:`flex items-center gap-2`,children:[`Journeys`,e.length?(0,Y.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 font-normal tracking-normal normal-case`,children:[`Next `,(0,Y.jsx)(s,{children:`J`})]}):null]}),P?(0,Y.jsx)(`div`,{className:`px-1 pb-1`,children:(0,Y.jsx)(it,{size:`xs`,icon:E_,value:E,onChange:e=>A(e.target.value),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-views-filter":`true`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),L.current?.querySelector(`[role="menuitemradio"]`)?.focus()):e.key!==`Escape`&&e.key!==`Tab`&&e.stopPropagation()}})}):null,(0,Y.jsxs)(ee,{ref:L,value:t?.id||vA,onValueChange:e=>e===vA?i():n(e),className:P?`max-h-72 overflow-y-auto`:void 0,"aria-label":`Journeys`,"data-sw-views-journeys":e.length,children:[F?null:(0,Y.jsxs)(p,{value:vA,"data-sw-views-journey":`none`,children:[(0,Y.jsx)(Bh,{size:15,"aria-hidden":`true`}),` None`,(0,Y.jsx)(`span`,{className:`ml-auto text-caption text-faint`,children:`All pages`})]}),I.map(e=>(0,Y.jsxs)(p,{value:e.id,"data-sw-views-journey":e.id,children:[(0,Y.jsx)(S_,{size:15,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-caption text-faint tabular-nums`,children:yA(e)})]},e.id)),F&&!I.length?(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted`,children:`No journey matches.`}):null]}),o?(0,Y.jsxs)(D,{className:R,onSelect:()=>c(),"data-sw-views-new-journey":`true`,children:[(0,Y.jsx)(f_,{size:15,"aria-hidden":`true`}),` New journey`]}):null,(0,Y.jsx)(y,{})]}):null,(0,Y.jsx)(k,{children:`Show`}),(0,Y.jsxs)(D,{className:R,role:`menuitemcheckbox`,"aria-checked":l,onSelect:u,"data-sw-links-toggle":`true`,children:[(0,Y.jsx)(uv,{size:15,"aria-hidden":`true`}),`Links between pages`,z(l)]}),h?(0,Y.jsxs)(D,{className:R,role:`menuitemcheckbox`,"aria-checked":!!g,onSelect:v,"data-sw-compare-toggle":`true`,children:[(0,Y.jsx)(Qh,{size:15,"aria-hidden":`true`}),` Compare environments`,z(!!g)]}):null,(0,Y.jsxs)(D,{className:R,role:`menuitemcheckbox`,"aria-checked":b,onSelect:x,children:[(0,Y.jsx)(Rg,{size:15,"aria-hidden":`true`}),` Minimap`,z(b)]}),N?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsxs)(D,{className:R,onSelect:()=>{l||u(),j.current=m},"data-sw-broken-links-open":`true`,children:[(0,Y.jsx)(wg,{size:15,className:`!text-bad`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block`,children:`Broken links`}),(0,Y.jsxs)(`span`,{className:`block text-caption text-muted`,children:[N,` `,N===1?`link leads`:`links lead`,` to an error`]})]}),(0,Y.jsx)(`span`,{className:`ml-auto 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`,children:N})]})]}):null,(0,Y.jsx)(y,{}),(0,Y.jsxs)(`p`,{className:`px-2 py-1.5 text-xs text-muted`,children:[d,`.`]})]})]}),U&&!S?(0,Y.jsx)(B,{variant:`soft`,className:`h-8 w-7 shrink-0 -ml-px rounded-l-none`,onClick:i,label:`Leave journey`,tooltip:(0,Y.jsx)(vx,{label:`Leave the journey`,keys:[`Esc`]}),side:`bottom`,"data-sw-view-journey-clear":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})}):null]})}function xA({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?`Pages captured ${A(n)}`:`Not captured yet`;return(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[(0,Y.jsx)(me,{size:12}),(0,Y.jsx)(`span`,{className:`tabular`,children:t.total?`${t.done||0}/${t.total}`:`Capturing`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:i})]}):r?(0,Y.jsx)(_,{content:`Last capture failed: ${t.error}`,side:`bottom`,children:(0,Y.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,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bad`,"aria-hidden":`true`}),` Capture failed`]})}):(0,Y.jsx)(_,{content:i,side:`bottom`,children:(0,Y.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,Y.jsx)(`span`,{className:O(`h-2 w-2 rounded-full`,n?`bg-ok`:`bg-faint`),"aria-hidden":`true`})})})})}function SA({data:e,capture:t}){let n=e?.manifest?.capturedAt;return(0,Y.jsxs)(`p`,{className:`text-xs whitespace-nowrap text-muted`,"data-sw-captured":`true`,children:[t?.running?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(me,{size:12}),` Capturing`,t.total?` ${t.done||0}/${t.total}`:``]}):n?`Captured ${A(n)}`:`Not captured yet`,!t?.running&&t?.state===`failed`&&t.error?(0,Y.jsxs)(`span`,{className:`ml-2 text-bad`,children:[`Last capture failed: `,t.error]}):null]})}var CA=e=>e.preventDefault(),wA={light:X_,dark:n_,system:e_},TA=`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 EA({name:e,avatarUrl:t=null,detail:n=null,items:i=[],workspaces:o=null,viewAs:s=null,showName:c=!1,label:l=`Profile and appearance`,about:u=!0,triggerClassName:d,side:f=`bottom`,align:m=`end`,...h}){let[g,_]=AO(),v=(0,J.useRef)(null);return(0,Y.jsxs)(je,{children:[(0,Y.jsx)(T,{asChild:!0,children:(0,Y.jsxs)(a,{ref:v,variant:`ghost`,size:`touch`,className:O(`shrink-0 gap-2 px-1.5 lg:h-10`,d),"aria-label":e?`${l}: ${e}`:l,"data-sw-profile-menu":!0,...h,children:[(0,Y.jsx)(de,{name:e||`?`,src:t,className:`h-8 w-8`}),c&&e?(0,Y.jsx)(`span`,{className:`hidden max-w-40 truncate text-sm text-fg md:inline`,children:e}):null]})}),(0,Y.jsxs)(r,{className:`w-72`,side:f,align:m,"data-sw-profile-content":!0,children:[e||n?(0,Y.jsxs)(k,{className:`normal-case`,children:[e?(0,Y.jsx)(`span`,{className:`block truncate text-[13px] font-medium tracking-normal text-fg`,children:e}):null,n?(0,Y.jsx)(`span`,{className:`block truncate text-xs font-normal tracking-normal text-muted`,children:n}):null]}):null,i.length?(0,Y.jsxs)(Y.Fragment,{children:[e||n?(0,Y.jsx)(y,{}):null,(0,Y.jsx)(ke,{children:i.map(({id:e,label:t,icon:n,onSelect:r,tone:i,hint:a,...o})=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(D,{onSelect:r,tone:i,"data-sw-profile-item":e,"aria-describedby":a?`sw-profile-hint-`+e:void 0,...o,children:[n?(0,Y.jsx)(n,{size:14,"aria-hidden":`true`}):null,` `,t]}),a?(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsx)(k,{children:`Workspace`}),o.list.map(e=>(0,Y.jsxs)(D,{onSelect:()=>o.onPick(e.id),"data-sw-profile-workspace":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.roleLabel?(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:e.roleLabel}):null,e.id===o.current?(0,Y.jsx)(st,{size:14,className:`!text-accent`,"aria-label":`Current`}):null]},e.id))]}):null,s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsx)(k,{children:`View as (demo)`}),(0,Y.jsx)(ee,{value:s.value,onValueChange:s.onChange,children:s.options.map(e=>(0,Y.jsxs)(p,{value:e.id,"data-sw-view-as":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]}):null,(0,Y.jsx)(y,{}),(0,Y.jsx)(k,{children:`Appearance`}),(0,Y.jsx)(ee,{value:g.mode,onValueChange:e=>_({mode:e}),className:`grid grid-cols-3 gap-1 px-1 pb-1`,"aria-label":`Mode`,children:hO.map(e=>{let t=wA[e.id];return(0,Y.jsxs)(p,{value:e.id,indicator:!1,className:TA,onSelect:CA,"data-sw-appearance-mode":e.id,children:[(0,Y.jsx)(t,{size:14,"aria-hidden":`true`}),` `,e.label]},e.id)})}),(0,Y.jsx)(ee,{value:g.theme,onValueChange:e=>_({theme:e}),className:`grid grid-cols-2 gap-1 px-1 pb-1`,"aria-label":`Theme`,children:gO.map(e=>(0,Y.jsxs)(p,{value:e.id,indicator:!1,className:O(TA,`justify-start px-2`),onSelect:CA,"data-sw-theme-option":e.id,children:[(0,Y.jsx)(`span`,{className:O(`h-4 w-4 shrink-0 rounded-full ring-1 ring-line`,`sw-swatch-${e.id}`),"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))}),u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{}),(0,Y.jsxs)(D,{onSelect:()=>ND(v.current),"data-sw-app-about":`menu`,children:[(0,Y.jsx)(gg,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`About Shapewall and updates`}),(0,Y.jsxs)(`span`,{className:`text-caption text-faint tabular-nums`,"data-sw-app-version":!0,children:[`v`,CD.version]})]}),(0,Y.jsx)(D,{asChild:!0,"data-sw-app-contact":`menu`,children:(0,Y.jsxs)(`a`,{href:SD,target:`_blank`,rel:`noopener noreferrer`,children:[(0,Y.jsx)(Ig,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Contact`})]})})]}):null]})]})}function DA(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,OA(e.role)].filter(Boolean).join(` · `):`A board on this machine`}var OA=e=>e?e[0].toUpperCase()+e.slice(1):null;function kA({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,Y.jsx)(EA,{name:e?.user?.name||t||null,avatarUrl:e?.user?.avatarUrl,detail:DA(e),items:[...e?.buzzAvailable===!0?[{id:`buzz`,label:`Existing Buzz conversation`,icon:M_,onSelect:n,"data-sw-buzz-open":`true`}]:[],...i?[{id:`account`,label:`Account and security`,icon:ov,onSelect:()=>P(`/account`)},{id:`console`,label:`Workspace Console`,icon:uh,onSelect:()=>P(`/console`)}]:a?[{id:`settings`,label:`Settings`,icon:M_,onSelect:o,"data-sw-settings-open":`profile`}]:[],...e?.shareEnabled?[{id:`share`,label:`Share with your team...`,icon:uh,onSelect:()=>s(!0)}]:[],...e?.consoleUrl&&!e?.guest?[{id:`console`,label:`Workspace Console`,icon:uh,onSelect:()=>P(e.consoleUrl)}]:[],...e?.public&&typeof e.reportUrl==`string`&&e.reportUrl.startsWith(`mailto:`)?[{id:`report`,label:`Report this board`,icon:Jh,onSelect:()=>P(e.reportUrl)}]:[],...r?[r.resetItem]:[]],viewAs:r?.viewAs||null,side:c,align:l,showName:u,triggerClassName:d})}var AA=null,jA=new Set;function MA(e){e!==AA&&(AA=e,jA.forEach(e=>e()))}var NA=e=>(jA.add(e),()=>jA.delete(e));function PA(){return(0,J.useSyncExternalStore)(NA,()=>AA,()=>null)}var FA=[`full`,`panels`,`view`,`viewport`,`tight`],IA={pad:12,gap:6,zoneGap:20,tightGap:4,tightZoneGap:12,name:[200,176,152,128,104],journey:[160,112],journeyMax:240,agentPill:22},LA={width:384,min:368,max:560,share:.4};function RA(e){let t=t=>e>=FA.indexOf(t);return{panels:t(`panels`),view:t(`view`),viewport:t(`viewport`),tight:t(`tight`)}}function zA(e,t,n=RA(t).tight?IA.tightGap:IA.gap){let r=RA(t),i=e.filter(e=>e&&!(e.gone&&r[e.gone]));if(!i.length)return 0;let a=e=>e.at&&r[e.at]?e.compact:Array.isArray(e.full)?e.full[t]:e.full;return i.reduce((e,t)=>e+a(t),0)+n*(i.length-1)}function BA({text:e,title:t,viewports:n=[],capture:r=!1,status:i={kind:`dot`},viewer:a=!1,panels:o={comments:0,agent:!1,checks:!1},settings:s=!1,journey:c=null}){let l=(t,n)=>Math.ceil(e(String(t),n))+1,u={left:[],right:[]};u.left.push((e=>({id:e,full:1,gone:`viewport`}))(`divider`)),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`});let d=c?l(c,`ui`):0,f=e=>Math.min(d,IA.journey[Math.min(e,IA.journey.length-1)]);u.left.push({id:`view`,full:c?FA.map((e,t)=>41+f(t)+27):41+l(`Views`,`ui`),...c?{grow:FA.map((e,t)=>Math.max(0,Math.min(d,IA.journeyMax)-f(t)))}:{},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`)}),s&&u.right.push({id:`settings`,full:32});let p=12+l(o.comments,`count`),m=[{full:46+l(`Comments`,`ui`)+p,compact:36+p}];return o.agent&&m.push({full:40+l(`Agent`,`ui`)+IA.agentPill,compact:30}),o.checks&&m.push({full:40+l(`Checks`,`ui`),compact:30}),u.right.push({id:`panels`,full:m.reduce((e,t)=>e+t.full,6),compact:m.reduce((e,t)=>e+t.compact,6),at:`panels`}),{name:40+l(t,`name`),left:u.left,right:u.right}}function VA(e,t,n){let r=e.find(e=>e.id===`view`&&e.grow);return!r||RA(t).view?0:(Array.isArray(r.full)?r.full[t]-41-27:0)+Math.max(0,Math.min(r.grow[t],Math.floor(n)))}function HA({inner:e,name:t,left:n,right:r,config:i}){for(let a=0;a<FA.length;a+=1){let o=RA(a).tight,s=o?i.tightGap:i.gap,c=zA(n,a,s),l=e-(Math.min(t,i.name[a])+(c?s+c:0))-zA(r,a,s)-(o?i.tightZoneGap:i.zoneGap);if(l>=0)return{step:a,journey:VA(n,a,l)}}return null}function UA({width:e,name:t,left:n=[],right:r=[],panel:i=null,config:a=IA}){let o=Math.max(0,e-2*a.pad),s=FA.length-1,c=i?r.find(e=>e.id===`panels`):null,l=c?i-2*a.pad:0;if(c&&c.full<=l){let e=HA({inner:o,name:t,left:n,right:r.map(e=>e===c?{id:`panels`,full:l+a.pad}:e),config:a});if(e)return{...e,stretched:!0}}return HA({inner:o,name:t,left:n,right:r,config:a})||{step:s,journey:VA(n,s,0)}}var WA={name:`600 14px`,ui:`500 13px`,xs:`500 12px`,count:`600 11px`},GA;function KA(e,t){return typeof document>`u`||(GA||=document.createElement(`canvas`).getContext(`2d`),!GA)?e.length*8:(GA.font=`${WA[t]} ${getComputedStyle(document.body).fontFamily}`,GA.measureText(e).width)}function qA(e,t){let[n,r]=(0,J.useState)(()=>typeof window>`u`?1280:window.innerWidth);return(0,J.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}var JA=`bg-surface-2/60 text-fg ring-1 ring-line ring-inset hover:bg-surface-2`,YA=`flex shrink-0 items-center rounded-md border border-line bg-surface-2 p-0.5`,XA=`h-[26px] text-ui`,ZA=()=>(0,Y.jsx)(`span`,{className:`h-5 w-px shrink-0 bg-line`,"aria-hidden":`true`,"data-sw-toolbar-divider":`true`}),QA=4e3;function $A(e){let[t,n]=(0,J.useState)(!1),r=(0,J.useRef)(e.state);return(0,J.useEffect)(()=>{let t=r.current;if(r.current=e.state,!_A(t,e.state)){e.state!==`idle`&&n(!1);return}n(!0);let i=window.setTimeout(()=>n(!1),QA);return()=>window.clearTimeout(i)},[e.state]),e.state===`idle`&&t?`done`:e.state}var ej={working:`bg-accent text-accent-fg`,waiting:`bg-warn text-warn-fg`,done:`bg-ok text-ok-fg`};function tj({shown:e,count:t}){if(e===`idle`)return null;let n=t>1&&e!==`done`;return(0,Y.jsx)(`span`,{className:O(`tabular inline-flex shrink-0 items-center justify-center rounded-full text-[11px] leading-4 font-semibold`,n?`px-1.5`:`mx-1 h-2 w-2`,ej[e],e===`working`&&`motion-safe:animate-breathe`),"aria-hidden":`true`,"data-sw-agent-activity-mark":e,"data-sw-agent-activity-pulse":e===`working`?`true`:void 0,children:n?t:null})}function nj({shown:e,count:t,touch:n=!1}){if(e===`idle`)return null;let r=t>1&&e!==`done`;return(0,Y.jsx)(`span`,{className:O(`tabular pointer-events-none absolute flex items-center justify-center rounded-full font-semibold ring-2 ring-surface`,n?`top-2 right-2`:`-top-1 -right-1`,r?`h-3.5 min-w-3.5 px-0.5 text-[9px] leading-none`:`h-2 w-2`,ej[e],e===`working`&&`motion-safe:animate-breathe`),"aria-hidden":`true`,"data-sw-agent-activity-mark":e,"data-sw-agent-activity-pulse":e===`working`?`true`:void 0,children:r?t:null})}var rj=(e,t)=>e===`done`?[`Agent done`,t.text].filter(Boolean).join(`. `):t.text;function ij({labels:e,stretched:t,allOpen:n,panelHidden:r,chatAvailable:i,chatThread:a,reopenChat:o,checksOpen:s,canChecks:c,openChecks:l,closeChecks:u,updateParams:d,activity:f,shown:p,openAgentThread:m}){let h=!r&&!a&&!s,g=rj(p,f),v=!i&&!!g,y={"data-sw-agent-activity":p,"data-sw-agent-activity-count":f.count||void 0},b=O(XA,!e&&`px-2`,t&&`flex-1 basis-0`);return(0,Y.jsxs)(`div`,{className:O(YA,t&&`w-full`),role:`group`,"aria-label":`Side panel`,"data-sw-panel-switch":`true`,children:[(0,Y.jsx)(_,{content:`${h?`Hide`:`Show`} comments (${n} open)${v?`. ${g}`:``}`,side:`bottom`,children:(0,Y.jsxs)(Ie,{variant:`segment`,className:b,pressed:h,onPressedChange:()=>d({panel:r||a||s?null:`off`,chat:null,ha:null,checks:null,cv:null}),"aria-label":`Comments, ${n} open${v?`. ${g}`:``}`,"data-sw-panel-toggle":`true`,...i?{}:y,children:[(0,Y.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,Y.jsx)(Kg,{size:14,"aria-hidden":`true`}),v?(0,Y.jsx)(nj,{shown:p,count:f.count}):null]}),e?`Comments`:null,(0,Y.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:n})]})}),i?(0,Y.jsx)(_,{content:g||(a?`Close the agent chat`:`Chat with your agent about this board`),side:`bottom`,children:(0,Y.jsxs)(Ie,{variant:`segment`,className:b,pressed:!!a,"aria-label":g?`Agent. ${g}`:`Agent`,onPressedChange:()=>a?d({chat:null,ha:null}):f.target?m(f.target):o(),"data-sw-chat-toggle":`true`,...y,children:[(0,Y.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,Y.jsx)(I,{size:14,"aria-hidden":`true`}),e?null:(0,Y.jsx)(nj,{shown:p,count:f.count})]}),e?`Agent`:null,e?(0,Y.jsx)(tj,{shown:p,count:f.count}):null]})}):null,c?(0,Y.jsx)(_,{content:s?`Close the checks`:`Page checks: performance, accessibility, SEO`,side:`bottom`,align:`end`,children:(0,Y.jsxs)(Ie,{variant:`segment`,className:b,pressed:!!s,"aria-label":`Checks`,onPressedChange:()=>s?u():l(),"data-sw-checks-toggle":`true`,children:[(0,Y.jsx)(Jh,{size:14,"aria-hidden":`true`}),e?`Checks`:null]})}):null]})}function aj({wide:e,info:t,boardId:n,boards:r,data:i,localProjects:o,projectsError:s,localName:c,onPickBoard:l,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:p,openSettings:m,setShareOpen:h,modes:g,mode:_,setMode:v,viewNotice:y,canComment:b,comparePair:x,setMenuOpen:S,showLinks:C,toggleLinks:w,linksTip:T,brokenLinks:E,canCompare:D,toggleCompare:k,minimapOn:A,toggleMinimap:j,journeys:ee=[],journey:M,openJourney:N,closeJourney:F,canEditJourneys:I,startBuilder:L,openBrokenLinks:R,capture:z,busy:te,canCapture:V,setCaptureConfirm:ne,chatAvailable:H,chatThread:U,reopenChat:re,updateParams:ie,panelHidden:ae,checksOpen:W,allOpen:G,canChecks:se,openChecks:ce,closeChecks:le,setSheetOpen:ue,sidebarTitled:de,activity:fe={state:`idle`,count:0,text:``,target:null},openAgentThread:pe=()=>{}}){let me=$A(fe),he=r.find(e=>e.id===n)?.title||i?.board?.title||n,ge=t?.hosted&&t?.project?.url&&t.role!==`guest`?t.project:null,ve=!b&&t?.hosted&&t?.role===`viewer`,ye=(0,J.useRef)(null),xe=qA(ye,e),Ce=PA(),Te=z?.running?`running`:z?.state===`failed`&&z.error?`failed`:`dot`,Ee=z?.running&&z.total?`${z.done||0}/${z.total}`:`Capturing`,De=g.map(e=>e.label).join(`
|
|
34
|
+
`),Oe=y?.changes?.includes(`viewport`)?y:null,ke=(0,J.useMemo)(()=>UA({width:xe,panel:Ce,...BA({text:KA,title:he,viewports:De?De.split(`
|
|
35
|
+
`):[],capture:!!V,status:{kind:Te,progress:Ee},viewer:ve,panels:{comments:G,agent:!!H,checks:!!se},settings:!!p,journey:M?.name||null})}),[xe,Ce,he,De,V,Te,Ee,ve,G,H,se,p,M?.name]),Ae=RA(ke.step),je=!!(e&&ke.stretched),K=(0,Y.jsx)(kA,{info:t,localName:c,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:p,openSettings:m,setShareOpen:h}),Me=(0,Y.jsxs)($e,{value:n,onValueChange:e=>{if(!e.startsWith(`project/`))return l(e);let t=o.find(t=>`project/${t.id}`===e);t?.url&&t.running&&P(t.url)},children:[(0,Y.jsx)(Se,{size:e?`sm`:`touch`,className:e?O(`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`,ge&&`h-6`):`min-w-0 flex-1 border-transparent bg-transparent px-2 text-[15px] font-semibold shadow-none`,"aria-label":`Board: ${he}`,"data-sw-picker":`true`,children:(0,Y.jsx)(oe,{children:(0,Y.jsx)(`span`,{className:`block truncate`,children:he})})}),(0,Y.jsxs)(_e,{children:[(0,Y.jsxs)(be,{children:[o.length>1||ge?(0,Y.jsx)(Ne,{children:ge?ge.name:`This project`}):null,r.map(t=>(0,Y.jsx)(q,{value:t.id,children:e?`${t.title} · ${t.pageCount} pages`:t.title},t.id))]}),o.length>1?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(we,{}),(0,Y.jsxs)(be,{children:[(0,Y.jsx)(Ne,{children:`Local projects`}),o.map(e=>(0,Y.jsxs)(q,{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,Y.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,Y.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,Y.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,Y.jsx)(`h1`,{className:`sr-only`,children:`Shapewall`}),Me,ve?(0,Y.jsx)(iO,{compact:!0}):null,(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,className:`shrink-0 gap-1.5 px-2.5 text-fg`,onClick:()=>{le(),ue(!0)},"aria-label":`Comments, ${G} open`,"data-sw-panel-toggle":`true`,children:[(0,Y.jsx)(Kg,{size:18,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`tabular text-[13px] font-semibold`,children:G})]}),(0,Y.jsxs)(B,{size:`icon`,variant:`ghost`,className:`relative shrink-0 text-fg`,onClick:()=>S(!0),label:`${H?`More: agent, pages, views, screen size`:`More: pages, views, screen size`}${me===`idle`?``:`. ${rj(me,fe)}`}`,"data-sw-menu":`true`,"data-sw-agent-activity":me,"data-sw-agent-activity-count":fe.count||void 0,children:[(0,Y.jsx)(nj,{shown:me,count:fe.count,touch:!0}),(0,Y.jsx)(Ih,{size:19,"aria-hidden":`true`})]}),K]});let Pe=g.map(e=>{let t=e.id===`all`?w_:Bv(e.id);return{id:e.id,tooltip:Ae.viewport?e.label:null,label:Ae.viewport?(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(t,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.label})]}):e.label}}),Fe=(0,Y.jsx)(xA,{data:i,capture:z}),Ie=Ae.tight?`gap-1`:`gap-1.5`;return(0,Y.jsxs)(`header`,{ref:ye,className:O(`grid h-14 shrink-0 items-center border-b border-line bg-surface px-3`,Ae.tight?`gap-x-3`:`gap-x-5`,`grid-cols-[auto_minmax(0,1fr)]`),"data-sw-toolbar":`full`,"data-sw-toolbar-fit":FA[ke.step],children:[(0,Y.jsxs)(`h1`,{className:`sr-only`,children:[`Shapewall: `,he]}),(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-center`,Ie),"data-sw-toolbar-zone":`left`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center`,style:{maxWidth:IA.name[ke.step]},children:[ge&&!de?(0,Y.jsx)(aO,{project:ge}):null,Me]}),V?null:Fe,Ae.viewport?null:(0,Y.jsx)(ZA,{}),g.length>1?(0,Y.jsx)(`span`,{className:O(`shrink-0 rounded-md`,Oe&&`animate-flash`),"data-sw-viewport-flash":Oe?Oe.to:void 0,children:(0,Y.jsx)(Xe,{label:`Screen size`,options:Pe,value:_,onChange:v,itemClassName:O(`h-[26px]`,Ae.viewport&&`px-2`)})},Oe?.at||`still`):null,(0,Y.jsx)(bA,{journeys:ee,journey:M,openJourney:N,closeJourney:F,canEditJourneys:I,startBuilder:L,showLinks:C,toggleLinks:w,linksTip:T,brokenLinks:E,openBrokenLinks:R,canCompare:D,comparePair:x,toggleCompare:k,minimapOn:A,toggleMinimap:j,compact:Ae.view,boxed:JA,labelMax:ke.journey||IA.journey[Math.min(ke.step,IA.journey.length-1)]}),V?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{variant:`ghost`,className:O(`shrink-0`,JA),disabled:z?.running||te,onClick:()=>ne(!0),label:`Capture now`,tooltip:`Recapture every page`,side:`bottom`,"data-sw-capture":`true`,children:(0,Y.jsx)(fh,{size:16,"aria-hidden":`true`})}),Fe]}):null]}),(0,Y.jsxs)(`div`,{className:O(`flex min-w-0 items-center justify-end`,Ie),"data-sw-toolbar-zone":`right`,children:[ve?(0,Y.jsx)(iO,{}):null,p?(0,Y.jsx)(B,{variant:`ghost`,className:O(`shrink-0`,JA),onClick:m,label:`Agent settings`,tooltip:`Agent settings: which agent the chat uses`,side:`bottom`,"data-sw-settings-open":`true`,children:(0,Y.jsx)(M_,{size:16,"aria-hidden":`true`})}):null,(0,Y.jsx)(`div`,{className:O(`shrink-0`,je&&`-mr-3 px-3`),style:je?{width:Ce}:void 0,"data-sw-panel-tabs":je?`stretched`:`compact`,children:(0,Y.jsx)(ij,{labels:je||!Ae.panels,stretched:je,allOpen:G,panelHidden:ae,chatAvailable:H,chatThread:U,reopenChat:re,checksOpen:W,canChecks:se,openChecks:ce,closeChecks:le,updateParams:ie,activity:fe,shown:me,openAgentThread:pe})})]})]})}function oj({menuOpen:e,setMenuOpen:t,data:n,chatAvailable:r,activity:i,chatThread:o,reopenChat:s,groupedPages:c,jumpToPage:l,modes:u,mode:d,setMode:f,journeys:p,journey:m,canEditJourneys:h,openJourney:g,closeJourney:_,startBuilder:v,canChecks:y,openChecks:b,showLinks:x,toggleLinks:S,brokenLinks:C,canCompare:w,comparePair:T,toggleCompare:E,settingsAvailable:D,openSettings:k,capture:A,canCapture:j,busy:ee,setCaptureConfirm:M,hostedAgents:P=null}){let F=`mb-1.5 flex items-center gap-1 text-[11px] font-medium tracking-wide text-faint uppercase`,[L,R]=(0,J.useState)(``),z=p.length>8,te=z?L.trim().toLowerCase():``,B=te?p.filter(e=>e.name.toLowerCase().includes(te)):p,V=e=>{t(!1),e?g(e):_()};return(0,Y.jsx)(N,{open:e,onClose:()=>t(!1),title:n?.board?.title||`Board`,children:(0,Y.jsxs)(`div`,{className:`space-y-5 p-5`,children:[u.length>1?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:F,children:`Screen size`}),(0,Y.jsx)(Xe,{label:`Screen size`,options:u,value:d,onChange:e=>{f(e),t(!1)},large:!0})]}):null,r?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:o?`default`:`secondary`,onClick:()=>{t(!1),s()},"data-sw-chat-toggle":`true`,children:[(0,Y.jsx)(I,{size:16,"aria-hidden":`true`}),` Chat with your agent`]}):null,P?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),P.open()},"data-sw-hosted-agent-open":`true`,children:[(0,Y.jsx)(I,{size:16,"aria-hidden":`true`}),` Agents`,P.list?.agents?.length?(0,Y.jsxs)(`span`,{className:`ml-auto text-xs font-normal text-muted`,children:[P.list.agents.filter(e=>e.state!==`offline`).length,` of `,P.list.agents.length,` online`]}):null]}):null,i?.text?(0,Y.jsxs)(`p`,{className:O(`-mt-1 flex items-start gap-2 text-xs`,i.state===`waiting`?`text-fg`:`text-muted`),role:`status`,"data-sw-agent-activity-line":i.state,children:[(0,Y.jsx)(`span`,{className:O(`mt-1 h-2 w-2 shrink-0 rounded-full`,i.state===`waiting`?`bg-warn`:`bg-accent`),"aria-hidden":`true`}),i.text]}):null,(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{className:F,children:[(0,Y.jsx)(Mg,{size:12,"aria-hidden":`true`}),` Go to a page`]}),(0,Y.jsx)(Tk,{groups:c,onPick:e=>{t(!1),l(e)}})]}),p.length||h?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:F,children:`Journeys`}),z?(0,Y.jsx)(it,{size:`touch`,icon:E_,wrapperClassName:`mb-1.5`,value:L,onChange:e=>R(e.target.value),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-views-filter":`true`}):null,(0,Y.jsxs)(`div`,{className:z?`flex max-h-80 flex-col gap-1.5 overflow-y-auto`:`flex flex-col gap-1.5`,role:`radiogroup`,"aria-label":`Journeys`,"data-sw-journey-menu":`true`,children:[p.length&&!te?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,role:`radio`,"aria-checked":!m,variant:m?`secondary`:`default`,onClick:()=>V(null),"data-sw-journey-open":`none`,children:[(0,Y.jsx)(Bh,{size:15,"aria-hidden":`true`}),` None`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs opacity-70`,children:`All pages`})]}):null,B.map(e=>(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,role:`radio`,"aria-checked":m?.id===e.id,variant:m?.id===e.id?`default`:`secondary`,onClick:()=>V(e.id),"data-sw-journey-open":e.id,children:[(0,Y.jsx)(S_,{size:15,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs tabular-nums opacity-70`,children:yA(e)})]},e.id)),te&&!B.length?(0,Y.jsx)(`p`,{className:`px-1 text-sm text-muted`,children:`No journey matches.`}):null,h?(0,Y.jsxs)(a,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{t(!1),v()},children:[(0,Y.jsx)(f_,{size:15,"aria-hidden":`true`}),` New journey`]}):null]})]}):null,(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`p`,{className:F,children:`Show`}),y?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),b()},"data-sw-checks-toggle":`true`,children:[(0,Y.jsx)(Jh,{size:16,"aria-hidden":`true`}),`Checks`]}):null,(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,"aria-pressed":x,variant:x?`default`:`secondary`,onClick:()=>{t(!1),S()},"data-sw-links-toggle":`true`,children:[(0,Y.jsx)(uv,{size:15,"aria-hidden":`true`}),` `,x?`Hide links between pages`:`Show links between pages`,(0,Y.jsx)(uA,{count:C.length})]}),w?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,"aria-pressed":!!T,variant:T?`default`:`secondary`,onClick:()=>{t(!1),E()},"data-sw-compare-toggle":`true`,children:[(0,Y.jsx)(Qh,{size:15,"aria-hidden":`true`}),` `,T?`Leave compare mode`:`Compare environments`]}):null,D?(0,Y.jsxs)(a,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),k()},"data-sw-settings-open":`true`,children:[(0,Y.jsx)(M_,{size:15,"aria-hidden":`true`}),` Agent settings`]}):null]}),(0,Y.jsxs)(`div`,{className:`space-y-2 border-t border-line pt-4`,children:[(0,Y.jsx)(SA,{data:n,capture:A}),j?(0,Y.jsxs)(a,{size:`touch`,className:`w-full`,disabled:A?.running||ee,onClick:()=>{t(!1),M(!0)},"data-sw-capture":`true`,children:[(0,Y.jsx)(fh,{size:15,"aria-hidden":`true`}),` Capture now`]}):null]})]})})}function sj({notice:e,onUndo:t,modeLabel:n,compact:r=!1,inSheet:i=!1}){let o=aC(e,n,{compact:r});return o?(0,Y.jsxs)(`div`,{className:O(`flex items-center gap-2 text-xs text-fg`,i?`w-full border-b border-line bg-surface-2 px-4 py-2`:`pointer-events-auto w-max max-w-full rounded-lg border border-line bg-surface py-1 pr-1 pl-3 shadow-pop`),role:`status`,"data-sw-view-notice":e.changes.join(` `),"data-sw-viewport-notice":e.changes.includes(`viewport`)?e.to:void 0,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:o.text}),(0,Y.jsx)(a,{size:r?`touch`:`xs`,variant:`secondary`,className:`shrink-0`,onClick:t,"data-sw-viewport-notice-back":`true`,children:o.back})]}):null}function cj({wide:e,commentMode:t,canComment:n,composing:r=!1,parkedDraft:i=null,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,viewNotice:y,undoViewNotice:b,noticeInSheet:x=!1,covered:S=!1,dismissTip:C,modes:w,comparePair:T}){let E=e=>w.find(t=>t.id===e)?.label||e,D=aC(y,E),O=!!D&&!x;if(!e&&S)return null;let k=e?`Scroll or drag to move, Ctrl+scroll or pinch to zoom. Click a page for its actions${n&&!T?`: Comment is first. Or press C, or use the Comment tool below`:``}.`:`Pinch to zoom. Tap a page for its actions${n&&!T?`: Comment is first. Or use the comment tool below`:``}.`;return(0,Y.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:[o&&!s&&!c&&yv(l?.links,u,d)>150?(0,Y.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,Y.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,Y.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,Y.jsx)(a,{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&&!r&&!o&&!_&&!v&&!D?(0,Y.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,Y.jsx)(Sg,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:k}),(0,Y.jsx)(B,{size:e?`icon-xs`:`icon`,variant:`ghost`,className:`shrink-0 rounded-full shadow-none`,onClick:C,label:`Dismiss the tip`,"data-sw-tip-dismiss":`true`,children:(0,Y.jsx)(se,{size:14,"aria-hidden":`true`})})]}):null,i?(0,Y.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-1 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs font-medium text-fg shadow-pop`,role:`status`,"data-sw-draft-kept":`true`,children:[(0,Y.jsx)(Wg,{size:13,className:`mr-1 shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Draft kept for `,i.title]}),(0,Y.jsx)(a,{size:`xs`,variant:`soft`,className:`ml-1 shrink-0 rounded-full`,onClick:i.onReopen,"data-sw-draft-reopen":`true`,children:`Reopen`}),(0,Y.jsx)(a,{size:`xs`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:i.onDiscard,"data-sw-draft-discard":`true`,children:`Discard`})]}):null,O?(0,Y.jsx)(sj,{notice:y,onUndo:b,modeLabel:E,compact:!e}):null]})}var lj=e=>e?.tool?`${e.owner}\n${e.key}`:``;function uj(e){let t=Yx(lj);return e&&!!t}function dj({flow:e,canvasRef:t,targets:n,focusFor:r,shotFor:i}){let a=Yx(lj),o=(0,J.useRef)(null),s=(0,J.useRef)({targets:n,focusFor:r,shotFor:i,active:a});return s.current={targets:n,focusFor:r,shotFor:i,active:a},(0,J.useEffect)(()=>{if(!a){o.current&&e.setViewport(o.current,{duration:UO(400)}),o.current=null;return}let[n,r]=a.split(`
|
|
36
|
+
`),{targetId:i,viewport:c}=Hv(r),l=s.current.targets?.[i],u=l?.frames.find(e=>e.viewport===c);if(!u)return;let d=!1;return VO(s.current.shotFor(i,c)).catch(()=>1).then(r=>{if(d||s.current.active!==a)return;let i=Math.min(1,Math.max(0,s.current.focusFor(n))),c=Math.min(1,Math.max(.25,r,i+.08)),f={x:l.x+u.x,y:l.y+u.y,width:u.w,height:u.h*c},p=t.current?.getBoundingClientRect();if(ak(f,e.getViewport(),p))return;let m=lk(f,p,i/c);m&&(o.current||=e.getViewport(),e.setViewport(m,{duration:UO(450)}))}),()=>{d=!0}},[a,e,t]),null}function fj({titleFor:e}){let t=Yx(lj);if(!t)return null;let[n,r]=t.split(`
|
|
37
|
+
`),{targetId:i,viewport:a}=Hv(r);return(0,Y.jsx)(`div`,{className:`pointer-events-none relative z-30 flex max-w-full justify-center`,"data-sw-drawing-mode":`true`,children:(0,Y.jsx)(hS,{owner:n,title:e?.(i,a)||``})})}var pj=[`select`,`hand`,`comment`,`draw`,`text`],mj=new Set([`select`,`hand`]);function hj({wide:e=!1,commenting:t=!1,draw:n=!1,liveBoard:r=!1,livePage:i=!1}={}){let a={select:!0,hand:e,comment:t,draw:t&&n,text:e&&r&&(t||i)};return pj.filter(e=>a[e])}function gj({drawing:e=!1,commentMode:t=!1,drawArmed:n=!1,selecting:r=!1,hand:i=!1}={}){return e||t&&n?`draw`:t?`comment`:r?`text`:i?`hand`:`select`}function _j(e){return e.includes(`hand`)&&e.some(e=>!mj.has(e))}var vj={v:`select`,h:`hand`};function yj(e,{tools:t=pj,busy:n=!1,handled:r=!1}={}){if(!e||r||n||e.altKey||e.ctrlKey||e.metaKey||e.repeat)return null;let i=vj[String(e.key||``).toLowerCase()];if(!i||!t.includes(i))return null;let a=e.target;return a&&(OC(a)||a.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`,`IFRAME`].includes(a.tagName))?null:i}var bj={select:{label:`Select`,tip:`Select: click a page or a pin`,keys:[`V`],shortcut:`V`,icon:i_},hand:{label:`Hand`,tip:`Hand: drag anywhere to move, opens nothing`,keys:[`H`],shortcut:`H`,icon:cg},comment:{label:`Comment`,tip:`Comment: click a page to pin a note`,keys:[`C`],shortcut:`C`,icon:Wg},draw:{label:`Draw`,tip:`Draw on a page: box, arrow or pen`,keys:[],icon:ch},text:{label:`Select text`,tip:`Select text on the selected live page`,keys:[],icon:W_}};function xj({touch:e,children:t}){return(0,Y.jsx)(`div`,{className:O(`pointer-events-none absolute inset-x-0 bottom-0 flex flex-col items-center gap-2`,e?`px-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))]`:`px-3 pb-3`),"data-sw-tool-dock":`true`,children:t})}function Sj({tools:e,active:t,onTool:n,touch:r,shift:i=0}){let o=(0,J.useRef)(null),s=_j(e);return(0,Y.jsx)(`div`,{ref:o,className:O(`pointer-events-auto relative z-30 flex items-center gap-0.5 rounded-lg border border-line bg-surface/95 p-0.5 shadow-pop backdrop-blur`,r&&`rounded-xl`),style:i?{transform:`translateX(${i}px)`}:void 0,role:`toolbar`,"aria-label":`Board tools`,"aria-orientation":`horizontal`,onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Array.from(o.current?.querySelectorAll(`button[data-sw-tool]`)||[]),n=t.indexOf(document.activeElement);if(n<0)return;let r=null;e.key===`ArrowRight`||e.key===`ArrowDown`?r=(n+1)%t.length:e.key===`ArrowLeft`||e.key===`ArrowUp`?r=(n-1+t.length)%t.length:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),e.stopPropagation(),t[r].focus())},"data-sw-tools":t,children:e.map(e=>{let i=bj[e],o=e===t,c=o&&mj.has(e),l=(0,Y.jsx)(a,{variant:o&&!c?`default`:`ghost`,size:r?`icon`:`icon-sm`,className:O(`shadow-none focus-visible:outline-offset-1`,r&&`rounded-lg`,!o&&`text-fg/80 hover:text-fg`,c&&`bg-surface-2 text-fg ring-1 ring-line-strong/70 ring-inset hover:bg-surface-2`),"data-sw-tool-look":o?c?`quiet`:`accent`:void 0,"aria-label":i.label,"aria-pressed":o,"aria-keyshortcuts":i.shortcut,tabIndex:o?0:-1,onClick:()=>n(e),"data-sw-tool":e,"data-sw-comment-mode":e===`comment`?`true`:void 0,children:(0,Y.jsx)(i.icon,{size:r?19:16,"aria-hidden":`true`})},e),u=r?l:(0,Y.jsx)(_,{content:(0,Y.jsx)(vx,{label:i.tip,keys:i.keys}),side:`top`,children:l},e);return e===`hand`&&s?(0,Y.jsxs)(J.Fragment,{children:[u,(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px shrink-0 bg-line`,"aria-hidden":`true`,"data-sw-tools-divider":`true`})]},e):u})})}var Cj=`pointer-events-auto relative z-30 flex w-max max-w-full items-center gap-2 rounded-[18px] py-0.5 pr-0.5 pl-3 text-xs font-medium shadow-pop`;function wj({wide:e,picking:t=null,composing:n=null,selectText:r=null,onDone:i}){let o=ux(e=>!!e.readingKey);if(n)return(0,Y.jsxs)(`div`,{className:O(Cj,`border border-line bg-surface text-fg`),role:`status`,"data-sw-tool-note":`true`,"data-sw-comment-hint":`composing`,children:[(0,Y.jsx)(Wg,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,"data-sw-comment-hint-target":`true`,children:[(0,Y.jsx)(`span`,{className:`text-muted`,children:`Commenting on`}),` `,n.target]}),(0,Y.jsx)(a,{size:`xs`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:n.onCancel,"data-sw-comment-hint-cancel":`true`,children:`Cancel (Esc)`})]});if(t){let n=t.draw?ch:Wg,r=e?`Click`:`Tap`,o=t.draw?null:t.page,s=t.draw?`${r} a page to draw on it. The drawing goes with your comment.`:t.live?`${r} 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.`;return(0,Y.jsxs)(`div`,{className:O(Cj,`bg-accent text-accent-fg`),role:`status`,"data-sw-tool-note":`true`,"data-sw-comment-hint":t.draw?`draw`:t.live?`element`:`page`,"data-sw-comment-hint-page":o?o.key:void 0,children:[(0,Y.jsx)(n,{size:13,className:`shrink-0`,"aria-hidden":`true`}),o?(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r,` where the comment goes on `,(0,Y.jsx)(`span`,{className:`font-semibold`,children:o.title}),o.keyboard?`, or press Enter`:null]}):(0,Y.jsx)(`span`,{className:`min-w-0`,children:s}),(0,Y.jsxs)(a,{size:e?`xs`:`touch`,variant:`inverse`,className:`shrink-0 rounded-full`,onClick:i,"data-sw-comment-hint-done":`true`,children:[`Done`,e?` (Esc)`:``]})]})}return r?(0,Y.jsxs)(`div`,{className:O(Cj,`border border-line bg-surface text-fg`),role:`status`,"data-sw-tool-note":`true`,"data-sw-select-text-note":o?`reading`:`armed`,children:[(0,Y.jsx)(W_,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:o?`Selecting text on ${r.title}. Move the pointer off the page to scroll and zoom the board again.`:`Select text is on for ${r.title}: click the page, then select and copy.`}),(0,Y.jsx)(a,{size:`xs`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:r.onDone,"data-sw-select-text-done":`true`,children:`Done`})]}):null}function Tj(e){let[t,n]=(0,J.useState)(()=>typeof window>`u`?1280:window.innerWidth);return(0,J.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>n(Math.round(t.getBoundingClientRect().width));if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function Ej(e,t){let[n,r]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{let n=e.current;if(!t||!n){r(null);return}let i=()=>{let e=Math.round(n.getBoundingClientRect().top),t=window.innerHeight;r(n=>n&&n.canvasTop===e&&n.windowHeight===t?n:{canvasTop:e,windowHeight:t})};i(),window.addEventListener(`resize`,i);let a=typeof ResizeObserver>`u`?null:new ResizeObserver(i);return a?.observe(n),()=>{window.removeEventListener(`resize`,i),a?.disconnect()}},[e,t]),n}function Dj(e){let[t,n]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{let t=typeof window>`u`?null:window.visualViewport;if(!e||!t){n(!1);return}let r=()=>n(window.innerHeight-t.height>120);return r(),t.addEventListener(`resize`,r),()=>t.removeEventListener(`resize`,r)},[e]),t}var Oj={margin:12,gap:8,zoomFull:197,zoomCompact:122,minimap:168,frame:6,between:2,button:32,touchMargin:8,touchButton:44,fit:44},kj=600+2*(Oj.minimap+Oj.margin+Oj.gap);function Aj(e,t=!1,n=!1){return e<=0?0:Oj.frame+e*(t?Oj.touchButton:Oj.button)+(e-1)*Oj.between+(n?5+Oj.between:0)}function jj({width:e,tools:t,left:n=[],right:r=0,margin:i=Oj.margin,gap:a=Oj.gap}){let o=(e-t)/2,s=n.length?n:[0],c=[];for(let e of r?[!0,!1]:[!1])s.forEach((t,n)=>{(t||!e||s.length===1)&&c.push({size:t,index:n,keepRight:e})});let l=n=>({min:i+(n.size?n.size+a:0),max:e-i-(n.keepRight?r+a:0)-t});for(let e of c){let{min:t,max:n}=l(e);if(!(t>n))return{shift:Math.round(Math.min(n,Math.max(t,o))-o),compact:e.index,right:e.keepRight}}let u=c[c.length-1];return{shift:Math.round(l(u).min-o),compact:u.index,right:!1}}function Mj(){let e=document.querySelector(`[data-sw-composer-popover]`);e&&(e.setAttribute(`data-sw-composer-nudged`,String(Date.now())),HO()||e.animate?.([{translate:`0`},{translate:`-6px`},{translate:`5px`},{translate:`-3px`},{translate:`0`}],{duration:280,easing:`ease-out`}),e.querySelector(`[data-sw-comment-input]`)?.focus({preventScroll:!0}))}function Nj(){let[e,t]=(0,J.useState)(null),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{e||r(!1)},[e]),(0,J.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 Pj(e,t){let n=!!e?.untilSheet;(0,J.useEffect)(()=>{if(!n)return;let e=()=>{document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)&&t(e=>e?.untilSheet?null:e)};e();let r=new MutationObserver(e);return r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`]}),()=>r.disconnect()},[n,t])}function Fj({toast:e,setToast:t,onHold:n,wide:r}){return Pj(e,t),e?(0,Y.jsxs)(`div`,{onMouseEnter:()=>n?.(!0),onMouseLeave:()=>n?.(!1),onFocus:()=>n?.(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||n?.(!1)},className:`pointer-events-auto relative z-[80] flex w-max max-w-full 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`,role:`status`,"data-sw-toast":`true`,children:[(0,Y.jsx)(`span`,{className:`min-w-0`,children:e.text}),e.undo?(0,Y.jsx)(a,{size:r?`xs`:`touch`,variant:`inverse`,onClick:()=>{e.undo(),t(null)},"data-sw-toast-undo":`true`,children:`Undo`}):null,(0,Y.jsx)(B,{size:r?`icon-xs`:`icon`,variant:`inverse`,onClick:()=>t(null),label:`Dismiss`,children:(0,Y.jsx)(se,{size:13,"aria-hidden":`true`})})]},e.at):null}function Ij({notice:e,setNotice:t,wide:n}){return e?(0,Y.jsxs)(`div`,{className:O(`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,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text}),(0,Y.jsx)(a,{variant:`ghost`,size:n?`xs`:`touch`,onClick:()=>t(null),children:`Dismiss`})]}):null}var Lj=`https://shapewall.com/docs/where-to-run#where-the-work-happens`,Rj={approval:`needs your OK`,"needs-human":`needs a person`,"branch-ready":`fix ready on a branch`},zj=`flex min-h-11 w-full items-center gap-2 rounded-md border border-line bg-surface px-2.5 py-1.5 text-left text-sm text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent lg:min-h-9`;function Bj({title:e,items:t,tone:n,note:r,onOpen:i,hook:a}){return t.length?(0,Y.jsxs)(`section`,{className:`space-y-1.5`,"data-sw-hosted-agent-list":a,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-semibold text-muted`,children:e}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:t.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:zj,"data-sw-hosted-agent-item":e.id,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${n}`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),r(e)?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:r(e)}):null]})},e.id))})]}):null}function Vj({mode:e}){return(0,Y.jsx)(e===`none`?Bh:e===`auto`?I_:Xh,{size:12,className:`mt-0.5 shrink-0`,"aria-hidden":`true`})}function Hj({label:e,ids:t,nameOf:n,onOpen:r,hook:i,tone:a}){return t.length?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,"data-sw-hosted-agent-comments":i,children:[(0,Y.jsx)(`span`,{className:`text-[11px] text-muted`,children:e}),t.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:O(`inline-flex min-h-11 max-w-full items-center rounded-full border px-2 text-xs font-medium outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent lg:min-h-6`,a),"data-sw-hosted-agent-comment":e,children:(0,Y.jsx)(`span`,{className:`truncate`,children:n(e)})},e))]}):null}function Uj({agent:e,nameOf:t,onOpen:n,onChat:r}){let i=e.state===`offline`&&e.queued.length>0,o=!!(r&&e.link?.connected&&e.link.chats),[s,c]=(0,J.useState)(!1),l=e.edits?.mode||`none`,u=fE(e),d=(e.elsewhere?.working||0)+(e.elsewhere?.queued||0);return(0,Y.jsxs)(`li`,{className:`space-y-1.5 rounded-lg border border-line bg-surface p-2.5`,"data-sw-hosted-agent-row":e.id,"data-sw-hosted-agent-name":e.name,"data-sw-agent-state":e.state,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(QT,{label:e.name,state:tE[e.state],icon:e.icon,tint:e.tint,logo:e.logo,className:`mt-0.5`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-sm`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),e.isDefault?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-line px-1.5 text-[10px] leading-4 font-medium text-muted`,"data-sw-agent-default":`true`,children:`Default`}):null]}),(0,Y.jsxs)(`p`,{className:O(`text-xs`,i?`text-fg`:`text-muted`),"data-sw-hosted-agent-state":!0,children:[nE(e),e.machine?` · ${e.machine}`:``]}),u?(0,Y.jsxs)(`p`,{className:`flex min-w-0 items-start gap-1 text-xs text-muted`,"data-sw-hosted-agent-mode":l,children:[(0,Y.jsx)(Vj,{mode:l}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:l===`none`?`${u}. No edits, no commands.`:u})]}):null]}),o?(0,Y.jsxs)(a,{size:`sm`,variant:e.chat?.ok?`default`:`secondary`,className:`min-h-11 shrink-0 lg:min-h-8`,disabled:!e.chat?.ok||s,onClick:async()=>{c(!0);try{await r(e)}finally{c(!1)}},"aria-label":`Chat with ${e.name}`,"data-sw-hosted-agent-chat":e.id,children:[(0,Y.jsx)(Kg,{size:14,"aria-hidden":`true`}),` Chat`]}):null]}),o&&(e.chat?.ok?l!==`none`:e.canSend)?(0,Y.jsx)(`p`,{className:`text-[11px] text-muted`,"data-sw-hosted-agent-chat-note":e.chat?.ok?`ok`:e.chat?.code||`no`,children:e.chat?.ok?`Chat reads the project and answers. A fix starts from a comment: Fix with `+e.name+`.`:e.chat?.code===`agent_offline`?`${e.name} is offline: chat needs it online. A comment sent to it waits.`:e.chat?.reason}):null,(0,Y.jsx)(Hj,{label:`Working on`,ids:e.working,nameOf:t,onOpen:n,hook:`working`,tone:`border-accent/40 bg-accent/10 text-fg`}),(0,Y.jsx)(Hj,{label:i?`Waiting for it`:`Next`,ids:e.queued,nameOf:t,onOpen:n,hook:`queued`,tone:i?`border-warn/50 bg-warn/10 text-fg`:`border-line bg-surface text-fg`}),d?(0,Y.jsxs)(`p`,{className:`text-[11px] text-muted`,children:[d===1?`1 more comment`:`${d} more comments`,` on other boards of this project.`]}):null,(0,Y.jsxs)(`p`,{className:`text-[11px] text-muted`,"data-sw-hosted-agent-audience":e.audience.kind,children:[e.canSend?`Takes work from: ${Wj(e.audience.text)}.`:o?String(e.reason||``).replace(`can send work to`,`can use`):e.reason,e.canSend&&e.audience.inherited?` (As before 0.4.0.)`:``]})]})}var Wj=e=>/^(Only|Everyone)/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e;function Gj({agents:e=null,listening:t=null,activity:n,approvals:r=0,titleOf:i=()=>``,manageUrl:a=null,onOpenComment:o,onClose:s,heading:c=!0,onChat:l=null,onBoardChat:u=null,admin:d=!1}){let f=e?.agents||[],p=!!e,m=p?f.some(e=>e.state!==`offline`):!!t?.online,h=typeof window>`u`?``:window.location.origin,g=e=>{let t=i(e);return t?`#${e} ${t}`:`#${e}`},_=e?.unassigned||[],v=f.some(e=>e.working.length||e.queued.length)||_.length;return(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-sw-hosted-agent":`true`,children:[c?(0,Y.jsx)(MC,{icon:I,title:`Agents`,onClose:s,closeLabel:`Close the agent panel`,closeProps:{"data-sw-hosted-agent-close":`true`}}):null,(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto border-t border-line p-3`,children:[f.length?(0,Y.jsxs)(`section`,{className:`space-y-1.5`,"data-sw-hosted-agent-listening":m?`online`:`none`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`flex-1 text-xs font-semibold text-muted`,role:`status`,children:m?`Agents of this project`:`No agent is online`}),a?(0,Y.jsxs)(`a`,{href:a,className:`inline-flex min-h-11 items-center gap-1 text-xs font-medium text-accent underline-offset-2 hover:underline lg:min-h-0`,"data-sw-hosted-agent-manage":`true`,children:[(0,Y.jsx)(A_,{size:12,"aria-hidden":`true`}),` Manage`]}):null]}),m?null:(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Comments sent to an agent wait until it is back. Nothing is lost.`}),(0,Y.jsx)(`ul`,{className:`space-y-1.5`,"data-sw-hosted-agent-rows":!0,children:f.map(e=>(0,Y.jsx)(Uj,{agent:e,nameOf:g,onOpen:o,onChat:l},e.id))}),u&&f.some(e=>e.link?.connected&&e.link.chats)?(0,Y.jsxs)(`button`,{type:`button`,onClick:u,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-accent underline-offset-2 outline-none hover:underline focus-visible:outline-2 focus-visible:outline-accent lg:min-h-0`,"data-sw-hosted-agent-board-chat":`true`,children:[(0,Y.jsx)(Kg,{size:12,"aria-hidden":`true`}),` Open the board chat (everyone in the workspace reads it)`]}):null]}):(0,Y.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface-2/60 p-3 text-sm`,role:`status`,"data-sw-hosted-agent-listening":m?`online`:`none`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${m?`bg-ok`:`bg-faint`}`,"aria-hidden":`true`}),m?`Agent online: ${t?.name||`agent`}`:`No agent is connected to this project`]}),m?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[`Last heard `,A(t.lastSeenAt),`.`]}):(0,Y.jsxs)(Y.Fragment,{children:[d?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Comments sent to an agent wait until one connects. To chat with your coding agent here, run this in the project's folder, on the machine that has the code:`}),(0,Y.jsxs)(`code`,{className:`mt-1.5 block rounded bg-surface px-2 py-1.5 font-mono text-xs break-all text-fg`,"data-sw-hosted-agent-command":`connect`,children:[`shapewall agent connect --remote `,h]}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs text-muted`,children:`It reads and answers only. For an agent that fixes the comments sent to it, with a project token that may take work, run:`}),(0,Y.jsxs)(`code`,{className:`mt-1.5 block rounded bg-surface px-2 py-1.5 font-mono text-xs break-all text-fg`,"data-sw-hosted-agent-command":`watch`,children:[`shapewall watch --remote `,h]})]}):(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Comments sent to an agent wait until one connects. An admin of this workspace connects one from the machine that has the code.`}),(0,Y.jsxs)(`span`,{className:`mt-1.5 flex flex-wrap gap-x-3`,children:[(0,Y.jsx)(`a`,{href:Lj,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center text-xs font-medium text-accent underline-offset-2 hover:underline lg:min-h-0`,"data-sw-hosted-agent-docs":`true`,children:`Where the agent runs`}),a?(0,Y.jsx)(`a`,{href:a,className:`inline-flex min-h-11 items-center text-xs font-medium text-accent underline-offset-2 hover:underline lg:min-h-0`,"data-sw-hosted-agent-manage":`true`,children:`Connect an agent`}):null]})]})]}),_.length?(0,Y.jsxs)(`section`,{className:`space-y-1.5`,"data-sw-hosted-agent-list":`unassigned`,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-semibold text-muted`,children:`Waiting for any agent`}),(0,Y.jsx)(Hj,{label:``,ids:_,nameOf:g,onOpen:o,hook:`unassigned`,tone:`border-line bg-surface text-fg`})]}):null,r?(0,Y.jsxs)(`p`,{className:`rounded-lg border border-warn/40 bg-warn/10 px-3 py-2 text-xs text-fg`,"data-sw-hosted-agent-approvals":r,children:[r===1?`A request waits`:`${r} requests wait`,` for your OK: see the strip at the top of the board.`]}):null,(0,Y.jsx)(Bj,{title:`Needs you`,hook:`waiting`,items:n.waiting,tone:`bg-warn`,note:e=>Rj[e.why]||``,onOpen:o}),p?null:(0,Y.jsx)(Bj,{title:`Working`,hook:`working`,items:n.working,tone:`bg-accent`,note:()=>``,onOpen:o}),!n.waiting.length&&!n.working.length&&!v?(0,Y.jsx)(`p`,{className:`text-xs text-muted`,"data-sw-hosted-agent-idle":`true`,children:`Nothing is running, and nothing waits for you. To hand a comment to an agent, open it and choose Send to agent.`}):null]})]})}var Kj=(0,J.lazy)(()=>AD(()=>import(`./ChecksPanel-DRFcFhCj.js`),__vite__mapDeps([4,1,2,3,5,6]),import.meta.url)),qj=(0,J.lazy)(()=>AD(()=>import(`./BoardChat-BawjlTc7.js`),__vite__mapDeps([7,1,2,8,5,3,6]),import.meta.url));function Jj({wide:e,checksOpen:t,checksProps:n,chatThread:r,chatProps:i,panelHidden:a,panelProps:o,updateParams:s,hostedAgent:c=null}){return e&&t?(0,Y.jsx)(rM,{panel:`checks`,"aria-label":`Checks`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{className:`p-4 text-sm text-muted`,children:`Loading checks…`}),children:(0,Y.jsx)(Kj,{...n})})},`checks`):e&&r?(0,Y.jsx)(rM,{panel:`agent`,"aria-label":`Agent`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(hv,{}),children:(0,Y.jsx)(qj,{...i,onClose:()=>s({chat:null})})})},`agent`):e&&c?(0,Y.jsx)(rM,{panel:`agent`,"aria-label":`Agent`,children:(0,Y.jsx)(Gj,{...c,onClose:()=>s({ha:null})})},`hosted-agent`):e&&!a?(0,Y.jsx)(rM,{panel:`comments`,id:`sw-comments`,tabIndex:-1,className:`outline-none`,"aria-label":`Comments`,children:(0,Y.jsx)(qw,{...o,onClose:()=>s({panel:`off`})})},`comments`):null}var{width:Yj,min:Xj,max:Zj,share:Qj}=LA,$j=16,eM=`side`,tM=()=>Math.max(Xj,Math.min(Zj,Math.floor(window.innerWidth*Qj)));function nM(e){return Math.min(tM(),Math.max(Xj,Math.round(e)))}function rM({panel:e,defaultWidth:t=Yj,className:n,children:r,...i}){let[a,o]=(0,J.useState)(()=>nM(Sk(eM)??t)),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>MA(a),[a]),(0,J.useLayoutEffect)(()=>()=>MA(null),[]),(0,J.useEffect)(()=>{let e=()=>o(e=>nM(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let u=e=>{let n=nM(e);o(n),Ck(eM,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(nM(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:$j;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,Y.jsxs)(`aside`,{className:O(`relative flex shrink-0 flex-col border-l border-line bg-surface`,n),style:{width:a},"data-sw-rail":e,...i,children:[(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,"aria-valuenow":a,"aria-valuemin":Xj,"aria-valuemax":tM(),"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,Y.jsx)(`span`,{"aria-hidden":`true`,className:O(`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,Y.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null,r]})}function iM({hostedAgent:e=null,checksOpen:t,closeChecks:n,checksProps:r,chatAvailable:i,chatThread:a,chatProps:o,updateParams:s,sheetOpen:c,setSheetOpen:l,panelProps:u,threadSheet:d,threadProps:f,closeThread:p,selectedComment:m,targetTitle:h,draft:g,busy:_,setDraft:v,draftDescription:y,composerProps:b,viewNotice:x=null,undoViewNotice:S=null,modeLabel:C=e=>e,startDraw:w=!1,threadFromList:T=!1,sheetContentMax:E=null,sheetPanelMax:D=null}){return(0,Y.jsxs)(Y.Fragment,{children:[t?(0,Y.jsx)(N,{open:!0,onClose:n,title:`Checks`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] min-h-0 flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{children:`Loading checks…`}),children:(0,Y.jsx)(Kj,{...r})})})}):null,i?(0,Y.jsx)(N,{open:!!a,onClose:()=>s({chat:null}),title:`Agent`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(hv,{heading:!1}),children:(0,Y.jsx)(qj,{...o,heading:!1})})})}):null,e?(0,Y.jsx)(N,{open:!0,onClose:()=>s({ha:null}),title:`Agents`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex max-h-[78dvh] min-h-0 flex-col outline-none`,tabIndex:-1,"data-autofocus":!0,"data-sw-hosted-agent-sheet":`true`,children:(0,Y.jsx)(Gj,{...e,heading:!1})})}):null,(0,Y.jsx)(N,{open:c&&!t,onClose:()=>l(!1),title:`Comments`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex max-h-[70dvh] flex-col`,children:(0,Y.jsx)(qw,{...u,heading:!1})})}),(0,Y.jsx)(N,{open:d&&!!f&&!t,onClose:p,title:m?`#${m.id} · ${h(m.pageId)}`:`Comment`,description:m?`${m.viewport} capture`:void 0,size:`md`,back:T?`Comments`:null,maxHeight:D,children:f?(0,Y.jsx)(`div`,{className:`relative flex max-h-[62dvh] flex-col outline-none`,style:E?{maxHeight:E}:void 0,tabIndex:-1,"data-autofocus":!0,"data-sw-thread-sheet":m.id,children:(0,Y.jsx)(GE,{...f,notice:x&&x.id===m.id?(0,Y.jsx)(sj,{notice:x,onUndo:S,modeLabel:C,compact:!0,inSheet:!0}):null})}):null}),(0,Y.jsx)(N,{open:!!g&&!t,onClose:()=>_?null:v(null),title:`New comment`,description:y,children:(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(FT,{...b,touch:!0,startDraw:w})})})]})}var aM=e=>String(e).replace(/\/w\/[^/#?]+.*$/,`/account`),oM=`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`;function sM({journeys:e=[],journeyId:t=null,onJourney:n,canEditJourneys:r=!1,onNewJourney:i=null,bare:a=!1}){let[o,s]=(0,J.useState)(``),c=e.length>8,l=c?o.trim().toLowerCase():``,u=l?e.filter(e=>String(e.name||e.id).toLowerCase().includes(l)):e,d=e=>O(oM,e?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),f=e=>O(`shrink-0`,e?`text-accent`:`text-faint`);return(0,Y.jsxs)(`div`,{className:O(`flex w-full flex-col`,!a&&`border-t border-line pt-2`),"data-sw-journeys-sidebar":`true`,children:[a?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:e.length})]}),c?(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(it,{size:`sm`,icon:E_,value:o,onChange:e=>s(e.target.value.slice(0,80)),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-journeys-filter":`true`})}):null,(0,Y.jsxs)(`ul`,{className:`pb-2`,"aria-label":`Journeys`,children:[e.length&&!l?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(!t),"aria-current":t?void 0:`true`,onClick:()=>n(null),"data-sw-pages-journey":`none`,children:[(0,Y.jsx)(Bh,{size:14,"aria-hidden":`true`,className:f(!t)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`None`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:`Show all pages`})]})}):null,u.map(e=>{let r=e.id===t;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(r),"aria-current":r?`true`:void 0,onClick:()=>n(r?null:e.id),"data-sw-pages-journey":e.id,children:[(0,Y.jsx)(S_,{size:14,"aria-hidden":`true`,className:f(r)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint tabular`,children:yA(e)})]})},e.id)}),l&&!u.length?(0,Y.jsxs)(`li`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`No journey matches "`,o.trim(),`".`]}):null,e.length?null:(0,Y.jsx)(`li`,{className:`px-2.5 py-2 text-xs text-muted`,children:`No journeys yet.`}),r&&i?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:O(oM,`text-muted hover:bg-surface-2 hover:text-fg`),onClick:i,"data-sw-journeys-new":`true`,children:[(0,Y.jsx)(f_,{size:14,"aria-hidden":`true`,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`New journey`})]})}):null]})]})}function cM({groups:e,comments:t,activePage:n,onPage:r,bare:i=!1,filter:a=!0}){let[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(()=>new Set),u=o.trim().toLowerCase(),d=(0,J.useMemo)(()=>{let e=new Map;for(let n of t||[])n.status===`open`&&e.set(n.pageId,(e.get(n.pageId)||0)+1);return e},[t]),f=e.map(e=>({...e,pages:u?e.pages.filter(t=>`${t.title} ${t.path||``} ${e.group}`.toLowerCase().includes(u)):e.pages})).filter(e=>e.pages.length),p=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),m=e.reduce((e,t)=>e+t.pages.length,0);return(0,Y.jsxs)(`div`,{className:O(`flex w-full flex-col`,!i&&`border-t border-line pt-2`),"data-sw-pages-sidebar":`true`,children:[i?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:m})]}),i||!a?null:(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(it,{size:`sm`,icon:E_,value:o,onChange:e=>s(e.target.value.slice(0,80)),placeholder:`Filter pages`,"aria-label":`Filter pages`,"data-sw-pages-filter":`true`})}),(0,Y.jsxs)(`div`,{className:`pb-2`,children:[f.map(e=>{let t=c.has(e.group)&&!u;return(0,Y.jsxs)(`section`,{className:`mb-1`,"data-sw-pages-group":e.group,children:[(0,Y.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:()=>p(e.group),children:[(0,Y.jsx)(pe,{size:13,"aria-hidden":`true`,className:O(`transition-transform`,t&&`-rotate-90`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.group}),(0,Y.jsx)(`span`,{className:`ml-auto font-normal text-faint tabular`,children:e.pages.length})]}),t?null:(0,Y.jsx)(`ul`,{className:`ml-4`,children:e.pages.map((t,i)=>{let a=d.get(t.id)||0,o=t.id===n,s=i===e.pages.length-1;return(0,Y.jsx)(`li`,{className:O(`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,Y.jsxs)(`button`,{type:`button`,className:O(`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:()=>r(t.id),"data-sw-pages-item":t.id,children:[(0,Y.jsx)(Wh,{size:14,"aria-hidden":`true`,className:O(`shrink-0`,o?`text-accent`:`text-faint`)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),a?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted tabular`,"aria-label":`${a} open`,children:a}):null]})},t.id)})})]},e.group)}),u&&!f.length?(0,Y.jsxs)(`p`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`Nothing matches "`,o.trim(),`".`]}):null]})]})}var lM=`shapewall.sidebar.nav`,uM=[`pages`,`journeys`];function dM(){try{let e=window.localStorage.getItem(lM);return uM.includes(e)?e:`pages`}catch{return`pages`}}function fM({className:e=``}){return(0,Y.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-accent ${e}`,"aria-hidden":`true`,"data-sw-journey-dot":`true`})}function pM({groups:e,journeys:t=[],comments:n,activePage:r,journeyId:i,onPage:a,onJourney:o,canEditJourneys:s,onNewJourney:c}){let[l,u]=(0,J.useState)(dM),d=e.reduce((e,t)=>e+t.pages.length,0);if(!t.length&&!s)return(0,Y.jsx)(cM,{groups:e,comments:n,activePage:r,onPage:a,filter:!1});let f=e=>{u(e);try{window.localStorage.setItem(lM,e)}catch{}},p=`gap-1`;return(0,Y.jsxs)(Ee,{value:l,onValueChange:f,className:`flex w-full flex-col border-t border-line pt-2`,"data-sw-sidebar-nav":l,children:[(0,Y.jsxs)(Re,{"aria-label":`Pages and journeys`,className:`mb-2`,children:[(0,Y.jsxs)(qe,{value:`pages`,className:p,"data-sw-sidebar-tab":`pages`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:d})]}),(0,Y.jsxs)(qe,{value:`journeys`,className:p,"data-sw-sidebar-tab":`journeys`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:t.length}),i?(0,Y.jsx)(fM,{className:`ml-0.5`}):null]})]}),(0,Y.jsx)(le,{value:`pages`,tabIndex:-1,children:(0,Y.jsx)(cM,{bare:!0,groups:e,comments:n,activePage:r,onPage:a})}),(0,Y.jsx)(le,{value:`journeys`,tabIndex:-1,children:(0,Y.jsx)(sM,{bare:!0,journeys:t,journeyId:i,onJourney:o,canEditJourneys:s,onNewJourney:c})})]})}function mM({info:e,localSettingsAvailable:t,setShareOpen:n}){let r=[{id:`board`,label:`Board`,icon:bg,href:`./`,active:!0}],i=e?.consoleUrl&&!e?.guest?e.consoleUrl:null;return i?(r.push({id:`workspace`,label:`Workspace`,icon:uh,href:i}),r.push({id:`account`,label:`Account and security`,icon:ov,href:aM(i)})):t&&(r.push({id:`workspace`,label:`Workspace`,icon:uh,href:`/console`}),r.push({id:`account`,label:`Account and security`,icon:ov,href:`/account`})),e?.shareEnabled&&r.push({id:`share`,label:`Share with your team`,icon:P_,onSelect:()=>n(!0)}),r}function hM({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,expanded:c,onToggle:l,pages:u,openPalette:d=null,quiet:f=!1}){let p=!!e&&!e.guest&&!e.public&&!e.share,m=typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`);(0,J.useEffect)(()=>{p&&qk(window.location.pathname+(m?`?board=`+encodeURIComponent(m):``))},[p,m]);let h=mM({info:e,localSettingsAvailable:i,setShareOpen:s}),g=d&&!c?[h[0],{id:`search`,label:`Search (${Dk})`,icon:E_,onSelect:d,"aria-haspopup":`dialog`,"data-sw-page-jump":`true`,"data-sw-palette-trigger":`true`},...h.slice(1)]:h,_=!!u&&(u.journeys?.length>0||u.canEditJourneys),v=(e,t)=>n=>{e(),t?.(n)},y=!c&&u?[{id:`pages`,label:`Pages`,icon:Kh,flyout:({close:e})=>(0,Y.jsx)(cM,{groups:u.groups,comments:u.comments,activePage:u.activePage,onPage:v(e,u.onPage)})},..._?[{id:`journeys`,label:`Journeys`,icon:S_,dot:!!u.journeyId,"data-sw-rail-journeys":u.journeyId||`none`,flyout:({close:e})=>(0,Y.jsx)(sM,{journeys:u.journeys,journeyId:u.journeyId,onJourney:v(e,u.onJourney),canEditJourneys:u.canEditJourneys,onNewJourney:u.onNewJourney?()=>v(e,u.onNewJourney)():null})}]:[]]:[];return(0,Y.jsxs)(lA,{expanded:c,onToggle:l,home:`./`,homeLabel:`Shapewall`,title:e?.project?.name||e?.title,logo:(0,Y.jsx)(`img`,{src:`./favicon.svg`,alt:``,className:`h-7 w-7`}),items:g,sections:y,flyoutsDisabled:f,profile:c=>(0,Y.jsx)(kA,{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:[d&&c?(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(Pk,{onOpen:d})}):null,u?(0,Y.jsx)(pM,{...u}):null]})}var gM=(0,J.lazy)(()=>AD(()=>import(`./QuickConnect-CiVmxi0l.js`).then(e=>e.o).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([8,1,2,5,3]),import.meta.url)),_M=(0,J.lazy)(()=>AD(()=>import(`./History-FzpzGmXZ.js`),__vite__mapDeps([9,1,2]),import.meta.url)),vM=(0,J.lazy)(()=>AD(()=>import(`./ShareDialog-D0tmOGcQ.js`).then(e=>({default:e.ShareDialog})),__vite__mapDeps([10,1,2]),import.meta.url)),yM=(0,J.lazy)(()=>AD(()=>import(`./LocalSettings-BGFl4VKr.js`),__vite__mapDeps([11,1,2,8,5,3]),import.meta.url));function bM({info:e,boardId:t,boards:n,wide:r,shareOpen:i,setShareOpen:s,refetchView:c,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=o(i),j=o(u);return(0,Y.jsxs)(Y.Fragment,{children:[e?.shareEnabled&&A?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(vM,{open:i,onClose:()=>s(!1),boardId:t,onMoved:c})}):null,l&&j?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(gM,{open:u,onClose:()=>d({settings:null}),onSaved:f,touch:!r,buzz:e?.buzzAvailable===!0})}):null,p?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(yM,{open:!0,onClose:()=>d({settings:null}),info:e,boardCount:n.length,onSaved:f,touch:!r,onOpenUpdates:()=>{d({settings:null}),m.current?.open()}})}):null,h?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(_M,{open:!!h,onClose:g,page:h,viewport:_,data:y,comments:b.filter(e=>e.pageId===v&&e.viewport===_),urlFor:(e,n)=>G(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:!r,onImageError:C})}):null,(0,Y.jsx)(N,{open:w,onClose:()=>E?null:T(!1),title:`Capture every page now?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{size:r?`md`:`touch`,onClick:()=>T(!1),disabled:E,children:`Cancel`}),D&&O(D)?(0,Y.jsxs)(a,{size:r?`md`:`touch`,onClick:()=>k(null,[D]),disabled:E,"data-sw-capture-only":D,children:[`Only `,O(D).title]}):null,(0,Y.jsx)(a,{size:r?`md`:`touch`,variant:`default`,onClick:()=>k(),disabled:E,"data-sw-capture-confirm":`true`,children:`Capture all`})]}),children:(0,Y.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 xM=2;function SM(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function CM({canvasRef:e,flow:t,targets:n,viewports:r,settledZoom:i,setSettledZoom:a,comparePair:o,captures:s,variantsById:c}){let l=(0,J.useRef)(null),[u,d]=(0,J.useState)(()=>new Set),[f,p]=(0,J.useState)(()=>new Set),m=(0,J.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,J.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,J.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,xM).map(e=>e.key));l.current&&!f.has(l.current)&&(l.current=null),d(e=>SM(e,f)?e:f)},[e,t,n,h,i,r]);return(0,J.useEffect)(()=>{g()},[g]),{liveKeys:u,readyKeys:f,setLiveReady:m,liveFileFor:h,recomputeLive:g,openLive:(0,J.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:UO(450)}))},[e,t,n,a])}}function wM({journey:e,builder:t,goStep:n,step:r,closeJourney:i}){(0,J.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 TM({commentMode:e,setCommentMode:t,canComment:n,comparePair:r,setDraft:i,keepDraft:a}){(0,J.useEffect)(()=>{if(!e)return;let n=e=>{e.key!==`Escape`||OC(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),(0,J.useEffect)(()=>{if(!n||r)return;let e=e=>{if(e.defaultPrevented&&!tt(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(),a?.()||(i(null),t(e=>!e)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r,a,t,i])}function EM({journeys:e,journey:t,builder:n,openJourney:r,closeJourney:i}){(0,J.useEffect)(()=>{if(!e.length||n)return;let a=n=>{if(n.defaultPrevented&&!tt(n)||n.altKey||n.ctrlKey||n.metaKey||n.repeat||n.key!==`j`&&n.key!==`J`||OC(n.target)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`))return;n.preventDefault();let a=t?e.findIndex(e=>e.id===t.id):-1,o=e.length+1,s=(a+1+(n.shiftKey?-1:1)+o)%o-1;s<0?i():r(e[s].id)};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[n,i,t,e,r])}function DM(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&Array.isArray(e.branches)}function OM(e){let t=new Set,n=e=>{for(let r of e||[])if(typeof r==`string`)t.add(r);else if(DM(r))for(let e of r.branches)n(e.steps)};return n(e),[...t]}function kM(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(!DM(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 AM(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(!DM(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 jM(e,t,n){return[...e.forks.slice(0,t).map(e=>e.chosen),n]}function MM({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,onLeave:b=()=>{}}){let x=(0,J.useCallback)(e=>{e&&b(),r(),n({j:e||null,step:e?1:null,jc:null,jb:null})},[r,b,n]),C=(0,J.useCallback)(()=>n({j:null,step:null,jc:null,jb:null}),[n]),w=(0,J.useCallback)(e=>{s&&(b(),n({step:Sv(e,s.length)}))},[b,s,n]),T=(0,J.useCallback)((e,t)=>{o&&(b(),n({jb:jM(o,e,t).join(`,`)}))},[b,o,n]),E=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!a||!g||l){a||(E.current=null);return}let e=s[c-1],t=`${a.id}:${c}:${e}:${_}:${v}`;if(E.current===t)return;let n=h[e];n&&(E.current=t,y(null),m.fitBounds({x:n.x,y:n.y-48,width:n.w,height:n.h+48},{padding:.18,duration:UO(450)}))},[l,v,m,a,h,_,g,s,y,c]),wM({journey:a,builder:l,goStep:w,step:c,closeJourney:C});let D=(0,J.useCallback)((e=null)=>{b(),i(!1),r(),u(e?{id:e.id,name:e.name,steps:structuredClone(e.steps),into:null}:{id:null,name:``,steps:[],into:null})},[r,b,u,i]),O=(0,J.useCallback)(e=>{u(t=>{if(!t||OM(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]),k=`/api/boards/${encodeURIComponent(e)}/journeys`;return{openJourney:x,closeJourney:C,goStep:w,chooseJourneyBranch:T,startBuilder:D,addBuilderStep:O,saveBuilder:async()=>{if(l&&!d){f(!0);try{let e={name:l.name,steps:l.steps},n=l.id?await S.patch(`${k}/${encodeURIComponent(l.id)}`,e):await S.post(k,e);await t.refetch(),u(null),E.current=null,x(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 S.delete(`${k}/${encodeURIComponent(a.id)}`),C(),t.refetch()}catch(e){p({tone:`bad`,text:e.message||`The journey was not deleted.`})}finally{f(!1)}}}}}function NM({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,onAgentsChanged:h=null}){let g=(0,J.useRef)(new Map),_=(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()},v=`/api/boards/${encodeURIComponent(e)}/comments`,y=async(e,t)=>{o(!0);try{let n=await S.post(`${v}/${e.id}/${t}`,{author:a()||void 0});_(n.comment),f&&t===`resolve`&&p===`open`&&d(),t===`resolve`&&m(`resolve`)&&c({at:Date.now(),text:`Resolved comment #${e.id}.`,undo:()=>y(n.comment,`reopen`)})}catch(e){s({tone:`bad`,text:e.message||`That did not save.`})}finally{o(!1)}},b=async(e,t,n={})=>{let{onImageError:r,images:i,drawing:c}=n;o(!0);try{let n=await S.post(`${v}/${e.id}/replies`,{body:t,author:a()||void 0,...i?.length?{images:i}:{},...c?{drawing:c}:{}});return _(n.comment),!0}catch(e){return r&&/image/.test(e.code||``)?r(e.message||`An image was not accepted.`):s({tone:`bad`,text:e.message||`That reply did not save.`}),!1}finally{o(!1)}},x=async(e,t)=>{o(!0);try{let n=await S.patch(`${v}/${e.id}`,{body:t});return _(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That edit did not save.`}),!1}finally{o(!1)}},C=async(e,t,n=null)=>{try{let a=await S.post(`${v}/${e.id}/reactions`,{emoji:t,...n?{replyId:n}:{},...r?.hosted?{}:{author:i||void 0}});_(a.comment,!1,{counts:!1})}catch(e){s({tone:`bad`,text:e.message||`That reaction did not save.`})}},w=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}`})}},T=async e=>{o(!0);try{let t=await S.post(`${v}/${e.id}/github/issue`,{});_(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)}},E=e=>{g.current.delete(e),l(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},D=async e=>{let t=g.current.get(e.id);if(t){window.clearTimeout(t.timer);try{await S.delete(`${v}/${e.id}`),_(e,!0)}catch(e){s({tone:`bad`,text:e.message||`That did not delete.`})}finally{E(e.id)}}},O=(0,J.useRef)(D);return O.current=D,(0,J.useEffect)(()=>{let e=()=>{for(let{comment:e}of[...g.current.values()])O.current(e)};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),e()}},[]),{commentsUrl:v,applyComment:_,setStatus:y,replyTo:b,editComment:x,reactTo:C,copyLink:w,githubIssue:T,removeComment:async e=>{u===e.id&&d(),l(t=>new Set(t).add(e.id));let t=window.setTimeout(()=>O.current(e),6e3);g.current.set(e.id,{comment:e,timer:t}),c({at:Date.now(),text:`Deleted comment #${e.id}.`,undo:()=>{window.clearTimeout(t),E(e.id)}})},sendToAgent:async(e,n=void 0)=>{let{dispatchHash:i}=e,a=!!(e.needsRunApproval&&[`admin`,`owner`].includes(r.role));o(!0);try{a&&await JD();let t=await S.post(`${v}/${e.id}/send-to-agent`,{dispatchHash:i,approve:a,...n===void 0?{}:{agentId:n}});_(t.comment),h?.()}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)}},releaseAgent:async e=>{o(!0);try{let t=await S.post(`${v}/${e.id}/release-agent`,{});_(t.comment),h?.()}catch(e){s({tone:`bad`,text:e.message})}finally{o(!1)}}}}function PM(e){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(()=>new Set),s=te(`/api/boards/${encodeURIComponent(e)}`,{pollMs:r||t?2e3:Ue?0:3e4}),c=te(`/api/boards/${encodeURIComponent(e)}/comments`,{pollMs:Ue?0:t?1e3:2e4}),l=s.data,u=l?.capture;return(0,J.useEffect)(()=>{i(!!u?.running)},[u?.running]),{view:s,commentsQuery:c,data:l,capture:u,comments:(0,J.useMemo)(()=>{let e=Array.isArray(c.data?.comments)?c.data.comments:[];return a.size?e.filter(e=>!a.has(e.id)):e},[c.data,a]),fixRequest:t,setFixRequest:n,setPolling:i,deletingIds:a,setDeletingIds:o}}function FM({params:e,data:t,builder:n}){let r=(0,J.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,J.useMemo)(()=>i?AM(i.steps,a.split(`,`).filter(Boolean)):null,[i,a]),s=(0,J.useMemo)(()=>i?kM(i.steps):null,[i]),c=(0,J.useMemo)(()=>o?o.steps.map(e=>e.pageId):null,[o]);return{journeys:r,journey:i,route:o,routeGraph:s,routePages:c,step:Sv(e.get(`step`),c?.length||0),journeyComments:!!i&&e.get(`jc`)===`1`}}var IM=1600;function LM(e){if(!e)return null;let t=document.querySelector(`[data-sw-thread-sheet]`)?.closest(`[role="dialog"]`)?.offsetHeight;return t?window.innerHeight-t-e.top:null}function RM({pendingFocus:e,setPendingFocus:t,targets:n,viewports:r,mode:i,flow:a,canvasRef:o,wide:s,setSettledZoom:c,onHidden:l=null,onLanded:u=null}){let d=(0,J.useRef)(l);d.current=l;let f=(0,J.useRef)(u);f.current=u;let p=(0,J.useRef)(0);(0,J.useEffect)(()=>()=>window.cancelAnimationFrame(p.current),[]),(0,J.useEffect)(()=>{if(!e)return;let l=_y(n,e);if(!l){if(!n[e.pageId]||!r[e.viewport]){t(null),d.current?.(e);return}if(i!==`all`&&i!==e.viewport)return;let a=window.setTimeout(()=>{t(null),d.current?.(e)},700);return()=>window.clearTimeout(a)}t(null),c(null),window.cancelAnimationFrame(p.current);let u=!s&&e.id!=null,m=0,h=()=>{let t=o.current?.getBoundingClientRect(),r=s?null:LM(t);if(u&&r===null&&m<5){m+=1,p.current=window.requestAnimationFrame(h);return}let i=pC({point:l,box:t,wide:s,zoom:a.getZoom(),cardTop:n[e.pageId]?.y??null,sheetTop:r});i?a.setViewport(i,{duration:mC(a.getViewport(),i)?0:UO(450)}):a.setCenter(l.x,l.y,{zoom:uC(a.getZoom()),duration:UO(450)}),f.current?.(e)};h()},[o,a,i,n,e,t,c,r,s])}function zM({wide:e,nodesReady:t,initialCamera:n,selectedCommentId:r,canvasRef:i,nodes:a,flow:o,setSettledZoom:s}){let c=(0,J.useRef)(!1);(0,J.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(KO);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 BM({mode:e,pendingFocus:t,shapeKey:n,clearFocus:r,fitBoard:i}){let a=(0,J.useRef)(e);(0,J.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,J.useRef)(n);(0,J.useEffect)(()=>{if(o.current===n||(o.current=n,r(),t))return;let e=window.setTimeout(i,60);return()=>window.clearTimeout(e)},[r,i,t,n])}function VM({nodesReady:e,data:t,commentsLoaded:n,selectedCommentId:r,selectedComment:i,initialCamera:a,focusComment:o,deletingIds:s,setNotice:c,updateParams:l}){let u=(0,J.useRef)(!1);(0,J.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,J.useRef)(null);(0,J.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 HM({selectedComment:e,visibleComments:t,focusComment:n,mode:r,viewports:i,modes:a}){let o=(0,J.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 UM=[`issues`,`pages`,`seo`,`performance`,`history`],WM=e=>UM.includes(e)&&e!==`issues`?e:null;function GM({boardId:e,info:t,params:n,updateParams:r,pages:i}){let a=!!t?.checksAvailable,o=a&&!!n.get(`checks`),s=i?.some(e=>e.id===n.get(`checks`))?n.get(`checks`):null,c=n.get(`cv`)||null,l=UM.includes(n.get(`ct`))?n.get(`ct`):`issues`,u=/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.get(`ce`)||``)?n.get(`ce`):null,d=`/api/boards/${encodeURIComponent(e)}/checks`,f=u?`?env=${encodeURIComponent(u)}`:``,p=te(a?`${d}${f}`:null,{pollMs:Ue?0:3e4}),m=te(a&&o&&!Ue?`${d}/seo${f}`:null),h=a&&!Ue&&!t?.hosted,[g,_]=(0,J.useState)(!1),v=te(h&&o?`${d}/run`:null,{pollMs:g?1500:0}),y=v.data?.run||null,b=y?.state===`running`;(0,J.useEffect)(()=>_(b),[b]);let x=(0,J.useRef)(!1),{refetch:C}=p,{refetch:w}=m;(0,J.useEffect)(()=>{x.current&&!b&&(C(),w()),x.current=b},[b,C,w]);let[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!1),k=(0,J.useCallback)(async({pages:e=null,seo:t=!0}={})=>{O(!0),E(null);try{return await S.post(`${d}/run`,{seo:t,...e?{pages:e}:{},...u?{env:u}:{}}),_(!0),await v.refetch(),!0}catch(e){return E(e.message||`The checks run did not start.`),v.refetch(),!1}finally{O(!1)}},[d,u,v]),[A,j]=(0,J.useState)(!1),ee=(0,J.useCallback)(async()=>{j(!0),E(null);try{await S.delete(`${d}/run`)}catch(e){E(e.message||`The checks run could not be stopped.`)}finally{j(!1),v.refetch()}},[d,v]),M=(0,J.useCallback)((e=null,t=null,n=null)=>r({checks:e||`all`,cv:t,chat:null,...n?{ct:WM(n)}:{}}),[r]),N=(0,J.useCallback)(e=>r({ct:WM(e)}),[r]),P=(0,J.useCallback)(()=>r({checks:null,cv:null,ct:null}),[r]),F=(0,J.useMemo)(()=>{let e=new Map;for(let t of p.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},[p.data]),I=h?{loading:v.loading,canRun:!!v.data?.canRun,reason:v.data?.reason||null,limit:v.data?.limit||100,privatePages:v.data?.privatePages||[],seoDefault:v.data?.seoDefault!==!1,run:y,starting:D,error:T,start:k,stop:ee,stopping:A}:null,L=[`shapewall checks run`,`--board ${e}`,s?`--only ${s}`:null,u?`--env ${u}`:null,l===`seo`?`--seo`:null,`--limit 100`].filter(Boolean).join(` `);return{canChecks:a,checksOpen:o,checksPage:s,checksViewport:c,checksEnvironment:u,checksTab:l,setChecksTab:N,checksQuery:p,seoQuery:m,checksRun:I,checksPanelProps:{tab:l,onTab:N,seo:m.error?null:m.data,run:I,command:L},openChecks:M,closeChecks:P,checksCounts:F}}function KM({boardId:e,info:t,params:n,updateParams:r}){let i=!Ue&&!!t?.agent&&!(t?.remote?.noRemoteChat&&t?.remote?.kind!==`host`),a=n.get(`chat`)||``,o=i?CE(a):null,s=!!(t?.agent?.settingsEditable||t?.agent?.settingsReadonly),c=!Ue&&!Ge&&!t?.consoleUrl&&!t?.workspace&&!t?.hosted&&!t?.guest,l=c&&n.get(`settings`)===`general`,u=s&&n.get(`settings`)===`agent`,d=(0,J.useCallback)(()=>r({settings:`agent`}),[r]);return(0,J.useEffect)(()=>{o&&EE(e,SE(o))},[e,o]),{chatAvailable:i,chatThread:o,reopenChat:(0,J.useCallback)(()=>r({chat:DE(e),checks:null,cv:null}),[e,r]),settingsAvailable:s,localSettingsAvailable:c,generalSettingsOpen:l,settingsOpen:u,openSettings:d,openChat:(0,J.useCallback)(e=>{r({chat:SE(e),checks:null,cv:null})},[r])}}function qM({boardId:e,params:t,updateParams:n,environmentList:r,setCommentMode:i,pageCount:a=0}){let o=(0,J.useMemo)(()=>Array.isArray(r)?r:[],[r]),s=(0,J.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=te(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,J.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 JM({comments:e,query:t,stateFilter:n,mentionFilter:r,titleOfPage:i,filter:a,journey:o,journeyComments:s}){let c=(0,J.useMemo)(()=>Fv(e,{query:t,state:n,mention:r,titleOf:i}),[e,r,t,n,i]),l=(0,J.useMemo)(()=>{let e=s?new Set(o.pages||OM(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,J.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 YM({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,J.useMemo)(()=>new Set(Object.keys(e).filter(e=>!e.startsWith(`variant:`))),[e]),m=(0,J.useMemo)(()=>o?AM(o.steps).steps.map(e=>e.pageId):null,[o]),h=o?m:l,g=(0,J.useMemo)(()=>r&&!i?bv(n,p):null,[n,p,i,r]),_=(0,J.useMemo)(()=>o||!s?null:{graph:c,path:s.steps.map(e=>e.key)},[o,s,c]),v=(0,J.useMemo)(()=>[...t,...xv({links:n||{},showLinks:r,activePage:a,journeySteps:o?m:null,journeyRoute:_,currentStep:o?0:u,present:p,hideTargets:g}).map(e=>({...e,...e.id.startsWith(`journey:`)?{data:{...e.data,toTitle:f(e.target)}}:{},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,J.useMemo)(()=>{if(o||!d||!l)return null;let e=new Set(l);return new Set((d.pages||OM(d.steps)).filter(t=>!e.has(t)))},[o,d,l]);return{presentPages:p,shownSteps:h,hiddenLinkTargets:g,edges:v,journeyView:(0,J.useMemo)(()=>h?{steps:vv(h),offPath:y,currentStep:o?null:u,currentPage:o?null:h[u-1]}:null,[o,y,h,u])}}var XM=[];function ZM(e){let t=(0,J.useRef)(e);t.current=e;let{boardId:r,data:i,viewports:a,journeyView:o,compareView:s,commentMode:c,canComment:l,wide:u,hosted:d,imageVersion:f,pinsByTarget:p,me:m,checksCounts:h,canChecks:g,agentFocus:_,agentWorkingPages:v,setLiveReady:y,focusedKey:b,selectingKey:x,settledZoom:S,selectedComment:C,draftSpot:w,unread:T,liveKeys:E,commentTargetKey:D=null}=e,[O]=(0,J.useState)(()=>ox({focusedKey:b,selectingKey:x,settledZoom:S,selectedComment:C,draftSpot:w,unread:T,liveKeys:E,commentTargetKey:D}));(0,J.useLayoutEffect)(()=>{O.set({focusedKey:b,selectingKey:x,settledZoom:S,selectedComment:C,draftSpot:w,unread:T,liveKeys:E,commentTargetKey:D})},[O,b,x,S,C,w,T,E,D]);let k=(0,J.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&&oy(p,c.getZoom())&&(l(null),c.fitBounds(qO({x:f.x+p.x,y:f.y,width:p.w,height:p.y+p.h},u.current?.getBoundingClientRect(),.08),{padding:.08,duration:UO(450)})),d(`${t}|${n}`)},onPin:t=>{let n=e(),{layout:r,flow:i,canvasRef:a}=n;if(n.keepDraft())return;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:UO(450)}),n.setToast({at:Date.now(),text:`Zoomed in: tap the spot again to pin your comment.`,untilSheet:!0})}else n.setDraft(e=>({...t,body:e?.body||n.checkDraft||``,author:e?.author??n.authorName()})),n.setCheckDraft(``)},onSelectComment:t=>e().selectComment(t),onHoverComment:e=>O.set({hoveredId:e}),onReading:e=>O.set({readingKey:e}),onJourneyStep:t=>e().goStep(t),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()}},[O]);return{board:(0,J.useMemo)(()=>({boardId:r,captures:i?.captures||{},manifest:i?.manifest||null,counts:i?.commentCounts||{},viewports:a,journey:o,compare:s,commentMode:c&&l&&!s,touch:!u,imageUrl:(e,t,n)=>G(r,e,t,n||f),liveUrl:(e,t,i)=>n(r,e,t,i||f),elementsUrl:(e,t,n)=>re(r,e,t,n||f),domFallback:!Ue&&!Ge&&!d,setLiveReady:y,pinsFor:(e,t)=>p.get(`${e}|${t}`)||XM,me:m,checksCount:e=>h.get(e)||0,historyCount:e=>Mv(i?.versions,e),agentWorking:_,agentWorkingPages:v,onFocusFrame:k.onFocusFrame,onPin:k.onPin,onSelectComment:k.onSelectComment,onReading:k.onReading,onJourneyStep:k.onJourneyStep,onHoverComment:u?k.onHoverComment:null,onOpenCluster:k.onOpenCluster,onChecks:g?k.onChecks:null,onHistory:k.onHistory,onShowViewport:k.onShowViewport,onImageError:k.onImageError}),[k,_,v,r,g,l,h,c,s,i?.captures,i?.commentCounts,i?.manifest,i?.versions,d,f,o,m,p,y,a,u]),view:O}}function QM({boardId:e,view:t,setBusy:n,setNotice:r,setPolling:i}){let[a,o]=(0,J.useState)(!1);return{captureConfirm:a,setCaptureConfirm:o,startCapture:async(a=null,s=null)=>{n(!0);try{r({tone:`info`,text:(await S.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 $M({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,media:h={attach:!1,draw:!1,attachNote:null},pageImage:g=()=>null}){let _=Fx({enabled:h.attach}),v=e?`${e.pageId}|${e.viewport}`:null;(0,J.useEffect)(()=>{!v||!h.draw?Jx.end(`composer`):Jx.get()?.owner===`composer`?Jx.moveTo(v,`composer`):Jx.start(v,`composer`)},[v,h.draw]);let{clear:y}=_;(0,J.useEffect)(()=>{e||y()},[e,y]),(0,J.useEffect)(()=>()=>Jx.end(`composer`),[]);let b=async()=>{if(!e||n||_.reading)return;let f=Jx.get(),p=f?.owner===`composer`&&f.key===v?f.shapes:[],m=Px(_.images);if(e.body.trim()||p.length||m.length){r(!0);try{let n=(e.author||``).trim();M(n);let{comment:r}=await S.post(i,{pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y,body:e.body,author:n,...e.anchor?{anchor:e.anchor}:{},...m.length?{images:m}:{},...p.length?{drawing:Xx(p)}:{}});Jx.end(`composer`),t(null),s(n),a(r),o(r),l({c:u?r.id:null,filter:d===`all`?`all`:null})}catch(e){/image/.test(e.code||``)?_.setError(e.message||`An image was not accepted.`):c({tone:`bad`,text:e.message||`The comment was not saved.`})}finally{r(!1)}}},x=e?e.anchor?e.target||Ry(Ly(e.anchor.selector),e.anchor.text):`a spot on ${f(e.pageId)}`:``;return{draftDescription:e?`${f(e.pageId)} · ${Vv(e.viewport)} · ${e.anchor?x:`${Math.round(e.x)}% across, ${Math.round(e.y)}% down`}`:``,draftTarget:x,composerProps:{draft:e,onChange:e=>t(t=>t&&{...t,...e}),onSubmit:b,onCancel:()=>t(null),busy:n,people:p,hosted:!!m?.hosted,signedInAs:m?.user?.name||null,media:{...h,images:_,owner:`composer`,page:e&&h.draw?g(e.pageId,e.viewport):null,pageTitle:e?f(e.pageId):``}}}}function eN({canComment:e,comparePair:t,commentMode:n,markPicked:r,setDraft:i,keepDraft:a,setCommentMode:o,showLinks:s,toggleLinks:c,canCompare:l,toggleCompare:u,wide:d,fitBoard:f,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:Wg,keys:`C`,run:()=>{r(),a()||(i(null),o(e=>!e))}}:null,{id:`links`,label:s?`Hide links between pages`:`Show links between pages`,icon:uv,run:c},l?{id:`compare`,label:t?`Leave compare mode`:`Compare environments`,icon:Qh,run:u}:null,d?{id:`fit`,label:`Fit the whole board`,icon:Bg,keys:`Shift 1`,run:f}:null,d?{id:`minimap`,label:p?`Hide the minimap`:`Show the minimap`,icon:Rg,run:m}:null,h?{id:`agent`,label:`Chat with your agent`,icon:I,run:g}:null,_?{id:`checks`,label:`Open page checks`,icon:Jh,run:()=>v()}:null].filter(Boolean)}var tN=30,nN=28,rN=240;function iN(e){let t=1/e;return{"--sw-zoom":e.toFixed(4),"--sw-inv":t.toFixed(4),"--sw-title-scale":Math.min(t,96/tN).toFixed(4),"--sw-title-fade":Math.max(0,Math.min(1,(e-.16)*25)).toFixed(3),"--sw-group-scale":Math.min(t,rN/nN).toFixed(4),"--sw-label-scale":Math.min(t,1.6).toFixed(4),"--sw-chip-scale":Math.min(t,1).toFixed(4)}}function aN(){let e=rd();return(0,J.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(iN(n)))r.style.setProperty(e,t)}};return n(e.getState()),e.subscribe(n)},[e]),null}function oN({fitBoard:e,zoomTo:t}){let n=tf();(0,J.useEffect)(()=>{let r=r=>{if(!(r.defaultPrevented||r.altKey||r.ctrlKey||r.metaKey||OC(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:UO(200)});else if(!r.shiftKey&&r.key===`-`)n.zoomOut({duration:UO(200)});else return;r.preventDefault()}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,n,t])}function sN({wide:e,clearFocus:t,setSettledZoom:n,minimapOn:i,liveKeys:a,toggleMinimap:o,hideFit:c,hideMinimap:l=!1,compact:u=!1,hideZoom:d=!1,fitBoard:f}){let p=tf(),m=$(e=>Math.round(e.transform[2]*100)),h=e=>{t(),n(null);let{x:r,y:i,zoom:a}=p.getViewport(),o=document.querySelector(`[data-sw-canvas]`)?.getBoundingClientRect(),s=(o?.width||0)/2,c=(o?.height||0)/2,l=e/a;p.setViewport({x:s-(s-r)*l,y:c-(c-i)*l,zoom:e},{duration:UO(250)})};if(oN({fitBoard:f,zoomTo:h}),!e)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(aN,{}),(0,Y.jsx)(pd,{position:`bottom-left`,className:O(`!m-2 !mb-[calc(0.5rem+env(safe-area-inset-bottom,0px))]`,c&&`hidden`),children:(0,Y.jsx)(B,{size:`icon`,variant:`secondary`,className:`bg-surface/95 shadow-pop backdrop-blur`,onClick:f,label:`Fit the whole board`,"data-sw-fit":`true`,children:(0,Y.jsx)(Bg,{size:17,"aria-hidden":`true`})})})]});let g=i&&!a.size&&!l,v=i&&a.size?`Minimap: hidden while a page is live`:i?`Hide the minimap`:`Show the minimap`,b=`h-8 w-8 rounded-md text-muted shadow-none hover:bg-surface-2 hover:text-fg`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(aN,{}),(0,Y.jsx)(pd,{position:`bottom-left`,className:O(`!m-3`,d&&`hidden`),children:(0,Y.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":u?`compact`:`true`,children:[(0,Y.jsx)(B,{className:O(b,`react-flow__controls-zoomout`),onClick:()=>p.zoomOut({duration:UO(200)}),label:`Zoom out`,tooltip:(0,Y.jsx)(vx,{label:`Zoom out`,keys:[`-`]}),children:(0,Y.jsx)(Xg,{size:15,"aria-hidden":`true`})}),(0,Y.jsxs)(je,{children:[(0,Y.jsx)(_,{content:`Zoom level`,children:(0,Y.jsxs)(T,{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 ${m}%`,"data-sw-zoom-level":m,children:[m,`%`]})}),(0,Y.jsxs)(r,{side:`top`,align:`start`,className:`min-w-52`,children:[(0,Y.jsxs)(D,{onSelect:()=>p.zoomIn({duration:UO(200)}),children:[`Zoom in `,(0,Y.jsx)(s,{className:`ml-auto`,children:`+`})]}),(0,Y.jsxs)(D,{onSelect:()=>p.zoomOut({duration:UO(200)}),children:[`Zoom out `,(0,Y.jsx)(s,{className:`ml-auto`,children:`-`})]}),(0,Y.jsx)(y,{}),(0,Y.jsx)(D,{onSelect:()=>h(.5),children:`Zoom to 50%`}),(0,Y.jsxs)(D,{onSelect:()=>h(1),children:[`Zoom to 100% `,(0,Y.jsx)(s,{className:`ml-auto`,children:`Shift 0`})]}),(0,Y.jsx)(D,{onSelect:()=>h(2),children:`Zoom to 200%`}),(0,Y.jsx)(y,{}),(0,Y.jsxs)(D,{onSelect:f,children:[`Fit the whole board `,(0,Y.jsx)(s,{className:`ml-auto`,children:`Shift 1`})]}),u?(0,Y.jsx)(D,{onSelect:o,"data-sw-minimap-item":`true`,children:i?`Hide the minimap`:`Show the minimap`}):null]})]}),(0,Y.jsx)(B,{className:O(b,`react-flow__controls-zoomin`),onClick:()=>p.zoomIn({duration:UO(200)}),label:`Zoom in`,tooltip:(0,Y.jsx)(vx,{label:`Zoom in`,keys:[`+`]}),children:(0,Y.jsx)(f_,{size:15,"aria-hidden":`true`})}),u?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),(0,Y.jsx)(B,{className:O(b,`react-flow__controls-fitview`),onClick:f,label:`Fit the whole board`,tooltip:(0,Y.jsx)(vx,{label:`Fit the whole board`,keys:[`Shift`,`1`]}),children:(0,Y.jsx)(Bg,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(B,{className:O(b,i&&`text-accent hover:text-accent`),"aria-pressed":i,onClick:o,label:i?`Hide the minimap`:`Show the minimap`,tooltip:v,"data-sw-minimap-toggle":i?a.size?`auto-hidden`:`on`:`off`,children:(0,Y.jsx)(Rg,{size:14,"aria-hidden":`true`})})]})]})}),g?(0,Y.jsx)(Ym,{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 cN(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 lN(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 uN({card:e,canvas:t,bar:n,avoid:r=null,gap:i=8,zoom:a=1,toggleSize:o=44,pin:s=!1}){let{width:c,height:l}=t,u=r?r.bottom+i:i,d=e=>Math.max(i,Math.min(l-n.height-i,e)),f=(e,t=n)=>!cN({...e,width:t.width,height:t.height},r,i),p=t=>{let r={left:t,top:d(e.top)};if(f(r))return r;let a={left:t,top:u};return a.top+n.height+i<=l?a:null},m=null,h=Math.max(i,Math.min(e.right-n.width,c-n.width-i));if(e.titleTop-n.height-i>=i){let t={left:h,top:e.titleTop-n.height-i};f(t)&&(m=t)}if(!m&&e.right+i+n.width<=c-i&&(m=p(e.right+i)),!m&&e.left-i-n.width>=i&&(m=p(e.left-i-n.width)),s){let t=e.right-e.left,r=t>=n.width?e.right-n.width:e.left+(t-n.width)/2,a=Math.round(Math.max(i,Math.min(c-n.width-i,r))),o=f({left:a,top:i})?i:u,s=Math.max(o,e.titleTop-n.height-i);return s=Math.min(s,e.bottom-n.height-i,l-n.height-i),{place:{left:a,top:Math.round(s)},toggle:{left:a,top:o},fallback:{left:a,top:o}}}let g=e.titleTop>=i&&a>.2?{top:Math.max(i,e.titleTop-7),left:Math.max(i,Math.min(c-52,e.right-44-Math.min(140,(e.right-e.left)*.3)))}:{top:i,left:i};f(g,{width:o,height:o})||(g={...g,top:u});let _={left:i,top:f({left:i,top:i})?i:u};return{place:m,toggle:g,fallback:_}}var dN=[`select`,`capture`,`history`,`checks`,`open`],fN=[`open`,`select`,`done`,`checks`,`history`,`capture`],pN={desktop:{icon:32,gap:4,pad:10,divider:6,count:22,title:160,titleMin:88,titleChip:140,label:{comment:100,open:104,select:103,done:74,checks:84,history:88,capture:90}},touch:{icon:44,gap:4,pad:10,divider:6,count:22,title:0,titleMin:0,titleChip:0,label:{comment:108,open:112,select:118,done:82,checks:98,history:102,capture:106}}};function mN({canvasWidth:e,touch:t=!1,items:n={},margin:r=16}){let i=t?pN.touch:pN.desktop,a=Math.max(0,e-r),o=fN.filter(e=>n.live===e||[`checks`,`history`,`capture`].includes(e)&&n[e]),s=e=>i.label[e]+(n[`${e}Count`]?i.count:0),c=(e,r)=>{let a=o.filter(t=>!e.includes(t)),c=n.link?t||e.length?`menu`:`bar`:null,l=e.length>0||c===`menu`,u=[];n.comment&&u.push(i.label.comment);for(let e of a)u.push(s(e));l&&u.push(i.icon),c===`bar`&&u.push(i.icon),u.push(i.icon),r&&u.push(0);let d=u.reduce((e,t)=>e+t,0)+i.gap*(u.length-1)+i.pad+i.divider;return{title:r,bar:a,menu:o.filter(t=>e.includes(t)),link:c,more:l,fixed:d}};if(t){let e=c(o.filter(e=>e!==`done`),!1);return{step:`compact`,title:!1,chip:!1,bar:e.bar,menu:e.menu,link:e.link,more:e.more,width:Math.min(e.fixed,a),fits:e.fixed<=a}}let l=c([],!t),u=Math.min(l.fixed+i.title,a),d=[];t||d.push(l),d.push(c([],!1));let f=[];for(let e of dN)o.includes(e)&&(f.push(e),d.push(c([...f],!1)));let p=e=>e.fixed+(e.title?i.titleMin:0),m=d.find(e=>p(e)<=(e.title?u:a))||d.at(-1),h=p(m)<=(m.title?u:a),g=m.title&&u-m.fixed>=i.titleChip;return{step:m.title?`full`:m.menu.length?`more-${m.menu.length}`:`title`,title:m.title,chip:g,bar:m.bar,menu:m.menu,link:m.link,more:m.more,width:m.title?u:Math.min(m.fixed,a),fits:h}}var hN=30;function gN({focused:e,target:t,frame:n,title:r,hasLive:i,live:o,ready:s,selecting:c,touch:l,href:u,onOpenLive:d,onToggleSelect:f,onClose:p,onComment:m=null,commenting:h=!1,history:g=0,checks:v=0,onHistory:y=null,onChecks:b=null,onCapture:x=null,captureBusy:S=!1}){let C=$(e=>e.transform),w=$(e=>e.width),T=$(e=>e.height),E=$(e=>e.domNode),[D,k]=(0,J.useState)(null),A=D===e;(0,J.useEffect)(()=>{e||k(null)},[e]);let[j,ee]=(0,J.useState)(null),[M,N]=(0,J.useState)(0);if((0,J.useLayoutEffect)(()=>{let t=e&&E?E.closest(`[data-sw-canvas]`):null,n=t?.querySelector(`[data-sw-canvas-notes]`)||null,r=t?.querySelector(`[data-sw-tool-dock]`)||null,i=()=>{let e=E?.getBoundingClientRect(),t=n?lN(Array.from(n.children).map(e=>e.getBoundingClientRect()),e):null;ee(e=>JSON.stringify(e)===JSON.stringify(t)?e:t);let i=r?lN(Array.from(r.children).filter(e=>!e.hasAttribute(`data-sw-toast`)).map(e=>e.getBoundingClientRect()),e):null;N(i?Math.max(0,Math.round(e.height-i.top)):0)};if(i(),!n&&!r)return;let a=new MutationObserver(i),o=typeof ResizeObserver>`u`?null:new ResizeObserver(i);for(let e of[n,r])e&&(a.observe(e,{childList:!0,subtree:!0,characterData:!0}),o?.observe(e));return()=>{a.disconnect(),o?.disconnect()}},[e,E,w,T]),!e||!t||!n)return null;let[P,F,I]=C,L=(t.x+n.x)*I+P,R=(t.y+n.y)*I+F,z=t.y*I+F-(I>.2?hN:0),te=L+n.w*I,V=R+n.h*I;if(te<0||L>w||V<0||R>T||oy(n,I))return null;let ne=l?54:40,H=mN({canvasWidth:w,touch:l,items:{comment:!!m,live:o?c?`done`:`select`:i?`open`:null,checks:!!b,history:!!y,capture:!!x,link:!!u,checksCount:v>0,historyCount:g>0}}),U=H.width,{place:re,toggle:ie,fallback:ae}=uN({card:{left:L,top:R,right:te,bottom:V,titleTop:z},canvas:{width:w,height:Math.max(ne+16,T-M)},bar:{width:U,height:ne},avoid:j,gap:8,zoom:I,pin:l}),W=l?`touch`:`sm`,G=l?`icon`:`icon-sm`;if(!re&&!A)return(0,Y.jsx)(B,{size:`icon`,variant:`secondary`,style:ie,className:`nodrag nopan absolute z-20 rounded-full bg-surface/95 text-fg shadow-pop`,onClick:t=>{t.stopPropagation(),k(e)},label:`${r} actions`,side:`bottom`,"data-sw-frame-bar-toggle":e,children:(0,Y.jsx)(Ih,{size:18,"aria-hidden":`true`})});let oe=re||ae,ce=re&&re.left<L+n.w*I?{right:w-(oe.left+U),top:oe.top,maxWidth:U}:{left:oe.left,top:oe.top,maxWidth:U},le=v?`${v} need${v===1?`s`:``} attention`:null,ue=`Page history: ${g+1} captures`,de={open:{label:`Open live`,name:`Open live`,icon:Qg,tip:`Open the live page: scroll it, click it`,onSelect:d,data:{"data-sw-open-live":e}},select:{label:`Select text`,name:`Select text`,icon:W_,disabled:!s,pressed:!1,onSelect:f,data:{"data-sw-select-text":e}},done:{label:`Done`,name:`Done`,icon:W_,tip:(0,Y.jsx)(vx,{label:`Done selecting text`,keys:[`Esc`]}),disabled:!s,pressed:!0,onSelect:f,data:{"data-sw-select-text":e}},checks:{label:`Checks`,name:`Page checks`,description:le||void 0,icon:Jh,tip:le?`Page checks: ${le}`:null,count:v||null,warn:!0,onSelect:b,data:{"data-sw-frame-checks":e}},history:{label:`History`,name:ue,icon:g_,tip:ue,count:g?g+1:null,onSelect:y,data:{"data-sw-frame-history":e}},capture:{label:`Capture`,name:`Capture this page`,icon:fh,tip:`Recapture this page at every screen size`,disabled:S,onSelect:x,data:{"data-sw-frame-capture":e}}},fe=e=>{let t=de[e],n=(0,Y.jsxs)(a,{size:W,variant:t.pressed?`soft`:`ghost`,className:O(t.pressed?`shadow-none focus-visible:outline-offset-1`:yN,l&&`text-[13px]`),"aria-label":t.name,"aria-description":t.description,"aria-pressed":t.pressed,disabled:t.disabled,onClick:t.onSelect,...t.data,children:[(0,Y.jsx)(t.icon,{size:vN,"aria-hidden":`true`}),t.label,t.count?(0,Y.jsx)(xN,{tone:t.warn?`warn`:`neutral`,children:t.count}):null]},e);return t.tip&&!l?(0,Y.jsx)(_,{content:t.tip,side:`bottom`,children:n},e):n},pe=H.more?`more`:H.link===`bar`?`link`:`close`,me=e=>O(yN,e===pe&&bN);return(0,Y.jsxs)(`div`,{className:O(`nodrag nopan nowheel absolute z-20 flex w-max flex-nowrap items-center gap-1 overflow-hidden rounded-lg border border-line bg-surface/95 p-1 shadow-pop backdrop-blur`,l&&`rounded-xl`),style:ce,role:`toolbar`,"aria-label":`${r} actions`,"data-sw-frame-bar":e,"data-sw-frame-bar-fit":H.step,onClick:e=>e.stopPropagation(),children:[H.title?(0,Y.jsxs)(`span`,{className:`flex min-w-0 shrink items-center gap-2 pr-1 pl-2`,"data-sw-frame-bar-title":`true`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-semibold text-fg`,title:r,children:r}),(0,Y.jsx)(`span`,{className:O(`shrink-0 rounded bg-surface-2 px-1.5 text-[10.5px] leading-[18px] font-medium text-muted`,!H.chip&&`sr-only`),children:Vv(n.viewport)})]}):null,m?(0,Y.jsx)(CN,{focused:e,size:W,touch:l,active:h,onComment:m},e):null,H.bar.map(fe),H.more?(0,Y.jsx)(_N,{focused:e,title:r,size:G,touch:l,className:me(`more`),actions:H.menu.map(e=>({id:e,...de[e]})),view:C.join(`,`),href:H.link===`menu`?u:null}):null,H.link===`bar`?(0,Y.jsx)(B,{asChild:!0,size:G,className:me(`link`),label:`Open the page in a new tab`,side:`bottom`,"data-sw-frame-bar-link":`true`,children:(0,Y.jsx)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,children:(0,Y.jsx)(Rh,{size:vN,"aria-hidden":`true`})})}):null,(0,Y.jsx)(B,{size:G,className:me(`close`),onClick:re?p:()=>k(null),label:re?`Close`:`Collapse`,side:`bottom`,"data-sw-frame-bar-close":`true`,children:(0,Y.jsx)(se,{size:vN,"aria-hidden":`true`})})]})}function _N({focused:e,title:t,size:n,touch:i,className:o,actions:s,href:c,view:l}){let[u,d]=(0,J.useState)(!1);(0,J.useEffect)(()=>d(!1),[l]);let f=(0,Y.jsx)(T,{asChild:!0,children:(0,Y.jsx)(a,{size:n,variant:`ghost`,className:O(o,`data-[state=open]:bg-surface-2 data-[state=open]:text-fg`),"aria-label":`More actions for ${t}`,"data-sw-frame-more":e,children:(0,Y.jsx)(Ih,{size:vN,"aria-hidden":`true`})})});return(0,Y.jsxs)(je,{open:u,onOpenChange:d,modal:!i,children:[i?f:(0,Y.jsx)(_,{content:`More actions`,side:`bottom`,children:f}),(0,Y.jsxs)(r,{side:`bottom`,align:`end`,className:`min-w-52`,"data-sw-frame-more-menu":e,children:[s.map(e=>(0,Y.jsxs)(D,{disabled:e.disabled,onSelect:e.onSelect,"aria-description":e.description,...e.data,children:[(0,Y.jsx)(e.icon,{size:vN,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count?(0,Y.jsx)(xN,{tone:e.warn?`warn`:`neutral`,children:e.count}):null]},e.id)),c?(0,Y.jsxs)(Y.Fragment,{children:[s.length?(0,Y.jsx)(y,{}):null,(0,Y.jsx)(D,{asChild:!0,"data-sw-frame-bar-link":`true`,children:(0,Y.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,children:[(0,Y.jsx)(Rh,{size:vN,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Open in a new tab`})]})})]}):null]})]})}var vN=16,yN=`text-fg/80 shadow-none hover:text-fg focus-visible:outline-offset-1`,bN=`relative ml-1.5 before:pointer-events-none before:absolute before:top-1/2 before:-left-[5.5px] before:h-5 before:w-px before:-translate-y-1/2 before:bg-line before:content-['']`;function xN({tone:e=`neutral`,children:t}){return(0,Y.jsx)(`span`,{className:O(`tabular -mr-0.5 inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-1 text-[10.5px] leading-none font-semibold`,e===`warn`?`bg-warn/15 text-fg`:`bg-surface-2 text-muted`),"aria-hidden":`true`,children:t})}var SN=2600;function CN({focused:e,size:t,touch:n,active:r,onComment:i}){let[o,s]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(_k())return;vk(),s(!0);let e=window.setTimeout(()=>s(!1),SN);return()=>window.clearTimeout(e)},[]);let c=(0,Y.jsxs)(a,{size:t,variant:r?`default`:`soft`,className:O(`shadow-none focus-visible:outline-offset-1`,n&&`text-[13px]`,o&&!r&&`outline-2 outline-offset-2 outline-accent`),"aria-label":`Comment on this page`,"aria-pressed":r,"aria-keyshortcuts":`C`,onClick:i,"data-sw-frame-comment":e,"data-sw-frame-comment-emphasis":o?`true`:void 0,children:[(0,Y.jsx)(Wg,{size:vN,"aria-hidden":`true`}),` Comment`]});return n?c:(0,Y.jsx)(_,{content:(0,Y.jsx)(vx,{label:`Comment on this page`,keys:[`C`]}),side:`bottom`,children:c})}function wN({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,onComment:g=null,commentTargetKey:_=null}){let v=(0,J.useContext)(Jv);if(!r)return null;let y=r.lastIndexOf(`|`),b=r.slice(0,y),x=r.slice(y+1),S=i.targets[b],C=S?.frames.find(e=>e.viewport===x);if(!C)return null;let w=b.startsWith(`variant:`)?a?.variants?.find(e=>`variant:${e.id}`===b):null,T=w?null:a?.board?.pages.find(e=>e.id===b);return(0,Y.jsx)(gN,{focused:r,target:S,frame:C,title:w?w.title:T?.title||b,hasLive:!!u(b,x),live:o.has(r),ready:s.has(r),selecting:c===r,touch:l,href:T?.url||(w?.source&&/^https?:/.test(w.source)?w.source:null),onOpenLive:()=>d(b,x),onToggleSelect:()=>f(r),onClose:p,onComment:g?e=>g(r,e):null,commenting:_===r,history:T&&a?.versions?.[T.id]?.[x]?.length||0,checks:T&&e&&v?.onChecks?v.checksCount(T.id):0,onChecks:T&&e?()=>e(T.id,x):null,onHistory:T&&n(T.id)?()=>t(T.id,x):null,onCapture:T&&m?()=>m(T.id):null,captureBusy:h})}var TN=(0,J.lazy)(()=>AD(()=>import(`./ShareDialog-D0tmOGcQ.js`).then(e=>({default:e.MigrationBanner})),__vite__mapDeps([10,1,2]),import.meta.url)),EN=()=>{},DN=new Set;function ON(e,t){let n=new Map;for(let r of e||[])n.has(t(r))||n.set(t(r),r);return n}function kN({boardId:e,boards:t,info:n,onPickBoard:r,onInfoChanged:i,onOpenBuzz:a}){let o=ft(`(min-width: 1024px)`),s=ft(`(max-width: 640px)`),c=tf(),l=ue(),u=MO(),[d,f]=v(),p=(0,J.useRef)(d);p.current=d;let h=(0,J.useCallback)(e=>p.current.get(e),[]),[g,_]=(0,J.useState)(!1),y=!n?.readOnly&&(!Ue||w),b=y&&!Ue&&!n?.hosted,x=y&&n?.allowCapture,C=e=>n?.permissions?.[e]!==!1,{view:T,commentsQuery:E,data:D,capture:k,comments:A,fixRequest:j,setFixRequest:ee,setPolling:M,deletingIds:N,setDeletingIds:F}=PM(e),I=te(n?.localProjectsEnabled?`/api/local-projects`:null,{pollMs:3e4}),L=I.data?.projects||[],R=(0,J.useMemo)(()=>D?.viewports||{},[D?.viewports]),z=Object.keys(R),B=(0,J.useMemo)(()=>{let e=z.map(e=>({id:e,label:Vv(e)}));return e.length>1&&e.push({id:`all`,label:e.length===2?`Both`:`All`}),e},[z.join(`,`)]),ne=(0,J.useCallback)(e=>B.find(t=>t.id===e)?.label||e,[B]),H=s&&z.includes(`phone`)?`phone`:z[0]||`desktop`,U=B.some(e=>e.id===d.get(`vp`))?d.get(`vp`):H,re=Uw.some(e=>e.id===d.get(`filter`))?d.get(`filter`):`open`,ie=Number(d.get(`c`))||null,ae=(d.get(`q`)||``).slice(0,120),W=Nv.some(e=>e.id===d.get(`st`))?d.get(`st`):null,oe=/^[a-z][\w.-]{0,39}$/.test(d.get(`m`)||``)?d.get(`m`):null,se=d.get(`panel`)===`off`,{canChecks:ce,checksOpen:le,checksPage:de,checksViewport:fe,checksQuery:pe,openChecks:he,closeChecks:ge,checksCounts:_e,checksPanelProps:ve,checksRun:ye}=GM({boardId:e,info:n,params:d,updateParams:f,pages:D?.board?.pages}),[be,xe]=(0,J.useState)(``),{chatAvailable:Se,chatThread:Ce,settingsAvailable:we,localSettingsAvailable:Te,generalSettingsOpen:Ee,settingsOpen:De,openSettings:Oe,openChat:ke,reopenChat:je}=KM({boardId:e,info:n,params:d,updateParams:f}),K=(0,J.useRef)(null),Me=(0,J.useRef)(JO(d.get(`v`))),Ne=(0,J.useRef)(null),[Pe,Fe]=(0,J.useState)(!1),[Ie,Le]=(0,J.useState)(!1);(0,J.useEffect)(()=>{Pe||Le(!1)},[Pe]);let[Re,Be]=(0,J.useState)(null),[q,He]=(0,J.useState)(null),We=(0,J.useRef)(null);We.current=q;let Ke=(0,J.useRef)(0),qe=(0,J.useCallback)(()=>{let e=Jx.get();return!!We.current&&(!!We.current.body.trim()||Ke.current>0||e?.owner===`composer`&&e.shapes.length>0)},[]),Je=(0,J.useRef)(null),Ye=(0,J.useCallback)(()=>qe()?(Je.current?.()||Mj(),!0):!1,[qe]),[Xe,Ze]=(0,J.useState)(!1);(0,J.useEffect)(()=>{q||Ze(!1)},[q]);let Qe=(0,J.useCallback)(()=>{let e=Jx.get();return!!We.current&&(Ke.current>0||e?.owner===`composer`&&e.shapes.length>0)},[]),[$e,et]=(0,J.useState)(!1),[nt,rt]=(0,J.useState)(!1),it=n?.localUser?.name||``,[at,ot]=(0,J.useState)(()=>m()),st=at||it,ct=(0,J.useCallback)(()=>m()||it,[it]),lt=(0,J.useRef)(null),[ut,dt]=(0,J.useState)(!1),[pt,mt]=(0,J.useState)(null),[ht,gt,_t]=Nj(),[vt,yt]=(0,J.useState)(()=>fk()),bt=vt??pk(D?.board?.pages?.length||0),[xt,St]=(0,J.useState)(!1),Ct=VC(e),[wt,Tt]=(0,J.useState)([]),Et=Ct&&[`working`,`waiting`].includes(Ct.state)&&Number(Ct.commentId)||null,Dt=(0,J.useMemo)(()=>Et?new Set([Et]):DN,[Et]),[Ot,kt]=(0,J.useState)(!1),[At,jt]=(0,J.useState)(null),[Mt,Nt]=(0,J.useState)(null),[Pt,Ft]=(0,J.useState)(null),[It,Lt]=(0,J.useState)(null),[Rt,zt]=(0,J.useState)(()=>!hk()),[Bt,Vt]=FO(!!l),[Ht,Ut]=(0,J.useState)(()=>new Set),Wt=(0,J.useCallback)(e=>Ut(t=>t.has(e)?t:new Set(t).add(e)),[]),Gt=(0,J.useCallback)(()=>{zt(!1),bk()},[]),Kt=()=>{Vt(),Gt()},qt=d.get(`hist`),Jt=d.get(`hv`),{journeys:Yt,journey:Xt,route:Zt,routeGraph:Qt,routePages:$t,step:en,journeyComments:tn}=FM({params:d,data:D,builder:Pt}),nn=d.get(`links`)===`1`,[rn,an]=(0,J.useState)(!1);(0,J.useEffect)(()=>{nn||an(!1)},[nn]);let on=Array.isArray(D?.brokenLinks)?D.brokenLinks:[],sn=on.length?`Arrows for the links between pages; ${on.length} ${on.length===1?`link leads`:`links lead`} to an error`:`Arrows for the links between pages`,{environments:cn,comparePair:ln,changedOnly:un,showDiff:dn,compareQuery:fn,compareData:pn,compareView:mn,setCompare:hn,canCompare:gn,toggleCompare:_n,setChangedOnly:vn}=qM({boardId:e,params:d,updateParams:f,environmentList:D?.environments,setCommentMode:Fe,pageCount:D?.board?.pages?.length||0}),yn=(0,J.useMemo)(()=>{let e=D?.board?.pages||[];return!un||!pn?e:e.filter(e=>(Ov(pn,e.id)||0)>0)},[un,pn,D?.board?.pages]),bn=(0,J.useMemo)(()=>D?.board&&z.length?fy({pages:yn,groups:D.board.groups,variants:D.variants,viewports:R,mode:U,compare:ln}):{nodes:[],edges:[],targets:{}},[D?.board,D?.variants,yn,R,U,ln]),[xn,Sn,Cn]=pm(bn.nodes);(0,J.useEffect)(()=>{Sn(bn.nodes)},[bn.nodes,Sn]);let wn=gm(),[Tn,En]=uk(wn),[Dn,On]=(0,J.useState)(null),[kn,An]=(0,J.useState)(null),jn=(0,J.useCallback)(()=>{On(null),An(null)},[]),Mn=(0,J.useCallback)(()=>{jn(),En(null),c.fitView({...KO,duration:UO(400)})},[jn,c,En]);BM({mode:U,pendingFocus:At,shapeKey:`${ln?.join(`_`)||``}|${un&&pn?yn.length:`all`}`,clearFocus:jn,fitBoard:Mn});let Nn=(0,J.useMemo)(()=>ON(D?.board?.pages,e=>e.id),[D?.board?.pages]),Pn=(0,J.useMemo)(()=>ON(D?.variants,e=>`variant:${e.id}`),[D?.variants]),Fn=(0,J.useCallback)(e=>String(e).startsWith(`variant:`)?Pn.get(e)?.title||``:Nn.get(e)?.title||``,[Nn,Pn]),{visibleComments:In,pinsByTarget:Ln,counts:Rn}=JM({comments:A,query:ae,stateFilter:W,mentionFilter:oe,titleOfPage:Fn,filter:re,journey:Xt,journeyComments:tn}),zn=(0,J.useMemo)(()=>Ve(A),[A]),Bn=(0,J.useMemo)(()=>({name:n?.user?.name||st||``,handle:n?.user?.handle||null}),[n?.user?.name,n?.user?.handle,st]),Vn=y&&!D?.migratedTo?.readOnly&&C(`comment`),Hn=e=>{let t=!!Bn.handle&&e.authorHandle===Bn.handle;return{reply:y&&!D?.migratedTo?.readOnly&&C(`reply`),resolve:y&&!D?.migratedTo?.readOnly&&C(`resolve`),react:y&&!D?.migratedTo?.readOnly&&C(`react`),edit:y&&!D?.migratedTo?.readOnly&&C(`edit`)&&(!n?.hosted||bD({isAuthor:t})),delete:y&&!D?.migratedTo?.readOnly&&C(`delete`)&&(!n?.hosted||xD({role:n.role,isAuthor:t}))}},{seen:Un,markSeen:Wn,markAllSeen:Gn}=_D(e),Kn=(0,J.useMemo)(()=>new Set(A.filter(e=>gD(e,Un,Bn)).map(e=>e.id)),[A,Bn,Un]),qn=A.find(e=>e.id===ie)||null,Jn=uj(o),Yn=(0,J.useMemo)(()=>{let e=new Set;for(let t of A)t.status!==`resolved`&&(t.agentStatus===`working`||Dt.has(t.id))&&e.add(t.pageId);return e},[Dt,A]),Xn=(0,J.useCallback)(e=>Nn.get(e)||null,[Nn]),Zn=(0,J.useCallback)(e=>{if(e.startsWith(`variant:`)){let t=Pn.get(e);return t?`Variant: ${t.title}`:`Removed variant`}return Xn(e)?.title||e},[Pn,Xn]),Qn=D?.manifest?.capturedAt||`none`,$n=(0,J.useRef)(null),{refetch:er}=T,{refetch:tr}=E,{refetch:nr}=fn,rr=(0,J.useCallback)(()=>{let e=`${Qn}|${D?.environments?.map(e=>e.capturedAt).join(`,`)||``}`;$n.current!==e&&($n.current=e,er(),tr(),nr())},[D?.environments,Qn,tr,nr,er]),ir=(0,J.useRef)(!1),[ar,or]=(0,J.useState)(!1),sr=(0,J.useCallback)(e=>{ir.current=e,or(e)},[]),cr=(0,J.useCallback)(e=>{Ye()||(sr(!1),He(null),f({c:e.id}),o||(et(!1),rt(!0)))},[sr,Ye,f,o]),lr=(0,J.useCallback)(()=>{rt(!1),f({c:null}),ir.current&&!o&&et(!0),sr(!1)},[sr,f,o]),[ur,dr]=(0,J.useState)(!1);(0,J.useEffect)(()=>{q||dr(!1)},[q]);let fr=(0,J.useRef)(null);fr.current=ie;let pr=(0,J.useCallback)(()=>{fr.current&&(sr(!1),rt(!1),f({c:null})),o&&We.current&&(qe()?dr(!0):He(null))},[sr,qe,f,o]),mr=(0,J.useCallback)(()=>{let e=We.current;e&&(dr(!1),U!==`all`&&e.viewport!==U&&R[e.viewport]&&f({vp:e.viewport===H?null:e.viewport}),jt({pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y}))},[H,U,f,R]),hr=(0,J.useCallback)(e=>{if(Ye())return;let t=U!==`all`&&e.viewport!==U&&!!R[e.viewport],n=String(e.pageId).startsWith(`variant:`),r=n?Pn.get(e.pageId):null,i=n?r?.pageId:e.pageId,a=!!nC({hasTarget:!!bn.targets[e.pageId],known:!(!i||!Nn.has(i)||n&&!r),changedOnly:un&&!!pn,pageChanged:(Ov(pn,i)||0)>0})?.showAllPages;He(null),jt(e),f({c:e.id,...t?{vp:e.viewport===H?null:e.viewport}:{},...a?{changed:`0`}:{}});let s=[...t?[`viewport`]:[],...a?[`changed`]:[]];Lt(s.length?{id:e.id,at:Date.now(),changes:s,from:U,to:e.viewport,back:{...t?{vp:h(`vp`)}:{},...a?{changed:h(`changed`)}:{}}}:null),o||(et(!1),rt(!0))},[un,pn,H,Ye,bn.targets,U,Nn,h,f,Pn,R,o]);(0,J.useEffect)(()=>{if(!It)return;let e=window.setTimeout(()=>Lt(null),6e3);return()=>window.clearTimeout(e)},[It]);let gr=(0,J.useCallback)(()=>{It&&(f(It.back),Lt(null))},[f,It]),_r=(0,J.useCallback)(e=>{e?.id!=null&>({at:Date.now(),text:`Comment #${e.id} is on a page this view is not showing, so the board stayed put.`})},[gt]),vr=(0,J.useRef)(0),yr=(0,J.useRef)(()=>{}),br=(0,J.useCallback)(e=>yr.current(e),[]);(0,J.useEffect)(()=>()=>window.clearTimeout(vr.current),[]),RM({pendingFocus:At,setPendingFocus:jt,targets:bn.targets,viewports:R,mode:U,flow:c,canvasRef:Ne,wide:o,setSettledZoom:En,onHidden:_r,onLanded:br}),zM({wide:o,nodesReady:wn,initialCamera:Me,selectedCommentId:ie,canvasRef:Ne,nodes:bn.nodes,flow:c,setSettledZoom:En});let xr=(0,J.useRef)(!Me.current&&!ie&&!d.get(`j`)),Sr=(0,J.useRef)(!Me.current&&!!ie),[Cr,wr]=(0,J.useState)(()=>!o||!xr.current);(0,J.useEffect)(()=>{if(!xr.current||!wn||!bn.nodes.length)return;if(xr.current=!1,!o){wr(!0);return}let e=nk(bn.nodes,Ne.current?.getBoundingClientRect());En(null);let t=e?c.setViewport(e):c.fitView(KO);Promise.resolve(t).finally(()=>wr(!0))},[c,bn.nodes,wn,En,o]);let Tr=(0,J.useRef)(!1),Er=()=>{Tr.current=!0},Dr=(0,J.useCallback)(e=>{Tr.current&&(Tr.current=!1,e.preventDefault(),Ne.current?.focus({preventScroll:!0}))},[]),{liveKeys:Or,readyKeys:kr,setLiveReady:Ar,liveFileFor:jr,recomputeLive:Mr,openLive:Nr}=CM({canvasRef:Ne,flow:c,targets:bn.targets,viewports:R,settledZoom:Tn,setSettledZoom:En,comparePair:ln,captures:D?.captures,variantsById:Pn});(0,J.useEffect)(()=>{kn&&!Or.has(kn)&&An(null)},[Or,kn]),(0,J.useEffect)(()=>{Pe&&An(null)},[Pe]);let{openJourney:Pr,closeJourney:Fr,goStep:Ir,chooseJourneyBranch:Lr,startBuilder:Rr,addBuilderStep:zr,saveBuilder:Br,removeJourney:Vr}=MM({onLeave:pr,boardId:e,view:T,updateParams:f,clearFocus:jn,setCommentMode:Fe,journey:Xt,route:Zt,routePages:$t,step:en,builder:Pt,setBuilder:Ft,busy:Ot,setBusy:kt,setNotice:mt,flow:c,targets:bn.targets,nodesReady:wn,mode:U,comparePair:ln,setSettledZoom:En}),Hr=Dn&&!Dn.startsWith(`variant:`)?Hv(Dn):null,Ur=Hr?.targetId||null,Wr=Mt||Ur,Gr=d.get(`la`)===`1`,{presentPages:Kr,shownSteps:qr,hiddenLinkTargets:Jr,edges:Yr,journeyView:Xr}=YM({targets:bn.targets,layoutEdges:bn.edges,links:D?.links,showLinks:nn,showAllLinks:Gr,activePage:Wr,builder:Pt,route:Zt,routeGraph:Qt,routePages:$t,step:en,journey:Xt,targetTitle:Zn}),Zr=(0,J.useCallback)((e,t=null)=>{if(!e||String(e).startsWith(`variant:`))return;let n=U===`all`?z[0]:U;f({hist:e,hv:t&&t!==n?t:null})},[U,f,z.join(`,`)]),Qr=qt&&D?.board?.pages.find(e=>e.id===qt)||null,$r=Jt&&R[Jt]?Jt:U===`all`?z[0]:U,ei=(0,J.useCallback)(()=>f({hist:null,hv:null}),[f]);Je.current=()=>ur?(mr(),!0):!1;let ti=t=>{let n=bn.targets[t];if(!n)return;pr(),En(null);let r=n.frames[0],i=n.frames.map(e=>D?.captures?.[t]?.[e.viewport]).filter(e=>e?.thumb||e?.file);YO(c,n,Ne.current?.getBoundingClientRect(),{phoneCompare:!!ln&&!o,shotUrls:i.map(t=>G(e,`captures`,t.thumb||t.file,Qn))}),r&&On(`${t}|${r.viewport}`)},ni=(0,J.useMemo)(()=>{let e=yn;return[...new Set(e.map(e=>e.group))].map(t=>({group:t,pages:e.filter(e=>e.group===t)}))},[yn]),ri=(0,J.useMemo)(()=>q?{pageId:q.pageId,viewport:q.viewport,x:q.x,y:q.y,anchor:q.anchor}:null,[q?.pageId,q?.viewport,q?.x,q?.y,q?.anchor]),ii=(0,J.useCallback)((e,t,n)=>{let r=bn.targets[e],i=r?.frames.find(e=>e.viewport===t);i&&(c.getZoom()>=3.9?cr(n[0].comment):(En(null),c.fitBounds(XO(r,i,n),{padding:.3,duration:UO(450)})))},[c,bn.targets,cr,En]),{board:ai,view:oi}=ZM({boardId:e,data:D,viewports:R,journeyView:Xr,compareView:mn,commentMode:Pe,canComment:Vn,wide:o,hosted:n?.hosted,imageVersion:Qn,pinsByTarget:Ln,me:Bn,checksCounts:_e,canChecks:ce,agentFocus:Dt,agentWorkingPages:Yn,setLiveReady:Ar,focusedKey:Dn,selectingKey:kn,settledZoom:Tn,selectedComment:qn,draftSpot:ri,unread:Kn,liveKeys:Or,commentTargetKey:Re?.key||null,selectedCommentId:ie,closeThread:lr,builder:Pt,addBuilderStep:zr,goStep:Ir,layout:bn,flow:c,canvasRef:Ne,setSettledZoom:En,setFocusedKey:On,setToast:gt,setDraft:He,keepDraft:Ye,checkDraft:be,setCheckDraft:xe,authorName:ct,selectComment:cr,openCluster:ii,openChecks:he,openHistory:(...e)=>{pr(),Zr(...e)},updateParams:f,defaultMode:H,onImageError:rr});yr.current=e=>{window.clearTimeout(vr.current),oi.set({landedId:e?.id??null}),e?.id!=null&&(vr.current=window.setTimeout(()=>oi.set({landedId:null}),IM))};let si=!!(n?.hosted&&!Ge&&!n?.guest&&n?.role&&e),ci=te(si?`/api/boards/${encodeURIComponent(e)}/agents`:null,{pollMs:15e3}),li=si&&ci.data||null;(0,J.useEffect)(()=>Ae(li?.agents||[]),[li]);let{commentsUrl:ui,applyComment:di,setStatus:fi,replyTo:pi,editComment:mi,reactTo:hi,copyLink:gi,githubIssue:_i,removeComment:vi,sendToAgent:yi,releaseAgent:bi}=NM({onAgentsChanged:ci.refetch,boardId:e,commentsQuery:E,view:T,info:n,localName:st,authorName:ct,setBusy:kt,setNotice:mt,setToast:gt,setDeletingIds:F,selectedCommentId:ie,closeThread:lr,wide:o,filter:re,allowed:C}),xi=(0,J.useMemo)(()=>({attach:Vn&&!Ue&&!n?.guest,draw:Vn&&!Ue,attachNote:Vn&&!Ue&&n?.guest?`Guests on a share link cannot attach images. You can still draw on the page.`:null}),[Vn,n?.guest]),Si=(0,J.useCallback)((t,n)=>{let r=D?.captures?.[t]?.[n];if(!r?.file)return null;let i=String(t).startsWith(`variant:`)?Pn.get(t):null,a=Nn.get(i?i.pageId:t),o=ly(R,n,a?.frameHeight);return o?{src:G(e,`captures`,r.file,Qn),native:o}:null},[e,D?.captures,Qn,Nn,Pn,R]),{draftDescription:Ci,draftTarget:wi,composerProps:Ti}=$M({draft:q,setDraft:He,busy:Ot,setBusy:kt,commentsUrl:ui,applyComment:di,markSeen:Wn,setLocalName:ot,setNotice:mt,updateParams:f,wide:o,filter:re,targetTitle:Zn,people:zn,info:n,media:xi,pageImage:Si}),[Ei,Di]=(0,J.useState)(!1);(0,J.useEffect)(()=>{q||Di(!1),Ie&&q&&(Le(!1),o?Jx.get()?.owner===`composer`&&Jx.set({tool:`box`}):Di(!0))},[Ie,q,o]);let{captureConfirm:Oi,setCaptureConfirm:ki,startCapture:Ai}=QM({boardId:e,view:T,setBusy:kt,setNotice:mt,setPolling:M}),ji=(0,J.useCallback)(e=>{f({v:`${Math.round(e.x)},${Math.round(e.y)},${e.zoom.toFixed(3)}`}),En(e.zoom),Mr()},[Mr,En,f]),[Mi,Ni]=(0,J.useState)(!1),Pi=(0,J.useRef)(!1),Fi=AC({canvasRef:Ne,flow:c,minZoom:GO,maxZoom:4,onRest:ji,handRef:Pi}),Ii=(0,J.useCallback)((e,t)=>{Fi.moving()||ji(t)},[ji,Fi]);V(!!Dn,jn),(0,J.useEffect)(()=>{Dn&&Rt&&Gt()},[Gt,Dn,Rt]),V(Pe,()=>Fe(!1)),V(!!Xt,Fr),V(!!Pt,()=>Ft(null)),TM({commentMode:Pe,setCommentMode:Fe,canComment:Vn,comparePair:ln,setDraft:He,keepDraft:Ye}),EM({journeys:Yt,journey:Xt,builder:Pt,openJourney:Pr,closeJourney:Fr});let[Li,Ri]=eA(o,!1);(0,J.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(),St(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),Ke.current=Ti.media.images.images.length,(0,J.useEffect)(()=>{!Pe&&!qe()&&He(null)},[Pe,qe]),(0,J.useEffect)(()=>{let e=new URLSearchParams(window.location.search);Number(e.get(`c`))&&e.get(`j`)&&f({j:null,step:null,jc:null,jb:null})},[]),(0,J.useEffect)(()=>{qn&&Wn(qn)},[Wn,qn]),(0,J.useEffect)(()=>{qn&&Wt(`open`),Pe&&(Wt(`comment`),vk()),Ce&&Wt(`agent`)},[Ce,Pe,Wt,qn]),VM({nodesReady:wn,data:D,commentsLoaded:E.data,selectedCommentId:ie,selectedComment:qn,initialCamera:Me,focusComment:hr,deletingIds:N,setNotice:mt,updateParams:f});let{threadList:zi,threadIndex:Bi,stepThread:Vi,neighborNote:Hi}=HM({selectedComment:qn,visibleComments:In,focusComment:hr,mode:U,viewports:R,modes:B});(0,J.useEffect)(()=>{let e=null,t=oi.subscribe(()=>{let{hoveredId:t}=oi.get(),n=t===null?null:Ne.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`)}},[oi]);let Ui=e=>{let t=qn||q;t&&e!==`all`&&t.viewport!==e&&pr(),Lt(null),f({vp:e===H?null:e})},Wi=!!(n?.hosted&&!Ge&&D?.agentDispatch),Gi=Wi&&o&&d.get(`ha`)===`1`&&!le,Ki=Wi&&!o&&d.get(`ha`)===`1`&&!le&&!Ce,qi=()=>f({ha:`1`,checks:null,cv:null}),Ji=async t=>{let n=xE();try{await S.post(`/api/agent/boards/${encodeURIComponent(e)}/threads/${n}/profile`,{profileId:t.id}),ke(n)}catch(e){gt({at:Date.now(),text:e.message||`Could not open a chat with ${t.name}.`})}},X=ci.refetch;(0,J.useEffect)(()=>{if(!si)return;let e=e=>{e.detail?.thread||X()};return window.addEventListener(`shapewall:hosted-agents`,e),()=>window.removeEventListener(`shapewall:hosted-agents`,e)},[si,X]);let Yi=A.filter(e=>e.status===`open`).length,Xi=(0,J.useMemo)(()=>mA({comments:A,focus:Ct,approvals:wt,titleOf:Fn,agents:n?.hosted&&D?.agentDispatch?li:null,listening:n?.hosted&&D?.agentDispatch&&D?.agentListening||null}),[li,wt,A,D?.agentDispatch,D?.agentListening,Ct,n?.hosted,Fn]),Zi=Wi?{agents:li,listening:D?.agentListening||null,activity:Xi,approvals:wt.length,titleOf:e=>Fn(A.find(t=>t.id===e)?.pageId),manageUrl:[`admin`,`owner`].includes(n?.role)&&n?.workspace?.id&&n?.project?.id?`/w/${n.workspace.id}/agents/${n.project.id}`:null,onOpenComment:e=>{let t=A.find(t=>t.id===e);t&&(o||f({ha:null}),hr(t))},onChat:Se?Ji:null,onBoardChat:Se?()=>ke(`board`):null,admin:[`admin`,`owner`].includes(n?.role)}:null,Qi=Fw({boardId:e,enabled:!(!Se||D?.migratedTo?.readOnly||!n?.agent?.fixWithAgent||!n?.agent?.configured||n?.hosted&&!Ge),onProgress:()=>{E.refetch(),T.refetch()}}),[$i,ea]=(0,J.useState)(null),ta=e=>{let t=A.find(t=>t.id===e);t?hr(t):ke(_E(e))},na={...Qi,agentName:n?.agent?.label||`agent`,boardId:e,onOpenThread:ta,onConfirm:e=>ea(e)},ra={batch:na,comments:In,filter:re,counts:Rn,onFilter:e=>f({filter:e===`open`?null:e}),selectedId:ie,onHover:ai.onHoverComment,onFocus:e=>{sr(!o),hr(e)},unread:Kn,onMarkAllRead:()=>Gn(A),people:zn,narrow:{query:ae,state:W,mention:oe,onQuery:e=>f({q:e||null}),onState:e=>f({st:e}),onMention:e=>f({m:e}),onClear:()=>f({q:null,st:null,m:null})},canAct:Vn,targetTitle:Zn,touch:!o,onResetBrowserComments:w?()=>{ze(e),f({c:null}),E.refetch(),T.refetch()}:null,journeyFilter:Xt?{name:Xt.name,on:tn,onToggle:()=>f({jc:tn?null:`1`})}:null},ia=qn?{comment:qn,page:Xn(qn.pageId),title:Zn(qn.pageId),people:zn,me:Bn,can:Hn(qn),role:n?.guest?`guest`:n?.role||null,hosted:!!n?.hosted,agents:n?.hosted&&D?.agentDispatch?li:null,onSaveName:ot,media:{...xi,boardId:e,pageImage:Si,pageTitle:Zn(qn.pageId),currentVersion:e=>String(e.pageId).startsWith(`variant:`)?null:Cv(D?.manifest?.pages?.[e.pageId]?.[e.viewport],D?.manifest)},busy:Ot,touch:!o,editingRef:lt,actions:{onReply:pi,onSendToAgent:n?.hosted&&D?.agentDispatch&&!qn.authorGuest&&!qn.authorAgent?yi:null,onReleaseAgent:n?.hosted&&D?.agentDispatch?bi:null,onStatus:fi,onEdit:mi,onDelete:vi,onReact:hi,onCopyLink:gi,onFixAgent:Se&&!D?.migratedTo?.readOnly&&n?.agent?.fixWithAgent&&n?.agent?.configured?e=>{ee({commentId:e.id,nonce:Date.now()}),o||rt(!1),ke(_E(e.id))}:null,onHostedFix:n?.hosted&&!Ge&&Se&&D?.agentDispatch&&!D?.migratedTo?.readOnly&&!qn.authorGuest&&!qn.authorAgent?(e,t)=>{ee({commentId:e.id,nonce:Date.now(),hosted:{agentId:t,dispatchHash:e.dispatchHash}}),o||rt(!1),ke(_E(e.id))}:null,onAskAgent:Se?e=>{o||rt(!1),ke(_E(e.id))}:null,onGithubIssue:!Ue&&n?.github?.ready?_i:null,onHistory:e=>{o||rt(!1),Zr(e.pageId,e.viewport)}},nav:{index:Bi,total:zi.length,onPrev:()=>Vi(-1),onNext:()=>Vi(1),prevNote:Hi(-1),nextNote:Hi(1)},beforeAfter:D?{pairFor:e=>Ev(e,{manifest:D.manifest,captures:D.captures,versions:D.versions}),nativeFor:e=>{let t=String(e.pageId).startsWith(`variant:`)?Pn.get(e.pageId):null,n=Nn.get(t?t.pageId:e.pageId);return ly(R,e.viewport,n?.frameHeight)||null},urlFor:t=>G(e,t.kind,t.file,t.version),onImageError:rr}:null}:null,aa={boardId:e,batch:na,fixRequest:j,onFixDone:()=>{ee(null),ci.refetch(),T.refetch(),E.refetch()},agent:n?.agent,threadId:Ce||`board`,onThread:ke,comments:A,pages:D?.board?.pages||[],captures:D?.captures||{},imageVersion:Qn,defaultViewport:U===`all`?H:U,focused:Hr?{pageId:Hr.targetId,viewport:Hr.viewport}:null,touch:!o,onOpenSettings:we?Oe:null,settingsLocked:!!(Se&&!we&&n?.agent?.settingsLocked),onAgentChanged:i,people:zn,onRunChecks:ye?async()=>{let e=await ye.start({seo:ye.seoDefault});return he(),e}:null,journeys:Yt,checksCounts:ce?_e:null,onBoardChanged:()=>{T.refetch(),E.refetch()},onNavigate:e=>{if(!o&&e.kind!==`check`&&f({chat:null}),e.kind===`comment`){let t=A.find(t=>t.id===e.id);t&&hr(t)}else e.kind===`page`?ti(e.id):e.kind===`journey`?Pr(e.id):e.kind===`check`&&he(e.id)},onRecapture:x&&!ln?e=>e?Ai(null,Array.isArray(e)?e:[e]):ki(!0):Ge?()=>mt({tone:`info`,text:`The demo does not take new captures. On your own board this recaptures the changed pages.`}):null},oa=Jn?`drawing`:q&&o&&!ur?`composing`:Pe&&Vn&&!ln?`picking`:`off`,sa=Vn&&!ln,ca=(0,J.useMemo)(()=>!ln&&(Object.values(D?.captures||{}).some(e=>Object.values(e||{}).some(e=>e?.live))||(D?.variants||[]).some(e=>Object.values(e.files||{}).some(e=>e?.live))),[ln,D?.captures,D?.variants]),la=hj({wide:o,commenting:sa,draw:xi.draw,liveBoard:ca,livePage:Or.size>0||!!kn}),ua=gj({drawing:Jn,commentMode:Pe&&sa,drawArmed:Ie,selecting:!!kn&&o,hand:Mi&&o});Pi.current=ua===`hand`,(0,J.useEffect)(()=>{(Pe||kn||Jn)&&Ni(!1)},[Pe,kn,Jn]);let da=(e,t)=>{sa&&(Pe&&!Ie&&Re?.key===e?Fe(!1):Ye()||(He(null),Le(!1),Fe(!0),Be({key:e,keyboard:t?.detail===0})))},fa=q?`${q.pageId}|${q.viewport}`:null;(0,J.useEffect)(()=>{Re&&(!Pe||Ie||Dn!==Re.key||fa&&fa!==Re.key)&&Be(null)},[Pe,Re,fa,Ie,Dn]);let pa=Re?.keyboard?Re.key:null;(0,J.useEffect)(()=>{if(!pa)return;let{targetId:e,viewport:t}=Hv(pa),n=Ne.current,r=window.requestAnimationFrame(()=>{n?.querySelector(`[data-sw-frame=${JSON.stringify(`${e}:${t}`)}]`)?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(r),window.requestAnimationFrame(()=>{let e=document.activeElement;(!e||e===document.body||e.matches(`[data-sw-frame], .react-flow__node`))&&n?.querySelector(`[data-sw-frame-comment=${JSON.stringify(pa)}]`)?.focus({preventScroll:!0})})}},[pa]);let ma=e=>{let t=Jx.get();e===`select`||e===`hand`?(t?.tool&&Jx.set({tool:null}),An(null),Fe(!1),Ni(e===`hand`),e===`hand`&&jn()):e===`comment`?t?.tool?(Jx.set({tool:null}),Le(!1),Fe(!0)):Pe&&Ie?Le(!1):Fe(e=>!e):e===`draw`?o&&t?Jx.set({tool:t.tool?null:`box`}):Pe&&Ie?Fe(!1):Ye()||(He(null),Fe(!0),Le(!0)):e===`text`&&(kn?An(null):Dn&&Or.has(Dn)&&kr.has(Dn)?(t?.tool&&Jx.set({tool:null}),Fe(!1),An(Dn)):gt({at:Date.now(),text:`Select text works on a live page: click a page, then Open live (or zoom in until it goes live).`}))};(0,J.useEffect)(()=>{if(!kn&&!Mi||Pe)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||OC(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||(e.preventDefault(),An(null),Ni(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[kn,Mi,Pe]);let ha=(0,J.useRef)(ma);ha.current=ma;let ga=la.join(`,`);(0,J.useEffect)(()=>{let e=e=>{let t=yj(e,{tools:ga.split(`,`),busy:!!document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`),handled:e.defaultPrevented&&!tt(e)});t&&(e.preventDefault(),ha.current(t))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ga]);let _a=Jn?`drawing`:oa===`composing`?`composing`:Pe&&sa?`picking`:kn&&o?`text`:null,va=Dj(!o),ya=!o&&(!!q||nt||$e||ut||!!le||!!Ce||Ki),ba=!!D&&la.length>1,xa=ba&&!ya&&!va,Sa=Tj(Ne),Ca=Ej(Ne,!o),wa=Ca?_C(Ca):null,Ta=Ca?vC(Ca):null,Ea=!!_a&&Sa<kj,Da=o&&bt&&!Or.size&&!Xt&&!Pt&&!Ea,Oa=xa?jj(o?{width:Sa,tools:Aj(la.length,!1,_j(la)),left:[Oj.zoomFull,Oj.zoomCompact,0],right:Da?Oj.minimap:0}:{width:Sa,tools:Aj(la.length,!0),left:Xt||Pt?[]:[Oj.fit],margin:Oj.touchMargin}):{shift:0,compact:0,right:!0},ka=()=>f({links:nn?null:`1`}),Aa=()=>{let e=!bt;yt(e),yk(e)},ja=!!Qr||De||Ee||Oi||!o&&le,Ma={data:pe.data,error:pe.error,loading:pe.loading,pages:D?.board?.pages||[],pageId:de,viewport:fe,onSelect:he,onClose:ge,onRefresh:pe.refetch,onEnvironment:e=>f({ce:e}),canComment:Vn,local:!Ue&&!n?.hosted,onView:(e,t)=>{ge(),f({vp:t,page:e}),jt({pageId:e,viewport:t,x:50,y:50})},onDraft:(e,t,n)=>{xe(`${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)),ge(),f({vp:e.viewport}),jt({pageId:e.pageId,viewport:e.viewport,x:50,y:50}),et(!1),Fe(!0),gt({at:Date.now(),text:`Choose a pin on the page, then review and save your comment.`})},...ve},Na=e=>{e.preventDefault(),ge(),o?((se||Ce)&&f({panel:null,chat:null}),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>document.getElementById(`sw-comments`)?.focus()))):et(!0)},Pa=e=>jC(e,e=>{let t=bn.targets[e]?.frames[0];t&&ai.onFocusFrame(e,t.viewport)}),Fa=()=>{ln||pr(),_n()},Ia=eN({canComment:Vn,comparePair:ln,commentMode:Pe,markPicked:Er,setDraft:He,keepDraft:Ye,setCommentMode:Fe,showLinks:nn,toggleLinks:ka,canCompare:gn,toggleCompare:Fa,wide:o,fitBoard:Mn,minimapOn:bt,toggleMinimap:Aa,chatAvailable:Se,reopenChat:je,canChecks:ce,openChecks:he}),La={setMenuOpen:dt,data:D,chatAvailable:Se,chatThread:Ce,reopenChat:je,activity:Xi,openAgentThread:e=>ke(_E(e)),updateParams:f,groupedPages:ni,jumpToPage:ti,modes:B,mode:U,setMode:Ui,journeys:Yt,journey:Xt,canEditJourneys:b,openJourney:Pr,closeJourney:Fr,startBuilder:Rr,openBrokenLinks:()=>an(!0),canChecks:ce,openChecks:he,showLinks:nn,toggleLinks:ka,brokenLinks:on,canCompare:gn,comparePair:ln,toggleCompare:Fa,settingsAvailable:we,openSettings:Oe,capture:k,canCapture:x,busy:Ot,setCaptureConfirm:ki};return(0,Y.jsxs)(AN,{board:ai,view:oi,people:zn,children:[(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,"data-sw-board":e,style:{paddingTop:`env(safe-area-inset-top, 0px)`},children:[(0,Y.jsx)(LD,{}),(0,Y.jsx)(nO,{}),n?.hosted&&D?.agentApprove?(0,Y.jsx)(eO,{boardId:e,onRows:Tt,onOpenThread:Se?ke:null,openThread:Ce||null}):null,(0,Y.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:Na,"data-sw-skip-comments":`true`,children:`Skip to comments`}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[o?(0,Y.jsx)(hM,{...La,info:n,localName:st,onOpenBuzz:a,demo:l,localSettingsAvailable:Te,setShareOpen:_,expanded:Li,onToggle:Ri,openPalette:()=>St(!0),quiet:Jn,pages:D?{groups:ni,journeys:Yt,comments:A,activePage:Wr,journeyId:Xt?.id||null,onPage:ti,onJourney:Pr,canEditJourneys:b,onNewJourney:()=>Rr()}:null}):null,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(aj,{...La,...o&&Wi?{chatAvailable:!0,chatThread:Ce||(Gi?`hosted`:null),reopenChat:qi,openAgentThread:qi}:{},wide:o,info:n,boardId:e,boards:t,localProjects:L,projectsError:I.error,localName:st,onPickBoard:r,onOpenBuzz:a,demo:l,localSettingsAvailable:Te,setShareOpen:_,viewNotice:It,canComment:Vn,minimapOn:bt,toggleMinimap:Aa,linksTip:sn,panelHidden:se,checksOpen:le,allOpen:Yi,closeChecks:ge,setSheetOpen:et,sidebarTitled:o&&Li}),!n?.hosted&&D?.migratedTo?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(TN,{marker:D.migratedTo,boardId:e,editable:!!n?.shareEnabled,onChange:T.refetch})}):null,(0,Y.jsx)(Ij,{notice:pt,setNotice:mt,wide:o}),ln?(0,Y.jsx)(iT,{environments:cn,pair:ln,loading:fn.loading||!pn,error:fn.error?fn.error.message:null,changedPages:pn?.changedPages??0,totalPages:D?.board?.pages?.length||0,changedOnly:un,showDiff:dn,canComment:Vn,canCapture:x,captureBusy:Ot||!!k?.running,touch:!o,onPair:e=>hn(e),onChangedOnly:vn,onShowDiff:e=>f({diff:e?null:`off`}),onCapture:e=>Ai(e),onClose:()=>hn(null)}):null,(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{ref:Ne,tabIndex:-1,className:O(`relative min-w-0 flex-1 outline-none`,oa===`picking`&&`sw-commenting`,ua===`hand`&&`sw-hand`),onKeyDown:Pa,"data-sw-canvas":`true`,"data-sw-comment-flow":oa,children:[nn&&on.length?(0,Y.jsx)(fA,{items:on,open:rn,onOpenChange:an}):null,o&&D?(0,Y.jsx)(dj,{flow:c,canvasRef:Ne,targets:bn.targets,focusFor:e=>((e===`composer`?q?.y:qn?.y)??50)/100,shotFor:(t,n)=>{let r=D.captures?.[t]?.[n];return r?.file?G(e,`captures`,r.thumb||r.file,Qn):null}}):null,Jn?null:(0,Y.jsx)(cj,{wide:o,commentMode:Pe,canComment:Vn,composing:oa===`composing`,parkedDraft:q&&ur?{title:Zn(q.pageId),onReopen:mr,onDiscard:()=>He(null)}:null,showLinks:nn,activePage:Wr,shownSteps:qr,data:D,presentPages:Kr,hiddenLinkTargets:Jr,showAllLinks:Gr,targetTitle:Zn,updateParams:f,tipOpen:Rt,tryOpen:Bt,journey:Xt,builder:Pt,viewNotice:It,undoViewNotice:gr,noticeInSheet:!o&&nt&&It?.id===ie,covered:ya,dismissTip:Gt,modes:B,comparePair:ln}),!D&&T.error?(0,Y.jsx)(_v,{error:T.error,onRetry:T.refetch}):D?(0,Y.jsxs)(cm,{nodes:xn,edges:Yr,edgeTypes:tC,onNodeMouseEnter:nn?(e,t)=>Nt(t.type===`page`?t.id:null):void 0,onNodeMouseLeave:nn?()=>Nt(null):void 0,onNodesChange:Cn,onNodeClick:EN,nodeTypes:qS,colorMode:u,defaultViewport:Me.current||void 0,fitView:Sr.current,style:Cr?void 0:{opacity:0},edgesFocusable:!1,fitViewOptions:KO,minZoom:GO,maxZoom:4,panOnScroll:!1,zoomOnScroll:!1,panActivationKeyCode:null,zoomActivationKeyCode:null,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,zoomOnDoubleClick:!Pe&&ua!==`hand`,onMoveEnd:Ii,onPaneClick:()=>{jn(),ie&&lr()},proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(wm,{gap:40,size:1}),(0,Y.jsx)(wN,{onChecks:ce?he:null,onHistory:(...e)=>{pr(),Zr(...e)},historyCountFor:e=>Mv(D?.versions,e),focusedKey:Jn?null:Dn,layout:bn,data:D,liveKeys:Or,readyKeys:kr,selectingKey:kn,touch:!o,liveFileFor:jr,onOpenLive:Nr,onToggleSelect:e=>An(t=>t===e?null:e),onClose:jn,onCapture:x&&!ln?e=>Ai(null,[e]):null,captureBusy:Ot||!!k?.running,onComment:sa?da:null,commentTargetKey:Pe&&!Ie&&Re?.key||null}),o&&q&&!ur&&!ja?(0,Y.jsx)(lD,{point:_y(bn.targets,q),resetKey:`${q.pageId}|${q.viewport}|${q.x}|${q.y}`,stowed:Jn,onClose:()=>Ot?null:He(null),onEscape:()=>Xe?(Ze(!1),!1):!Qe()||(Ze(!0),!1),children:(0,Y.jsx)(FT,{...Ti,touch:!1,description:Ci,discard:Xe?{onDiscard:()=>He(null),onKeep:()=>Ze(!1)}:null})}):null,o&&ia&&!q&&!ja?(0,Y.jsx)(cD,{comment:qn,point:_y(bn.targets,qn),onClose:lr,stowed:Jn,onPrev:()=>Vi(-1),onNext:()=>Vi(1),editingRef:lt,children:(0,Y.jsx)(GE,{...ia,onClose:lr})}):null,(0,Y.jsx)(sN,{wide:o,clearFocus:jn,setSettledZoom:En,minimapOn:bt,liveKeys:Or,toggleMinimap:Aa,hideFit:!!(Xt||Pt),hideMinimap:!!(Xt||Pt)||Ea||!Oa.right,compact:Oa.compact===1,hideZoom:o&&Oa.compact===2,fitBoard:Mn})]}):(0,Y.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(me,{}),` Loading board`]}),n?.hosted&&!Ge?(0,Y.jsx)(cO,{touch:!o,enabled:!!D&&!Ue,boardId:e,canvasRef:Ne,flow:c,selection:ie,mode:U,onMode:e=>f({vp:e}),onInvalidate:()=>{E.refetch(),T.refetch(),ci.refetch()}}):null,Bt&&D&&!Xt&&!Pt&&!Jn&&(!Pe||o)&&!Ea?(0,Y.jsx)(IO,{touch:!o,chip:!!_a,done:Ht,onOpenComment:()=>{let e=In.filter(e=>e.status===`open`),t=e.find(e=>U===`all`||e.viewport===U)||e[0]||In[0];t&&hr(t)},onComment:Vn&&!ln?()=>{Ye()||(He(null),Fe(!0))}:null,onAgent:Se?je:null,onUsage:l?.usageHref?()=>P(l.usageHref):null,onClose:Kt}):null,ln&&un&&pn&&!yn.length?(0,Y.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,(0,Y.jsxs)(xj,{touch:!o,children:[(0,Y.jsx)(Fj,{toast:ht,setToast:gt,onHold:_t,wide:o}),Pt?(0,Y.jsx)(Zw,{draft:Pt,pages:D?.board?.pages||[],onChange:Ft,onSave:Br,onCancel:()=>Ft(null),pageTitle:e=>Xn(e)?.title||e,busy:Ot,touch:!o}):Xt&&!Jn?(0,Y.jsx)(Xw,{journey:Xt,route:Zt,step:en,pageTitle:e=>Xn(e)?.title||e,onStep:Ir,onChoose:Lr,onClose:Fr,onEdit:()=>Rr(Xt),onDelete:Vr,canEdit:b&&Xt.source===`board`,busy:Ot,touch:!o},Xt.id):null,_a===`drawing`?(0,Y.jsx)(fj,{titleFor:(e,t)=>`${Zn(e)} · ${Vv(t)}`}):_a&&!ya?(0,Y.jsx)(wj,{wide:o,composing:_a===`composing`?{target:wi,onCancel:()=>Ot?null:He(null)}:null,picking:_a===`picking`?{live:Re?kr.has(Re.key):kr.size>0,draw:Ie,page:Re?{key:Re.key,title:Zn(Hv(Re.key).targetId),keyboard:Re.keyboard}:null}:null,selectText:_a===`text`?{title:`${Zn(Hv(kn).targetId)} · ${Vv(Hv(kn).viewport)}`,onDone:()=>An(null)}:null,onDone:()=>Fe(!1)}):null,xa?(0,Y.jsx)(Sj,{tools:la,active:ua,onTool:ma,touch:!o,shift:Oa.shift}):ba&&!o?(0,Y.jsx)(`div`,{className:`h-[52px] shrink-0`,"aria-hidden":`true`}):null]})]}),(0,Y.jsx)(Jj,{wide:o,checksOpen:le,checksProps:Ma,chatThread:Ce,chatProps:aa,panelHidden:se,panelProps:ra,updateParams:f,hostedAgent:Gi?Zi:null})]})]})]}),(0,Y.jsx)(PD,{ref:K})]}),o?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(iM,{hostedAgent:Ki?Zi:null,checksOpen:le,closeChecks:ge,checksProps:Ma,chatAvailable:Se,chatThread:Ce,chatProps:aa,updateParams:f,sheetOpen:$e,setSheetOpen:et,panelProps:ra,viewNotice:It,undoViewNotice:gr,modeLabel:ne,threadSheet:nt,threadProps:ia,closeThread:lr,selectedComment:qn,targetTitle:Zn,draft:q,busy:Ot,setDraft:He,draftDescription:Ci,composerProps:Ti,startDraw:Ei,threadFromList:ar,sheetContentMax:wa,sheetPanelMax:Ta}),(0,Y.jsx)(oj,{...La,chatAvailable:!Wi&&Se,menuOpen:ut,hostedAgents:Wi?{open:qi,list:li}:null})]}),Qi.offered?(0,Y.jsx)(Rw,{open:!!$i,onClose:()=>{ea(null),Qi.setError(null)},ids:$i||[],comments:A,max:Qi.max,agentName:na.agentName,targetTitle:Zn,busy:Qi.busy,error:Qi.error,touch:!o,onStart:async e=>{await Qi.start(e)&&ea(null)}}):null,(0,Y.jsx)(bM,{info:n,boardId:e,boards:t,wide:o,shareOpen:g,setShareOpen:_,refetchView:er,settingsAvailable:we,settingsOpen:De,updateParams:f,onInfoChanged:i,generalSettingsOpen:Ee,updates:K,historyPage:Qr,closeHistory:ei,historyViewport:$r,historyPageId:qt,data:D,comments:A,filter:re,focusComment:hr,onImageError:rr,captureConfirm:Oi,setCaptureConfirm:ki,busy:Ot,focusedPage:Ur,findPage:Xn,startCapture:Ai}),(0,Y.jsx)(Fk,{open:xt,onOpenChange:St,groups:ni,journeys:Yt,canEditJourneys:b,comments:A,titleOf:Zn,actions:Ia,onPage:e=>{Er(),ti(e)},onJourney:e=>{Er(),Pr(e)},onNewJourney:()=>{Er(),Rr()},onComment:e=>{Er(),hr(e)},onCloseAutoFocus:Dr})]})}function AN({board:e,view:t,people:n,children:r}){return(0,Y.jsx)(Jv.Provider,{value:e,children:(0,Y.jsx)(cx.Provider,{value:t,children:(0,Y.jsx)(Bb.Provider,{value:n,children:r})})})}function jN(){let[e,t]=(0,J.useState)(``),[n,r]=(0,J.useState)(null),[i,o]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await S.get(`/api/pairing`);if(!e)return;r(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 S.post(`/api/pairing`,{name:e});r(e=>({...e,pairing:t}))}catch(e){o(e.message)}},c=n?.pairing,l=c?.code,u=/iPad|iPhone|iPod/.test(navigator.userAgent),d=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone;return(0,Y.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,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:`Shapewall`}),(0,Y.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:`Pair this device`})]}),(0,Y.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.`}),n?.ownMachine?(0,Y.jsx)(`p`,{className:`rounded-lg border border-line p-3 text-sm text-muted`,"data-sw-pairing-own-machine":!0,children:`This is the computer that runs Shapewall. Its tailnet address never lets you in by itself, because any program on this computer could ask the same way. Use the private owner link instead: the terminal that started Shapewall printed it, and it opens the board on this computer’s own address.`}):null,c?.state===`pending`?(0,Y.jsxs)(`section`,{className:`space-y-3 rounded-lg border border-line p-4`,"aria-live":`polite`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`Waiting for approval: `,c.name]}),(0,Y.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,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Expires in five minutes. On the host, open Devices or run `,(0,Y.jsxs)(`code`,{children:[`shapewall devices approve `,l]}),`.`]})]}):(0,Y.jsxs)(`form`,{className:`space-y-3`,onSubmit:s,children:[[`denied`,`expired`].includes(c?.state)?(0,Y.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,Y.jsx)(`label`,{htmlFor:`device-name`,className:`block text-sm text-fg`,children:`Device name`}),(0,Y.jsx)(it,{id:`device-name`,required:!0,maxLength:80,placeholder:`My phone`,value:e,onChange:e=>t(e.target.value)}),(0,Y.jsx)(a,{type:`submit`,children:`Request pairing`})]}),i?(0,Y.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:i}):null,n?.secure?null:(0,Y.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,Y.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 MN({info:e}){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),c=e?.remote,l=!!c?.manage;(0,J.useEffect)(()=>{if(!l)return;let e=!0,t=async()=>{try{let t=await S.get(`/api/devices`);e&&i(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 S[e](t),l?i(await S.get(`/api/devices`)):window.location.reload()}catch(e){s(e.message)}};if(!c||!l&&!c.device)return null;let d=r?.pending||[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(a,{size:`sm`,variant:`ghost`,onClick:()=>n(!0),"data-sw-devices-open":!0,children:l?`Devices${d.length?` (${d.length} waiting)`:``}`:c.device.name})}),(0,Y.jsx)(N,{open:t,onClose:()=>n(!1),title:l?`Your devices`:`This device`,children:(0,Y.jsxs)(`div`,{className:`max-h-[70dvh] space-y-4 overflow-auto p-5`,"data-sw-devices":!0,children:[o?(0,Y.jsx)(`p`,{role:`alert`,className:`text-sm text-bad`,children:o}):null,l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsxs)(`section`,{className:`space-y-2 rounded border border-line p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-muted`,children:[e.browser,` · `,e.ip]}),(0,Y.jsxs)(`p`,{className:`font-mono text-lg text-fg`,children:[e.code.slice(0,4),`-`,e.code.slice(4)]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(a,{size:`sm`,onClick:()=>u(`post`,`/api/devices/${e.code}/approve`),children:`Approve`}),(0,Y.jsx)(a,{size:`sm`,variant:`secondary`,onClick:()=>u(`post`,`/api/devices/${e.code}/deny`),children:`Deny`})]})]},e.id)),(r?.devices||[]).map(e=>(0,Y.jsxs)(`section`,{className:`flex items-center justify-between gap-2 rounded border border-line p-3`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0 break-words text-sm text-fg`,children:[e.name,(0,Y.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Last seen `,new Date(e.lastSeenAt).toLocaleDateString()]})]}),(0,Y.jsx)(a,{size:`sm`,variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${e.id}`),children:`Revoke`})]},e.id)),!d.length&&!r?.devices?.length?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No paired devices or requests yet.`}):null]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Paired as `,c.device.name,`. Settings and other devices are managed on the host computer.`]}),(0,Y.jsx)(a,{variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${c.device.id}`),children:`Revoke this device`})]})]})})]})}var NN=(0,J.lazy)(()=>AD(()=>import(`./BuzzDialog-DnjF36OB.js`),__vite__mapDeps([12,1,2]),import.meta.url)),PN=!Ge&&typeof document<`u`&&!!document.querySelector(`meta[name="shapewall-remote"]`);function FN(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),s=o(n);(0,J.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`shapewall:pairing-required`,e),()=>window.removeEventListener(`shapewall:pairing-required`,e)},[]);let c=te(PN?`/api/pairing`:null),l=!PN||[`host`,`device`,`identity`].includes(c.data?.access),u=te(l?`/api/info`:null);uw(u.refetch,!!u.data?.agent);let d=te(l&&u.data?.agent?.configured?`/api/agent/status`:null);uw(d.refetch,!!u.data?.agent?.configured);let f=u.data?.agent?.configured?[u.data.agent,d.data,...d.data?.profiles||[]]:[],p=JSON.stringify(f.map(e=>[e?.label,e?.icon,e?.tint,e?.logo]));(0,J.useEffect)(()=>i(f),[p]);let m=u.data?.agent?.ownerWrites===!0;(0,J.useEffect)(()=>$C(m),[m]);let h=ue(),g=te(l?`/api/boards`:null),[_,y]=v(),x=Array.isArray(g.data?.boards)?g.data.boards:[],S=_.get(`board`),C=x.find(e=>e.id===S)||x[0];b(u.data?.fixturesAt);let w=Ge?h?.shareProblem:null;IN(w?`Share link`:C?.title);let T=Ge&&_.has(`share`);return(0,J.useEffect)(()=>{T&&y({share:null})},[T,y]),PN&&!c.loading&&!l||e||u.error?.code===`pairing_required`||g.error?.code===`pairing_required`?(0,Y.jsx)(jN,{}):w?(0,Y.jsx)(BD,{problem:w,onLeave:h.leaveShare}):g.loading||u.loading?(0,Y.jsx)(mv,{}):g.error?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_v,{error:g.error,onRetry:()=>Promise.all([g.refetch(),u.error?u.refetch():null]),extra:Ge?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{asChild:!0,size:`touch`,variant:`secondary`,className:`lg:h-10`,children:(0,Y.jsx)(`a`,{href:`console.html#/signin`,children:`Sign in to the demo`})}),(0,Y.jsx)(a,{size:`touch`,variant:`ghost`,className:`lg:h-10`,onClick:()=>h?.reset(),children:`Reset the demo`})]}):null}),Ge?(0,Y.jsx)(RD,{}):null]}):C?(0,Y.jsxs)(z,{children:[(0,Y.jsx)(MN,{info:u.data}),u.data?.buzzAvailable===!0&&s?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(NN,{open:n,onClose:()=>r(!1),boardId:C.id},C.id)}):null,(0,Y.jsx)(im,{children:(0,Y.jsx)(kN,{boardId:C.id,boards:x,info:u.data,onInfoChanged:u.refetch,onOpenBuzz:()=>r(!0),onPickBoard:e=>y({board:e,c:null,v:null})})},C.id)]}):(0,Y.jsx)(`div`,{className:`flex h-full bg-sunken`,children:(0,Y.jsx)(j,{size:`lg`,icon:bg,title:`No boards yet`,children:u.data?.hosted?(0,Y.jsxs)(Y.Fragment,{children:[`Capture your site locally, then run `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall push`}),` with a project token.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Add pages to `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall.config.json`}),`, then run`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall capture`}),`.`]})})})}function IN(e){(0,J.useEffect)(()=>{if(!Ge||!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 LN(){typeof navigator<`u`&&`serviceWorker`in navigator&&window.isSecureContext&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`./sw.js`,{scope:`./`}).catch(()=>{})})}var RN=/^(?=[A-Za-z0-9_-]*\d)(?=[A-Za-z0-9_-]*[A-Za-z])[A-Za-z0-9_-]{24,}$/;function zN(e){if(typeof e!=`string`)return;let t=e.replace(/[?#][\s\S]*$/,``).match(/^([a-z][a-z0-9+.-]*:\/\/[^/]*)?([\s\S]*)$/i);return(t[1]||``).replace(/^([a-z][a-z0-9+.-]*:\/\/)[^@/]*@/i,`$1`)+t[2].split(`/`).map(e=>RN.test(e)?`[token]`:e).join(`/`)}var BN=new Set([`navigation`,`fetch`,`xhr`]);function VN(e){if(!e||!BN.has(e.category))return null;let t=e.data||{},n={};return e.category===`navigation`?(t.from!==void 0&&(n.from=zN(String(t.from))),t.to!==void 0&&(n.to=zN(String(t.to)))):(t.url!==void 0&&(n.url=zN(String(t.url))),typeof t.method==`string`&&(n.method=t.method),Number.isInteger(t.status_code)&&(n.status_code=t.status_code)),{type:e.type,category:e.category,level:e.level,timestamp:e.timestamp,data:n}}function HN(e){if(e&&Array.isArray(e.frames))for(let t of e.frames)delete t.vars,typeof t.abs_path==`string`&&(t.abs_path=zN(t.abs_path)),typeof t.filename==`string`&&(t.filename=zN(t.filename))}function UN(e){return e.replace(/["“][\s\S]*["”]|["“][\s\S]*$/,`"[redacted]"`)}function WN(e){if(!e||typeof e!=`object`)return e;if(delete e.user,delete e.extra,delete e.server_name,e.request){let t=Object.entries(e.request.headers||{}).find(([e])=>e.toLowerCase()===`user-agent`)?.[1];e.request={...e.request.method?{method:e.request.method}:{},...e.request.url?{url:zN(e.request.url)}:{},...typeof t==`string`?{headers:{"User-Agent":t}}:{}}}typeof e.transaction==`string`&&(e.transaction=zN(e.transaction)),Array.isArray(e.breadcrumbs)&&(e.breadcrumbs=e.breadcrumbs.map(VN).filter(Boolean));for(let t of e.exception?.values||[])HN(t.stacktrace),typeof t.value==`string`&&(t.value=UN(t.value));typeof e.message==`string`&&(e.message=UN(e.message)),e.logentry&&typeof e.logentry.message==`string`&&(e.logentry={message:UN(e.logentry.message)});for(let t of e.threads?.values||[])HN(t.stacktrace);if(e.contexts){if(e.contexts.device){let{type:t,family:n,model:r,arch:i}=e.contexts.device;e.contexts.device=Object.fromEntries(Object.entries({type:t,family:n,model:r,arch:i}).filter(([,e])=>e!==void 0))}delete e.contexts.app?.app_memory,delete e.contexts.culture,delete e.contexts.cloud_resource}return e}var GN=`shapewall:chunk-reload:`,KN=!1,qN=()=>{try{return typeof window<`u`?window.sessionStorage:null}catch{return null}},JN=()=>({storage:qN(),release:CD.revision||CD.version,path:typeof window<`u`?window.location.pathname:`/`,now:Date.now(),reload:()=>window.location.reload()}),YN=e=>({...JN(),...e}),XN=({release:e,path:t})=>GN+String(e).slice(0,12)+`:`+t,ZN=(e,t)=>{try{return e?e.getItem(t):null}catch{return null}},QN=(e,t,n)=>{try{e?.setItem(t,n)}catch{}},$N=(e,t)=>{let n=Number(ZN(e.storage,t));return Number.isFinite(n)&&n>0&&e.now-n<6e5},eP=e=>{let t=String(e?.message||e||``).toLowerCase();return t.includes(`failed to fetch dynamically imported module`)||t.includes(`error loading dynamically imported module`)||t.includes(`importing a module script failed`)||t.includes(`unable to preload css`)||t.includes(`failed to load module script`)||t.includes(`chunkloaderror`)||t.includes(`loading chunk`)},tP=()=>KN,nP=(e,t)=>{if(!eP(e))return!1;if(KN)return!0;let n=YN(t);return n.storage?!$N(n,XN(n)):!1},rP=(e,t)=>{if(!eP(e))return!1;if(KN)return!0;let n=YN(t),r=XN(n);if($N(n,r))return!1;let i=String(n.now);return QN(n.storage,r,i),ZN(n.storage,r)===i&&(KN=!0,n.reload(),!0)},iP=(e,t)=>{if(KN)return!1;if(!eP(e))return!0;let n=YN(t),r=XN(n)+`:reported`;return!$N(n,r)&&(QN(n.storage,r,String(n.now)),!0)};function aP(e=typeof window<`u`?window:null){e&&(e.addEventListener(`vite:preloadError`,e=>{rP(e?.payload)}),e.addEventListener(`unhandledrejection`,e=>{rP(e?.reason)}),e.addEventListener(`error`,e=>{rP(e?.error||e?.message)}))}var oP=null,sP=!1,cP=[],lP=5,uP=e=>{try{oP.captureException(e)}catch{}},dP=e=>document.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`)?.trim()||``;function fP(){let e=dP(`shapewall-error-dsn`);if(!e)return;sP=!0;let t=dP(`shapewall-error-environment`)||`production`;AD(()=>import(`./error-reports-sdk-COuSIAQO.js`).then(n=>{n.init({dsn:e,environment:t,release:`0b45aa2`,sendDefaultPii:!1,tracesSampleRate:0,maxBreadcrumbs:20,integrations:e=>e.filter(e=>![`BrowserSession`,`Breadcrumbs`].includes(e.name)).concat(n.breadcrumbsIntegration({console:!1,dom:!1,fetch:!0,xhr:!0,history:!0,sentry:!1})),beforeSend:e=>tP()?null:WN(e),beforeBreadcrumb:e=>VN(e)}),oP=n,cP.splice(0).forEach(uP)}),[],import.meta.url).catch(()=>{})}function pP(e){sP&&iP(e)&&(oP?uP(e):cP.length<lP&&cP.push(e))}function mP(){return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-40 items-center justify-center gap-2 bg-sunken p-6 text-sm text-muted`,"data-sw-chunk-recovering":!0,children:[(0,Y.jsx)(me,{}),(0,Y.jsx)(`span`,{role:`status`,children:`Updating to the latest version…`})]})}function hP({error:e}){let t=eP(e);return(0,Y.jsx)(`div`,{className:`flex h-full overflow-y-auto bg-sunken`,role:`alert`,"data-sw-chunk-failed":!0,children:(0,Y.jsx)(j,{size:`lg`,tone:`bad`,icon:nv,title:`This part of Shapewall did not load`,details:e?.message?String(e.message):null,action:(0,Y.jsxs)(a,{size:`touch`,variant:`default`,className:`lg:h-10`,onClick:()=>window.location.reload(),"data-sw-chunk-reload":!0,children:[(0,Y.jsx)(b_,{size:15,"aria-hidden":`true`}),` Reload`]}),children:t?`Shapewall may have been upgraded while this tab was open, or the connection dropped. Reload to get the current version.`:`Something went wrong while showing this. Reload to try again.`})})}var gP=class extends J.Component{state={error:null,recovering:!1};static getDerivedStateFromError(e){return{error:e,recovering:nP(e)}}componentDidCatch(e){rP(e)||(this.state.recovering&&this.setState({recovering:!1}),pP(e))}render(){return this.state.error?this.state.recovering?(0,Y.jsx)(mP,{}):this.props.fallback??(0,Y.jsx)(hP,{error:this.state.error}):this.props.children}},_P=900;function vP(){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 yP(){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`),_P)))},{capture:!0,passive:!0})}typeof document<`u`&&vP()&&(document.documentElement.classList.add(`sw-scrollbars`),yP()),fP(),aP(),document.querySelector(`meta[name="shapewall-agent-settings"]`)?AD(async()=>{let{default:e}=await import(`./Management-BGdmGtby.js`);return{default:e}},__vite__mapDeps([13,8,1,2,5,3]),import.meta.url).then(({default:e})=>(0,_t.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(gP,{children:(0,Y.jsx)(e,{})}))):((0,_t.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(J.StrictMode,{children:(0,Y.jsx)(gP,{children:(0,Y.jsx)(FN,{})})})),LN());export{Kg as $,RC as A,J_ as B,ww as C,fw as D,Sw as E,jv as F,A_ as G,H_ as H,cv as I,v_ as J,E_ as K,iv as L,Dx as M,Ex as N,Cw as O,Ox as P,Jg as Q,nv as R,pw as S,yw as T,R_ as U,K_ as V,I_ as W,m_ as X,g_ as Y,u_ as Z,IT as _,Sh as _t,JD as a,Sg as at,kw as b,jE as c,og as ct,PE as d,Jh as dt,Wg as et,xE as f,Wh as ft,eE as g,Eh as gt,QT as h,Mh as ht,AO as i,Og as it,MC as j,uw as k,AE as l,ng as lt,NE as m,Ih as mt,hO as n,Mg as nt,CD as o,gg as ot,bE as p,Rh as pt,S_ as q,gO as r,Ag as rt,wD as s,ug as st,WO as t,Pg as tt,yE as u,Xh as ut,Vw as v,vh as vt,bw as w,xw as x,Ow as y,oh as yt,ev as z};
|