@get-enlace/ui 0.0.5 → 0.0.6

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.
@@ -0,0 +1,65 @@
1
+ var WC=Object.defineProperty;var UC=(t,e,n)=>e in t?WC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ag=(t,e,n)=>UC(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function Kv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qv={exports:{}},pc={},Yv={exports:{}},oe={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Il=Symbol.for("react.element"),qC=Symbol.for("react.portal"),KC=Symbol.for("react.fragment"),QC=Symbol.for("react.strict_mode"),YC=Symbol.for("react.profiler"),XC=Symbol.for("react.provider"),GC=Symbol.for("react.context"),JC=Symbol.for("react.forward_ref"),ZC=Symbol.for("react.suspense"),e2=Symbol.for("react.memo"),t2=Symbol.for("react.lazy"),ug=Symbol.iterator;function n2(t){return t===null||typeof t!="object"?null:(t=ug&&t[ug]||t["@@iterator"],typeof t=="function"?t:null)}var Xv={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Gv=Object.assign,Jv={};function Ks(t,e,n){this.props=t,this.context=e,this.refs=Jv,this.updater=n||Xv}Ks.prototype.isReactComponent={};Ks.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Ks.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Zv(){}Zv.prototype=Ks.prototype;function fp(t,e,n){this.props=t,this.context=e,this.refs=Jv,this.updater=n||Xv}var dp=fp.prototype=new Zv;dp.constructor=fp;Gv(dp,Ks.prototype);dp.isPureReactComponent=!0;var cg=Array.isArray,e1=Object.prototype.hasOwnProperty,pp={current:null},t1={key:!0,ref:!0,__self:!0,__source:!0};function n1(t,e,n){var i,r={},s=null,o=null;if(e!=null)for(i in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)e1.call(e,i)&&!t1.hasOwnProperty(i)&&(r[i]=e[i]);var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){for(var a=Array(l),u=0;u<l;u++)a[u]=arguments[u+2];r.children=a}if(t&&t.defaultProps)for(i in l=t.defaultProps,l)r[i]===void 0&&(r[i]=l[i]);return{$$typeof:Il,type:t,key:s,ref:o,props:r,_owner:pp.current}}function i2(t,e){return{$$typeof:Il,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function mp(t){return typeof t=="object"&&t!==null&&t.$$typeof===Il}function r2(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var hg=/\/+/g;function eh(t,e){return typeof t=="object"&&t!==null&&t.key!=null?r2(""+t.key):e.toString(36)}function Fa(t,e,n,i,r){var s=typeof t;(s==="undefined"||s==="boolean")&&(t=null);var o=!1;if(t===null)o=!0;else switch(s){case"string":case"number":o=!0;break;case"object":switch(t.$$typeof){case Il:case qC:o=!0}}if(o)return o=t,r=r(o),t=i===""?"."+eh(o,0):i,cg(r)?(n="",t!=null&&(n=t.replace(hg,"$&/")+"/"),Fa(r,e,n,"",function(u){return u})):r!=null&&(mp(r)&&(r=i2(r,n+(!r.key||o&&o.key===r.key?"":(""+r.key).replace(hg,"$&/")+"/")+t)),e.push(r)),1;if(o=0,i=i===""?".":i+":",cg(t))for(var l=0;l<t.length;l++){s=t[l];var a=i+eh(s,l);o+=Fa(s,e,n,a,r)}else if(a=n2(t),typeof a=="function")for(t=a.call(t),l=0;!(s=t.next()).done;)s=s.value,a=i+eh(s,l++),o+=Fa(s,e,n,a,r);else if(s==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return o}function Ql(t,e,n){if(t==null)return t;var i=[],r=0;return Fa(t,i,"","",function(s){return e.call(n,s,r++)}),i}function s2(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var gt={current:null},Va={transition:null},o2={ReactCurrentDispatcher:gt,ReactCurrentBatchConfig:Va,ReactCurrentOwner:pp};function i1(){throw Error("act(...) is not supported in production builds of React.")}oe.Children={map:Ql,forEach:function(t,e,n){Ql(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Ql(t,function(){e++}),e},toArray:function(t){return Ql(t,function(e){return e})||[]},only:function(t){if(!mp(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};oe.Component=Ks;oe.Fragment=KC;oe.Profiler=YC;oe.PureComponent=fp;oe.StrictMode=QC;oe.Suspense=ZC;oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=o2;oe.act=i1;oe.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var i=Gv({},t.props),r=t.key,s=t.ref,o=t._owner;if(e!=null){if(e.ref!==void 0&&(s=e.ref,o=pp.current),e.key!==void 0&&(r=""+e.key),t.type&&t.type.defaultProps)var l=t.type.defaultProps;for(a in e)e1.call(e,a)&&!t1.hasOwnProperty(a)&&(i[a]=e[a]===void 0&&l!==void 0?l[a]:e[a])}var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){l=Array(a);for(var u=0;u<a;u++)l[u]=arguments[u+2];i.children=l}return{$$typeof:Il,type:t.type,key:r,ref:s,props:i,_owner:o}};oe.createContext=function(t){return t={$$typeof:GC,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:XC,_context:t},t.Consumer=t};oe.createElement=n1;oe.createFactory=function(t){var e=n1.bind(null,t);return e.type=t,e};oe.createRef=function(){return{current:null}};oe.forwardRef=function(t){return{$$typeof:JC,render:t}};oe.isValidElement=mp;oe.lazy=function(t){return{$$typeof:t2,_payload:{_status:-1,_result:t},_init:s2}};oe.memo=function(t,e){return{$$typeof:e2,type:t,compare:e===void 0?null:e}};oe.startTransition=function(t){var e=Va.transition;Va.transition={};try{t()}finally{Va.transition=e}};oe.unstable_act=i1;oe.useCallback=function(t,e){return gt.current.useCallback(t,e)};oe.useContext=function(t){return gt.current.useContext(t)};oe.useDebugValue=function(){};oe.useDeferredValue=function(t){return gt.current.useDeferredValue(t)};oe.useEffect=function(t,e){return gt.current.useEffect(t,e)};oe.useId=function(){return gt.current.useId()};oe.useImperativeHandle=function(t,e,n){return gt.current.useImperativeHandle(t,e,n)};oe.useInsertionEffect=function(t,e){return gt.current.useInsertionEffect(t,e)};oe.useLayoutEffect=function(t,e){return gt.current.useLayoutEffect(t,e)};oe.useMemo=function(t,e){return gt.current.useMemo(t,e)};oe.useReducer=function(t,e,n){return gt.current.useReducer(t,e,n)};oe.useRef=function(t){return gt.current.useRef(t)};oe.useState=function(t){return gt.current.useState(t)};oe.useSyncExternalStore=function(t,e,n){return gt.current.useSyncExternalStore(t,e,n)};oe.useTransition=function(){return gt.current.useTransition()};oe.version="18.3.1";Yv.exports=oe;var M=Yv.exports;const V=Kv(M);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var l2=M,a2=Symbol.for("react.element"),u2=Symbol.for("react.fragment"),c2=Object.prototype.hasOwnProperty,h2=l2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,f2={key:!0,ref:!0,__self:!0,__source:!0};function r1(t,e,n){var i,r={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(i in e)c2.call(e,i)&&!f2.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:a2,type:t,key:s,ref:o,props:r,_owner:h2.current}}pc.Fragment=u2;pc.jsx=r1;pc.jsxs=r1;Qv.exports=pc;var y=Qv.exports,cf={},s1={exports:{}},zt={},o1={exports:{}},l1={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(t){function e(P,T){var B=P.length;P.push(T);e:for(;0<B;){var F=B-1>>>1,z=P[F];if(0<r(z,T))P[F]=T,P[B]=z,B=F;else break e}}function n(P){return P.length===0?null:P[0]}function i(P){if(P.length===0)return null;var T=P[0],B=P.pop();if(B!==T){P[0]=B;e:for(var F=0,z=P.length,L=z>>>1;F<L;){var H=2*(F+1)-1,q=P[H],ee=H+1,J=P[ee];if(0>r(q,B))ee<z&&0>r(J,q)?(P[F]=J,P[ee]=B,F=ee):(P[F]=q,P[H]=B,F=H);else if(ee<z&&0>r(J,B))P[F]=J,P[ee]=B,F=ee;else break e}}return T}function r(P,T){var B=P.sortIndex-T.sortIndex;return B!==0?B:P.id-T.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,h=null,f=3,d=!1,p=!1,g=!1,x=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(P){for(var T=n(u);T!==null;){if(T.callback===null)i(u);else if(T.startTime<=P)i(u),T.sortIndex=T.expirationTime,e(a,T);else break;T=n(u)}}function k(P){if(g=!1,w(P),!p)if(n(a)!==null)p=!0,N(S);else{var T=n(u);T!==null&&j(k,T.startTime-P)}}function S(P,T){p=!1,g&&(g=!1,m(A),A=-1),d=!0;var B=f;try{for(w(T),h=n(a);h!==null&&(!(h.expirationTime>T)||P&&!O());){var F=h.callback;if(typeof F=="function"){h.callback=null,f=h.priorityLevel;var z=F(h.expirationTime<=T);T=t.unstable_now(),typeof z=="function"?h.callback=z:h===n(a)&&i(a),w(T)}else i(a);h=n(a)}if(h!==null)var L=!0;else{var H=n(u);H!==null&&j(k,H.startTime-T),L=!1}return L}finally{h=null,f=B,d=!1}}var _=!1,E=null,A=-1,I=5,R=-1;function O(){return!(t.unstable_now()-R<I)}function D(){if(E!==null){var P=t.unstable_now();R=P;var T=!0;try{T=E(!0,P)}finally{T?$():(_=!1,E=null)}}else _=!1}var $;if(typeof v=="function")$=function(){v(D)};else if(typeof MessageChannel<"u"){var b=new MessageChannel,C=b.port2;b.port1.onmessage=D,$=function(){C.postMessage(null)}}else $=function(){x(D,0)};function N(P){E=P,_||(_=!0,$())}function j(P,T){A=x(function(){P(t.unstable_now())},T)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(P){P.callback=null},t.unstable_continueExecution=function(){p||d||(p=!0,N(S))},t.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<P?Math.floor(1e3/P):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return n(a)},t.unstable_next=function(P){switch(f){case 1:case 2:case 3:var T=3;break;default:T=f}var B=f;f=T;try{return P()}finally{f=B}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(P,T){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var B=f;f=P;try{return T()}finally{f=B}},t.unstable_scheduleCallback=function(P,T,B){var F=t.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?F+B:F):B=F,P){case 1:var z=-1;break;case 2:z=250;break;case 5:z=1073741823;break;case 4:z=1e4;break;default:z=5e3}return z=B+z,P={id:c++,callback:T,priorityLevel:P,startTime:B,expirationTime:z,sortIndex:-1},B>F?(P.sortIndex=B,e(u,P),n(a)===null&&P===n(u)&&(g?(m(A),A=-1):g=!0,j(k,B-F))):(P.sortIndex=z,e(a,P),p||d||(p=!0,N(S))),P},t.unstable_shouldYield=O,t.unstable_wrapCallback=function(P){var T=f;return function(){var B=f;f=T;try{return P.apply(this,arguments)}finally{f=B}}}})(l1);o1.exports=l1;var d2=o1.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var p2=M,jt=d2;function U(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a1=new Set,Qo={};function Or(t,e){_s(t,e),_s(t+"Capture",e)}function _s(t,e){for(Qo[t]=e,t=0;t<e.length;t++)a1.add(e[t])}var ni=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),hf=Object.prototype.hasOwnProperty,m2=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,fg={},dg={};function g2(t){return hf.call(dg,t)?!0:hf.call(fg,t)?!1:m2.test(t)?dg[t]=!0:(fg[t]=!0,!1)}function y2(t,e,n,i){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function v2(t,e,n,i){if(e===null||typeof e>"u"||y2(t,e,n,i))return!0;if(i)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function yt(t,e,n,i,r,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Ze={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ze[t]=new yt(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ze[e]=new yt(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ze[t]=new yt(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ze[t]=new yt(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ze[t]=new yt(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Ze[t]=new yt(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Ze[t]=new yt(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Ze[t]=new yt(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Ze[t]=new yt(t,5,!1,t.toLowerCase(),null,!1,!1)});var gp=/[\-:]([a-z])/g;function yp(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(gp,yp);Ze[e]=new yt(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(gp,yp);Ze[e]=new yt(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(gp,yp);Ze[e]=new yt(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Ze[t]=new yt(t,1,!1,t.toLowerCase(),null,!1,!1)});Ze.xlinkHref=new yt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Ze[t]=new yt(t,1,!1,t.toLowerCase(),null,!0,!0)});function vp(t,e,n,i){var r=Ze.hasOwnProperty(e)?Ze[e]:null;(r!==null?r.type!==0:i||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(v2(e,n,r,i)&&(n=null),i||r===null?g2(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):r.mustUseProperty?t[r.propertyName]=n===null?r.type===3?!1:"":n:(e=r.attributeName,i=r.attributeNamespace,n===null?t.removeAttribute(e):(r=r.type,n=r===3||r===4&&n===!0?"":""+n,i?t.setAttributeNS(i,e,n):t.setAttribute(e,n))))}var ui=p2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Yl=Symbol.for("react.element"),qr=Symbol.for("react.portal"),Kr=Symbol.for("react.fragment"),wp=Symbol.for("react.strict_mode"),ff=Symbol.for("react.profiler"),u1=Symbol.for("react.provider"),c1=Symbol.for("react.context"),xp=Symbol.for("react.forward_ref"),df=Symbol.for("react.suspense"),pf=Symbol.for("react.suspense_list"),kp=Symbol.for("react.memo"),di=Symbol.for("react.lazy"),h1=Symbol.for("react.offscreen"),pg=Symbol.iterator;function no(t){return t===null||typeof t!="object"?null:(t=pg&&t[pg]||t["@@iterator"],typeof t=="function"?t:null)}var Ne=Object.assign,th;function ko(t){if(th===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);th=e&&e[1]||""}return`
34
+ `+th+t}var nh=!1;function ih(t,e){if(!t||nh)return"";nh=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(u){var i=u}Reflect.construct(t,[],e)}else{try{e.call()}catch(u){i=u}t.call(e.prototype)}else{try{throw Error()}catch(u){i=u}t()}}catch(u){if(u&&i&&typeof u.stack=="string"){for(var r=u.stack.split(`
35
+ `),s=i.stack.split(`
36
+ `),o=r.length-1,l=s.length-1;1<=o&&0<=l&&r[o]!==s[l];)l--;for(;1<=o&&0<=l;o--,l--)if(r[o]!==s[l]){if(o!==1||l!==1)do if(o--,l--,0>l||r[o]!==s[l]){var a=`
37
+ `+r[o].replace(" at new "," at ");return t.displayName&&a.includes("<anonymous>")&&(a=a.replace("<anonymous>",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{nh=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?ko(t):""}function w2(t){switch(t.tag){case 5:return ko(t.type);case 16:return ko("Lazy");case 13:return ko("Suspense");case 19:return ko("SuspenseList");case 0:case 2:case 15:return t=ih(t.type,!1),t;case 11:return t=ih(t.type.render,!1),t;case 1:return t=ih(t.type,!0),t;default:return""}}function mf(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Kr:return"Fragment";case qr:return"Portal";case ff:return"Profiler";case wp:return"StrictMode";case df:return"Suspense";case pf:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case c1:return(t.displayName||"Context")+".Consumer";case u1:return(t._context.displayName||"Context")+".Provider";case xp:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case kp:return e=t.displayName||null,e!==null?e:mf(t.type)||"Memo";case di:e=t._payload,t=t._init;try{return mf(t(e))}catch{}}return null}function x2(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return mf(e);case 8:return e===wp?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ji(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function f1(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function k2(t){var e=f1(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),i=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(o){i=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return i},setValue:function(o){i=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Xl(t){t._valueTracker||(t._valueTracker=k2(t))}function d1(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),i="";return t&&(i=f1(t)?t.checked?"true":"false":t.value),t=i,t!==n?(e.setValue(t),!0):!1}function cu(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function gf(t,e){var n=e.checked;return Ne({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function mg(t,e){var n=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;n=ji(e.value!=null?e.value:n),t._wrapperState={initialChecked:i,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function p1(t,e){e=e.checked,e!=null&&vp(t,"checked",e,!1)}function yf(t,e){p1(t,e);var n=ji(e.value),i=e.type;if(n!=null)i==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(i==="submit"||i==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?vf(t,e.type,n):e.hasOwnProperty("defaultValue")&&vf(t,e.type,ji(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function gg(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function vf(t,e,n){(e!=="number"||cu(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var So=Array.isArray;function us(t,e,n,i){if(t=t.options,e){e={};for(var r=0;r<n.length;r++)e["$"+n[r]]=!0;for(n=0;n<t.length;n++)r=e.hasOwnProperty("$"+t[n].value),t[n].selected!==r&&(t[n].selected=r),r&&i&&(t[n].defaultSelected=!0)}else{for(n=""+ji(n),e=null,r=0;r<t.length;r++){if(t[r].value===n){t[r].selected=!0,i&&(t[r].defaultSelected=!0);return}e!==null||t[r].disabled||(e=t[r])}e!==null&&(e.selected=!0)}}function wf(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(U(91));return Ne({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function yg(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(U(92));if(So(n)){if(1<n.length)throw Error(U(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:ji(n)}}function m1(t,e){var n=ji(e.value),i=ji(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),i!=null&&(t.defaultValue=""+i)}function vg(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function g1(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function xf(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?g1(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Gl,y1=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,i,r){MSApp.execUnsafeLocalFunction(function(){return t(e,n,i,r)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Gl=Gl||document.createElement("div"),Gl.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Gl.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Yo(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Po={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},S2=["Webkit","ms","Moz","O"];Object.keys(Po).forEach(function(t){S2.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Po[e]=Po[t]})});function v1(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Po.hasOwnProperty(t)&&Po[t]?(""+e).trim():e+"px"}function w1(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var i=n.indexOf("--")===0,r=v1(n,e[n],i);n==="float"&&(n="cssFloat"),i?t.setProperty(n,r):t[n]=r}}var b2=Ne({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function kf(t,e){if(e){if(b2[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(U(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(U(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(U(61))}if(e.style!=null&&typeof e.style!="object")throw Error(U(62))}}function Sf(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var bf=null;function Sp(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Cf=null,cs=null,hs=null;function wg(t){if(t=Dl(t)){if(typeof Cf!="function")throw Error(U(280));var e=t.stateNode;e&&(e=wc(e),Cf(t.stateNode,t.type,e))}}function x1(t){cs?hs?hs.push(t):hs=[t]:cs=t}function k1(){if(cs){var t=cs,e=hs;if(hs=cs=null,wg(t),e)for(t=0;t<e.length;t++)wg(e[t])}}function S1(t,e){return t(e)}function b1(){}var rh=!1;function C1(t,e,n){if(rh)return t(e,n);rh=!0;try{return S1(t,e,n)}finally{rh=!1,(cs!==null||hs!==null)&&(b1(),k1())}}function Xo(t,e){var n=t.stateNode;if(n===null)return null;var i=wc(n);if(i===null)return null;n=i[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(t=t.type,i=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!i;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(U(231,e,typeof n));return n}var Ef=!1;if(ni)try{var io={};Object.defineProperty(io,"passive",{get:function(){Ef=!0}}),window.addEventListener("test",io,io),window.removeEventListener("test",io,io)}catch{Ef=!1}function C2(t,e,n,i,r,s,o,l,a){var u=Array.prototype.slice.call(arguments,3);try{e.apply(n,u)}catch(c){this.onError(c)}}var Ro=!1,hu=null,fu=!1,_f=null,E2={onError:function(t){Ro=!0,hu=t}};function _2(t,e,n,i,r,s,o,l,a){Ro=!1,hu=null,C2.apply(E2,arguments)}function N2(t,e,n,i,r,s,o,l,a){if(_2.apply(this,arguments),Ro){if(Ro){var u=hu;Ro=!1,hu=null}else throw Error(U(198));fu||(fu=!0,_f=u)}}function Ir(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function E1(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function xg(t){if(Ir(t)!==t)throw Error(U(188))}function A2(t){var e=t.alternate;if(!e){if(e=Ir(t),e===null)throw Error(U(188));return e!==t?null:t}for(var n=t,i=e;;){var r=n.return;if(r===null)break;var s=r.alternate;if(s===null){if(i=r.return,i!==null){n=i;continue}break}if(r.child===s.child){for(s=r.child;s;){if(s===n)return xg(r),t;if(s===i)return xg(r),e;s=s.sibling}throw Error(U(188))}if(n.return!==i.return)n=r,i=s;else{for(var o=!1,l=r.child;l;){if(l===n){o=!0,n=r,i=s;break}if(l===i){o=!0,i=r,n=s;break}l=l.sibling}if(!o){for(l=s.child;l;){if(l===n){o=!0,n=s,i=r;break}if(l===i){o=!0,i=s,n=r;break}l=l.sibling}if(!o)throw Error(U(189))}}if(n.alternate!==i)throw Error(U(190))}if(n.tag!==3)throw Error(U(188));return n.stateNode.current===n?t:e}function _1(t){return t=A2(t),t!==null?N1(t):null}function N1(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=N1(t);if(e!==null)return e;t=t.sibling}return null}var A1=jt.unstable_scheduleCallback,kg=jt.unstable_cancelCallback,M2=jt.unstable_shouldYield,T2=jt.unstable_requestPaint,De=jt.unstable_now,O2=jt.unstable_getCurrentPriorityLevel,bp=jt.unstable_ImmediatePriority,M1=jt.unstable_UserBlockingPriority,du=jt.unstable_NormalPriority,I2=jt.unstable_LowPriority,T1=jt.unstable_IdlePriority,mc=null,Ln=null;function P2(t){if(Ln&&typeof Ln.onCommitFiberRoot=="function")try{Ln.onCommitFiberRoot(mc,t,void 0,(t.current.flags&128)===128)}catch{}}var pn=Math.clz32?Math.clz32:L2,R2=Math.log,D2=Math.LN2;function L2(t){return t>>>=0,t===0?32:31-(R2(t)/D2|0)|0}var Jl=64,Zl=4194304;function bo(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function pu(t,e){var n=t.pendingLanes;if(n===0)return 0;var i=0,r=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~r;l!==0?i=bo(l):(s&=o,s!==0&&(i=bo(s)))}else o=n&~r,o!==0?i=bo(o):s!==0&&(i=bo(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=i;0<e;)n=31-pn(e),r=1<<n,i|=t[n],e&=~r;return i}function B2(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function j2(t,e){for(var n=t.suspendedLanes,i=t.pingedLanes,r=t.expirationTimes,s=t.pendingLanes;0<s;){var o=31-pn(s),l=1<<o,a=r[o];a===-1?(!(l&n)||l&i)&&(r[o]=B2(l,e)):a<=e&&(t.expiredLanes|=l),s&=~l}}function Nf(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function O1(){var t=Jl;return Jl<<=1,!(Jl&4194240)&&(Jl=64),t}function sh(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function Pl(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-pn(e),t[e]=n}function $2(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var i=t.eventTimes;for(t=t.expirationTimes;0<n;){var r=31-pn(n),s=1<<r;e[r]=0,i[r]=-1,t[r]=-1,n&=~s}}function Cp(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var i=31-pn(n),r=1<<i;r&e|t[i]&e&&(t[i]|=e),n&=~r}}var de=0;function I1(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var P1,Ep,R1,D1,L1,Af=!1,ea=[],Ai=null,Mi=null,Ti=null,Go=new Map,Jo=new Map,wi=[],z2="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Sg(t,e){switch(t){case"focusin":case"focusout":Ai=null;break;case"dragenter":case"dragleave":Mi=null;break;case"mouseover":case"mouseout":Ti=null;break;case"pointerover":case"pointerout":Go.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":Jo.delete(e.pointerId)}}function ro(t,e,n,i,r,s){return t===null||t.nativeEvent!==s?(t={blockedOn:e,domEventName:n,eventSystemFlags:i,nativeEvent:s,targetContainers:[r]},e!==null&&(e=Dl(e),e!==null&&Ep(e)),t):(t.eventSystemFlags|=i,e=t.targetContainers,r!==null&&e.indexOf(r)===-1&&e.push(r),t)}function F2(t,e,n,i,r){switch(e){case"focusin":return Ai=ro(Ai,t,e,n,i,r),!0;case"dragenter":return Mi=ro(Mi,t,e,n,i,r),!0;case"mouseover":return Ti=ro(Ti,t,e,n,i,r),!0;case"pointerover":var s=r.pointerId;return Go.set(s,ro(Go.get(s)||null,t,e,n,i,r)),!0;case"gotpointercapture":return s=r.pointerId,Jo.set(s,ro(Jo.get(s)||null,t,e,n,i,r)),!0}return!1}function B1(t){var e=ur(t.target);if(e!==null){var n=Ir(e);if(n!==null){if(e=n.tag,e===13){if(e=E1(n),e!==null){t.blockedOn=e,L1(t.priority,function(){R1(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ha(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=Mf(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var i=new n.constructor(n.type,n);bf=i,n.target.dispatchEvent(i),bf=null}else return e=Dl(n),e!==null&&Ep(e),t.blockedOn=n,!1;e.shift()}return!0}function bg(t,e,n){Ha(t)&&n.delete(e)}function V2(){Af=!1,Ai!==null&&Ha(Ai)&&(Ai=null),Mi!==null&&Ha(Mi)&&(Mi=null),Ti!==null&&Ha(Ti)&&(Ti=null),Go.forEach(bg),Jo.forEach(bg)}function so(t,e){t.blockedOn===e&&(t.blockedOn=null,Af||(Af=!0,jt.unstable_scheduleCallback(jt.unstable_NormalPriority,V2)))}function Zo(t){function e(r){return so(r,t)}if(0<ea.length){so(ea[0],t);for(var n=1;n<ea.length;n++){var i=ea[n];i.blockedOn===t&&(i.blockedOn=null)}}for(Ai!==null&&so(Ai,t),Mi!==null&&so(Mi,t),Ti!==null&&so(Ti,t),Go.forEach(e),Jo.forEach(e),n=0;n<wi.length;n++)i=wi[n],i.blockedOn===t&&(i.blockedOn=null);for(;0<wi.length&&(n=wi[0],n.blockedOn===null);)B1(n),n.blockedOn===null&&wi.shift()}var fs=ui.ReactCurrentBatchConfig,mu=!0;function H2(t,e,n,i){var r=de,s=fs.transition;fs.transition=null;try{de=1,_p(t,e,n,i)}finally{de=r,fs.transition=s}}function W2(t,e,n,i){var r=de,s=fs.transition;fs.transition=null;try{de=4,_p(t,e,n,i)}finally{de=r,fs.transition=s}}function _p(t,e,n,i){if(mu){var r=Mf(t,e,n,i);if(r===null)mh(t,e,i,gu,n),Sg(t,i);else if(F2(r,t,e,n,i))i.stopPropagation();else if(Sg(t,i),e&4&&-1<z2.indexOf(t)){for(;r!==null;){var s=Dl(r);if(s!==null&&P1(s),s=Mf(t,e,n,i),s===null&&mh(t,e,i,gu,n),s===r)break;r=s}r!==null&&i.stopPropagation()}else mh(t,e,i,null,n)}}var gu=null;function Mf(t,e,n,i){if(gu=null,t=Sp(i),t=ur(t),t!==null)if(e=Ir(t),e===null)t=null;else if(n=e.tag,n===13){if(t=E1(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return gu=t,null}function j1(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(O2()){case bp:return 1;case M1:return 4;case du:case I2:return 16;case T1:return 536870912;default:return 16}default:return 16}}var Ci=null,Np=null,Wa=null;function $1(){if(Wa)return Wa;var t,e=Np,n=e.length,i,r="value"in Ci?Ci.value:Ci.textContent,s=r.length;for(t=0;t<n&&e[t]===r[t];t++);var o=n-t;for(i=1;i<=o&&e[n-i]===r[s-i];i++);return Wa=r.slice(t,1<i?1-i:void 0)}function Ua(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function ta(){return!0}function Cg(){return!1}function Ft(t){function e(n,i,r,s,o){this._reactName=n,this._targetInst=r,this.type=i,this.nativeEvent=s,this.target=o,this.currentTarget=null;for(var l in t)t.hasOwnProperty(l)&&(n=t[l],this[l]=n?n(s):s[l]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?ta:Cg,this.isPropagationStopped=Cg,this}return Ne(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=ta)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ta)},persist:function(){},isPersistent:ta}),e}var Qs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ap=Ft(Qs),Rl=Ne({},Qs,{view:0,detail:0}),U2=Ft(Rl),oh,lh,oo,gc=Ne({},Rl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mp,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==oo&&(oo&&t.type==="mousemove"?(oh=t.screenX-oo.screenX,lh=t.screenY-oo.screenY):lh=oh=0,oo=t),oh)},movementY:function(t){return"movementY"in t?t.movementY:lh}}),Eg=Ft(gc),q2=Ne({},gc,{dataTransfer:0}),K2=Ft(q2),Q2=Ne({},Rl,{relatedTarget:0}),ah=Ft(Q2),Y2=Ne({},Qs,{animationName:0,elapsedTime:0,pseudoElement:0}),X2=Ft(Y2),G2=Ne({},Qs,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),J2=Ft(G2),Z2=Ne({},Qs,{data:0}),_g=Ft(Z2),eE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tE={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},nE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function iE(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=nE[t])?!!e[t]:!1}function Mp(){return iE}var rE=Ne({},Rl,{key:function(t){if(t.key){var e=eE[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Ua(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?tE[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mp,charCode:function(t){return t.type==="keypress"?Ua(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ua(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),sE=Ft(rE),oE=Ne({},gc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ng=Ft(oE),lE=Ne({},Rl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mp}),aE=Ft(lE),uE=Ne({},Qs,{propertyName:0,elapsedTime:0,pseudoElement:0}),cE=Ft(uE),hE=Ne({},gc,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),fE=Ft(hE),dE=[9,13,27,32],Tp=ni&&"CompositionEvent"in window,Do=null;ni&&"documentMode"in document&&(Do=document.documentMode);var pE=ni&&"TextEvent"in window&&!Do,z1=ni&&(!Tp||Do&&8<Do&&11>=Do),Ag=" ",Mg=!1;function F1(t,e){switch(t){case"keyup":return dE.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function V1(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Qr=!1;function mE(t,e){switch(t){case"compositionend":return V1(e);case"keypress":return e.which!==32?null:(Mg=!0,Ag);case"textInput":return t=e.data,t===Ag&&Mg?null:t;default:return null}}function gE(t,e){if(Qr)return t==="compositionend"||!Tp&&F1(t,e)?(t=$1(),Wa=Np=Ci=null,Qr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return z1&&e.locale!=="ko"?null:e.data;default:return null}}var yE={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Tg(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!yE[t.type]:e==="textarea"}function H1(t,e,n,i){x1(i),e=yu(e,"onChange"),0<e.length&&(n=new Ap("onChange","change",null,n,i),t.push({event:n,listeners:e}))}var Lo=null,el=null;function vE(t){ew(t,0)}function yc(t){var e=Gr(t);if(d1(e))return t}function wE(t,e){if(t==="change")return e}var W1=!1;if(ni){var uh;if(ni){var ch="oninput"in document;if(!ch){var Og=document.createElement("div");Og.setAttribute("oninput","return;"),ch=typeof Og.oninput=="function"}uh=ch}else uh=!1;W1=uh&&(!document.documentMode||9<document.documentMode)}function Ig(){Lo&&(Lo.detachEvent("onpropertychange",U1),el=Lo=null)}function U1(t){if(t.propertyName==="value"&&yc(el)){var e=[];H1(e,el,t,Sp(t)),C1(vE,e)}}function xE(t,e,n){t==="focusin"?(Ig(),Lo=e,el=n,Lo.attachEvent("onpropertychange",U1)):t==="focusout"&&Ig()}function kE(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return yc(el)}function SE(t,e){if(t==="click")return yc(e)}function bE(t,e){if(t==="input"||t==="change")return yc(e)}function CE(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var yn=typeof Object.is=="function"?Object.is:CE;function tl(t,e){if(yn(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!hf.call(e,r)||!yn(t[r],e[r]))return!1}return!0}function Pg(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Rg(t,e){var n=Pg(t);t=0;for(var i;n;){if(n.nodeType===3){if(i=t+n.textContent.length,t<=e&&i>=e)return{node:n,offset:e-t};t=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Pg(n)}}function q1(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?q1(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function K1(){for(var t=window,e=cu();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=cu(t.document)}return e}function Op(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function EE(t){var e=K1(),n=t.focusedElem,i=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&q1(n.ownerDocument.documentElement,n)){if(i!==null&&Op(n)){if(e=i.start,t=i.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!t.extend&&s>i&&(r=i,i=s,s=r),r=Rg(n,s);var o=Rg(n,i);r&&o&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),s>i?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var _E=ni&&"documentMode"in document&&11>=document.documentMode,Yr=null,Tf=null,Bo=null,Of=!1;function Dg(t,e,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Of||Yr==null||Yr!==cu(i)||(i=Yr,"selectionStart"in i&&Op(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Bo&&tl(Bo,i)||(Bo=i,i=yu(Tf,"onSelect"),0<i.length&&(e=new Ap("onSelect","select",null,e,n),t.push({event:e,listeners:i}),e.target=Yr)))}function na(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var Xr={animationend:na("Animation","AnimationEnd"),animationiteration:na("Animation","AnimationIteration"),animationstart:na("Animation","AnimationStart"),transitionend:na("Transition","TransitionEnd")},hh={},Q1={};ni&&(Q1=document.createElement("div").style,"AnimationEvent"in window||(delete Xr.animationend.animation,delete Xr.animationiteration.animation,delete Xr.animationstart.animation),"TransitionEvent"in window||delete Xr.transitionend.transition);function vc(t){if(hh[t])return hh[t];if(!Xr[t])return t;var e=Xr[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in Q1)return hh[t]=e[n];return t}var Y1=vc("animationend"),X1=vc("animationiteration"),G1=vc("animationstart"),J1=vc("transitionend"),Z1=new Map,Lg="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ui(t,e){Z1.set(t,e),Or(e,[t])}for(var fh=0;fh<Lg.length;fh++){var dh=Lg[fh],NE=dh.toLowerCase(),AE=dh[0].toUpperCase()+dh.slice(1);Ui(NE,"on"+AE)}Ui(Y1,"onAnimationEnd");Ui(X1,"onAnimationIteration");Ui(G1,"onAnimationStart");Ui("dblclick","onDoubleClick");Ui("focusin","onFocus");Ui("focusout","onBlur");Ui(J1,"onTransitionEnd");_s("onMouseEnter",["mouseout","mouseover"]);_s("onMouseLeave",["mouseout","mouseover"]);_s("onPointerEnter",["pointerout","pointerover"]);_s("onPointerLeave",["pointerout","pointerover"]);Or("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Or("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Or("onBeforeInput",["compositionend","keypress","textInput","paste"]);Or("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Or("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Or("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Co="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ME=new Set("cancel close invalid load scroll toggle".split(" ").concat(Co));function Bg(t,e,n){var i=t.type||"unknown-event";t.currentTarget=n,N2(i,e,void 0,t),t.currentTarget=null}function ew(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var i=t[n],r=i.event;i=i.listeners;e:{var s=void 0;if(e)for(var o=i.length-1;0<=o;o--){var l=i[o],a=l.instance,u=l.currentTarget;if(l=l.listener,a!==s&&r.isPropagationStopped())break e;Bg(r,l,u),s=a}else for(o=0;o<i.length;o++){if(l=i[o],a=l.instance,u=l.currentTarget,l=l.listener,a!==s&&r.isPropagationStopped())break e;Bg(r,l,u),s=a}}}if(fu)throw t=_f,fu=!1,_f=null,t}function ke(t,e){var n=e[Lf];n===void 0&&(n=e[Lf]=new Set);var i=t+"__bubble";n.has(i)||(tw(e,t,2,!1),n.add(i))}function ph(t,e,n){var i=0;e&&(i|=4),tw(n,t,i,e)}var ia="_reactListening"+Math.random().toString(36).slice(2);function nl(t){if(!t[ia]){t[ia]=!0,a1.forEach(function(n){n!=="selectionchange"&&(ME.has(n)||ph(n,!1,t),ph(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[ia]||(e[ia]=!0,ph("selectionchange",!1,e))}}function tw(t,e,n,i){switch(j1(e)){case 1:var r=H2;break;case 4:r=W2;break;default:r=_p}n=r.bind(null,e,n,t),r=void 0,!Ef||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(r=!0),i?r!==void 0?t.addEventListener(e,n,{capture:!0,passive:r}):t.addEventListener(e,n,!0):r!==void 0?t.addEventListener(e,n,{passive:r}):t.addEventListener(e,n,!1)}function mh(t,e,n,i,r){var s=i;if(!(e&1)&&!(e&2)&&i!==null)e:for(;;){if(i===null)return;var o=i.tag;if(o===3||o===4){var l=i.stateNode.containerInfo;if(l===r||l.nodeType===8&&l.parentNode===r)break;if(o===4)for(o=i.return;o!==null;){var a=o.tag;if((a===3||a===4)&&(a=o.stateNode.containerInfo,a===r||a.nodeType===8&&a.parentNode===r))return;o=o.return}for(;l!==null;){if(o=ur(l),o===null)return;if(a=o.tag,a===5||a===6){i=s=o;continue e}l=l.parentNode}}i=i.return}C1(function(){var u=s,c=Sp(n),h=[];e:{var f=Z1.get(t);if(f!==void 0){var d=Ap,p=t;switch(t){case"keypress":if(Ua(n)===0)break e;case"keydown":case"keyup":d=sE;break;case"focusin":p="focus",d=ah;break;case"focusout":p="blur",d=ah;break;case"beforeblur":case"afterblur":d=ah;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":d=Eg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":d=K2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":d=aE;break;case Y1:case X1:case G1:d=X2;break;case J1:d=cE;break;case"scroll":d=U2;break;case"wheel":d=fE;break;case"copy":case"cut":case"paste":d=J2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":d=Ng}var g=(e&4)!==0,x=!g&&t==="scroll",m=g?f!==null?f+"Capture":null:f;g=[];for(var v=u,w;v!==null;){w=v;var k=w.stateNode;if(w.tag===5&&k!==null&&(w=k,m!==null&&(k=Xo(v,m),k!=null&&g.push(il(v,k,w)))),x)break;v=v.return}0<g.length&&(f=new d(f,p,null,n,c),h.push({event:f,listeners:g}))}}if(!(e&7)){e:{if(f=t==="mouseover"||t==="pointerover",d=t==="mouseout"||t==="pointerout",f&&n!==bf&&(p=n.relatedTarget||n.fromElement)&&(ur(p)||p[ii]))break e;if((d||f)&&(f=c.window===c?c:(f=c.ownerDocument)?f.defaultView||f.parentWindow:window,d?(p=n.relatedTarget||n.toElement,d=u,p=p?ur(p):null,p!==null&&(x=Ir(p),p!==x||p.tag!==5&&p.tag!==6)&&(p=null)):(d=null,p=u),d!==p)){if(g=Eg,k="onMouseLeave",m="onMouseEnter",v="mouse",(t==="pointerout"||t==="pointerover")&&(g=Ng,k="onPointerLeave",m="onPointerEnter",v="pointer"),x=d==null?f:Gr(d),w=p==null?f:Gr(p),f=new g(k,v+"leave",d,n,c),f.target=x,f.relatedTarget=w,k=null,ur(c)===u&&(g=new g(m,v+"enter",p,n,c),g.target=w,g.relatedTarget=x,k=g),x=k,d&&p)t:{for(g=d,m=p,v=0,w=g;w;w=jr(w))v++;for(w=0,k=m;k;k=jr(k))w++;for(;0<v-w;)g=jr(g),v--;for(;0<w-v;)m=jr(m),w--;for(;v--;){if(g===m||m!==null&&g===m.alternate)break t;g=jr(g),m=jr(m)}g=null}else g=null;d!==null&&jg(h,f,d,g,!1),p!==null&&x!==null&&jg(h,x,p,g,!0)}}e:{if(f=u?Gr(u):window,d=f.nodeName&&f.nodeName.toLowerCase(),d==="select"||d==="input"&&f.type==="file")var S=wE;else if(Tg(f))if(W1)S=bE;else{S=kE;var _=xE}else(d=f.nodeName)&&d.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(S=SE);if(S&&(S=S(t,u))){H1(h,S,n,c);break e}_&&_(t,f,u),t==="focusout"&&(_=f._wrapperState)&&_.controlled&&f.type==="number"&&vf(f,"number",f.value)}switch(_=u?Gr(u):window,t){case"focusin":(Tg(_)||_.contentEditable==="true")&&(Yr=_,Tf=u,Bo=null);break;case"focusout":Bo=Tf=Yr=null;break;case"mousedown":Of=!0;break;case"contextmenu":case"mouseup":case"dragend":Of=!1,Dg(h,n,c);break;case"selectionchange":if(_E)break;case"keydown":case"keyup":Dg(h,n,c)}var E;if(Tp)e:{switch(t){case"compositionstart":var A="onCompositionStart";break e;case"compositionend":A="onCompositionEnd";break e;case"compositionupdate":A="onCompositionUpdate";break e}A=void 0}else Qr?F1(t,n)&&(A="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(A="onCompositionStart");A&&(z1&&n.locale!=="ko"&&(Qr||A!=="onCompositionStart"?A==="onCompositionEnd"&&Qr&&(E=$1()):(Ci=c,Np="value"in Ci?Ci.value:Ci.textContent,Qr=!0)),_=yu(u,A),0<_.length&&(A=new _g(A,t,null,n,c),h.push({event:A,listeners:_}),E?A.data=E:(E=V1(n),E!==null&&(A.data=E)))),(E=pE?mE(t,n):gE(t,n))&&(u=yu(u,"onBeforeInput"),0<u.length&&(c=new _g("onBeforeInput","beforeinput",null,n,c),h.push({event:c,listeners:u}),c.data=E))}ew(h,e)})}function il(t,e,n){return{instance:t,listener:e,currentTarget:n}}function yu(t,e){for(var n=e+"Capture",i=[];t!==null;){var r=t,s=r.stateNode;r.tag===5&&s!==null&&(r=s,s=Xo(t,n),s!=null&&i.unshift(il(t,s,r)),s=Xo(t,e),s!=null&&i.push(il(t,s,r))),t=t.return}return i}function jr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function jg(t,e,n,i,r){for(var s=e._reactName,o=[];n!==null&&n!==i;){var l=n,a=l.alternate,u=l.stateNode;if(a!==null&&a===i)break;l.tag===5&&u!==null&&(l=u,r?(a=Xo(n,s),a!=null&&o.unshift(il(n,a,l))):r||(a=Xo(n,s),a!=null&&o.push(il(n,a,l)))),n=n.return}o.length!==0&&t.push({event:e,listeners:o})}var TE=/\r\n?/g,OE=/\u0000|\uFFFD/g;function $g(t){return(typeof t=="string"?t:""+t).replace(TE,`
38
+ `).replace(OE,"")}function ra(t,e,n){if(e=$g(e),$g(t)!==e&&n)throw Error(U(425))}function vu(){}var If=null,Pf=null;function Rf(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var Df=typeof setTimeout=="function"?setTimeout:void 0,IE=typeof clearTimeout=="function"?clearTimeout:void 0,zg=typeof Promise=="function"?Promise:void 0,PE=typeof queueMicrotask=="function"?queueMicrotask:typeof zg<"u"?function(t){return zg.resolve(null).then(t).catch(RE)}:Df;function RE(t){setTimeout(function(){throw t})}function gh(t,e){var n=e,i=0;do{var r=n.nextSibling;if(t.removeChild(n),r&&r.nodeType===8)if(n=r.data,n==="/$"){if(i===0){t.removeChild(r),Zo(e);return}i--}else n!=="$"&&n!=="$?"&&n!=="$!"||i++;n=r}while(n);Zo(e)}function Oi(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function Fg(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var Ys=Math.random().toString(36).slice(2),On="__reactFiber$"+Ys,rl="__reactProps$"+Ys,ii="__reactContainer$"+Ys,Lf="__reactEvents$"+Ys,DE="__reactListeners$"+Ys,LE="__reactHandles$"+Ys;function ur(t){var e=t[On];if(e)return e;for(var n=t.parentNode;n;){if(e=n[ii]||n[On]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=Fg(t);t!==null;){if(n=t[On])return n;t=Fg(t)}return e}t=n,n=t.parentNode}return null}function Dl(t){return t=t[On]||t[ii],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Gr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(U(33))}function wc(t){return t[rl]||null}var Bf=[],Jr=-1;function qi(t){return{current:t}}function Se(t){0>Jr||(t.current=Bf[Jr],Bf[Jr]=null,Jr--)}function ye(t,e){Jr++,Bf[Jr]=t.current,t.current=e}var $i={},lt=qi($i),_t=qi(!1),xr=$i;function Ns(t,e){var n=t.type.contextTypes;if(!n)return $i;var i=t.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in n)r[s]=e[s];return i&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function Nt(t){return t=t.childContextTypes,t!=null}function wu(){Se(_t),Se(lt)}function Vg(t,e,n){if(lt.current!==$i)throw Error(U(168));ye(lt,e),ye(_t,n)}function nw(t,e,n){var i=t.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return n;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(U(108,x2(t)||"Unknown",r));return Ne({},n,i)}function xu(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||$i,xr=lt.current,ye(lt,t),ye(_t,_t.current),!0}function Hg(t,e,n){var i=t.stateNode;if(!i)throw Error(U(169));n?(t=nw(t,e,xr),i.__reactInternalMemoizedMergedChildContext=t,Se(_t),Se(lt),ye(lt,t)):Se(_t),ye(_t,n)}var Kn=null,xc=!1,yh=!1;function iw(t){Kn===null?Kn=[t]:Kn.push(t)}function BE(t){xc=!0,iw(t)}function Ki(){if(!yh&&Kn!==null){yh=!0;var t=0,e=de;try{var n=Kn;for(de=1;t<n.length;t++){var i=n[t];do i=i(!0);while(i!==null)}Kn=null,xc=!1}catch(r){throw Kn!==null&&(Kn=Kn.slice(t+1)),A1(bp,Ki),r}finally{de=e,yh=!1}}return null}var Zr=[],es=0,ku=null,Su=0,Vt=[],Ht=0,kr=null,Xn=1,Gn="";function ir(t,e){Zr[es++]=Su,Zr[es++]=ku,ku=t,Su=e}function rw(t,e,n){Vt[Ht++]=Xn,Vt[Ht++]=Gn,Vt[Ht++]=kr,kr=t;var i=Xn;t=Gn;var r=32-pn(i)-1;i&=~(1<<r),n+=1;var s=32-pn(e)+r;if(30<s){var o=r-r%5;s=(i&(1<<o)-1).toString(32),i>>=o,r-=o,Xn=1<<32-pn(e)+r|n<<r|i,Gn=s+t}else Xn=1<<s|n<<r|i,Gn=t}function Ip(t){t.return!==null&&(ir(t,1),rw(t,1,0))}function Pp(t){for(;t===ku;)ku=Zr[--es],Zr[es]=null,Su=Zr[--es],Zr[es]=null;for(;t===kr;)kr=Vt[--Ht],Vt[Ht]=null,Gn=Vt[--Ht],Vt[Ht]=null,Xn=Vt[--Ht],Vt[Ht]=null}var Bt=null,Dt=null,be=!1,an=null;function sw(t,e){var n=Ut(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function Wg(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,Bt=t,Dt=Oi(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,Bt=t,Dt=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=kr!==null?{id:Xn,overflow:Gn}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=Ut(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,Bt=t,Dt=null,!0):!1;default:return!1}}function jf(t){return(t.mode&1)!==0&&(t.flags&128)===0}function $f(t){if(be){var e=Dt;if(e){var n=e;if(!Wg(t,e)){if(jf(t))throw Error(U(418));e=Oi(n.nextSibling);var i=Bt;e&&Wg(t,e)?sw(i,n):(t.flags=t.flags&-4097|2,be=!1,Bt=t)}}else{if(jf(t))throw Error(U(418));t.flags=t.flags&-4097|2,be=!1,Bt=t}}}function Ug(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Bt=t}function sa(t){if(t!==Bt)return!1;if(!be)return Ug(t),be=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!Rf(t.type,t.memoizedProps)),e&&(e=Dt)){if(jf(t))throw ow(),Error(U(418));for(;e;)sw(t,e),e=Oi(e.nextSibling)}if(Ug(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(U(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){Dt=Oi(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}Dt=null}}else Dt=Bt?Oi(t.stateNode.nextSibling):null;return!0}function ow(){for(var t=Dt;t;)t=Oi(t.nextSibling)}function As(){Dt=Bt=null,be=!1}function Rp(t){an===null?an=[t]:an.push(t)}var jE=ui.ReactCurrentBatchConfig;function lo(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(U(309));var i=n.stateNode}if(!i)throw Error(U(147,t));var r=i,s=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===s?e.ref:(e=function(o){var l=r.refs;o===null?delete l[s]:l[s]=o},e._stringRef=s,e)}if(typeof t!="string")throw Error(U(284));if(!n._owner)throw Error(U(290,t))}return t}function oa(t,e){throw t=Object.prototype.toString.call(e),Error(U(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function qg(t){var e=t._init;return e(t._payload)}function lw(t){function e(m,v){if(t){var w=m.deletions;w===null?(m.deletions=[v],m.flags|=16):w.push(v)}}function n(m,v){if(!t)return null;for(;v!==null;)e(m,v),v=v.sibling;return null}function i(m,v){for(m=new Map;v!==null;)v.key!==null?m.set(v.key,v):m.set(v.index,v),v=v.sibling;return m}function r(m,v){return m=Di(m,v),m.index=0,m.sibling=null,m}function s(m,v,w){return m.index=w,t?(w=m.alternate,w!==null?(w=w.index,w<v?(m.flags|=2,v):w):(m.flags|=2,v)):(m.flags|=1048576,v)}function o(m){return t&&m.alternate===null&&(m.flags|=2),m}function l(m,v,w,k){return v===null||v.tag!==6?(v=Ch(w,m.mode,k),v.return=m,v):(v=r(v,w),v.return=m,v)}function a(m,v,w,k){var S=w.type;return S===Kr?c(m,v,w.props.children,k,w.key):v!==null&&(v.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===di&&qg(S)===v.type)?(k=r(v,w.props),k.ref=lo(m,v,w),k.return=m,k):(k=Ja(w.type,w.key,w.props,null,m.mode,k),k.ref=lo(m,v,w),k.return=m,k)}function u(m,v,w,k){return v===null||v.tag!==4||v.stateNode.containerInfo!==w.containerInfo||v.stateNode.implementation!==w.implementation?(v=Eh(w,m.mode,k),v.return=m,v):(v=r(v,w.children||[]),v.return=m,v)}function c(m,v,w,k,S){return v===null||v.tag!==7?(v=gr(w,m.mode,k,S),v.return=m,v):(v=r(v,w),v.return=m,v)}function h(m,v,w){if(typeof v=="string"&&v!==""||typeof v=="number")return v=Ch(""+v,m.mode,w),v.return=m,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Yl:return w=Ja(v.type,v.key,v.props,null,m.mode,w),w.ref=lo(m,null,v),w.return=m,w;case qr:return v=Eh(v,m.mode,w),v.return=m,v;case di:var k=v._init;return h(m,k(v._payload),w)}if(So(v)||no(v))return v=gr(v,m.mode,w,null),v.return=m,v;oa(m,v)}return null}function f(m,v,w,k){var S=v!==null?v.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return S!==null?null:l(m,v,""+w,k);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Yl:return w.key===S?a(m,v,w,k):null;case qr:return w.key===S?u(m,v,w,k):null;case di:return S=w._init,f(m,v,S(w._payload),k)}if(So(w)||no(w))return S!==null?null:c(m,v,w,k,null);oa(m,w)}return null}function d(m,v,w,k,S){if(typeof k=="string"&&k!==""||typeof k=="number")return m=m.get(w)||null,l(v,m,""+k,S);if(typeof k=="object"&&k!==null){switch(k.$$typeof){case Yl:return m=m.get(k.key===null?w:k.key)||null,a(v,m,k,S);case qr:return m=m.get(k.key===null?w:k.key)||null,u(v,m,k,S);case di:var _=k._init;return d(m,v,w,_(k._payload),S)}if(So(k)||no(k))return m=m.get(w)||null,c(v,m,k,S,null);oa(v,k)}return null}function p(m,v,w,k){for(var S=null,_=null,E=v,A=v=0,I=null;E!==null&&A<w.length;A++){E.index>A?(I=E,E=null):I=E.sibling;var R=f(m,E,w[A],k);if(R===null){E===null&&(E=I);break}t&&E&&R.alternate===null&&e(m,E),v=s(R,v,A),_===null?S=R:_.sibling=R,_=R,E=I}if(A===w.length)return n(m,E),be&&ir(m,A),S;if(E===null){for(;A<w.length;A++)E=h(m,w[A],k),E!==null&&(v=s(E,v,A),_===null?S=E:_.sibling=E,_=E);return be&&ir(m,A),S}for(E=i(m,E);A<w.length;A++)I=d(E,m,A,w[A],k),I!==null&&(t&&I.alternate!==null&&E.delete(I.key===null?A:I.key),v=s(I,v,A),_===null?S=I:_.sibling=I,_=I);return t&&E.forEach(function(O){return e(m,O)}),be&&ir(m,A),S}function g(m,v,w,k){var S=no(w);if(typeof S!="function")throw Error(U(150));if(w=S.call(w),w==null)throw Error(U(151));for(var _=S=null,E=v,A=v=0,I=null,R=w.next();E!==null&&!R.done;A++,R=w.next()){E.index>A?(I=E,E=null):I=E.sibling;var O=f(m,E,R.value,k);if(O===null){E===null&&(E=I);break}t&&E&&O.alternate===null&&e(m,E),v=s(O,v,A),_===null?S=O:_.sibling=O,_=O,E=I}if(R.done)return n(m,E),be&&ir(m,A),S;if(E===null){for(;!R.done;A++,R=w.next())R=h(m,R.value,k),R!==null&&(v=s(R,v,A),_===null?S=R:_.sibling=R,_=R);return be&&ir(m,A),S}for(E=i(m,E);!R.done;A++,R=w.next())R=d(E,m,A,R.value,k),R!==null&&(t&&R.alternate!==null&&E.delete(R.key===null?A:R.key),v=s(R,v,A),_===null?S=R:_.sibling=R,_=R);return t&&E.forEach(function(D){return e(m,D)}),be&&ir(m,A),S}function x(m,v,w,k){if(typeof w=="object"&&w!==null&&w.type===Kr&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Yl:e:{for(var S=w.key,_=v;_!==null;){if(_.key===S){if(S=w.type,S===Kr){if(_.tag===7){n(m,_.sibling),v=r(_,w.props.children),v.return=m,m=v;break e}}else if(_.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===di&&qg(S)===_.type){n(m,_.sibling),v=r(_,w.props),v.ref=lo(m,_,w),v.return=m,m=v;break e}n(m,_);break}else e(m,_);_=_.sibling}w.type===Kr?(v=gr(w.props.children,m.mode,k,w.key),v.return=m,m=v):(k=Ja(w.type,w.key,w.props,null,m.mode,k),k.ref=lo(m,v,w),k.return=m,m=k)}return o(m);case qr:e:{for(_=w.key;v!==null;){if(v.key===_)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(m,v.sibling),v=r(v,w.children||[]),v.return=m,m=v;break e}else{n(m,v);break}else e(m,v);v=v.sibling}v=Eh(w,m.mode,k),v.return=m,m=v}return o(m);case di:return _=w._init,x(m,v,_(w._payload),k)}if(So(w))return p(m,v,w,k);if(no(w))return g(m,v,w,k);oa(m,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(m,v.sibling),v=r(v,w),v.return=m,m=v):(n(m,v),v=Ch(w,m.mode,k),v.return=m,m=v),o(m)):n(m,v)}return x}var Ms=lw(!0),aw=lw(!1),bu=qi(null),Cu=null,ts=null,Dp=null;function Lp(){Dp=ts=Cu=null}function Bp(t){var e=bu.current;Se(bu),t._currentValue=e}function zf(t,e,n){for(;t!==null;){var i=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,i!==null&&(i.childLanes|=e)):i!==null&&(i.childLanes&e)!==e&&(i.childLanes|=e),t===n)break;t=t.return}}function ds(t,e){Cu=t,Dp=ts=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(bt=!0),t.firstContext=null)}function Zt(t){var e=t._currentValue;if(Dp!==t)if(t={context:t,memoizedValue:e,next:null},ts===null){if(Cu===null)throw Error(U(308));ts=t,Cu.dependencies={lanes:0,firstContext:t}}else ts=ts.next=t;return e}var cr=null;function jp(t){cr===null?cr=[t]:cr.push(t)}function uw(t,e,n,i){var r=e.interleaved;return r===null?(n.next=n,jp(e)):(n.next=r.next,r.next=n),e.interleaved=n,ri(t,i)}function ri(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var pi=!1;function $p(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function cw(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ei(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Ii(t,e,n){var i=t.updateQueue;if(i===null)return null;if(i=i.shared,ue&2){var r=i.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),i.pending=e,ri(t,n)}return r=i.interleaved,r===null?(e.next=e,jp(i)):(e.next=r.next,r.next=e),i.interleaved=e,ri(t,n)}function qa(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,Cp(t,n)}}function Kg(t,e){var n=t.updateQueue,i=t.alternate;if(i!==null&&(i=i.updateQueue,n===i)){var r=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?r=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?r=s=e:s=s.next=e}else r=s=e;n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:i.shared,effects:i.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Eu(t,e,n,i){var r=t.updateQueue;pi=!1;var s=r.firstBaseUpdate,o=r.lastBaseUpdate,l=r.shared.pending;if(l!==null){r.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var h=r.baseState;o=0,c=u=a=null,l=s;do{var f=l.lane,d=l.eventTime;if((i&f)===f){c!==null&&(c=c.next={eventTime:d,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,g=l;switch(f=e,d=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){h=p.call(d,h,f);break e}h=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,f=typeof p=="function"?p.call(d,h,f):p,f==null)break e;h=Ne({},h,f);break e;case 2:pi=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,f=r.effects,f===null?r.effects=[l]:f.push(l))}else d={eventTime:d,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=d,a=h):c=c.next=d,o|=f;if(l=l.next,l===null){if(l=r.shared.pending,l===null)break;f=l,l=f.next,f.next=null,r.lastBaseUpdate=f,r.shared.pending=null}}while(!0);if(c===null&&(a=h),r.baseState=a,r.firstBaseUpdate=u,r.lastBaseUpdate=c,e=r.shared.interleaved,e!==null){r=e;do o|=r.lane,r=r.next;while(r!==e)}else s===null&&(r.shared.lanes=0);br|=o,t.lanes=o,t.memoizedState=h}}function Qg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var i=t[e],r=i.callback;if(r!==null){if(i.callback=null,i=n,typeof r!="function")throw Error(U(191,r));r.call(i)}}}var Ll={},Bn=qi(Ll),sl=qi(Ll),ol=qi(Ll);function hr(t){if(t===Ll)throw Error(U(174));return t}function zp(t,e){switch(ye(ol,e),ye(sl,t),ye(Bn,Ll),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:xf(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=xf(e,t)}Se(Bn),ye(Bn,e)}function Ts(){Se(Bn),Se(sl),Se(ol)}function hw(t){hr(ol.current);var e=hr(Bn.current),n=xf(e,t.type);e!==n&&(ye(sl,t),ye(Bn,n))}function Fp(t){sl.current===t&&(Se(Bn),Se(sl))}var Ee=qi(0);function _u(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var vh=[];function Vp(){for(var t=0;t<vh.length;t++)vh[t]._workInProgressVersionPrimary=null;vh.length=0}var Ka=ui.ReactCurrentDispatcher,wh=ui.ReactCurrentBatchConfig,Sr=0,_e=null,$e=null,We=null,Nu=!1,jo=!1,ll=0,$E=0;function tt(){throw Error(U(321))}function Hp(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!yn(t[n],e[n]))return!1;return!0}function Wp(t,e,n,i,r,s){if(Sr=s,_e=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Ka.current=t===null||t.memoizedState===null?HE:WE,t=n(i,r),jo){s=0;do{if(jo=!1,ll=0,25<=s)throw Error(U(301));s+=1,We=$e=null,e.updateQueue=null,Ka.current=UE,t=n(i,r)}while(jo)}if(Ka.current=Au,e=$e!==null&&$e.next!==null,Sr=0,We=$e=_e=null,Nu=!1,e)throw Error(U(300));return t}function Up(){var t=ll!==0;return ll=0,t}function Mn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return We===null?_e.memoizedState=We=t:We=We.next=t,We}function en(){if($e===null){var t=_e.alternate;t=t!==null?t.memoizedState:null}else t=$e.next;var e=We===null?_e.memoizedState:We.next;if(e!==null)We=e,$e=t;else{if(t===null)throw Error(U(310));$e=t,t={memoizedState:$e.memoizedState,baseState:$e.baseState,baseQueue:$e.baseQueue,queue:$e.queue,next:null},We===null?_e.memoizedState=We=t:We=We.next=t}return We}function al(t,e){return typeof e=="function"?e(t):e}function xh(t){var e=en(),n=e.queue;if(n===null)throw Error(U(311));n.lastRenderedReducer=t;var i=$e,r=i.baseQueue,s=n.pending;if(s!==null){if(r!==null){var o=r.next;r.next=s.next,s.next=o}i.baseQueue=r=s,n.pending=null}if(r!==null){s=r.next,i=i.baseState;var l=o=null,a=null,u=s;do{var c=u.lane;if((Sr&c)===c)a!==null&&(a=a.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:t(i,u.action);else{var h={lane:c,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};a===null?(l=a=h,o=i):a=a.next=h,_e.lanes|=c,br|=c}u=u.next}while(u!==null&&u!==s);a===null?o=i:a.next=l,yn(i,e.memoizedState)||(bt=!0),e.memoizedState=i,e.baseState=o,e.baseQueue=a,n.lastRenderedState=i}if(t=n.interleaved,t!==null){r=t;do s=r.lane,_e.lanes|=s,br|=s,r=r.next;while(r!==t)}else r===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function kh(t){var e=en(),n=e.queue;if(n===null)throw Error(U(311));n.lastRenderedReducer=t;var i=n.dispatch,r=n.pending,s=e.memoizedState;if(r!==null){n.pending=null;var o=r=r.next;do s=t(s,o.action),o=o.next;while(o!==r);yn(s,e.memoizedState)||(bt=!0),e.memoizedState=s,e.baseQueue===null&&(e.baseState=s),n.lastRenderedState=s}return[s,i]}function fw(){}function dw(t,e){var n=_e,i=en(),r=e(),s=!yn(i.memoizedState,r);if(s&&(i.memoizedState=r,bt=!0),i=i.queue,qp(gw.bind(null,n,i,t),[t]),i.getSnapshot!==e||s||We!==null&&We.memoizedState.tag&1){if(n.flags|=2048,ul(9,mw.bind(null,n,i,r,e),void 0,null),qe===null)throw Error(U(349));Sr&30||pw(n,e,r)}return r}function pw(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=_e.updateQueue,e===null?(e={lastEffect:null,stores:null},_e.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function mw(t,e,n,i){e.value=n,e.getSnapshot=i,yw(e)&&vw(t)}function gw(t,e,n){return n(function(){yw(e)&&vw(t)})}function yw(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!yn(t,n)}catch{return!0}}function vw(t){var e=ri(t,1);e!==null&&mn(e,t,1,-1)}function Yg(t){var e=Mn();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:t},e.queue=t,t=t.dispatch=VE.bind(null,_e,t),[e.memoizedState,t]}function ul(t,e,n,i){return t={tag:t,create:e,destroy:n,deps:i,next:null},e=_e.updateQueue,e===null?(e={lastEffect:null,stores:null},_e.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(i=n.next,n.next=t,t.next=i,e.lastEffect=t)),t}function ww(){return en().memoizedState}function Qa(t,e,n,i){var r=Mn();_e.flags|=t,r.memoizedState=ul(1|e,n,void 0,i===void 0?null:i)}function kc(t,e,n,i){var r=en();i=i===void 0?null:i;var s=void 0;if($e!==null){var o=$e.memoizedState;if(s=o.destroy,i!==null&&Hp(i,o.deps)){r.memoizedState=ul(e,n,s,i);return}}_e.flags|=t,r.memoizedState=ul(1|e,n,s,i)}function Xg(t,e){return Qa(8390656,8,t,e)}function qp(t,e){return kc(2048,8,t,e)}function xw(t,e){return kc(4,2,t,e)}function kw(t,e){return kc(4,4,t,e)}function Sw(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function bw(t,e,n){return n=n!=null?n.concat([t]):null,kc(4,4,Sw.bind(null,e,t),n)}function Kp(){}function Cw(t,e){var n=en();e=e===void 0?null:e;var i=n.memoizedState;return i!==null&&e!==null&&Hp(e,i[1])?i[0]:(n.memoizedState=[t,e],t)}function Ew(t,e){var n=en();e=e===void 0?null:e;var i=n.memoizedState;return i!==null&&e!==null&&Hp(e,i[1])?i[0]:(t=t(),n.memoizedState=[t,e],t)}function _w(t,e,n){return Sr&21?(yn(n,e)||(n=O1(),_e.lanes|=n,br|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,bt=!0),t.memoizedState=n)}function zE(t,e){var n=de;de=n!==0&&4>n?n:4,t(!0);var i=wh.transition;wh.transition={};try{t(!1),e()}finally{de=n,wh.transition=i}}function Nw(){return en().memoizedState}function FE(t,e,n){var i=Ri(t);if(n={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null},Aw(t))Mw(e,n);else if(n=uw(t,e,n,i),n!==null){var r=dt();mn(n,t,i,r),Tw(n,e,i)}}function VE(t,e,n){var i=Ri(t),r={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null};if(Aw(t))Mw(e,r);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(r.hasEagerState=!0,r.eagerState=l,yn(l,o)){var a=e.interleaved;a===null?(r.next=r,jp(e)):(r.next=a.next,a.next=r),e.interleaved=r;return}}catch{}finally{}n=uw(t,e,r,i),n!==null&&(r=dt(),mn(n,t,i,r),Tw(n,e,i))}}function Aw(t){var e=t.alternate;return t===_e||e!==null&&e===_e}function Mw(t,e){jo=Nu=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function Tw(t,e,n){if(n&4194240){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,Cp(t,n)}}var Au={readContext:Zt,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useInsertionEffect:tt,useLayoutEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useMutableSource:tt,useSyncExternalStore:tt,useId:tt,unstable_isNewReconciler:!1},HE={readContext:Zt,useCallback:function(t,e){return Mn().memoizedState=[t,e===void 0?null:e],t},useContext:Zt,useEffect:Xg,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Qa(4194308,4,Sw.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Qa(4194308,4,t,e)},useInsertionEffect:function(t,e){return Qa(4,2,t,e)},useMemo:function(t,e){var n=Mn();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var i=Mn();return e=n!==void 0?n(e):e,i.memoizedState=i.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},i.queue=t,t=t.dispatch=FE.bind(null,_e,t),[i.memoizedState,t]},useRef:function(t){var e=Mn();return t={current:t},e.memoizedState=t},useState:Yg,useDebugValue:Kp,useDeferredValue:function(t){return Mn().memoizedState=t},useTransition:function(){var t=Yg(!1),e=t[0];return t=zE.bind(null,t[1]),Mn().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var i=_e,r=Mn();if(be){if(n===void 0)throw Error(U(407));n=n()}else{if(n=e(),qe===null)throw Error(U(349));Sr&30||pw(i,e,n)}r.memoizedState=n;var s={value:n,getSnapshot:e};return r.queue=s,Xg(gw.bind(null,i,s,t),[t]),i.flags|=2048,ul(9,mw.bind(null,i,s,n,e),void 0,null),n},useId:function(){var t=Mn(),e=qe.identifierPrefix;if(be){var n=Gn,i=Xn;n=(i&~(1<<32-pn(i)-1)).toString(32)+n,e=":"+e+"R"+n,n=ll++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=$E++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},WE={readContext:Zt,useCallback:Cw,useContext:Zt,useEffect:qp,useImperativeHandle:bw,useInsertionEffect:xw,useLayoutEffect:kw,useMemo:Ew,useReducer:xh,useRef:ww,useState:function(){return xh(al)},useDebugValue:Kp,useDeferredValue:function(t){var e=en();return _w(e,$e.memoizedState,t)},useTransition:function(){var t=xh(al)[0],e=en().memoizedState;return[t,e]},useMutableSource:fw,useSyncExternalStore:dw,useId:Nw,unstable_isNewReconciler:!1},UE={readContext:Zt,useCallback:Cw,useContext:Zt,useEffect:qp,useImperativeHandle:bw,useInsertionEffect:xw,useLayoutEffect:kw,useMemo:Ew,useReducer:kh,useRef:ww,useState:function(){return kh(al)},useDebugValue:Kp,useDeferredValue:function(t){var e=en();return $e===null?e.memoizedState=t:_w(e,$e.memoizedState,t)},useTransition:function(){var t=kh(al)[0],e=en().memoizedState;return[t,e]},useMutableSource:fw,useSyncExternalStore:dw,useId:Nw,unstable_isNewReconciler:!1};function on(t,e){if(t&&t.defaultProps){e=Ne({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function Ff(t,e,n,i){e=t.memoizedState,n=n(i,e),n=n==null?e:Ne({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var Sc={isMounted:function(t){return(t=t._reactInternals)?Ir(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var i=dt(),r=Ri(t),s=ei(i,r);s.payload=e,n!=null&&(s.callback=n),e=Ii(t,s,r),e!==null&&(mn(e,t,r,i),qa(e,t,r))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var i=dt(),r=Ri(t),s=ei(i,r);s.tag=1,s.payload=e,n!=null&&(s.callback=n),e=Ii(t,s,r),e!==null&&(mn(e,t,r,i),qa(e,t,r))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=dt(),i=Ri(t),r=ei(n,i);r.tag=2,e!=null&&(r.callback=e),e=Ii(t,r,i),e!==null&&(mn(e,t,i,n),qa(e,t,i))}};function Gg(t,e,n,i,r,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(i,s,o):e.prototype&&e.prototype.isPureReactComponent?!tl(n,i)||!tl(r,s):!0}function Ow(t,e,n){var i=!1,r=$i,s=e.contextType;return typeof s=="object"&&s!==null?s=Zt(s):(r=Nt(e)?xr:lt.current,i=e.contextTypes,s=(i=i!=null)?Ns(t,r):$i),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Sc,t.stateNode=e,e._reactInternals=t,i&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=s),e}function Jg(t,e,n,i){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,i),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,i),e.state!==t&&Sc.enqueueReplaceState(e,e.state,null)}function Vf(t,e,n,i){var r=t.stateNode;r.props=n,r.state=t.memoizedState,r.refs={},$p(t);var s=e.contextType;typeof s=="object"&&s!==null?r.context=Zt(s):(s=Nt(e)?xr:lt.current,r.context=Ns(t,s)),r.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(Ff(t,e,s,n),r.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(e=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),e!==r.state&&Sc.enqueueReplaceState(r,r.state,null),Eu(t,n,r,i),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308)}function Os(t,e){try{var n="",i=e;do n+=w2(i),i=i.return;while(i);var r=n}catch(s){r=`
39
+ Error generating stack: `+s.message+`
40
+ `+s.stack}return{value:t,source:e,stack:r,digest:null}}function Sh(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Hf(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var qE=typeof WeakMap=="function"?WeakMap:Map;function Iw(t,e,n){n=ei(-1,n),n.tag=3,n.payload={element:null};var i=e.value;return n.callback=function(){Tu||(Tu=!0,Zf=i),Hf(t,e)},n}function Pw(t,e,n){n=ei(-1,n),n.tag=3;var i=t.type.getDerivedStateFromError;if(typeof i=="function"){var r=e.value;n.payload=function(){return i(r)},n.callback=function(){Hf(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Hf(t,e),typeof i!="function"&&(Pi===null?Pi=new Set([this]):Pi.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function Zg(t,e,n){var i=t.pingCache;if(i===null){i=t.pingCache=new qE;var r=new Set;i.set(e,r)}else r=i.get(e),r===void 0&&(r=new Set,i.set(e,r));r.has(n)||(r.add(n),t=o_.bind(null,t,e,n),e.then(t,t))}function e0(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function t0(t,e,n,i,r){return t.mode&1?(t.flags|=65536,t.lanes=r,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=ei(-1,1),e.tag=2,Ii(n,e,1))),n.lanes|=1),t)}var KE=ui.ReactCurrentOwner,bt=!1;function ht(t,e,n,i){e.child=t===null?aw(e,null,n,i):Ms(e,t.child,n,i)}function n0(t,e,n,i,r){n=n.render;var s=e.ref;return ds(e,r),i=Wp(t,e,n,i,s,r),n=Up(),t!==null&&!bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,si(t,e,r)):(be&&n&&Ip(e),e.flags|=1,ht(t,e,i,r),e.child)}function i0(t,e,n,i,r){if(t===null){var s=n.type;return typeof s=="function"&&!tm(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,Rw(t,e,s,i,r)):(t=Ja(n.type,null,i,e,e.mode,r),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,!(t.lanes&r)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:tl,n(o,i)&&t.ref===e.ref)return si(t,e,r)}return e.flags|=1,t=Di(s,i),t.ref=e.ref,t.return=e,e.child=t}function Rw(t,e,n,i,r){if(t!==null){var s=t.memoizedProps;if(tl(s,i)&&t.ref===e.ref)if(bt=!1,e.pendingProps=i=s,(t.lanes&r)!==0)t.flags&131072&&(bt=!0);else return e.lanes=t.lanes,si(t,e,r)}return Wf(t,e,n,i,r)}function Dw(t,e,n){var i=e.pendingProps,r=i.children,s=t!==null?t.memoizedState:null;if(i.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},ye(is,It),It|=n;else{if(!(n&1073741824))return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,ye(is,It),It|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},i=s!==null?s.baseLanes:n,ye(is,It),It|=i}else s!==null?(i=s.baseLanes|n,e.memoizedState=null):i=n,ye(is,It),It|=i;return ht(t,e,r,n),e.child}function Lw(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Wf(t,e,n,i,r){var s=Nt(n)?xr:lt.current;return s=Ns(e,s),ds(e,r),n=Wp(t,e,n,i,s,r),i=Up(),t!==null&&!bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,si(t,e,r)):(be&&i&&Ip(e),e.flags|=1,ht(t,e,n,r),e.child)}function r0(t,e,n,i,r){if(Nt(n)){var s=!0;xu(e)}else s=!1;if(ds(e,r),e.stateNode===null)Ya(t,e),Ow(e,n,i),Vf(e,n,i,r),i=!0;else if(t===null){var o=e.stateNode,l=e.memoizedProps;o.props=l;var a=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Zt(u):(u=Nt(n)?xr:lt.current,u=Ns(e,u));var c=n.getDerivedStateFromProps,h=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==i||a!==u)&&Jg(e,o,i,u),pi=!1;var f=e.memoizedState;o.state=f,Eu(e,i,o,r),a=e.memoizedState,l!==i||f!==a||_t.current||pi?(typeof c=="function"&&(Ff(e,n,c,i),a=e.memoizedState),(l=pi||Gg(e,n,l,i,f,a,u))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=i,e.memoizedState=a),o.props=i,o.state=a,o.context=u,i=l):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),i=!1)}else{o=e.stateNode,cw(t,e),l=e.memoizedProps,u=e.type===e.elementType?l:on(e.type,l),o.props=u,h=e.pendingProps,f=o.context,a=n.contextType,typeof a=="object"&&a!==null?a=Zt(a):(a=Nt(n)?xr:lt.current,a=Ns(e,a));var d=n.getDerivedStateFromProps;(c=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==h||f!==a)&&Jg(e,o,i,a),pi=!1,f=e.memoizedState,o.state=f,Eu(e,i,o,r);var p=e.memoizedState;l!==h||f!==p||_t.current||pi?(typeof d=="function"&&(Ff(e,n,d,i),p=e.memoizedState),(u=pi||Gg(e,n,u,i,f,p,a)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(i,p,a),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(i,p,a)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),e.memoizedProps=i,e.memoizedState=p),o.props=i,o.state=p,o.context=a,i=u):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),i=!1)}return Uf(t,e,n,i,s,r)}function Uf(t,e,n,i,r,s){Lw(t,e);var o=(e.flags&128)!==0;if(!i&&!o)return r&&Hg(e,n,!1),si(t,e,s);i=e.stateNode,KE.current=e;var l=o&&typeof n.getDerivedStateFromError!="function"?null:i.render();return e.flags|=1,t!==null&&o?(e.child=Ms(e,t.child,null,s),e.child=Ms(e,null,l,s)):ht(t,e,l,s),e.memoizedState=i.state,r&&Hg(e,n,!0),e.child}function Bw(t){var e=t.stateNode;e.pendingContext?Vg(t,e.pendingContext,e.pendingContext!==e.context):e.context&&Vg(t,e.context,!1),zp(t,e.containerInfo)}function s0(t,e,n,i,r){return As(),Rp(r),e.flags|=256,ht(t,e,n,i),e.child}var qf={dehydrated:null,treeContext:null,retryLane:0};function Kf(t){return{baseLanes:t,cachePool:null,transitions:null}}function jw(t,e,n){var i=e.pendingProps,r=Ee.current,s=!1,o=(e.flags&128)!==0,l;if((l=o)||(l=t!==null&&t.memoizedState===null?!1:(r&2)!==0),l?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(r|=1),ye(Ee,r&1),t===null)return $f(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=i.children,t=i.fallback,s?(i=e.mode,s=e.child,o={mode:"hidden",children:o},!(i&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=Ec(o,i,0,null),t=gr(t,i,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=Kf(n),e.memoizedState=qf,t):Qp(e,o));if(r=t.memoizedState,r!==null&&(l=r.dehydrated,l!==null))return QE(t,e,o,i,l,r,n);if(s){s=i.fallback,o=e.mode,r=t.child,l=r.sibling;var a={mode:"hidden",children:i.children};return!(o&1)&&e.child!==r?(i=e.child,i.childLanes=0,i.pendingProps=a,e.deletions=null):(i=Di(r,a),i.subtreeFlags=r.subtreeFlags&14680064),l!==null?s=Di(l,s):(s=gr(s,o,n,null),s.flags|=2),s.return=e,i.return=e,i.sibling=s,e.child=i,i=s,s=e.child,o=t.child.memoizedState,o=o===null?Kf(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=qf,i}return s=t.child,t=s.sibling,i=Di(s,{mode:"visible",children:i.children}),!(e.mode&1)&&(i.lanes=n),i.return=e,i.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=i,e.memoizedState=null,i}function Qp(t,e){return e=Ec({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function la(t,e,n,i){return i!==null&&Rp(i),Ms(e,t.child,null,n),t=Qp(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function QE(t,e,n,i,r,s,o){if(n)return e.flags&256?(e.flags&=-257,i=Sh(Error(U(422))),la(t,e,o,i)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=i.fallback,r=e.mode,i=Ec({mode:"visible",children:i.children},r,0,null),s=gr(s,r,o,null),s.flags|=2,i.return=e,s.return=e,i.sibling=s,e.child=i,e.mode&1&&Ms(e,t.child,null,o),e.child.memoizedState=Kf(o),e.memoizedState=qf,s);if(!(e.mode&1))return la(t,e,o,null);if(r.data==="$!"){if(i=r.nextSibling&&r.nextSibling.dataset,i)var l=i.dgst;return i=l,s=Error(U(419)),i=Sh(s,i,void 0),la(t,e,o,i)}if(l=(o&t.childLanes)!==0,bt||l){if(i=qe,i!==null){switch(o&-o){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(i.suspendedLanes|o)?0:r,r!==0&&r!==s.retryLane&&(s.retryLane=r,ri(t,r),mn(i,t,r,-1))}return em(),i=Sh(Error(U(421))),la(t,e,o,i)}return r.data==="$?"?(e.flags|=128,e.child=t.child,e=l_.bind(null,t),r._reactRetry=e,null):(t=s.treeContext,Dt=Oi(r.nextSibling),Bt=e,be=!0,an=null,t!==null&&(Vt[Ht++]=Xn,Vt[Ht++]=Gn,Vt[Ht++]=kr,Xn=t.id,Gn=t.overflow,kr=e),e=Qp(e,i.children),e.flags|=4096,e)}function o0(t,e,n){t.lanes|=e;var i=t.alternate;i!==null&&(i.lanes|=e),zf(t.return,e,n)}function bh(t,e,n,i,r){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=n,s.tailMode=r)}function $w(t,e,n){var i=e.pendingProps,r=i.revealOrder,s=i.tail;if(ht(t,e,i.children,n),i=Ee.current,i&2)i=i&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&o0(t,n,e);else if(t.tag===19)o0(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}i&=1}if(ye(Ee,i),!(e.mode&1))e.memoizedState=null;else switch(r){case"forwards":for(n=e.child,r=null;n!==null;)t=n.alternate,t!==null&&_u(t)===null&&(r=n),n=n.sibling;n=r,n===null?(r=e.child,e.child=null):(r=n.sibling,n.sibling=null),bh(e,!1,r,n,s);break;case"backwards":for(n=null,r=e.child,e.child=null;r!==null;){if(t=r.alternate,t!==null&&_u(t)===null){e.child=r;break}t=r.sibling,r.sibling=n,n=r,r=t}bh(e,!0,n,null,s);break;case"together":bh(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Ya(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function si(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),br|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(U(153));if(e.child!==null){for(t=e.child,n=Di(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=Di(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function YE(t,e,n){switch(e.tag){case 3:Bw(e),As();break;case 5:hw(e);break;case 1:Nt(e.type)&&xu(e);break;case 4:zp(e,e.stateNode.containerInfo);break;case 10:var i=e.type._context,r=e.memoizedProps.value;ye(bu,i._currentValue),i._currentValue=r;break;case 13:if(i=e.memoizedState,i!==null)return i.dehydrated!==null?(ye(Ee,Ee.current&1),e.flags|=128,null):n&e.child.childLanes?jw(t,e,n):(ye(Ee,Ee.current&1),t=si(t,e,n),t!==null?t.sibling:null);ye(Ee,Ee.current&1);break;case 19:if(i=(n&e.childLanes)!==0,t.flags&128){if(i)return $w(t,e,n);e.flags|=128}if(r=e.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),ye(Ee,Ee.current),i)break;return null;case 22:case 23:return e.lanes=0,Dw(t,e,n)}return si(t,e,n)}var zw,Qf,Fw,Vw;zw=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Qf=function(){};Fw=function(t,e,n,i){var r=t.memoizedProps;if(r!==i){t=e.stateNode,hr(Bn.current);var s=null;switch(n){case"input":r=gf(t,r),i=gf(t,i),s=[];break;case"select":r=Ne({},r,{value:void 0}),i=Ne({},i,{value:void 0}),s=[];break;case"textarea":r=wf(t,r),i=wf(t,i),s=[];break;default:typeof r.onClick!="function"&&typeof i.onClick=="function"&&(t.onclick=vu)}kf(n,i);var o;n=null;for(u in r)if(!i.hasOwnProperty(u)&&r.hasOwnProperty(u)&&r[u]!=null)if(u==="style"){var l=r[u];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Qo.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in i){var a=i[u];if(l=r!=null?r[u]:void 0,i.hasOwnProperty(u)&&a!==l&&(a!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||a&&a.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in a)a.hasOwnProperty(o)&&l[o]!==a[o]&&(n||(n={}),n[o]=a[o])}else n||(s||(s=[]),s.push(u,n)),n=a;else u==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,l=l?l.__html:void 0,a!=null&&l!==a&&(s=s||[]).push(u,a)):u==="children"?typeof a!="string"&&typeof a!="number"||(s=s||[]).push(u,""+a):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Qo.hasOwnProperty(u)?(a!=null&&u==="onScroll"&&ke("scroll",t),s||l===a||(s=[])):(s=s||[]).push(u,a))}n&&(s=s||[]).push("style",n);var u=s;(e.updateQueue=u)&&(e.flags|=4)}};Vw=function(t,e,n,i){n!==i&&(e.flags|=4)};function ao(t,e){if(!be)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:i.sibling=null}}function nt(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,i=0;if(e)for(var r=t.child;r!==null;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags&14680064,i|=r.flags&14680064,r.return=t,r=r.sibling;else for(r=t.child;r!==null;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=t,r=r.sibling;return t.subtreeFlags|=i,t.childLanes=n,e}function XE(t,e,n){var i=e.pendingProps;switch(Pp(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nt(e),null;case 1:return Nt(e.type)&&wu(),nt(e),null;case 3:return i=e.stateNode,Ts(),Se(_t),Se(lt),Vp(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(t===null||t.child===null)&&(sa(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,an!==null&&(nd(an),an=null))),Qf(t,e),nt(e),null;case 5:Fp(e);var r=hr(ol.current);if(n=e.type,t!==null&&e.stateNode!=null)Fw(t,e,n,i,r),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!i){if(e.stateNode===null)throw Error(U(166));return nt(e),null}if(t=hr(Bn.current),sa(e)){i=e.stateNode,n=e.type;var s=e.memoizedProps;switch(i[On]=e,i[rl]=s,t=(e.mode&1)!==0,n){case"dialog":ke("cancel",i),ke("close",i);break;case"iframe":case"object":case"embed":ke("load",i);break;case"video":case"audio":for(r=0;r<Co.length;r++)ke(Co[r],i);break;case"source":ke("error",i);break;case"img":case"image":case"link":ke("error",i),ke("load",i);break;case"details":ke("toggle",i);break;case"input":mg(i,s),ke("invalid",i);break;case"select":i._wrapperState={wasMultiple:!!s.multiple},ke("invalid",i);break;case"textarea":yg(i,s),ke("invalid",i)}kf(n,s),r=null;for(var o in s)if(s.hasOwnProperty(o)){var l=s[o];o==="children"?typeof l=="string"?i.textContent!==l&&(s.suppressHydrationWarning!==!0&&ra(i.textContent,l,t),r=["children",l]):typeof l=="number"&&i.textContent!==""+l&&(s.suppressHydrationWarning!==!0&&ra(i.textContent,l,t),r=["children",""+l]):Qo.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&ke("scroll",i)}switch(n){case"input":Xl(i),gg(i,s,!0);break;case"textarea":Xl(i),vg(i);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(i.onclick=vu)}i=r,e.updateQueue=i,i!==null&&(e.flags|=4)}else{o=r.nodeType===9?r:r.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=g1(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=o.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof i.is=="string"?t=o.createElement(n,{is:i.is}):(t=o.createElement(n),n==="select"&&(o=t,i.multiple?o.multiple=!0:i.size&&(o.size=i.size))):t=o.createElementNS(t,n),t[On]=e,t[rl]=i,zw(t,e,!1,!1),e.stateNode=t;e:{switch(o=Sf(n,i),n){case"dialog":ke("cancel",t),ke("close",t),r=i;break;case"iframe":case"object":case"embed":ke("load",t),r=i;break;case"video":case"audio":for(r=0;r<Co.length;r++)ke(Co[r],t);r=i;break;case"source":ke("error",t),r=i;break;case"img":case"image":case"link":ke("error",t),ke("load",t),r=i;break;case"details":ke("toggle",t),r=i;break;case"input":mg(t,i),r=gf(t,i),ke("invalid",t);break;case"option":r=i;break;case"select":t._wrapperState={wasMultiple:!!i.multiple},r=Ne({},i,{value:void 0}),ke("invalid",t);break;case"textarea":yg(t,i),r=wf(t,i),ke("invalid",t);break;default:r=i}kf(n,r),l=r;for(s in l)if(l.hasOwnProperty(s)){var a=l[s];s==="style"?w1(t,a):s==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,a!=null&&y1(t,a)):s==="children"?typeof a=="string"?(n!=="textarea"||a!=="")&&Yo(t,a):typeof a=="number"&&Yo(t,""+a):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Qo.hasOwnProperty(s)?a!=null&&s==="onScroll"&&ke("scroll",t):a!=null&&vp(t,s,a,o))}switch(n){case"input":Xl(t),gg(t,i,!1);break;case"textarea":Xl(t),vg(t);break;case"option":i.value!=null&&t.setAttribute("value",""+ji(i.value));break;case"select":t.multiple=!!i.multiple,s=i.value,s!=null?us(t,!!i.multiple,s,!1):i.defaultValue!=null&&us(t,!!i.multiple,i.defaultValue,!0);break;default:typeof r.onClick=="function"&&(t.onclick=vu)}switch(n){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}}i&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return nt(e),null;case 6:if(t&&e.stateNode!=null)Vw(t,e,t.memoizedProps,i);else{if(typeof i!="string"&&e.stateNode===null)throw Error(U(166));if(n=hr(ol.current),hr(Bn.current),sa(e)){if(i=e.stateNode,n=e.memoizedProps,i[On]=e,(s=i.nodeValue!==n)&&(t=Bt,t!==null))switch(t.tag){case 3:ra(i.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&ra(i.nodeValue,n,(t.mode&1)!==0)}s&&(e.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[On]=e,e.stateNode=i}return nt(e),null;case 13:if(Se(Ee),i=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(be&&Dt!==null&&e.mode&1&&!(e.flags&128))ow(),As(),e.flags|=98560,s=!1;else if(s=sa(e),i!==null&&i.dehydrated!==null){if(t===null){if(!s)throw Error(U(318));if(s=e.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(U(317));s[On]=e}else As(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;nt(e),s=!1}else an!==null&&(nd(an),an=null),s=!0;if(!s)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(i=i!==null,i!==(t!==null&&t.memoizedState!==null)&&i&&(e.child.flags|=8192,e.mode&1&&(t===null||Ee.current&1?Fe===0&&(Fe=3):em())),e.updateQueue!==null&&(e.flags|=4),nt(e),null);case 4:return Ts(),Qf(t,e),t===null&&nl(e.stateNode.containerInfo),nt(e),null;case 10:return Bp(e.type._context),nt(e),null;case 17:return Nt(e.type)&&wu(),nt(e),null;case 19:if(Se(Ee),s=e.memoizedState,s===null)return nt(e),null;if(i=(e.flags&128)!==0,o=s.rendering,o===null)if(i)ao(s,!1);else{if(Fe!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(o=_u(t),o!==null){for(e.flags|=128,ao(s,!1),i=o.updateQueue,i!==null&&(e.updateQueue=i,e.flags|=4),e.subtreeFlags=0,i=n,n=e.child;n!==null;)s=n,t=i,s.flags&=14680066,o=s.alternate,o===null?(s.childLanes=0,s.lanes=t,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=o.childLanes,s.lanes=o.lanes,s.child=o.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=o.memoizedProps,s.memoizedState=o.memoizedState,s.updateQueue=o.updateQueue,s.type=o.type,t=o.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return ye(Ee,Ee.current&1|2),e.child}t=t.sibling}s.tail!==null&&De()>Is&&(e.flags|=128,i=!0,ao(s,!1),e.lanes=4194304)}else{if(!i)if(t=_u(o),t!==null){if(e.flags|=128,i=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ao(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!be)return nt(e),null}else 2*De()-s.renderingStartTime>Is&&n!==1073741824&&(e.flags|=128,i=!0,ao(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=De(),e.sibling=null,n=Ee.current,ye(Ee,i?n&1|2:n&1),e):(nt(e),null);case 22:case 23:return Zp(),i=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?It&1073741824&&(nt(e),e.subtreeFlags&6&&(e.flags|=8192)):nt(e),null;case 24:return null;case 25:return null}throw Error(U(156,e.tag))}function GE(t,e){switch(Pp(e),e.tag){case 1:return Nt(e.type)&&wu(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ts(),Se(_t),Se(lt),Vp(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Fp(e),null;case 13:if(Se(Ee),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(U(340));As()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Se(Ee),null;case 4:return Ts(),null;case 10:return Bp(e.type._context),null;case 22:case 23:return Zp(),null;case 24:return null;default:return null}}var aa=!1,rt=!1,JE=typeof WeakSet=="function"?WeakSet:Set,Y=null;function ns(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(i){Ae(t,e,i)}else n.current=null}function Yf(t,e,n){try{n()}catch(i){Ae(t,e,i)}}var l0=!1;function ZE(t,e){if(If=mu,t=K1(),Op(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,h=t,f=null;t:for(;;){for(var d;h!==n||r!==0&&h.nodeType!==3||(l=o+r),h!==s||i!==0&&h.nodeType!==3||(a=o+i),h.nodeType===3&&(o+=h.nodeValue.length),(d=h.firstChild)!==null;)f=h,h=d;for(;;){if(h===t)break t;if(f===n&&++u===r&&(l=o),f===s&&++c===i&&(a=o),(d=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=d}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(Pf={focusedElem:t,selectionRange:n},mu=!1,Y=e;Y!==null;)if(e=Y,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Y=t;else for(;Y!==null;){e=Y;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,x=p.memoizedState,m=e.stateNode,v=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:on(e.type,g),x);m.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(U(163))}}catch(k){Ae(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Y=t;break}Y=e.return}return p=l0,l0=!1,p}function $o(t,e,n){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&t)===t){var s=r.destroy;r.destroy=void 0,s!==void 0&&Yf(e,n,s)}r=r.next}while(r!==i)}}function bc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var i=n.create;n.destroy=i()}n=n.next}while(n!==e)}}function Xf(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function Hw(t){var e=t.alternate;e!==null&&(t.alternate=null,Hw(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[On],delete e[rl],delete e[Lf],delete e[DE],delete e[LE])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Ww(t){return t.tag===5||t.tag===3||t.tag===4}function a0(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Ww(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Gf(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=vu));else if(i!==4&&(t=t.child,t!==null))for(Gf(t,e,n),t=t.sibling;t!==null;)Gf(t,e,n),t=t.sibling}function Jf(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(i!==4&&(t=t.child,t!==null))for(Jf(t,e,n),t=t.sibling;t!==null;)Jf(t,e,n),t=t.sibling}var Ye=null,ln=!1;function hi(t,e,n){for(n=n.child;n!==null;)Uw(t,e,n),n=n.sibling}function Uw(t,e,n){if(Ln&&typeof Ln.onCommitFiberUnmount=="function")try{Ln.onCommitFiberUnmount(mc,n)}catch{}switch(n.tag){case 5:rt||ns(n,e);case 6:var i=Ye,r=ln;Ye=null,hi(t,e,n),Ye=i,ln=r,Ye!==null&&(ln?(t=Ye,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Ye.removeChild(n.stateNode));break;case 18:Ye!==null&&(ln?(t=Ye,n=n.stateNode,t.nodeType===8?gh(t.parentNode,n):t.nodeType===1&&gh(t,n),Zo(t)):gh(Ye,n.stateNode));break;case 4:i=Ye,r=ln,Ye=n.stateNode.containerInfo,ln=!0,hi(t,e,n),Ye=i,ln=r;break;case 0:case 11:case 14:case 15:if(!rt&&(i=n.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Yf(n,e,o),r=r.next}while(r!==i)}hi(t,e,n);break;case 1:if(!rt&&(ns(n,e),i=n.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=n.memoizedProps,i.state=n.memoizedState,i.componentWillUnmount()}catch(l){Ae(n,e,l)}hi(t,e,n);break;case 21:hi(t,e,n);break;case 22:n.mode&1?(rt=(i=rt)||n.memoizedState!==null,hi(t,e,n),rt=i):hi(t,e,n);break;default:hi(t,e,n)}}function u0(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new JE),e.forEach(function(i){var r=a_.bind(null,t,i);n.has(i)||(n.add(i),i.then(r,r))})}}function sn(t,e){var n=e.deletions;if(n!==null)for(var i=0;i<n.length;i++){var r=n[i];try{var s=t,o=e,l=o;e:for(;l!==null;){switch(l.tag){case 5:Ye=l.stateNode,ln=!1;break e;case 3:Ye=l.stateNode.containerInfo,ln=!0;break e;case 4:Ye=l.stateNode.containerInfo,ln=!0;break e}l=l.return}if(Ye===null)throw Error(U(160));Uw(s,o,r),Ye=null,ln=!1;var a=r.alternate;a!==null&&(a.return=null),r.return=null}catch(u){Ae(r,e,u)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)qw(e,t),e=e.sibling}function qw(t,e){var n=t.alternate,i=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(sn(e,t),Cn(t),i&4){try{$o(3,t,t.return),bc(3,t)}catch(g){Ae(t,t.return,g)}try{$o(5,t,t.return)}catch(g){Ae(t,t.return,g)}}break;case 1:sn(e,t),Cn(t),i&512&&n!==null&&ns(n,n.return);break;case 5:if(sn(e,t),Cn(t),i&512&&n!==null&&ns(n,n.return),t.flags&32){var r=t.stateNode;try{Yo(r,"")}catch(g){Ae(t,t.return,g)}}if(i&4&&(r=t.stateNode,r!=null)){var s=t.memoizedProps,o=n!==null?n.memoizedProps:s,l=t.type,a=t.updateQueue;if(t.updateQueue=null,a!==null)try{l==="input"&&s.type==="radio"&&s.name!=null&&p1(r,s),Sf(l,o);var u=Sf(l,s);for(o=0;o<a.length;o+=2){var c=a[o],h=a[o+1];c==="style"?w1(r,h):c==="dangerouslySetInnerHTML"?y1(r,h):c==="children"?Yo(r,h):vp(r,c,h,u)}switch(l){case"input":yf(r,s);break;case"textarea":m1(r,s);break;case"select":var f=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!s.multiple;var d=s.value;d!=null?us(r,!!s.multiple,d,!1):f!==!!s.multiple&&(s.defaultValue!=null?us(r,!!s.multiple,s.defaultValue,!0):us(r,!!s.multiple,s.multiple?[]:"",!1))}r[rl]=s}catch(g){Ae(t,t.return,g)}}break;case 6:if(sn(e,t),Cn(t),i&4){if(t.stateNode===null)throw Error(U(162));r=t.stateNode,s=t.memoizedProps;try{r.nodeValue=s}catch(g){Ae(t,t.return,g)}}break;case 3:if(sn(e,t),Cn(t),i&4&&n!==null&&n.memoizedState.isDehydrated)try{Zo(e.containerInfo)}catch(g){Ae(t,t.return,g)}break;case 4:sn(e,t),Cn(t);break;case 13:sn(e,t),Cn(t),r=t.child,r.flags&8192&&(s=r.memoizedState!==null,r.stateNode.isHidden=s,!s||r.alternate!==null&&r.alternate.memoizedState!==null||(Gp=De())),i&4&&u0(t);break;case 22:if(c=n!==null&&n.memoizedState!==null,t.mode&1?(rt=(u=rt)||c,sn(e,t),rt=u):sn(e,t),Cn(t),i&8192){if(u=t.memoizedState!==null,(t.stateNode.isHidden=u)&&!c&&t.mode&1)for(Y=t,c=t.child;c!==null;){for(h=Y=c;Y!==null;){switch(f=Y,d=f.child,f.tag){case 0:case 11:case 14:case 15:$o(4,f,f.return);break;case 1:ns(f,f.return);var p=f.stateNode;if(typeof p.componentWillUnmount=="function"){i=f,n=f.return;try{e=i,p.props=e.memoizedProps,p.state=e.memoizedState,p.componentWillUnmount()}catch(g){Ae(i,n,g)}}break;case 5:ns(f,f.return);break;case 22:if(f.memoizedState!==null){h0(h);continue}}d!==null?(d.return=f,Y=d):h0(h)}c=c.sibling}e:for(c=null,h=t;;){if(h.tag===5){if(c===null){c=h;try{r=h.stateNode,u?(s=r.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(l=h.stateNode,a=h.memoizedProps.style,o=a!=null&&a.hasOwnProperty("display")?a.display:null,l.style.display=v1("display",o))}catch(g){Ae(t,t.return,g)}}}else if(h.tag===6){if(c===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(g){Ae(t,t.return,g)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===t)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;c===h&&(c=null),h=h.return}c===h&&(c=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:sn(e,t),Cn(t),i&4&&u0(t);break;case 21:break;default:sn(e,t),Cn(t)}}function Cn(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(Ww(n)){var i=n;break e}n=n.return}throw Error(U(160))}switch(i.tag){case 5:var r=i.stateNode;i.flags&32&&(Yo(r,""),i.flags&=-33);var s=a0(t);Jf(t,s,r);break;case 3:case 4:var o=i.stateNode.containerInfo,l=a0(t);Gf(t,l,o);break;default:throw Error(U(161))}}catch(a){Ae(t,t.return,a)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function e_(t,e,n){Y=t,Kw(t)}function Kw(t,e,n){for(var i=(t.mode&1)!==0;Y!==null;){var r=Y,s=r.child;if(r.tag===22&&i){var o=r.memoizedState!==null||aa;if(!o){var l=r.alternate,a=l!==null&&l.memoizedState!==null||rt;l=aa;var u=rt;if(aa=o,(rt=a)&&!u)for(Y=r;Y!==null;)o=Y,a=o.child,o.tag===22&&o.memoizedState!==null?f0(r):a!==null?(a.return=o,Y=a):f0(r);for(;s!==null;)Y=s,Kw(s),s=s.sibling;Y=r,aa=l,rt=u}c0(t)}else r.subtreeFlags&8772&&s!==null?(s.return=r,Y=s):c0(t)}}function c0(t){for(;Y!==null;){var e=Y;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:rt||bc(5,e);break;case 1:var i=e.stateNode;if(e.flags&4&&!rt)if(n===null)i.componentDidMount();else{var r=e.elementType===e.type?n.memoizedProps:on(e.type,n.memoizedProps);i.componentDidUpdate(r,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}var s=e.updateQueue;s!==null&&Qg(e,s,i);break;case 3:var o=e.updateQueue;if(o!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}Qg(e,o,n)}break;case 5:var l=e.stateNode;if(n===null&&e.flags&4){n=l;var a=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":a.autoFocus&&n.focus();break;case"img":a.src&&(n.src=a.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var u=e.alternate;if(u!==null){var c=u.memoizedState;if(c!==null){var h=c.dehydrated;h!==null&&Zo(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(U(163))}rt||e.flags&512&&Xf(e)}catch(f){Ae(e,e.return,f)}}if(e===t){Y=null;break}if(n=e.sibling,n!==null){n.return=e.return,Y=n;break}Y=e.return}}function h0(t){for(;Y!==null;){var e=Y;if(e===t){Y=null;break}var n=e.sibling;if(n!==null){n.return=e.return,Y=n;break}Y=e.return}}function f0(t){for(;Y!==null;){var e=Y;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{bc(4,e)}catch(a){Ae(e,n,a)}break;case 1:var i=e.stateNode;if(typeof i.componentDidMount=="function"){var r=e.return;try{i.componentDidMount()}catch(a){Ae(e,r,a)}}var s=e.return;try{Xf(e)}catch(a){Ae(e,s,a)}break;case 5:var o=e.return;try{Xf(e)}catch(a){Ae(e,o,a)}}}catch(a){Ae(e,e.return,a)}if(e===t){Y=null;break}var l=e.sibling;if(l!==null){l.return=e.return,Y=l;break}Y=e.return}}var t_=Math.ceil,Mu=ui.ReactCurrentDispatcher,Yp=ui.ReactCurrentOwner,Xt=ui.ReactCurrentBatchConfig,ue=0,qe=null,Be=null,Je=0,It=0,is=qi(0),Fe=0,cl=null,br=0,Cc=0,Xp=0,zo=null,xt=null,Gp=0,Is=1/0,qn=null,Tu=!1,Zf=null,Pi=null,ua=!1,Ei=null,Ou=0,Fo=0,ed=null,Xa=-1,Ga=0;function dt(){return ue&6?De():Xa!==-1?Xa:Xa=De()}function Ri(t){return t.mode&1?ue&2&&Je!==0?Je&-Je:jE.transition!==null?(Ga===0&&(Ga=O1()),Ga):(t=de,t!==0||(t=window.event,t=t===void 0?16:j1(t.type)),t):1}function mn(t,e,n,i){if(50<Fo)throw Fo=0,ed=null,Error(U(185));Pl(t,n,i),(!(ue&2)||t!==qe)&&(t===qe&&(!(ue&2)&&(Cc|=n),Fe===4&&xi(t,Je)),At(t,i),n===1&&ue===0&&!(e.mode&1)&&(Is=De()+500,xc&&Ki()))}function At(t,e){var n=t.callbackNode;j2(t,e);var i=pu(t,t===qe?Je:0);if(i===0)n!==null&&kg(n),t.callbackNode=null,t.callbackPriority=0;else if(e=i&-i,t.callbackPriority!==e){if(n!=null&&kg(n),e===1)t.tag===0?BE(d0.bind(null,t)):iw(d0.bind(null,t)),PE(function(){!(ue&6)&&Ki()}),n=null;else{switch(I1(i)){case 1:n=bp;break;case 4:n=M1;break;case 16:n=du;break;case 536870912:n=T1;break;default:n=du}n=tx(n,Qw.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function Qw(t,e){if(Xa=-1,Ga=0,ue&6)throw Error(U(327));var n=t.callbackNode;if(ps()&&t.callbackNode!==n)return null;var i=pu(t,t===qe?Je:0);if(i===0)return null;if(i&30||i&t.expiredLanes||e)e=Iu(t,i);else{e=i;var r=ue;ue|=2;var s=Xw();(qe!==t||Je!==e)&&(qn=null,Is=De()+500,mr(t,e));do try{r_();break}catch(l){Yw(t,l)}while(!0);Lp(),Mu.current=s,ue=r,Be!==null?e=0:(qe=null,Je=0,e=Fe)}if(e!==0){if(e===2&&(r=Nf(t),r!==0&&(i=r,e=td(t,r))),e===1)throw n=cl,mr(t,0),xi(t,i),At(t,De()),n;if(e===6)xi(t,i);else{if(r=t.current.alternate,!(i&30)&&!n_(r)&&(e=Iu(t,i),e===2&&(s=Nf(t),s!==0&&(i=s,e=td(t,s))),e===1))throw n=cl,mr(t,0),xi(t,i),At(t,De()),n;switch(t.finishedWork=r,t.finishedLanes=i,e){case 0:case 1:throw Error(U(345));case 2:rr(t,xt,qn);break;case 3:if(xi(t,i),(i&130023424)===i&&(e=Gp+500-De(),10<e)){if(pu(t,0)!==0)break;if(r=t.suspendedLanes,(r&i)!==i){dt(),t.pingedLanes|=t.suspendedLanes&r;break}t.timeoutHandle=Df(rr.bind(null,t,xt,qn),e);break}rr(t,xt,qn);break;case 4:if(xi(t,i),(i&4194240)===i)break;for(e=t.eventTimes,r=-1;0<i;){var o=31-pn(i);s=1<<o,o=e[o],o>r&&(r=o),i&=~s}if(i=r,i=De()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*t_(i/1960))-i,10<i){t.timeoutHandle=Df(rr.bind(null,t,xt,qn),i);break}rr(t,xt,qn);break;case 5:rr(t,xt,qn);break;default:throw Error(U(329))}}}return At(t,De()),t.callbackNode===n?Qw.bind(null,t):null}function td(t,e){var n=zo;return t.current.memoizedState.isDehydrated&&(mr(t,e).flags|=256),t=Iu(t,e),t!==2&&(e=xt,xt=n,e!==null&&nd(e)),t}function nd(t){xt===null?xt=t:xt.push.apply(xt,t)}function n_(t){for(var e=t;;){if(e.flags&16384){var n=e.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var i=0;i<n.length;i++){var r=n[i],s=r.getSnapshot;r=r.value;try{if(!yn(s(),r))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function xi(t,e){for(e&=~Xp,e&=~Cc,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-pn(e),i=1<<n;t[n]=-1,e&=~i}}function d0(t){if(ue&6)throw Error(U(327));ps();var e=pu(t,0);if(!(e&1))return At(t,De()),null;var n=Iu(t,e);if(t.tag!==0&&n===2){var i=Nf(t);i!==0&&(e=i,n=td(t,i))}if(n===1)throw n=cl,mr(t,0),xi(t,e),At(t,De()),n;if(n===6)throw Error(U(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,rr(t,xt,qn),At(t,De()),null}function Jp(t,e){var n=ue;ue|=1;try{return t(e)}finally{ue=n,ue===0&&(Is=De()+500,xc&&Ki())}}function Cr(t){Ei!==null&&Ei.tag===0&&!(ue&6)&&ps();var e=ue;ue|=1;var n=Xt.transition,i=de;try{if(Xt.transition=null,de=1,t)return t()}finally{de=i,Xt.transition=n,ue=e,!(ue&6)&&Ki()}}function Zp(){It=is.current,Se(is)}function mr(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,IE(n)),Be!==null)for(n=Be.return;n!==null;){var i=n;switch(Pp(i),i.tag){case 1:i=i.type.childContextTypes,i!=null&&wu();break;case 3:Ts(),Se(_t),Se(lt),Vp();break;case 5:Fp(i);break;case 4:Ts();break;case 13:Se(Ee);break;case 19:Se(Ee);break;case 10:Bp(i.type._context);break;case 22:case 23:Zp()}n=n.return}if(qe=t,Be=t=Di(t.current,null),Je=It=e,Fe=0,cl=null,Xp=Cc=br=0,xt=zo=null,cr!==null){for(e=0;e<cr.length;e++)if(n=cr[e],i=n.interleaved,i!==null){n.interleaved=null;var r=i.next,s=n.pending;if(s!==null){var o=s.next;s.next=r,i.next=o}n.pending=i}cr=null}return t}function Yw(t,e){do{var n=Be;try{if(Lp(),Ka.current=Au,Nu){for(var i=_e.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}Nu=!1}if(Sr=0,We=$e=_e=null,jo=!1,ll=0,Yp.current=null,n===null||n.return===null){Fe=1,cl=e,Be=null;break}e:{var s=t,o=n.return,l=n,a=e;if(e=Je,l.flags|=32768,a!==null&&typeof a=="object"&&typeof a.then=="function"){var u=a,c=l,h=c.tag;if(!(c.mode&1)&&(h===0||h===11||h===15)){var f=c.alternate;f?(c.updateQueue=f.updateQueue,c.memoizedState=f.memoizedState,c.lanes=f.lanes):(c.updateQueue=null,c.memoizedState=null)}var d=e0(o);if(d!==null){d.flags&=-257,t0(d,o,l,s,e),d.mode&1&&Zg(s,u,e),e=d,a=u;var p=e.updateQueue;if(p===null){var g=new Set;g.add(a),e.updateQueue=g}else p.add(a);break e}else{if(!(e&1)){Zg(s,u,e),em();break e}a=Error(U(426))}}else if(be&&l.mode&1){var x=e0(o);if(x!==null){!(x.flags&65536)&&(x.flags|=256),t0(x,o,l,s,e),Rp(Os(a,l));break e}}s=a=Os(a,l),Fe!==4&&(Fe=2),zo===null?zo=[s]:zo.push(s),s=o;do{switch(s.tag){case 3:s.flags|=65536,e&=-e,s.lanes|=e;var m=Iw(s,a,e);Kg(s,m);break e;case 1:l=a;var v=s.type,w=s.stateNode;if(!(s.flags&128)&&(typeof v.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Pi===null||!Pi.has(w)))){s.flags|=65536,e&=-e,s.lanes|=e;var k=Pw(s,l,e);Kg(s,k);break e}}s=s.return}while(s!==null)}Jw(n)}catch(S){e=S,Be===n&&n!==null&&(Be=n=n.return);continue}break}while(!0)}function Xw(){var t=Mu.current;return Mu.current=Au,t===null?Au:t}function em(){(Fe===0||Fe===3||Fe===2)&&(Fe=4),qe===null||!(br&268435455)&&!(Cc&268435455)||xi(qe,Je)}function Iu(t,e){var n=ue;ue|=2;var i=Xw();(qe!==t||Je!==e)&&(qn=null,mr(t,e));do try{i_();break}catch(r){Yw(t,r)}while(!0);if(Lp(),ue=n,Mu.current=i,Be!==null)throw Error(U(261));return qe=null,Je=0,Fe}function i_(){for(;Be!==null;)Gw(Be)}function r_(){for(;Be!==null&&!M2();)Gw(Be)}function Gw(t){var e=ex(t.alternate,t,It);t.memoizedProps=t.pendingProps,e===null?Jw(t):Be=e,Yp.current=null}function Jw(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=GE(n,e),n!==null){n.flags&=32767,Be=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Fe=6,Be=null;return}}else if(n=XE(n,e,It),n!==null){Be=n;return}if(e=e.sibling,e!==null){Be=e;return}Be=e=t}while(e!==null);Fe===0&&(Fe=5)}function rr(t,e,n){var i=de,r=Xt.transition;try{Xt.transition=null,de=1,s_(t,e,n,i)}finally{Xt.transition=r,de=i}return null}function s_(t,e,n,i){do ps();while(Ei!==null);if(ue&6)throw Error(U(327));n=t.finishedWork;var r=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(U(177));t.callbackNode=null,t.callbackPriority=0;var s=n.lanes|n.childLanes;if($2(t,s),t===qe&&(Be=qe=null,Je=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ua||(ua=!0,tx(du,function(){return ps(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=Xt.transition,Xt.transition=null;var o=de;de=1;var l=ue;ue|=4,Yp.current=null,ZE(t,n),qw(n,t),EE(Pf),mu=!!If,Pf=If=null,t.current=n,e_(n),T2(),ue=l,de=o,Xt.transition=s}else t.current=n;if(ua&&(ua=!1,Ei=t,Ou=r),s=t.pendingLanes,s===0&&(Pi=null),P2(n.stateNode),At(t,De()),e!==null)for(i=t.onRecoverableError,n=0;n<e.length;n++)r=e[n],i(r.value,{componentStack:r.stack,digest:r.digest});if(Tu)throw Tu=!1,t=Zf,Zf=null,t;return Ou&1&&t.tag!==0&&ps(),s=t.pendingLanes,s&1?t===ed?Fo++:(Fo=0,ed=t):Fo=0,Ki(),null}function ps(){if(Ei!==null){var t=I1(Ou),e=Xt.transition,n=de;try{if(Xt.transition=null,de=16>t?16:t,Ei===null)var i=!1;else{if(t=Ei,Ei=null,Ou=0,ue&6)throw Error(U(331));var r=ue;for(ue|=4,Y=t.current;Y!==null;){var s=Y,o=s.child;if(Y.flags&16){var l=s.deletions;if(l!==null){for(var a=0;a<l.length;a++){var u=l[a];for(Y=u;Y!==null;){var c=Y;switch(c.tag){case 0:case 11:case 15:$o(8,c,s)}var h=c.child;if(h!==null)h.return=c,Y=h;else for(;Y!==null;){c=Y;var f=c.sibling,d=c.return;if(Hw(c),c===u){Y=null;break}if(f!==null){f.return=d,Y=f;break}Y=d}}}var p=s.alternate;if(p!==null){var g=p.child;if(g!==null){p.child=null;do{var x=g.sibling;g.sibling=null,g=x}while(g!==null)}}Y=s}}if(s.subtreeFlags&2064&&o!==null)o.return=s,Y=o;else e:for(;Y!==null;){if(s=Y,s.flags&2048)switch(s.tag){case 0:case 11:case 15:$o(9,s,s.return)}var m=s.sibling;if(m!==null){m.return=s.return,Y=m;break e}Y=s.return}}var v=t.current;for(Y=v;Y!==null;){o=Y;var w=o.child;if(o.subtreeFlags&2064&&w!==null)w.return=o,Y=w;else e:for(o=v;Y!==null;){if(l=Y,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:bc(9,l)}}catch(S){Ae(l,l.return,S)}if(l===o){Y=null;break e}var k=l.sibling;if(k!==null){k.return=l.return,Y=k;break e}Y=l.return}}if(ue=r,Ki(),Ln&&typeof Ln.onPostCommitFiberRoot=="function")try{Ln.onPostCommitFiberRoot(mc,t)}catch{}i=!0}return i}finally{de=n,Xt.transition=e}}return!1}function p0(t,e,n){e=Os(n,e),e=Iw(t,e,1),t=Ii(t,e,1),e=dt(),t!==null&&(Pl(t,1,e),At(t,e))}function Ae(t,e,n){if(t.tag===3)p0(t,t,n);else for(;e!==null;){if(e.tag===3){p0(e,t,n);break}else if(e.tag===1){var i=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Pi===null||!Pi.has(i))){t=Os(n,t),t=Pw(e,t,1),e=Ii(e,t,1),t=dt(),e!==null&&(Pl(e,1,t),At(e,t));break}}e=e.return}}function o_(t,e,n){var i=t.pingCache;i!==null&&i.delete(e),e=dt(),t.pingedLanes|=t.suspendedLanes&n,qe===t&&(Je&n)===n&&(Fe===4||Fe===3&&(Je&130023424)===Je&&500>De()-Gp?mr(t,0):Xp|=n),At(t,e)}function Zw(t,e){e===0&&(t.mode&1?(e=Zl,Zl<<=1,!(Zl&130023424)&&(Zl=4194304)):e=1);var n=dt();t=ri(t,e),t!==null&&(Pl(t,e,n),At(t,n))}function l_(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),Zw(t,n)}function a_(t,e){var n=0;switch(t.tag){case 13:var i=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:i=t.stateNode;break;default:throw Error(U(314))}i!==null&&i.delete(e),Zw(t,n)}var ex;ex=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||_t.current)bt=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return bt=!1,YE(t,e,n);bt=!!(t.flags&131072)}else bt=!1,be&&e.flags&1048576&&rw(e,Su,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Ya(t,e),t=e.pendingProps;var r=Ns(e,lt.current);ds(e,n),r=Wp(null,e,i,t,r,n);var s=Up();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Nt(i)?(s=!0,xu(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,$p(e),r.updater=Sc,e.stateNode=r,r._reactInternals=e,Vf(e,i,t,n),e=Uf(null,e,i,!0,s,n)):(e.tag=0,be&&s&&Ip(e),ht(null,e,r,n),e=e.child),e;case 16:i=e.elementType;e:{switch(Ya(t,e),t=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=c_(i),t=on(i,t),r){case 0:e=Wf(null,e,i,t,n);break e;case 1:e=r0(null,e,i,t,n);break e;case 11:e=n0(null,e,i,t,n);break e;case 14:e=i0(null,e,i,on(i.type,t),n);break e}throw Error(U(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:on(i,r),Wf(t,e,i,r,n);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:on(i,r),r0(t,e,i,r,n);case 3:e:{if(Bw(e),t===null)throw Error(U(387));i=e.pendingProps,s=e.memoizedState,r=s.element,cw(t,e),Eu(e,i,null,n);var o=e.memoizedState;if(i=o.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=Os(Error(U(423)),e),e=s0(t,e,i,n,r);break e}else if(i!==r){r=Os(Error(U(424)),e),e=s0(t,e,i,n,r);break e}else for(Dt=Oi(e.stateNode.containerInfo.firstChild),Bt=e,be=!0,an=null,n=aw(e,null,i,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(As(),i===r){e=si(t,e,n);break e}ht(t,e,i,n)}e=e.child}return e;case 5:return hw(e),t===null&&$f(e),i=e.type,r=e.pendingProps,s=t!==null?t.memoizedProps:null,o=r.children,Rf(i,r)?o=null:s!==null&&Rf(i,s)&&(e.flags|=32),Lw(t,e),ht(t,e,o,n),e.child;case 6:return t===null&&$f(e),null;case 13:return jw(t,e,n);case 4:return zp(e,e.stateNode.containerInfo),i=e.pendingProps,t===null?e.child=Ms(e,null,i,n):ht(t,e,i,n),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:on(i,r),n0(t,e,i,r,n);case 7:return ht(t,e,e.pendingProps,n),e.child;case 8:return ht(t,e,e.pendingProps.children,n),e.child;case 12:return ht(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,o=r.value,ye(bu,i._currentValue),i._currentValue=o,s!==null)if(yn(s.value,o)){if(s.children===r.children&&!_t.current){e=si(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===i){if(s.tag===1){a=ei(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),zf(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(U(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),zf(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ht(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,ds(e,n),r=Zt(r),i=i(r),e.flags|=1,ht(t,e,i,n),e.child;case 14:return i=e.type,r=on(i,e.pendingProps),r=on(i.type,r),i0(t,e,i,r,n);case 15:return Rw(t,e,e.type,e.pendingProps,n);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:on(i,r),Ya(t,e),e.tag=1,Nt(i)?(t=!0,xu(e)):t=!1,ds(e,n),Ow(e,i,r),Vf(e,i,r,n),Uf(null,e,i,!0,t,n);case 19:return $w(t,e,n);case 22:return Dw(t,e,n)}throw Error(U(156,e.tag))};function tx(t,e){return A1(t,e)}function u_(t,e,n,i){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ut(t,e,n,i){return new u_(t,e,n,i)}function tm(t){return t=t.prototype,!(!t||!t.isReactComponent)}function c_(t){if(typeof t=="function")return tm(t)?1:0;if(t!=null){if(t=t.$$typeof,t===xp)return 11;if(t===kp)return 14}return 2}function Di(t,e){var n=t.alternate;return n===null?(n=Ut(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Ja(t,e,n,i,r,s){var o=2;if(i=t,typeof t=="function")tm(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Kr:return gr(n.children,r,s,e);case wp:o=8,r|=8;break;case ff:return t=Ut(12,n,e,r|2),t.elementType=ff,t.lanes=s,t;case df:return t=Ut(13,n,e,r),t.elementType=df,t.lanes=s,t;case pf:return t=Ut(19,n,e,r),t.elementType=pf,t.lanes=s,t;case h1:return Ec(n,r,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case u1:o=10;break e;case c1:o=9;break e;case xp:o=11;break e;case kp:o=14;break e;case di:o=16,i=null;break e}throw Error(U(130,t==null?t:typeof t,""))}return e=Ut(o,n,e,r),e.elementType=t,e.type=i,e.lanes=s,e}function gr(t,e,n,i){return t=Ut(7,t,i,e),t.lanes=n,t}function Ec(t,e,n,i){return t=Ut(22,t,i,e),t.elementType=h1,t.lanes=n,t.stateNode={isHidden:!1},t}function Ch(t,e,n){return t=Ut(6,t,null,e),t.lanes=n,t}function Eh(t,e,n){return e=Ut(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function h_(t,e,n,i,r){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sh(0),this.expirationTimes=sh(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sh(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function nm(t,e,n,i,r,s,o,l,a){return t=new h_(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Ut(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:i,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},$p(s),t}function f_(t,e,n){var i=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:qr,key:i==null?null:""+i,children:t,containerInfo:e,implementation:n}}function nx(t){if(!t)return $i;t=t._reactInternals;e:{if(Ir(t)!==t||t.tag!==1)throw Error(U(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(Nt(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(U(171))}if(t.tag===1){var n=t.type;if(Nt(n))return nw(t,n,e)}return e}function ix(t,e,n,i,r,s,o,l,a){return t=nm(n,i,!0,t,r,s,o,l,a),t.context=nx(null),n=t.current,i=dt(),r=Ri(n),s=ei(i,r),s.callback=e??null,Ii(n,s,r),t.current.lanes=r,Pl(t,r,i),At(t,i),t}function _c(t,e,n,i){var r=e.current,s=dt(),o=Ri(r);return n=nx(n),e.context===null?e.context=n:e.pendingContext=n,e=ei(s,o),e.payload={element:t},i=i===void 0?null:i,i!==null&&(e.callback=i),t=Ii(r,e,o),t!==null&&(mn(t,r,o,s),qa(t,r,o)),o}function Pu(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function m0(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function im(t,e){m0(t,e),(t=t.alternate)&&m0(t,e)}function d_(){return null}var rx=typeof reportError=="function"?reportError:function(t){console.error(t)};function rm(t){this._internalRoot=t}Nc.prototype.render=rm.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(U(409));_c(t,e,null,null)};Nc.prototype.unmount=rm.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;Cr(function(){_c(null,t,null,null)}),e[ii]=null}};function Nc(t){this._internalRoot=t}Nc.prototype.unstable_scheduleHydration=function(t){if(t){var e=D1();t={blockedOn:null,target:t,priority:e};for(var n=0;n<wi.length&&e!==0&&e<wi[n].priority;n++);wi.splice(n,0,t),n===0&&B1(t)}};function sm(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Ac(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function g0(){}function p_(t,e,n,i,r){if(r){if(typeof i=="function"){var s=i;i=function(){var u=Pu(o);s.call(u)}}var o=ix(e,i,t,0,null,!1,!1,"",g0);return t._reactRootContainer=o,t[ii]=o.current,nl(t.nodeType===8?t.parentNode:t),Cr(),o}for(;r=t.lastChild;)t.removeChild(r);if(typeof i=="function"){var l=i;i=function(){var u=Pu(a);l.call(u)}}var a=nm(t,0,!1,null,null,!1,!1,"",g0);return t._reactRootContainer=a,t[ii]=a.current,nl(t.nodeType===8?t.parentNode:t),Cr(function(){_c(e,a,n,i)}),a}function Mc(t,e,n,i,r){var s=n._reactRootContainer;if(s){var o=s;if(typeof r=="function"){var l=r;r=function(){var a=Pu(o);l.call(a)}}_c(e,o,t,r)}else o=p_(n,e,t,r,i);return Pu(o)}P1=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=bo(e.pendingLanes);n!==0&&(Cp(e,n|1),At(e,De()),!(ue&6)&&(Is=De()+500,Ki()))}break;case 13:Cr(function(){var i=ri(t,1);if(i!==null){var r=dt();mn(i,t,1,r)}}),im(t,1)}};Ep=function(t){if(t.tag===13){var e=ri(t,134217728);if(e!==null){var n=dt();mn(e,t,134217728,n)}im(t,134217728)}};R1=function(t){if(t.tag===13){var e=Ri(t),n=ri(t,e);if(n!==null){var i=dt();mn(n,t,e,i)}im(t,e)}};D1=function(){return de};L1=function(t,e){var n=de;try{return de=t,e()}finally{de=n}};Cf=function(t,e,n){switch(e){case"input":if(yf(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var i=n[e];if(i!==t&&i.form===t.form){var r=wc(i);if(!r)throw Error(U(90));d1(i),yf(i,r)}}}break;case"textarea":m1(t,n);break;case"select":e=n.value,e!=null&&us(t,!!n.multiple,e,!1)}};S1=Jp;b1=Cr;var m_={usingClientEntryPoint:!1,Events:[Dl,Gr,wc,x1,k1,Jp]},uo={findFiberByHostInstance:ur,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},g_={bundleType:uo.bundleType,version:uo.version,rendererPackageName:uo.rendererPackageName,rendererConfig:uo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ui.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=_1(t),t===null?null:t.stateNode},findFiberByHostInstance:uo.findFiberByHostInstance||d_,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ca=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ca.isDisabled&&ca.supportsFiber)try{mc=ca.inject(g_),Ln=ca}catch{}}zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=m_;zt.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sm(e))throw Error(U(200));return f_(t,e,null,n)};zt.createRoot=function(t,e){if(!sm(t))throw Error(U(299));var n=!1,i="",r=rx;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(i=e.identifierPrefix),e.onRecoverableError!==void 0&&(r=e.onRecoverableError)),e=nm(t,1,!1,null,null,n,!1,i,r),t[ii]=e.current,nl(t.nodeType===8?t.parentNode:t),new rm(e)};zt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(U(188)):(t=Object.keys(t).join(","),Error(U(268,t)));return t=_1(e),t=t===null?null:t.stateNode,t};zt.flushSync=function(t){return Cr(t)};zt.hydrate=function(t,e,n){if(!Ac(e))throw Error(U(200));return Mc(null,t,e,!0,n)};zt.hydrateRoot=function(t,e,n){if(!sm(t))throw Error(U(405));var i=n!=null&&n.hydratedSources||null,r=!1,s="",o=rx;if(n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),e=ix(e,null,t,1,n??null,r,!1,s,o),t[ii]=e.current,nl(t),i)for(t=0;t<i.length;t++)n=i[t],r=n._getVersion,r=r(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,r]:e.mutableSourceEagerHydrationData.push(n,r);return new Nc(e)};zt.render=function(t,e,n){if(!Ac(e))throw Error(U(200));return Mc(null,t,e,!1,n)};zt.unmountComponentAtNode=function(t){if(!Ac(t))throw Error(U(40));return t._reactRootContainer?(Cr(function(){Mc(null,null,t,!1,function(){t._reactRootContainer=null,t[ii]=null})}),!0):!1};zt.unstable_batchedUpdates=Jp;zt.unstable_renderSubtreeIntoContainer=function(t,e,n,i){if(!Ac(n))throw Error(U(200));if(t==null||t._reactInternals===void 0)throw Error(U(38));return Mc(t,e,n,!1,i)};zt.version="18.3.1-next-f1338f8080-20240426";function sx(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sx)}catch(t){console.error(t)}}sx(),s1.exports=zt;var ox=s1.exports,y0=ox;cf.createRoot=y0.createRoot,cf.hydrateRoot=y0.hydrateRoot;const y_={},v0=t=>{let e;const n=new Set,i=(c,h)=>{const f=typeof c=="function"?c(e):c;if(!Object.is(f,e)){const d=e;e=h??(typeof f!="object"||f===null)?f:Object.assign({},e,f),n.forEach(p=>p(e,d))}},r=()=>e,a={setState:i,getState:r,getInitialState:()=>u,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{(y_?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=e=t(i,r,a);return a},lx=t=>t?v0(t):v0;var ax={exports:{}},ux={},cx={exports:{}},hx={};/**
41
+ * @license React
42
+ * use-sync-external-store-shim.production.js
43
+ *
44
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */var Ps=M;function v_(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var w_=typeof Object.is=="function"?Object.is:v_,x_=Ps.useState,k_=Ps.useEffect,S_=Ps.useLayoutEffect,b_=Ps.useDebugValue;function C_(t,e){var n=e(),i=x_({inst:{value:n,getSnapshot:e}}),r=i[0].inst,s=i[1];return S_(function(){r.value=n,r.getSnapshot=e,_h(r)&&s({inst:r})},[t,n,e]),k_(function(){return _h(r)&&s({inst:r}),t(function(){_h(r)&&s({inst:r})})},[t]),b_(n),n}function _h(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!w_(t,n)}catch{return!0}}function E_(t,e){return e()}var __=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?E_:C_;hx.useSyncExternalStore=Ps.useSyncExternalStore!==void 0?Ps.useSyncExternalStore:__;cx.exports=hx;var N_=cx.exports;/**
49
+ * @license React
50
+ * use-sync-external-store-shim/with-selector.production.js
51
+ *
52
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
53
+ *
54
+ * This source code is licensed under the MIT license found in the
55
+ * LICENSE file in the root directory of this source tree.
56
+ */var Tc=M,A_=N_;function M_(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var T_=typeof Object.is=="function"?Object.is:M_,O_=A_.useSyncExternalStore,I_=Tc.useRef,P_=Tc.useEffect,R_=Tc.useMemo,D_=Tc.useDebugValue;ux.useSyncExternalStoreWithSelector=function(t,e,n,i,r){var s=I_(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=R_(function(){function a(d){if(!u){if(u=!0,c=d,d=i(d),r!==void 0&&o.hasValue){var p=o.value;if(r(p,d))return h=p}return h=d}if(p=h,T_(c,d))return p;var g=i(d);return r!==void 0&&r(p,g)?(c=d,p):(c=d,h=g)}var u=!1,c,h,f=n===void 0?null:n;return[function(){return a(e())},f===null?void 0:function(){return a(f())}]},[e,n,i,r]);var l=O_(t,s[0],s[1]);return P_(function(){o.hasValue=!0,o.value=l},[l]),D_(l),l};ax.exports=ux;var L_=ax.exports;const fx=Kv(L_),dx={},{useDebugValue:B_}=V,{useSyncExternalStoreWithSelector:j_}=fx;let w0=!1;const $_=t=>t;function z_(t,e=$_,n){(dx?"production":void 0)!=="production"&&n&&!w0&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),w0=!0);const i=j_(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return B_(i),i}const x0=t=>{(dx?"production":void 0)!=="production"&&typeof t!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof t=="function"?lx(t):t,n=(i,r)=>z_(e,i,r);return Object.assign(n,e),n},F_=t=>t?x0(t):x0,V_="api";async function H_(){const t=await fetch(`${V_}/spec`);if(!t.ok)throw new Error(`Failed to load spec: ${t.status}`);return t.json()}const W_=["get","post","put","patch","delete"];function U_(t){var i;const e=[],n=t.paths??{};for(const[r,s]of Object.entries(n)){const o=s.parameters??[];for(const l of W_){const a=s[l];if(!a)continue;const u=[...o,...a.parameters??[]].map(p=>({name:p.name,in:p.in,required:!!p.required,schema:ms(t,p.schema)??{}})),{schema:c,contentType:h}=q_((i=a.requestBody)==null?void 0:i.content),f=ms(t,c),d=ms(t,K_(a.responses));e.push({id:`${l.toUpperCase()} ${r}`,method:l,path:r,summary:a.summary,operationId:a.operationId,tags:Array.isArray(a.tags)?a.tags:void 0,parameters:u,requestBodySchema:f,requestBodyContentType:h,responseSchema:d})}}return e}function q_(t){var e,n;return t?(e=t["application/json"])!=null&&e.schema?{schema:t["application/json"].schema,contentType:"application/json"}:(n=t["multipart/form-data"])!=null&&n.schema?{schema:t["multipart/form-data"].schema,contentType:"multipart/form-data"}:{schema:null,contentType:null}:{schema:null,contentType:null}}function K_(t){var n,i,r;if(!t)return null;const e=Object.keys(t).find(s=>/^2\d\d$/.test(s));return e?((r=(i=(n=t[e])==null?void 0:n.content)==null?void 0:i["application/json"])==null?void 0:r.schema)??null:null}function ms(t,e,n=new Set){if(!e||typeof e!="object")return e??null;if(typeof e.$ref=="string"){if(n.has(e.$ref))return{};const i=Q_(t,e.$ref);return i?ms(t,i,new Set(n).add(e.$ref)):e}if(e.type==="array"&&e.items)return{...e,items:ms(t,e.items,n)};if(e.properties){const i={};for(const[r,s]of Object.entries(e.properties))i[r]=ms(t,s,n);return{...e,properties:i}}return e}function Q_(t,e){if(e.startsWith("#/"))return e.slice(2).split("/").reduce((n,i)=>n==null?void 0:n[i],t)}function px(t){return btoa(unescape(encodeURIComponent(t)))}const k0=new Map,Nh=new Map,Y_=3e4,X_=300;async function G_(t,e,n){const i={"Content-Type":"application/x-www-form-urlencoded"};n&&(i.Authorization=`Basic ${px(`${n.clientId}:${n.clientSecret}`)}`);const r=await fetch(t,{method:"POST",headers:i,body:new URLSearchParams(e).toString()});if(!r.ok)throw new Error(`OAuth2 token request to ${t} failed with status ${r.status}`);const s=await r.json().catch(()=>null);if(!(s!=null&&s.access_token))throw new Error(`OAuth2 token response from ${t} had no access_token`);const o=typeof s.expires_in=="number"?s.expires_in:X_;return{accessToken:s.access_token,expiresInSeconds:o}}async function S0(t,e,n,i){const r=k0.get(t);if(r&&r.expiresAt>Date.now()+Y_)return r.accessToken;const s=Nh.get(t);if(s)return s;const o=(async()=>{const{accessToken:l,expiresInSeconds:a}=await G_(e,n,i);return k0.set(t,{accessToken:l,expiresAt:Date.now()+a*1e3}),l})();return Nh.set(t,o),o.finally(()=>Nh.delete(t)).catch(()=>{}),o}async function mx(t){switch(t.type){case"bearer":return{headers:{Authorization:`Bearer ${t.token}`}};case"basic":return{headers:{Authorization:`Basic ${px(`${t.username}:${t.password}`)}`}};case"apiKey":return t.in==="query"?{query:{[t.paramName]:t.key}}:{headers:{[t.paramName]:t.key}};case"oauth2_clientCredentials":{const e={grant_type:"client_credentials"};t.scope&&(e.scope=t.scope);const n=t.clientAuthMethod==="basic"?{clientId:t.clientId,clientSecret:t.clientSecret}:void 0;return t.clientAuthMethod==="body"&&(e.client_id=t.clientId,e.client_secret=t.clientSecret),{headers:{Authorization:`Bearer ${await S0(t.id,t.tokenUrl,e,n)}`}}}case"oauth2_password":{const e={grant_type:"password",username:t.username,password:t.password};t.scope&&(e.scope=t.scope);const n=!!(t.clientId&&t.clientSecret),i=n&&t.clientAuthMethod==="basic"?{clientId:t.clientId,clientSecret:t.clientSecret}:void 0;return n&&t.clientAuthMethod==="body"&&(e.client_id=t.clientId,e.client_secret=t.clientSecret),{headers:{Authorization:`Bearer ${await S0(t.id,t.tokenUrl,e,i)}`}}}case"cookie":return{credentials:"include"}}}function Bl(){return/\{\{enlace:([a-zA-Z0-9_-]+)\}\}/g}function gx(t){return`{{enlace:${t}}}`}function J_(t,e,n){return t[e-1]==='"'&&t[n]==='"'}function yx(t,e){if(!e)return t;const n=e.trim().replace(/^\$\.?/,"");return lm(t,n)}function vx(t,e){const n=e.toLowerCase();for(const[i,r]of Object.entries(t))if(i.toLowerCase()===n)return r}function id(t,e,n){const i=(n==null?void 0:n.get(t.sourceNodeId))??"an upstream step",r=e.get(t.sourceNodeId);if(!r||!r.response)throw new Error(`Can't map from "${i}" — that step has no captured response yet.`);switch(t.type){case"response_body":return yx(r.response.body,t.jsonPath);case"response_raw":return r.response.body;case"response_header":{const s=t.headerName??"",o=vx(r.response.headers,s);if(o===void 0)throw new Error(`Can't map header "${s}" from "${i}" — that response has no such header.`);return o}}}function Z_(t){return t.includes("{{enlace:")}function eN(t,e,n,i){if(!Z_(t))return t;const r=[...t.matchAll(Bl())],s=a=>{const u=e[a];if(!u)throw new Error(`Body references unknown tag "${a}".`);return u};if(r.length===1&&r[0][0]===t)return id(s(r[0][1]),n,i);let o="",l=0;for(const a of r){const u=a.index??0,c=id(s(a[1]),n,i);o+=t.slice(l,u)+String(c),l=u+a[0].length}return o+t.slice(l)}function rd(t,e,n,i){return typeof t=="string"?eN(t,e,n,i):Array.isArray(t)?t.map(r=>rd(r,e,n,i)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([r,s])=>[r,rd(s,e,n,i)])):t}function tN(t){return JSON.stringify(String(t)).slice(1,-1)}function Ah(t,e,n){const i=t.template;let r="",s=0;for(const o of i.matchAll(Bl())){const l=o.index??0,a=l+o[0].length,u=o[1],c=t.tags[u];if(!c)throw new Error(`Body references unknown tag "${u}".`);const h=id(c,e,n),f=J_(i,l,a),d=f?l-1:l,p=f?a+1:a,g=f?JSON.stringify(h):tN(h);r+=i.slice(s,d)+g,s=p}return r+=i.slice(s),JSON.parse(r)}function om(t,e){const n=new Map(t.map(r=>[r.id,r])),i=new Map;for(const r of t)i.set(r.id,new Set);for(const{fromNodeId:r,toNodeId:s}of e)n.has(r)&&i.has(s)&&i.get(s).add(r);for(const r of t)for(const s of Object.values(r.fieldValues))s.source==="mapped"&&n.has(s.fromNodeId)&&i.get(r.id).add(s.fromNodeId);return i}function nN(t,e,n){const i=om(t,e),r=new Set,s=[...i.get(n)??[]];for(;s.length>0;){const o=s.shift();r.has(o)||(r.add(o),s.push(...i.get(o)??[]))}return r}function iN(t,e){const n=e.get(t.operationId);return(n==null?void 0:n.operationId)??(n==null?void 0:n.id)??t.operationId}function Oc(t,e){const n=t.map(o=>iN(o,e)),i=new Map;for(const o of n)i.set(o,(i.get(o)??0)+1);const r=new Map,s=new Map;return t.forEach((o,l)=>{const a=n[l];if((i.get(a)??0)<2){s.set(o.id,a);return}const u=(r.get(a)??0)+1;r.set(a,u),s.set(o.id,`${a} #${u}`)}),s}function Ru(t,e){return`${t}->${e}`}class wx extends Error{constructor(e){super(`Workflow has a cyclic dependency involving nodes: ${e.join(", ")}`),this.nodeIds=e,this.name="CyclicWorkflowError"}}function xx(t,e=[]){const n=om(t,e),i=new Set(t.map(s=>s.id)),r=[];for(;i.size>0;){const s=t.filter(o=>i.has(o.id)&&[...n.get(o.id)].every(l=>!i.has(l)));if(s.length===0)throw new wx([...i]);r.push(s);for(const o of s)i.delete(o.id)}return r}function rN(t,e=[]){return xx(t,e).flat()}function lm(t,e){if(!e)return;const n=e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let i=t;for(const r of n){if(i==null)return;i=i[r]}return i}function hl(t,e,n){const i=e.split(".").filter(Boolean);let r=t;i.forEach((s,o)=>{o===i.length-1?r[s]=n:(r[s]=r[s]??{},r=r[s])})}function sN(t,e,n,i,r){var o;if(t.source==="static")return t.value;if(t.source==="file"){const l=r[`${n}::${e}`];if(!l)throw new Error(`Re-select the file for "${e}"${t.fileName?` (${t.fileName})`:""} — file contents are not persisted.`);return l}const s=i.get(t.fromNodeId);return lm((o=s==null?void 0:s.response)==null?void 0:o.body,t.fromResponseFieldPath)}async function kx(t,e,n,i,r,s,o={}){var k,S,_;let l=e.path;const a=new URLSearchParams,u=e.requestBodyContentType==="multipart/form-data",c=u?{}:{"Content-Type":"application/json"},h={},f=u?"form":t.requestMode??"form",d={...(k=t.rawPath)==null?void 0:k.tags,...(S=t.rawQuery)==null?void 0:S.tags,...(_=t.rawBody)==null?void 0:_.tags};for(const[E,A]of Object.entries(t.fieldValues)){const[I,...R]=E.split(".");if(f==="raw"&&(I==="path"||I==="query"||I==="body"))continue;let O=sN(A,E,t.id,n,o);A.source!=="file"&&Object.keys(d).length>0&&(O=rd(O,d,n,s));const D=R.join(".");I==="path"?l=l.replace(`{${D}}`,encodeURIComponent(String(O??""))):I==="query"?O!==void 0&&a.set(D,String(O)):I==="header"?O!==void 0&&(c[D]=String(O)):I==="body"&&hl(h,D,O)}if(f==="raw"){if(t.rawPath){const E=Ah(t.rawPath,n,s);if(E&&typeof E=="object"&&!Array.isArray(E))for(const[A,I]of Object.entries(E))I!=null&&(l=l.replace(`{${A}}`,encodeURIComponent(String(I))))}if(t.rawQuery){const E=Ah(t.rawQuery,n,s);if(E&&typeof E=="object"&&!Array.isArray(E))for(const[A,I]of Object.entries(E))I!=null&&a.set(A,typeof I=="string"?I:String(I))}}const p=[];let g="omit";if(t.credentialId){const E=i.get(t.credentialId);if(E){const A=await mx(E);Object.assign(c,A.headers);for(const[I,R]of Object.entries(A.query??{}))a.set(I,R),p.push(I);A.credentials&&(g=A.credentials)}}const x=a.toString(),m=`${r}${l}${x?`?${x}`:""}`;let v;u?v=Object.keys(h).length>0?Sx(h):void 0:f==="raw"&&t.rawBody?v=Ah(t.rawBody,n,s):v=Object.keys(h).length>0?h:void 0;const w=!!e.requestBodySchema&&v!==void 0;return{method:e.method.toUpperCase(),url:m,headers:c,body:w?v:void 0,redactQueryParams:p.length>0?p:void 0,credentials:g}}function Sx(t,e=new FormData,n=""){for(const[i,r]of Object.entries(t)){const s=n?`${n}.${i}`:i;r instanceof File?e.append(s,r,r.name):r!==null&&typeof r=="object"&&!Array.isArray(r)?Sx(r,e,s):r!=null&&e.append(s,typeof r=="string"?r:String(r))}return e}async function oN(t,e,n,i,r,s,o){const l=new Date().toISOString();let a;try{a=await kx(t,e,n,i,r,s,o)}catch(c){return{nodeId:t.id,request:{method:e.method.toUpperCase(),url:`${r}${e.path}`,headers:{},credentials:"omit"},timestampStart:l,timestampEnd:new Date().toISOString(),error:c instanceof Error?c.message:String(c)}}const u={nodeId:t.id,request:a,timestampStart:l,timestampEnd:""};try{const c=a.body===void 0?void 0:a.body instanceof FormData?a.body:JSON.stringify(a.body),h=await fetch(a.url,{method:a.method,headers:a.headers,body:c,credentials:a.credentials}),f={};h.headers.forEach((g,x)=>f[x]=g);const p=(h.headers.get("content-type")??"").includes("application/json")?await h.json().catch(()=>null):await h.text();u.response={status:h.status,headers:f,body:p},u.timestampEnd=new Date().toISOString(),h.status>=400&&(u.error=`Request failed with status ${h.status}`)}catch(c){u.timestampEnd=new Date().toISOString(),u.error=c instanceof Error?c.message:String(c)}return u}async function lN(t,e,n,i){const{nodes:r,connections:s}=t;xx(r,s);const o=om(r,s),l=new Map(r.map(O=>[O.id,"pending"])),a=new Map,u=[],c=Oc(r,e),h=i.armedBreakpoints??new Set,f=i.uploadedFiles??{},d=new Set,p=(O,D,$,b)=>{var C;return(C=i.onEvent)==null?void 0:C.call(i,{nodeId:O,status:D,step:$,request:b})},g=O=>[...o.get(O)].every(D=>l.get(D)==="completed"),x=O=>!d.has(O)&&s.some(D=>D.toNodeId===O&&h.has(Ru(D.fromNodeId,D.toNodeId)));let m=!1,v=0,w=0,k=null,S=null;const _=()=>{S==null||S(),S=null},E=()=>new Promise(O=>S=O);function A(){for(const O of r){const D=l.get(O.id);(D==="pending"||D==="paused")&&(D==="paused"&&w--,l.set(O.id,"skipped"),p(O.id,"skipped"))}}function I(O,D){l.set(O.id,"in-flight"),v++,p(O.id,"in-flight"),oN(O,D,a,n,i.baseUrl,c,f).then($=>{u.push($),a.set($.nodeId,$);const b=$.error?"failed":"completed";l.set(O.id,b),v--,p(O.id,b,$),$.error&&(m=!0,A()),_()})}function R(){for(const O of r){if(k)return;if(l.get(O.id)!=="pending"||m||!g(O.id))continue;const D=e.get(O.operationId);if(!D){k=new Error(`Unknown operation "${O.operationId}" referenced by ${c.get(O.id)??"a step"}`),_();return}if(x(O.id)){l.set(O.id,"paused"),w++,p(O.id,"paused"),kx(O,D,a,n,i.baseUrl,c,f).then($=>{l.get(O.id)==="paused"&&p(O.id,"paused",void 0,$)}).catch(()=>{});continue}I(O,D)}}for(i.onControl&&i.onControl({continue:()=>{let O=!1;for(const D of r)l.get(D.id)==="paused"&&(d.add(D.id),l.set(D.id,"pending"),w--,O=!0);O&&_()},step:O=>{l.get(O)==="paused"&&(d.add(O),l.set(O,"pending"),w--,_())},stop:()=>{m=!0,A(),_()}}),R();(v>0||w>0)&&(await E(),!k);)R();if(k)throw k;return{steps:u}}function aN(t){var i;const e=((i=t==null?void 0:t.components)==null?void 0:i.securitySchemes)??{},n=[];for(const[r,s]of Object.entries(e)){const o=uN(r,s);o&&n.push({schemeName:r,description:s==null?void 0:s.description,template:o})}return n}function uN(t,e){if(!e||typeof e!="object")return null;if(e.type==="http"&&e.scheme==="bearer")return $r(t,{name:t,type:"bearer",token:""});if(e.type==="http"&&e.scheme==="basic")return $r(t,{name:t,type:"basic",username:"",password:""});if(e.type==="apiKey"&&(e.in==="header"||e.in==="query"))return $r(t,{name:t,type:"apiKey",paramName:e.name??"",in:e.in,key:""});if(e.type==="apiKey"&&e.in==="cookie")return $r(t,{name:t,type:"cookie",loginUrl:""});if(e.type==="oauth2"){const n=e.flows??{};return n.clientCredentials?$r(t,{name:t,type:"oauth2_clientCredentials",tokenUrl:n.clientCredentials.tokenUrl??"",clientId:"",clientSecret:"",scope:b0(n.clientCredentials.scopes),clientAuthMethod:"basic"}):n.password?$r(t,{name:t,type:"oauth2_password",tokenUrl:n.password.tokenUrl??"",username:"",password:"",clientId:"",clientSecret:"",scope:b0(n.password.scopes),clientAuthMethod:"basic"}):null}return null}function $r(t,e){return{...e,fromSecurityScheme:t}}function b0(t){return t?Object.keys(t).join(" "):""}const cN={width:240,height:100},hN=16;function fN(t,e){return{width:t.width+e,height:t.height+e}}function dN(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function C0(t,e,n){const i={...t,...n};return e.some(r=>dN(i,{...r,...n}))}function ha(t,e){const n=t.x-e.x,i=t.y-e.y;return n*n+i*i}function E0(t,e,n={}){const i=fN(n.size??cN,n.gap??hN);if(e.length===0||!C0(t,e,i))return t;const r=[],s=c=>{C0(c,e,i)||r.push(c)};for(const c of e)s({x:c.x+i.width,y:t.y}),s({x:c.x-i.width,y:t.y}),s({x:t.x,y:c.y+i.height}),s({x:t.x,y:c.y-i.height}),s({x:c.x+i.width,y:c.y}),s({x:c.x-i.width,y:c.y}),s({x:c.x,y:c.y+i.height}),s({x:c.x,y:c.y-i.height});if(r.length>0)return r.sort((c,h)=>ha(c,t)-ha(h,t)),r[0];const o=Math.max(24,Math.round(Math.min(i.width,i.height)/4)),l=n.maxSearchDistance??Math.max(i.width,i.height)*4,a=Math.ceil(l/o);for(let c=1;c<=a;c++){const h=c*o;for(let f=-c;f<=c;f++){const d=f*o;s({x:t.x+h,y:t.y+d}),s({x:t.x-h,y:t.y+d}),s({x:t.x+d,y:t.y+h}),s({x:t.x+d,y:t.y-h})}if(r.length>0)return r.sort((f,d)=>ha(f,t)-ha(d,t)),r[0]}return{x:e.reduce((c,h)=>Math.max(c,h.x),t.x)+i.width,y:t.y}}function fl(){return crypto.randomUUID()}const sd="enlace-collection",od=1,Du={bearer:"Bearer token",basic:"Basic auth",apiKey:"API key",oauth2_clientCredentials:"OAuth2 (client credentials)",oauth2_password:"OAuth2 (password) · Legacy",cookie:"Cookie (session)"};function ld(t,e){switch(t){case"bearer":return{name:e,type:t,token:""};case"basic":return{name:e,type:t,username:"",password:""};case"apiKey":return{name:e,type:t,paramName:"",in:"header",key:""};case"oauth2_clientCredentials":return{name:e,type:t,tokenUrl:"",clientId:"",clientSecret:"",scope:"",clientAuthMethod:"basic"};case"oauth2_password":return{name:e,type:t,tokenUrl:"",username:"",password:"",clientId:"",clientSecret:"",scope:"",clientAuthMethod:"basic"};case"cookie":return{name:e,type:t,loginUrl:""}}}function pN(t){return t==="oauth2_clientCredentials"||t==="oauth2_password"}function jl(t){if(!t.name)return!1;switch(t.type){case"bearer":return!!t.token;case"basic":return!!(t.username&&t.password);case"apiKey":return!!(t.paramName&&t.key);case"oauth2_clientCredentials":return!!(t.tokenUrl&&t.clientId&&t.clientSecret);case"oauth2_password":return!!(t.tokenUrl&&t.username&&t.password);case"cookie":return!0}}const _0="••••••••";function bx(t){window.open(t,"_blank")}function dl(t){const{id:e,...n}=t;return n}function mN(t){switch(t.type){case"bearer":return"";case"basic":return t.username;case"apiKey":return`${t.paramName} (${t.in}) · ${_0}`;case"oauth2_clientCredentials":return"";case"oauth2_password":return`${t.username} · ${_0}`;case"cookie":return"No stored secret — relies on your browser already being logged into the target"}}const gN=["token","password","key","clientSecret"],Cx=new Set(["bearer","basic","apiKey","oauth2_clientCredentials","oauth2_password","cookie"]);function yN(t){var s,o,l,a,u;const e=((s=t.name)==null?void 0:s.trim())||((l=(o=t.specInfo)==null?void 0:o.title)==null?void 0:l.trim())||"Untitled",n=t.nodes.map(Ex),r={operationIds:[...new Set(n.map(c=>c.operationId))]};return(a=t.specInfo)!=null&&a.title&&(r.title=t.specInfo.title),(u=t.specInfo)!=null&&u.version&&(r.version=t.specInfo.version),{format:sd,version:od,name:e,exportedAt:(t.now??(()=>new Date().toISOString()))(),secrets:t.includeSecrets?"included":"stripped",credentials:t.credentials.map(c=>t.includeSecrets?_x(c):bN(c)),workflows:[{id:"workflow-1",name:e,specHint:r,nodes:n,connections:t.connections.map(c=>({fromNodeId:c.fromNodeId,toNodeId:c.toNodeId})),nodePositions:Object.fromEntries(Object.entries(t.nodePositions).map(([c,h])=>[c,{x:h.x,y:h.y}]))}]}}function vN(t,e={}){let n=t;if(typeof t=="string"){const m=EN(t);if(!m.ok)return m;n=m.value}if(!st(n))return{ok:!1,error:"Enlace collection must be a JSON object."};if(n.format!==sd)return{ok:!1,error:`Unknown Enlace collection format "${String(n.format)}".`};if(n.version!==od)return{ok:!1,error:`Unsupported Enlace collection version "${String(n.version)}".`};if(n.secrets!=="stripped"&&n.secrets!=="included")return{ok:!1,error:'Enlace collection has an invalid "secrets" mode.'};if(!Array.isArray(n.credentials))return{ok:!1,error:'Enlace collection is missing a "credentials" array.'};if(!Array.isArray(n.workflows)||n.workflows.length!==1)return{ok:!1,error:"This version supports collections with exactly one workflow."};const i=n.workflows[0];if(!st(i))return{ok:!1,error:"Enlace collection has an invalid workflow."};if(!Array.isArray(i.nodes))return{ok:!1,error:'Collection workflow is missing a "nodes" array.'};if(!Array.isArray(i.connections))return{ok:!1,error:'Collection workflow is missing a "connections" array.'};if(!st(i.nodePositions))return{ok:!1,error:'Collection workflow is missing a "nodePositions" object.'};const r=[];for(let m=0;m<i.nodes.length;m++){const v=_N(i.nodes[m],m);if(typeof v=="string")return{ok:!1,error:v};r.push(v)}const s=[];for(let m=0;m<i.connections.length;m++){const v=MN(i.connections[m],m);if(typeof v=="string")return{ok:!1,error:v};s.push(v)}const o={};for(const[m,v]of Object.entries(i.nodePositions)){if(am(m))return{ok:!1,error:`Collection workflow has an invalid node id "${m}".`};if(!st(v)||typeof v.x!="number"||typeof v.y!="number")return{ok:!1,error:`Collection workflow has an invalid position for node "${m}".`};o[m]={x:v.x,y:v.y}}const l=[];let a=!1;for(let m=0;m<n.credentials.length;m++){const v=n.secrets==="included"?ON(n.credentials[m],m):TN(n.credentials[m],m);if(typeof v=="string")return{ok:!1,error:v};"secretsDiscarded"in v&&v.secretsDiscarded&&(a=!0),l.push("credential"in v?v.credential:v.stub)}const u=IN(i.specHint,r),c=typeof n.name=="string"&&n.name.trim()?n.name.trim():typeof i.name=="string"&&i.name.trim()?i.name.trim():"Untitled",h={id:typeof i.id=="string"?i.id:"workflow-1",name:typeof i.name=="string"&&i.name.trim()?i.name.trim():c,specHint:u,nodes:r,connections:s,nodePositions:o},f={format:sd,version:od,name:c,exportedAt:typeof n.exportedAt=="string"?n.exportedAt:"",secrets:n.secrets,credentials:l,workflows:[h]},d=new Set((e.operations??[]).map(m=>m.id)),p=e.operations===void 0?[]:[...new Set(r.map(m=>m.operationId).filter(m=>!d.has(m)))],x=Nx(f).filter(m=>!jl(dl(m))).map(m=>({id:m.id,name:m.name,type:m.type}));return{ok:!0,collection:f,warnings:{unknownOperationIds:p,credentialsNeedingSecrets:x,secretsIncluded:n.secrets==="included",unexpectedSecretsDiscarded:a}}}function wN(t){const e=t.workflows[0];return{nodes:e.nodes.map(Ex),connections:e.connections.map(n=>({fromNodeId:n.fromNodeId,toNodeId:n.toNodeId})),nodePositions:Object.fromEntries(Object.entries(e.nodePositions).map(([n,i])=>[n,{x:i.x,y:i.y}])),credentials:Nx(t)}}function xN(t){if(t.unknownOperationIds.length===0)return null;const e=t.unknownOperationIds.join(", ");return t.unknownOperationIds.length===1?`Operation ${e} isn't in the loaded spec — load the matching spec before running.`:`Operations ${e} aren't in the loaded spec — load the matching spec before running.`}function kN(t){const e=t.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),n=t.secrets==="included"?"-with-secrets":"";return e?`${e}${n}.enlace`:`enlace-collection${n}.enlace`}function SN(t,e){const n=new Map(e.map(s=>[s.id,s])),i=new Set,r=[];for(const s of t){if(!s.credentialId||i.has(s.credentialId))continue;const o=n.get(s.credentialId);o&&!jl(dl(o))&&(i.add(o.id),r.push(o))}return r}function Ex(t){const e={id:t.id,operationId:t.operationId,credentialId:t.credentialId??null,fieldValues:{...t.fieldValues}};return t.requestMode&&(e.requestMode=t.requestMode),t.rawPath&&(e.rawPath=Mh(t.rawPath)),t.rawQuery&&(e.rawQuery=Mh(t.rawQuery)),t.rawBody&&(e.rawBody=Mh(t.rawBody)),e}function bN(t){const e={id:t.id,name:t.name,...t.fromSecurityScheme?{fromSecurityScheme:t.fromSecurityScheme}:{}};switch(t.type){case"bearer":return{...e,type:"bearer"};case"basic":return{...e,type:"basic",...t.username?{username:t.username}:{}};case"apiKey":return{...e,type:"apiKey",paramName:t.paramName,in:t.in};case"oauth2_clientCredentials":return{...e,type:"oauth2_clientCredentials",tokenUrl:t.tokenUrl,...t.clientId?{clientId:t.clientId}:{},...t.scope?{scope:t.scope}:{},clientAuthMethod:t.clientAuthMethod};case"oauth2_password":return{...e,type:"oauth2_password",tokenUrl:t.tokenUrl,...t.username?{username:t.username}:{},...t.clientId?{clientId:t.clientId}:{},...t.scope?{scope:t.scope}:{},clientAuthMethod:t.clientAuthMethod};case"cookie":return{...e,type:"cookie",...t.loginUrl?{loginUrl:t.loginUrl}:{}}}}function _x(t){const e={id:t.id,name:t.name,...t.fromSecurityScheme?{fromSecurityScheme:t.fromSecurityScheme}:{}};switch(t.type){case"bearer":return{...e,type:"bearer",token:t.token};case"basic":return{...e,type:"basic",username:t.username,password:t.password};case"apiKey":return{...e,type:"apiKey",paramName:t.paramName,in:t.in,key:t.key};case"oauth2_clientCredentials":return{...e,type:"oauth2_clientCredentials",tokenUrl:t.tokenUrl,clientId:t.clientId,clientSecret:t.clientSecret,...t.scope?{scope:t.scope}:{},clientAuthMethod:t.clientAuthMethod};case"oauth2_password":return{...e,type:"oauth2_password",tokenUrl:t.tokenUrl,username:t.username,password:t.password,...t.clientId?{clientId:t.clientId}:{},...t.clientSecret?{clientSecret:t.clientSecret}:{},...t.scope?{scope:t.scope}:{},clientAuthMethod:t.clientAuthMethod};case"cookie":return{...e,type:"cookie",...t.loginUrl?{loginUrl:t.loginUrl}:{}}}}function CN(t){const e={id:t.id,name:t.name,...t.fromSecurityScheme?{fromSecurityScheme:t.fromSecurityScheme}:{}};switch(t.type){case"bearer":return{...e,type:"bearer",token:""};case"basic":return{...e,type:"basic",username:t.username??"",password:""};case"apiKey":return{...e,type:"apiKey",paramName:t.paramName,in:t.in,key:""};case"oauth2_clientCredentials":return{...e,type:"oauth2_clientCredentials",tokenUrl:t.tokenUrl,clientId:t.clientId??"",clientSecret:"",...t.scope?{scope:t.scope}:{},clientAuthMethod:t.clientAuthMethod??"basic"};case"oauth2_password":return{...e,type:"oauth2_password",tokenUrl:t.tokenUrl,username:t.username??"",password:"",...t.clientId?{clientId:t.clientId}:{},clientSecret:"",...t.scope?{scope:t.scope}:{},clientAuthMethod:t.clientAuthMethod??"basic"};case"cookie":return{...e,type:"cookie",...t.loginUrl?{loginUrl:t.loginUrl}:{}}}}function Nx(t){return t.secrets==="included"?t.credentials.map(e=>_x(e)):t.credentials.map(e=>CN(e))}function EN(t){try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1,error:"Could not parse Enlace collection as JSON."}}}function _N(t,e){if(!st(t)||typeof t.id!="string"||typeof t.operationId!="string")return`Enlace collection has an invalid node at index ${e}.`;if(t.credentialId!=null&&typeof t.credentialId!="string")return`Enlace collection node "${t.id}" has an invalid credentialId.`;const n=NN(t.fieldValues,t.id);if(typeof n=="string")return n;const i={id:t.id,operationId:t.operationId,credentialId:typeof t.credentialId=="string"?t.credentialId:null,fieldValues:n},r=t.requestMode??t.bodyMode;(r==="form"||r==="raw")&&(i.requestMode=r);for(const s of["rawPath","rawQuery","rawBody"])if(t[s]!=null){const o=AN(t[s],t.id,s);if(typeof o=="string")return o;i[s]=o}return i}function NN(t,e){if(t==null)return{};if(!st(t))return`Enlace collection node "${e}" has invalid fieldValues.`;const n={};for(const[i,r]of Object.entries(t)){if(am(i))return`Enlace collection node "${e}" has an invalid field path "${i}".`;if(!st(r)||r.source!=="static"&&r.source!=="mapped"&&r.source!=="file")return`Enlace collection node "${e}" has an invalid field value at "${i}".`;if(r.source==="static")n[i]={source:"static",value:r.value};else if(r.source==="file"){if(typeof r.fileName!="string")return`Enlace collection node "${e}" has an invalid file field at "${i}".`;n[i]={source:"file",fileName:r.fileName}}else if(typeof r.fromNodeId=="string"&&typeof r.fromResponseFieldPath=="string")n[i]={source:"mapped",fromNodeId:r.fromNodeId,fromResponseFieldPath:r.fromResponseFieldPath};else return`Enlace collection node "${e}" has an invalid mapped field at "${i}".`}return n}function AN(t,e,n="rawBody"){if(!st(t)||typeof t.template!="string"||!st(t.tags))return`Enlace collection node "${e}" has an invalid ${n}.`;const i={};for(const[r,s]of Object.entries(t.tags)){if(am(r))return`Enlace collection node "${e}" has an invalid ${n} tag id "${r}".`;if(!st(s)||typeof s.id!="string"||typeof s.sourceNodeId!="string"||s.type!=="response_body"&&s.type!=="response_raw"&&s.type!=="response_header")return`Enlace collection node "${e}" has an invalid ${n} tag "${r}".`;const o={id:s.id,type:s.type,sourceNodeId:s.sourceNodeId};typeof s.jsonPath=="string"&&(o.jsonPath=s.jsonPath),typeof s.headerName=="string"&&(o.headerName=s.headerName),i[r]=o}return{template:t.template,tags:i}}function MN(t,e){return!st(t)||typeof t.fromNodeId!="string"||typeof t.toNodeId!="string"?`Enlace collection has an invalid connection at index ${e}.`:{fromNodeId:t.fromNodeId,toNodeId:t.toNodeId}}function TN(t,e){if(!st(t)||typeof t.id!="string"||typeof t.name!="string"||typeof t.type!="string")return`Enlace collection has an invalid credential at index ${e}.`;if(!Cx.has(t.type))return`Enlace collection has an unknown credential type "${t.type}" at index ${e}.`;const n=gN.some(s=>Object.prototype.hasOwnProperty.call(t,s)),i={id:t.id,name:t.name,...typeof t.fromSecurityScheme=="string"?{fromSecurityScheme:t.fromSecurityScheme}:{}};switch(t.type){case"bearer":return{stub:{...i,type:"bearer"},secretsDiscarded:n};case"basic":return{stub:{...i,type:"basic",...typeof t.username=="string"?{username:t.username}:{}},secretsDiscarded:n};case"apiKey":return{stub:{...i,type:"apiKey",paramName:typeof t.paramName=="string"?t.paramName:"",in:t.in==="query"?"query":"header"},secretsDiscarded:n};case"oauth2_clientCredentials":return{stub:{...i,type:"oauth2_clientCredentials",tokenUrl:typeof t.tokenUrl=="string"?t.tokenUrl:"",...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.scope=="string"?{scope:t.scope}:{},clientAuthMethod:Lu(t.clientAuthMethod)},secretsDiscarded:n};case"oauth2_password":return{stub:{...i,type:"oauth2_password",tokenUrl:typeof t.tokenUrl=="string"?t.tokenUrl:"",...typeof t.username=="string"?{username:t.username}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.scope=="string"?{scope:t.scope}:{},clientAuthMethod:Lu(t.clientAuthMethod)},secretsDiscarded:n};case"cookie":return{stub:{...i,type:"cookie",...typeof t.loginUrl=="string"&&t.loginUrl?{loginUrl:t.loginUrl}:{}},secretsDiscarded:n}}}function ON(t,e){if(!st(t)||typeof t.id!="string"||typeof t.name!="string"||typeof t.type!="string")return`Enlace collection has an invalid credential at index ${e}.`;if(!Cx.has(t.type))return`Enlace collection has an unknown credential type "${t.type}" at index ${e}.`;const n={id:t.id,name:t.name,...typeof t.fromSecurityScheme=="string"?{fromSecurityScheme:t.fromSecurityScheme}:{}},i=r=>typeof t[r]=="string"?t[r]:"";switch(t.type){case"bearer":return{credential:{...n,type:"bearer",token:i("token")}};case"basic":return{credential:{...n,type:"basic",username:i("username"),password:i("password")}};case"apiKey":return{credential:{...n,type:"apiKey",paramName:i("paramName"),in:t.in==="query"?"query":"header",key:i("key")}};case"oauth2_clientCredentials":return{credential:{...n,type:"oauth2_clientCredentials",tokenUrl:i("tokenUrl"),clientId:i("clientId"),clientSecret:i("clientSecret"),...typeof t.scope=="string"?{scope:t.scope}:{},clientAuthMethod:Lu(t.clientAuthMethod)}};case"oauth2_password":return{credential:{...n,type:"oauth2_password",tokenUrl:i("tokenUrl"),username:i("username"),password:i("password"),...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.clientSecret=="string"?{clientSecret:t.clientSecret}:{},...typeof t.scope=="string"?{scope:t.scope}:{},clientAuthMethod:Lu(t.clientAuthMethod)}};case"cookie":{const r=i("loginUrl");return{credential:{...n,type:"cookie",...r?{loginUrl:r}:{}}}}}}function Lu(t){return t==="body"?"body":"basic"}function IN(t,e){const i={operationIds:st(t)&&Array.isArray(t.operationIds)?t.operationIds.filter(r=>typeof r=="string"):[...new Set(e.map(r=>r.operationId))]};return st(t)&&typeof t.title=="string"&&(i.title=t.title),st(t)&&typeof t.version=="string"&&(i.version=t.version),i}function Mh(t){return{template:t.template,tags:Object.fromEntries(Object.entries(t.tags).map(([e,n])=>[e,{...n}]))}}function am(t){return t==="__proto__"}function st(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function PN(t){return{x:80+t%4*220,y:80+Math.floor(t/4)*140}}function RN(t){var n;const e=t.servers??[];return e.length===0||!((n=e[0])!=null&&n.url)?null:(e.length>1&&console.warn(`enlace: spec declares ${e.length} servers; defaulting to the first (${e[0].url}).`),e[0].url)}function wt(t){return t.isRunning}function Th(t,e){return`${t}::${e}`}const le=F_((t,e)=>({operations:[],baseUrl:null,specInfo:null,workflowName:"Untitled",nodes:[],connections:[],nodePositions:{},credentials:[],uploadedFiles:{},declaredCredentials:[],selectedNodeId:null,runResult:null,stepStatusByNodeId:{},armedBreakpoints:new Set,previewRequestByNodeId:{},activeControl:null,isRunning:!1,isDebugRun:!1,error:null,credentialReview:null,loadOperations:async()=>{try{const n=await H_(),i=U_(n),r=RN(n),s=aN(n),o=n.info??{},l={};typeof o.title=="string"&&(l.title=o.title),typeof o.version=="string"&&(l.version=o.version),t({operations:i,baseUrl:r,specInfo:l,declaredCredentials:s,error:r?null:"Could not determine a target base URL — add a `servers` entry to the OpenAPI spec."})}catch(n){t({error:n instanceof Error?n.message:String(n)})}},addNode:(n,i)=>{if(wt(e()))return"";const r=fl(),s={id:r,operationId:n,credentialId:null,fieldValues:{}};return t(o=>{const l=i??PN(o.nodes.length),a=Object.values(o.nodePositions);return{nodes:[...o.nodes,s],nodePositions:{...o.nodePositions,[r]:E0(l,a)},selectedNodeId:r}}),r},updateNodePosition:(n,i,r)=>t(s=>{const o=(r==null?void 0:r.avoidOverlap)===!0?E0(i,Object.entries(s.nodePositions).filter(([l])=>l!==n).map(([,l])=>l)):i;return{nodePositions:{...s.nodePositions,[n]:o}}}),removeNode:n=>t(i=>{if(wt(i))return i;const r={...i.nodePositions};delete r[n];const s={...i.uploadedFiles},o=`${n}::`;for(const a of Object.keys(s))a.startsWith(o)&&delete s[a];return{nodes:i.nodes.filter(a=>a.id!==n).map(a=>{const u={...a.fieldValues};let c=!1;for(const[h,f]of Object.entries(u))f.source==="mapped"&&f.fromNodeId===n&&(u[h]={source:"static",value:""},c=!0);return c?{...a,fieldValues:u}:a}),nodePositions:r,uploadedFiles:s,connections:i.connections.filter(a=>a.fromNodeId!==n&&a.toNodeId!==n),selectedNodeId:i.selectedNodeId===n?null:i.selectedNodeId}}),selectNode:n=>t({selectedNodeId:n}),setCredential:(n,i)=>t(r=>wt(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,credentialId:i}:s)}),setFieldValue:(n,i,r)=>t(s=>{if(wt(s))return s;const o={...s.uploadedFiles},l=Th(n,i);return r.source!=="file"&&delete o[l],{uploadedFiles:o,nodes:s.nodes.map(a=>a.id===n?{...a,fieldValues:{...a.fieldValues,[i]:r}}:a)}}),mergeFieldValues:(n,i)=>t(r=>{if(wt(r))return r;const s={...r.uploadedFiles};for(const[o,l]of Object.entries(i))l.source!=="file"&&delete s[Th(n,o)];return{uploadedFiles:s,nodes:r.nodes.map(o=>o.id===n?{...o,fieldValues:{...o.fieldValues,...i}}:o)}}),setUploadedFile:(n,i,r)=>t(s=>{if(wt(s))return s;const o=Th(n,i),l={...s.uploadedFiles};return r?l[o]=r:delete l[o],{uploadedFiles:l,nodes:s.nodes.map(a=>{if(a.id!==n)return a;const u={...a.fieldValues};return r?u[i]={source:"file",fileName:r.name}:delete u[i],{...a,fieldValues:u}})}}),setRequestMode:(n,i)=>t(r=>wt(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,requestMode:i}:s)}),setRawPath:(n,i)=>t(r=>wt(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,rawPath:i}:s)}),setRawQuery:(n,i)=>t(r=>wt(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,rawQuery:i}:s)}),setRawBody:(n,i)=>t(r=>wt(r)?r:{nodes:r.nodes.map(s=>s.id===n?{...s,rawBody:i}:s)}),connectNodes:(n,i)=>t(r=>wt(r)||n===i||r.connections.some(o=>o.fromNodeId===n&&o.toNodeId===i)?r:{connections:[...r.connections,{fromNodeId:n,toNodeId:i}]}),disconnectNodes:(n,i)=>t(r=>{if(wt(r))return r;const s=new Set(r.armedBreakpoints);return s.delete(Ru(n,i)),{connections:r.connections.filter(o=>!(o.fromNodeId===n&&o.toNodeId===i)),armedBreakpoints:s}}),toggleBreakpoint:(n,i)=>t(r=>{if(wt(r))return r;const s=Ru(n,i),o=new Set(r.armedBreakpoints);return o.has(s)?o.delete(s):o.add(s),{armedBreakpoints:o}}),continueExecution:()=>{var n;return(n=e().activeControl)==null?void 0:n.continue()},stepNode:n=>{var i;return(i=e().activeControl)==null?void 0:i.step(n)},stopExecution:()=>{var n;return(n=e().activeControl)==null?void 0:n.stop()},clearResults:()=>{e().isRunning||t({runResult:null,stepStatusByNodeId:{},previewRequestByNodeId:{},error:null})},addCredential:(n,i)=>{const r={...n,id:i??fl()};t(s=>({credentials:[...s.credentials,r]}))},updateCredential:(n,i)=>{const r={...i,id:n};t(s=>({credentials:s.credentials.map(o=>o.id===n?r:o)}))},removeCredential:n=>t(i=>({credentials:i.credentials.filter(r=>r.id!==n),nodes:i.nodes.map(r=>r.credentialId===n?{...r,credentialId:null}:r)})),replaceWorkflow:n=>{var s,o,l;if(wt(e()))return;const i=wN(n),r=((o=(s=n.workflows[0])==null?void 0:s.name)==null?void 0:o.trim())||((l=n.name)==null?void 0:l.trim())||"Untitled";t({nodes:i.nodes,connections:i.connections,nodePositions:i.nodePositions,credentials:i.credentials,uploadedFiles:{},workflowName:r,selectedNodeId:null,runResult:null,stepStatusByNodeId:{},armedBreakpoints:new Set,previewRequestByNodeId:{},activeControl:null,isDebugRun:!1,error:null,credentialReview:null})},setWorkflowName:n=>t({workflowName:n.trim()||"Untitled"}),setCredentialReview:n=>t({credentialReview:n}),run:async n=>{const i=(n==null?void 0:n.useBreakpoints)??!1,{nodes:r,armedBreakpoints:s,credentials:o}=e(),l=SN(r,o);if(l.length>0){const a=l.map(u=>`"${u.name}"`).join(", ");t({error:l.length===1?`Credential ${a} needs a secret before this chain can run.`:`Credentials ${a} need a secret before this chain can run.`});return}t({isRunning:!0,isDebugRun:i,error:null,runResult:{steps:[]},stepStatusByNodeId:r.reduce((a,u)=>(a[u.id]="pending",a),{}),previewRequestByNodeId:{}});try{const{connections:a,operations:u,credentials:c,baseUrl:h,uploadedFiles:f}=e();if(!h)throw new Error("Could not determine a target base URL — add a `servers` entry to the OpenAPI spec.");const d=new Map(u.map(x=>[x.id,x])),p=new Map(c.map(x=>[x.id,x])),g=await lN({nodes:r,connections:a},d,p,{baseUrl:h,uploadedFiles:f,onEvent:x=>{t(m=>{var v;return{stepStatusByNodeId:{...m.stepStatusByNodeId,[x.nodeId]:x.status},runResult:x.step?{steps:[...((v=m.runResult)==null?void 0:v.steps)??[],x.step]}:m.runResult,previewRequestByNodeId:x.request?{...m.previewRequestByNodeId,[x.nodeId]:x.request}:m.previewRequestByNodeId}})},onControl:x=>t({activeControl:x}),...i?{armedBreakpoints:new Set(s)}:{}});t({runResult:g})}catch(a){t({error:a instanceof Error?a.message:String(a)})}finally{t({isRunning:!1,isDebugRun:!1,activeControl:null})}}})),Eo="(untagged)";function DN(t){var i;const e=[],n=new Map;for(const r of t){const s=((i=r.tags)==null?void 0:i[0])??Eo;n.has(s)||(e.push(s),n.set(s,[])),n.get(s).push(r)}return e.filter(r=>r!==Eo).concat(e.includes(Eo)?[Eo]:[]).map(r=>({tag:r,operations:n.get(r)}))}function LN({operations:t}){const[e,n]=M.useState(""),[i,r]=M.useState(new Set),s=e.trim().toLowerCase(),o=s?t.filter(g=>{var x;return s.startsWith("/")?g.path.toLowerCase().includes(s):(x=g.operationId)==null?void 0:x.toLowerCase().includes(s)}):t,l=DN(o),a=l.length>1||l.length===1&&l[0].tag!==Eo,u=s.length>0,c=l.map(g=>g.tag),h=c.length>0&&c.every(g=>i.has(g)),f=g=>{r(x=>{const m=new Set(x);return m.has(g)?m.delete(g):m.add(g),m})},d=()=>{r(h?new Set:new Set(c))},p=g=>y.jsx("li",{draggable:!0,onDragStart:x=>x.dataTransfer.setData("text/operation-id",g.id),children:y.jsxs("fieldset",{className:`operation-list__item operation-list__item--${g.method}`,children:[g.operationId&&y.jsx("legend",{className:"operation-list__operation-id",children:g.operationId}),y.jsx("span",{className:`method-badge method-badge--${g.method}`,children:g.method.toUpperCase()}),y.jsx("span",{className:"operation-list__path",children:g.path})]})},g.id);return y.jsxs("aside",{className:"operation-list",children:[y.jsxs("div",{className:"operation-list__heading",children:[y.jsx("h2",{children:"Operations"}),a&&!u&&y.jsx("button",{type:"button",className:"operation-list__toggle-all",onClick:d,children:h?"Collapse all":"Expand all"})]}),y.jsx("div",{className:"operation-list__search",children:y.jsx("input",{type:"text",placeholder:"Search by operationId or /path…","aria-label":"Search operations by operationId",value:e,onChange:g=>n(g.target.value)})}),u&&o.length===0?y.jsxs("p",{className:"operation-list__empty",children:['No operations match "',e,'".']}):a?y.jsx("div",{className:"operation-list__groups",children:l.map(({tag:g,operations:x})=>{const m=u||i.has(g);return y.jsxs("div",{className:"operation-list__group",children:[y.jsxs("button",{type:"button",className:`operation-list__group-header${m?"":" operation-list__group-header--collapsed"}`,onClick:()=>f(g),"aria-expanded":m,children:[y.jsx("span",{className:"operation-list__group-chevron",children:m?"⌄":"›"}),y.jsx("span",{className:"operation-list__group-name",children:g}),y.jsx("span",{className:"operation-list__group-count",children:x.length})]}),m&&y.jsx("ul",{children:x.map(p)})]},g)})}):y.jsx("ul",{children:o.map(p)})]})}function vt(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,i;n<t.length;n++)(i=vt(t[n]))!==""&&(e+=(e&&" ")+i);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}const{useDebugValue:BN}=V,{useSyncExternalStoreWithSelector:jN}=fx,$N=t=>t;function Ax(t,e=$N,n){const i=jN(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return BN(i),i}const N0=(t,e)=>{const n=lx(t),i=(r,s=e)=>Ax(n,r,s);return Object.assign(i,n),i},zN=(t,e)=>t?N0(t,e):N0;function at(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[i,r]of t)if(!Object.is(r,e.get(i)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(e,i)||!Object.is(t[i],e[i]))return!1;return!0}var FN={value:()=>{}};function Ic(){for(var t=0,e=arguments.length,n={},i;t<e;++t){if(!(i=arguments[t]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new Za(n)}function Za(t){this._=t}function VN(t,e){return t.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}Za.prototype=Ic.prototype={constructor:Za,on:function(t,e){var n=this._,i=VN(t+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(t=i[s]).type)&&(r=HN(n[r],t.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(t=i[s]).type)n[r]=A0(n[r],t.name,e);else if(e==null)for(r in n)n[r]=A0(n[r],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Za(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],i=0,r=s.length;i<r;++i)s[i].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],r=0,s=i.length;r<s;++r)i[r].value.apply(e,n)}};function HN(t,e){for(var n=0,i=t.length,r;n<i;++n)if((r=t[n]).name===e)return r.value}function A0(t,e,n){for(var i=0,r=t.length;i<r;++i)if(t[i].name===e){t[i]=FN,t=t.slice(0,i).concat(t.slice(i+1));break}return n!=null&&t.push({name:e,value:n}),t}var ad="http://www.w3.org/1999/xhtml";const M0={svg:"http://www.w3.org/2000/svg",xhtml:ad,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Pc(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),M0.hasOwnProperty(e)?{space:M0[e],local:t}:t}function WN(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===ad&&e.documentElement.namespaceURI===ad?e.createElement(t):e.createElementNS(n,t)}}function UN(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Mx(t){var e=Pc(t);return(e.local?UN:WN)(e)}function qN(){}function um(t){return t==null?qN:function(){return this.querySelector(t)}}function KN(t){typeof t!="function"&&(t=um(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s=e[r],o=s.length,l=i[r]=new Array(o),a,u,c=0;c<o;++c)(a=s[c])&&(u=t.call(a,a.__data__,c,s))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new $t(i,this._parents)}function QN(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function YN(){return[]}function Tx(t){return t==null?YN:function(){return this.querySelectorAll(t)}}function XN(t){return function(){return QN(t.apply(this,arguments))}}function GN(t){typeof t=="function"?t=XN(t):t=Tx(t);for(var e=this._groups,n=e.length,i=[],r=[],s=0;s<n;++s)for(var o=e[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(i.push(t.call(a,a.__data__,u,o)),r.push(a));return new $t(i,r)}function Ox(t){return function(){return this.matches(t)}}function Ix(t){return function(e){return e.matches(t)}}var JN=Array.prototype.find;function ZN(t){return function(){return JN.call(this.children,t)}}function eA(){return this.firstElementChild}function tA(t){return this.select(t==null?eA:ZN(typeof t=="function"?t:Ix(t)))}var nA=Array.prototype.filter;function iA(){return Array.from(this.children)}function rA(t){return function(){return nA.call(this.children,t)}}function sA(t){return this.selectAll(t==null?iA:rA(typeof t=="function"?t:Ix(t)))}function oA(t){typeof t!="function"&&(t=Ox(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s=e[r],o=s.length,l=i[r]=[],a,u=0;u<o;++u)(a=s[u])&&t.call(a,a.__data__,u,s)&&l.push(a);return new $t(i,this._parents)}function Px(t){return new Array(t.length)}function lA(){return new $t(this._enter||this._groups.map(Px),this._parents)}function Bu(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Bu.prototype={constructor:Bu,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function aA(t){return function(){return t}}function uA(t,e,n,i,r,s){for(var o=0,l,a=e.length,u=s.length;o<u;++o)(l=e[o])?(l.__data__=s[o],i[o]=l):n[o]=new Bu(t,s[o]);for(;o<a;++o)(l=e[o])&&(r[o]=l)}function cA(t,e,n,i,r,s,o){var l,a,u=new Map,c=e.length,h=s.length,f=new Array(c),d;for(l=0;l<c;++l)(a=e[l])&&(f[l]=d=o.call(a,a.__data__,l,e)+"",u.has(d)?r[l]=a:u.set(d,a));for(l=0;l<h;++l)d=o.call(t,s[l],l,s)+"",(a=u.get(d))?(i[l]=a,a.__data__=s[l],u.delete(d)):n[l]=new Bu(t,s[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(r[l]=a)}function hA(t){return t.__data__}function fA(t,e){if(!arguments.length)return Array.from(this,hA);var n=e?cA:uA,i=this._parents,r=this._groups;typeof t!="function"&&(t=aA(t));for(var s=r.length,o=new Array(s),l=new Array(s),a=new Array(s),u=0;u<s;++u){var c=i[u],h=r[u],f=h.length,d=dA(t.call(c,c&&c.__data__,u,i)),p=d.length,g=l[u]=new Array(p),x=o[u]=new Array(p),m=a[u]=new Array(f);n(c,h,g,x,m,d,e);for(var v=0,w=0,k,S;v<p;++v)if(k=g[v]){for(v>=w&&(w=v+1);!(S=x[w])&&++w<p;);k._next=S||null}}return o=new $t(o,i),o._enter=l,o._exit=a,o}function dA(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function pA(){return new $t(this._exit||this._groups.map(Px),this._parents)}function mA(t,e,n){var i=this.enter(),r=this,s=this.exit();return typeof t=="function"?(i=t(i),i&&(i=i.selection())):i=i.append(t+""),e!=null&&(r=e(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function gA(t){for(var e=t.selection?t.selection():t,n=this._groups,i=e._groups,r=n.length,s=i.length,o=Math.min(r,s),l=new Array(r),a=0;a<o;++a)for(var u=n[a],c=i[a],h=u.length,f=l[a]=new Array(h),d,p=0;p<h;++p)(d=u[p]||c[p])&&(f[p]=d);for(;a<r;++a)l[a]=n[a];return new $t(l,this._parents)}function yA(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var i=t[e],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function vA(t){t||(t=wA);function e(h,f){return h&&f?t(h.__data__,f.__data__):!h-!f}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o=n[s],l=o.length,a=r[s]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new $t(r,this._parents).order()}function wA(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function xA(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function kA(){return Array.from(this)}function SA(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function bA(){let t=0;for(const e of this)++t;return t}function CA(){return!this.node()}function EA(t){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var r=e[n],s=0,o=r.length,l;s<o;++s)(l=r[s])&&t.call(l,l.__data__,s,r);return this}function _A(t){return function(){this.removeAttribute(t)}}function NA(t){return function(){this.removeAttributeNS(t.space,t.local)}}function AA(t,e){return function(){this.setAttribute(t,e)}}function MA(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function TA(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function OA(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function IA(t,e){var n=Pc(t);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((e==null?n.local?NA:_A:typeof e=="function"?n.local?OA:TA:n.local?MA:AA)(n,e))}function Rx(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function PA(t){return function(){this.style.removeProperty(t)}}function RA(t,e,n){return function(){this.style.setProperty(t,e,n)}}function DA(t,e,n){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function LA(t,e,n){return arguments.length>1?this.each((e==null?PA:typeof e=="function"?DA:RA)(t,e,n??"")):Rs(this.node(),t)}function Rs(t,e){return t.style.getPropertyValue(e)||Rx(t).getComputedStyle(t,null).getPropertyValue(e)}function BA(t){return function(){delete this[t]}}function jA(t,e){return function(){this[t]=e}}function $A(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function zA(t,e){return arguments.length>1?this.each((e==null?BA:typeof e=="function"?$A:jA)(t,e)):this.node()[t]}function Dx(t){return t.trim().split(/^|\s+/)}function cm(t){return t.classList||new Lx(t)}function Lx(t){this._node=t,this._names=Dx(t.getAttribute("class")||"")}Lx.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Bx(t,e){for(var n=cm(t),i=-1,r=e.length;++i<r;)n.add(e[i])}function jx(t,e){for(var n=cm(t),i=-1,r=e.length;++i<r;)n.remove(e[i])}function FA(t){return function(){Bx(this,t)}}function VA(t){return function(){jx(this,t)}}function HA(t,e){return function(){(e.apply(this,arguments)?Bx:jx)(this,t)}}function WA(t,e){var n=Dx(t+"");if(arguments.length<2){for(var i=cm(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof e=="function"?HA:e?FA:VA)(n,e))}function UA(){this.textContent=""}function qA(t){return function(){this.textContent=t}}function KA(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function QA(t){return arguments.length?this.each(t==null?UA:(typeof t=="function"?KA:qA)(t)):this.node().textContent}function YA(){this.innerHTML=""}function XA(t){return function(){this.innerHTML=t}}function GA(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function JA(t){return arguments.length?this.each(t==null?YA:(typeof t=="function"?GA:XA)(t)):this.node().innerHTML}function ZA(){this.nextSibling&&this.parentNode.appendChild(this)}function eM(){return this.each(ZA)}function tM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function nM(){return this.each(tM)}function iM(t){var e=typeof t=="function"?t:Mx(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function rM(){return null}function sM(t,e){var n=typeof t=="function"?t:Mx(t),i=e==null?rM:typeof e=="function"?e:um(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function oM(){var t=this.parentNode;t&&t.removeChild(this)}function lM(){return this.each(oM)}function aM(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function uM(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function cM(t){return this.select(t?uM:aM)}function hM(t){return arguments.length?this.property("__data__",t):this.node().__data__}function fM(t){return function(e){t.call(this,e,this.__data__)}}function dM(t){return t.trim().split(/^|\s+/).map(function(e){var n="",i=e.indexOf(".");return i>=0&&(n=e.slice(i+1),e=e.slice(0,i)),{type:e,name:n}})}function pM(t){return function(){var e=this.__on;if(e){for(var n=0,i=-1,r=e.length,s;n<r;++n)s=e[n],(!t.type||s.type===t.type)&&s.name===t.name?this.removeEventListener(s.type,s.listener,s.options):e[++i]=s;++i?e.length=i:delete this.__on}}}function mM(t,e,n){return function(){var i=this.__on,r,s=fM(e);if(i){for(var o=0,l=i.length;o<l;++o)if((r=i[o]).type===t.type&&r.name===t.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=e;return}}this.addEventListener(t.type,s,n),r={type:t.type,name:t.name,value:e,listener:s,options:n},i?i.push(r):this.__on=[r]}}function gM(t,e,n){var i=dM(t+""),r,s=i.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(r=0,c=l[a];r<s;++r)if((o=i[r]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?mM:pM,r=0;r<s;++r)this.each(l(i[r],e,n));return this}function $x(t,e,n){var i=Rx(t),r=i.CustomEvent;typeof r=="function"?r=new r(e,n):(r=i.document.createEvent("Event"),n?(r.initEvent(e,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function yM(t,e){return function(){return $x(this,t,e)}}function vM(t,e){return function(){return $x(this,t,e.apply(this,arguments))}}function wM(t,e){return this.each((typeof e=="function"?vM:yM)(t,e))}function*xM(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var zx=[null];function $t(t,e){this._groups=t,this._parents=e}function $l(){return new $t([[document.documentElement]],zx)}function kM(){return this}$t.prototype=$l.prototype={constructor:$t,select:KN,selectAll:GN,selectChild:tA,selectChildren:sA,filter:oA,data:fA,enter:lA,exit:pA,join:mA,merge:gA,selection:kM,order:yA,sort:vA,call:xA,nodes:kA,node:SA,size:bA,empty:CA,each:EA,attr:IA,style:LA,property:zA,classed:WA,text:QA,html:JA,raise:eM,lower:nM,append:iM,insert:sM,remove:lM,clone:cM,datum:hM,on:gM,dispatch:wM,[Symbol.iterator]:xM};function un(t){return typeof t=="string"?new $t([[document.querySelector(t)]],[document.documentElement]):new $t([[t]],zx)}function SM(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Tn(t,e){if(t=SM(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,i=i.matrixTransform(e.getScreenCTM().inverse()),[i.x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}const bM={passive:!1},pl={capture:!0,passive:!1};function Oh(t){t.stopImmediatePropagation()}function gs(t){t.preventDefault(),t.stopImmediatePropagation()}function Fx(t){var e=t.document.documentElement,n=un(t).on("dragstart.drag",gs,pl);"onselectstart"in e?n.on("selectstart.drag",gs,pl):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Vx(t,e){var n=t.document.documentElement,i=un(t).on("dragstart.drag",null);e&&(i.on("click.drag",gs,pl),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const fa=t=>()=>t;function ud(t,{sourceEvent:e,subject:n,target:i,identifier:r,active:s,x:o,y:l,dx:a,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}ud.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function CM(t){return!t.ctrlKey&&!t.button}function EM(){return this.parentNode}function _M(t,e){return e??{x:t.x,y:t.y}}function NM(){return navigator.maxTouchPoints||"ontouchstart"in this}function AM(){var t=CM,e=EM,n=_M,i=NM,r={},s=Ic("start","drag","end"),o=0,l,a,u,c,h=0;function f(k){k.on("mousedown.drag",d).filter(i).on("touchstart.drag",x).on("touchmove.drag",m,bM).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(k,S){if(!(c||!t.call(this,k,S))){var _=w(this,e.call(this,k,S),k,S,"mouse");_&&(un(k.view).on("mousemove.drag",p,pl).on("mouseup.drag",g,pl),Fx(k.view),Oh(k),u=!1,l=k.clientX,a=k.clientY,_("start",k))}}function p(k){if(gs(k),!u){var S=k.clientX-l,_=k.clientY-a;u=S*S+_*_>h}r.mouse("drag",k)}function g(k){un(k.view).on("mousemove.drag mouseup.drag",null),Vx(k.view,u),gs(k),r.mouse("end",k)}function x(k,S){if(t.call(this,k,S)){var _=k.changedTouches,E=e.call(this,k,S),A=_.length,I,R;for(I=0;I<A;++I)(R=w(this,E,k,S,_[I].identifier,_[I]))&&(Oh(k),R("start",k,_[I]))}}function m(k){var S=k.changedTouches,_=S.length,E,A;for(E=0;E<_;++E)(A=r[S[E].identifier])&&(gs(k),A("drag",k,S[E]))}function v(k){var S=k.changedTouches,_=S.length,E,A;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),E=0;E<_;++E)(A=r[S[E].identifier])&&(Oh(k),A("end",k,S[E]))}function w(k,S,_,E,A,I){var R=s.copy(),O=Tn(I||_,S),D,$,b;if((b=n.call(k,new ud("beforestart",{sourceEvent:_,target:f,identifier:A,active:o,x:O[0],y:O[1],dx:0,dy:0,dispatch:R}),E))!=null)return D=b.x-O[0]||0,$=b.y-O[1]||0,function C(N,j,P){var T=O,B;switch(N){case"start":r[A]=C,B=o++;break;case"end":delete r[A],--o;case"drag":O=Tn(P||j,S),B=o;break}R.call(N,k,new ud(N,{sourceEvent:j,subject:b,target:f,identifier:A,active:B,x:O[0]+D,y:O[1]+$,dx:O[0]-T[0],dy:O[1]-T[1],dispatch:R}),E)}}return f.filter=function(k){return arguments.length?(t=typeof k=="function"?k:fa(!!k),f):t},f.container=function(k){return arguments.length?(e=typeof k=="function"?k:fa(k),f):e},f.subject=function(k){return arguments.length?(n=typeof k=="function"?k:fa(k),f):n},f.touchable=function(k){return arguments.length?(i=typeof k=="function"?k:fa(!!k),f):i},f.on=function(){var k=s.on.apply(s,arguments);return k===s?f:k},f.clickDistance=function(k){return arguments.length?(h=(k=+k)*k,f):Math.sqrt(h)},f}function hm(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Hx(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function zl(){}var ml=.7,ju=1/ml,ys="\\s*([+-]?\\d+)\\s*",gl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",jn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",MM=/^#([0-9a-f]{3,8})$/,TM=new RegExp(`^rgb\\(${ys},${ys},${ys}\\)$`),OM=new RegExp(`^rgb\\(${jn},${jn},${jn}\\)$`),IM=new RegExp(`^rgba\\(${ys},${ys},${ys},${gl}\\)$`),PM=new RegExp(`^rgba\\(${jn},${jn},${jn},${gl}\\)$`),RM=new RegExp(`^hsl\\(${gl},${jn},${jn}\\)$`),DM=new RegExp(`^hsla\\(${gl},${jn},${jn},${gl}\\)$`),T0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};hm(zl,yl,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:O0,formatHex:O0,formatHex8:LM,formatHsl:BM,formatRgb:I0,toString:I0});function O0(){return this.rgb().formatHex()}function LM(){return this.rgb().formatHex8()}function BM(){return Wx(this).formatHsl()}function I0(){return this.rgb().formatRgb()}function yl(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=MM.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?P0(e):n===3?new Ct(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?da(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?da(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=TM.exec(t))?new Ct(e[1],e[2],e[3],1):(e=OM.exec(t))?new Ct(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=IM.exec(t))?da(e[1],e[2],e[3],e[4]):(e=PM.exec(t))?da(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=RM.exec(t))?L0(e[1],e[2]/100,e[3]/100,1):(e=DM.exec(t))?L0(e[1],e[2]/100,e[3]/100,e[4]):T0.hasOwnProperty(t)?P0(T0[t]):t==="transparent"?new Ct(NaN,NaN,NaN,0):null}function P0(t){return new Ct(t>>16&255,t>>8&255,t&255,1)}function da(t,e,n,i){return i<=0&&(t=e=n=NaN),new Ct(t,e,n,i)}function jM(t){return t instanceof zl||(t=yl(t)),t?(t=t.rgb(),new Ct(t.r,t.g,t.b,t.opacity)):new Ct}function cd(t,e,n,i){return arguments.length===1?jM(t):new Ct(t,e,n,i??1)}function Ct(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}hm(Ct,cd,Hx(zl,{brighter(t){return t=t==null?ju:Math.pow(ju,t),new Ct(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ml:Math.pow(ml,t),new Ct(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ct(yr(this.r),yr(this.g),yr(this.b),$u(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:R0,formatHex:R0,formatHex8:$M,formatRgb:D0,toString:D0}));function R0(){return`#${fr(this.r)}${fr(this.g)}${fr(this.b)}`}function $M(){return`#${fr(this.r)}${fr(this.g)}${fr(this.b)}${fr((isNaN(this.opacity)?1:this.opacity)*255)}`}function D0(){const t=$u(this.opacity);return`${t===1?"rgb(":"rgba("}${yr(this.r)}, ${yr(this.g)}, ${yr(this.b)}${t===1?")":`, ${t})`}`}function $u(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function yr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function fr(t){return t=yr(t),(t<16?"0":"")+t.toString(16)}function L0(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new cn(t,e,n,i)}function Wx(t){if(t instanceof cn)return new cn(t.h,t.s,t.l,t.opacity);if(t instanceof zl||(t=yl(t)),!t)return new cn;if(t instanceof cn)return t;t=t.rgb();var e=t.r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),s=Math.max(e,n,i),o=NaN,l=s-r,a=(s+r)/2;return l?(e===s?o=(n-i)/l+(n<i)*6:n===s?o=(i-e)/l+2:o=(e-n)/l+4,l/=a<.5?s+r:2-s-r,o*=60):l=a>0&&a<1?0:o,new cn(o,l,a,t.opacity)}function zM(t,e,n,i){return arguments.length===1?Wx(t):new cn(t,e,n,i??1)}function cn(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}hm(cn,zM,Hx(zl,{brighter(t){return t=t==null?ju:Math.pow(ju,t),new cn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ml:Math.pow(ml,t),new cn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Ct(Ih(t>=240?t-240:t+120,r,i),Ih(t,r,i),Ih(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new cn(B0(this.h),pa(this.s),pa(this.l),$u(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=$u(this.opacity);return`${t===1?"hsl(":"hsla("}${B0(this.h)}, ${pa(this.s)*100}%, ${pa(this.l)*100}%${t===1?")":`, ${t})`}`}}));function B0(t){return t=(t||0)%360,t<0?t+360:t}function pa(t){return Math.max(0,Math.min(1,t||0))}function Ih(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Ux=t=>()=>t;function FM(t,e){return function(n){return t+n*e}}function VM(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}function HM(t){return(t=+t)==1?qx:function(e,n){return n-e?VM(e,n,t):Ux(isNaN(e)?n:e)}}function qx(t,e){var n=e-t;return n?FM(t,n):Ux(isNaN(t)?e:t)}const j0=function t(e){var n=HM(e);function i(r,s){var o=n((r=cd(r)).r,(s=cd(s)).r),l=n(r.g,s.g),a=n(r.b,s.b),u=qx(r.opacity,s.opacity);return function(c){return r.r=o(c),r.g=l(c),r.b=a(c),r.opacity=u(c),r+""}}return i.gamma=t,i}(1);function mi(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var hd=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ph=new RegExp(hd.source,"g");function WM(t){return function(){return t}}function UM(t){return function(e){return t(e)+""}}function qM(t,e){var n=hd.lastIndex=Ph.lastIndex=0,i,r,s,o=-1,l=[],a=[];for(t=t+"",e=e+"";(i=hd.exec(t))&&(r=Ph.exec(e));)(s=r.index)>n&&(s=e.slice(n,s),l[o]?l[o]+=s:l[++o]=s),(i=i[0])===(r=r[0])?l[o]?l[o]+=r:l[++o]=r:(l[++o]=null,a.push({i:o,x:mi(i,r)})),n=Ph.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?a[0]?UM(a[0].x):WM(e):(e=a.length,function(u){for(var c=0,h;c<e;++c)l[(h=a[c]).i]=h.x(u);return l.join("")})}var $0=180/Math.PI,fd={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Kx(t,e,n,i,r,s){var o,l,a;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(a=t*n+e*i)&&(n-=t*a,i-=e*a),(l=Math.sqrt(n*n+i*i))&&(n/=l,i/=l,a/=l),t*i<e*n&&(t=-t,e=-e,a=-a,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(e,t)*$0,skewX:Math.atan(a)*$0,scaleX:o,scaleY:l}}var ma;function KM(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?fd:Kx(e.a,e.b,e.c,e.d,e.e,e.f)}function QM(t){return t==null||(ma||(ma=document.createElementNS("http://www.w3.org/2000/svg","g")),ma.setAttribute("transform",t),!(t=ma.transform.baseVal.consolidate()))?fd:(t=t.matrix,Kx(t.a,t.b,t.c,t.d,t.e,t.f))}function Qx(t,e,n,i){function r(u){return u.length?u.pop()+" ":""}function s(u,c,h,f,d,p){if(u!==h||c!==f){var g=d.push("translate(",null,e,null,n);p.push({i:g-4,x:mi(u,h)},{i:g-2,x:mi(c,f)})}else(h||f)&&d.push("translate("+h+e+f+n)}function o(u,c,h,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:h.push(r(h)+"rotate(",null,i)-2,x:mi(u,c)})):c&&h.push(r(h)+"rotate("+c+i)}function l(u,c,h,f){u!==c?f.push({i:h.push(r(h)+"skewX(",null,i)-2,x:mi(u,c)}):c&&h.push(r(h)+"skewX("+c+i)}function a(u,c,h,f,d,p){if(u!==h||c!==f){var g=d.push(r(d)+"scale(",null,",",null,")");p.push({i:g-4,x:mi(u,h)},{i:g-2,x:mi(c,f)})}else(h!==1||f!==1)&&d.push(r(d)+"scale("+h+","+f+")")}return function(u,c){var h=[],f=[];return u=t(u),c=t(c),s(u.translateX,u.translateY,c.translateX,c.translateY,h,f),o(u.rotate,c.rotate,h,f),l(u.skewX,c.skewX,h,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,h,f),u=c=null,function(d){for(var p=-1,g=f.length,x;++p<g;)h[(x=f[p]).i]=x.x(d);return h.join("")}}}var YM=Qx(KM,"px, ","px)","deg)"),XM=Qx(QM,", ",")",")"),GM=1e-12;function z0(t){return((t=Math.exp(t))+1/t)/2}function JM(t){return((t=Math.exp(t))-1/t)/2}function ZM(t){return((t=Math.exp(2*t))-1)/(t+1)}const eT=function t(e,n,i){function r(s,o){var l=s[0],a=s[1],u=s[2],c=o[0],h=o[1],f=o[2],d=c-l,p=h-a,g=d*d+p*p,x,m;if(g<GM)m=Math.log(f/u)/e,x=function(E){return[l+E*d,a+E*p,u*Math.exp(e*E*m)]};else{var v=Math.sqrt(g),w=(f*f-u*u+i*g)/(2*u*n*v),k=(f*f-u*u-i*g)/(2*f*n*v),S=Math.log(Math.sqrt(w*w+1)-w),_=Math.log(Math.sqrt(k*k+1)-k);m=(_-S)/e,x=function(E){var A=E*m,I=z0(S),R=u/(n*v)*(I*ZM(e*A+S)-JM(S));return[l+R*d,a+R*p,u*I/z0(e*A+S)]}}return x.duration=m*1e3*e/Math.SQRT2,x}return r.rho=function(s){var o=Math.max(.001,+s),l=o*o,a=l*l;return t(o,l,a)},r}(Math.SQRT2,2,4);var Ds=0,_o=0,co=0,Yx=1e3,zu,No,Fu=0,Er=0,Rc=0,vl=typeof performance=="object"&&performance.now?performance:Date,Xx=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function fm(){return Er||(Xx(tT),Er=vl.now()+Rc)}function tT(){Er=0}function Vu(){this._call=this._time=this._next=null}Vu.prototype=Gx.prototype={constructor:Vu,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?fm():+n)+(e==null?0:+e),!this._next&&No!==this&&(No?No._next=this:zu=this,No=this),this._call=t,this._time=n,dd()},stop:function(){this._call&&(this._call=null,this._time=1/0,dd())}};function Gx(t,e,n){var i=new Vu;return i.restart(t,e,n),i}function nT(){fm(),++Ds;for(var t=zu,e;t;)(e=Er-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ds}function F0(){Er=(Fu=vl.now())+Rc,Ds=_o=0;try{nT()}finally{Ds=0,rT(),Er=0}}function iT(){var t=vl.now(),e=t-Fu;e>Yx&&(Rc-=e,Fu=t)}function rT(){for(var t,e=zu,n,i=1/0;e;)e._call?(i>e._time&&(i=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:zu=n);No=t,dd(i)}function dd(t){if(!Ds){_o&&(_o=clearTimeout(_o));var e=t-Er;e>24?(t<1/0&&(_o=setTimeout(F0,t-vl.now()-Rc)),co&&(co=clearInterval(co))):(co||(Fu=vl.now(),co=setInterval(iT,Yx)),Ds=1,Xx(F0))}}function V0(t,e,n){var i=new Vu;return e=e==null?0:+e,i.restart(r=>{i.stop(),t(r+e)},e,n),i}var sT=Ic("start","end","cancel","interrupt"),oT=[],Jx=0,H0=1,pd=2,eu=3,W0=4,md=5,tu=6;function Dc(t,e,n,i,r,s){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;lT(t,n,{name:e,index:i,group:r,on:sT,tween:oT,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Jx})}function dm(t,e){var n=wn(t,e);if(n.state>Jx)throw new Error("too late; already scheduled");return n}function Fn(t,e){var n=wn(t,e);if(n.state>eu)throw new Error("too late; already running");return n}function wn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function lT(t,e,n){var i=t.__transition,r;i[e]=n,n.timer=Gx(s,0,n.time);function s(u){n.state=H0,n.timer.restart(o,n.delay,n.time),n.delay<=u&&o(u-n.delay)}function o(u){var c,h,f,d;if(n.state!==H0)return a();for(c in i)if(d=i[c],d.name===n.name){if(d.state===eu)return V0(o);d.state===W0?(d.state=tu,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete i[c]):+c<e&&(d.state=tu,d.timer.stop(),d.on.call("cancel",t,t.__data__,d.index,d.group),delete i[c])}if(V0(function(){n.state===eu&&(n.state=W0,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=pd,n.on.call("start",t,t.__data__,n.index,n.group),n.state===pd){for(n.state=eu,r=new Array(f=n.tween.length),c=0,h=-1;c<f;++c)(d=n.tween[c].value.call(t,t.__data__,n.index,n.group))&&(r[++h]=d);r.length=h+1}}function l(u){for(var c=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(a),n.state=md,1),h=-1,f=r.length;++h<f;)r[h].call(t,c);n.state===md&&(n.on.call("end",t,t.__data__,n.index,n.group),a())}function a(){n.state=tu,n.timer.stop(),delete i[e];for(var u in i)return;delete t.__transition}}function nu(t,e){var n=t.__transition,i,r,s=!0,o;if(n){e=e==null?null:e+"";for(o in n){if((i=n[o]).name!==e){s=!1;continue}r=i.state>pd&&i.state<md,i.state=tu,i.timer.stop(),i.on.call(r?"interrupt":"cancel",t,t.__data__,i.index,i.group),delete n[o]}s&&delete t.__transition}}function aT(t){return this.each(function(){nu(this,t)})}function uT(t,e){var n,i;return function(){var r=Fn(this,t),s=r.tween;if(s!==n){i=n=s;for(var o=0,l=i.length;o<l;++o)if(i[o].name===e){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function cT(t,e,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=Fn(this,t),o=s.tween;if(o!==i){r=(i=o).slice();for(var l={name:e,value:n},a=0,u=r.length;a<u;++a)if(r[a].name===e){r[a]=l;break}a===u&&r.push(l)}s.tween=r}}function hT(t,e){var n=this._id;if(t+="",arguments.length<2){for(var i=wn(this.node(),n).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===t)return o.value;return null}return this.each((e==null?uT:cT)(n,t,e))}function pm(t,e,n){var i=t._id;return t.each(function(){var r=Fn(this,i);(r.value||(r.value={}))[e]=n.apply(this,arguments)}),function(r){return wn(r,i).value[e]}}function Zx(t,e){var n;return(typeof e=="number"?mi:e instanceof yl?j0:(n=yl(e))?(e=n,j0):qM)(t,e)}function fT(t){return function(){this.removeAttribute(t)}}function dT(t){return function(){this.removeAttributeNS(t.space,t.local)}}function pT(t,e,n){var i,r=n+"",s;return function(){var o=this.getAttribute(t);return o===r?null:o===i?s:s=e(i=o,n)}}function mT(t,e,n){var i,r=n+"",s;return function(){var o=this.getAttributeNS(t.space,t.local);return o===r?null:o===i?s:s=e(i=o,n)}}function gT(t,e,n){var i,r,s;return function(){var o,l=n(this),a;return l==null?void this.removeAttribute(t):(o=this.getAttribute(t),a=l+"",o===a?null:o===i&&a===r?s:(r=a,s=e(i=o,l)))}}function yT(t,e,n){var i,r,s;return function(){var o,l=n(this),a;return l==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),a=l+"",o===a?null:o===i&&a===r?s:(r=a,s=e(i=o,l)))}}function vT(t,e){var n=Pc(t),i=n==="transform"?XM:Zx;return this.attrTween(t,typeof e=="function"?(n.local?yT:gT)(n,i,pm(this,"attr."+t,e)):e==null?(n.local?dT:fT)(n):(n.local?mT:pT)(n,i,e))}function wT(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function xT(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function kT(t,e){var n,i;function r(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&xT(t,s)),n}return r._value=e,r}function ST(t,e){var n,i;function r(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&wT(t,s)),n}return r._value=e,r}function bT(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var i=Pc(t);return this.tween(n,(i.local?kT:ST)(i,e))}function CT(t,e){return function(){dm(this,t).delay=+e.apply(this,arguments)}}function ET(t,e){return e=+e,function(){dm(this,t).delay=e}}function _T(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?CT:ET)(e,t)):wn(this.node(),e).delay}function NT(t,e){return function(){Fn(this,t).duration=+e.apply(this,arguments)}}function AT(t,e){return e=+e,function(){Fn(this,t).duration=e}}function MT(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?NT:AT)(e,t)):wn(this.node(),e).duration}function TT(t,e){if(typeof e!="function")throw new Error;return function(){Fn(this,t).ease=e}}function OT(t){var e=this._id;return arguments.length?this.each(TT(e,t)):wn(this.node(),e).ease}function IT(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Fn(this,t).ease=n}}function PT(t){if(typeof t!="function")throw new Error;return this.each(IT(this._id,t))}function RT(t){typeof t!="function"&&(t=Ox(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s=e[r],o=s.length,l=i[r]=[],a,u=0;u<o;++u)(a=s[u])&&t.call(a,a.__data__,u,s)&&l.push(a);return new oi(i,this._parents,this._name,this._id)}function DT(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,i=e.length,r=n.length,s=Math.min(i,r),o=new Array(i),l=0;l<s;++l)for(var a=e[l],u=n[l],c=a.length,h=o[l]=new Array(c),f,d=0;d<c;++d)(f=a[d]||u[d])&&(h[d]=f);for(;l<i;++l)o[l]=e[l];return new oi(o,this._parents,this._name,this._id)}function LT(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function BT(t,e,n){var i,r,s=LT(e)?dm:Fn;return function(){var o=s(this,t),l=o.on;l!==i&&(r=(i=l).copy()).on(e,n),o.on=r}}function jT(t,e){var n=this._id;return arguments.length<2?wn(this.node(),n).on.on(t):this.each(BT(n,t,e))}function $T(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function zT(){return this.on("end.remove",$T(this._id))}function FT(t){var e=this._name,n=this._id;typeof t!="function"&&(t=um(t));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var l=i[o],a=l.length,u=s[o]=new Array(a),c,h,f=0;f<a;++f)(c=l[f])&&(h=t.call(c,c.__data__,f,l))&&("__data__"in c&&(h.__data__=c.__data__),u[f]=h,Dc(u[f],e,n,f,u,wn(c,n)));return new oi(s,this._parents,e,n)}function VT(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Tx(t));for(var i=this._groups,r=i.length,s=[],o=[],l=0;l<r;++l)for(var a=i[l],u=a.length,c,h=0;h<u;++h)if(c=a[h]){for(var f=t.call(c,c.__data__,h,a),d,p=wn(c,n),g=0,x=f.length;g<x;++g)(d=f[g])&&Dc(d,e,n,g,f,p);s.push(f),o.push(c)}return new oi(s,o,e,n)}var HT=$l.prototype.constructor;function WT(){return new HT(this._groups,this._parents)}function UT(t,e){var n,i,r;return function(){var s=Rs(this,t),o=(this.style.removeProperty(t),Rs(this,t));return s===o?null:s===n&&o===i?r:r=e(n=s,i=o)}}function ek(t){return function(){this.style.removeProperty(t)}}function qT(t,e,n){var i,r=n+"",s;return function(){var o=Rs(this,t);return o===r?null:o===i?s:s=e(i=o,n)}}function KT(t,e,n){var i,r,s;return function(){var o=Rs(this,t),l=n(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(t),Rs(this,t))),o===a?null:o===i&&a===r?s:(r=a,s=e(i=o,l))}}function QT(t,e){var n,i,r,s="style."+e,o="end."+s,l;return function(){var a=Fn(this,t),u=a.on,c=a.value[s]==null?l||(l=ek(e)):void 0;(u!==n||r!==c)&&(i=(n=u).copy()).on(o,r=c),a.on=i}}function YT(t,e,n){var i=(t+="")=="transform"?YM:Zx;return e==null?this.styleTween(t,UT(t,i)).on("end.style."+t,ek(t)):typeof e=="function"?this.styleTween(t,KT(t,i,pm(this,"style."+t,e))).each(QT(this._id,t)):this.styleTween(t,qT(t,i,e),n).on("end.style."+t,null)}function XT(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}function GT(t,e,n){var i,r;function s(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&XT(t,o,n)),i}return s._value=e,s}function JT(t,e,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(e==null)return this.tween(i,null);if(typeof e!="function")throw new Error;return this.tween(i,GT(t,e,n??""))}function ZT(t){return function(){this.textContent=t}}function eO(t){return function(){var e=t(this);this.textContent=e??""}}function tO(t){return this.tween("text",typeof t=="function"?eO(pm(this,"text",t)):ZT(t==null?"":t+""))}function nO(t){return function(e){this.textContent=t.call(this,e)}}function iO(t){var e,n;function i(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&nO(r)),e}return i._value=t,i}function rO(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,iO(t))}function sO(){for(var t=this._name,e=this._id,n=tk(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=wn(a,e);Dc(a,t,n,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new oi(i,this._parents,t,n)}function oO(){var t,e,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var l={value:o},a={value:function(){--r===0&&s()}};n.each(function(){var u=Fn(this,i),c=u.on;c!==t&&(e=(t=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),r===0&&s()})}var lO=0;function oi(t,e,n,i){this._groups=t,this._parents=e,this._name=n,this._id=i}function tk(){return++lO}var Un=$l.prototype;oi.prototype={constructor:oi,select:FT,selectAll:VT,selectChild:Un.selectChild,selectChildren:Un.selectChildren,filter:RT,merge:DT,selection:WT,transition:sO,call:Un.call,nodes:Un.nodes,node:Un.node,size:Un.size,empty:Un.empty,each:Un.each,on:jT,attr:vT,attrTween:bT,style:YT,styleTween:JT,text:tO,textTween:rO,remove:zT,tween:hT,delay:_T,duration:MT,ease:OT,easeVarying:PT,end:oO,[Symbol.iterator]:Un[Symbol.iterator]};function aO(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var uO={time:null,delay:0,duration:250,ease:aO};function cO(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function hO(t){var e,n;t instanceof oi?(e=t._id,t=t._name):(e=tk(),(n=uO).time=fm(),t=t==null?null:t+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Dc(a,t,e,u,o,n||cO(a,e));return new oi(i,this._parents,t,e)}$l.prototype.interrupt=aT;$l.prototype.transition=hO;const ga=t=>()=>t;function fO(t,{sourceEvent:e,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Jn(t,e,n){this.k=t,this.x=e,this.y=n}Jn.prototype={constructor:Jn,scale:function(t){return t===1?this:new Jn(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Jn(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Li=new Jn(1,0,0);Jn.prototype;function Rh(t){t.stopImmediatePropagation()}function ho(t){t.preventDefault(),t.stopImmediatePropagation()}function dO(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function pO(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function U0(){return this.__zoom||Li}function mO(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function gO(){return navigator.maxTouchPoints||"ontouchstart"in this}function yO(t,e,n){var i=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function vO(){var t=dO,e=pO,n=yO,i=mO,r=gO,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=eT,u=Ic("start","zoom","end"),c,h,f,d=500,p=150,g=0,x=10;function m(b){b.property("__zoom",U0).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",R).filter(r).on("touchstart.zoom",O).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(b,C,N,j){var P=b.selection?b.selection():b;P.property("__zoom",U0),b!==P?S(b,C,N,j):P.interrupt().each(function(){_(this,arguments).event(j).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},m.scaleBy=function(b,C,N,j){m.scaleTo(b,function(){var P=this.__zoom.k,T=typeof C=="function"?C.apply(this,arguments):C;return P*T},N,j)},m.scaleTo=function(b,C,N,j){m.transform(b,function(){var P=e.apply(this,arguments),T=this.__zoom,B=N==null?k(P):typeof N=="function"?N.apply(this,arguments):N,F=T.invert(B),z=typeof C=="function"?C.apply(this,arguments):C;return n(w(v(T,z),B,F),P,o)},N,j)},m.translateBy=function(b,C,N,j){m.transform(b,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof N=="function"?N.apply(this,arguments):N),e.apply(this,arguments),o)},null,j)},m.translateTo=function(b,C,N,j,P){m.transform(b,function(){var T=e.apply(this,arguments),B=this.__zoom,F=j==null?k(T):typeof j=="function"?j.apply(this,arguments):j;return n(Li.translate(F[0],F[1]).scale(B.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof N=="function"?-N.apply(this,arguments):-N),T,o)},j,P)};function v(b,C){return C=Math.max(s[0],Math.min(s[1],C)),C===b.k?b:new Jn(C,b.x,b.y)}function w(b,C,N){var j=C[0]-N[0]*b.k,P=C[1]-N[1]*b.k;return j===b.x&&P===b.y?b:new Jn(b.k,j,P)}function k(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function S(b,C,N,j){b.on("start.zoom",function(){_(this,arguments).event(j).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(j).end()}).tween("zoom",function(){var P=this,T=arguments,B=_(P,T).event(j),F=e.apply(P,T),z=N==null?k(F):typeof N=="function"?N.apply(P,T):N,L=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),H=P.__zoom,q=typeof C=="function"?C.apply(P,T):C,ee=a(H.invert(z).concat(L/H.k),q.invert(z).concat(L/q.k));return function(J){if(J===1)J=q;else{var he=ee(J),we=L/he[2];J=new Jn(we,z[0]-he[0]*we,z[1]-he[1]*we)}B.zoom(null,J)}})}function _(b,C,N){return!N&&b.__zooming||new E(b,C)}function E(b,C){this.that=b,this.args=C,this.active=0,this.sourceEvent=null,this.extent=e.apply(b,C),this.taps=0}E.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,C){return this.mouse&&b!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var C=un(this.that).datum();u.call(b,this.that,new fO(b,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),C)}};function A(b,...C){if(!t.apply(this,arguments))return;var N=_(this,C).event(b),j=this.__zoom,P=Math.max(s[0],Math.min(s[1],j.k*Math.pow(2,i.apply(this,arguments)))),T=Tn(b);if(N.wheel)(N.mouse[0][0]!==T[0]||N.mouse[0][1]!==T[1])&&(N.mouse[1]=j.invert(N.mouse[0]=T)),clearTimeout(N.wheel);else{if(j.k===P)return;N.mouse=[T,j.invert(T)],nu(this),N.start()}ho(b),N.wheel=setTimeout(B,p),N.zoom("mouse",n(w(v(j,P),N.mouse[0],N.mouse[1]),N.extent,o));function B(){N.wheel=null,N.end()}}function I(b,...C){if(f||!t.apply(this,arguments))return;var N=b.currentTarget,j=_(this,C,!0).event(b),P=un(b.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",L,!0),T=Tn(b,N),B=b.clientX,F=b.clientY;Fx(b.view),Rh(b),j.mouse=[T,this.__zoom.invert(T)],nu(this),j.start();function z(H){if(ho(H),!j.moved){var q=H.clientX-B,ee=H.clientY-F;j.moved=q*q+ee*ee>g}j.event(H).zoom("mouse",n(w(j.that.__zoom,j.mouse[0]=Tn(H,N),j.mouse[1]),j.extent,o))}function L(H){P.on("mousemove.zoom mouseup.zoom",null),Vx(H.view,j.moved),ho(H),j.event(H).end()}}function R(b,...C){if(t.apply(this,arguments)){var N=this.__zoom,j=Tn(b.changedTouches?b.changedTouches[0]:b,this),P=N.invert(j),T=N.k*(b.shiftKey?.5:2),B=n(w(v(N,T),j,P),e.apply(this,C),o);ho(b),l>0?un(this).transition().duration(l).call(S,B,j,b):un(this).call(m.transform,B,j,b)}}function O(b,...C){if(t.apply(this,arguments)){var N=b.touches,j=N.length,P=_(this,C,b.changedTouches.length===j).event(b),T,B,F,z;for(Rh(b),B=0;B<j;++B)F=N[B],z=Tn(F,this),z=[z,this.__zoom.invert(z),F.identifier],P.touch0?!P.touch1&&P.touch0[2]!==z[2]&&(P.touch1=z,P.taps=0):(P.touch0=z,T=!0,P.taps=1+!!c);c&&(c=clearTimeout(c)),T&&(P.taps<2&&(h=z[0],c=setTimeout(function(){c=null},d)),nu(this),P.start())}}function D(b,...C){if(this.__zooming){var N=_(this,C).event(b),j=b.changedTouches,P=j.length,T,B,F,z;for(ho(b),T=0;T<P;++T)B=j[T],F=Tn(B,this),N.touch0&&N.touch0[2]===B.identifier?N.touch0[0]=F:N.touch1&&N.touch1[2]===B.identifier&&(N.touch1[0]=F);if(B=N.that.__zoom,N.touch1){var L=N.touch0[0],H=N.touch0[1],q=N.touch1[0],ee=N.touch1[1],J=(J=q[0]-L[0])*J+(J=q[1]-L[1])*J,he=(he=ee[0]-H[0])*he+(he=ee[1]-H[1])*he;B=v(B,Math.sqrt(J/he)),F=[(L[0]+q[0])/2,(L[1]+q[1])/2],z=[(H[0]+ee[0])/2,(H[1]+ee[1])/2]}else if(N.touch0)F=N.touch0[0],z=N.touch0[1];else return;N.zoom("touch",n(w(B,F,z),N.extent,o))}}function $(b,...C){if(this.__zooming){var N=_(this,C).event(b),j=b.changedTouches,P=j.length,T,B;for(Rh(b),f&&clearTimeout(f),f=setTimeout(function(){f=null},d),T=0;T<P;++T)B=j[T],N.touch0&&N.touch0[2]===B.identifier?delete N.touch0:N.touch1&&N.touch1[2]===B.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(B=Tn(B,this),Math.hypot(h[0]-B[0],h[1]-B[1])<x)){var F=un(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return m.wheelDelta=function(b){return arguments.length?(i=typeof b=="function"?b:ga(+b),m):i},m.filter=function(b){return arguments.length?(t=typeof b=="function"?b:ga(!!b),m):t},m.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:ga(!!b),m):r},m.extent=function(b){return arguments.length?(e=typeof b=="function"?b:ga([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),m):e},m.scaleExtent=function(b){return arguments.length?(s[0]=+b[0],s[1]=+b[1],m):[s[0],s[1]]},m.translateExtent=function(b){return arguments.length?(o[0][0]=+b[0][0],o[1][0]=+b[1][0],o[0][1]=+b[0][1],o[1][1]=+b[1][1],m):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},m.constrain=function(b){return arguments.length?(n=b,m):n},m.duration=function(b){return arguments.length?(l=+b,m):l},m.interpolate=function(b){return arguments.length?(a=b,m):a},m.on=function(){var b=u.on.apply(u,arguments);return b===u?m:b},m.clickDistance=function(b){return arguments.length?(g=(b=+b)*b,m):Math.sqrt(g)},m.tapDistance=function(b){return arguments.length?(x=+b,m):x},m}const Lc=M.createContext(null),wO=Lc.Provider,li={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},nk=li.error001();function Ce(t,e){const n=M.useContext(Lc);if(n===null)throw new Error(nk);return Ax(n,t,e)}const Ke=()=>{const t=M.useContext(Lc);if(t===null)throw new Error(nk);return M.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},xO=t=>t.userSelectionActive?"none":"all";function ik({position:t,children:e,className:n,style:i,...r}){const s=Ce(xO),o=`${t}`.split("-");return V.createElement("div",{className:vt(["react-flow__panel",n,...o]),style:{...i,pointerEvents:s},...r},e)}function kO({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:V.createElement(ik,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},V.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const SO=({x:t,y:e,label:n,labelStyle:i={},labelShowBg:r=!0,labelBgStyle:s={},labelBgPadding:o=[2,4],labelBgBorderRadius:l=2,children:a,className:u,...c})=>{const h=M.useRef(null),[f,d]=M.useState({x:0,y:0,width:0,height:0}),p=vt(["react-flow__edge-textwrapper",u]);return M.useEffect(()=>{if(h.current){const g=h.current.getBBox();d({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),typeof n>"u"||!n?null:V.createElement("g",{transform:`translate(${t-f.width/2} ${e-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...c},r&&V.createElement("rect",{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),V.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:h,style:i},n),a)};var bO=M.memo(SO);const mm=t=>({width:t.offsetWidth,height:t.offsetHeight}),Ls=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),gm=(t={x:0,y:0},e)=>({x:Ls(t.x,e[0][0],e[1][0]),y:Ls(t.y,e[0][1],e[1][1])}),q0=(t,e,n)=>t<e?Ls(Math.abs(t-e),1,50)/50:t>n?-Ls(Math.abs(t-n),1,50)/50:0,rk=(t,e)=>{const n=q0(t.x,35,e.width-35)*20,i=q0(t.y,35,e.height-35)*20;return[n,i]},sk=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},CO=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),ym=({x:t,y:e,width:n,height:i})=>({x:t,y:e,x2:t+n,y2:e+i}),EO=({x:t,y:e,x2:n,y2:i})=>({x:t,y:e,width:n-t,height:i-e}),K0=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),gd=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),i=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*i)},_O=t=>qt(t.width)&&qt(t.height)&&qt(t.x)&&qt(t.y),qt=t=>!isNaN(t)&&isFinite(t),Te=Symbol.for("internals"),ok=["Enter"," ","Escape"],NO=(t,e)=>{},AO=t=>"nativeEvent"in t;function yd(t){var r,s;const e=AO(t)?t.nativeEvent:t,n=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const lk=t=>"clientX"in t,Bi=(t,e)=>{var s,o;const n=lk(t),i=n?t.clientX:(s=t.touches)==null?void 0:s[0].clientX,r=n?t.clientY:(o=t.touches)==null?void 0:o[0].clientY;return{x:i-((e==null?void 0:e.left)??0),y:r-((e==null?void 0:e.top)??0)}},Hu=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},Xs=({id:t,path:e,labelX:n,labelY:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:f,interactionWidth:d=20})=>V.createElement(V.Fragment,null,V.createElement("path",{id:t,style:c,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),d&&V.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}),r&&qt(n)&&qt(i)?V.createElement(bO,{x:n,y:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u}):null);Xs.displayName="BaseEdge";function fo(t,e,n){return n===void 0?n:i=>{const r=e().edges.find(s=>s.id===t);r&&n(i,{...r})}}function ak({sourceX:t,sourceY:e,targetX:n,targetY:i}){const r=Math.abs(n-t)/2,s=n<t?n+r:n-r,o=Math.abs(i-e)/2,l=i<e?i+o:i-o;return[s,l,r,o]}function uk({sourceX:t,sourceY:e,targetX:n,targetY:i,sourceControlX:r,sourceControlY:s,targetControlX:o,targetControlY:l}){const a=t*.125+r*.375+o*.375+n*.125,u=e*.125+s*.375+l*.375+i*.125,c=Math.abs(a-t),h=Math.abs(u-e);return[a,u,c,h]}var _r;(function(t){t.Strict="strict",t.Loose="loose"})(_r||(_r={}));var dr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(dr||(dr={}));var wl;(function(t){t.Partial="partial",t.Full="full"})(wl||(wl={}));var ki;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(ki||(ki={}));var xl;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(xl||(xl={}));var G;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(G||(G={}));function Q0({pos:t,x1:e,y1:n,x2:i,y2:r}){return t===G.Left||t===G.Right?[.5*(e+i),n]:[e,.5*(n+r)]}function ck({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:i,targetY:r,targetPosition:s=G.Top}){const[o,l]=Q0({pos:n,x1:t,y1:e,x2:i,y2:r}),[a,u]=Q0({pos:s,x1:i,y1:r,x2:t,y2:e}),[c,h,f,d]=uk({sourceX:t,sourceY:e,targetX:i,targetY:r,sourceControlX:o,sourceControlY:l,targetControlX:a,targetControlY:u});return[`M${t},${e} C${o},${l} ${a},${u} ${i},${r}`,c,h,f,d]}const vm=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r=G.Bottom,targetPosition:s=G.Top,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,interactionWidth:g})=>{const[x,m,v]=ck({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s});return V.createElement(Xs,{path:x,labelX:m,labelY:v,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,interactionWidth:g})});vm.displayName="SimpleBezierEdge";const Y0={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},MO=({source:t,sourcePosition:e=G.Bottom,target:n})=>e===G.Left||e===G.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},X0=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function TO({source:t,sourcePosition:e=G.Bottom,target:n,targetPosition:i=G.Top,center:r,offset:s}){const o=Y0[e],l=Y0[i],a={x:t.x+o.x*s,y:t.y+o.y*s},u={x:n.x+l.x*s,y:n.y+l.y*s},c=MO({source:a,sourcePosition:e,target:u}),h=c.x!==0?"x":"y",f=c[h];let d=[],p,g;const x={x:0,y:0},m={x:0,y:0},[v,w,k,S]=ak({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(o[h]*l[h]===-1){p=r.x??v,g=r.y??w;const E=[{x:p,y:a.y},{x:p,y:u.y}],A=[{x:a.x,y:g},{x:u.x,y:g}];o[h]===f?d=h==="x"?E:A:d=h==="x"?A:E}else{const E=[{x:a.x,y:u.y}],A=[{x:u.x,y:a.y}];if(h==="x"?d=o.x===f?A:E:d=o.y===f?E:A,e===i){const $=Math.abs(t[h]-n[h]);if($<=s){const b=Math.min(s-1,s-$);o[h]===f?x[h]=(a[h]>t[h]?-1:1)*b:m[h]=(u[h]>n[h]?-1:1)*b}}if(e!==i){const $=h==="x"?"y":"x",b=o[h]===l[$],C=a[$]>u[$],N=a[$]<u[$];(o[h]===1&&(!b&&C||b&&N)||o[h]!==1&&(!b&&N||b&&C))&&(d=h==="x"?E:A)}const I={x:a.x+x.x,y:a.y+x.y},R={x:u.x+m.x,y:u.y+m.y},O=Math.max(Math.abs(I.x-d[0].x),Math.abs(R.x-d[0].x)),D=Math.max(Math.abs(I.y-d[0].y),Math.abs(R.y-d[0].y));O>=D?(p=(I.x+R.x)/2,g=d[0].y):(p=d[0].x,g=(I.y+R.y)/2)}return[[t,{x:a.x+x.x,y:a.y+x.y},...d,{x:u.x+m.x,y:u.y+m.y},n],p,g,k,S]}function OO(t,e,n,i){const r=Math.min(X0(t,e)/2,X0(e,n)/2,i),{x:s,y:o}=e;if(t.x===s&&s===n.x||t.y===o&&o===n.y)return`L${s} ${o}`;if(t.y===o){const u=t.x<n.x?-1:1,c=t.y<n.y?1:-1;return`L ${s+r*u},${o}Q ${s},${o} ${s},${o+r*c}`}const l=t.x<n.x?1:-1,a=t.y<n.y?-1:1;return`L ${s},${o+r*a}Q ${s},${o} ${s+r*l},${o}`}function vd({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:i,targetY:r,targetPosition:s=G.Top,borderRadius:o=5,centerX:l,centerY:a,offset:u=20}){const[c,h,f,d,p]=TO({source:{x:t,y:e},sourcePosition:n,target:{x:i,y:r},targetPosition:s,center:{x:l,y:a},offset:u});return[c.reduce((x,m,v)=>{let w="";return v>0&&v<c.length-1?w=OO(c[v-1],m,c[v+1],o):w=`${v===0?"M":"L"}${m.x} ${m.y}`,x+=w,x},""),h,f,d,p]}const Bc=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,sourcePosition:h=G.Bottom,targetPosition:f=G.Top,markerEnd:d,markerStart:p,pathOptions:g,interactionWidth:x})=>{const[m,v,w]=vd({sourceX:t,sourceY:e,sourcePosition:h,targetX:n,targetY:i,targetPosition:f,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset});return V.createElement(Xs,{path:m,labelX:v,labelY:w,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:p,interactionWidth:x})});Bc.displayName="SmoothStepEdge";const wm=M.memo(t=>{var e;return V.createElement(Bc,{...t,pathOptions:M.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});wm.displayName="StepEdge";function IO({sourceX:t,sourceY:e,targetX:n,targetY:i}){const[r,s,o,l]=ak({sourceX:t,sourceY:e,targetX:n,targetY:i});return[`M ${t},${e}L ${n},${i}`,r,s,o,l]}const xm=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:f,interactionWidth:d})=>{const[p,g,x]=IO({sourceX:t,sourceY:e,targetX:n,targetY:i});return V.createElement(Xs,{path:p,labelX:g,labelY:x,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:f,interactionWidth:d})});xm.displayName="StraightEdge";function ya(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function G0({pos:t,x1:e,y1:n,x2:i,y2:r,c:s}){switch(t){case G.Left:return[e-ya(e-i,s),n];case G.Right:return[e+ya(i-e,s),n];case G.Top:return[e,n-ya(n-r,s)];case G.Bottom:return[e,n+ya(r-n,s)]}}function km({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:i,targetY:r,targetPosition:s=G.Top,curvature:o=.25}){const[l,a]=G0({pos:n,x1:t,y1:e,x2:i,y2:r,c:o}),[u,c]=G0({pos:s,x1:i,y1:r,x2:t,y2:e,c:o}),[h,f,d,p]=uk({sourceX:t,sourceY:e,targetX:i,targetY:r,sourceControlX:l,sourceControlY:a,targetControlX:u,targetControlY:c});return[`M${t},${e} C${l},${a} ${u},${c} ${i},${r}`,h,f,d,p]}const Wu=M.memo(({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r=G.Bottom,targetPosition:s=G.Top,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,pathOptions:g,interactionWidth:x})=>{const[m,v,w]=km({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s,curvature:g==null?void 0:g.curvature});return V.createElement(Xs,{path:m,labelX:v,labelY:w,label:o,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:h,style:f,markerEnd:d,markerStart:p,interactionWidth:x})});Wu.displayName="BezierEdge";const Sm=M.createContext(null),PO=Sm.Provider;Sm.Consumer;const RO=()=>M.useContext(Sm),DO=t=>"id"in t&&"source"in t&&"target"in t,LO=({source:t,sourceHandle:e,target:n,targetHandle:i})=>`reactflow__edge-${t}${e||""}-${n}${i||""}`,wd=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("&")}`,BO=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),jO=(t,e)=>{if(!t.source||!t.target)return e;let n;return DO(t)?n={...t}:n={...t,id:LO(t)},BO(n,e)?e:e.concat(n)},xd=({x:t,y:e},[n,i,r],s,[o,l])=>{const a={x:(t-n)/r,y:(e-i)/r};return s?{x:o*Math.round(a.x/o),y:l*Math.round(a.y/l)}:a},hk=({x:t,y:e},[n,i,r])=>({x:t*r+n,y:e*r+i}),vs=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],i=(t.height??0)*e[1],r={x:t.position.x-n,y:t.position.y-i};return{...r,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-i}:r}},bm=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((i,r)=>{const{x:s,y:o}=vs(r,e).positionAbsolute;return CO(i,ym({x:s,y:o,width:r.width||0,height:r.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return EO(n)},fk=(t,e,[n,i,r]=[0,0,1],s=!1,o=!1,l=[0,0])=>{const a={x:(e.x-n)/r,y:(e.y-i)/r,width:e.width/r,height:e.height/r},u=[];return t.forEach(c=>{const{width:h,height:f,selectable:d=!0,hidden:p=!1}=c;if(o&&!d||p)return!1;const{positionAbsolute:g}=vs(c,l),x={x:g.x,y:g.y,width:h||0,height:f||0},m=gd(a,x),v=typeof h>"u"||typeof f>"u"||h===null||f===null,w=s&&m>0,k=(h||0)*(f||0);(v||w||m>=k||c.dragging)&&u.push(c)}),u},dk=(t,e)=>{const n=t.map(i=>i.id);return e.filter(i=>n.includes(i.source)||n.includes(i.target))},pk=(t,e,n,i,r,s=.1)=>{const o=e/(t.width*(1+s)),l=n/(t.height*(1+s)),a=Math.min(o,l),u=Ls(a,i,r),c=t.x+t.width/2,h=t.y+t.height/2,f=e/2-c*u,d=n/2-h*u;return{x:f,y:d,zoom:u}},sr=(t,e=0)=>t.transition().duration(e);function J0(t,e,n,i){return(e[n]||[]).reduce((r,s)=>{var o,l;return`${t.id}-${s.id}-${n}`!==i&&r.push({id:s.id||null,type:n,nodeId:t.id,x:(((o=t.positionAbsolute)==null?void 0:o.x)??0)+s.x+s.width/2,y:(((l=t.positionAbsolute)==null?void 0:l.y)??0)+s.y+s.height/2}),r},[])}function $O(t,e,n,i,r,s){const{x:o,y:l}=Bi(t),u=e.elementsFromPoint(o,l).find(p=>p.classList.contains("react-flow__handle"));if(u){const p=u.getAttribute("data-nodeid");if(p){const g=Cm(void 0,u),x=u.getAttribute("data-handleid"),m=s({nodeId:p,id:x,type:g});if(m){const v=r.find(w=>w.nodeId===p&&w.type===g&&w.id===x);return{handle:{id:x,type:g,nodeId:p,x:(v==null?void 0:v.x)||n.x,y:(v==null?void 0:v.y)||n.y},validHandleResult:m}}}}let c=[],h=1/0;if(r.forEach(p=>{const g=Math.sqrt((p.x-n.x)**2+(p.y-n.y)**2);if(g<=i){const x=s(p);g<=h&&(g<h?c=[{handle:p,validHandleResult:x}]:g===h&&c.push({handle:p,validHandleResult:x}),h=g)}}),!c.length)return{handle:null,validHandleResult:mk()};if(c.length===1)return c[0];const f=c.some(({validHandleResult:p})=>p.isValid),d=c.some(({handle:p})=>p.type==="target");return c.find(({handle:p,validHandleResult:g})=>d?p.type==="target":f?g.isValid:!0)||c[0]}const zO={source:null,target:null,sourceHandle:null,targetHandle:null},mk=()=>({handleDomNode:null,isValid:!1,connection:zO,endHandle:null});function gk(t,e,n,i,r,s,o){const l=r==="target",a=o.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),u={...mk(),handleDomNode:a};if(a){const c=Cm(void 0,a),h=a.getAttribute("data-nodeid"),f=a.getAttribute("data-handleid"),d=a.classList.contains("connectable"),p=a.classList.contains("connectableend"),g={source:l?h:n,sourceHandle:l?f:i,target:l?n:h,targetHandle:l?i:f};u.connection=g,d&&p&&(e===_r.Strict?l&&c==="source"||!l&&c==="target":h!==n||f!==i)&&(u.endHandle={nodeId:h,handleId:f,type:c},u.isValid=s(g))}return u}function FO({nodes:t,nodeId:e,handleId:n,handleType:i}){return t.reduce((r,s)=>{if(s[Te]){const{handleBounds:o}=s[Te];let l=[],a=[];o&&(l=J0(s,o,"source",`${e}-${n}-${i}`),a=J0(s,o,"target",`${e}-${n}-${i}`)),r.push(...l,...a)}return r},[])}function Cm(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Dh(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function VO(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function yk({event:t,handleId:e,nodeId:n,onConnect:i,isTarget:r,getState:s,setState:o,isValidConnection:l,edgeUpdaterType:a,onReconnectEnd:u}){const c=sk(t.target),{connectionMode:h,domNode:f,autoPanOnConnect:d,connectionRadius:p,onConnectStart:g,panBy:x,getNodes:m,cancelConnection:v}=s();let w=0,k;const{x:S,y:_}=Bi(t),E=c==null?void 0:c.elementFromPoint(S,_),A=Cm(a,E),I=f==null?void 0:f.getBoundingClientRect();if(!I||!A)return;let R,O=Bi(t,I),D=!1,$=null,b=!1,C=null;const N=FO({nodes:m(),nodeId:n,handleId:e,handleType:A}),j=()=>{if(!d)return;const[B,F]=rk(O,I);x({x:B,y:F}),w=requestAnimationFrame(j)};o({connectionPosition:O,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:A,connectionStartHandle:{nodeId:n,handleId:e,type:A},connectionEndHandle:null}),g==null||g(t,{nodeId:n,handleId:e,handleType:A});function P(B){const{transform:F}=s();O=Bi(B,I);const{handle:z,validHandleResult:L}=$O(B,c,xd(O,F,!1,[1,1]),p,N,H=>gk(H,h,n,e,r?"target":"source",l,c));if(k=z,D||(j(),D=!0),C=L.handleDomNode,$=L.connection,b=L.isValid,o({connectionPosition:k&&b?hk({x:k.x,y:k.y},F):O,connectionStatus:VO(!!k,b),connectionEndHandle:L.endHandle}),!k&&!b&&!C)return Dh(R);$.source!==$.target&&C&&(Dh(R),R=C,C.classList.add("connecting","react-flow__handle-connecting"),C.classList.toggle("valid",b),C.classList.toggle("react-flow__handle-valid",b))}function T(B){var F,z;(k||C)&&$&&b&&(i==null||i($)),(z=(F=s()).onConnectEnd)==null||z.call(F,B),a&&(u==null||u(B)),Dh(R),v(),cancelAnimationFrame(w),D=!1,b=!1,$=null,C=null,c.removeEventListener("mousemove",P),c.removeEventListener("mouseup",T),c.removeEventListener("touchmove",P),c.removeEventListener("touchend",T)}c.addEventListener("mousemove",P),c.addEventListener("mouseup",T),c.addEventListener("touchmove",P),c.addEventListener("touchend",T)}const Z0=()=>!0,HO=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),WO=(t,e,n)=>i=>{const{connectionStartHandle:r,connectionEndHandle:s,connectionClickStartHandle:o}=i;return{connecting:(r==null?void 0:r.nodeId)===t&&(r==null?void 0:r.handleId)===e&&(r==null?void 0:r.type)===n||(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===n,clickConnecting:(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.handleId)===e&&(o==null?void 0:o.type)===n}},vk=M.forwardRef(({type:t="source",position:e=G.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:o,onConnect:l,children:a,className:u,onMouseDown:c,onTouchStart:h,...f},d)=>{var I,R;const p=o||null,g=t==="target",x=Ke(),m=RO(),{connectOnClick:v,noPanClassName:w}=Ce(HO,at),{connecting:k,clickConnecting:S}=Ce(WO(m,p,t),at);m||(R=(I=x.getState()).onError)==null||R.call(I,"010",li.error010());const _=O=>{const{defaultEdgeOptions:D,onConnect:$,hasDefaultEdges:b}=x.getState(),C={...D,...O};if(b){const{edges:N,setEdges:j}=x.getState();j(jO(C,N))}$==null||$(C),l==null||l(C)},E=O=>{if(!m)return;const D=lk(O);r&&(D&&O.button===0||!D)&&yk({event:O,handleId:p,nodeId:m,onConnect:_,isTarget:g,getState:x.getState,setState:x.setState,isValidConnection:n||x.getState().isValidConnection||Z0}),D?c==null||c(O):h==null||h(O)},A=O=>{const{onClickConnectStart:D,onClickConnectEnd:$,connectionClickStartHandle:b,connectionMode:C,isValidConnection:N}=x.getState();if(!m||!b&&!r)return;if(!b){D==null||D(O,{nodeId:m,handleId:p,handleType:t}),x.setState({connectionClickStartHandle:{nodeId:m,type:t,handleId:p}});return}const j=sk(O.target),P=n||N||Z0,{connection:T,isValid:B}=gk({nodeId:m,id:p,type:t},C,b.nodeId,b.handleId||null,b.type,P,j);B&&_(T),$==null||$(O),x.setState({connectionClickStartHandle:null})};return V.createElement("div",{"data-handleid":p,"data-nodeid":m,"data-handlepos":e,"data-id":`${m}-${p}-${t}`,className:vt(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",w,u,{source:!g,target:g,connectable:i,connectablestart:r,connectableend:s,connecting:S,connectionindicator:i&&(r&&!k||s&&k)}]),onMouseDown:E,onTouchStart:E,onClick:v?A:void 0,ref:d,...f},a)});vk.displayName="Handle";var Bs=M.memo(vk);const wk=({data:t,isConnectable:e,targetPosition:n=G.Top,sourcePosition:i=G.Bottom})=>V.createElement(V.Fragment,null,V.createElement(Bs,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,V.createElement(Bs,{type:"source",position:i,isConnectable:e}));wk.displayName="DefaultNode";var kd=M.memo(wk);const xk=({data:t,isConnectable:e,sourcePosition:n=G.Bottom})=>V.createElement(V.Fragment,null,t==null?void 0:t.label,V.createElement(Bs,{type:"source",position:n,isConnectable:e}));xk.displayName="InputNode";var kk=M.memo(xk);const Sk=({data:t,isConnectable:e,targetPosition:n=G.Top})=>V.createElement(V.Fragment,null,V.createElement(Bs,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);Sk.displayName="OutputNode";var bk=M.memo(Sk);const Em=()=>null;Em.displayName="GroupNode";const UO=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),va=t=>t.id;function qO(t,e){return at(t.selectedNodes.map(va),e.selectedNodes.map(va))&&at(t.selectedEdges.map(va),e.selectedEdges.map(va))}const Ck=M.memo(({onSelectionChange:t})=>{const e=Ke(),{selectedNodes:n,selectedEdges:i}=Ce(UO,qO);return M.useEffect(()=>{const r={nodes:n,edges:i};t==null||t(r),e.getState().onSelectionChange.forEach(s=>s(r))},[n,i,t]),null});Ck.displayName="SelectionListener";const KO=t=>!!t.onSelectionChange;function QO({onSelectionChange:t}){const e=Ce(KO);return t||e?V.createElement(Ck,{onSelectionChange:t}):null}const YO=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function zr(t,e){M.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function re(t,e,n){M.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const XO=({nodes:t,edges:e,defaultNodes:n,defaultEdges:i,onConnect:r,onConnectStart:s,onConnectEnd:o,onClickConnectStart:l,onClickConnectEnd:a,nodesDraggable:u,nodesConnectable:c,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:d,elevateNodesOnSelect:p,minZoom:g,maxZoom:x,nodeExtent:m,onNodesChange:v,onEdgesChange:w,elementsSelectable:k,connectionMode:S,snapGrid:_,snapToGrid:E,translateExtent:A,connectOnClick:I,defaultEdgeOptions:R,fitView:O,fitViewOptions:D,onNodesDelete:$,onEdgesDelete:b,onNodeDrag:C,onNodeDragStart:N,onNodeDragStop:j,onSelectionDrag:P,onSelectionDragStart:T,onSelectionDragStop:B,noPanClassName:F,nodeOrigin:z,rfId:L,autoPanOnConnect:H,autoPanOnNodeDrag:q,onError:ee,connectionRadius:J,isValidConnection:he,nodeDragThreshold:we})=>{const{setNodes:pe,setEdges:ie,setDefaultNodesAndEdges:He,setMinZoom:ct,setMaxZoom:Qe,setTranslateExtent:je,setNodeExtent:Sn,reset:xe}=Ce(YO,at),te=Ke();return M.useEffect(()=>{const Tt=i==null?void 0:i.map(Yi=>({...Yi,...R}));return He(n,Tt),()=>{xe()}},[]),re("defaultEdgeOptions",R,te.setState),re("connectionMode",S,te.setState),re("onConnect",r,te.setState),re("onConnectStart",s,te.setState),re("onConnectEnd",o,te.setState),re("onClickConnectStart",l,te.setState),re("onClickConnectEnd",a,te.setState),re("nodesDraggable",u,te.setState),re("nodesConnectable",c,te.setState),re("nodesFocusable",h,te.setState),re("edgesFocusable",f,te.setState),re("edgesUpdatable",d,te.setState),re("elementsSelectable",k,te.setState),re("elevateNodesOnSelect",p,te.setState),re("snapToGrid",E,te.setState),re("snapGrid",_,te.setState),re("onNodesChange",v,te.setState),re("onEdgesChange",w,te.setState),re("connectOnClick",I,te.setState),re("fitViewOnInit",O,te.setState),re("fitViewOnInitOptions",D,te.setState),re("onNodesDelete",$,te.setState),re("onEdgesDelete",b,te.setState),re("onNodeDrag",C,te.setState),re("onNodeDragStart",N,te.setState),re("onNodeDragStop",j,te.setState),re("onSelectionDrag",P,te.setState),re("onSelectionDragStart",T,te.setState),re("onSelectionDragStop",B,te.setState),re("noPanClassName",F,te.setState),re("nodeOrigin",z,te.setState),re("rfId",L,te.setState),re("autoPanOnConnect",H,te.setState),re("autoPanOnNodeDrag",q,te.setState),re("onError",ee,te.setState),re("connectionRadius",J,te.setState),re("isValidConnection",he,te.setState),re("nodeDragThreshold",we,te.setState),zr(t,pe),zr(e,ie),zr(g,ct),zr(x,Qe),zr(A,je),zr(m,Sn),null},ey={display:"none"},GO={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ek="react-flow__node-desc",_k="react-flow__edge-desc",JO="react-flow__aria-live",ZO=t=>t.ariaLiveMessage;function eI({rfId:t}){const e=Ce(ZO);return V.createElement("div",{id:`${JO}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:GO},e)}function tI({rfId:t,disableKeyboardA11y:e}){return V.createElement(V.Fragment,null,V.createElement("div",{id:`${Ek}-${t}`,style:ey},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),V.createElement("div",{id:`${_k}-${t}`,style:ey},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&V.createElement(eI,{rfId:t}))}var kl=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,i]=M.useState(!1),r=M.useRef(!1),s=M.useRef(new Set([])),[o,l]=M.useMemo(()=>{if(t!==null){const u=(Array.isArray(t)?t:[t]).filter(h=>typeof h=="string").map(h=>h.split("+")),c=u.reduce((h,f)=>h.concat(...f),[]);return[u,c]}return[[],[]]},[t]);return M.useEffect(()=>{const a=typeof document<"u"?document:null,u=(e==null?void 0:e.target)||a;if(t!==null){const c=d=>{if(r.current=d.ctrlKey||d.metaKey||d.shiftKey,(!r.current||r.current&&!e.actInsideInputWithModifier)&&yd(d))return!1;const g=ny(d.code,l);s.current.add(d[g]),ty(o,s.current,!1)&&(d.preventDefault(),i(!0))},h=d=>{if((!r.current||r.current&&!e.actInsideInputWithModifier)&&yd(d))return!1;const g=ny(d.code,l);ty(o,s.current,!0)?(i(!1),s.current.clear()):s.current.delete(d[g]),d.key==="Meta"&&s.current.clear(),r.current=!1},f=()=>{s.current.clear(),i(!1)};return u==null||u.addEventListener("keydown",c),u==null||u.addEventListener("keyup",h),window.addEventListener("blur",f),()=>{u==null||u.removeEventListener("keydown",c),u==null||u.removeEventListener("keyup",h),window.removeEventListener("blur",f)}}},[t,i]),n};function ty(t,e,n){return t.filter(i=>n||i.length===e.size).some(i=>i.every(r=>e.has(r)))}function ny(t,e){return e.includes(t)?"code":"key"}function Nk(t,e,n,i){var l,a;const r=t.parentNode||t.parentId;if(!r)return n;const s=e.get(r),o=vs(s,i);return Nk(s,e,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(((l=s[Te])==null?void 0:l.z)??0)>(n.z??0)?((a=s[Te])==null?void 0:a.z)??0:n.z??0},i)}function Ak(t,e,n){t.forEach(i=>{var s;const r=i.parentNode||i.parentId;if(r&&!t.has(r))throw new Error(`Parent node ${r} not found`);if(r||n!=null&&n[i.id]){const{x:o,y:l,z:a}=Nk(i,t,{...i.position,z:((s=i[Te])==null?void 0:s.z)??0},e);i.positionAbsolute={x:o,y:l},i[Te].z=a,n!=null&&n[i.id]&&(i[Te].isParent=!0)}})}function Lh(t,e,n,i){const r=new Map,s={},o=i?1e3:0;return t.forEach(l=>{var d;const a=(qt(l.zIndex)?l.zIndex:0)+(l.selected?o:0),u=e.get(l.id),c={...l,positionAbsolute:{x:l.position.x,y:l.position.y}},h=l.parentNode||l.parentId;h&&(s[h]=!0);const f=(u==null?void 0:u.type)&&(u==null?void 0:u.type)!==l.type;Object.defineProperty(c,Te,{enumerable:!1,value:{handleBounds:f||(d=u==null?void 0:u[Te])==null?void 0:d.handleBounds,z:a}}),r.set(l.id,c)}),Ak(r,n,s),r}function Mk(t,e={}){const{getNodes:n,width:i,height:r,minZoom:s,maxZoom:o,d3Zoom:l,d3Selection:a,fitViewOnInitDone:u,fitViewOnInit:c,nodeOrigin:h}=t(),f=e.initial&&!u&&c;if(l&&a&&(f||!e.initial)){const p=n().filter(x=>{var v;const m=e.includeHiddenNodes?x.width&&x.height:!x.hidden;return(v=e.nodes)!=null&&v.length?m&&e.nodes.some(w=>w.id===x.id):m}),g=p.every(x=>x.width&&x.height);if(p.length>0&&g){const x=bm(p,h),{x:m,y:v,zoom:w}=pk(x,i,r,e.minZoom??s,e.maxZoom??o,e.padding??.1),k=Li.translate(m,v).scale(w);return typeof e.duration=="number"&&e.duration>0?l.transform(sr(a,e.duration),k):l.transform(a,k),!0}}return!1}function nI(t,e){return t.forEach(n=>{const i=e.get(n.id);i&&e.set(i.id,{...i,[Te]:i[Te],selected:n.selected})}),new Map(e)}function iI(t,e){return e.map(n=>{const i=t.find(r=>r.id===n.id);return i&&(n.selected=i.selected),n})}function wa({changedNodes:t,changedEdges:e,get:n,set:i}){const{nodeInternals:r,edges:s,onNodesChange:o,onEdgesChange:l,hasDefaultNodes:a,hasDefaultEdges:u}=n();t!=null&&t.length&&(a&&i({nodeInternals:nI(t,r)}),o==null||o(t)),e!=null&&e.length&&(u&&i({edges:iI(e,s)}),l==null||l(e))}const Fr=()=>{},rI={zoomIn:Fr,zoomOut:Fr,zoomTo:Fr,getZoom:()=>1,setViewport:Fr,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Fr,fitBounds:Fr,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},sI=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),oI=()=>{const t=Ke(),{d3Zoom:e,d3Selection:n}=Ce(sI,at);return M.useMemo(()=>n&&e?{zoomIn:r=>e.scaleBy(sr(n,r==null?void 0:r.duration),1.2),zoomOut:r=>e.scaleBy(sr(n,r==null?void 0:r.duration),1/1.2),zoomTo:(r,s)=>e.scaleTo(sr(n,s==null?void 0:s.duration),r),getZoom:()=>t.getState().transform[2],setViewport:(r,s)=>{const[o,l,a]=t.getState().transform,u=Li.translate(r.x??o,r.y??l).scale(r.zoom??a);e.transform(sr(n,s==null?void 0:s.duration),u)},getViewport:()=>{const[r,s,o]=t.getState().transform;return{x:r,y:s,zoom:o}},fitView:r=>Mk(t.getState,r),setCenter:(r,s,o)=>{const{width:l,height:a,maxZoom:u}=t.getState(),c=typeof(o==null?void 0:o.zoom)<"u"?o.zoom:u,h=l/2-r*c,f=a/2-s*c,d=Li.translate(h,f).scale(c);e.transform(sr(n,o==null?void 0:o.duration),d)},fitBounds:(r,s)=>{const{width:o,height:l,minZoom:a,maxZoom:u}=t.getState(),{x:c,y:h,zoom:f}=pk(r,o,l,a,u,(s==null?void 0:s.padding)??.1),d=Li.translate(c,h).scale(f);e.transform(sr(n,s==null?void 0:s.duration),d)},project:r=>{const{transform:s,snapToGrid:o,snapGrid:l}=t.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),xd(r,s,o,l)},screenToFlowPosition:r=>{const{transform:s,snapToGrid:o,snapGrid:l,domNode:a}=t.getState();if(!a)return r;const{x:u,y:c}=a.getBoundingClientRect(),h={x:r.x-u,y:r.y-c};return xd(h,s,o,l)},flowToScreenPosition:r=>{const{transform:s,domNode:o}=t.getState();if(!o)return r;const{x:l,y:a}=o.getBoundingClientRect(),u=hk(r,s);return{x:u.x+l,y:u.y+a}},viewportInitialized:!0}:rI,[e,n])};function jc(){const t=oI(),e=Ke(),n=M.useCallback(()=>e.getState().getNodes().map(g=>({...g})),[]),i=M.useCallback(g=>e.getState().nodeInternals.get(g),[]),r=M.useCallback(()=>{const{edges:g=[]}=e.getState();return g.map(x=>({...x}))},[]),s=M.useCallback(g=>{const{edges:x=[]}=e.getState();return x.find(m=>m.id===g)},[]),o=M.useCallback(g=>{const{getNodes:x,setNodes:m,hasDefaultNodes:v,onNodesChange:w}=e.getState(),k=x(),S=typeof g=="function"?g(k):g;if(v)m(S);else if(w){const _=S.length===0?k.map(E=>({type:"remove",id:E.id})):S.map(E=>({item:E,type:"reset"}));w(_)}},[]),l=M.useCallback(g=>{const{edges:x=[],setEdges:m,hasDefaultEdges:v,onEdgesChange:w}=e.getState(),k=typeof g=="function"?g(x):g;if(v)m(k);else if(w){const S=k.length===0?x.map(_=>({type:"remove",id:_.id})):k.map(_=>({item:_,type:"reset"}));w(S)}},[]),a=M.useCallback(g=>{const x=Array.isArray(g)?g:[g],{getNodes:m,setNodes:v,hasDefaultNodes:w,onNodesChange:k}=e.getState();if(w){const _=[...m(),...x];v(_)}else if(k){const S=x.map(_=>({item:_,type:"add"}));k(S)}},[]),u=M.useCallback(g=>{const x=Array.isArray(g)?g:[g],{edges:m=[],setEdges:v,hasDefaultEdges:w,onEdgesChange:k}=e.getState();if(w)v([...m,...x]);else if(k){const S=x.map(_=>({item:_,type:"add"}));k(S)}},[]),c=M.useCallback(()=>{const{getNodes:g,edges:x=[],transform:m}=e.getState(),[v,w,k]=m;return{nodes:g().map(S=>({...S})),edges:x.map(S=>({...S})),viewport:{x:v,y:w,zoom:k}}},[]),h=M.useCallback(({nodes:g,edges:x})=>{const{nodeInternals:m,getNodes:v,edges:w,hasDefaultNodes:k,hasDefaultEdges:S,onNodesDelete:_,onEdgesDelete:E,onNodesChange:A,onEdgesChange:I}=e.getState(),R=(g||[]).map(C=>C.id),O=(x||[]).map(C=>C.id),D=v().reduce((C,N)=>{const j=N.parentNode||N.parentId,P=!R.includes(N.id)&&j&&C.find(B=>B.id===j);return(typeof N.deletable=="boolean"?N.deletable:!0)&&(R.includes(N.id)||P)&&C.push(N),C},[]),$=w.filter(C=>typeof C.deletable=="boolean"?C.deletable:!0),b=$.filter(C=>O.includes(C.id));if(D||b){const C=dk(D,$),N=[...b,...C],j=N.reduce((P,T)=>(P.includes(T.id)||P.push(T.id),P),[]);if((S||k)&&(S&&e.setState({edges:w.filter(P=>!j.includes(P.id))}),k&&(D.forEach(P=>{m.delete(P.id)}),e.setState({nodeInternals:new Map(m)}))),j.length>0&&(E==null||E(N),I&&I(j.map(P=>({id:P,type:"remove"})))),D.length>0&&(_==null||_(D),A)){const P=D.map(T=>({id:T.id,type:"remove"}));A(P)}}},[]),f=M.useCallback(g=>{const x=_O(g),m=x?null:e.getState().nodeInternals.get(g.id);return!x&&!m?[null,null,x]:[x?g:K0(m),m,x]},[]),d=M.useCallback((g,x=!0,m)=>{const[v,w,k]=f(g);return v?(m||e.getState().getNodes()).filter(S=>{if(!k&&(S.id===w.id||!S.positionAbsolute))return!1;const _=K0(S),E=gd(_,v);return x&&E>0||E>=v.width*v.height}):[]},[]),p=M.useCallback((g,x,m=!0)=>{const[v]=f(g);if(!v)return!1;const w=gd(v,x);return m&&w>0||w>=v.width*v.height},[]);return M.useMemo(()=>({...t,getNodes:n,getNode:i,getEdges:r,getEdge:s,setNodes:o,setEdges:l,addNodes:a,addEdges:u,toObject:c,deleteElements:h,getIntersectingNodes:d,isNodeIntersecting:p}),[t,n,i,r,s,o,l,a,u,c,h,d,p])}const lI={actInsideInputWithModifier:!1};var aI=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=Ke(),{deleteElements:i}=jc(),r=kl(t,lI),s=kl(e);M.useEffect(()=>{if(r){const{edges:o,getNodes:l}=n.getState(),a=l().filter(c=>c.selected),u=o.filter(c=>c.selected);i({nodes:a,edges:u}),n.setState({nodesSelectionActive:!1})}},[r]),M.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function uI(t){const e=Ke();M.useEffect(()=>{let n;const i=()=>{var s,o;if(!t.current)return;const r=mm(t.current);(r.height===0||r.width===0)&&((o=(s=e.getState()).onError)==null||o.call(s,"004",li.error004())),e.setState({width:r.width||500,height:r.height||500})};return i(),window.addEventListener("resize",i),t.current&&(n=new ResizeObserver(()=>i()),n.observe(t.current)),()=>{window.removeEventListener("resize",i),n&&t.current&&n.unobserve(t.current)}},[])}const _m={position:"absolute",width:"100%",height:"100%",top:0,left:0},cI=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,xa=t=>({x:t.x,y:t.y,zoom:t.k}),Vr=(t,e)=>t.target.closest(`.${e}`),iy=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),ry=t=>{const e=t.ctrlKey&&Hu()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},hI=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),fI=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:i,zoomOnScroll:r=!0,zoomOnPinch:s=!0,panOnScroll:o=!1,panOnScrollSpeed:l=.5,panOnScrollMode:a=dr.Free,zoomOnDoubleClick:u=!0,elementsSelectable:c,panOnDrag:h=!0,defaultViewport:f,translateExtent:d,minZoom:p,maxZoom:g,zoomActivationKeyCode:x,preventScrolling:m=!0,children:v,noWheelClassName:w,noPanClassName:k})=>{const S=M.useRef(),_=Ke(),E=M.useRef(!1),A=M.useRef(!1),I=M.useRef(null),R=M.useRef({x:0,y:0,zoom:0}),{d3Zoom:O,d3Selection:D,d3ZoomHandler:$,userSelectionActive:b}=Ce(hI,at),C=kl(x),N=M.useRef(0),j=M.useRef(!1),P=M.useRef();return uI(I),M.useEffect(()=>{if(I.current){const T=I.current.getBoundingClientRect(),B=vO().scaleExtent([p,g]).translateExtent(d),F=un(I.current).call(B),z=Li.translate(f.x,f.y).scale(Ls(f.zoom,p,g)),L=[[0,0],[T.width,T.height]],H=B.constrain()(z,L,d);B.transform(F,H),B.wheelDelta(ry),_.setState({d3Zoom:B,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[H.x,H.y,H.k],domNode:I.current.closest(".react-flow")})}},[]),M.useEffect(()=>{D&&O&&(o&&!C&&!b?D.on("wheel.zoom",T=>{if(Vr(T,w))return!1;T.preventDefault(),T.stopImmediatePropagation();const B=D.property("__zoom").k||1;if(T.ctrlKey&&s){const he=Tn(T),we=ry(T),pe=B*Math.pow(2,we);O.scaleTo(D,pe,he,T);return}const F=T.deltaMode===1?20:1;let z=a===dr.Vertical?0:T.deltaX*F,L=a===dr.Horizontal?0:T.deltaY*F;!Hu()&&T.shiftKey&&a!==dr.Vertical&&(z=T.deltaY*F,L=0),O.translateBy(D,-(z/B)*l,-(L/B)*l,{internal:!0});const H=xa(D.property("__zoom")),{onViewportChangeStart:q,onViewportChange:ee,onViewportChangeEnd:J}=_.getState();clearTimeout(P.current),j.current||(j.current=!0,e==null||e(T,H),q==null||q(H)),j.current&&(t==null||t(T,H),ee==null||ee(H),P.current=setTimeout(()=>{n==null||n(T,H),J==null||J(H),j.current=!1},150))},{passive:!1}):typeof $<"u"&&D.on("wheel.zoom",function(T,B){if(!m&&T.type==="wheel"&&!T.ctrlKey||Vr(T,w))return null;T.preventDefault(),$.call(this,T,B)},{passive:!1}))},[b,o,a,D,O,$,C,s,m,w,e,t,n]),M.useEffect(()=>{O&&O.on("start",T=>{var z,L;if(!T.sourceEvent||T.sourceEvent.internal)return null;N.current=(z=T.sourceEvent)==null?void 0:z.button;const{onViewportChangeStart:B}=_.getState(),F=xa(T.transform);E.current=!0,R.current=F,((L=T.sourceEvent)==null?void 0:L.type)==="mousedown"&&_.setState({paneDragging:!0}),B==null||B(F),e==null||e(T.sourceEvent,F)})},[O,e]),M.useEffect(()=>{O&&(b&&!E.current?O.on("zoom",null):b||O.on("zoom",T=>{var F;const{onViewportChange:B}=_.getState();if(_.setState({transform:[T.transform.x,T.transform.y,T.transform.k]}),A.current=!!(i&&iy(h,N.current??0)),(t||B)&&!((F=T.sourceEvent)!=null&&F.internal)){const z=xa(T.transform);B==null||B(z),t==null||t(T.sourceEvent,z)}}))},[b,O,t,h,i]),M.useEffect(()=>{O&&O.on("end",T=>{if(!T.sourceEvent||T.sourceEvent.internal)return null;const{onViewportChangeEnd:B}=_.getState();if(E.current=!1,_.setState({paneDragging:!1}),i&&iy(h,N.current??0)&&!A.current&&i(T.sourceEvent),A.current=!1,(n||B)&&cI(R.current,T.transform)){const F=xa(T.transform);R.current=F,clearTimeout(S.current),S.current=setTimeout(()=>{B==null||B(F),n==null||n(T.sourceEvent,F)},o?150:0)}})},[O,o,h,n,i]),M.useEffect(()=>{O&&O.filter(T=>{const B=C||r,F=s&&T.ctrlKey;if((h===!0||Array.isArray(h)&&h.includes(1))&&T.button===1&&T.type==="mousedown"&&(Vr(T,"react-flow__node")||Vr(T,"react-flow__edge")))return!0;if(!h&&!B&&!o&&!u&&!s||b||!u&&T.type==="dblclick"||Vr(T,w)&&T.type==="wheel"||Vr(T,k)&&(T.type!=="wheel"||o&&T.type==="wheel"&&!C)||!s&&T.ctrlKey&&T.type==="wheel"||!B&&!o&&!F&&T.type==="wheel"||!h&&(T.type==="mousedown"||T.type==="touchstart")||Array.isArray(h)&&!h.includes(T.button)&&T.type==="mousedown")return!1;const z=Array.isArray(h)&&h.includes(T.button)||!T.button||T.button<=1;return(!T.ctrlKey||T.type==="wheel")&&z})},[b,O,r,s,o,u,h,c,C]),V.createElement("div",{className:"react-flow__renderer",ref:I,style:_m},v)},dI=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function pI(){const{userSelectionActive:t,userSelectionRect:e}=Ce(dI,at);return t&&e?V.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function sy(t,e){const n=e.parentNode||e.parentId,i=t.find(r=>r.id===n);if(i){const r=e.position.x+e.width-i.width,s=e.position.y+e.height-i.height;if(r>0||s>0||e.position.x<0||e.position.y<0){if(i.style={...i.style},i.style.width=i.style.width??i.width,i.style.height=i.style.height??i.height,r>0&&(i.style.width+=r),s>0&&(i.style.height+=s),e.position.x<0){const o=Math.abs(e.position.x);i.position.x=i.position.x-o,i.style.width+=o,e.position.x=0}if(e.position.y<0){const o=Math.abs(e.position.y);i.position.y=i.position.y-o,i.style.height+=o,e.position.y=0}i.width=i.style.width,i.height=i.style.height}}}function mI(t,e){if(t.some(i=>i.type==="reset"))return t.filter(i=>i.type==="reset").map(i=>i.item);const n=t.filter(i=>i.type==="add").map(i=>i.item);return e.reduce((i,r)=>{const s=t.filter(l=>l.id===r.id);if(s.length===0)return i.push(r),i;const o={...r};for(const l of s)if(l)switch(l.type){case"select":{o.selected=l.selected;break}case"position":{typeof l.position<"u"&&(o.position=l.position),typeof l.positionAbsolute<"u"&&(o.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(o.dragging=l.dragging),o.expandParent&&sy(i,o);break}case"dimensions":{typeof l.dimensions<"u"&&(o.width=l.dimensions.width,o.height=l.dimensions.height),typeof l.updateStyle<"u"&&(o.style={...o.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(o.resizing=l.resizing),o.expandParent&&sy(i,o);break}case"remove":return i}return i.push(o),i},n)}function gI(t,e){return mI(t,e)}const gi=(t,e)=>({id:t,type:"select",selected:e});function rs(t,e){return t.reduce((n,i)=>{const r=e.includes(i.id);return!i.selected&&r?(i.selected=!0,n.push(gi(i.id,!0))):i.selected&&!r&&(i.selected=!1,n.push(gi(i.id,!1))),n},[])}const Bh=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},yI=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),Tk=M.memo(({isSelecting:t,selectionMode:e=wl.Full,panOnDrag:n,onSelectionStart:i,onSelectionEnd:r,onPaneClick:s,onPaneContextMenu:o,onPaneScroll:l,onPaneMouseEnter:a,onPaneMouseMove:u,onPaneMouseLeave:c,children:h})=>{const f=M.useRef(null),d=Ke(),p=M.useRef(0),g=M.useRef(0),x=M.useRef(),{userSelectionActive:m,elementsSelectable:v,dragging:w}=Ce(yI,at),k=()=>{d.setState({userSelectionActive:!1,userSelectionRect:null}),p.current=0,g.current=0},S=$=>{s==null||s($),d.getState().resetSelectedElements(),d.setState({nodesSelectionActive:!1})},_=$=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){$.preventDefault();return}o==null||o($)},E=l?$=>l($):void 0,A=$=>{const{resetSelectedElements:b,domNode:C}=d.getState();if(x.current=C==null?void 0:C.getBoundingClientRect(),!v||!t||$.button!==0||$.target!==f.current||!x.current)return;const{x:N,y:j}=Bi($,x.current);b(),d.setState({userSelectionRect:{width:0,height:0,startX:N,startY:j,x:N,y:j}}),i==null||i($)},I=$=>{const{userSelectionRect:b,nodeInternals:C,edges:N,transform:j,onNodesChange:P,onEdgesChange:T,nodeOrigin:B,getNodes:F}=d.getState();if(!t||!x.current||!b)return;d.setState({userSelectionActive:!0,nodesSelectionActive:!1});const z=Bi($,x.current),L=b.startX??0,H=b.startY??0,q={...b,x:z.x<L?z.x:L,y:z.y<H?z.y:H,width:Math.abs(z.x-L),height:Math.abs(z.y-H)},ee=F(),J=fk(C,q,j,e===wl.Partial,!0,B),he=dk(J,N).map(pe=>pe.id),we=J.map(pe=>pe.id);if(p.current!==we.length){p.current=we.length;const pe=rs(ee,we);pe.length&&(P==null||P(pe))}if(g.current!==he.length){g.current=he.length;const pe=rs(N,he);pe.length&&(T==null||T(pe))}d.setState({userSelectionRect:q})},R=$=>{if($.button!==0)return;const{userSelectionRect:b}=d.getState();!m&&b&&$.target===f.current&&(S==null||S($)),d.setState({nodesSelectionActive:p.current>0}),k(),r==null||r($)},O=$=>{m&&(d.setState({nodesSelectionActive:p.current>0}),r==null||r($)),k()},D=v&&(t||m);return V.createElement("div",{className:vt(["react-flow__pane",{dragging:w,selection:t}]),onClick:D?void 0:Bh(S,f),onContextMenu:Bh(_,f),onWheel:Bh(E,f),onMouseEnter:D?void 0:a,onMouseDown:D?A:void 0,onMouseMove:D?I:u,onMouseUp:D?R:void 0,onMouseLeave:D?O:c,ref:f,style:_m},h,V.createElement(pI,null))});Tk.displayName="Pane";function Ok(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const i=e.get(n);return i?i.selected?!0:Ok(i,e):!1}function oy(t,e,n){let i=t;do{if(i!=null&&i.matches(e))return!0;if(i===n.current)return!1;i=i.parentElement}while(i);return!1}function vI(t,e,n,i){return Array.from(t.values()).filter(r=>(r.selected||r.id===i)&&(!r.parentNode||r.parentId||!Ok(r,t))&&(r.draggable||e&&typeof r.draggable>"u")).map(r=>{var s,o;return{id:r.id,position:r.position||{x:0,y:0},positionAbsolute:r.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((s=r.positionAbsolute)==null?void 0:s.x)??0),y:n.y-(((o=r.positionAbsolute)==null?void 0:o.y)??0)},delta:{x:0,y:0},extent:r.extent,parentNode:r.parentNode||r.parentId,parentId:r.parentNode||r.parentId,width:r.width,height:r.height,expandParent:r.expandParent}})}function wI(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function Ik(t,e,n,i,r=[0,0],s){const o=wI(t,t.extent||i);let l=o;const a=t.parentNode||t.parentId;if(t.extent==="parent"&&!t.expandParent)if(a&&t.width&&t.height){const h=n.get(a),{x:f,y:d}=vs(h,r).positionAbsolute;l=h&&qt(f)&&qt(d)&&qt(h.width)&&qt(h.height)?[[f+t.width*r[0],d+t.height*r[1]],[f+h.width-t.width+t.width*r[0],d+h.height-t.height+t.height*r[1]]]:l}else s==null||s("005",li.error005()),l=o;else if(t.extent&&a&&t.extent!=="parent"){const h=n.get(a),{x:f,y:d}=vs(h,r).positionAbsolute;l=[[t.extent[0][0]+f,t.extent[0][1]+d],[t.extent[1][0]+f,t.extent[1][1]+d]]}let u={x:0,y:0};if(a){const h=n.get(a);u=vs(h,r).positionAbsolute}const c=l&&l!=="parent"?gm(e,l):e;return{position:{x:c.x-u.x,y:c.y-u.y},positionAbsolute:c}}function jh({nodeId:t,dragItems:e,nodeInternals:n}){const i=e.map(r=>({...n.get(r.id),position:r.position,positionAbsolute:r.positionAbsolute}));return[t?i.find(r=>r.id===t):i[0],i]}const ly=(t,e,n,i)=>{const r=e.querySelectorAll(t);if(!r||!r.length)return null;const s=Array.from(r),o=e.getBoundingClientRect(),l={x:o.width*i[0],y:o.height*i[1]};return s.map(a=>{const u=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(u.left-o.left-l.x)/n,y:(u.top-o.top-l.y)/n,...mm(a)}})};function po(t,e,n){return n===void 0?n:i=>{const r=e().nodeInternals.get(t);r&&n(i,{...r})}}function Sd({id:t,store:e,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:o,nodeInternals:l,onError:a}=e.getState(),u=l.get(t);if(!u){a==null||a("012",li.error012(t));return}e.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var c;return(c=i==null?void 0:i.current)==null?void 0:c.blur()})):r([t])}function xI(){const t=Ke();return M.useCallback(({sourceEvent:n})=>{const{transform:i,snapGrid:r,snapToGrid:s}=t.getState(),o=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,a={x:(o-i[0])/i[2],y:(l-i[1])/i[2]};return{xSnapped:s?r[0]*Math.round(a.x/r[0]):a.x,ySnapped:s?r[1]*Math.round(a.y/r[1]):a.y,...a}},[])}function $h(t){return(e,n,i)=>t==null?void 0:t(e,i)}function Pk({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:s,selectNodesOnDrag:o}){const l=Ke(),[a,u]=M.useState(!1),c=M.useRef([]),h=M.useRef({x:null,y:null}),f=M.useRef(0),d=M.useRef(null),p=M.useRef({x:0,y:0}),g=M.useRef(null),x=M.useRef(!1),m=M.useRef(!1),v=M.useRef(!1),w=xI();return M.useEffect(()=>{if(t!=null&&t.current){const k=un(t.current),S=({x:A,y:I})=>{const{nodeInternals:R,onNodeDrag:O,onSelectionDrag:D,updateNodePositions:$,nodeExtent:b,snapGrid:C,snapToGrid:N,nodeOrigin:j,onError:P}=l.getState();h.current={x:A,y:I};let T=!1,B={x:0,y:0,x2:0,y2:0};if(c.current.length>1&&b){const z=bm(c.current,j);B=ym(z)}if(c.current=c.current.map(z=>{const L={x:A-z.distance.x,y:I-z.distance.y};N&&(L.x=C[0]*Math.round(L.x/C[0]),L.y=C[1]*Math.round(L.y/C[1]));const H=[[b[0][0],b[0][1]],[b[1][0],b[1][1]]];c.current.length>1&&b&&!z.extent&&(H[0][0]=z.positionAbsolute.x-B.x+b[0][0],H[1][0]=z.positionAbsolute.x+(z.width??0)-B.x2+b[1][0],H[0][1]=z.positionAbsolute.y-B.y+b[0][1],H[1][1]=z.positionAbsolute.y+(z.height??0)-B.y2+b[1][1]);const q=Ik(z,L,R,H,j,P);return T=T||z.position.x!==q.position.x||z.position.y!==q.position.y,z.position=q.position,z.positionAbsolute=q.positionAbsolute,z}),!T)return;$(c.current,!0,!0),u(!0);const F=r?O:$h(D);if(F&&g.current){const[z,L]=jh({nodeId:r,dragItems:c.current,nodeInternals:R});F(g.current,z,L)}},_=()=>{if(!d.current)return;const[A,I]=rk(p.current,d.current);if(A!==0||I!==0){const{transform:R,panBy:O}=l.getState();h.current.x=(h.current.x??0)-A/R[2],h.current.y=(h.current.y??0)-I/R[2],O({x:A,y:I})&&S(h.current)}f.current=requestAnimationFrame(_)},E=A=>{var j;const{nodeInternals:I,multiSelectionActive:R,nodesDraggable:O,unselectNodesAndEdges:D,onNodeDragStart:$,onSelectionDragStart:b}=l.getState();m.current=!0;const C=r?$:$h(b);(!o||!s)&&!R&&r&&((j=I.get(r))!=null&&j.selected||D()),r&&s&&o&&Sd({id:r,store:l,nodeRef:t});const N=w(A);if(h.current=N,c.current=vI(I,O,N,r),C&&c.current){const[P,T]=jh({nodeId:r,dragItems:c.current,nodeInternals:I});C(A.sourceEvent,P,T)}};if(e)k.on(".drag",null);else{const A=AM().on("start",I=>{const{domNode:R,nodeDragThreshold:O}=l.getState();O===0&&E(I),v.current=!1;const D=w(I);h.current=D,d.current=(R==null?void 0:R.getBoundingClientRect())||null,p.current=Bi(I.sourceEvent,d.current)}).on("drag",I=>{var $,b;const R=w(I),{autoPanOnNodeDrag:O,nodeDragThreshold:D}=l.getState();if(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!x.current&&m.current&&O&&(x.current=!0,_()),!m.current){const C=R.xSnapped-((($=h==null?void 0:h.current)==null?void 0:$.x)??0),N=R.ySnapped-(((b=h==null?void 0:h.current)==null?void 0:b.y)??0);Math.sqrt(C*C+N*N)>D&&E(I)}(h.current.x!==R.xSnapped||h.current.y!==R.ySnapped)&&c.current&&m.current&&(g.current=I.sourceEvent,p.current=Bi(I.sourceEvent,d.current),S(R))}}).on("end",I=>{if(!(!m.current||v.current)&&(u(!1),x.current=!1,m.current=!1,cancelAnimationFrame(f.current),c.current)){const{updateNodePositions:R,nodeInternals:O,onNodeDragStop:D,onSelectionDragStop:$}=l.getState(),b=r?D:$h($);if(R(c.current,!1,!1),b){const[C,N]=jh({nodeId:r,dragItems:c.current,nodeInternals:O});b(I.sourceEvent,C,N)}}}).filter(I=>{const R=I.target;return!I.button&&(!n||!oy(R,`.${n}`,t))&&(!i||oy(R,i,t))});return k.call(A),()=>{k.on(".drag",null)}}}},[t,e,n,i,s,l,r,o,w]),a}function Rk(){const t=Ke();return M.useCallback(n=>{const{nodeInternals:i,nodeExtent:r,updateNodePositions:s,getNodes:o,snapToGrid:l,snapGrid:a,onError:u,nodesDraggable:c}=t.getState(),h=o().filter(v=>v.selected&&(v.draggable||c&&typeof v.draggable>"u")),f=l?a[0]:5,d=l?a[1]:5,p=n.isShiftPressed?4:1,g=n.x*f*p,x=n.y*d*p,m=h.map(v=>{if(v.positionAbsolute){const w={x:v.positionAbsolute.x+g,y:v.positionAbsolute.y+x};l&&(w.x=a[0]*Math.round(w.x/a[0]),w.y=a[1]*Math.round(w.y/a[1]));const{positionAbsolute:k,position:S}=Ik(v,w,i,r,void 0,u);v.position=S,v.positionAbsolute=k}return v});s(m,!0,!1)},[])}const ws={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var mo=t=>{const e=({id:n,type:i,data:r,xPos:s,yPos:o,xPosOrigin:l,yPosOrigin:a,selected:u,onClick:c,onMouseEnter:h,onMouseMove:f,onMouseLeave:d,onContextMenu:p,onDoubleClick:g,style:x,className:m,isDraggable:v,isSelectable:w,isConnectable:k,isFocusable:S,selectNodesOnDrag:_,sourcePosition:E,targetPosition:A,hidden:I,resizeObserver:R,dragHandle:O,zIndex:D,isParent:$,noDragClassName:b,noPanClassName:C,initialized:N,disableKeyboardA11y:j,ariaLabel:P,rfId:T,hasHandleBounds:B})=>{const F=Ke(),z=M.useRef(null),L=M.useRef(null),H=M.useRef(E),q=M.useRef(A),ee=M.useRef(i),J=w||v||c||h||f||d,he=Rk(),we=po(n,F.getState,h),pe=po(n,F.getState,f),ie=po(n,F.getState,d),He=po(n,F.getState,p),ct=po(n,F.getState,g),Qe=xe=>{const{nodeDragThreshold:te}=F.getState();if(w&&(!_||!v||te>0)&&Sd({id:n,store:F,nodeRef:z}),c){const Tt=F.getState().nodeInternals.get(n);Tt&&c(xe,{...Tt})}},je=xe=>{if(!yd(xe)&&!j)if(ok.includes(xe.key)&&w){const te=xe.key==="Escape";Sd({id:n,store:F,unselect:te,nodeRef:z})}else v&&u&&Object.prototype.hasOwnProperty.call(ws,xe.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${xe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~o}`}),he({x:ws[xe.key].x,y:ws[xe.key].y,isShiftPressed:xe.shiftKey}))};M.useEffect(()=>()=>{L.current&&(R==null||R.unobserve(L.current),L.current=null)},[]),M.useEffect(()=>{if(z.current&&!I){const xe=z.current;(!N||!B||L.current!==xe)&&(L.current&&(R==null||R.unobserve(L.current)),R==null||R.observe(xe),L.current=xe)}},[I,N,B]),M.useEffect(()=>{const xe=ee.current!==i,te=H.current!==E,Tt=q.current!==A;z.current&&(xe||te||Tt)&&(xe&&(ee.current=i),te&&(H.current=E),Tt&&(q.current=A),F.getState().updateNodeDimensions([{id:n,nodeElement:z.current,forceUpdate:!0}]))},[n,i,E,A]);const Sn=Pk({nodeRef:z,disabled:I||!v,noDragClassName:b,handleSelector:O,nodeId:n,isSelectable:w,selectNodesOnDrag:_});return I?null:V.createElement("div",{className:vt(["react-flow__node",`react-flow__node-${i}`,{[C]:v},m,{selected:u,selectable:w,parent:$,dragging:Sn}]),ref:z,style:{zIndex:D,transform:`translate(${l}px,${a}px)`,pointerEvents:J?"all":"none",visibility:N?"visible":"hidden",...x},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:we,onMouseMove:pe,onMouseLeave:ie,onContextMenu:He,onClick:Qe,onDoubleClick:ct,onKeyDown:S?je:void 0,tabIndex:S?0:void 0,role:S?"button":void 0,"aria-describedby":j?void 0:`${Ek}-${T}`,"aria-label":P},V.createElement(PO,{value:n},V.createElement(t,{id:n,data:r,type:i,xPos:s,yPos:o,selected:u,isConnectable:k,sourcePosition:E,targetPosition:A,dragging:Sn,dragHandle:O,zIndex:D})))};return e.displayName="NodeWrapper",M.memo(e)};const kI=t=>{const e=t.getNodes().filter(n=>n.selected);return{...bm(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function SI({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const i=Ke(),{width:r,height:s,x:o,y:l,transformString:a,userSelectionActive:u}=Ce(kI,at),c=Rk(),h=M.useRef(null);if(M.useEffect(()=>{var p;n||(p=h.current)==null||p.focus({preventScroll:!0})},[n]),Pk({nodeRef:h}),u||!r||!s)return null;const f=t?p=>{const g=i.getState().getNodes().filter(x=>x.selected);t(p,g)}:void 0,d=p=>{Object.prototype.hasOwnProperty.call(ws,p.key)&&c({x:ws[p.key].x,y:ws[p.key].y,isShiftPressed:p.shiftKey})};return V.createElement("div",{className:vt(["react-flow__nodesselection","react-flow__container",e]),style:{transform:a}},V.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:s,top:l,left:o}}))}var bI=M.memo(SI);const CI=t=>t.nodesSelectionActive,Dk=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:o,deleteKeyCode:l,onMove:a,onMoveStart:u,onMoveEnd:c,selectionKeyCode:h,selectionOnDrag:f,selectionMode:d,onSelectionStart:p,onSelectionEnd:g,multiSelectionKeyCode:x,panActivationKeyCode:m,zoomActivationKeyCode:v,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:_,panOnScrollSpeed:E,panOnScrollMode:A,zoomOnDoubleClick:I,panOnDrag:R,defaultViewport:O,translateExtent:D,minZoom:$,maxZoom:b,preventScrolling:C,onSelectionContextMenu:N,noWheelClassName:j,noPanClassName:P,disableKeyboardA11y:T})=>{const B=Ce(CI),F=kl(h),z=kl(m),L=z||R,H=z||_,q=F||f&&L!==!0;return aI({deleteKeyCode:l,multiSelectionKeyCode:x}),V.createElement(fI,{onMove:a,onMoveStart:u,onMoveEnd:c,onPaneContextMenu:s,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:H,panOnScrollSpeed:E,panOnScrollMode:A,zoomOnDoubleClick:I,panOnDrag:!F&&L,defaultViewport:O,translateExtent:D,minZoom:$,maxZoom:b,zoomActivationKeyCode:v,preventScrolling:C,noWheelClassName:j,noPanClassName:P},V.createElement(Tk,{onSelectionStart:p,onSelectionEnd:g,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:o,panOnDrag:L,isSelecting:!!q,selectionMode:d},t,B&&V.createElement(bI,{onSelectionContextMenu:N,noPanClassName:P,disableKeyboardA11y:T})))};Dk.displayName="FlowRenderer";var EI=M.memo(Dk);function _I(t){return Ce(M.useCallback(n=>t?fk(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function NI(t){const e={input:mo(t.input||kk),default:mo(t.default||kd),output:mo(t.output||bk),group:mo(t.group||Em)},n={},i=Object.keys(t).filter(r=>!["input","default","output","group"].includes(r)).reduce((r,s)=>(r[s]=mo(t[s]||kd),r),n);return{...e,...i}}const AI=({x:t,y:e,width:n,height:i,origin:r})=>!n||!i?{x:t,y:e}:r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:t,y:e}:{x:t-n*r[0],y:e-i*r[1]},MI=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),Lk=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,updateNodeDimensions:s,onError:o}=Ce(MI,at),l=_I(t.onlyRenderVisibleElements),a=M.useRef(),u=M.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const c=new ResizeObserver(h=>{const f=h.map(d=>({id:d.target.getAttribute("data-id"),nodeElement:d.target,forceUpdate:!0}));s(f)});return a.current=c,c},[]);return M.useEffect(()=>()=>{var c;(c=a==null?void 0:a.current)==null||c.disconnect()},[]),V.createElement("div",{className:"react-flow__nodes",style:_m},l.map(c=>{var S,_,E;let h=c.type||"default";t.nodeTypes[h]||(o==null||o("003",li.error003(h)),h="default");const f=t.nodeTypes[h]||t.nodeTypes.default,d=!!(c.draggable||e&&typeof c.draggable>"u"),p=!!(c.selectable||r&&typeof c.selectable>"u"),g=!!(c.connectable||n&&typeof c.connectable>"u"),x=!!(c.focusable||i&&typeof c.focusable>"u"),m=t.nodeExtent?gm(c.positionAbsolute,t.nodeExtent):c.positionAbsolute,v=(m==null?void 0:m.x)??0,w=(m==null?void 0:m.y)??0,k=AI({x:v,y:w,width:c.width??0,height:c.height??0,origin:t.nodeOrigin});return V.createElement(f,{key:c.id,id:c.id,className:c.className,style:c.style,type:h,data:c.data,sourcePosition:c.sourcePosition||G.Bottom,targetPosition:c.targetPosition||G.Top,hidden:c.hidden,xPos:v,yPos:w,xPosOrigin:k.x,yPosOrigin:k.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!c.selected,isDraggable:d,isSelectable:p,isConnectable:g,isFocusable:x,resizeObserver:u,dragHandle:c.dragHandle,zIndex:((S=c[Te])==null?void 0:S.z)??0,isParent:!!((_=c[Te])!=null&&_.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!c.width&&!!c.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:c.ariaLabel,hasHandleBounds:!!((E=c[Te])!=null&&E.handleBounds)})}))};Lk.displayName="NodeRenderer";var TI=M.memo(Lk);const OI=(t,e,n)=>n===G.Left?t-e:n===G.Right?t+e:t,II=(t,e,n)=>n===G.Top?t-e:n===G.Bottom?t+e:t,ay="react-flow__edgeupdater",uy=({position:t,centerX:e,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:s,onMouseOut:o,type:l})=>V.createElement("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:o,className:vt([ay,`${ay}-${l}`]),cx:OI(e,i,t),cy:II(n,i,t),r:i,stroke:"transparent",fill:"transparent"}),PI=()=>!0;var Hr=t=>{const e=({id:n,className:i,type:r,data:s,onClick:o,onEdgeDoubleClick:l,selected:a,animated:u,label:c,labelStyle:h,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:g,style:x,source:m,target:v,sourceX:w,sourceY:k,targetX:S,targetY:_,sourcePosition:E,targetPosition:A,elementsSelectable:I,hidden:R,sourceHandleId:O,targetHandleId:D,onContextMenu:$,onMouseEnter:b,onMouseMove:C,onMouseLeave:N,reconnectRadius:j,onReconnect:P,onReconnectStart:T,onReconnectEnd:B,markerEnd:F,markerStart:z,rfId:L,ariaLabel:H,isFocusable:q,isReconnectable:ee,pathOptions:J,interactionWidth:he,disableKeyboardA11y:we})=>{const pe=M.useRef(null),[ie,He]=M.useState(!1),[ct,Qe]=M.useState(!1),je=Ke(),Sn=M.useMemo(()=>`url('#${wd(z,L)}')`,[z,L]),xe=M.useMemo(()=>`url('#${wd(F,L)}')`,[F,L]);if(R)return null;const te=et=>{var bn;const{edges:rn,addSelectedEdges:Ji,unselectNodesAndEdges:Zi,multiSelectionActive:er}=je.getState(),Wn=rn.find(eo=>eo.id===n);Wn&&(I&&(je.setState({nodesSelectionActive:!1}),Wn.selected&&er?(Zi({nodes:[],edges:[Wn]}),(bn=pe.current)==null||bn.blur()):Ji([n])),o&&o(et,Wn))},Tt=fo(n,je.getState,l),Yi=fo(n,je.getState,$),Js=fo(n,je.getState,b),Pr=fo(n,je.getState,C),Rr=fo(n,je.getState,N),Hn=(et,rn)=>{if(et.button!==0)return;const{edges:Ji,isValidConnection:Zi}=je.getState(),er=rn?v:m,Wn=(rn?D:O)||null,bn=rn?"target":"source",eo=Zi||PI,Gc=rn,to=Ji.find(tr=>tr.id===n);Qe(!0),T==null||T(et,to,bn);const Jc=tr=>{Qe(!1),B==null||B(tr,to,bn)};yk({event:et,handleId:Wn,nodeId:er,onConnect:tr=>P==null?void 0:P(to,tr),isTarget:Gc,getState:je.getState,setState:je.setState,isValidConnection:eo,edgeUpdaterType:bn,onReconnectEnd:Jc})},Dr=et=>Hn(et,!0),Xi=et=>Hn(et,!1),Gi=()=>He(!0),Lr=()=>He(!1),Br=!I&&!o,Zs=et=>{var rn;if(!we&&ok.includes(et.key)&&I){const{unselectNodesAndEdges:Ji,addSelectedEdges:Zi,edges:er}=je.getState();et.key==="Escape"?((rn=pe.current)==null||rn.blur(),Ji({edges:[er.find(bn=>bn.id===n)]})):Zi([n])}};return V.createElement("g",{className:vt(["react-flow__edge",`react-flow__edge-${r}`,i,{selected:a,animated:u,inactive:Br,updating:ie}]),onClick:te,onDoubleClick:Tt,onContextMenu:Yi,onMouseEnter:Js,onMouseMove:Pr,onMouseLeave:Rr,onKeyDown:q?Zs:void 0,tabIndex:q?0:void 0,role:q?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":H===null?void 0:H||`Edge from ${m} to ${v}`,"aria-describedby":q?`${_k}-${L}`:void 0,ref:pe},!ct&&V.createElement(t,{id:n,source:m,target:v,selected:a,animated:u,label:c,labelStyle:h,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:g,data:s,style:x,sourceX:w,sourceY:k,targetX:S,targetY:_,sourcePosition:E,targetPosition:A,sourceHandleId:O,targetHandleId:D,markerStart:Sn,markerEnd:xe,pathOptions:J,interactionWidth:he}),ee&&V.createElement(V.Fragment,null,(ee==="source"||ee===!0)&&V.createElement(uy,{position:E,centerX:w,centerY:k,radius:j,onMouseDown:Dr,onMouseEnter:Gi,onMouseOut:Lr,type:"source"}),(ee==="target"||ee===!0)&&V.createElement(uy,{position:A,centerX:S,centerY:_,radius:j,onMouseDown:Xi,onMouseEnter:Gi,onMouseOut:Lr,type:"target"})))};return e.displayName="EdgeWrapper",M.memo(e)};function RI(t){const e={default:Hr(t.default||Wu),straight:Hr(t.bezier||xm),step:Hr(t.step||wm),smoothstep:Hr(t.step||Bc),simplebezier:Hr(t.simplebezier||vm)},n={},i=Object.keys(t).filter(r=>!["default","bezier"].includes(r)).reduce((r,s)=>(r[s]=Hr(t[s]||Wu),r),n);return{...e,...i}}function cy(t,e,n=null){const i=((n==null?void 0:n.x)||0)+e.x,r=((n==null?void 0:n.y)||0)+e.y,s=(n==null?void 0:n.width)||e.width,o=(n==null?void 0:n.height)||e.height;switch(t){case G.Top:return{x:i+s/2,y:r};case G.Right:return{x:i+s,y:r+o/2};case G.Bottom:return{x:i+s/2,y:r+o};case G.Left:return{x:i,y:r+o/2}}}function hy(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const DI=(t,e,n,i,r,s)=>{const o=cy(n,t,e),l=cy(s,i,r);return{sourceX:o.x,sourceY:o.y,targetX:l.x,targetY:l.y}};function LI({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:i,targetWidth:r,targetHeight:s,width:o,height:l,transform:a}){const u={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x+n,e.x+r),y2:Math.max(t.y+i,e.y+s)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);const c=ym({x:(0-a[0])/a[2],y:(0-a[1])/a[2],width:o/a[2],height:l/a[2]}),h=Math.max(0,Math.min(c.x2,u.x2)-Math.max(c.x,u.x)),f=Math.max(0,Math.min(c.y2,u.y2)-Math.max(c.y,u.y));return Math.ceil(h*f)>0}function fy(t){var i,r,s,o,l;const e=((i=t==null?void 0:t[Te])==null?void 0:i.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&typeof((r=t==null?void 0:t.positionAbsolute)==null?void 0:r.x)<"u"&&typeof((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.y)<"u";return[{x:((o=t==null?void 0:t.positionAbsolute)==null?void 0:o.x)||0,y:((l=t==null?void 0:t.positionAbsolute)==null?void 0:l.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const BI=[{level:0,isMaxLevel:!0,edges:[]}];function jI(t,e,n=!1){let i=-1;const r=t.reduce((o,l)=>{var c,h;const a=qt(l.zIndex);let u=a?l.zIndex:0;if(n){const f=e.get(l.target),d=e.get(l.source),p=l.selected||(f==null?void 0:f.selected)||(d==null?void 0:d.selected),g=Math.max(((c=d==null?void 0:d[Te])==null?void 0:c.z)||0,((h=f==null?void 0:f[Te])==null?void 0:h.z)||0,1e3);u=(a?l.zIndex:0)+(p?g:0)}return o[u]?o[u].push(l):o[u]=[l],i=u>i?u:i,o},{}),s=Object.entries(r).map(([o,l])=>{const a=+o;return{edges:l,level:a,isMaxLevel:a===i}});return s.length===0?BI:s}function $I(t,e,n){const i=Ce(M.useCallback(r=>t?r.edges.filter(s=>{const o=e.get(s.source),l=e.get(s.target);return(o==null?void 0:o.width)&&(o==null?void 0:o.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&LI({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:l.width,targetHeight:l.height,width:r.width,height:r.height,transform:r.transform})}):r.edges,[t,e]));return jI(i,e,n)}const zI=({color:t="none",strokeWidth:e=1})=>V.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),FI=({color:t="none",strokeWidth:e=1})=>V.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),dy={[xl.Arrow]:zI,[xl.ArrowClosed]:FI};function VI(t){const e=Ke();return M.useMemo(()=>{var r,s;return Object.prototype.hasOwnProperty.call(dy,t)?dy[t]:((s=(r=e.getState()).onError)==null||s.call(r,"009",li.error009(t)),null)},[t])}const HI=({id:t,type:e,color:n,width:i=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:o,orient:l="auto-start-reverse"})=>{const a=VI(e);return a?V.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0"},V.createElement(a,{color:n,strokeWidth:o})):null},WI=({defaultColor:t,rfId:e})=>n=>{const i=[];return n.edges.reduce((r,s)=>([s.markerStart,s.markerEnd].forEach(o=>{if(o&&typeof o=="object"){const l=wd(o,e);i.includes(l)||(r.push({id:l,color:o.color||t,...o}),i.push(l))}}),r),[]).sort((r,s)=>r.id.localeCompare(s.id))},Bk=({defaultColor:t,rfId:e})=>{const n=Ce(M.useCallback(WI({defaultColor:t,rfId:e}),[t,e]),(i,r)=>!(i.length!==r.length||i.some((s,o)=>s.id!==r[o].id)));return V.createElement("defs",null,n.map(i=>V.createElement(HI,{id:i.id,key:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient})))};Bk.displayName="MarkerDefinitions";var UI=M.memo(Bk);const qI=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),jk=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:i,edgeTypes:r,noPanClassName:s,onEdgeContextMenu:o,onEdgeMouseEnter:l,onEdgeMouseMove:a,onEdgeMouseLeave:u,onEdgeClick:c,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,reconnectRadius:g,children:x,disableKeyboardA11y:m})=>{const{edgesFocusable:v,edgesUpdatable:w,elementsSelectable:k,width:S,height:_,connectionMode:E,nodeInternals:A,onError:I}=Ce(qI,at),R=$I(e,A,n);return S?V.createElement(V.Fragment,null,R.map(({level:O,edges:D,isMaxLevel:$})=>V.createElement("svg",{key:O,style:{zIndex:O},width:S,height:_,className:"react-flow__edges react-flow__container"},$&&V.createElement(UI,{defaultColor:t,rfId:i}),V.createElement("g",null,D.map(b=>{const[C,N,j]=fy(A.get(b.source)),[P,T,B]=fy(A.get(b.target));if(!j||!B)return null;let F=b.type||"default";r[F]||(I==null||I("011",li.error011(F)),F="default");const z=r[F]||r.default,L=E===_r.Strict?T.target:(T.target??[]).concat(T.source??[]),H=hy(N.source,b.sourceHandle),q=hy(L,b.targetHandle),ee=(H==null?void 0:H.position)||G.Bottom,J=(q==null?void 0:q.position)||G.Top,he=!!(b.focusable||v&&typeof b.focusable>"u"),we=b.reconnectable||b.updatable,pe=typeof f<"u"&&(we||w&&typeof we>"u");if(!H||!q)return I==null||I("008",li.error008(H,b)),null;const{sourceX:ie,sourceY:He,targetX:ct,targetY:Qe}=DI(C,H,ee,P,q,J);return V.createElement(z,{key:b.id,id:b.id,className:vt([b.className,s]),type:F,data:b.data,selected:!!b.selected,animated:!!b.animated,hidden:!!b.hidden,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,style:b.style,source:b.source,target:b.target,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerEnd:b.markerEnd,markerStart:b.markerStart,sourceX:ie,sourceY:He,targetX:ct,targetY:Qe,sourcePosition:ee,targetPosition:J,elementsSelectable:k,onContextMenu:o,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,onClick:c,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,reconnectRadius:g,rfId:i,ariaLabel:b.ariaLabel,isFocusable:he,isReconnectable:pe,pathOptions:"pathOptions"in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth,disableKeyboardA11y:m})})))),x):null};jk.displayName="EdgeRenderer";var KI=M.memo(jk);const QI=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function YI({children:t}){const e=Ce(QI);return V.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function XI(t){const e=jc(),n=M.useRef(!1);M.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const GI={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},$k=({nodeId:t,handleType:e,style:n,type:i=ki.Bezier,CustomComponent:r,connectionStatus:s})=>{var _,E,A;const{fromNode:o,handleId:l,toX:a,toY:u,connectionMode:c}=Ce(M.useCallback(I=>({fromNode:I.nodeInternals.get(t),handleId:I.connectionHandleId,toX:(I.connectionPosition.x-I.transform[0])/I.transform[2],toY:(I.connectionPosition.y-I.transform[1])/I.transform[2],connectionMode:I.connectionMode}),[t]),at),h=(_=o==null?void 0:o[Te])==null?void 0:_.handleBounds;let f=h==null?void 0:h[e];if(c===_r.Loose&&(f=f||(h==null?void 0:h[e==="source"?"target":"source"])),!o||!f)return null;const d=l?f.find(I=>I.id===l):f[0],p=d?d.x+d.width/2:(o.width??0)/2,g=d?d.y+d.height/2:o.height??0,x=(((E=o.positionAbsolute)==null?void 0:E.x)??0)+p,m=(((A=o.positionAbsolute)==null?void 0:A.y)??0)+g,v=d==null?void 0:d.position,w=v?GI[v]:null;if(!v||!w)return null;if(r)return V.createElement(r,{connectionLineType:i,connectionLineStyle:n,fromNode:o,fromHandle:d,fromX:x,fromY:m,toX:a,toY:u,fromPosition:v,toPosition:w,connectionStatus:s});let k="";const S={sourceX:x,sourceY:m,sourcePosition:v,targetX:a,targetY:u,targetPosition:w};return i===ki.Bezier?[k]=km(S):i===ki.Step?[k]=vd({...S,borderRadius:0}):i===ki.SmoothStep?[k]=vd(S):i===ki.SimpleBezier?[k]=ck(S):k=`M${x},${m} ${a},${u}`,V.createElement("path",{d:k,fill:"none",className:"react-flow__connection-path",style:n})};$k.displayName="ConnectionLine";const JI=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function ZI({containerStyle:t,style:e,type:n,component:i}){const{nodeId:r,handleType:s,nodesConnectable:o,width:l,height:a,connectionStatus:u}=Ce(JI,at);return!(r&&s&&l&&o)?null:V.createElement("svg",{style:t,width:l,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},V.createElement("g",{className:vt(["react-flow__connection",u])},V.createElement($k,{nodeId:r,handleType:s,style:e,type:n,CustomComponent:i,connectionStatus:u})))}function py(t,e){return M.useRef(null),Ke(),M.useMemo(()=>e(t),[t])}const zk=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:i,onMoveEnd:r,onInit:s,onNodeClick:o,onEdgeClick:l,onNodeDoubleClick:a,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:d,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:x,connectionLineType:m,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:S,selectionOnDrag:_,selectionMode:E,multiSelectionKeyCode:A,panActivationKeyCode:I,zoomActivationKeyCode:R,deleteKeyCode:O,onlyRenderVisibleElements:D,elementsSelectable:$,selectNodesOnDrag:b,defaultViewport:C,translateExtent:N,minZoom:j,maxZoom:P,preventScrolling:T,defaultMarkerColor:B,zoomOnScroll:F,zoomOnPinch:z,panOnScroll:L,panOnScrollSpeed:H,panOnScrollMode:q,zoomOnDoubleClick:ee,panOnDrag:J,onPaneClick:he,onPaneMouseEnter:we,onPaneMouseMove:pe,onPaneMouseLeave:ie,onPaneScroll:He,onPaneContextMenu:ct,onEdgeContextMenu:Qe,onEdgeMouseEnter:je,onEdgeMouseMove:Sn,onEdgeMouseLeave:xe,onReconnect:te,onReconnectStart:Tt,onReconnectEnd:Yi,reconnectRadius:Js,noDragClassName:Pr,noWheelClassName:Rr,noPanClassName:Hn,elevateEdgesOnSelect:Dr,disableKeyboardA11y:Xi,nodeOrigin:Gi,nodeExtent:Lr,rfId:Br})=>{const Zs=py(t,NI),et=py(e,RI);return XI(s),V.createElement(EI,{onPaneClick:he,onPaneMouseEnter:we,onPaneMouseMove:pe,onPaneMouseLeave:ie,onPaneContextMenu:ct,onPaneScroll:He,deleteKeyCode:O,selectionKeyCode:S,selectionOnDrag:_,selectionMode:E,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:A,panActivationKeyCode:I,zoomActivationKeyCode:R,elementsSelectable:$,onMove:n,onMoveStart:i,onMoveEnd:r,zoomOnScroll:F,zoomOnPinch:z,zoomOnDoubleClick:ee,panOnScroll:L,panOnScrollSpeed:H,panOnScrollMode:q,panOnDrag:J,defaultViewport:C,translateExtent:N,minZoom:j,maxZoom:P,onSelectionContextMenu:p,preventScrolling:T,noDragClassName:Pr,noWheelClassName:Rr,noPanClassName:Hn,disableKeyboardA11y:Xi},V.createElement(YI,null,V.createElement(KI,{edgeTypes:et,onEdgeClick:l,onEdgeDoubleClick:u,onlyRenderVisibleElements:D,onEdgeContextMenu:Qe,onEdgeMouseEnter:je,onEdgeMouseMove:Sn,onEdgeMouseLeave:xe,onReconnect:te,onReconnectStart:Tt,onReconnectEnd:Yi,reconnectRadius:Js,defaultMarkerColor:B,noPanClassName:Hn,elevateEdgesOnSelect:!!Dr,disableKeyboardA11y:Xi,rfId:Br},V.createElement(ZI,{style:v,type:m,component:w,containerStyle:k})),V.createElement("div",{className:"react-flow__edgelabel-renderer"}),V.createElement(TI,{nodeTypes:Zs,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:d,selectNodesOnDrag:b,onlyRenderVisibleElements:D,noPanClassName:Hn,noDragClassName:Pr,disableKeyboardA11y:Xi,nodeOrigin:Gi,nodeExtent:Lr,rfId:Br})))};zk.displayName="GraphView";var eP=M.memo(zk);const bd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],fi={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:bd,nodeExtent:bd,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:_r.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:NO,isValidConnection:void 0},tP=()=>zN((t,e)=>({...fi,setNodes:n=>{const{nodeInternals:i,nodeOrigin:r,elevateNodesOnSelect:s}=e();t({nodeInternals:Lh(n,i,r,s)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:i={}}=e();t({edges:n.map(r=>({...i,...r}))})},setDefaultNodesAndEdges:(n,i)=>{const r=typeof n<"u",s=typeof i<"u",o=r?Lh(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:o,edges:s?i:[],hasDefaultNodes:r,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:i,nodeInternals:r,fitViewOnInit:s,fitViewOnInitDone:o,fitViewOnInitOptions:l,domNode:a,nodeOrigin:u}=e(),c=a==null?void 0:a.querySelector(".react-flow__viewport");if(!c)return;const h=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(h.transform),d=n.reduce((g,x)=>{const m=r.get(x.id);if(m!=null&&m.hidden)r.set(m.id,{...m,[Te]:{...m[Te],handleBounds:void 0}});else if(m){const v=mm(x.nodeElement);!!(v.width&&v.height&&(m.width!==v.width||m.height!==v.height||x.forceUpdate))&&(r.set(m.id,{...m,[Te]:{...m[Te],handleBounds:{source:ly(".source",x.nodeElement,f,u),target:ly(".target",x.nodeElement,f,u)}},...v}),g.push({id:m.id,type:"dimensions",dimensions:v}))}return g},[]);Ak(r,u);const p=o||s&&!o&&Mk(e,{initial:!0,...l});t({nodeInternals:new Map(r),fitViewOnInitDone:p}),(d==null?void 0:d.length)>0&&(i==null||i(d))},updateNodePositions:(n,i=!0,r=!1)=>{const{triggerNodeChanges:s}=e(),o=n.map(l=>{const a={id:l.id,type:"position",dragging:r};return i&&(a.positionAbsolute=l.positionAbsolute,a.position=l.position),a});s(o)},triggerNodeChanges:n=>{const{onNodesChange:i,nodeInternals:r,hasDefaultNodes:s,nodeOrigin:o,getNodes:l,elevateNodesOnSelect:a}=e();if(n!=null&&n.length){if(s){const u=gI(n,l()),c=Lh(u,r,o,a);t({nodeInternals:c})}i==null||i(n)}},addSelectedNodes:n=>{const{multiSelectionActive:i,edges:r,getNodes:s}=e();let o,l=null;i?o=n.map(a=>gi(a,!0)):(o=rs(s(),n),l=rs(r,[])),wa({changedNodes:o,changedEdges:l,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:i,edges:r,getNodes:s}=e();let o,l=null;i?o=n.map(a=>gi(a,!0)):(o=rs(r,n),l=rs(s(),[])),wa({changedNodes:l,changedEdges:o,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:i}={})=>{const{edges:r,getNodes:s}=e(),o=n||s(),l=i||r,a=o.map(c=>(c.selected=!1,gi(c.id,!1))),u=l.map(c=>gi(c.id,!1));wa({changedNodes:a,changedEdges:u,get:e,set:t})},setMinZoom:n=>{const{d3Zoom:i,maxZoom:r}=e();i==null||i.scaleExtent([n,r]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:i,minZoom:r}=e();i==null||i.scaleExtent([r,n]),t({maxZoom:n})},setTranslateExtent:n=>{var i;(i=e().d3Zoom)==null||i.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:i}=e(),s=i().filter(l=>l.selected).map(l=>gi(l.id,!1)),o=n.filter(l=>l.selected).map(l=>gi(l.id,!1));wa({changedNodes:s,changedEdges:o,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:i}=e();i.forEach(r=>{r.positionAbsolute=gm(r.position,n)}),t({nodeExtent:n,nodeInternals:new Map(i)})},panBy:n=>{const{transform:i,width:r,height:s,d3Zoom:o,d3Selection:l,translateExtent:a}=e();if(!o||!l||!n.x&&!n.y)return!1;const u=Li.translate(i[0]+n.x,i[1]+n.y).scale(i[2]),c=[[0,0],[r,s]],h=o==null?void 0:o.constrain()(u,c,a);return o.transform(l,h),i[0]!==h.x||i[1]!==h.y||i[2]!==h.k},cancelConnection:()=>t({connectionNodeId:fi.connectionNodeId,connectionHandleId:fi.connectionHandleId,connectionHandleType:fi.connectionHandleType,connectionStatus:fi.connectionStatus,connectionStartHandle:fi.connectionStartHandle,connectionEndHandle:fi.connectionEndHandle}),reset:()=>t({...fi})}),Object.is),Nm=({children:t})=>{const e=M.useRef(null);return e.current||(e.current=tP()),V.createElement(wO,{value:e.current},t)};Nm.displayName="ReactFlowProvider";const Fk=({children:t})=>M.useContext(Lc)?V.createElement(V.Fragment,null,t):V.createElement(Nm,null,t);Fk.displayName="ReactFlowWrapper";const nP={input:kk,default:kd,output:bk,group:Em},iP={default:Wu,straight:xm,step:wm,smoothstep:Bc,simplebezier:vm},rP=[0,0],sP=[15,15],oP={x:0,y:0,zoom:1},lP={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Vk=M.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:s=nP,edgeTypes:o=iP,onNodeClick:l,onEdgeClick:a,onInit:u,onMove:c,onMoveStart:h,onMoveEnd:f,onConnect:d,onConnectStart:p,onConnectEnd:g,onClickConnectStart:x,onClickConnectEnd:m,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:k,onNodeContextMenu:S,onNodeDoubleClick:_,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:I,onNodesDelete:R,onEdgesDelete:O,onSelectionChange:D,onSelectionDragStart:$,onSelectionDrag:b,onSelectionDragStop:C,onSelectionContextMenu:N,onSelectionStart:j,onSelectionEnd:P,connectionMode:T=_r.Strict,connectionLineType:B=ki.Bezier,connectionLineStyle:F,connectionLineComponent:z,connectionLineContainerStyle:L,deleteKeyCode:H="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:ee=!1,selectionMode:J=wl.Full,panActivationKeyCode:he="Space",multiSelectionKeyCode:we=Hu()?"Meta":"Control",zoomActivationKeyCode:pe=Hu()?"Meta":"Control",snapToGrid:ie=!1,snapGrid:He=sP,onlyRenderVisibleElements:ct=!1,selectNodesOnDrag:Qe=!0,nodesDraggable:je,nodesConnectable:Sn,nodesFocusable:xe,nodeOrigin:te=rP,edgesFocusable:Tt,edgesUpdatable:Yi,elementsSelectable:Js,defaultViewport:Pr=oP,minZoom:Rr=.5,maxZoom:Hn=2,translateExtent:Dr=bd,preventScrolling:Xi=!0,nodeExtent:Gi,defaultMarkerColor:Lr="#b1b1b7",zoomOnScroll:Br=!0,zoomOnPinch:Zs=!0,panOnScroll:et=!1,panOnScrollSpeed:rn=.5,panOnScrollMode:Ji=dr.Free,zoomOnDoubleClick:Zi=!0,panOnDrag:er=!0,onPaneClick:Wn,onPaneMouseEnter:bn,onPaneMouseMove:eo,onPaneMouseLeave:Gc,onPaneScroll:to,onPaneContextMenu:Jc,children:rg,onEdgeContextMenu:tr,onEdgeDoubleClick:hC,onEdgeMouseEnter:fC,onEdgeMouseMove:dC,onEdgeMouseLeave:pC,onEdgeUpdate:mC,onEdgeUpdateStart:gC,onEdgeUpdateEnd:yC,onReconnect:vC,onReconnectStart:wC,onReconnectEnd:xC,reconnectRadius:kC=10,edgeUpdaterRadius:SC=10,onNodesChange:bC,onEdgesChange:CC,noDragClassName:EC="nodrag",noWheelClassName:_C="nowheel",noPanClassName:sg="nopan",fitView:NC=!1,fitViewOptions:AC,connectOnClick:MC=!0,attributionPosition:TC,proOptions:OC,defaultEdgeOptions:IC,elevateNodesOnSelect:PC=!0,elevateEdgesOnSelect:RC=!1,disableKeyboardA11y:og=!1,autoPanOnConnect:DC=!0,autoPanOnNodeDrag:LC=!0,connectionRadius:BC=20,isValidConnection:jC,onError:$C,style:zC,id:lg,nodeDragThreshold:FC,...VC},HC)=>{const Zc=lg||"1";return V.createElement("div",{...VC,style:{...zC,...lP},ref:HC,className:vt(["react-flow",r]),"data-testid":"rf__wrapper",id:lg},V.createElement(Fk,null,V.createElement(eP,{onInit:u,onMove:c,onMoveStart:h,onMoveEnd:f,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:k,onNodeContextMenu:S,onNodeDoubleClick:_,nodeTypes:s,edgeTypes:o,connectionLineType:B,connectionLineStyle:F,connectionLineComponent:z,connectionLineContainerStyle:L,selectionKeyCode:q,selectionOnDrag:ee,selectionMode:J,deleteKeyCode:H,multiSelectionKeyCode:we,panActivationKeyCode:he,zoomActivationKeyCode:pe,onlyRenderVisibleElements:ct,selectNodesOnDrag:Qe,defaultViewport:Pr,translateExtent:Dr,minZoom:Rr,maxZoom:Hn,preventScrolling:Xi,zoomOnScroll:Br,zoomOnPinch:Zs,zoomOnDoubleClick:Zi,panOnScroll:et,panOnScrollSpeed:rn,panOnScrollMode:Ji,panOnDrag:er,onPaneClick:Wn,onPaneMouseEnter:bn,onPaneMouseMove:eo,onPaneMouseLeave:Gc,onPaneScroll:to,onPaneContextMenu:Jc,onSelectionContextMenu:N,onSelectionStart:j,onSelectionEnd:P,onEdgeContextMenu:tr,onEdgeDoubleClick:hC,onEdgeMouseEnter:fC,onEdgeMouseMove:dC,onEdgeMouseLeave:pC,onReconnect:vC??mC,onReconnectStart:wC??gC,onReconnectEnd:xC??yC,reconnectRadius:kC??SC,defaultMarkerColor:Lr,noDragClassName:EC,noWheelClassName:_C,noPanClassName:sg,elevateEdgesOnSelect:RC,rfId:Zc,disableKeyboardA11y:og,nodeOrigin:te,nodeExtent:Gi}),V.createElement(XO,{nodes:t,edges:e,defaultNodes:n,defaultEdges:i,onConnect:d,onConnectStart:p,onConnectEnd:g,onClickConnectStart:x,onClickConnectEnd:m,nodesDraggable:je,nodesConnectable:Sn,nodesFocusable:xe,edgesFocusable:Tt,edgesUpdatable:Yi,elementsSelectable:Js,elevateNodesOnSelect:PC,minZoom:Rr,maxZoom:Hn,nodeExtent:Gi,onNodesChange:bC,onEdgesChange:CC,snapToGrid:ie,snapGrid:He,connectionMode:T,translateExtent:Dr,connectOnClick:MC,defaultEdgeOptions:IC,fitView:NC,fitViewOptions:AC,onNodesDelete:R,onEdgesDelete:O,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:I,onSelectionDrag:b,onSelectionDragStart:$,onSelectionDragStop:C,noPanClassName:sg,nodeOrigin:te,rfId:Zc,autoPanOnConnect:DC,autoPanOnNodeDrag:LC,onError:$C,connectionRadius:BC,isValidConnection:jC,nodeDragThreshold:FC}),V.createElement(QO,{onSelectionChange:D}),rg,V.createElement(kO,{proOptions:OC,position:TC}),V.createElement(tI,{rfId:Zc,disableKeyboardA11y:og})))});Vk.displayName="ReactFlow";const aP=t=>{var e;return(e=t.domNode)==null?void 0:e.querySelector(".react-flow__edgelabel-renderer")};function uP({children:t}){const e=Ce(aP);return e?ox.createPortal(t,e):null}function cP(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},V.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function hP(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},V.createElement("path",{d:"M0 0h32v4.2H0z"}))}function fP(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},V.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function dP(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},V.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function pP(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},V.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Ao=({children:t,className:e,...n})=>V.createElement("button",{type:"button",className:vt(["react-flow__controls-button",e]),...n},t);Ao.displayName="ControlButton";const mP=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),Hk=({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:o,onFitView:l,onInteractiveChange:a,className:u,children:c,position:h="bottom-left"})=>{const f=Ke(),[d,p]=M.useState(!1),{isInteractive:g,minZoomReached:x,maxZoomReached:m}=Ce(mP,at),{zoomIn:v,zoomOut:w,fitView:k}=jc();if(M.useEffect(()=>{p(!0)},[]),!d)return null;const S=()=>{v(),s==null||s()},_=()=>{w(),o==null||o()},E=()=>{k(r),l==null||l()},A=()=>{f.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),a==null||a(!g)};return V.createElement(ik,{className:vt(["react-flow__controls",u]),position:h,style:t,"data-testid":"rf__controls"},e&&V.createElement(V.Fragment,null,V.createElement(Ao,{onClick:S,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:m},V.createElement(cP,null)),V.createElement(Ao,{onClick:_,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},V.createElement(hP,null))),n&&V.createElement(Ao,{className:"react-flow__controls-fitview",onClick:E,title:"fit view","aria-label":"fit view"},V.createElement(fP,null)),i&&V.createElement(Ao,{className:"react-flow__controls-interactive",onClick:A,title:"toggle interactivity","aria-label":"toggle interactivity"},g?V.createElement(pP,null):V.createElement(dP,null)),c)};Hk.displayName="Controls";var gP=M.memo(Hk),gn;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(gn||(gn={}));function yP({color:t,dimensions:e,lineWidth:n}){return V.createElement("path",{stroke:t,strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})}function vP({color:t,radius:e}){return V.createElement("circle",{cx:e,cy:e,r:e,fill:t})}const wP={[gn.Dots]:"#91919a",[gn.Lines]:"#eee",[gn.Cross]:"#e2e2e2"},xP={[gn.Dots]:1,[gn.Lines]:1,[gn.Cross]:6},kP=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Wk({id:t,variant:e=gn.Dots,gap:n=20,size:i,lineWidth:r=1,offset:s=2,color:o,style:l,className:a}){const u=M.useRef(null),{transform:c,patternId:h}=Ce(kP,at),f=o||wP[e],d=i||xP[e],p=e===gn.Dots,g=e===gn.Cross,x=Array.isArray(n)?n:[n,n],m=[x[0]*c[2]||1,x[1]*c[2]||1],v=d*c[2],w=g?[v,v]:m,k=p?[v/s,v/s]:[w[0]/s,w[1]/s];return V.createElement("svg",{className:vt(["react-flow__background",a]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},V.createElement("pattern",{id:h+t,x:c[0]%m[0],y:c[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},p?V.createElement(vP,{color:f,radius:v/s}):V.createElement(yP,{dimensions:w,color:f,lineWidth:r})),V.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${h+t})`}))}Wk.displayName="Background";var SP=M.memo(Wk);function bP({id:t,sourceX:e,sourceY:n,targetX:i,targetY:r,sourcePosition:s,targetPosition:o,markerEnd:l,style:a,data:u}){const c=le(x=>x.toggleBreakpoint),h=le(x=>x.isRunning),[f,d,p]=km({sourceX:e,sourceY:n,sourcePosition:s,targetX:i,targetY:r,targetPosition:o}),g=h?"Can't change breakpoints while the workflow is running":u!=null&&u.armed?"Click to select · Double-click to remove debug point":"Click to select · Double-click to add debug point";return y.jsxs(y.Fragment,{children:[y.jsx(Xs,{id:t,path:f,markerEnd:l,style:a}),y.jsx("title",{children:g}),(u==null?void 0:u.armed)&&y.jsx(uP,{children:y.jsx("button",{type:"button",className:"nodrag nopan breakpoint-marker breakpoint-marker--armed",disabled:h,style:{transform:`translate(-50%, -50%) translate(${d}px, ${p}px) scale(calc(1 / var(--rf-zoom, 1)))`},onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),c(u.fromNodeId,u.toNodeId)},onDoubleClick:x=>x.stopPropagation(),title:h?"Can't change breakpoints while the workflow is running":"Remove breakpoint","aria-label":"Remove breakpoint","aria-pressed":!0})})]})}const CP={"in-flight":"●",paused:"⏸",completed:"✓",failed:"!"};function EP({data:t}){const{node:e,operation:n,selected:i,status:r,label:s}=t,o=le(h=>h.removeNode),l=le(h=>h.isRunning),a=(n==null?void 0:n.method)??"get",u=!!(n!=null&&n.operationId)||s!==void 0&&/#\d+$/.test(s),c=r&&CP[r];return y.jsxs("div",{className:"workflow-node-shell",children:[y.jsxs("fieldset",{className:`workflow-node${i?" workflow-node--selected":""}${r?` workflow-node--${r}`:""}`,children:[u&&y.jsx("legend",{className:"workflow-node__operation-id",children:s}),c&&y.jsx("span",{className:`workflow-node__status-badge workflow-node__status-badge--${r}`,"aria-hidden":"true",children:c}),y.jsx(Bs,{type:"target",position:G.Left,title:"Drop here to connect — sets run order, not data"}),y.jsxs("div",{className:"workflow-node__header",children:[y.jsx("span",{className:`method-badge method-badge--${a}`,children:a.toUpperCase()}),y.jsx("span",{className:"workflow-node__path",children:(n==null?void 0:n.path)??"Unknown operation"})]}),(n==null?void 0:n.summary)&&y.jsx("div",{className:"workflow-node__summary",title:n.summary,children:n.summary}),r==="paused"&&y.jsx("div",{className:"workflow-node__paused-label",children:"⏸ Paused here"}),y.jsx(Bs,{type:"source",position:G.Right,title:"Drag to connect — sets run order, not data"})]}),y.jsx("button",{type:"button",className:"nodrag nopan workflow-node__remove-btn",disabled:l,onMouseDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),o(e.id)},title:l?"Can't remove a node while the workflow is running":"Remove this node","aria-label":"Remove this node",children:"×"})]})}const _P={workflowNode:EP},NP={connection:bP};function AP(){return y.jsx(Nm,{children:y.jsx(MP,{})})}function MP(){const{nodes:t,nodePositions:e,connections:n,operations:i,selectedNodeId:r,stepStatusByNodeId:s,armedBreakpoints:o,addNode:l,updateNodePosition:a,selectNode:u,connectNodes:c,disconnectNodes:h,removeNode:f,toggleBreakpoint:d}=le(),{screenToFlowPosition:p,fitView:g,getViewport:x}=jc(),m=M.useRef(null),v=M.useRef(t.length),[w,k]=M.useState(null),S=M.useCallback(C=>{var N;(N=m.current)==null||N.style.setProperty("--rf-zoom",String(C.zoom))},[]);M.useEffect(()=>{S(x())},[x,S]);const _=M.useMemo(()=>{const C=new Map(i.map(N=>[N.id,N]));return Oc(t,C)},[t,i]),E=M.useMemo(()=>t.map(C=>({id:C.id,type:"workflowNode",position:e[C.id]??{x:80,y:80},selected:C.id===r,data:{node:C,operation:i.find(N=>N.id===C.operationId),selected:C.id===r,status:s[C.id],label:_.get(C.id)}})),[t,e,i,r,s,_]),A=M.useMemo(()=>{const C=[];for(const N of t)for(const j of Object.values(N.fieldValues))j.source==="mapped"&&C.push({id:`map-${j.fromNodeId}->${N.id}-${C.length}`,source:j.fromNodeId,target:N.id,className:"edge-mapping",animated:!0});for(const N of n)C.push({id:`conn-${N.fromNodeId}->${N.toNodeId}`,source:N.fromNodeId,target:N.toNodeId,type:"connection",className:"edge-connection",markerEnd:{type:xl.ArrowClosed,color:"#9aa0a6"},data:{fromNodeId:N.fromNodeId,toNodeId:N.toNodeId,armed:o.has(Ru(N.fromNodeId,N.toNodeId))}});return C.map(N=>({...N,selected:N.id===w}))},[t,n,w,o]),I=M.useCallback(C=>{C.preventDefault();const N=C.dataTransfer.getData("text/operation-id");if(!N)return;const j=p({x:C.clientX,y:C.clientY});l(N,j)},[l,p]),R=M.useCallback(C=>{C.source&&C.target&&c(C.source,C.target)},[c]),O=M.useCallback(C=>{for(const N of C)N.type==="position"&&N.position?a(N.id,N.position):N.type==="remove"&&f(N.id)},[a,f]),D=M.useCallback(C=>{for(const N of C)if(N.type==="select")k(N.selected?N.id:null),N.selected&&u(null);else if(N.type==="remove"){const j=A.find(P=>P.id===N.id);j!=null&&j.data&&h(j.data.fromNodeId,j.data.toNodeId)}},[A,h,u]),$=M.useCallback(()=>{const C=m.current;if(!C||t.length===0)return;const N=C.getBoundingClientRect();[...C.querySelectorAll(".react-flow__node")].some(T=>{const B=T.getBoundingClientRect();return B.left<N.left||B.top<N.top||B.right>N.right||B.bottom>N.bottom})&&g({padding:.2,duration:300})},[t.length,g]),b=M.useCallback((C,N)=>{a(N.id,N.position,{avoidOverlap:!0}),requestAnimationFrame(()=>$())},[a,$]);return M.useEffect(()=>{if(v.current===t.length)return;v.current=t.length;const C=requestAnimationFrame($);return()=>cancelAnimationFrame(C)},[t.length,$]),M.useEffect(()=>{const C=m.current;if(!C)return;let N=0;const j=new ResizeObserver(()=>{cancelAnimationFrame(N),N=requestAnimationFrame($)});return j.observe(C),()=>{j.disconnect(),cancelAnimationFrame(N)}},[$]),y.jsx("div",{className:"canvas",ref:m,onDrop:I,onDragOver:C=>C.preventDefault(),children:y.jsxs(Vk,{nodes:E,edges:A,nodeTypes:_P,edgeTypes:NP,onNodeClick:(C,N)=>{u(N.id),k(null)},onPaneClick:()=>{u(null),k(null)},onConnect:R,onNodesChange:O,onNodeDragStop:b,onEdgesChange:D,onEdgeDoubleClick:(C,N)=>{const j=N.data;j!=null&&j.fromNodeId&&j.toNodeId&&d(j.fromNodeId,j.toNodeId)},onMove:(C,N)=>S(N),fitView:!0,fitViewOptions:{padding:.2},proOptions:{hideAttribution:!0},children:[y.jsx(SP,{color:"#3a3d42",gap:16}),y.jsx(gP,{})]})})}function zh(t,e){if(e==="integer"||e==="number"){if(t.trim()==="")return t;const n=Number(t);return Number.isNaN(n)?t:n}if(e==="boolean")return t==="true"?!0:t==="false"?!1:t;if(e==="array"){if(t.trim()==="")return t;try{return JSON.parse(t)}catch{return t}}return t}const TP="Unrecognized schema shape (e.g. oneOf/anyOf/allOf) — not supported yet.",OP=new Set(["string","integer","number","boolean"]);function Nr(t){return(t==null?void 0:t.type)==="array"}function js(t){return!Nr(t)&&!!t&&(t.type==="object"||!!t.properties)}function Mo(t){var e;return(e=t==null?void 0:t.enum)!=null&&e.length?t.enum[0]:(t==null?void 0:t.type)==="integer"||(t==null?void 0:t.type)==="number"?0:(t==null?void 0:t.type)==="boolean"?!0:"string"}function IP(t){if(js(t)){const e={};for(const[n,i]of Object.entries(t.properties??{}))e[n]=Nr(i)?[]:js(i)?{}:Mo(i);return JSON.stringify([e])}return Nr(t)?JSON.stringify([[Mo(t.items)]]):JSON.stringify([Mo(t),Mo(t)])}function Uk(t,e,n){return{path:t,required:e,supported:!0,type:"array",reason:IP(n.items)}}function Am(t,e){const n=[],i=(t==null?void 0:t.properties)??{},r=(t==null?void 0:t.required)??[];for(const[s,o]of Object.entries(i)){const l=e?`${e}.${s}`:s,a=r.includes(s);if(js(o)){n.push(...Am(o,l));continue}if(Nr(o)){n.push(Uk(l,a,o));continue}const u=OP.has(o==null?void 0:o.type)||!!(o!=null&&o.enum);n.push(u?{path:l,required:a,supported:!0,type:o==null?void 0:o.type,format:typeof(o==null?void 0:o.format)=="string"?o.format:void 0,enum:o==null?void 0:o.enum}:{path:l,required:a,supported:!1,reason:TP})}return n}function Mm(t){return[...t.parameters.map(n=>{var r,s,o;const i=`${n.in}.${n.name}`;return Nr(n.schema)?Uk(i,n.required,n.schema):{path:i,required:n.required,supported:!0,type:(r=n.schema)==null?void 0:r.type,format:typeof((s=n.schema)==null?void 0:s.format)=="string"?n.schema.format:void 0,enum:(o=n.schema)==null?void 0:o.enum}}),...Am(t.requestBodySchema,"body")]}function PP(t){return Am(t.responseSchema,"")}function RP(t,e){if(!t||!e||t===e)return!0;const n=new Set(["integer","number"]);return n.has(t)&&n.has(e)}function DP(t){const e={type:"object",properties:{},required:[]};for(const n of t)Object.assign(e.properties,n.properties??{}),e.required.push(...n.required??[]),n.type&&!e.type&&(e.type=n.type);return e}function LP(t){var e,n;return((e=t.oneOf)==null?void 0:e[0])??((n=t.anyOf)==null?void 0:n[0])}function To(t){var n;if(!t)return null;if((n=t.allOf)!=null&&n.length)return To(DP(t.allOf));const e=LP(t);if(e)return To(e);if(Nr(t))return[To(t.items)];if(js(t)){const i={};for(const[r,s]of Object.entries(t.properties??{}))i[r]=To(s);return i}return Mo(t)}function Cd(t){var e,n,i;if(!t)return!1;if((e=t.oneOf)!=null&&e.length||(n=t.anyOf)!=null&&n.length||(i=t.allOf)!=null&&i.length)return!0;if(Nr(t)){const r=t.items;return js(r)?!0:Cd(r)}return js(t)?Object.values(t.properties??{}).some(Cd):!1}const BP=/"__ENLACE_RAW_TAG__([a-zA-Z0-9_-]+)__"/g,jP=t=>`__ENLACE_RAW_TAG__${t}__`;function qk(t){return Mm(t).filter(e=>e.supported&&e.path.startsWith("body.")).map(e=>e.path.slice(5))}function Kk(t,e){const n=`${e}.`;return Mm(t).filter(i=>i.supported&&i.path.startsWith(n)).map(i=>i.path.slice(n.length))}function Qk(t,e){return{template:JSON.stringify(t,null,2).replace(BP,(i,r)=>`"${gx(r)}"`),tags:e}}function Yk(t,e,n,i){if(i.source==="static")hl(t,n,i.value);else if(i.source==="mapped"){const r=fl();e[r]={id:r,type:"response_body",sourceNodeId:i.fromNodeId,jsonPath:i.fromResponseFieldPath||void 0},hl(t,n,jP(r))}}function my(t,e,n){const i={},r={},s=`${t}.`;for(const o of Kk(e,t)){const l=n[`${s}${o}`];l?Yk(i,r,o,l):i[o]=""}return Qk(i,r)}function $P(t,e){const n=To(t.requestBodySchema),i=typeof n=="object"&&n!==null?n:{},r={};for(const s of qk(t)){const o=e[`body.${s}`];o&&Yk(i,r,s,o)}return Qk(i,r)}function Ed(t,e){if(t===e)return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t)||Array.isArray(e))return!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length?!1:t.every((n,i)=>Ed(n,e[i]));if(typeof t=="object"){const n=Object.keys(t),i=Object.keys(e);return n.length!==i.length?!1:n.every(r=>Ed(t[r],e[r]))}return!1}function Xk(t,e,n,i){let r;try{r=JSON.parse(t.template)}catch(h){return{fieldValues:{},lossy:!1,parseError:h instanceof Error?h.message:String(h)}}const s={},o={},l=new Set;for(const h of e){const f=lm(r,h);if(f===void 0&&!i)continue;const d=typeof f=="string"?f.match(/^\{\{enlace:([a-zA-Z0-9_-]+)\}\}$/):null,p=d?t.tags[d[1]]:void 0;p&&p.type==="response_body"?(s[`${n}${h}`]={source:"mapped",fromNodeId:p.sourceNodeId,fromResponseFieldPath:p.jsonPath??""},l.add(p.id),hl(o,h,f)):(s[`${n}${h}`]={source:"static",value:f},hl(o,h,f))}const c=[...new Set([...t.template.matchAll(Bl())].map(h=>h[1]))].some(h=>!l.has(h))||!Ed(o,r);return{fieldValues:s,lossy:c}}function gy(t,e,n){return Xk(e,Kk(n,t),`${t}.`,!1)}function zP(t,e){return Xk(t,qk(e),"body.",!0)}let _d=[],Gk=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?Gk:_d).push(n=n+t[e])})();function FP(t){if(t<768)return!1;for(let e=0,n=_d.length;;){let i=e+n>>1;if(t<_d[i])n=i;else if(t>=Gk[i])e=i+1;else return!0;if(e==n)return!1}}function yy(t){return t>=127462&&t<=127487}const vy=8205;function VP(t,e,n=!0,i=!0){return(n?Jk:HP)(t,e,i)}function Jk(t,e,n){if(e==t.length)return e;e&&Zk(t.charCodeAt(e))&&eS(t.charCodeAt(e-1))&&e--;let i=Fh(t,e);for(e+=wy(i);e<t.length;){let r=Fh(t,e);if(i==vy||r==vy||n&&FP(r))e+=wy(r),i=r;else if(yy(r)){let s=0,o=e-2;for(;o>=0&&yy(Fh(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function HP(t,e,n){for(;e>1;){let i=Jk(t,e-2,n);if(i<e)return i;e--}return 0}function Fh(t,e){let n=t.charCodeAt(e);if(!eS(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return Zk(i)?(n-55296<<10)+(i-56320)+65536:n}function Zk(t){return t>=56320&&t<57344}function eS(t){return t>=55296&&t<56320}function wy(t){return t<65536?1:2}class ae{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,i){[e,n]=$s(this,e,n);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),In.from(r,this.length-(n-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=$s(this,e,n);let i=[];return this.decompose(e,n,i,0),In.from(i,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Vo(this),s=new Vo(e);for(let o=n,l=n;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Vo(this,e)}iterRange(e,n=this.length){return new tS(this,e,n)}iterLines(e,n){let i;if(e==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new nS(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ae.empty:e.length<=32?new Re(e):In.from(Re.split(e,[]))}}class Re extends ae{constructor(e,n=WP(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((n?i:l)>=e)return new UP(r,l,i,o);r=l+1,i++}}decompose(e,n,i,r){let s=e<=0&&n>=this.length?this:new Re(xy(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=iu(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new Re(l,o.length+s.length));else{let a=l.length>>1;i.push(new Re(l.slice(0,a)),new Re(l.slice(a)))}}else i.push(s)}replace(e,n,i){if(!(i instanceof Re))return super.replace(e,n,i);[e,n]=$s(this,e,n);let r=iu(this.text,iu(i.text,xy(this.text,0,e)),n),s=this.length+i.length-(n-e);return r.length<=32?new Re(r,s):In.from(Re.split(r,[]),s)}sliceString(e,n=this.length,i=`
57
+ `){[e,n]=$s(this,e,n);let r="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&n>s&&(r+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return r}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(n.push(new Re(i,r)),i=[],r=-1);return r>-1&&n.push(new Re(i,r)),n}}class In extends ae{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,i,r);r=l+1,i=a+1}}decompose(e,n,i,r){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&n>=o){let u=r&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?i.push(l):l.decompose(e-o,n-o,i,u)}o=a+1}}replace(e,n,i){if([e,n]=$s(this,e,n),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&n<=l){let a=o.replace(e-s,n-s,i),u=this.lines-o.lines+a.lines;if(a.lines<u>>4&&a.lines>u>>6){let c=this.children.slice();return c[r]=a,new In(c,this.length-(n-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,i)}sliceString(e,n=this.length,i=`
58
+ `){[e,n]=$s(this,e,n);let r="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&n>o&&(r+=l.sliceString(e-o,n-o,i)),o=a+1}return r}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof In))return 0;let i=0,[r,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=n,s+=n){if(r==o||s==l)return i;let a=this.children[r],u=e.children[s];if(a!=u)return i+a.scanIdentical(u,n);i+=a.length+1}}static from(e,n=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new Re(d,n)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,u=-1,c=[];function h(d){let p;if(d.lines>s&&d instanceof In)for(let g of d.children)h(g);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof Re&&a&&(p=c[c.length-1])instanceof Re&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new Re(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,u+=d.length+1,c.push(d))}function f(){a!=0&&(l.push(c.length==1?c[0]:In.from(c,u)),u=-1,a=c.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new In(l,n)}}ae.empty=new Re([""],0);function WP(t){let e=-1;for(let n of t)e+=n.length+1;return e}function iu(t,e,n=0,i=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=i;s++){let l=t[s],a=r+l.length;a>=n&&(a>i&&(l=l.slice(0,i-r)),r<n&&(l=l.slice(n-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function xy(t,e,n){return iu(t,[""],e,n)}class Vo{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof Re?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof Re?r.text.length:r.children.length;if(o==(n>0?l:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[i]+=n,e==0)return this.lineBreak=!0,this.value=`
59
+ `,this;e--}else if(r instanceof Re){let a=r.text[o+(n<0?-1:0)];if(this.offsets[i]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Re?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class tS{constructor(e,n,i){this.value="",this.done=!1,this.cursor=new Vo(e,n>i?-1:1),this.pos=n>i?e.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class nS{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:i,value:r}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ae.prototype[Symbol.iterator]=function(){return this.iter()},Vo.prototype[Symbol.iterator]=tS.prototype[Symbol.iterator]=nS.prototype[Symbol.iterator]=function(){return this});class UP{constructor(e,n,i,r){this.from=e,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}}function $s(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function ot(t,e,n=!0,i=!0){return VP(t,e,n,i)}function qP(t){return t>=56320&&t<57344}function KP(t){return t>=55296&&t<56320}function or(t,e){let n=t.charCodeAt(e);if(!KP(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return qP(i)?(n-55296<<10)+(i-56320)+65536:n}function QP(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Wr(t){return t<65536?1:2}const Nd=/\r\n?|\n/;var Rt=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Rt||(Rt={}));class $n{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n+1];e+=i<0?this.sections[n]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,i=0,r=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,n=!1){Ad(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];r<0?e.push(i,r):e.push(r,i)}return new $n(e)}composeDesc(e){return this.empty?e:e.empty?this:iS(this,e)}mapDesc(e,n=!1){return e.empty?this:Md(this,e,n)}mapPos(e,n=-1,i=Rt.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],u=r+l;if(a<0){if(u>e)return s+(e-r);s+=l}else{if(i!=Rt.Simple&&u>=e&&(i==Rt.TrackDel&&r<e&&u>e||i==Rt.TrackBefore&&r<e||i==Rt.TrackAfter&&u>e))return null;if(u>e||u==e&&n<0&&!l)return e==r||n<0?s:s+a;s+=a}r=u}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,n=e){for(let i=0,r=0;i<this.sections.length&&r<=n;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=n&&l>=e)return r<e&&l>n?"cover":!0;r=l}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new $n(e)}static create(e){return new $n(e)}}class ze extends $n{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Ad(this,(n,i,r,s,o)=>e=e.replace(r,r+(i-n),o),!1),e}mapDesc(e,n=!1){return Md(this,e,n,!0)}invert(e){let n=this.sections.slice(),i=[];for(let r=0,s=0;r<n.length;r+=2){let o=n[r],l=n[r+1];if(l>=0){n[r]=l,n[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(ae.empty);i.push(o?e.slice(s,s+o):ae.empty)}s+=o}return new ze(n,i)}compose(e){return this.empty?e:e.empty?this:iS(this,e,!0)}map(e,n=!1){return e.empty?this:Md(this,e,n,!0)}iterChanges(e,n=!1){Ad(this,e,n)}get desc(){return $n.create(this.sections)}filter(e){let n=[],i=[],r=[],s=new Sl(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);it(r,c,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;it(n,c,h),h>0&&_i(i,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l<u;){if(s.done)break e;let c=Math.min(s.len,u-l);it(n,c,-1),it(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new ze(n,i),filtered:$n.create(r)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n],r=this.sections[n+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<n&&it(r,n-o,-1);let h=new ze(r,s);l=l?l.compose(h.map(l)):h,r=[],s=[],o=0}function u(c){if(Array.isArray(c))for(let h of c)u(h);else if(c instanceof ze){if(c.length!=n)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${n})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:h,to:f=h,insert:d}=c;if(h>f||h<0||f>n)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${n})`);let p=d?typeof d=="string"?ae.of(d.split(i||Nd)):d:ae.empty,g=p.length;if(h==f&&g==0)return;h<o&&a(),h>o&&it(r,h-o,-1),it(r,f-h,g),_i(s,r,p),o=f}}return u(e),a(!l),l}static empty(e){return new ze(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;i.length<r;)i.push(ae.empty);i[r]=ae.of(s.slice(1)),n.push(s[0],i[r].length)}}}return new ze(n,i)}static createSet(e,n){return new ze(e,n)}}function it(t,e,n,i=!1){if(e==0&&n<=0)return;let r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function _i(t,e,n){if(n.length==0)return;let i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<i;)t.push(ae.empty);t.push(n)}}function Ad(t,e,n){let i=t.inserted;for(let r=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)r+=l,s+=l;else{let u=r,c=s,h=ae.empty;for(;u+=l,c+=a,a&&i&&(h=h.append(i[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(r,u,s,c,h),r=u,s=c}}}function Md(t,e,n,i=!1){let r=[],s=i?[]:null,o=new Sl(t),l=new Sl(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);it(r,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!n))){let u=l.len;for(it(r,l.ins,-1);u;){let c=Math.min(o.len,u);o.ins>=0&&a<o.i&&o.len<=c&&(it(r,0,o.ins),s&&_i(s,r,o.text),a=o.i),o.forward(c),u-=c}l.next()}else if(o.ins>=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let h=Math.min(c,l.len);u+=h,c-=h,l.forward(h)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;it(r,u,a<o.i?o.ins:0),s&&a<o.i&&_i(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?ze.createSet(r,s):$n.create(r);throw new Error("Mismatched change set lengths")}}}function iS(t,e,n=!1){let i=[],r=n?[]:null,s=new Sl(t),o=new Sl(e);for(let l=!1;;){if(s.done&&o.done)return r?ze.createSet(i,r):$n.create(i);if(s.ins==0)it(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)it(i,0,o.ins,l),r&&_i(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),u=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;it(i,a,c,l),r&&c&&_i(r,i,o.text)}else o.ins==-1?(it(i,s.off?0:s.len,a,l),r&&_i(r,i,s.textBit(a))):(it(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&_i(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>u),s.forward2(a),o.forward(a)}}}}class Sl{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?ae.empty:e[n]}textBit(e){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!e?ae.empty:n[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Si{constructor(e,n,i,r){this.from=e,this.to=n,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,n):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Si(i,r,this.flags,this.goalColumn)}extend(e,n=e,i=0){if(e<=this.anchor&&n>=this.anchor)return W.range(e,n,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return W.range(this.anchor,r,void 0,void 0,i)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return W.range(e.anchor,e.head)}static create(e,n,i,r){return new Si(e,n,i,r)}}class W{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:W.create(this.ranges.map(i=>i.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new W([this.main],0)}addRange(e,n=!0){return W.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let i=this.ranges.slice();return i[n]=e,W.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new W(e.ranges.map(n=>Si.fromJSON(n)),e.main)}static single(e,n=e){return new W([W.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return W.normalized(e.slice(),n);i=s.to}return new W(e,n)}static cursor(e,n=0,i,r){return Si.create(e,e,(n==0?0:n<0?8:16)|(i==null?7:Math.min(6,i)),r)}static range(e,n,i,r,s){let o=r==null?7:Math.min(6,r);return!s&&e!=n&&(s=n<e?1:-1),s&&(o|=s<0?8:16),n<e?Si.create(n,e,o|32,i):Si.create(e,n,o,i)}static undirectionalRange(e,n){return Si.create(e,n,64,void 0)}static normalized(e,n=0){let i=e[n];e.sort((r,s)=>r.from-s.from),n=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=n&&n--,e.splice(--r,2,s.anchor>s.head?W.range(a,l):W.range(l,a))}}return new W(e,n)}}function rS(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Tm=0;class ne{constructor(e,n,i,r,s){this.combine=e,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=Tm++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new ne(e.combine||(n=>n),e.compareInput||((n,i)=>n===i),e.compare||(e.combine?(n,i)=>n===i:Om),!!e.static,e.enables)}of(e){return new ru([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ru(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ru(e,this,2,n)}from(e,n){return n||(n=i=>i),this.compute([e],i=>n(i.field(e)))}}function Om(t,e){return t==e||t.length==e.length&&t.every((n,i)=>n===e[i])}class ru{constructor(e,n,i,r){this.dependencies=e,this.facet=n,this.type=i,this.value=r,this.id=Tm++}dynamicSlot(e){var n;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?u=!0:((n=e[h.id])!==null&&n!==void 0?n:1)&1||c.push(e[h.id]);return{create(h){return h.values[o]=i(h),1},update(h,f){if(a&&f.docChanged||u&&(f.docChanged||f.selection)||Td(h,c)){let d=i(h);if(l?!ky(d,h.values[o],r):!r(d,h.values[o]))return h.values[o]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[s];if(p!=null){let g=qu(f,p);if(this.dependencies.every(x=>x instanceof ne?f.facet(x)===h.facet(x):x instanceof ci?f.field(x,!1)==h.field(x,!1):!0)||(l?ky(d=i(h),g,r):r(d=i(h),g)))return h.values[o]=g,0}else d=i(h);return h.values[o]=d,1}}}get extension(){return this}}function ky(t,e,n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}function Td(t,e){let n=!1;for(let i of e)Ho(t,i)&1&&(n=!0);return n}function YP(t,e,n){let i=n.map(a=>t[a.id]),r=n.map(a=>a.type),s=i.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;c<i.length;c++){let h=qu(a,i[c]);if(r[c]==2)for(let f of h)u.push(f);else u.push(h)}return e.combine(u)}return{create(a){for(let u of i)Ho(a,u);return a.values[o]=l(a),1},update(a,u){if(!Td(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,u){let c=Td(a,i),h=u.config.facets[e.id],f=u.facet(e);if(h&&!c&&Om(n,h))return a.values[o]=f,0;let d=l(a);return e.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}const ka=ne.define({static:!0});class ci{constructor(e,n,i,r,s){this.id=e,this.createF=n,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let n=new ci(Tm++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(ka).find(i=>i.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let s=i.values[n],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[n]=o,1)},reconfigure:(i,r)=>{let s=i.facet(ka),o=r.facet(ka),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[n]=l.create(i),1):r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}}init(e){return[this,ka.of({field:this,create:e})]}get extension(){return this}}const ar={lowest:4,low:3,default:2,high:1,highest:0};function go(t){return e=>new sS(e,t)}const Fl={highest:go(ar.highest),high:go(ar.high),default:go(ar.default),low:go(ar.low),lowest:go(ar.lowest)};class sS{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class Vl{of(e){return new Od(this,e)}reconfigure(e){return Vl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Od{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Uu{constructor(e,n,i,r,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,i){let r=[],s=Object.create(null),o=new Map;for(let f of XP(e,n,o))f instanceof ci?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],u=[];for(let f of r)l[f.id]=u.length<<1,u.push(d=>f.slot(d));let c=i==null?void 0:i.config.facets;for(let f in s){let d=s[f],p=d[0].facet,g=c&&c[f]||[];if(d.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,Om(g,d))a.push(i.facet(p));else{let x=p.combine(d.map(m=>m.value));a.push(i&&p.compare(x,i.facet(p))?i.facet(p):x)}else{for(let x of d)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(m=>x.dynamicSlot(m)));l[p.id]=u.length<<1,u.push(x=>YP(x,p,d))}}let h=u.map(f=>f(l));return new Uu(e,o,h,l,a,s)}}function XP(t,e,n){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let u=i[a].indexOf(o);u>-1&&i[a].splice(u,1),o instanceof Od&&n.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof Od){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof sS)s(o.inner,o.prec);else if(o instanceof ci)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ru)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ar.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,ar.default),i.reduce((o,l)=>o.concat(l))}function Ho(t,e){if(e&1)return 2;let n=e>>1,i=t.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function qu(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const oS=ne.define(),Id=ne.define({combine:t=>t.some(e=>e),static:!0}),lS=ne.define({combine:t=>t.length?t[0]:void 0,static:!0}),aS=ne.define(),uS=ne.define(),cS=ne.define(),hS=ne.define({combine:t=>t.length?t[0]:!1});class Vn{constructor(e,n){this.type=e,this.value=n}static define(){return new GP}}class GP{of(e){return new Vn(this,e)}}class JP{constructor(e){this.map=e}of(e){return new ve(this,e)}}class ve{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new ve(this.type,n)}is(e){return this.type==e}static define(e={}){return new JP(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(n);s&&i.push(s)}return i}}ve.reconfigure=ve.define();ve.appendConfig=ve.define();class Ve{constructor(e,n,i,r,s,o){this.startState=e,this.changes=n,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&rS(i,n.newLength),s.some(l=>l.type==Ve.time)||(this.annotations=s.concat(Ve.time.of(Date.now())))}static create(e,n,i,r,s,o){return new Ve(e,n,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Ve.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Ve.time=Vn.define();Ve.userEvent=Vn.define();Ve.addToHistory=Vn.define();Ve.remote=Vn.define();function ZP(t,e){let n=[];for(let i=0,r=0;;){let s,o;if(i<t.length&&(r==e.length||e[r]>=t[i]))s=t[i++],o=t[i++];else if(r<e.length)s=e[r++],o=e[r++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function fS(t,e,n){var i;let r,s,o;return n?(r=e.changes,s=ze.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=t.selection)===null||i===void 0?void 0:i.map(r),effects:ve.mapEffects(t.effects,r).concat(ve.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Pd(t,e,n){let i=e.selection,r=xs(e.annotations);return e.userEvent&&(r=r.concat(Ve.userEvent.of(e.userEvent))),{changes:e.changes instanceof ze?e.changes:ze.of(e.changes||[],n,t.facet(lS)),selection:i&&(i instanceof W?i:W.single(i.anchor,i.head)),effects:xs(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function dS(t,e,n){let i=Pd(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;i=fS(i,Pd(t,e[s],o?i.changes.newLength:t.doc.length),o)}let r=Ve.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return tR(n?eR(r):r)}function eR(t){let e=t.startState,n=!0;for(let r of e.facet(aS)){let s=r(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:ZP(n,s))}if(n!==!0){let r,s;if(n===!1)s=t.changes.invertedDesc,r=ze.empty(e.doc.length);else{let o=t.changes.filter(n);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=Ve.create(e,r,t.selection&&t.selection.map(s),ve.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let i=e.facet(uS);for(let r=i.length-1;r>=0;r--){let s=i[r](t);s instanceof Ve?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ve?t=s[0]:t=dS(e,xs(s),!1)}return t}function tR(t){let e=t.startState,n=e.facet(cS),i=t;for(let r=n.length-1;r>=0;r--){let s=n[r](t);s&&Object.keys(s).length&&(i=fS(i,Pd(e,s,t.changes.newLength),!0))}return i==t?t:Ve.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const nR=[];function xs(t){return t==null?nR:Array.isArray(t)?t:[t]}var Zn=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Zn||(Zn={}));const iR=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Rd;try{Rd=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function rR(t){if(Rd)return Rd.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||iR.test(n)))return!0}return!1}function sR(t){return e=>{if(!/\S/.test(e))return Zn.Space;if(rR(e))return Zn.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Zn.Word;return Zn.Other}}class ce{constructor(e,n,i,r,s,o){this.config=e,this.doc=n,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Ho(this,l<<1);this.computeSlot=null}field(e,n=!0){let i=this.config.address[e.id];if(i==null){if(n)throw new RangeError("Field is not present in this state");return}return Ho(this,i),qu(this,i)}update(...e){return dS(this,e,!0)}applyTransaction(e){let n=this.config,{base:i,compartments:r}=n;for(let l of e.effects)l.is(Vl.reconfigure)?(n&&(r=new Map,n.compartments.forEach((a,u)=>r.set(u,a)),n=null),r.set(l.value.compartment,l.value.extension)):l.is(ve.reconfigure)?(n=null,i=l.value):l.is(ve.appendConfig)&&(n=null,i=xs(i).concat(l.value));let s;n?s=e.startState.values.slice():(n=Uu.resolve(i,r,this),s=new ce(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Id)?e.newSelection:e.newSelection.asSingle();new ce(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:W.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,i=e(n.ranges[0]),r=this.changes(i.changes),s=[i.range],o=xs(i.effects);for(let l=1;l<n.ranges.length;l++){let a=e(n.ranges[l]),u=this.changes(a.changes),c=u.map(r);for(let f=0;f<l;f++)s[f]=s[f].map(c);let h=r.mapDesc(u,!0);s.push(a.range.map(h)),r=r.compose(c),o=ve.mapEffects(o,c).concat(ve.mapEffects(xs(a.effects),h))}return{changes:r,selection:W.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof ze?e:ze.of(e,this.doc.length,this.facet(ce.lineSeparator))}toText(e){return ae.of(e.split(this.facet(ce.lineSeparator)||Nd))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Ho(this,n),qu(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof ci&&this.config.address[r.id]!=null&&(n[i]=r.spec.toJSON(this.field(e[i]),this))}return n}static fromJSON(e,n={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return ce.create({doc:e.doc,selection:W.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(e={}){let n=Uu.resolve(e.extensions||[],new Map),i=e.doc instanceof ae?e.doc:ae.of((e.doc||"").split(n.staticFacet(ce.lineSeparator)||Nd)),r=e.selection?e.selection instanceof W?e.selection:W.single(e.selection.anchor,e.selection.head):W.single(0);return rS(r,i.length),n.staticFacet(Id)||(r=r.asSingle()),new ce(n,i,r,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(ce.tabSize)}get lineBreak(){return this.facet(ce.lineSeparator)||`
60
+ `}get readOnly(){return this.facet(hS)}phrase(e,...n){for(let i of this.facet(ce.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>n.length?i:n[s-1]})),e}languageDataAt(e,n,i=-1){let r=[];for(let s of this.facet(oS))for(let o of s(this,n,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return sR(n.length?n[0]:"")}wordAt(e){let{text:n,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=ot(n,o,!1);if(s(n.slice(a,o))!=Zn.Word)break;o=a}for(;l<r;){let a=ot(n,l);if(s(n.slice(l,a))!=Zn.Word)break;l=a}return o==l?null:W.range(o+i,l+i)}}ce.allowMultipleSelections=Id;ce.tabSize=ne.define({combine:t=>t.length?t[0]:4});ce.lineSeparator=lS;ce.readOnly=hS;ce.phrases=ne.define({compare(t,e){let n=Object.keys(t),i=Object.keys(e);return n.length==i.length&&n.every(r=>t[r]==e[r])}});ce.languageData=oS;ce.changeFilter=aS;ce.transactionFilter=uS;ce.transactionExtender=cS;Vl.reconfigure=ve.define();function pS(t,e,n={}){let i={};for(let r of t)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))i[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class zi{eq(e){return this==e}range(e,n=e){return Dd.create(e,n,this)}}zi.prototype.startSide=zi.prototype.endSide=0;zi.prototype.point=!1;zi.prototype.mapMode=Rt.TrackDel;function Im(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Dd=class mS{constructor(e,n,i){this.from=e,this.to=n,this.value=i}static create(e,n,i){return new mS(e,n,i)}};function Ld(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Pm{constructor(e,n,i,r){this.from=e,this.to=n,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,n,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,i,r){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,n){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let u=this.value[a],c=this.from[a]+e,h=this.to[a]+e,f,d;if(c==h){let p=n.mapPos(c,u.startSide,u.mapMode);if(p==null||(f=d=p,u.startSide!=u.endSide&&(d=n.mapPos(c,u.endSide),d<f)))continue}else if(f=n.mapPos(c,u.startSide),d=n.mapPos(h,u.endSide),f>d||f==d&&u.startSide>0&&u.endSide<=0)continue;(d-f||u.endSide-u.startSide)<0||(o<0&&(o=f),u.point&&(l=Math.max(l,d-f)),i.push(u),r.push(f-o),s.push(d-o))}return{mapped:i.length?new Pm(r,s,i,l):null,pos:o}}}class fe{constructor(e,n,i,r){this.chunkPos=e,this.chunk=n,this.nextLayer=i,this.maxPoint=r}static create(e,n,i,r){return new fe(e,n,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(i&&(n=n.slice().sort(Ld)),this.isEmpty)return n.length?fe.of(n):this;let l=new gS(this,null,-1).goto(0),a=0,u=[],c=new bl;for(;l.value||a<n.length;)if(a<n.length&&(l.from-n[a].from||l.startSide-n[a].value.startSide)>=0){let h=n[a++];c.addInner(h.from,h.to,h.value)||u.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==n.length||this.chunkEnd(l.chunkIndex)<n[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||u.push(Dd.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!u.length?fe.empty:this.nextLayer.update({add:u,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let n=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],u=e.touchesRange(l,l+a.length);if(u===!1)r=Math.max(r,a.maxPoint),n.push(a),i.push(e.mapPos(l));else if(u===!0){let{mapped:c,pos:h}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),n.push(c),i.push(h))}}let s=this.nextLayer.map(e);return n.length==0?s:new fe(i,n,s||fe.empty,r)}between(e,n,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(n>=s&&e<=s+o.length&&o.between(s,e-s,n-s,i)===!1)return}this.nextLayer.between(e,n,i)}}iter(e=0){return Cl.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Cl.from(e).goto(n)}static compare(e,n,i,r,s=-1){let o=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=s),l=n.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=s),a=Sy(o,l,i),u=new yo(o,a,s),c=new yo(l,a,s);i.iterGaps((h,f,d)=>by(u,h,c,f,d,r)),i.empty&&i.length==0&&by(u,0,c,0,0,r)}static eq(e,n,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Sy(s,o),a=new yo(s,l,0).goto(i),u=new yo(o,l,0).goto(i);for(;;){if(a.to!=u.to||!Bd(a.active,u.active)||a.point&&(!u.point||!Im(a.point,u.point)))return!1;if(a.to>r)return!0;a.next(),u.next()}}static spans(e,n,i,r,s=-1){let o=new yo(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),h=o.pointFrom<n?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);r.point(l,u,o.point,c,h,o.pointRank),a=Math.min(o.openEnd(u),c.length)}else u>l&&(r.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,n=!1){let i=new bl;for(let r of e instanceof Dd?[e]:n?oR(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return fe.empty;let n=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=fe.empty;r=r.nextLayer)n=new fe(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}fe.empty=new fe([],[],null,-1);function oR(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let i=t[n];if(Ld(e,i)>0)return t.slice().sort(Ld);e=i}return t}fe.empty.nextLayer=fe.empty;class bl{finishChunk(e){this.chunks.push(new Pm(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,i){this.addInner(e,n,i)||(this.nextLayer||(this.nextLayer=new bl)).add(e,n,i)}addInner(e,n,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=n,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let i=n.value.length-1;return this.last=n.value[i],this.lastFrom=n.from[i]+e,this.lastTo=n.to[i]+e,!0}finish(){return this.finishInner(fe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=fe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Sy(t,e,n){let i=new Map;for(let s of t)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(n?n.mapPos(l):l)==s.chunkPos[o]&&!(n!=null&&n.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}class gS{constructor(e,n,i,r=0){this.layer=e,this.skip=n,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,n=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,n,!1),this}gotoInner(e,n,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],n,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,n){(this.to-e||this.endSide-n)<0&&this.gotoInner(e,n,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],n=this.layer.chunk[this.chunkIndex],i=e+n.from[this.rangeIndex];if(this.from=i,this.to=e+n.to[this.rangeIndex],this.value=n.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Cl{constructor(e){this.heap=e}static from(e,n=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new gS(o,n,i,s));return r.length==1?r[0]:new Cl(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let i of this.heap)i.goto(e,n);for(let i=this.heap.length>>1;i>=0;i--)Vh(this.heap,i);return this.next(),this}forward(e,n){for(let i of this.heap)i.forward(e,n);for(let i=this.heap.length>>1;i>=0;i--)Vh(this.heap,i);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Vh(this.heap,0)}}}function Vh(t,e){for(let n=t[e];;){let i=(e<<1)+1;if(i>=t.length)break;let r=t[i];if(i+1<t.length&&r.compare(t[i+1])>=0&&(r=t[i+1],i++),n.compare(r)<0)break;t[i]=n,t[e]=r,e=i}}class yo{constructor(e,n,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Cl.from(e,n,i)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Sa(this.active,e),Sa(this.activeTo,e),Sa(this.activeRank,e),this.minActive=Cy(this.active,this.activeTo)}addActive(e){let n=0,{value:i,to:r,rank:s}=this.cursor;for(;n<this.activeRank.length&&(s-this.activeRank[n]||r-this.activeTo[n])>0;)n++;ba(this.active,n,i),ba(this.activeTo,n,r),ba(this.activeRank,n,s),e&&ba(e,n,this.cursor.from),this.minActive=Cy(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Sa(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let n=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&n.push(this.active[i]);return n.reverse()}openEnd(e){let n=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)n++;return n}}function by(t,e,n,i,r,s){t.goto(e),n.goto(i);let o=i+r,l=i,a=i-e,u=!!s.boundChange;for(let c=!1;;){let h=t.to+a-n.to,f=h||t.endSide-n.endSide,d=f<0?t.to+a:n.to,p=Math.min(d,o);if(t.point||n.point?(t.point&&n.point&&Im(t.point,n.point)&&Bd(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!Bd(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&p<o&&(h||t.openEnd(d)!=n.openEnd(d))&&(c=!0)),d>o)break;l=d,f<=0&&t.next(),f>=0&&n.next()}}function Bd(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!Im(t[n],e[n]))return!1;return!0}function Sa(t,e){for(let n=e,i=t.length-1;n<i;n++)t[n]=t[n+1];t.pop()}function ba(t,e,n){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=n}function Cy(t,e){let n=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||t[r].endSide-t[n].endSide)<0&&(n=r,i=e[r]);return n}function $c(t,e,n=t.length){let i=0;for(let r=0;r<n&&r<t.length;)t.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=ot(t,r));return i}function lR(t,e,n,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==t.length)break;s+=t.charCodeAt(r)==9?n-s%n:1,r=ot(t,r)}return t.length}const jd="ͼ",Ey=typeof Symbol>"u"?"__"+jd:Symbol.for(jd),$d=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),_y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Fi{constructor(e,n){this.rules=[];let{finish:i}=n||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],h=/^@(\w+)\b/.exec(o[0]),f=h&&h[1]=="keyframes";if(h&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(g=>o.map(x=>g.replace(/&/,x))).reduce((g,x)=>g.concat(x)),p,a);else if(p&&typeof p=="object"){if(!h)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,c,f)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||f)&&a.push((i&&!h&&!u?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
61
+ `)}static newName(){let e=_y[Ey]||1;return _y[Ey]=e+1,jd+e.toString(36)}static mount(e,n,i){let r=e[$d],s=i&&i.nonce;r?s&&r.setNonce(s):r=new aR(e,s),r.mount(Array.isArray(n)?n:[n],e)}}let Ny=new Map;class aR{constructor(e,n){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Ny.get(i);if(s)return e[$d]=s;this.sheet=new r.CSSStyleSheet,Ny.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[$d]=this}mount(e,n){let i=this.sheet,r=0,s=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),i)for(let u=0;u<l.rules.length;u++)i.insertRule(l.rules[u],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=l.rules.length,s++}}if(i)n.adoptedStyleSheets.indexOf(this.sheet)<0&&(n.adoptedStyleSheets=[this.sheet,...n.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
62
+ `;this.styleTag.textContent=o;let l=n.head||n;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Vi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},El={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},uR=typeof navigator<"u"&&/Mac/.test(navigator.platform),cR=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ge=0;Ge<10;Ge++)Vi[48+Ge]=Vi[96+Ge]=String(Ge);for(var Ge=1;Ge<=24;Ge++)Vi[Ge+111]="F"+Ge;for(var Ge=65;Ge<=90;Ge++)Vi[Ge]=String.fromCharCode(Ge+32),El[Ge]=String.fromCharCode(Ge);for(var Hh in Vi)El.hasOwnProperty(Hh)||(El[Hh]=Vi[Hh]);function hR(t){var e=uR&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||cR&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?El:Vi)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let ft=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zd=typeof document<"u"?document:{documentElement:{style:{}}};const Fd=/Edge\/(\d+)/.exec(ft.userAgent),yS=/MSIE \d/.test(ft.userAgent),Vd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ft.userAgent),zc=!!(yS||Vd||Fd),Ay=!zc&&/gecko\/(\d+)/i.test(ft.userAgent),Wh=!zc&&/Chrome\/(\d+)/.exec(ft.userAgent),My="webkitFontSmoothing"in zd.documentElement.style,Hd=!zc&&/Apple Computer/.test(ft.vendor),Ty=Hd&&(/Mobile\/\w+/.test(ft.userAgent)||ft.maxTouchPoints>2);var Q={mac:Ty||/Mac/.test(ft.platform),windows:/Win/.test(ft.platform),linux:/Linux|X11/.test(ft.platform),ie:zc,ie_version:yS?zd.documentMode||6:Vd?+Vd[1]:Fd?+Fd[1]:0,gecko:Ay,gecko_version:Ay?+(/Firefox\/(\d+)/.exec(ft.userAgent)||[0,0])[1]:0,chrome:!!Wh,chrome_version:Wh?+Wh[1]:0,ios:Ty,android:/Android\b/.test(ft.userAgent),webkit:My,webkit_version:My?+(/\bAppleWebKit\/(\d+)/.exec(ft.userAgent)||[0,0])[1]:0,safari:Hd,safari_version:Hd?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ft.userAgent)||[0,0])[1]:0,tabSize:zd.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Rm(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Ku=Object.create(null);function Dm(t,e,n){if(t==e)return!0;t||(t=Ku),e||(e=Ku);let i=Object.keys(t),r=Object.keys(e);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=n&&(r.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function fR(t,e){for(let n=t.attributes.length-1;n>=0;n--){let i=t.attributes[n].name;e[i]==null&&t.removeAttribute(i)}for(let n in e){let i=e[n];n=="style"?t.style.cssText=i:t.getAttribute(n)!=i&&t.setAttribute(n,i)}}function Oy(t,e,n){let i=!1;if(e)for(let r in e)n&&r in n||(i=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(i=!0,r=="style"?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return i}function dR(t){let e=Object.create(null);for(let n=0;n<t.attributes.length;n++){let i=t.attributes[n];e[i.name]=i.value}return e}class Hl{eq(e){return!1}updateDOM(e,n,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,n,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Gt=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Gt||(Gt={}));class Ie extends zi{constructor(e,n,i,r){super(),this.startSide=e,this.endSide=n,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Wl(e)}static widget(e){let n=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return n+=i&&!e.inlineOrder?n>0?3e8:-4e8:n>0?1e8:-1e8,new Ar(e,n,n,i,e.widget||null,!1)}static replace(e){let n=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=vS(e,n);i=(s?n?-3e8:-1:5e8)-1,r=(o?n?2e8:1:-6e8)+1}return new Ar(e,i,r,n,e.widget||null,!0)}static line(e){return new Ul(e)}static set(e,n=!1){return fe.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Ie.none=fe.empty;class Wl extends Ie{constructor(e){let{start:n,end:i}=vS(e);super(n?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Rm(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ku}eq(e){return this==e||e instanceof Wl&&this.tagName==e.tagName&&Dm(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Wl.prototype.point=!1;class Ul extends Ie{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ul&&this.spec.class==e.spec.class&&Dm(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Ul.prototype.mapMode=Rt.TrackBefore;Ul.prototype.point=!0;class Ar extends Ie{constructor(e,n,i,r,s,o){super(n,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?n<=0?Rt.TrackBefore:Rt.TrackAfter:Rt.TrackDel}get type(){return this.startSide!=this.endSide?Gt.WidgetRange:this.startSide<=0?Gt.WidgetBefore:Gt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ar&&pR(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}Ar.prototype.point=!0;function vS(t,e=!1){let{inclusiveStart:n,inclusiveEnd:i}=t;return n==null&&(n=t.inclusive),i==null&&(i=t.inclusive),{start:n??e,end:i??e}}function pR(t,e){return t==e||!!(t&&e&&t.compare(e))}function ks(t,e,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=t?n[r]=Math.max(n[r],e):n.push(t,e)}class _l extends zi{constructor(e,n,i){super(),this.tagName=e,this.attributes=n,this.rank=i}eq(e){return e==this||e instanceof _l&&this.tagName==e.tagName&&Dm(this.attributes,e.attributes)}static create(e){return new _l(e.tagName,e.attributes||Ku,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return fe.of(e,n)}}_l.prototype.startSide=_l.prototype.endSide=-1;function Nl(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Wd(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Wo(t,e){if(!e.anchorNode)return!1;try{return Wd(t,e.anchorNode)}catch{return!1}}function su(t){return t.nodeType==3?Al(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Uo(t,e,n,i){return n?Iy(t,e,n,i,-1)||Iy(t,e,n,i,1):!1}function Hi(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Qu(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Iy(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:ai(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Hi(t)+(r<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=r<0?ai(t):0}else return!1}}function ai(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Yu(t,e){let{left:n,right:i}=t;if(n==i)return t;let r=e?n:i;return{left:r,right:r,top:t.top,bottom:t.bottom}}function mR(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function wS(t,e){let n=e.width/t.offsetWidth,i=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-t.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function gR(t,e,n,i,r,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,h=!1;c&&!h;)if(c.nodeType==1){let f,d=c==a.body,p=1,g=1;if(d)f=mR(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(h=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let v=c.getBoundingClientRect();({scaleX:p,scaleY:g}=wS(c,v)),f={left:v.left,right:v.left+c.clientWidth*p,top:v.top,bottom:v.top+c.clientHeight*g}}let x=0,m=0;if(r=="nearest")e.top<f.top+o?(m=e.top-(f.top+o),n>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+o)):e.bottom>f.bottom-o&&(m=e.bottom-f.bottom+o,n<0&&e.top-m<f.top&&(m=e.top-(f.top+o)));else{let v=e.bottom-e.top,w=f.bottom-f.top;m=(r=="center"&&v<=w?e.top+v/2-w/2:r=="start"||r=="center"&&n<0?e.top-o:e.bottom-w+o)-f.top}if(i=="nearest"?e.left<f.left+s?(x=e.left-(f.left+s),n>0&&e.right>f.right+x&&(x=e.right-f.right+s)):e.right>f.right-s&&(x=e.right-f.right+s,n<0&&e.left<f.left+x&&(x=e.left-(f.left+s))):x=(i=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:i=="start"==l?e.left-s:e.right-(f.right-f.left)+s)-f.left,x||m)if(d)u.scrollBy(x,m);else{let v=0,w=0;if(m){let k=c.scrollTop;c.scrollTop+=m/g,w=(c.scrollTop-k)*g}if(x){let k=c.scrollLeft;c.scrollLeft+=x/p,v=(c.scrollLeft-k)*p}e={left:e.left-v,top:e.top-w,right:e.right-v,bottom:e.bottom-w},v&&Math.abs(v-x)<1&&(i="nearest"),w&&Math.abs(w-m)<1&&(r="nearest")}if(d)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function xS(t,e=!0){let n=t.ownerDocument,i=null,r=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class yR{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:i}=e;this.set(n,Math.min(e.anchorOffset,n?ai(n):0),i,Math.min(e.focusOffset,i?ai(i):0))}set(e,n,i,r){this.anchorNode=e,this.anchorOffset=n,this.focusNode=i,this.focusOffset=r}}function kS(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function SS(t,e=!0){for(let{node:n,left:i,top:r}of t)e&&n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}let lr=null;Q.safari&&Q.safari_version>=26&&(lr=!1);function bS(t){if(t.setActive)return t.setActive();if(lr)return t.focus(lr);let e=kS(t);t.focus(lr==null?{get preventScroll(){return lr={preventScroll:!0},!0}}:void 0),lr||(lr=!1,SS(e))}let Py;function Al(t,e,n=e){let i=Py||(Py=document.createRange());return i.setEnd(t,n),i.setStart(t,e),i}function Ss(t,e,n,i){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function vR(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function wR(t,e){let n=e.focusNode,i=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=i)return!1;for(i=Math.min(i,ai(n));;)if(i){if(n.nodeType!=1)return!1;let r=n.childNodes[i-1];r.contentEditable=="false"?i--:(n=r,i=ai(n))}else{if(n==t)return!0;i=Hi(n),n=n.parentNode}}function CS(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function ES(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i>0)return{node:n,offset:i};if(n.nodeType==1&&i>0){if(n.contentEditable=="false")return null;n=n.childNodes[i-1],i=ai(n)}else if(n.parentNode&&!Qu(n))i=Hi(n),n=n.parentNode;else return null}}function _S(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i<n.nodeValue.length)return{node:n,offset:i};if(n.nodeType==1&&i<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[i],i=0}else if(n.parentNode&&!Qu(n))i=Hi(n)+1,n=n.parentNode;else return null}}class fn{constructor(e,n,i=!0){this.node=e,this.offset=n,this.precise=i}static before(e,n){return new fn(e.parentNode,Hi(e),n)}static after(e,n){return new fn(e.parentNode,Hi(e)+1,n)}}var Oe=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Oe||(Oe={}));const Mr=Oe.LTR,Lm=Oe.RTL;function NS(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<+t[n]);return e}const xR=NS("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),kR=NS("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ud=Object.create(null),En=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);Ud[e]=n,Ud[n]=-e}function AS(t){return t<=247?xR[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?kR[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const SR=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Rn{get dir(){return this.level%2?Lm:Mr}constructor(e,n,i){this.from=e,this.to=n,this.level=i}side(e,n){return this.dir==n==e?this.to:this.from}forward(e,n){return e==(this.dir==n)}static find(e,n,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=n&&l.to>=n){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<n:l.to>n:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function MS(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let i=t[n],r=e[n];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!MS(i.inner,r.inner))return!1}return!0}const me=[];function bR(t,e,n,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:n,a=s?256:r;for(let u=o,c=a,h=a;u<l;u++){let f=AS(t.charCodeAt(u));f==512?f=c:f==8&&h==4&&(f=16),me[u]=f==4?2:f,f&7&&(h=f),c=f}for(let u=o,c=a,h=a;u<l;u++){let f=me[u];if(f==128)u<l-1&&c==me[u+1]&&c&24?f=me[u]=c:me[u]=256;else if(f==64){let d=u+1;for(;d<l&&me[d]==64;)d++;let p=u&&c==8||d<n&&me[d]==8?h==1?1:8:256;for(let g=u;g<d;g++)me[g]=p;u=d-1}else f==8&&h==1&&(me[u]=1);c=f,f&7&&(h=f)}}}function CR(t,e,n,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let u=o?i[o-1].to:e,c=o<i.length?i[o].from:n;for(let h=u,f,d,p;h<c;h++)if(d=Ud[f=t.charCodeAt(h)])if(d<0){for(let g=l-3;g>=0;g-=3)if(En[g+1]==-d){let x=En[g+2],m=x&2?r:x&4?x&1?s:r:0;m&&(me[h]=me[En[g]]=m),l=g;break}}else{if(En.length==189)break;En[l++]=h,En[l++]=f,En[l++]=a}else if((p=me[h])==2||p==1){let g=p==r;a=g?0:1;for(let x=l-3;x>=0;x-=3){let m=En[x+2];if(m&2)break;if(g)En[x+2]|=2;else{if(m&4)break;En[x+2]|=4}}}}}function ER(t,e,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:t,l=r<n.length?n[r].from:e;for(let a=o;a<l;){let u=me[a];if(u==256){let c=a+1;for(;;)if(c==l){if(r==n.length)break;c=n[r++].to,l=r<n.length?n[r].from:e}else if(me[c]==256)c++;else break;let h=s==1,f=(c<e?me[c]:i)==1,d=h==f?h?1:2:i;for(let p=c,g=r,x=g?n[g-1].to:t;p>a;)p==x&&(p=n[--g].from,x=g?n[g-1].to:t),me[--p]=d;a=c}else s=u,a++}}}function qd(t,e,n,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,u=0;a<n;){let c=!0,h=!1;if(u==s.length||a<s[u].from){let g=me[a];g!=l&&(c=!1,h=g==16)}let f=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(u<s.length&&p==s[u].from){if(h)break e;let g=s[u];if(!c)for(let x=g.to,m=u+1;;){if(x==n)break e;if(m<s.length&&s[m].from==x)x=s[m++].to;else{if(me[x]==l)break e;break}}if(u++,f)f.push(g);else{g.from>a&&o.push(new Rn(a,g.from,d));let x=g.direction==Mr!=!(d%2);Kd(t,x?i+1:i,r,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==n||(c?me[p]!=l:me[p]==l))break;p++}f?qd(t,a,p,i+1,r,f,o):a<p&&o.push(new Rn(a,p,d)),a=p}else for(let a=n,u=s.length;a>e;){let c=!0,h=!1;if(!u||a>s[u-1].to){let g=me[a-1];g!=l&&(c=!1,h=g==16)}let f=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(h)break e;let g=s[--u];if(!c)for(let x=g.from,m=u;;){if(x==e)break e;if(m&&s[m-1].to==x)x=s[--m].from;else{if(me[x-1]==l)break e;break}}if(f)f.push(g);else{g.to<a&&o.push(new Rn(g.to,a,d));let x=g.direction==Mr!=!(d%2);Kd(t,x?i+1:i,r,g.inner,g.from,g.to,o),a=g.from}p=g.from}else{if(p==e||(c?me[p-1]!=l:me[p-1]==l))break;p--}f?qd(t,p,a,i+1,r,f,o):p<a&&o.push(new Rn(p,a,d)),a=p}}function Kd(t,e,n,i,r,s,o){let l=e%2?2:1;bR(t,r,s,i,l),CR(t,r,s,i,l),ER(r,s,i,l),qd(t,r,s,e,n,i,o)}function _R(t,e,n){if(!t)return[new Rn(0,0,e==Lm?1:0)];if(e==Mr&&!n.length&&!SR.test(t))return TS(t.length);if(n.length)for(;t.length>me.length;)me[me.length]=256;let i=[],r=e==Mr?0:1;return Kd(t,r,r,n,0,t.length,i),i}function TS(t){return[new Rn(0,t,0)]}let OS="";function NR(t,e,n,i,r){var s;let o=i.head-t.from,l=Rn.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],u=a.side(r,n);if(o==u){let f=l+=r?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!r,n),u=a.side(r,n)}let c=ot(t.text,o,a.forward(r,n));(c<a.from||c>a.to)&&(c=u),OS=t.text.slice(Math.min(o,c),Math.max(o,c));let h=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return h&&c==u&&h.level+(r?0:1)<a.level?W.cursor(h.side(!r,n)+t.from,h.forward(r,n)?1:-1,h.level):W.cursor(c+t.from,a.forward(r,n)?-1:1,a.level)}function AR(t,e,n){for(let i=e;i<n;i++){let r=AS(t.charCodeAt(i));if(r==1)return Mr;if(r==2||r==4)return Lm}return Mr}const IS=ne.define(),PS=ne.define(),RS=ne.define(),DS=ne.define(),Qd=ne.define(),LS=ne.define(),BS=ne.define(),Bm=ne.define(),jm=ne.define(),jS=ne.define({combine:t=>t.some(e=>e)}),MR=ne.define({combine:t=>t.some(e=>e)}),$S=ne.define();class bs{constructor(e,n,i,r,s,o=!1){this.range=e,this.y=n,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new bs(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new bs(W.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ca=ve.define({map:(t,e)=>t.map(e)}),zS=ve.define();function Lt(t,e,n){let i=t.facet(DS);i.length?i[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Yn=ne.define({combine:t=>t.length?t[0]:!0});let TR=0;const ss=ne.define({combine(t){return t.filter((e,n)=>{for(let i=0;i<n;i++)if(t[i].plugin==e.plugin)return!1;return!0})}});class zn{constructor(e,n,i,r,s){this.id=e,this.create=n,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(ss.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(ss.of({plugin:this,arg:e}))}static define(e,n){const{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=n||{};return new zn(TR++,e,i,r,l=>{let a=[];return o&&a.push(Fc.of(u=>{let c=u.plugin(l);return c?o(c):Ie.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return zn.define((i,r)=>new e(i,r),n)}}class Uh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(i){if(Lt(n.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Lt(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(i){Lt(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const FS=ne.define(),$m=ne.define(),Fc=ne.define(),VS=ne.define(),zm=ne.define(),ql=ne.define(),HS=ne.define();function Ry(t,e){let n=t.state.facet(HS);if(!n.length)return n;let i=n.map(s=>s instanceof Function?s(t):s),r=[];return fe.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,h=r;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,p;if(d==null&&(d=AR(e.text,u,c)),a>0&&h.length&&(p=h[h.length-1]).to==u&&p.direction==d)p.to=c,h=p.inner;else{let g={from:u,to:c,direction:d,inner:[]};h.push(g),h=g.inner}}}}),r}const WS=ne.define();function Fm(t){let e=0,n=0,i=0,r=0;for(let s of t.state.facet(WS)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:n,top:i,bottom:r}}const Oo=ne.define();class Kt{constructor(e,n,i,r){this.fromA=e,this.toA=n,this.fromB=i,this.toB=r}join(e){return new Kt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,i=this;for(;n>0;n--){let r=e[n-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(n-1,1)}}return e.splice(n,0,i),e}static extendWithRanges(e,n){if(n.length==0)return e;let i=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<n.length?n[s]:1e9,u=Math.min(l,a);if(u==1e9)break;let c=u+o,h=u,f=c;for(;;)if(s<n.length&&n[s]<=h){let d=n[s+1];s+=2,h=Math.max(h,d);for(let p=r;p<e.length&&e[p].fromB<=h;p++)o=e[p].toA-e[p].toB;f=Math.max(f,d+o)}else if(r<e.length&&e[r].fromB<=h){let d=e[r++];h=Math.max(h,d.toB),f=Math.max(f,d.toA),o=d.toA-d.toB}else break;i.push(new Kt(c,f,u,h))}return i}}class Xu{constructor(e,n,i){this.view=e,this.state=n,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ze.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new Kt(s,o,l,a))),this.changedRanges=r}static create(e,n,i){return new Xu(e,n,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const OR=[];class Pe{constructor(e,n,i=0){this.dom=e,this.length=n,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return OR}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&fR(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let i=n;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,i){return null}domPosFor(e,n){let i=Hi(this.dom),r=this.length?e>0:n>0;return new fn(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Hc)return e;return null}static get(e){return e.cmTile}}class Vc extends Pe{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,i=null,r,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:n.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;r&&r!=l.dom;)r=Dy(r);else n.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:n.firstChild,s&&r&&(s.written=!0);r;)r=Dy(r);this.length=o}}function Dy(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Hc extends Vc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Pe.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!n.length)return;i=i.parent,i.breakAfter&&s++,r=n.pop()}else{let o=i.children[r++];if(o instanceof ti)n.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==u&&(n<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,r=e-a),(u>e||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&n<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}}class ti extends Vc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let i=new ti(n||document.createElement(e.tagName),e);return n||(i.flags|=4),i}}class zs extends Vc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,i){let r=new zs(n||document.createElement("div"),e);return(!n||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,n,i){let r=null,s=-1,o=null,l=-1;function a(c,h){for(let f=0,d=0;f<c.children.length&&d<=h;f++){let p=c.children[f],g=d+p.length;g>=h&&(p.isComposite()?a(p,h-d):(!o||o.isHidden&&(n>0&&!(o.flags&32)||i&&PR(o,p)))&&(g>h||p.flags&32&&n<=1)?(o=p,l=h-d):(d<h||p.flags&16&&!p.isHidden&&n>=-1)&&(r=p,s=h-d)),d=g}}a(this,e);let u=(n<0?r:o)||r||o;return u?{tile:u,offset:u==r?s:l}:null}coordsIn(e,n,i){let r=this.resolveInline(e,n,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),n,i):IR(this)}domIn(e,n){let i=this.resolveInline(e,n);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new fn(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:n);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new fn(a.dom,0);a==i.tile&&(l=!0)}}return new fn(this.dom,0)}}function IR(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=su(e);return n[n.length-1]||null}function PR(t,e){let n=t.coordsIn(0,1),i=e.coordsIn(0,1);return n&&i&&i.top<n.bottom}class St extends Vc{constructor(e,n){super(e),this.mark=n}get domAttrs(){return this.mark.attrs}static of(e,n){let i=new St(n||document.createElement(e.tagName),e);return n||(i.flags|=4),i}}class pr extends Pe{constructor(e,n){super(e,n.length),this.text=n}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,n,i){let r=this.dom.nodeValue.length;e>r&&(e=r);let s=e,o=e,l=0;e==0&&n<0||e==r&&n>=0?Q.chrome||Q.gecko||(e?(s--,l=1):o<r&&(o++,l=-1)):n<0?s--:o<r&&o++;let a=Al(this.dom,s,o).getClientRects();if(!a.length)return null;let u=a[(l?l<0:n>=0)?0:a.length-1];return Q.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),i==null?u:Yu(u,(l?l>0:n<0)==i)}static of(e,n){let i=new pr(n||document.createTextNode(e),e);return n||(i.flags|=2),i}}class Tr extends Pe{constructor(e,n,i,r){super(e,n,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,i){let r=this.widget.coordsAt(this.dom,e,n);if(r)return r;if(i)return Yu(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return Yu(o,!l)}}get overrideDOMText(){if(!this.length)return ae.empty;let{root:e}=this;if(!e)return ae.empty;let n=this.posAtStart;return e.view.state.doc.slice(n,n+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,n,i,r,s){return s||(s=e.toDOM(n),e.editable||(s.contentEditable="false")),new Tr(s,i,e,r)}}class Gu extends Pe{constructor(e){let n=document.createElement("img");n.className="cm-widgetBuffer",n.setAttribute("aria-hidden","true"),super(n,0,e)}get isHidden(){return!0}get overrideDOMText(){return ae.empty}coordsIn(e,n,i){let r=this.dom.getBoundingClientRect();return i==null?r:Yu(r,n>0==i)}}class RR{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!u,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,i&&a.isComposite()&&i.enter(a))}else{let a=r.length;if(s<a&&e){let u=Math.min(e,a-s);i&&i.skip(r,s,s+u),e-=u,s+=u}if(s==a)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(!e)break}return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class DR{constructor(e,n,i,r){this.from=e,this.to=n,this.wrapper=i,this.rank=r}}class LR{constructor(e,n,i){this.cache=e,this.root=n,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,n,i,r){var s;this.flushBuffer();let o=this.ensureMarks(n,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new pr(l.dom,l.text+e);a.parent=o}else o.append(r||pr.of(e,(s=this.cache.find(pr))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,n){let i=this.curLine;i.dom!=n.line.dom&&(i.setDOM(this.cache.reused.has(n.line)?qh(n.line.dom):n.line.dom),this.cache.reused.set(n.line,2));let r=i;for(let l=n.marks.length-1;l>=0;l--){let a=n.marks[l],u=r.lastChild;if(u instanceof St&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(qh(a.dom)),r=u;else{if(this.cache.reused.get(a)){let h=Pe.get(a.dom);h&&h.setDOM(qh(a.dom))}let c=St.of(a.mark,a.dom);r.append(c),r=c}this.cache.reused.set(a,2)}let s=Pe.get(e.text);s&&this.cache.reused.set(s,2);let o=new pr(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,n,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(n,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,i){this.flushBuffer(),this.ensureMarks(n,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var i;e||(e=US);let r=zs.start(e,n||((i=this.cache.find(zs))===null||i===void 0?void 0:i.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=r.lastChild)&&l instanceof St&&l.mark.eq(o))r=l,n--;else{let a=St.of(o,(i=this.cache.find(St,u=>u.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Ly(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Q.ios&&Ly(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Kh,0,32)||new Tr(Kh.toDOM(),0,Kh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let n=e.rank*102+e.value.rank,i=new DR(e.from,e.to,e.value,n),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let i of this.wrappers){let r=n.lastChild;if(i.from<this.pos&&r instanceof ti&&r.wrapper.eq(i.wrapper))n=r;else{let s=ti.of(i.wrapper,(e=this.cache.find(ti,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),i=this.cache.find(Gu,void 0,1);return i&&(i.flags=n),i||new Gu(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class BR{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,n);return this.textOff=n,i}}const Ju=[Tr,zs,pr,St,Gu,ti,Hc];for(let t=0;t<Ju.length;t++)Ju[t].bucket=t;class jR{constructor(e){this.view=e,this.buckets=Ju.map(()=>[]),this.index=Ju.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,i=this.buckets[n];i.length<6?i.push(e):i[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l<s.length;l++){let a=(l+o)%s.length,u=s[a];if((!n||n(u))&&!this.reused.has(u))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(u,i),u}return null}findWidget(e,n,i){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==n&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Tr(l.dom,n,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,n=2){if(!this.reused.has(e))return this.reused.set(e,n),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class $R{constructor(e,n,i,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new jR(e),this.text=new BR(e.state.doc),this.builder=new LR(this.cache,new Hc(e,e.contentDOM),fe.iter(i)),this.cache.reused.set(n,2),this.old=new RR(n),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let i=n&&this.getCompositionContext(n.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let u=a-r;this.preserve(u,!o,!l),r=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA<n.range.toA?1:-1),this.emit(s,n.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(n,i),this.text.skip(n.range.toB-n.range.fromB),this.forward(n.range.fromA,l.toA),this.emit(n.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,n,i){let r=VR(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l<o.length?Tr.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);u.flags&256?(u.flags&=-2,this.builder.addBlockWidget(u)):(this.builder.ensureLine(null),this.builder.addInlineWidget(u,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Gu)this.cache.add(o);else if(o instanceof St)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof St&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof St&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let i=null,r=this.builder,s=-1,o=fe.spans(this.decorations,e,n,{point:(l,a,u,c,h,f)=>{if(u instanceof Ar){if(this.disallowBlockEffectsFor[f]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,h>c.length)r.continueWidget(a-l);else{let d=u.widget||(u.block?Fs.block:Fs.inline),p=zR(u),g=this.cache.findWidget(d,a-l,p)||Tr.of(d,this.view,a-l,p);u.block?(u.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(g)):(r.ensureLine(i),r.addInlineWidget(g,c,h))}i=null}else i=FR(i,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let h=l;h<a;){let f=this.text.next(Math.min(512,a-h));f==null?(r.addLineStartIfNotCovered(i),r.addBreak(),h++):(r.ensureLine(i),r.addText(f,u,h==l?c:u.length),h+=f.length),i=null}s=u.length}});s>-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,n,i=1){n-e<=10?this.old.advance(n-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let n=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=Pe.get(r);if(r==this.view.contentDOM)break;s instanceof St?n.push(s):s!=null&&s.isLine()?i=s:s instanceof ti||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new zs(r,US):i||n.push(St.of(new Wl({tagName:r.nodeName.toLowerCase(),attributes:dR(r)}),r)))}return{line:i,marks:n}}}function Ly(t,e){let n=i=>{for(let r of i.children)if((e?r.isText():r.length)||n(r))return!0;return!1};return n(t)}function zR(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const US={class:"cm-line"};function FR(t,e){let n=e.spec.attributes,i=e.spec.class;return!n&&!i||(t||(t={class:"cm-line"}),n&&Rm(n,t),i&&(t.class+=" "+i)),t}function VR(t){let e=[];for(let n=t.parents.length;n>1;n--){let i=n==t.parents.length?t.tile:t.parents[n].tile;i instanceof St&&e.push(i.mark)}return e}function qh(t){let e=Pe.get(t);return e&&e.setDOM(t.cloneNode()),t}class Fs extends Hl{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Fs.inline=new Fs("span");Fs.block=new Fs("div");const Kh=new class extends Hl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class By{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Ie.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Hc(e,e.contentDOM),this.updateInner([new Kt(0,0,0,e.state.doc.length)],null)}update(e){var n;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:h})=>h<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!GR(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?WR(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:h}=this.hasComposition;i=new Kt(c,h,e.changes.mapPos(c,-1),e.changes.mapPos(h,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Q.ie||Q.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=KR(o,this.decorations,e.changes);a.length&&(i=Kt.extendWithRanges(i,a));let u=YR(l,this.blockWrappers,e.changes);return u.length&&(i=Kt.extendWithRanges(i,u)),s&&!i.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(n||e.length){let o=this.tile,l=new $R(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Pe.get(n.text)&&l.cache.reused.set(Pe.get(n.text),2),this.tile=l.run(e,n),Yd(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Q.chrome||Q.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof Qh&&r.push(s.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let n of e.transactions)for(let i of n.effects)i.is(zS)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,n=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,s=r==i,o=!s&&!(this.view.state.facet(Yn)||i.tabIndex>-1)&&Wo(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Q.gecko&&a.empty&&!this.hasComposition&&HR(u)){let f=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(f,u.node.childNodes[u.offset]||null)),u=c=new fn(f,0),l=!0}let h=this.view.observer.selectionRange;(l||!h.focusNode||(!Uo(u.node,u.offset,h.anchorNode,h.anchorOffset)||!Uo(c.node,c.offset,h.focusNode,h.focusOffset))&&!this.suppressWidgetCursorChange(h,a))&&(this.view.observer.ignore(()=>{Q.android&&Q.chrome&&i.contains(h.focusNode)&&XR(h.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let f=Nl(this.view.root);if(f)if(a.empty){if(Q.gecko){let d=UR(u.node,u.offset);if(d&&d!=3){let p=(d==1?ES:_S)(u.node,u.offset);p&&(u=new fn(p.node,p.offset))}}f.collapse(u.node,u.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(u.node,u.offset);try{f.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),d.setEnd(c.node,c.offset),d.setStart(u.node,u.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new fn(h.anchorNode,h.anchorOffset),this.impreciseHead=c.precise?null:new fn(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Uo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,i=Nl(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!n.empty||!n.assoc||!i.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);i.collapse(c.node,c.offset),i.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=n.from&&i.collapse(r,s)}posFromDOM(e,n){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[n];else{let o=ai(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Pe.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+n:r+(n?i.length:0):r}domAtPos(e,n){let{tile:i,offset:r}=this.tile.resolveBlock(e,n);return i.isWidget()?i.domPosFor(r,n):i.domIn(r,n)}inlineDOMNearPos(e,n){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let h=c+u.length;if(c<=e&&(i=u,r=e-c,s=h<e),h>=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,n):(s&&o?i=null:a&&i&&(o=null),i&&n<0||!o?i.domIn(r,n):o.domIn(l,n))}coordsAt(e,n,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.widget instanceof Qh?null:r.coordsInWidget(s,n,!0):r.coordsIn(s,n,i)}lineAt(e,n){let{tile:i}=this.tile.resolveBlock(e,n);return i.isLine()?i:null}coordsForChar(e){let{tile:n,offset:i}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=ot(s.text,o);if(l==o)return null;let a=Al(s.dom,o,l).getClientRects();for(let u=0;u<a.length;u++){let c=a[u];if(u==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return r(n,i)}measureVisibleLineHeights(e){let n=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Oe.LTR,u=0,c=(h,f,d)=>{for(let p=0;p<h.children.length&&!(f>r);p++){let g=h.children[p],x=f+g.length,m=g.dom.getBoundingClientRect(),{height:v}=m;if(d&&!p&&(u+=m.top-d.top),g instanceof ti)x>i&&c(g,f,m);else if(f>=i&&(u>0&&n.push(-u),n.push(v+u),u=0,o)){let w=g.dom.lastChild,k=w?su(w):[];if(k.length){let S=k[k.length-1],_=a?S.right-m.left:m.right-S.left;_>l&&(l=_,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=x)}}d&&p==h.children.length-1&&(u+=d.bottom-m.bottom),f=x+g.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Oe.RTL:Oe.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=su(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),i,r,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=su(n.firstChild)[0];i=n.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,n.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let i=0,r=0;;r++){let s=r==n.viewports.length?null:n.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(i).top)/this.view.scaleY;e.push(Ie.replace({widget:new Qh(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Ie.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Fc).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(zm).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,n.push(fe.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(VS).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet($S))try{if(u(this.view,e.range,e))return!0}catch(c){Lt(this.view.state,c,"scroll handler")}let{range:n}=e,i=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),r;if(!i)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=Fm(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(gR(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Oe.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let u=this.view.docView.lineAt(n.head,1);if(u){let c=kS(u.dom);u.dom.scrollIntoView({block:"nearest"}),SS(c,!1)}}}lineHasWidget(e){let n=i=>i.isWidget()||i.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){Yd(this.tile)}}function Yd(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let i of t.children)Yd(i,e)}}function HR(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function qS(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let i=ES(n.focusNode,n.focusOffset),r=_S(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=Pe.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let a=Pe.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function WR(t,e,n){let i=qS(t,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new Kt(a.mapPos(s),a.mapPos(o),s,o),text:r}}function UR(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let qR=class{constructor(){this.changes=[]}compareRange(e,n){ks(e,n,this.changes)}comparePoint(e,n){ks(e,n,this.changes)}boundChange(e){ks(e,e,this.changes)}};function KR(t,e,n){let i=new qR;return fe.compare(t,e,n,i),i.changes}class QR{constructor(){this.changes=[]}compareRange(e,n){ks(e,n,this.changes)}comparePoint(){}boundChange(e){ks(e,e,this.changes)}}function YR(t,e,n){let i=new QR;return fe.compare(t,e,n,i),i.changes}function XR(t,e){for(let n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable=="false")return!0;return!1}function GR(t,e){let n=!1;return e&&t.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(n=!0)}),n}class Qh extends Hl{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function JR(t,e,n=1){let i=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(r.length==0)return W.cursor(e);s==0?n=1:s==r.length&&(n=-1);let o=s,l=s;n<0?o=ot(r.text,s,!1):l=ot(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let u=ot(r.text,o,!1);if(i(r.text.slice(u,o))!=a)break;o=u}for(;l<r.length;){let u=ot(r.text,l);if(i(r.text.slice(l,u))!=a)break;l=u}return W.undirectionalRange(o+r.from,l+r.from)}function ZR(t,e,n,i,r){let s=Math.round((i-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&n.height>t.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((r-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+lR(o,s,t.state.tabSize)}function eD(t,e,n){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Gt.Text&&(r.type!=s.type||(n<0?s.from<e:s.to>e)))&&(r=s)}}return r||i}return i}function tD(t,e,n,i){let r=eD(t,e.head,e.assoc||-1),s=!i||r.type!=Gt.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(r.from),a=t.posAtCoords({x:n==(l==Oe.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return W.cursor(a,n?-1:1)}return W.cursor(n?r.to:r.from,n?-1:1)}function jy(t,e,n,i){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let l=e,a=null;;){let u=NR(r,s,o,l,n),c=OS;if(!u){if(r.number==(n?t.state.doc.lines:1))return l;c=`
63
+ `,r=t.state.doc.line(r.number+(n?1:-1)),s=t.bidiSpans(r),u=t.visualLineSide(r,!n)}if(a){if(!a(c))return l}else{if(!i)return u;a=i(c)}l=u}}function nD(t,e,n){let i=t.state.charCategorizer(e),r=i(n);return s=>{let o=i(s);return r==Zn.Space&&(r=o),r==o}}function iD(t,e,n,i){let r=e.head,s=n?1:-1;if(r==(n?t.state.doc.length:0))return W.cursor(r,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(r,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let h=a.left+o,f=t.viewState.heightOracle.textHeight>>1,d=i??f;for(let p=0;;p+=f){let g=l+(d+p)*s,x=Xd(t,{x:h,y:g},!1,s);if(n?g>a.bottom:g<a.top)return W.cursor(x.pos,x.assoc);let m=t.coordsAtPos(x.pos,x.assoc),v=m?(m.top+m.bottom)/2:0;if(!m||(n?v>l:v<l))return W.cursor(x.pos,x.assoc,void 0,o)}}function qo(t,e,n){for(;;){let i=0;for(let r of t)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||n||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function KS(t,e){let n=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=qo(t,r.from,0);o!=r.from&&(s=W.cursor(o,-1))}else{let o=qo(t,r.from,-1),l=qo(t,r.to,1);(o!=r.from||l!=r.to)&&(r.undirectional?s=W.undirectionalRange(r.from,r.to):s=W.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(n||(n=e.ranges.slice()),n[i]=s)}return n?W.create(n,e.mainIndex):e}function Yh(t,e,n){let i=qo(t.state.facet(ql).map(r=>r(t)),n.from,e.head>n.from?-1:1);return i==n.from?n:W.cursor(i,i<n.from?1:-1)}class Pn{constructor(e,n){this.pos=e,this.assoc=n}}function Xd(t,e,n,i){let r=t.contentDOM.getBoundingClientRect(),s=r.top+t.viewState.paddingTop,{x:o,y:l}=e,a=l-s,u;for(;;){if(a<0)return new Pn(0,1);if(a>t.viewState.docHeight)return new Pn(t.state.doc.length,-1);if(u=t.elementAtHeight(a),i==null)break;if(u.type==Gt.Text){if(i<0?u.to<t.viewport.from:u.from>t.viewport.to)break;let f=t.docView.coordsAt(i<0?u.from:u.to,i>0?-1:1);if(f&&(i<0?f.top<=a+s:f.bottom>=a+s))break}let h=t.viewState.heightOracle.textHeight/2;a=i>0?u.bottom+h:u.top-h}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==Gt.Text){let h=ZR(t,r,u,o,l);return new Pn(h,h==u.from?1:-1)}}if(u.type!=Gt.Text)return a<(u.top+u.bottom)/2?new Pn(u.from,1):new Pn(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new rD(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class rD{constructor(e,n,i,r){this.view=e,this.x=n,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,n){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rn.find(r,e-i.from,-1,n)].level==this.baseDir}dirAt(e,n){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Rn.find(r,e-i.from,-1,n)].dir}bidiIn(e,n){let{spans:i,line:r}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from<n)}scan(e,n,i=!1){let r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a,u,c=-1,h=1e9,f;e:for(;r<s;){let p=s-r,g=r+s>>1;t:if(o.has(g)){for(let v=1;v<p;v++){let w=g+v;if(w>=s&&(w-=p),!o.has(w)){g=w;break t}}break e}o.add(g);let x=n(g),m=0;if(x)for(let v=0;v<x.length;v++){let w=x[v];if(!(w.width==0&&x.length>1))if(w.bottom<this.y)(!a||a.bottom<w.bottom)&&(a=w),m=1;else if(w.top>this.y)(!u||u.top>w.top)&&(u=w),m=-1;else{let k=w.left>this.x?this.x-w.left:w.right<this.x?this.x-w.right:0,S=Math.abs(k);S<h&&(c=g,h=S,f=w),k&&(m=k<0==(this.baseDir==Oe.LTR)?-1:1)}}m==-1&&(!l||this.baseDirAt(e[g],1))?s=g:m==1&&(!l||this.baseDirAt(e[g+1],-1))&&(r=g+1)}if(!f){if(!u&&!a)return{i:e[0],after:!1};let p=a&&(!u||this.y-a.bottom<u.top-this.y)?a:u;return this.y=(p.top+p.bottom)/2,this.scan(e,n,!0)}if(h&&!i){let{top:p,bottom:g}=f;if(a&&a.bottom>(p+p+g)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+g+g)/3)return this.y=u.top+1,this.scan(e,n,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==Oe.LTR;return{i:c,after:this.x>(f.left+f.right)/2==d}}scanText(e,n){let i=[];for(let s=0;s<e.length;s=ot(e.text,s))i.push(n+s);i.push(n+e.length);let r=this.scan(i,s=>{let o=i[s]-n,l=i[s+1]-n;return Al(e.dom,o,l).getClientRects()});return r.after?new Pn(i[r.i+1],-1):new Pn(i[r.i],1)}scanTile(e,n){if(!e.length)return new Pn(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let i=[n];for(let l=0,a=n;l<e.children.length;l++)i.push(a+=e.children[l].length);let r=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Al(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Pn(i[r.i+1],-1):new Pn(o,1)}}const Ur="￿";class sD{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(ce.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ur}readRange(e,n){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=Pe.get(r),l=r.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=Pe.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Qu(r))||Qu(l)&&(r.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!lD(l,n)&&this.lineBreak(),r=l}return this.findPointBefore(i,n),this}readTextNode(e){let n=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,n.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(i,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){let n=Pe.get(e),i=n&&n.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==n&&(i.pos=this.text.length)}findPointInside(e,n){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(oD(e,i.node,i.offset)?n:0))}}function oD(t,e,n){for(;;){if(!e||n<ai(e))return!1;if(e==t)return!0;n=Hi(e)+1,e=e.parentNode}}function lD(t,e){let n;for(;!(t==e||!t);t=t.nextSibling){let i=Pe.get(t);if(!(i!=null&&i.isWidget()))return!1;i&&(n||(n=[])).push(i)}if(n)for(let i of n){let r=i.overrideDOMText;if(r!=null&&r.length)return!1}return!0}class $y{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class aD{constructor(e,n,i,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=n>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=QS(e.docView.tile,n,i,0))){let a=s||o?[]:cD(e),u=new sD(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=hD(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Wd(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Wd(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),h=e.viewport;if((Q.ios||Q.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(h.from>0||h.to<e.state.doc.length)){let f=Math.min(u,c),d=Math.max(u,c),p=h.from-f,g=h.to-d;(p==0||p==1||f==0)&&(g==0||g==-1||d==e.state.doc.length)&&(u=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(W.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(u,-1),d=0;f&&(d=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=W.create([W.cursor(u,d)])}else this.newSel=W.single(c,u)}}}function QS(t,e,n,i){if(t.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,u=i,c=i;a<t.children.length;a++){let h=t.children[a],f=u+h.length;if(u<e&&f>n)return QS(h,e,n,u);if(f>=e&&r==-1&&(r=a,s=u),u>n&&h.dom.parentNode==t.dom){o=a,l=c;break}c=f,u=f+h.breakAfter}return{from:s,to:l<0?i+t.length:l,startDOM:(r?t.children[r-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o<t.children.length&&o>=0?t.children[o].dom:null}}else return t.isText()?{from:i,to:i+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function YS(t,e){let n,{newSel:i}=e,{state:r}=t,s=r.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Q.android&&e.text.length<a-l)&&(u=s.to,c="end");let h=r.doc.sliceString(l,a,Ur),f,d;!s.empty&&s.from>=l&&s.to<=a&&(e.typeOver||h!=e.text)&&h.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&h.slice(s.to-l)==e.text.slice(f=e.text.length-(h.length-(s.to-l)))?n={from:s.from,to:s.to,insert:ae.of(e.text.slice(s.from-l,f).split(Ur))}:(d=XS(h,e.text,u-l,c))&&(Q.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Ur+Ur&&d.toB--,n={from:l+d.from,to:l+d.toA,insert:ae.of(e.text.slice(d.from,d.toB).split(Ur))})}else i&&(!t.hasFocus&&r.facet(Yn)||Zu(i,s))&&(i=null);if(!n&&!i)return!1;if((Q.mac||Q.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(i&&n.insert.length==2&&(i=W.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:ae.of([n.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&t.docView.lineHasWidget(s.to)&&t.inputState.insertingTextAt>Date.now()-50?n={from:s.from,to:s.to,insert:r.toText(t.inputState.insertingText)}:Q.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==`
64
+ `&&t.lineWrapping&&(i&&(i=W.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:ae.of([" "])}),n)return Vm(t,n,i,o);if(i&&!Zu(i,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=KS(r.facet(ql).map(u=>u(t)),i))),t.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function Vm(t,e,n,i=-1){if(Q.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(Q.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ss(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Ss(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Ss(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=uD(t,e,n));return t.state.facet(LS).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function uD(t,e,n){let i,r=t.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,u=a<0?s.from:s.to,c=qo(r.facet(ql).map(h=>h(t)),u,a);e.from==c&&(o=c)}if(o>-1)i={changes:e,selection:W.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",u=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=r.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),h,f=n&&qS(t,n.main.head);if(f){let p=e.insert.length-(e.to-e.from);h={from:f.from,to:f.to-p}}else h=t.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let g=p.to-d,x=g-c.length;if(t.state.sliceDoc(x,g)!=c||g>=h.from&&x<=h.to)return{range:p};let m=r.changes({from:x,to:g,insert:e.insert}),v=p.to-s.to;return{changes:m,range:u?W.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):p.map(m)}})}else i={changes:a,selection:u&&r.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function XS(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o<s&&t.length<e.length){let a=n<=s&&n>=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function cD(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new $y(n,i)),(r!=n||s!=i)&&e.push(new $y(r,s))),e}function hD(t,e){if(t.length==0)return null;let n=t[0].pos,i=t.length==2?t[1].pos:n;return n>-1&&i>-1?W.single(n+e,i+e):null}function Zu(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class fD{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Q.safari&&e.contentDOM.addEventListener("input",()=>null),Q.gecko&&AD(e.contentDOM.ownerDocument)}handleEvent(e){!kD(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=pD(e),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&JS.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Q.android&&Q.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Q.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(GS.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||mD.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Q.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&dD(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ss(this.view.contentDOM,n.key,n.keyCode,n.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Q.safari&&!Q.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function dD(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function zy(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(r){Lt(n.state,r)}}}function pD(t){let e=Object.create(null);function n(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of t){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(zy(i.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(zy(i.value,a))}}for(let i in vn)n(i).handlers.push(vn[i]);for(let i in mt)n(i).observers.push(mt[i]);return e}const GS=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],mD="dthko",JS=[16,17,18,20,91,92,224,225],Ea=6;function _a(t){return Math.max(0,t)*.7+8}function gD(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class yD{constructor(e,n,i,r){this.view=e,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=xS(e.contentDOM),this.atoms=e.state.facet(ql).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(ce.allowMultipleSelections)&&vD(e,n),this.dragging=xD(e,n)&&tb(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&gD(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Fm(this.view);e.clientX-a.left<=r+Ea?n=-_a(r-e.clientX):e.clientX+a.right>=o-Ea&&(n=_a(e.clientX-o)),e.clientY-a.top<=s+Ea?i=-_a(s-e.clientY):e.clientY+a.bottom>=l-Ea&&(i=_a(e.clientY-l)),this.setScrollSpeed(n,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,i=KS(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function vD(t,e){let n=t.state.facet(IS);return n.length?n[0](e):Q.mac?e.metaKey:e.ctrlKey}function wD(t,e){let n=t.state.facet(PS);return n.length?n[0](e):Q.mac?!e.altKey:!e.ctrlKey}function xD(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=Nl(t.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function kD(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=Pe.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const vn=Object.create(null),mt=Object.create(null),ZS=Q.ie&&Q.ie_version<15||Q.ios&&Q.webkit_version<604;function SD(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),eb(t,n.value)},50)}function Wc(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function eb(t,e){e=Wc(t.state,Bm,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(Gd!=null&&n.selection.ranges.every(a=>a.empty)&&Gd==s.toString()){let a=-1;i=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let h=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:h},range:W.cursor(u.from+h.length)}})}else o?i=n.changeByRange(a=>{let u=s.line(r++);return{changes:{from:a.from,to:a.to,insert:u.text},range:W.cursor(a.from+u.length)}}):i=n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}mt.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Q.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};mt.wheel=mt.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};vn.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);mt.touchstart=(t,e)=>{let n=t.inputState,i=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")};mt.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};mt.touchend=(t,e)=>{t.inputState.touchActive=!1};vn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of t.state.facet(RS))if(n=i(t,e),n)break;if(!n&&e.button==0&&(n=CD(t,e)),n){let i=!t.hasFocus;t.inputState.startMouseSelection(new yD(t,e,n,i)),i&&t.observer.ignore(()=>{bS(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Fy(t,e,n,i){if(i==1)return W.cursor(e,n);if(i==2)return JR(t.state,e,n);{let r=t.docView.lineAt(e,n),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<t.state.doc.length&&l==s.to&&l++,W.undirectionalRange(o,l)}}const bD=Q.ie&&Q.ie_version<=11;let Vy=null,Hy=0,Wy=0;function tb(t){if(!bD)return t.detail;let e=Vy,n=Wy;return Vy=t,Wy=Date.now(),Hy=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Hy+1)%3:1}function CD(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=tb(e),r=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=Fy(t,a.pos,a.assoc,i);if(n.pos!=a.pos&&!o){let h=Fy(t,n.pos,n.assoc,i),f=Math.min(h.from,c.from),d=Math.max(h.to,c.to);c=f<c.from?W.range(f,d,c.assoc):W.range(d,f,c.assoc)}return o?r.replaceRange(r.main.extend(c.from,c.to,c.assoc)):l&&i==1&&r.ranges.length>1&&(u=ED(r,a.pos))?u:l?r.addRange(c):W.create([c])}}}function ED(t,e){for(let n=0;n<t.ranges.length;n++){let{from:i,to:r}=t.ranges[n];if(i<=e&&r>=e)return W.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}vn.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=n.to||o<=n.from)&&(n=W.undirectionalRange(s,o))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Wc(t.state,jm,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};vn.dragend=t=>(t.inputState.draggedContent=null,!1);function Uy(t,e,n,i){if(n=Wc(t.state,Bm,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=i&&s&&wD(t,e)?{from:s.from,to:s.to}:null,l={from:r,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}vn.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&Uy(t,e,i.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Uy(t,e,i,!0),!0}return!1};vn.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=ZS?null:e.clipboardData;return n?(eb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(SD(t),!1)};function _D(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}function ND(t){let e=[],n=[],i=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}i=!0}return{text:Wc(t,jm,e.join(t.lineBreak)),ranges:n,linewise:i}}let Gd=null;vn.copy=vn.cut=(t,e)=>{if(!Wo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=ND(t.state);if(!n&&!r)return!1;Gd=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=ZS?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(_D(t,n),!1)};const nb=Vn.define();function ib(t,e){let n=[];for(let i of t.facet(BS)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:nb.of(!0)}):null}function rb(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ib(t.state,e);n?t.dispatch(n):t.update([])}},10)}mt.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rb(t)};mt.blur=t=>{t.observer.clearSelectionRange(),rb(t)};mt.compositionstart=mt.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};mt.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Q.chrome&&Q.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};mt.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};vn.beforeinput=(t,e)=>{var n,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return Vm(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let r;if(Q.chrome&&Q.android&&(r=GS.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Q.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Q.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>mt.compositionend(t,e),20),!1};const qy=new Set;function AD(t){qy.has(t)||(qy.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Ky=["pre-wrap","normal","pre-line","break-spaces"];let Vs=!1;function Qy(){Vs=!1}class MD{constructor(e){this.lineWrapping=e,this.doc=ae.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Ky.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(n=!0,this.heightSamples[Math.floor(r*10)]=!0)}return n}refresh(e,n,i,r,s,o){let l=Ky.indexOf(e)>-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let u=0;u<o.length;u++){let c=o[u];c<0?u++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class TD{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class hn{constructor(e,n,i,r,s){this.from=e,this.length=n,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Gt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ar?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new hn(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var ge=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(ge||(ge={}));const ou=.001;class pt{constructor(e,n,i=2){this.length=e,this.height=n,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ou&&(Vs=!0),this.height=e)}replace(e,n,i){return pt.of(i)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:h}=r[l],f=s.lineAt(a,ge.ByPosNoHeight,i.setDoc(n),0,0),d=f.to>=u?f:s.lineAt(u,ge.ByPosNoHeight,i,0,0);for(h+=d.to-u,u=d.to;l>0&&f.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<f.from&&(f=s.lineAt(a,ge.ByPosNoHeight,i,0,0));c+=f.from-a,a=f.from;let p=Hm.build(i.setDoc(o),e,c,h);s=ec(s,s.replace(a,u,p))}return s.updateHeight(i,0)}static empty(){return new Pt(0,0,0)}static of(e){if(e.length==1)return e[0];let n=0,i=e.length,r=0,s=0;for(;;)if(n==i)if(r>s*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[n++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[n-1]==null?(o=1,n--):e[n]==null&&(o=1,i++),new ID(pt.of(e.slice(0,n)),o,pt.of(e.slice(i)))}}function ec(t,e){return t==e?t:(t.constructor!=e.constructor&&(Vs=!0),e)}pt.prototype.size=1;const OD=Ie.replace({});class sb extends pt{constructor(e,n,i){super(e,n),this.deco=i,this.spaceAbove=0}mainBlock(e,n){return new hn(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,n,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new hn(r,0,i,this.spaceAbove,OD):this.mainBlock(i,r)}lineAt(e,n,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,n,i,r,s,o){e<=s+this.length&&n>=s&&o(this.lineAt(0,ge.ByPos,i,r,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Pt extends sb{constructor(e,n,i){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,n){return new hn(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,i){let r=i[0];return i.length==1&&(r instanceof Pt||r instanceof Xe&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Xe?r=new Pt(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):pt.of(i)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Xe extends pt{constructor(e){super(e,0)}heightMetrics(e,n){let i=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,n,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r);if(n.lineWrapping){let u=r+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),c=n.doc.lineAt(u),h=l+c.length*a,f=Math.max(i,e-h/2);return new hn(c.from,c.length,f,h,0)}else{let u=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:h}=n.doc.line(s+u);return new hn(c,h,i+l*u,l,0)}}lineAt(e,n,i,r,s){if(n==ge.ByHeight)return this.blockAt(e,i,r,s);if(n==ge.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new hn(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),u=i.doc.lineAt(e),c=l+u.length*a,h=u.number-o,f=r+l*h+a*(u.from-s-h);return new hn(u.from,u.length,Math.max(r,Math.min(f,r+this.height-c)),c,0)}forEachLine(e,n,i,r,s,o){e=Math.max(e,s),n=Math.min(n,s+this.length);let{firstLine:l,perLine:a,perChar:u}=this.heightMetrics(i,s);for(let c=e,h=r;c<=n;){let f=i.doc.lineAt(c);if(c==e){let p=f.number-l;h+=a*p+u*(e-s-p)}let d=a+u*f.length;o(new hn(f.from,f.length,h,d,0)),h+=d,c=f.to+1}}replace(e,n,i){let r=this.length-n;if(r>0){let s=i[i.length-1];s instanceof Xe?i[i.length-1]=new Xe(s.length+r):i.push(null,new Xe(r-1))}if(e>0){let s=i[0];s instanceof Xe?i[0]=new Xe(e+s.length):i.unshift(new Xe(e-1),null)}return pt.of(i)}decomposeLeft(e,n){n.push(new Xe(e-1),null)}decomposeRight(e,n){n.push(null,new Xe(this.length-e-1))}updateHeight(e,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let o=[],l=Math.max(n,r.from),a=-1;for(r.from>n&&o.push(new Xe(r.from-n-1).updateHeight(e,n));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let h=r.heights[r.index++],f=0;h<0&&(f=-h,h=r.heights[r.index++]),a==-1?a=h:Math.abs(h-a)>=ou&&(a=-2);let d=new Pt(c,h,f);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new Xe(s-l).updateHeight(e,l));let u=pt.of(o);return(a<0||Math.abs(u.height-this.height)>=ou||Math.abs(a-this.heightMetrics(e,n).perLine)>=ou)&&(Vs=!0),ec(this,u)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class ID extends pt{constructor(e,n,i){super(e.length+n+i.length,e.height+i.height,n|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,n,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,n,i,r):this.right.blockAt(e,n,s,r+this.left.length+this.break)}lineAt(e,n,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=n==ge.ByHeight?e<o:e<l,u=a?this.left.lineAt(e,n,i,r,s):this.right.lineAt(e,n,i,o,l);if(this.break||(a?u.to<l:u.from>l))return u;let c=n==ge.ByPosNoHeight?ge.ByPosNoHeight:ge.ByPos;return a?u.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(u)}forEachLine(e,n,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,n,i,r,s,o),n>=a&&this.right.forEachLine(e,n,i,l,a,o);else{let u=this.lineAt(a,ge.ByPos,i,r,s);e<u.from&&this.left.forEachLine(e,u.from-1,i,r,s,o),u.to>=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,i,l,a,o)}}replace(e,n,i){let r=this.left.length+this.break;if(n<r)return this.balanced(this.left.replace(e,n,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Yy(s,o-1),n<this.length){let l=s.length;this.decomposeRight(n,s),Yy(s,l)}return pt.of(s)}decomposeLeft(e,n){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(i++,e>=i&&n.push(null)),e>i&&this.right.decomposeLeft(e-i,n)}decomposeRight(e,n){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e<i&&this.left.decomposeRight(e,n),this.break&&e<r&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?pt.of(this.break?[e,null,n]:[e,n]):(this.left=ec(this.left,e),this.right=ec(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,i=!1,r){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return r&&r.from<=n+s.length&&r.more?a=s=s.updateHeight(e,n,i,r):s.updateHeight(e,n,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Yy(t,e){let n,i;t[e]==null&&(n=t[e-1])instanceof Xe&&(i=t[e+1])instanceof Xe&&t.splice(e-1,3,new Xe(n.length+1+i.length))}const PD=5;class Hm{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Pt?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Pt(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,i){if(e<n||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=n-e;i.block?this.addBlock(new sb(o,r,i)):(o||s||r>=PD)&&this.addLineDeco(r,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Pt(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let i=new Xe(n-e);return this.oracle.doc.lineAt(e).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Pt)return e;let n=new Pt(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Pt)&&!this.isCovered?this.nodes.push(new Pt(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Pt&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,n,i,r){let s=new Hm(i,e);return fe.spans(n,i,r,s,0),s.finish(i)}}function RD(t,e,n){let i=new DD;return fe.compare(t,e,n,i,0),i.changes}class DD{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,i,r){(e<n||i&&i.heightRelevant||r&&r.heightRelevant)&&ks(e,n,this.changes,5)}}function LD(t,e){let n=t.getBoundingClientRect(),i=t.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),l=Math.max(0,n.top),a=Math.min(r.innerHeight,n.bottom);for(let u=t.parentNode;u&&u!=i.body;)if(u.nodeType==1){let c=u,h=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&h.overflow!="visible"){let f=c.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(u==t.parentNode?r.innerHeight:a,f.bottom)}u=h.position=="absolute"||h.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function BD(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function jD(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Xh{constructor(e,n,i,r){this.from=e,this.to=n,this.size=i,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,n){return Ie.replace({widget:new $D(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class $D extends Hl{constructor(e,n){super(),this.size=e,this.vertical=n}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Xy{constructor(e,n){this.view=e,this.state=n,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Gy,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Oe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=n.facet($m).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new MD(i),this.stateDeco=Jy(n),this.heightMap=pt.empty().applyChanges(this.stateDeco,ae.empty,this.heightOracle.setDoc(n.doc),[new Kt(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ie.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Na(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Gy:new Wm(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Io(e,this.scaler))})}update(e,n=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Jy(this.state);let r=e.changedRanges,s=Kt.extendWithRanges(r,RD(i,this.stateDeco,e?e.changes:ze.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Qy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Vs)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<a.from||n.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(MR)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Oe.RTL:Oe.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:S,scaleY:_}=wS(n,l);(S>.005&&Math.abs(this.scaleX-S)>.005||_>.005&&Math.abs(this.scaleY-_)>.005)&&(this.scaleX=S,this.scaleY=_,u|=16,o=a=!0)}let h=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let d=xS(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=CS(this.scrollParent||e.win);let g=(this.printing?jD:LD)(n,this.paddingTop),x=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget&&!BD(e.dom))return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(S)&&(o=!0),o||r.lineWrapping&&Math.abs(w-this.contentDOMWidth)>r.charWidth){let{lineHeight:_,charWidth:E,textHeight:A}=e.docView.measureTextSize();o=_>0&&r.refresh(s,_,E,A,Math.max(5,w/E),S),o&&(e.docView.minWidth=0,u|=16)}x>0&&m>0?c=Math.max(x,m):x<0&&m<0&&(c=Math.min(x,m)),Qy();for(let _ of this.viewports){let E=_.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(_);this.heightMap=(o?pt.empty().applyChanges(this.stateDeco,ae.empty,this.heightOracle,[new Kt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new TD(_.from,E))}Vs&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Na(r.lineAt(o-i*1e3,ge.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ge.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(u<a.from||u>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=r.lineAt(u,ge.ByPos,s,0,0),f;n.y=="center"?f=(h.top+h.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u<a.from?f=h.top:f=h.bottom-c,a=new Na(r.lineAt(f-1e3/2,ge.ByHeight,s,0,0).from,r.lineAt(f+c+1e3/2,ge.ByHeight,s,0,0).to)}}return a}mapViewport(e,n){let i=n.mapPos(e.from,-1),r=n.mapPos(e.to,1);return new Na(this.heightMap.lineAt(i,ge.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ge.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ge.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,ge.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(n==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let i=[];for(let r of e)n.touchesRange(r.from,r.to)||i.push(new Xh(n.mapPos(r.from),n.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,n){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=Oe.LTR&&!i)return[];let l=[],a=(c,h,f,d)=>{if(h-c<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let m of g)if(m>c&&m<h){a(c,m-10,f,d),a(m+10,h,f,d);return}let x=FD(e,m=>m.from>=f.from&&m.to<=f.to&&Math.abs(m.from-c)<s&&Math.abs(m.to-h)<s&&!g.some(v=>m.from<v&&m.to>v));if(!x){if(h<f.to&&n&&i&&n.visibleRanges.some(w=>w.from<=h&&w.to>=h)){let w=n.moveToLineBoundary(W.cursor(h),!1,!0).head;w>c&&(h=w)}let m=this.gapSize(f,c,h,d),v=i||m<2e6?m:2e6;x=new Xh(c,h,m,v)}l.push(x)},u=c=>{if(c.length<o||c.type!=Gt.Text)return;let h=zD(c.from,c.to,this.stateDeco);if(h.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,m;if(f!=null){let v=Ma(h,f),w=((this.visibleBottom-this.visibleTop)/2+g)/c.height;x=v-w,m=v+w}else x=(this.visibleTop-c.top-g)/c.height,m=(this.visibleBottom-c.top+g)/c.height;d=Aa(h,x),p=Aa(h,m)}else{let g=h.total*this.heightOracle.charWidth,x=r*this.heightOracle.charWidth,m=0;if(g>2e6)for(let _ of e)_.from>=c.from&&_.from<c.to&&_.size!=_.displaySize&&_.from*this.heightOracle.charWidth+m<this.pixelViewport.left&&(m=_.size-_.displaySize);let v=this.pixelViewport.left+m,w=this.pixelViewport.right+m,k,S;if(f!=null){let _=Ma(h,f),E=((w-v)/2+x)/g;k=_-E,S=_+E}else k=(v-x)/g,S=(w+x)/g;d=Aa(h,k),p=Aa(h,S)}d>c.from&&a(c.from,d,c,h),p<c.to&&a(p,c.to,c,h)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(u):u(c);return l}gapSize(e,n,i,r){let s=Ma(r,i)-Ma(r,n);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Xh.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Ie.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];fe.spans(n,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Io(this.heightMap.lineAt(e,ge.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Io(this.heightMap.lineAt(this.scaler.fromDOM(e),ge.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Io(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Na{constructor(e,n){this.from=e,this.to=n}}function zD(t,e,n){let i=[],r=t,s=0;return fe.spans(n,t,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function Aa({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function Ma(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}function FD(t,e){for(let n of t)if(e(n))return n}const Gy={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Jy(t){let e=t.facet(Fc).filter(i=>typeof i!="function"),n=t.facet(zm).filter(i=>typeof i!="function");return n.length&&e.push(fe.join(n)),e}class Wm{constructor(e,n,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let u=n.lineAt(l,ge.ByPos,e,0,0).top,c=n.lineAt(a,ge.ByPos,e,0,0).bottom;return r+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof Wm?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,i)=>n.from==e.viewports[i].from&&n.to==e.viewports[i].to):!1}}function Io(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new hn(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(r=>Io(r,e)):t._content)}const Ta=ne.define({combine:t=>t.join(" ")}),Jd=ne.define({combine:t=>t.indexOf(!0)>-1}),Zd=Fi.newName(),ob=Fi.newName(),lb=Fi.newName(),ab={"&light":"."+ob,"&dark":"."+lb};function ep(t,e,n){return new Fi(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+i}})}const VD=ep("."+Zd,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},ab),HD={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Gh=Q.ie&&Q.ie_version<=11;class WD{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new yR,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let i of n)this.queue.push(i);(Q.ie&&Q.ie_version<=11||Q.ios&&e.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Q.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Q.chrome&&Q.chrome_version<126)&&(this.editContext=new qD(e),e.state.facet(Yn)&&(e.contentDOM.editContext=this.editContext.editContext)),Gh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,i)=>n!=e[i]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Yn)?i.root.activeElement!=this.dom:!Wo(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Q.ie&&Q.ie_version<=11||Q.android&&Q.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Uo(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Nl(e.root);if(!n)return!1;let i=Q.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&UD(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=Wo(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&wR(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let i=this.dom;i;)if(i.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=n)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,HD),Gh&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Gh&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ss(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),n==-1?{from:n,to:i}=o:(n=Math.min(o.from,n),i=Math.max(o.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:e,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Wo(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new aD(this.view,e,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=YS(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!Zu(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let i=Zy(n,e.previousSibling||e.target.previousSibling,-1),r=Zy(n,e.nextSibling||e.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Yn)!=e.state.facet(Yn)&&(e.view.contentDOM.editContext=e.state.facet(Yn)?this.editContext.editContext:null))}destroy(){var e,n,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Zy(t,e,n){for(;e;){let i=Pe.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function ev(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return Uo(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function UD(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return ev(t,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?ev(t,n):null}class qD{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>i.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let c=XS(e.state.sliceDoc(l,a),i.text,(u?r.from:r.to)-l,u?"end":null);if(!c){let f=W.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Zu(f,r)||e.dispatch({selection:f,userEvent:"select"});return}let h={from:c.from+l,to:c.toA+l,insert:ae.of(i.text.slice(c.from,c.toB).split(`
65
+ `))};if((Q.mac||Q.android)&&h.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(h={from:l,to:a,insert:ae.of([i.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let f=this.to-this.from+(h.to-h.from+h.insert.length);Vm(e,h,W.single(this.toEditorPos(i.selectionStart,f),this.toEditorPos(i.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}n.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a<u){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(Ie.mark({attributes:{style:c}}).range(a,u))}}}e.dispatch({effects:zS.of(Ie.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=Nl(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(i)return;let c=u.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(u)){r=this.pendingContextChange=null,n+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+u.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),r&&!i&&this.revertPending(e.state),!i}update(e){let n=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Z{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||vR(e.parent)||document,this.viewState=new Xy(this,e.state||ce.create(e)),e.scrollTo&&e.scrollTo.is(Ca)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ss).map(r=>new Uh(r));for(let r of this.plugins)r.update(this);this.observer=new WD(this),this.inputState=new fD(this),this.inputState.ensureHandlers(this.plugins),this.docView=new By(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Ve?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(nb))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=ib(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(ce.phrases)!=this.state.facet(ce.phrases))return this.setState(s);r=Xu.create(this,s,e),r.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:p,y:g}=this.state.facet(Z.cursorScrollMargin);h=new bs(d.empty?d:W.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of f.effects)d.is(Ca)&&(h=d.value.clip(this.state))}this.viewState.update(r,h),this.bidiCache=tc.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(Oo)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Ta)!=r.state.facet(Ta)&&(this.viewState.mustMeasureContent=!0),(n||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Qd))try{f(r)}catch(d){Lt(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!YS(this,c)&&u.force&&Ss(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Xy(this,e),this.plugins=e.facet(ss).map(i=>new Uh(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new By(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ss),i=e.state.facet(ss);if(n!=i){let r=[];for(let s of i){let o=n.indexOf(s);if(o<0)r.push(new Uh(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);n!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(i){Lt(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(CS(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(d=>{try{return d.read(this)}catch(p){return Lt(this.state,p),tv}}),h=Xu.create(this,this.state,[]),f=!1;h.flags|=a,n?n.flags|=a:n=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let d=0;d<u.length;d++)if(c[d]!=tv)try{let p=u[d];p.write&&p.write(c[d],this)}catch(p){Lt(this.state,p)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((p>1||p<-1)&&!(Q.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?s<0?i.scrollTop=i.scrollHeight:i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(Qd))l(n)}get themeClasses(){return Zd+" "+(this.state.facet(Jd)?lb:ob)+" "+this.state.facet(Ta)}updateAttrs(){let e=nv(this,FS,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Yn)?"true":"false",class:"cm-content",style:`${Q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),nv(this,$m,n);let i=this.observer.ignore(()=>{let r=Oy(this.contentDOM,this.contentAttrs,n),s=Oy(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=n,i}showAnnouncements(e){let n=!0;for(let i of e)for(let r of i.effects)if(r.is(Z.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Oo);let e=this.state.facet(Z.cspNonce);Fi.mount(this.root,this.styleModules.concat(VD).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(i=>i.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,i){return Yh(this,e,jy(this,e,n,i))}moveByGroup(e,n){return Yh(this,e,jy(this,e,n,i=>nD(this,e.head,i)))}visualLineSide(e,n){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[n?i.length-1:0];return W.cursor(s.side(n,r)+e.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,i=!0){return tD(this,e,n,i)}moveVertically(e,n,i){return Yh(this,e,iD(this,e,n,i))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let i=Xd(this,e,n);return i&&i.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Xd(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[Rn.find(r,e-i.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==Oe.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(jS)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>KD)return TS(e.length);let n=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||MS(s.isolates,i=Ry(this,e))))return s.order;i||(i=Ry(this,e));let r=_R(e.text,n,i);return this.bidiCache.push(new tc(e.from,e.to,n,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Q.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{bS(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var i,r,s,o;return Ca.of(new bs(typeof e=="number"?W.cursor(e):e,(i=n.y)!==null&&i!==void 0?i:"nearest",(r=n.x)!==null&&r!==void 0?r:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Ca.of(new bs(W.cursor(i.from),"start","start",i.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return zn.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return zn.define(()=>({}),{eventObservers:e})}static theme(e,n){let i=Fi.newName(),r=[Ta.of(i),Oo.of(ep(`.${i}`,e))];return n&&n.dark&&r.push(Jd.of(!0)),r}static baseTheme(e){return Fl.lowest(Oo.of(ep("."+Zd,e,ab)))}static findFromDOM(e){var n;let i=e.querySelector(".cm-content"),r=i&&Pe.get(i)||Pe.get(e);return((n=r==null?void 0:r.root)===null||n===void 0?void 0:n.view)||null}}Z.styleModule=Oo;Z.inputHandler=LS;Z.clipboardInputFilter=Bm;Z.clipboardOutputFilter=jm;Z.scrollHandler=$S;Z.focusChangeEffect=BS;Z.perLineTextDirection=jS;Z.exceptionSink=DS;Z.updateListener=Qd;Z.editable=Yn;Z.mouseSelectionStyle=RS;Z.dragMovesSelection=PS;Z.clickAddsSelectionRange=IS;Z.decorations=Fc;Z.blockWrappers=VS;Z.outerDecorations=zm;Z.atomicRanges=ql;Z.bidiIsolatedRanges=HS;Z.cursorScrollMargin=ne.define({combine:t=>{let e=5,n=5;for(let i of t)typeof i=="number"?e=n=i:{x:e,y:n}=i;return{x:e,y:n}}});Z.scrollMargins=WS;Z.darkTheme=Jd;Z.cspNonce=ne.define({combine:t=>t.length?t[0]:""});Z.contentAttributes=$m;Z.editorAttributes=FS;Z.lineWrapping=Z.contentAttributes.of({class:"cm-lineWrapping"});Z.announce=ve.define();const KD=4096,tv={};class tc{constructor(e,n,i,r,s,o){this.from=e,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:Oe.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!n.touchesRange(o.from,o.to)&&i.push(new tc(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function nv(t,e,n){for(let i=t.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(t):s;o&&Rm(o,n)}return n}const QD=Q.mac?"mac":Q.windows?"win":Q.linux?"linux":"key";function YD(t,e){const n=t.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<n.length-1;++a){const u=n[a];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Oa(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const XD=Fl.default(Z.domEventHandlers({keydown(t,e){return e3(GD(e.state),t,e,"editor")}})),Um=ne.define({enables:XD}),iv=new WeakMap;function GD(t){let e=t.facet(Um),n=iv.get(e);return n||iv.set(e,n=ZD(e.reduce((i,r)=>i.concat(r),[]))),n}let bi=null;const JD=4e3;function ZD(t,e=QD){let n=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var h,f;let d=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(m=>YD(m,e));for(let m=1;m<p.length;m++){let v=p.slice(0,m).join(" ");r(v,!0),d[v]||(d[v]={preventDefault:!0,stopPropagation:!1,run:[w=>{let k=bi={view:w,prefix:v,scope:o};return setTimeout(()=>{bi==k&&(bi=null)},JD),!0}]})}let g=p.join(" ");r(g,!1);let x=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((f=(h=d._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:h}=o;for(let f in c)c[f].run.push(d=>h(d,tp))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let tp=null;function e3(t,e,n,i){tp=e;let r=hR(e),s=or(r,0),o=Wr(s)==r.length&&r!=" ",l="",a=!1,u=!1,c=!1;bi&&bi.view==n&&bi.scope==i&&(l=bi.prefix+" ",JS.indexOf(e.keyCode)<0&&(u=!0,bi=null));let h=new Set,f=x=>{if(x){for(let m of x.run)if(!h.has(m)&&(h.add(m),m(n)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},d=t[i],p,g;return d&&(f(d[l+Oa(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Q.windows&&e.ctrlKey&&e.altKey)&&!(Q.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Vi[e.keyCode])&&p!=r?(f(d[l+Oa(p,e,!0)])||e.shiftKey&&(g=El[e.keyCode])!=r&&g!=p&&f(d[l+Oa(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[l+Oa(r,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),tp=null,a}const Ia="-10000px";class t3{constructor(e,n,i,r){this.facet=n,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,n){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;a<s.length;a++){let u=s[a],c=-1;if(u){for(let h=0;h<this.tooltips.length;h++){let f=this.tooltips[h];f&&f.create==u.create&&(c=h)}if(c<0)o[a]=this.createTooltipView(u,a?o[a-1]:null),l&&(l[a]=!!u.above);else{let h=o[a]=this.tooltipViews[c];l&&(l[a]=n[c]),h.update&&h.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return n&&(l.forEach((a,u)=>n[u]=a),n.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function n3(t={}){return lu.of(t)}function i3(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const lu=ne.define({combine:t=>{var e,n,i;return{position:Q.ios?"absolute":((e=t.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(r=>r.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((i=t.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||i3}}}),rv=new WeakMap,ub=zn.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(lu);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new t3(t,cb,(n,i)=>this.createTooltip(n,i),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,i=t.state.facet(lu);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),i=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",n.dom.appendChild(r)}return n.dom.style.position=this.position,n.dom.style.top=Ia,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(t=i.destroy)===null||t===void 0||t.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Q.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=Fm(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(lu).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:i,scaleX:r,scaleY:s}=t,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],u=this.manager.tooltipViews[l],{dom:c}=u,h=t.pos[l],f=t.size[l];if(!h||a.clip!==!1&&(h.bottom<=Math.max(n.top,i.top)||h.top>=Math.min(n.bottom,i.bottom)||h.right<Math.max(n.left,i.left)-.1||h.left>Math.min(n.right,i.right)+.1)){c.style.top=Ia;continue}let d=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=f.right-f.left,x=(e=rv.get(u))!==null&&e!==void 0?e:f.bottom-f.top,m=u.offset||s3,v=this.view.textDirection==Oe.LTR,w=f.width>i.right-i.left?v?i.left:i.right-f.width:v?Math.max(i.left,Math.min(h.left-(d?14:0)+m.x,i.right-g)):Math.min(Math.max(i.left,h.left-g+(d?14:0)-m.x),i.right-g),k=this.above[l];!a.strictSide&&(k?h.top-x-p-m.y<i.top:h.bottom+x+p+m.y>i.bottom)&&k==i.bottom-h.bottom>h.top-i.top&&(k=this.above[l]=!k);let S=(k?h.top-i.top:i.bottom-h.bottom)-p;if(S<x&&u.resize!==!1){if(S<this.view.defaultLineHeight){c.style.top=Ia;continue}rv.set(u,x),c.style.height=(x=S)/s+"px"}else c.style.height&&(c.style.height="");let _=k?h.top-x-p-m.y:h.bottom+p+m.y,E=w+g;if(u.overlap!==!0)for(let A of o)A.left<E&&A.right>w&&A.top<_+x&&A.bottom>_&&(_=k?A.top-x-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(_-t.parent.top)/s+"px",sv(c,(w-t.parent.left)/r)):(c.style.top=_/s+"px",sv(c,w/r)),d){let A=h.left+(v?m.x:-m.x)-(w+14-7);d.style.left=A/r+"px"}u.overlap!==!0&&o.push({left:w,top:_,right:E,bottom:_+x}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Ia}},{eventObservers:{scroll(){this.maybeMeasure()}}});function sv(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const r3=Z.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),s3={x:0,y:0},cb=ne.define({enables:[ub,r3]});function hb(t,e){let n=t.plugin(ub);if(!n)return null;let i=n.manager.tooltips.indexOf(e);return i<0?null:n.manager.tooltipViews[i]}class Hs extends zi{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Hs.prototype.elementClass="";Hs.prototype.toDOM=void 0;Hs.prototype.mapMode=Rt.TrackBefore;Hs.prototype.startSide=Hs.prototype.endSide=-1;Hs.prototype.point=!0;const fb=1024;let o3=0;class Jh{constructor(e,n){this.from=e,this.to=n}}class se{constructor(e={}){this.id=o3++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Mt.match(e)),n=>{let i=e(n);return i===void 0?null:[this,i]}}}se.closedBy=new se({deserialize:t=>t.split(" ")});se.openedBy=new se({deserialize:t=>t.split(" ")});se.group=new se({deserialize:t=>t.split(" ")});se.isolate=new se({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});se.contextHash=new se({perNode:!0});se.lookAhead=new se({perNode:!0});se.mounted=new se({perNode:!0});class Ko{constructor(e,n,i,r=!1){this.tree=e,this.overlay=n,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[se.mounted.id]}}const l3=Object.create(null);class Mt{constructor(e,n,i,r=0){this.name=e,this.props=n,this.id=i,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):l3,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Mt(e.name||"",n,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(se.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let i in e)for(let r of i.split(" "))n[r]=e[i];return i=>{for(let r=i.prop(se.group),s=-1;s<(r?r.length:0);s++){let o=n[s<0?i.name:r[s]];if(o)return o}}}}Mt.none=new Mt("",Object.create(null),0,8);class qm{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);if(o){r||(r=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}n.push(r?new Mt(i.name,r,i.id,i.flags):i)}return new qm(n)}}const Pa=new WeakMap,ov=new WeakMap;var Me;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Me||(Me={}));class Le{constructor(e,n,i,r,s){if(this.type=e,this.children=n,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Ko.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let i of this.children){let r=i.toString();r&&(n&&(n+=","),n+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new ip(this.topNode,e)}cursorAt(e,n=0,i=0){let r=Pa.get(this)||this.topNode,s=new ip(r);return s.moveTo(e,n),Pa.set(this,s._tree),s}get topNode(){return new Jt(this,0,0,null)}resolve(e,n=0){let i=Ml(Pa.get(this)||this.topNode,e,n,!1);return Pa.set(this,i),i}resolveInner(e,n=0){let i=Ml(ov.get(this)||this.topNode,e,n,!0);return ov.set(this,i),i}resolveStack(e,n=0){return c3(this,e,n)}iterate(e){let{enter:n,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&Me.IncludeAnonymous)>0;for(let a=this.cursor(o|Me.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Ym(Mt.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new Le(this.type,n,i,r,this.propValues),e.makeTree||((n,i,r)=>new Le(Mt.none,n,i,r)))}static build(e){return h3(e)}}Le.empty=new Le(Mt.none,[],[],0);class Km{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Km(this.buffer,this.index)}}class Wi{constructor(e,n,i){this.buffer=e,this.length=n,this.set=i}get type(){return Mt.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],i=this.buffer[e+3],r=this.set.types[n],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=n&&!(db(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,n,i){let r=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l<n;){s[a++]=r[l++],s[a++]=r[l++]-i;let u=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,u)}return new Wi(s,o,this.set)}}function db(t,e,n,i){switch(t){case-2:return n<e;case-1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function Ml(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!i&&t instanceof Jt&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=i?0:Me.IgnoreOverlays;if(i)for(let o=t,l=o.parent;l;o=l,l=o.parent)o instanceof Jt&&o.index<0&&((r=l.enter(e,n,s))===null||r===void 0?void 0:r.from)!=o.from&&(t=l);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class pb{cursor(e=0){return new ip(this,e)}getChild(e,n=null,i=null){let r=lv(this,e,n,i);return r.length?r[0]:null}getChildren(e,n=null,i=null){return lv(this,e,n,i)}resolve(e,n=0){return Ml(this,e,n,!1)}resolveInner(e,n=0){return Ml(this,e,n,!0)}matchContext(e){return np(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),i=this;for(;n;){let r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(i=n,n=r.prevSibling):n=r}return i}get node(){return this}get next(){return this.parent}}class Jt extends pb{constructor(e,n,i,r){super(),this._tree=e,this.from=n,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,u=n>0?l.length:-1;e!=u;e+=n){let c=l[e],h=a[e]+o.from,f;if(!(!(s&Me.EnterBracketed&&c instanceof Le&&(f=Ko.get(c))&&!f.overlay&&f.bracketed&&i>=h&&i<=h+c.length)&&!db(r,i,h,h+c.length))){if(c instanceof Wi){if(s&Me.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,n,i-h,r);if(d>-1)return new Ni(new a3(o,c,e,h),null,d)}else if(s&Me.IncludeAnonymous||!c.type.isAnonymous||Qm(c)){let d;if(!(s&Me.IgnoreMounts)&&(d=Ko.get(c))&&!d.overlay)return new Jt(d.tree,h,e,o);let p=new Jt(c,h,e,o);return s&Me.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,i,r,s)}}}if(s&Me.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,i=0){let r;if(!(i&Me.IgnoreOverlays)&&(r=Ko.get(this._tree))&&r.overlay){let s=e-this.from,o=i&Me.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((n>0||o?l<=s:l<s)&&(n<0||o?a>=s:a>s))return new Jt(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function lv(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function np(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class a3{constructor(e,n,i,r){this.parent=e,this.buffer=n,this.index=i,this.start=r}}class Ni extends pb{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,i){super(),this.context=e,this._parent=n,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,i);return s<0?null:new Ni(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,i=0){if(i&Me.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Ni(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Ni(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Ni(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),n.push(0)}return new Le(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function mb(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let i=n instanceof Jt&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new u3(r,n)}class u3{constructor(e,n){this.heads=e,this.node=n}get next(){return mb(this.heads)}}function c3(t,e,n){let i=t.resolveInner(e,n),r=null;for(let s=i instanceof Jt?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,n)),s=o}else{let o=Ko.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Jt(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Ml(l,e,n,!1))}}return r?mb(r):i}class ip{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Me.EnterBracketed,e instanceof Jt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof Jt?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,i=this.mode){return this.buffer?i&Me.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Me.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Me.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:i}=r)}else({index:n,_parent:i}=this._tree);for(;i;{index:n,_parent:i}=i)if(n>-1)for(let s=n+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&Me.IncludeAnonymous||l instanceof Wi||!l.type.isAnonymous||Qm(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;n=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)n=new Ni(this.buffer,n,this.stack[r]);return this.bufferNode=new Ni(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&n&&n(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return np(this.node.parent,e);let{buffer:n}=this.buffer,{types:i}=n.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return np(this._tree,e,r);let o=i[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Qm(t){return t.children.some(e=>e instanceof Wi||!e.type.isAnonymous||Qm(e))}function h3(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=fb,reused:s=[],minRepeatType:o=i.types.length}=t,l=Array.isArray(n)?new Km(n,n.length):n,a=i.types,u=0,c=0;function h(S,_,E,A,I,R){let{id:O,start:D,end:$,size:b}=l,C=c,N=u;if(b<0)if(l.next(),b==-1){let F=s[O];E.push(F),A.push(D-S);return}else if(b==-3){u=O;return}else if(b==-4){c=O;return}else throw new RangeError(`Unrecognized record size: ${b}`);let j=a[O],P,T,B=D-S;if($-D<=r&&(T=x(l.pos-_,I))){let F=new Uint16Array(T.size-T.skip),z=l.pos-T.size,L=F.length;for(;l.pos>z;)L=m(T.start,F,L);P=new Wi(F,$-T.start,i),B=T.start-S}else{let F=l.pos-b;l.next();let z=[],L=[],H=O>=o?O:-1,q=0,ee=$;for(;l.pos>F;)H>=0&&l.id==H&&l.size>=0?(l.end<=ee-r&&(p(z,L,D,q,l.end,ee,H,C,N),q=z.length,ee=l.end),l.next()):R>2500?f(D,F,z,L):h(D,F,z,L,H,R+1);if(H>=0&&q>0&&q<z.length&&p(z,L,D,q,D,ee,H,C,N),z.reverse(),L.reverse(),H>-1&&q>0){let J=d(j,N);P=Ym(j,z,L,0,z.length,0,$-D,J,J)}else P=g(j,z,L,$-D,C-$,N)}E.push(P),A.push(B)}function f(S,_,E,A){let I=[],R=0,O=-1;for(;l.pos>_;){let{id:D,start:$,end:b,size:C}=l;if(C>4)l.next();else{if(O>-1&&$<O)break;O<0&&(O=b-r),I.push(D,$,b),R++,l.next()}}if(R){let D=new Uint16Array(R*4),$=I[I.length-2];for(let b=I.length-3,C=0;b>=0;b-=3)D[C++]=I[b],D[C++]=I[b+1]-$,D[C++]=I[b+2]-$,D[C++]=C;E.push(new Wi(D,I[2]-$,i)),A.push($-S)}}function d(S,_){return(E,A,I)=>{let R=0,O=E.length-1,D,$;if(O>=0&&(D=E[O])instanceof Le){if(!O&&D.type==S&&D.length==I)return D;($=D.prop(se.lookAhead))&&(R=A[O]+D.length+$)}return g(S,E,A,I,R,_)}}function p(S,_,E,A,I,R,O,D,$){let b=[],C=[];for(;S.length>A;)b.push(S.pop()),C.push(_.pop()+E-I);S.push(g(i.types[O],b,C,R-I,D-R,$)),_.push(I-E)}function g(S,_,E,A,I,R,O){if(R){let D=[se.contextHash,R];O=O?[D].concat(O):[D]}if(I>25){let D=[se.lookAhead,I];O=O?[D].concat(O):[D]}return new Le(S,_,E,A,O)}function x(S,_){let E=l.fork(),A=0,I=0,R=0,O=E.end-r,D={size:0,start:0,skip:0};e:for(let $=E.pos-S;E.pos>$;){let b=E.size;if(E.id==_&&b>=0){D.size=A,D.start=I,D.skip=R,R+=4,A+=4,E.next();continue}let C=E.pos-b;if(b<0||C<$||E.start<O)break;let N=E.id>=o?4:0,j=E.start;for(E.next();E.pos>C;){if(E.size<0)if(E.size==-3||E.size==-4)N+=4;else break e;else E.id>=o&&(N+=4);E.next()}I=j,A+=b,R+=N}return(_<0||A==S)&&(D.size=A,D.start=I,D.skip=R),D.size>4?D:void 0}function m(S,_,E){let{id:A,start:I,end:R,size:O}=l;if(l.next(),O>=0&&A<o){let D=E;if(O>4){let $=l.pos-(O-4);for(;l.pos>$;)E=m(S,_,E)}_[--E]=D,_[--E]=R-S,_[--E]=I-S,_[--E]=A}else O==-3?u=A:O==-4&&(c=A);return E}let v=[],w=[];for(;l.pos>0;)h(t.start||0,t.bufferStart||0,v,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:v.length?w[0]+v[0].length:0;return new Le(a[t.topID],v.reverse(),w.reverse(),k)}const av=new WeakMap;function au(t,e){if(!t.isAnonymous||e instanceof Wi||e.type!=t)return 1;let n=av.get(e);if(n==null){n=1;for(let i of e.children){if(i.type!=t||!(i instanceof Le)){n=1;break}n+=au(t,i)}av.set(e,n)}return n}function Ym(t,e,n,i,r,s,o,l,a){let u=0;for(let p=i;p<r;p++)u+=au(t,e[p]);let c=Math.ceil(u*1.5/8),h=[],f=[];function d(p,g,x,m,v){for(let w=x;w<m;){let k=w,S=g[w],_=au(t,p[w]);for(w++;w<m;w++){let E=au(t,p[w]);if(_+E>=c)break;_+=E}if(w==k+1){if(_>c){let E=p[k];d(E.children,E.positions,0,E.children.length,g[k]+v);continue}h.push(p[k])}else{let E=g[w-1]+p[w-1].length-S;h.push(Ym(t,p,g,k,w,S,E,null,a))}f.push(S+v-s)}}return d(e,n,i,r,0),(l||a)(h,f,o)}class vr{constructor(e,n,i,r,s=!1,o=!1){this.from=e,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],i=!1){let r=[new vr(0,e.length,e,0,!1,i)];for(let s of n)s.to>e.length&&r.push(s);return r}static applyChanges(e,n,i=128){if(!n.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l<n.length?n[l]:null,h=c?c.fromA:1e9;if(h-a>=i)for(;o&&o.from<h;){let f=o;if(a>=f.from||h<=f.to||u){let d=Math.max(f.from,a)-u,p=Math.min(f.to,h)-u;f=d>=p?null:new vr(d,p,f.tree,f.offset+u,l>0,!!c)}if(f&&r.push(f),o.to>h)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,u=c.toA-c.toB}return r}}class gb{startParse(e,n,i){return typeof e=="string"&&(e=new f3(e)),i=i?i.length?i.map(r=>new Jh(r.from,r.to)):[new Jh(0,0)]:[new Jh(0,e.length)],this.createParse(e,n||[],i)}parse(e,n,i){let r=this.startParse(e,n,i);for(;;){let s=r.advance();if(s)return s}}}class f3{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new se({perNode:!0});var uv={};class nc{constructor(e,n,i,r,s,o,l,a,u,c=0,h){this.p=e,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new nc(e,[],n,i,i,0,[],0,r?new cv(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=s.dynamicPrecedence(r);if(l&&(this.score+=l),i==0){r<s.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let a=this.stack.length-(i-1)*3-(e&262144?6:0),u=a?this.stack[a-2]:this.p.ranges[0].from;r<s.minRepeatTerm&&u==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-u;c>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,f=this.bufferBase+this.buffer.length-h;if(r<s.minRepeatTerm||e&131072){let d=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,u,d,f+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=s.getGoto(d,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,u)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==i)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4);else{let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new nc(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new d3(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if(!(i&65536))return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<n.length;s+=2){let o=n[s+1];r.some((l,a)=>a&1&&l==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r<n.length&&i.length<4;r+=2){let s=n[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let i=n>>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new cv(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class cv{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class d3{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class ic{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new ic(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new ic(this.stack,this.pos,this.index)}}function Ra(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i<t.length;){let s=0;for(;;){let o=t.charCodeAt(i++),l=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class uu{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const hv=new uu;class p3{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=hv,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;n<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=hv,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class Cs{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;m3(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}Cs.prototype.contextual=Cs.prototype.fallback=Cs.prototype.extend=!1;Cs.prototype.fallback=Cs.prototype.extend=!1;function m3(t,e,n,i,r,s){let o=0,l=1<<i,{dialect:a}=n.p.parser;e:for(;l&t[o];){let u=t[o+1];for(let d=o+3;d<u;d+=2)if((t[d+1]&l)>0){let p=t[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||g3(p,e.token.value,r,s))){e.acceptToken(p);break}}let c=e.next,h=0,f=t[o+2];if(e.next<0&&f>h&&t[u+f*3-3]==65535){o=t[u+f*3-1];continue e}for(;h<f;){let d=h+f>>1,p=u+d+(d<<1),g=t[p],x=t[p+1]||65536;if(c<g)f=d;else if(c>=x)h=d+1;else{o=t[p+2],e.advance();continue e}}break}}function fv(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function g3(t,e,n,i){let r=fv(n,i,e);return r<0||fv(n,i,t)<r}const Ot=typeof process<"u"&&uv&&/\bparse\b/.test(uv.LOG);let Zh=null;function dv(t,e,n){let i=t.cursor(Me.IncludeAnonymous);for(i.moveTo(e);;)if(!(n<0?i.childBefore(e):i.childAfter(e)))for(;;){if((n<0?i.to<e:i.from>e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class y3{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?dv(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?dv(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let i=this.trees[n],r=this.index[n];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[n]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof Le){if(o==e){if(o<this.safeFrom)return null;let l=o+s.length;if(l<=this.safeTo){let a=s.prop(se.lookAhead);if(!a||l+a<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class v3{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new uu)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;u<s.length;u++){if(!(1<<u&o))continue;let c=s[u],h=this.tokens[u];if(!(i&&!c.fallback)&&((c.contextual||h.start!=e.pos||h.mask!=o||h.context!=l)&&(this.updateCachedToken(h,c,e),h.mask=o,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let f=n;if(h.extended>-1&&(n=this.addActions(e,h.extended,h.end,n)),n=this.addActions(e,h.value,h.end,n),!c.extend&&(i=h,n>f))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new uu,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new uu,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let l=s.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=i,r}addActions(e,n,i,r){let{state:s}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let u=o.stateSlot(s,a?2:1);;u+=3){if(l[u]==65535)if(l[u+1]==1)u=Qn(l,u+2);else{r==0&&l[u+1]==2&&(r=this.putAction(Qn(l,u+2),n,i,r));break}l[u]==n&&(r=this.putAction(Qn(l,u+1),n,i,r))}return r}}class w3{constructor(e,n,i,r){this.parser=e,this.input=n,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new p3(n,r),this.tokens=new v3(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[nc.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new y3(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>n)i.push(l);else{if(this.advanceStack(l,i,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!i.length){let o=r&&k3(r);if(o)return Ot&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Ot&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return Ot&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let u=i[a];if(l.sameState(u)||l.buffer.length>500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,i){let r=e.pos,{parser:s}=this,o=Ot?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let h=this.fragments.nodeAt(r);h;){let f=this.parser.nodeSet.types[h.type.id]==h.type?s.getGoto(e.state,h.type.id):-1;if(f>-1&&h.length&&(!u||(h.prop(se.contextHash)||0)==c))return e.useNode(h,f),Ot&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(h.type.id)})`),!0;if(!(h instanceof Le)||h.children.length==0||h.positions[0]>0)break;let d=h.children[0];if(d instanceof Le&&h.positions[0]==0)h=d;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Ot&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;u<a.length;){let c=a[u++],h=a[u++],f=a[u++],d=u==a.length||!i,p=d?e:e.split(),g=this.tokens.mainToken;if(p.apply(c,h,g?g.start:p.pos,f),Ot&&console.log(o+this.stackID(p)+` (via ${c&65536?`reduce of ${s.getName(c&65535)}`:"shift"} for ${s.getName(h)} @ ${r}${p==e?"":", split"})`),d)return!0;p.pos>r?n.push(p):i.push(p)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return pv(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let l=e[o],a=n[o<<1],u=n[(o<<1)+1],c=Ot?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),Ot&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let h=l.split(),f=c;for(let d=0;d<10&&h.forceReduce()&&(Ot&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,i));d++)Ot&&(f=this.stackID(h)+" -> ");for(let d of l.recoverByInsert(a))Ot&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),Ot&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),pv(l,i)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),Le.build({buffer:ic.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Zh||(Zh=new WeakMap)).get(e);return n||Zh.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function pv(t,e){for(let n=0;n<e.length;n++){let i=e[n];if(i.pos==t.pos&&i.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class x3{constructor(e,n,i){this.source=e,this.flags=n,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class rc extends gb{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let l=0;l<e.repeatNodeCount;l++)n.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),r=[];for(let l=0;l<n.length;l++)r.push([]);function s(l,a,u){r[l].push([a,a.deserialize(String(u))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=se[a]);for(let u=1;u<l.length;){let c=l[u++];if(c>=0)s(c,a,l[u++]);else{let h=l[u+-c];for(let f=-c;f>0;f--)s(l[u++],a,h);u++}}}this.nodeSet=new qm(n.map((l,a)=>Mt.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=fb;let o=Ra(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(mv),this.states=Ra(e.states,Uint32Array),this.data=Ra(e.stateData),this.goto=Ra(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new Cs(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,i){let r=new w3(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],l=o&1,a=r[s++];if(l&&i)return a;for(let u=s+(o>>1);s<u;s++)if(r[s]==e)return a;if(l)return-1}}hasAction(e,n){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Qn(i,s+2)];else{if(i[s+1]==2)return Qn(i,s+2);break}if(o==n||o==0)return Qn(i,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Qn(this.data,s+2);else break;r=n(Qn(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Qn(this.data,i+2);else break;if(!(this.data[i+2]&1)){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(rc.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=mv(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<n.length;s++)if(!i[s])for(let o=this.dialects[n[s]],l;(l=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[l]=1;return new x3(e,i,r)}static deserialize(e){return new rc(e)}}function Qn(t,e){return t[e]|t[e+1]<<16}function k3(t){let e=null;for(let n of t){let i=n.p.stoppedAt;(n.pos==n.p.stream.end||i!=null&&n.pos>i)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function mv(t){if(t.external){let e=t.extend?1:0;return(n,i)=>t.external(n,i)<<1|e}return t.get}let S3=0;class Wt{constructor(e,n,i,r){this.name=e,this.set=n,this.base=i,this.modified=r,this.id=S3++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let i=typeof e=="string"?e:"?";if(e instanceof Wt&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let r=new Wt(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(e){let n=new sc(e);return i=>i.modified.indexOf(n)>-1?i:sc.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}}let b3=0;class sc{constructor(e){this.name=e,this.instances=[],this.id=b3++}static get(e,n){if(!n.length)return e;let i=n[0].instances.find(l=>l.base==e&&C3(n,l.modified));if(i)return i;let r=[],s=new Wt(e.name,r,e,n);for(let l of n)l.instances.push(s);let o=E3(n);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(sc.get(l,a));return s}}function C3(t,e){return t.length==e.length&&t.every((n,i)=>n==e[i])}function E3(t){let e=[[]];for(let n=0;n<t.length;n++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[n]));return e.sort((n,i)=>i.length-n.length)}function yb(t){let e=Object.create(null);for(let n in t){let i=t[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],o=2,l=r;for(let h=0;;){if(l=="..."&&h>0&&h+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==r.length)break;let d=r[h++];if(h==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(h)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+r);let c=new Tl(i,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return vb.add(e)}const vb=new se({combine(t,e){let n,i,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new Tl(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class Tl{constructor(e,n,i,r){this.tags=e,this.mode=n,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Tl.empty=new Tl([],2,null);function wb(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:i}}function _3(t,e){let n=null;for(let i of t){let r=i.style(e);r&&(n=n?n+" "+r:r)}return n}function N3(t,e,n,i=0,r=t.length){let s=new A3(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}class A3{constructor(e,n,i){this.at=e,this.highlighters=n,this.span=i,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=n)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let u=r,c=M3(e)||Tl.empty,h=_3(s,c.tags);if(h&&(u&&(u+=" "),u+=h,c.mode==1&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(n,l),u),c.opaque)return;let f=e.tree&&e.tree.prop(se.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(x=>!x.scope||x.scope(f.tree.type)),g=e.firstChild();for(let x=0,m=l;;x++){let v=x<f.overlay.length?f.overlay[x]:null,w=v?v.from+l:a,k=Math.max(n,m),S=Math.min(i,w);if(k<S&&g)for(;e.from<S&&(this.highlightRange(e,k,S,r,s),this.startSpan(Math.min(S,e.to),u),!(e.to>=w||!e.nextSibling())););if(!v||w>i)break;m=v.to+l,m>n&&(this.highlightRange(d.cursor(),Math.max(n,v.from+l),Math.min(i,m),"",p),this.startSpan(Math.min(i,m),u))}g&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=n)){if(e.from>=i)break;this.highlightRange(e,n,i,r,s),this.startSpan(Math.min(i,e.to),u)}while(e.nextSibling());e.parent()}}}function M3(t){let e=t.type.prop(vb);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const K=Wt.define,Da=K(),yi=K(),gv=K(yi),yv=K(yi),vi=K(),La=K(vi),ef=K(vi),An=K(),nr=K(An),_n=K(),Nn=K(),rp=K(),vo=K(rp),Ba=K(),X={comment:Da,lineComment:K(Da),blockComment:K(Da),docComment:K(Da),name:yi,variableName:K(yi),typeName:gv,tagName:K(gv),propertyName:yv,attributeName:K(yv),className:K(yi),labelName:K(yi),namespace:K(yi),macroName:K(yi),literal:vi,string:La,docString:K(La),character:K(La),attributeValue:K(La),number:ef,integer:K(ef),float:K(ef),bool:K(vi),regexp:K(vi),escape:K(vi),color:K(vi),url:K(vi),keyword:_n,self:K(_n),null:K(_n),atom:K(_n),unit:K(_n),modifier:K(_n),operatorKeyword:K(_n),controlKeyword:K(_n),definitionKeyword:K(_n),moduleKeyword:K(_n),operator:Nn,derefOperator:K(Nn),arithmeticOperator:K(Nn),logicOperator:K(Nn),bitwiseOperator:K(Nn),compareOperator:K(Nn),updateOperator:K(Nn),definitionOperator:K(Nn),typeOperator:K(Nn),controlOperator:K(Nn),punctuation:rp,separator:K(rp),bracket:vo,angleBracket:K(vo),squareBracket:K(vo),paren:K(vo),brace:K(vo),content:An,heading:nr,heading1:K(nr),heading2:K(nr),heading3:K(nr),heading4:K(nr),heading5:K(nr),heading6:K(nr),contentSeparator:K(An),list:K(An),quote:K(An),emphasis:K(An),strong:K(An),link:K(An),monospace:K(An),strikethrough:K(An),inserted:K(),deleted:K(),changed:K(),invalid:K(),meta:Ba,documentMeta:K(Ba),annotation:K(Ba),processingInstruction:K(Ba),definition:Wt.defineModifier("definition"),constant:Wt.defineModifier("constant"),function:Wt.defineModifier("function"),standard:Wt.defineModifier("standard"),local:Wt.defineModifier("local"),special:Wt.defineModifier("special")};for(let t in X){let e=X[t];e instanceof Wt&&(e.name=t)}wb([{tag:X.link,class:"tok-link"},{tag:X.heading,class:"tok-heading"},{tag:X.emphasis,class:"tok-emphasis"},{tag:X.strong,class:"tok-strong"},{tag:X.keyword,class:"tok-keyword"},{tag:X.atom,class:"tok-atom"},{tag:X.bool,class:"tok-bool"},{tag:X.url,class:"tok-url"},{tag:X.labelName,class:"tok-labelName"},{tag:X.inserted,class:"tok-inserted"},{tag:X.deleted,class:"tok-deleted"},{tag:X.literal,class:"tok-literal"},{tag:X.string,class:"tok-string"},{tag:X.number,class:"tok-number"},{tag:[X.regexp,X.escape,X.special(X.string)],class:"tok-string2"},{tag:X.variableName,class:"tok-variableName"},{tag:X.local(X.variableName),class:"tok-variableName tok-local"},{tag:X.definition(X.variableName),class:"tok-variableName tok-definition"},{tag:X.special(X.variableName),class:"tok-variableName2"},{tag:X.definition(X.propertyName),class:"tok-propertyName tok-definition"},{tag:X.typeName,class:"tok-typeName"},{tag:X.namespace,class:"tok-namespace"},{tag:X.className,class:"tok-className"},{tag:X.macroName,class:"tok-macroName"},{tag:X.propertyName,class:"tok-propertyName"},{tag:X.operator,class:"tok-operator"},{tag:X.comment,class:"tok-comment"},{tag:X.meta,class:"tok-meta"},{tag:X.invalid,class:"tok-invalid"},{tag:X.punctuation,class:"tok-punctuation"}]);const T3=yb({String:X.string,Number:X.number,"True False":X.bool,PropertyName:X.propertyName,Null:X.null,", :":X.separator,"[ ]":X.squareBracket,"{ }":X.brace}),O3=rc.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[T3],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});var tf;const os=new se;function I3(t){return ne.define({combine:t?e=>e.concat(t):void 0})}const P3=new se;class dn{constructor(e,n,i=[],r=""){this.data=e,this.name=r,ce.prototype.hasOwnProperty("tree")||Object.defineProperty(ce.prototype,"tree",{get(){return tn(this)}}),this.parser=n,this.extension=[Us.of(this),ce.languageData.of((s,o,l)=>{let a=vv(s,o,l),u=a.type.prop(os);if(!u)return[];let c=s.facet(u),h=a.type.prop(P3);if(h){let f=a.resolve(o-a.from,l);for(let d of h)if(d.test(f,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,n,i=-1){return vv(e,n,i).type.prop(os)==this.data}findRegions(e){let n=e.facet(Us);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(os)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(se.mounted);if(l){if(l.tree.prop(os)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let u=s.children[a];u instanceof Le&&r(u,s.positions[a]+o)}};return r(tn(e),0),i}get allowsNesting(){return!0}}dn.setState=ve.define();function vv(t,e,n){let i=t.facet(Us),r=tn(t).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,n,Me.ExcludeBuffers|Me.EnterBracketed))s.type.isTop&&(r=s);return r}class oc extends dn{constructor(e,n,i){super(e,n,[],i),this.parser=n}static define(e){let n=I3(e.languageData);return new oc(n,e.parser.configure({props:[os.add(i=>i.isTop?n:void 0)]}),e.name)}configure(e,n){return new oc(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function tn(t){let e=t.field(dn.state,!1);return e?e.tree:Le.empty}class R3{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let i=this.cursorPos-this.string.length;return e<i||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-i,n-i)}}let wo=null;class lc{constructor(e,n,i=[],r,s,o,l,a){this.parser=e,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,i){return new lc(e,n,[],Le.empty,0,i,[],null)}startParse(){return this.parser.startParse(new R3(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Le.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(vr.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(vr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=wo;wo=this;try{return e()}finally{wo=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=wv(e,n.from,n.to);return e}changes(e,n){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,h,f)=>a.push({fromA:u,toA:c,fromB:h,toB:f})),i=vr.applyChanges(i,a),r=Le.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),h=e.mapPos(u.to,-1);c<h&&l.push({from:c,to:h})}}}return new lc(this.parser,n,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=wv(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends gb{createParse(n,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=wo;if(a){for(let u of r)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Le(Mt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return wo}}function wv(t,e,n){return vr.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Ws{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new Ws(n)}static init(e){let n=Math.min(3e3,e.doc.length),i=lc.create(e.facet(Us).parser,e,{from:0,to:n});return i.work(20,n)||i.takeTree(),new Ws(i)}}dn.state=ci.define({create:Ws.init,update(t,e){for(let n of e.effects)if(n.is(dn.setState))return n.value;return e.startState.facet(Us)!=e.state.facet(Us)?Ws.init(e.state):t.apply(e)}});let xb=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(xb=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const nf=typeof navigator<"u"&&(!((tf=navigator.scheduling)===null||tf===void 0)&&tf.isInputPending)?()=>navigator.scheduling.isInputPending():null,D3=zn.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(dn.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(dn.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=xb(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(dn.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!nf?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>nf&&nf()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:dn.setState.of(new Ws(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Lt(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Us=ne.define({combine(t){return t.length?t[0]:null},enables:t=>[dn.state,D3,Z.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class L3{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const B3=ne.define(),Xm=ne.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function ac(t){let e=t.facet(Xm);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function uc(t,e){let n="",i=t.tabSize,r=t.facet(Xm)[0];if(r==" "){for(;e>=i;)n+=" ",e-=i;r=" "}for(let s=0;s<e;s++)n+=r;return n}function kb(t,e){t instanceof ce&&(t=new Uc(t));for(let i of t.state.facet(B3)){let r=i(t,e);if(r!==void 0)return r}let n=tn(t.state);return n.length>=e?j3(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=ac(e)}lineAt(e,n=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(n<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,n);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,n=e.length){return $c(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Sb=new se;function j3(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return bb(i,t,n)}function bb(t,e,n){for(let i=t;i;i=i.next){let r=z3(i.node);if(r)return r(Gm.create(e,n,i))}return 0}function $3(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function z3(t){let e=t.type.prop(Sb);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(se.closedBy))){let r=t.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>W3(o,!0,1,void 0,s&&!$3(o)?r.from:void 0)}return t.parent==null?F3:null}function F3(){return 0}class Gm extends Uc{constructor(e,n,i){super(e.state,e.options),this.base=e,this.pos=n,this.context=i}get node(){return this.context.node}static create(e,n,i){return new Gm(e,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(V3(i,e))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return bb(this.context.next,this.base,this.pos)}}function V3(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function H3(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function W3(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,a=H3(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function xv({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}const U3=new se;function q3(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}class qc{constructor(e,n){this.specs=e;let i;function r(l){let a=Fi.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const s=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,o=n.scope;this.scope=o instanceof dn?l=>l.prop(os)==o.data:o?l=>l==o:void 0,this.style=wb(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Fi(i):null,this.themeType=n.themeType}static define(e,n){return new qc(e,n||{})}}const sp=ne.define(),K3=ne.define({combine(t){return t.length?[t[0]]:null}});function rf(t){let e=t.facet(sp);return e.length?e:t.facet(K3)}function Q3(t,e){let n=[X3],i;return t instanceof qc&&(t.module&&n.push(Z.styleModule.of(t.module)),i=t.themeType),i?n.push(sp.computeN([Z.darkTheme],r=>r.facet(Z.darkTheme)==(i=="dark")?[t]:[])):n.push(sp.of(t)),n}class Y3{constructor(e){this.markCache=Object.create(null),this.tree=tn(e.state),this.decorations=this.buildDeco(e,rf(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=tn(e.state),i=rf(e.state),r=i!=rf(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!r&&n.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Ie.none;let i=new bl;for(let{from:r,to:s}of e.visibleRanges)N3(this.tree,n,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Ie.mark({class:a})))},r,s);return i.finish()}}const X3=Fl.high(zn.fromClass(Y3,{decorations:t=>t.decorations})),G3=1e4,J3="()[]{}",Z3=new se;function op(t,e,n){let i=t.prop(e<0?se.openedBy:se.closedBy);if(i)return i;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function lp(t){let e=t.type.prop(Z3);return e?e(t.node):t}function ls(t,e,n,i={}){let r=i.maxScanDistance||G3,s=i.brackets||J3,o=tn(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=op(a.type,n,s);if(u&&a.from<a.to){let c=lp(a);if(c&&(n>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return e4(t,e,n,a,c,u,s)}}return t4(t,e,n,o,l.type,r,s)}function e4(t,e,n,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(i.from):c.childAfter(i.to)))do if(n<0?c.to<=i.from:c.from>=i.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let h=lp(c);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(op(c.type,n,o))u++;else if(op(c.type,-n,o)){if(u==0){let h=lp(c);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}u--}}while(n<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function t4(t,e,n,i,r,s,o){if(n<0?!e:e==t.doc.length)return null;let l=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),h=0;for(let f=0;!c.next().done&&f<=s;){let d=c.value;n<0&&(f+=d.length);let p=e+f*n;for(let g=n>0?0:d.length-1,x=n>0?d.length:-1;g!=x;g+=n){let m=o.indexOf(d[g]);if(!(m<0||i.resolveInner(p+g,1).type!=r))if(m%2==0==n>0)h++;else{if(h==1)return{start:u,end:{from:p+g,to:p+g+1},matched:m>>1==a>>1};h--}}n>0&&(f+=d.length)}return c.done?{start:u,matched:!1}:null}const n4=Object.create(null),kv=[Mt.none],Sv=[],bv=Object.create(null),i4=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])i4[t]=r4(n4,e);function sf(t,e){Sv.indexOf(t)>-1||(Sv.push(t),console.warn(e))}function r4(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||X[u];c?typeof c=="function"?a.length?a=a.map(c):sf(u,`Modifier ${u} used at start of tag`):a.length?sf(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:sf(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(l=>l.id),s=bv[r];if(s)return s.id;let o=bv[r]=Mt.define({id:kv.length,name:i,props:[yb({[i]:n})]});return kv.push(o),o.id}Oe.RTL,Oe.LTR;const s4=oc.define({name:"json",parser:O3.configure({props:[Sb.add({Object:xv({except:/^\s*\}/}),Array:xv({except:/^\s*\]/})}),U3.add({"Object Array":q3})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function o4(){return new L3(s4)}class Cb{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=tn(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(Eb(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Cv(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function l4(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;s<r.length;s++)n[r[s]]=!0}let i=Cv(e)+Cv(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function a4(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:l4(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}class Ev{constructor(e,n,i,r){this.completion=e,this.source=n,this.match=i,this.score=r}}function wr(t){return t.selection.main.from}function Eb(t,e){var n;let{source:i}=t,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?t:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const _b=Vn.define();function u4(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return{...t.changeByRange(l=>{if(l!=r&&n!=i&&t.sliceDoc(l.from+s,l.from+o)!=t.sliceDoc(n,i))return{range:l};let a=t.toText(e);return{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:a},range:W.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const _v=new WeakMap;function c4(t){if(!Array.isArray(t))return t;let e=_v.get(t);return e||_v.set(t,e=a4(t)),e}const cc=ve.define(),Ol=ve.define();class h4{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let i=or(e,n),r=Wr(i);this.chars.push(i);let s=e.slice(n,n+r),o=s.toUpperCase();this.folded.push(or(o==s?s.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:i,any:r,precise:s,byWord:o}=this;if(n.length==1){let v=or(e,0),w=Wr(v),k=w==e.length?0:-100;if(v!=n[0])if(v==i[0])k+=-200;else return null;return this.ret(k,[0,w])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=n.length,u=0;if(l<0){for(let v=0,w=Math.min(e.length,200);v<w&&u<a;){let k=or(e,v);(k==n[u]||k==i[u])&&(r[u++]=v),v+=Wr(k)}if(u<a)return null}let c=0,h=0,f=!1,d=0,p=-1,g=-1,x=/[a-z]/.test(e),m=!0;for(let v=0,w=Math.min(e.length,200),k=0;v<w&&h<a;){let S=or(e,v);l<0&&(c<a&&S==n[c]&&(s[c++]=v),d<a&&(S==n[d]||S==i[d]?(d==0&&(p=v),g=v+1,d++):d=0));let _,E=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(_=QP(S))!=_.toLowerCase()?1:_!=_.toUpperCase()?2:0;(!v||E==1&&x||k==0&&E!=0)&&(n[h]==S||i[h]==S&&(f=!0)?o[h++]=v:o.length&&(m=!1)),k=E,v+=Wr(S)}return h==a&&o[0]==0&&m?this.result(-100+(f?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,g]):h==a?this.result(-100+(f?-200:0)+-700+(m?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,i){let r=[],s=0;for(let o of n){let l=o+(this.astral?Wr(or(i,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-i.length,r)}}class f4{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),i=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,n.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const Ue=ne.define({combine(t){return pS(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:d4,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>i=>Nv(e(i),n(i)),optionClass:(e,n)=>i=>Nv(e(i),n(i)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function Nv(t,e){return t?e?t+" "+e:t:e}function d4(t,e,n,i,r,s){let o=t.textDirection==Oe.RTL,l=o,a=!1,u="top",c,h,f=e.left-r.left,d=r.right-e.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&f<Math.min(p,d)?l=!1:!l&&d<Math.min(p,f)&&(l=!0),p<=(l?f:d))c=Math.max(r.top,Math.min(n.top,r.bottom-g))-e.top,h=Math.min(400,l?f:d);else{a=!0,h=Math.min(400,(o?e.right:r.right-e.left)-30);let v=r.bottom-e.bottom;v>=g||v>e.top?c=n.bottom-e.top:(u="bottom",c=e.bottom-n.top)}let x=(e.bottom-e.top)/s.offsetHeight,m=(e.right-e.left)/s.offsetWidth;return{style:`${u}: ${c/x}px; max-width: ${h/m}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Jm=ve.define();function p4(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(n,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=n.displayLabel||n.label,a=0;for(let u=0;u<s.length;){let c=s[u++],h=s[u++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(l.slice(c,h))),f.className="cm-completionMatchedText",a=h}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(n){if(!n.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=n.detail,i},position:80}),e.sort((n,i)=>n.position-i.position).map(n=>n.render)}function of(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let i=Math.ceil((t-e)/n);return{from:t-i*n,to:t-(i-1)*n}}class m4{constructor(e,n,i){this.view=e,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:s,selected:o}=r.open,l=e.state.facet(Ue);this.optionContent=p4(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=of(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:u}=e.state.field(n).open;for(let c=a.target,h;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(h=/-(\d+)$/.exec(c.id))&&+h[1]<u.length){this.applyCompletion(e,u[+h[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:Jm.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(Ue).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Ol.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:l}=i.open;(!r.open||r.open.options!=s)&&(this.range=of(s.length,o,e.state.facet(Ue).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),l!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=of(n.options.length,n.selected,this.view.state.facet(Ue).maxRenderedOptions),this.showOptions(n.options,e.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,r)}).catch(l=>Lt(this.view.state,l,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&y4(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Ue).positionInfo(this.view,n,r,i,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,i){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:u}=l;if(u){let f=typeof u=="string"?u:u.name;if(f!=s&&(o>i.from||i.from==0))if(s=f,typeof u!="string"&&u.header)r.appendChild(u.header(u));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=f}}const c=r.appendChild(document.createElement("li"));c.id=n+"-"+o,c.setAttribute("role","option");let h=this.optionClass(l);h&&(c.className=h);for(let f of this.optionContent){let d=f(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function g4(t,e){return n=>new m4(n,t,e)}function y4(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}function Av(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function v4(t,e){let n=[],i=null,r=null,s=c=>{n.push(c);let{section:h}=c.completion;if(h){i||(i=[]);let f=typeof h=="string"?h:h.name;i.some(d=>d.name==f)||i.push(typeof h=="string"?{name:f}:h)}},o=e.facet(Ue);for(let c of t)if(c.hasResult()){let h=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)s(new Ev(f,c.source,h?h(f):[],1e9-n.length));else{let f=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new f4(f):new h4(f);for(let g of c.result.options)if(d=p.match(g.label)){let x=g.displayLabel?h?h(g,d.matched):[]:d.matched,m=d.score+(g.boost||0);if(s(new Ev(g,c.source,x,m)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:v}=g.section;r||(r=Object.create(null)),r[v]=Math.max(m,r[v]||-1e9)}}}}if(i){let c=Object.create(null),h=0,f=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(f))h-=1e5,c[d.name]=h;for(let d of n){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,u=o.compareCompletions;for(let c of n.sort((h,f)=>f.score-h.score||u(h.completion,f.completion))){let h=c.completion;!a||a.label!=h.label||a.detail!=h.detail||a.type!=null&&h.type!=null&&a.type!=h.type||a.apply!=h.apply||a.boost!=h.boost?l.push(c):Av(c.completion)>Av(a)&&(l[l.length-1]=c),a=c.completion}return l}class as{constructor(e,n,i,r,s,o){this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new as(this.options,Mv(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,i,r,s,o){if(r&&!o&&e.some(u=>u.isPending))return r.setDisabled();let l=v4(e,n);if(!l.length)return r&&e.some(u=>u.isPending)?r.setDisabled():null;let a=n.facet(Ue).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let u=r.options[r.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==u){a=c;break}}return new as(l,Mv(i,a),{pos:e.reduce((u,c)=>c.hasResult()?Math.min(u,c.from):u,1e8),create:C4,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new as(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new as(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class hc{constructor(e,n,i){this.active=e,this.id=n,this.open=i}static start(){return new hc(S4,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,i=n.facet(Ue),s=(i.override||n.languageDataAt("autocomplete",wr(n)).map(c4)).map(a=>(this.active.find(c=>c.source==a)||new Qt(a,this.active.some(c=>c.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((a,u)=>a==this.active[u])&&(s=this.active);let o=this.open,l=e.effects.some(a=>a.is(Zm));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!w4(s,this.active)||l?o=as.build(s,n,this.id,o,i,l):o&&o.disabled&&!s.some(a=>a.isPending)&&(o=null),!o&&s.every(a=>!a.isPending)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new Qt(a.source,0):a));for(let a of e.effects)a.is(Jm)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new hc(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?x4:k4}}function w4(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}const x4={"aria-autocomplete":"list"},k4={};function Mv(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const S4=[];function Nb(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(_b);if(i&&e.activateOnCompletion(i))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Qt{constructor(e,n,i=!1){this.source=e,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let i=Nb(e,n),r=this;(i&8||i&16&&this.touches(e))&&(r=new Qt(r.source,0)),i&4&&r.state==0&&(r=new Qt(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(cc))r=new Qt(r.source,1,s.value);else if(s.is(Ol))r=new Qt(r.source,0);else if(s.is(Zm))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(wr(e.state))}}class Es extends Qt{constructor(e,n,i,r,s,o){super(e,3,n),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var i;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=wr(e.state);if(l>o||!r||n&2&&(wr(e.startState)==this.from||l<this.limit))return new Qt(this.source,n&4?1:0);let a=e.changes.mapPos(this.limit);return b4(r.validFor,e.state,s,o)?new Es(this.source,this.explicit,a,r,s,o):r.update&&(r=r.update(r,s,o,new Cb(e.state,l,!1)))?new Es(this.source,this.explicit,a,r,r.from,(i=r.to)!==null&&i!==void 0?i:wr(e.state)):new Qt(this.source,1,this.explicit)}map(e){if(e.empty)return this;let n=this.result.map?this.result.map(this.result,e):this.result;return n?new Es(this.source,this.explicit,e.mapPos(this.limit),n,e.mapPos(this.from),e.mapPos(this.to,1)):new Qt(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function b4(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return typeof t=="function"?t(r,n,i,e):Eb(t,!0).test(r)}const Zm=ve.define({map(t,e){return t.map(n=>n.map(e))}}),kt=ci.define({create(){return hc.start()},update(t,e){return t.update(e)},provide:t=>[cb.from(t,e=>e.tooltip),Z.contentAttributes.from(t,e=>e.attrs)]});function eg(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(kt).active.find(r=>r.source==e.source);return i instanceof Es?(typeof n=="string"?t.dispatch({...u4(t.state,n,i.from,i.to),annotations:_b.of(e.completion)}):n(t,e.completion,i.from,i.to),!0):!1}const C4=g4(kt,eg);function ja(t,e="option"){return n=>{let i=n.state.field(kt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(Ue).interactionDelay)return!1;let r=1,s;e=="page"&&(s=hb(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+r*(t?1:-1):t?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),n.dispatch({effects:Jm.of(l)}),!0}}const E4=t=>{let e=t.state.field(kt,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Ue).interactionDelay?!1:eg(t,e.open.options[e.open.selected])},lf=t=>t.state.field(kt,!1)?(t.dispatch({effects:cc.of(!0)}),!0):!1,_4=t=>{let e=t.state.field(kt,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Ol.of(null)}),!0)};class N4{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const A4=50,M4=1e3,T4=zn.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(kt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(kt),n=t.state.facet(Ue);if(!t.selectionSet&&!t.docChanged&&t.startState.field(kt)==e)return;let i=t.transactions.some(s=>{let o=Nb(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(i||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>A4&&Date.now()-o.time>M4){for(let l of o.context.abortListeners)try{l()}catch(a){Lt(this.view.state,a)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(cc)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(kt);for(let n of e.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ue).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=wr(e),i=new Cb(e,n,t.explicit,this.view),r=new N4(t,i);this.running.push(r),Promise.resolve(t.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Ol.of(null)}),Lt(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ue).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(Ue),i=this.view.state.field(kt);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let l=wr(s.updates.length?s.updates[0].startState:this.view.state),a=Math.min(l,s.done.from+(s.active.explicit?0:1)),u=new Es(s.active.source,s.active.explicit,a,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:l);for(let c of s.updates)u=u.update(c,n);if(u.hasResult()){e.push(u);continue}}let o=i.active.find(l=>l.source==s.active.source);if(o&&o.isPending)if(s.done==null){let l=new Qt(s.active.source,0);for(let a of s.updates)l=l.update(a,n);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Zm.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(kt,!1);if(e&&e.tooltip&&this.view.state.facet(Ue).closeOnBlur){let n=e.open&&hb(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Ol.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:cc.of(!1)}),20),this.composing=0}}}),O4=typeof navigator=="object"&&/Win/.test(navigator.platform),I4=Fl.highest(Z.domEventHandlers({keydown(t,e){let n=e.state.field(kt,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(O4&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&eg(e,i),!1}})),P4=Z.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Ab=new class extends zi{};Ab.startSide=1;Ab.endSide=-1;function R4(t={}){return[I4,kt,Ue.of(t),T4,L4,P4]}const D4=[{key:"Ctrl-Space",run:lf},{mac:"Alt-`",run:lf},{mac:"Alt-i",run:lf},{key:"Escape",run:_4},{key:"ArrowDown",run:ja(!0)},{key:"ArrowUp",run:ja(!1)},{key:"PageDown",run:ja(!0,"page")},{key:"PageUp",run:ja(!1,"page")},{key:"Enter",run:E4}],L4=Fl.highest(Um.computeN([Ue],t=>t.facet(Ue).defaultKeymap?[D4]:[])),B4=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=ng(t.state,n.from);return i.line?j4(t):i.block?z4(t):!1};function tg(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(i(n.update(r)),!0):!1}}const j4=tg(H4,0),$4=tg(Mb,0),z4=tg((t,e)=>Mb(t,e,V4(e)),0);function ng(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const xo=50;function F4(t,{open:e,close:n},i,r){let s=t.sliceDoc(i-xo,i),o=t.sliceDoc(r,r+xo),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,h;r-i<=2*xo?c=h=t.sliceDoc(i,r):(c=t.sliceDoc(i,i+xo),h=t.sliceDoc(r-xo,r));let f=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(h)[0].length,p=h.length-d-n.length;return c.slice(f,f+e.length)==e&&h.slice(p,p+n.length)==n?{open:{pos:i+f+e.length,margin:/\s/.test(c.charAt(f+e.length))?1:0},close:{pos:r-d-n.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function V4(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function Mb(t,e,n=e.selection.ranges){let i=n.map(s=>ng(e,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,o)=>F4(e,i[o],s.from,s.to));if(t!=2&&!r.every(s=>s))return{changes:e.changes(n.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(t!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:u,close:c}=l;s.push({from:u.pos-a.open.length,to:u.pos+u.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function H4(t,e,n=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of n){let l=i.length,a=1e9,u;for(let c=s;c<=o;){let h=e.doc.lineAt(c);if(u==null&&(u=ng(e,h.from).line,!u))continue e;if(h.from>r&&(s==o||o>h.from)){r=h.from;let f=/^\s*/.exec(h.text)[0].length,d=f==h.length,p=h.text.slice(f,f+u.length)==u?f:-1;f<h.text.length&&f<a&&(a=f),i.push({line:h,comment:p,token:u,indent:f,empty:d,single:!1})}c=h.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(t!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:h}of i)(h||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const ap=Vn.define(),W4=Vn.define(),U4=ne.define(),Tb=ne.define({combine(t){return pS(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(i,r)=>e(i,r)||n(i,r)})}}),Ob=ci.define({create(){return Dn.empty},update(t,e){let n=e.state.facet(Tb),i=e.annotation(ap);if(i){let a=Et.fromTransaction(e,i.selection),u=i.side,c=u==0?t.undone:t.done;return a?c=fc(c,c.length,n.minDepth,a):c=Rb(c,e.startState.selection),new Dn(u==0?i.rest:c,u==0?c:i.rest)}let r=e.annotation(W4);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(Ve.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Et.fromTransaction(e),o=e.annotation(Ve.time),l=e.annotation(Ve.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Dn(t.done.map(Et.fromJSON),t.undone.map(Et.fromJSON))}});function q4(t={}){return[Ob,Tb.of(t),Z.domEventHandlers({beforeinput(e,n){let i=e.inputType=="historyUndo"?Ib:e.inputType=="historyRedo"?up:null;return i?(e.preventDefault(),i(n)):!1}})]}function Kc(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(Ob,!1);if(!r)return!1;let s=r.pop(t,n,e);return s?(i(s),!0):!1}}const Ib=Kc(0,!1),up=Kc(1,!1),K4=Kc(0,!0),Q4=Kc(1,!0);class Et{constructor(e,n,i,r,s){this.changes=e,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new Et(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new Et(e.changes&&ze.fromJSON(e.changes),[],e.mapped&&$n.fromJSON(e.mapped),e.startSelection&&W.fromJSON(e.startSelection),e.selectionsAfter.map(W.fromJSON))}static fromTransaction(e,n){let i=Yt;for(let r of e.startState.facet(U4)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new Et(e.changes.invert(e.startState.doc),i,void 0,n||e.startState.selection,Yt)}static selection(e){return new Et(void 0,Yt,void 0,void 0,e)}}function fc(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function Y4(t,e){let n=[],i=!1;return t.iterChangedRanges((r,s)=>n.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<n.length;){let u=n[a++],c=n[a++];l>=u&&o<=c&&(i=!0)}}),i}function X4(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,i)=>n.empty!=e.ranges[i].empty).length===0}function Pb(t,e){return t.length?e.length?t.concat(e):t:e}const Yt=[],G4=200;function Rb(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-G4));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),fc(t,t.length-1,1e9,n.setSelAfter(i)))}else return[Et.selection([e])]}function J4(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function af(t,e){if(!t.length)return t;let n=t.length,i=Yt;for(;n;){let r=Z4(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=t.slice(0,n);return s[n-1]=r,s}else e=r.mapped,n--,i=r.selectionsAfter}return i.length?[Et.selection(i)]:Yt}function Z4(t,e,n){let i=Pb(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):Yt,n);if(!t.changes)return Et.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Et(r,ve.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const eL=/^(input\.type|delete)($|\.)/;class Dn{constructor(e,n,i=0,r=void 0){this.done=e,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Dn(this.done,this.undone):this}addChanges(e,n,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||eL.test(i))&&(!l.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,Y4(l.changes,e.changes))||i=="input.type.compose")?o=fc(o,o.length-1,r.minDepth,new Et(e.changes.compose(l.changes),Pb(ve.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Yt)):o=fc(o,o.length,r.minDepth,e),new Dn(o,Yt,n,i)}addSelection(e,n,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Yt;return s.length>0&&n-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&X4(s[s.length-1],e)?this:new Dn(Rb(this.done,e),this.undone,n,i)}addMapping(e){return new Dn(af(this.done,e),af(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):n.selection);if(i&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:ap.of({side:e,rest:J4(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Yt:r.slice(0,r.length-1);return s.mapped&&(l=af(l,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:ap.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Dn.empty=new Dn(Yt,Yt);const tL=[{key:"Mod-z",run:Ib,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:up,preventDefault:!0},{linux:"Ctrl-Shift-z",run:up,preventDefault:!0},{key:"Mod-u",run:K4,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Q4,preventDefault:!0}];function Gs(t,e){return W.create(t.ranges.map(e),t.mainIndex)}function xn(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function kn({state:t,dispatch:e},n){let i=Gs(t.selection,n);return i.eq(t.selection,!0)?!1:(e(xn(t,i)),!0)}function Qc(t,e){return W.cursor(e?t.to:t.from)}function Db(t,e){return kn(t,n=>n.empty?t.moveByChar(n,e):Qc(n,e))}function ut(t){return t.textDirectionAt(t.state.selection.main.head)==Oe.LTR}const Lb=t=>Db(t,!ut(t)),Bb=t=>Db(t,ut(t));function jb(t,e){return kn(t,n=>n.empty?t.moveByGroup(n,e):Qc(n,e))}const nL=t=>jb(t,!ut(t)),iL=t=>jb(t,ut(t));function rL(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let i=tn(t).resolveInner(e.head),r=n?se.closedBy:se.openedBy;for(let a=e.head;;){let u=n?i.childAfter(a):i.childBefore(a);if(!u)break;rL(t,u,r)?i=u:a=n?u.to:u.from}let s=i.type.prop(r),o,l;return s&&(o=n?ls(t,i.from,1):ls(t,i.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?i.to:i.from,W.cursor(l,n?-1:1)}const sL=t=>kn(t,e=>Yc(t.state,e,!ut(t))),oL=t=>kn(t,e=>Yc(t.state,e,ut(t)));function $b(t,e){return kn(t,n=>{if(!n.empty)return Qc(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}const zb=t=>$b(t,!1),Fb=t=>$b(t,!0);function Vb(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,i=0,r;if(e){for(let s of t.state.facet(Z.scrollMargins)){let o=s(t);o!=null&&o.top&&(n=Math.max(o==null?void 0:o.top,n)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=t.scrollDOM.clientHeight-n-i}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function Hb(t,e){let n=Vb(t),{state:i}=t,r=Gs(i.selection,o=>o.empty?t.moveVertically(o,e,n.height):Qc(o,e));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(i.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottom<u&&(s=Z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return t.dispatch(xn(i,r),{effects:s}),!0}const Tv=t=>Hb(t,!1),cp=t=>Hb(t,!0);function Qi(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=W.cursor(i.from+s))}return r}const lL=t=>kn(t,e=>Qi(t,e,!0)),aL=t=>kn(t,e=>Qi(t,e,!1)),uL=t=>kn(t,e=>Qi(t,e,!ut(t))),cL=t=>kn(t,e=>Qi(t,e,ut(t))),hL=t=>kn(t,e=>W.cursor(t.lineBlockAt(e.head).from,1)),fL=t=>kn(t,e=>W.cursor(t.lineBlockAt(e.head).to,-1));function dL(t,e,n){let i=!1,r=Gs(t.selection,s=>{let o=ls(t,s.head,-1)||ls(t,s.head,1)||s.head>0&&ls(t,s.head-1,1)||s.head<t.doc.length&&ls(t,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return W.cursor(l)});return i?(e(xn(t,r)),!0):!1}const pL=({state:t,dispatch:e})=>dL(t,e);function nn(t,e,n){let i=Gs(t.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=W.range(r.head,r.anchor));let s=n(r);return W.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(t.state.selection)?!1:(t.dispatch(xn(t.state,i)),!0)}function Wb(t,e){return nn(t,e,n=>t.moveByChar(n,e))}const Ub=t=>Wb(t,!ut(t)),qb=t=>Wb(t,ut(t));function Kb(t,e){return nn(t,e,n=>t.moveByGroup(n,e))}const mL=t=>Kb(t,!ut(t)),gL=t=>Kb(t,ut(t)),yL=t=>{let e=!ut(t);return nn(t,e,n=>Yc(t.state,n,e))},vL=t=>{let e=ut(t);return nn(t,e,n=>Yc(t.state,n,e))};function Qb(t,e){return nn(t,e,n=>t.moveVertically(n,e))}const Yb=t=>Qb(t,!1),Xb=t=>Qb(t,!0);function Gb(t,e){return nn(t,e,n=>t.moveVertically(n,e,Vb(t).height))}const Ov=t=>Gb(t,!1),Iv=t=>Gb(t,!0),wL=t=>nn(t,!0,e=>Qi(t,e,!0)),xL=t=>nn(t,!1,e=>Qi(t,e,!1)),kL=t=>{let e=!ut(t);return nn(t,e,n=>Qi(t,n,e))},SL=t=>{let e=ut(t);return nn(t,e,n=>Qi(t,n,e))},bL=t=>nn(t,!1,e=>W.cursor(t.lineBlockAt(e.head).from)),CL=t=>nn(t,!0,e=>W.cursor(t.lineBlockAt(e.head).to)),Pv=({state:t,dispatch:e})=>(e(xn(t,{anchor:0})),!0),Rv=({state:t,dispatch:e})=>(e(xn(t,{anchor:t.doc.length})),!0),Dv=({state:t,dispatch:e})=>(e(xn(t,{anchor:t.selection.main.anchor,head:0})),!0),Lv=({state:t,dispatch:e})=>(e(xn(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),EL=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),_L=({state:t,dispatch:e})=>{let n=Xc(t).map(({from:i,to:r})=>W.undirectionalRange(i,Math.min(r+1,t.doc.length)));return e(t.update({selection:W.create(n),userEvent:"select"})),!0},NL=({state:t,dispatch:e})=>{let n=Gs(t.selection,i=>{let r=tn(t),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return W.undirectionalRange(l.from,l.to)}return i});return n.eq(t.selection)?!1:(e(xn(t,n)),!0)};function Jb(t,e){let{state:n}=t,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to<t.state.doc.length:o.from>0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(u=>u.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(t.dispatch(xn(n,W.create(r,r.length-1))),!0)}const AL=t=>Jb(t,!1),ML=t=>Jb(t,!0),TL=({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=W.create([n.main]):n.main.empty||(i=W.create([W.cursor(n.main.head)])),i?(e(xn(t,i)),!0):!1};function Kl(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(n="delete.backward",a=$a(t,a,!1)):a>o&&(n="delete.forward",a=$a(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=$a(t,o,!1),l=$a(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:W.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?Z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function $a(t,e,n){if(t instanceof Z)for(let i of t.state.facet(Z.atomicRanges).map(r=>r(t)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=n?s:r)});return e}const Zb=(t,e,n)=>Kl(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),l,a;if(n&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let u=$c(l,s.tabSize),c=u%ac(s)||ac(s);for(let h=0;h<c&&l[l.length-1-h]==" ";h++)r--;a=r}else a=ot(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=ot(o.text,a-o.from,!1,!1)+o.from);return a}),hp=t=>Zb(t,!1,!0),eC=t=>Zb(t,!0,!1),tC=(t,e)=>Kl(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=ot(s.text,i-s.from,e)+s.from,u=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||i!=n.head)&&(l=c),i=a}return i}),nC=t=>tC(t,!1),OL=t=>tC(t,!0),IL=t=>Kl(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),PL=t=>Kl(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),RL=t=>Kl(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),DL=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ae.of(["",""])},range:W.cursor(i.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},LL=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{if(!i.empty||i.from==0||i.from==t.doc.length)return{range:i};let r=i.from,s=t.doc.lineAt(r),o=r==s.from?r-1:ot(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:ot(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(r,l).append(t.doc.slice(o,r))},range:W.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xc(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=t.doc.lineAt(i.to-1)),n>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function iC(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let s of Xc(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)r.push(W.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)r.push(W.range(a.anchor-l,a.head-l))}}return i.length?(e(t.update({changes:i,scrollIntoView:!0,selection:W.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const BL=({state:t,dispatch:e})=>iC(t,e,!1),jL=({state:t,dispatch:e})=>iC(t,e,!0);function rC(t,e,n){if(t.readOnly)return!1;let i=[];for(let s of Xc(t))n?i.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):i.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let r=t.changes(i);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const $L=({state:t,dispatch:e})=>rC(t,e,!1),zL=({state:t,dispatch:e})=>rC(t,e,!0),FL=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Xc(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Gs(e.selection,r=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(r.head),l=t.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,s)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function VL(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=tn(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(se.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const Bv=sC(!1),HL=sC(!0);function sC(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!t&&s==o&&VL(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Uc(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=kb(u,s);for(c==null&&(c=$c(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let h=["",uc(e,c)];return a&&h.push(uc(e,u.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:ae.of(h)},range:W.cursor(s+1+h[1].length)}});return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function ig(t,e){let n=-1;return t.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=t.doc.lineAt(o);l.number>n&&(i.empty||i.to>l.from)&&(e(l,r,i),n=l.number),o=l.to+1}let s=t.changes(r);return{changes:r,range:W.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const WL=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new Uc(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),r=ig(t,(s,o,l)=>{let a=kb(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=uc(t,a);(u!=c||l.from<s.from+u.length)&&(n[s.from]=a,o.push({from:s.from,to:s.from+u.length,insert:c}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},UL=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ig(t,(n,i)=>{i.push({from:n.from,insert:t.facet(Xm)})}),{userEvent:"input.indent"})),!0),qL=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ig(t,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=$c(r,t.tabSize),o=0,l=uc(t,Math.max(0,s-ac(t)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:n.from+o,to:n.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),KL=t=>(t.setTabFocusMode(),!0),QL=[{key:"Ctrl-b",run:Lb,shift:Ub,preventDefault:!0},{key:"Ctrl-f",run:Bb,shift:qb},{key:"Ctrl-p",run:zb,shift:Yb},{key:"Ctrl-n",run:Fb,shift:Xb},{key:"Ctrl-a",run:hL,shift:bL},{key:"Ctrl-e",run:fL,shift:CL},{key:"Ctrl-d",run:eC},{key:"Ctrl-h",run:hp},{key:"Ctrl-k",run:IL},{key:"Ctrl-Alt-h",run:nC},{key:"Ctrl-o",run:DL},{key:"Ctrl-t",run:LL},{key:"Ctrl-v",run:cp}],YL=[{key:"ArrowLeft",run:Lb,shift:Ub,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:nL,shift:mL,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:uL,shift:kL,preventDefault:!0},{key:"ArrowRight",run:Bb,shift:qb,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:iL,shift:gL,preventDefault:!0},{mac:"Cmd-ArrowRight",run:cL,shift:SL,preventDefault:!0},{key:"ArrowUp",run:zb,shift:Yb,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Pv,shift:Dv},{mac:"Ctrl-ArrowUp",run:Tv,shift:Ov},{key:"ArrowDown",run:Fb,shift:Xb,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Rv,shift:Lv},{mac:"Ctrl-ArrowDown",run:cp,shift:Iv},{key:"PageUp",run:Tv,shift:Ov},{key:"PageDown",run:cp,shift:Iv},{key:"Home",run:aL,shift:xL,preventDefault:!0},{key:"Mod-Home",run:Pv,shift:Dv},{key:"End",run:lL,shift:wL,preventDefault:!0},{key:"Mod-End",run:Rv,shift:Lv},{key:"Enter",run:Bv,shift:Bv},{key:"Mod-a",run:EL},{key:"Backspace",run:hp,shift:hp,preventDefault:!0},{key:"Delete",run:eC,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:nC,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:OL,preventDefault:!0},{mac:"Mod-Backspace",run:PL,preventDefault:!0},{mac:"Mod-Delete",run:RL,preventDefault:!0}].concat(QL.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),XL=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:sL,shift:yL},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:oL,shift:vL},{key:"Alt-ArrowUp",run:BL},{key:"Shift-Alt-ArrowUp",run:$L},{key:"Alt-ArrowDown",run:jL},{key:"Shift-Alt-ArrowDown",run:zL},{key:"Mod-Alt-ArrowUp",run:AL},{key:"Mod-Alt-ArrowDown",run:ML},{key:"Escape",run:TL},{key:"Mod-Enter",run:HL},{key:"Alt-l",mac:"Ctrl-l",run:_L},{key:"Mod-i",run:NL,preventDefault:!0},{key:"Mod-[",run:qL},{key:"Mod-]",run:UL},{key:"Mod-Alt-\\",run:WL},{key:"Shift-Mod-k",run:FL},{key:"Shift-Mod-\\",run:pL},{key:"Mod-/",run:B4},{key:"Alt-A",mac:"Ctrl-A",run:$4},{key:"Ctrl-m",mac:"Shift-Alt-m",run:KL}].concat(YL);function dc({title:t,onClose:e,children:n,headerExtra:i}){return M.useEffect(()=>{const r=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e]),y.jsx("div",{className:"modal__backdrop",onClick:e,children:y.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":t,onClick:r=>r.stopPropagation(),children:[y.jsxs("div",{className:"modal__header",children:[y.jsx("span",{className:"modal__title",children:t}),i,y.jsx("button",{type:"button",className:"modal__close",onClick:e,"aria-label":"Close",children:"×"})]}),y.jsx("div",{className:"modal__body",children:n})]})})}const jv={response_body:"Response → Body Attribute",response_raw:"Response → Raw Body",response_header:"Response → Header"};function $v({ancestorNodes:t,nodeLabels:e,initialType:n,initialTag:i,onConfirm:r,onDelete:s,onCancel:o}){var k;const l=le(S=>S.runResult),[a,u]=M.useState((i==null?void 0:i.type)??n),c=i?t.some(S=>S.id===i.sourceNodeId):!0,[h,f]=M.useState(i?c?i.sourceNodeId:"":((k=t[0])==null?void 0:k.id)??""),[d,p]=M.useState((i==null?void 0:i.jsonPath)??""),[g,x]=M.useState((i==null?void 0:i.headerName)??""),m=!!h&&(a!=="response_header"||g.trim().length>0);function v(){if(!h)return"Select a request first.";const S=l==null?void 0:l.steps.find(E=>E.nodeId===h);if(!S||!S.response)return"No prior run captured for this node yet — run the chain once to preview.";if(a==="response_header"){const E=vx(S.response.headers,g);return E===void 0?`(no "${g}" header in the last response)`:E}const _=a==="response_raw"?S.response.body:yx(S.response.body,d);return JSON.stringify(_,null,2)??"undefined"}function w(){if(!m)return;const S={id:(i==null?void 0:i.id)??fl(),type:a,sourceNodeId:h,jsonPath:a==="response_body"&&d.trim()||void 0,headerName:a==="response_header"?g.trim():void 0};r(S)}return y.jsxs(dc,{title:i?"Edit mapping":"Insert response mapping",onClose:o,children:[y.jsxs("label",{className:"tag-config-modal__field",children:["Map",y.jsx("select",{value:a,onChange:S=>u(S.target.value),children:Object.keys(jv).map(S=>y.jsx("option",{value:S,children:jv[S]},S))})]}),y.jsxs("label",{className:"tag-config-modal__field",children:["Request",t.length===0?y.jsx("p",{className:"node-inspector__hint",children:"No upstream nodes reachable from here yet — connect this node from another on the canvas first."}):y.jsxs("select",{value:h,onChange:S=>f(S.target.value),children:[y.jsx("option",{value:"",disabled:!0,children:i&&!c?"-- Original request no longer exists — pick a new one --":"-- Select request --"}),t.map(S=>y.jsx("option",{value:S.id,children:e.get(S.id)},S.id))]})]}),a==="response_body"&&y.jsxs("label",{className:"tag-config-modal__field",children:["Filter (JSONPath)",y.jsx("input",{type:"text",placeholder:"e.g. $.items[0].id (blank = whole body)",value:d,onChange:S=>p(S.target.value)})]}),a==="response_header"&&y.jsxs("label",{className:"tag-config-modal__field",children:["Header name",y.jsx("input",{type:"text",placeholder:"e.g. x-trace-id",value:g,onChange:S=>x(S.target.value)})]}),y.jsxs("div",{className:"tag-config-modal__preview",children:[y.jsx("span",{className:"tag-config-modal__preview-label",children:"Live Preview"}),y.jsx("pre",{children:v()})]}),y.jsxs("div",{className:"tag-config-modal__actions",children:[i&&s&&y.jsx("button",{type:"button",className:"tag-config-modal__delete",onClick:s,children:"Remove mapping"}),y.jsx("button",{type:"button",onClick:o,children:"Cancel"}),y.jsx("button",{type:"button",disabled:!m,onClick:w,children:i?"Save":"Insert"})]})]})}const GL=qc.define([{tag:X.propertyName,color:"var(--color-get)"},{tag:X.string,color:"var(--color-post)"},{tag:[X.number,X.bool],color:"var(--color-put)"},{tag:X.null,color:"var(--color-cookie)"},{tag:[X.separator,X.squareBracket,X.brace],color:"var(--color-text-muted)"}]),za=Vn.define(),oC=ve.define();function JL(t,e,n){const i=e.has(t.sourceNodeId)?n.get(t.sourceNodeId):"(missing)";return t.type==="response_header"?`${i} → header ${t.headerName??""}`:t.type==="response_raw"?`${i} → raw body`:`${i} → ${t.jsonPath||"body"}`}class zv extends Hl{constructor(e,n,i,r){super(),this.tagId=e,this.label=n,this.broken=i,this.onClick=r}eq(e){return e.tagId===this.tagId&&e.label===this.label&&e.broken===this.broken}toDOM(){const e=document.createElement("span");return e.className=this.broken?"tag-chip tag-chip--broken":"tag-chip",e.textContent=this.label,this.onClick?(e.title=this.broken?"This mapping's source node no longer exists — click to fix or remove it":"Click to edit this mapping",e.addEventListener("mousedown",n=>n.preventDefault()),e.addEventListener("click",n=>{n.stopPropagation(),this.onClick(this.tagId)})):(e.title="Unrecognized tag reference — no mapping is configured for this",e.style.cursor="default"),e}ignoreEvent(){return!0}}function Fv(t,e){const n=[];for(const i of t.matchAll(Bl())){const r=i[1],s=e.tags[r],o=i.index??0,l=o+i[0].length;if(!s){n.push(Ie.replace({widget:new zv(r,"Unrecognized tag",!0,null)}).range(o,l));continue}const a=!e.nodesById.has(s.sourceNodeId),u=JL(s,e.nodesById,e.nodeLabels);n.push(Ie.replace({widget:new zv(r,u,a,e.onClickChip)}).range(o,l))}return Ie.set(n)}function ZL(t){return zn.fromClass(class{constructor(e){ag(this,"decorations");this.decorations=Fv(e.state.doc.toString(),t.current)}update(e){const n=e.transactions.some(i=>i.effects.some(r=>r.is(oC)));(e.docChanged||n)&&(this.decorations=Fv(e.state.doc.toString(),t.current))}},{decorations:e=>e.decorations})}function eB(t){return e=>{const n=e.matchBefore(/\{\{\w*/);return!n||tn(e.state).resolveInner(n.from,-1).name!=="String"?null:{from:n.from,to:n.to,filter:!1,options:[{label:"Response → Map from...",apply:(r,s,o,l)=>t("response_body",o,l)}]}}}function tB(t){return[o4(),Q3(GL),q4(),Um.of([...XL,...tL]),R4({override:[eB(t)]}),Z.lineWrapping,Z.theme({},{dark:!0}),n3({parent:document.body})]}function uf({rawBody:t,onChange:e,ancestorNodes:n,nodeLabels:i,readOnly:r=!1,showHint:s=!0}){const o=M.useRef(null),l=M.useRef(null),a=M.useRef(null),u=M.useRef({rawBody:t,onChange:e});u.current={rawBody:t,onChange:e};const c=M.useRef(new Vl),[h,f]=M.useState(null),[d,p]=M.useState(null),g=new Map(n.map(S=>[S.id,S]));a.current={tags:t.tags,nodesById:g,nodeLabels:i,onClickChip:S=>p(S)},M.useEffect(()=>{if(!o.current)return;const S=Z.updateListener.of(I=>{if(!I.docChanged||I.transactions.some($=>$.annotation(za)))return;const R=I.state.doc.toString(),O=new Set([...R.matchAll(Bl())].map($=>$[1])),D=Object.fromEntries(Object.entries(u.current.rawBody.tags).filter(([$])=>O.has($)));u.current.onChange({template:R,tags:D})}),_=ZL(a),E=[...tB((I,R,O)=>f({type:I,from:R,to:O})),_,Z.atomicRanges.of(I=>{var R;return((R=I.plugin(_))==null?void 0:R.decorations)??Ie.none}),S,c.current.of([ce.readOnly.of(r),Z.editable.of(!r)])],A=new Z({doc:u.current.rawBody.template,extensions:E,parent:o.current});return l.current=A,()=>A.destroy()},[]),M.useEffect(()=>{const S=l.current;S&&S.state.doc.toString()!==t.template&&S.dispatch({changes:{from:0,to:S.state.doc.length,insert:t.template},annotations:za.of(!0)})},[t.template]),M.useEffect(()=>{var S;(S=l.current)==null||S.dispatch({effects:c.current.reconfigure([ce.readOnly.of(r),Z.editable.of(!r)])})},[r]),M.useEffect(()=>{var S;(S=l.current)==null||S.dispatch({effects:oC.of()})},[t.tags]);function x(S){const _=l.current;if(!_||!h)return;const E=_.state.doc.length,A=Math.min(h.from,E),I=Math.min(Math.max(h.to,A),E);_.dispatch({changes:{from:A,to:I,insert:gx(S.id)},annotations:za.of(!0)}),e({template:_.state.doc.toString(),tags:{...t.tags,[S.id]:S}}),f(null)}function m(S,_){const E=new RegExp(`\\{\\{enlace:${_}\\}\\}`).exec(S);return E?{from:E.index,to:E.index+E[0].length}:null}function v(S){e({template:t.template,tags:{...t.tags,[S.id]:S}}),p(null)}function w(){const S=l.current;if(!S||!d)return;const _=m(S.state.doc.toString(),d);_&&S.dispatch({changes:{from:_.from,to:_.to,insert:""},annotations:za.of(!0)});const E={...t.tags};delete E[d],e({template:S.state.doc.toString(),tags:E}),p(null)}const k=d?t.tags[d]:void 0;return y.jsxs("div",{className:"raw-body-editor",children:[s&&y.jsxs("div",{className:"raw-body-editor__hint",children:["Type ",y.jsx("code",{children:"{{"})," inside a string to map a value from an upstream response."]}),y.jsx("div",{className:`raw-body-editor__codemirror${r?" raw-body-editor__codemirror--readonly":""}`,ref:o}),h&&y.jsx($v,{ancestorNodes:n,nodeLabels:i,initialType:h.type,onConfirm:x,onCancel:()=>f(null)}),k&&y.jsx($v,{ancestorNodes:n,nodeLabels:i,initialType:k.type,initialTag:k,onConfirm:v,onDelete:w,onCancel:()=>p(null)})]})}function nB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),y.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function iB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),y.jsx("polyline",{points:"17 8 12 3 7 8"}),y.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}function rB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("polyline",{points:"3 6 5 6 21 6"}),y.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),y.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),y.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function sB(){const{nodes:t,connections:e,operations:n,selectedNodeId:i,credentials:r,isRunning:s,setCredential:o,setFieldValue:l,mergeFieldValues:a,setUploadedFile:u,setRequestMode:c,setRawPath:h,setRawQuery:f,setRawBody:d}=le(),p=t.find(L=>L.id===i),g=n.find(L=>L.id===(p==null?void 0:p.operationId)),x=M.useMemo(()=>new Map(n.map(L=>[L.id,L])),[n]),m=M.useMemo(()=>g?Mm(g):[],[g]),v=M.useMemo(()=>m.filter(L=>L.path.startsWith("path.")),[m]),w=M.useMemo(()=>m.filter(L=>L.path.startsWith("query.")),[m]),k=M.useMemo(()=>m.filter(L=>L.path.startsWith("header.")),[m]),S=M.useMemo(()=>m.filter(L=>L.path.startsWith("body.")),[m]),[_,E]=M.useState(null),[A,I]=M.useState(null),[R,O]=M.useState(!1),D=M.useRef(null),$=M.useMemo(()=>{if(!p)return[];const L=nN(t,e,p.id);return t.filter(H=>L.has(H.id))},[t,e,p]),b=M.useMemo(()=>Oc(t,x),[t,x]);if(M.useEffect(()=>{if(!R)return;function L(q){D.current&&!D.current.contains(q.target)&&O(!1)}function H(q){q.key==="Escape"&&O(!1)}return document.addEventListener("mousedown",L),document.addEventListener("keydown",H),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",H)}},[R]),M.useEffect(()=>{O(!1)},[i]),!p||!g)return y.jsx("aside",{className:"node-inspector node-inspector--empty",children:y.jsx("p",{className:"node-inspector__empty-msg",children:"Select a node to configure it."})});const C=g.requestBodyContentType==="multipart/form-data",N=C?"form":p.requestMode??"form",j=!C&&(v.length>0||w.length>0||!!g.requestBodySchema),P=r.find(L=>L.id===p.credentialId)??null;function T(){!p||!g||(E(null),v.length>0&&h(p.id,my("path",g,p.fieldValues)),w.length>0&&f(p.id,my("query",g,p.fieldValues)),g.requestBodySchema&&d(p.id,$P(g,p.fieldValues)),c(p.id,"raw"))}function B(){if(!p||!g)return;E(null);const L={};let H=!1;if(p.rawPath&&v.length>0){const q=gy("path",p.rawPath,g);if(q.parseError){E(`Can't switch to Form view — path Raw JSON isn't valid: ${q.parseError}`);return}Object.assign(L,q.fieldValues),H=H||q.lossy}if(p.rawQuery&&w.length>0){const q=gy("query",p.rawQuery,g);if(q.parseError){E(`Can't switch to Form view — query Raw JSON isn't valid: ${q.parseError}`);return}Object.assign(L,q.fieldValues),H=H||q.lossy}if(p.rawBody&&g.requestBodySchema){const q=zP(p.rawBody,g);if(q.parseError){E(`Can't switch to Form view — body Raw JSON isn't valid: ${q.parseError}`);return}Object.assign(L,q.fieldValues),H=H||q.lossy}if(H){I(L);return}a(p.id,L),c(p.id,"form")}function F(){!p||!A||(a(p.id,A),c(p.id,"form"),I(null))}function z(L){const H=p.fieldValues[L.path],q=L.format==="binary",ee=!q&&(H==null?void 0:H.source)==="mapped",J=!L.supported,he=ee?$.find(ie=>ie.id===H.fromNodeId):void 0,we=he?n.find(ie=>ie.id===he.operationId):void 0,pe=we?PP(we):[];if(q){const ie=(H==null?void 0:H.source)==="file"?H.fileName:"";return y.jsxs("div",{className:`node-inspector__field${J?" node-inspector__field--disabled":""}`,title:L.reason,children:[y.jsxs("label",{children:[L.path,L.required?" *":""," (file)",J?" (unsupported)":""]}),y.jsx("div",{className:`node-inspector__file-drop${ie?" node-inspector__file-drop--filled":""}${J?" node-inspector__file-drop--disabled":""}`,children:ie?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"node-inspector__file-name",title:ie,children:ie}),y.jsx("button",{type:"button",className:"node-inspector__file-clear",disabled:J,"aria-label":`Clear ${L.path}`,onClick:()=>u(p.id,L.path,null),children:y.jsx(rB,{})})]}):y.jsxs(y.Fragment,{children:[y.jsx("input",{type:"file",className:"node-inspector__file-input",disabled:J,"aria-label":L.path,onChange:He=>{var Qe;const ct=((Qe=He.target.files)==null?void 0:Qe[0])??null;u(p.id,L.path,ct)}},"empty"),y.jsx("span",{className:"node-inspector__file-prompt","aria-hidden":"true",children:y.jsx(iB,{})})]})})]},L.path)}return y.jsxs("div",{className:`node-inspector__field${J?" node-inspector__field--disabled":""}`,title:L.reason,children:[y.jsxs("label",{children:[L.path,L.required?" *":"",L.type?` (${L.type})`:"",J?" (unsupported)":""]}),y.jsxs("div",{className:`node-inspector__field-row${ee?" node-inspector__field-row--mapped":""}`,children:[y.jsxs("select",{className:"node-inspector__source-select",disabled:J,value:ee?"mapped":"static","aria-label":`Source for ${L.path}`,onChange:ie=>{ie.target.value==="static"?l(p.id,L.path,{source:"static",value:""}):$[0]&&l(p.id,L.path,{source:"mapped",fromNodeId:$[0].id,fromResponseFieldPath:""})},children:[y.jsx("option",{value:"static",children:"Static"}),y.jsx("option",{value:"mapped",disabled:$.length===0,children:"Mapped"})]}),!ee&&(L.type==="array"?y.jsx("textarea",{rows:3,disabled:J,placeholder:L.reason,title:L.reason,"aria-label":L.path,value:(H==null?void 0:H.source)==="static"?typeof H.value=="string"?H.value:JSON.stringify(H.value,null,2):"",onChange:ie=>l(p.id,L.path,{source:"static",value:zh(ie.target.value,L.type)})}):L.enum?y.jsxs("select",{disabled:J,"aria-label":L.path,value:(H==null?void 0:H.source)==="static"?String(H.value??""):"",onChange:ie=>l(p.id,L.path,{source:"static",value:zh(ie.target.value,L.type)}),children:[y.jsx("option",{value:"",children:"Select..."}),L.enum.map(ie=>y.jsx("option",{value:String(ie),children:String(ie)},String(ie)))]}):y.jsx("input",{type:"text",disabled:J,"aria-label":L.path,value:(H==null?void 0:H.source)==="static"?String(H.value??""):"",onChange:ie=>l(p.id,L.path,{source:"static",value:zh(ie.target.value,L.type)})})),ee&&y.jsxs(y.Fragment,{children:[y.jsx("select",{disabled:J,"aria-label":`Map ${L.path} from node`,value:H.fromNodeId,onChange:ie=>l(p.id,L.path,{...H,fromNodeId:ie.target.value}),children:$.map(ie=>y.jsx("option",{value:ie.id,children:b.get(ie.id)},ie.id))}),y.jsxs("select",{disabled:J,"aria-label":`Map ${L.path} from response field`,value:H.fromResponseFieldPath,onChange:ie=>l(p.id,L.path,{...H,fromResponseFieldPath:ie.target.value}),children:[y.jsx("option",{value:"",children:"Select field..."}),pe.map(ie=>{const He=ie.supported&&!RP(L.type,ie.type),ct=!ie.supported||He,Qe=ie.supported?He?`Type mismatch: "${L.path}" expects ${L.type}, this field is ${ie.type}.`:void 0:ie.reason;return y.jsxs("option",{value:ie.path,disabled:ct,title:Qe,children:[ie.path,ie.supported?He?" (type mismatch)":"":" (unsupported)"]},ie.path)})]})]})]})]},L.path)}return y.jsxs("aside",{className:"node-inspector",children:[s&&y.jsx("p",{className:"node-inspector__banner",children:"Workflow is running — editing is locked until it finishes."}),y.jsxs("fieldset",{className:"node-inspector__fieldset",disabled:s,children:[y.jsxs("div",{className:"node-inspector__header",ref:D,children:[y.jsxs("div",{className:"node-inspector__op-title",children:[y.jsx("button",{type:"button",className:`node-inspector__cred-lock${P?" node-inspector__cred-lock--set":""}`,"aria-label":"Credential","aria-expanded":R,"aria-haspopup":"listbox",title:P?`Credential: ${P.name}`:"No credential",onClick:()=>O(L=>!L),children:y.jsx(nB,{})}),y.jsx("span",{className:`method-badge method-badge--${g.method}`,children:g.method.toUpperCase()}),y.jsx("h2",{className:"node-inspector__path",children:g.path})]}),R&&y.jsxs("ul",{className:"node-inspector__cred-menu",role:"listbox","aria-label":"Available credentials",children:[y.jsx("li",{role:"presentation",children:y.jsx("button",{type:"button",role:"option","aria-selected":!P,className:`node-inspector__cred-option${P?"":" node-inspector__cred-option--active"}`,onClick:()=>{o(p.id,null),O(!1)},children:"None"})}),r.map(L=>y.jsx("li",{role:"presentation",children:y.jsx("button",{type:"button",role:"option","aria-selected":(P==null?void 0:P.id)===L.id,className:`node-inspector__cred-option${(P==null?void 0:P.id)===L.id?" node-inspector__cred-option--active":""}`,onClick:()=>{o(p.id,L.id),O(!1)},children:L.name})},L.id))]})]}),y.jsxs("div",{className:"node-inspector__request-header",children:[y.jsx("h3",{children:"Request"}),j&&y.jsxs("label",{className:"body-mode-switch",title:"Switch to Raw to edit path, query, and body as JSON and map values with tag chips.",children:[y.jsx("span",{className:"body-mode-switch__label",children:N==="raw"?"Raw":"Form"}),y.jsx("input",{type:"checkbox",checked:N==="raw",onChange:L=>L.target.checked?T():B(),"aria-label":N==="raw"?"Switch to Form view":"Switch to Raw view"}),y.jsx("span",{className:"body-mode-switch__track",children:y.jsx("span",{className:"body-mode-switch__thumb"})})]})]}),$.length===0&&N==="form"&&m.length>0&&y.jsx("p",{className:"node-inspector__hint",children:'Connect this node from another on the canvas (drag box to box) to enable "Map from...".'}),_&&y.jsx("p",{className:"node-inspector__error",children:_}),N==="raw"&&y.jsxs("p",{className:"node-inspector__hint",children:["Type ",y.jsx("code",{children:"{{"})," inside a string to map a value from an upstream response."]}),v.length>0&&y.jsxs("section",{className:"node-inspector__section",children:[y.jsx("h4",{className:"node-inspector__section-title",children:"Path variables"}),N==="form"?v.map(z):p.rawPath?y.jsx(uf,{rawBody:p.rawPath,onChange:L=>h(p.id,L),ancestorNodes:$,nodeLabels:b,readOnly:s,showHint:!1}):null]}),w.length>0&&y.jsxs("section",{className:"node-inspector__section",children:[y.jsx("h4",{className:"node-inspector__section-title",children:"Query params"}),N==="form"?w.map(z):p.rawQuery?y.jsx(uf,{rawBody:p.rawQuery,onChange:L=>f(p.id,L),ancestorNodes:$,nodeLabels:b,readOnly:s,showHint:!1}):null]}),k.length>0&&y.jsxs("section",{className:"node-inspector__section",children:[y.jsx("h4",{className:"node-inspector__section-title",children:"Headers"}),k.map(z)]}),g.requestBodySchema&&y.jsxs("section",{className:"node-inspector__section node-inspector__body",children:[y.jsx("h4",{className:"node-inspector__section-title",children:"Body"}),N==="form"&&Cd(g.requestBodySchema)?y.jsxs("p",{className:"node-inspector__banner",children:["This body has a shape the form can't fully represent (arrays of objects or polymorphic fields)."," ",y.jsx("button",{type:"button",onClick:T,children:"Switch to Raw"})]}):null,N==="form"?S.map(z):p.rawBody?y.jsx(uf,{rawBody:p.rawBody,onChange:L=>d(p.id,L),ancestorNodes:$,nodeLabels:b,readOnly:s,showHint:!1}):null]})]}),A&&y.jsxs(dc,{title:"Switch to Form view?",onClose:()=>I(null),children:[y.jsx("p",{children:"Switching to Form view may lose custom JSON structure — continue?"}),y.jsxs("div",{className:"tag-config-modal__actions",children:[y.jsx("button",{type:"button",onClick:()=>I(null),children:"Cancel"}),y.jsx("button",{type:"button",onClick:F,children:"Switch anyway"})]})]})]})}function lC(t,e){if(!e||e.length===0)return t;try{const n=new URL(t);for(const i of e)n.searchParams.has(i)&&n.searchParams.set(i,"[redacted]");return n.toString()}catch{return t}}function Vv(t){return{...t,url:lC(t.url,t.redactQueryParams),headers:Object.fromEntries(Object.entries(t.headers).map(([e,n])=>e.toLowerCase()==="authorization"?[e,"[redacted]"]:[e,n]))}}function oB(t){if(t==null)return null;if(typeof t=="string")return t;if(typeof FormData<"u"&&t instanceof FormData){const e={};return t.forEach((n,i)=>{e[i]=n instanceof File?`(file) ${n.name}`:String(n)}),JSON.stringify(e,null,2)}try{return JSON.stringify(t,null,2)}catch{return String(t)}}function aC({headers:t}){const e=Object.entries(t);return y.jsxs("details",{className:"debug-headers",children:[y.jsxs("summary",{className:"debug-headers__summary",children:["Headers (",e.length,")"]}),e.length===0?y.jsx("p",{className:"debug-headers__empty",children:"None"}):y.jsx("table",{className:"debug-headers__table",children:y.jsx("tbody",{children:e.map(([n,i])=>y.jsxs("tr",{children:[y.jsx("th",{children:n}),y.jsx("td",{children:i})]},n))})})]})}function uC({value:t}){const e=oB(t);return y.jsxs("div",{className:"debug-body",children:[y.jsx("div",{className:"debug-body__label",children:"Body"}),e===null?y.jsx("p",{className:"debug-body__empty",children:"No body"}):y.jsx("pre",{className:"debug-body__pre",children:e})]})}function Hv({request:t}){return y.jsxs("div",{className:"debug-step__panel",children:[y.jsxs("div",{className:"debug-step__panel-title",children:["Request",y.jsx("span",{className:"debug-step__request-url",children:lC(t.url,t.redactQueryParams)}),t.credentials==="include"&&y.jsx("span",{className:"debug-step__credentials-chip",children:"credentials: include"})]}),y.jsx(aC,{headers:t.headers}),y.jsx(uC,{value:t.body})]})}function lB({response:t,error:e}){return t?y.jsxs("div",{className:"debug-step__panel",children:[y.jsx("div",{className:"debug-step__panel-title",children:"Response"}),y.jsx(aC,{headers:t.headers}),y.jsx(uC,{value:t.body})]}):y.jsxs("div",{className:"debug-step__panel",children:[y.jsx("div",{className:"debug-step__panel-title",children:"Response"}),y.jsx("p",{className:"debug-step__panel-empty",children:e??"No response"})]})}const aB={pending:"○","in-flight":"●",paused:"⏸",completed:"✓",failed:"!",skipped:"–"};function uB({status:t}){return y.jsx("span",{className:`debugger-row__status-icon debugger-row__status-icon--${t}`,"aria-label":t,children:aB[t]})}function Wv({operation:t,label:e,status:n,step:i,previewRequest:r,preferOpen:s}){const o=(t==null?void 0:t.method)??(i==null?void 0:i.request.method.toLowerCase())??"get",l=!!i||!!r,a=M.useRef(null);M.useEffect(()=>{if(!s||!a.current)return;const c=a.current;c instanceof HTMLDetailsElement&&(c.open=!0),typeof c.scrollIntoView=="function"&&c.scrollIntoView({block:"nearest",behavior:"smooth"})},[s]);const u=y.jsxs(y.Fragment,{children:[y.jsx(uB,{status:n}),y.jsx("span",{className:`method-badge method-badge--${o}`,children:o.toUpperCase()}),y.jsx("span",{className:"debug-step__url",children:e}),(i==null?void 0:i.response)&&y.jsx("span",{className:`status-badge ${i.error?"status-badge--error":"status-badge--ok"}`,children:i.response.status}),(i==null?void 0:i.error)&&!i.response&&y.jsx("span",{className:"status-badge status-badge--error",children:"ERROR"}),(i==null?void 0:i.error)&&y.jsx("span",{className:"debug-step__error",children:i.error})]});return l?y.jsxs("details",{ref:a,className:"debugger-row",children:[y.jsxs("summary",{className:"debugger-row__summary",children:[y.jsx("span",{className:"debugger-row__chevron","aria-hidden":"true",children:"▶"}),u]}),y.jsx("div",{className:"debug-step__panels",children:i?y.jsxs(y.Fragment,{children:[y.jsx(Hv,{request:Vv(i.request)}),y.jsx(lB,{response:i.response,error:i.error})]}):y.jsxs("div",{className:"debug-step__panel debug-step__panel--preview",children:[y.jsx("div",{className:"debugger-row__detail-label debugger-row__detail-label--preview",children:"Preview — resolved, not yet sent"}),y.jsx(Hv,{request:Vv(r)})]})})]}):y.jsx("div",{className:"debugger-row debugger-row--plain",children:y.jsx("div",{className:"debugger-row__summary",children:u})})}function cB(){const{nodes:t,connections:e,operations:n,stepStatusByNodeId:i,previewRequestByNodeId:r,runResult:s,isRunning:o,error:l,selectedNodeId:a,continueExecution:u,stepNode:c}=le(),h=M.useMemo(()=>new Map(n.map(A=>[A.id,A])),[n]),f=M.useMemo(()=>new Map(((s==null?void 0:s.steps)??[]).map(A=>[A.nodeId,A])),[s]),d=M.useMemo(()=>Oc(t,h),[t,h]),p=M.useMemo(()=>{try{return rN(t,e)}catch(A){if(A instanceof wx)return t;throw A}},[t,e]),g=M.useMemo(()=>p.filter(A=>i[A.id]==="paused").map(A=>A.id),[p,i]),x=g.includes(a??"")?a:g[0],m=x?d.get(x)??x:null;M.useRef(null);const[v,w]=M.useState(null),k=M.useRef(!1);M.useEffect(()=>{const A=g.length>0;A&&!k.current&&x&&w(x),A||w(null),k.current=A},[g,x]);const S=t.length>0,_=((s==null?void 0:s.steps.length)??0)>0,E=!S&&!_&&!o&&!l;return y.jsxs("div",{className:"debug-pane__body results-list",children:[g.length>0&&m&&y.jsxs("div",{className:"results-pause-bar",role:"status",children:[y.jsxs("span",{className:"results-pause-bar__label",children:["Paused at ",y.jsx("strong",{children:m})]}),y.jsxs("span",{className:"results-pause-bar__actions",children:[y.jsx("button",{type:"button",className:"btn btn--icon btn--execute",onClick:u,title:"Continue — release every node currently paused","aria-label":"Continue",children:"▶"}),y.jsx("button",{type:"button",className:"btn btn--icon btn--secondary",onClick:()=>x&&c(x),title:"Step — release just this paused node","aria-label":"Step",children:"⏭"})]})]}),o&&g.length===0&&y.jsx("p",{className:"debug-pane__status debug-pane__status--running",children:"Running…"}),!o&&l&&y.jsx("p",{className:"debug-pane__status debug-pane__status--error",children:l}),E&&y.jsx("p",{className:"debug-pane__status",children:"Run the workflow to see each step's request and response."}),S&&p.map(A=>{const I=i[A.id]??(f.has(A.id)?"completed":"pending"),R=!o&&!i[A.id]&&f.has(A.id)?f.get(A.id).error?"failed":"completed":I;return y.jsx(Wv,{operation:h.get(A.operationId),label:d.get(A.id)??A.operationId,status:R,step:f.get(A.id),previewRequest:r[A.id],preferOpen:v===A.id},A.id)}),!S&&_&&s.steps.map(A=>y.jsx(Wv,{operation:void 0,label:A.request.method,status:A.error?"failed":"completed",step:A,previewRequest:void 0,preferOpen:!1},A.nodeId))]})}function hB(t,e,n){if(t.length===0)return n>0?`${n} call(s)`:"";const i=new Map;for(const l of t){const a=e[l.id]??"pending";i.set(a,(i.get(a)??0)+1)}const r=[...i.keys()].some(l=>l!=="pending")||Object.keys(e).length>0;if(!r&&n===0)return`${t.length} step(s)`;if(!r&&n>0)return`${n} call(s)`;const s=["in-flight","paused","completed","failed","skipped","pending"],o={pending:"pending","in-flight":"in flight",paused:"paused",completed:"completed",failed:"failed",skipped:"skipped"};return s.filter(l=>(i.get(l)??0)>0).map(l=>`${i.get(l)} ${o[l]}`).join(" · ")}const fB=140,dB=140,pB=.55;function mB({collapsed:t,onToggleCollapsed:e}){const n=le(p=>p.runResult),i=le(p=>p.nodes),r=le(p=>p.stepStatusByNodeId),s=le(p=>p.isRunning),o=le(p=>p.error),l=le(p=>p.clearResults),[a,u]=M.useState(fB),c=M.useRef(null),h=M.useCallback(p=>{p.preventDefault(),p.target.setPointerCapture(p.pointerId),c.current={startY:p.clientY,startHeight:a}},[a]);M.useEffect(()=>{const p=x=>{if(!c.current)return;const m=c.current.startY-x.clientY,v=Math.floor(window.innerHeight*pB);u(Math.min(v,Math.max(dB,c.current.startHeight+m)))},g=()=>{c.current=null};return window.addEventListener("pointermove",p),window.addEventListener("pointerup",g),()=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",g)}},[]);const f=hB(i,r,(n==null?void 0:n.steps.length)??0),d=!s&&!!(n||o||Object.keys(r).length>0);return y.jsxs("div",{className:`debug-pane${t?" debug-pane--collapsed":""}`,style:t?void 0:{height:a,maxHeight:"none"},children:[!t&&y.jsx("div",{className:"debug-pane__resize",onPointerDown:h,role:"separator","aria-orientation":"horizontal","aria-label":"Resize results",title:"Drag to resize"}),y.jsxs("div",{className:"debug-pane__header",children:[y.jsxs("button",{type:"button",className:"debug-pane__toggle",onClick:e,"aria-label":t?"Show results":"Hide results","aria-expanded":!t,children:[y.jsx("span",{className:"debug-pane__toggle-chevron","aria-hidden":"true",children:t?"▲":"▼"}),y.jsx("span",{className:"debug-pane__title",children:"Results"})]}),f&&y.jsx("span",{className:"debug-pane__count",children:f}),y.jsx("button",{type:"button",className:"debug-pane__clear",onClick:l,disabled:!d,title:s?"Can't clear while a run is in progress.":"Clear results",children:"Clear"})]}),!t&&y.jsx(cB,{})]})}function gB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),y.jsx("polyline",{points:"15 3 21 3 21 9"}),y.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function yB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M12 20h9"}),y.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]})}function vB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("polyline",{points:"3 6 5 6 21 6"}),y.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function wB({credential:t,usageCount:e,onEdit:n,onDelete:i}){const r=jl(dl(t)),s=mN(t);function o(){e>0&&!window.confirm(e===1?`Delete "${t.name}"? It's used by 1 node — that node will lose this credential.`:`Delete "${t.name}"? It's used by ${e} nodes — those nodes will lose this credential.`)||i(t.id)}return y.jsx("li",{className:"credential-card",children:y.jsxs("div",{className:"credential-card__top",children:[y.jsxs("div",{className:"credential-card__main",children:[y.jsx("div",{className:"credential-card__name",children:t.name}),y.jsxs("div",{className:"credential-card__meta",children:[y.jsx("span",{className:`credential-badge credential-badge--${t.type}`,children:Du[t.type]}),r?s?y.jsx("span",{className:"credential-card__preview",children:s}):null:y.jsx("span",{className:"credential-card__flag",children:"Needs a value"})]}),t.fromSecurityScheme&&y.jsxs("div",{className:"credential-card__source",children:["From spec: ",y.jsx("code",{children:t.fromSecurityScheme})]})]}),y.jsxs("div",{className:"credential-card__actions",children:[t.type==="cookie"&&t.loginUrl&&y.jsx("button",{type:"button",className:"credential-card__icon-btn",onClick:()=>bx(t.loginUrl),"aria-label":`Open login page for ${t.name}`,title:"Opens the login page in a new tab — log in there if your session has expired.",children:y.jsx(gB,{})}),y.jsx("button",{type:"button",className:"credential-card__icon-btn",onClick:()=>n(t),"aria-label":`Edit ${t.name}`,title:"Edit",children:y.jsx(yB,{})}),y.jsx("button",{type:"button",className:"credential-card__icon-btn credential-card__icon-btn--danger",onClick:o,"aria-label":`Delete ${t.name}`,title:"Delete",children:y.jsx(vB,{})})]})]})})}function xB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),y.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function kB(){return y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),y.jsx("circle",{cx:"12",cy:"12",r:"3"}),y.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]})}function qs({label:t,placeholder:e,value:n,onChange:i}){const[r,s]=M.useState(!1);return y.jsxs("label",{className:"credentials-panel__field",children:[t,y.jsxs("span",{className:"credentials-panel__secret-input",children:[y.jsx("input",{placeholder:e,type:r?"text":"password",value:n,onChange:o=>i(o.target.value)}),y.jsx("button",{type:"button",className:"credentials-panel__reveal-btn",onClick:()=>s(o=>!o),"aria-label":r?`Hide ${t}`:`Show ${t}`,title:r?"Hide value":"Show value",children:r?y.jsx(kB,{}):y.jsx(xB,{})})]})]})}function SB({draft:t,setDraft:e}){return y.jsx(qs,{label:"Token",placeholder:"bearer token",value:t.token,onChange:n=>e({...t,token:n})})}function bB({draft:t,setDraft:e}){return y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"credentials-panel__field",children:["Username",y.jsx("input",{placeholder:"username",value:t.username,onChange:n=>e({...t,username:n.target.value})})]}),y.jsx(qs,{label:"Password",placeholder:"password",value:t.password,onChange:n=>e({...t,password:n})})]})}function CB({draft:t,setDraft:e}){return y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"credentials-panel__field",children:["Header/query param name",y.jsx("input",{placeholder:"e.g. X-API-Key",value:t.paramName,onChange:n=>e({...t,paramName:n.target.value})})]}),y.jsxs("label",{className:"credentials-panel__field",children:["Sent in",y.jsxs("select",{value:t.in,onChange:n=>e({...t,in:n.target.value}),children:[y.jsx("option",{value:"header",children:"Header"}),y.jsx("option",{value:"query",children:"Query param"})]})]}),y.jsx(qs,{label:"Key value",placeholder:"key value",value:t.key,onChange:n=>e({...t,key:n})})]})}function EB({draft:t,setDraft:e}){return y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"credentials-panel__warning",children:"Only use test/sandbox credentials here. This value is visible to anyone with access to this browser, per Enlace's pre-prod trust model."}),y.jsxs("label",{className:"credentials-panel__field",children:["Token URL",y.jsx("input",{placeholder:"https://auth.example.com/oauth/token",value:t.tokenUrl,onChange:n=>e({...t,tokenUrl:n.target.value})})]}),y.jsxs("label",{className:"credentials-panel__field",children:["Client ID",y.jsx("input",{placeholder:"client id",value:t.clientId,onChange:n=>e({...t,clientId:n.target.value})})]}),y.jsx(qs,{label:"Client secret",placeholder:"client secret",value:t.clientSecret,onChange:n=>e({...t,clientSecret:n})}),y.jsxs("label",{className:"credentials-panel__field",children:["Client auth method",y.jsxs("select",{value:t.clientAuthMethod,onChange:n=>e({...t,clientAuthMethod:n.target.value}),children:[y.jsx("option",{value:"basic",children:"HTTP Basic header (RFC 6749 client_secret_basic)"}),y.jsx("option",{value:"body",children:"POST body params (client_secret_post)"})]})]}),y.jsx("p",{className:"credentials-panel__hint",children:"How clientId/clientSecret are sent on the token request itself. Some identity servers require Basic and reject body params; pick Basic unless your token endpoint specifically wants the older body-param style."}),y.jsxs("label",{className:"credentials-panel__field",children:["Scope (optional)",y.jsx("input",{placeholder:"scope",value:t.scope??"",onChange:n=>e({...t,scope:n.target.value})})]})]})}function _B({draft:t,setDraft:e}){return y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"credentials-panel__warning",children:"Legacy grant type — deprecated in general OAuth2 guidance. Only use test/sandbox credentials here. This value is visible to anyone with access to this browser, per Enlace's pre-prod trust model."}),y.jsxs("label",{className:"credentials-panel__field",children:["Token URL",y.jsx("input",{placeholder:"https://auth.example.com/oauth/token",value:t.tokenUrl,onChange:n=>e({...t,tokenUrl:n.target.value})})]}),y.jsxs("label",{className:"credentials-panel__field",children:["Username",y.jsx("input",{placeholder:"resource owner username",value:t.username,onChange:n=>e({...t,username:n.target.value})})]}),y.jsx(qs,{label:"Password",placeholder:"resource owner password",value:t.password,onChange:n=>e({...t,password:n})}),y.jsxs("label",{className:"credentials-panel__field",children:["Client ID (optional)",y.jsx("input",{placeholder:"client id",value:t.clientId??"",onChange:n=>e({...t,clientId:n.target.value})})]}),y.jsx(qs,{label:"Client secret (optional)",placeholder:"client secret",value:t.clientSecret??"",onChange:n=>e({...t,clientSecret:n})}),y.jsxs("label",{className:"credentials-panel__field",children:["Client auth method",y.jsxs("select",{value:t.clientAuthMethod,onChange:n=>e({...t,clientAuthMethod:n.target.value}),children:[y.jsx("option",{value:"basic",children:"HTTP Basic header (RFC 6749 client_secret_basic)"}),y.jsx("option",{value:"body",children:"POST body params (client_secret_post)"})]})]}),y.jsx("p",{className:"credentials-panel__hint",children:"Only applies if client ID/secret above are filled in — a public client with neither has nothing to send either way."}),y.jsxs("label",{className:"credentials-panel__field",children:["Scope (optional)",y.jsx("input",{placeholder:"scope",value:t.scope??"",onChange:n=>e({...t,scope:n.target.value})})]})]})}function NB({draft:t,setDraft:e}){return y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"credentials-panel__field",children:["Login page URL (optional)",y.jsx("input",{placeholder:"https://your-app.example.com/auth/login",value:t.loginUrl??"",onChange:n=>e({...t,loginUrl:n.target.value})})]}),t.loginUrl&&y.jsx("button",{type:"button",className:"btn btn--secondary credentials-panel__login-btn",onClick:()=>bx(t.loginUrl),children:"Open login page ↗"}),y.jsx("p",{className:"credentials-panel__hint",children:"This credential doesn't add anything to your requests itself — no header, no query param. Log into the target yourself, in any tab of this browser, however that target's own login works — Enlace has no part in it. Once you're logged in, this browser already holds the session cookie, and requests using this credential carry it automatically, as long as the target's server allows credentialed requests from this origin (that's the target's own CORS setting, not something Enlace can change). The URL above, if you set one, is just a convenience link to jump to the login page — handy again later if the session expires."})]})}function AB({draft:t,setDraft:e,editingId:n,onCancel:i,onSave:r}){const s=M.useRef(null),[o,l]=M.useState(!1),[a,u]=M.useState(null),c=M.useRef(fl());M.useEffect(()=>{var p;(p=s.current)==null||p.focus()},[]);const h=p=>{u(null),e(p)},f=pN(t.type),d=async()=>{if(!f){r();return}l(!0),u(null);try{const p=n??c.current;await mx({...t,id:p}),r(p)}catch(p){u(p instanceof Error?p.message:String(p))}finally{l(!1)}};return y.jsxs("div",{className:"credentials-drawer__form",children:[t.fromSecurityScheme&&y.jsx("p",{className:"credentials-panel__spec-banner",children:n?y.jsxs(y.Fragment,{children:["Originally configured from the spec's ",y.jsxs("code",{children:["securitySchemes.",t.fromSecurityScheme]}),"."]}):y.jsxs(y.Fragment,{children:["This credential is declared in the spec's ",y.jsxs("code",{children:["securitySchemes.",t.fromSecurityScheme]})," — fill in the secret value(s) below."]})}),y.jsxs("label",{className:"credentials-panel__field",children:["Name",y.jsx("input",{ref:s,placeholder:"name",value:t.name,onChange:p=>h({...t,name:p.target.value})})]}),y.jsxs("label",{className:"credentials-panel__field",children:["Type",y.jsx("select",{value:t.type,onChange:p=>h(ld(p.target.value,t.name)),children:Object.keys(Du).map(p=>y.jsx("option",{value:p,children:Du[p]},p))})]}),t.type==="bearer"&&y.jsx(SB,{draft:t,setDraft:h}),t.type==="basic"&&y.jsx(bB,{draft:t,setDraft:h}),t.type==="apiKey"&&y.jsx(CB,{draft:t,setDraft:h}),t.type==="oauth2_clientCredentials"&&y.jsx(EB,{draft:t,setDraft:h}),t.type==="oauth2_password"&&y.jsx(_B,{draft:t,setDraft:h}),t.type==="cookie"&&y.jsx(NB,{draft:t,setDraft:h}),a&&y.jsxs("p",{className:"credentials-panel__verify-error",role:"alert",children:["Verification failed: ",a]}),y.jsxs("div",{className:"credentials-drawer__form-actions",children:[y.jsx("button",{type:"button",className:"btn btn--secondary",onClick:i,disabled:o,children:"Cancel"}),y.jsx("button",{type:"button",className:"btn btn--authorize",disabled:!jl(t)||o,onClick:d,children:o?"Verifying…":n?f?"Verify & save changes":"Save changes":f?"Verify & Save":"Save"})]})]})}function MB({entries:t,onConfigure:e}){return t.length===0?null:y.jsxs("div",{className:"credentials-drawer__declared",children:[y.jsx("h3",{children:"Declared in spec"}),y.jsx("ul",{className:"credentials-drawer__declared-list",children:t.map(n=>y.jsxs("li",{className:"declared-credential",children:[y.jsxs("div",{className:"declared-credential__info",children:[y.jsx("div",{className:"declared-credential__name",children:y.jsx("code",{children:n.schemeName})}),y.jsxs("div",{className:"declared-credential__type",children:[Du[n.template.type],n.description?` — ${n.description}`:""]})]}),y.jsx("button",{type:"button",className:"btn btn--secondary",onClick:()=>e(n),children:"Configure"})]},n.schemeName))})]})}function TB({showTrigger:t=!0,open:e,onOpenChange:n}={}){const{credentials:i,declaredCredentials:r,nodes:s,credentialReview:o,addCredential:l,updateCredential:a,removeCredential:u,setCredentialReview:c}=le(),[h,f]=M.useState(!1),d=e!==void 0,p=d?e:h,g=C=>{d||f(C),n==null||n(C)},[x,m]=M.useState(!1),[v,w]=M.useState(null),[k,S]=M.useState(()=>ld("bearer","")),_=()=>{m(!1),w(null),S(ld("bearer",""))},E=()=>{g(!1),_(),c(null)},A=C=>{S(C.template),m(!0)},I=C=>{S(dl(C)),w(C.id),m(!0)},R=C=>{v?a(v,k):l(k,C),_()};M.useEffect(()=>{o&&g(!0)},[o]);const O=o?i.filter(C=>o.needsValueIds.includes(C.id)&&!jl(dl(C))):[],D=[];O.length>0&&D.push(O.length===1?"1 imported credential needs a value before this chain can run — it’s marked below.":`${O.length} imported credentials need a value before this chain can run — they’re marked below.`),o!=null&&o.secretsDiscarded&&D.push("Unexpected secrets in a stripped collection were discarded on import."),M.useEffect(()=>{if(!p)return;const C=N=>{N.key==="Escape"&&E()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[p]);const $=new Set(i.map(C=>C.fromSecurityScheme).filter(Boolean)),b=r.filter(C=>!$.has(C.schemeName));return y.jsxs(y.Fragment,{children:[t&&y.jsxs("button",{type:"button",className:"credentials-trigger",onClick:()=>g(!0),children:[y.jsx("span",{className:"credentials-trigger__count",children:i.length}),"credential",i.length===1?"":"s"]}),p&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"credentials-drawer__backdrop",onClick:E}),y.jsxs("aside",{className:"credentials-drawer",children:[y.jsxs("div",{className:"credentials-drawer__header",children:[y.jsx("h2",{children:x?v?"Edit credential":"New credential":"Credentials"}),y.jsx("button",{type:"button",className:"pane-collapse-btn",onClick:E,title:"Close","aria-label":"Close credentials",children:"✕"})]}),y.jsxs("div",{className:"credentials-drawer__body",children:[D.length>0&&y.jsx("p",{className:"credentials-drawer__review",role:"status",children:D.join(" ")}),i.length===0&&!x&&y.jsx("p",{className:"credentials-drawer__empty",children:"No credentials yet. Add one, then attach it to a node via the lock icon in the inspector."}),i.length>0&&y.jsx("ul",{className:"credentials-drawer__list",children:i.map(C=>y.jsx(wB,{credential:C,usageCount:s.filter(N=>N.credentialId===C.id).length,onEdit:I,onDelete:u},C.id))}),!x&&y.jsx(MB,{entries:b,onConfigure:A}),x?y.jsx(AB,{draft:k,setDraft:S,editingId:v,onCancel:_,onSave:R}):y.jsx("button",{type:"button",className:"credentials-drawer__add-btn",onClick:()=>m(!0),children:"+ New credential"})]})]})]})]})}function OB(t){return typeof t.text=="function"?t.text():new Promise((e,n)=>{const i=new FileReader;i.onload=()=>e(String(i.result??"")),i.onerror=()=>n(i.error??new Error("Failed to read file")),i.readAsText(t)})}function IB(t){const e=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(e),i=window.document.createElement("a");i.href=n,i.download=kN(t),i.click(),URL.revokeObjectURL(n)}const PB=M.forwardRef(function({hideButtons:e=!1},n){const i=le(C=>C.nodes),r=le(C=>C.connections),s=le(C=>C.nodePositions),o=le(C=>C.credentials),l=le(C=>C.specInfo),a=le(C=>C.workflowName),u=le(C=>C.operations),c=le(C=>C.isRunning),h=le(C=>C.replaceWorkflow),f=le(C=>C.setWorkflowName),d=le(C=>C.setCredentialReview),p=C=>le.setState({error:C}),g=M.useRef(null),[x,m]=M.useState(null),[v,w]=M.useState(!1),[k,S]=M.useState(""),[_,E]=M.useState(!1),[A,I]=M.useState(!1),R=()=>{var N;const C=a.trim()&&a!=="Untitled"?a:null;S(C||((N=l==null?void 0:l.title)==null?void 0:N.trim())||"Untitled"),E(!1),I(!1),w(!0)},O=()=>{var C;(C=g.current)==null||C.click()};M.useImperativeHandle(n,()=>({openExport:R,openImport:O}));const D=()=>{const C=yN({name:k,includeSecrets:_,nodes:i,connections:r,nodePositions:s,credentials:o,specInfo:l});IB(C),f(k),w(!1)},$=(C,N)=>{if(le.getState().isRunning){m(null),p("Can't import while the workflow is running.");return}h(C),m(null),p(xN(N));const j=N.credentialsNeedingSecrets.map(P=>P.id);d(j.length>0||N.unexpectedSecretsDiscarded?{needsValueIds:j,secretsDiscarded:N.unexpectedSecretsDiscarded}:null)},b=async C=>{if(!C)return;const N=await OB(C),j=vN(N,{operations:u});if(!j.ok){m(null),p(j.error);return}if(i.length>0||j.warnings.secretsIncluded){m({collection:j.collection,warnings:j.warnings});return}$(j.collection,j.warnings)};return y.jsxs("div",{className:`workflow-file-menu${e?" workflow-file-menu--host":""}`,children:[!e&&y.jsxs(y.Fragment,{children:[y.jsx("button",{type:"button",className:"btn btn--secondary",onClick:R,disabled:i.length===0,title:"Download this workflow and its credentials as an Enlace collection.",children:"Export"}),y.jsx("button",{type:"button",className:"btn btn--secondary",onClick:O,disabled:c,title:c?"Can't import while the workflow is running.":void 0,children:"Import"})]}),y.jsx("input",{ref:g,type:"file",accept:".enlace,application/json",hidden:!0,onChange:C=>{var j;const N=(j=C.target.files)==null?void 0:j[0];C.target.value="",b(N)}}),v&&y.jsxs(dc,{title:"Export Enlace collection",onClose:()=>w(!1),children:[y.jsxs("label",{className:"workflow-export__field",children:[y.jsx("span",{children:"Name"}),y.jsx("input",{autoFocus:!0,value:k,onChange:C=>S(C.target.value),placeholder:"Collection name"})]}),y.jsxs("fieldset",{className:"workflow-export__credentials",children:[y.jsx("legend",{children:"Credentials"}),y.jsxs("label",{children:[y.jsx("input",{type:"radio",name:"credential-export",checked:!_,onChange:()=>{E(!1),I(!1)}}),y.jsxs("span",{children:[y.jsx("strong",{children:"Partial (recommended)"}),y.jsx("small",{children:"Include credential names and configuration, but strip tokens, passwords, and keys."})]})]}),y.jsxs("label",{children:[y.jsx("input",{type:"radio",name:"credential-export",checked:_,onChange:()=>E(!0)}),y.jsxs("span",{children:[y.jsx("strong",{children:"Full credentials"}),y.jsx("small",{children:"Include usable tokens, passwords, API keys, and client secrets."})]})]})]}),_&&y.jsxs("div",{className:"workflow-export__warning",role:"alert",children:[y.jsx("strong",{children:"Warning: this file can authenticate as you."}),y.jsx("p",{children:"Store it securely and do not share or commit it to source control."}),y.jsxs("label",{children:[y.jsx("input",{type:"checkbox",checked:A,onChange:C=>I(C.target.checked)}),"I understand this export contains usable secrets."]})]}),y.jsxs("div",{className:"tag-config-modal__actions",children:[y.jsx("button",{type:"button",onClick:()=>w(!1),children:"Cancel"}),y.jsx("button",{type:"button",onClick:D,disabled:!k.trim()||_&&!A,children:"Export"})]})]}),x&&y.jsxs(dc,{title:x.collection.secrets==="included"?"Import collection with secrets?":"Replace current canvas?",onClose:()=>m(null),children:[y.jsxs("p",{children:[i.length>0?`Importing this file will replace ${i.length} node${i.length===1?"":"s"} on the canvas.`:"Importing this file will replace the current empty canvas.",x.collection.secrets==="included"?" This collection contains full credential secrets, which will be imported into memory.":" Credential secrets in this tab are discarded; imported credentials will need their values filled in."]}),y.jsxs("div",{className:"tag-config-modal__actions",children:[y.jsx("button",{type:"button",onClick:()=>m(null),children:"Cancel"}),y.jsx("button",{type:"button",onClick:()=>$(x.collection,x.warnings),disabled:c,children:x.collection.secrets==="included"?"Import secrets":"Replace"})]})]})]})});function RB(){const t=le(f=>f.credentials),e=le(f=>f.nodes),n=le(f=>f.isRunning),[i,r]=M.useState(!1),[s,o]=M.useState(!1),l=M.useRef(null),a=M.useRef(null),u=M.useRef(null);M.useEffect(()=>{if(!i)return;const f=p=>{var x;const g=p.target;(x=a.current)!=null&&x.contains(g)||r(!1)},d=p=>{p.key==="Escape"&&r(!1)};return document.addEventListener("pointerdown",f),document.addEventListener("keydown",d),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",d)}},[i]);const c=()=>r(!1),h=()=>r(f=>!f);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{ref:a,className:"chrome-settings",role:"button",tabIndex:0,"aria-label":"Settings","aria-haspopup":"menu","aria-expanded":i,title:"Settings",onClick:h,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),h())},children:[y.jsx("span",{className:"chrome-settings__glyph","aria-hidden":"true",children:y.jsx(DB,{})}),i&&y.jsxs("div",{ref:u,className:"chrome-settings__menu",role:"menu","aria-label":"Settings",onClick:f=>f.stopPropagation(),children:[y.jsxs("button",{type:"button",role:"menuitem",className:"chrome-settings__item",onClick:()=>{c(),o(!0)},children:[y.jsx(LB,{}),y.jsxs("span",{children:["Credentials (",t.length,")"]})]}),y.jsxs("button",{type:"button",role:"menuitem",className:"chrome-settings__item",disabled:e.length===0,title:e.length===0?"Add a node before exporting.":void 0,onClick:()=>{var f;c(),(f=l.current)==null||f.openExport()},children:[y.jsx(BB,{}),y.jsx("span",{children:"Export"})]}),y.jsxs("button",{type:"button",role:"menuitem",className:"chrome-settings__item",disabled:n,title:n?"Can't import while the workflow is running.":void 0,onClick:()=>{var f;c(),(f=l.current)==null||f.openImport()},children:[y.jsx(jB,{}),y.jsx("span",{children:"Import"})]})]})]}),y.jsx(TB,{showTrigger:!1,open:s,onOpenChange:o}),y.jsx(PB,{ref:l,hideButtons:!0})]})}function DB(){return y.jsx("svg",{className:"chrome-settings__icon",viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M19.14 12.94c.04-.31.06-.63.06-.94s-.02-.63-.06-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.07 7.07 0 0 0-1.63-.94l-.36-2.54a.5.5 0 0 0-.5-.42h-3.84a.5.5 0 0 0-.5.42l-.36 2.54c-.59.24-1.13.55-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.77 8.84a.5.5 0 0 0 .12.64l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94L2.89 14.5a.5.5 0 0 0-.12.64l1.92 3.32c.12.22.37.3.6.22l2.39-.96c.5.39 1.04.71 1.63.94l.36 2.54c.05.24.26.42.5.42h3.84c.24 0 .45-.18.5-.42l.36-2.54c.59-.24 1.13-.55 1.63-.94l2.39.96c.23.08.48 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58zM12 15.5A3.5 3.5 0 1 1 12 8.5a3.5 3.5 0 0 1 0 7z"})})}function LB(){return y.jsx("svg",{className:"chrome-settings__item-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M10.5 2a3.5 3.5 0 0 0-3.37 4.4L2 11.53V14h2.5l.5-.5.5.5H8v-1.5L11.6 8.87A3.5 3.5 0 1 0 10.5 2zm0 2a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3z"})})}function BB(){return y.jsx("svg",{className:"chrome-settings__item-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M8 2.5 4.5 6h2v4h3V6h2L8 2.5zM3 12v1.5h10V12H3z"})})}function jB(){return y.jsx("svg",{className:"chrome-settings__item-icon",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M8 10.5 11.5 7h-2V3h-3v4h-2L8 10.5zM3 12v1.5h10V12H3z"})})}function $B(){const t=le(u=>u.workflowName),e=le(u=>u.setWorkflowName),[n,i]=M.useState(!1),[r,s]=M.useState(t),o=M.useRef(null);M.useEffect(()=>{n||s(t)},[t,n]),M.useEffect(()=>{if(!n)return;const u=o.current;u&&(u.focus(),u.select())},[n]);function l(){s(t),i(!0)}function a(u){e(u),i(!1)}return y.jsxs("div",{className:"workflow-switcher",children:[n?y.jsx("input",{ref:o,className:"workflow-switcher__input",value:r,"aria-label":"Workflow name",onChange:u=>s(u.target.value),onBlur:u=>a(u.currentTarget.value),onKeyDown:u=>{u.key==="Enter"?(u.preventDefault(),u.currentTarget.blur()):u.key==="Escape"&&(u.preventDefault(),u.currentTarget.value=t,s(t),u.currentTarget.blur())}}):y.jsx("button",{type:"button",className:"workflow-switcher__name-btn","aria-label":`Workflow: ${t}`,title:"Rename workflow",onClick:l,children:y.jsx("span",{className:"workflow-switcher__name",children:t})}),y.jsx("button",{type:"button",className:"workflow-switcher__chevron",disabled:!0,title:"Multiple workflows coming later","aria-label":"Switch workflow",children:"▾"})]})}function zB({isRunning:t,isDebugRun:e,pausedCount:n,canStep:i,onRun:r,onDebug:s,onContinue:o,onStep:l,onStop:a,stepTitle:u}){return t&&e?y.jsxs("div",{className:"run-segment",role:"group","aria-label":"Debug controls",children:[y.jsx("button",{type:"button",className:"run-segment__btn run-segment__btn--primary",onClick:o,disabled:n===0,title:"Continue — release every node currently paused","aria-label":"Continue",children:y.jsx(Uv,{})}),y.jsx("button",{type:"button",className:"run-segment__btn run-segment__btn--ghost",onClick:l,disabled:!i,title:u,"aria-label":"Step",children:y.jsx(VB,{})}),y.jsx("button",{type:"button",className:"run-segment__btn run-segment__btn--stop",onClick:a,title:"Stop — nothing new fires; anything already in flight still completes","aria-label":"Stop",children:y.jsx(qv,{})})]}):t?y.jsxs("div",{className:"run-segment",role:"group","aria-label":"Run in progress",children:[y.jsxs("div",{className:"run-segment__btn run-segment__btn--primary run-segment__btn--status","aria-live":"polite",children:[y.jsx(HB,{}),y.jsx("span",{className:"run-segment__sr-only",children:"Running"})]}),y.jsx("button",{type:"button",className:"run-segment__btn run-segment__btn--stop",onClick:a,title:"Stop — nothing new fires; anything already in flight still completes","aria-label":"Stop",children:y.jsx(qv,{})})]}):y.jsxs("div",{className:"run-segment",role:"group","aria-label":"Run controls",children:[y.jsxs("button",{type:"button",className:"run-segment__btn run-segment__btn--primary",onClick:r,children:[y.jsx(Uv,{}),y.jsx("span",{children:"Run"})]}),y.jsxs("button",{type:"button",className:"run-segment__btn run-segment__btn--debug",onClick:s,title:"Run, honoring any breakpoints armed on the canvas",children:[y.jsx(FB,{}),y.jsx("span",{children:"Debug"})]})]})}function Uv(){return y.jsx("svg",{className:"run-segment__icon",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M4 2.5v11l9-5.5L4 2.5z"})})}function FB(){return y.jsx("svg",{className:"run-segment__icon",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M8 2.5 13.5 8 8 13.5 2.5 8 8 2.5z"})})}function VB(){return y.jsx("svg",{className:"run-segment__icon",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:y.jsx("path",{fill:"currentColor",d:"M2.5 3v10l5.5-5L2.5 3zm7 0v10h1.5V3H9.5zm3 0v10H14V3h-1.5z"})})}function qv(){return y.jsx("svg",{className:"run-segment__icon",viewBox:"0 0 16 16",width:"11",height:"11","aria-hidden":"true",children:y.jsx("rect",{fill:"currentColor",x:"3.5",y:"3.5",width:"9",height:"9",rx:"1"})})}function HB(){return y.jsxs("svg",{className:"run-segment__icon run-segment__spinner",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:[y.jsx("circle",{cx:"8",cy:"8",r:"5.5",fill:"none",stroke:"currentColor",strokeOpacity:"0.3",strokeWidth:"2"}),y.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",d:"M8 2.5a5.5 5.5 0 0 1 5.5 5.5"})]})}const cC=240,WB=240,UB=560;function qB({children:t,onCollapse:e,onWidthChange:n}){const[i,r]=M.useState(cC),s=M.useRef(null);M.useEffect(()=>{n==null||n(i)},[i,n]);const o=M.useCallback(l=>{l.preventDefault(),l.target.setPointerCapture(l.pointerId),s.current={startX:l.clientX,startWidth:i}},[i]);return M.useEffect(()=>{const l=u=>{if(!s.current)return;const c=s.current.startX-u.clientX;r(Math.min(UB,Math.max(WB,s.current.startWidth+c)))},a=()=>{s.current=null};return window.addEventListener("pointermove",l),window.addEventListener("pointerup",a),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",a)}},[]),y.jsxs("div",{className:"inspector-shell",children:[y.jsx("div",{className:"inspector-shell__resize",onPointerDown:o,role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector",title:"Drag to resize"}),y.jsx("button",{type:"button",className:"inspector-shell__collapse",onClick:e,title:"Hide inspector","aria-label":"Hide inspector",children:"›"}),t]})}function KB(){const{operations:t,loadOperations:e,run:n,isRunning:i,nodes:r,stepStatusByNodeId:s,selectedNodeId:o,isDebugRun:l,continueExecution:a,stepNode:u,stopExecution:c}=le(),[h,f]=M.useState(!0),[d,p]=M.useState(!0),[g,x]=M.useState(cC),m=M.useCallback(k=>x(k),[]);M.useEffect(()=>{e()},[e]);const v=r.filter(k=>s[k.id]==="paused").map(k=>k.id),w=v.includes(o??"")?o:v[0];return y.jsxs("div",{className:"app",children:[y.jsxs("header",{className:"app__header",children:[y.jsxs("h1",{className:"app__title",children:[y.jsx("img",{src:"./favicon.svg",alt:"",className:"app__logo"}),"Enlace"]}),y.jsx($B,{}),y.jsxs("div",{className:"app__chrome-actions",children:[y.jsx(zB,{isRunning:i,isDebugRun:l,pausedCount:v.length,canStep:!!w,onRun:()=>n(),onDebug:()=>n({useBreakpoints:!0}),onContinue:a,onStep:()=>w&&u(w),onStop:c,stepTitle:v.length>1?"Step — release just the selected paused node (or the first paused node, if none is selected)":"Step — release the paused node"}),y.jsx(RB,{})]})]}),y.jsxs("div",{className:`app__body${h?"":" app__body--inspector-collapsed"}`,style:h?{gridTemplateColumns:`240px minmax(240px, 1fr) ${g}px`}:void 0,children:[y.jsx(LN,{operations:t}),y.jsx(AP,{}),h?y.jsx(qB,{onCollapse:()=>f(!1),onWidthChange:m,children:y.jsx(sB,{})}):y.jsx("button",{type:"button",className:"pane-strip pane-strip--right",onClick:()=>f(!0),title:"Show inspector","aria-label":"Show inspector",children:"‹"})]}),y.jsx(mB,{collapsed:!d,onToggleCollapsed:()=>p(k=>!k)})]})}cf.createRoot(document.getElementById("root")).render(y.jsx(V.StrictMode,{children:y.jsx(KB,{})}));