product-doc 0.14.1 → 0.14.2

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlights-NUSPeu9U.js","assets/stream-tokenizer-8imCpDcl.js","assets/shiki-CTIyHrkn.js","assets/core-BkcJpkJE.js","assets/elk.bundled-CVOErv1M.js","assets/rolldown-runtime-Dd_uD5pT.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlights-nN81K30Y.js","assets/stream-tokenizer-D5CKTlAR.js","assets/shiki-CqdI0RHM.js","assets/core-cZCITU9I.js","assets/elk.bundled-CVOErv1M.js","assets/rolldown-runtime-Dd_uD5pT.js"])))=>i.map(i=>d[i]);
2
2
  import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.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 r=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function ee(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function te(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),te(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=te(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=te(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return te(ee(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function N(e,t,n){if(e==null)return e;var r=[],i=0;return te(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ne(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var re=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function P(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,re)}catch(e){re(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ie(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else P(ie.bind(null,e))}var F={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=F,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ie,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ne}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=P,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),i=n(((e,t)=>{t.exports=r()})),a=n((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}}}})),o=n(((e,t)=>{t.exports=a()})),s=n((e=>{var t=i();function n(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 r(){}var a={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.0`})),c=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=n((e=>{var t=o(),n=i(),r=c();function a(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 s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(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 u(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 d(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 f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(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)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(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 _(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 v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(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)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(a(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(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 E(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 D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),ee=Symbol.for(`react.profiler`),te=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),P=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),F=Symbol.for(`react.lazy`),ae=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case ee:return`Profiler`;case M:return`StrictMode`;case re:return`Suspense`;case P:return`SuspenseList`;case ae:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case N:return e.displayName||`Context`;case te:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ie:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case F:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var me=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var Se=ye(null),Ce=ye(null),we=ye(null),Te=ye(null);function Ee(e,t){switch(xe(we,t),xe(Ce,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?mp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=mp(t),e=hp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}be(Se),xe(Se,e)}function De(){be(Se),be(Ce),be(we)}function Oe(e){var t=e.memoizedState;t!==null&&(uh._currentValue=t.memoizedState,xe(Te,e)),t=Se.current;var n=hp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function ke(e){Ce.current===e&&(be(Se),be(Ce)),Te.current===e&&(be(Te),uh._currentValue=ge)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Ae+e+je}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!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(`
@@ -73,7 +73,7 @@ function print() { __p += __j.call(arguments, '') }
73
73
  }
74
74
  `,LG=B(Fd.md,Vd.subtle,{overflow:`hidden`,minWidth:0}),RG=B(J({size:`xs`,fontWeight:500,color:`lowContrast`}),Y.padding({x:6,y:4}),Md([`bottom`],`border`),{margin:0,overflowWrap:`anywhere`,backgroundColor:G.gray[2]});function zG(e){return{theme:PG,themeType:e.themeType,overflow:`wrap`,diffStyle:`unified`,unsafeCSS:`${FG}
75
75
  [data-diffs-header] [data-additions-count],
76
- [data-diffs-header] [data-deletions-count] { display: none; }`,disableFileHeader:e.disableFileHeader}}function BG(e,t,n){let r=t===`deletions`?`deletion`:`addition`,i=e.hunks.find(e=>n>=e[`${r}Start`]&&n<e[`${r}Start`]+e[`${r}Count`]);if(e.isPartial&&i===void 0)return;let a=e.isPartial&&i!==void 0?i[`${r}LineIndex`]+n-i[`${r}Start`]:n-1;return e[`${r}Lines`][a]?.replace(/\r?\n$/,``)}function VG(e){return{theme:PG,themeType:e,overflow:`wrap`,unsafeCSS:FG}}var HG=`diffs-container`,UG=(()=>{try{return!1}catch{return!1}})(),WG=/(?=^From [a-f0-9]+ .+$)/m,GG=/(?=^diff --git)/gm,KG=/(?<=\n)/,qG=/^(---|\+\+\+)\s+([^\t\r\n]+)/,JG=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,YG=`header-prefix`,XG=`header-filename-suffix`,ZG=`header-metadata`,QG=`header-custom`,$G={dark:`pierre-dark`,light:`pierre-light`},eK=`data-theme-css`,tK=`data-unsafe-css`,nK=`data-diffs-scrollbar-measure`,rK=`data-diffs-code-view-header`,iK=`data-diffs-code-view-footer`,aK=`--diffs-scrollbar-gutter-measured`,oK=1e5,sK={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},cK={...sK,hunkLineCount:1},lK={paddingTop:8,paddingBottom:8,gap:8},uK={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},dK=Object.freeze({fromStart:0,fromEnd:0}),fK={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},pK=Object.freeze([]),mK={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},hK,gK=0,_K=class extends Error{constructor(){super(`Highlighter is disposed`),this.name=`HighlighterDisposedError`}};function vK(){return hK}function yK(e){return e??hK??`shiki-js`}function bK(e){if(hK!=null&&hK!==e)throw Error(`Cannot load the "${e}" highlighter while "${hK}" is in use. Only one highlighter type can be active at a time; dispose every "${hK}" instance (disposeHighlighter() disposes the shared one) before switching.`)}function xK(e){bK(e),hK=e,gK++}function SK(){gK--,gK===0&&(hK=void 0)}var CK=new Map,wK=new Map,TK=new Map,EK=new Set;function DK(e=$G){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function OK(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}function kK(e){let t;return()=>t??=e().then(e=>(t=e,e),e=>{throw t=void 0,e})}function AK(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var jK=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},MK=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},NK=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function PK(e={}){let t=new Map,n=new Map,r=new Map,i=0;function a(e,n){if(t.has(e))throw new jK(e);t.set(e,n)}function o(e,n){return!t.has(e)&&(t.set(e,n),!0)}function s(e){return t.has(e)}function c(a){let o=n.get(a);if(o!==void 0)return Promise.resolve(o);let s=r.get(a);if(s!==void 0)return s;let c=t.get(a);if(c===void 0&&e.fallbackLoader===void 0)return Promise.reject(new MK(a));let l=i,u=Promise.resolve().then(()=>c===void 0?e.fallbackLoader?.(a):c()).then(async t=>{if(t===void 0)throw new MK(a);let o=AK(t),s=e.normalizeTheme===void 0?o:await e.normalizeTheme(o,a);return l===i&&n.set(a,s),r.get(a)===u&&r.delete(a),s}).catch(e=>{throw r.get(a)===u&&r.delete(a),e});return r.set(a,u),u}function l(e){return Promise.all(e.map(e=>c(e)))}function u(e,t){n.set(e,t)}function d(e){for(let[t,n]of e)u(t,n)}function f(e){return n.get(e)}function p(e){let t=[];for(let r of e){let e=n.get(r);if(e===void 0)throw new NK(r);t.push(e)}return t}function m(e){return n.has(e)}function h(e){for(let t of e)if(!n.has(t))return!1;return!0}function g(e){let t=n.get(e);return t===void 0?c(e):t}function _(){i++,n.clear(),r.clear()}return{clearResolvedThemes:_,getResolvedOrResolveTheme:g,getResolvedTheme:f,getResolvedThemes:p,hasRegisteredTheme:s,hasResolvedTheme:m,hasResolvedThemes:h,registerTheme:a,registerThemeIfAbsent:o,resolveTheme:c,resolveThemes:l,seedResolvedTheme:u,seedResolvedThemes:d}}var FK=new Map,IK=new Map,LK=kK(()=>YW(()=>import(`./loader-Cvp9wZb2.js`),[])),RK=kK(()=>YW(()=>import(`./themes-CGzFOfgV.js`),[])),zK=kK(()=>YW(()=>import(`./core-BkcJpkJE.js`),[])),BK=[[`editor.lineHighlightBackground`,`editor.active_line.background`],[`editor.selectionBackground`,`element.selected`],[`editor.findMatchBackground`,`search.match_background`],[`editor.findMatchHighlightBackground`,`search.match_background`],[`editorBracketMatch.background`,`editor.document_highlight.bracket_background`],[`editorError.foreground`,`error`],[`editorWarning.foreground`,`warning`],[`editorInfo.foreground`,`info`],[`editorHint.foreground`,`hint`],[`gitDecoration.addedResourceForeground`,`created`,`terminal.ansi.green`],[`gitDecoration.deletedResourceForeground`,`deleted`,`terminal.ansi.red`],[`gitDecoration.modifiedResourceForeground`,`modified`,`terminal.ansi.blue`]];function VK(e,t){let n=`themes`in t?t.themes[0]:t;if(n==null)throw Error(`Theme "${e}" is an empty Zed theme family.`);let r={...n,name:e},i={};for(let[e,t]of Object.entries(r.style))typeof t==`string`&&(i[e]=t);let a=r.style.players?.[0];a?.cursor!=null&&(i[`editorCursor.foreground`]??=a.cursor),a?.selection!=null&&(i[`editor.selectionBackground`]??=a.selection);for(let[e,...t]of BK){if(i[e]!=null)continue;let n=t.find(e=>i[e]!=null);n!=null&&(i[e]=i[n])}if(r.cssVariables===!0)i[`editor.foreground`]=`var(--hls-foreground)`,i[`editor.background`]=`var(--hls-background)`;else if(typeof r.cssVariables==`object`){i[`editor.foreground`]??=i.text??i.foreground??`foreground`,i[`editor.background`]??=i.background??`background`;let{prefix:e=`--hls-`,defaults:t}=r.cssVariables;for(let[n,r]of Object.entries(i)){let a=t?.[r];i[n]=`var(${e}${r}${a?`, ${a}`:``})`}}let o=r.appearance===`light`?`light`:`dark`;return{name:e,type:o,colors:i,zed:r,fg:i[`editor.foreground`]??i.text??i.foreground??(o===`light`?`#333333`:`#bbbbbb`),bg:i[`editor.background`]??i.background??(o===`light`?`#ffffff`:`#1e1e1e`)}}function HK(e){let t=IK.get(e);return t??(t=PK({fallbackLoader:async t=>{if(typeof __DIFFS_WORKER__<`u`?__DIFFS_WORKER__:OK())throw Error(`Theme "${t}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedThemes parameter.`);let n=FK.get(t);if(e===`highlights`){let e=n?.zed??n?.diffs;if(e!=null){let n=await e(),r=`default`in n?n.default:n;if(`zed`in r&&r.zed!=null)return r;if(`style`in r||`themes`in r)return VK(t,r);throw Error(`Theme "${t}" is a TextMate theme; register a Zed theme with registerCustomTheme(name, loader, 'zed') for Highlights.`)}let r=LK(),{themes:i}=r instanceof Promise?await r:r,a=i[t];if(a!=null)return VK(t,(await a()).default);if(n?.textmate!=null)throw Error(`Theme "${t}" is only registered for TextMate; use registerCustomTheme(name, loader, 'zed') for Highlights.`)}else{let e=n?.textmate??n?.diffs,r;if(e!=null){let t=await e();r=`default`in t?t.default:t}else{let e=RK(),{themes:i}=e instanceof Promise?await e:e,a=i.getTheme(t);if(a==null&&n?.zed!=null)throw Error(`Theme "${t}" is only registered for Zed; use registerCustomTheme(name, loader, 'textmate') for Shiki.`);if(a==null)throw Error(`No valid theme loader registered for "${t}"`);let o=await a.load();r=`default`in o?o.default:o}if(`style`in r||`themes`in r)throw Error(`Theme "${t}" is a Zed theme; use preferredHighlighter: 'highlights' or register a TextMate theme for Shiki.`);let i=zK(),{normalizeTheme:a,createCssVariablesTheme:o}=i instanceof Promise?await i:i;if(`cssVariables`in r&&r.cssVariables!=null)return{...r,textmate:a(o(r.cssVariables))};if(`textmate`in r&&r.textmate!=null)return{...r,textmate:a(r.textmate)};let s=a(r);return{name:s.name,type:s.type,fg:s.fg,bg:s.bg,colors:s.colors,textmate:s}}throw Error(`No valid theme loader registered for "${t}"`)},normalizeTheme:(e,t)=>{if(e.name!==t)throw Error(`resolvedTheme: themeName: ${t} does not match theme.name: ${e.name}`);return e}}),IK.set(e,t),t)}function UK(e,t=yK()){return typeof t!=`string`&&t.isDisposed?!1:(typeof t==`string`?HK(t):t.themeResolver).hasResolvedThemes(DK(e))}var WK;async function GK(e){let t=yK(e);xK(t);try{if(t===`highlights`){let{HighlightsHighlighter:e}=await YW(async()=>{let{HighlightsHighlighter:e}=await import(`./highlights-NUSPeu9U.js`);return{HighlightsHighlighter:e}},__vite__mapDeps([0,1]));return new e}let{ShikiHighlighter:e}=await YW(async()=>{let{ShikiHighlighter:e}=await import(`./shiki-CTIyHrkn.js`);return{ShikiHighlighter:e}},__vite__mapDeps([2,3,1]));return await e.create(t)}finally{SK()}}async function KK({themes:e,langs:t,preferredHighlighter:n}){qK();let r=WK??=GK(vK()??n),i;try{i=await r}catch(e){throw WK===r&&(WK=void 0),e}if(WK===r&&(WK=i),await Promise.all([i.themeResolver.resolveThemes(e),i.loadLanguages(t)]),i.isDisposed)throw new _K;return i}function qK(){WK!=null&&!(`then`in WK)&&WK.isDisposed&&(WK=void 0)}function JK({theme:e,lang:t,langs:n}={}){qK();let r=WK;if(!(r==null||`then`in r||e!=null&&!UK(e,r)||(t!=null||n!=null)&&!r.hasLoadedLanguages([...t==null?[]:[t],...n??[]])))return r}async function YK(e){await KK(e)}var XK=new Set,ZK=null;function QK(e){XK.add(e),ZK??=requestAnimationFrame(eq)}function $K(e){XK.delete(e)&&XK.size===0&&ZK!=null&&(cancelAnimationFrame(ZK),ZK=null)}function eq(e){let t=new Set(XK);XK.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}ZK=XK.size>0?requestAnimationFrame(eq):null}function tq(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function nq(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function rq(e,t){let n=e?.theme??$G,r=t?.theme??$G,i=iq(e),a=iq(t);return nq(n,r)&&tq(e,t,[`theme`,`parseDiffOptions`])&&tq(i,a)}function iq(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}function aq(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function oq({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:a}){let o=n+a*2,s=r?n+i*2:o;if(t=Math.max(t,s),o>=t||r){let n=Math.max(e-i,0),r=Math.min(e+s,t);return{top:n,bottom:Math.max(r,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t),c))}}function sq(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function cq(e){return{type:`text`,value:e}}function lq({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function uq({name:e,width:t=16,height:n=16,properties:r}){return lq({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[lq({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function dq(e){return lq({tagName:`div`,properties:{"data-gutter":``},children:e})}function fq(e,t,n,r={}){return lq({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[lq({tagName:`span`,properties:{"data-line-number-content":``},children:[cq(`${t}`)]})]})}function pq(e,t,n){return lq({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function mq(){return lq({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[uq({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}var hq=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),gq=new Set([`svg`,`template`,`script`,`style`]),_q={class:`class`,className:`class`,id:`id`,role:`role`,style:`style`,tabIndex:`tabindex`,tabindex:`tabindex`,title:`title`},vq=/^data-[\w.:-]+$/,yq=/[<&]/g,bq=/[\0"&'`]/g,xq={"<":`&#x3C;`,"&":`&#x26;`,'"':`&#x22;`,"'":`&#x27;`,"`":`&#x60;`,"\0":`&#x0;`},Sq=256;function Cq(e){let t=new Map;return Array.isArray(e)?wq(e,t):Tq(e,t)}function wq(e,t){let n=``;for(let r of e)n+=Tq(r,t);return n}function Tq(e,t){switch(e.type){case`text`:return kq(e.value);case`element`:return Eq(e,t);case`root`:return wq(e.children,t);default:return UW(e)}}function Eq(e,t){let{tagName:n}=e;if(n===`span`&&e.children.length===1&&e.children[0].type===`text`&&typeof e.properties?.style==`string`){let n=!0;for(let t in e.properties)if(t!==`style`&&e.properties[t]!=null){n=!1;break}if(n)return`<span ${Dq(e.properties.style,t)}>${kq(e.children[0].value)}</span>`}if(gq.has(n))return UW(e);let r=Oq(e.properties,t);if(r==null)return UW(e);let i=r===``?`<${n}>`:`<${n} ${r}>`,a=wq(e.children,t);return a===``&&hq.has(n.toLowerCase())?i:`${i}${a}</${n}>`}function Dq(e,t){let n=t.get(e);return n??(n=`style="${Aq(e)}"`,t.size<Sq&&t.set(e,n)),n}function Oq(e,t){let n=``;for(let r in e){let i=e[r];if(i==null)continue;let a=_q[r]??(vq.test(r)?r:void 0);if(a==null)return;if(i===!1||typeof i==`number`&&Number.isNaN(i))continue;let o=r===`style`&&typeof i==`string`?Dq(i,t):i===!0?a:`${a}="${Aq(Array.isArray(i)?i.join(` `).trim():String(i))}"`;n+=n===``?o:` ${o}`}return n}function kq(e){return e.indexOf(`<`)<0&&e.indexOf(`&`)<0?e:e.replace(yq,jq)}function Aq(e){return e.replace(bq,jq)}function jq(e){return xq[e]}function Mq(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function Nq(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var Pq=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),$K(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||aq(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;(this.isSelectionDirty()||n||i)&&(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;(this.isSelectionDirty()||r||i)&&(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&Nq(e.composedPath())||(eJ(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;(t!==`disabled`||o||n!=null||r!=null||i!=null||a!=null)&&(eJ(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(eJ(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){eJ(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();eJ(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);eJ(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=zq(i)&&this.hoveredLine?.lineElement===i.lineElement;Rq(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),Rq(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),zq(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(Vq(i)&&p!=null){p(i);break}if(Bq(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!zq(i))break;Rq(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,eJ(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),eJ(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),eJ(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();Nq(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(Mq(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=Cq(mq());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);Lq(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(Wq(t));if(Lq(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(Lq(n)&&(!t||n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(Lq(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&Nq(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=Wq(e);if(t&&Nq(n))return;let r=Gq(e);return r==null?this.pathFromAnnotationSlot(e):Wq(r)}pathFromAnnotationSlot(e){let t=Kq(e)?.previousElementSibling;if(t instanceof HTMLElement&&(t.hasAttribute(`data-line`)||t.hasAttribute(`data-column-number`)))return Wq(t);let n=Jq(qq(e));if(n==null)return;let r=this.targetForSelectionPoint(n);return r==null?void 0:Wq(r.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=Yq(t)?t:Yq(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}aq(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,QK(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{$K(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!Zq(this.renderedSelectedLinesState,n),i=!Zq(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);Hq(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=$q(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=$q(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:Uq(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:Uq(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:Qq(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:Qq(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function Fq({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:Iq({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function Iq({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function Lq(e){return e!=null&&`kind`in e&&e.kind===`line`}function Rq(e){return e!=null&&`kind`in e&&e.kind===`token`}function zq(e){return Lq(e)||Rq(e)}function Bq(e){return`type`in e&&e.type===`line-info`}function Vq(e){return`kind`in e&&e.kind===`merge-conflict-action`}function Hq(e){return e===`current`||e===`incoming`||e===`both`}function Uq(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function Wq(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function Gq(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function Kq(e){let t=e.closest(`[slot^="annotation-"]`),n=(t instanceof HTMLElement&&t.assignedSlot!=null?t.assignedSlot:e.tagName===`SLOT`?e:void 0)?.closest(`[data-line-annotation]`);return n instanceof HTMLElement?n:void 0}function qq(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function Jq(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function Yq(e){return e!=null&&typeof e.elementFromPoint==`function`}function Xq(e,t){return e===t||aq(e??void 0,t??void 0)}function Zq(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&Xq(e?.range??null,t.range)}function Qq(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function $q(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function eJ(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var tJ=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),iJ(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?sJ(t):cJ(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:nJ(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:rJ(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;(i||a)&&(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&aJ(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function nJ(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function rJ(e){return Math.max(Math.ceil(e),0)}function iJ(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?aJ(e,{codeWidthChanged:!0,numberWidthChanged:!0}):oJ(e))}function aJ(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function oJ(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function sJ(e){e.codeElement.isConnected&&oJ(e)}function cJ(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}function lJ(e,t){let n=Array.isArray(e)?e:[e];return t==null?n.every(e=>e===`text`||e===`ansi`||EK.has(e)):t.hasLoadedLanguages(n)}function uJ(e,t){return nq(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function dJ(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function fJ(e){return lq({tagName:`div`,children:[lq({tagName:`div`,children:e.annotations?.map(e=>lq({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function pJ(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function mJ({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return lq({tagName:`div`,children:[t===`custom`?lq({tagName:`slot`,properties:{name:QG}}):hJ({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[gJ(r)]],properties:i})}function hJ({name:e,prevName:t,iconType:n}){let r=[lq({tagName:`slot`,properties:{name:YG}}),uq({name:pJ(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(lq({tagName:`div`,children:[lq({tagName:`bdi`,children:[cq(t)]})],properties:{"data-prev-name":``}})),r.push(uq({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(lq({tagName:`div`,children:[lq({tagName:`bdi`,children:[cq(e)]})],properties:{"data-title":``}})),r.push(lq({tagName:`slot`,properties:{name:XG}})),lq({tagName:`div`,children:r,properties:{"data-header-content":``}})}function gJ(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(lq({tagName:`span`,children:[cq(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(lq({tagName:`span`,children:[cq(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(lq({tagName:`slot`,properties:{name:ZG}})),lq({tagName:`div`,children:t,properties:{"data-metadata":``}})}function _J(e){return lq({tagName:`pre`,properties:vJ(e)})}function vJ({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}var yJ=new Map,bJ={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,odin:`odin`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,BUCK:`python`,BUILD:`python`,PACKAGE:`python`,WORKSPACE:`python`,Tiltfile:`python`,bazel:`python`,bxl:`python`,bzl:`python`,bzlmod:`python`,star:`python`,sky:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function xJ(e){let t=SJ(e);if(t!=null)return t;let n=e.split(/[/\\]/).pop()??e;return n===e?`text`:SJ(n)??`text`}function SJ(e){if(yJ.has(e))return yJ.get(e)??`text`;if(Object.hasOwn(bJ,e))return bJ[e]??null;let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(yJ.has(t[1]))return yJ.get(t[1])??`text`;if(Object.hasOwn(bJ,t[1]))return bJ[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return yJ.has(n)?yJ.get(n)??`text`:Object.hasOwn(bJ,n)?bJ[n]??`text`:null}function CJ(e,{theme:t,preferredHighlighter:n}){return{langs:Array.isArray(e)?e:[e??`text`],themes:DK(t),preferredHighlighter:yK(n)}}function wJ(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function TJ(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function EJ(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var DJ=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,OJ=/^0(?:\.0+)?%?$/;function kJ(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function AJ(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function jJ(e){if(e==null)return null;let t=AJ(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function MJ(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||DJ.test(t))return!0;let n=kJ(t);return n!=null&&OJ.test(n)}function NJ(e,t,n){if(t==null||n==null)return!1;let r=jJ(e),i=jJ(t),a=jJ(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var PJ=new WeakMap;function FJ(e){let t=PJ.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;IJ(r,`editor.background`,i),IJ(r,`editor.foreground`,a),IJ(r,`sideBar.background`,o),IJ(r,`sideBar.foreground`,s),IJ(r,`input.background`,n[`input.background`]??o),IJ(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),IJ(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),IJ(r,`gitDecoration.addedResourceForeground`,LJ(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),IJ(r,`gitDecoration.modifiedResourceForeground`,LJ(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),IJ(r,`gitDecoration.deletedResourceForeground`,LJ(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(MJ(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(MJ(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(RJ(l,o)||NJ(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return PJ.set(e,u),u}function IJ(e,t,n){n!=null&&n!==``&&(e[t]=n)}function LJ(...e){for(let t of e)if(t!=null&&t!==``)return t}function RJ(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function zJ({theme:e=$G,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=BJ(i,t);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${EJ(`global`)}fg:${a.fg};`,r+=`${EJ(`global`)}bg:${a.bg};`,r+=VJ(i,n)}else{let n=t.getTheme(e.dark),i=BJ(n,t);r+=`${EJ(`global`)}dark:${i.fg};`,r+=`${EJ(`global`)}dark-bg:${i.bg};`,r+=VJ(n,`dark`),n=t.getTheme(e.light),i=BJ(n,t),r+=`${EJ(`global`)}light:${i.fg};`,r+=`${EJ(`global`)}light-bg:${i.bg};`,r+=VJ(n,`light`)}return r}function BJ(e,t){if(t.name===`highlights`&&e.zed?.cssVariables===!0){let e=EJ(`token`);return{fg:`var(${e}foreground)`,bg:`var(${e}background)`}}return FJ(e)}function VJ(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${EJ(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${EJ(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${EJ(`global`)}${t}modified-color:${a};`),n}function HJ(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(cq(`
76
+ [data-diffs-header] [data-deletions-count] { display: none; }`,disableFileHeader:e.disableFileHeader}}function BG(e,t,n){let r=t===`deletions`?`deletion`:`addition`,i=e.hunks.find(e=>n>=e[`${r}Start`]&&n<e[`${r}Start`]+e[`${r}Count`]);if(e.isPartial&&i===void 0)return;let a=e.isPartial&&i!==void 0?i[`${r}LineIndex`]+n-i[`${r}Start`]:n-1;return e[`${r}Lines`][a]?.replace(/\r?\n$/,``)}function VG(e){return{theme:PG,themeType:e,overflow:`wrap`,unsafeCSS:FG}}var HG=`diffs-container`,UG=(()=>{try{return!1}catch{return!1}})(),WG=/(?=^From [a-f0-9]+ .+$)/m,GG=/(?=^diff --git)/gm,KG=/(?<=\n)/,qG=/^(---|\+\+\+)\s+([^\t\r\n]+)/,JG=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,YG=`header-prefix`,XG=`header-filename-suffix`,ZG=`header-metadata`,QG=`header-custom`,$G={dark:`pierre-dark`,light:`pierre-light`},eK=`data-theme-css`,tK=`data-unsafe-css`,nK=`data-diffs-scrollbar-measure`,rK=`data-diffs-code-view-header`,iK=`data-diffs-code-view-footer`,aK=`--diffs-scrollbar-gutter-measured`,oK=1e5,sK={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},cK={...sK,hunkLineCount:1},lK={paddingTop:8,paddingBottom:8,gap:8},uK={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},dK=Object.freeze({fromStart:0,fromEnd:0}),fK={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},pK=Object.freeze([]),mK={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},hK,gK=0,_K=class extends Error{constructor(){super(`Highlighter is disposed`),this.name=`HighlighterDisposedError`}};function vK(){return hK}function yK(e){return e??hK??`shiki-js`}function bK(e){if(hK!=null&&hK!==e)throw Error(`Cannot load the "${e}" highlighter while "${hK}" is in use. Only one highlighter type can be active at a time; dispose every "${hK}" instance (disposeHighlighter() disposes the shared one) before switching.`)}function xK(e){bK(e),hK=e,gK++}function SK(){gK--,gK===0&&(hK=void 0)}var CK=new Map,wK=new Map,TK=new Map,EK=new Set;function DK(e=$G){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function OK(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}function kK(e){let t;return()=>t??=e().then(e=>(t=e,e),e=>{throw t=void 0,e})}function AK(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var jK=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},MK=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},NK=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function PK(e={}){let t=new Map,n=new Map,r=new Map,i=0;function a(e,n){if(t.has(e))throw new jK(e);t.set(e,n)}function o(e,n){return!t.has(e)&&(t.set(e,n),!0)}function s(e){return t.has(e)}function c(a){let o=n.get(a);if(o!==void 0)return Promise.resolve(o);let s=r.get(a);if(s!==void 0)return s;let c=t.get(a);if(c===void 0&&e.fallbackLoader===void 0)return Promise.reject(new MK(a));let l=i,u=Promise.resolve().then(()=>c===void 0?e.fallbackLoader?.(a):c()).then(async t=>{if(t===void 0)throw new MK(a);let o=AK(t),s=e.normalizeTheme===void 0?o:await e.normalizeTheme(o,a);return l===i&&n.set(a,s),r.get(a)===u&&r.delete(a),s}).catch(e=>{throw r.get(a)===u&&r.delete(a),e});return r.set(a,u),u}function l(e){return Promise.all(e.map(e=>c(e)))}function u(e,t){n.set(e,t)}function d(e){for(let[t,n]of e)u(t,n)}function f(e){return n.get(e)}function p(e){let t=[];for(let r of e){let e=n.get(r);if(e===void 0)throw new NK(r);t.push(e)}return t}function m(e){return n.has(e)}function h(e){for(let t of e)if(!n.has(t))return!1;return!0}function g(e){let t=n.get(e);return t===void 0?c(e):t}function _(){i++,n.clear(),r.clear()}return{clearResolvedThemes:_,getResolvedOrResolveTheme:g,getResolvedTheme:f,getResolvedThemes:p,hasRegisteredTheme:s,hasResolvedTheme:m,hasResolvedThemes:h,registerTheme:a,registerThemeIfAbsent:o,resolveTheme:c,resolveThemes:l,seedResolvedTheme:u,seedResolvedThemes:d}}var FK=new Map,IK=new Map,LK=kK(()=>YW(()=>import(`./loader-DfKq13Mg.js`),[])),RK=kK(()=>YW(()=>import(`./themes-DsXaTcpb.js`),[])),zK=kK(()=>YW(()=>import(`./core-cZCITU9I.js`),[])),BK=[[`editor.lineHighlightBackground`,`editor.active_line.background`],[`editor.selectionBackground`,`element.selected`],[`editor.findMatchBackground`,`search.match_background`],[`editor.findMatchHighlightBackground`,`search.match_background`],[`editorBracketMatch.background`,`editor.document_highlight.bracket_background`],[`editorError.foreground`,`error`],[`editorWarning.foreground`,`warning`],[`editorInfo.foreground`,`info`],[`editorHint.foreground`,`hint`],[`gitDecoration.addedResourceForeground`,`created`,`terminal.ansi.green`],[`gitDecoration.deletedResourceForeground`,`deleted`,`terminal.ansi.red`],[`gitDecoration.modifiedResourceForeground`,`modified`,`terminal.ansi.blue`]];function VK(e,t){let n=`themes`in t?t.themes[0]:t;if(n==null)throw Error(`Theme "${e}" is an empty Zed theme family.`);let r={...n,name:e},i={};for(let[e,t]of Object.entries(r.style))typeof t==`string`&&(i[e]=t);let a=r.style.players?.[0];a?.cursor!=null&&(i[`editorCursor.foreground`]??=a.cursor),a?.selection!=null&&(i[`editor.selectionBackground`]??=a.selection);for(let[e,...t]of BK){if(i[e]!=null)continue;let n=t.find(e=>i[e]!=null);n!=null&&(i[e]=i[n])}if(r.cssVariables===!0)i[`editor.foreground`]=`var(--hls-foreground)`,i[`editor.background`]=`var(--hls-background)`;else if(typeof r.cssVariables==`object`){i[`editor.foreground`]??=i.text??i.foreground??`foreground`,i[`editor.background`]??=i.background??`background`;let{prefix:e=`--hls-`,defaults:t}=r.cssVariables;for(let[n,r]of Object.entries(i)){let a=t?.[r];i[n]=`var(${e}${r}${a?`, ${a}`:``})`}}let o=r.appearance===`light`?`light`:`dark`;return{name:e,type:o,colors:i,zed:r,fg:i[`editor.foreground`]??i.text??i.foreground??(o===`light`?`#333333`:`#bbbbbb`),bg:i[`editor.background`]??i.background??(o===`light`?`#ffffff`:`#1e1e1e`)}}function HK(e){let t=IK.get(e);return t??(t=PK({fallbackLoader:async t=>{if(typeof __DIFFS_WORKER__<`u`?__DIFFS_WORKER__:OK())throw Error(`Theme "${t}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedThemes parameter.`);let n=FK.get(t);if(e===`highlights`){let e=n?.zed??n?.diffs;if(e!=null){let n=await e(),r=`default`in n?n.default:n;if(`zed`in r&&r.zed!=null)return r;if(`style`in r||`themes`in r)return VK(t,r);throw Error(`Theme "${t}" is a TextMate theme; register a Zed theme with registerCustomTheme(name, loader, 'zed') for Highlights.`)}let r=LK(),{themes:i}=r instanceof Promise?await r:r,a=i[t];if(a!=null)return VK(t,(await a()).default);if(n?.textmate!=null)throw Error(`Theme "${t}" is only registered for TextMate; use registerCustomTheme(name, loader, 'zed') for Highlights.`)}else{let e=n?.textmate??n?.diffs,r;if(e!=null){let t=await e();r=`default`in t?t.default:t}else{let e=RK(),{themes:i}=e instanceof Promise?await e:e,a=i.getTheme(t);if(a==null&&n?.zed!=null)throw Error(`Theme "${t}" is only registered for Zed; use registerCustomTheme(name, loader, 'textmate') for Shiki.`);if(a==null)throw Error(`No valid theme loader registered for "${t}"`);let o=await a.load();r=`default`in o?o.default:o}if(`style`in r||`themes`in r)throw Error(`Theme "${t}" is a Zed theme; use preferredHighlighter: 'highlights' or register a TextMate theme for Shiki.`);let i=zK(),{normalizeTheme:a,createCssVariablesTheme:o}=i instanceof Promise?await i:i;if(`cssVariables`in r&&r.cssVariables!=null)return{...r,textmate:a(o(r.cssVariables))};if(`textmate`in r&&r.textmate!=null)return{...r,textmate:a(r.textmate)};let s=a(r);return{name:s.name,type:s.type,fg:s.fg,bg:s.bg,colors:s.colors,textmate:s}}throw Error(`No valid theme loader registered for "${t}"`)},normalizeTheme:(e,t)=>{if(e.name!==t)throw Error(`resolvedTheme: themeName: ${t} does not match theme.name: ${e.name}`);return e}}),IK.set(e,t),t)}function UK(e,t=yK()){return typeof t!=`string`&&t.isDisposed?!1:(typeof t==`string`?HK(t):t.themeResolver).hasResolvedThemes(DK(e))}var WK;async function GK(e){let t=yK(e);xK(t);try{if(t===`highlights`){let{HighlightsHighlighter:e}=await YW(async()=>{let{HighlightsHighlighter:e}=await import(`./highlights-nN81K30Y.js`);return{HighlightsHighlighter:e}},__vite__mapDeps([0,1]));return new e}let{ShikiHighlighter:e}=await YW(async()=>{let{ShikiHighlighter:e}=await import(`./shiki-CqdI0RHM.js`);return{ShikiHighlighter:e}},__vite__mapDeps([2,3,1]));return await e.create(t)}finally{SK()}}async function KK({themes:e,langs:t,preferredHighlighter:n}){qK();let r=WK??=GK(vK()??n),i;try{i=await r}catch(e){throw WK===r&&(WK=void 0),e}if(WK===r&&(WK=i),await Promise.all([i.themeResolver.resolveThemes(e),i.loadLanguages(t)]),i.isDisposed)throw new _K;return i}function qK(){WK!=null&&!(`then`in WK)&&WK.isDisposed&&(WK=void 0)}function JK({theme:e,lang:t,langs:n}={}){qK();let r=WK;if(!(r==null||`then`in r||e!=null&&!UK(e,r)||(t!=null||n!=null)&&!r.hasLoadedLanguages([...t==null?[]:[t],...n??[]])))return r}async function YK(e){await KK(e)}var XK=new Set,ZK=null;function QK(e){XK.add(e),ZK??=requestAnimationFrame(eq)}function $K(e){XK.delete(e)&&XK.size===0&&ZK!=null&&(cancelAnimationFrame(ZK),ZK=null)}function eq(e){let t=new Set(XK);XK.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}ZK=XK.size>0?requestAnimationFrame(eq):null}function tq(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function nq(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function rq(e,t){let n=e?.theme??$G,r=t?.theme??$G,i=iq(e),a=iq(t);return nq(n,r)&&tq(e,t,[`theme`,`parseDiffOptions`])&&tq(i,a)}function iq(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}function aq(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function oq({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:a}){let o=n+a*2,s=r?n+i*2:o;if(t=Math.max(t,s),o>=t||r){let n=Math.max(e-i,0),r=Math.min(e+s,t);return{top:n,bottom:Math.max(r,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t),c))}}function sq(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function cq(e){return{type:`text`,value:e}}function lq({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function uq({name:e,width:t=16,height:n=16,properties:r}){return lq({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[lq({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function dq(e){return lq({tagName:`div`,properties:{"data-gutter":``},children:e})}function fq(e,t,n,r={}){return lq({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[lq({tagName:`span`,properties:{"data-line-number-content":``},children:[cq(`${t}`)]})]})}function pq(e,t,n){return lq({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function mq(){return lq({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[uq({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}var hq=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),gq=new Set([`svg`,`template`,`script`,`style`]),_q={class:`class`,className:`class`,id:`id`,role:`role`,style:`style`,tabIndex:`tabindex`,tabindex:`tabindex`,title:`title`},vq=/^data-[\w.:-]+$/,yq=/[<&]/g,bq=/[\0"&'`]/g,xq={"<":`&#x3C;`,"&":`&#x26;`,'"':`&#x22;`,"'":`&#x27;`,"`":`&#x60;`,"\0":`&#x0;`},Sq=256;function Cq(e){let t=new Map;return Array.isArray(e)?wq(e,t):Tq(e,t)}function wq(e,t){let n=``;for(let r of e)n+=Tq(r,t);return n}function Tq(e,t){switch(e.type){case`text`:return kq(e.value);case`element`:return Eq(e,t);case`root`:return wq(e.children,t);default:return UW(e)}}function Eq(e,t){let{tagName:n}=e;if(n===`span`&&e.children.length===1&&e.children[0].type===`text`&&typeof e.properties?.style==`string`){let n=!0;for(let t in e.properties)if(t!==`style`&&e.properties[t]!=null){n=!1;break}if(n)return`<span ${Dq(e.properties.style,t)}>${kq(e.children[0].value)}</span>`}if(gq.has(n))return UW(e);let r=Oq(e.properties,t);if(r==null)return UW(e);let i=r===``?`<${n}>`:`<${n} ${r}>`,a=wq(e.children,t);return a===``&&hq.has(n.toLowerCase())?i:`${i}${a}</${n}>`}function Dq(e,t){let n=t.get(e);return n??(n=`style="${Aq(e)}"`,t.size<Sq&&t.set(e,n)),n}function Oq(e,t){let n=``;for(let r in e){let i=e[r];if(i==null)continue;let a=_q[r]??(vq.test(r)?r:void 0);if(a==null)return;if(i===!1||typeof i==`number`&&Number.isNaN(i))continue;let o=r===`style`&&typeof i==`string`?Dq(i,t):i===!0?a:`${a}="${Aq(Array.isArray(i)?i.join(` `).trim():String(i))}"`;n+=n===``?o:` ${o}`}return n}function kq(e){return e.indexOf(`<`)<0&&e.indexOf(`&`)<0?e:e.replace(yq,jq)}function Aq(e){return e.replace(bq,jq)}function jq(e){return xq[e]}function Mq(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function Nq(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var Pq=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),$K(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||aq(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;(this.isSelectionDirty()||n||i)&&(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;(this.isSelectionDirty()||r||i)&&(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&Nq(e.composedPath())||(eJ(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;(t!==`disabled`||o||n!=null||r!=null||i!=null||a!=null)&&(eJ(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(eJ(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){eJ(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();eJ(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);eJ(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=zq(i)&&this.hoveredLine?.lineElement===i.lineElement;Rq(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),Rq(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),zq(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(Vq(i)&&p!=null){p(i);break}if(Bq(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!zq(i))break;Rq(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,eJ(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),eJ(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),eJ(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();Nq(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(Mq(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=Cq(mq());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);Lq(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(Wq(t));if(Lq(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(Lq(n)&&(!t||n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(Lq(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&Nq(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=Wq(e);if(t&&Nq(n))return;let r=Gq(e);return r==null?this.pathFromAnnotationSlot(e):Wq(r)}pathFromAnnotationSlot(e){let t=Kq(e)?.previousElementSibling;if(t instanceof HTMLElement&&(t.hasAttribute(`data-line`)||t.hasAttribute(`data-column-number`)))return Wq(t);let n=Jq(qq(e));if(n==null)return;let r=this.targetForSelectionPoint(n);return r==null?void 0:Wq(r.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=Yq(t)?t:Yq(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}aq(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,QK(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{$K(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!Zq(this.renderedSelectedLinesState,n),i=!Zq(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);Hq(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=$q(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=$q(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:Uq(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:Uq(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:Qq(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:Qq(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function Fq({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:Iq({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function Iq({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function Lq(e){return e!=null&&`kind`in e&&e.kind===`line`}function Rq(e){return e!=null&&`kind`in e&&e.kind===`token`}function zq(e){return Lq(e)||Rq(e)}function Bq(e){return`type`in e&&e.type===`line-info`}function Vq(e){return`kind`in e&&e.kind===`merge-conflict-action`}function Hq(e){return e===`current`||e===`incoming`||e===`both`}function Uq(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function Wq(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function Gq(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function Kq(e){let t=e.closest(`[slot^="annotation-"]`),n=(t instanceof HTMLElement&&t.assignedSlot!=null?t.assignedSlot:e.tagName===`SLOT`?e:void 0)?.closest(`[data-line-annotation]`);return n instanceof HTMLElement?n:void 0}function qq(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function Jq(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function Yq(e){return e!=null&&typeof e.elementFromPoint==`function`}function Xq(e,t){return e===t||aq(e??void 0,t??void 0)}function Zq(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&Xq(e?.range??null,t.range)}function Qq(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function $q(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function eJ(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var tJ=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),iJ(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?sJ(t):cJ(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:nJ(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:rJ(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;(i||a)&&(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&aJ(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function nJ(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function rJ(e){return Math.max(Math.ceil(e),0)}function iJ(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?aJ(e,{codeWidthChanged:!0,numberWidthChanged:!0}):oJ(e))}function aJ(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function oJ(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function sJ(e){e.codeElement.isConnected&&oJ(e)}function cJ(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}function lJ(e,t){let n=Array.isArray(e)?e:[e];return t==null?n.every(e=>e===`text`||e===`ansi`||EK.has(e)):t.hasLoadedLanguages(n)}function uJ(e,t){return nq(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function dJ(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function fJ(e){return lq({tagName:`div`,children:[lq({tagName:`div`,children:e.annotations?.map(e=>lq({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function pJ(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function mJ({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return lq({tagName:`div`,children:[t===`custom`?lq({tagName:`slot`,properties:{name:QG}}):hJ({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[gJ(r)]],properties:i})}function hJ({name:e,prevName:t,iconType:n}){let r=[lq({tagName:`slot`,properties:{name:YG}}),uq({name:pJ(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(lq({tagName:`div`,children:[lq({tagName:`bdi`,children:[cq(t)]})],properties:{"data-prev-name":``}})),r.push(uq({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(lq({tagName:`div`,children:[lq({tagName:`bdi`,children:[cq(e)]})],properties:{"data-title":``}})),r.push(lq({tagName:`slot`,properties:{name:XG}})),lq({tagName:`div`,children:r,properties:{"data-header-content":``}})}function gJ(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(lq({tagName:`span`,children:[cq(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(lq({tagName:`span`,children:[cq(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(lq({tagName:`slot`,properties:{name:ZG}})),lq({tagName:`div`,children:t,properties:{"data-metadata":``}})}function _J(e){return lq({tagName:`pre`,properties:vJ(e)})}function vJ({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}var yJ=new Map,bJ={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,odin:`odin`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,BUCK:`python`,BUILD:`python`,PACKAGE:`python`,WORKSPACE:`python`,Tiltfile:`python`,bazel:`python`,bxl:`python`,bzl:`python`,bzlmod:`python`,star:`python`,sky:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function xJ(e){let t=SJ(e);if(t!=null)return t;let n=e.split(/[/\\]/).pop()??e;return n===e?`text`:SJ(n)??`text`}function SJ(e){if(yJ.has(e))return yJ.get(e)??`text`;if(Object.hasOwn(bJ,e))return bJ[e]??null;let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(yJ.has(t[1]))return yJ.get(t[1])??`text`;if(Object.hasOwn(bJ,t[1]))return bJ[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return yJ.has(n)?yJ.get(n)??`text`:Object.hasOwn(bJ,n)?bJ[n]??`text`:null}function CJ(e,{theme:t,preferredHighlighter:n}){return{langs:Array.isArray(e)?e:[e??`text`],themes:DK(t),preferredHighlighter:yK(n)}}function wJ(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function TJ(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function EJ(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var DJ=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,OJ=/^0(?:\.0+)?%?$/;function kJ(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function AJ(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function jJ(e){if(e==null)return null;let t=AJ(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function MJ(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||DJ.test(t))return!0;let n=kJ(t);return n!=null&&OJ.test(n)}function NJ(e,t,n){if(t==null||n==null)return!1;let r=jJ(e),i=jJ(t),a=jJ(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var PJ=new WeakMap;function FJ(e){let t=PJ.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;IJ(r,`editor.background`,i),IJ(r,`editor.foreground`,a),IJ(r,`sideBar.background`,o),IJ(r,`sideBar.foreground`,s),IJ(r,`input.background`,n[`input.background`]??o),IJ(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),IJ(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),IJ(r,`gitDecoration.addedResourceForeground`,LJ(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),IJ(r,`gitDecoration.modifiedResourceForeground`,LJ(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),IJ(r,`gitDecoration.deletedResourceForeground`,LJ(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(MJ(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(MJ(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(RJ(l,o)||NJ(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return PJ.set(e,u),u}function IJ(e,t,n){n!=null&&n!==``&&(e[t]=n)}function LJ(...e){for(let t of e)if(t!=null&&t!==``)return t}function RJ(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function zJ({theme:e=$G,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=BJ(i,t);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${EJ(`global`)}fg:${a.fg};`,r+=`${EJ(`global`)}bg:${a.bg};`,r+=VJ(i,n)}else{let n=t.getTheme(e.dark),i=BJ(n,t);r+=`${EJ(`global`)}dark:${i.fg};`,r+=`${EJ(`global`)}dark-bg:${i.bg};`,r+=VJ(n,`dark`),n=t.getTheme(e.light),i=BJ(n,t),r+=`${EJ(`global`)}light:${i.fg};`,r+=`${EJ(`global`)}light-bg:${i.bg};`,r+=VJ(n,`light`)}return r}function BJ(e,t){if(t.name===`highlights`&&e.zed?.cssVariables===!0){let e=EJ(`token`);return{fg:`var(${e}foreground)`,bg:`var(${e}background)`}}return FJ(e)}function VJ(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${EJ(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${EJ(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${EJ(`global`)}${t}modified-color:${a};`),n}function HJ(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(cq(`
77
77
  `)),e}var UJ=new WeakMap;function WJ(e,t=!1){let{htmlStyle:n}=e;if(n!=null){let e=t?UJ.get(n):void 0;if(e==null){e=``;for(let t in n)e+=`${e===``?``:`;`}${t}:${n[t]}`;t&&UJ.set(n,e)}return e}let r=e.color==null?``:`color:${e.color}`;if(e.bgColor!=null&&(r+=`;background-color:${e.bgColor}`),e.fontStyle!=null){e.fontStyle&1&&(r+=`;font-style:italic`),e.fontStyle&2&&(r+=`;font-weight:bold`);let t=!!(e.fontStyle&4),n=!!(e.fontStyle&8);(t||n)&&(r+=`;text-decoration:${t?`underline`:``}${t&&n?` `:``}${n?`line-through`:``}`)}return r.replace(/^;/,``)}function GJ(e,t,n){let r=!1,i;Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return r||=(i=n(),!0),Object.getOwnPropertyDescriptor(e,t)?.configurable===!0&&Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:i}),i},set(n){if(Object.getOwnPropertyDescriptor(e,t)?.configurable===!0)Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n});else if(Object.isFrozen(e))throw TypeError(`Cannot assign to read only array index '${t}'`);else i=n,r=!0}})}var KJ=Symbol(`no-token`),qJ=Symbol(`multiple-tokens`);function JJ(e){let t=YJ(e);if(t!=null)return t;let n=KJ,r=[],i=[],a,o=()=>{if(i.length===0||a==null){i=[],a=void 0;return}if(i.length===1){let e=i[0];if(e?.type===`element`){ZJ(e,a);for(let t of e.children)XJ(t)}else XJ(e);r.push(e),i=[],a=void 0;return}for(let e of i)XJ(e);r.push(lq({tagName:`span`,properties:{"data-char":a},children:i})),i=[],a=void 0},s=e=>{if(e!==KJ){if(e===qJ){n=qJ;return}if(n===KJ){n=e;return}n!==e&&(n=qJ)}};for(let t of e.children){let e=t.type===`element`?JJ(t):KJ;if(s(e),typeof e!=`number`){o(),r.push(t);continue}a!=null&&a!==e&&o(),a??=e,i.push(t)}return o(),e.children=r,n}function YJ(e){let t=e.properties[`data-char`];if(typeof t==`number`)return t}function XJ(e){if(e.type===`element`){e.properties[`data-char`]=void 0;for(let t of e.children)XJ(t)}}function ZJ(e,t){e.properties[`data-char`]=t}function QJ(e,{state:t,lazyLineAST:n=!1,cacheHtmlStyles:r=!1,useTokenTransformer:i=!1,mergeWhitespaces:a=`always`,decorations:o=[],lineOffsets:s=[]}){let c;for(let t of o){let n=c??=new Map,r={...t,start:nY(t.start,s),end:nY(t.end,s)},i=Math.min(r.end.line,e.length-1);for(let e=r.start.line;e<=i;e++){let t=n.get(e);t??n.set(e,t=[]),t.push(r)}}let l=(e,n)=>{let o;if(i||a!==`never`){let t=``,n=0;for(let r=0;r<e.length;r++){let a=e[r];if(i){let t=a.content.trim();if(t!==``&&t!==a.content){o??=e.slice(0,r);let n=a.content.indexOf(t);n>0&&o.push({content:a.content.slice(0,n),offset:a.offset}),o.push({...a,content:t,offset:a.offset+n});let i=n+t.length;i<a.content.length&&o.push({content:a.content.slice(i),offset:a.offset+i});continue}}else{let i=!!((a.fontStyle??0)&12);if(!i&&/^\s+$/.test(a.content)&&r<e.length-1){o??=e.slice(0,r),t===``&&(n=a.offset),t+=a.content;continue}t!==``&&o!=null&&(i?o.push({content:t,offset:n}):a={...a,content:t+a.content,offset:n},t=``)}o?.push(a)}}o??=e;let s={type:`element`,tagName:t==null?`span`:`div`,properties:t==null?{class:`line`}:{},children:[]},l=c?.get(n),u=l==null?$J(s,o,i,r):eY(s,o,l,n,i,r);return i&&u===0&&s.children.push({type:`element`,tagName:`br`,properties:{},children:[]}),i&&l!=null&&JJ(s),t==null?s:HJ(s,n+1,t)};if(!n)return e.map(l);let u=Array(e.length);for(let t=0;t<e.length;t++){let n=e[t];GJ(u,t,()=>l(n,t))}return u}function $J(e,t,n,r){let i=0;for(let a of t)a.content!==``&&(e.children.push(tY(a,WJ(a,r),a.content,i,n)),i+=a.content.length);return i}function eY(e,t,n,r,i,a){n.length>1&&n.sort((e,t)=>e.start.line===t.start.line?e.start.character===t.start.character?e.end.line===t.end.line?t.end.character-e.end.character:t.end.line-e.end.line:e.start.character-t.start.character:e.start.line-t.start.line);let o=t.reduce((e,t)=>e+t.content.length,0),s=[];for(let e=0;e<n.length;e++){let t=n[e],i={decoration:t,order:e,from:t.start.line===r?t.start.character:0,to:t.end.line===r?t.end.character:o};s.push({position:Math.max(0,Math.min(i.from,o)),range:i,start:!0},{position:Math.max(0,Math.min(i.to,o)),range:i,start:!1})}s.sort((e,t)=>e.position-t.position);let c=[],l=[],u=0,d=(e,t)=>{let n=0,r=c.length;for(;n<r;){let t=n+r>>>1;c[t].order<e.order?n=t+1:r=t}t?c.splice(n,0,e):c[n]===e&&c.splice(n,1)},f=()=>{let t=e,n=0;for(let e of c){if(l[n]?.range!==e){l.length=n;let r={type:`element`,tagName:`span`,properties:{...e.decoration.properties},children:[]};t.children.push(r),l.push({range:e,node:r})}t=l[n++].node}return l.length=n,t},p=e,m=e=>{let t=u;for(;s[u]?.position===e;)u++;let n=!1;for(let n=t;n<u;n++){let{range:t,start:r}=s[n];!r&&t.from!==t.to&&e<o&&d(t,!1)}for(let r=t;r<u;r++){let{range:t,start:i}=s[r];i&&t.from<=e&&t.to>=e&&(t.to>e||t.from===e||e===o)&&(d(t,!0),t.from===t.to&&(n=!0))}if(n){f();for(let e=t;e<u;e++){let{range:t,start:n}=s[e];n&&t.from===t.to&&d(t,!1)}}e<o&&(p=f())},h=0;for(let e of t){if(e.content===``)continue;let t=h,n=t+e.content.length,r=WJ(e,a);for(;h<n;){s[u]?.position===h&&m(h);let a=Math.min(n,s[u]?.position??n);p.children.push(tY(e,r,h===t&&a===n?e.content:e.content.slice(h-t,a-t),t,i)),h=a}}return s[u]?.position===h&&m(h),h}function tY(e,t,n,r,i){let a=e.htmlAttrs==null?{}:{...e.htmlAttrs};return t!==``&&(a.style=t),i&&(a[`data-char`]=r),{type:`element`,tagName:`span`,properties:a,children:[{type:`text`,value:n}]}}function nY(e,t){if(typeof e!=`number`)return e;let n=0,r=t.length;for(;n+1<r;){let i=n+r>>>1;t[i]<=e?n=i:r=i}return{line:n,character:e-(t[n]??0)}}var rY=10,iY=13,aY=4,oY=40;function sY(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
78
78
  `),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
79
79
  `,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
@@ -252,7 +252,7 @@ diff --git`)}function zZ(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.star
252
252
  `).map(e=>e.trim()===``?`>`:`> ${e}`);let t=Math.max(2,...e.lines.map(e=>Math.max(0,...(e.match(/`+/g)??[]).map(e=>e.length)))),n="`".repeat(t+1);return[`${n}${/\.([a-z0-9]+)$/i.exec(e.path)?.[1]??``}`,...e.lines,n]}function v4(e){let t=u4(),[n,r]=(0,R.useState)(!1),i=V(b4.card),a=V(b4.body),o=V(b4.actions),s=e.comment,c=s===void 0||t.activeId===s.id,l=s===void 0?t.draft:s.anchor;return(0,z.jsxs)(`div`,{className:i,"data-comment-card":``,"data-active":c,onClick:()=>{s!==void 0&&t.setActiveId(s.id)},onFocus:()=>{s!==void 0&&t.setActiveId(s.id)},children:[e.detached===!0&&s?.anchor.kind===`text`&&(0,z.jsxs)(Kz,{size:`xs`,color:`lowContrast`,children:[`Text not found: “`,s.anchor.display.trim(),`”`]}),l?.kind===`lines`&&l.start!==l.end&&(0,z.jsxs)(Kz,{size:`xs`,color:`lowContrast`,children:[`Lines `,l.start,`–`,l.end]}),s===void 0?(0,z.jsx)(y4,{initial:``,submitLabel:`Comment`,onSubmit:t.saveDraft,onCancel:t.cancelDraft}):n?(0,z.jsx)(y4,{initial:s.body,submitLabel:`Save`,onSubmit:e=>{t.update(s.id,e),r(!1)},onCancel:()=>r(!1)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:a,children:s.body}),(0,z.jsxs)(`div`,{className:o,"data-actions":``,children:[(0,z.jsx)(Vz,{variant:`quiet`,size:`sm`,"aria-label":`Edit comment`,onPress:()=>r(!0),children:(0,z.jsx)(SB,{size:`sm`})}),(0,z.jsx)(Vz,{variant:`quiet`,size:`sm`,"aria-label":`Delete comment`,onPress:()=>t.remove(s.id),children:(0,z.jsx)(DB,{size:`sm`})})]})]})]})}function y4(e){let[t,n]=(0,R.useState)(e.initial),r=(0,R.useRef)(null);(0,R.useEffect)(()=>{let e=requestAnimationFrame(()=>r.current?.focus());return()=>cancelAnimationFrame(e)},[]);let i=V(iV.input({}),b4.textarea),a=V(b4.buttons),o=t.trim()===``,s=()=>{o||e.onSubmit(t.trim())};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`textarea`,{className:i,"aria-label":`Comment`,placeholder:`Add a comment…`,ref:r,rows:3,value:t,onChange:e=>n(e.target.value),onKeyDown:t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),s()),t.key===`Escape`&&(t.preventDefault(),e.onCancel())}}),(0,z.jsxs)(`div`,{className:a,children:[(0,z.jsx)(Vz,{variant:`quiet`,size:`sm`,onPress:e.onCancel,children:`Cancel`}),(0,z.jsx)(Vz,{variant:`primary`,variantColor:`blue`,size:`sm`,isDisabled:o,onPress:s,children:e.submitLabel})]})]})}var b4={card:B(Yd({direction:`column`,gap:3}),Fd.md,Vd.subtle,Y.padding({x:4,y:4}),ef.standard(`box-shadow`),{position:`relative`,minWidth:0,backgroundColor:K.element,cursor:`default`,"&[data-active='true']":{boxShadow:Bd.medium},"&:hover > [data-actions], &:focus-within > [data-actions], &[data-active='true'] > [data-actions]":{opacity:1}}),body:B(J({size:`sm`,color:`highContrast`}),{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,paddingRight:`52px`}),actions:B(Yd({direction:`row`,gap:1}),{position:`absolute`,top:`4px`,right:`4px`,opacity:0,"@media (hover: none)":{opacity:1}}),textarea:B({display:`block`,height:`auto`,minHeight:`60px`,resize:`vertical`,fontFamily:`inherit`}),buttons:B(Yd({direction:`row`,justifyContent:`end`,gap:2}),{})},x4=`draft`;function S4(e){let t=u4();return(0,R.useMemo)(()=>C4(t,e),[t,e])}function C4(e,t){let n=e.draft?.kind===`lines`&&e.draft.target===t?e.draft:void 0,r=r=>[...e.comments.flatMap(e=>e.anchor.kind===`lines`&&e.anchor.target===t&&e.anchor.path===r?[{id:e.id,anchor:e.anchor}]:[]),...n?.path===r?[{id:x4,anchor:n}]:[]];return{draftSelection:n===void 0?void 0:{id:n.path,range:{start:n.start,end:n.end,side:n.side}},diffAnnotations:e=>r(e).map(({id:e,anchor:t})=>({side:t.side??`additions`,lineNumber:t.end,metadata:e})),fileAnnotations:e=>r(e).map(({id:e,anchor:t})=>({lineNumber:t.end,metadata:e})),start:n=>e.startDraft({kind:`lines`,target:t,...n})}}function w4(e){let t=e.endSide??e.side,n=(e.side??t)===t;return{side:t,start:n?Math.min(e.start,e.end):e.end,end:n?Math.max(e.start,e.end):e.end}}function T4(e){let t=5381;for(let n=0;n<e.length;n++)t=Math.imul(t,33)^e.charCodeAt(n);return t>>>0}function E4(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function D4(e){let t=u4(),n=V(O4.slot),r=e.id===x4?void 0:t.comments.find(t=>t.id===e.id);if(e.id===x4||r!==void 0)return(0,z.jsx)(`div`,{className:n,children:(0,z.jsx)(v4,{comment:r})})}var O4={slot:B(Y.padding({x:6,y:4}),{maxWidth:`560px`,whiteSpace:`normal`,fontFamily:bd})};function k4(e){let{resolvedTheme:t}=oa(),n=V(LG),r=e.path===void 0?`diff`:e.path,i=c4(e.source,r),a=e.path===void 0,o=S4(`fence:${T4(e.source).toString(36)}`);return(0,z.jsx)(`div`,{className:n,"data-file-path":r,"data-diffmap-kind":`diff`,children:(0,z.jsx)(o4,{patch:i,disableWorkerPool:!0,renderHeaderMetadata:u2,lineAnnotations:o.diffAnnotations(r),renderAnnotation:e=>(0,z.jsx)(D4,{id:e.metadata}),options:{...zG({themeType:t,disableFileHeader:a}),enableGutterUtility:!0,onGutterUtilityClick:e=>{let{side:t=`additions`,start:n,end:a}=w4(e),s=B0(i);o.start({path:r,side:t,start:n,end:a,lineOffset:0,lines:E4(n,a).flatMap(e=>BG(s,t,e)??[]),context:`diff in the document`})}}})})}var A4=(0,R.createContext)(`local`);function j4(){return(0,R.useContext)(A4)}var M4=(0,R.createContext)(void 0);function N4(){return(0,R.useContext)(M4)}var P4=(0,R.createContext)(void 0);function F4(){return(0,R.useContext)(P4)}function I4(e,t){let n={sha:t.sha,branch:t.branch===void 0?void 0:t.branch.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``),pull:t.pull===void 0?void 0:String(t.pull)},r=new Set,i=e.replace(/\{(sha|branch|pull)\}/g,(e,t)=>{let i=n[t];return i===void 0?(r.add(t),``):encodeURIComponent(i)});return r.size>0?Error(`previews.preview needs ${[...r].map(e=>`{${e}}`).join(` and `)}, which come from the pull request.`):i}var L4=class extends Error{failure;constructor(e){super(V4(e)),this.failure=e}};function R4(e){if(e.ok)return;if(e.status===404)return{status:`not-found`};let t=e.headers.get(`x-ratelimit-remaining`);return e.status===429||e.status===403&&t===`0`?{status:`rate-limited`,resetAt:z4(e)}:e.status===403?{status:`forbidden`}:{status:`error`,message:`GitHub returned ${String(e.status)}.`}}function z4(e){let t=Number(e.headers.get(`x-ratelimit-reset`));if(Number.isFinite(t)&&t>0)return t*1e3;let n=Number(e.headers.get(`retry-after`));if(Number.isFinite(n)&&n>0)return Date.now()+n*1e3}function B4(e){if(e!==void 0)return new Date(e).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}function V4(e){switch(e.status){case`not-found`:return`GitHub has no public file here.`;case`forbidden`:return`GitHub refused this request.`;case`rate-limited`:{let t=B4(e.resetAt);return t===void 0?`GitHub's hourly request limit for your network ran out. Wait a few minutes, then refresh.`:`GitHub's hourly request limit for your network ran out. It resets at ${t}.`}case`offline`:return`Couldn't reach GitHub. Check your connection, then refresh.`;case`error`:return e.message}}var H4=`https://api.github.com`,U4={Accept:`application/vnd.github+json`},W4=new Map;async function G4(e,t,n){let r=`${e.owner}/${e.repo}@${e.sha}:${t}`,i=W4.get(r);if(i!==void 0)return i;let a=q4(e,t,n).catch(e=>{if(W4.delete(r),e instanceof Error&&e.name===`AbortError`)throw e;return e instanceof Error?e:Error(`Failed to load this file from GitHub.`)});return W4.set(r,a),a}function K4(e,t){let n=t.includes(`.`)?t.slice(t.lastIndexOf(`.`)+1):t,r=e.split(/\r?\n/),i=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=RegExp(`(?:function|class|const|let|var|type|interface|enum|#)\\s+${i}\\b|\\b${i}\\s*[=:(]`);for(let e=0;e<r.length;e++)if(a.test(r[e]))return{start:e+1,end:e+1};return{start:1,end:Math.max(1,r.length)}}async function q4(e,t,n){let r=t.split(`/`).map(encodeURIComponent).join(`/`),i=await Y4(`/repos/${encodeURIComponent(e.owner)}/${encodeURIComponent(e.repo)}/contents/${r}?ref=${encodeURIComponent(e.sha)}`,n);if(i.status!==`ok`)return new L4(i);let a=await i.body.json().catch(()=>void 0);if(Array.isArray(a))return Error(`"${t}" is a directory at this commit.`);if(a===void 0)return Error(`Could not read "${t}" at this commit.`);if(a.type!==void 0&&a.type!==`file`)return Error(`"${t}" is not a file at this commit.`);if(a.encoding===`base64`&&typeof a.content==`string`)return J4(a.content.replace(/\n/g,``));if(typeof a.download_url==`string`&&a.download_url.length>0){let e=await fetch(a.download_url,{signal:n}).catch(e=>e);if(e instanceof Error){if(e.name===`AbortError`)throw e;return Error(`Could not fetch "${t}" at this commit.`)}return!(e instanceof Response)||!e.ok?Error(`Could not fetch "${t}" at this commit.`):e.text()}return Error(`Could not read "${t}" at this commit.`)}function J4(e){try{let t=atob(e),n=Uint8Array.from(t,e=>e.charCodeAt(0));return new TextDecoder().decode(n)}catch(e){return Error(`GitHub returned invalid file encoding.`,{cause:e})}}async function Y4(e,t){let n=await fetch(`${H4}${e}`,{headers:U4,signal:t}).catch(e=>e);if(n instanceof Error&&n.name===`AbortError`)throw n;return n instanceof Response?R4(n)??{status:`ok`,body:n}:{status:`offline`}}function X4(e){let{resolvedTheme:t}=oa(),n=V(LG),r=Z4(e),i=VG(t),a=r===void 0?e.fallback:r.contents,o=S4(`excerpt:${e.path}#${String(e.start)}-${String(e.end)}`);return(0,z.jsx)(`div`,{className:n,"data-file-path":e.path,"data-diffmap-kind":`file`,children:(0,z.jsx)(X2,{file:{name:e.path,contents:a},disableWorkerPool:!0,lineAnnotations:o.fileAnnotations(e.path),renderAnnotation:e=>(0,z.jsx)(D4,{id:e.metadata}),options:{...i,enableGutterUtility:!0,onGutterUtilityClick:t=>{let{start:n,end:r}=w4(t);o.start({path:e.path,side:void 0,start:n,end:r,lineOffset:e.start-1,lines:a.split(/\r?\n/).slice(n-1,r),context:`file excerpt in the document`})}}})})}function Z4(e){let[t,n]=(0,R.useState)(),r=j4(),i=N4(),a=F4(),o=Q4(a,e);return(0,R.useEffect)(()=>{if(a!==void 0)return;if(r===`github`){if(i===void 0)return;G4(i,e.path).then(t=>{if(t instanceof Error)return;let n=t.split(/\r?\n/),r=e.start,i=Math.min(e.end,n.length);return{path:e.path,start:r,end:i,contents:n.slice(r-1,i).join(`
253
253
  `)}}).then(e=>{e!==void 0&&n(e)}).catch(e=>{console.warn(`diffmap file excerpt failed`,e)});return}if(r!==`local`)return;let t=new URLSearchParams({path:e.path,start:String(e.start),end:String(e.end)});fetch(`/__diffmap/file?${t.toString()}`).then(e=>{if(!e.ok){U0({event:`viewer_error`,kind:`excerpt`});return}return e.json()}).then(e=>{e!==void 0&&n(e)}).catch(e=>{U0({event:`viewer_error`,kind:`excerpt`}),console.warn(`diffmap file excerpt failed`,e)})},[e.path,e.start,e.end,r,i,a]),o??t}function Q4(e,t){if(e===void 0)return;let n=e[t.path];if(n===void 0)return;let r=n.split(/\r?\n/),i=t.start,a=Math.min(t.end,r.length);return{path:t.path,start:i,end:a,contents:r.slice(i-1,a).join(`
254
254
  `)}}function $4(e){let t=V(e3.shell);return(0,z.jsx)(`div`,{className:t,"data-diffmap-kind":`html`,dangerouslySetInnerHTML:{__html:e.source}})}var e3={shell:B(Fd.md,Vd.subtle,Y.padding({all:4}),{minWidth:0,backgroundColor:K.element})};function t3(e){let t=e.inline===!0,n=V(t?n3.inline:n3.block),r=j4()===`gist`?`HTML from this gist is not rendered.`:`HTML is not rendered on the hosted viewer.`;return t?(0,z.jsx)(`span`,{className:n,children:r}):(0,z.jsx)(`aside`,{className:n,"data-diffmap-kind":`html-disabled`,children:r})}var n3={block:B(Fd.md,Y.padding({all:4}),J({size:`sm`,color:`lowContrast`}),{minWidth:0,backgroundColor:G.gray[3]}),inline:B(J({size:`sm`,color:`lowContrast`}),{backgroundColor:G.gray[3]})},r3={bg:`var(--diffmap-mermaid-bg)`,fg:`var(--diffmap-mermaid-fg)`,accent:`var(--diffmap-mermaid-accent)`,muted:`var(--diffmap-mermaid-muted)`,surface:`var(--diffmap-mermaid-surface)`,border:`var(--diffmap-mermaid-border)`,font:`diffmap mermaid font`};function i3(e,t){let n=e.indexOf(`</style>`),r=e.slice(0,n);for(let[e,n]of Object.entries(r3)){let i=t[e];r=r.replaceAll(encodeURIComponent(n),encodeURIComponent(i)).replaceAll(n,i)}return r+e.slice(n)}var a3=`.edge, .edge-label, .message, .class-relationship, .er-relationship`;function o3(e,t){let n=s3(e),r=s3(t.today),i=s3(t.proposed),a=c3(r),o=c3(i);for(let e of n.querySelectorAll(`[data-id]`)){let t=e.getAttribute(`data-id`);o.has(t)?a.has(t)?a.get(t)!==o.get(t)&&e.setAttribute(`data-change`,`~`):e.setAttribute(`data-change`,`+`):e.setAttribute(`data-change`,`-`)}for(let e of n.querySelectorAll(`[data-actor]`)){let t=e.getAttribute(`data-actor`);o.has(t)?a.has(t)||e.setAttribute(`data-change`,`+`):e.setAttribute(`data-change`,`-`)}let s=u3(r),c=u3(i);for(let e of n.querySelectorAll(a3)){let t=l3(e);c.has(t)?s.has(t)||e.setAttribute(`data-change`,`+`):e.setAttribute(`data-change`,`-`)}return n.documentElement.outerHTML}function s3(e){return new DOMParser().parseFromString(e,`image/svg+xml`)}function c3(e){return new Map([...e.querySelectorAll(`[data-id]`)].map(e=>[e.getAttribute(`data-id`),e.getAttribute(`data-label`)]))}function l3(e){return[e.getAttribute(`class`),e.getAttribute(`data-from`),e.getAttribute(`data-to`),e.getAttribute(`data-label`)??``].join(`\0`)}function u3(e){return new Set([...e.querySelectorAll(a3)].map(l3))}var d3=[[`added`,`[data-change='+']`,G.green[9]],[`removed`,`[data-change='-']`,G.red[9]],[`hover`,`.source-edge:hover`,G.blue[8]],[`selected`,`.source-edge[aria-pressed='true']`,G.blue[9]]];function f3(e,t){let n=new DOMParser().parseFromString(e,`image/svg+xml`);p3(n);let r=[...n.querySelectorAll(`.edge, .message, .class-relationship, .er-relationship`)],i=[...n.querySelectorAll(`.edge-label`)];for(let[e,a]of t.entries()){let t=a.target===`node`?[...n.querySelectorAll(`[data-id]`)].filter(e=>e.dataset.id===a.id):r.slice(Number(a.id),Number(a.id)+1);if(t.length===0)return new mG({reason:`Mermaid ${a.target}:${a.id} does not exist in this diagram.`});for(let o of t){let t=n.createElementNS(`http://www.w3.org/2000/svg`,`g`);o.replaceWith(t),t.append(o),t.setAttribute(`data-source-index`,String(e)),t.setAttribute(`class`,`source-target source-${a.target}`),t.setAttribute(`role`,`button`),t.setAttribute(`tabindex`,`0`),t.setAttribute(`aria-controls`,`source-diff-panel`),t.setAttribute(`aria-pressed`,`false`);let s=o.getAttribute(`data-label`);if(t.setAttribute(`aria-label`,`Open source: ${s===null||s.length===0?a.annotation.text:s}`),a.target!==`edge`)continue;let c=Number(a.id),l=e=>e.dataset.from===o.dataset.from&&e.dataset.to===o.dataset.to&&e.dataset.label===o.dataset.label,u=r.slice(0,c).filter(l).length,d=i.filter(l)[u];d!==void 0&&t.append(d);let f=o.matches(`polyline, path, line`)?[o]:[...o.querySelectorAll(`line, polyline, path`)];for(let e of f){let n=e.cloneNode(!0);n.removeAttribute(`marker-start`),n.removeAttribute(`marker-end`),n.setAttribute(`class`,`source-hit`),n.setAttribute(`stroke`,`transparent`),n.setAttribute(`stroke-width`,`14`),n.setAttribute(`fill`,`none`),n.setAttribute(`aria-hidden`,`true`),t.prepend(n)}}}return n.documentElement.outerHTML}function p3(e){let t=[];for(let n of e.querySelectorAll(`marker[id]`)){let r=n.id;for(let[e,,t]of d3){let i=n.cloneNode(!0);i.id=`${r}--${e}`,m3(i,t),n.after(i)}m3(n,`var(--_line)`);for(let n of[`start`,`end`]){let i=`[marker-${n}="url(#${r})"]`;if(e.querySelector(i)!==null)for(let[e,a]of d3)t.push(`:is(${a}, ${a} *)${i} { marker-${n}: url(#${r}--${e}); }`)}}if(t.length===0)return;let n=e.createElementNS(`http://www.w3.org/2000/svg`,`style`);n.textContent=t.join(`
255
- `),e.documentElement.prepend(n)}function m3(e,t){for(let n of[e,...e.querySelectorAll(`*`)])for(let e of[`fill`,`stroke`])n.getAttribute(e)===`var(--_arrow)`&&n.setAttribute(e,t)}function h3(e){let[t,n]=(0,R.useState)(!1),r=V(LG,_3.frame),i=V(_3.expand),a=V(_3.dialog),o=V(_3.header),s=V(RG),c=V(_3.dialogTitle);return(0,z.jsxs)(`figure`,{className:r,children:[e.title!==void 0&&(0,z.jsx)(`figcaption`,{className:s,children:e.title}),(0,z.jsx)(g3,{...e,fullscreen:!1}),(0,z.jsx)(Vz,{className:i,size:`sm`,variant:`quiet`,"aria-label":`Full screen`,onClick:()=>{n(!0),U0({event:`diagram_used`,action:`fullscreen`})},children:(0,z.jsx)(yB,{size:`xs`})}),(0,z.jsxs)(wV,{isOpen:t,onOpenChange:n,size:`lg`,"aria-label":e.title??`Diagram`,className:a,children:[(0,z.jsxs)(`div`,{className:o,children:[(0,z.jsx)(`span`,{className:c,children:e.title}),(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,slot:`close`,"aria-label":`Exit full screen`,children:(0,z.jsx)(Yz,{size:`xs`})})]}),(0,z.jsx)(g3,{...e,fullscreen:!0,onSelectAnnotation:t=>{n(!1),e.onSelectAnnotation(t)}})]})]})}function g3(e){let t=(0,R.useRef)(null),n=V(_3.shell,e.fullscreen?_3.fullscreenShell:_3.inlineShell),r=(0,R.useMemo)(()=>{let t=e=>i3(e,{bg:K.app,fg:G.gray[12],accent:G.accent[9],muted:G.gray[11],surface:K.element,border:G.gray[6],font:bd}),n=t(e.svg.all);return`today`in e.svg?o3(n,{today:t(e.svg.today),proposed:t(e.svg.proposed)}):n},[e.svg]),i=(0,R.useMemo)(()=>f3(r,e.annotations),[r,e.annotations]),a=(0,R.useMemo)(()=>({__html:i instanceof Error?``:i}),[i]);return(0,R.useEffect)(()=>{if(!(i instanceof Error))for(let n of t.current.querySelectorAll(`[data-source-index]`)){let t=e.annotations[Number(n.getAttribute(`data-source-index`))].annotation;n.setAttribute(`aria-pressed`,String(t===e.selectedAnnotation))}},[i,e.annotations,e.selectedAnnotation]),i instanceof Error?(0,z.jsx)(`div`,{ref:t,className:n,"data-diffmap-kind":`mermaid`,children:i.message}):(0,z.jsx)(`div`,{ref:t,className:n,"data-diffmap-kind":`mermaid`,onClick:t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-source-index]`);r!==null&&e.onSelectAnnotation(e.annotations[Number(r.getAttribute(`data-source-index`))].annotation)},onKeyDown:t=>{if(t.key!==`Enter`&&t.key!==` `)return;let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-source-index]`);r!==null&&(t.preventDefault(),e.onSelectAnnotation(e.annotations[Number(r.getAttribute(`data-source-index`))].annotation))},dangerouslySetInnerHTML:a})}var _3={frame:B({position:`relative`,width:`100%`,margin:0,"& > figcaption":{paddingRight:`40px`},"& > [data-diffmap-kind='mermaid']":{padding:Y.value(6)}}),expand:B({position:`absolute`,top:`6px`,right:`6px`}),dialogTitle:B(J({size:`xs`,fontWeight:500,color:`lowContrast`})),dialog:B({width:`calc(100vw - 32px)`,height:`calc(100dvh - 32px)`,padding:Y.value(6),"& > [role='dialog']":{flex:1,minHeight:0,gap:Y.value(2)}}),header:B({display:`flex`,alignItems:`center`,justifyContent:`space-between`}),inlineShell:B({maxHeight:`60vh`,"& svg":{maxHeight:`60vh`}}),fullscreenShell:B({flex:1,"& svg":{height:`100%`}}),shell:B({width:`100%`,minHeight:0,overflow:`auto`,minWidth:0,border:0,boxShadow:`none`,"& .source-target":{cursor:`pointer`},"& .source-target:focus, & .source-target:focus-visible":{outline:`none`},"& .source-hit":{pointerEvents:`stroke`},"& .source-node:hover > g > rect, & .source-node:hover > g > polygon":{fill:G.blue[2],stroke:G.blue[8],strokeWidth:2},"& .source-node:hover text":{fill:G.blue[10]},"& .source-node[aria-pressed='true'] > g > rect, & .source-node[aria-pressed='true'] > g > polygon":{fill:G.blue[3],stroke:G.blue[9],strokeWidth:2},"& .source-node[aria-pressed='true'] text":{fill:G.blue[11]},"& .source-edge:hover > .edge, & .source-edge:hover > .message > line, & .source-edge:hover > .message > polyline, & .source-edge:hover > .class-relationship, & .source-edge:hover > .er-relationship":{stroke:G.blue[8],strokeWidth:1.5},"& .source-edge[aria-pressed='true'] > .edge, & .source-edge[aria-pressed='true'] > .message > line, & .source-edge[aria-pressed='true'] > .message > polyline, & .source-edge[aria-pressed='true'] > .class-relationship, & .source-edge[aria-pressed='true'] > .er-relationship":{stroke:G.blue[9],strokeWidth:2},"& svg":{display:`block`,width:`100%`,height:`auto`},...v3(`-`,G.red),...v3(`+`,G.green),...v3(`~`,G.amber)})};function v3(e,t){let n=`[data-change='${e}']`,r=e===`-`?{strokeDasharray:`5 3`}:{};return{[`& [data-id]${n} > :is(rect, polygon, circle, ellipse, path), & .edge-label${n} > rect`]:{fill:t[2],stroke:t[9],strokeWidth:1.5,...r},[`& ${n} text`]:{fill:t[11]},[`& :is(polyline, line)${n}, & ${n} > :is(line, polyline, path)`]:{stroke:t[9],strokeWidth:1.5,...r}}}var y3=`M3.788 9A.999.999 0 0 1 3 8.615l-2.288-3a1 1 0 1 1 1.576-1.23l1.5 1.991 3.924-4.991a1 1 0 1 1 1.576 1.23l-4.712 6A.999.999 0 0 1 3.788 9z`;function b3(e){let t=V(UB.root),n=V(UB.box),r=V(UB.check);return(0,z.jsx)(EV,{placement:e.placement??`bottom`,content:e.isSelected?`Mark as not reviewed`:`Mark as reviewed`,children:(0,z.jsx)(LI,{className:t,"data-reviewed":!0,"aria-label":`Reviewed`,isSelected:e.isSelected,isDisabled:e.isDisabled,onChange:e.onChange,children:(0,z.jsx)(`span`,{className:n,children:(0,z.jsx)(`svg`,{focusable:`false`,"aria-hidden":`true`,className:r,viewBox:`0 0 11 11`,children:(0,z.jsx)(`path`,{d:y3})})})})})}var x3,S3=(0,R.createContext)({load:()=>x3??=fetch(`/__diffmap/config`).then(async e=>await e.json(),e=>({error:String(e)}))});function C3(){return(0,R.useContext)(S3)}function w3(){let{load:e}=C3(),[t,n]=(0,R.useState)(void 0);return(0,R.useEffect)(()=>{let t=!0;return e().then(e=>{t&&n(e)}),()=>{t=!1}},[e]),t}function T3(e){return e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/([A-Z])([A-Z][a-z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function E3(e){return e.slice(e.indexOf(`--`)+2).split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function D3(e,t){let n=[];for(let r=t;r!==void 0;r=e[r].parent)n.unshift(e[r].story);return n}function O3(e,t){let n=[];for(let r=t;r!==void 0;r=e[r].parent)n.unshift(r);return n}function k3(e,t){return e.flatMap((e,n)=>e.parent===t?[n]:[])}function A3(e){let t=e.map(()=>({column:0,row:0})),n=0,r=(i,a)=>{let o=k3(e,i),s;if(o.length===0)s=n++;else{let e=o.map(e=>r(e,a+1));s=(e[0]+e.at(-1))/2}return t[i]={column:a,row:s},s};return e.length>0&&r(0,0),{placements:t,columns:Math.max(0,...t.map(e=>e.column))+1,rows:Math.max(1,n)}}var j3=8e3;function M3(e){let[t,n]=(0,R.useState)(0);return(0,z.jsx)(N3,{...e,onRetry:()=>n(t+1)},t)}function N3(e){let t=(0,R.useRef)(null),n=(0,R.useRef)(null),[r,i]=(0,R.useState)(e.lazy!==!0),[a,o]=(0,R.useState)(`loading`),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(),[p]=(0,R.useState)(()=>I3(e.page,e.initialPath)),m=(0,R.useRef)(void 0),h=(0,R.useRef)(0),g=(0,R.useRef)(()=>{}),_=(0,R.useRef)(()=>{}),v=(0,R.useRef)(!1),y=(0,R.useRef)(e);(0,R.useLayoutEffect)(()=>{y.current=e});let b=new URL(e.page,window.location.href).origin,x=C3().deployment!==void 0;(0,R.useEffect)(()=>{if(r)return;let e=n.current,t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i(!0)},{rootMargin:`300px`});return t.observe(e),()=>t.disconnect()},[r]),(0,R.useLayoutEffect)(()=>{if(e.renderWidth===void 0)return;let t=n.current,r=new ResizeObserver(()=>f(t.clientWidth));return r.observe(t),()=>r.disconnect()},[e.renderWidth]),(0,R.useEffect)(()=>{if(!r)return;let e=t.current,n=t=>e.contentWindow?.postMessage(t,b),i=()=>{let e=m.current;e!==void 0&&e.seq!==h.current&&(h.current=e.seq,n({type:`preview-show`,story:e.path.at(-1),how:e.how,path:e.path}))},a=!1,s=setTimeout(()=>{a||o(`unreachable`)},j3),l=()=>n({type:`preview-connect`}),d=t=>{if(t.source!==e.contentWindow||t.origin!==b)return;let r=t.data;switch(r?.type){case`preview-hello`:l();return;case`preview-ready`:a=!0,clearTimeout(s),o(`ready`),n({type:`preview-mode`,mode:y.current.mode}),y.current.onReady?.(r.stories),i();return;case`preview-size`:c(r.height);return;case`preview-state`:v.current=!0,u(void 0),y.current.onState?.(r);return;case`preview-error`:u(r.message),y.current.onError?.(r.message);return}};return window.addEventListener(`message`,d),e.addEventListener(`load`,l),g.current=()=>{a&&i()},_.current=e=>{a&&n({type:`preview-mode`,mode:e})},()=>{clearTimeout(s),window.removeEventListener(`message`,d),e.removeEventListener(`load`,l)}},[r,b]),(0,R.useEffect)(()=>{if(!r)return;let e=t.current,n=()=>requestAnimationFrame(()=>{document.activeElement===e&&(y.current.mode===`live`&&v.current||(e.blur(),F3?.isConnected&&F3.focus({preventScroll:!0})))});return window.addEventListener(`blur`,n),()=>window.removeEventListener(`blur`,n)},[r]),(0,R.useEffect)(()=>{e.request!==void 0&&(m.current=e.request,g.current())},[e.request]),(0,R.useEffect)(()=>{_.current(e.mode)},[e.mode]);let S=e.renderWidth===void 0||d===void 0?1:Math.min(1,d/e.renderWidth),C=e.renderHeight??s??160,w=Math.min(C*S,e.maxHeight??1/0),T=V(L3.box),E=V(L3.frame,e.mode===`thumbnail`&&L3.inert),D=V(L3.overlay),O=V(L3.error);return(0,z.jsxs)(`div`,{ref:n,className:T,style:{height:w},"data-preview-status":a,children:[r&&(0,z.jsx)(`iframe`,{ref:t,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,src:p,title:e.label,className:E,tabIndex:e.mode===`thumbnail`?-1:void 0,"aria-hidden":e.mode===`thumbnail`||void 0,style:{width:e.renderWidth??`100%`,height:e.renderWidth===void 0?w:C,transform:S===1?void 0:`scale(${S})`}}),a===`loading`&&(0,z.jsx)(`div`,{className:D,children:(0,z.jsx)(nz,{})}),a===`unreachable`&&(0,z.jsxs)(`div`,{className:D,role:`alert`,children:[(0,z.jsx)(wB,{size:`md`}),x?(0,z.jsxs)(`span`,{children:[`The pull request's preview deployment isn't answering at`,` `,e.page,`.`]}):(0,z.jsxs)(`span`,{children:[`Can't reach the app's preview page at `,e.page,`.`]}),e.mode===`live`&&(0,z.jsxs)(z.Fragment,{children:[x?(0,z.jsxs)(`span`,{children:[`It may still be building: retry in a minute, or `,(0,z.jsx)(P3,{}),`.`]}):(0,z.jsx)(`span`,{children:`Start the app's dev server, then retry.`}),(0,z.jsxs)(Vz,{size:`sm`,onClick:e.onRetry,children:[(0,z.jsx)(TB,{size:`xs`}),`Retry`]})]})]}),l!==void 0&&e.mode===`live`&&(0,z.jsx)(`div`,{className:O,role:`alert`,children:l})]})}function P3(){let e=V(L3.inlineLink);return(0,z.jsx)(`a`,{className:e,href:`https://github.com/tanishqkancharla/diffmap/blob/main/guide.md#serve-and-share`,children:`run this spec with product-doc serve`})}var F3;document.addEventListener(`focusin`,e=>{e.target instanceof HTMLElement&&e.target.tagName!==`IFRAME`&&(F3=e.target)});function I3(e,t){let n=new URL(e,window.location.href);return n.searchParams.set(`story`,t.at(-1)),t.length>1&&n.searchParams.set(`path`,t.join(`,`)),n.href}var L3={box:B({position:`relative`,width:`100%`,overflow:`hidden`,transition:`height 160ms ease-out`}),frame:B({display:`block`,border:0,transformOrigin:`0 0`,backgroundColor:`white`}),inert:B({pointerEvents:`none`}),inlineLink:B({font:`inherit`,color:G.gray[12],textDecorationLine:`underline`,textUnderlineOffset:`2px`}),overlay:B(J({size:`xs`,color:`lowContrast`}),Y.padding({all:6}),{position:`absolute`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:Y.value(3),textAlign:`center`,backgroundColor:G.gray[2]}),error:B(J({size:`xs`}),Y.padding({x:4,y:2}),{position:`absolute`,insetInline:0,bottom:0,color:G.red[11],backgroundColor:G.red[2]})};function R3(e){let t=z3(),[n,r]=(0,R.useState)(),i=V(LG),a=V(RG),o=V(V3.grid,e.stories.length>1&&V3.multiple),s=V(V3.cell),c=V(V3.name),l=V(V3.note);return(0,z.jsxs)(`figure`,{className:i,"data-diffmap-kind":`preview`,children:[e.title!==void 0&&(0,z.jsx)(`figcaption`,{className:a,children:e.title}),`message`in t?t.message:(0,z.jsx)(`div`,{className:o,children:e.stories.map(e=>{let i=n?.get(e);return(0,z.jsxs)(`div`,{className:s,children:[(0,z.jsx)(`div`,{className:c,children:i===void 0?E3(e):T3(i.name)}),(0,z.jsx)(M3,{page:t.url,initialPath:[e],mode:`live`,maxHeight:560,label:i===void 0?E3(e):T3(i.name),onReady:e=>r(new Map(e.map(e=>[e.id,e])))}),i?.description!==void 0&&(0,z.jsx)(`div`,{className:l,children:i.description})]},e)})})]})}function z3(){let e=j4(),{deployment:t}=C3(),n=w3();if(e!==`local`&&(e!==`github`||t===void 0))return{message:(0,z.jsxs)(B3,{children:[`Live previews show when you `,(0,z.jsx)(P3,{}),`.`]})};if(n===void 0)return{message:(0,z.jsx)(B3,{children:`Loading…`})};if(`error`in n)return{message:(0,z.jsxs)(B3,{children:[`Can't read .diffmap/config.json: `,n.error]})};if(t===void 0){let e=n.config.previews?.local;return e===void 0?{message:(0,z.jsx)(B3,{children:`Add previews.local to .diffmap/config.json, the URL of the app's preview page, such as http://localhost:5173/previews.html.`})}:{url:e}}let r=n.config.previews?.preview;if(r===void 0)return{message:(0,z.jsxs)(B3,{children:[`This repo's .diffmap/config.json has no previews.preview, the URL of the preview page on each pull request's deployment. Until it does, live previews show when you `,(0,z.jsx)(P3,{}),`.`]})};let i=I4(r,t);return i instanceof Error?{message:(0,z.jsxs)(B3,{children:[i.message,` Open this spec from its pull request, or `,(0,z.jsx)(P3,{}),`.`]})}:{url:i}}function B3(e){let t=V(V3.notice);return(0,z.jsx)(`div`,{className:t,children:e.children})}var V3={grid:B({display:`grid`,gridTemplateColumns:`1fr`,gap:Y.value(1),backgroundColor:G.gray[4]}),multiple:B({gridTemplateColumns:`repeat(auto-fit, minmax(280px, 1fr))`}),cell:B({display:`flex`,flexDirection:`column`,minWidth:0,backgroundColor:G.gray[1]}),name:B(J({size:`xs`,fontWeight:500}),Y.padding({x:6,y:3}),{borderBottom:`1px solid ${G.gray[4]}`}),note:B(J({size:`xs`,color:`lowContrast`}),Y.padding({x:6,y:3}),{margin:0,lineHeight:1.5,borderTop:`1px solid ${G.gray[4]}`}),notice:B(J({size:`sm`,color:`lowContrast`}),Y.padding({all:6}))},H3=new Set,U3=new Map;function W3(){return`diffmap-reviewed-previews:${window.location.pathname}`}function G3(){let e=W3(),t=U3.get(e);if(t===void 0){try{t=JSON.parse(localStorage.getItem(e)??`{}`)}catch{t={}}U3.set(e,t)}return t}function K3(e){let t=W3();U3.set(t,e);try{Object.keys(e).length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(e))}catch(e){console.warn(`diffmap could not save reviewed previews`,e)}for(let e of H3)e()}function q3(){let e=(0,R.useSyncExternalStore)(e=>(H3.add(e),()=>H3.delete(e)),G3);return{isReviewed:(0,R.useCallback)((t,n)=>n!==void 0&&e[t]===n,[e]),setReviewed:(0,R.useCallback)((e,t,n)=>{let{[e]:r,...i}=G3();K3(n?{...i,[e]:t}:i)},[])}}var J3=720,Y3=248,X3=8,Z3=300,Q3={width:152,height:128,gapX:32,gapY:16};function $3(e){let{states:t}=e,n=z3(),r=w3(),i=r!==void 0&&`config`in r?r.config.flows:void 0,a=i?.transitions??`play`,o=i?.viewport,[s,c]=(0,R.useState)(0),[l,u]=(0,R.useState)(void 0),[d,f]=(0,R.useState)(void 0),[p,m]=(0,R.useState)(),[h,g]=(0,R.useState)({}),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(!0),[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(),T=(0,R.useRef)(!1),E=(0,R.useRef)(void 0),[D,O]=(0,R.useState)(),k=(0,R.useRef)(0),A=(0,R.useRef)(null),j=(0,R.useRef)(null),M=(0,R.useRef)(null),{isReviewed:ee,setReviewed:te}=q3(),N=e=>t.findIndex(t=>t.story===e),ne=e=>{let n=p?.get(t[e].story);return n===void 0?E3(t[e].story):T3(n.name)},re=e=>`flow:${D3(t,e).join(`>`)}`,P=e=>{if(e===s&&l===e)return;let n=a===`play`&&l!==void 0&&t[e].parent===l?`play`:`render`;c(e),k.current+=1,f({path:D3(t,e),how:n,seq:k.current})},ie=e=>{e&&O(A.current.offsetHeight),v(e)};(0,R.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&v(!1)},t=document.body.style.overflow;return document.body.style.overflow=`hidden`,window.addEventListener(`keydown`,e),j.current?.focus(),()=>{document.body.style.overflow=t,window.removeEventListener(`keydown`,e)}},[_]),(0,R.useEffect)(()=>{if(!_)return;let e=M.current,t=e?.querySelector(`[data-state='${s}']`);if(e===null||t==null)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();e.scrollTo({left:e.scrollLeft+r.left-n.left-(n.width-r.width)/2,top:e.scrollTop+r.top-n.top-(n.height-r.height)/2,behavior:`instant`})},[s,_]),(0,R.useEffect)(()=>{if(C===void 0)return;let e=()=>{window.clearTimeout(E.current),T.current=!1,w(void 0)};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[C]);let F=A3(t),ae=O3(t,s),oe=k3(t,s),se=t[s].parent,ce=p!==void 0&&l!==s,le=p?.get(t[s].story)?.description,ue=e=>ee(re(e),h[t[e].story]),de=(e,n)=>{let r=h[t[e].story];r!==void 0&&te(re(e),r,n)},fe=(e,t)=>{if(S(!0),e===s){pe();return}let n=t.getBoundingClientRect(),r=t.closest(`[data-states-sidebar]`).getBoundingClientRect(),i=r.right+X3,a=i+Y3<=window.innerWidth-X3?i:r.left-X3-Y3,o=Math.max(X3,Math.min(n.top,window.innerHeight-Z3));if(window.clearTimeout(E.current),T.current){w({index:e,top:o,left:a});return}E.current=window.setTimeout(()=>{T.current=!0,w({index:e,top:o,left:a})},300)},pe=()=>{window.clearTimeout(E.current),T.current=!1,w(void 0)},me=V(n6.wrapper),I=V(n6.scrim),he=V(LG,n6.card,_&&n6.expandedCard),ge=V(RG,n6.header),_e=V(n6.crumbs),ve=V(n6.crumbStep),ye=V(n6.crumb),be=V(n6.body,!_&&y&&n6.bodyWithSidebar,_&&n6.expandedBody),xe=V(n6.stage,_&&n6.expandedStage),Se=V(n6.controls),Ce=V(n6.note),we=V(n6.actions),Te=V(n6.endNote),Ee=V(n6.sidebar),De=V(n6.outline),Oe=V(n6.outlineItem),ke=V(n6.outlineLabel),Ae=V(n6.guides),je=V(n6.guide),Me=V(TV.root,n6.peekCard),Ne=V(n6.peekFrames),Pe=V(n6.peekFrame),Fe=V(n6.map),Ie=V(n6.mapCard),Le=V(n6.thumbFrame),Re=V(n6.thumbLabel),ze=V(n6.thumbHit),Be=V(n6.thumbReview),Ve=V(n6.reviewedMark),He=V(n6.edges);if(`message`in n)return(0,z.jsxs)(`figure`,{className:he,"data-diffmap-kind":`flow`,children:[e.title!==void 0&&(0,z.jsx)(`figcaption`,{className:ge,children:e.title}),n.message]});let Ue=e=>({position:`absolute`,left:`calc(${F.placements[e].column*(Q3.width+Q3.gapX)}px + ${Y.value(6)})`,top:`calc(${F.placements[e].row*(Q3.height+Q3.gapY)}px + ${Y.value(6)})`}),We=F.columns*(Q3.width+Q3.gapX)-Q3.gapX,Ge=F.rows*(Q3.height+Q3.gapY)-Q3.gapY,Ke=(e,r)=>{let i=t[e],a=ue(e);return(0,z.jsxs)(`div`,{className:Ie,"data-state":e,"aria-current":e===s?`step`:void 0,style:r,children:[(0,z.jsx)(`div`,{className:Le,"data-reviewed":a,children:p!==void 0&&(0,z.jsx)(M3,{page:n.url,initialPath:D3(t,e),mode:`thumbnail`,renderWidth:J3,label:ne(e),onState:e=>g(t=>({...t,[i.story]:e.fingerprint}))})}),a&&(0,z.jsx)(`div`,{className:Ve,role:`img`,"aria-label":`Reviewed: ${ne(e)}`,children:(0,z.jsx)(aB,{size:`sm`})}),(0,z.jsx)(`div`,{className:Re,children:i.action??`Start`}),(0,z.jsx)(`button`,{type:`button`,className:ze,"aria-label":ne(e),onClick:()=>P(e)}),(0,z.jsx)(`div`,{className:Be,role:`group`,"aria-label":`Review ${ne(e)}`,children:(0,z.jsx)(b3,{isSelected:a,onChange:t=>de(e,t)})})]},i.story)};return(0,z.jsxs)(`div`,{ref:A,className:me,style:{height:_?D:void 0},children:[_&&(0,z.jsx)(`div`,{className:I,onClick:()=>ie(!1)}),(0,z.jsxs)(`figure`,{ref:j,className:he,"data-diffmap-kind":`flow`,tabIndex:-1,"aria-label":e.title??`Flow`,"aria-modal":_||void 0,role:_?`dialog`:void 0,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`ArrowRight`&&oe[0]!==void 0&&P(oe[0]),e.key===`ArrowLeft`&&se!==void 0&&P(se))},children:[(0,z.jsxs)(`figcaption`,{className:ge,children:[e.title!==void 0&&(0,z.jsx)(`span`,{children:e.title}),(0,z.jsx)(`nav`,{className:_e,"aria-label":`Steps taken`,children:ae.map((e,t)=>(0,z.jsxs)(`span`,{className:ve,children:[t>0&&(0,z.jsx)(cB,{size:`2xs`}),(0,z.jsx)(`button`,{type:`button`,className:ye,"aria-current":e===s?`step`:void 0,onClick:()=>P(e),children:ne(e)})]},e))}),ce&&(0,z.jsx)(nz,{size:`xs`,"aria-label":`Playing the step`}),(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":_?`Collapse the flow`:`Expand the flow`,onClick:()=>ie(!_),children:_?(0,z.jsx)(Yz,{size:`xs`}):(0,z.jsx)(yB,{size:`xs`})}),!_&&(0,z.jsx)(EV,{content:y?`Hide states`:`Show states`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":y?`Hide states`:`Show states`,"aria-pressed":y,onClick:()=>b(!y),children:(0,z.jsx)(vB,{size:`xs`})})})]}),(0,z.jsxs)(`div`,{className:be,children:[(0,z.jsxs)(`div`,{className:xe,children:[(0,z.jsx)(M3,{page:n.url,initialPath:[t[0].story],mode:`live`,lazy:!0,request:d,renderWidth:_?o?.width:void 0,renderHeight:_?o?.height:void 0,maxHeight:_?void 0:640,label:`${e.title??`Flow`}: ${ne(s)}`,onReady:e=>m(new Map(e.map(e=>[e.id,e]))),onState:e=>{let t=N(e.story);t!==-1&&(u(t),g(t=>t[e.story]===void 0?{...t,[e.story]:e.fingerprint}:t))}}),(0,z.jsxs)(`div`,{className:Se,children:[le!==void 0&&(0,z.jsx)(`div`,{className:Ce,children:le}),(0,z.jsxs)(Vz,{size:`sm`,isDisabled:se===void 0,onClick:()=>se!==void 0&&P(se),children:[(0,z.jsx)(rB,{size:`xs`}),`Back`]}),(0,z.jsx)(`div`,{className:we,children:oe.length===0?(0,z.jsx)(`span`,{className:Te,children:`End of this path`}):(0,z.jsx)(t6,{steps:oe.map(e=>({index:e,action:t[e].action})),onSelect:P})})]})]}),_?(0,z.jsxs)(`div`,{ref:M,className:Fe,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,style:{width:`calc(${We}px + 2 * ${Y.value(6)})`,height:`calc(${Ge}px + 2 * ${Y.value(6)})`}}),(0,z.jsx)(`svg`,{className:He,"aria-hidden":!0,children:t.map((e,t)=>{if(e.parent===void 0)return;let n=F.placements[e.parent],r=F.placements[t],i=n.column*(Q3.width+Q3.gapX)+Q3.width,a=n.row*(Q3.height+Q3.gapY)+Q3.height/2,o=r.column*(Q3.width+Q3.gapX),s=r.row*(Q3.height+Q3.gapY)+Q3.height/2,c=(i+o)/2;return(0,z.jsx)(`path`,{d:`M ${i} ${a} C ${c} ${a}, ${c} ${s}, ${o} ${s}`,"data-active":ae.includes(t)||void 0},e.story)})}),t.map((e,t)=>Ke(t,Ue(t)))]}):y&&(0,z.jsxs)(`div`,{className:Ee,"data-states-sidebar":!0,onPointerEnter:()=>S(!0),children:[(0,z.jsx)(`nav`,{className:De,"aria-label":`Every state`,onPointerLeave:pe,children:t.map((e,n)=>{let r=O3(t,n);return(0,z.jsxs)(`div`,{className:Oe,"aria-current":n===s?`step`:void 0,"data-on-path":ae.includes(n)||void 0,onPointerEnter:e=>fe(n,e.currentTarget),children:[(0,z.jsx)(`span`,{className:Ae,"aria-hidden":!0,children:r.slice(1).map((e,n)=>(0,z.jsx)(`span`,{className:je,"data-elbow":n===r.length-2||void 0,"data-continued":e6(t,e)||void 0},e))}),(0,z.jsx)(`button`,{type:`button`,className:ke,"aria-current":n===s?`step`:void 0,onClick:()=>{pe(),P(n)},onFocus:e=>fe(n,e.currentTarget.parentElement),onBlur:pe,children:ne(n)}),(0,z.jsx)(b3,{isSelected:ue(n),isDisabled:h[e.story]===void 0,onChange:e=>de(n,e)})]},e.story)})}),x&&p!==void 0&&(0,hD.createPortal)((0,z.jsxs)(`div`,{className:Me,"data-open":C!==void 0||void 0,style:{top:C?.top??0,left:C?.left??0},"aria-hidden":!0,children:[(0,z.jsx)(`div`,{className:Ne,children:t.map((e,r)=>(0,z.jsx)(`div`,{className:Pe,"data-shown":r===C?.index||void 0,children:(0,z.jsx)(M3,{page:n.url,initialPath:D3(t,r),mode:`thumbnail`,renderWidth:J3,maxHeight:140,label:ne(r),onState:t=>g(n=>({...n,[e.story]:t.fingerprint}))})},e.story))}),C!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`strong`,{children:ne(C.index)}),p.get(t[C.index].story)?.description!==void 0&&(0,z.jsx)(`span`,{"data-description":!0,children:p.get(t[C.index].story).description})]})]}),document.body)]})]})]})]})}function e6(e,t){let n=e[t].parent;return e.some((e,r)=>r>t&&e.parent===n)}function t6(e){let[t,...n]=e.steps,r=V(n6.segmented);return(0,z.jsxs)(`div`,{className:r,children:[(0,z.jsxs)(Vz,{size:`sm`,variant:`primary`,onClick:()=>e.onSelect(t.index),children:[t.action,(0,z.jsx)(iB,{size:`xs`})]}),n.length>0&&(0,z.jsxs)(FH,{placement:`bottom end`,children:[(0,z.jsx)(Vz,{size:`sm`,variant:`primary`,"aria-label":`${n.length} other next ${n.length===1?`step`:`steps`}`,children:(0,z.jsx)(oB,{size:`xs`})}),(0,z.jsx)(LH,{onAction:t=>e.onSelect(Number(t)),children:n.map(e=>(0,z.jsx)(RH,{id:String(e.index),children:e.action},e.index))})]})]})}var n6={wrapper:B({position:`relative`,width:`100%`}),scrim:B({position:`fixed`,inset:0,zIndex:50,backgroundColor:`rgb(0 0 0 / 0.25)`}),card:B({width:`100%`,margin:0,outline:`none`}),expandedCard:B({position:`fixed`,inset:`16px`,zIndex:51,width:`auto`,display:`flex`,flexDirection:`column`,backgroundColor:G.gray[1]}),header:B({display:`flex`,alignItems:`center`,gap:Y.value(4),minHeight:`36px`,"& > span:first-child":{flexShrink:0,color:G.gray[12]}}),crumbs:B({display:`flex`,alignItems:`center`,gap:Y.value(1),flex:1,minWidth:0,overflow:`hidden`,whiteSpace:`nowrap`}),crumbStep:B({display:`flex`,alignItems:`center`,gap:Y.value(1),flexShrink:0}),crumb:B(J({size:`xs`}),Ud(),{border:0,padding:`2px 4px`,borderRadius:`4px`,background:`none`,color:G.gray[11],cursor:`pointer`,"&[aria-current='step']":{color:G.gray[12],fontWeight:600},"&:hover":{color:G.gray[12]}}),body:B({display:`grid`,gridTemplateColumns:`minmax(0, 1fr)`,minHeight:0}),bodyWithSidebar:B({gridTemplateColumns:`minmax(0, 1fr) 200px`}),expandedBody:B({flex:1,gridTemplateColumns:`minmax(0, 3fr) minmax(0, 2fr)`,gridTemplateAreas:`'stage map'`}),stage:B({display:`flex`,flexDirection:`column`,minWidth:0,backgroundColor:G.gray[2]}),expandedStage:B({gridArea:`stage`,overflow:`auto`}),controls:B(Y.padding({x:6,y:4}),{display:`flex`,flexWrap:`wrap`,alignItems:`center`,columnGap:Y.value(4),rowGap:Y.value(3),borderTop:`1px solid ${G.gray[4]}`,backgroundColor:G.gray[1]}),note:B(J({size:`xs`,color:`lowContrast`}),{flexBasis:`100%`,lineHeight:1.5}),actions:B({display:`flex`,alignItems:`center`,gap:Y.value(2),marginLeft:`auto`}),endNote:B(J({size:`xs`,color:`lowContrast`}),{paddingInline:Y.value(2)}),segmented:B({display:`inline-flex`,"& > button:not(:last-child)":{borderTopRightRadius:0,borderBottomRightRadius:0},"& > button + button":{borderTopLeftRadius:0,borderBottomLeftRadius:0,marginLeft:`1px`}}),peekCard:B({position:`fixed`,width:`${Y3}px`,maxWidth:`none`,boxSizing:`border-box`,display:`flex`,flexDirection:`column`,gap:`2px`,padding:Y.value(2),visibility:`hidden`,pointerEvents:`none`,"&[data-open]":{visibility:`visible`},"& > strong":{marginTop:Y.value(1),fontWeight:600},"& > [data-description]":{color:G.gray[11],marginTop:`2px`,lineHeight:1.45}}),peekFrames:B(Fd.sm,{position:`relative`,overflow:`hidden`}),peekFrame:B({position:`absolute`,top:0,left:0,right:0,visibility:`hidden`,"&[data-shown]":{position:`relative`,visibility:`visible`}}),sidebar:B({position:`relative`,minWidth:0,borderLeft:`1px solid ${G.gray[4]}`,backgroundColor:G.gray[1]}),outline:B({position:`absolute`,inset:0,display:`flex`,flexDirection:`column`,padding:Y.value(2),overflowY:`auto`}),outlineItem:B(J({size:`xs`}),{display:`flex`,alignItems:`stretch`,flexShrink:0,minHeight:`28px`,paddingInline:`4px 6px`,borderRadius:`4px`,color:G.gray[11],"& > label":{alignSelf:`center`,flexShrink:0},"&[data-on-path]":{color:G.gray[12]},"&:hover":{backgroundColor:G.gray[3]},"&[aria-current='step']":{backgroundColor:G.accent[3],color:G.gray[12],fontWeight:600}}),outlineLabel:B(Ud(),{flex:1,minWidth:0,padding:`0 4px`,border:0,borderRadius:`4px`,background:`none`,color:`inherit`,font:`inherit`,textAlign:`left`,cursor:`pointer`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),guides:B({display:`inline-flex`,flexShrink:0}),guide:B({position:`relative`,width:`16px`,flexShrink:0,"&[data-continued]::before":{content:`''`,position:`absolute`,left:`7px`,insetBlock:0,borderLeft:`1px solid ${G.gray[6]}`},"&[data-elbow]::after":{content:`''`,position:`absolute`,left:`7px`,right:0,top:0,bottom:`50%`,borderLeft:`1px solid ${G.gray[6]}`,borderBottom:`1px solid ${G.gray[6]}`,borderBottomLeftRadius:`5px`},"&[data-elbow][data-continued]::after":{top:`50%`,bottom:`auto`,borderLeft:0,borderBottomLeftRadius:0}}),map:B({gridArea:`map`,position:`relative`,overflow:`auto`,borderLeft:`1px solid ${G.gray[4]}`,backgroundColor:G.gray[2]}),mapCard:B(Fd.md,Vd.subtle,{position:`relative`,flexShrink:0,width:`${Q3.width}px`,height:`${Q3.height}px`,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:G.gray[1],"&[aria-current='step']":{boxShadow:`0 0 0 2px ${G.accent[9]}`},"&:has(> button:focus-visible)":{boxShadow:`0 0 0 2px ${G.accent[8]}`}}),thumbFrame:B({height:`${Q3.height-36}px`,overflow:`hidden`,flexShrink:0,transition:`opacity 120ms`,"&[data-reviewed='true']":{opacity:.35}}),thumbLabel:B(J({size:`xs`,fontWeight:500}),Y.padding({x:3,y:2}),{display:`flex`,alignItems:`center`,flex:1,minHeight:0,borderTop:`1px solid ${G.gray[4]}`,color:G.gray[12],lineHeight:1.25}),thumbHit:B({position:`absolute`,inset:0,padding:0,border:0,background:`none`,cursor:`pointer`,outline:`none`}),thumbReview:B({position:`absolute`,top:Y.value(1),right:Y.value(1),zIndex:1,display:`flex`,padding:`2px`,borderRadius:`4px`,backgroundColor:G.gray[1]}),reviewedMark:B(Fd.circle,Vd.subtle,{position:`absolute`,top:`${(Q3.height-36)/2}px`,left:`50%`,transform:`translate(-50%, -50%)`,width:`32px`,height:`32px`,display:`grid`,placeItems:`center`,color:`white`,backgroundColor:G.green[9],pointerEvents:`none`}),edges:B({position:`absolute`,top:Y.value(6),left:Y.value(6),width:`100%`,height:`100%`,overflow:`visible`,pointerEvents:`none`,"& path":{fill:`none`,stroke:G.gray[7],strokeWidth:1.5},"& path[data-active]":{stroke:G.accent[9],strokeWidth:2}})},r6=String.raw`[A-Za-z_]\w*`;new RegExp(String.raw`^service\s+(${r6})(?:\s+"([^"]*)")?\s*$`),new RegExp(String.raw`^state\s+(${r6})\s*=\s*(.+)$`),new RegExp(String.raw`^(${r6})\s*->\s*(${r6})(?:\s*:\s*(.*))?$`),new RegExp(String.raw`^(${r6})\.(${r6})\s*=\s*(.+)$`),new RegExp(String.raw`^(${r6})$`);function i6(e,t){return e.flatMap(e=>[{service:e,parent:t},...i6(e.children,e)])}function a6(e,t,n=`proposed`){let r=n===`today`?`+`:`-`,i=new Map(i6(e.services).map(({service:e})=>[e.name,new Map(e.state.filter(e=>e.sign!==r).map(e=>[e.key,n===`today`?e.todayValue??e.value:e.value]))]));for(let{updates:n}of e.steps.slice(0,t))for(let e of n)e.sign!==r&&i.get(e.service).set(e.key,e.value);return i}function o6(e){if(e.label===``)return``;let t={"+":`+ `,"-":`− `," ":``}[e.sign],n=e.annotation===void 0?``:` ↗`;return`${t}${e.label}${n}`}function s6(e){let t=new Map(i6(e.services).map(({service:e},t)=>[e.name,t])),n=new Map;for(let r of e.steps)for(let e of r.events){let r=t.get(e.from)<=t.get(e.to),[i,a]=r?[e.from,e.to]:[e.to,e.from],o=c6(i,a),s=n.get(o)??{id:o,a:i,b:a,forward:!1,backward:!1,label:void 0,sign:e.sign};r?s.forward=!0:s.backward=!0,s.sign!==e.sign&&(s.sign=` `);let c=o6(e);c.length>(s.label?.length??0)&&(s.label=c),n.set(o,s)}return[...n.values()]}function c6(e,t){return e<t?`${e}|${t}`:`${t}|${e}`}var l6;function u6(){return l6??=YW(()=>import(`./elk.bundled-CVOErv1M.js`).then(t=>e(t.default,1)).then(e=>new e.default),__vite__mapDeps([4,5])),l6}function d6(e,t){return e.children.some(e=>e.name===t||d6(e,t))}async function f6(e){let t=String(e.direction===`RIGHT`?Math.max(40,e.label.width+24):Math.max(40,e.label.height+28)),n=r=>{let i=e.sizes.get(r.name);if(r.children.length===0)return{id:r.name,width:i.width,height:i.height};let a=e.links.some(e=>e.a===r.name&&d6(r,e.b)),o=e=>a?e+24:0,s=i.height+4+(e.direction===`DOWN`?o(e.label.height):0),c=16+(e.direction===`RIGHT`?o(e.label.width):0);return{id:r.name,layoutOptions:{"elk.padding":`[top=${s},left=${c},bottom=16,right=16]`,"elk.nodeSize.constraints":`MINIMUM_SIZE`,"elk.layered.spacing.nodeNodeBetweenLayers":t,"elk.nodeSize.minimum":e.direction===`DOWN`?`(0,${i.width})`:`(${i.width},0)`},children:r.children.map(n)}},r={id:`root`,layoutOptions:{"elk.algorithm":`layered`,"elk.direction":e.direction,"elk.edgeRouting":`ORTHOGONAL`,"elk.hierarchyHandling":`INCLUDE_CHILDREN`,"elk.layered.considerModelOrder.strategy":`NODES_AND_EDGES`,"elk.json.edgeCoords":`ROOT`,"elk.json.shapeCoords":`ROOT`,"elk.padding":`[top=8,left=8,bottom=8,right=8]`,"elk.spacing.nodeNode":`32`,"elk.layered.spacing.nodeNodeBetweenLayers":t,"elk.spacing.edgeNode":`16`,"elk.spacing.edgeEdge":`12`},children:e.diagram.services.map(n),edges:e.links.map(e=>({id:e.id,sources:[e.a],targets:[e.b]}))},i=await(await u6()).layout(r),a=new Map,o=e=>{for(let t of e??[])a.set(t.id,{x:t.x,y:t.y,width:t.width,height:t.height}),o(t.children)};o(i.children);let s=new Map((i.edges??[]).map(e=>{let t=e.sections[0];return[e.id,[t.startPoint,...t.bendPoints??[],t.endPoint]]}));return{width:i.width,height:i.height,sizes:e.sizes,boxes:a,routes:s}}var p6=200,m6=28;function h6(e){let t=e.diagram,n=(0,R.useMemo)(()=>i6(t.services),[t]),r=(0,R.useMemo)(()=>s6(t),[t]),i=(0,R.useMemo)(()=>y6(t),[t]),a=(0,R.useRef)(null),o=(0,R.useRef)(null),[s,c]=(0,R.useState)(),l=(0,R.useMemo)(()=>t.steps.some(e=>e.events.some(e=>e.note!==void 0)||e.updates.some(e=>e.note!==void 0)||e.notes.length>0)?256:0,[t]),u=(0,R.useId)();(0,R.useLayoutEffect)(()=>{let e=0,n=-1,i=async i=>{let s=a.current.clientWidth;if(!i&&s===n)return;n=s;let u=++e,d=new Map([...o.current.querySelectorAll(`[data-measure-service]`)].map(e=>[e.getAttribute(`data-measure-service`),E6(e)])),f={width:0,height:0},p=new Map;for(let e of o.current.querySelectorAll(`[data-measure-link]`)){let t=E6(e);p.set(e.getAttribute(`data-measure-link`),t),f.width=Math.max(f.width,t.width),f.height=Math.max(f.height,t.height)}let m={diagram:t,links:r,sizes:d,label:f},h=e=>e.width+l<=s,g=await f6({...m,direction:`RIGHT`}),_=h(g)?g:await f6({...m,direction:`DOWN`}),v=_.width<g.width?_:g,y=Math.min(1,s/v.width),b=(s-v.width*y)/2;u===e&&c({layout:v,labels:p,scale:y,left:b,notesBelow:b<l})};i(!0),document.fonts.ready.then(()=>i(!0));let s=new ResizeObserver(()=>void i(!1));return s.observe(a.current),()=>{e=NaN,s.disconnect()}},[t,r,l]);let d=(0,R.useMemo)(()=>new Map(n.map(({service:e,parent:t})=>[e.name,t?.name])),[n]),f=(0,R.useMemo)(()=>{let e=new Map;for(let{service:t,parent:r}of n)e.set(t.name,r===void 0?0:e.get(r.name)+1);return e},[n]),p=V(j6.stage),m=V(j6.measureLayer),h=V(j6.canvas),g=V(j6.overlay),_=V(j6.box),v=V(j6.pill),y=s?.layout,b=y===void 0?[]:n.flatMap(({service:e})=>e.children.length===0?[y.boxes.get(e.name)]:[]),x=e.phase===`settled`,S=(0,R.useMemo)(()=>x?[...e.events.flatMap((e,t)=>e.note===void 0?[]:[{id:`event-${t}`,text:e.note,target:`[data-event-label="${t}"]`,service:void 0}]),...e.updates.flatMap((e,t)=>e.note===void 0?[]:[{id:`update-${t}`,text:e.note,target:`[data-state-row="${e.service}.${e.key}"]`,service:e.service}]),...e.notes.map((e,t)=>({id:`service-${t}`,text:e.text,target:`[data-service-header="${e.service}"]`,service:e.service}))]:[],[x,e.events,e.updates,e.notes]),C=s===void 0?0:s.left+s.layout.width*s.scale+m6,w=(0,R.useRef)(null),T=(0,R.useRef)(new Map),[E,D]=(0,R.useState)();(0,R.useLayoutEffect)(()=>{if(s===void 0||S.length===0)return;let e=a.current.getBoundingClientRect(),t=S.map(t=>{let n=w.current.querySelector(t.target).getBoundingClientRect(),r=t.service===void 0?void 0:s.layout.boxes.get(t.service),i=r===void 0?n.right-e.left:s.left+(r.x+r.width)*s.scale;return{id:t.id,from:{x:i,y:n.top-e.top+n.height/2},height:T.current.get(t.id).offsetHeight}}).toSorted((e,t)=>e.from.y-t.from.y),n=new Map,r=s.notesBelow?s.layout.height*s.scale+8:-1/0;for(let[e,i]of t.entries()){let t=s.notesBelow?r+8:Math.max(i.from.y-12,r+8);n.set(i.id,{top:t,from:i.from,n:e+1}),r=t+i.height}D({items:n,bottom:r})},[S,s]);let O=V(j6.note),k=V(j6.noteLines),A=V(j6.noteNumber),j=y===void 0?120:Math.max(y.height*s.scale,S.length>0&&E!==void 0?E.bottom+4:0);return(0,z.jsxs)(`div`,{ref:a,className:p,style:{height:j},children:[(0,z.jsxs)(`div`,{ref:o,className:m,"aria-hidden":`true`,inert:!0,children:[n.map(({service:t})=>(0,z.jsx)(`section`,{className:_,"data-measure-service":t.name,children:(0,z.jsx)(_6,{...e,service:t,values:{today:i.get(t.name),proposed:i.get(t.name)},previous:void 0,changed:new Set})},t.name)),r.map(e=>e.label!==void 0&&(0,z.jsx)(`div`,{className:v,"data-measure-link":e.id,children:e.label},e.id))]}),y!==void 0&&(0,z.jsxs)(`div`,{ref:w,className:h,style:{left:s.left,width:y.width,height:y.height,transform:`scale(${s.scale})`},children:[n.map(({service:t})=>{let n=y.boxes.get(t.name);return(0,z.jsx)(`section`,{className:_,"data-depth":f.get(t.name),"data-change":t.sign,"data-active":e.active.has(t.name),"aria-label":t.name,style:{left:n.x,top:n.y,width:n.width,height:n.height},children:(0,z.jsx)(_6,{...e,service:t,values:b6(e.state,t.name),previous:b6(e.previousState,t.name)})},t.name)}),(0,z.jsxs)(`svg`,{className:g,width:y.width,height:y.height,"aria-hidden":`true`,children:[(0,z.jsx)(`defs`,{children:S6.map(e=>(0,z.jsx)(`marker`,{id:`${u}-${e.id}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,z.jsx)(`path`,{d:`M0,1 L9,5 L0,9 z`,style:{fill:e.head}})},e.id))}),r.map(t=>{let n=T6(y,t,d),r=(t,n)=>e.events.filter(e=>e.from===t&&e.to===n),i=r(t.a,t.b),a=r(t.b,t.a),o=i.length>0||a.length>0,s=C6(o,o?x6([...i,...a]):t.sign),c=e=>`url(#${u}-${(e.length>0?s:C6(!1,t.sign)).id})`;return(0,z.jsx)(`path`,{d:D6(n),fill:`none`,markerEnd:t.forward?c(i):void 0,markerStart:t.backward?c(a):void 0,style:{stroke:s.line,strokeWidth:o?2:1,strokeDasharray:o?void 0:`4 4`}},t.id)})]}),e.events.map((t,n)=>{let i=c6(t.from,t.to),a=r.find(e=>e.id===i),o=T6(y,a,d),c=t.from===a.a?o:o.toReversed(),l=e.events.slice(0,n).filter(e=>c6(e.from,e.to)===i).length,u=a.a===a.b?y.boxes.get(a.a):void 0,f=s.labels.get(i),p=(f?.width??0)/2,m=k6(o,f,b),h=u===void 0?{x:Math.min(Math.max(m.x,p),y.width-p),y:m.y}:{x:u.x+u.width-8,y:u.y};return(0,z.jsx)(g6,{...e,event:t,points:c,label:{x:h.x,y:h.y+l*22},anchor:u===void 0?`center`:`end`,index:n},`${e.stepKey}-${n}`)})]}),S.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`svg`,{className:k,"aria-hidden":`true`,children:S.map(t=>{let n=E?.items.get(t.id);if(n===void 0)return;let r=n.top+12;return s?.notesBelow?(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`circle`,{cx:n.from.x,cy:n.from.y,r:7}),(0,z.jsx)(`text`,{x:n.from.x,y:n.from.y,children:n.n})]},`${e.stepKey}-${t.id}`):(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`circle`,{cx:n.from.x,cy:n.from.y,r:2.5}),(0,z.jsx)(`path`,{d:`M${n.from.x},${n.from.y} H${C-12} V${r} H${C}`,fill:`none`})]},`${e.stepKey}-${t.id}`)})}),S.map(t=>{let n=E?.items.get(t.id);return(0,z.jsxs)(Ow.div,{ref:e=>{e===null?T.current.delete(t.id):T.current.set(t.id,e)},className:O,"data-below":s?.notesBelow,style:{left:s?.notesBelow?0:C,top:n?.top??0,visibility:n===void 0?`hidden`:`visible`},initial:{opacity:0},animate:{opacity:1},children:[s?.notesBelow&&n!==void 0&&(0,z.jsx)(`span`,{className:A,children:n.n}),t.text]},`${e.stepKey}-${t.id}`)})]})]})}function g6(e){let t=V(j6.packet),n=V(j6.labelAnchor),r=V(j6.pill),i=e.event.annotation,a=e.event.label===``?void 0:o6(e.event),o=O6(e.points),s=o.at(-1)||1,c=e.phase===`travel`?e.index*750/1e3:0;return(0,z.jsxs)(z.Fragment,{children:[e.phase===`travel`&&(0,z.jsx)(Ow.div,{className:t,"data-change":e.event.sign,initial:{x:e.points[0].x,y:e.points[0].y,opacity:0},animate:{x:e.points.map(e=>e.x),y:e.points.map(e=>e.y),opacity:1},transition:{delay:c,duration:750/1e3,ease:`easeInOut`,times:o.map(e=>e/s),opacity:{delay:c,duration:0}}}),(a!==void 0||e.event.note!==void 0)&&(0,z.jsx)(Ow.div,{className:n,style:{left:e.label.x,top:e.label.y},"data-anchor":e.anchor,"data-event-label":e.index,initial:{opacity:0},animate:{opacity:1},transition:{delay:c},children:a!==void 0&&(i===void 0?(0,z.jsx)(`div`,{className:r,"data-change":e.event.sign,children:a}):(0,z.jsx)(`button`,{type:`button`,className:r,"data-change":e.event.sign,"aria-pressed":e.selectedAnnotation===i,"aria-controls":`source-diff-panel`,"aria-label":`Open source: ${i.text}`,onClick:()=>e.onSelectAnnotation(i),children:a}))})]})}function _6(e){let t=e.service,n=V(j6.header),r=V(j6.header,j6.headerButton),i=V(j6.stateList),a=V(j6.stateRow),o=t.annotation,s=t.description!==void 0,c=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Kz,{size:`sm`,fontWeight:600,style:{whiteSpace:`nowrap`,textDecorationLine:t.sign===`-`?`line-through`:void 0},"data-described":s,children:[t.name,o!==void 0&&(0,z.jsx)(Kz,{size:`xs`,color:`accent`,"aria-hidden":`true`,children:` ↗`})]}),t.label!==void 0&&(0,z.jsx)(Kz,{size:`xs`,color:`lowContrast`,children:t.label})]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v6,{description:t.description,children:o===void 0?(0,z.jsx)(`div`,{className:n,tabIndex:s?0:void 0,"data-service-header":t.name,children:c}):(0,z.jsx)(`button`,{type:`button`,className:r,"aria-pressed":e.selectedAnnotation===o,"aria-controls":`source-diff-panel`,"aria-label":`Open source: ${t.name}`,"data-service-header":t.name,onClick:()=>e.onSelectAnnotation(o),children:c})}),t.state.length>0&&(0,z.jsx)(`dl`,{className:i,style:{"--key-width":`${Math.max(...t.state.map(({key:e})=>e.length))}ch`},children:t.state.map(({key:n,description:r,sign:i})=>{let o=e.changed.has(`${t.name}.${n}`),s=i===`-`?`today`:`proposed`,c=e.values.today.get(n),l=e.values.proposed.get(n);return(0,z.jsxs)(`div`,{className:a,"data-changed":o,"data-change":i,"data-state-row":`${t.name}.${n}`,children:[(0,z.jsx)(v6,{description:r,children:(0,z.jsx)(`dt`,{tabIndex:r===void 0?void 0:0,"data-described":r!==void 0,children:n})}),(0,z.jsx)(`dd`,{children:i===` `&&c!==l?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Kz,{size:`xs`,monospace:!0,style:{color:G.red[11]},children:[(0,z.jsx)(`s`,{children:c}),` `]}),(0,z.jsx)(Kz,{size:`xs`,monospace:!0,style:{color:G.green[11]},children:l})]}):(0,z.jsxs)(z.Fragment,{children:[o&&(0,z.jsxs)(Kz,{size:`xs`,monospace:!0,color:`lowContrast`,children:[(0,z.jsx)(`s`,{children:e.previous?.[s].get(n)}),` `]}),(0,z.jsx)(Kz,{size:`xs`,monospace:!0,color:o?`accent`:void 0,children:e.values[s].get(n)})]})})]},n)})})]})}function v6(e){return e.description===void 0?e.children:(0,z.jsx)(EV,{content:e.description,placement:`top`,children:e.children})}function y6(e){let t=i6(e.services),n=new Map(t.map(({service:e})=>[e.name,new Map])),r=t=>({today:a6(e,t,`today`),proposed:a6(e,t,`proposed`)}),i=r(0);for(let a=0;a<=e.steps.length;a++){let o=a===0?i:r(a),s=new Set(e.steps[a-1]?.updates.map(e=>`${e.service}.${e.key}`));for(let{service:e}of t)for(let{key:t}of e.state){let r=n.get(e.name),a=n=>n.get(e.name).get(t),c=a(o.today),l=a(o.proposed),u=[c===void 0||l===void 0||c===l?l??c??``:`${c} ${l}`];s.has(`${e.name}.${t}`)&&u.push(`${a(i.today)??``} ${c??``}`,`${a(i.proposed)??``} ${l??``}`);for(let e of u)e.length>(r.get(t)?.length??-1)&&r.set(t,e)}i=o}return n}function b6(e,t){return{today:e.today.get(t),proposed:e.proposed.get(t)}}function x6(e){return e.every(t=>t.sign===e[0].sign)?e[0].sign:` `}var S6=[`idle`,`active`].flatMap(e=>[`+`,`-`,` `].map(t=>{let n=t===`+`?G.green:t===`-`?G.red:void 0,r=e===`active`,i=r?n?.[9]??G.accent[9]:n?.[8]??G.gray[7];return{id:`${e}-${{"+":`added`,"-":`removed`," ":`same`}[t]}`,state:e,sign:t,line:i,head:r||n!==void 0?i:G.gray[8]}}));function C6(e,t){return S6.find(n=>n.sign===t&&n.state===`active`===e)}function w6(e,t,n){for(let r=e.get(n);r!==void 0;r=e.get(r))if(r===t)return!0;return!1}function T6(e,t,n){let r=e.routes.get(t.id);if(!w6(n,t.a,t.b))return r;let i=e.boxes.get(t.a).y+e.sizes.get(t.a).height,[a,o]=r;return o===void 0||a.x!==o.x||o.y<=i?r:[{x:a.x,y:i},...r.slice(1)]}function E6(e){let t=e.getBoundingClientRect();return{width:Math.ceil(t.width),height:Math.ceil(t.height)}}function D6(e){return e.map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `)}function O6(e){let t=0;return e.map((n,r)=>{let i=e[r-1];return i!==void 0&&(t+=Math.hypot(n.x-i.x,n.y-i.y)),t})}function k6(e,t,n){let r=e.slice(1).map((t,n)=>{let r=e[n];return{length:Math.hypot(t.x-r.x,t.y-r.y),at:{x:(r.x+t.x)/2,y:(r.y+t.y)/2}}}).toSorted((e,t)=>t.length-e.length);return((t===void 0?void 0:r.find(({at:e})=>n.every(n=>Math.abs(e.x-(n.x+n.width/2))>=(n.width+t.width)/2||Math.abs(e.y-(n.y+n.height/2))>=(n.height+t.height)/2)))??r[0])?.at??e[0]}var A6={"&[data-described='true']":{textDecorationLine:`underline`,textDecorationStyle:`dotted`,textDecorationColor:G.gray[8],textUnderlineOffset:`3px`}},j6={stage:B({position:`relative`,minWidth:0,overflow:`hidden`}),measureLayer:B({position:`absolute`,width:0,height:0,overflow:`hidden`,visibility:`hidden`,"& > [data-measure-service]":{position:`absolute`,width:`max-content`,minWidth:120,maxWidth:240},"& > [data-measure-link]":{position:`absolute`,width:`max-content`}}),canvas:B({position:`absolute`,top:0,transformOrigin:`0 0`}),noteLines:B({position:`absolute`,inset:0,width:`100%`,height:`100%`,overflow:`visible`,pointerEvents:`none`,"& path":{stroke:G.accent[7],strokeWidth:1},"& circle":{fill:G.accent[9]},"& text":{fill:K.app,fontSize:9,fontWeight:600,textAnchor:`middle`,dominantBaseline:`central`}}),noteNumber:B({position:`absolute`,top:-7,left:-7,display:`flex`,alignItems:`center`,justifyContent:`center`,width:14,height:14,borderRadius:`50%`,fontSize:9,fontWeight:600,color:K.app,backgroundColor:G.accent[9]}),overlay:B({position:`absolute`,inset:0,overflow:`visible`,pointerEvents:`none`}),box:B(Fd.md,{position:`absolute`,display:`flex`,flexDirection:`column`,border:`1px solid ${G.gray[6]}`,backgroundColor:K.element,"&[data-depth='1'], &[data-depth='3']":{backgroundColor:G.gray[2]},"&[data-change='+']":{borderColor:G.green[8],backgroundColor:G.green[2]},"&[data-change='-']":{borderColor:G.red[8],borderStyle:`dashed`,backgroundColor:G.red[2]},"&[data-active='true']":{borderColor:G.accent[8]},"&[data-active='true'][data-change='+']":{borderColor:G.green[10]},"&[data-active='true'][data-change='-']":{borderColor:G.red[10]}}),header:B(Yd({direction:`row`,alignItems:`baseline`,gap:3,wrap:!0}),Y.padding({x:4,y:3}),Ud(),{minWidth:0,"& > [data-described='true']":A6[`&[data-described='true']`]}),headerButton:B({width:`100%`,border:0,background:`transparent`,font:`inherit`,color:`inherit`,textAlign:`start`,cursor:`pointer`,borderRadius:`inherit`,"&:hover":{backgroundColor:K.elementHover},"&[aria-pressed='true']":{backgroundColor:G.blue[3]}}),stateList:B(J({size:`xs`,monospace:!0}),{margin:0,paddingInline:Y.value(4),paddingBottom:Y.value(3),"& dt":{flex:`none`,minWidth:`min(var(--key-width), 100%)`,color:G.gray[11]},"& dt[data-described='true']":A6[`&[data-described='true']`],"& dt:focus-visible":{outline:`2px solid ${G.blueAlpha[8]}`},"& dd":{flex:`1 1 auto`,margin:0,minWidth:0,overflowWrap:`anywhere`}}),stateRow:B(Fd.xs,{display:`flex`,flexWrap:`wrap`,alignItems:`baseline`,columnGap:Y.value(4),paddingInline:Y.value(2),marginInline:`-${Y.value(2)}`,"&[data-change='+']":{backgroundColor:G.greenAlpha[3],boxShadow:`inset 2px 0 ${G.green[9]}`},"&[data-change='-']":{backgroundColor:G.redAlpha[3],boxShadow:`inset 2px 0 ${G.red[9]}`},"&[data-changed='true']":{backgroundColor:G.accentAlpha[3]}}),packet:B(Fd.circle,{position:`absolute`,top:-6,left:-6,width:12,height:12,backgroundColor:G.accent[9],boxShadow:`0 0 0 3px ${G.accentAlpha[5]}`,pointerEvents:`none`,zIndex:2,"&[data-change='+']":{backgroundColor:G.green[9],boxShadow:`0 0 0 3px ${G.greenAlpha[5]}`},"&[data-change='-']":{backgroundColor:G.red[9],boxShadow:`0 0 0 3px ${G.redAlpha[5]}`}}),labelAnchor:B({position:`absolute`,zIndex:1,transform:`translate(-50%, -50%)`,"&[data-anchor='end']":{transform:`translate(-100%, -50%)`}}),pill:B(Fd.pill,J({size:`xs`,monospace:!0}),Y.padding({x:3}),{display:`block`,maxWidth:220,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,border:`1px solid ${G.accent[7]}`,backgroundColor:K.app,color:G.accent[11],"&[data-change='+']":{borderColor:G.green[7],color:G.green[11]},"&[data-change='-']":{borderColor:G.red[7],borderStyle:`dashed`,color:G.red[11]},"&:is(button)":{cursor:`pointer`},"&:is(button):hover":{backgroundColor:G.accent[3]},"&[aria-pressed='true']":{backgroundColor:G.blue[3]}},Ud()),note:B(J({size:`xs`}),Fd.sm,Y.padding({x:4,y:2}),{position:`absolute`,width:`max-content`,maxWidth:p6,border:`1px solid ${G.accent[7]}`,backgroundColor:K.app,"&[data-below='true']":{right:0,marginInline:`auto`,maxWidth:`min(100%, 420px)`}})},M6=1200,N6={"+":`Added: `,"-":`Removed: `," ":``};function P6(e){let t=V(L6.error);return e.parsed.ok?(0,z.jsx)(F6,{...e,diagram:e.parsed.diagram},e.source):(0,z.jsxs)(`div`,{className:t,"data-diffmap-kind":`services`,children:[`Line `,e.parsed.line,`: `,e.parsed.reason]})}function F6(e){let t=e.diagram,n=t.steps.length,r=!!iw(),[i,a]=(0,R.useState)({step:0,phase:`settled`}),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>Array.from({length:n+1},(e,n)=>({today:a6(t,n,`today`),proposed:a6(t,n,`proposed`)})),[t,n]),l=i.step,u=l===0?void 0:t.steps[l-1],d=u??t.start,f=i.phase===`settled`,p=c[f?l:l-1],m=new Set(f&&u!==void 0?u.updates.map(e=>`${e.service}.${e.key}`):[]),h=new Set(u?.events.flatMap(e=>[e.from,e.to])??[]),g=(e,n)=>a(I6(t,e,n&&!r));(0,R.useEffect)(()=>{if(i.phase!==`travel`)return;let e=setTimeout(()=>a({step:i.step,phase:`settled`}),750*(t.steps[i.step-1]?.events.length??1));return()=>clearTimeout(e)},[i,t]),(0,R.useEffect)(()=>{if(!o||i.phase!==`settled`)return;let e=setTimeout(()=>{i.step>=n?s(!1):a(I6(t,i.step+1,!r))},i.step===0?300:M6);return()=>clearTimeout(e)},[o,i,n,t,r]);let _=()=>{s(!1),l>0&&g(l-1,!1)},v=()=>{s(!1),l<n&&g(l+1,!0)},y=()=>{if(o)return s(!1);l>=n&&g(0,!1),s(!0),U0({event:`diagram_used`,action:`play`})},b=e=>{e.key===`ArrowLeft`&&(e.preventDefault(),_()),e.key===`ArrowRight`&&(e.preventDefault(),v())},x=V(LG,L6.frame),S=V(L6.body),C=V(L6.controls),w=V(L6.scrubber),T=V(L6.segment),E=V(RG),D=V(L6.detail),O=V(L6.counter);return(0,z.jsxs)(`figure`,{className:x,"data-diffmap-kind":`services`,onKeyDownCapture:b,children:[t.start!==void 0&&(0,z.jsx)(`figcaption`,{className:E,children:t.start.caption}),(0,z.jsxs)(`div`,{className:S,children:[(d!==void 0||n>0)&&(0,z.jsx)(`div`,{className:D,"aria-live":`polite`,children:u===void 0?t.start?.description!==void 0&&(0,z.jsx)(Kz,{size:`sm`,children:t.start.description}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Kz,{size:`sm`,children:[u.sign!==` `&&(0,z.jsx)(Kz,{size:`sm`,fontWeight:600,style:{color:u.sign===`+`?G.green[11]:G.red[11]},children:N6[u.sign]}),u.caption]}),u.description!==void 0&&(0,z.jsx)(Kz,{size:`xs`,color:`lowContrast`,children:u.description})]})}),n>0&&(0,z.jsxs)(`div`,{className:C,children:[(0,z.jsx)(EV,{content:`Restart`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Restart`,isDisabled:l===0&&!o,onClick:()=>{s(!1),g(0,!1)},children:(0,z.jsx)(EB,{size:`xs`})})}),(0,z.jsx)(EV,{content:`Previous step (←)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Previous step`,isDisabled:l===0,onClick:_,children:(0,z.jsx)(sB,{size:`xs`})})}),(0,z.jsxs)(Vz,{size:`sm`,"aria-label":o?`Pause`:`Play`,onClick:y,children:[o?(0,z.jsx)(xB,{size:`xs`}):(0,z.jsx)(CB,{size:`xs`}),o?`Pause`:l>=n?`Replay`:`Play`]}),(0,z.jsx)(EV,{content:`Next step (→)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Next step`,isDisabled:l>=n,onClick:v,children:(0,z.jsx)(cB,{size:`xs`})})}),(0,z.jsx)(`div`,{className:w,role:`group`,"aria-label":`Steps`,children:t.steps.map((e,t)=>(0,z.jsx)(EV,{placement:`top`,content:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`strong`,{children:[t+1,`. `,e.caption]}),e.description!==void 0&&(0,z.jsxs)(z.Fragment,{children:[` `,e.description]})]}),children:(0,z.jsx)(`button`,{type:`button`,className:T,"data-change":e.sign,"data-state":t+1===l?`current`:t+1<l?`done`:`todo`,"aria-label":`Step ${t+1}: ${N6[e.sign]}${e.caption}`,"aria-current":t+1===l?`step`:void 0,onClick:()=>{s(!1),g(t+1,t+1===l+1)}})},t))}),(0,z.jsxs)(Kz,{className:O,size:`xs`,color:`lowContrast`,tabular:!0,children:[l,` / `,n]})]}),(0,z.jsx)(h6,{...e,state:p,previousState:c[Math.max(l-1,0)],changed:m,active:h,events:u?.events??[],updates:u?.updates??[],notes:u?.notes??[],phase:i.phase,stepKey:l})]})]})}function I6(e,t,n){let r=e.steps[t-1]?.events.length??0;return{step:t,phase:n&&r>0?`travel`:`settled`}}var L6={error:B(J({size:`sm`,color:`lowContrast`})),frame:B({width:`100%`,margin:0}),body:B(Yd({direction:`column`,gap:4}),Y.padding({all:6})),controls:B(Yd({direction:`row`,alignItems:`center`,gap:2}),{"& > button":{flexShrink:0,overflow:`visible`}}),scrubber:B(Yd({direction:`row`,alignItems:`center`,gap:1}),{flex:`1 1 auto`,minWidth:0,marginInline:Y.value(4)}),segment:B(Fd.pill,{flex:`1 1 0`,minWidth:6,height:20,padding:0,border:0,cursor:`pointer`,background:`transparent`,position:`relative`,"&::after":{content:`''`,position:`absolute`,insetInline:0,top:8,height:4,borderRadius:2,backgroundColor:G.gray[5]},"&:hover::after":{backgroundColor:G.gray[7]},"&[data-state='done']::after":{backgroundColor:G.accent[7]},"&[data-state='current']::after":{backgroundColor:G.accent[9]},"&[data-change='+']::after":{backgroundColor:G.green[6]},"&[data-change='+'][data-state='done']::after":{backgroundColor:G.green[8]},"&[data-change='+'][data-state='current']::after":{backgroundColor:G.green[10]},"&[data-change='-']::after":{backgroundColor:G.red[6]},"&[data-change='-'][data-state='done']::after":{backgroundColor:G.red[8]},"&[data-change='-'][data-state='current']::after":{backgroundColor:G.red[10]}},Ud()),counter:B({flexShrink:0,minWidth:`5ch`,textAlign:`end`}),detail:B(Yd({direction:`column`,gap:2}),{minHeight:44})};function R6(e){let t=e.fence,n=j4()===`local`;return t.kind===`mermaid`?(0,z.jsx)(h3,{svg:t.svg,annotations:t.annotations,title:t.title,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`services`?(0,z.jsx)(P6,{source:t.source,parsed:t.parsed,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`html`?n?(0,z.jsx)($4,{source:t.source}):(0,z.jsx)(t3,{}):t.kind===`changes`?(0,z.jsx)(i2,{rev:t.rev,review:t.review,ignore:t.ignore,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`callstack`?(0,z.jsx)(X0,{lines:t.lines,highlights:t.highlights,notes:t.notes,title:t.title,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`preview`?(0,z.jsx)(R3,{stories:t.stories,title:t.title}):t.kind===`flow`?(0,z.jsx)($3,{states:t.states,title:t.title}):t.kind===`diff`?(0,z.jsx)(k4,{source:t.source,path:t.path}):t.kind===`file`?(0,z.jsx)(X4,{path:t.path,start:t.start,end:t.end,fallback:t.source}):(0,z.jsx)(G0,{lang:t.lang,source:t.source,highlights:t.highlights,notes:t.notes,title:t.title})}function z6(e){return/\.(?:mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(e)}function B6(e){return!/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)}var V6=(0,R.createContext)(e=>e);function H6(e){return`/__diffmap/media?${new URLSearchParams({path:e}).toString()}`}function U6(e){return e.alt||e.title||(z6(e.src)?`Video`:`Image`)}function W6({videoRef:e,onLoadedMetadata:t,...n}){let r=(0,R.useContext)(V6),i=B6(n.src)?r(n.src):n.src,a=V(Q6.media),o=n.className??a;return z6(n.src)?(0,z.jsx)(`video`,{ref:e,className:o,src:i,title:n.title,"aria-label":n.alt,controls:!0,playsInline:!0,preload:`metadata`,onLoadedMetadata:t}):(0,z.jsx)(`img`,{className:o,src:i,alt:n.alt,title:n.title})}function G6(e){return(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Full screen: ${U6(e.media)}`,onClick:e.onClick,children:(0,z.jsx)(yB,{size:`xs`})})}function K6(){let[e,t]=(0,R.useState)(),[n,r]=(0,R.useState)(!1),i=(0,R.useRef)(null),a=(0,R.useRef)(!1),o=V(Q6.dialog),s=V(Q6.dialogHeader),c=V(Q6.expandedMedia),l=(e,t)=>{t.currentTime=e.currentTime,t.volume=e.volume,t.muted=e.muted,t.playbackRate=e.playbackRate,a.current&&t.play().catch(()=>{})},u=(e,n)=>{a.current=!(!n||n.paused||n.ended),n?.pause(),t({media:e,video:n}),r(!0)},d=()=>{let t=i.current,n=e?.video;t&&n&&(t.readyState===0?a.current&&n.play().catch(()=>{}):(a.current=!t.paused&&!t.ended,t.pause(),l(t,n))),r(!1)};return{open:u,dialog:(0,z.jsxs)(wV,{isOpen:n,onOpenChange:e=>{e||d()},size:`lg`,"aria-label":e?U6(e.media):`Media`,className:o,children:[(0,z.jsxs)(`div`,{className:s,children:[(0,z.jsx)(Kz,{size:`xs`,fontWeight:500,color:`lowContrast`,children:e&&U6(e.media)}),(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,slot:`close`,"aria-label":`Exit full screen`,children:(0,z.jsx)(Yz,{size:`xs`})})]}),e&&(0,z.jsx)(W6,{...e.media,className:c,videoRef:i,onLoadedMetadata:t=>{n&&e.video&&l(e.video,t.currentTarget)}},e.media.src)]})}}function q6(e){let t=V(Q6.mediaShell),n=V(Q6.expand),r=(0,R.useRef)(null),i=K6();return(0,z.jsxs)(`span`,{className:t,children:[(0,z.jsx)(W6,{...e,videoRef:r}),(0,z.jsx)(`span`,{className:n,children:(0,z.jsx)(G6,{media:e,onClick:()=>i.open(e,r.current)})}),i.dialog]})}function J6(e){let t=V(LG,Q6.frame),n=V(RG,Q6.cardHeader),r=V(Q6.cardMedia),i=(0,R.useRef)(null),a=K6(),o={src:e.item.attrs.src??``,alt:e.item.attrs.alt,title:e.item.attrs.title};return(0,z.jsxs)(`figure`,{className:t,"data-diffmap-kind":`media`,children:[(0,z.jsxs)(`figcaption`,{className:n,children:[(0,z.jsx)(Kz,{size:`xs`,fontWeight:500,color:`lowContrast`,style:{marginRight:`auto`},children:o.alt}),(0,z.jsx)(G6,{media:o,onClick:()=>a.open(o,i.current)})]}),(0,z.jsx)(W6,{...o,className:r,videoRef:i}),a.dialog]})}function Y6(e){let t=e.node.children.flatMap(e=>e.type===`element`?[e]:[]),n=e.node.attrs.layout;return n===`carousel`?(0,z.jsx)(Z6,{items:t,title:e.node.attrs.title}):(0,z.jsx)(X6,{items:t,columns:n===`side-by-side`?t.length:void 0})}function X6(e){let t=V(Q6.grid);return(0,z.jsx)(`div`,{className:t,"data-diffmap-kind":`gallery`,style:{gridTemplateColumns:e.columns===void 0?`repeat(auto-fill, minmax(min(240px, 100%), 1fr))`:`repeat(${e.columns}, minmax(0, 1fr))`},children:e.items.map((e,t)=>(0,z.jsx)(J6,{item:e},t))})}function Z6(e){let[t,n]=(0,R.useState)(0),r=e.items.length-1,i=e.items[t],a=V(LG,Q6.frame),o=V(RG,Q6.cardHeader),s=V(Q6.description),c=V(Q6.stack),l=V(Q6.slide),u=V(Q6.cardMedia),d=(0,R.useRef)(null),f=K6(),p={src:i.attrs.src??``,alt:i.attrs.alt,title:i.attrs.title},m=e=>{for(let e of d.current?.querySelectorAll(`video`)??[])e.pause();n(e)};return(0,z.jsxs)(`figure`,{className:a,"data-diffmap-kind":`gallery`,"aria-roledescription":`carousel`,"aria-label":e.title,onKeyDownCapture:e=>{e.target instanceof Element&&e.target.closest(`video, [role='dialog']`)||(e.key===`ArrowLeft`&&t>0&&(e.preventDefault(),m(t-1)),e.key===`ArrowRight`&&t<r&&(e.preventDefault(),m(t+1)))},children:[(0,z.jsxs)(`figcaption`,{className:o,children:[(0,z.jsx)(`span`,{children:e.title}),(0,z.jsxs)(`span`,{style:{marginLeft:`auto`},children:[t+1,` / `,r+1]}),(0,z.jsx)(EV,{content:`Previous (←)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Previous`,isDisabled:t===0,onClick:()=>m(t-1),children:(0,z.jsx)(sB,{size:`xs`})})}),(0,z.jsx)(EV,{content:`Next (→)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Next`,isDisabled:t===r,onClick:()=>m(t+1),children:(0,z.jsx)(cB,{size:`xs`})})}),(0,z.jsx)(G6,{media:p,onClick:()=>f.open(p,d.current?.querySelector(`[data-current='true'] video`))})]}),(0,z.jsx)(`div`,{className:s,"aria-live":`polite`,children:i.attrs.alt}),(0,z.jsx)(`div`,{ref:d,className:c,children:e.items.map((e,n)=>(0,z.jsx)(`div`,{className:l,"data-current":n===t,"aria-hidden":n!==t,inert:n!==t,children:(0,z.jsx)(W6,{src:e.attrs.src??``,alt:e.attrs.alt,title:e.attrs.title,className:u})},n))}),f.dialog]})}var Q6={mediaShell:B({position:`relative`,display:`inline-block`,maxWidth:`100%`,verticalAlign:`middle`}),expand:B(Fd.sm,{display:`inline-flex`,position:`absolute`,top:`6px`,right:`6px`,backgroundColor:K.element}),dialog:B({width:`calc(100vw - 32px)`,height:`calc(100dvh - 32px)`,padding:Y.value(6),"& > [role='dialog']":{flex:1,minHeight:0,gap:Y.value(2)}}),dialogHeader:B({display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:Y.value(4)}),expandedMedia:B({display:`block`,flex:1,minHeight:0,minWidth:0,width:`100%`,height:`100%`,objectFit:`contain`}),media:B(Fd.sm,{maxWidth:`100%`,height:`auto`,verticalAlign:`middle`}),frame:B({width:`100%`,margin:0}),cardMedia:B({display:`block`,width:`100%`,maxHeight:`min(70vh, 640px)`,objectFit:`contain`}),grid:B({display:`grid`,gap:Y.value(6),alignItems:`start`}),cardHeader:B(Yd({direction:`row`,alignItems:`center`,gap:1}),{"& button":{marginBlock:-3}}),description:B(J({size:`sm`}),Y.padding({x:6,y:3}),Md([`bottom`],`border`),{minHeight:`1lh`,boxSizing:`content-box`}),stack:B({display:`grid`}),slide:B({gridArea:`1 / 1`,display:`flex`,alignItems:`center`,"&[data-current='false']":{visibility:`hidden`}})},$6=new Set([`hr`,`br`]);function e8(e){let t=j4()===`local`;return(0,z.jsx)(z.Fragment,{children:e.document.nodes.map((n,r)=>t8(n,r,e,t))})}function t8(e,t,n,r){return e.type===`text`?e.value:e.type===`html`?r?e.block?(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:e.source}},t):(0,z.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.source}},t):(0,z.jsx)(t3,{inline:e.block!==!0},t):e.type===`view`?(0,z.jsx)(R6,{fence:e.fence,...n},t):e.type===`reference`?(0,z.jsx)(s8,{annotation:e.annotation,...n},t):n8(e,t,n,r)}function n8(e,t,n,r){if(e.tag===`table`)return o8(e,t,n,r);let i=e.children.map((e,t)=>t8(e,t,n,r));if(e.tag===`alert`)return(0,z.jsx)(`blockquote`,{"data-alert":e.attrs.alertType,children:i},t);if(e.tag===`details`)return(0,z.jsx)(c8,{summary:e.attrs.summary??`Details`,children:i},t);if(e.tag===`badge`)return(0,z.jsx)(_f,{children:i},t);if(e.tag===`gallery`)return(0,z.jsx)(Y6,{node:e},t);let a=r8(e);return a===void 0?e.tag===`img`?(0,z.jsx)(q6,{src:e.attrs.src??``,alt:e.attrs.alt,title:e.attrs.title},t):e.tag===`li`&&e.attrs.task===!0?(0,z.jsx)(l8,{node:e,children:i},t):e.tag===`code`?(0,z.jsx)(qB,{...d8(e),style:{whiteSpace:`normal`,overflowWrap:`anywhere`},children:i},t):e.tag===`a`?(0,z.jsx)(xG,{href:e.attrs.href,title:e.attrs.title,className:e.attrs.className,id:e.attrs.id,children:i},t):$6.has(e.tag)?(0,R.createElement)(e.tag,{key:t,...d8(e)}):(0,R.createElement)(e.tag,{key:t,...d8(e)},i):a.map((e,n)=>(0,z.jsx)(J6,{item:e},`${t}-${n}`))}function r8(e){if(e.tag!==`p`)return;let t=e.children.filter(e=>e.type!==`text`||e.value.trim()!==``);if(t.length!==0&&t.every(e=>e.type===`element`&&e.tag===`img`))return t}function i8(e,t){return e.children.filter(e=>e.type===`element`&&e.tag===t)}function a8(e){if(e.attrs.align===`left`)return`start`;if(e.attrs.align===`right`)return`end`;if(e.attrs.align===`center`)return`center`}function o8(e,t,n,r){let i=i8(e,`thead`).flatMap(e=>i8(e,`tr`)).flatMap(e=>i8(e,`th`)),a=i8(e,`tbody`).flatMap(e=>i8(e,`tr`));return(0,z.jsxs)(dH,{"aria-label":i.map(u8).join(`, `),children:[(0,z.jsx)(fH,{children:i.map((e,t)=>(0,z.jsx)(pH,{id:`column-${t}`,isRowHeader:t===0,align:a8(e),children:e.children.map((e,t)=>t8(e,t,n,r))},t))}),(0,z.jsx)(mH,{children:a.map((e,t)=>(0,z.jsx)(hH,{id:`row-${t}`,textValue:u8(e),children:i8(e,`td`).map((e,t)=>(0,z.jsx)(gH,{align:a8(e),children:e.children.map((e,t)=>t8(e,t,n,r))},t))},t))})]},t)}function s8(e){let t=V(f8);return(0,z.jsx)(`button`,{type:`button`,className:t,"aria-pressed":e.selectedAnnotation===e.annotation,"aria-controls":`source-diff-panel`,title:e.annotation.text,onClick:()=>e.onSelectAnnotation(e.annotation),children:(0,z.jsx)(qB,{children:e.annotation.text})})}function c8(e){let t=V(m8),n=V(p8);return(0,z.jsxs)(`details`,{className:t,children:[(0,z.jsx)(`summary`,{className:n,children:e.summary}),(0,z.jsx)(`div`,{className:`diffmap-details-content`,children:e.children})]})}function l8(e){let[t,n]=(0,R.useState)(e.node.attrs.checked===!0),r=V(h8);return(0,z.jsxs)(`li`,{id:e.node.attrs.id,className:[r,e.node.attrs.className].filter(Boolean).join(` `),"data-task":``,children:[(0,z.jsx)(`span`,{className:`diffmap-task-checkbox`,children:(0,z.jsx)(WB,{label:u8(e.node),checked:t,setChecked:n})}),(0,z.jsx)(`div`,{className:`diffmap-task-content`,children:e.children})]})}function u8(e){return e.type===`text`?e.value:e.type===`reference`?e.annotation.text:e.type===`element`?e.children.map(u8).join(``):``}function d8(e){return{id:e.attrs.id,href:e.attrs.href,src:e.attrs.src,alt:e.attrs.alt,title:e.attrs.title,className:e.attrs.className,start:e.attrs.start}}var f8=B(Fd.sm,{display:`inline`,padding:0,border:0,font:`inherit`,color:`inherit`,background:`transparent`,cursor:`pointer`,"& > code":{color:G.blue[11]},"&:hover > code":{backgroundColor:G.blue[3]},"&[aria-pressed='true'] > code":{backgroundColor:G.blue[4],color:G.blue[12]}},Ud()),p8=B(Fd.sm,Ud(),{cursor:`pointer`,width:`fit-content`,fontWeight:500}),m8=B({"& > .diffmap-details-content":{display:`flex`,flexDirection:`column`,gap:Y.value(8),marginTop:Y.value(6)}}),h8=B({display:`grid`,gridTemplateColumns:`auto minmax(0, 1fr)`,alignItems:`start`,columnGap:Y.value(3),"& > .diffmap-task-checkbox":{display:`flex`,alignItems:`center`,minHeight:`1lh`},"& > .diffmap-task-content":{minWidth:0},"& .diffmap-task-checkbox label > span:last-child":{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0}}),g8=4;function _8(e,t){if(e.contents===void 0){let t=e.patch===void 0?void 0:SZ(e.patch,void 0,!1)[0]?.files[0];return t===void 0?void 0:{id:e.path,type:`diff`,fileDiff:t}}let{old:n,new:r}=e.contents,i=t=>wQ(n===void 0?null:{name:e.prevPath??e.path,contents:n},r===void 0?null:{name:e.path,contents:r},{context:t}),a=g8,o=i(a),s=r===void 0?0:r.split(`
255
+ `),e.documentElement.prepend(n)}function m3(e,t){for(let n of[e,...e.querySelectorAll(`*`)])for(let e of[`fill`,`stroke`])n.getAttribute(e)===`var(--_arrow)`&&n.setAttribute(e,t)}function h3(e){let[t,n]=(0,R.useState)(!1),r=V(LG,_3.frame),i=V(_3.expand),a=V(_3.dialog),o=V(_3.header),s=V(RG),c=V(_3.dialogTitle);return(0,z.jsxs)(`figure`,{className:r,children:[e.title!==void 0&&(0,z.jsx)(`figcaption`,{className:s,children:e.title}),(0,z.jsx)(g3,{...e,fullscreen:!1}),(0,z.jsx)(Vz,{className:i,size:`sm`,variant:`quiet`,"aria-label":`Full screen`,onClick:()=>{n(!0),U0({event:`diagram_used`,action:`fullscreen`})},children:(0,z.jsx)(yB,{size:`xs`})}),(0,z.jsxs)(wV,{isOpen:t,onOpenChange:n,size:`lg`,"aria-label":e.title??`Diagram`,className:a,children:[(0,z.jsxs)(`div`,{className:o,children:[(0,z.jsx)(`span`,{className:c,children:e.title}),(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,slot:`close`,"aria-label":`Exit full screen`,children:(0,z.jsx)(Yz,{size:`xs`})})]}),(0,z.jsx)(g3,{...e,fullscreen:!0,onSelectAnnotation:t=>{n(!1),e.onSelectAnnotation(t)}})]})]})}function g3(e){let t=(0,R.useRef)(null),n=V(_3.shell,e.fullscreen?_3.fullscreenShell:_3.inlineShell),r=(0,R.useMemo)(()=>{let t=e=>i3(e,{bg:K.app,fg:G.gray[12],accent:G.accent[9],muted:G.gray[11],surface:K.element,border:G.gray[6],font:bd}),n=t(e.svg.all);return`today`in e.svg?o3(n,{today:t(e.svg.today),proposed:t(e.svg.proposed)}):n},[e.svg]),i=(0,R.useMemo)(()=>f3(r,e.annotations),[r,e.annotations]),a=(0,R.useMemo)(()=>({__html:i instanceof Error?``:i}),[i]);return(0,R.useEffect)(()=>{if(!(i instanceof Error))for(let n of t.current.querySelectorAll(`[data-source-index]`)){let t=e.annotations[Number(n.getAttribute(`data-source-index`))].annotation;n.setAttribute(`aria-pressed`,String(t===e.selectedAnnotation))}},[i,e.annotations,e.selectedAnnotation]),i instanceof Error?(0,z.jsx)(`div`,{ref:t,className:n,"data-diffmap-kind":`mermaid`,children:i.message}):(0,z.jsx)(`div`,{ref:t,className:n,"data-diffmap-kind":`mermaid`,onClick:t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-source-index]`);r!==null&&e.onSelectAnnotation(e.annotations[Number(r.getAttribute(`data-source-index`))].annotation)},onKeyDown:t=>{if(t.key!==`Enter`&&t.key!==` `)return;let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-source-index]`);r!==null&&(t.preventDefault(),e.onSelectAnnotation(e.annotations[Number(r.getAttribute(`data-source-index`))].annotation))},dangerouslySetInnerHTML:a})}var _3={frame:B({position:`relative`,width:`100%`,margin:0,"& > figcaption":{paddingRight:`40px`},"& > [data-diffmap-kind='mermaid']":{padding:Y.value(6)}}),expand:B({position:`absolute`,top:`6px`,right:`6px`}),dialogTitle:B(J({size:`xs`,fontWeight:500,color:`lowContrast`})),dialog:B({width:`calc(100vw - 32px)`,height:`calc(100dvh - 32px)`,padding:Y.value(6),"& > [role='dialog']":{flex:1,minHeight:0,gap:Y.value(2)}}),header:B({display:`flex`,alignItems:`center`,justifyContent:`space-between`}),inlineShell:B({maxHeight:`60vh`,"& svg":{maxHeight:`60vh`}}),fullscreenShell:B({flex:1,"& svg":{height:`100%`}}),shell:B({width:`100%`,minHeight:0,overflow:`auto`,minWidth:0,border:0,boxShadow:`none`,"& .source-target":{cursor:`pointer`},"& .source-target:focus, & .source-target:focus-visible":{outline:`none`},"& .source-hit":{pointerEvents:`stroke`},"& .source-node:hover > g > rect, & .source-node:hover > g > polygon":{fill:G.blue[2],stroke:G.blue[8],strokeWidth:2},"& .source-node:hover text":{fill:G.blue[10]},"& .source-node[aria-pressed='true'] > g > rect, & .source-node[aria-pressed='true'] > g > polygon":{fill:G.blue[3],stroke:G.blue[9],strokeWidth:2},"& .source-node[aria-pressed='true'] text":{fill:G.blue[11]},"& .source-edge:hover > .edge, & .source-edge:hover > .message > line, & .source-edge:hover > .message > polyline, & .source-edge:hover > .class-relationship, & .source-edge:hover > .er-relationship":{stroke:G.blue[8],strokeWidth:1.5},"& .source-edge[aria-pressed='true'] > .edge, & .source-edge[aria-pressed='true'] > .message > line, & .source-edge[aria-pressed='true'] > .message > polyline, & .source-edge[aria-pressed='true'] > .class-relationship, & .source-edge[aria-pressed='true'] > .er-relationship":{stroke:G.blue[9],strokeWidth:2},"& svg":{display:`block`,width:`100%`,height:`auto`},...v3(`-`,G.red),...v3(`+`,G.green),...v3(`~`,G.amber)})};function v3(e,t){let n=`[data-change='${e}']`,r=e===`-`?{strokeDasharray:`5 3`}:{};return{[`& [data-id]${n} > :is(rect, polygon, circle, ellipse, path), & .edge-label${n} > rect`]:{fill:t[2],stroke:t[9],strokeWidth:1.5,...r},[`& ${n} text`]:{fill:t[11]},[`& :is(polyline, line)${n}, & ${n} > :is(line, polyline, path)`]:{stroke:t[9],strokeWidth:1.5,...r}}}var y3=`M3.788 9A.999.999 0 0 1 3 8.615l-2.288-3a1 1 0 1 1 1.576-1.23l1.5 1.991 3.924-4.991a1 1 0 1 1 1.576 1.23l-4.712 6A.999.999 0 0 1 3.788 9z`;function b3(e){let t=V(UB.root),n=V(UB.box),r=V(UB.check);return(0,z.jsx)(EV,{placement:e.placement??`bottom`,content:e.isSelected?`Mark as not reviewed`:`Mark as reviewed`,children:(0,z.jsx)(LI,{className:t,"data-reviewed":!0,"aria-label":`Reviewed`,isSelected:e.isSelected,isDisabled:e.isDisabled,onChange:e.onChange,children:(0,z.jsx)(`span`,{className:n,children:(0,z.jsx)(`svg`,{focusable:`false`,"aria-hidden":`true`,className:r,viewBox:`0 0 11 11`,children:(0,z.jsx)(`path`,{d:y3})})})})})}var x3,S3=(0,R.createContext)({load:()=>x3??=fetch(`/__diffmap/config`).then(async e=>await e.json(),e=>({error:String(e)}))});function C3(){return(0,R.useContext)(S3)}function w3(){let{load:e}=C3(),[t,n]=(0,R.useState)(void 0);return(0,R.useEffect)(()=>{let t=!0;return e().then(e=>{t&&n(e)}),()=>{t=!1}},[e]),t}function T3(e){return e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/([A-Z])([A-Z][a-z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function E3(e){return e.slice(e.indexOf(`--`)+2).split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function D3(e,t){let n=[];for(let r=t;r!==void 0;r=e[r].parent)n.unshift(e[r].story);return n}function O3(e,t){let n=[];for(let r=t;r!==void 0;r=e[r].parent)n.unshift(r);return n}function k3(e,t){return e.flatMap((e,n)=>e.parent===t?[n]:[])}function A3(e){let t=e.map(()=>({column:0,row:0})),n=0,r=(i,a)=>{let o=k3(e,i),s;if(o.length===0)s=n++;else{let e=o.map(e=>r(e,a+1));s=(e[0]+e.at(-1))/2}return t[i]={column:a,row:s},s};return e.length>0&&r(0,0),{placements:t,columns:Math.max(0,...t.map(e=>e.column))+1,rows:Math.max(1,n)}}var j3=8e3;function M3(e){let[t,n]=(0,R.useState)(0);return(0,z.jsx)(N3,{...e,onRetry:()=>n(t+1)},t)}function N3(e){let t=(0,R.useRef)(null),n=(0,R.useRef)(null),[r,i]=(0,R.useState)(e.lazy!==!0),[a,o]=(0,R.useState)(`loading`),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(),[p]=(0,R.useState)(()=>I3(e.page,e.initialPath)),m=(0,R.useRef)(void 0),h=(0,R.useRef)(0),g=(0,R.useRef)(()=>{}),_=(0,R.useRef)(()=>{}),v=(0,R.useRef)(!1),y=(0,R.useRef)(e);(0,R.useLayoutEffect)(()=>{y.current=e});let b=new URL(e.page,window.location.href).origin,x=C3().deployment!==void 0;(0,R.useEffect)(()=>{if(r)return;let e=n.current,t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i(!0)},{rootMargin:`300px`});return t.observe(e),()=>t.disconnect()},[r]),(0,R.useLayoutEffect)(()=>{if(e.renderWidth===void 0)return;let t=n.current,r=new ResizeObserver(()=>f(t.clientWidth));return r.observe(t),()=>r.disconnect()},[e.renderWidth]),(0,R.useEffect)(()=>{if(!r)return;let e=t.current,n=t=>e.contentWindow?.postMessage(t,b),i=()=>{let e=m.current;e!==void 0&&e.seq!==h.current&&(h.current=e.seq,n({type:`preview-show`,story:e.path.at(-1),how:e.how,path:e.path}))},a=!1,s=setTimeout(()=>{a||o(`unreachable`)},j3),l=()=>n({type:`preview-connect`}),d=t=>{if(t.source!==e.contentWindow||t.origin!==b)return;let r=t.data;switch(r?.type){case`preview-hello`:l();return;case`preview-ready`:a=!0,clearTimeout(s),o(`ready`),n({type:`preview-mode`,mode:y.current.mode}),y.current.onReady?.(r.stories),i();return;case`preview-size`:c(r.height);return;case`preview-state`:v.current=!0,u(void 0),y.current.onState?.(r);return;case`preview-error`:u(r.message),y.current.onError?.(r.message);return}};return window.addEventListener(`message`,d),e.addEventListener(`load`,l),g.current=()=>{a&&i()},_.current=e=>{a&&n({type:`preview-mode`,mode:e})},()=>{clearTimeout(s),window.removeEventListener(`message`,d),e.removeEventListener(`load`,l)}},[r,b]),(0,R.useEffect)(()=>{if(!r)return;let e=t.current,n=()=>requestAnimationFrame(()=>{document.activeElement===e&&(y.current.mode===`live`&&v.current||(e.blur(),F3?.isConnected&&F3.focus({preventScroll:!0})))});return window.addEventListener(`blur`,n),()=>window.removeEventListener(`blur`,n)},[r]),(0,R.useEffect)(()=>{e.request!==void 0&&(m.current=e.request,g.current())},[e.request]),(0,R.useEffect)(()=>{_.current(e.mode)},[e.mode]);let S=e.renderWidth===void 0||d===void 0?1:Math.min(1,d/e.renderWidth),C=e.renderHeight??s??160,w=Math.min(C*S,e.maxHeight??1/0),T=V(L3.box),E=V(L3.frame,e.mode===`thumbnail`&&L3.inert),D=V(L3.overlay),O=V(L3.error);return(0,z.jsxs)(`div`,{ref:n,className:T,style:{height:w},"data-preview-status":a,children:[r&&(0,z.jsx)(`iframe`,{ref:t,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,src:p,title:e.label,className:E,tabIndex:e.mode===`thumbnail`?-1:void 0,"aria-hidden":e.mode===`thumbnail`||void 0,style:{width:e.renderWidth??`100%`,height:e.renderWidth===void 0?w:C,transform:S===1?void 0:`scale(${S})`}}),a===`loading`&&(0,z.jsx)(`div`,{className:D,children:(0,z.jsx)(nz,{})}),a===`unreachable`&&(0,z.jsxs)(`div`,{className:D,role:`alert`,children:[(0,z.jsx)(wB,{size:`md`}),x?(0,z.jsxs)(`span`,{children:[`The pull request's preview deployment isn't answering at`,` `,e.page,`.`]}):(0,z.jsxs)(`span`,{children:[`Can't reach the app's preview page at `,e.page,`.`]}),e.mode===`live`&&(0,z.jsxs)(z.Fragment,{children:[x?(0,z.jsxs)(`span`,{children:[`It may still be building: retry in a minute, or `,(0,z.jsx)(P3,{}),`.`]}):(0,z.jsx)(`span`,{children:`Start the app's dev server, then retry.`}),(0,z.jsxs)(Vz,{size:`sm`,onClick:e.onRetry,children:[(0,z.jsx)(TB,{size:`xs`}),`Retry`]})]})]}),l!==void 0&&e.mode===`live`&&(0,z.jsx)(`div`,{className:O,role:`alert`,children:l})]})}function P3(){let e=V(L3.inlineLink);return(0,z.jsx)(`a`,{className:e,href:`https://github.com/tanishqkancharla/diffmap/blob/main/guide.md#serve-and-share`,children:`run this spec with product-doc serve`})}var F3;document.addEventListener(`focusin`,e=>{e.target instanceof HTMLElement&&e.target.tagName!==`IFRAME`&&(F3=e.target)});function I3(e,t){let n=new URL(e,window.location.href);return n.searchParams.set(`story`,t.at(-1)),t.length>1&&n.searchParams.set(`path`,t.join(`,`)),n.href}var L3={box:B({position:`relative`,width:`100%`,overflow:`hidden`,transition:`height 160ms ease-out`}),frame:B({display:`block`,border:0,transformOrigin:`0 0`,backgroundColor:`white`}),inert:B({pointerEvents:`none`}),inlineLink:B({font:`inherit`,color:G.gray[12],textDecorationLine:`underline`,textUnderlineOffset:`2px`}),overlay:B(J({size:`xs`,color:`lowContrast`}),Y.padding({all:6}),{position:`absolute`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:Y.value(3),textAlign:`center`,backgroundColor:G.gray[2]}),error:B(J({size:`xs`}),Y.padding({x:4,y:2}),{position:`absolute`,insetInline:0,bottom:0,color:G.red[11],backgroundColor:G.red[2]})};function R3(e){let t=z3(),[n,r]=(0,R.useState)(),i=V(LG),a=V(RG),o=V(V3.grid,e.stories.length>1&&V3.multiple),s=V(V3.cell),c=V(V3.name),l=V(V3.note);return(0,z.jsxs)(`figure`,{className:i,"data-diffmap-kind":`preview`,children:[e.title!==void 0&&(0,z.jsx)(`figcaption`,{className:a,children:e.title}),`message`in t?t.message:(0,z.jsx)(`div`,{className:o,children:e.stories.map(e=>{let i=n?.get(e);return(0,z.jsxs)(`div`,{className:s,children:[(0,z.jsx)(`div`,{className:c,children:i===void 0?E3(e):T3(i.name)}),(0,z.jsx)(M3,{page:t.url,initialPath:[e],mode:`live`,maxHeight:560,label:i===void 0?E3(e):T3(i.name),onReady:e=>r(new Map(e.map(e=>[e.id,e])))}),i?.description!==void 0&&(0,z.jsx)(`div`,{className:l,children:i.description})]},e)})})]})}function z3(){let e=j4(),{deployment:t}=C3(),n=w3();if(e!==`local`&&(e!==`github`||t===void 0))return{message:(0,z.jsxs)(B3,{children:[`Live previews show when you `,(0,z.jsx)(P3,{}),`.`]})};if(n===void 0)return{message:(0,z.jsx)(B3,{children:`Loading…`})};if(`error`in n)return{message:(0,z.jsxs)(B3,{children:[`Can't read .diffmap/config.json: `,n.error]})};if(t===void 0){let e=n.config.previews?.local;return e===void 0?{message:(0,z.jsx)(B3,{children:`Add previews.local to .diffmap/config.json, the URL of the app's preview page, such as http://localhost:5173/previews.html.`})}:{url:e}}let r=n.config.previews?.preview;if(r===void 0)return{message:(0,z.jsxs)(B3,{children:[`This repo's .diffmap/config.json has no previews.preview, the URL of the preview page on each pull request's deployment. Until it does, live previews show when you `,(0,z.jsx)(P3,{}),`.`]})};let i=I4(r,t);return i instanceof Error?{message:(0,z.jsxs)(B3,{children:[i.message,` Open this spec from its pull request, or `,(0,z.jsx)(P3,{}),`.`]})}:{url:i}}function B3(e){let t=V(V3.notice);return(0,z.jsx)(`div`,{className:t,children:e.children})}var V3={grid:B({display:`grid`,gridTemplateColumns:`1fr`,gap:Y.value(1),backgroundColor:G.gray[4]}),multiple:B({gridTemplateColumns:`repeat(auto-fit, minmax(280px, 1fr))`}),cell:B({display:`flex`,flexDirection:`column`,minWidth:0,backgroundColor:G.gray[1]}),name:B(J({size:`xs`,fontWeight:500}),Y.padding({x:6,y:3}),{borderBottom:`1px solid ${G.gray[4]}`}),note:B(J({size:`xs`,color:`lowContrast`}),Y.padding({x:6,y:3}),{margin:0,lineHeight:1.5,borderTop:`1px solid ${G.gray[4]}`}),notice:B(J({size:`sm`,color:`lowContrast`}),Y.padding({all:6}))},H3=new Set,U3=new Map;function W3(){return`diffmap-reviewed-previews:${window.location.pathname}`}function G3(){let e=W3(),t=U3.get(e);if(t===void 0){try{t=JSON.parse(localStorage.getItem(e)??`{}`)}catch{t={}}U3.set(e,t)}return t}function K3(e){let t=W3();U3.set(t,e);try{Object.keys(e).length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(e))}catch(e){console.warn(`diffmap could not save reviewed previews`,e)}for(let e of H3)e()}function q3(){let e=(0,R.useSyncExternalStore)(e=>(H3.add(e),()=>H3.delete(e)),G3);return{isReviewed:(0,R.useCallback)((t,n)=>n!==void 0&&e[t]===n,[e]),setReviewed:(0,R.useCallback)((e,t,n)=>{let{[e]:r,...i}=G3();K3(n?{...i,[e]:t}:i)},[])}}var J3=720,Y3=248,X3=8,Z3=300,Q3={width:152,height:128,gapX:32,gapY:16};function $3(e){let{states:t}=e,n=z3(),r=w3(),i=r!==void 0&&`config`in r?r.config.flows:void 0,a=i?.transitions??`play`,o=i?.viewport,[s,c]=(0,R.useState)(0),[l,u]=(0,R.useState)(void 0),[d,f]=(0,R.useState)(void 0),[p,m]=(0,R.useState)(),[h,g]=(0,R.useState)({}),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(!0),[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(),T=(0,R.useRef)(!1),E=(0,R.useRef)(void 0),[D,O]=(0,R.useState)(),k=(0,R.useRef)(0),A=(0,R.useRef)(null),j=(0,R.useRef)(null),M=(0,R.useRef)(null),{isReviewed:ee,setReviewed:te}=q3(),N=e=>t.findIndex(t=>t.story===e),ne=e=>{let n=p?.get(t[e].story);return n===void 0?E3(t[e].story):T3(n.name)},re=e=>`flow:${D3(t,e).join(`>`)}`,P=e=>{if(e===s&&l===e)return;let n=a===`play`&&l!==void 0&&t[e].parent===l?`play`:`render`;c(e),k.current+=1,f({path:D3(t,e),how:n,seq:k.current})},ie=e=>{e&&O(A.current.offsetHeight),v(e)};(0,R.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&v(!1)},t=document.body.style.overflow;return document.body.style.overflow=`hidden`,window.addEventListener(`keydown`,e),j.current?.focus(),()=>{document.body.style.overflow=t,window.removeEventListener(`keydown`,e)}},[_]),(0,R.useEffect)(()=>{if(!_)return;let e=M.current,t=e?.querySelector(`[data-state='${s}']`);if(e===null||t==null)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();e.scrollTo({left:e.scrollLeft+r.left-n.left-(n.width-r.width)/2,top:e.scrollTop+r.top-n.top-(n.height-r.height)/2,behavior:`instant`})},[s,_]),(0,R.useEffect)(()=>{if(C===void 0)return;let e=()=>{window.clearTimeout(E.current),T.current=!1,w(void 0)};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[C]);let F=A3(t),ae=O3(t,s),oe=k3(t,s),se=t[s].parent,ce=p!==void 0&&l!==s,le=p?.get(t[s].story)?.description,ue=e=>ee(re(e),h[t[e].story]),de=(e,n)=>{let r=h[t[e].story];r!==void 0&&te(re(e),r,n)},fe=(e,t)=>{if(S(!0),e===s){pe();return}let n=t.getBoundingClientRect(),r=t.closest(`[data-states-sidebar]`).getBoundingClientRect(),i=r.right+X3,a=i+Y3<=window.innerWidth-X3?i:r.left-X3-Y3,o=Math.max(X3,Math.min(n.top,window.innerHeight-Z3));if(window.clearTimeout(E.current),T.current){w({index:e,top:o,left:a});return}E.current=window.setTimeout(()=>{T.current=!0,w({index:e,top:o,left:a})},300)},pe=()=>{window.clearTimeout(E.current),T.current=!1,w(void 0)},me=V(n6.wrapper),I=V(n6.scrim),he=V(LG,n6.card,_&&n6.expandedCard),ge=V(RG,n6.header),_e=V(n6.crumbs),ve=V(n6.crumbStep),ye=V(n6.crumb),be=V(n6.body,!_&&y&&n6.bodyWithSidebar,_&&n6.expandedBody),xe=V(n6.stage,_&&n6.expandedStage),Se=V(n6.controls),Ce=V(n6.note),we=V(n6.actions),Te=V(n6.endNote),Ee=V(n6.sidebar),De=V(n6.outline),Oe=V(n6.outlineItem),ke=V(n6.outlineLabel),Ae=V(n6.guides),je=V(n6.guide),Me=V(TV.root,n6.peekCard),Ne=V(n6.peekFrames),Pe=V(n6.peekFrame),Fe=V(n6.map),Ie=V(n6.mapCard),Le=V(n6.thumbFrame),Re=V(n6.thumbLabel),ze=V(n6.thumbHit),Be=V(n6.thumbReview),Ve=V(n6.reviewedMark),He=V(n6.edges);if(`message`in n)return(0,z.jsxs)(`figure`,{className:he,"data-diffmap-kind":`flow`,children:[e.title!==void 0&&(0,z.jsx)(`figcaption`,{className:ge,children:e.title}),n.message]});let Ue=e=>({position:`absolute`,left:`calc(${F.placements[e].column*(Q3.width+Q3.gapX)}px + ${Y.value(6)})`,top:`calc(${F.placements[e].row*(Q3.height+Q3.gapY)}px + ${Y.value(6)})`}),We=F.columns*(Q3.width+Q3.gapX)-Q3.gapX,Ge=F.rows*(Q3.height+Q3.gapY)-Q3.gapY,Ke=(e,r)=>{let i=t[e],a=ue(e);return(0,z.jsxs)(`div`,{className:Ie,"data-state":e,"aria-current":e===s?`step`:void 0,style:r,children:[(0,z.jsx)(`div`,{className:Le,"data-reviewed":a,children:p!==void 0&&(0,z.jsx)(M3,{page:n.url,initialPath:D3(t,e),mode:`thumbnail`,renderWidth:J3,label:ne(e),onState:e=>g(t=>({...t,[i.story]:e.fingerprint}))})}),a&&(0,z.jsx)(`div`,{className:Ve,role:`img`,"aria-label":`Reviewed: ${ne(e)}`,children:(0,z.jsx)(aB,{size:`sm`})}),(0,z.jsx)(`div`,{className:Re,children:i.action??`Start`}),(0,z.jsx)(`button`,{type:`button`,className:ze,"aria-label":ne(e),onClick:()=>P(e)}),(0,z.jsx)(`div`,{className:Be,role:`group`,"aria-label":`Review ${ne(e)}`,children:(0,z.jsx)(b3,{isSelected:a,onChange:t=>de(e,t)})})]},i.story)};return(0,z.jsxs)(`div`,{ref:A,className:me,style:{height:_?D:void 0},children:[_&&(0,z.jsx)(`div`,{className:I,onClick:()=>ie(!1)}),(0,z.jsxs)(`figure`,{ref:j,className:he,"data-diffmap-kind":`flow`,tabIndex:-1,"aria-label":e.title??`Flow`,"aria-modal":_||void 0,role:_?`dialog`:void 0,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`ArrowRight`&&oe[0]!==void 0&&P(oe[0]),e.key===`ArrowLeft`&&se!==void 0&&P(se))},children:[(0,z.jsxs)(`figcaption`,{className:ge,children:[e.title!==void 0&&(0,z.jsx)(`span`,{children:e.title}),(0,z.jsx)(`nav`,{className:_e,"aria-label":`Steps taken`,children:ae.map((e,t)=>(0,z.jsxs)(`span`,{className:ve,children:[t>0&&(0,z.jsx)(cB,{size:`2xs`}),(0,z.jsx)(`button`,{type:`button`,className:ye,"aria-current":e===s?`step`:void 0,onClick:()=>P(e),children:ne(e)})]},e))}),ce&&(0,z.jsx)(nz,{size:`xs`,"aria-label":`Playing the step`}),(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":_?`Collapse the flow`:`Expand the flow`,onClick:()=>ie(!_),children:_?(0,z.jsx)(Yz,{size:`xs`}):(0,z.jsx)(yB,{size:`xs`})}),!_&&(0,z.jsx)(EV,{content:y?`Hide states`:`Show states`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":y?`Hide states`:`Show states`,"aria-pressed":y,onClick:()=>b(!y),children:(0,z.jsx)(vB,{size:`xs`})})})]}),(0,z.jsxs)(`div`,{className:be,children:[(0,z.jsxs)(`div`,{className:xe,children:[(0,z.jsx)(M3,{page:n.url,initialPath:[t[0].story],mode:`live`,lazy:!0,request:d,renderWidth:_?o?.width:void 0,renderHeight:_?o?.height:void 0,maxHeight:_?void 0:640,label:`${e.title??`Flow`}: ${ne(s)}`,onReady:e=>m(new Map(e.map(e=>[e.id,e]))),onState:e=>{let t=N(e.story);t!==-1&&(u(t),g(t=>t[e.story]===void 0?{...t,[e.story]:e.fingerprint}:t))}}),(0,z.jsxs)(`div`,{className:Se,children:[le!==void 0&&(0,z.jsx)(`div`,{className:Ce,children:le}),(0,z.jsxs)(Vz,{size:`sm`,isDisabled:se===void 0,onClick:()=>se!==void 0&&P(se),children:[(0,z.jsx)(rB,{size:`xs`}),`Back`]}),(0,z.jsx)(`div`,{className:we,children:oe.length===0?(0,z.jsx)(`span`,{className:Te,children:`End of this path`}):(0,z.jsx)(t6,{steps:oe.map(e=>({index:e,action:t[e].action})),onSelect:P})})]})]}),_?(0,z.jsxs)(`div`,{ref:M,className:Fe,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,style:{width:`calc(${We}px + 2 * ${Y.value(6)})`,height:`calc(${Ge}px + 2 * ${Y.value(6)})`}}),(0,z.jsx)(`svg`,{className:He,"aria-hidden":!0,children:t.map((e,t)=>{if(e.parent===void 0)return;let n=F.placements[e.parent],r=F.placements[t],i=n.column*(Q3.width+Q3.gapX)+Q3.width,a=n.row*(Q3.height+Q3.gapY)+Q3.height/2,o=r.column*(Q3.width+Q3.gapX),s=r.row*(Q3.height+Q3.gapY)+Q3.height/2,c=(i+o)/2;return(0,z.jsx)(`path`,{d:`M ${i} ${a} C ${c} ${a}, ${c} ${s}, ${o} ${s}`,"data-active":ae.includes(t)||void 0},e.story)})}),t.map((e,t)=>Ke(t,Ue(t)))]}):y&&(0,z.jsxs)(`div`,{className:Ee,"data-states-sidebar":!0,onPointerEnter:()=>S(!0),children:[(0,z.jsx)(`nav`,{className:De,"aria-label":`Every state`,onPointerLeave:pe,children:t.map((e,n)=>{let r=O3(t,n);return(0,z.jsxs)(`div`,{className:Oe,"aria-current":n===s?`step`:void 0,"data-on-path":ae.includes(n)||void 0,onPointerEnter:e=>fe(n,e.currentTarget),children:[(0,z.jsx)(`span`,{className:Ae,"aria-hidden":!0,children:r.slice(1).map((e,n)=>(0,z.jsx)(`span`,{className:je,"data-elbow":n===r.length-2||void 0,"data-continued":e6(t,e)||void 0},e))}),(0,z.jsx)(`button`,{type:`button`,className:ke,"aria-current":n===s?`step`:void 0,onClick:()=>{pe(),P(n)},onFocus:e=>fe(n,e.currentTarget.parentElement),onBlur:pe,children:ne(n)}),(0,z.jsx)(b3,{isSelected:ue(n),isDisabled:h[e.story]===void 0,onChange:e=>de(n,e)})]},e.story)})}),x&&p!==void 0&&(0,hD.createPortal)((0,z.jsxs)(`div`,{className:Me,"data-open":C!==void 0||void 0,style:{top:C?.top??0,left:C?.left??0},"aria-hidden":!0,children:[(0,z.jsx)(`div`,{className:Ne,children:t.map((e,r)=>(0,z.jsx)(`div`,{className:Pe,"data-shown":r===C?.index||void 0,children:(0,z.jsx)(M3,{page:n.url,initialPath:D3(t,r),mode:`thumbnail`,renderWidth:J3,maxHeight:140,label:ne(r),onState:t=>g(n=>({...n,[e.story]:t.fingerprint}))})},e.story))}),C!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`strong`,{children:ne(C.index)}),p.get(t[C.index].story)?.description!==void 0&&(0,z.jsx)(`span`,{"data-description":!0,children:p.get(t[C.index].story).description})]})]}),document.body)]})]})]})]})}function e6(e,t){let n=e[t].parent;return e.some((e,r)=>r>t&&e.parent===n)}function t6(e){let[t,...n]=e.steps,r=V(n6.segmented);return(0,z.jsxs)(`div`,{className:r,children:[(0,z.jsxs)(Vz,{size:`sm`,variant:`primary`,onClick:()=>e.onSelect(t.index),children:[t.action,(0,z.jsx)(iB,{size:`xs`})]}),n.length>0&&(0,z.jsxs)(FH,{placement:`bottom end`,children:[(0,z.jsx)(Vz,{size:`sm`,variant:`primary`,"aria-label":`${n.length} other next ${n.length===1?`step`:`steps`}`,children:(0,z.jsx)(oB,{size:`xs`})}),(0,z.jsx)(LH,{onAction:t=>e.onSelect(Number(t)),children:n.map(e=>(0,z.jsx)(RH,{id:String(e.index),children:e.action},e.index))})]})]})}var n6={wrapper:B({position:`relative`,width:`100%`}),scrim:B({position:`fixed`,inset:0,zIndex:50,backgroundColor:`rgb(0 0 0 / 0.25)`}),card:B({width:`100%`,margin:0,outline:`none`}),expandedCard:B({position:`fixed`,inset:`16px`,zIndex:51,width:`auto`,display:`flex`,flexDirection:`column`,backgroundColor:G.gray[1]}),header:B({display:`flex`,alignItems:`center`,gap:Y.value(4),minHeight:`36px`,"& > span:first-child":{flexShrink:0,color:G.gray[12]}}),crumbs:B({display:`flex`,alignItems:`center`,gap:Y.value(1),flex:1,minWidth:0,overflow:`hidden`,whiteSpace:`nowrap`}),crumbStep:B({display:`flex`,alignItems:`center`,gap:Y.value(1),flexShrink:0}),crumb:B(J({size:`xs`}),Ud(),{border:0,padding:`2px 4px`,borderRadius:`4px`,background:`none`,color:G.gray[11],cursor:`pointer`,"&[aria-current='step']":{color:G.gray[12],fontWeight:600},"&:hover":{color:G.gray[12]}}),body:B({display:`grid`,gridTemplateColumns:`minmax(0, 1fr)`,minHeight:0}),bodyWithSidebar:B({gridTemplateColumns:`minmax(0, 1fr) 200px`}),expandedBody:B({flex:1,gridTemplateColumns:`minmax(0, 3fr) minmax(0, 2fr)`,gridTemplateAreas:`'stage map'`}),stage:B({display:`flex`,flexDirection:`column`,minWidth:0,backgroundColor:G.gray[2]}),expandedStage:B({gridArea:`stage`,overflow:`auto`}),controls:B(Y.padding({x:6,y:4}),{display:`flex`,flexWrap:`wrap`,alignItems:`center`,columnGap:Y.value(4),rowGap:Y.value(3),borderTop:`1px solid ${G.gray[4]}`,backgroundColor:G.gray[1]}),note:B(J({size:`xs`,color:`lowContrast`}),{flexBasis:`100%`,lineHeight:1.5}),actions:B({display:`flex`,alignItems:`center`,gap:Y.value(2),marginLeft:`auto`}),endNote:B(J({size:`xs`,color:`lowContrast`}),{paddingInline:Y.value(2)}),segmented:B({display:`inline-flex`,"& > button:not(:last-child)":{borderTopRightRadius:0,borderBottomRightRadius:0},"& > button + button":{borderTopLeftRadius:0,borderBottomLeftRadius:0,marginLeft:`1px`}}),peekCard:B({position:`fixed`,width:`${Y3}px`,maxWidth:`none`,boxSizing:`border-box`,display:`flex`,flexDirection:`column`,gap:`2px`,padding:Y.value(2),visibility:`hidden`,pointerEvents:`none`,"&[data-open]":{visibility:`visible`},"& > strong":{marginTop:Y.value(1),fontWeight:600},"& > [data-description]":{color:G.gray[11],marginTop:`2px`,lineHeight:1.45}}),peekFrames:B(Fd.sm,{position:`relative`,overflow:`hidden`}),peekFrame:B({position:`absolute`,top:0,left:0,right:0,visibility:`hidden`,"&[data-shown]":{position:`relative`,visibility:`visible`}}),sidebar:B({position:`relative`,minWidth:0,borderLeft:`1px solid ${G.gray[4]}`,backgroundColor:G.gray[1]}),outline:B({position:`absolute`,inset:0,display:`flex`,flexDirection:`column`,padding:Y.value(2),overflowY:`auto`}),outlineItem:B(J({size:`xs`}),{display:`flex`,alignItems:`stretch`,flexShrink:0,minHeight:`28px`,paddingInline:`4px 6px`,borderRadius:`4px`,color:G.gray[11],"& > label":{alignSelf:`center`,flexShrink:0},"&[data-on-path]":{color:G.gray[12]},"&:hover":{backgroundColor:G.gray[3]},"&[aria-current='step']":{backgroundColor:G.accent[3],color:G.gray[12],fontWeight:600}}),outlineLabel:B(Ud(),{flex:1,minWidth:0,padding:`0 4px`,border:0,borderRadius:`4px`,background:`none`,color:`inherit`,font:`inherit`,textAlign:`left`,cursor:`pointer`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),guides:B({display:`inline-flex`,flexShrink:0}),guide:B({position:`relative`,width:`16px`,flexShrink:0,"&[data-continued]::before":{content:`''`,position:`absolute`,left:`7px`,insetBlock:0,borderLeft:`1px solid ${G.gray[6]}`},"&[data-elbow]::after":{content:`''`,position:`absolute`,left:`7px`,right:0,top:0,bottom:`50%`,borderLeft:`1px solid ${G.gray[6]}`,borderBottom:`1px solid ${G.gray[6]}`,borderBottomLeftRadius:`5px`},"&[data-elbow][data-continued]::after":{top:`50%`,bottom:`auto`,borderLeft:0,borderBottomLeftRadius:0}}),map:B({gridArea:`map`,position:`relative`,overflow:`auto`,borderLeft:`1px solid ${G.gray[4]}`,backgroundColor:G.gray[2]}),mapCard:B(Fd.md,Vd.subtle,{position:`relative`,flexShrink:0,width:`${Q3.width}px`,height:`${Q3.height}px`,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:G.gray[1],"&[aria-current='step']":{boxShadow:`0 0 0 2px ${G.accent[9]}`},"&:has(> button:focus-visible)":{boxShadow:`0 0 0 2px ${G.accent[8]}`}}),thumbFrame:B({height:`${Q3.height-36}px`,overflow:`hidden`,flexShrink:0,transition:`opacity 120ms`,"&[data-reviewed='true']":{opacity:.35}}),thumbLabel:B(J({size:`xs`,fontWeight:500}),Y.padding({x:3,y:2}),{display:`flex`,alignItems:`center`,flex:1,minHeight:0,borderTop:`1px solid ${G.gray[4]}`,color:G.gray[12],lineHeight:1.25}),thumbHit:B({position:`absolute`,inset:0,padding:0,border:0,background:`none`,cursor:`pointer`,outline:`none`}),thumbReview:B({position:`absolute`,top:Y.value(1),right:Y.value(1),zIndex:1,display:`flex`,padding:`2px`,borderRadius:`4px`,backgroundColor:G.gray[1]}),reviewedMark:B(Fd.circle,Vd.subtle,{position:`absolute`,top:`${(Q3.height-36)/2}px`,left:`50%`,transform:`translate(-50%, -50%)`,width:`32px`,height:`32px`,display:`grid`,placeItems:`center`,color:`white`,backgroundColor:G.green[9],pointerEvents:`none`}),edges:B({position:`absolute`,top:Y.value(6),left:Y.value(6),width:`100%`,height:`100%`,overflow:`visible`,pointerEvents:`none`,"& path":{fill:`none`,stroke:G.gray[7],strokeWidth:1.5},"& path[data-active]":{stroke:G.accent[9],strokeWidth:2}})},r6=String.raw`[A-Za-z_]\w*`;new RegExp(String.raw`^service\s+(${r6})(?:\s+"([^"]*)")?\s*$`),new RegExp(String.raw`^state\s+(${r6})\s*=\s*(.+)$`),new RegExp(String.raw`^(${r6})\s*->\s*(${r6})(?:\s*:\s*(.*))?$`),new RegExp(String.raw`^(${r6})\.(${r6})\s*=\s*(.+)$`),new RegExp(String.raw`^(${r6})$`);function i6(e,t){return e.flatMap(e=>[{service:e,parent:t},...i6(e.children,e)])}function a6(e,t,n=`proposed`){let r=n===`today`?`+`:`-`,i=new Map(i6(e.services).map(({service:e})=>[e.name,new Map(e.state.filter(e=>e.sign!==r).map(e=>[e.key,n===`today`?e.todayValue??e.value:e.value]))]));for(let{updates:n}of e.steps.slice(0,t))for(let e of n)e.sign!==r&&i.get(e.service).set(e.key,e.value);return i}function o6(e){if(e.label===``)return``;let t={"+":`+ `,"-":`− `," ":``}[e.sign],n=e.annotation===void 0?``:` ↗`;return`${t}${e.label}${n}`}function s6(e){let t=new Map(i6(e.services).map(({service:e},t)=>[e.name,t])),n=new Map;for(let r of e.steps)for(let e of r.events){let r=t.get(e.from)<=t.get(e.to),[i,a]=r?[e.from,e.to]:[e.to,e.from],o=c6(i,a),s=n.get(o)??{id:o,a:i,b:a,forward:!1,backward:!1,sign:e.sign};r?s.forward=!0:s.backward=!0,s.sign!==e.sign&&(s.sign=` `),n.set(o,s)}return[...n.values()]}function c6(e,t){return e<t?`${e}|${t}`:`${t}|${e}`}var l6;function u6(){return l6??=YW(()=>import(`./elk.bundled-CVOErv1M.js`).then(t=>e(t.default,1)).then(e=>new e.default),__vite__mapDeps([4,5])),l6}function d6(e,t){return e.children.some(e=>e.name===t||d6(e,t))}async function f6(e){let t={width:Math.max(0,...[...e.labels.values()].map(e=>e.width)),height:Math.max(0,...[...e.labels.values()].map(e=>e.height))},n=r=>{let i=e.sizes.get(r.name);if(r.children.length===0)return{id:r.name,width:i.width,height:i.height};let a=e.links.some(e=>e.a===r.name&&d6(r,e.b)),o=e=>a?e+24:0,s=i.height+4+(e.direction===`DOWN`?o(t.height):0),c=16+(e.direction===`RIGHT`?o(t.width):0);return{id:r.name,layoutOptions:{"elk.padding":`[top=${s},left=${c},bottom=16,right=16]`,"elk.nodeSize.constraints":`MINIMUM_SIZE`,"elk.layered.spacing.nodeNodeBetweenLayers":`40`,"elk.nodeSize.minimum":e.direction===`DOWN`?`(0,${i.width})`:`(${i.width},0)`},children:r.children.map(n)}},r={id:`root`,layoutOptions:{"elk.algorithm":`layered`,"elk.direction":e.direction,"elk.edgeRouting":`ORTHOGONAL`,"elk.hierarchyHandling":`INCLUDE_CHILDREN`,"elk.layered.considerModelOrder.strategy":`NODES_AND_EDGES`,"elk.json.edgeCoords":`ROOT`,"elk.json.shapeCoords":`ROOT`,"elk.padding":`[top=24,left=24,bottom=24,right=24]`,"elk.spacing.nodeNode":`32`,"elk.layered.spacing.nodeNodeBetweenLayers":`40`,"elk.spacing.edgeNode":`16`,"elk.spacing.edgeEdge":`12`,"elk.edgeLabels.inline":`false`},children:e.diagram.services.map(n),edges:e.links.map(t=>({id:t.id,sources:[t.a],targets:[t.b],labels:e.labels.has(t.id)?[{id:`${t.id}-messages`,text:`messages`,...e.labels.get(t.id),layoutOptions:{"elk.edgeLabels.placement":`CENTER`}}]:[]}))},i=await(await u6()).layout(r),a=new Map,o=e=>{for(let t of e??[])a.set(t.id,{x:t.x,y:t.y,width:t.width,height:t.height}),o(t.children)};o(i.children);let s=new Map((i.edges??[]).map(e=>{let t=e.sections[0];return[e.id,[t.startPoint,...t.bendPoints??[],t.endPoint]]}));return{width:i.width,height:i.height,sizes:e.sizes,boxes:a,routes:s,labels:new Map((i.edges??[]).flatMap(e=>(e.labels??[]).map(t=>[e.id,{x:t.x,y:t.y,width:t.width,height:t.height}])))}}var p6=200,m6=28,h6=6;function g6(e){let t=e.diagram,n=(0,R.useMemo)(()=>i6(t.services),[t]),r=(0,R.useMemo)(()=>s6(t),[t]),i=(0,R.useMemo)(()=>b6(t),[t]),a=(0,R.useRef)(null),o=(0,R.useRef)(null),[s,c]=(0,R.useState)(0),[l,u]=(0,R.useState)(),d=(0,R.useMemo)(()=>t.steps.some(e=>e.events.some(e=>e.note!==void 0)||e.updates.some(e=>e.note!==void 0)||e.notes.length>0)?256:0,[t]),f=(0,R.useId)();(0,R.useLayoutEffect)(()=>{let e=0,n=-1,i=async i=>{let s=a.current.clientWidth;if(!i&&s===n)return;n=s;let c=++e,l=new Map([...o.current.querySelectorAll(`[data-measure-service]`)].map(e=>[e.getAttribute(`data-measure-service`),D6(e)])),f=Math.max(0,...[...l.values()].map(e=>e.width));o.current.style.setProperty(`--label-width`,`${Math.min(220,Math.max(80,s-f/2-56))}px`);let p=new Map;for(let e of o.current.querySelectorAll(`[data-measure-event]`)){let[n,r]=e.getAttribute(`data-measure-event`).split(`:`).map(Number);p.set(t.steps[n].events[r],D6(e))}let m=new Map;for(let e of t.steps){let t=new Map;for(let n of e.events){let e=p.get(n);if(e===void 0)continue;let r=c6(n.from,n.to),i=t.get(r);t.set(r,{width:Math.max(i?.width??0,e.width),height:(i===void 0?0:i.height+h6)+e.height})}for(let[e,n]of t){let t=m.get(e);m.set(e,{width:Math.max(t?.width??0,n.width),height:Math.max(t?.height??0,n.height)})}}let h={diagram:t,links:r,sizes:l,labels:m},g=e=>e.width+d<=s,_=await f6({...h,direction:`RIGHT`}),v=g(_)?_:await f6({...h,direction:`DOWN`}),y=v.width<_.width?v:_,b=y.width,x=Math.max(0,(s-b)/2);c===e&&u({layout:y,labels:p,overflow:b>s,left:x,notesBelow:x<d})};i(!0),document.fonts.ready.then(()=>i(!0));let s=new ResizeObserver(()=>void i(!1));return s.observe(a.current),()=>{e=NaN,s.disconnect()}},[t,r,d]);let p=(0,R.useMemo)(()=>new Map(n.map(({service:e,parent:t})=>[e.name,t?.name])),[n]),m=(0,R.useMemo)(()=>{let e=new Map;for(let{service:t,parent:r}of n)e.set(t.name,r===void 0?0:e.get(r.name)+1);return e},[n]),h=V(j6.stage),g=V(j6.measureLayer),_=V(j6.canvas),v=V(j6.overlay),y=V(j6.box),b=V(j6.pill),x=l?.layout,S=e.phase===`settled`,C=(0,R.useMemo)(()=>S?[...e.events.flatMap((e,t)=>e.note===void 0?[]:[{id:`event-${t}`,text:e.note,target:`[data-event-label="${t}"]`,service:void 0}]),...e.updates.flatMap((e,t)=>e.note===void 0?[]:[{id:`update-${t}`,text:e.note,target:`[data-state-row="${e.service}.${e.key}"]`,service:e.service}]),...e.notes.map((e,t)=>({id:`service-${t}`,text:e.text,target:`[data-service-header="${e.service}"]`,service:e.service}))]:[],[S,e.events,e.updates,e.notes]),w=l===void 0?0:l.left+l.layout.width+m6,T=(0,R.useRef)(null),E=(0,R.useRef)(new Map),[D,O]=(0,R.useState)();(0,R.useLayoutEffect)(()=>{if(l===void 0||C.length===0)return;let e=a.current.getBoundingClientRect(),t=C.map(t=>{let n=T.current.querySelector(t.target).getBoundingClientRect(),r=t.service===void 0?void 0:l.layout.boxes.get(t.service),i=l.notesBelow?r===void 0?n.left-e.left+a.current.scrollLeft-10:l.left+r.x+r.width+10:r===void 0?n.right-e.left+a.current.scrollLeft:l.left+r.x+r.width;return{id:t.id,from:{x:i,y:n.top-e.top+n.height/2},height:E.current.get(t.id).offsetHeight}}).toSorted((e,t)=>e.from.y-t.from.y),n=new Map,r=l.notesBelow?l.layout.height+8:-1/0;for(let[e,i]of t.entries()){let t=l.notesBelow?r+8:Math.max(i.from.y-12,r+8);n.set(i.id,{top:t,from:i.from,n:e+1}),r=t+i.height}O({items:n,bottom:r})},[C,l]);let k=V(j6.note),A=V(j6.noteLines),j=V(j6.noteNumber),M=x===void 0?120:Math.max(x.height+16,C.length>0&&D!==void 0?D.bottom+4:0);return(0,z.jsxs)(`div`,{ref:a,className:h,style:{height:M},onScroll:e=>c(e.currentTarget.scrollLeft),tabIndex:l?.overflow?0:void 0,"data-diagram-scroll":l?.overflow||void 0,role:`region`,"aria-label":`Service diagram`,"aria-description":l?.overflow?`Scroll horizontally to see all services. Focus this diagram to scroll with arrow keys.`:void 0,children:[l?.overflow&&(0,z.jsx)(Kz,{size:`xs`,color:`lowContrast`,style:{position:`sticky`,left:0},children:`Scroll horizontally to see all services.`}),(0,z.jsxs)(`div`,{ref:o,className:g,"aria-hidden":`true`,inert:!0,children:[n.map(({service:t})=>(0,z.jsx)(`section`,{className:y,"data-measure-service":t.name,children:(0,z.jsx)(v6,{...e,service:t,values:{today:i.get(t.name),proposed:i.get(t.name)},previous:void 0,changed:new Set})},t.name)),t.steps.flatMap((e,t)=>e.events.map((e,n)=>(e.label!==``||e.note!==void 0)&&(0,z.jsx)(`div`,{className:b,"data-measure-event":`${t}:${n}`,children:o6(e)},`${t}:${n}`)))]}),x!==void 0&&(0,z.jsxs)(`div`,{ref:T,className:_,style:{left:l.left,width:x.width,height:x.height},children:[n.map(({service:t})=>{let n=x.boxes.get(t.name);return(0,z.jsx)(`section`,{className:y,"data-depth":m.get(t.name),"data-change":t.sign,"data-active":e.active.has(t.name),"aria-label":t.name,style:{left:n.x,top:n.y,width:n.width,height:n.height},children:(0,z.jsx)(v6,{...e,service:t,values:x6(e.state,t.name),previous:x6(e.previousState,t.name)})},t.name)}),(0,z.jsxs)(`svg`,{className:v,width:x.width,height:x.height,"aria-hidden":`true`,children:[(0,z.jsx)(`defs`,{children:C6.map(e=>(0,z.jsx)(`marker`,{id:`${f}-${e.id}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,z.jsx)(`path`,{d:`M0,1 L9,5 L0,9 z`,style:{fill:e.head}})},e.id))}),r.map(t=>{let n=E6(x,t,p),r=(t,n)=>e.events.filter(e=>e.from===t&&e.to===n),i=r(t.a,t.b),a=r(t.b,t.a),o=i.length>0||a.length>0,s=w6(o,o?S6([...i,...a]):t.sign),c=e=>`url(#${f}-${(e.length>0?s:w6(!1,t.sign)).id})`;return(0,z.jsx)(`path`,{d:O6(n),fill:`none`,markerEnd:t.forward?c(i):void 0,markerStart:t.backward?c(a):void 0,style:{stroke:s.line,strokeWidth:o?2:1,strokeDasharray:o?void 0:`4 4`}},t.id)})]}),e.events.map((t,n)=>{let i=c6(t.from,t.to),a=r.find(e=>e.id===i),o=E6(x,a,p),s=t.from===a.a?o:o.toReversed(),c=e.events.slice(0,n).filter(e=>c6(e.from,e.to)===i),u=x.labels.get(i),d=l.labels.get(t),f=c.reduce((e,t)=>{let n=l.labels.get(t);return e+(n===void 0?0:n.height+h6)},0);return(0,z.jsx)(_6,{...e,event:t,points:s,label:{x:(u?.x??0)+(u?.width??0)/2,y:(u?.y??0)+f},width:d?.width,index:n},`${e.stepKey}-${n}`)})]}),C.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`svg`,{className:A,"aria-hidden":`true`,children:C.map(t=>{let n=D?.items.get(t.id);if(n===void 0)return;let r=n.top+12;return l?.notesBelow?(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`circle`,{cx:n.from.x,cy:n.from.y,r:7}),(0,z.jsx)(`text`,{x:n.from.x,y:n.from.y,children:n.n})]},`${e.stepKey}-${t.id}`):(0,z.jsxs)(`g`,{children:[(0,z.jsx)(`circle`,{cx:n.from.x,cy:n.from.y,r:2.5}),(0,z.jsx)(`path`,{d:`M${n.from.x},${n.from.y} H${w-12} V${r} H${w}`,fill:`none`})]},`${e.stepKey}-${t.id}`)})}),C.map(t=>{let n=D?.items.get(t.id);return(0,z.jsxs)(`div`,{ref:e=>{e===null?E.current.delete(t.id):E.current.set(t.id,e)},className:k,"data-below":l?.notesBelow,style:{left:l?.notesBelow?0:w,transform:l?.notesBelow?`translateX(${s}px)`:void 0,top:n?.top??0,visibility:n===void 0?`hidden`:`visible`},children:[l?.notesBelow&&n!==void 0&&(0,z.jsx)(`span`,{className:j,children:n.n}),t.text]},`${e.stepKey}-${t.id}`)})]})]})}function _6(e){let t=V(j6.packet),n=V(j6.labelAnchor),r=V(j6.pill),i=e.event.annotation,a=e.event.label===``?void 0:o6(e.event),o=k6(e.points),s=o.at(-1)||1,c=e.phase===`travel`?e.index*750/1e3:0;return(0,z.jsxs)(z.Fragment,{children:[e.phase===`travel`&&(0,z.jsx)(Ow.div,{className:t,"data-change":e.event.sign,initial:{x:e.points[0].x,y:e.points[0].y,opacity:0},animate:{x:e.points.map(e=>e.x),y:e.points.map(e=>e.y),opacity:1},transition:{delay:c,duration:750/1e3,ease:`easeInOut`,times:o.map(e=>e/s),opacity:{delay:c,duration:0}}}),(a!==void 0||e.event.note!==void 0)&&(0,z.jsx)(Ow.div,{className:n,style:{left:e.label.x,top:e.label.y,width:e.width},"data-event-label":e.index,initial:{visibility:`hidden`},animate:{visibility:`visible`},transition:{delay:c,duration:0},children:a!==void 0&&(i===void 0?(0,z.jsx)(`div`,{className:r,"data-change":e.event.sign,children:a}):(0,z.jsx)(`button`,{type:`button`,className:r,"data-change":e.event.sign,"aria-pressed":e.selectedAnnotation===i,"aria-controls":`source-diff-panel`,"aria-label":`Open source: ${i.text}`,onClick:()=>e.onSelectAnnotation(i),children:a}))})]})}function v6(e){let t=e.service,n=V(j6.header),r=V(j6.header,j6.headerButton),i=V(j6.stateList),a=V(j6.stateRow),o=t.annotation,s=t.description!==void 0,c=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Kz,{size:`sm`,fontWeight:600,style:{whiteSpace:`nowrap`,textDecorationLine:t.sign===`-`?`line-through`:void 0},"data-described":s,children:[t.name,o!==void 0&&(0,z.jsx)(Kz,{size:`xs`,color:`accent`,"aria-hidden":`true`,children:` ↗`})]}),t.label!==void 0&&(0,z.jsx)(Kz,{size:`xs`,color:`lowContrast`,children:t.label})]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(y6,{description:t.description,children:o===void 0?(0,z.jsx)(`div`,{className:n,tabIndex:s?0:void 0,"data-service-header":t.name,children:c}):(0,z.jsx)(`button`,{type:`button`,className:r,"aria-pressed":e.selectedAnnotation===o,"aria-controls":`source-diff-panel`,"aria-label":`Open source: ${t.name}`,"data-service-header":t.name,onClick:()=>e.onSelectAnnotation(o),children:c})}),t.state.length>0&&(0,z.jsx)(`dl`,{className:i,style:{"--key-width":`${Math.max(...t.state.map(({key:e})=>e.length))}ch`},children:t.state.map(({key:n,description:r,sign:i})=>{let o=e.changed.has(`${t.name}.${n}`),s=i===`-`?`today`:`proposed`,c=e.values.today.get(n),l=e.values.proposed.get(n);return(0,z.jsxs)(`div`,{className:a,"data-changed":o,"data-change":i,"data-state-row":`${t.name}.${n}`,children:[(0,z.jsx)(y6,{description:r,children:(0,z.jsx)(`dt`,{tabIndex:r===void 0?void 0:0,"data-described":r!==void 0,children:n})}),(0,z.jsx)(`dd`,{children:i===` `&&c!==l?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Kz,{size:`xs`,monospace:!0,style:{color:G.red[11]},children:[(0,z.jsx)(`s`,{children:c}),` `]}),(0,z.jsx)(Kz,{size:`xs`,monospace:!0,style:{color:G.green[11]},children:l})]}):(0,z.jsxs)(z.Fragment,{children:[o&&(0,z.jsxs)(Kz,{size:`xs`,monospace:!0,color:`lowContrast`,children:[(0,z.jsx)(`s`,{children:e.previous?.[s].get(n)}),` `]}),(0,z.jsx)(Kz,{size:`xs`,monospace:!0,color:o?`accent`:void 0,children:e.values[s].get(n)})]})})]},n)})})]})}function y6(e){return e.description===void 0?e.children:(0,z.jsx)(EV,{content:e.description,placement:`top`,children:e.children})}function b6(e){let t=i6(e.services),n=new Map(t.map(({service:e})=>[e.name,new Map])),r=t=>({today:a6(e,t,`today`),proposed:a6(e,t,`proposed`)}),i=r(0);for(let a=0;a<=e.steps.length;a++){let o=a===0?i:r(a),s=new Set(e.steps[a-1]?.updates.map(e=>`${e.service}.${e.key}`));for(let{service:e}of t)for(let{key:t}of e.state){let r=n.get(e.name),a=n=>n.get(e.name).get(t),c=a(o.today),l=a(o.proposed),u=[c===void 0||l===void 0||c===l?l??c??``:`${c} ${l}`];s.has(`${e.name}.${t}`)&&u.push(`${a(i.today)??``} ${c??``}`,`${a(i.proposed)??``} ${l??``}`);for(let e of u)e.length>(r.get(t)?.length??-1)&&r.set(t,e)}i=o}return n}function x6(e,t){return{today:e.today.get(t),proposed:e.proposed.get(t)}}function S6(e){return e.every(t=>t.sign===e[0].sign)?e[0].sign:` `}var C6=[`idle`,`active`].flatMap(e=>[`+`,`-`,` `].map(t=>{let n=t===`+`?G.green:t===`-`?G.red:void 0,r=e===`active`?n?.[9]??G.accent[9]:n?.[9]??G.gray[9];return{id:`${e}-${{"+":`added`,"-":`removed`," ":`same`}[t]}`,state:e,sign:t,line:r,head:r}}));function w6(e,t){return C6.find(n=>n.sign===t&&n.state===`active`===e)}function T6(e,t,n){for(let r=e.get(n);r!==void 0;r=e.get(r))if(r===t)return!0;return!1}function E6(e,t,n){let r=e.routes.get(t.id);if(!T6(n,t.a,t.b))return r;let i=e.boxes.get(t.a).y+e.sizes.get(t.a).height,[a,o]=r;return o===void 0||a.x!==o.x||o.y<=i?r:[{x:a.x,y:i},...r.slice(1)]}function D6(e){let t=e.getBoundingClientRect();return{width:Math.ceil(t.width),height:Math.ceil(t.height)}}function O6(e){return e.map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `)}function k6(e){let t=0;return e.map((n,r)=>{let i=e[r-1];return i!==void 0&&(t+=Math.hypot(n.x-i.x,n.y-i.y)),t})}var A6={"&[data-described='true']":{textDecorationLine:`underline`,textDecorationStyle:`dotted`,textDecorationColor:G.gray[8],textUnderlineOffset:`3px`}},j6={stage:B({position:`relative`,minWidth:0,overflowX:`auto`,overflowY:`hidden`},Ud()),measureLayer:B({position:`absolute`,width:0,height:0,overflow:`hidden`,visibility:`hidden`,"& > [data-measure-service]":{position:`absolute`,width:`max-content`,minWidth:120,maxWidth:240},"& > [data-measure-event]":{position:`absolute`,width:`max-content`,maxWidth:`var(--label-width)`}}),canvas:B({position:`absolute`,top:0}),noteLines:B({position:`absolute`,inset:0,width:`100%`,height:`100%`,overflow:`visible`,pointerEvents:`none`,zIndex:3,"& path":{stroke:G.accent[7],strokeWidth:1},"& circle":{fill:G.gray[12]},"& text":{fill:K.app,fontSize:9,fontWeight:600,textAnchor:`middle`,dominantBaseline:`central`}}),noteNumber:B({position:`absolute`,top:4,left:4,display:`flex`,alignItems:`center`,justifyContent:`center`,width:14,height:14,borderRadius:`50%`,fontSize:9,fontWeight:600,color:K.app,backgroundColor:G.gray[12]}),overlay:B({position:`absolute`,inset:0,overflow:`visible`,pointerEvents:`none`}),box:B(Fd.md,{position:`absolute`,display:`flex`,flexDirection:`column`,border:`1px solid ${G.gray[6]}`,backgroundColor:K.element,"&[data-depth='1'], &[data-depth='3']":{backgroundColor:G.gray[2]},"&[data-change='+']":{borderColor:G.green[8],backgroundColor:G.green[2]},"&[data-change='-']":{borderColor:G.red[8],borderStyle:`dashed`,backgroundColor:G.red[2]},"&[data-active='true']":{borderColor:G.accent[8]},"&[data-active='true'][data-change='+']":{borderColor:G.green[10]},"&[data-active='true'][data-change='-']":{borderColor:G.red[10]}}),header:B(Yd({direction:`row`,alignItems:`baseline`,gap:3,wrap:!0}),Y.padding({x:4,y:3}),Ud(),{minWidth:0,"& > [data-described='true']":A6[`&[data-described='true']`]}),headerButton:B({width:`100%`,border:0,background:`transparent`,font:`inherit`,color:`inherit`,textAlign:`start`,cursor:`pointer`,borderRadius:`inherit`,"&:hover":{backgroundColor:K.elementHover},"&[aria-pressed='true']":{backgroundColor:G.blue[3]}}),stateList:B(J({size:`xs`,monospace:!0}),{margin:0,paddingInline:Y.value(4),paddingBottom:Y.value(3),"& dt":{flex:`none`,minWidth:`min(var(--key-width), 100%)`,color:G.gray[11]},"& dt[data-described='true']":A6[`&[data-described='true']`],"& dt:focus-visible":{outline:`2px solid ${G.blueAlpha[8]}`},"& dd":{flex:`1 1 auto`,margin:0,minWidth:0,overflowWrap:`anywhere`}}),stateRow:B(Fd.xs,{display:`flex`,flexWrap:`wrap`,alignItems:`baseline`,columnGap:Y.value(4),paddingInline:Y.value(2),marginInline:`-${Y.value(2)}`,"&[data-change='+']":{backgroundColor:G.greenAlpha[3],boxShadow:`inset 2px 0 ${G.green[9]}`},"&[data-change='-']":{backgroundColor:G.redAlpha[3],boxShadow:`inset 2px 0 ${G.red[9]}`},"&[data-changed='true']":{backgroundColor:G.accentAlpha[3]}}),packet:B(Fd.circle,{position:`absolute`,top:-6,left:-6,width:12,height:12,backgroundColor:G.accent[9],boxShadow:`0 0 0 3px ${G.accentAlpha[5]}`,pointerEvents:`none`,zIndex:2,"&[data-change='+']":{backgroundColor:G.green[9],boxShadow:`0 0 0 3px ${G.greenAlpha[5]}`},"&[data-change='-']":{backgroundColor:G.red[9],boxShadow:`0 0 0 3px ${G.redAlpha[5]}`}}),labelAnchor:B({position:`absolute`,zIndex:1,transform:`translateX(-50%)`}),pill:B(Fd.sm,J({size:`xs`,monospace:!0}),Y.padding({x:3}),{display:`block`,paddingBlock:0,maxWidth:220,whiteSpace:`normal`,overflowWrap:`anywhere`,textAlign:`start`,border:`1px solid ${G.accent[7]}`,backgroundColor:K.app,color:G.gray[12],"&[data-change='+']":{borderColor:G.green[7],color:G.green[11]},"&[data-change='-']":{borderColor:G.red[7],borderStyle:`dashed`,color:G.red[11]},"&:is(button)":{cursor:`pointer`},"&:is(button):hover":{backgroundColor:G.accent[3]},"&[aria-pressed='true']":{backgroundColor:G.blue[3]}},Ud()),note:B(J({size:`xs`}),Fd.sm,Y.padding({x:4,y:2}),{position:`absolute`,width:`max-content`,maxWidth:p6,overflowWrap:`anywhere`,border:`1px solid ${G.accent[7]}`,backgroundColor:K.app,"&[data-below='true']":{right:0,marginInline:`auto`,maxWidth:`min(100%, 420px)`,paddingLeft:24}})},M6=1200,N6={"+":`Added: `,"-":`Removed: `," ":``};function P6(e){let t=V(L6.error);return e.parsed.ok?(0,z.jsx)(F6,{...e,diagram:e.parsed.diagram},e.source):(0,z.jsxs)(`div`,{className:t,"data-diffmap-kind":`services`,children:[`Line `,e.parsed.line,`: `,e.parsed.reason]})}function F6(e){let t=e.diagram,n=t.steps.length,r=!!iw(),[i,a]=(0,R.useState)({step:0,phase:`settled`}),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>Array.from({length:n+1},(e,n)=>({today:a6(t,n,`today`),proposed:a6(t,n,`proposed`)})),[t,n]),l=i.step,u=l===0?void 0:t.steps[l-1],d=u??t.start,f=i.phase===`settled`,p=c[f?l:l-1],m=new Set(f&&u!==void 0?u.updates.map(e=>`${e.service}.${e.key}`):[]),h=new Set(u?.events.flatMap(e=>[e.from,e.to])??[]),g=(e,n)=>a(I6(t,e,n&&!r));(0,R.useEffect)(()=>{if(i.phase!==`travel`)return;let e=setTimeout(()=>a({step:i.step,phase:`settled`}),750*(t.steps[i.step-1]?.events.length??1));return()=>clearTimeout(e)},[i,t]),(0,R.useEffect)(()=>{if(!o||i.phase!==`settled`)return;let e=setTimeout(()=>{i.step>=n?s(!1):a(I6(t,i.step+1,!r))},i.step===0?300:M6);return()=>clearTimeout(e)},[o,i,n,t,r]);let _=()=>{s(!1),l>0&&g(l-1,!1)},v=()=>{s(!1),l<n&&g(l+1,!0)},y=()=>{if(o)return s(!1);l>=n&&g(0,!1),s(!0),U0({event:`diagram_used`,action:`play`})},b=e=>{e.target instanceof HTMLElement&&e.target.hasAttribute(`data-diagram-scroll`)||(e.key===`ArrowLeft`&&(e.preventDefault(),_()),e.key===`ArrowRight`&&(e.preventDefault(),v()))},x=V(LG,L6.frame),S=V(L6.body),C=V(L6.controls),w=V(L6.scrubber),T=V(L6.segment),E=V(RG),D=V(L6.detail),O=V(L6.counter);return(0,z.jsxs)(`figure`,{className:x,"data-diffmap-kind":`services`,onKeyDownCapture:b,children:[t.start!==void 0&&(0,z.jsx)(`figcaption`,{className:E,children:t.start.caption}),(0,z.jsxs)(`div`,{className:S,children:[(d!==void 0||n>0)&&(0,z.jsx)(`div`,{className:D,"aria-live":`polite`,children:u===void 0?t.start?.description!==void 0&&(0,z.jsx)(Kz,{size:`sm`,children:t.start.description}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Kz,{size:`sm`,children:[u.sign!==` `&&(0,z.jsx)(Kz,{size:`sm`,fontWeight:600,style:{color:u.sign===`+`?G.green[11]:G.red[11]},children:N6[u.sign]}),u.caption]}),u.description!==void 0&&(0,z.jsx)(Kz,{size:`xs`,color:`lowContrast`,children:u.description})]})}),n>0&&(0,z.jsxs)(`div`,{className:C,children:[(0,z.jsx)(EV,{content:`Restart`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Restart`,isDisabled:l===0&&!o,onClick:()=>{s(!1),g(0,!1)},children:(0,z.jsx)(EB,{size:`xs`})})}),(0,z.jsx)(EV,{content:`Previous step (←)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Previous step`,isDisabled:l===0,onClick:_,children:(0,z.jsx)(sB,{size:`xs`})})}),(0,z.jsxs)(Vz,{size:`sm`,"aria-label":o?`Pause`:`Play`,onClick:y,children:[o?(0,z.jsx)(xB,{size:`xs`}):(0,z.jsx)(CB,{size:`xs`}),o?`Pause`:l>=n?`Replay`:`Play`]}),(0,z.jsx)(EV,{content:`Next step (→)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Next step`,isDisabled:l>=n,onClick:v,children:(0,z.jsx)(cB,{size:`xs`})})}),(0,z.jsx)(`div`,{className:w,role:`group`,"aria-label":`Steps`,children:t.steps.map((e,t)=>(0,z.jsx)(EV,{placement:`top`,content:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`strong`,{children:[t+1,`. `,e.caption]}),e.description!==void 0&&(0,z.jsxs)(z.Fragment,{children:[` `,e.description]})]}),children:(0,z.jsx)(`button`,{type:`button`,className:T,"data-change":e.sign,"data-state":t+1===l?`current`:t+1<l?`done`:`todo`,"aria-label":`Step ${t+1}: ${N6[e.sign]}${e.caption}`,"aria-current":t+1===l?`step`:void 0,onClick:()=>{s(!1),g(t+1,t+1===l+1)}})},t))}),(0,z.jsxs)(Kz,{className:O,size:`xs`,color:`lowContrast`,tabular:!0,children:[l,` / `,n]})]}),(0,z.jsx)(g6,{...e,state:p,previousState:c[Math.max(l-1,0)],changed:m,active:h,events:u?.events??[],updates:u?.updates??[],notes:u?.notes??[],phase:i.phase,stepKey:l})]})]})}function I6(e,t,n){let r=e.steps[t-1]?.events.length??0;return{step:t,phase:n&&r>0?`travel`:`settled`}}var L6={error:B(J({size:`sm`,color:`lowContrast`})),frame:B({width:`100%`,margin:0}),body:B(Yd({direction:`column`,gap:4}),Y.padding({all:6})),controls:B(Yd({direction:`row`,alignItems:`center`,gap:2}),{"& > button":{flexShrink:0,overflow:`visible`}}),scrubber:B(Yd({direction:`row`,alignItems:`center`,gap:1}),{flex:`1 1 auto`,minWidth:0,marginInline:Y.value(4)}),segment:B(Fd.pill,{flex:`1 1 0`,minWidth:6,height:20,padding:0,border:0,cursor:`pointer`,background:`transparent`,position:`relative`,"&::after":{content:`''`,position:`absolute`,insetInline:0,top:8,height:4,borderRadius:2,backgroundColor:G.gray[5]},"&:hover::after":{backgroundColor:G.gray[7]},"&[data-state='done']::after":{backgroundColor:G.accent[7]},"&[data-state='current']::after":{backgroundColor:G.accent[9]},"&[data-change='+']::after":{backgroundColor:G.green[6]},"&[data-change='+'][data-state='done']::after":{backgroundColor:G.green[8]},"&[data-change='+'][data-state='current']::after":{backgroundColor:G.green[10]},"&[data-change='-']::after":{backgroundColor:G.red[6]},"&[data-change='-'][data-state='done']::after":{backgroundColor:G.red[8]},"&[data-change='-'][data-state='current']::after":{backgroundColor:G.red[10]}},Ud()),counter:B({flexShrink:0,minWidth:`5ch`,textAlign:`end`}),detail:B(Yd({direction:`column`,gap:2}),{minHeight:44})};function R6(e){let t=e.fence,n=j4()===`local`;return t.kind===`mermaid`?(0,z.jsx)(h3,{svg:t.svg,annotations:t.annotations,title:t.title,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`services`?(0,z.jsx)(P6,{source:t.source,parsed:t.parsed,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`html`?n?(0,z.jsx)($4,{source:t.source}):(0,z.jsx)(t3,{}):t.kind===`changes`?(0,z.jsx)(i2,{rev:t.rev,review:t.review,ignore:t.ignore,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`callstack`?(0,z.jsx)(X0,{lines:t.lines,highlights:t.highlights,notes:t.notes,title:t.title,selectedAnnotation:e.selectedAnnotation,onSelectAnnotation:e.onSelectAnnotation}):t.kind===`preview`?(0,z.jsx)(R3,{stories:t.stories,title:t.title}):t.kind===`flow`?(0,z.jsx)($3,{states:t.states,title:t.title}):t.kind===`diff`?(0,z.jsx)(k4,{source:t.source,path:t.path}):t.kind===`file`?(0,z.jsx)(X4,{path:t.path,start:t.start,end:t.end,fallback:t.source}):(0,z.jsx)(G0,{lang:t.lang,source:t.source,highlights:t.highlights,notes:t.notes,title:t.title})}function z6(e){return/\.(?:mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(e)}function B6(e){return!/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)}var V6=(0,R.createContext)(e=>e);function H6(e){return`/__diffmap/media?${new URLSearchParams({path:e}).toString()}`}function U6(e){return e.alt||e.title||(z6(e.src)?`Video`:`Image`)}function W6({videoRef:e,onLoadedMetadata:t,...n}){let r=(0,R.useContext)(V6),i=B6(n.src)?r(n.src):n.src,a=V(Q6.media),o=n.className??a;return z6(n.src)?(0,z.jsx)(`video`,{ref:e,className:o,src:i,title:n.title,"aria-label":n.alt,controls:!0,playsInline:!0,preload:`metadata`,onLoadedMetadata:t}):(0,z.jsx)(`img`,{className:o,src:i,alt:n.alt,title:n.title})}function G6(e){return(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Full screen: ${U6(e.media)}`,onClick:e.onClick,children:(0,z.jsx)(yB,{size:`xs`})})}function K6(){let[e,t]=(0,R.useState)(),[n,r]=(0,R.useState)(!1),i=(0,R.useRef)(null),a=(0,R.useRef)(!1),o=V(Q6.dialog),s=V(Q6.dialogHeader),c=V(Q6.expandedMedia),l=(e,t)=>{t.currentTime=e.currentTime,t.volume=e.volume,t.muted=e.muted,t.playbackRate=e.playbackRate,a.current&&t.play().catch(()=>{})},u=(e,n)=>{a.current=!(!n||n.paused||n.ended),n?.pause(),t({media:e,video:n}),r(!0)},d=()=>{let t=i.current,n=e?.video;t&&n&&(t.readyState===0?a.current&&n.play().catch(()=>{}):(a.current=!t.paused&&!t.ended,t.pause(),l(t,n))),r(!1)};return{open:u,dialog:(0,z.jsxs)(wV,{isOpen:n,onOpenChange:e=>{e||d()},size:`lg`,"aria-label":e?U6(e.media):`Media`,className:o,children:[(0,z.jsxs)(`div`,{className:s,children:[(0,z.jsx)(Kz,{size:`xs`,fontWeight:500,color:`lowContrast`,children:e&&U6(e.media)}),(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,slot:`close`,"aria-label":`Exit full screen`,children:(0,z.jsx)(Yz,{size:`xs`})})]}),e&&(0,z.jsx)(W6,{...e.media,className:c,videoRef:i,onLoadedMetadata:t=>{n&&e.video&&l(e.video,t.currentTarget)}},e.media.src)]})}}function q6(e){let t=V(Q6.mediaShell),n=V(Q6.expand),r=(0,R.useRef)(null),i=K6();return(0,z.jsxs)(`span`,{className:t,children:[(0,z.jsx)(W6,{...e,videoRef:r}),(0,z.jsx)(`span`,{className:n,children:(0,z.jsx)(G6,{media:e,onClick:()=>i.open(e,r.current)})}),i.dialog]})}function J6(e){let t=V(LG,Q6.frame),n=V(RG,Q6.cardHeader),r=V(Q6.cardMedia),i=(0,R.useRef)(null),a=K6(),o={src:e.item.attrs.src??``,alt:e.item.attrs.alt,title:e.item.attrs.title};return(0,z.jsxs)(`figure`,{className:t,"data-diffmap-kind":`media`,children:[(0,z.jsxs)(`figcaption`,{className:n,children:[(0,z.jsx)(Kz,{size:`xs`,fontWeight:500,color:`lowContrast`,style:{marginRight:`auto`},children:o.alt}),(0,z.jsx)(G6,{media:o,onClick:()=>a.open(o,i.current)})]}),(0,z.jsx)(W6,{...o,className:r,videoRef:i}),a.dialog]})}function Y6(e){let t=e.node.children.flatMap(e=>e.type===`element`?[e]:[]),n=e.node.attrs.layout;return n===`carousel`?(0,z.jsx)(Z6,{items:t,title:e.node.attrs.title}):(0,z.jsx)(X6,{items:t,columns:n===`side-by-side`?t.length:void 0})}function X6(e){let t=V(Q6.grid);return(0,z.jsx)(`div`,{className:t,"data-diffmap-kind":`gallery`,style:{gridTemplateColumns:e.columns===void 0?`repeat(auto-fill, minmax(min(240px, 100%), 1fr))`:`repeat(${e.columns}, minmax(0, 1fr))`},children:e.items.map((e,t)=>(0,z.jsx)(J6,{item:e},t))})}function Z6(e){let[t,n]=(0,R.useState)(0),r=e.items.length-1,i=e.items[t],a=V(LG,Q6.frame),o=V(RG,Q6.cardHeader),s=V(Q6.description),c=V(Q6.stack),l=V(Q6.slide),u=V(Q6.cardMedia),d=(0,R.useRef)(null),f=K6(),p={src:i.attrs.src??``,alt:i.attrs.alt,title:i.attrs.title},m=e=>{for(let e of d.current?.querySelectorAll(`video`)??[])e.pause();n(e)};return(0,z.jsxs)(`figure`,{className:a,"data-diffmap-kind":`gallery`,"aria-roledescription":`carousel`,"aria-label":e.title,onKeyDownCapture:e=>{e.target instanceof Element&&e.target.closest(`video, [role='dialog']`)||(e.key===`ArrowLeft`&&t>0&&(e.preventDefault(),m(t-1)),e.key===`ArrowRight`&&t<r&&(e.preventDefault(),m(t+1)))},children:[(0,z.jsxs)(`figcaption`,{className:o,children:[(0,z.jsx)(`span`,{children:e.title}),(0,z.jsxs)(`span`,{style:{marginLeft:`auto`},children:[t+1,` / `,r+1]}),(0,z.jsx)(EV,{content:`Previous (←)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Previous`,isDisabled:t===0,onClick:()=>m(t-1),children:(0,z.jsx)(sB,{size:`xs`})})}),(0,z.jsx)(EV,{content:`Next (→)`,placement:`top`,children:(0,z.jsx)(Vz,{size:`sm`,variant:`quiet`,"aria-label":`Next`,isDisabled:t===r,onClick:()=>m(t+1),children:(0,z.jsx)(cB,{size:`xs`})})}),(0,z.jsx)(G6,{media:p,onClick:()=>f.open(p,d.current?.querySelector(`[data-current='true'] video`))})]}),(0,z.jsx)(`div`,{className:s,"aria-live":`polite`,children:i.attrs.alt}),(0,z.jsx)(`div`,{ref:d,className:c,children:e.items.map((e,n)=>(0,z.jsx)(`div`,{className:l,"data-current":n===t,"aria-hidden":n!==t,inert:n!==t,children:(0,z.jsx)(W6,{src:e.attrs.src??``,alt:e.attrs.alt,title:e.attrs.title,className:u})},n))}),f.dialog]})}var Q6={mediaShell:B({position:`relative`,display:`inline-block`,maxWidth:`100%`,verticalAlign:`middle`}),expand:B(Fd.sm,{display:`inline-flex`,position:`absolute`,top:`6px`,right:`6px`,backgroundColor:K.element}),dialog:B({width:`calc(100vw - 32px)`,height:`calc(100dvh - 32px)`,padding:Y.value(6),"& > [role='dialog']":{flex:1,minHeight:0,gap:Y.value(2)}}),dialogHeader:B({display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:Y.value(4)}),expandedMedia:B({display:`block`,flex:1,minHeight:0,minWidth:0,width:`100%`,height:`100%`,objectFit:`contain`}),media:B(Fd.sm,{maxWidth:`100%`,height:`auto`,verticalAlign:`middle`}),frame:B({width:`100%`,margin:0}),cardMedia:B({display:`block`,maxWidth:`100%`,maxHeight:`min(70vh, 640px)`,marginInline:`auto`,objectFit:`contain`}),grid:B({display:`grid`,gap:Y.value(6),alignItems:`start`}),cardHeader:B(Yd({direction:`row`,alignItems:`center`,gap:1}),{contain:`inline-size`,"& button":{marginBlock:-3}}),description:B(J({size:`sm`}),Y.padding({x:6,y:3}),Md([`bottom`],`border`),{minHeight:`1lh`,boxSizing:`content-box`}),stack:B({display:`grid`}),slide:B({gridArea:`1 / 1`,display:`flex`,alignItems:`center`,"&[data-current='false']":{visibility:`hidden`}})},$6=new Set([`hr`,`br`]);function e8(e){let t=j4()===`local`;return(0,z.jsx)(z.Fragment,{children:e.document.nodes.map((n,r)=>t8(n,r,e,t))})}function t8(e,t,n,r){return e.type===`text`?e.value:e.type===`html`?r?e.block?(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:e.source}},t):(0,z.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.source}},t):(0,z.jsx)(t3,{inline:e.block!==!0},t):e.type===`view`?(0,z.jsx)(R6,{fence:e.fence,...n},t):e.type===`reference`?(0,z.jsx)(s8,{annotation:e.annotation,...n},t):n8(e,t,n,r)}function n8(e,t,n,r){if(e.tag===`table`)return o8(e,t,n,r);let i=e.children.map((e,t)=>t8(e,t,n,r));if(e.tag===`alert`)return(0,z.jsx)(`blockquote`,{"data-alert":e.attrs.alertType,children:i},t);if(e.tag===`details`)return(0,z.jsx)(c8,{summary:e.attrs.summary??`Details`,children:i},t);if(e.tag===`badge`)return(0,z.jsx)(_f,{children:i},t);if(e.tag===`gallery`)return(0,z.jsx)(Y6,{node:e},t);let a=r8(e);return a===void 0?e.tag===`img`?(0,z.jsx)(q6,{src:e.attrs.src??``,alt:e.attrs.alt,title:e.attrs.title},t):e.tag===`li`&&e.attrs.task===!0?(0,z.jsx)(l8,{node:e,children:i},t):e.tag===`code`?(0,z.jsx)(qB,{...d8(e),style:{whiteSpace:`normal`,overflowWrap:`anywhere`},children:i},t):e.tag===`a`?(0,z.jsx)(xG,{href:e.attrs.href,title:e.attrs.title,className:e.attrs.className,id:e.attrs.id,children:i},t):$6.has(e.tag)?(0,R.createElement)(e.tag,{key:t,...d8(e)}):(0,R.createElement)(e.tag,{key:t,...d8(e)},i):a.map((e,n)=>(0,z.jsx)(J6,{item:e},`${t}-${n}`))}function r8(e){if(e.tag!==`p`)return;let t=e.children.filter(e=>e.type!==`text`||e.value.trim()!==``);if(t.length!==0&&t.every(e=>e.type===`element`&&e.tag===`img`))return t}function i8(e,t){return e.children.filter(e=>e.type===`element`&&e.tag===t)}function a8(e){if(e.attrs.align===`left`)return`start`;if(e.attrs.align===`right`)return`end`;if(e.attrs.align===`center`)return`center`}function o8(e,t,n,r){let i=i8(e,`thead`).flatMap(e=>i8(e,`tr`)).flatMap(e=>i8(e,`th`)),a=i8(e,`tbody`).flatMap(e=>i8(e,`tr`));return(0,z.jsxs)(dH,{"aria-label":i.map(u8).join(`, `),children:[(0,z.jsx)(fH,{children:i.map((e,t)=>(0,z.jsx)(pH,{id:`column-${t}`,isRowHeader:t===0,align:a8(e),children:e.children.map((e,t)=>t8(e,t,n,r))},t))}),(0,z.jsx)(mH,{children:a.map((e,t)=>(0,z.jsx)(hH,{id:`row-${t}`,textValue:u8(e),children:i8(e,`td`).map((e,t)=>(0,z.jsx)(gH,{align:a8(e),children:e.children.map((e,t)=>t8(e,t,n,r))},t))},t))})]},t)}function s8(e){let t=V(f8);return(0,z.jsx)(`button`,{type:`button`,className:t,"aria-pressed":e.selectedAnnotation===e.annotation,"aria-controls":`source-diff-panel`,title:e.annotation.text,onClick:()=>e.onSelectAnnotation(e.annotation),children:(0,z.jsx)(qB,{children:e.annotation.text})})}function c8(e){let t=V(m8),n=V(p8);return(0,z.jsxs)(`details`,{className:t,children:[(0,z.jsx)(`summary`,{className:n,children:e.summary}),(0,z.jsx)(`div`,{className:`diffmap-details-content`,children:e.children})]})}function l8(e){let[t,n]=(0,R.useState)(e.node.attrs.checked===!0),r=V(h8);return(0,z.jsxs)(`li`,{id:e.node.attrs.id,className:[r,e.node.attrs.className].filter(Boolean).join(` `),"data-task":``,children:[(0,z.jsx)(`span`,{className:`diffmap-task-checkbox`,children:(0,z.jsx)(WB,{label:u8(e.node),checked:t,setChecked:n})}),(0,z.jsx)(`div`,{className:`diffmap-task-content`,children:e.children})]})}function u8(e){return e.type===`text`?e.value:e.type===`reference`?e.annotation.text:e.type===`element`?e.children.map(u8).join(``):``}function d8(e){return{id:e.attrs.id,href:e.attrs.href,src:e.attrs.src,alt:e.attrs.alt,title:e.attrs.title,className:e.attrs.className,start:e.attrs.start}}var f8=B(Fd.sm,{display:`inline`,padding:0,border:0,font:`inherit`,color:`inherit`,background:`transparent`,cursor:`pointer`,"& > code":{color:G.blue[11]},"&:hover > code":{backgroundColor:G.blue[3]},"&[aria-pressed='true'] > code":{backgroundColor:G.blue[4],color:G.blue[12]}},Ud()),p8=B(Fd.sm,Ud(),{cursor:`pointer`,width:`fit-content`,fontWeight:500}),m8=B({"& > .diffmap-details-content":{display:`flex`,flexDirection:`column`,gap:Y.value(8),marginTop:Y.value(6)}}),h8=B({display:`grid`,gridTemplateColumns:`auto minmax(0, 1fr)`,alignItems:`start`,columnGap:Y.value(3),"& > .diffmap-task-checkbox":{display:`flex`,alignItems:`center`,minHeight:`1lh`},"& > .diffmap-task-content":{minWidth:0},"& .diffmap-task-checkbox label > span:last-child":{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0}}),g8=4;function _8(e,t){if(e.contents===void 0){let t=e.patch===void 0?void 0:SZ(e.patch,void 0,!1)[0]?.files[0];return t===void 0?void 0:{id:e.path,type:`diff`,fileDiff:t}}let{old:n,new:r}=e.contents,i=t=>wQ(n===void 0?null:{name:e.prevPath??e.path,contents:n},r===void 0?null:{name:e.path,contents:r},{context:t}),a=g8,o=i(a),s=r===void 0?0:r.split(`
256
256
  `).length;if(t!==void 0)for(;a<s&&!v8(o.hunks,t);)a*=4,o=i(a);return{id:e.path,type:`diff`,fileDiff:o,...a===g8?{}:{version:a}}}function v8(e,t){for(let n=t.start;n<=t.end;n++)if(!e.some(e=>n>=e.additionStart&&n<e.additionStart+e.additionCount))return!1;return!0}var y8=(0,R.createContext)(void 0);function b8(){return(0,R.useContext)(y8)}var x8=28;function S8(e){let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(),[a,o]=(0,R.useState)(),s=(0,R.useRef)(null),c=(0,R.useRef)(null),l=(0,R.useRef)(null),[u,d]=(0,R.useState)({top:0,left:0}),f=V(w8.trigger),p=V(w8.float),m=V(w8.item),h=V(w8.row),g=V(w8.handle),_=V(w8.foot),v=()=>{t2(e.rev).then(i)};(0,R.useEffect)(()=>{t2(e.rev).then(i)},[e.rev]),(0,R.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.target;c.current?.contains(t)||s.current?.contains(t)||n(!1)},r=e=>{e.key===`Escape`&&(n(!1),s.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,r)}},[t]);let y=r instanceof Error?void 0:r,b=y===void 0?void 0:aG(y,e.rev),x=a??b,S=y!==void 0&&x!==void 0?sG(y,x):nG(e.rev).replace(`..`,`…`),C=b?.newest;(0,R.useEffect)(()=>{t&&C!==void 0&&l.current?.children[C]?.scrollIntoView({block:`center`})},[t,C]);let w=t=>{o(void 0),y!==void 0&&e.onChange(rG(y,t))},T=e=>Math.round((e.clientY-l.current.getBoundingClientRect().top)/x8),E=(e,t)=>{if(y===void 0||x===void 0)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let n=x,r=n,i=e.currentTarget,a=e=>{let i=T(e);r=t===`newest`?{...n,newest:Math.max(0,Math.min(i,n.oldest))}:{...n,oldest:Math.min(y.length-1,Math.max(i-1,n.newest))},o(r)},s=()=>{i.removeEventListener(`pointermove`,a),i.removeEventListener(`pointerup`,s),i.removeEventListener(`pointercancel`,s),w(r)};i.addEventListener(`pointermove`,a),i.addEventListener(`pointerup`,s),i.addEventListener(`pointercancel`,s)},D=(e,t)=>{if(y===void 0||e.button!==0)return;e.preventDefault();let n=l.current;n.setPointerCapture(e.pointerId);let r={newest:t,oldest:t};o(r);let i=e=>{let i=Math.max(0,Math.min(y.length-1,Math.floor((e.clientY-n.getBoundingClientRect().top)/x8)));r={newest:Math.min(t,i),oldest:Math.max(t,i)},o(r)},a=()=>{n.removeEventListener(`pointermove`,i),n.removeEventListener(`pointerup`,a),n.removeEventListener(`pointercancel`,a),w(r)};n.addEventListener(`pointermove`,i),n.addEventListener(`pointerup`,a),n.addEventListener(`pointercancel`,a)},O=(e,t)=>{y!==void 0&&x!==void 0&&w(e===`newest`?{...x,newest:Math.max(0,Math.min(x.oldest,x.newest+t))}:{...x,oldest:Math.min(y.length-1,Math.max(x.newest,x.oldest+t))})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Vz,{ref:s,className:f,variant:`quiet`,"aria-haspopup":`dialog`,"aria-expanded":t,onClick:()=>{let e=s.current.getBoundingClientRect(),r=s.current.querySelector(`svg`).getBoundingClientRect();d({top:e.bottom+4,left:r.left-C8}),t||v(),n(!t)},children:[(0,z.jsx)(gB,{size:`sm`}),(0,z.jsx)(`span`,{children:S}),(0,z.jsx)(oB,{size:`sm`})]}),t&&(0,hD.createPortal)((0,z.jsx)(`div`,{ref:c,className:p,role:`dialog`,"aria-label":`Pick changes`,style:u,children:r instanceof Error?(0,z.jsx)(`div`,{className:_,children:r.message}):y===void 0?(0,z.jsx)(`div`,{className:_,children:`Loading changes…`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:m,"data-selected":x?.newest===0&&x.oldest===y.length-1,onClick:()=>w({newest:0,oldest:y.length-1}),children:[(0,z.jsx)(gB,{size:`sm`}),(0,z.jsx)(`span`,{children:`All commits`}),x?.newest===0&&x.oldest===y.length-1&&(0,z.jsx)(aB,{size:`sm`})]}),(0,z.jsx)(`div`,{className:`scroll`,children:(0,z.jsxs)(`div`,{ref:l,className:`rows`,children:[y.map((e,t)=>{let n=x!==void 0&&t>=x.newest&&t<=x.oldest;return(0,z.jsxs)(`button`,{type:`button`,className:h,"data-inside":n,"data-kind":e.kind,"data-first":t===0,"data-last":t===y.length-1,title:e.kind===`commit`?`${e.sha.slice(0,7)} ${e.subject}`:void 0,onPointerDown:e=>D(e,t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w({newest:t,oldest:t}))},children:[(0,z.jsx)(`span`,{className:`rail`,"aria-hidden":`true`,children:(0,z.jsx)(`span`,{className:`dot`})}),e.kind===`commit`?(0,z.jsxs)(`span`,{className:`label`,children:[(0,z.jsx)(`span`,{className:`sha`,children:e.sha.slice(0,7)}),(0,z.jsx)(`span`,{className:`subject`,children:e.subject})]}):(0,z.jsx)(`span`,{className:`label`,children:e.kind===`staged`?`Staged`:`Unstaged`}),(0,z.jsxs)(`span`,{className:`stat`,children:[e.additions>0&&(0,z.jsxs)(`span`,{className:`added`,children:[`+`,e.additions]}),e.deletions>0&&(0,z.jsxs)(`span`,{className:`removed`,children:[`−`,e.deletions]})]})]},e.kind===`commit`?e.sha:e.kind)}),x!==void 0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`window`,"aria-hidden":`true`,style:{top:x.newest*x8,height:(x.oldest-x.newest+1)*x8}}),(0,z.jsx)(`button`,{type:`button`,className:g,style:{top:x.newest*x8},"aria-label":`Newest change in the range`,onPointerDown:e=>E(e,`newest`),onKeyDown:e=>{let t={ArrowUp:-1,ArrowDown:1}[e.key];t!==void 0&&(e.preventDefault(),O(`newest`,t))}}),(0,z.jsx)(`button`,{type:`button`,className:g,style:{top:(x.oldest+1)*x8},"aria-label":`Oldest change in the range`,onPointerDown:e=>E(e,`oldest`),onKeyDown:e=>{let t={ArrowUp:-1,ArrowDown:1}[e.key];t!==void 0&&(e.preventDefault(),O(`oldest`,t))}})]})]})}),(0,z.jsx)(`div`,{className:_,children:`Click a change, or drag the handles for a range.`})]})}),document.body)]})}var C8=9,w8={trigger:B(J({size:`md`,fontWeight:400,color:`highContrast`}),{gap:`8px`,minWidth:0,"& > span":{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}}),float:B(Fd.sm,Vd.strong,Y.padding({y:1}),J({size:`sm`,color:`highContrast`}),{position:`fixed`,zIndex:50,width:`400px`,maxWidth:`calc(100vw - 32px)`,backgroundColor:K.element,"& .scroll":{maxHeight:`min(60vh, 520px)`,overflowY:`auto`,paddingBlock:`6px`,borderBlock:`1px solid ${Ad.border}`,marginBlock:`2px`},"& .rows":{position:`relative`,touchAction:`none`},"& .window":{position:`absolute`,left:`16px`,width:`2px`,borderRadius:`1px`,backgroundColor:G.accent[9],pointerEvents:`none`}}),item:B({paddingInline:`${String(C8)}px`,display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,height:`${String(x8)}px`,border:0,background:`transparent`,font:`inherit`,color:`inherit`,textAlign:`left`,cursor:`default`,"& > span":{flex:`1 1 auto`},"& > svg":{flexShrink:0},"&:hover":{backgroundColor:K.elementHover},"&[data-selected='true']":{color:G.accent[9],fontWeight:500}},Ud()),row:B({display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,height:`${String(x8)}px`,paddingInline:`${String(C8)}px`,border:0,background:`transparent`,font:`inherit`,color:`inherit`,textAlign:`left`,cursor:`default`,userSelect:`none`,"&:hover":{backgroundColor:K.elementHover},"&[data-inside='true']":{color:G.accent[9],fontWeight:500},"& .rail":{position:`relative`,alignSelf:`stretch`,width:`16px`,flexShrink:0},"& .rail::before":{content:`''`,position:`absolute`,left:`calc(50% - 0.5px)`,top:0,bottom:0,borderLeft:`1px solid ${G.gray[6]}`},"&[data-first='true'] .rail::before":{top:`50%`},"&[data-last='true'] .rail::before":{bottom:`50%`},"& .dot":{position:`absolute`,left:`50%`,top:`50%`,width:`7px`,height:`7px`,margin:`-3.5px 0 0 -3.5px`,borderRadius:`50%`,backgroundColor:G.gray[9]},"&[data-kind='staged'] .dot, &[data-kind='unstaged'] .dot":{backgroundColor:K.app,boxShadow:`inset 0 0 0 1.5px ${G.gray[9]}`},"&[data-inside='true'] .dot":{backgroundColor:G.accent[9],boxShadow:`none`},"& .label":{display:`flex`,gap:`8px`,flex:`1 1 auto`,minWidth:0},"& .sha":{fontFamily:wG,flexShrink:0},"& .subject":{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},"& .stat":{display:`flex`,gap:`6px`,fontWeight:400,flexShrink:0,fontFamily:wG,fontSize:`12px`,fontVariantNumeric:`tabular-nums`},"& .added":{color:G.green[11]},"& .removed":{color:G.red[11]}},Ud()),handle:B({position:`absolute`,left:`9px`,width:`16px`,height:`8px`,marginTop:`-4px`,padding:0,border:0,borderRadius:`4px`,backgroundColor:K.app,boxShadow:`inset 0 0 0 2px ${G.accent[9]}`,cursor:`ns-resize`,touchAction:`none`,zIndex:1},Ud(void 0,`inset 0 0 0 2px ${G.accent[9]}`)),foot:B(Y.padding({x:4,y:1}),J({size:`xs`,color:`lowContrast`}))};async function T8(e,t){let n=await fetch(`/__diffmap/${e}?${t}`).catch(e=>new hG({reason:`Could not reach the source service.`,cause:e}));if(n instanceof Error)return n;let r=await n.json().then(e=>e).catch(e=>new hG({reason:`Could not read the source response.`,cause:e}));return r instanceof Error?r:r.error===void 0?r.definition===void 0?new hG({reason:`No definition found.`}):r.definition:new hG({reason:r.error})}function E8(e,t){let[n,r]=(0,R.useState)(),i=N4(),a=F4(),o=j4(),s=e?.rev===void 0?a:t??(o===`gist`?D8:void 0),c=(0,R.useMemo)(()=>{if(e?.kind===`file`&&s!==void 0)return O8(s,e)},[e,s]);return(0,R.useEffect)(()=>{if(e?.kind!==`file`||s!==void 0)return;let t=!0;if(i!==void 0)return G4(e.rev===void 0?i:{...i,sha:e.rev.split(`..`).at(-1)},e.path).then(n=>{if(!t)return;if(n instanceof Error){let t=n.message===`not-found`?`Could not read ${e.path} at this commit.`:n.message;r({reference:e,result:new hG({reason:t})});return}let i=Math.max(1,n.split(/\r?\n/).length),a=e.symbol===void 0?{start:e.start??1,end:e.end??i}:K4(n,e.symbol);r({reference:e,result:{path:e.path,contents:n,start:a.start,end:a.end}})}),()=>{t=!1};if(o!==`local`)return;let n=new URLSearchParams({path:e.path});return e.rev!==void 0&&n.set(`rev`,e.rev),e.symbol!==void 0&&n.set(`symbol`,e.symbol),e.start!==void 0&&n.set(`start`,String(e.start)),e.end!==void 0&&n.set(`end`,String(e.end)),T8(`source`,n).then(n=>{n instanceof Error&&U0({event:`viewer_error`,kind:`source`}),t&&r({reference:e,result:n})}),()=>{t=!1}},[e,i,o,s]),c===void 0?n?.reference===e?n?.result:void 0:c}var D8={};function O8(e,t){let n=e[t.path];if(n===void 0)return new hG({reason:`No hosted file for ${t.path}.`});let r=Math.max(1,n.split(/\r?\n/).length),i=t.symbol===void 0?{start:t.start??1,end:t.end??r}:K4(n,t.symbol);return{path:t.path,contents:n,start:i.start,end:i.end}}function k8(e){let[t,n]=(0,R.useState)(()=>M8(e));return(0,R.useEffect)(()=>{try{Object.keys(t).length===0?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch(e){console.warn(`diffmap could not save reviewed files`,e)}},[e,t]),(0,R.useMemo)(()=>({isReviewed:e=>t[e.path]===j8(e),setReviewed:(e,t)=>n(n=>{let{[e.path]:r,...i}=n;return t?{...i,[e.path]:j8(e)}:i})}),[t])}var A8=new WeakMap;function j8(e){let t=A8.get(e);return t===void 0&&(t=T4(JSON.stringify([e.prevPath,e.contents,e.patch])),A8.set(e,t)),t}function M8(e){try{let t=localStorage.getItem(e);return t===null?{}:JSON.parse(t)}catch{return{}}}function N8(e){return`https://gist.github.com/${e}`}function P8(e,t,n,r){return`https://github.com/${e}/${t}/blob/${n}/${r.split(`/`).map(encodeURIComponent).join(`/`)}`}function F8(e){if(e.github!==void 0){let t=e.github.sha.slice(0,7);return{kind:`github`,label:`${e.github.owner}/${e.github.repo} @ ${t}`,href:P8(e.github.owner,e.github.repo,e.github.sha,e.path)}}return e.gist===void 0?{kind:`none`}:{kind:`gist`,label:`${e.gist.gistId} / ${e.gist.file}`,href:e.gist.htmlUrl.length>0?e.gist.htmlUrl:N8(e.gist.gistId)}}function I8(e){let{resolvedTheme:t}=oa(),n=j4(),r=(0,R.useRef)(null),[i,a]=(0,R.useState)({selection:e.selection,history:[],request:void 0});i.selection!==e.selection&&a({selection:e.selection,history:[],request:void 0});let o=(0,R.useRef)(0),s=F4(),c=r2(e.rev),l=e.selection?.reference,u=l?.kind===`file`&&(l.rev===void 0||c!==void 0&&!(c instanceof Error)&&!c.files.some(e=>e.path===l.path)),d=E8(u?l:void 0,c instanceof Error?void 0:c?.sources),f=c===void 0?`Loading changes…`:u&&d===void 0&&(n===`local`||n===`github`||s!==void 0)?`Opening source…`:i.request===`finding`?`Finding definition…`:void 0,p={rev:e.rev,review:e.review,selection:e.selection,history:i.history,changes:c,source:d},[m,h]=(0,R.useState)(p);f===void 0&&(m.rev!==p.rev||m.review!==p.review||m.selection!==p.selection||m.history!==p.history||m.changes!==p.changes||m.source!==p.source)&&h(p);let{history:g,selection:_,changes:v,source:y,review:b}=m,x=g.at(-1),S=V(V8.panel),C=V(V8.header,V8.dimmed),w=V(V8.titleRow),T=V(V8.close),E=V(V8.title),D=V(V8.pin),O=V(V8.links),k=V(V8.code),A=V(V8.summary),j=V(V8.codeWrap),M=V(V8.collapseIcon),ee=V(V8.fileHeader),te=N4(),N=b8(),ne=V(V8.body),re=V(V8.loading),P=_?.reference,ie=(0,R.useMemo)(()=>{if(v===void 0||v instanceof Error)return[];let{reviewed:e,other:t}=lG(v.files,b);return[...e,...t].flatMap(e=>_8(e)??[])},[v,b]),F=y instanceof Error?void 0:y,ae=F!==void 0&&ie.some(e=>e.id===F.path),oe=x??(F!==void 0&&v!==void 0&&!ae?F:void 0),se=i.request instanceof Error?i.request:y instanceof Error?y:v instanceof Error&&oe===void 0?v:void 0,ce=se===void 0?v!==void 0&&ie.length===0&&oe===void 0?{tone:`neutral`,message:`No changes.`}:void 0:{tone:`warning`,message:se.message},le=(0,R.useMemo)(()=>{if(oe!==void 0)return{id:oe.path,range:{start:oe.start,end:oe.end}};let e=F??(P?.kind===`file`&&P.start!==void 0?{path:P.path,start:P.start,end:P.end??P.start}:void 0);return e===void 0?null:{id:e.path,range:{start:e.start,end:e.end,side:`additions`}}},[P,oe,F]),ue=oe?.path??P?.path,{isReviewed:de,setReviewed:fe}=k8(`diffmap-reviewed:${window.location.pathname}`),pe=(0,R.useMemo)(()=>new Map(v===void 0||v instanceof Error?[]:v.files.map(e=>[e.path,e])),[v]),[me,I]=(0,R.useState)({rev:m.rev,selection:_,toggled:new Set});(me.rev!==m.rev||me.selection!==_)&&I({rev:m.rev,selection:_,toggled:new Set});let he=(0,R.useMemo)(()=>{let e=ie.map(e=>e.id);return new Set(e.filter(e=>{let t=pe.get(e);return(t!==void 0&&de(t)&&e!==ue)!==me.toggled.has(e)}))},[ie,pe,de,ue,me.toggled]),ge=le?.id,_e=le?.range.start,ve=le?.range.end,ye=le!==null&&`side`in le.range?le.range.side:void 0,be=(0,R.useMemo)(()=>ie.map(e=>{let t=e.id===ge&&ye===`additions`&&v!==void 0&&!(v instanceof Error)?v.files.find(t=>t.path===e.id):void 0,n=t===void 0?e:_8(t,{start:_e,end:ve})??e,r=he.has(e.id);return{...n,collapsed:r,version:(n.version??0)*2+ +!!r}}),[ie,v,he,ge,_e,ve,ye]),xe=e=>{let t=new Set(me.toggled);t.delete(e)||t.add(e),I({...me,toggled:t})},Se=(e,t)=>{let n=pe.get(e);if(n===void 0)return;fe(n,t),t&&U0({event:`file_reviewed`});let r=t&&e!==ue,i=new Set(me.toggled);r===t?i.delete(e):i.add(e),I({...me,toggled:i})},Ce=e=>{if(oe!==void 0)return;let t=e.nativeEvent.composedPath();if(t.some(e=>e instanceof Element&&e.hasAttribute(`data-reviewed`)))return;let n=t.find(e=>e instanceof Element&&e.hasAttribute(`data-diffs-header`))?.getRootNode();if(!(n instanceof ShadowRoot))return;let r=n.host.querySelector(`[data-collapse-path]`)?.getAttribute(`data-collapse-path`);r!=null&&xe(r)},we=oe===void 0?{kind:`none`}:F8({path:oe.path,github:te!==void 0&&P?.rev!==void 0&&x===void 0?{...te,sha:P.rev.split(`..`).at(-1)}:te,gist:N}),Te=oe!==void 0,Ee=zG({themeType:t,disableFileHeader:Te}),De=v===void 0||v instanceof Error?void 0:v,Oe=oe!==void 0||De!==void 0;(0,R.useEffect)(()=>{Oe&&_!==void 0&&ue!==void 0&&ge===void 0&&r.current?.scrollTo({type:`item`,id:ue,align:`start`,offset:Te?0:L8,behavior:`instant`})},[Oe,ue,ge,_,Te]),(0,R.useEffect)(()=>{Oe&&ge!==void 0&&_e!==void 0&&ve!==void 0&&r.current?.scrollTo({type:`range`,id:ge,range:{start:_e,end:ve,...ye===void 0?{}:{side:ye}},align:`center`,behavior:`instant`})},[Oe,ge,_e,ve,ye]);let ke=(e,t,r)=>{if(n!==`local`||!t.metaKey&&!t.ctrlKey)return;t.preventDefault();let i=r.item,s,c;if(i.type===`file`)s=i.file.name,c=i.file.contents.split(/\r?\n/)[e.lineNumber-1];else{let t=`side`in e&&e.side===`deletions`?`deletions`:`additions`;s=i.fileDiff.name,c=BG(i.fileDiff,t,e.lineNumber)}let l=new URLSearchParams({path:s,line:String(e.lineNumber),column:String(e.lineCharStart),text:c}),u=++o.current;a({selection:_,history:g,request:`finding`}),T8(`definition`,l).then(e=>{u===o.current&&a(t=>t.selection===_?e instanceof Error?{...t,request:e}:{selection:_,history:[...g,e],request:void 0}:t)})},Ae=S4(oe===void 0?`panel:${m.rev}`:`panel-file`),[je,Me]=(0,R.useState)(),Ne=(e,t)=>Me(e?{id:t.item.id,range:e}:void 0),Pe=(0,R.useMemo)(()=>(oe===void 0?be:[{type:`file`,id:oe.path,version:T4(oe.contents),file:{name:oe.path,contents:oe.contents}}]).map(e=>{let t=e.type===`file`?Ae.fileAnnotations(e.id):Ae.diffAnnotations(e.id);if(t.length===0)return e;let n=t.map(e=>`${e.metadata}@${String(e.lineNumber)}`).join();return{...e,annotations:t,version:T4(`${String(e.version??0)}:${n}`)}}),[oe,be,Ae]),Fe=(e,t)=>{let n=t.item,{side:r=`additions`,start:i,end:a}=w4(e);if(n.type===`file`){Ae.start({path:n.id,side:void 0,start:i,end:a,lineOffset:0,lines:n.file.contents.split(/\r?\n/).slice(i-1,a),context:`current file`});return}Ae.start({path:n.id,side:r,start:i,end:a,lineOffset:0,lines:E4(i,a).flatMap(e=>BG(n.fileDiff,r,e)??[]),context:`Diff panel: ${nG(m.rev)}`})};return(0,z.jsxs)(`aside`,{id:`source-diff-panel`,"aria-label":`Source changes`,"aria-busy":f!==void 0,className:S,children:[(0,z.jsxs)(`div`,{className:C,"data-diffmap-kind":`source-header`,"data-loading":f!==void 0,children:[(0,z.jsx)(Vz,{className:T,variant:`quiet`,size:`sm`,"aria-label":`Collapse diff`,onPress:e.onClose,children:(0,z.jsx)(oB,{size:`sm`})}),!Te&&e.onRevChange!==void 0&&(0,z.jsxs)(`div`,{className:w,children:[(0,z.jsx)(S8,{rev:e.rev,onChange:e.onRevChange}),De!==void 0&&(0,z.jsx)(o2,{className:A,changes:De})]}),!Te&&e.onRevChange===void 0&&De!==void 0&&(0,z.jsx)(`div`,{className:w,children:_?.annotation.title===void 0?De.url===void 0?(0,z.jsx)(`div`,{className:E,title:De.title,children:De.title}):(0,z.jsx)(`a`,{className:E,href:De.url,title:De.title,children:De.title}):(0,z.jsx)(`div`,{className:E,title:_.annotation.title,children:_.annotation.title})}),Te&&(0,z.jsxs)(`div`,{className:w,children:[(0,z.jsx)(`div`,{className:E,title:oe.path,children:oe.path}),x!==void 0&&(0,z.jsx)(Vz,{variant:`quiet`,onClick:()=>{o.current++,a({selection:_,history:g.slice(0,-1),request:void 0})},children:g.length===1?`Back to reference`:`Back`})]}),we.kind===`github`&&(0,z.jsx)(`a`,{className:D,href:we.href,"data-diffmap-pin":`github`,title:we.label,children:we.label}),we.kind===`gist`&&(0,z.jsx)(`a`,{className:D,href:we.href,"data-diffmap-pin":`gist`,title:we.label,children:we.label}),ce!==void 0&&(0,z.jsx)(nB,{tone:ce.tone,role:`status`,children:ce.message}),_!==void 0&&_.annotation.references.length>1&&(0,z.jsx)(`div`,{className:O,"aria-label":`Linked changes`,children:_.annotation.references.map((t,n)=>(0,z.jsx)(Vz,{variantColor:`blue`,variant:t===_.reference?`primary`:`quiet`,onClick:()=>e.onSelect({annotation:_.annotation,reference:t}),children:EG(t)},n))})]}),(0,z.jsxs)(`div`,{className:ne,children:[(0,z.jsx)(`div`,{className:j,"data-cards":!Te,inert:f!==void 0,onClick:Ce,children:(0,z.jsx)(O2,{ref:r,className:k,items:Pe,selectedLines:je??Ae.draftSelection??le,disableWorkerPool:!0,options:{...Ee,unsafeCSS:Ee.unsafeCSS+IG+B8,layout:Te?{paddingTop:0,paddingBottom:0,gap:0}:{paddingTop:L8,paddingBottom:L8,gap:L8},stickyHeaders:!0,itemMetrics:{diffHeaderHeight:R8},onTokenClick:ke,enableGutterUtility:!0,onGutterUtilityClick:Fe,onLineSelectionStart:Ne,onLineSelectionChange:Ne,onLineSelectionEnd:()=>Me(void 0)},renderAnnotation:(...[e])=>(0,z.jsx)(D4,{id:e.metadata}),renderCustomHeader:e=>{let t=e.type===`diff`?z8[e.fileDiff.type]:void 0,n=pe.get(e.id);return(0,z.jsxs)(`div`,{className:ee,children:[(0,z.jsx)(`span`,{className:M,"data-collapse-path":e.id,"data-collapsed":he.has(e.id),"aria-hidden":`true`,children:(0,z.jsx)(oB,{size:`sm`})}),(0,z.jsx)(c2,{path:e.type===`diff`?e.fileDiff.name:e.file.name}),(0,z.jsxs)(`span`,{className:`meta`,children:[t!==void 0&&(0,z.jsx)(_f,{className:`status`,"data-status":t,children:t}),e.type===`diff`&&u2(e.fileDiff),n!==void 0&&(0,z.jsx)(b3,{isSelected:de(n),onChange:t=>Se(e.id,t)})]})]})}})}),(0,z.jsx)(`div`,{className:re,"data-loading":f!==void 0,"data-cards":!Te,children:f!==void 0&&(0,z.jsx)(OH,{progressLabel:f})})]})]})}var L8=12,R8=36,z8={new:`new`,deleted:`deleted`,"rename-pure":`renamed`,"rename-changed":`renamed`},B8=`:host {
257
257
  --diffs-light-bg: ${K.app};
258
258
  --diffs-dark-bg: ${K.app};
@@ -261,4 +261,4 @@ diff --git`)}function zZ(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.star
261
261
  [data-diffs-header] {
262
262
  border-bottom: 1px solid ${Ad.border};
263
263
  cursor: pointer;
264
- }`,V8={panel:B(Yd({direction:`column`}),Md([`left`],`border`),{position:`relative`,gridArea:`diff`,minWidth:0,minHeight:0,overflow:`hidden`,backgroundColor:K.app,"@media (max-width: 900px)":{height:`45vh`,borderLeft:`none`,borderTop:`1px solid ${Ad.border}`}}),header:B(Yd({direction:`column`}),Y.padding({y:3}),{paddingInline:`7px`},Md([`bottom`],`border`),J({size:`sm`,color:`lowContrast`}),{gap:`6px`,minWidth:0,maxHeight:`35%`,overflowY:`auto`,flexShrink:0,position:`relative`,"@media (max-width: 900px)":{paddingRight:`calc(${nf.smHeight} + 14px)`,minHeight:`calc(${nf.smHeight} + 12px)`}}),close:B({display:`none`,"@media (max-width: 900px)":{display:`flex`,position:`absolute`,top:`6px`,right:`7px`,width:nf.smHeight}}),summary:B({marginLeft:`auto`,marginRight:`9px`}),titleRow:B(Yd({direction:`row`,alignItems:`center`}),{gap:`6px`,minWidth:0}),title:B(J({size:`sm`,fontWeight:600,color:`highContrast`}),{minWidth:0,flex:`1 1 auto`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),pin:B(J({size:`sm`,color:`lowContrast`}),{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,textDecoration:`none`,"&:is(a):hover":{textDecoration:`underline`}}),links:B(Yd({direction:`row`}),{gap:`6px`,flexWrap:`wrap`}),codeWrap:B({display:`flex`,flexDirection:`column`,flex:`1 1 auto`,minWidth:0,minHeight:0,"&[data-cards='true']":{backgroundColor:G.gray[2]},"&[data-cards='true'] diffs-container":{marginInline:`${String(L8)}px`,borderRadius:`8px`,boxShadow:Bd.subtle,overflow:`clip`}}),dimmed:B(ef.standard(`opacity`),{"&[data-loading='true']":{opacity:.4,transitionDelay:`150ms`}}),body:B({position:`relative`,display:`flex`,flexDirection:`column`,flex:`1 1 auto`,minWidth:0,minHeight:0}),loading:B(ef.standard(`opacity`),{position:`absolute`,inset:0,display:`flex`,backgroundColor:K.app,"&[data-cards='true']":{backgroundColor:G.gray[2]},pointerEvents:`none`,opacity:0,"&[data-loading='true']":{opacity:1,transitionDelay:`150ms`}}),fileHeader:B(Yd({direction:`row`,alignItems:`center`}),J({size:`sm`,color:`lowContrast`}),{gap:`8px`,minHeight:`35px`,paddingInline:`12px`,"& .meta":{display:`flex`,alignItems:`center`,gap:`8px`,flexShrink:0},"& .status":{fontFamily:`inherit`,fontSize:`inherit`},"& :is(.file-name, .head, .tail), & .stat > span":{textBox:`trim-both cap alphabetic`},"& [title], & :is(.file-name, .file-folder, .head, .tail)":{overflow:`visible`,overflowX:`clip`,minWidth:0},"& [data-reviewed]":{cursor:`default`},"& .status[data-status='new']":{backgroundColor:G.greenAlpha[3],color:G.green[11]},"& .status[data-status='deleted']":{backgroundColor:G.redAlpha[3],color:G.red[11]}}),collapseIcon:B({display:`flex`,color:G.gray[11],transition:`transform 150ms ease-out`,"&[data-collapsed='true']":{transform:`rotate(-90deg)`}}),code:B({flex:`1 1 auto`,minWidth:0,minHeight:0,overflow:`auto`})},H8=B({color:G.red[9]});function U8(e){let t=V(H8);return(0,z.jsxs)(Vz,{variant:`default`,onClick:e.onClick,children:[(0,z.jsx)(Yz,{className:t,size:`sm`}),`Close server`]})}var W8={neutral:G.gray,info:G.blue,warning:G.amber,danger:G.red};function G8(e){let t=V(Z8.shell),n=V(Z8.header),r=V(Z8.wordmark),i=V(Z8.body),a=V(Z8.column),o=V(Z8.badge,X8[e.tone]),s=V(Z8.description),c=V(Z8.actions),l=e.icon;return(0,z.jsxs)(`div`,{className:t,children:[(0,z.jsx)(`header`,{className:n,children:(0,z.jsx)(`div`,{className:r,children:`diffmap`})}),(0,z.jsx)(`main`,{className:i,children:(0,z.jsxs)(`div`,{className:a,children:[(0,z.jsx)(`div`,{className:o,"aria-hidden":`true`,children:(0,z.jsx)(l,{size:`lg`})}),(0,z.jsx)(MB,{children:e.title}),(0,z.jsx)(`div`,{className:s,children:e.children}),e.detail!==void 0&&(0,z.jsx)(nB,{tone:e.tone,layout:e.detailTitle===void 0?`inline`:`stacked`,title:e.detailTitle,icon:!1,role:e.tone===`danger`?`alert`:`status`,children:e.detail}),e.actions!==void 0&&(0,z.jsx)(`div`,{className:c,children:e.actions}),e.footer]})})]})}function K8(e){let t=V(Bz.root({variant:e.variant}),Z8.link);return(0,z.jsx)(bI,{className:t,href:e.href,children:e.children})}function q8(e){return(0,z.jsxs)(Vz,{variant:`primary`,onPress:()=>window.location.reload(),children:[(0,z.jsx)(TB,{size:`sm`}),e.label??`Try again`]})}function J8(e){let t=V(Z8.code);return(0,z.jsx)(`code`,{className:t,children:e.children})}function Y8(e){return(0,z.jsx)(G8,{tone:`danger`,icon:fB,title:e.title??`This walkthrough has an error`,detailTitle:(0,z.jsx)(J8,{children:e.file}),detail:e.message,actions:e.actions,children:e.children})}var X8=Object.fromEntries(Object.entries(W8).map(([e,t])=>[e,B({backgroundColor:t[3],color:t[11]})])),Z8={shell:B(Yd({direction:`column`}),{width:`100%`,height:`100vh`,minWidth:0,minHeight:0,overflow:`hidden`,backgroundColor:K.app}),header:B(Yd({direction:`row`,alignItems:`center`}),Y.padding({x:6,y:3}),Xd({size:`hug`}),Md([`bottom`],`border`),{minWidth:0,minHeight:`37px`}),wordmark:B(J({size:`md`,fontWeight:600,color:`highContrast`})),body:B(Y.padding({x:8}),{flex:`1 1 auto`,minWidth:0,minHeight:0,overflowY:`auto`,paddingTop:`min(16vh, 160px)`,paddingBottom:Y.value(16)}),loadingBody:B(Yd({direction:`column`}),{flex:`1 1 auto`,minWidth:0,minHeight:0}),column:B(Yd({direction:`column`,gap:6}),{width:`100%`,maxWidth:`34rem`,marginInline:`auto`}),badge:B(Yd({direction:`row`,alignItems:`center`,justifyContent:`center`}),Fd.lg,{width:`40px`,height:`40px`}),description:B(Yd({direction:`column`,gap:4}),J({size:`md`,color:`lowContrast`}),{"& p":{color:`inherit`}}),actions:B(Yd({direction:`row`,alignItems:`center`,gap:4}),{flexWrap:`wrap`,paddingTop:Y.value(2)}),link:B({textDecoration:`none`}),code:B(J({size:`sm`,color:`highContrast`,monospace:!0}),{overflowWrap:`anywhere`})},Q8=`connected`,$8=new Set;function e5(e){if(Q8!==`closed`&&Q8!==e){Q8=e;for(let e of $8)e()}}function t5(){return(0,R.useSyncExternalStore)(e=>($8.add(e),()=>$8.delete(e)),()=>Q8)}function n5(e){let{comments:t}=u4(),n=vG(),r=yG(n)?n.pages.map(e=>({title:e.title,comments:e===n.current?t:p4(d4(n.href(e)))})):void 0,i=r===void 0?t.length:r.reduce((e,t)=>e+t.comments.length,0),[a,o]=(0,R.useState)(!1),s=V(Bz.label,r5);if((0,R.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),1500);return()=>clearTimeout(e)},[a]),i!==0)return(0,z.jsxs)(Vz,{onPress:()=>{let n=m4({title:e.title,source:e.source,comments:t,pages:r});navigator.clipboard.writeText(n).then(()=>{o(!0),U0({event:`comments_copied`})},e=>console.warn(`diffmap copy failed`,e))},children:[a?(0,z.jsx)(aB,{size:`sm`}):(0,z.jsx)(lB,{size:`sm`}),a?`Copied`:`Copy comments`,(0,z.jsx)(`span`,{className:s,children:i})]})}var r5=B({color:G.gray[11],fontVariantNumeric:`tabular-nums`}),i5=32;function a5(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],r=``;for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e;n.push({node:t,start:r.length}),r+=t.data}return{text:r,nodes:n}}function o5(e,t,n){let{text:r}=a5(e),i=l5(e,t.startContainer,t.startOffset),a=l5(e,t.endContainer,t.endOffset),o=r.slice(i,a);if(o.trim()!==``)return{kind:`text`,quote:o,prefix:r.slice(Math.max(0,i-i5),i),suffix:r.slice(a,a+i5),offset:i,display:n,section:d5(e,t.startContainer)}}function s5(e,t){let n;for(let r=e.text.indexOf(t.quote);r!==-1;r=e.text.indexOf(t.quote,r+1)){let i=e.text.slice(Math.max(0,r-i5),r),a=e.text.slice(r+t.quote.length,r+t.quote.length+i5),o=p5(i,t.prefix)+f5(a,t.suffix),s=Math.abs(r-t.offset);(n===void 0||o>n.score||o===n.score&&s<n.distance)&&(n={at:r,score:o,distance:s})}if(n!==void 0)return u5(e,n.at,n.at+t.quote.length)}function c5(e){let t=e.startContainer,n=(t instanceof Element?t:t.parentElement)?.closest(`details:not([open])`);return n==null?[...e.getClientRects()].filter(e=>e.width>0)[0]??e.getBoundingClientRect():(n.querySelector(`summary`)??n).getBoundingClientRect()}function l5(e,t,n){let r=document.createRange();return r.setStart(e,0),r.setEnd(t,n),r.toString().length}function u5(e,t,n){let r=e.nodes.find(e=>t<e.start+e.node.data.length),i=e.nodes.findLast(e=>n>e.start);if(r===void 0||i===void 0)return;let a=document.createRange();return a.setStart(r.node,t-r.start),a.setEnd(i.node,n-i.start),a}function d5(e,t){let n=[...e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)].findLast(e=>e.contains(t)||(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)!==0)?.textContent?.trim();return n===``?void 0:n}function f5(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function p5(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var m5=24,h5=16,g5=220,_5=300,v5=360,y5=8,b5=`draft`;function x5(e){let t=u4(),n=(0,R.useRef)(null),r=(0,R.useRef)(new Map),[i,a]=(0,R.useState)(),[o,s]=(0,R.useState)({}),[c,l]=(0,R.useState)(),[u]=(0,R.useState)(()=>new ResizeObserver(e=>{s(t=>{let n={...t};for(let t of e){let e=t.target.dataset.commentId;e!==void 0&&(n[e]=t.borderBoxSize[0].blockSize)}return n})})),d=V(A5.layer),f=V(A5.slot),p=V(Bz.root({variant:`default`}),A5.add),m=V(Bz.label),h=t.comments.filter(e=>e.anchor.kind===`text`),g=t.draft?.kind===`text`?t.draft:void 0,_=(0,R.useEffectEvent)(()=>{let i=e.contentRef.current,o=n.current;if(i===null||o===null)return;let s=a5(i),c=o.getBoundingClientRect(),l=i.getBoundingClientRect(),u={},d=[],f=[];r.current.clear();let p=(e,n)=>{let i=s5(s,n);u[e]=i===void 0?void 0:T5(c5(i),c),i!==void 0&&(r.current.set(e,i),(e===t.activeId||e===b5?f:d).push(i))};for(let e of h)p(e.id,e.anchor);g!==void 0&&p(b5,g),w5(`diffmap-comment`,d),w5(`diffmap-comment-active`,f);let m={width:c.width,contentLeft:l.left-c.left,contentRight:l.right-c.left,anchors:u};a(e=>JSON.stringify(e)===JSON.stringify(m)?e:m)});(0,R.useLayoutEffect)(()=>{_()},[t.comments,t.draft,t.activeId]),(0,R.useEffect)(()=>{let t=e.contentRef.current,r=n.current;if(t===null||r===null)return;let i=0,a=()=>{cancelAnimationFrame(i),i=requestAnimationFrame(()=>_())},o=new ResizeObserver(a);o.observe(t),o.observe(r);let s=new MutationObserver(a);return s.observe(t,{subtree:!0,childList:!0,characterData:!0}),()=>{cancelAnimationFrame(i),o.disconnect(),s.disconnect(),w5(`diffmap-comment`,[]),w5(`diffmap-comment-active`,[])}},[e.contentRef]),(0,R.useEffect)(()=>{let t=!1,r=()=>{let r=e.contentRef.current,i=n.current,a=document.getSelection();if(t||r===null||i===null||a===null||a.rangeCount===0||a.isCollapsed){l(void 0);return}let o=a.getRangeAt(0),s=[...o.getClientRects()].filter(e=>e.width>0);if(!r.contains(o.commonAncestorContainer)||o.toString().trim()===``||s.length===0){l(void 0);return}let c=i.getBoundingClientRect(),u=T5(s[0],c),d=T5(s.at(-1),c);l({range:o.cloneRange(),display:a.toString(),box:{top:u.top,left:u.left,bottom:d.bottom,right:d.right}})},i=e=>{D5(e.target,`[data-comment-add]`)||(t=!0,l(void 0))},a=()=>{t&&(t=!1,setTimeout(r))};return document.addEventListener(`selectionchange`,r),document.addEventListener(`pointerdown`,i),document.addEventListener(`pointerup`,a),()=>{document.removeEventListener(`selectionchange`,r),document.removeEventListener(`pointerdown`,i),document.removeEventListener(`pointerup`,a)}},[e.contentRef]);let v=(0,R.useEffectEvent)(e=>{if(D5(e.target,`[data-comment-card], [data-comment-add]`)||document.getSelection()?.isCollapsed===!1)return;let n=O5(e.clientX,e.clientY),i=n===void 0?void 0:[...r.current].find(([e,t])=>e!==b5&&k5(t,n.node,n.offset))?.[0];t.setActiveId(i)});(0,R.useEffect)(()=>{let e=e=>v(e);return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[]);let y=()=>{let n=e.contentRef.current;if(c===void 0||n===null)return;let r=o5(n,c.range,c.display);r!==void 0&&(t.startDraft(r),document.getSelection()?.removeAllRanges(),l(void 0))},b=[...h.map(e=>({id:e.id,comment:e})),...g===void 0?[]:[{id:b5,comment:void 0}]].filter(e=>i!==void 0&&e.id in i.anchors),x=i===void 0?0:i.width-i.contentRight-m5-h5,S=x>=g5,C=g===void 0?t.activeId:b5,w=[];if(i!==void 0&&S){let e=C5(b.map(e=>({id:e.id,anchorTop:i.anchors[e.id]?.top??0,anchorLeft:i.anchors[e.id]?.left??0,height:o[e.id]??80})),C);for(let t of b)w.push({id:t.id,top:e[t.id],left:i.contentRight+m5,width:Math.min(_5,x)})}else if(i!==void 0&&C!==void 0){let e=i.anchors[C],t=Math.min(v5,i.contentRight-i.contentLeft);b.some(e=>e.id===C)&&w.push({id:C,top:e===void 0?0:e.bottom+y5,left:E5(e?.left??i.contentLeft,i.contentLeft,i.contentRight-t),width:t})}return(0,z.jsxs)(`div`,{ref:n,className:d,"aria-label":`Comments`,children:[w.map(e=>{let t=b.find(t=>t.id===e.id)?.comment;return(0,z.jsx)(`div`,{className:f,"data-comment-id":e.id,"data-floating":!S,ref:e=>{if(e!==null)return u.observe(e),()=>u.unobserve(e)},style:{transform:`translateY(${String(e.top)}px)`,left:e.left,width:e.width},children:(0,z.jsx)(v4,{comment:t,detached:i?.anchors[e.id]===void 0})},e.id)}),c!==void 0&&g===void 0&&i!==void 0&&(0,z.jsxs)(`button`,{type:`button`,className:p,"data-comment-add":``,style:{top:c.box.top-y5,left:E5(c.box.left,i.contentLeft,i.contentRight-120)},onMouseDown:e=>e.preventDefault(),onClick:y,children:[(0,z.jsx)(bB,{size:`sm`}),(0,z.jsx)(`span`,{className:m,children:`Comment`})]})]})}var S5=B({"& ::highlight(diffmap-comment), &::highlight(diffmap-comment)":{backgroundColor:G.amberAlpha[5]},"& ::highlight(diffmap-comment-active), &::highlight(diffmap-comment-active)":{backgroundColor:G.amberAlpha[8]}});function C5(e,t){let n=e.toSorted((e,t)=>Math.round(e.anchorTop)-Math.round(t.anchorTop)||e.anchorLeft-t.anchorLeft),r=Math.max(0,n.findIndex(e=>e.id===t)),i={};for(let e=r;e<n.length;e++){let t=n[e],a=n[e-1];i[t.id]=e===r||a===void 0?t.anchorTop:Math.max(t.anchorTop,i[a.id]+a.height+y5)}for(let e=r-1;e>=0;e--){let t=n[e],r=n[e+1];i[t.id]=Math.min(t.anchorTop,i[r.id]-t.height-y5)}return i}function w5(e,t){typeof CSS>`u`||!(`highlights`in CSS)||(t.length===0?CSS.highlights.delete(e):CSS.highlights.set(e,new Highlight(...t)))}function T5(e,t){return{top:e.top-t.top,bottom:e.bottom-t.top,left:e.left-t.left,right:e.right-t.left}}function E5(e,t,n){return Math.max(t,Math.min(e,n))}function D5(e,t){return e instanceof Element&&e.closest(t)!==null}function O5(e,t){if(`caretPositionFromPoint`in document){let n=document.caretPositionFromPoint(e,t);return n===null?void 0:{node:n.offsetNode,offset:n.offset}}let n=document.caretRangeFromPoint(e,t);if(n!==null)return{node:n.startContainer,offset:n.startOffset}}function k5(e,t,n){try{return e.isPointInRange(t,n)}catch{return!1}}var A5={layer:B({gridColumn:`1 / -1`,gridRow:`1`,position:`relative`,pointerEvents:`none`,minWidth:0}),slot:B({position:`absolute`,top:0,pointerEvents:`auto`,transition:`transform 120ms ease-out`,"&[data-floating='true']":{zIndex:2},"&[data-floating='true'] > [data-comment-card]":{boxShadow:Bd.strong}}),add:B(Vd.medium,{position:`absolute`,transform:`translateY(-100%)`,pointerEvents:`auto`,zIndex:2})};function j5(e){let t=V(M5);return(0,z.jsxs)(Vz,{className:t,"aria-pressed":e.pressed,"aria-expanded":e.pressed,"aria-controls":`source-diff-panel`,onClick:e.onClick,children:[(0,z.jsx)(_B,{size:`sm`}),`Diff`]})}var M5=B({"&[aria-pressed='true']":{backgroundColor:K.elementActive}});function N5(e){let t=V(P5.button);return(0,z.jsx)(Vz,{className:t,variant:`quiet`,"aria-label":`Table of contents`,"aria-haspopup":`dialog`,"aria-expanded":e.expanded,onClick:e.onClick,children:(0,z.jsx)(OB,{size:`sm`})})}var P5={button:B({flexShrink:0,"@media (min-width: 601px)":{display:`none`}})},F5=12,I5=3,L5=3,R5=50,z5=100,B5=180,V5={type:`spring`,visualDuration:.15,bounce:Qd.dialogEnter.bounce},H5={duration:.09,ease:`easeIn`},U5={duration:Qd.reduced.durationMs/1e3,ease:`easeInOut`},W5=220;function G5(e,t){return Q5(e).length>0||yG(t)}function K5(e,t){let n=Q5(e);return yG(t)?t.pages.flatMap(e=>[{id:`diffmap-page:${e.slug}`,text:e.title,level:1,page:e,currentPage:e===t.current},...e===t.current?n.map(e=>({...e,level:Math.max(e.level,2)})):[]]):n}function q5(e,t){let n=Math.max(0,e-t);return Math.max(I5,F5-n*L5)}function J5(e){let t=vG(),n=K5(e.headings,t),r=$5(n),{activeId:i,setActiveId:a}=t7(e.headings,e.articleRef),o=(0,R.useRef)(null),s=e7(o),c=V(r7.rail),l=V(r7.docked),u=V(r7.drawer),d=V(r7.list);if(r.length===0)return;let f=(n,r)=>{if(t!==void 0){if(r!==t.current){bG(n,t,r);return}n.preventDefault(),e.articleRef.current?.scrollTo({top:0,behavior:`smooth`})}},p=(0,z.jsx)(X5,{items:r,className:d,activeId:i,onSelect:a,onPage:f,pageHref:t?.href});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`nav`,{ref:o,id:`diffmap-toc`,className:c,"aria-label":`Table of contents`,"data-diffmap-kind":`toc`,"data-docked":s?`true`:`false`,children:s?(0,z.jsx)(`div`,{className:l,"data-diffmap-kind":`toc-list`,children:p}):(0,z.jsx)(Y5,{headings:n,activeId:i,children:p})}),(0,z.jsx)(qV,{isOpen:e.drawerOpen,onOpenChange:e.onDrawerOpenChange,"aria-label":`Table of contents`,children:(0,z.jsx)(`nav`,{className:u,"aria-label":`Table of contents`,children:(0,z.jsx)(X5,{items:r,className:d,activeId:i,onSelect:t=>{a(t),e.onDrawerOpenChange(!1)},onPage:(t,n)=>{f(t,n),e.onDrawerOpenChange(!1)},pageHref:t?.href})})})]})}function Y5(e){let t=V(r7.cluster),n=V(r7.line),r=V(r7.card),i=!!iw(),[a,o]=(0,R.useState)(!1),s=(0,R.useRef)(!1),c=(0,R.useRef)(void 0),l=(0,R.useRef)(void 0);(0,R.useEffect)(()=>{let e=()=>{s.current=!1,window.clearTimeout(c.current),window.clearTimeout(l.current),c.current=void 0,l.current=void 0,o(!1)};return document.documentElement.addEventListener(`mouseleave`,e),()=>{document.documentElement.removeEventListener(`mouseleave`,e),window.clearTimeout(c.current),window.clearTimeout(l.current)}},[]);let u=e.headings.reduce((e,t)=>Math.min(e,t.level),6);return(0,z.jsxs)(`div`,{className:t,"data-open":a?`true`:`false`,onPointerEnter:()=>{s.current=!0,window.clearTimeout(l.current),l.current=void 0,!(a||c.current!==void 0)&&(c.current=window.setTimeout(()=>{c.current=void 0,s.current&&o(!0)},R5))},onPointerLeave:()=>{s.current=!1,window.clearTimeout(c.current),c.current=void 0,window.clearTimeout(l.current),l.current=window.setTimeout(()=>{l.current=void 0,!s.current&&o(!1)},z5)},children:[e.headings.map(t=>(0,z.jsx)(`span`,{className:n,"data-diffmap-kind":`toc-line`,"data-level":t.level,"data-current":e.activeId===t.id||t.currentPage===!0?`true`:`false`,style:{width:q5(t.level,u)}},t.id)),(0,z.jsx)(Ow.div,{className:r,style:{y:`-50%`},initial:!1,animate:a?{opacity:1,scale:1}:{opacity:0,scale:i?1:.94},transition:i?U5:a?V5:H5,"data-diffmap-kind":`toc-card`,"data-open":a?`true`:`false`,"aria-hidden":!a,inert:!a,children:e.children})]})}function X5(e){return(0,z.jsx)(`ol`,{className:e.className,children:e.items.map(t=>(0,z.jsx)(Z5,{...e,item:t},t.id))})}function Z5(e){let t=V(r7.item),n=V(r7.link),r=e.activeId===e.item.id,i=e.item.page;return(0,z.jsxs)(`li`,{className:t,children:[i!==void 0&&e.pageHref!==void 0?(0,z.jsx)(`a`,{className:n,href:e.pageHref(i),"data-diffmap-kind":`toc-page`,"aria-current":e.item.currentPage===!0?`page`:void 0,onClick:t=>e.onPage(t,i),children:e.item.text}):(0,z.jsx)(`a`,{className:n,href:`#${e.item.id}`,"aria-current":r?`location`:void 0,onClick:t=>{let n=document.getElementById(e.item.id);n&&(t.preventDefault(),e.onSelect(e.item.id),n.scrollIntoView({behavior:`smooth`,block:`start`}),history.pushState({},``,`#${e.item.id}`))},children:e.item.text}),e.item.children.length>0&&(0,z.jsx)(X5,{...e,items:e.item.children})]})}function Q5(e){return e[0]?.level===1?e.slice(1):e}function $5(e){let t=[],n=[];for(let r of e){let e={...r,children:[]};for(;n.length>0;){let e=n[n.length-1];if(e===void 0||e.level<r.level)break;n.pop()}let i=n[n.length-1];i===void 0?t.push(e):i.children.push(e),n.push(e)}return t}function e7(e){let[t,n]=(0,R.useState)(!1);return(0,R.useLayoutEffect)(()=>{let t=e.current;if(t===null)return;let r=()=>{t.clientWidth!==0&&n(t.clientWidth>=W5)};r();let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function t7(e,t){let[n,r]=(0,R.useState)();return(0,R.useEffect)(()=>{let n=Q5(e).map(e=>e.id),i=n.flatMap(e=>{let t=document.getElementById(e);return t?[t]:[]});if(i.length===0)return;let a=t.current??void 0,o=new Set,s=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting?o.add(t.target.id):o.delete(t.target.id);let t=n.find(e=>o.has(e));t!==void 0&&r(t)},{root:a,rootMargin:`0px 0px -70% 0px`,threshold:0});for(let e of i)s.observe(e);return()=>s.disconnect()},[t,e]),{activeId:n,setActiveId:r}}var n7={"& ol":{listStyle:`none`,counterReset:`none`,margin:0,padding:0},"& ol, & li":{display:`flex`,flexDirection:`column`,gap:`1px`},"& ol ol":{paddingInlineStart:Y.value(6)},"& ol > li::before":{content:`none`},"& a":{fontWeight:400,textDecoration:`none`}},r7={rail:B({gridColumn:`1`,gridRow:`1`,position:`sticky`,top:0,alignSelf:`start`,justifySelf:`stretch`,boxSizing:`border-box`,width:`100%`,minWidth:0,height:`100cqh`,zIndex:3,display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`flex-start`,pointerEvents:`none`,"@media (max-width: 600px)":{display:`none`}}),cluster:B(Y.padding({top:4,bottom:4,left:2,right:6}),{position:`relative`,minWidth:`40px`,display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:`12px`,pointerEvents:`auto`,"&[data-open='true'] [data-diffmap-kind='toc-line']":{opacity:0}}),line:B({display:`block`,height:`1px`,flexShrink:0,borderRadius:`999px`,backgroundColor:G.gray[8],opacity:1,transition:`opacity ${String(B5)}ms ${Zd}`,"@media (prefers-reduced-motion: reduce)":{transition:`none`},"&[data-current='true']":{backgroundColor:G.gray[12]}}),card:B(Fd.lg,Vd.medium,yd.element,Y.padding({x:3,y:3}),{position:`absolute`,insetInlineStart:0,top:`50%`,zIndex:1,boxSizing:`border-box`,width:`min(240px, calc(100cqw - 24px))`,maxHeight:`min(32rem, calc(100cqh - 24px))`,overflowX:`hidden`,overflowY:`auto`,overscrollBehavior:`contain`,transformOrigin:`left center`,pointerEvents:`none`,"&[data-open='true']":{pointerEvents:`auto`},...n7}),docked:B(Y.padding({right:6}),{boxSizing:`border-box`,width:`100%`,maxWidth:`240px`,maxHeight:`calc(100cqh - 24px)`,overflowX:`hidden`,overflowY:`auto`,overscrollBehavior:`contain`,pointerEvents:`auto`,...n7}),drawer:B(Y.padding({x:3,y:3}),n7),list:B(J({size:`sm`,fontWeight:400,color:`lowContrast`})),item:B({"&::before":{content:`none`}}),link:B(Fd.sm,Y.padding({x:4,y:2}),J({size:`sm`,fontWeight:400,color:`lowContrast`}),Ud(),{display:`block`,overflowWrap:`anywhere`,cursor:`pointer`,"&:hover":{backgroundColor:G.gray[3]},"&[aria-current='location']":{color:G.accent[9],fontWeight:500,backgroundColor:G.accent[3]},"&[aria-current='location']:hover":{backgroundColor:G.accent[4]},"&[data-diffmap-kind='toc-page']":{color:G.gray[12],fontWeight:500},"&[aria-current='page']":{backgroundColor:G.gray[3]}})};function i7(e){let t=e.document,n=o7(e.mode===`local`),[r,i]=(0,R.useState)(),[a,o]=(0,R.useState)(!1),s=e.mode===`local`,c=e.defaultRev??t.changeCards[0]?.rev??t.references.find(e=>e.rev!==void 0)?.rev??(s?`all`:`working`),[l,u]=(0,R.useState)(c),d=e=>{i(e),u(e.reference.rev??(s?`working`:c))},f=s||t.references.length>0||t.changeCards.length>0||e.defaultRev!==void 0,p=f&&a,m=t.changeCards.find(e=>e.rev===l&&e.review.length>0)?.review??a7,h=V(l7.body),[g,_]=(0,R.useState)(!1),v=e.title??t.headings.find(e=>e.level===1)?.text??`diffmap`,y=e.spec,b=yG(y)?y.title:e.mode===`local`&&n!==void 0?n.title:v,x=yG(y)?`${y.current.title} · ${y.title}`:b,S=V(l7.shell),C=V(l7.header),w=V(l7.heading),T=V(l7.title),E=V(l7.actions),D=V(l7.article),O=V(l7.prose),k=V(l7.column),A=V(mf(`md`),l7.content,S5),j=(0,R.useRef)(null),M=f4(d4(y?.href(y.current)??window.location.pathname)),ee=V(l7.reconnecting),te=t5()===`disconnected`,N=s7(e.pageLoading===!0,150),ne=V(l7.stage),re=(0,R.useRef)(null),P=G5(t.headings,y),[ie,F]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{document.title=x},[x]),(0,R.useEffect)(()=>{p&&U0({event:`diff_opened`})},[p]),(0,R.useEffect)(()=>re.current===null?void 0:W0(re.current),[]),(0,R.useEffect)(()=>{let e=decodeURIComponent(window.location.hash.replace(/^#/,``));e!==``&&document.getElementById(e)?.scrollIntoView({block:`start`})},[]),g?(0,z.jsx)(G8,{tone:`neutral`,icon:Yz,title:`Server closed`,children:(0,z.jsxs)(FB,{children:[`You closed the server for `,b,`. Run diffmap serve again to reopen it.`]})}):(0,z.jsx)(A4.Provider,{value:e.mode,children:(0,z.jsx)(_G.Provider,{value:y,children:(0,z.jsx)(l4.Provider,{value:M,children:(0,z.jsxs)(`div`,{className:S,children:[(0,z.jsxs)(`header`,{className:C,children:[(0,z.jsxs)(`div`,{className:w,children:[P&&(0,z.jsx)(N5,{expanded:ie,onClick:()=>F(!0)}),(0,z.jsx)(`div`,{className:T,children:b}),N&&(0,z.jsx)(nz,{size:`xs`,"aria-label":`Loading page`})]}),(0,z.jsxs)(`div`,{className:E,children:[(0,z.jsx)(n5,{title:b,source:s?n?.file:`${window.location.origin}${window.location.pathname}`}),f&&(0,z.jsx)(j5,{pressed:a,onClick:()=>o(e=>!e)}),e.headerActions,s&&te&&(0,z.jsxs)(`div`,{className:ee,role:`status`,title:`The diffmap server stopped. This page reloads when diffmap serve runs again.`,children:[(0,z.jsx)(nz,{size:`xs`,variant:`muted`}),`Server stopped · reconnecting`]}),s&&!te&&(0,z.jsx)(U8,{onClick:()=>{U0({event:`server_closed`}),e5(`closed`),_(!0),c7()}})]})]}),(0,z.jsx)(`div`,{className:ne,children:(0,z.jsxs)(`div`,{className:h,"data-has-source-diffs":p,children:[(0,z.jsx)(`article`,{ref:re,className:D,children:(0,z.jsxs)(`div`,{className:O,"data-has-toc":P?`true`:`false`,children:[(0,z.jsxs)(`div`,{className:k,children:[(0,z.jsx)(`div`,{ref:j,className:A,"data-diffmap-kind":`page`,children:(0,z.jsx)(e8,{document:t,selectedAnnotation:r?.annotation,onSelectAnnotation:e=>{U0({event:`reference_opened`}),o(!0),d({annotation:e,reference:e.references[0]})}})}),(0,z.jsx)(SG,{})]}),(0,z.jsx)(x5,{contentRef:j}),P&&(0,z.jsx)(J5,{headings:t.headings,articleRef:re,drawerOpen:ie,onDrawerOpenChange:F})]})}),p&&(0,z.jsx)(I8,{rev:l,review:m,onRevChange:s?e=>{U0({event:`range_changed`}),i(void 0),u(e)}:void 0,selection:r,onSelect:d,onClose:()=>o(!1)})]})})]})})})})}var a7=[];function o7(e){let[t,n]=(0,R.useState)();return(0,R.useEffect)(()=>{e&&fetch(`/__diffmap/meta`).then(e=>e.json()).then(e=>{n(e)})},[e]),t}function s7(e,t){let[n,r]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{if(!e)return;let n=setTimeout(()=>r(!0),t);return()=>{clearTimeout(n),r(!1)}},[e,t]),e&&n}async function c7(){await fetch(`/__diffmap/shutdown`,{method:`POST`})}var l7={shell:B(Yd({direction:`column`}),{width:`100%`,height:`100vh`,minWidth:0,minHeight:0,overflow:`hidden`,backgroundColor:G.gray[4]}),header:B(Yd({direction:`row`,alignItems:`center`,justifyContent:`between`}),Y.padding({x:6,y:3}),Xd({size:`hug`}),Md([`bottom`],`border`),{minWidth:0,backgroundColor:K.app}),heading:B(Yd({direction:`row`,alignItems:`center`,gap:3}),{minWidth:0,flex:`1 1 auto`}),title:B(J({size:`md`,fontWeight:600,color:`highContrast`}),{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),actions:B(Yd({direction:`row`,alignItems:`center`,gap:3}),{flexShrink:0}),stage:B(Yd({direction:`column`}),{position:`relative`,flex:`1 1 auto`,minWidth:0,minHeight:0}),body:B({display:`grid`,gridTemplateRows:`minmax(0, 1fr)`,flex:`1 1 auto`,minHeight:0,minWidth:0,overflow:`hidden`,backgroundColor:K.app,"--diffmap-columns":`minmax(0, 1fr)`,"--diffmap-areas":`"article"`,gridTemplateColumns:`var(--diffmap-columns)`,gridTemplateAreas:`var(--diffmap-areas)`,"&[data-has-source-diffs='true']":{"--diffmap-columns":`minmax(0, 1fr) minmax(0, 1fr)`,"--diffmap-areas":`"article diff"`},"@media (max-width: 900px)":{gridTemplateColumns:`minmax(0, 1fr)`,gridTemplateRows:`minmax(0, 1fr) auto`,gridTemplateAreas:`"article" "diff"`}}),article:B(Y.padding({x:12,y:12}),{gridArea:`article`,flex:`1 1 auto`,minWidth:0,minHeight:0,overflowY:`auto`,backgroundColor:K.app,containerType:`size`,"@media (max-width: 600px)":{paddingInline:Y.value(6),paddingBlock:Y.value(8)}}),prose:B({display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, ${rf}) minmax(0, 1fr)`,width:`100%`,maxWidth:`none`,minWidth:0,"&[data-has-toc='true']":{gridTemplateColumns:`var(--diffmap-toc-columns, minmax(48px, 1fr) minmax(0, ${rf}) minmax(48px, 1fr))`},"@media (max-width: 600px)":{"--diffmap-toc-columns":`0 minmax(0, 1fr) 0`}}),column:B({gridColumn:`2 / 3`,gridRow:`1`,minWidth:0}),content:B({width:`100%`,maxWidth:`none`,minWidth:0,"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:Y.value(4)},"& ul > li[data-task]::before, & ol > li[data-task]::before":{content:`none`}}),reconnecting:B(Yd({direction:`row`,alignItems:`center`,gap:3}),J({size:`sm`,color:`lowContrast`}),{whiteSpace:`nowrap`})},u7=document.getElementById(`root`);if(u7===null)throw Error(`diffmap root element is missing`);async function d7(e){let t=await fetch(e);if(!t.ok)throw Error(`${e} answered ${String(t.status)}`);return await t.json()}async function f7(e){return await d7(`/__diffmap/document?${new URLSearchParams({page:e})}`)}function p7(){return decodeURIComponent(window.location.pathname).replace(/^\/+|\/+$/g,``)}function m7(e){return`/${encodeURIComponent(e.slug)}`}function h7(e){if(e.page===void 0)return;let t=m7(e.page);window.location.pathname!==t&&window.history.replaceState(window.history.state,``,`${t}${window.location.hash}`)}var g7=Promise.all([f7(p7()),d7(`/__diffmap/spec`)]),_7;H0(),U0({event:`viewer_opened`});function v7(e){e.viewerDocument===void 0&&U0({event:`viewer_error`,kind:`document`})}var y7=document.querySelector(`meta[name="diffmap-reload-token"]`)?.content??``,b7=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/__diffmap/events?${new URLSearchParams({token:y7})}`,x7=!1,S7=1e3;C7();function C7(){let e=new WebSocket(b7),t=!1;e.addEventListener(`message`,e=>{(e.data===`pages`||e.data===_7)&&window.location.reload()}),e.addEventListener(`open`,()=>{t=!0,x7=!0,S7=1e3,e5(`connected`)}),e.addEventListener(`close`,()=>{t?(e5(`disconnected`),setTimeout(C7,1e3)):x7&&setTimeout(w7,1e3)})}function w7(){fetch(`/__diffmap/meta`).then(e=>e.ok?e.json():void 0).then(e=>{e===void 0?setTimeout(w7,1e3):e.reloadToken===y7?(setTimeout(C7,S7),S7=Math.min(S7*2,1e4)):window.location.reload()},()=>setTimeout(w7,1e3))}function T7(){fetch(`/__diffmap/meta`).then(e=>{e.ok?window.location.reload():setTimeout(T7,1e3)},()=>setTimeout(T7,1e3))}function E7(){let[e,t]=(0,R.useState)();return(0,R.useEffect)(()=>{g7.then(([e,n])=>{h7(e),_7=e.page?.file,v7(e),t({page:e,spec:n})},e=>{t(e instanceof Error?e:Error(String(e))),setTimeout(T7,1e3)})},[]),e===void 0?(0,z.jsx)(D7,{}):e instanceof Error?(0,z.jsx)(G8,{tone:`danger`,icon:wB,title:`Can't reach the diffmap server`,actions:(0,z.jsx)(q8,{}),children:(0,z.jsx)(FB,{children:`The server that opened this page isn't answering. Run diffmap serve again and this page reloads on its own.`})}):(0,z.jsx)(O7,{initialPage:e.page,spec:`error`in e.spec?void 0:e.spec})}function D7(){let e=V(A7.boot);return(0,z.jsx)(`div`,{className:e,children:(0,z.jsx)(OH,{})})}function O7(e){let[t,n]=(0,R.useState)(e.initialPage),[r,i]=(0,R.useState)(!1),a=e.spec,o=(e,t)=>{i(!0),f7(e).then(e=>{i(!1),t?.(e),(e.page?.file!==_7||e.viewerDocument===void 0)&&(v7(e),_7=e.page?.file,n(e))},()=>i(!1))},s=(0,R.useEffectEvent)(()=>o(p7()));(0,R.useEffect)(()=>(window.addEventListener(`popstate`,s),()=>window.removeEventListener(`popstate`,s)),[]);let c=a?.pages.find(e=>e.file===t.page?.file)??t.page;return t.missingPage===void 0?t.specError===void 0?t.viewerDocument===void 0?(0,z.jsx)(Y8,{title:`This page has an error`,file:t.page?.file??`This page`,message:t.parseError??`Unknown parse error.`,children:(0,z.jsx)(FB,{children:`Fix the problem below and save the file. This page reloads on its own.`})}):(0,z.jsx)(V6.Provider,{value:H6,children:(0,z.jsx)(i7,{document:t.viewerDocument,mode:`local`,pageLoading:r,spec:a===void 0||c===void 0?void 0:{title:a.title,pages:a.pages,current:c,href:m7,navigate:(e,t)=>o(e.slug,()=>window.history.pushState({},``,`${m7(e)}${t}`))}},c?.file)}):(0,z.jsx)(G8,{tone:`danger`,icon:fB,title:`Can't read this spec`,detail:t.specError,children:(0,z.jsx)(FB,{children:`diffmap couldn't read the spec it's serving. Fix the problem below; this page reloads when the spec's files change.`})}):(0,z.jsx)(G8,{tone:`neutral`,icon:pB,title:`Page not found`,actions:(0,z.jsx)(K8,{href:`/`,variant:`primary`,children:`Go to the cover page`}),footer:a!==void 0&&(0,z.jsx)(k7,{pages:a.pages}),children:(0,z.jsxs)(FB,{children:[`This spec has no page at /`,t.missingPage,`. It may have been renamed or removed since this link was made.`]})})}function k7(e){return(0,z.jsxs)(zH,{column:!0,gap:3,pt:6,children:[(0,z.jsx)(LB,{children:`Pages in this spec`}),e.pages.map(e=>(0,z.jsx)(zB,{href:m7(e),children:e.title},e.file))]})}var A7={boot:B({display:`flex`,width:`100%`,height:`100vh`})};(0,ui.createRoot)(u7).render((0,z.jsx)(R.StrictMode,{children:(0,z.jsx)(kd,{children:(0,z.jsx)(E7,{})})}));export{HK as a,EK as c,wK as d,_K as f,UW as g,YW as h,Cq as i,TK as l,SK as m,QJ as n,AK as o,xK as p,EJ as r,OK as s,lY as t,CK as u};
264
+ }`,V8={panel:B(Yd({direction:`column`}),Md([`left`],`border`),{position:`relative`,gridArea:`diff`,minWidth:0,minHeight:0,overflow:`hidden`,backgroundColor:K.app,"@media (max-width: 900px)":{height:`45vh`,borderLeft:`none`,borderTop:`1px solid ${Ad.border}`}}),header:B(Yd({direction:`column`}),Y.padding({y:3}),{paddingInline:`7px`},Md([`bottom`],`border`),J({size:`sm`,color:`lowContrast`}),{gap:`6px`,minWidth:0,maxHeight:`35%`,overflowY:`auto`,flexShrink:0,position:`relative`,"@media (max-width: 900px)":{paddingRight:`calc(${nf.smHeight} + 14px)`,minHeight:`calc(${nf.smHeight} + 12px)`}}),close:B({display:`none`,"@media (max-width: 900px)":{display:`flex`,position:`absolute`,top:`6px`,right:`7px`,width:nf.smHeight}}),summary:B({marginLeft:`auto`,marginRight:`9px`}),titleRow:B(Yd({direction:`row`,alignItems:`center`}),{gap:`6px`,minWidth:0}),title:B(J({size:`sm`,fontWeight:600,color:`highContrast`}),{minWidth:0,flex:`1 1 auto`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),pin:B(J({size:`sm`,color:`lowContrast`}),{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,textDecoration:`none`,"&:is(a):hover":{textDecoration:`underline`}}),links:B(Yd({direction:`row`}),{gap:`6px`,flexWrap:`wrap`}),codeWrap:B({display:`flex`,flexDirection:`column`,flex:`1 1 auto`,minWidth:0,minHeight:0,"&[data-cards='true']":{backgroundColor:G.gray[2]},"&[data-cards='true'] diffs-container":{marginInline:`${String(L8)}px`,borderRadius:`8px`,boxShadow:Bd.subtle,overflow:`clip`}}),dimmed:B(ef.standard(`opacity`),{"&[data-loading='true']":{opacity:.4,transitionDelay:`150ms`}}),body:B({position:`relative`,display:`flex`,flexDirection:`column`,flex:`1 1 auto`,minWidth:0,minHeight:0}),loading:B(ef.standard(`opacity`),{position:`absolute`,inset:0,display:`flex`,backgroundColor:K.app,"&[data-cards='true']":{backgroundColor:G.gray[2]},pointerEvents:`none`,opacity:0,"&[data-loading='true']":{opacity:1,transitionDelay:`150ms`}}),fileHeader:B(Yd({direction:`row`,alignItems:`center`}),J({size:`sm`,color:`lowContrast`}),{gap:`8px`,minHeight:`35px`,paddingInline:`12px`,"& .meta":{display:`flex`,alignItems:`center`,gap:`8px`,flexShrink:0},"& .status":{fontFamily:`inherit`,fontSize:`inherit`},"& :is(.file-name, .head, .tail), & .stat > span":{textBox:`trim-both cap alphabetic`},"& [title], & :is(.file-name, .file-folder, .head, .tail)":{overflow:`visible`,overflowX:`clip`,minWidth:0},"& [data-reviewed]":{cursor:`default`},"& .status[data-status='new']":{backgroundColor:G.greenAlpha[3],color:G.green[11]},"& .status[data-status='deleted']":{backgroundColor:G.redAlpha[3],color:G.red[11]}}),collapseIcon:B({display:`flex`,color:G.gray[11],transition:`transform 150ms ease-out`,"&[data-collapsed='true']":{transform:`rotate(-90deg)`}}),code:B({flex:`1 1 auto`,minWidth:0,minHeight:0,overflow:`auto`})},H8=B({color:G.red[9]});function U8(e){let t=V(H8);return(0,z.jsxs)(Vz,{variant:`default`,onClick:e.onClick,children:[(0,z.jsx)(Yz,{className:t,size:`sm`}),`Close server`]})}var W8={neutral:G.gray,info:G.blue,warning:G.amber,danger:G.red};function G8(e){let t=V(Z8.shell),n=V(Z8.header),r=V(Z8.wordmark),i=V(Z8.body),a=V(Z8.column),o=V(Z8.badge,X8[e.tone]),s=V(Z8.description),c=V(Z8.actions),l=e.icon;return(0,z.jsxs)(`div`,{className:t,children:[(0,z.jsx)(`header`,{className:n,children:(0,z.jsx)(`div`,{className:r,children:`diffmap`})}),(0,z.jsx)(`main`,{className:i,children:(0,z.jsxs)(`div`,{className:a,children:[(0,z.jsx)(`div`,{className:o,"aria-hidden":`true`,children:(0,z.jsx)(l,{size:`lg`})}),(0,z.jsx)(MB,{children:e.title}),(0,z.jsx)(`div`,{className:s,children:e.children}),e.detail!==void 0&&(0,z.jsx)(nB,{tone:e.tone,layout:e.detailTitle===void 0?`inline`:`stacked`,title:e.detailTitle,icon:!1,role:e.tone===`danger`?`alert`:`status`,children:e.detail}),e.actions!==void 0&&(0,z.jsx)(`div`,{className:c,children:e.actions}),e.footer]})})]})}function K8(e){let t=V(Bz.root({variant:e.variant}),Z8.link);return(0,z.jsx)(bI,{className:t,href:e.href,children:e.children})}function q8(e){return(0,z.jsxs)(Vz,{variant:`primary`,onPress:()=>window.location.reload(),children:[(0,z.jsx)(TB,{size:`sm`}),e.label??`Try again`]})}function J8(e){let t=V(Z8.code);return(0,z.jsx)(`code`,{className:t,children:e.children})}function Y8(e){return(0,z.jsx)(G8,{tone:`danger`,icon:fB,title:e.title??`This walkthrough has an error`,detailTitle:(0,z.jsx)(J8,{children:e.file}),detail:e.message,actions:e.actions,children:e.children})}var X8=Object.fromEntries(Object.entries(W8).map(([e,t])=>[e,B({backgroundColor:t[3],color:t[11]})])),Z8={shell:B(Yd({direction:`column`}),{width:`100%`,height:`100vh`,minWidth:0,minHeight:0,overflow:`hidden`,backgroundColor:K.app}),header:B(Yd({direction:`row`,alignItems:`center`}),Y.padding({x:6,y:3}),Xd({size:`hug`}),Md([`bottom`],`border`),{minWidth:0,minHeight:`37px`}),wordmark:B(J({size:`md`,fontWeight:600,color:`highContrast`})),body:B(Y.padding({x:8}),{flex:`1 1 auto`,minWidth:0,minHeight:0,overflowY:`auto`,paddingTop:`min(16vh, 160px)`,paddingBottom:Y.value(16)}),loadingBody:B(Yd({direction:`column`}),{flex:`1 1 auto`,minWidth:0,minHeight:0}),column:B(Yd({direction:`column`,gap:6}),{width:`100%`,maxWidth:`34rem`,marginInline:`auto`}),badge:B(Yd({direction:`row`,alignItems:`center`,justifyContent:`center`}),Fd.lg,{width:`40px`,height:`40px`}),description:B(Yd({direction:`column`,gap:4}),J({size:`md`,color:`lowContrast`}),{"& p":{color:`inherit`}}),actions:B(Yd({direction:`row`,alignItems:`center`,gap:4}),{flexWrap:`wrap`,paddingTop:Y.value(2)}),link:B({textDecoration:`none`}),code:B(J({size:`sm`,color:`highContrast`,monospace:!0}),{overflowWrap:`anywhere`})},Q8=`connected`,$8=new Set;function e5(e){if(Q8!==`closed`&&Q8!==e){Q8=e;for(let e of $8)e()}}function t5(){return(0,R.useSyncExternalStore)(e=>($8.add(e),()=>$8.delete(e)),()=>Q8)}function n5(e){let{comments:t}=u4(),n=vG(),r=yG(n)?n.pages.map(e=>({title:e.title,comments:e===n.current?t:p4(d4(n.href(e)))})):void 0,i=r===void 0?t.length:r.reduce((e,t)=>e+t.comments.length,0),[a,o]=(0,R.useState)(!1),s=V(Bz.label,r5);if((0,R.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),1500);return()=>clearTimeout(e)},[a]),i!==0)return(0,z.jsxs)(Vz,{onPress:()=>{let n=m4({title:e.title,source:e.source,comments:t,pages:r});navigator.clipboard.writeText(n).then(()=>{o(!0),U0({event:`comments_copied`})},e=>console.warn(`diffmap copy failed`,e))},children:[a?(0,z.jsx)(aB,{size:`sm`}):(0,z.jsx)(lB,{size:`sm`}),a?`Copied`:`Copy comments`,(0,z.jsx)(`span`,{className:s,children:i})]})}var r5=B({color:G.gray[11],fontVariantNumeric:`tabular-nums`}),i5=32;function a5(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],r=``;for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e;n.push({node:t,start:r.length}),r+=t.data}return{text:r,nodes:n}}function o5(e,t,n){let{text:r}=a5(e),i=l5(e,t.startContainer,t.startOffset),a=l5(e,t.endContainer,t.endOffset),o=r.slice(i,a);if(o.trim()!==``)return{kind:`text`,quote:o,prefix:r.slice(Math.max(0,i-i5),i),suffix:r.slice(a,a+i5),offset:i,display:n,section:d5(e,t.startContainer)}}function s5(e,t){let n;for(let r=e.text.indexOf(t.quote);r!==-1;r=e.text.indexOf(t.quote,r+1)){let i=e.text.slice(Math.max(0,r-i5),r),a=e.text.slice(r+t.quote.length,r+t.quote.length+i5),o=p5(i,t.prefix)+f5(a,t.suffix),s=Math.abs(r-t.offset);(n===void 0||o>n.score||o===n.score&&s<n.distance)&&(n={at:r,score:o,distance:s})}if(n!==void 0)return u5(e,n.at,n.at+t.quote.length)}function c5(e){let t=e.startContainer,n=(t instanceof Element?t:t.parentElement)?.closest(`details:not([open])`);return n==null?[...e.getClientRects()].filter(e=>e.width>0)[0]??e.getBoundingClientRect():(n.querySelector(`summary`)??n).getBoundingClientRect()}function l5(e,t,n){let r=document.createRange();return r.setStart(e,0),r.setEnd(t,n),r.toString().length}function u5(e,t,n){let r=e.nodes.find(e=>t<e.start+e.node.data.length),i=e.nodes.findLast(e=>n>e.start);if(r===void 0||i===void 0)return;let a=document.createRange();return a.setStart(r.node,t-r.start),a.setEnd(i.node,n-i.start),a}function d5(e,t){let n=[...e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)].findLast(e=>e.contains(t)||(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)!==0)?.textContent?.trim();return n===``?void 0:n}function f5(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function p5(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var m5=24,h5=16,g5=220,_5=300,v5=360,y5=8,b5=`draft`;function x5(e){let t=u4(),n=(0,R.useRef)(null),r=(0,R.useRef)(new Map),[i,a]=(0,R.useState)(),[o,s]=(0,R.useState)({}),[c,l]=(0,R.useState)(),[u]=(0,R.useState)(()=>new ResizeObserver(e=>{s(t=>{let n={...t};for(let t of e){let e=t.target.dataset.commentId;e!==void 0&&(n[e]=t.borderBoxSize[0].blockSize)}return n})})),d=V(A5.layer),f=V(A5.slot),p=V(Bz.root({variant:`default`}),A5.add),m=V(Bz.label),h=t.comments.filter(e=>e.anchor.kind===`text`),g=t.draft?.kind===`text`?t.draft:void 0,_=(0,R.useEffectEvent)(()=>{let i=e.contentRef.current,o=n.current;if(i===null||o===null)return;let s=a5(i),c=o.getBoundingClientRect(),l=i.getBoundingClientRect(),u={},d=[],f=[];r.current.clear();let p=(e,n)=>{let i=s5(s,n);u[e]=i===void 0?void 0:T5(c5(i),c),i!==void 0&&(r.current.set(e,i),(e===t.activeId||e===b5?f:d).push(i))};for(let e of h)p(e.id,e.anchor);g!==void 0&&p(b5,g),w5(`diffmap-comment`,d),w5(`diffmap-comment-active`,f);let m={width:c.width,contentLeft:l.left-c.left,contentRight:l.right-c.left,anchors:u};a(e=>JSON.stringify(e)===JSON.stringify(m)?e:m)});(0,R.useLayoutEffect)(()=>{_()},[t.comments,t.draft,t.activeId]),(0,R.useEffect)(()=>{let t=e.contentRef.current,r=n.current;if(t===null||r===null)return;let i=0,a=()=>{cancelAnimationFrame(i),i=requestAnimationFrame(()=>_())},o=new ResizeObserver(a);o.observe(t),o.observe(r);let s=new MutationObserver(a);return s.observe(t,{subtree:!0,childList:!0,characterData:!0}),()=>{cancelAnimationFrame(i),o.disconnect(),s.disconnect(),w5(`diffmap-comment`,[]),w5(`diffmap-comment-active`,[])}},[e.contentRef]),(0,R.useEffect)(()=>{let t=!1,r=()=>{let r=e.contentRef.current,i=n.current,a=document.getSelection();if(t||r===null||i===null||a===null||a.rangeCount===0||a.isCollapsed){l(void 0);return}let o=a.getRangeAt(0),s=[...o.getClientRects()].filter(e=>e.width>0);if(!r.contains(o.commonAncestorContainer)||o.toString().trim()===``||s.length===0){l(void 0);return}let c=i.getBoundingClientRect(),u=T5(s[0],c),d=T5(s.at(-1),c);l({range:o.cloneRange(),display:a.toString(),box:{top:u.top,left:u.left,bottom:d.bottom,right:d.right}})},i=e=>{D5(e.target,`[data-comment-add]`)||(t=!0,l(void 0))},a=()=>{t&&(t=!1,setTimeout(r))};return document.addEventListener(`selectionchange`,r),document.addEventListener(`pointerdown`,i),document.addEventListener(`pointerup`,a),()=>{document.removeEventListener(`selectionchange`,r),document.removeEventListener(`pointerdown`,i),document.removeEventListener(`pointerup`,a)}},[e.contentRef]);let v=(0,R.useEffectEvent)(e=>{if(D5(e.target,`[data-comment-card], [data-comment-add]`)||document.getSelection()?.isCollapsed===!1)return;let n=O5(e.clientX,e.clientY),i=n===void 0?void 0:[...r.current].find(([e,t])=>e!==b5&&k5(t,n.node,n.offset))?.[0];t.setActiveId(i)});(0,R.useEffect)(()=>{let e=e=>v(e);return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[]);let y=()=>{let n=e.contentRef.current;if(c===void 0||n===null)return;let r=o5(n,c.range,c.display);r!==void 0&&(t.startDraft(r),document.getSelection()?.removeAllRanges(),l(void 0))},b=[...h.map(e=>({id:e.id,comment:e})),...g===void 0?[]:[{id:b5,comment:void 0}]].filter(e=>i!==void 0&&e.id in i.anchors),x=i===void 0?0:i.width-i.contentRight-m5-h5,S=x>=g5,C=g===void 0?t.activeId:b5,w=[];if(i!==void 0&&S){let e=C5(b.map(e=>({id:e.id,anchorTop:i.anchors[e.id]?.top??0,anchorLeft:i.anchors[e.id]?.left??0,height:o[e.id]??80})),C);for(let t of b)w.push({id:t.id,top:e[t.id],left:i.contentRight+m5,width:Math.min(_5,x)})}else if(i!==void 0&&C!==void 0){let e=i.anchors[C],t=Math.min(v5,i.contentRight-i.contentLeft);b.some(e=>e.id===C)&&w.push({id:C,top:e===void 0?0:e.bottom+y5,left:E5(e?.left??i.contentLeft,i.contentLeft,i.contentRight-t),width:t})}return(0,z.jsxs)(`div`,{ref:n,className:d,"aria-label":`Comments`,children:[w.map(e=>{let t=b.find(t=>t.id===e.id)?.comment;return(0,z.jsx)(`div`,{className:f,"data-comment-id":e.id,"data-floating":!S,ref:e=>{if(e!==null)return u.observe(e),()=>u.unobserve(e)},style:{transform:`translateY(${String(e.top)}px)`,left:e.left,width:e.width},children:(0,z.jsx)(v4,{comment:t,detached:i?.anchors[e.id]===void 0})},e.id)}),c!==void 0&&g===void 0&&i!==void 0&&(0,z.jsxs)(`button`,{type:`button`,className:p,"data-comment-add":``,style:{top:c.box.top-y5,left:E5(c.box.left,i.contentLeft,i.contentRight-120)},onMouseDown:e=>e.preventDefault(),onClick:y,children:[(0,z.jsx)(bB,{size:`sm`}),(0,z.jsx)(`span`,{className:m,children:`Comment`})]})]})}var S5=B({"& ::highlight(diffmap-comment), &::highlight(diffmap-comment)":{backgroundColor:G.amberAlpha[5]},"& ::highlight(diffmap-comment-active), &::highlight(diffmap-comment-active)":{backgroundColor:G.amberAlpha[8]}});function C5(e,t){let n=e.toSorted((e,t)=>Math.round(e.anchorTop)-Math.round(t.anchorTop)||e.anchorLeft-t.anchorLeft),r=Math.max(0,n.findIndex(e=>e.id===t)),i={};for(let e=r;e<n.length;e++){let t=n[e],a=n[e-1];i[t.id]=e===r||a===void 0?t.anchorTop:Math.max(t.anchorTop,i[a.id]+a.height+y5)}for(let e=r-1;e>=0;e--){let t=n[e],r=n[e+1];i[t.id]=Math.min(t.anchorTop,i[r.id]-t.height-y5)}return i}function w5(e,t){typeof CSS>`u`||!(`highlights`in CSS)||(t.length===0?CSS.highlights.delete(e):CSS.highlights.set(e,new Highlight(...t)))}function T5(e,t){return{top:e.top-t.top,bottom:e.bottom-t.top,left:e.left-t.left,right:e.right-t.left}}function E5(e,t,n){return Math.max(t,Math.min(e,n))}function D5(e,t){return e instanceof Element&&e.closest(t)!==null}function O5(e,t){if(`caretPositionFromPoint`in document){let n=document.caretPositionFromPoint(e,t);return n===null?void 0:{node:n.offsetNode,offset:n.offset}}let n=document.caretRangeFromPoint(e,t);if(n!==null)return{node:n.startContainer,offset:n.startOffset}}function k5(e,t,n){try{return e.isPointInRange(t,n)}catch{return!1}}var A5={layer:B({gridColumn:`1 / -1`,gridRow:`1`,position:`relative`,pointerEvents:`none`,minWidth:0}),slot:B({position:`absolute`,top:0,pointerEvents:`auto`,transition:`transform 120ms ease-out`,"&[data-floating='true']":{zIndex:2},"&[data-floating='true'] > [data-comment-card]":{boxShadow:Bd.strong}}),add:B(Vd.medium,{position:`absolute`,transform:`translateY(-100%)`,pointerEvents:`auto`,zIndex:2})};function j5(e){let t=V(M5);return(0,z.jsxs)(Vz,{className:t,"aria-pressed":e.pressed,"aria-expanded":e.pressed,"aria-controls":`source-diff-panel`,onClick:e.onClick,children:[(0,z.jsx)(_B,{size:`sm`}),`Diff`]})}var M5=B({"&[aria-pressed='true']":{backgroundColor:K.elementActive}});function N5(e){let t=V(P5.button);return(0,z.jsx)(Vz,{className:t,variant:`quiet`,"aria-label":`Table of contents`,"aria-haspopup":`dialog`,"aria-expanded":e.expanded,onClick:e.onClick,children:(0,z.jsx)(OB,{size:`sm`})})}var P5={button:B({flexShrink:0,"@media (min-width: 601px)":{display:`none`}})},F5=12,I5=3,L5=3,R5=50,z5=100,B5=180,V5={type:`spring`,visualDuration:.15,bounce:Qd.dialogEnter.bounce},H5={duration:.09,ease:`easeIn`},U5={duration:Qd.reduced.durationMs/1e3,ease:`easeInOut`},W5=220;function G5(e,t){return Q5(e).length>0||yG(t)}function K5(e,t){let n=Q5(e);return yG(t)?t.pages.flatMap(e=>[{id:`diffmap-page:${e.slug}`,text:e.title,level:1,page:e,currentPage:e===t.current},...e===t.current?n.map(e=>({...e,level:Math.max(e.level,2)})):[]]):n}function q5(e,t){let n=Math.max(0,e-t);return Math.max(I5,F5-n*L5)}function J5(e){let t=vG(),n=K5(e.headings,t),r=$5(n),{activeId:i,setActiveId:a}=t7(e.headings,e.articleRef),o=(0,R.useRef)(null),s=e7(o),c=V(r7.rail),l=V(r7.docked),u=V(r7.drawer),d=V(r7.list);if(r.length===0)return;let f=(n,r)=>{if(t!==void 0){if(r!==t.current){bG(n,t,r);return}n.preventDefault(),e.articleRef.current?.scrollTo({top:0,behavior:`smooth`})}},p=(0,z.jsx)(X5,{items:r,className:d,activeId:i,onSelect:a,onPage:f,pageHref:t?.href});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`nav`,{ref:o,id:`diffmap-toc`,className:c,"aria-label":`Table of contents`,"data-diffmap-kind":`toc`,"data-docked":s?`true`:`false`,children:s?(0,z.jsx)(`div`,{className:l,"data-diffmap-kind":`toc-list`,children:p}):(0,z.jsx)(Y5,{headings:n,activeId:i,children:p})}),(0,z.jsx)(qV,{isOpen:e.drawerOpen,onOpenChange:e.onDrawerOpenChange,"aria-label":`Table of contents`,children:(0,z.jsx)(`nav`,{className:u,"aria-label":`Table of contents`,children:(0,z.jsx)(X5,{items:r,className:d,activeId:i,onSelect:t=>{a(t),e.onDrawerOpenChange(!1)},onPage:(t,n)=>{f(t,n),e.onDrawerOpenChange(!1)},pageHref:t?.href})})})]})}function Y5(e){let t=V(r7.cluster),n=V(r7.line),r=V(r7.card),i=!!iw(),[a,o]=(0,R.useState)(!1),s=(0,R.useRef)(!1),c=(0,R.useRef)(void 0),l=(0,R.useRef)(void 0);(0,R.useEffect)(()=>{let e=()=>{s.current=!1,window.clearTimeout(c.current),window.clearTimeout(l.current),c.current=void 0,l.current=void 0,o(!1)};return document.documentElement.addEventListener(`mouseleave`,e),()=>{document.documentElement.removeEventListener(`mouseleave`,e),window.clearTimeout(c.current),window.clearTimeout(l.current)}},[]);let u=e.headings.reduce((e,t)=>Math.min(e,t.level),6);return(0,z.jsxs)(`div`,{className:t,"data-open":a?`true`:`false`,onPointerEnter:()=>{s.current=!0,window.clearTimeout(l.current),l.current=void 0,!(a||c.current!==void 0)&&(c.current=window.setTimeout(()=>{c.current=void 0,s.current&&o(!0)},R5))},onPointerLeave:()=>{s.current=!1,window.clearTimeout(c.current),c.current=void 0,window.clearTimeout(l.current),l.current=window.setTimeout(()=>{l.current=void 0,!s.current&&o(!1)},z5)},children:[e.headings.map(t=>(0,z.jsx)(`span`,{className:n,"data-diffmap-kind":`toc-line`,"data-level":t.level,"data-current":e.activeId===t.id||t.currentPage===!0?`true`:`false`,style:{width:q5(t.level,u)}},t.id)),(0,z.jsx)(Ow.div,{className:r,style:{y:`-50%`},initial:!1,animate:a?{opacity:1,scale:1}:{opacity:0,scale:i?1:.94},transition:i?U5:a?V5:H5,"data-diffmap-kind":`toc-card`,"data-open":a?`true`:`false`,"aria-hidden":!a,inert:!a,children:e.children})]})}function X5(e){return(0,z.jsx)(`ol`,{className:e.className,children:e.items.map(t=>(0,z.jsx)(Z5,{...e,item:t},t.id))})}function Z5(e){let t=V(r7.item),n=V(r7.link),r=e.activeId===e.item.id,i=e.item.page;return(0,z.jsxs)(`li`,{className:t,children:[i!==void 0&&e.pageHref!==void 0?(0,z.jsx)(`a`,{className:n,href:e.pageHref(i),"data-diffmap-kind":`toc-page`,"aria-current":e.item.currentPage===!0?`page`:void 0,onClick:t=>e.onPage(t,i),children:e.item.text}):(0,z.jsx)(`a`,{className:n,href:`#${e.item.id}`,"aria-current":r?`location`:void 0,onClick:t=>{let n=document.getElementById(e.item.id);n&&(t.preventDefault(),e.onSelect(e.item.id),n.scrollIntoView({behavior:`smooth`,block:`start`}),history.pushState({},``,`#${e.item.id}`))},children:e.item.text}),e.item.children.length>0&&(0,z.jsx)(X5,{...e,items:e.item.children})]})}function Q5(e){return e[0]?.level===1?e.slice(1):e}function $5(e){let t=[],n=[];for(let r of e){let e={...r,children:[]};for(;n.length>0;){let e=n[n.length-1];if(e===void 0||e.level<r.level)break;n.pop()}let i=n[n.length-1];i===void 0?t.push(e):i.children.push(e),n.push(e)}return t}function e7(e){let[t,n]=(0,R.useState)(!1);return(0,R.useLayoutEffect)(()=>{let t=e.current;if(t===null)return;let r=()=>{t.clientWidth!==0&&n(t.clientWidth>=W5)};r();let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function t7(e,t){let[n,r]=(0,R.useState)();return(0,R.useEffect)(()=>{let n=Q5(e).map(e=>e.id),i=n.flatMap(e=>{let t=document.getElementById(e);return t?[t]:[]});if(i.length===0)return;let a=t.current??void 0,o=new Set,s=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting?o.add(t.target.id):o.delete(t.target.id);let t=n.find(e=>o.has(e));t!==void 0&&r(t)},{root:a,rootMargin:`0px 0px -70% 0px`,threshold:0});for(let e of i)s.observe(e);return()=>s.disconnect()},[t,e]),{activeId:n,setActiveId:r}}var n7={"& ol":{listStyle:`none`,counterReset:`none`,margin:0,padding:0},"& ol, & li":{display:`flex`,flexDirection:`column`,gap:`1px`},"& ol ol":{paddingInlineStart:Y.value(6)},"& ol > li::before":{content:`none`},"& a":{fontWeight:400,textDecoration:`none`}},r7={rail:B({gridColumn:`1`,gridRow:`1`,position:`sticky`,top:0,alignSelf:`start`,justifySelf:`stretch`,boxSizing:`border-box`,width:`100%`,minWidth:0,height:`100cqh`,zIndex:3,display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`flex-start`,pointerEvents:`none`,"@media (max-width: 600px)":{display:`none`}}),cluster:B(Y.padding({top:4,bottom:4,left:2,right:6}),{position:`relative`,minWidth:`40px`,display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:`12px`,pointerEvents:`auto`,"&[data-open='true'] [data-diffmap-kind='toc-line']":{opacity:0}}),line:B({display:`block`,height:`1px`,flexShrink:0,borderRadius:`999px`,backgroundColor:G.gray[8],opacity:1,transition:`opacity ${String(B5)}ms ${Zd}`,"@media (prefers-reduced-motion: reduce)":{transition:`none`},"&[data-current='true']":{backgroundColor:G.gray[12]}}),card:B(Fd.lg,Vd.medium,yd.element,Y.padding({x:3,y:3}),{position:`absolute`,insetInlineStart:0,top:`50%`,zIndex:1,boxSizing:`border-box`,width:`min(240px, calc(100cqw - 24px))`,maxHeight:`min(32rem, calc(100cqh - 24px))`,overflowX:`hidden`,overflowY:`auto`,overscrollBehavior:`contain`,transformOrigin:`left center`,pointerEvents:`none`,"&[data-open='true']":{pointerEvents:`auto`},...n7}),docked:B(Y.padding({right:6}),{boxSizing:`border-box`,width:`100%`,maxWidth:`240px`,maxHeight:`calc(100cqh - 24px)`,overflowX:`hidden`,overflowY:`auto`,overscrollBehavior:`contain`,pointerEvents:`auto`,...n7}),drawer:B(Y.padding({x:3,y:3}),n7),list:B(J({size:`sm`,fontWeight:400,color:`lowContrast`})),item:B({"&::before":{content:`none`}}),link:B(Fd.sm,Y.padding({x:4,y:2}),J({size:`sm`,fontWeight:400,color:`lowContrast`}),Ud(),{display:`block`,overflowWrap:`anywhere`,cursor:`pointer`,"&:hover":{backgroundColor:G.gray[3]},"&[aria-current='location']":{color:G.accent[9],fontWeight:500,backgroundColor:G.accent[3]},"&[aria-current='location']:hover":{backgroundColor:G.accent[4]},"&[data-diffmap-kind='toc-page']":{color:G.gray[12],fontWeight:500},"&[aria-current='page']":{backgroundColor:G.gray[3]}})};function i7(e){let t=e.document,n=o7(e.mode===`local`),[r,i]=(0,R.useState)(),[a,o]=(0,R.useState)(!1),s=e.mode===`local`,c=e.defaultRev??t.changeCards[0]?.rev??t.references.find(e=>e.rev!==void 0)?.rev??(s?`all`:`working`),[l,u]=(0,R.useState)(c),d=e=>{i(e),u(e.reference.rev??(s?`working`:c))},f=s||t.references.length>0||t.changeCards.length>0||e.defaultRev!==void 0,p=f&&a,m=t.changeCards.find(e=>e.rev===l&&e.review.length>0)?.review??a7,h=V(u7.body),[g,_]=(0,R.useState)(!1),v=e.title??t.headings.find(e=>e.level===1)?.text??`diffmap`,y=e.spec,b=yG(y)?y.title:e.mode===`local`&&n!==void 0?n.title:v,x=yG(y)?`${y.current.title} · ${y.title}`:b,S=V(u7.shell),C=V(u7.header),w=V(u7.heading),T=V(u7.title),E=V(u7.actions),D=V(u7.article),O=V(u7.prose),k=V(u7.column),A=V(mf(`md`),u7.content,S5),j=(0,R.useRef)(null),M=f4(d4(y?.href(y.current)??window.location.pathname)),ee=V(u7.reconnecting),te=t5()===`disconnected`,N=s7(e.pageLoading===!0,150),ne=V(u7.stage),re=(0,R.useRef)(null),P=G5(t.headings,y),[ie,F]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{document.title=x},[x]),(0,R.useEffect)(()=>{p&&U0({event:`diff_opened`})},[p]),(0,R.useEffect)(()=>re.current===null?void 0:W0(re.current),[]),(0,R.useEffect)(()=>{let e=decodeURIComponent(window.location.hash.replace(/^#/,``));e!==``&&document.getElementById(e)?.scrollIntoView({block:`start`})},[]),g?(0,z.jsx)(G8,{tone:`neutral`,icon:Yz,title:`Server closed`,children:(0,z.jsxs)(FB,{children:[`You closed the server for `,b,`. Run diffmap serve again to reopen it.`]})}):(0,z.jsx)(A4.Provider,{value:e.mode,children:(0,z.jsx)(_G.Provider,{value:y,children:(0,z.jsx)(l4.Provider,{value:M,children:(0,z.jsxs)(`div`,{className:S,children:[(0,z.jsxs)(`header`,{className:C,children:[(0,z.jsxs)(`div`,{className:w,children:[P&&(0,z.jsx)(N5,{expanded:ie,onClick:()=>F(!0)}),(0,z.jsx)(`div`,{className:T,children:b}),N&&(0,z.jsx)(nz,{size:`xs`,"aria-label":`Loading page`})]}),(0,z.jsxs)(`div`,{className:E,children:[(0,z.jsx)(n5,{title:b,source:s?n?.file:`${window.location.origin}${window.location.pathname}`}),f&&(0,z.jsx)(j5,{pressed:a,onClick:()=>o(e=>!e)}),e.headerActions,s&&te&&(0,z.jsxs)(`div`,{className:ee,role:`status`,title:`The diffmap server stopped. This page reloads when diffmap serve runs again.`,children:[(0,z.jsx)(nz,{size:`xs`,variant:`muted`}),`Server stopped · reconnecting`]}),s&&!te&&(0,z.jsx)(U8,{onClick:()=>{U0({event:`server_closed`}),e5(`closed`),_(!0),c7()}})]})]}),(0,z.jsx)(`div`,{className:ne,children:(0,z.jsxs)(`div`,{className:h,"data-has-source-diffs":p,children:[(0,z.jsx)(`article`,{ref:re,className:D,children:(0,z.jsxs)(`div`,{className:O,"data-has-toc":P?`true`:`false`,children:[(0,z.jsxs)(`div`,{className:k,children:[(0,z.jsx)(`div`,{ref:j,className:A,"data-diffmap-kind":`page`,children:(0,z.jsx)(e8,{document:t,selectedAnnotation:r?.annotation,onSelectAnnotation:e=>{U0({event:`reference_opened`}),o(!0),d({annotation:e,reference:e.references[0]})}})}),(0,z.jsx)(SG,{})]}),(0,z.jsx)(x5,{contentRef:j}),P&&(0,z.jsx)(J5,{headings:t.headings,articleRef:re,drawerOpen:ie,onDrawerOpenChange:F})]})}),p&&(0,z.jsx)(I8,{rev:l,review:m,onRevChange:s?e=>{U0({event:`range_changed`}),i(void 0),u(e)}:void 0,selection:r,onSelect:d,onClose:()=>o(!1)})]})})]})})})})}var a7=[];function o7(e){let[t,n]=(0,R.useState)();return(0,R.useEffect)(()=>{e&&fetch(`/__diffmap/meta`).then(e=>e.json()).then(e=>{n(e)})},[e]),t}function s7(e,t){let[n,r]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{if(!e)return;let n=setTimeout(()=>r(!0),t);return()=>{clearTimeout(n),r(!1)}},[e,t]),e&&n}async function c7(){await fetch(`/__diffmap/shutdown`,{method:`POST`})}var l7=`min(150%, 100cqw - 2 * var(--diffmap-wide-inset, 0px))`,u7={shell:B(Yd({direction:`column`}),{width:`100%`,height:`100vh`,minWidth:0,minHeight:0,overflow:`hidden`,backgroundColor:G.gray[4]}),header:B(Yd({direction:`row`,alignItems:`center`,justifyContent:`between`}),Y.padding({x:6,y:3}),Xd({size:`hug`}),Md([`bottom`],`border`),{minWidth:0,backgroundColor:K.app}),heading:B(Yd({direction:`row`,alignItems:`center`,gap:3}),{minWidth:0,flex:`1 1 auto`}),title:B(J({size:`md`,fontWeight:600,color:`highContrast`}),{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),actions:B(Yd({direction:`row`,alignItems:`center`,gap:3}),{flexShrink:0}),stage:B(Yd({direction:`column`}),{position:`relative`,flex:`1 1 auto`,minWidth:0,minHeight:0}),body:B({display:`grid`,gridTemplateRows:`minmax(0, 1fr)`,flex:`1 1 auto`,minHeight:0,minWidth:0,overflow:`hidden`,backgroundColor:K.app,"--diffmap-columns":`minmax(0, 1fr)`,"--diffmap-areas":`"article"`,gridTemplateColumns:`var(--diffmap-columns)`,gridTemplateAreas:`var(--diffmap-areas)`,"&[data-has-source-diffs='true']":{"--diffmap-columns":`minmax(0, 1fr) minmax(0, 1fr)`,"--diffmap-areas":`"article diff"`},"@media (max-width: 900px)":{gridTemplateColumns:`minmax(0, 1fr)`,gridTemplateRows:`minmax(0, 1fr) auto`,gridTemplateAreas:`"article" "diff"`}}),article:B(Y.padding({x:12,y:12}),{gridArea:`article`,flex:`1 1 auto`,minWidth:0,minHeight:0,overflowY:`auto`,backgroundColor:K.app,containerType:`size`,"@media (max-width: 600px)":{paddingInline:Y.value(6),paddingBlock:Y.value(8)}}),prose:B({display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, ${rf}) minmax(0, 1fr)`,width:`100%`,maxWidth:`none`,minWidth:0,"--diffmap-wide-inset":`0px`,"&[data-has-toc='true']":{gridTemplateColumns:`var(--diffmap-toc-columns, minmax(48px, 1fr) minmax(0, ${rf}) minmax(48px, 1fr))`,"--diffmap-wide-inset":`48px`},"&:has(> [data-diffmap-kind='toc'][data-docked='true'])":{"--diffmap-wide-inset":`240px`},"@media (max-width: 600px)":{"--diffmap-toc-columns":`0 minmax(0, 1fr) 0`}}),column:B({gridColumn:`2 / 3`,gridRow:`1`,minWidth:0}),content:B({width:`100%`,maxWidth:`none`,minWidth:0,"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:Y.value(4)},"& ul > li[data-task]::before, & ol > li[data-task]::before":{content:`none`},"& > :is([data-diffmap-kind='preview'], [data-diffmap-kind='gallery'], [data-diffmap-kind='html'], :has(> [data-diffmap-kind='flow']))":{width:l7,minWidth:`100%`,alignSelf:`center`},"& > :is([data-diffmap-kind='media'], :has(> [data-diffmap-kind='mermaid']))":{width:`max-content`,minWidth:`100%`,maxWidth:l7,alignSelf:`center`}}),reconnecting:B(Yd({direction:`row`,alignItems:`center`,gap:3}),J({size:`sm`,color:`lowContrast`}),{whiteSpace:`nowrap`})},d7=document.getElementById(`root`);if(d7===null)throw Error(`diffmap root element is missing`);async function f7(e){let t=await fetch(e);if(!t.ok)throw Error(`${e} answered ${String(t.status)}`);return await t.json()}async function p7(e){return await f7(`/__diffmap/document?${new URLSearchParams({page:e})}`)}function m7(){return decodeURIComponent(window.location.pathname).replace(/^\/+|\/+$/g,``)}function h7(e){return`/${encodeURIComponent(e.slug)}`}function g7(e){if(e.page===void 0)return;let t=h7(e.page);window.location.pathname!==t&&window.history.replaceState(window.history.state,``,`${t}${window.location.hash}`)}var _7=Promise.all([p7(m7()),f7(`/__diffmap/spec`)]),v7;H0(),U0({event:`viewer_opened`});function y7(e){e.viewerDocument===void 0&&U0({event:`viewer_error`,kind:`document`})}var b7=document.querySelector(`meta[name="diffmap-reload-token"]`)?.content??``,x7=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/__diffmap/events?${new URLSearchParams({token:b7})}`,S7=!1,C7=1e3;w7();function w7(){let e=new WebSocket(x7),t=!1;e.addEventListener(`message`,e=>{(e.data===`pages`||e.data===v7)&&window.location.reload()}),e.addEventListener(`open`,()=>{t=!0,S7=!0,C7=1e3,e5(`connected`)}),e.addEventListener(`close`,()=>{t?(e5(`disconnected`),setTimeout(w7,1e3)):S7&&setTimeout(T7,1e3)})}function T7(){fetch(`/__diffmap/meta`).then(e=>e.ok?e.json():void 0).then(e=>{e===void 0?setTimeout(T7,1e3):e.reloadToken===b7?(setTimeout(w7,C7),C7=Math.min(C7*2,1e4)):window.location.reload()},()=>setTimeout(T7,1e3))}function E7(){fetch(`/__diffmap/meta`).then(e=>{e.ok?window.location.reload():setTimeout(E7,1e3)},()=>setTimeout(E7,1e3))}function D7(){let[e,t]=(0,R.useState)();return(0,R.useEffect)(()=>{_7.then(([e,n])=>{g7(e),v7=e.page?.file,y7(e),t({page:e,spec:n})},e=>{t(e instanceof Error?e:Error(String(e))),setTimeout(E7,1e3)})},[]),e===void 0?(0,z.jsx)(O7,{}):e instanceof Error?(0,z.jsx)(G8,{tone:`danger`,icon:wB,title:`Can't reach the diffmap server`,actions:(0,z.jsx)(q8,{}),children:(0,z.jsx)(FB,{children:`The server that opened this page isn't answering. Run diffmap serve again and this page reloads on its own.`})}):(0,z.jsx)(k7,{initialPage:e.page,spec:`error`in e.spec?void 0:e.spec})}function O7(){let e=V(j7.boot);return(0,z.jsx)(`div`,{className:e,children:(0,z.jsx)(OH,{})})}function k7(e){let[t,n]=(0,R.useState)(e.initialPage),[r,i]=(0,R.useState)(!1),a=e.spec,o=(e,t)=>{i(!0),p7(e).then(e=>{i(!1),t?.(e),(e.page?.file!==v7||e.viewerDocument===void 0)&&(y7(e),v7=e.page?.file,n(e))},()=>i(!1))},s=(0,R.useEffectEvent)(()=>o(m7()));(0,R.useEffect)(()=>(window.addEventListener(`popstate`,s),()=>window.removeEventListener(`popstate`,s)),[]);let c=a?.pages.find(e=>e.file===t.page?.file)??t.page;return t.missingPage===void 0?t.specError===void 0?t.viewerDocument===void 0?(0,z.jsx)(Y8,{title:`This page has an error`,file:t.page?.file??`This page`,message:t.parseError??`Unknown parse error.`,children:(0,z.jsx)(FB,{children:`Fix the problem below and save the file. This page reloads on its own.`})}):(0,z.jsx)(V6.Provider,{value:H6,children:(0,z.jsx)(i7,{document:t.viewerDocument,mode:`local`,pageLoading:r,spec:a===void 0||c===void 0?void 0:{title:a.title,pages:a.pages,current:c,href:h7,navigate:(e,t)=>o(e.slug,()=>window.history.pushState({},``,`${h7(e)}${t}`))}},c?.file)}):(0,z.jsx)(G8,{tone:`danger`,icon:fB,title:`Can't read this spec`,detail:t.specError,children:(0,z.jsx)(FB,{children:`diffmap couldn't read the spec it's serving. Fix the problem below; this page reloads when the spec's files change.`})}):(0,z.jsx)(G8,{tone:`neutral`,icon:pB,title:`Page not found`,actions:(0,z.jsx)(K8,{href:`/`,variant:`primary`,children:`Go to the cover page`}),footer:a!==void 0&&(0,z.jsx)(A7,{pages:a.pages}),children:(0,z.jsxs)(FB,{children:[`This spec has no page at /`,t.missingPage,`. It may have been renamed or removed since this link was made.`]})})}function A7(e){return(0,z.jsxs)(zH,{column:!0,gap:3,pt:6,children:[(0,z.jsx)(LB,{children:`Pages in this spec`}),e.pages.map(e=>(0,z.jsx)(zB,{href:h7(e),children:e.title},e.file))]})}var j7={boot:B({display:`flex`,width:`100%`,height:`100vh`})};(0,ui.createRoot)(d7).render((0,z.jsx)(R.StrictMode,{children:(0,z.jsx)(kd,{children:(0,z.jsx)(D7,{})})}));export{HK as a,EK as c,wK as d,_K as f,UW as g,YW as h,Cq as i,TK as l,SK as m,QJ as n,AK as o,xK as p,EJ as r,OK as s,lY as t,CK as u};