UNPKG

@bytebase/dbhub

Version:

Token-efficient database MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, ClickHouse, SQLite

218 lines • 890 kB
var m3=Object.defineProperty;var g3=(n,e,t)=>e in n?m3(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ft=(n,e,t)=>g3(n,typeof e!="symbol"?e+"":e,t);function y3(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in n)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();function v3(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ep={exports:{}},ra={},Rp={exports:{}},Qe={};/**
 * @license React
 * react.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Px;function x3(){if(Px)return Qe;Px=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;function g(A){return A===null||typeof A!="object"?null:(A=p&&A[p]||A["@@iterator"],typeof A=="function"?A:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function C(A,$,oe){this.props=A,this.context=$,this.refs=w,this.updater=oe||y}C.prototype.isReactComponent={},C.prototype.setState=function(A,$){if(typeof A!="object"&&typeof A!="function"&&A!=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,A,$,"setState")},C.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function E(){}E.prototype=C.prototype;function T(A,$,oe){this.props=A,this.context=$,this.refs=w,this.updater=oe||y}var M=T.prototype=new E;M.constructor=T,x(M,C.prototype),M.isPureReactComponent=!0;var P=Array.isArray,O=Object.prototype.hasOwnProperty,N={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function F(A,$,oe){var ce,me={},le=null,de=null;if($!=null)for(ce in $.ref!==void 0&&(de=$.ref),$.key!==void 0&&(le=""+$.key),$)O.call($,ce)&&!L.hasOwnProperty(ce)&&(me[ce]=$[ce]);var ee=arguments.length-2;if(ee===1)me.children=oe;else if(1<ee){for(var fe=Array(ee),ye=0;ye<ee;ye++)fe[ye]=arguments[ye+2];me.children=fe}if(A&&A.defaultProps)for(ce in ee=A.defaultProps,ee)me[ce]===void 0&&(me[ce]=ee[ce]);return{$$typeof:n,type:A,key:le,ref:de,props:me,_owner:N.current}}function U(A,$){return{$$typeof:n,type:A.type,key:$,ref:A.ref,props:A.props,_owner:A._owner}}function Q(A){return typeof A=="object"&&A!==null&&A.$$typeof===n}function q(A){var $={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(oe){return $[oe]})}var H=/\/+/g;function j(A,$){return typeof A=="object"&&A!==null&&A.key!=null?q(""+A.key):$.toString(36)}function Y(A,$,oe,ce,me){var le=typeof A;(le==="undefined"||le==="boolean")&&(A=null);var de=!1;if(A===null)de=!0;else switch(le){case"string":case"number":de=!0;break;case"object":switch(A.$$typeof){case n:case e:de=!0}}if(de)return de=A,me=me(de),A=ce===""?"."+j(de,0):ce,P(me)?(oe="",A!=null&&(oe=A.replace(H,"$&/")+"/"),Y(me,$,oe,"",function(ye){return ye})):me!=null&&(Q(me)&&(me=U(me,oe+(!me.key||de&&de.key===me.key?"":(""+me.key).replace(H,"$&/")+"/")+A)),$.push(me)),1;if(de=0,ce=ce===""?".":ce+":",P(A))for(var ee=0;ee<A.length;ee++){le=A[ee];var fe=ce+j(le,ee);de+=Y(le,$,oe,fe,me)}else if(fe=g(A),typeof fe=="function")for(A=fe.call(A),ee=0;!(le=A.next()).done;)le=le.value,fe=ce+j(le,ee++),de+=Y(le,$,oe,fe,me);else if(le==="object")throw $=String(A),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.");return de}function W(A,$,oe){if(A==null)return A;var ce=[],me=0;return Y(A,ce,"","",function(le){return $.call(oe,le,me++)}),ce}function _(A){if(A._status===-1){var $=A._result;$=$(),$.then(function(oe){(A._status===0||A._status===-1)&&(A._status=1,A._result=oe)},function(oe){(A._status===0||A._status===-1)&&(A._status=2,A._result=oe)}),A._status===-1&&(A._status=0,A._result=$)}if(A._status===1)return A._result.default;throw A._result}var X={current:null},D={transition:null},B={ReactCurrentDispatcher:X,ReactCurrentBatchConfig:D,ReactCurrentOwner:N};function K(){throw Error("act(...) is not supported in production builds of React.")}return Qe.Children={map:W,forEach:function(A,$,oe){W(A,function(){$.apply(this,arguments)},oe)},count:function(A){var $=0;return W(A,function(){$++}),$},toArray:function(A){return W(A,function($){return $})||[]},only:function(A){if(!Q(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},Qe.Component=C,Qe.Fragment=t,Qe.Profiler=i,Qe.PureComponent=T,Qe.StrictMode=r,Qe.Suspense=u,Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=B,Qe.act=K,Qe.cloneElement=function(A,$,oe){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var ce=x({},A.props),me=A.key,le=A.ref,de=A._owner;if($!=null){if($.ref!==void 0&&(le=$.ref,de=N.current),$.key!==void 0&&(me=""+$.key),A.type&&A.type.defaultProps)var ee=A.type.defaultProps;for(fe in $)O.call($,fe)&&!L.hasOwnProperty(fe)&&(ce[fe]=$[fe]===void 0&&ee!==void 0?ee[fe]:$[fe])}var fe=arguments.length-2;if(fe===1)ce.children=oe;else if(1<fe){ee=Array(fe);for(var ye=0;ye<fe;ye++)ee[ye]=arguments[ye+2];ce.children=ee}return{$$typeof:n,type:A.type,key:me,ref:le,props:ce,_owner:de}},Qe.createContext=function(A){return A={$$typeof:o,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:s,_context:A},A.Consumer=A},Qe.createElement=F,Qe.createFactory=function(A){var $=F.bind(null,A);return $.type=A,$},Qe.createRef=function(){return{current:null}},Qe.forwardRef=function(A){return{$$typeof:a,render:A}},Qe.isValidElement=Q,Qe.lazy=function(A){return{$$typeof:h,_payload:{_status:-1,_result:A},_init:_}},Qe.memo=function(A,$){return{$$typeof:f,type:A,compare:$===void 0?null:$}},Qe.startTransition=function(A){var $=D.transition;D.transition={};try{A()}finally{D.transition=$}},Qe.unstable_act=K,Qe.useCallback=function(A,$){return X.current.useCallback(A,$)},Qe.useContext=function(A){return X.current.useContext(A)},Qe.useDebugValue=function(){},Qe.useDeferredValue=function(A){return X.current.useDeferredValue(A)},Qe.useEffect=function(A,$){return X.current.useEffect(A,$)},Qe.useId=function(){return X.current.useId()},Qe.useImperativeHandle=function(A,$,oe){return X.current.useImperativeHandle(A,$,oe)},Qe.useInsertionEffect=function(A,$){return X.current.useInsertionEffect(A,$)},Qe.useLayoutEffect=function(A,$){return X.current.useLayoutEffect(A,$)},Qe.useMemo=function(A,$){return X.current.useMemo(A,$)},Qe.useReducer=function(A,$,oe){return X.current.useReducer(A,$,oe)},Qe.useRef=function(A){return X.current.useRef(A)},Qe.useState=function(A){return X.current.useState(A)},Qe.useSyncExternalStore=function(A,$,oe){return X.current.useSyncExternalStore(A,$,oe)},Qe.useTransition=function(){return X.current.useTransition()},Qe.version="18.3.1",Qe}var Ax;function rc(){return Ax||(Ax=1,Rp.exports=x3()),Rp.exports}/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Nx;function w3(){if(Nx)return ra;Nx=1;var n=rc(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(a,u,f){var h,p={},g=null,y=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(h in u)r.call(u,h)&&!s.hasOwnProperty(h)&&(p[h]=u[h]);if(a&&a.defaultProps)for(h in u=a.defaultProps,u)p[h]===void 0&&(p[h]=u[h]);return{$$typeof:e,type:a,key:g,ref:y,props:p,_owner:i.current}}return ra.Fragment=t,ra.jsx=o,ra.jsxs=o,ra}var Lx;function b3(){return Lx||(Lx=1,Ep.exports=w3()),Ep.exports}var k=b3(),S=rc();const S3=v3(S),Zb=y3({__proto__:null,default:S3},[S]);var Ou={},Tp={exports:{}},On={},Mp={exports:{}},Op={};/**
 * @license React
 * scheduler.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Dx;function k3(){return Dx||(Dx=1,function(n){function e(D,B){var K=D.length;D.push(B);e:for(;0<K;){var A=K-1>>>1,$=D[A];if(0<i($,B))D[A]=B,D[K]=$,K=A;else break e}}function t(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var B=D[0],K=D.pop();if(K!==B){D[0]=K;e:for(var A=0,$=D.length,oe=$>>>1;A<oe;){var ce=2*(A+1)-1,me=D[ce],le=ce+1,de=D[le];if(0>i(me,K))le<$&&0>i(de,me)?(D[A]=de,D[le]=K,A=le):(D[A]=me,D[ce]=K,A=ce);else if(le<$&&0>i(de,K))D[A]=de,D[le]=K,A=le;else break e}}return B}function i(D,B){var K=D.sortIndex-B.sortIndex;return K!==0?K:D.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var u=[],f=[],h=1,p=null,g=3,y=!1,x=!1,w=!1,C=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function M(D){for(var B=t(f);B!==null;){if(B.callback===null)r(f);else if(B.startTime<=D)r(f),B.sortIndex=B.expirationTime,e(u,B);else break;B=t(f)}}function P(D){if(w=!1,M(D),!x)if(t(u)!==null)x=!0,_(O);else{var B=t(f);B!==null&&X(P,B.startTime-D)}}function O(D,B){x=!1,w&&(w=!1,E(F),F=-1),y=!0;var K=g;try{for(M(B),p=t(u);p!==null&&(!(p.expirationTime>B)||D&&!q());){var A=p.callback;if(typeof A=="function"){p.callback=null,g=p.priorityLevel;var $=A(p.expirationTime<=B);B=n.unstable_now(),typeof $=="function"?p.callback=$:p===t(u)&&r(u),M(B)}else r(u);p=t(u)}if(p!==null)var oe=!0;else{var ce=t(f);ce!==null&&X(P,ce.startTime-B),oe=!1}return oe}finally{p=null,g=K,y=!1}}var N=!1,L=null,F=-1,U=5,Q=-1;function q(){return!(n.unstable_now()-Q<U)}function H(){if(L!==null){var D=n.unstable_now();Q=D;var B=!0;try{B=L(!0,D)}finally{B?j():(N=!1,L=null)}}else N=!1}var j;if(typeof T=="function")j=function(){T(H)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,W=Y.port2;Y.port1.onmessage=H,j=function(){W.postMessage(null)}}else j=function(){C(H,0)};function _(D){L=D,N||(N=!0,j())}function X(D,B){F=C(function(){D(n.unstable_now())},B)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(D){D.callback=null},n.unstable_continueExecution=function(){x||y||(x=!0,_(O))},n.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<D?Math.floor(1e3/D):5},n.unstable_getCurrentPriorityLevel=function(){return g},n.unstable_getFirstCallbackNode=function(){return t(u)},n.unstable_next=function(D){switch(g){case 1:case 2:case 3:var B=3;break;default:B=g}var K=g;g=B;try{return D()}finally{g=K}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(D,B){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var K=g;g=D;try{return B()}finally{g=K}},n.unstable_scheduleCallback=function(D,B,K){var A=n.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?A+K:A):K=A,D){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=K+$,D={id:h++,callback:B,priorityLevel:D,startTime:K,expirationTime:$,sortIndex:-1},K>A?(D.sortIndex=K,e(f,D),t(u)===null&&D===t(f)&&(w?(E(F),F=-1):w=!0,X(P,K-A))):(D.sortIndex=$,e(u,D),x||y||(x=!0,_(O))),D},n.unstable_shouldYield=q,n.unstable_wrapCallback=function(D){var B=g;return function(){var K=g;g=B;try{return D.apply(this,arguments)}finally{g=K}}}}(Op)),Op}var Ix;function C3(){return Ix||(Ix=1,Mp.exports=k3()),Mp.exports}/**
 * @license React
 * react-dom.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var jx;function E3(){if(jx)return On;jx=1;var n=rc(),e=C3();function t(l){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+l,d=1;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function s(l,c){o(l,c),o(l+"Capture",c)}function o(l,c){for(i[l]=c,l=0;l<c.length;l++)r.add(c[l])}var a=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[: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]*$/,h={},p={};function g(l){return u.call(p,l)?!0:u.call(h,l)?!1:f.test(l)?p[l]=!0:(h[l]=!0,!1)}function y(l,c,d,m){if(d!==null&&d.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return m?!1:d!==null?!d.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function x(l,c,d,m){if(c===null||typeof c>"u"||y(l,c,d,m))return!0;if(m)return!1;if(d!==null)switch(d.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function w(l,c,d,m,v,b,R){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=m,this.attributeNamespace=v,this.mustUseProperty=d,this.propertyName=l,this.type=c,this.sanitizeURL=b,this.removeEmptyString=R}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){C[l]=new w(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var c=l[0];C[c]=new w(c,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){C[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){C[l]=new w(l,2,!1,l,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(l){C[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){C[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){C[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){C[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){C[l]=new w(l,5,!1,l.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function T(l){return l[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(l){var c=l.replace(E,T);C[c]=new w(c,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var c=l.replace(E,T);C[c]=new w(c,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var c=l.replace(E,T);C[c]=new w(c,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){C[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),C.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){C[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function M(l,c,d,m){var v=C.hasOwnProperty(c)?C[c]:null;(v!==null?v.type!==0:m||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(x(c,d,v,m)&&(d=null),m||v===null?g(c)&&(d===null?l.removeAttribute(c):l.setAttribute(c,""+d)):v.mustUseProperty?l[v.propertyName]=d===null?v.type===3?!1:"":d:(c=v.attributeName,m=v.attributeNamespace,d===null?l.removeAttribute(c):(v=v.type,d=v===3||v===4&&d===!0?"":""+d,m?l.setAttributeNS(m,c,d):l.setAttribute(c,d))))}var P=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,O=Symbol.for("react.element"),N=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),Q=Symbol.for("react.provider"),q=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),X=Symbol.for("react.offscreen"),D=Symbol.iterator;function B(l){return l===null||typeof l!="object"?null:(l=D&&l[D]||l["@@iterator"],typeof l=="function"?l:null)}var K=Object.assign,A;function $(l){if(A===void 0)try{throw Error()}catch(d){var c=d.stack.trim().match(/\n( *(at )?)/);A=c&&c[1]||""}return`
`+A+l}var oe=!1;function ce(l,c){if(!l||oe)return"";oe=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(Z){var m=Z}Reflect.construct(l,[],c)}else{try{c.call()}catch(Z){m=Z}l.call(c.prototype)}else{try{throw Error()}catch(Z){m=Z}l()}}catch(Z){if(Z&&m&&typeof Z.stack=="string"){for(var v=Z.stack.split(`
`),b=m.stack.split(`
`),R=v.length-1,I=b.length-1;1<=R&&0<=I&&v[R]!==b[I];)I--;for(;1<=R&&0<=I;R--,I--)if(v[R]!==b[I]){if(R!==1||I!==1)do if(R--,I--,0>I||v[R]!==b[I]){var z=`
`+v[R].replace(" at new "," at ");return l.displayName&&z.includes("<anonymous>")&&(z=z.replace("<anonymous>",l.displayName)),z}while(1<=R&&0<=I);break}}}finally{oe=!1,Error.prepareStackTrace=d}return(l=l?l.displayName||l.name:"")?$(l):""}function me(l){switch(l.tag){case 5:return $(l.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return l=ce(l.type,!1),l;case 11:return l=ce(l.type.render,!1),l;case 1:return l=ce(l.type,!0),l;default:return""}}function le(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case L:return"Fragment";case N:return"Portal";case U:return"Profiler";case F:return"StrictMode";case j:return"Suspense";case Y:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case q:return(l.displayName||"Context")+".Consumer";case Q:return(l._context.displayName||"Context")+".Provider";case H:var c=l.render;return l=l.displayName,l||(l=c.displayName||c.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case W:return c=l.displayName||null,c!==null?c:le(l.type)||"Memo";case _:c=l._payload,l=l._init;try{return le(l(c))}catch{}}return null}function de(l){var c=l.type;switch(l.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=c.render,l=l.displayName||l.name||"",c.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(c);case 8:return c===F?"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 c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function ee(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function fe(l){var c=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ye(l){var c=fe(l)?"checked":"value",d=Object.getOwnPropertyDescriptor(l.constructor.prototype,c),m=""+l[c];if(!l.hasOwnProperty(c)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var v=d.get,b=d.set;return Object.defineProperty(l,c,{configurable:!0,get:function(){return v.call(this)},set:function(R){m=""+R,b.call(this,R)}}),Object.defineProperty(l,c,{enumerable:d.enumerable}),{getValue:function(){return m},setValue:function(R){m=""+R},stopTracking:function(){l._valueTracker=null,delete l[c]}}}}function ne(l){l._valueTracker||(l._valueTracker=ye(l))}function he(l){if(!l)return!1;var c=l._valueTracker;if(!c)return!0;var d=c.getValue(),m="";return l&&(m=fe(l)?l.checked?"true":"false":l.value),l=m,l!==d?(c.setValue(l),!0):!1}function we(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function at(l,c){var d=c.checked;return K({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??l._wrapperState.initialChecked})}function ze(l,c){var d=c.defaultValue==null?"":c.defaultValue,m=c.checked!=null?c.checked:c.defaultChecked;d=ee(c.value!=null?c.value:d),l._wrapperState={initialChecked:m,initialValue:d,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function pe(l,c){c=c.checked,c!=null&&M(l,"checked",c,!1)}function Re(l,c){pe(l,c);var d=ee(c.value),m=c.type;if(d!=null)m==="number"?(d===0&&l.value===""||l.value!=d)&&(l.value=""+d):l.value!==""+d&&(l.value=""+d);else if(m==="submit"||m==="reset"){l.removeAttribute("value");return}c.hasOwnProperty("value")?Le(l,c.type,d):c.hasOwnProperty("defaultValue")&&Le(l,c.type,ee(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(l.defaultChecked=!!c.defaultChecked)}function Te(l,c,d){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var m=c.type;if(!(m!=="submit"&&m!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+l._wrapperState.initialValue,d||c===l.value||(l.value=c),l.defaultValue=c}d=l.name,d!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,d!==""&&(l.name=d)}function Le(l,c,d){(c!=="number"||we(l.ownerDocument)!==l)&&(d==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+d&&(l.defaultValue=""+d))}var We=Array.isArray;function Me(l,c,d,m){if(l=l.options,c){c={};for(var v=0;v<d.length;v++)c["$"+d[v]]=!0;for(d=0;d<l.length;d++)v=c.hasOwnProperty("$"+l[d].value),l[d].selected!==v&&(l[d].selected=v),v&&m&&(l[d].defaultSelected=!0)}else{for(d=""+ee(d),c=null,v=0;v<l.length;v++){if(l[v].value===d){l[v].selected=!0,m&&(l[v].defaultSelected=!0);return}c!==null||l[v].disabled||(c=l[v])}c!==null&&(c.selected=!0)}}function xe(l,c){if(c.dangerouslySetInnerHTML!=null)throw Error(t(91));return K({},c,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function Ve(l,c){var d=c.value;if(d==null){if(d=c.children,c=c.defaultValue,d!=null){if(c!=null)throw Error(t(92));if(We(d)){if(1<d.length)throw Error(t(93));d=d[0]}c=d}c==null&&(c=""),d=c}l._wrapperState={initialValue:ee(d)}}function Ue(l,c){var d=ee(c.value),m=ee(c.defaultValue);d!=null&&(d=""+d,d!==l.value&&(l.value=d),c.defaultValue==null&&l.defaultValue!==d&&(l.defaultValue=d)),m!=null&&(l.defaultValue=""+m)}function Ce(l){var c=l.textContent;c===l._wrapperState.initialValue&&c!==""&&c!==null&&(l.value=c)}function Fe(l){switch(l){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 it(l,c){return l==null||l==="http://www.w3.org/1999/xhtml"?Fe(c):l==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var qe,Ye=function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,d,m,v){MSApp.execUnsafeLocalFunction(function(){return l(c,d,m,v)})}:l}(function(l,c){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=c;else{for(qe=qe||document.createElement("div"),qe.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=qe.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;c.firstChild;)l.appendChild(c.firstChild)}});function Ke(l,c){if(c){var d=l.firstChild;if(d&&d===l.lastChild&&d.nodeType===3){d.nodeValue=c;return}}l.textContent=c}var tt={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},Di=["Webkit","ms","Moz","O"];Object.keys(tt).forEach(function(l){Di.forEach(function(c){c=c+l.charAt(0).toUpperCase()+l.substring(1),tt[c]=tt[l]})});function Wt(l,c,d){return c==null||typeof c=="boolean"||c===""?"":d||typeof c!="number"||c===0||tt.hasOwnProperty(l)&&tt[l]?(""+c).trim():c+"px"}function vt(l,c){l=l.style;for(var d in c)if(c.hasOwnProperty(d)){var m=d.indexOf("--")===0,v=Wt(d,c[d],m);d==="float"&&(d="cssFloat"),m?l.setProperty(d,v):l[d]=v}}var kn=K({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 Gn(l,c){if(c){if(kn[l]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(t(137,l));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(t(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(t(61))}if(c.style!=null&&typeof c.style!="object")throw Error(t(62))}}function Yn(l,c){if(l.indexOf("-")===-1)return typeof c.is=="string";switch(l){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 Dr=null;function st(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Et=null,$t=null,Nt=null;function li(l){if(l=Wl(l)){if(typeof Et!="function")throw Error(t(280));var c=l.stateNode;c&&(c=Hc(c),Et(l.stateNode,l.type,c))}}function ai(l){$t?Nt?Nt.push(l):Nt=[l]:$t=l}function Ss(){if($t){var l=$t,c=Nt;if(Nt=$t=null,li(l),c)for(l=0;l<c.length;l++)li(c[l])}}function ao(l,c){return l(c)}function ci(){}var wl=!1;function bc(l,c,d){if(wl)return l(c,d);wl=!0;try{return ao(l,c,d)}finally{wl=!1,($t!==null||Nt!==null)&&(ci(),Ss())}}function ks(l,c){var d=l.stateNode;if(d===null)return null;var m=Hc(d);if(m===null)return null;d=m[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(l=l.type,m=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!m;break e;default:l=!1}if(l)return null;if(d&&typeof d!="function")throw Error(t(231,c,typeof d));return d}var bl=!1;if(a)try{var ui={};Object.defineProperty(ui,"passive",{get:function(){bl=!0}}),window.addEventListener("test",ui,ui),window.removeEventListener("test",ui,ui)}catch{bl=!1}function Sc(l,c,d,m,v,b,R,I,z){var Z=Array.prototype.slice.call(arguments,3);try{c.apply(d,Z)}catch(se){this.onError(se)}}var Cs=!1,co=null,Ir=!1,Sl=null,$d={onError:function(l){Cs=!0,co=l}};function Hd(l,c,d,m,v,b,R,I,z){Cs=!1,co=null,Sc.apply($d,arguments)}function kc(l,c,d,m,v,b,R,I,z){if(Hd.apply(this,arguments),Cs){if(Cs){var Z=co;Cs=!1,co=null}else throw Error(t(198));Ir||(Ir=!0,Sl=Z)}}function jr(l){var c=l,d=l;if(l.alternate)for(;c.return;)c=c.return;else{l=c;do c=l,(c.flags&4098)!==0&&(d=c.return),l=c.return;while(l)}return c.tag===3?d:null}function kl(l){if(l.tag===13){var c=l.memoizedState;if(c===null&&(l=l.alternate,l!==null&&(c=l.memoizedState)),c!==null)return c.dehydrated}return null}function ey(l){if(jr(l)!==l)throw Error(t(188))}function ER(l){var c=l.alternate;if(!c){if(c=jr(l),c===null)throw Error(t(188));return c!==l?null:l}for(var d=l,m=c;;){var v=d.return;if(v===null)break;var b=v.alternate;if(b===null){if(m=v.return,m!==null){d=m;continue}break}if(v.child===b.child){for(b=v.child;b;){if(b===d)return ey(v),l;if(b===m)return ey(v),c;b=b.sibling}throw Error(t(188))}if(d.return!==m.return)d=v,m=b;else{for(var R=!1,I=v.child;I;){if(I===d){R=!0,d=v,m=b;break}if(I===m){R=!0,m=v,d=b;break}I=I.sibling}if(!R){for(I=b.child;I;){if(I===d){R=!0,d=b,m=v;break}if(I===m){R=!0,m=b,d=v;break}I=I.sibling}if(!R)throw Error(t(189))}}if(d.alternate!==m)throw Error(t(190))}if(d.tag!==3)throw Error(t(188));return d.stateNode.current===d?l:c}function ty(l){return l=ER(l),l!==null?ny(l):null}function ny(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var c=ny(l);if(c!==null)return c;l=l.sibling}return null}var ry=e.unstable_scheduleCallback,iy=e.unstable_cancelCallback,RR=e.unstable_shouldYield,TR=e.unstable_requestPaint,Lt=e.unstable_now,MR=e.unstable_getCurrentPriorityLevel,Ud=e.unstable_ImmediatePriority,sy=e.unstable_UserBlockingPriority,Cc=e.unstable_NormalPriority,OR=e.unstable_LowPriority,oy=e.unstable_IdlePriority,Ec=null,Br=null;function PR(l){if(Br&&typeof Br.onCommitFiberRoot=="function")try{Br.onCommitFiberRoot(Ec,l,void 0,(l.current.flags&128)===128)}catch{}}var mr=Math.clz32?Math.clz32:LR,AR=Math.log,NR=Math.LN2;function LR(l){return l>>>=0,l===0?32:31-(AR(l)/NR|0)|0}var Rc=64,Tc=4194304;function Cl(l){switch(l&-l){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 l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function Mc(l,c){var d=l.pendingLanes;if(d===0)return 0;var m=0,v=l.suspendedLanes,b=l.pingedLanes,R=d&268435455;if(R!==0){var I=R&~v;I!==0?m=Cl(I):(b&=R,b!==0&&(m=Cl(b)))}else R=d&~v,R!==0?m=Cl(R):b!==0&&(m=Cl(b));if(m===0)return 0;if(c!==0&&c!==m&&(c&v)===0&&(v=m&-m,b=c&-c,v>=b||v===16&&(b&4194240)!==0))return c;if((m&4)!==0&&(m|=d&16),c=l.entangledLanes,c!==0)for(l=l.entanglements,c&=m;0<c;)d=31-mr(c),v=1<<d,m|=l[d],c&=~v;return m}function DR(l,c){switch(l){case 1:case 2:case 4:return c+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 c+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 IR(l,c){for(var d=l.suspendedLanes,m=l.pingedLanes,v=l.expirationTimes,b=l.pendingLanes;0<b;){var R=31-mr(b),I=1<<R,z=v[R];z===-1?((I&d)===0||(I&m)!==0)&&(v[R]=DR(I,c)):z<=c&&(l.expiredLanes|=I),b&=~I}}function qd(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function ly(){var l=Rc;return Rc<<=1,(Rc&4194240)===0&&(Rc=64),l}function Kd(l){for(var c=[],d=0;31>d;d++)c.push(l);return c}function El(l,c,d){l.pendingLanes|=c,c!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,c=31-mr(c),l[c]=d}function jR(l,c){var d=l.pendingLanes&~c;l.pendingLanes=c,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=c,l.mutableReadLanes&=c,l.entangledLanes&=c,c=l.entanglements;var m=l.eventTimes;for(l=l.expirationTimes;0<d;){var v=31-mr(d),b=1<<v;c[v]=0,m[v]=-1,l[v]=-1,d&=~b}}function Qd(l,c){var d=l.entangledLanes|=c;for(l=l.entanglements;d;){var m=31-mr(d),v=1<<m;v&c|l[m]&c&&(l[m]|=c),d&=~v}}var ut=0;function ay(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var cy,Gd,uy,fy,dy,Yd=!1,Oc=[],Ii=null,ji=null,Bi=null,Rl=new Map,Tl=new Map,Fi=[],BR="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 hy(l,c){switch(l){case"focusin":case"focusout":Ii=null;break;case"dragenter":case"dragleave":ji=null;break;case"mouseover":case"mouseout":Bi=null;break;case"pointerover":case"pointerout":Rl.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Tl.delete(c.pointerId)}}function Ml(l,c,d,m,v,b){return l===null||l.nativeEvent!==b?(l={blockedOn:c,domEventName:d,eventSystemFlags:m,nativeEvent:b,targetContainers:[v]},c!==null&&(c=Wl(c),c!==null&&Gd(c)),l):(l.eventSystemFlags|=m,c=l.targetContainers,v!==null&&c.indexOf(v)===-1&&c.push(v),l)}function FR(l,c,d,m,v){switch(c){case"focusin":return Ii=Ml(Ii,l,c,d,m,v),!0;case"dragenter":return ji=Ml(ji,l,c,d,m,v),!0;case"mouseover":return Bi=Ml(Bi,l,c,d,m,v),!0;case"pointerover":var b=v.pointerId;return Rl.set(b,Ml(Rl.get(b)||null,l,c,d,m,v)),!0;case"gotpointercapture":return b=v.pointerId,Tl.set(b,Ml(Tl.get(b)||null,l,c,d,m,v)),!0}return!1}function py(l){var c=Es(l.target);if(c!==null){var d=jr(c);if(d!==null){if(c=d.tag,c===13){if(c=kl(d),c!==null){l.blockedOn=c,dy(l.priority,function(){uy(d)});return}}else if(c===3&&d.stateNode.current.memoizedState.isDehydrated){l.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}l.blockedOn=null}function Pc(l){if(l.blockedOn!==null)return!1;for(var c=l.targetContainers;0<c.length;){var d=Jd(l.domEventName,l.eventSystemFlags,c[0],l.nativeEvent);if(d===null){d=l.nativeEvent;var m=new d.constructor(d.type,d);Dr=m,d.target.dispatchEvent(m),Dr=null}else return c=Wl(d),c!==null&&Gd(c),l.blockedOn=d,!1;c.shift()}return!0}function my(l,c,d){Pc(l)&&d.delete(c)}function zR(){Yd=!1,Ii!==null&&Pc(Ii)&&(Ii=null),ji!==null&&Pc(ji)&&(ji=null),Bi!==null&&Pc(Bi)&&(Bi=null),Rl.forEach(my),Tl.forEach(my)}function Ol(l,c){l.blockedOn===c&&(l.blockedOn=null,Yd||(Yd=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,zR)))}function Pl(l){function c(v){return Ol(v,l)}if(0<Oc.length){Ol(Oc[0],l);for(var d=1;d<Oc.length;d++){var m=Oc[d];m.blockedOn===l&&(m.blockedOn=null)}}for(Ii!==null&&Ol(Ii,l),ji!==null&&Ol(ji,l),Bi!==null&&Ol(Bi,l),Rl.forEach(c),Tl.forEach(c),d=0;d<Fi.length;d++)m=Fi[d],m.blockedOn===l&&(m.blockedOn=null);for(;0<Fi.length&&(d=Fi[0],d.blockedOn===null);)py(d),d.blockedOn===null&&Fi.shift()}var uo=P.ReactCurrentBatchConfig,Ac=!0;function _R(l,c,d,m){var v=ut,b=uo.transition;uo.transition=null;try{ut=1,Xd(l,c,d,m)}finally{ut=v,uo.transition=b}}function VR(l,c,d,m){var v=ut,b=uo.transition;uo.transition=null;try{ut=4,Xd(l,c,d,m)}finally{ut=v,uo.transition=b}}function Xd(l,c,d,m){if(Ac){var v=Jd(l,c,d,m);if(v===null)mh(l,c,m,Nc,d),hy(l,m);else if(FR(v,l,c,d,m))m.stopPropagation();else if(hy(l,m),c&4&&-1<BR.indexOf(l)){for(;v!==null;){var b=Wl(v);if(b!==null&&cy(b),b=Jd(l,c,d,m),b===null&&mh(l,c,m,Nc,d),b===v)break;v=b}v!==null&&m.stopPropagation()}else mh(l,c,m,null,d)}}var Nc=null;function Jd(l,c,d,m){if(Nc=null,l=st(m),l=Es(l),l!==null)if(c=jr(l),c===null)l=null;else if(d=c.tag,d===13){if(l=kl(c),l!==null)return l;l=null}else if(d===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;l=null}else c!==l&&(l=null);return Nc=l,null}function gy(l){switch(l){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(MR()){case Ud:return 1;case sy:return 4;case Cc:case OR:return 16;case oy:return 536870912;default:return 16}default:return 16}}var zi=null,Zd=null,Lc=null;function yy(){if(Lc)return Lc;var l,c=Zd,d=c.length,m,v="value"in zi?zi.value:zi.textContent,b=v.length;for(l=0;l<d&&c[l]===v[l];l++);var R=d-l;for(m=1;m<=R&&c[d-m]===v[b-m];m++);return Lc=v.slice(l,1<m?1-m:void 0)}function Dc(l){var c=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&c===13&&(l=13)):l=c,l===10&&(l=13),32<=l||l===13?l:0}function Ic(){return!0}function vy(){return!1}function _n(l){function c(d,m,v,b,R){this._reactName=d,this._targetInst=v,this.type=m,this.nativeEvent=b,this.target=R,this.currentTarget=null;for(var I in l)l.hasOwnProperty(I)&&(d=l[I],this[I]=d?d(b):b[I]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?Ic:vy,this.isPropagationStopped=vy,this}return K(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=Ic)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=Ic)},persist:function(){},isPersistent:Ic}),c}var fo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},eh=_n(fo),Al=K({},fo,{view:0,detail:0}),WR=_n(Al),th,nh,Nl,jc=K({},Al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ih,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Nl&&(Nl&&l.type==="mousemove"?(th=l.screenX-Nl.screenX,nh=l.screenY-Nl.screenY):nh=th=0,Nl=l),th)},movementY:function(l){return"movementY"in l?l.movementY:nh}}),xy=_n(jc),$R=K({},jc,{dataTransfer:0}),HR=_n($R),UR=K({},Al,{relatedTarget:0}),rh=_n(UR),qR=K({},fo,{animationName:0,elapsedTime:0,pseudoElement:0}),KR=_n(qR),QR=K({},fo,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),GR=_n(QR),YR=K({},fo,{data:0}),wy=_n(YR),XR={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},JR={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"},ZR={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function e4(l){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(l):(l=ZR[l])?!!c[l]:!1}function ih(){return e4}var t4=K({},Al,{key:function(l){if(l.key){var c=XR[l.key]||l.key;if(c!=="Unidentified")return c}return l.type==="keypress"?(l=Dc(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?JR[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ih,charCode:function(l){return l.type==="keypress"?Dc(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Dc(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),n4=_n(t4),r4=K({},jc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),by=_n(r4),i4=K({},Al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ih}),s4=_n(i4),o4=K({},fo,{propertyName:0,elapsedTime:0,pseudoElement:0}),l4=_n(o4),a4=K({},jc,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),c4=_n(a4),u4=[9,13,27,32],sh=a&&"CompositionEvent"in window,Ll=null;a&&"documentMode"in document&&(Ll=document.documentMode);var f4=a&&"TextEvent"in window&&!Ll,Sy=a&&(!sh||Ll&&8<Ll&&11>=Ll),ky=" ",Cy=!1;function Ey(l,c){switch(l){case"keyup":return u4.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ry(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var ho=!1;function d4(l,c){switch(l){case"compositionend":return Ry(c);case"keypress":return c.which!==32?null:(Cy=!0,ky);case"textInput":return l=c.data,l===ky&&Cy?null:l;default:return null}}function h4(l,c){if(ho)return l==="compositionend"||!sh&&Ey(l,c)?(l=yy(),Lc=Zd=zi=null,ho=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Sy&&c.locale!=="ko"?null:c.data;default:return null}}var p4={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 Ty(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c==="input"?!!p4[l.type]:c==="textarea"}function My(l,c,d,m){ai(m),c=Vc(c,"onChange"),0<c.length&&(d=new eh("onChange","change",null,d,m),l.push({event:d,listeners:c}))}var Dl=null,Il=null;function m4(l){qy(l,0)}function Bc(l){var c=vo(l);if(he(c))return l}function g4(l,c){if(l==="change")return c}var Oy=!1;if(a){var oh;if(a){var lh="oninput"in document;if(!lh){var Py=document.createElement("div");Py.setAttribute("oninput","return;"),lh=typeof Py.oninput=="function"}oh=lh}else oh=!1;Oy=oh&&(!document.documentMode||9<document.documentMode)}function Ay(){Dl&&(Dl.detachEvent("onpropertychange",Ny),Il=Dl=null)}function Ny(l){if(l.propertyName==="value"&&Bc(Il)){var c=[];My(c,Il,l,st(l)),bc(m4,c)}}function y4(l,c,d){l==="focusin"?(Ay(),Dl=c,Il=d,Dl.attachEvent("onpropertychange",Ny)):l==="focusout"&&Ay()}function v4(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Bc(Il)}function x4(l,c){if(l==="click")return Bc(c)}function w4(l,c){if(l==="input"||l==="change")return Bc(c)}function b4(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var gr=typeof Object.is=="function"?Object.is:b4;function jl(l,c){if(gr(l,c))return!0;if(typeof l!="object"||l===null||typeof c!="object"||c===null)return!1;var d=Object.keys(l),m=Object.keys(c);if(d.length!==m.length)return!1;for(m=0;m<d.length;m++){var v=d[m];if(!u.call(c,v)||!gr(l[v],c[v]))return!1}return!0}function Ly(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function Dy(l,c){var d=Ly(l);l=0;for(var m;d;){if(d.nodeType===3){if(m=l+d.textContent.length,l<=c&&m>=c)return{node:d,offset:c-l};l=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Ly(d)}}function Iy(l,c){return l&&c?l===c?!0:l&&l.nodeType===3?!1:c&&c.nodeType===3?Iy(l,c.parentNode):"contains"in l?l.contains(c):l.compareDocumentPosition?!!(l.compareDocumentPosition(c)&16):!1:!1}function jy(){for(var l=window,c=we();c instanceof l.HTMLIFrameElement;){try{var d=typeof c.contentWindow.location.href=="string"}catch{d=!1}if(d)l=c.contentWindow;else break;c=we(l.document)}return c}function ah(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c&&(c==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||c==="textarea"||l.contentEditable==="true")}function S4(l){var c=jy(),d=l.focusedElem,m=l.selectionRange;if(c!==d&&d&&d.ownerDocument&&Iy(d.ownerDocument.documentElement,d)){if(m!==null&&ah(d)){if(c=m.start,l=m.end,l===void 0&&(l=c),"selectionStart"in d)d.selectionStart=c,d.selectionEnd=Math.min(l,d.value.length);else if(l=(c=d.ownerDocument||document)&&c.defaultView||window,l.getSelection){l=l.getSelection();var v=d.textContent.length,b=Math.min(m.start,v);m=m.end===void 0?b:Math.min(m.end,v),!l.extend&&b>m&&(v=m,m=b,b=v),v=Dy(d,b);var R=Dy(d,m);v&&R&&(l.rangeCount!==1||l.anchorNode!==v.node||l.anchorOffset!==v.offset||l.focusNode!==R.node||l.focusOffset!==R.offset)&&(c=c.createRange(),c.setStart(v.node,v.offset),l.removeAllRanges(),b>m?(l.addRange(c),l.extend(R.node,R.offset)):(c.setEnd(R.node,R.offset),l.addRange(c)))}}for(c=[],l=d;l=l.parentNode;)l.nodeType===1&&c.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<c.length;d++)l=c[d],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var k4=a&&"documentMode"in document&&11>=document.documentMode,po=null,ch=null,Bl=null,uh=!1;function By(l,c,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;uh||po==null||po!==we(m)||(m=po,"selectionStart"in m&&ah(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),Bl&&jl(Bl,m)||(Bl=m,m=Vc(ch,"onSelect"),0<m.length&&(c=new eh("onSelect","select",null,c,d),l.push({event:c,listeners:m}),c.target=po)))}function Fc(l,c){var d={};return d[l.toLowerCase()]=c.toLowerCase(),d["Webkit"+l]="webkit"+c,d["Moz"+l]="moz"+c,d}var mo={animationend:Fc("Animation","AnimationEnd"),animationiteration:Fc("Animation","AnimationIteration"),animationstart:Fc("Animation","AnimationStart"),transitionend:Fc("Transition","TransitionEnd")},fh={},Fy={};a&&(Fy=document.createElement("div").style,"AnimationEvent"in window||(delete mo.animationend.animation,delete mo.animationiteration.animation,delete mo.animationstart.animation),"TransitionEvent"in window||delete mo.transitionend.transition);function zc(l){if(fh[l])return fh[l];if(!mo[l])return l;var c=mo[l],d;for(d in c)if(c.hasOwnProperty(d)&&d in Fy)return fh[l]=c[d];return l}var zy=zc("animationend"),_y=zc("animationiteration"),Vy=zc("animationstart"),Wy=zc("transitionend"),$y=new Map,Hy="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 _i(l,c){$y.set(l,c),s(c,[l])}for(var dh=0;dh<Hy.length;dh++){var hh=Hy[dh],C4=hh.toLowerCase(),E4=hh[0].toUpperCase()+hh.slice(1);_i(C4,"on"+E4)}_i(zy,"onAnimationEnd"),_i(_y,"onAnimationIteration"),_i(Vy,"onAnimationStart"),_i("dblclick","onDoubleClick"),_i("focusin","onFocus"),_i("focusout","onBlur"),_i(Wy,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fl="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(" "),R4=new Set("cancel close invalid load scroll toggle".split(" ").concat(Fl));function Uy(l,c,d){var m=l.type||"unknown-event";l.currentTarget=d,kc(m,c,void 0,l),l.currentTarget=null}function qy(l,c){c=(c&4)!==0;for(var d=0;d<l.length;d++){var m=l[d],v=m.event;m=m.listeners;e:{var b=void 0;if(c)for(var R=m.length-1;0<=R;R--){var I=m[R],z=I.instance,Z=I.currentTarget;if(I=I.listener,z!==b&&v.isPropagationStopped())break e;Uy(v,I,Z),b=z}else for(R=0;R<m.length;R++){if(I=m[R],z=I.instance,Z=I.currentTarget,I=I.listener,z!==b&&v.isPropagationStopped())break e;Uy(v,I,Z),b=z}}}if(Ir)throw l=Sl,Ir=!1,Sl=null,l}function xt(l,c){var d=c[bh];d===void 0&&(d=c[bh]=new Set);var m=l+"__bubble";d.has(m)||(Ky(c,l,2,!1),d.add(m))}function ph(l,c,d){var m=0;c&&(m|=4),Ky(d,l,m,c)}var _c="_reactListening"+Math.random().toString(36).slice(2);function zl(l){if(!l[_c]){l[_c]=!0,r.forEach(function(d){d!=="selectionchange"&&(R4.has(d)||ph(d,!1,l),ph(d,!0,l))});var c=l.nodeType===9?l:l.ownerDocument;c===null||c[_c]||(c[_c]=!0,ph("selectionchange",!1,c))}}function Ky(l,c,d,m){switch(gy(c)){case 1:var v=_R;break;case 4:v=VR;break;default:v=Xd}d=v.bind(null,c,d,l),v=void 0,!bl||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(v=!0),m?v!==void 0?l.addEventListener(c,d,{capture:!0,passive:v}):l.addEventListener(c,d,!0):v!==void 0?l.addEventListener(c,d,{passive:v}):l.addEventListener(c,d,!1)}function mh(l,c,d,m,v){var b=m;if((c&1)===0&&(c&2)===0&&m!==null)e:for(;;){if(m===null)return;var R=m.tag;if(R===3||R===4){var I=m.stateNode.containerInfo;if(I===v||I.nodeType===8&&I.parentNode===v)break;if(R===4)for(R=m.return;R!==null;){var z=R.tag;if((z===3||z===4)&&(z=R.stateNode.containerInfo,z===v||z.nodeType===8&&z.parentNode===v))return;R=R.return}for(;I!==null;){if(R=Es(I),R===null)return;if(z=R.tag,z===5||z===6){m=b=R;continue e}I=I.parentNode}}m=m.return}bc(function(){var Z=b,se=st(d),ae=[];e:{var re=$y.get(l);if(re!==void 0){var be=eh,Oe=l;switch(l){case"keypress":if(Dc(d)===0)break e;case"keydown":case"keyup":be=n4;break;case"focusin":Oe="focus",be=rh;break;case"focusout":Oe="blur",be=rh;break;case"beforeblur":case"afterblur":be=rh;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":be=xy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":be=HR;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":be=s4;break;case zy:case _y:case Vy:be=KR;break;case Wy:be=l4;break;case"scroll":be=WR;break;case"wheel":be=c4;break;case"copy":case"cut":case"paste":be=GR;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":be=by}var Pe=(c&4)!==0,Dt=!Pe&&l==="scroll",G=Pe?re!==null?re+"Capture":null:re;Pe=[];for(var V=Z,J;V!==null;){J=V;var ue=J.stateNode;if(J.tag===5&&ue!==null&&(J=ue,G!==null&&(ue=ks(V,G),ue!=null&&Pe.push(_l(V,ue,J)))),Dt)break;V=V.return}0<Pe.length&&(re=new be(re,Oe,null,d,se),ae.push({event:re,listeners:Pe}))}}if((c&7)===0){e:{if(re=l==="mouseover"||l==="pointerover",be=l==="mouseout"||l==="pointerout",re&&d!==Dr&&(Oe=d.relatedTarget||d.fromElement)&&(Es(Oe)||Oe[fi]))break e;if((be||re)&&(re=se.window===se?se:(re=se.ownerDocument)?re.defaultView||re.parentWindow:window,be?(Oe=d.relatedTarget||d.toElement,be=Z,Oe=Oe?Es(Oe):null,Oe!==null&&(Dt=jr(Oe),Oe!==Dt||Oe.tag!==5&&Oe.tag!==6)&&(Oe=null)):(be=null,Oe=Z),be!==Oe)){if(Pe=xy,ue="onMouseLeave",G="onMouseEnter",V="mouse",(l==="pointerout"||l==="pointerover")&&(Pe=by,ue="onPointerLeave",G="onPointerEnter",V="pointer"),Dt=be==null?re:vo(be),J=Oe==null?re:vo(Oe),re=new Pe(ue,V+"leave",be,d,se),re.target=Dt,re.relatedTarget=J,ue=null,Es(se)===Z&&(Pe=new Pe(G,V+"enter",Oe,d,se),Pe.target=J,Pe.relatedTarget=Dt,ue=Pe),Dt=ue,be&&Oe)t:{for(Pe=be,G=Oe,V=0,J=Pe;J;J=go(J))V++;for(J=0,ue=G;ue;ue=go(ue))J++;for(;0<V-J;)Pe=go(Pe),V--;for(;0<J-V;)G=go(G),J--;for(;V--;){if(Pe===G||G!==null&&Pe===G.alternate)break t;Pe=go(Pe),G=go(G)}Pe=null}else Pe=null;be!==null&&Qy(ae,re,be,Pe,!1),Oe!==null&&Dt!==null&&Qy(ae,Dt,Oe,Pe,!0)}}e:{if(re=Z?vo(Z):window,be=re.nodeName&&re.nodeName.toLowerCase(),be==="select"||be==="input"&&re.type==="file")var Ae=g4;else if(Ty(re))if(Oy)Ae=w4;else{Ae=v4;var Ie=y4}else(be=re.nodeName)&&be.toLowerCase()==="input"&&(re.type==="checkbox"||re.type==="radio")&&(Ae=x4);if(Ae&&(Ae=Ae(l,Z))){My(ae,Ae,d,se);break e}Ie&&Ie(l,re,Z),l==="focusout"&&(Ie=re._wrapperState)&&Ie.controlled&&re.type==="number"&&Le(re,"number",re.value)}switch(Ie=Z?vo(Z):window,l){case"focusin":(Ty(Ie)||Ie.contentEditable==="true")&&(po=Ie,ch=Z,Bl=null);break;case"focusout":Bl=ch=po=null;break;case"mousedown":uh=!0;break;case"contextmenu":case"mouseup":case"dragend":uh=!1,By(ae,d,se);break;case"selectionchange":if(k4)break;case"keydown":case"keyup":By(ae,d,se)}var je;if(sh)e:{switch(l){case"compositionstart":var _e="onCompositionStart";break e;case"compositionend":_e="onCompositionEnd";break e;case"compositionupdate":_e="onCompositionUpdate";break e}_e=void 0}else ho?Ey(l,d)&&(_e="onCompositionEnd"):l==="keydown"&&d.keyCode===229&&(_e="onCompositionStart");_e&&(Sy&&d.locale!=="ko"&&(ho||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&ho&&(je=yy()):(zi=se,Zd="value"in zi?zi.value:zi.textContent,ho=!0)),Ie=Vc(Z,_e),0<Ie.length&&(_e=new wy(_e,l,null,d,se),ae.push({event:_e,listeners:Ie}),je?_e.data=je:(je=Ry(d),je!==null&&(_e.data=je)))),(je=f4?d4(l,d):h4(l,d))&&(Z=Vc(Z,"onBeforeInput"),0<Z.length&&(se=new wy("onBeforeInput","beforeinput",null,d,se),ae.push({event:se,listeners:Z}),se.data=je))}qy(ae,c)})}function _l(l,c,d){return{instance:l,listener:c,currentTarget:d}}function Vc(l,c){for(var d=c+"Capture",m=[];l!==null;){var v=l,b=v.stateNode;v.tag===5&&b!==null&&(v=b,b=ks(l,d),b!=null&&m.unshift(_l(l,b,v)),b=ks(l,c),b!=null&&m.push(_l(l,b,v))),l=l.return}return m}function go(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function Qy(l,c,d,m,v){for(var b=c._reactName,R=[];d!==null&&d!==m;){var I=d,z=I.alternate,Z=I.stateNode;if(z!==null&&z===m)break;I.tag===5&&Z!==null&&(I=Z,v?(z=ks(d,b),z!=null&&R.unshift(_l(d,z,I))):v||(z=ks(d,b),z!=null&&R.push(_l(d,z,I)))),d=d.return}R.length!==0&&l.push({event:c,listeners:R})}var T4=/\r\n?/g,M4=/\u0000|\uFFFD/g;function Gy(l){return(typeof l=="string"?l:""+l).replace(T4,`
`).replace(M4,"")}function Wc(l,c,d){if(c=Gy(c),Gy(l)!==c&&d)throw Error(t(425))}function $c(){}var gh=null,yh=null;function vh(l,c){return l==="textarea"||l==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var xh=typeof setTimeout=="function"?setTimeout:void 0,O4=typeof clearTimeout=="function"?clearTimeout:void 0,Yy=typeof Promise=="function"?Promise:void 0,P4=typeof queueMicrotask=="function"?queueMicrotask:typeof Yy<"u"?function(l){return Yy.resolve(null).then(l).catch(A4)}:xh;function A4(l){setTimeout(function(){throw l})}function wh(l,c){var d=c,m=0;do{var v=d.nextSibling;if(l.removeChild(d),v&&v.nodeType===8)if(d=v.data,d==="/$"){if(m===0){l.removeChild(v),Pl(c);return}m--}else d!=="$"&&d!=="$?"&&d!=="$!"||m++;d=v}while(d);Pl(c)}function Vi(l){for(;l!=null;l=l.nextSibling){var c=l.nodeType;if(c===1||c===3)break;if(c===8){if(c=l.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return l}function Xy(l){l=l.previousSibling;for(var c=0;l;){if(l.nodeType===8){var d=l.data;if(d==="$"||d==="$!"||d==="$?"){if(c===0)return l;c--}else d==="/$"&&c++}l=l.previousSibling}return null}var yo=Math.random().toString(36).slice(2),Fr="__reactFiber$"+yo,Vl="__reactProps$"+yo,fi="__reactContainer$"+yo,bh="__reactEvents$"+yo,N4="__reactListeners$"+yo,L4="__reactHandles$"+yo;function Es(l){var c=l[Fr];if(c)return c;for(var d=l.parentNode;d;){if(c=d[fi]||d[Fr]){if(d=c.alternate,c.child!==null||d!==null&&d.child!==null)for(l=Xy(l);l!==null;){if(d=l[Fr])return d;l=Xy(l)}return c}l=d,d=l.parentNode}return null}function Wl(l){return l=l[Fr]||l[fi],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function vo(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(t(33))}function Hc(l){return l[Vl]||null}var Sh=[],xo=-1;function Wi(l){return{current:l}}function wt(l){0>xo||(l.current=Sh[xo],Sh[xo]=null,xo--)}function mt(l,c){xo++,Sh[xo]=l.current,l.current=c}var $i={},fn=Wi($i),Cn=Wi(!1),Rs=$i;function wo(l,c){var d=l.type.contextTypes;if(!d)return $i;var m=l.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===c)return m.__reactInternalMemoizedMaskedChildContext;var v={},b;for(b in d)v[b]=c[b];return m&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=c,l.__reactInternalMemoizedMaskedChildContext=v),v}function En(l){return l=l.childContextTypes,l!=null}function Uc(){wt(Cn),wt(fn)}function Jy(l,c,d){if(fn.current!==$i)throw Error(t(168));mt(fn,c),mt(Cn,d)}function Zy(l,c,d){var m=l.stateNode;if(c=c.childContextTypes,typeof m.getChildContext!="function")return d;m=m.getChildContext();for(var v in m)if(!(v in c))throw Error(t(108,de(l)||"Unknown",v));return K({},d,m)}function qc(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||$i,Rs=fn.current,mt(fn,l),mt(Cn,Cn.current),!0}function ev(l,c,d){var m=l.stateNode;if(!m)throw Error(t(169));d?(l=Zy(l,c,Rs),m.__reactInternalMemoizedMergedChildContext=l,wt(Cn),wt(fn),mt(fn,l)):wt(Cn),mt(Cn,d)}var di=null,Kc=!1,kh=!1;function tv(l){di===null?di=[l]:di.push(l)}function D4(l){Kc=!0,tv(l)}function Hi(){if(!kh&&di!==null){kh=!0;var l=0,c=ut;try{var d=di;for(ut=1;l<d.length;l++){var m=d[l];do m=m(!0);while(m!==null)}di=null,Kc=!1}catch(v){throw di!==null&&(di=di.slice(l+1)),ry(Ud,Hi),v}finally{ut=c,kh=!1}}return null}var bo=[],So=0,Qc=null,Gc=0,Xn=[],Jn=0,Ts=null,hi=1,pi="";function Ms(l,c){bo[So++]=Gc,bo[So++]=Qc,Qc=l,Gc=c}function nv(l,c,d){Xn[Jn++]=hi,Xn[Jn++]=pi,Xn[Jn++]=Ts,Ts=l;var m=hi;l=pi;var v=32-mr(m)-1;m&=~(1<<v),d+=1;var b=32-mr(c)+v;if(30<b){var R=v-v%5;b=(m&(1<<R)-1).toString(32),m>>=R,v-=R,hi=1<<32-mr(c)+v|d<<v|m,pi=b+l}else hi=1<<b|d<<v|m,pi=l}function Ch(l){l.return!==null&&(Ms(l,1),nv(l,1,0))}function Eh(l){for(;l===Qc;)Qc=bo[--So],bo[So]=null,Gc=bo[--So],bo[So]=null;for(;l===Ts;)Ts=Xn[--Jn],Xn[Jn]=null,pi=Xn[--Jn],Xn[Jn]=null,hi=Xn[--Jn],Xn[Jn]=null}var Vn=null,Wn=null,St=!1,yr=null;function rv(l,c){var d=nr(5,null,null,0);d.elementType="DELETED",d.stateNode=c,d.return=l,c=l.deletions,c===null?(l.deletions=[d],l.flags|=16):c.push(d)}function iv(l,c){switch(l.tag){case 5:var d=l.type;return c=c.nodeType!==1||d.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(l.stateNode=c,Vn=l,Wn=Vi(c.firstChild),!0):!1;case 6:return c=l.pendingProps===""||c.nodeType!==3?null:c,c!==null?(l.stateNode=c,Vn=l,Wn=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(d=Ts!==null?{id:hi,overflow:pi}:null,l.memoizedState={dehydrated:c,treeContext:d,retryLane:1073741824},d=nr(18,null,null,0),d.stateNode=c,d.return=l,l.child=d,Vn=l,Wn=null,!0):!1;default:return!1}}function Rh(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Th(l){if(St){var c=Wn;if(c){var d=c;if(!iv(l,c)){if(Rh(l))throw Error(t(418));c=Vi(d.nextSibling);var m=Vn;c&&iv(l,c)?rv(m,d):(l.flags=l.flags&-4097|2,St=!1,Vn=l)}}else{if(Rh(l))throw Error(t(418));l.flags=l.flags&-4097|2,St=!1,Vn=l}}}function sv(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;Vn=l}function Yc(l){if(l!==Vn)return!1;if(!St)return sv(l),St=!0,!1;var c;if((c=l.tag!==3)&&!(c=l.tag!==5)&&(c=l.type,c=c!=="head"&&c!=="body"&&!vh(l.type,l.memoizedProps)),c&&(c=Wn)){if(Rh(l))throw ov(),Error(t(418));for(;c;)rv(l,c),c=Vi(c.nextSibling)}if(sv(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(t(317));e:{for(l=l.nextSibling,c=0;l;){if(l.nodeType===8){var d=l.data;if(d==="/$"){if(c===0){Wn=Vi(l.nextSibling);break e}c--}else d!=="$"&&d!=="$!"&&d!=="$?"||c++}l=l.nextSibling}Wn=null}}else Wn=Vn?Vi(l.stateNode.nextSibling):null;return!0}function ov(){for(var l=Wn;l;)l=Vi(l.nextSibling)}function ko(){Wn=Vn=null,St=!1}function Mh(l){yr===null?yr=[l]:yr.push(l)}var I4=P.ReactCurrentBatchConfig;function $l(l,c,d){if(l=d.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(t(309));var m=d.stateNode}if(!m)throw Error(t(147,l));var v=m,b=""+l;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===b?c.ref:(c=function(R){var I=v.refs;R===null?delete I[b]:I[b]=R},c._stringRef=b,c)}if(typeof l!="string")throw Error(t(284));if(!d._owner)throw Error(t(290,l))}return l}function Xc(l,c){throw l=Object.prototype.toString.call(c),Error(t(31,l==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":l))}function lv(l){var c=l._init;return c(l._payload)}function av(l){function c(G,V){if(l){var J=G.deletions;J===null?(G.deletions=[V],G.flags|=16):J.push(V)}}function d(G,V){if(!l)return null;for(;V!==null;)c(G,V),V=V.sibling;return null}function m(G,V){for(G=new Map;V!==null;)V.key!==null?G.set(V.key,V):G.set(V.index,V),V=V.sibling;return G}function v(G,V){return G=Ji(G,V),G.index=0,G.sibling=null,G}function b(G,V,J){return G.index=J,l?(J=G.alternate,J!==null?(J=J.index,J<V?(G.flags|=2,V):J):(G.flags|=2,V)):(G.flags|=1048576,V)}function R(G){return l&&G.alternate===null&&(G.flags|=2),G}function I(G,V,J,ue){return V===null||V.tag!==6?(V=xp(J,G.mode,ue),V.return=G,V):(V=v(V,J),V.return=G,V)}function z(G,V,J,ue){var Ae=J.type;return Ae===L?se(G,V,J.props.children,ue,J.key):V!==null&&(V.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===_&&lv(Ae)===V.type)?(ue=v(V,J.props),ue.ref=$l(G,V,J),ue.return=G,ue):(ue=bu(J.type,J.key,J.props,null,G.mode,ue),ue.ref=$l(G,V,J),ue.return=G,ue)}function Z(G,V,J,ue){return V===null||V.tag!==4||V.stateNode.containerInfo!==J.containerInfo||V.stateNode.implementation!==J.implementation?(V=wp(J,G.mode,ue),V.return=G,V):(V=v(V,J.children||[]),V.return=G,V)}function se(G,V,J,ue,Ae){return V===null||V.tag!==7?(V=js(J,G.mode,ue,Ae),V.return=G,V):(V=v(V,J),V.return=G,V)}function ae(G,V,J){if(typeof V=="string"&&V!==""||typeof V=="number")return V=xp(""+V,G.mode,J),V.return=G,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case O:return J=bu(V.type,V.key,V.props,null,G.mode,J),J.ref=$l(G,null,V),J.return=G,J;case N:return V=wp(V,G.mode,J),V.return=G,V;case _:var ue=V._init;return ae(G,ue(V._payload),J)}if(We(V)||B(V))return V=js(V,G.mode,J,null),V.return=G,V;Xc(G,V)}return null}function re(G,V,J,ue){var Ae=V!==null?V.key:null;if(typeof J=="string"&&J!==""||typeof J=="number")return Ae!==null?null:I(G,V,""+J,ue);if(typeof J=="object"&&J!==null){switch(J.$$typeof){case O:return J.key===Ae?z(G,V,J,ue):null;case N:return J.key===Ae?Z(G,V,J,ue):null;case _:return Ae=J._init,re(G,V,Ae(J._payload),ue)}if(We(J)||B(J))return Ae!==null?null:se(G,V,J,ue,null);Xc(G,J)}return null}function be(G,V,J,ue,Ae){if(typeof ue=="string"&&ue!==""||typeof ue=="number")return G=G.get(J)||null,I(V,G,""+ue,Ae);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case O:return G=G.get(ue.key===null?J:ue.key)||null,z(V,G,ue,Ae);case N:return G=G.get(ue.key===null?J:ue.key)||null,Z(V,G,ue,Ae);case _:var Ie=ue._init;return be(G,V,J,Ie(ue._payload),Ae)}if(We(ue)||B(ue))return G=G.get(J)||null,se(V,G,ue,Ae,null);Xc(V,ue)}return null}function Oe(G,V,J,ue){for(var Ae=null,Ie=null,je=V,_e=V=0,Zt=null;je!==null&&_e<J.length;_e++){je.index>_e?(Zt=je,je=null):Zt=je.sibling;var ot=re(G,je,J[_e],ue);if(ot===null){je===null&&(je=Zt);break}l&&je&&ot.alternate===null&&c(G,je),V=b(ot,V,_e),Ie===null?Ae=ot:Ie.sibling=ot,Ie=ot,je=Zt}if(_e===J.length)return d(G,je),St&&Ms(G,_e),Ae;if(je===null){for(;_e<J.length;_e++)je=ae(G,J[_e],ue),je!==null&&(V=b(je,V,_e),Ie===null?Ae=je:Ie.sibling=je,Ie=je);return St&&Ms(G,_e),Ae}for(je=m(G,je);_e<J.length;_e++)Zt=be(je,G,_e,J[_e],ue),Zt!==null&&(l&&Zt.alternate!==null&&je.delete(Zt.key===null?_e:Zt.key),V=b(Zt,V,_e),Ie===null?Ae=Zt:Ie.sibling=Zt,Ie=Zt);return l&&je.forEach(function(Zi){return c(G,Zi)}),St&&Ms(G,_e),Ae}function Pe(G,V,J,ue){var Ae=B(J);if(typeof Ae!="function")throw Error(t(150));if(J=Ae.call(J),J==null)throw Error(t(151));for(var Ie=Ae=null,je=V,_e=V=0,Zt=null,ot=J.next();je!==null&&!ot.done;_e++,ot=J.next()){je.index>_e?(Zt=je,je=null):Zt=je.sibling;var Zi=re(G,je,ot.value,ue);if(Zi===null){je===null&&(je=Zt);break}l&&je&&Zi.alternate===null&&c(G,je),V=b(Zi,V,_e),Ie===null?Ae=Zi:Ie.sibling=Zi,Ie=Zi,je=Zt}if(ot.done)return d(G,je),St&&Ms(G,_e),Ae;if(je===null){for(;!ot.done;_e++,ot=J.next())ot=ae(G,ot.value,ue),ot!==null&&(V=b(ot,V,_e),Ie===null?Ae=ot:Ie.sibling=ot,Ie=ot);return St&&Ms(G,_e),Ae}for(je=m(G,je);!ot.done;_e++,ot=J.next())ot=be(je,G,_e,ot.value,ue),ot!==null&&(l&&ot.alternate!==null&&je.delete(ot.key===null?_e:ot.key),V=b(ot,V,_e),Ie===null?Ae=ot:Ie.sibling=ot,Ie=ot);return l&&je.forEach(function(p3){return c(G,p3)}),St&&Ms(G,_e),Ae}function Dt(G,V,J,ue){if(typeof J=="object"&&J!==null&&J.type===L&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case O:e:{for(var Ae=J.key,Ie=V;Ie!==null;){if(Ie.key===Ae){if(Ae=J.type,Ae===L){if(Ie.tag===7){d(G,Ie.sibling),V=v(Ie,J.props.children),V.return=G,G=V;break e}}else if(Ie.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===_&&lv(Ae)===Ie.type){d(G,Ie.sibling),V=v(Ie,J.props),V.ref=$l(G,Ie,J),V.return=G,G=V;break e}d(G,Ie);break}else c(G,Ie);Ie=Ie.sibling}J.type===L?(V=js(J.props.children,G.mode,ue,J.key),V.return=G,G=V):(ue=bu(J.type,J.key,J.props,null,G.mode,ue),ue.ref=$l(G,V,J),ue.return=G,G=ue)}return R(G);case N:e:{for(Ie=J.key;V!==null;){if(V.key===Ie)if(V.tag===4&&V.stateNode.containerInfo===J.containerInfo&&V.stateNode.implementation===J.implementation){d(G,V.sibling),V=v(V,J.children||[]),V.return=G,G=V;break e}else{d(G,V);break}else c(G,V);V=V.sibling}V=wp(J,G.mode,ue),V.return=G,G=V}return R(G);case _:return Ie=J._init,Dt(G,V,Ie(J._payload),ue)}if(We(J))return Oe(G,V,J,ue);if(B(J))return Pe(G,V,J,ue);Xc(G,J)}return typeof J=="string"&&J!==""||typeof J=="number"?(J=""+J,V!==null&&V.tag===6?(d(G,V.sibling),V=v(V,J),V.return=G,G=V):(d(G,V),V=xp(J,G.mode,ue),V.return=G,G=V),R(G)):d(G,V)}return Dt}var Co=av(!0),cv=av(!1),Jc=Wi(null),Zc=null,Eo=null,Oh=null;function Ph(){Oh=Eo=Zc=null}function Ah(l){var c=Jc.current;wt(Jc),l._currentValue=c}function Nh(l,c,d){for(;l!==null;){var m=l.alternate;if((l.childLanes&c)!==c?(l.childLanes|=c,m!==null&&(m.childLanes|=c)):m!==null&&(m.childLanes&c)!==c&&(m.childLanes|=c),l===d)break;l=l.return}}function Ro(l,c){Zc=l,Oh=Eo=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&c)!==0&&(Rn=!0),l.firstContext=null)}function Zn(l){var c=l._currentValue;if(Oh!==l)if(l={context:l,memoizedValue:c,next:null},Eo===null){if(Zc===null)throw Error(t(308));Eo=l,Zc.dependencies={lanes:0,firstContext:l}}else Eo=Eo.next=l;return c}var Os=null;function Lh(l){Os===null?Os=[l]:Os.push(l)}function uv(l,c,d,m){var v=c.interleaved;return v===null?(d.next=d,Lh(c)):(d.next=v.next,v.next=d),c.interleaved=d,mi(l,m)}function mi(l,c){l.lanes|=c;var d=l.alternate;for(d!==null&&(d.lanes|=c),d=l,l=l.return;l!==null;)l.childLanes|=c,d=l.alternate,d!==null&&(d.childLanes|=c),d=l,l=l.return;return d.tag===3?d.stateNode:null}var Ui=!1;function Dh(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fv(l,c){l=l.updateQueue,c.updateQueue===l&&(c.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function gi(l,c){return{eventTime:l,lane:c,tag:0,payload:null,callback:null,next:null}}function qi(l,c,d){var m=l.updateQueue;if(m===null)return null;if(m=m.shared,(rt&2)!==0){var v=m.pending;return v===null?c.next=c:(c.next=v.next,v.next=c),m.pending=c,mi(l,d)}return v=m.interleaved,v===null?(c.next=c,Lh(m)):(c.next=v.next,v.next=c),m.interleaved=c,mi(l,d)}function eu(l,c,d){if(c=c.updateQueue,c!==null&&(c=c.shared,(d&4194240)!==0)){var m=c.lanes;m&=l.pendingLanes,d|=m,c.lanes=d,Qd(l,d)}}function dv(l,c){var d=l.updateQueue,m=l.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var v=null,b=null;if(d=d.firstBaseUpdate,d!==null){do{var R={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};b===null?v=b=R:b=b.next=R,d=d.next}while(d!==null);b===null?v=b=c:b=b.next=c}else v=b=c;d={baseState:m.baseState,firstBaseUpdate:v,lastBaseUpdate:b,shared:m.shared,effects:m.effects},l.updateQueue=d;return}l=d.lastBaseUpdate,l===null?d.firstBaseUpdate=c:l.next=c,d.lastBaseUpdate=c}function tu(l,c,d,m){var v=l.updateQueue;Ui=!1;var b=v.firstBaseUpdate,R=v.lastBaseUpdate,I=v.shared.pending;if(I!==null){v.shared.pending=null;var z=I,Z=z.next;z.next=null,R===null?b=Z:R.next=Z,R=z;var se=l.alternate;se!==null&&(se=se.updateQueue,I=se.lastBaseUpdate,I!==R&&(I===null?se.firstBaseUpdate=Z:I.next=Z,se.lastBaseUpdate=z))}if(b!==null){var ae=v.baseState;R=0,se=Z=z=null,I=b;do{var re=I.lane,be=I.eventTime;if((m&re)===re){se!==null&&(se=se.next={eventTime:be,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var Oe=l,Pe=I;switch(re=c,be=d,Pe.tag){case 1:if(Oe=Pe.payload,typeof Oe=="function"){ae=Oe.call(be,ae,re);break e}ae=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Pe.payload,re=typeof Oe=="function"?Oe.call(be,ae,re):Oe,re==null)break e;ae=K({},ae,re);break e;case 2:Ui=!0}}I.callback!==null&&I.lane!==0&&(l.flags|=64,re=v.effects,re===null?v.effects=[I]:re.push(I))}else be={eventTime:be,lane:re,tag:I.tag,payload:I.payload,callback:I.callback,next:null},se===null?(Z=se=be,z=ae):se=se.next=be,R|=re;if(I=I.next,I===null){if(I=v.shared.pending,I===null)break;re=I,I=re.next,re.next=null,v.lastBaseUpdate=re,v.shared.pending=null}}while(!0);if(se===null&&(z=ae),v.baseState=z,v.firstBaseUpdate=Z,v.lastBaseUpdate=se,c=v.shared.interleaved,c!==null){v=c;do R|=v.lane,v=v.next;while(v!==c)}else b===null&&(v.shared.lanes=0);Ns|=R,l.lanes=R,l.memoizedState=ae}}function hv(l,c,d){if(l=c.effects,c.effects=null,l!==null)for(c=0;c<l.length;c++){var m=l[c],v=m.callback;if(v!==null){if(m.callback=null,m=d,typeof v!="function")throw Error(t(191,v));v.call(m)}}}var Hl={},zr=Wi(Hl),Ul=Wi(Hl),ql=Wi(Hl);function Ps(l){if(l===Hl)throw Error(t(174));return l}function Ih(l,c){switch(mt(ql,c),mt(Ul,l),mt(zr,Hl),l=c.nodeType,l){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:it(null,"");break;default:l=l===8?c.parentNode:c,c=l.namespaceURI||null,l=l.tagName,c=it(c,l)}wt(zr),mt(zr,c)}function To(){wt(zr),wt(Ul),wt(ql)}function pv(l){Ps(ql.current);var c=Ps(zr.current),d=it(c,l.type);c!==d&&(mt(Ul,l),mt(zr,d))}function jh(l){Ul.current===l&&(wt(zr),wt(Ul))}var Rt=Wi(0);function nu(l){for(var c=l;c!==null;){if(c.tag===13){var d=c.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var Bh=[];function Fh(){for(var l=0;l<Bh.length;l++)Bh[l]._workInProgressVersionPrimary=null;Bh.length=0}var ru=P.ReactCurrentDispatcher,zh=P.ReactCurrentBatchConfig,As=0,Tt=null,Ht=null,Xt=null,iu=!1,Kl=!1,Ql=0,j4=0;function dn(){throw Error(t(321))}function _h(l,c){if(c===null)return!1;for(var d=0;d<c.length&&d<l.length;d++)if(!gr(l[d],c[d]))return!1;return!0}function Vh(l,c,d,m,v,b){if(As=b,Tt=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,ru.current=l===null||l.memoizedState===null?_4:V4,l=d(m,v),Kl){b=0;do{if(Kl=!1,Ql=0,25<=b)throw Error(t(301));b+=1,Xt=Ht=null,c.updateQueue=null,ru.current=W4,l=d(m,v)}while(Kl)}if(ru.current=lu,c=Ht!==null&&Ht.next!==null,As=0,Xt=Ht=Tt=null,iu=!1,c)throw Error(t(300));return l}function Wh(){var l=Ql!==0;return Ql=0,l}function _r(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xt===null?Tt.memoizedState=Xt=l:Xt=Xt.next=l,Xt}function er(){if(Ht===null){var l=Tt.alternate;l=l!==null?l.memoizedState:null}else l=Ht.next;var c=Xt===null?Tt.memoizedState:Xt.next;if(c!==null)Xt=c,Ht=l;else{if(l===null)throw Error(t(310));Ht=l,l={memoizedState:Ht.memoizedState,baseState:Ht.baseState,baseQueue:Ht.baseQueue,queue:Ht.queue,next:null},Xt===null?Tt.memoizedState=Xt=l:Xt=Xt.next=l}return Xt}function Gl(l,c){return typeof c=="function"?c(l):c}function $h(l){var c=er(),d=c.queue;if(d===null)throw Error(t(311));d.lastRenderedReducer=l;var m=Ht,v=m.baseQueue,b=d.pending;if(b!==null){if(v!==null){var R=v.next;v.next=b.next,b.next=R}m.baseQueue=v=b,d.pending=null}if(v!==null){b=v.next,m=m.baseState;var I=R=null,z=null,Z=b;do{var se=Z.lane;if((As&se)===se)z!==null&&(z=z.next={lane:0,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),m=Z.hasEagerState?Z.eagerState:l(m,Z.action);else{var ae={lane:se,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null};z===null?(I=z=ae,R=m):z=z.next=ae,Tt.lanes|=se,Ns|=se}Z=Z.next}while(Z!==null&&Z!==b);z===null?R=m:z.next=I,gr(m,c.memoizedState)||(Rn=!0),c.memoizedState=m,c.baseState=R,c.baseQueue=z,d.lastRenderedState=m}if(l=d.interleaved,l!==null){v=l;do b=v.lane,Tt.lanes|=b,Ns|=b,v=v.next;while(v!==l)}else v===null&&(d.lanes=0);return[c.memoizedState,d.dispatch]}function Hh(l){var c=er(),d=c.queue;if(d===null)throw Error(t(311));d.lastRenderedReducer=l;var m=d.dispatch,v=d.pending,b=c.memoizedState;if(v!==null){d.pending=null;var R=v=v.next;do b=l(b,R.action),R=R.next;while(R!==v);gr(b,c.memoizedState)||(Rn=!0),c.memoizedState=b,c.baseQueue===null&&(c.baseState=b),d.lastRenderedState=b}return[b,m]}function mv(){}function gv(l,c){var d=Tt,m=er(),v=c(),b=!gr(m.memoizedState,v);if(b&&(m.memoizedState=v,Rn=!0),m=m.queue,Uh(xv.bind(null,d,m,l),[l]),m.getSnapshot!==c||b||Xt!==null&&Xt.memoizedState.tag&1){if(d.flags|=2048,Yl(9,vv.bind(null,d,m,v,c),void 0,null),Jt===null)throw Error(t(349));(As&30)!==0||yv(d,c,v)}return v}function yv(l,c,d){l.flags|=16384,l={getSnapshot:c,value:d},c=Tt.updateQueue,c===null?(c={lastEffect:null,stores:null},Tt.updateQueue=c,c.stores=[l]):(d=c.stores,d===null?c.stores=[l]:d.push(l))}function vv(l,c,d,m){c.value=d,c.getSnapshot=m,wv(c)&&bv(l)}function xv(l,c,d){return d(function(){wv(c)&&bv(l)})}function wv(l){var c=l.getSnapshot;l=l.value;try{var d=c();return!gr(l,d)}catch{return!0}}function bv(l){var c=mi(l,1);c!==null&&br(c,l,1,-1)}function Sv(l){var c=_r();return typeof l=="function"&&(l=l()),c.memoizedState=c.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Gl,lastRenderedState:l},c.queue=l,l=l.dispatch=z4.bind(null,Tt,l),[c.memoizedState,l]}function Yl(l,c,d,m){return l={tag:l,create:c,destroy:d,deps:m,next:null},c=Tt.updateQueue,c===null?(c={lastEffect:null,stores:null},Tt.updateQueue=c,c.lastEffect=l.next=l):(d=c.lastEffect,d===null?c.lastEffect=l.next=l:(m=d.next,d.next=l,l.next=m,c.lastEffect=l)),l}function kv(){return er().memoizedState}function su(l,c,d,m){var v=_r();Tt.flags|=l,v.memoizedState=Yl(1|c,d,void 0,m===void 0?null:m)}function ou(l,c,d,m){var v=er();m=m===void 0?null:m;var b=void 0;if(Ht!==null){var R=Ht.memoizedState;if(b=R.destroy,m!==null&&_h(m,R.deps)){v.memoizedState=Yl(c,d,b,m);return}}Tt.flags|=l,v.memoizedState=Yl(1|c,d,b,m)}function Cv(l,c){return su(8390656,8,l,c)}function Uh(l,c){return ou(2048,8,l,c)}function Ev(l,c){return ou(4,2,l,c)}function Rv(l,c){return ou(4,4,l,c)}function Tv(l,c){if(typeof c=="function")return l=l(),c(l),function(){c(null)};if(c!=null)return l=l(),c.current=l,function(){c.current=null}}function Mv(l,c,d){return d=d!=null?d.concat([l]):null,ou(4,4,Tv.bind(null,c,l),d)}function qh(){}function Ov(l,c){var d=er();c=c===void 0?null:c;var m=d.memoizedState;return m!==null&&c!==null&&_h(c,m[1])?m[0]:(d.memoizedState=[l,c],l)}function Pv(l,c){var d=er();c=c===void 0?null:c;var m=d.memoizedState;return m!==null&&c!==null&&_h(c,m[1])?m[0]:(l=l(),d.memoizedState=[l,c],l)}function Av(l,c,d){return(As&21)===0?(l.baseState&&(l.baseState=!1,Rn=!0),l.memoizedState=d):(gr(d,c)||(d=ly(),Tt.lanes|=d,Ns|=d,l.baseState=!0),c)}function B4(l,c){var d=ut;ut=d!==0&&4>d?d:4,l(!0);var m=zh.transition;zh.transition={};try{l(!1),c()}finally{ut=d,zh.transition=m}}function Nv(){return er().memoizedState}function F4(l,c,d){var m=Yi(l);if(d={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null},Lv(l))Dv(c,d);else if(d=uv(l,c,d,m),d!==null){var v=xn();br(d,l,m,v),Iv(d,c,m)}}function z4(l,c,d){var m=Yi(l),v={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null};if(Lv(l))Dv(c,v);else{var b=l.alternate;if(l.lanes===0&&(b===null||b.lanes===0)&&(b=c.lastRenderedReducer,b!==null))try{var R=c.lastRenderedState,I=b(R,d);if(v.hasEagerState=!0,v.eagerState=I,gr(I,R)){var z=c.interleaved;z===null?(v.next=v,Lh(c)):(v.next=z.next,z.next=v),c.interleaved=v;return}}catch{}finally{}d=uv(l,c,v,m),d!==null&&(v=xn(),br(d,l,m,v),Iv(d,c,m))}}function Lv(l){var c=l.alternate;return l===Tt||c!==null&&c===Tt}function Dv(l,c){Kl=iu=!0;var d=l.pending;d===null?c.next=c:(c.next=d.next,d.next=c),l.pending=c}function Iv(l,c,d){if((d&4194240)!==0){var m=c.lanes;m&=l.pendingLanes,d|=m,c.lanes=d,Qd(l,d)}}var lu={readContext:Zn,useCallback:dn,useContext:dn,useEffect:dn,useImperativeHandle:dn,useInsertionEffect:dn,useLayoutEffect:dn,useMemo:dn,useReducer:dn,useRef:dn,useState:dn,useDebugValue:dn,useDeferredValue:dn,useTransition:dn,useMutableSource:dn,useSyncExternalStore:dn,useId:dn,unstable_isNewReconciler:!1},_4={readContext:Zn,useCallback:function(l,c){return _r().memoizedState=[l,c===void 0?null:c],l},useContext:Zn,useEffect:Cv,useImperativeHandle:function(l,c,d){return d=d!=null?d.concat([l]):null,su(4194308,4,Tv.bind(null,c,l),d)},useLayoutEffect:function(l,c){return su(4194308,4,l,c)},useInsertionEffect:function(l,c){return su(4,2,l,c)},useMemo:function(l,c){var d=_r();return c=c===void 0?null:c,l=l(),d.memoizedState=[l,c],l},useReducer:function(l,c,d){var m=_r();return c=d!==void 0?d(c):c,m.memoizedState=m.baseState=c,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:c},m.queue=l,l=l.dispatch=F4.bind(null,Tt,l),[m.memoizedState,l]},useRef:function(l){var c=_r();return l={current:l},c.memoizedState=l},useState:Sv,useDebugValue:qh,useDeferredValue:function(l){return _r().memoizedState=l},useTransition:function(){var l=Sv(!1),c=l[0];return l=B4.bind(null,l[1]),_r().memoizedState=l,[c,l]},useMutableSource:function(){},useSyncExternalStore:function(l,c,d){var m=Tt,v=_r();if(St){if(d===void 0)throw Error(t(407));d=d()}else{if(d=c(),Jt===null)throw Error(t(349));(As&30)!==0||yv(m,c,d)}v.memoizedState=d;var b={value:d,getSnapshot:c};return v.queue=b,Cv(xv.bind(null,m,b,l),[l]),m.flags|=2048,Yl(9,vv.bind(null,m,b,d,c),void 0,null),d},useId:function(){var l=_r(),c=Jt.identifierPrefix;if(St){var d=pi,m=hi;d=(m&~(1<<32-mr(m)-1)).toString(32)+d,c=":"+c+"R"+d,d=Ql++,0<d&&(c+="H"+d.toString(32)),c+=":"}else d=j4++,c=":"+c+"r"+d.toString(32)+":";return l.memoizedState=c},unstable_isNewReconciler:!1},V4={readContext:Zn,useCallback:Ov,useContext:Zn,useEffect:Uh,useImperativeHandle:Mv,useInsertionEffect:Ev,useLayoutEffect:Rv,useMemo:Pv,useReducer:$h,useRef:kv,useState:function(){return $h(Gl)},useDebugValue:qh,useDeferredValue:function(l){var c=er();return Av(c,Ht.memoizedState,l)},useTransition:function(){var l=$h(Gl)[0],c=er().memoizedState;return[l,c]},useMutableSource:mv,useSyncExternalStore:gv,useId:Nv,unstable_isNewReconciler:!1},W4={readContext:Zn,useCallback:Ov,useContext:Zn,useEffect:Uh,useImperativeHandle:Mv,useInsertionEffect:Ev,useLayoutEffect:Rv,useMemo:Pv,useReducer:Hh,useRef:kv,useState:function(){return Hh(Gl)},useDebugValue:qh,useDeferredValue:function(l){var c=er();return Ht===null?c.memoizedState=l:Av(c,Ht.memoizedState,l)},useTransition:function(){var l=Hh(Gl)[0],c=er().memoizedState;return[l,c]},useMutableSource:mv,useSyncExternalStore:gv,useId:Nv,unstable_isNewReconciler:!1};function vr(l,c){if(l&&l.defaultProps){c=K({},c),l=l.defaultProps;for(var d in l)c[d]===void 0&&(c[d]=l[d]);return c}return c}function Kh(l,c,d,m){c=l.memoizedState,d=d(m,c),d=d==null?c:K({},c,d),l.memoizedState=d,l.lanes===0&&(l.updateQueue.baseState=d)}var au={isMounted:function(l){return(l=l._reactInternals)?jr(l)===l:!1},enqueueSetState:function(l,c,d){l=l._reactInternals;var m=xn(),v=Yi(l),b=gi(m,v);b.payload=c,d!=null&&(b.callback=d),c=qi(l,b,v),c!==null&&(br(c,l,v,m),eu(c,l,v))},enqueueReplaceState:function(l,c,d){l=l._reactInternals;var m=xn(),v=Yi(l),b=gi(m,v);b.tag=1,b.payload=c,d!=null&&(b.callback=d),c=qi(l,b,v),c!==null&&(br(c,l,v,m),eu(c,l,v))},enqueueForceUpdate:function(l,c){l=l._reactInternals;var d=xn(),m=Yi(l),v=gi(d,m);v.tag=2,c!=null&&(v.callback=c),c=qi(l,v,m),c!==null&&(br(c,l,m,d),eu(c,l,m))}};function jv(l,c,d,m,v,b,R){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(m,b,R):c.prototype&&c.prototype.isPureReactComponent?!jl(d,m)||!jl(v,b):!0}function Bv(l,c,d){var m=!1,v=$i,b=c.contextType;return typeof b=="object"&&b!==null?b=Zn(b):(v=En(c)?Rs:fn.current,m=c.contextTypes,b=(m=m!=null)?wo(l,v):$i),c=new c(d,b),l.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=au,l.stateNode=c,c._reactInternals=l,m&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=v,l.__reactInternalMemoizedMaskedChildContext=b),c}function Fv(l,c,d,m){l=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(d,m),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(d,m),c.state!==l&&au.enqueueReplaceState(c,c.state,null)}function Qh(l,c,d,m){var v=l.stateNode;v.props=d,v.state=l.memoizedState,v.refs={},Dh(l);var b=c.contextType;typeof b=="object"&&b!==null?v.context=Zn(b):(b=En(c)?Rs:fn.current,v.context=wo(l,b)),v.state=l.memoizedState,b=c.getDerivedStateFromProps,typeof b=="function"&&(Kh(l,c,b,d),v.state=l.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(c=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),c!==v.state&&au.enqueueReplaceState(v,v.state,null),tu(l,d,v,m),v.state=l.memoizedState),typeof v.componentDidMount=="function"&&(l.flags|=4194308)}function Mo(l,c){try{var d="",m=c;do d+=me(m),m=m.return;while(m);var v=d}catch(b){v=`
Error generating stack: `+b.message+`
`+b.stack}return{value:l,source:c,stack:v,digest:null}}function Gh(l,c,d){return{value:l,source:null,stack:d??null,digest:c??null}}function Yh(l,c){try{console.error(c.value)}catch(d){setTimeout(function(){throw d})}}var $4=typeof WeakMap=="function"?WeakMap:Map;function zv(l,c,d){d=gi(-1,d),d.tag=3,d.payload={element:null};var m=c.value;return d.callback=function(){mu||(mu=!0,fp=m),Yh(l,c)},d}function _v(l,c,d){d=gi(-1,d),d.tag=3;var m=l.type.getDerivedStateFromError;if(typeof m=="function"){var v=c.value;d.payload=function(){return m(v)},d.callback=function(){Yh(l,c)}}var b=l.stateNode;return b!==null&&typeof b.componentDidCatch=="function"&&(d.callback=function(){Yh(l,c),typeof m!="function"&&(Qi===null?Qi=new Set([this]):Qi.add(this));var R=c.stack;this.componentDidCatch(c.value,{componentStack:R!==null?R:""})}),d}function Vv(l,c,d){var m=l.pingCache;if(m===null){m=l.pingCache=new $4;var v=new Set;m.set(c,v)}else v=m.get(c),v===void 0&&(v=new Set,m.set(c,v));v.has(d)||(v.add(d),l=r3.bind(null,l,c,d),c.then(l,l))}function Wv(l){do{var c;if((c=l.tag===13)&&(c=l.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return l;l=l.return}while(l!==null);return null}function $v(l,c,d,m,v){return(l.mode&1)===0?(l===c?l.flags|=65536:(l.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(c=gi(-1,1),c.tag=2,qi(d,c,1))),d.lanes|=1),l):(l.flags|=65536,l.lanes=v,l)}var H4=P.ReactCurrentOwner,Rn=!1;function vn(l,c,d,m){c.child=l===null?cv(c,null,d,m):Co(c,l.child,d,m)}function Hv(l,c,d,m,v){d=d.render;var b=c.ref;return Ro(c,v),m=Vh(l,c,d,m,b,v),d=Wh(),l!==null&&!Rn?(c.updateQueue=l.updateQueue,c.flags&=-2053,l.lanes&=~v,yi(l,c,v)):(St&&d&&Ch(c),c.flags|=1,vn(l,c,m,v),c.child)}function Uv(l,c,d,m,v){if(l===null){var b=d.type;return typeof b=="function"&&!vp(b)&&b.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(c.tag=15,c.type=b,qv(l,c,b,m,v)):(l=bu(d.type,null,m,c,c.mode,v),l.ref=c.ref,l.return=c,c.child=l)}if(b=l.child,(l.lanes&v)===0){var R=b.memoizedProps;if(d=d.compare,d=d!==null?d:jl,d(R,m)&&l.ref===c.ref)return yi(l,c,v)}return c.flags|=1,l=Ji(b,m),l.ref=c.ref,l.return=c,c.child=l}function qv(l,c,d,m,v){if(l!==null){var b=l.memoizedProps;if(jl(b,m)&&l.ref===c.ref)if(Rn=!1,c.pendingProps=m=b,(l.lanes&v)!==0)(l.flags&131072)!==0&&(Rn=!0);else return c.lanes=l.lanes,yi(l,c,v)}return Xh(l,c,d,m,v)}function Kv(l,c,d){var m=c.pendingProps,v=m.children,b=l!==null?l.memoizedState:null;if(m.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},mt(Po,$n),$n|=d;else{if((d&1073741824)===0)return l=b!==null?b.baseLanes|d:d,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:l,cachePool:null,transitions:null},c.updateQueue=null,mt(Po,$n),$n|=l,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=b!==null?b.baseLanes:d,mt(Po,$n),$n|=m}else b!==null?(m=b.baseLanes|d,c.memoizedState=null):m=d,mt(Po,$n),$n|=m;return vn(l,c,v,d),c.child}function Qv(l,c){var d=c.ref;(l===null&&d!==null||l!==null&&l.ref!==d)&&(c.flags|=512,c.flags|=2097152)}function Xh(l,c,d,m,v){var b=En(d)?Rs:fn.current;return b=wo(c,b),Ro(c,v),d=Vh(l,c,d,m,b,v),m=Wh(),l!==null&&!Rn?(c.updateQueue=l.updateQueue,c.flags&=-2053,l.lanes&=~v,yi(l,c,v)):(St&&m&&Ch(c),c.flags|=1,vn(l,c,d,v),c.child)}function Gv(l,c,d,m,v){if(En(d)){var b=!0;qc(c)}else b=!1;if(Ro(c,v),c.stateNode===null)uu(l,c),Bv(c,d,m),Qh(c,d,m,v),m=!0;else if(l===null){var R=c.stateNode,I=c.memoizedProps;R.props=I;var z=R.context,Z=d.contextType;typeof Z=="object"&&Z!==null?Z=Zn(Z):(Z=En(d)?Rs:fn.current,Z=wo(c,Z));var se=d.getDerivedStateFromProps,ae=typeof se=="function"||typeof R.getSnapshotBeforeUpdate=="function";ae||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(I!==m||z!==Z)&&Fv(c,R,m,Z),Ui=!1;var re=c.memoizedState;R.state=re,tu(c,m,R,v),z=c.memoizedState,I!==m||re!==z||Cn.current||Ui?(typeof se=="function"&&(Kh(c,d,se,m),z=c.memoizedState),(I=Ui||jv(c,d,I,m,re,z,Z))?(ae||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(c.flags|=4194308)):(typeof R.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=m,c.memoizedState=z),R.props=m,R.state=z,R.context=Z,m=I):(typeof R.componentDidMount=="function"&&(c.flags|=4194308),m=!1)}else{R=c.stateNode,fv(l,c),I=c.memoizedProps,Z=c.type===c.elementType?I:vr(c.type,I),R.props=Z,ae=c.pendingProps,re=R.context,z=d.contextType,typeof z=="object"&&z!==null?z=Zn(z):(z=En(d)?Rs:fn.current,z=wo(c,z));var be=d.getDerivedStateFromProps;(se=typeof be=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(I!==ae||re!==z)&&Fv(c,R,m,z),Ui=!1,re=c.memoizedState,R.state=re,tu(c,m,R,v);var Oe=c.memoizedState;I!==ae||re!==Oe||Cn.current||Ui?(typeof be=="function"&&(Kh(c,d,be,m),Oe=c.memoizedState),(Z=Ui||jv(c,d,Z,m,re,Oe,z)||!1)?(se||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(m,Oe,z),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(m,Oe,z)),typeof R.componentDidUpdate=="function"&&(c.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof R.componentDidUpdate!="function"||I===l.memoizedProps&&re===l.memoizedState||(c.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||I===l.memoizedProps&&re===l.memoizedState||(c.flags|=1024),c.memoizedProps=m,c.memoizedState=Oe),R.props=m,R.state=Oe,R.context=z,m=Z):(typeof R.componentDidUpdate!="function"||I===l.memoizedProps&&re===l.memoizedState||(c.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||I===l.memoizedProps&&re===l.memoizedState||(c.flags|=1024),m=!1)}return Jh(l,c,d,m,b,v)}function Jh(l,c,d,m,v,b){Qv(l,c);var R=(c.flags&128)!==0;if(!m&&!R)return v&&ev(c,d,!1),yi(l,c,b);m=c.stateNode,H4.current=c;var I=R&&typeof d.getDerivedStateFromError!="function"?null:m.render();return c.flags|=1,l!==null&&R?(c.child=Co(c,l.child,null,b),c.child=Co(c,null,I,b)):vn(l,c,I,b),c.memoizedState=m.state,v&&ev(c,d,!0),c.child}function Yv(l){var c=l.stateNode;c.pendingContext?Jy(l,c.pendingContext,c.pendingContext!==c.context):c.context&&Jy(l,c.context,!1),Ih(l,c.containerInfo)}function Xv(l,c,d,m,v){return ko(),Mh(v),c.flags|=256,vn(l,c,d,m),c.child}var Zh={dehydrated:null,treeContext:null,retryLane:0};function ep(l){return{baseLanes:l,cachePool:null,transitions:null}}function Jv(l,c,d){var m=c.pendingProps,v=Rt.current,b=!1,R=(c.flags&128)!==0,I;if((I=R)||(I=l!==null&&l.memoizedState===null?!1:(v&2)!==0),I?(b=!0,c.flags&=-129):(l===null||l.memoizedState!==null)&&(v|=1),mt(Rt,v&1),l===null)return Th(c),l=c.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((c.mode&1)===0?c.lanes=1:l.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(R=m.children,l=m.fallback,b?(m=c.mode,b=c.child,R={mode:"hidden",children:R},(m&1)===0&&b!==null?(b.childLanes=0,b.pendingProps=R):b=Su(R,m,0,null),l=js(l,m,d,null),b.return=c,l.return=c,b.sibling=l,c.child=b,c.child.memoizedState=ep(d),c.memoizedState=Zh,l):tp(c,R));if(v=l.memoizedState,v!==null&&(I=v.dehydrated,I!==null))return U4(l,c,R,m,I,v,d);if(b){b=m.fallback,R=c.mode,v=l.child,I=v.sibling;var z={mode:"hidden",children:m.children};return(R&1)===0&&c.child!==v?(m=c.child,m.childLanes=0,m.pendingProps=z,c.deletions=null):(m=Ji(v,z),m.subtreeFlags=v.subtreeFlags&14680064),I!==null?b=Ji(I,b):(b=js(b,R,d,null),b.flags|=2),b.return=c,m.return=c,m.sibling=b,c.child=m,m=b,b=c.child,R=l.child.memoizedState,R=R===null?ep(d):{baseLanes:R.baseLanes|d,cachePool:null,transitions:R.transitions},b.memoizedState=R,b.childLanes=l.childLanes&~d,c.memoizedState=Zh,m}return b=l.child,l=b.sibling,m=Ji(b,{mode:"visible",children:m.children}),(c.mode&1)===0&&(m.lanes=d),m.return=c,m.sibling=null,l!==null&&(d=c.deletions,d===null?(c.deletions=[l],c.flags|=16):d.push(l)),c.child=m,c.memoizedState=null,m}function tp(l,c){return c=Su({mode:"visible",children:c},l.mode,0,null),c.return=l,l.child=c}function cu(l,c,d,m){return m!==null&&Mh(m),Co(c,l.child,null,d),l=tp(c,c.pendingProps.children),l.flags|=2,c.memoizedState=null,l}function U4(l,c,d,m,v,b,R){if(d)return c.flags&256?(c.flags&=-257,m=Gh(Error(t(422))),cu(l,c,R,m)):c.memoizedState!==null?(c.child=l.child,c.flags|=128,null):(b=m.fallback,v=c.mode,m=Su({mode:"visible",children:m.children},v,0,null),b=js(b,v,R,null),b.flags|=2,m.return=c,b.return=c,m.sibling=b,c.child=m,(c.mode&1)!==0&&Co(c,l.child,null,R),c.child.memoizedState=ep(R),c.memoizedState=Zh,b);if((c.mode&1)===0)return cu(l,c,R,null);if(v.data==="$!"){if(m=v.nextSibling&&v.nextSibling.dataset,m)var I=m.dgst;return m=I,b=Error(t(419)),m=Gh(b,m,void 0),cu(l,c,R,m)}if(I=(R&l.childLanes)!==0,Rn||I){if(m=Jt,m!==null){switch(R&-R){case 4:v=2;break;case 16:v=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:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(m.suspendedLanes|R))!==0?0:v,v!==0&&v!==b.retryLane&&(b.retryLane=v,mi(l,v),br(m,l,v,-1))}return yp(),m=Gh(Error(t(421))),cu(l,c,R,m)}return v.data==="$?"?(c.flags|=128,c.child=l.child,c=i3.bind(null,l),v._reactRetry=c,null):(l=b.treeContext,Wn=Vi(v.nextSibling),Vn=c,St=!0,yr=null,l!==null&&(Xn[Jn++]=hi,Xn[Jn++]=pi,Xn[Jn++]=Ts,hi=l.id,pi=l.overflow,Ts=c),c=tp(c,m.children),c.flags|=4096,c)}function Zv(l,c,d){l.lanes|=c;var m=l.alternate;m!==null&&(m.lanes|=c),Nh(l.return,c,d)}function np(l,c,d,m,v){var b=l.memoizedState;b===null?l.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:v}:(b.isBackwards=c,b.rendering=null,b.renderingStartTime=0,b.last=m,b.tail=d,b.tailMode=v)}function ex(l,c,d){var m=c.pendingProps,v=m.revealOrder,b=m.tail;if(vn(l,c,m.children,d),m=Rt.current,(m&2)!==0)m=m&1|2,c.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=c.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&Zv(l,d,c);else if(l.tag===19)Zv(l,d,c);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===c)break e;for(;l.sibling===null;){if(l.return===null||l.return===c)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}m&=1}if(mt(Rt,m),(c.mode&1)===0)c.memoizedState=null;else switch(v){case"forwards":for(d=c.child,v=null;d!==null;)l=d.alternate,l!==null&&nu(l)===null&&(v=d),d=d.sibling;d=v,d===null?(v=c.child,c.child=null):(v=d.sibling,d.sibling=null),np(c,!1,v,d,b);break;case"backwards":for(d=null,v=c.child,c.child=null;v!==null;){if(l=v.alternate,l!==null&&nu(l)===null){c.child=v;break}l=v.sibling,v.sibling=d,d=v,v=l}np(c,!0,d,null,b);break;case"together":np(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function uu(l,c){(c.mode&1)===0&&l!==null&&(l.alternate=null,c.alternate=null,c.flags|=2)}function yi(l,c,d){if(l!==null&&(c.dependencies=l.dependencies),Ns|=c.lanes,(d&c.childLanes)===0)return null;if(l!==null&&c.child!==l.child)throw Error(t(153));if(c.child!==null){for(l=c.child,d=Ji(l,l.pendingProps),c.child=d,d.return=c;l.sibling!==null;)l=l.sibling,d=d.sibling=Ji(l,l.pendingProps),d.return=c;d.sibling=null}return c.child}function q4(l,c,d){switch(c.tag){case 3:Yv(c),ko();break;case 5:pv(c);break;case 1:En(c.type)&&qc(c);break;case 4:Ih(c,c.stateNode.containerInfo);break;case 10:var m=c.type._context,v=c.memoizedProps.value;mt(Jc,m._currentValue),m._currentValue=v;break;case 13:if(m=c.memoizedState,m!==null)return m.dehydrated!==null?(mt(Rt,Rt.current&1),c.flags|=128,null):(d&c.child.childLanes)!==0?Jv(l,c,d):(mt(Rt,Rt.current&1),l=yi(l,c,d),l!==null?l.sibling:null);mt(Rt,Rt.current&1);break;case 19:if(m=(d&c.childLanes)!==0,(l.flags&128)!==0){if(m)return ex(l,c,d);c.flags|=128}if(v=c.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),mt(Rt,Rt.current),m)break;return null;case 22:case 23:return c.lanes=0,Kv(l,c,d)}return yi(l,c,d)}var tx,rp,nx,rx;tx=function(l,c){for(var d=c.child;d!==null;){if(d.tag===5||d.tag===6)l.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===c)break;for(;d.sibling===null;){if(d.return===null||d.return===c)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},rp=function(){},nx=function(l,c,d,m){var v=l.memoizedProps;if(v!==m){l=c.stateNode,Ps(zr.current);var b=null;switch(d){case"input":v=at(l,v),m=at(l,m),b=[];break;case"select":v=K({},v,{value:void 0}),m=K({},m,{value:void 0}),b=[];break;case"textarea":v=xe(l,v),m=xe(l,m),b=[];break;default:typeof v.onClick!="function"&&typeof m.onClick=="function"&&(l.onclick=$c)}Gn(d,m);var R;d=null;for(Z in v)if(!m.hasOwnProperty(Z)&&v.hasOwnProperty(Z)&&v[Z]!=null)if(Z==="style"){var I=v[Z];for(R in I)I.hasOwnProperty(R)&&(d||(d={}),d[R]="")}else Z!=="dangerouslySetInnerHTML"&&Z!=="children"&&Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&Z!=="autoFocus"&&(i.hasOwnProperty(Z)?b||(b=[]):(b=b||[]).push(Z,null));for(Z in m){var z=m[Z];if(I=v!=null?v[Z]:void 0,m.hasOwnProperty(Z)&&z!==I&&(z!=null||I!=null))if(Z==="style")if(I){for(R in I)!I.hasOwnProperty(R)||z&&z.hasOwnProperty(R)||(d||(d={}),d[R]="");for(R in z)z.hasOwnProperty(R)&&I[R]!==z[R]&&(d||(d={}),d[R]=z[R])}else d||(b||(b=[]),b.push(Z,d)),d=z;else Z==="dangerouslySetInnerHTML"?(z=z?z.__html:void 0,I=I?I.__html:void 0,z!=null&&I!==z&&(b=b||[]).push(Z,z)):Z==="children"?typeof z!="string"&&typeof z!="number"||(b=b||[]).push(Z,""+z):Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&(i.hasOwnProperty(Z)?(z!=null&&Z==="onScroll"&&xt("scroll",l),b||I===z||(b=[])):(b=b||[]).push(Z,z))}d&&(b=b||[]).push("style",d);var Z=b;(c.updateQueue=Z)&&(c.flags|=4)}},rx=function(l,c,d,m){d!==m&&(c.flags|=4)};function Xl(l,c){if(!St)switch(l.tailMode){case"hidden":c=l.tail;for(var d=null;c!==null;)c.alternate!==null&&(d=c),c=c.sibling;d===null?l.tail=null:d.sibling=null;break;case"collapsed":d=l.tail;for(var m=null;d!==null;)d.alternate!==null&&(m=d),d=d.sibling;m===null?c||l.tail===null?l.tail=null:l.tail.sibling=null:m.sibling=null}}function hn(l){var c=l.alternate!==null&&l.alternate.child===l.child,d=0,m=0;if(c)for(var v=l.child;v!==null;)d|=v.lanes|v.childLanes,m|=v.subtreeFlags&14680064,m|=v.flags&14680064,v.return=l,v=v.sibling;else for(v=l.child;v!==null;)d|=v.lanes|v.childLanes,m|=v.subtreeFlags,m|=v.flags,v.return=l,v=v.sibling;return l.subtreeFlags|=m,l.childLanes=d,c}function K4(l,c,d){var m=c.pendingProps;switch(Eh(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return hn(c),null;case 1:return En(c.type)&&Uc(),hn(c),null;case 3:return m=c.stateNode,To(),wt(Cn),wt(fn),Fh(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(l===null||l.child===null)&&(Yc(c)?c.flags|=4:l===null||l.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,yr!==null&&(pp(yr),yr=null))),rp(l,c),hn(c),null;case 5:jh(c);var v=Ps(ql.current);if(d=c.type,l!==null&&c.stateNode!=null)nx(l,c,d,m,v),l.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!m){if(c.stateNode===null)throw Error(t(166));return hn(c),null}if(l=Ps(zr.current),Yc(c)){m=c.stateNode,d=c.type;var b=c.memoizedProps;switch(m[Fr]=c,m[Vl]=b,l=(c.mode&1)!==0,d){case"dialog":xt("cancel",m),xt("close",m);break;case"iframe":case"object":case"embed":xt("load",m);break;case"video":case"audio":for(v=0;v<Fl.length;v++)xt(Fl[v],m);break;case"source":xt("error",m);break;case"img":case"image":case"link":xt("error",m),xt("load",m);break;case"details":xt("toggle",m);break;case"input":ze(m,b),xt("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!b.multiple},xt("invalid",m);break;case"textarea":Ve(m,b),xt("invalid",m)}Gn(d,b),v=null;for(var R in b)if(b.hasOwnProperty(R)){var I=b[R];R==="children"?typeof I=="string"?m.textContent!==I&&(b.suppressHydrationWarning!==!0&&Wc(m.textContent,I,l),v=["children",I]):typeof I=="number"&&m.textContent!==""+I&&(b.suppressHydrationWarning!==!0&&Wc(m.textContent,I,l),v=["children",""+I]):i.hasOwnProperty(R)&&I!=null&&R==="onScroll"&&xt("scroll",m)}switch(d){case"input":ne(m),Te(m,b,!0);break;case"textarea":ne(m),Ce(m);break;case"select":case"option":break;default:typeof b.onClick=="function"&&(m.onclick=$c)}m=v,c.updateQueue=m,m!==null&&(c.flags|=4)}else{R=v.nodeType===9?v:v.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=Fe(d)),l==="http://www.w3.org/1999/xhtml"?d==="script"?(l=R.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof m.is=="string"?l=R.createElement(d,{is:m.is}):(l=R.createElement(d),d==="select"&&(R=l,m.multiple?R.multiple=!0:m.size&&(R.size=m.size))):l=R.createElementNS(l,d),l[Fr]=c,l[Vl]=m,tx(l,c,!1,!1),c.stateNode=l;e:{switch(R=Yn(d,m),d){case"dialog":xt("cancel",l),xt("close",l),v=m;break;case"iframe":case"object":case"embed":xt("load",l),v=m;break;case"video":case"audio":for(v=0;v<Fl.length;v++)xt(Fl[v],l);v=m;break;case"source":xt("error",l),v=m;break;case"img":case"image":case"link":xt("error",l),xt("load",l),v=m;break;case"details":xt("toggle",l),v=m;break;case"input":ze(l,m),v=at(l,m),xt("invalid",l);break;case"option":v=m;break;case"select":l._wrapperState={wasMultiple:!!m.multiple},v=K({},m,{value:void 0}),xt("invalid",l);break;case"textarea":Ve(l,m),v=xe(l,m),xt("invalid",l);break;default:v=m}Gn(d,v),I=v;for(b in I)if(I.hasOwnProperty(b)){var z=I[b];b==="style"?vt(l,z):b==="dangerouslySetInnerHTML"?(z=z?z.__html:void 0,z!=null&&Ye(l,z)):b==="children"?typeof z=="string"?(d!=="textarea"||z!=="")&&Ke(l,z):typeof z=="number"&&Ke(l,""+z):b!=="suppressContentEditableWarning"&&b!=="suppressHydrationWarning"&&b!=="autoFocus"&&(i.hasOwnProperty(b)?z!=null&&b==="onScroll"&&xt("scroll",l):z!=null&&M(l,b,z,R))}switch(d){case"input":ne(l),Te(l,m,!1);break;case"textarea":ne(l),Ce(l);break;case"option":m.value!=null&&l.setAttribute("value",""+ee(m.value));break;case"select":l.multiple=!!m.multiple,b=m.value,b!=null?Me(l,!!m.multiple,b,!1):m.defaultValue!=null&&Me(l,!!m.multiple,m.defaultValue,!0);break;default:typeof v.onClick=="function"&&(l.onclick=$c)}switch(d){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return hn(c),null;case 6:if(l&&c.stateNode!=null)rx(l,c,l.memoizedProps,m);else{if(typeof m!="string"&&c.stateNode===null)throw Error(t(166));if(d=Ps(ql.current),Ps(zr.current),Yc(c)){if(m=c.stateNode,d=c.memoizedProps,m[Fr]=c,(b=m.nodeValue!==d)&&(l=Vn,l!==null))switch(l.tag){case 3:Wc(m.nodeValue,d,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&Wc(m.nodeValue,d,(l.mode&1)!==0)}b&&(c.flags|=4)}else m=(d.nodeType===9?d:d.ownerDocument).createTextNode(m),m[Fr]=c,c.stateNode=m}return hn(c),null;case 13:if(wt(Rt),m=c.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(St&&Wn!==null&&(c.mode&1)!==0&&(c.flags&128)===0)ov(),ko(),c.flags|=98560,b=!1;else if(b=Yc(c),m!==null&&m.dehydrated!==null){if(l===null){if(!b)throw Error(t(318));if(b=c.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(t(317));b[Fr]=c}else ko(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;hn(c),b=!1}else yr!==null&&(pp(yr),yr=null),b=!0;if(!b)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=d,c):(m=m!==null,m!==(l!==null&&l.memoizedState!==null)&&m&&(c.child.flags|=8192,(c.mode&1)!==0&&(l===null||(Rt.current&1)!==0?Ut===0&&(Ut=3):yp())),c.updateQueue!==null&&(c.flags|=4),hn(c),null);case 4:return To(),rp(l,c),l===null&&zl(c.stateNode.containerInfo),hn(c),null;case 10:return Ah(c.type._context),hn(c),null;case 17:return En(c.type)&&Uc(),hn(c),null;case 19:if(wt(Rt),b=c.memoizedState,b===null)return hn(c),null;if(m=(c.flags&128)!==0,R=b.rendering,R===null)if(m)Xl(b,!1);else{if(Ut!==0||l!==null&&(l.flags&128)!==0)for(l=c.child;l!==null;){if(R=nu(l),R!==null){for(c.flags|=128,Xl(b,!1),m=R.updateQueue,m!==null&&(c.updateQueue=m,c.flags|=4),c.subtreeFlags=0,m=d,d=c.child;d!==null;)b=d,l=m,b.flags&=14680066,R=b.alternate,R===null?(b.childLanes=0,b.lanes=l,b.child=null,b.subtreeFlags=0,b.memoizedProps=null,b.memoizedState=null,b.updateQueue=null,b.dependencies=null,b.stateNode=null):(b.childLanes=R.childLanes,b.lanes=R.lanes,b.child=R.child,b.subtreeFlags=0,b.deletions=null,b.memoizedProps=R.memoizedProps,b.memoizedState=R.memoizedState,b.updateQueue=R.updateQueue,b.type=R.type,l=R.dependencies,b.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),d=d.sibling;return mt(Rt,Rt.current&1|2),c.child}l=l.sibling}b.tail!==null&&Lt()>Ao&&(c.flags|=128,m=!0,Xl(b,!1),c.lanes=4194304)}else{if(!m)if(l=nu(R),l!==null){if(c.flags|=128,m=!0,d=l.updateQueue,d!==null&&(c.updateQueue=d,c.flags|=4),Xl(b,!0),b.tail===null&&b.tailMode==="hidden"&&!R.alternate&&!St)return hn(c),null}else 2*Lt()-b.renderingStartTime>Ao&&d!==1073741824&&(c.flags|=128,m=!0,Xl(b,!1),c.lanes=4194304);b.isBackwards?(R.sibling=c.child,c.child=R):(d=b.last,d!==null?d.sibling=R:c.child=R,b.last=R)}return b.tail!==null?(c=b.tail,b.rendering=c,b.tail=c.sibling,b.renderingStartTime=Lt(),c.sibling=null,d=Rt.current,mt(Rt,m?d&1|2:d&1),c):(hn(c),null);case 22:case 23:return gp(),m=c.memoizedState!==null,l!==null&&l.memoizedState!==null!==m&&(c.flags|=8192),m&&(c.mode&1)!==0?($n&1073741824)!==0&&(hn(c),c.subtreeFlags&6&&(c.flags|=8192)):hn(c),null;case 24:return null;case 25:return null}throw Error(t(156,c.tag))}function Q4(l,c){switch(Eh(c),c.tag){case 1:return En(c.type)&&Uc(),l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 3:return To(),wt(Cn),wt(fn),Fh(),l=c.flags,(l&65536)!==0&&(l&128)===0?(c.flags=l&-65537|128,c):null;case 5:return jh(c),null;case 13:if(wt(Rt),l=c.memoizedState,l!==null&&l.dehydrated!==null){if(c.alternate===null)throw Error(t(340));ko()}return l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 19:return wt(Rt),null;case 4:return To(),null;case 10:return Ah(c.type._context),null;case 22:case 23:return gp(),null;case 24:return null;default:return null}}var fu=!1,pn=!1,G4=typeof WeakSet=="function"?WeakSet:Set,Ee=null;function Oo(l,c){var d=l.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(m){Mt(l,c,m)}else d.current=null}function ip(l,c,d){try{d()}catch(m){Mt(l,c,m)}}var ix=!1;function Y4(l,c){if(gh=Ac,l=jy(),ah(l)){if("selectionStart"in l)var d={start:l.selectionStart,end:l.selectionEnd};else e:{d=(d=l.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var v=m.anchorOffset,b=m.focusNode;m=m.focusOffset;try{d.nodeType,b.nodeType}catch{d=null;break e}var R=0,I=-1,z=-1,Z=0,se=0,ae=l,re=null;t:for(;;){for(var be;ae!==d||v!==0&&ae.nodeType!==3||(I=R+v),ae!==b||m!==0&&ae.nodeType!==3||(z=R+m),ae.nodeType===3&&(R+=ae.nodeValue.length),(be=ae.firstChild)!==null;)re=ae,ae=be;for(;;){if(ae===l)break t;if(re===d&&++Z===v&&(I=R),re===b&&++se===m&&(z=R),(be=ae.nextSibling)!==null)break;ae=re,re=ae.parentNode}ae=be}d=I===-1||z===-1?null:{start:I,end:z}}else d=null}d=d||{start:0,end:0}}else d=null;for(yh={focusedElem:l,selectionRange:d},Ac=!1,Ee=c;Ee!==null;)if(c=Ee,l=c.child,(c.subtreeFlags&1028)!==0&&l!==null)l.return=c,Ee=l;else for(;Ee!==null;){c=Ee;try{var Oe=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(Oe!==null){var Pe=Oe.memoizedProps,Dt=Oe.memoizedState,G=c.stateNode,V=G.getSnapshotBeforeUpdate(c.elementType===c.type?Pe:vr(c.type,Pe),Dt);G.__reactInternalSnapshotBeforeUpdate=V}break;case 3:var J=c.stateNode.containerInfo;J.nodeType===1?J.textContent="":J.nodeType===9&&J.documentElement&&J.removeChild(J.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ue){Mt(c,c.return,ue)}if(l=c.sibling,l!==null){l.return=c.return,Ee=l;break}Ee=c.return}return Oe=ix,ix=!1,Oe}function Jl(l,c,d){var m=c.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var v=m=m.next;do{if((v.tag&l)===l){var b=v.destroy;v.destroy=void 0,b!==void 0&&ip(c,d,b)}v=v.next}while(v!==m)}}function du(l,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&l)===l){var m=d.create;d.destroy=m()}d=d.next}while(d!==c)}}function sp(l){var c=l.ref;if(c!==null){var d=l.stateNode;switch(l.tag){case 5:l=d;break;default:l=d}typeof c=="function"?c(l):c.current=l}}function sx(l){var c=l.alternate;c!==null&&(l.alternate=null,sx(c)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(c=l.stateNode,c!==null&&(delete c[Fr],delete c[Vl],delete c[bh],delete c[N4],delete c[L4])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function ox(l){return l.tag===5||l.tag===3||l.tag===4}function lx(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||ox(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function op(l,c,d){var m=l.tag;if(m===5||m===6)l=l.stateNode,c?d.nodeType===8?d.parentNode.insertBefore(l,c):d.insertBefore(l,c):(d.nodeType===8?(c=d.parentNode,c.insertBefore(l,d)):(c=d,c.appendChild(l)),d=d._reactRootContainer,d!=null||c.onclick!==null||(c.onclick=$c));else if(m!==4&&(l=l.child,l!==null))for(op(l,c,d),l=l.sibling;l!==null;)op(l,c,d),l=l.sibling}function lp(l,c,d){var m=l.tag;if(m===5||m===6)l=l.stateNode,c?d.insertBefore(l,c):d.appendChild(l);else if(m!==4&&(l=l.child,l!==null))for(lp(l,c,d),l=l.sibling;l!==null;)lp(l,c,d),l=l.sibling}var sn=null,xr=!1;function Ki(l,c,d){for(d=d.child;d!==null;)ax(l,c,d),d=d.sibling}function ax(l,c,d){if(Br&&typeof Br.onCommitFiberUnmount=="function")try{Br.onCommitFiberUnmount(Ec,d)}catch{}switch(d.tag){case 5:pn||Oo(d,c);case 6:var m=sn,v=xr;sn=null,Ki(l,c,d),sn=m,xr=v,sn!==null&&(xr?(l=sn,d=d.stateNode,l.nodeType===8?l.parentNode.removeChild(d):l.removeChild(d)):sn.removeChild(d.stateNode));break;case 18:sn!==null&&(xr?(l=sn,d=d.stateNode,l.nodeType===8?wh(l.parentNode,d):l.nodeType===1&&wh(l,d),Pl(l)):wh(sn,d.stateNode));break;case 4:m=sn,v=xr,sn=d.stateNode.containerInfo,xr=!0,Ki(l,c,d),sn=m,xr=v;break;case 0:case 11:case 14:case 15:if(!pn&&(m=d.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){v=m=m.next;do{var b=v,R=b.destroy;b=b.tag,R!==void 0&&((b&2)!==0||(b&4)!==0)&&ip(d,c,R),v=v.next}while(v!==m)}Ki(l,c,d);break;case 1:if(!pn&&(Oo(d,c),m=d.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=d.memoizedProps,m.state=d.memoizedState,m.componentWillUnmount()}catch(I){Mt(d,c,I)}Ki(l,c,d);break;case 21:Ki(l,c,d);break;case 22:d.mode&1?(pn=(m=pn)||d.memoizedState!==null,Ki(l,c,d),pn=m):Ki(l,c,d);break;default:Ki(l,c,d)}}function cx(l){var c=l.updateQueue;if(c!==null){l.updateQueue=null;var d=l.stateNode;d===null&&(d=l.stateNode=new G4),c.forEach(function(m){var v=s3.bind(null,l,m);d.has(m)||(d.add(m),m.then(v,v))})}}function wr(l,c){var d=c.deletions;if(d!==null)for(var m=0;m<d.length;m++){var v=d[m];try{var b=l,R=c,I=R;e:for(;I!==null;){switch(I.tag){case 5:sn=I.stateNode,xr=!1;break e;case 3:sn=I.stateNode.containerInfo,xr=!0;break e;case 4:sn=I.stateNode.containerInfo,xr=!0;break e}I=I.return}if(sn===null)throw Error(t(160));ax(b,R,v),sn=null,xr=!1;var z=v.alternate;z!==null&&(z.return=null),v.return=null}catch(Z){Mt(v,c,Z)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)ux(c,l),c=c.sibling}function ux(l,c){var d=l.alternate,m=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(wr(c,l),Vr(l),m&4){try{Jl(3,l,l.return),du(3,l)}catch(Pe){Mt(l,l.return,Pe)}try{Jl(5,l,l.return)}catch(Pe){Mt(l,l.return,Pe)}}break;case 1:wr(c,l),Vr(l),m&512&&d!==null&&Oo(d,d.return);break;case 5:if(wr(c,l),Vr(l),m&512&&d!==null&&Oo(d,d.return),l.flags&32){var v=l.stateNode;try{Ke(v,"")}catch(Pe){Mt(l,l.return,Pe)}}if(m&4&&(v=l.stateNode,v!=null)){var b=l.memoizedProps,R=d!==null?d.memoizedProps:b,I=l.type,z=l.updateQueue;if(l.updateQueue=null,z!==null)try{I==="input"&&b.type==="radio"&&b.name!=null&&pe(v,b),Yn(I,R);var Z=Yn(I,b);for(R=0;R<z.length;R+=2){var se=z[R],ae=z[R+1];se==="style"?vt(v,ae):se==="dangerouslySetInnerHTML"?Ye(v,ae):se==="children"?Ke(v,ae):M(v,se,ae,Z)}switch(I){case"input":Re(v,b);break;case"textarea":Ue(v,b);break;case"select":var re=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!b.multiple;var be=b.value;be!=null?Me(v,!!b.multiple,be,!1):re!==!!b.multiple&&(b.defaultValue!=null?Me(v,!!b.multiple,b.defaultValue,!0):Me(v,!!b.multiple,b.multiple?[]:"",!1))}v[Vl]=b}catch(Pe){Mt(l,l.return,Pe)}}break;case 6:if(wr(c,l),Vr(l),m&4){if(l.stateNode===null)throw Error(t(162));v=l.stateNode,b=l.memoizedProps;try{v.nodeValue=b}catch(Pe){Mt(l,l.return,Pe)}}break;case 3:if(wr(c,l),Vr(l),m&4&&d!==null&&d.memoizedState.isDehydrated)try{Pl(c.containerInfo)}catch(Pe){Mt(l,l.return,Pe)}break;case 4:wr(c,l),Vr(l);break;case 13:wr(c,l),Vr(l),v=l.child,v.flags&8192&&(b=v.memoizedState!==null,v.stateNode.isHidden=b,!b||v.alternate!==null&&v.alternate.memoizedState!==null||(up=Lt())),m&4&&cx(l);break;case 22:if(se=d!==null&&d.memoizedState!==null,l.mode&1?(pn=(Z=pn)||se,wr(c,l),pn=Z):wr(c,l),Vr(l),m&8192){if(Z=l.memoizedState!==null,(l.stateNode.isHidden=Z)&&!se&&(l.mode&1)!==0)for(Ee=l,se=l.child;se!==null;){for(ae=Ee=se;Ee!==null;){switch(re=Ee,be=re.child,re.tag){case 0:case 11:case 14:case 15:Jl(4,re,re.return);break;case 1:Oo(re,re.return);var Oe=re.stateNode;if(typeof Oe.componentWillUnmount=="function"){m=re,d=re.return;try{c=m,Oe.props=c.memoizedProps,Oe.state=c.memoizedState,Oe.componentWillUnmount()}catch(Pe){Mt(m,d,Pe)}}break;case 5:Oo(re,re.return);break;case 22:if(re.memoizedState!==null){hx(ae);continue}}be!==null?(be.return=re,Ee=be):hx(ae)}se=se.sibling}e:for(se=null,ae=l;;){if(ae.tag===5){if(se===null){se=ae;try{v=ae.stateNode,Z?(b=v.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none"):(I=ae.stateNode,z=ae.memoizedProps.style,R=z!=null&&z.hasOwnProperty("display")?z.display:null,I.style.display=Wt("display",R))}catch(Pe){Mt(l,l.return,Pe)}}}else if(ae.tag===6){if(se===null)try{ae.stateNode.nodeValue=Z?"":ae.memoizedProps}catch(Pe){Mt(l,l.return,Pe)}}else if((ae.tag!==22&&ae.tag!==23||ae.memoizedState===null||ae===l)&&ae.child!==null){ae.child.return=ae,ae=ae.child;continue}if(ae===l)break e;for(;ae.sibling===null;){if(ae.return===null||ae.return===l)break e;se===ae&&(se=null),ae=ae.return}se===ae&&(se=null),ae.sibling.return=ae.return,ae=ae.sibling}}break;case 19:wr(c,l),Vr(l),m&4&&cx(l);break;case 21:break;default:wr(c,l),Vr(l)}}function Vr(l){var c=l.flags;if(c&2){try{e:{for(var d=l.return;d!==null;){if(ox(d)){var m=d;break e}d=d.return}throw Error(t(160))}switch(m.tag){case 5:var v=m.stateNode;m.flags&32&&(Ke(v,""),m.flags&=-33);var b=lx(l);lp(l,b,v);break;case 3:case 4:var R=m.stateNode.containerInfo,I=lx(l);op(l,I,R);break;default:throw Error(t(161))}}catch(z){Mt(l,l.return,z)}l.flags&=-3}c&4096&&(l.flags&=-4097)}function X4(l,c,d){Ee=l,fx(l)}function fx(l,c,d){for(var m=(l.mode&1)!==0;Ee!==null;){var v=Ee,b=v.child;if(v.tag===22&&m){var R=v.memoizedState!==null||fu;if(!R){var I=v.alternate,z=I!==null&&I.memoizedState!==null||pn;I=fu;var Z=pn;if(fu=R,(pn=z)&&!Z)for(Ee=v;Ee!==null;)R=Ee,z=R.child,R.tag===22&&R.memoizedState!==null?px(v):z!==null?(z.return=R,Ee=z):px(v);for(;b!==null;)Ee=b,fx(b),b=b.sibling;Ee=v,fu=I,pn=Z}dx(l)}else(v.subtreeFlags&8772)!==0&&b!==null?(b.return=v,Ee=b):dx(l)}}function dx(l){for(;Ee!==null;){var c=Ee;if((c.flags&8772)!==0){var d=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:pn||du(5,c);break;case 1:var m=c.stateNode;if(c.flags&4&&!pn)if(d===null)m.componentDidMount();else{var v=c.elementType===c.type?d.memoizedProps:vr(c.type,d.memoizedProps);m.componentDidUpdate(v,d.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var b=c.updateQueue;b!==null&&hv(c,b,m);break;case 3:var R=c.updateQueue;if(R!==null){if(d=null,c.child!==null)switch(c.child.tag){case 5:d=c.child.stateNode;break;case 1:d=c.child.stateNode}hv(c,R,d)}break;case 5:var I=c.stateNode;if(d===null&&c.flags&4){d=I;var z=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":z.autoFocus&&d.focus();break;case"img":z.src&&(d.src=z.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var Z=c.alternate;if(Z!==null){var se=Z.memoizedState;if(se!==null){var ae=se.dehydrated;ae!==null&&Pl(ae)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}pn||c.flags&512&&sp(c)}catch(re){Mt(c,c.return,re)}}if(c===l){Ee=null;break}if(d=c.sibling,d!==null){d.return=c.return,Ee=d;break}Ee=c.return}}function hx(l){for(;Ee!==null;){var c=Ee;if(c===l){Ee=null;break}var d=c.sibling;if(d!==null){d.return=c.return,Ee=d;break}Ee=c.return}}function px(l){for(;Ee!==null;){var c=Ee;try{switch(c.tag){case 0:case 11:case 15:var d=c.return;try{du(4,c)}catch(z){Mt(c,d,z)}break;case 1:var m=c.stateNode;if(typeof m.componentDidMount=="function"){var v=c.return;try{m.componentDidMount()}catch(z){Mt(c,v,z)}}var b=c.return;try{sp(c)}catch(z){Mt(c,b,z)}break;case 5:var R=c.return;try{sp(c)}catch(z){Mt(c,R,z)}}}catch(z){Mt(c,c.return,z)}if(c===l){Ee=null;break}var I=c.sibling;if(I!==null){I.return=c.return,Ee=I;break}Ee=c.return}}var J4=Math.ceil,hu=P.ReactCurrentDispatcher,ap=P.ReactCurrentOwner,tr=P.ReactCurrentBatchConfig,rt=0,Jt=null,Ft=null,on=0,$n=0,Po=Wi(0),Ut=0,Zl=null,Ns=0,pu=0,cp=0,ea=null,Tn=null,up=0,Ao=1/0,vi=null,mu=!1,fp=null,Qi=null,gu=!1,Gi=null,yu=0,ta=0,dp=null,vu=-1,xu=0;function xn(){return(rt&6)!==0?Lt():vu!==-1?vu:vu=Lt()}function Yi(l){return(l.mode&1)===0?1:(rt&2)!==0&&on!==0?on&-on:I4.transition!==null?(xu===0&&(xu=ly()),xu):(l=ut,l!==0||(l=window.event,l=l===void 0?16:gy(l.type)),l)}function br(l,c,d,m){if(50<ta)throw ta=0,dp=null,Error(t(185));El(l,d,m),((rt&2)===0||l!==Jt)&&(l===Jt&&((rt&2)===0&&(pu|=d),Ut===4&&Xi(l,on)),Mn(l,m),d===1&&rt===0&&(c.mode&1)===0&&(Ao=Lt()+500,Kc&&Hi()))}function Mn(l,c){var d=l.callbackNode;IR(l,c);var m=Mc(l,l===Jt?on:0);if(m===0)d!==null&&iy(d),l.callbackNode=null,l.callbackPriority=0;else if(c=m&-m,l.callbackPriority!==c){if(d!=null&&iy(d),c===1)l.tag===0?D4(gx.bind(null,l)):tv(gx.bind(null,l)),P4(function(){(rt&6)===0&&Hi()}),d=null;else{switch(ay(m)){case 1:d=Ud;break;case 4:d=sy;break;case 16:d=Cc;break;case 536870912:d=oy;break;default:d=Cc}d=Cx(d,mx.bind(null,l))}l.callbackPriority=c,l.callbackNode=d}}function mx(l,c){if(vu=-1,xu=0,(rt&6)!==0)throw Error(t(327));var d=l.callbackNode;if(No()&&l.callbackNode!==d)return null;var m=Mc(l,l===Jt?on:0);if(m===0)return null;if((m&30)!==0||(m&l.expiredLanes)!==0||c)c=wu(l,m);else{c=m;var v=rt;rt|=2;var b=vx();(Jt!==l||on!==c)&&(vi=null,Ao=Lt()+500,Ds(l,c));do try{t3();break}catch(I){yx(l,I)}while(!0);Ph(),hu.current=b,rt=v,Ft!==null?c=0:(Jt=null,on=0,c=Ut)}if(c!==0){if(c===2&&(v=qd(l),v!==0&&(m=v,c=hp(l,v))),c===1)throw d=Zl,Ds(l,0),Xi(l,m),Mn(l,Lt()),d;if(c===6)Xi(l,m);else{if(v=l.current.alternate,(m&30)===0&&!Z4(v)&&(c=wu(l,m),c===2&&(b=qd(l),b!==0&&(m=b,c=hp(l,b))),c===1))throw d=Zl,Ds(l,0),Xi(l,m),Mn(l,Lt()),d;switch(l.finishedWork=v,l.finishedLanes=m,c){case 0:case 1:throw Error(t(345));case 2:Is(l,Tn,vi);break;case 3:if(Xi(l,m),(m&130023424)===m&&(c=up+500-Lt(),10<c)){if(Mc(l,0)!==0)break;if(v=l.suspendedLanes,(v&m)!==m){xn(),l.pingedLanes|=l.suspendedLanes&v;break}l.timeoutHandle=xh(Is.bind(null,l,Tn,vi),c);break}Is(l,Tn,vi);break;case 4:if(Xi(l,m),(m&4194240)===m)break;for(c=l.eventTimes,v=-1;0<m;){var R=31-mr(m);b=1<<R,R=c[R],R>v&&(v=R),m&=~b}if(m=v,m=Lt()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*J4(m/1960))-m,10<m){l.timeoutHandle=xh(Is.bind(null,l,Tn,vi),m);break}Is(l,Tn,vi);break;case 5:Is(l,Tn,vi);break;default:throw Error(t(329))}}}return Mn(l,Lt()),l.callbackNode===d?mx.bind(null,l):null}function hp(l,c){var d=ea;return l.current.memoizedState.isDehydrated&&(Ds(l,c).flags|=256),l=wu(l,c),l!==2&&(c=Tn,Tn=d,c!==null&&pp(c)),l}function pp(l){Tn===null?Tn=l:Tn.push.apply(Tn,l)}function Z4(l){for(var c=l;;){if(c.flags&16384){var d=c.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var m=0;m<d.length;m++){var v=d[m],b=v.getSnapshot;v=v.value;try{if(!gr(b(),v))return!1}catch{return!1}}}if(d=c.child,c.subtreeFlags&16384&&d!==null)d.return=c,c=d;else{if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function Xi(l,c){for(c&=~cp,c&=~pu,l.suspendedLanes|=c,l.pingedLanes&=~c,l=l.expirationTimes;0<c;){var d=31-mr(c),m=1<<d;l[d]=-1,c&=~m}}function gx(l){if((rt&6)!==0)throw Error(t(327));No();var c=Mc(l,0);if((c&1)===0)return Mn(l,Lt()),null;var d=wu(l,c);if(l.tag!==0&&d===2){var m=qd(l);m!==0&&(c=m,d=hp(l,m))}if(d===1)throw d=Zl,Ds(l,0),Xi(l,c),Mn(l,Lt()),d;if(d===6)throw Error(t(345));return l.finishedWork=l.current.alternate,l.finishedLanes=c,Is(l,Tn,vi),Mn(l,Lt()),null}function mp(l,c){var d=rt;rt|=1;try{return l(c)}finally{rt=d,rt===0&&(Ao=Lt()+500,Kc&&Hi())}}function Ls(l){Gi!==null&&Gi.tag===0&&(rt&6)===0&&No();var c=rt;rt|=1;var d=tr.transition,m=ut;try{if(tr.transition=null,ut=1,l)return l()}finally{ut=m,tr.transition=d,rt=c,(rt&6)===0&&Hi()}}function gp(){$n=Po.current,wt(Po)}function Ds(l,c){l.finishedWork=null,l.finishedLanes=0;var d=l.timeoutHandle;if(d!==-1&&(l.timeoutHandle=-1,O4(d)),Ft!==null)for(d=Ft.return;d!==null;){var m=d;switch(Eh(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&Uc();break;case 3:To(),wt(Cn),wt(fn),Fh();break;case 5:jh(m);break;case 4:To();break;case 13:wt(Rt);break;case 19:wt(Rt);break;case 10:Ah(m.type._context);break;case 22:case 23:gp()}d=d.return}if(Jt=l,Ft=l=Ji(l.current,null),on=$n=c,Ut=0,Zl=null,cp=pu=Ns=0,Tn=ea=null,Os!==null){for(c=0;c<Os.length;c++)if(d=Os[c],m=d.interleaved,m!==null){d.interleaved=null;var v=m.next,b=d.pending;if(b!==null){var R=b.next;b.next=v,m.next=R}d.pending=m}Os=null}return l}function yx(l,c){do{var d=Ft;try{if(Ph(),ru.current=lu,iu){for(var m=Tt.memoizedState;m!==null;){var v=m.queue;v!==null&&(v.pending=null),m=m.next}iu=!1}if(As=0,Xt=Ht=Tt=null,Kl=!1,Ql=0,ap.current=null,d===null||d.return===null){Ut=1,Zl=c,Ft=null;break}e:{var b=l,R=d.return,I=d,z=c;if(c=on,I.flags|=32768,z!==null&&typeof z=="object"&&typeof z.then=="function"){var Z=z,se=I,ae=se.tag;if((se.mode&1)===0&&(ae===0||ae===11||ae===15)){var re=se.alternate;re?(se.updateQueue=re.updateQueue,se.memoizedState=re.memoizedState,se.lanes=re.lanes):(se.updateQueue=null,se.memoizedState=null)}var be=Wv(R);if(be!==null){be.flags&=-257,$v(be,R,I,b,c),be.mode&1&&Vv(b,Z,c),c=be,z=Z;var Oe=c.updateQueue;if(Oe===null){var Pe=new Set;Pe.add(z),c.updateQueue=Pe}else Oe.add(z);break e}else{if((c&1)===0){Vv(b,Z,c),yp();break e}z=Error(t(426))}}else if(St&&I.mode&1){var Dt=Wv(R);if(Dt!==null){(Dt.flags&65536)===0&&(Dt.flags|=256),$v(Dt,R,I,b,c),Mh(Mo(z,I));break e}}b=z=Mo(z,I),Ut!==4&&(Ut=2),ea===null?ea=[b]:ea.push(b),b=R;do{switch(b.tag){case 3:b.flags|=65536,c&=-c,b.lanes|=c;var G=zv(b,z,c);dv(b,G);break e;case 1:I=z;var V=b.type,J=b.stateNode;if((b.flags&128)===0&&(typeof V.getDerivedStateFromError=="function"||J!==null&&typeof J.componentDidCatch=="function"&&(Qi===null||!Qi.has(J)))){b.flags|=65536,c&=-c,b.lanes|=c;var ue=_v(b,I,c);dv(b,ue);break e}}b=b.return}while(b!==null)}wx(d)}catch(Ae){c=Ae,Ft===d&&d!==null&&(Ft=d=d.return);continue}break}while(!0)}function vx(){var l=hu.current;return hu.current=lu,l===null?lu:l}function yp(){(Ut===0||Ut===3||Ut===2)&&(Ut=4),Jt===null||(Ns&268435455)===0&&(pu&268435455)===0||Xi(Jt,on)}function wu(l,c){var d=rt;rt|=2;var m=vx();(Jt!==l||on!==c)&&(vi=null,Ds(l,c));do try{e3();break}catch(v){yx(l,v)}while(!0);if(Ph(),rt=d,hu.current=m,Ft!==null)throw Error(t(261));return Jt=null,on=0,Ut}function e3(){for(;Ft!==null;)xx(Ft)}function t3(){for(;Ft!==null&&!RR();)xx(Ft)}function xx(l){var c=kx(l.alternate,l,$n);l.memoizedProps=l.pendingProps,c===null?wx(l):Ft=c,ap.current=null}function wx(l){var c=l;do{var d=c.alternate;if(l=c.return,(c.flags&32768)===0){if(d=K4(d,c,$n),d!==null){Ft=d;return}}else{if(d=Q4(d,c),d!==null){d.flags&=32767,Ft=d;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{Ut=6,Ft=null;return}}if(c=c.sibling,c!==null){Ft=c;return}Ft=c=l}while(c!==null);Ut===0&&(Ut=5)}function Is(l,c,d){var m=ut,v=tr.transition;try{tr.transition=null,ut=1,n3(l,c,d,m)}finally{tr.transition=v,ut=m}return null}function n3(l,c,d,m){do No();while(Gi!==null);if((rt&6)!==0)throw Error(t(327));d=l.finishedWork;var v=l.finishedLanes;if(d===null)return null;if(l.finishedWork=null,l.finishedLanes=0,d===l.current)throw Error(t(177));l.callbackNode=null,l.callbackPriority=0;var b=d.lanes|d.childLanes;if(jR(l,b),l===Jt&&(Ft=Jt=null,on=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||gu||(gu=!0,Cx(Cc,function(){return No(),null})),b=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||b){b=tr.transition,tr.transition=null;var R=ut;ut=1;var I=rt;rt|=4,ap.current=null,Y4(l,d),ux(d,l),S4(yh),Ac=!!gh,yh=gh=null,l.current=d,X4(d),TR(),rt=I,ut=R,tr.transition=b}else l.current=d;if(gu&&(gu=!1,Gi=l,yu=v),b=l.pendingLanes,b===0&&(Qi=null),PR(d.stateNode),Mn(l,Lt()),c!==null)for(m=l.onRecoverableError,d=0;d<c.length;d++)v=c[d],m(v.value,{componentStack:v.stack,digest:v.digest});if(mu)throw mu=!1,l=fp,fp=null,l;return(yu&1)!==0&&l.tag!==0&&No(),b=l.pendingLanes,(b&1)!==0?l===dp?ta++:(ta=0,dp=l):ta=0,Hi(),null}function No(){if(Gi!==null){var l=ay(yu),c=tr.transition,d=ut;try{if(tr.transition=null,ut=16>l?16:l,Gi===null)var m=!1;else{if(l=Gi,Gi=null,yu=0,(rt&6)!==0)throw Error(t(331));var v=rt;for(rt|=4,Ee=l.current;Ee!==null;){var b=Ee,R=b.child;if((Ee.flags&16)!==0){var I=b.deletions;if(I!==null){for(var z=0;z<I.length;z++){var Z=I[z];for(Ee=Z;Ee!==null;){var se=Ee;switch(se.tag){case 0:case 11:case 15:Jl(8,se,b)}var ae=se.child;if(ae!==null)ae.return=se,Ee=ae;else for(;Ee!==null;){se=Ee;var re=se.sibling,be=se.return;if(sx(se),se===Z){Ee=null;break}if(re!==null){re.return=be,Ee=re;break}Ee=be}}}var Oe=b.alternate;if(Oe!==null){var Pe=Oe.child;if(Pe!==null){Oe.child=null;do{var Dt=Pe.sibling;Pe.sibling=null,Pe=Dt}while(Pe!==null)}}Ee=b}}if((b.subtreeFlags&2064)!==0&&R!==null)R.return=b,Ee=R;else e:for(;Ee!==null;){if(b=Ee,(b.flags&2048)!==0)switch(b.tag){case 0:case 11:case 15:Jl(9,b,b.return)}var G=b.sibling;if(G!==null){G.return=b.return,Ee=G;break e}Ee=b.return}}var V=l.current;for(Ee=V;Ee!==null;){R=Ee;var J=R.child;if((R.subtreeFlags&2064)!==0&&J!==null)J.return=R,Ee=J;else e:for(R=V;Ee!==null;){if(I=Ee,(I.flags&2048)!==0)try{switch(I.tag){case 0:case 11:case 15:du(9,I)}}catch(Ae){Mt(I,I.return,Ae)}if(I===R){Ee=null;break e}var ue=I.sibling;if(ue!==null){ue.return=I.return,Ee=ue;break e}Ee=I.return}}if(rt=v,Hi(),Br&&typeof Br.onPostCommitFiberRoot=="function")try{Br.onPostCommitFiberRoot(Ec,l)}catch{}m=!0}return m}finally{ut=d,tr.transition=c}}return!1}function bx(l,c,d){c=Mo(d,c),c=zv(l,c,1),l=qi(l,c,1),c=xn(),l!==null&&(El(l,1,c),Mn(l,c))}function Mt(l,c,d){if(l.tag===3)bx(l,l,d);else for(;c!==null;){if(c.tag===3){bx(c,l,d);break}else if(c.tag===1){var m=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Qi===null||!Qi.has(m))){l=Mo(d,l),l=_v(c,l,1),c=qi(c,l,1),l=xn(),c!==null&&(El(c,1,l),Mn(c,l));break}}c=c.return}}function r3(l,c,d){var m=l.pingCache;m!==null&&m.delete(c),c=xn(),l.pingedLanes|=l.suspendedLanes&d,Jt===l&&(on&d)===d&&(Ut===4||Ut===3&&(on&130023424)===on&&500>Lt()-up?Ds(l,0):cp|=d),Mn(l,c)}function Sx(l,c){c===0&&((l.mode&1)===0?c=1:(c=Tc,Tc<<=1,(Tc&130023424)===0&&(Tc=4194304)));var d=xn();l=mi(l,c),l!==null&&(El(l,c,d),Mn(l,d))}function i3(l){var c=l.memoizedState,d=0;c!==null&&(d=c.retryLane),Sx(l,d)}function s3(l,c){var d=0;switch(l.tag){case 13:var m=l.stateNode,v=l.memoizedState;v!==null&&(d=v.retryLane);break;case 19:m=l.stateNode;break;default:throw Error(t(314))}m!==null&&m.delete(c),Sx(l,d)}var kx;kx=function(l,c,d){if(l!==null)if(l.memoizedProps!==c.pendingProps||Cn.current)Rn=!0;else{if((l.lanes&d)===0&&(c.flags&128)===0)return Rn=!1,q4(l,c,d);Rn=(l.flags&131072)!==0}else Rn=!1,St&&(c.flags&1048576)!==0&&nv(c,Gc,c.index);switch(c.lanes=0,c.tag){case 2:var m=c.type;uu(l,c),l=c.pendingProps;var v=wo(c,fn.current);Ro(c,d),v=Vh(null,c,m,l,v,d);var b=Wh();return c.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,En(m)?(b=!0,qc(c)):b=!1,c.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,Dh(c),v.updater=au,c.stateNode=v,v._reactInternals=c,Qh(c,m,l,d),c=Jh(null,c,m,!0,b,d)):(c.tag=0,St&&b&&Ch(c),vn(null,c,v,d),c=c.child),c;case 16:m=c.elementType;e:{switch(uu(l,c),l=c.pendingProps,v=m._init,m=v(m._payload),c.type=m,v=c.tag=l3(m),l=vr(m,l),v){case 0:c=Xh(null,c,m,l,d);break e;case 1:c=Gv(null,c,m,l,d);break e;case 11:c=Hv(null,c,m,l,d);break e;case 14:c=Uv(null,c,m,vr(m.type,l),d);break e}throw Error(t(306,m,""))}return c;case 0:return m=c.type,v=c.pendingProps,v=c.elementType===m?v:vr(m,v),Xh(l,c,m,v,d);case 1:return m=c.type,v=c.pendingProps,v=c.elementType===m?v:vr(m,v),Gv(l,c,m,v,d);case 3:e:{if(Yv(c),l===null)throw Error(t(387));m=c.pendingProps,b=c.memoizedState,v=b.element,fv(l,c),tu(c,m,null,d);var R=c.memoizedState;if(m=R.element,b.isDehydrated)if(b={element:m,isDehydrated:!1,cache:R.cache,pendingSuspenseBoundaries:R.pendingSuspenseBoundaries,transitions:R.transitions},c.updateQueue.baseState=b,c.memoizedState=b,c.flags&256){v=Mo(Error(t(423)),c),c=Xv(l,c,m,d,v);break e}else if(m!==v){v=Mo(Error(t(424)),c),c=Xv(l,c,m,d,v);break e}else for(Wn=Vi(c.stateNode.containerInfo.firstChild),Vn=c,St=!0,yr=null,d=cv(c,null,m,d),c.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(ko(),m===v){c=yi(l,c,d);break e}vn(l,c,m,d)}c=c.child}return c;case 5:return pv(c),l===null&&Th(c),m=c.type,v=c.pendingProps,b=l!==null?l.memoizedProps:null,R=v.children,vh(m,v)?R=null:b!==null&&vh(m,b)&&(c.flags|=32),Qv(l,c),vn(l,c,R,d),c.child;case 6:return l===null&&Th(c),null;case 13:return Jv(l,c,d);case 4:return Ih(c,c.stateNode.containerInfo),m=c.pendingProps,l===null?c.child=Co(c,null,m,d):vn(l,c,m,d),c.child;case 11:return m=c.type,v=c.pendingProps,v=c.elementType===m?v:vr(m,v),Hv(l,c,m,v,d);case 7:return vn(l,c,c.pendingProps,d),c.child;case 8:return vn(l,c,c.pendingProps.children,d),c.child;case 12:return vn(l,c,c.pendingProps.children,d),c.child;case 10:e:{if(m=c.type._context,v=c.pendingProps,b=c.memoizedProps,R=v.value,mt(Jc,m._currentValue),m._currentValue=R,b!==null)if(gr(b.value,R)){if(b.children===v.children&&!Cn.current){c=yi(l,c,d);break e}}else for(b=c.child,b!==null&&(b.return=c);b!==null;){var I=b.dependencies;if(I!==null){R=b.child;for(var z=I.firstContext;z!==null;){if(z.context===m){if(b.tag===1){z=gi(-1,d&-d),z.tag=2;var Z=b.updateQueue;if(Z!==null){Z=Z.shared;var se=Z.pending;se===null?z.next=z:(z.next=se.next,se.next=z),Z.pending=z}}b.lanes|=d,z=b.alternate,z!==null&&(z.lanes|=d),Nh(b.return,d,c),I.lanes|=d;break}z=z.next}}else if(b.tag===10)R=b.type===c.type?null:b.child;else if(b.tag===18){if(R=b.return,R===null)throw Error(t(341));R.lanes|=d,I=R.alternate,I!==null&&(I.lanes|=d),Nh(R,d,c),R=b.sibling}else R=b.child;if(R!==null)R.return=b;else for(R=b;R!==null;){if(R===c){R=null;break}if(b=R.sibling,b!==null){b.return=R.return,R=b;break}R=R.return}b=R}vn(l,c,v.children,d),c=c.child}return c;case 9:return v=c.type,m=c.pendingProps.children,Ro(c,d),v=Zn(v),m=m(v),c.flags|=1,vn(l,c,m,d),c.child;case 14:return m=c.type,v=vr(m,c.pendingProps),v=vr(m.type,v),Uv(l,c,m,v,d);case 15:return qv(l,c,c.type,c.pendingProps,d);case 17:return m=c.type,v=c.pendingProps,v=c.elementType===m?v:vr(m,v),uu(l,c),c.tag=1,En(m)?(l=!0,qc(c)):l=!1,Ro(c,d),Bv(c,m,v),Qh(c,m,v,d),Jh(null,c,m,!0,l,d);case 19:return ex(l,c,d);case 22:return Kv(l,c,d)}throw Error(t(156,c.tag))};function Cx(l,c){return ry(l,c)}function o3(l,c,d,m){this.tag=l,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function nr(l,c,d,m){return new o3(l,c,d,m)}function vp(l){return l=l.prototype,!(!l||!l.isReactComponent)}function l3(l){if(typeof l=="function")return vp(l)?1:0;if(l!=null){if(l=l.$$typeof,l===H)return 11;if(l===W)return 14}return 2}function Ji(l,c){var d=l.alternate;return d===null?(d=nr(l.tag,c,l.key,l.mode),d.elementType=l.elementType,d.type=l.type,d.stateNode=l.stateNode,d.alternate=l,l.alternate=d):(d.pendingProps=c,d.type=l.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=l.flags&14680064,d.childLanes=l.childLanes,d.lanes=l.lanes,d.child=l.child,d.memoizedProps=l.memoizedProps,d.memoizedState=l.memoizedState,d.updateQueue=l.updateQueue,c=l.dependencies,d.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},d.sibling=l.sibling,d.index=l.index,d.ref=l.ref,d}function bu(l,c,d,m,v,b){var R=2;if(m=l,typeof l=="function")vp(l)&&(R=1);else if(typeof l=="string")R=5;else e:switch(l){case L:return js(d.children,v,b,c);case F:R=8,v|=8;break;case U:return l=nr(12,d,c,v|2),l.elementType=U,l.lanes=b,l;case j:return l=nr(13,d,c,v),l.elementType=j,l.lanes=b,l;case Y:return l=nr(19,d,c,v),l.elementType=Y,l.lanes=b,l;case X:return Su(d,v,b,c);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case Q:R=10;break e;case q:R=9;break e;case H:R=11;break e;case W:R=14;break e;case _:R=16,m=null;break e}throw Error(t(130,l==null?l:typeof l,""))}return c=nr(R,d,c,v),c.elementType=l,c.type=m,c.lanes=b,c}function js(l,c,d,m){return l=nr(7,l,m,c),l.lanes=d,l}function Su(l,c,d,m){return l=nr(22,l,m,c),l.elementType=X,l.lanes=d,l.stateNode={isHidden:!1},l}function xp(l,c,d){return l=nr(6,l,null,c),l.lanes=d,l}function wp(l,c,d){return c=nr(4,l.children!==null?l.children:[],l.key,c),c.lanes=d,c.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},c}function a3(l,c,d,m,v){this.tag=c,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Kd(0),this.expirationTimes=Kd(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kd(0),this.identifierPrefix=m,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function bp(l,c,d,m,v,b,R,I,z){return l=new a3(l,c,d,I,z),c===1?(c=1,b===!0&&(c|=8)):c=0,b=nr(3,null,null,c),l.current=b,b.stateNode=l,b.memoizedState={element:m,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Dh(b),l}function c3(l,c,d){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:N,key:m==null?null:""+m,children:l,containerInfo:c,implementation:d}}function Ex(l){if(!l)return $i;l=l._reactInternals;e:{if(jr(l)!==l||l.tag!==1)throw Error(t(170));var c=l;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(En(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(t(171))}if(l.tag===1){var d=l.type;if(En(d))return Zy(l,d,c)}return c}function Rx(l,c,d,m,v,b,R,I,z){return l=bp(d,m,!0,l,v,b,R,I,z),l.context=Ex(null),d=l.current,m=xn(),v=Yi(d),b=gi(m,v),b.callback=c??null,qi(d,b,v),l.current.lanes=v,El(l,v,m),Mn(l,m),l}function ku(l,c,d,m){var v=c.current,b=xn(),R=Yi(v);return d=Ex(d),c.context===null?c.context=d:c.pendingContext=d,c=gi(b,R),c.payload={element:l},m=m===void 0?null:m,m!==null&&(c.callback=m),l=qi(v,c,R),l!==null&&(br(l,v,R,b),eu(l,v,R)),R}function Cu(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function Tx(l,c){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var d=l.retryLane;l.retryLane=d!==0&&d<c?d:c}}function Sp(l,c){Tx(l,c),(l=l.alternate)&&Tx(l,c)}function u3(){return null}var Mx=typeof reportError=="function"?reportError:function(l){console.error(l)};function kp(l){this._internalRoot=l}Eu.prototype.render=kp.prototype.render=function(l){var c=this._internalRoot;if(c===null)throw Error(t(409));ku(l,c,null,null)},Eu.prototype.unmount=kp.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var c=l.containerInfo;Ls(function(){ku(null,l,null,null)}),c[fi]=null}};function Eu(l){this._internalRoot=l}Eu.prototype.unstable_scheduleHydration=function(l){if(l){var c=fy();l={blockedOn:null,target:l,priority:c};for(var d=0;d<Fi.length&&c!==0&&c<Fi[d].priority;d++);Fi.splice(d,0,l),d===0&&py(l)}};function Cp(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function Ru(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function Ox(){}function f3(l,c,d,m,v){if(v){if(typeof m=="function"){var b=m;m=function(){var Z=Cu(R);b.call(Z)}}var R=Rx(c,m,l,0,null,!1,!1,"",Ox);return l._reactRootContainer=R,l[fi]=R.current,zl(l.nodeType===8?l.parentNode:l),Ls(),R}for(;v=l.lastChild;)l.removeChild(v);if(typeof m=="function"){var I=m;m=function(){var Z=Cu(z);I.call(Z)}}var z=bp(l,0,!1,null,null,!1,!1,"",Ox);return l._reactRootContainer=z,l[fi]=z.current,zl(l.nodeType===8?l.parentNode:l),Ls(function(){ku(c,z,d,m)}),z}function Tu(l,c,d,m,v){var b=d._reactRootContainer;if(b){var R=b;if(typeof v=="function"){var I=v;v=function(){var z=Cu(R);I.call(z)}}ku(c,R,l,v)}else R=f3(d,c,l,v,m);return Cu(R)}cy=function(l){switch(l.tag){case 3:var c=l.stateNode;if(c.current.memoizedState.isDehydrated){var d=Cl(c.pendingLanes);d!==0&&(Qd(c,d|1),Mn(c,Lt()),(rt&6)===0&&(Ao=Lt()+500,Hi()))}break;case 13:Ls(function(){var m=mi(l,1);if(m!==null){var v=xn();br(m,l,1,v)}}),Sp(l,1)}},Gd=function(l){if(l.tag===13){var c=mi(l,134217728);if(c!==null){var d=xn();br(c,l,134217728,d)}Sp(l,134217728)}},uy=function(l){if(l.tag===13){var c=Yi(l),d=mi(l,c);if(d!==null){var m=xn();br(d,l,c,m)}Sp(l,c)}},fy=function(){return ut},dy=function(l,c){var d=ut;try{return ut=l,c()}finally{ut=d}},Et=function(l,c,d){switch(c){case"input":if(Re(l,d),c=d.name,d.type==="radio"&&c!=null){for(d=l;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<d.length;c++){var m=d[c];if(m!==l&&m.form===l.form){var v=Hc(m);if(!v)throw Error(t(90));he(m),Re(m,v)}}}break;case"textarea":Ue(l,d);break;case"select":c=d.value,c!=null&&Me(l,!!d.multiple,c,!1)}},ao=mp,ci=Ls;var d3={usingClientEntryPoint:!1,Events:[Wl,vo,Hc,ai,Ss,mp]},na={findFiberByHostInstance:Es,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},h3={bundleType:na.bundleType,version:na.version,rendererPackageName:na.rendererPackageName,rendererConfig:na.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=ty(l),l===null?null:l.stateNode},findFiberByHostInstance:na.findFiberByHostInstance||u3,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 Mu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mu.isDisabled&&Mu.supportsFiber)try{Ec=Mu.inject(h3),Br=Mu}catch{}}return On.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=d3,On.createPortal=function(l,c){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Cp(c))throw Error(t(200));return c3(l,c,null,d)},On.createRoot=function(l,c){if(!Cp(l))throw Error(t(299));var d=!1,m="",v=Mx;return c!=null&&(c.unstable_strictMode===!0&&(d=!0),c.identifierPrefix!==void 0&&(m=c.identifierPrefix),c.onRecoverableError!==void 0&&(v=c.onRecoverableError)),c=bp(l,1,!1,null,null,d,!1,m,v),l[fi]=c.current,zl(l.nodeType===8?l.parentNode:l),new kp(c)},On.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var c=l._reactInternals;if(c===void 0)throw typeof l.render=="function"?Error(t(188)):(l=Object.keys(l).join(","),Error(t(268,l)));return l=ty(c),l=l===null?null:l.stateNode,l},On.flushSync=function(l){return Ls(l)},On.hydrate=function(l,c,d){if(!Ru(c))throw Error(t(200));return Tu(null,l,c,!0,d)},On.hydrateRoot=function(l,c,d){if(!Cp(l))throw Error(t(405));var m=d!=null&&d.hydratedSources||null,v=!1,b="",R=Mx;if(d!=null&&(d.unstable_strictMode===!0&&(v=!0),d.identifierPrefix!==void 0&&(b=d.identifierPrefix),d.onRecoverableError!==void 0&&(R=d.onRecoverableError)),c=Rx(c,null,l,1,d??null,v,!1,b,R),l[fi]=c.current,zl(l),m)for(l=0;l<m.length;l++)d=m[l],v=d._getVersion,v=v(d._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[d,v]:c.mutableSourceEagerHydrationData.push(d,v);return new Eu(c)},On.render=function(l,c,d){if(!Ru(c))throw Error(t(200));return Tu(null,l,c,!1,d)},On.unmountComponentAtNode=function(l){if(!Ru(l))throw Error(t(40));return l._reactRootContainer?(Ls(function(){Tu(null,null,l,!1,function(){l._reactRootContainer=null,l[fi]=null})}),!0):!1},On.unstable_batchedUpdates=mp,On.unstable_renderSubtreeIntoContainer=function(l,c,d,m){if(!Ru(d))throw Error(t(200));if(l==null||l._reactInternals===void 0)throw Error(t(38));return Tu(l,c,d,!1,m)},On.version="18.3.1-next-f1338f8080-20240426",On}var Bx;function e2(){if(Bx)return Tp.exports;Bx=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Tp.exports=E3(),Tp.exports}var Fx;function R3(){if(Fx)return Ou;Fx=1;var n=e2();return Ou.createRoot=n.createRoot,Ou.hydrateRoot=n.hydrateRoot,Ou}var T3=R3();/**
 * react-router v7.9.5
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */var zx="popstate";function M3(n={}){function e(r,i){let{pathname:s,search:o,hash:a}=r.location;return Cm("",{pathname:s,search:o,hash:a},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function t(r,i){return typeof i=="string"?i:Na(i)}return P3(e,t,null,n)}function Ct(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function fr(n,e){if(!n){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function O3(){return Math.random().toString(36).substring(2,10)}function _x(n,e){return{usr:n.state,key:n.key,idx:e}}function Cm(n,e,t=null,r){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof e=="string"?fl(e):e,state:t,key:e&&e.key||r||O3()}}function Na({pathname:n="/",search:e="",hash:t=""}){return e&&e!=="?"&&(n+=e.charAt(0)==="?"?e:"?"+e),t&&t!=="#"&&(n+=t.charAt(0)==="#"?t:"#"+t),n}function fl(n){let e={};if(n){let t=n.indexOf("#");t>=0&&(e.hash=n.substring(t),n=n.substring(0,t));let r=n.indexOf("?");r>=0&&(e.search=n.substring(r),n=n.substring(0,r)),n&&(e.pathname=n)}return e}function P3(n,e,t,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,a="POP",u=null,f=h();f==null&&(f=0,o.replaceState({...o.state,idx:f},""));function h(){return(o.state||{idx:null}).idx}function p(){a="POP";let C=h(),E=C==null?null:C-f;f=C,u&&u({action:a,location:w.location,delta:E})}function g(C,E){a="PUSH";let T=Cm(w.location,C,E);f=h()+1;let M=_x(T,f),P=w.createHref(T);try{o.pushState(M,"",P)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;i.location.assign(P)}s&&u&&u({action:a,location:w.location,delta:1})}function y(C,E){a="REPLACE";let T=Cm(w.location,C,E);f=h();let M=_x(T,f),P=w.createHref(T);o.replaceState(M,"",P),s&&u&&u({action:a,location:w.location,delta:0})}function x(C){return A3(C)}let w={get action(){return a},get location(){return n(i,o)},listen(C){if(u)throw new Error("A history only accepts one active listener");return i.addEventListener(zx,p),u=C,()=>{i.removeEventListener(zx,p),u=null}},createHref(C){return e(i,C)},createURL:x,encodeLocation(C){let E=x(C);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:g,replace:y,go(C){return o.go(C)}};return w}function A3(n,e=!1){let t="http://localhost";typeof window<"u"&&(t=window.location.origin!=="null"?window.location.origin:window.location.href),Ct(t,"No window.location.(origin|href) available to create URL");let r=typeof n=="string"?n:Na(n);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=t+r),new URL(r,t)}function t2(n,e,t="/"){return N3(n,e,t,!1)}function N3(n,e,t,r){let i=typeof e=="string"?fl(e):e,s=Ei(i.pathname||"/",t);if(s==null)return null;let o=n2(n);L3(o);let a=null;for(let u=0;a==null&&u<o.length;++u){let f=H3(s);a=W3(o[u],f,r)}return a}function n2(n,e=[],t=[],r="",i=!1){let s=(o,a,u=i,f)=>{let h={relativePath:f===void 0?o.path||"":f,caseSensitive:o.caseSensitive===!0,childrenIndex:a,route:o};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(r)&&u)return;Ct(h.relativePath.startsWith(r),`Absolute route path "${h.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(r.length)}let p=ki([r,h.relativePath]),g=t.concat(h);o.children&&o.children.length>0&&(Ct(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),n2(o.children,e,g,p,u)),!(o.path==null&&!o.index)&&e.push({path:p,score:_3(p,o.index),routesMeta:g})};return n.forEach((o,a)=>{var u;if(o.path===""||!((u=o.path)!=null&&u.includes("?")))s(o,a);else for(let f of r2(o.path))s(o,a,!0,f)}),e}function r2(n){let e=n.split("/");if(e.length===0)return[];let[t,...r]=e,i=t.endsWith("?"),s=t.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let o=r2(r.join("/")),a=[];return a.push(...o.map(u=>u===""?s:[s,u].join("/"))),i&&a.push(...o),a.map(u=>n.startsWith("/")&&u===""?"/":u)}function L3(n){n.sort((e,t)=>e.score!==t.score?t.score-e.score:V3(e.routesMeta.map(r=>r.childrenIndex),t.routesMeta.map(r=>r.childrenIndex)))}var D3=/^:[\w-]+$/,I3=3,j3=2,B3=1,F3=10,z3=-2,Vx=n=>n==="*";function _3(n,e){let t=n.split("/"),r=t.length;return t.some(Vx)&&(r+=z3),e&&(r+=j3),t.filter(i=>!Vx(i)).reduce((i,s)=>i+(D3.test(s)?I3:s===""?B3:F3),r)}function V3(n,e){return n.length===e.length&&n.slice(0,-1).every((r,i)=>r===e[i])?n[n.length-1]-e[e.length-1]:0}function W3(n,e,t=!1){let{routesMeta:r}=n,i={},s="/",o=[];for(let a=0;a<r.length;++a){let u=r[a],f=a===r.length-1,h=s==="/"?e:e.slice(s.length)||"/",p=Rf({path:u.relativePath,caseSensitive:u.caseSensitive,end:f},h),g=u.route;if(!p&&f&&t&&!r[r.length-1].route.index&&(p=Rf({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},h)),!p)return null;Object.assign(i,p.params),o.push({params:i,pathname:ki([s,p.pathname]),pathnameBase:Q3(ki([s,p.pathnameBase])),route:g}),p.pathnameBase!=="/"&&(s=ki([s,p.pathnameBase]))}return o}function Rf(n,e){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[t,r]=$3(n.path,n.caseSensitive,n.end),i=e.match(t);if(!i)return null;let s=i[0],o=s.replace(/(.)\/+$/,"$1"),a=i.slice(1);return{params:r.reduce((f,{paramName:h,isOptional:p},g)=>{if(h==="*"){let x=a[g]||"";o=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const y=a[g];return p&&!y?f[h]=void 0:f[h]=(y||"").replace(/%2F/g,"/"),f},{}),pathname:s,pathnameBase:o,pattern:n}}function $3(n,e=!1,t=!0){fr(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let r=[],i="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,u)=>(r.push({paramName:a,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(r.push({paramName:"*"}),i+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?i+="\\/*$":n!==""&&n!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function H3(n){try{return n.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return fr(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),n}}function Ei(n,e){if(e==="/")return n;if(!n.toLowerCase().startsWith(e.toLowerCase()))return null;let t=e.endsWith("/")?e.length-1:e.length,r=n.charAt(t);return r&&r!=="/"?null:n.slice(t)||"/"}function U3(n,e="/"){let{pathname:t,search:r="",hash:i=""}=typeof n=="string"?fl(n):n;return{pathname:t?t.startsWith("/")?t:q3(t,e):e,search:G3(r),hash:Y3(i)}}function q3(n,e){let t=e.replace(/\/+$/,"").split("/");return n.split("/").forEach(i=>{i===".."?t.length>1&&t.pop():i!=="."&&t.push(i)}),t.length>1?t.join("/"):"/"}function Pp(n,e,t,r){return`Cannot include a '${n}' character in a manually specified \`to.${e}\` field [${JSON.stringify(r)}].  Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function K3(n){return n.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function _g(n){let e=K3(n);return e.map((t,r)=>r===e.length-1?t.pathname:t.pathnameBase)}function Vg(n,e,t,r=!1){let i;typeof n=="string"?i=fl(n):(i={...n},Ct(!i.pathname||!i.pathname.includes("?"),Pp("?","pathname","search",i)),Ct(!i.pathname||!i.pathname.includes("#"),Pp("#","pathname","hash",i)),Ct(!i.search||!i.search.includes("#"),Pp("#","search","hash",i)));let s=n===""||i.pathname==="",o=s?"/":i.pathname,a;if(o==null)a=t;else{let p=e.length-1;if(!r&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),p-=1;i.pathname=g.join("/")}a=p>=0?e[p]:"/"}let u=U3(i,a),f=o&&o!=="/"&&o.endsWith("/"),h=(s||o===".")&&t.endsWith("/");return!u.pathname.endsWith("/")&&(f||h)&&(u.pathname+="/"),u}var ki=n=>n.join("/").replace(/\/\/+/g,"/"),Q3=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),G3=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Y3=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function X3(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var i2=["POST","PUT","PATCH","DELETE"];new Set(i2);var J3=["GET",...i2];new Set(J3);var dl=S.createContext(null);dl.displayName="DataRouter";var dd=S.createContext(null);dd.displayName="DataRouterState";S.createContext(!1);var s2=S.createContext({isTransitioning:!1});s2.displayName="ViewTransition";var Z3=S.createContext(new Map);Z3.displayName="Fetchers";var eT=S.createContext(null);eT.displayName="Await";var Pr=S.createContext(null);Pr.displayName="Navigation";var ic=S.createContext(null);ic.displayName="Location";var hr=S.createContext({outlet:null,matches:[],isDataRoute:!1});hr.displayName="Route";var Wg=S.createContext(null);Wg.displayName="RouteError";function tT(n,{relative:e}={}){Ct(hl(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:r}=S.useContext(Pr),{hash:i,pathname:s,search:o}=sc(n,{relative:e}),a=s;return t!=="/"&&(a=s==="/"?t:ki([t,s])),r.createHref({pathname:a,search:o,hash:i})}function hl(){return S.useContext(ic)!=null}function Ar(){return Ct(hl(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(ic).location}var o2="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function l2(n){S.useContext(Pr).static||S.useLayoutEffect(n)}function hd(){let{isDataRoute:n}=S.useContext(hr);return n?gT():nT()}function nT(){Ct(hl(),"useNavigate() may be used only in the context of a <Router> component.");let n=S.useContext(dl),{basename:e,navigator:t}=S.useContext(Pr),{matches:r}=S.useContext(hr),{pathname:i}=Ar(),s=JSON.stringify(_g(r)),o=S.useRef(!1);return l2(()=>{o.current=!0}),S.useCallback((u,f={})=>{if(fr(o.current,o2),!o.current)return;if(typeof u=="number"){t.go(u);return}let h=Vg(u,JSON.parse(s),i,f.relative==="path");n==null&&e!=="/"&&(h.pathname=h.pathname==="/"?e:ki([e,h.pathname])),(f.replace?t.replace:t.push)(h,f.state,f)},[e,t,s,i,n])}var rT=S.createContext(null);function iT(n){let e=S.useContext(hr).outlet;return S.useMemo(()=>e&&S.createElement(rT.Provider,{value:n},e),[e,n])}function pd(){let{matches:n}=S.useContext(hr),e=n[n.length-1];return e?e.params:{}}function sc(n,{relative:e}={}){let{matches:t}=S.useContext(hr),{pathname:r}=Ar(),i=JSON.stringify(_g(t));return S.useMemo(()=>Vg(n,JSON.parse(i),r,e==="path"),[n,i,r,e])}function sT(n,e){return a2(n,e)}function a2(n,e,t,r,i){var T;Ct(hl(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=S.useContext(Pr),{matches:o}=S.useContext(hr),a=o[o.length-1],u=a?a.params:{},f=a?a.pathname:"/",h=a?a.pathnameBase:"/",p=a&&a.route;{let M=p&&p.path||"";c2(f,!p||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${M}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.

Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let g=Ar(),y;if(e){let M=typeof e=="string"?fl(e):e;Ct(h==="/"||((T=M.pathname)==null?void 0:T.startsWith(h)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${M.pathname}" was given in the \`location\` prop.`),y=M}else y=g;let x=y.pathname||"/",w=x;if(h!=="/"){let M=h.replace(/^\//,"").split("/");w="/"+x.replace(/^\//,"").split("/").slice(M.length).join("/")}let C=t2(n,{pathname:w});fr(p||C!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),fr(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let E=uT(C&&C.map(M=>Object.assign({},M,{params:Object.assign({},u,M.params),pathname:ki([h,s.encodeLocation?s.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?h:ki([h,s.encodeLocation?s.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),o,t,r,i);return e&&E?S.createElement(ic.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...y},navigationType:"POP"}},E):E}function oT(){let n=mT(),e=X3(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),t=n instanceof Error?n.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",n),o=S.createElement(S.Fragment,null,S.createElement("p",null,"💿 Hey developer 👋"),S.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",S.createElement("code",{style:s},"ErrorBoundary")," or"," ",S.createElement("code",{style:s},"errorElement")," prop on your route.")),S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},e),t?S.createElement("pre",{style:i},t):null,o)}var lT=S.createElement(oT,null),aT=class extends S.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,e){return e.location!==n.location||e.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:e.error,location:e.location,revalidation:n.revalidation||e.revalidation}}componentDidCatch(n,e){this.props.unstable_onError?this.props.unstable_onError(n,e):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?S.createElement(hr.Provider,{value:this.props.routeContext},S.createElement(Wg.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function cT({routeContext:n,match:e,children:t}){let r=S.useContext(dl);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),S.createElement(hr.Provider,{value:n},t)}function uT(n,e=[],t=null,r=null,i=null){if(n==null){if(!t)return null;if(t.errors)n=t.matches;else if(e.length===0&&!t.initialized&&t.matches.length>0)n=t.matches;else return null}let s=n,o=t==null?void 0:t.errors;if(o!=null){let f=s.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);Ct(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let a=!1,u=-1;if(t)for(let f=0;f<s.length;f++){let h=s[f];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=f),h.route.id){let{loaderData:p,errors:g}=t,y=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!g||g[h.route.id]===void 0);if(h.route.lazy||y){a=!0,u>=0?s=s.slice(0,u+1):s=[s[0]];break}}}return s.reduceRight((f,h,p)=>{let g,y=!1,x=null,w=null;t&&(g=o&&h.route.id?o[h.route.id]:void 0,x=h.route.errorElement||lT,a&&(u<0&&p===0?(c2("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,w=null):u===p&&(y=!0,w=h.route.hydrateFallbackElement||null)));let C=e.concat(s.slice(0,p+1)),E=()=>{let T;return g?T=x:y?T=w:h.route.Component?T=S.createElement(h.route.Component,null):h.route.element?T=h.route.element:T=f,S.createElement(cT,{match:h,routeContext:{outlet:f,matches:C,isDataRoute:t!=null},children:T})};return t&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?S.createElement(aT,{location:t.location,revalidation:t.revalidation,component:x,error:g,children:E(),routeContext:{outlet:null,matches:C,isDataRoute:!0},unstable_onError:r}):E()},null)}function $g(n){return`${n} must be used within a data router.  See https://reactrouter.com/en/main/routers/picking-a-router.`}function fT(n){let e=S.useContext(dl);return Ct(e,$g(n)),e}function dT(n){let e=S.useContext(dd);return Ct(e,$g(n)),e}function hT(n){let e=S.useContext(hr);return Ct(e,$g(n)),e}function Hg(n){let e=hT(n),t=e.matches[e.matches.length-1];return Ct(t.route.id,`${n} can only be used on routes that contain a unique "id"`),t.route.id}function pT(){return Hg("useRouteId")}function mT(){var r;let n=S.useContext(Wg),e=dT("useRouteError"),t=Hg("useRouteError");return n!==void 0?n:(r=e.errors)==null?void 0:r[t]}function gT(){let{router:n}=fT("useNavigate"),e=Hg("useNavigate"),t=S.useRef(!1);return l2(()=>{t.current=!0}),S.useCallback(async(i,s={})=>{fr(t.current,o2),t.current&&(typeof i=="number"?n.navigate(i):await n.navigate(i,{fromRouteId:e,...s}))},[n,e])}var Wx={};function c2(n,e,t){!e&&!Wx[n]&&(Wx[n]=!0,fr(!1,t))}S.memo(yT);function yT({routes:n,future:e,state:t,unstable_onError:r}){return a2(n,void 0,t,r,e)}function wa({to:n,replace:e,state:t,relative:r}){Ct(hl(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=S.useContext(Pr);fr(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=S.useContext(hr),{pathname:o}=Ar(),a=hd(),u=Vg(n,_g(s),o,r==="path"),f=JSON.stringify(u);return S.useEffect(()=>{a(JSON.parse(f),{replace:e,state:t,relative:r})},[a,f,r,e,t]),null}function vT(n){return iT(n.context)}function _s(n){Ct(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function xT({basename:n="/",children:e=null,location:t,navigationType:r="POP",navigator:i,static:s=!1}){Ct(!hl(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let o=n.replace(/^\/*/,"/"),a=S.useMemo(()=>({basename:o,navigator:i,static:s,future:{}}),[o,i,s]);typeof t=="string"&&(t=fl(t));let{pathname:u="/",search:f="",hash:h="",state:p=null,key:g="default"}=t,y=S.useMemo(()=>{let x=Ei(u,o);return x==null?null:{location:{pathname:x,search:f,hash:h,state:p,key:g},navigationType:r}},[o,u,f,h,p,g,r]);return fr(y!=null,`<Router basename="${o}"> is not able to match the URL "${u}${f}${h}" because it does not start with the basename, so the <Router> won't render anything.`),y==null?null:S.createElement(Pr.Provider,{value:a},S.createElement(ic.Provider,{children:e,value:y}))}function wT({children:n,location:e}){return sT(Em(n),e)}function Em(n,e=[]){let t=[];return S.Children.forEach(n,(r,i)=>{if(!S.isValidElement(r))return;let s=[...e,i];if(r.type===S.Fragment){t.push.apply(t,Em(r.props.children,s));return}Ct(r.type===_s,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ct(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Em(r.props.children,s)),t.push(o)}),t}var uf="get",ff="application/x-www-form-urlencoded";function md(n){return n!=null&&typeof n.tagName=="string"}function bT(n){return md(n)&&n.tagName.toLowerCase()==="button"}function ST(n){return md(n)&&n.tagName.toLowerCase()==="form"}function kT(n){return md(n)&&n.tagName.toLowerCase()==="input"}function CT(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function ET(n,e){return n.button===0&&(!e||e==="_self")&&!CT(n)}function Rm(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((e,t)=>{let r=n[t];return e.concat(Array.isArray(r)?r.map(i=>[t,i]):[[t,r]])},[]))}function RT(n,e){let t=Rm(n);return e&&e.forEach((r,i)=>{t.has(i)||e.getAll(i).forEach(s=>{t.append(i,s)})}),t}var Pu=null;function TT(){if(Pu===null)try{new FormData(document.createElement("form"),0),Pu=!1}catch{Pu=!0}return Pu}var MT=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ap(n){return n!=null&&!MT.has(n)?(fr(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ff}"`),null):n}function OT(n,e){let t,r,i,s,o;if(ST(n)){let a=n.getAttribute("action");r=a?Ei(a,e):null,t=n.getAttribute("method")||uf,i=Ap(n.getAttribute("enctype"))||ff,s=new FormData(n)}else if(bT(n)||kT(n)&&(n.type==="submit"||n.type==="image")){let a=n.form;if(a==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=n.getAttribute("formaction")||a.getAttribute("action");if(r=u?Ei(u,e):null,t=n.getAttribute("formmethod")||a.getAttribute("method")||uf,i=Ap(n.getAttribute("formenctype"))||Ap(a.getAttribute("enctype"))||ff,s=new FormData(a,n),!TT()){let{name:f,type:h,value:p}=n;if(h==="image"){let g=f?`${f}.`:"";s.append(`${g}x`,"0"),s.append(`${g}y`,"0")}else f&&s.append(f,p)}}else{if(md(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=uf,r=null,i=ff,o=n}return s&&i==="text/plain"&&(o=s,s=void 0),{action:r,method:t.toLowerCase(),encType:i,formData:s,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Ug(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function PT(n,e,t){let r=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return r.pathname==="/"?r.pathname=`_root.${t}`:e&&Ei(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${t}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${t}`,r}async function AT(n,e){if(n.id in e)return e[n.id];try{let t=await import(n.module);return e[n.id]=t,t}catch(t){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function NT(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function LT(n,e,t){let r=await Promise.all(n.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await AT(s,t);return o.links?o.links():[]}return[]}));return BT(r.flat(1).filter(NT).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function $x(n,e,t,r,i,s){let o=(u,f)=>t[f]?u.route.id!==t[f].route.id:!0,a=(u,f)=>{var h;return t[f].pathname!==u.pathname||((h=t[f].route.path)==null?void 0:h.endsWith("*"))&&t[f].params["*"]!==u.params["*"]};return s==="assets"?e.filter((u,f)=>o(u,f)||a(u,f)):s==="data"?e.filter((u,f)=>{var p;let h=r.routes[u.route.id];if(!h||!h.hasLoader)return!1;if(o(u,f)||a(u,f))return!0;if(u.route.shouldRevalidate){let g=u.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((p=t[0])==null?void 0:p.params)||{},nextUrl:new URL(n,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function DT(n,e,{includeHydrateFallback:t}={}){return IT(n.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),t&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function IT(n){return[...new Set(n)]}function jT(n){let e={},t=Object.keys(n).sort();for(let r of t)e[r]=n[r];return e}function BT(n,e){let t=new Set;return new Set(e),n.reduce((r,i)=>{let s=JSON.stringify(jT(i));return t.has(s)||(t.add(s),r.push({key:s,link:i})),r},[])}function u2(){let n=S.useContext(dl);return Ug(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function FT(){let n=S.useContext(dd);return Ug(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var qg=S.createContext(void 0);qg.displayName="FrameworkContext";function f2(){let n=S.useContext(qg);return Ug(n,"You must render this element inside a <HydratedRouter> element"),n}function zT(n,e){let t=S.useContext(qg),[r,i]=S.useState(!1),[s,o]=S.useState(!1),{onFocus:a,onBlur:u,onMouseEnter:f,onMouseLeave:h,onTouchStart:p}=e,g=S.useRef(null);S.useEffect(()=>{if(n==="render"&&o(!0),n==="viewport"){let w=E=>{E.forEach(T=>{o(T.isIntersecting)})},C=new IntersectionObserver(w,{threshold:.5});return g.current&&C.observe(g.current),()=>{C.disconnect()}}},[n]),S.useEffect(()=>{if(r){let w=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(w)}}},[r]);let y=()=>{i(!0)},x=()=>{i(!1),o(!1)};return t?n!=="intent"?[s,g,{}]:[s,g,{onFocus:ia(a,y),onBlur:ia(u,x),onMouseEnter:ia(f,y),onMouseLeave:ia(h,x),onTouchStart:ia(p,y)}]:[!1,g,{}]}function ia(n,e){return t=>{n&&n(t),t.defaultPrevented||e(t)}}function _T({page:n,...e}){let{router:t}=u2(),r=S.useMemo(()=>t2(t.routes,n,t.basename),[t.routes,n,t.basename]);return r?S.createElement(WT,{page:n,matches:r,...e}):null}function VT(n){let{manifest:e,routeModules:t}=f2(),[r,i]=S.useState([]);return S.useEffect(()=>{let s=!1;return LT(n,e,t).then(o=>{s||i(o)}),()=>{s=!0}},[n,e,t]),r}function WT({page:n,matches:e,...t}){let r=Ar(),{manifest:i,routeModules:s}=f2(),{basename:o}=u2(),{loaderData:a,matches:u}=FT(),f=S.useMemo(()=>$x(n,e,u,i,r,"data"),[n,e,u,i,r]),h=S.useMemo(()=>$x(n,e,u,i,r,"assets"),[n,e,u,i,r]),p=S.useMemo(()=>{if(n===r.pathname+r.search+r.hash)return[];let x=new Set,w=!1;if(e.forEach(E=>{var M;let T=i.routes[E.route.id];!T||!T.hasLoader||(!f.some(P=>P.route.id===E.route.id)&&E.route.id in a&&((M=s[E.route.id])!=null&&M.shouldRevalidate)||T.hasClientLoader?w=!0:x.add(E.route.id))}),x.size===0)return[];let C=PT(n,o,"data");return w&&x.size>0&&C.searchParams.set("_routes",e.filter(E=>x.has(E.route.id)).map(E=>E.route.id).join(",")),[C.pathname+C.search]},[o,a,r,i,f,e,n,s]),g=S.useMemo(()=>DT(h,i),[h,i]),y=VT(h);return S.createElement(S.Fragment,null,p.map(x=>S.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...t})),g.map(x=>S.createElement("link",{key:x,rel:"modulepreload",href:x,...t})),y.map(({key:x,link:w})=>S.createElement("link",{key:x,nonce:t.nonce,...w})))}function $T(...n){return e=>{n.forEach(t=>{typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var d2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{d2&&(window.__reactRouterVersion="7.9.5")}catch{}function HT({basename:n,children:e,window:t}){let r=S.useRef();r.current==null&&(r.current=M3({window:t,v5Compat:!0}));let i=r.current,[s,o]=S.useState({action:i.action,location:i.location}),a=S.useCallback(u=>{S.startTransition(()=>o(u))},[o]);return S.useLayoutEffect(()=>i.listen(a),[i,a]),S.createElement(xT,{basename:n,children:e,location:s.location,navigationType:s.action,navigator:i})}var h2=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ti=S.forwardRef(function({onClick:e,discover:t="render",prefetch:r="none",relative:i,reloadDocument:s,replace:o,state:a,target:u,to:f,preventScrollReset:h,viewTransition:p,...g},y){let{basename:x}=S.useContext(Pr),w=typeof f=="string"&&h2.test(f),C,E=!1;if(typeof f=="string"&&w&&(C=f,d2))try{let U=new URL(window.location.href),Q=f.startsWith("//")?new URL(U.protocol+f):new URL(f),q=Ei(Q.pathname,x);Q.origin===U.origin&&q!=null?f=q+Q.search+Q.hash:E=!0}catch{fr(!1,`<Link to="${f}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=tT(f,{relative:i}),[M,P,O]=zT(r,g),N=QT(f,{replace:o,state:a,target:u,preventScrollReset:h,relative:i,viewTransition:p});function L(U){e&&e(U),U.defaultPrevented||N(U)}let F=S.createElement("a",{...g,...O,href:C||T,onClick:E||s?e:L,ref:$T(y,P),target:u,"data-discover":!w&&t==="render"?"true":void 0});return M&&!w?S.createElement(S.Fragment,null,F,S.createElement(_T,{page:T})):F});ti.displayName="Link";var UT=S.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:r="",end:i=!1,style:s,to:o,viewTransition:a,children:u,...f},h){let p=sc(o,{relative:f.relative}),g=Ar(),y=S.useContext(dd),{navigator:x,basename:w}=S.useContext(Pr),C=y!=null&&eM(p)&&a===!0,E=x.encodeLocation?x.encodeLocation(p).pathname:p.pathname,T=g.pathname,M=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;t||(T=T.toLowerCase(),M=M?M.toLowerCase():null,E=E.toLowerCase()),M&&w&&(M=Ei(M,w)||M);const P=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let O=T===E||!i&&T.startsWith(E)&&T.charAt(P)==="/",N=M!=null&&(M===E||!i&&M.startsWith(E)&&M.charAt(E.length)==="/"),L={isActive:O,isPending:N,isTransitioning:C},F=O?e:void 0,U;typeof r=="function"?U=r(L):U=[r,O?"active":null,N?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let Q=typeof s=="function"?s(L):s;return S.createElement(ti,{...f,"aria-current":F,className:U,ref:h,style:Q,to:o,viewTransition:a},typeof u=="function"?u(L):u)});UT.displayName="NavLink";var qT=S.forwardRef(({discover:n="render",fetcherKey:e,navigate:t,reloadDocument:r,replace:i,state:s,method:o=uf,action:a,onSubmit:u,relative:f,preventScrollReset:h,viewTransition:p,...g},y)=>{let x=JT(),w=ZT(a,{relative:f}),C=o.toLowerCase()==="get"?"get":"post",E=typeof a=="string"&&h2.test(a),T=M=>{if(u&&u(M),M.defaultPrevented)return;M.preventDefault();let P=M.nativeEvent.submitter,O=(P==null?void 0:P.getAttribute("formmethod"))||o;x(P||M.currentTarget,{fetcherKey:e,method:O,navigate:t,replace:i,state:s,relative:f,preventScrollReset:h,viewTransition:p})};return S.createElement("form",{ref:y,method:C,action:w,onSubmit:r?u:T,...g,"data-discover":!E&&n==="render"?"true":void 0})});qT.displayName="Form";function KT(n){return`${n} must be used within a data router.  See https://reactrouter.com/en/main/routers/picking-a-router.`}function p2(n){let e=S.useContext(dl);return Ct(e,KT(n)),e}function QT(n,{target:e,replace:t,state:r,preventScrollReset:i,relative:s,viewTransition:o}={}){let a=hd(),u=Ar(),f=sc(n,{relative:s});return S.useCallback(h=>{if(ET(h,e)){h.preventDefault();let p=t!==void 0?t:Na(u)===Na(f);a(n,{replace:p,state:r,preventScrollReset:i,relative:s,viewTransition:o})}},[u,a,f,t,r,e,n,i,s,o])}function GT(n){fr(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=S.useRef(Rm(n)),t=S.useRef(!1),r=Ar(),i=S.useMemo(()=>RT(r.search,t.current?null:e.current),[r.search]),s=hd(),o=S.useCallback((a,u)=>{const f=Rm(typeof a=="function"?a(new URLSearchParams(i)):a);t.current=!0,s("?"+f,u)},[s,i]);return[i,o]}var YT=0,XT=()=>`__${String(++YT)}__`;function JT(){let{router:n}=p2("useSubmit"),{basename:e}=S.useContext(Pr),t=pT();return S.useCallback(async(r,i={})=>{let{action:s,method:o,encType:a,formData:u,body:f}=OT(r,e);if(i.navigate===!1){let h=i.fetcherKey||XT();await n.fetch(h,t,i.action||s,{preventScrollReset:i.preventScrollReset,formData:u,body:f,formMethod:i.method||o,formEncType:i.encType||a,flushSync:i.flushSync})}else await n.navigate(i.action||s,{preventScrollReset:i.preventScrollReset,formData:u,body:f,formMethod:i.method||o,formEncType:i.encType||a,replace:i.replace,state:i.state,fromRouteId:t,flushSync:i.flushSync,viewTransition:i.viewTransition})},[n,e,t])}function ZT(n,{relative:e}={}){let{basename:t}=S.useContext(Pr),r=S.useContext(hr);Ct(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...sc(n||".",{relative:e})},o=Ar();if(n==null){s.search=o.search;let a=new URLSearchParams(s.search),u=a.getAll("index");if(u.some(h=>h==="")){a.delete("index"),u.filter(p=>p).forEach(p=>a.append("index",p));let h=a.toString();s.search=h?`?${h}`:""}}return(!n||n===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(s.pathname=s.pathname==="/"?t:ki([t,s.pathname])),Na(s)}function eM(n,{relative:e}={}){let t=S.useContext(s2);Ct(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`.  Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=p2("useViewTransitionState"),i=sc(n,{relative:e});if(!t.isTransitioning)return!1;let s=Ei(t.currentLocation.pathname,r)||t.currentLocation.pathname,o=Ei(t.nextLocation.pathname,r)||t.nextLocation.pathname;return Rf(i.pathname,o)!=null||Rf(i.pathname,s)!=null}var Mr=e2();/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const tM=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nM=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),Hx=n=>{const e=nM(n);return e.charAt(0).toUpperCase()+e.slice(1)},m2=(...n)=>n.filter((e,t,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===t).join(" ").trim(),rM=n=>{for(const e in n)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */var iM={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const sM=S.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...a},u)=>S.createElement("svg",{ref:u,...iM,width:e,height:e,stroke:n,strokeWidth:r?Number(t)*24/Number(e):t,className:m2("lucide",i),...!s&&!rM(a)&&{"aria-hidden":"true"},...a},[...o.map(([f,h])=>S.createElement(f,h)),...Array.isArray(s)?s:[s]]));/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vt=(n,e)=>{const t=S.forwardRef(({className:r,...i},s)=>S.createElement(sM,{ref:s,iconNode:e,className:m2(`lucide-${tM(Hx(n))}`,`lucide-${n}`,r),...i}));return t.displayName=Hx(n),t};/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oM=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],lM=Vt("check",oM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const aM=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],cM=Vt("chevron-down",aM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const uM=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],fM=Vt("chevron-left",uM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const dM=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],hM=Vt("chevron-right",dM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],gd=Vt("circle-alert",pM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const mM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],g2=Vt("circle-check",mM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const gM=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],yM=Vt("copy",gM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const vM=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],xM=Vt("history",vM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const wM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],bM=Vt("info",wM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const SM=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],y2=Vt("loader-circle",SM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const kM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],v2=Vt("lock",kM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const CM=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],EM=Vt("menu",CM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const RM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],TM=Vt("panel-left-close",RM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const MM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],OM=Vt("panel-left-open",MM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const PM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],AM=Vt("panels-top-left",PM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const NM=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],LM=Vt("pencil-line",NM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const DM=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],IM=Vt("play",DM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const jM=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],BM=Vt("table-2",jM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const FM=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],zM=Vt("triangle-alert",FM);/**
 * @license lucide-react v0.562.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _M=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],yd=Vt("x",_M);function Tm(n,e){if(n&&!e)return n;if(!n&&e)return e;if(n||e)return{...n,...e}}const ba={};function vd(n,e,t,r,i){let s={...Mm(n,ba)};return e&&(s=df(s,e)),t&&(s=df(s,t)),r&&(s=df(s,r)),s}function VM(n){if(n.length===0)return ba;if(n.length===1)return Mm(n[0],ba);let e={...Mm(n[0],ba)};for(let t=1;t<n.length;t+=1)e=df(e,n[t]);return e}function df(n,e){return x2(e)?e(n):WM(n,e)}function WM(n,e){if(!e)return n;for(const t in e){const r=e[t];switch(t){case"style":{n[t]=Tm(n.style,r);break}case"className":{n[t]=w2(n.className,r);break}default:$M(t,r)?n[t]=HM(n[t],r):n[t]=r}}return n}function $M(n,e){const t=n.charCodeAt(0),r=n.charCodeAt(1),i=n.charCodeAt(2);return t===111&&r===110&&i>=65&&i<=90&&(typeof e=="function"||typeof e>"u")}function x2(n){return typeof n=="function"}function Mm(n,e){return x2(n)?n(e):n??ba}function HM(n,e){return e?n?t=>{if(UM(t)){const i=t;Om(i);const s=e(i);return i.baseUIHandlerPrevented||n==null||n(i),s}const r=e(t);return n==null||n(t),r}:e:n}function Om(n){return n.preventBaseUIHandler=()=>{n.baseUIHandlerPrevented=!0},n}function w2(n,e){return e?n?e+" "+n:e:n}function UM(n){return n!=null&&typeof n=="object"&&"nativeEvent"in n}function gn(n,...e){const t=new URL(`https://base-ui.com/production-error/${n}`);return e.forEach(r=>t.searchParams.append("args[]",r)),`Base UI error #${n}; visit ${t} for the full message.`}const Ux={};function ri(n,e){const t=S.useRef(Ux);return t.current===Ux&&(t.current=n(e)),t}function La(n,e,t,r){const i=ri(b2).current;return KM(i,n,e,t,r)&&S2(i,[n,e,t,r]),i.callback}function qM(n){const e=ri(b2).current;return QM(e,n)&&S2(e,n),e.callback}function b2(){return{callback:null,cleanup:null,refs:[]}}function KM(n,e,t,r,i){return n.refs[0]!==e||n.refs[1]!==t||n.refs[2]!==r||n.refs[3]!==i}function QM(n,e){return n.refs.length!==e.length||n.refs.some((t,r)=>t!==e[r])}function S2(n,e){if(n.refs=e,e.every(t=>t==null)){n.callback=null;return}n.callback=t=>{if(n.cleanup&&(n.cleanup(),n.cleanup=null),t!=null){const r=Array(e.length).fill(null);for(let i=0;i<e.length;i+=1){const s=e[i];if(s!=null)switch(typeof s){case"function":{const o=s(t);typeof o=="function"&&(r[i]=o);break}case"object":{s.current=t;break}}}n.cleanup=()=>{for(let i=0;i<e.length;i+=1){const s=e[i];if(s!=null)switch(typeof s){case"function":{const o=r[i];typeof o=="function"?o():s(null);break}case"object":{s.current=null;break}}}}}}}const GM=parseInt(S.version,10);function Kg(n){return GM>=n}function qx(n){if(!S.isValidElement(n))return null;const e=n,t=e.props;return(Kg(19)?t==null?void 0:t.ref:e.ref)??null}function YM(n,e){const t={};for(const r in n){const i=n[r];if(e!=null&&e.hasOwnProperty(r)){const s=e[r](i);s!=null&&Object.assign(t,s);continue}i===!0?t[`data-${r.toLowerCase()}`]="":i&&(t[`data-${r.toLowerCase()}`]=i.toString())}return t}function XM(n,e){return typeof n=="function"?n(e):n}function JM(n,e){return typeof n=="function"?n(e):n}function Nn(){}const tn=Object.freeze({}),ZM={style:{transition:"none"}},k2="data-base-ui-click-trigger",eO={fallbackAxisSide:"end"},tO={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function At(n,e,t={}){const r=e.render,i=nO(e,t);if(t.enabled===!1)return null;const s=t.state??tn;return rO(n,r,i,s)}function nO(n,e={}){const{className:t,style:r,render:i}=n,{state:s=tn,ref:o,props:a,stateAttributesMapping:u,enabled:f=!0}=e,h=f?XM(t,s):void 0,p=f?JM(r,s):void 0,g=f?YM(s,u):tn,y=f?Tm(g,Array.isArray(a)?VM(a):a)??tn:tn;return typeof document<"u"&&(f?Array.isArray(o)?y.ref=qM([y.ref,qx(i),...o]):y.ref=La(y.ref,qx(i),o):La(null,null)),f?(h!==void 0&&(y.className=w2(y.className,h)),p!==void 0&&(y.style=Tm(y.style,p)),y):tn}function rO(n,e,t,r){if(e){if(typeof e=="function")return e(t,r);const i=vd(t,e.props);return i.ref=t.ref,S.cloneElement(e,i)}if(n&&typeof n=="string")return iO(n,t);throw new Error(gn(8))}function iO(n,e){return n==="button"?S.createElement("button",{type:"button",...e,key:e.key}):n==="img"?S.createElement("img",{alt:"",...e,key:e.key}):S.createElement(n,e)}function sO(n){return At(n.defaultTagName??"div",n,n)}function C2(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=C2(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function E2(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=C2(n))&&(r&&(r+=" "),r+=e);return r}const Kx=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,Qx=E2,oO=(n,e)=>t=>{var r;if((e==null?void 0:e.variants)==null)return Qx(n,t==null?void 0:t.class,t==null?void 0:t.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(f=>{const h=t==null?void 0:t[f],p=s==null?void 0:s[f];if(h===null)return null;const g=Kx(h)||Kx(p);return i[f][g]}),a=t&&Object.entries(t).reduce((f,h)=>{let[p,g]=h;return g===void 0||(f[p]=g),f},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((f,h)=>{let{class:p,className:g,...y}=h;return Object.entries(y).every(x=>{let[w,C]=x;return Array.isArray(C)?C.includes({...s,...a}[w]):{...s,...a}[w]===C})?[...f,p,g]:f},[]);return Qx(n,o,u,t==null?void 0:t.class,t==null?void 0:t.className)},Qg="-",lO=n=>{const e=cO(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:o=>{const a=o.split(Qg);return a[0]===""&&a.length!==1&&a.shift(),R2(a,e)||aO(o)},getConflictingClassGroupIds:(o,a)=>{const u=t[o]||[];return a&&r[o]?[...u,...r[o]]:u}}},R2=(n,e)=>{var o;if(n.length===0)return e.classGroupId;const t=n[0],r=e.nextPart.get(t),i=r?R2(n.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=n.join(Qg);return(o=e.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},Gx=/^\[(.+)\]$/,aO=n=>{if(Gx.test(n)){const e=Gx.exec(n)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},cO=n=>{const{theme:e,prefix:t}=n,r={nextPart:new Map,validators:[]};return fO(Object.entries(n.classGroups),t).forEach(([s,o])=>{Pm(o,r,s,e)}),r},Pm=(n,e,t,r)=>{n.forEach(i=>{if(typeof i=="string"){const s=i===""?e:Yx(e,i);s.classGroupId=t;return}if(typeof i=="function"){if(uO(i)){Pm(i(r),e,t,r);return}e.validators.push({validator:i,classGroupId:t});return}Object.entries(i).forEach(([s,o])=>{Pm(o,Yx(e,s),t,r)})})},Yx=(n,e)=>{let t=n;return e.split(Qg).forEach(r=>{t.nextPart.has(r)||t.nextPart.set(r,{nextPart:new Map,validators:[]}),t=t.nextPart.get(r)}),t},uO=n=>n.isThemeGetter,fO=(n,e)=>e?n.map(([t,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[t,i]}):n,dO=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,r=new Map;const i=(s,o)=>{t.set(s,o),e++,e>n&&(e=0,r=t,t=new Map)};return{get(s){let o=t.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){t.has(s)?t.set(s,o):i(s,o)}}},T2="!",hO=n=>{const{separator:e,experimentalParseClassName:t}=n,r=e.length===1,i=e[0],s=e.length,o=a=>{const u=[];let f=0,h=0,p;for(let C=0;C<a.length;C++){let E=a[C];if(f===0){if(E===i&&(r||a.slice(C,C+s)===e)){u.push(a.slice(h,C)),h=C+s;continue}if(E==="/"){p=C;continue}}E==="["?f++:E==="]"&&f--}const g=u.length===0?a:a.substring(h),y=g.startsWith(T2),x=y?g.substring(1):g,w=p&&p>h?p-h:void 0;return{modifiers:u,hasImportantModifier:y,baseClassName:x,maybePostfixModifierPosition:w}};return t?a=>t({className:a,parseClassName:o}):o},pO=n=>{if(n.length<=1)return n;const e=[];let t=[];return n.forEach(r=>{r[0]==="["?(e.push(...t.sort(),r),t=[]):t.push(r)}),e.push(...t.sort()),e},mO=n=>({cache:dO(n.cacheSize),parseClassName:hO(n),...lO(n)}),gO=/\s+/,yO=(n,e)=>{const{parseClassName:t,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=n.trim().split(gO);let a="";for(let u=o.length-1;u>=0;u-=1){const f=o[u],{modifiers:h,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:y}=t(f);let x=!!y,w=r(x?g.substring(0,y):g);if(!w){if(!x){a=f+(a.length>0?" "+a:a);continue}if(w=r(g),!w){a=f+(a.length>0?" "+a:a);continue}x=!1}const C=pO(h).join(":"),E=p?C+T2:C,T=E+w;if(s.includes(T))continue;s.push(T);const M=i(w,x);for(let P=0;P<M.length;++P){const O=M[P];s.push(E+O)}a=f+(a.length>0?" "+a:a)}return a};function vO(){let n=0,e,t,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=M2(e))&&(r&&(r+=" "),r+=t);return r}const M2=n=>{if(typeof n=="string")return n;let e,t="";for(let r=0;r<n.length;r++)n[r]&&(e=M2(n[r]))&&(t&&(t+=" "),t+=e);return t};function xO(n,...e){let t,r,i,s=o;function o(u){const f=e.reduce((h,p)=>p(h),n());return t=mO(f),r=t.cache.get,i=t.cache.set,s=a,a(u)}function a(u){const f=r(u);if(f)return f;const h=yO(u,t);return i(u,h),h}return function(){return s(vO.apply(null,arguments))}}const bt=n=>{const e=t=>t[n]||[];return e.isThemeGetter=!0,e},O2=/^\[(?:([a-z-]+):)?(.+)\]$/i,wO=/^\d+\/\d+$/,bO=new Set(["px","full","screen"]),SO=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,kO=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,CO=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,EO=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,RO=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xi=n=>Wo(n)||bO.has(n)||wO.test(n),es=n=>pl(n,"length",DO),Wo=n=>!!n&&!Number.isNaN(Number(n)),Np=n=>pl(n,"number",Wo),sa=n=>!!n&&Number.isInteger(Number(n)),TO=n=>n.endsWith("%")&&Wo(n.slice(0,-1)),$e=n=>O2.test(n),ts=n=>SO.test(n),MO=new Set(["length","size","percentage"]),OO=n=>pl(n,MO,P2),PO=n=>pl(n,"position",P2),AO=new Set(["image","url"]),NO=n=>pl(n,AO,jO),LO=n=>pl(n,"",IO),oa=()=>!0,pl=(n,e,t)=>{const r=O2.exec(n);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):t(r[2]):!1},DO=n=>kO.test(n)&&!CO.test(n),P2=()=>!1,IO=n=>EO.test(n),jO=n=>RO.test(n),BO=()=>{const n=bt("colors"),e=bt("spacing"),t=bt("blur"),r=bt("brightness"),i=bt("borderColor"),s=bt("borderRadius"),o=bt("borderSpacing"),a=bt("borderWidth"),u=bt("contrast"),f=bt("grayscale"),h=bt("hueRotate"),p=bt("invert"),g=bt("gap"),y=bt("gradientColorStops"),x=bt("gradientColorStopPositions"),w=bt("inset"),C=bt("margin"),E=bt("opacity"),T=bt("padding"),M=bt("saturate"),P=bt("scale"),O=bt("sepia"),N=bt("skew"),L=bt("space"),F=bt("translate"),U=()=>["auto","contain","none"],Q=()=>["auto","hidden","clip","visible","scroll"],q=()=>["auto",$e,e],H=()=>[$e,e],j=()=>["",xi,es],Y=()=>["auto",Wo,$e],W=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],_=()=>["solid","dashed","dotted","double","none"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D=()=>["start","end","center","between","around","evenly","stretch"],B=()=>["","0",$e],K=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>[Wo,$e];return{cacheSize:500,separator:":",theme:{colors:[oa],spacing:[xi,es],blur:["none","",ts,$e],brightness:A(),borderColor:[n],borderRadius:["none","","full",ts,$e],borderSpacing:H(),borderWidth:j(),contrast:A(),grayscale:B(),hueRotate:A(),invert:B(),gap:H(),gradientColorStops:[n],gradientColorStopPositions:[TO,es],inset:q(),margin:q(),opacity:A(),padding:H(),saturate:A(),scale:A(),sepia:B(),skew:A(),space:H(),translate:H()},classGroups:{aspect:[{aspect:["auto","square","video",$e]}],container:["container"],columns:[{columns:[ts]}],"break-after":[{"break-after":K()}],"break-before":[{"break-before":K()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...W(),$e]}],overflow:[{overflow:Q()}],"overflow-x":[{"overflow-x":Q()}],"overflow-y":[{"overflow-y":Q()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",sa,$e]}],basis:[{basis:q()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",$e]}],grow:[{grow:B()}],shrink:[{shrink:B()}],order:[{order:["first","last","none",sa,$e]}],"grid-cols":[{"grid-cols":[oa]}],"col-start-end":[{col:["auto",{span:["full",sa,$e]},$e]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[oa]}],"row-start-end":[{row:["auto",{span:[sa,$e]},$e]}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",$e]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",$e]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...D()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...D(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...D(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[T]}],px:[{px:[T]}],py:[{py:[T]}],ps:[{ps:[T]}],pe:[{pe:[T]}],pt:[{pt:[T]}],pr:[{pr:[T]}],pb:[{pb:[T]}],pl:[{pl:[T]}],m:[{m:[C]}],mx:[{mx:[C]}],my:[{my:[C]}],ms:[{ms:[C]}],me:[{me:[C]}],mt:[{mt:[C]}],mr:[{mr:[C]}],mb:[{mb:[C]}],ml:[{ml:[C]}],"space-x":[{"space-x":[L]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[L]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",$e,e]}],"min-w":[{"min-w":[$e,e,"min","max","fit"]}],"max-w":[{"max-w":[$e,e,"none","full","min","max","fit","prose",{screen:[ts]},ts]}],h:[{h:[$e,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[$e,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[$e,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[$e,e,"auto","min","max","fit"]}],"font-size":[{text:["base",ts,es]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Np]}],"font-family":[{font:[oa]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",$e]}],"line-clamp":[{"line-clamp":["none",Wo,Np]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",xi,$e]}],"list-image":[{"list-image":["none",$e]}],"list-style-type":[{list:["none","disc","decimal",$e]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[n]}],"placeholder-opacity":[{"placeholder-opacity":[E]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[n]}],"text-opacity":[{"text-opacity":[E]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[..._(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",xi,es]}],"underline-offset":[{"underline-offset":["auto",xi,$e]}],"text-decoration-color":[{decoration:[n]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:H()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$e]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",$e]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[E]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...W(),PO]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",OO]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},NO]}],"bg-color":[{bg:[n]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[y]}],"gradient-via":[{via:[y]}],"gradient-to":[{to:[y]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[E]}],"border-style":[{border:[..._(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[E]}],"divide-style":[{divide:_()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",..._()]}],"outline-offset":[{"outline-offset":[xi,$e]}],"outline-w":[{outline:[xi,es]}],"outline-color":[{outline:[n]}],"ring-w":[{ring:j()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[n]}],"ring-opacity":[{"ring-opacity":[E]}],"ring-offset-w":[{"ring-offset":[xi,es]}],"ring-offset-color":[{"ring-offset":[n]}],shadow:[{shadow:["","inner","none",ts,LO]}],"shadow-color":[{shadow:[oa]}],opacity:[{opacity:[E]}],"mix-blend":[{"mix-blend":[...X(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":X()}],filter:[{filter:["","none"]}],blur:[{blur:[t]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",ts,$e]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[p]}],saturate:[{saturate:[M]}],sepia:[{sepia:[O]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[t]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[E]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[O]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",$e]}],duration:[{duration:A()}],ease:[{ease:["linear","in","out","in-out",$e]}],delay:[{delay:A()}],animate:[{animate:["none","spin","ping","pulse","bounce",$e]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[P]}],"scale-x":[{"scale-x":[P]}],"scale-y":[{"scale-y":[P]}],rotate:[{rotate:[sa,$e]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[N]}],"skew-y":[{"skew-y":[N]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",$e]}],accent:[{accent:["auto",n]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",$e]}],"caret-color":[{caret:[n]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":H()}],"scroll-mx":[{"scroll-mx":H()}],"scroll-my":[{"scroll-my":H()}],"scroll-ms":[{"scroll-ms":H()}],"scroll-me":[{"scroll-me":H()}],"scroll-mt":[{"scroll-mt":H()}],"scroll-mr":[{"scroll-mr":H()}],"scroll-mb":[{"scroll-mb":H()}],"scroll-ml":[{"scroll-ml":H()}],"scroll-p":[{"scroll-p":H()}],"scroll-px":[{"scroll-px":H()}],"scroll-py":[{"scroll-py":H()}],"scroll-ps":[{"scroll-ps":H()}],"scroll-pe":[{"scroll-pe":H()}],"scroll-pt":[{"scroll-pt":H()}],"scroll-pr":[{"scroll-pr":H()}],"scroll-pb":[{"scroll-pb":H()}],"scroll-pl":[{"scroll-pl":H()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",$e]}],fill:[{fill:[n,"none"]}],"stroke-w":[{stroke:[xi,es,Np]}],stroke:[{stroke:[n,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},FO=xO(BO);function et(...n){return FO(E2(n))}function Am(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const n=crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&63|128;const e=Array.from(n,t=>t.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}const A2=oO("[&_svg]:-mx-0.5 relative inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-lg border font-medium text-base outline-none transition-[background-color,box-shadow] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:bg-disabled disabled:text-disabled-foreground disabled:border-transparent disabled:before:hidden sm:text-sm [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",{defaultVariants:{size:"default",variant:"default"},variants:{size:{default:"h-9 px-[calc(--spacing(3)-1px)] sm:h-8",icon:"size-9 sm:size-8","icon-lg":"size-10 sm:size-9","icon-sm":"size-8 sm:size-7","icon-xl":"size-11 sm:size-10 [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5","icon-xs":"size-7 rounded-sm before:rounded-[calc(var(--radius-sm)-1px)] sm:size-6 not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-4 sm:not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-3.5",lg:"h-10 px-[calc(--spacing(3.5)-1px)] sm:h-9",sm:"h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:h-7",xl:"h-11 px-[calc(--spacing(4)-1px)] text-lg sm:h-10 sm:text-base [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5",xs:"h-7 gap-1 rounded-sm px-[calc(--spacing(2)-1px)] text-sm before:rounded-[calc(var(--radius-sm)-1px)] sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5"},variant:{default:"border-primary bg-primary text-primary-foreground not-disabled:hover:bg-primary-hover not-disabled:active:bg-primary-active data-pressed:bg-primary-active",destructive:"border-destructive bg-destructive text-white hover:bg-destructive/90","destructive-outline":"border-border bg-transparent bg-clip-padding text-destructive-foreground dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border [:hover,[data-pressed]]:border-destructive/32 [:hover,[data-pressed]]:bg-destructive/4",ghost:"border-transparent hover:bg-accent data-pressed:bg-accent",link:"border-transparent underline-offset-4 hover:underline",outline:"border-border bg-background bg-clip-padding dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/90 [:active,[data-pressed]]:bg-secondary/80"}}});function Dn({className:n,variant:e,size:t,render:r,...i}){const s=r?void 0:"button",o={className:et(A2({className:n,size:t,variant:e})),"data-slot":"button",type:s};return sO({defaultTagName:"button",props:vd(o,i),render:r})}const zO=()=>{},Be=typeof document<"u"?S.useLayoutEffect:zO,N2=S.createContext(void 0);function oc(n){const e=S.useContext(N2);if(e===void 0&&!n)throw new Error(gn(72));return e}const _O=[];function L2(n){S.useEffect(n,_O)}const la=0;class ni{constructor(){ft(this,"currentId",la);ft(this,"clear",()=>{this.currentId!==la&&(clearTimeout(this.currentId),this.currentId=la)});ft(this,"disposeEffect",()=>this.clear)}static create(){return new ni}start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=la,t()},e)}isStarted(){return this.currentId!==la}}function Ri(){const n=ri(ni.create).current;return L2(n.disposeEffect),n}function xd(){return typeof window<"u"}function vs(n){return Gg(n)?(n.nodeName||"").toLowerCase():"#document"}function Pt(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function ii(n){var e;return(e=(Gg(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Gg(n){return xd()?n instanceof Node||n instanceof Pt(n).Node:!1}function ct(n){return xd()?n instanceof Element||n instanceof Pt(n).Element:!1}function zt(n){return xd()?n instanceof HTMLElement||n instanceof Pt(n).HTMLElement:!1}function Nm(n){return!xd()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Pt(n).ShadowRoot}const VO=new Set(["inline","contents"]);function oo(n){const{overflow:e,overflowX:t,overflowY:r,display:i}=Fn(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!VO.has(i)}const WO=new Set(["table","td","th"]);function $O(n){return WO.has(vs(n))}const HO=[":popover-open",":modal"];function wd(n){return HO.some(e=>{try{return n.matches(e)}catch{return!1}})}const UO=["transform","translate","scale","rotate","perspective"],qO=["transform","translate","scale","rotate","perspective","filter"],KO=["paint","layout","strict","content"];function Yg(n){const e=bd(),t=ct(n)?Fn(n):n;return UO.some(r=>t[r]?t[r]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||qO.some(r=>(t.willChange||"").includes(r))||KO.some(r=>(t.contain||"").includes(r))}function QO(n){let e=Ti(n);for(;zt(e)&&!Ci(e);){if(Yg(e))return e;if(wd(e))return null;e=Ti(e)}return null}function bd(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const GO=new Set(["html","body","#document"]);function Ci(n){return GO.has(vs(n))}function Fn(n){return Pt(n).getComputedStyle(n)}function Sd(n){return ct(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Ti(n){if(vs(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Nm(n)&&n.host||ii(n);return Nm(e)?e.host:e}function D2(n){const e=Ti(n);return Ci(e)?n.ownerDocument?n.ownerDocument.body:n.body:zt(e)&&oo(e)?e:D2(e)}function cs(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const i=D2(n),s=i===((r=n.ownerDocument)==null?void 0:r.body),o=Pt(i);if(s){const a=Lm(o);return e.concat(o,o.visualViewport||[],oo(i)?i:[],a&&t?cs(a):[])}return e.concat(i,cs(i,[],t))}function Lm(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Cr(n){const e=ri(YO,n).current;return e.next=n,Be(e.effect),e}function YO(n){const e={current:n,next:n,effect:()=>{e.current=e.next}};return e}const Lp=Zb[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],XO=Lp&&Lp!==S.useLayoutEffect?Lp:n=>n();function Ne(n){const e=ri(JO).current;return e.next=n,XO(e.effect),e.trampoline}function JO(){const n={next:void 0,callback:ZO,trampoline:(...e)=>{var t;return(t=n.callback)==null?void 0:t.call(n,...e)},effect:()=>{n.callback=n.next}};return n}function ZO(){}const ml=typeof navigator<"u",Dp=rP(),I2=sP(),j2=iP(),eP=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),tP=Dp.platform==="MacIntel"&&Dp.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Dp.platform),B2=ml&&/apple/i.test(navigator.vendor),Dm=ml&&/android/i.test(I2)||/android/i.test(j2),nP=ml&&I2.toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints,F2=j2.includes("jsdom/");function rP(){if(!ml)return{platform:"",maxTouchPoints:-1};const n=navigator.userAgentData;return n!=null&&n.platform?{platform:n.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function iP(){if(!ml)return"";const n=navigator.userAgentData;return n&&Array.isArray(n.brands)?n.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" "):navigator.userAgent}function sP(){if(!ml)return"";const n=navigator.userAgentData;return n!=null&&n.platform?n.platform:navigator.platform??""}const Im="data-base-ui-focusable",z2="active",_2="selected",V2="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function ir(n){var t;let e=n.activeElement;for(;((t=e==null?void 0:e.shadowRoot)==null?void 0:t.activeElement)!=null;)e=e.shadowRoot.activeElement;return e}function Xe(n,e){var r;if(!n||!e)return!1;const t=(r=e.getRootNode)==null?void 0:r.call(e);if(n.contains(e))return!0;if(t&&Nm(t)){let i=e;for(;i;){if(n===i)return!0;i=i.parentNode||i.host}}return!1}function en(n){return"composedPath"in n?n.composedPath()[0]:n.target}function Sr(n,e){if(e==null)return!1;if("composedPath"in n)return n.composedPath().includes(e);const t=n;return t.target!=null&&e.contains(t.target)}function oP(n){return n.matches("html,body")}function qt(n){return(n==null?void 0:n.ownerDocument)||document}function Xg(n){return zt(n)&&n.matches(V2)}function Xx(n){return n?n.getAttribute("role")==="combobox"&&Xg(n):!1}function Tf(n){if(!n||F2)return!0;try{return n.matches(":focus-visible")}catch{return!0}}function jm(n){return n?n.hasAttribute(Im)?n:n.querySelector(`[${Im}]`)||n:null}function Gs(n,e,t=!0){return n.filter(i=>{var s;return i.parentId===e&&(!t||((s=i.context)==null?void 0:s.open))}).flatMap(i=>[i,...Gs(n,i.id,t)])}function Jx(n,e){var i;let t=[],r=(i=n.find(s=>s.id===e))==null?void 0:i.parentId;for(;r;){const s=n.find(o=>o.id===r);r=s==null?void 0:s.parentId,s&&(t=t.concat(s))}return t}function lP(n){n.preventDefault(),n.stopPropagation()}function aP(n){return"nativeEvent"in n}function cP(n){return n.mozInputSource===0&&n.isTrusted?!0:Dm&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function uP(n){return F2?!1:!Dm&&n.width===0&&n.height===0||Dm&&n.width===1&&n.height===1&&n.pressure===0&&n.detail===0&&n.pointerType==="mouse"||n.width<1&&n.height<1&&n.pressure===0&&n.detail===0&&n.pointerType==="touch"}function eo(n,e){const t=["mouse","pen"];return e||t.push("",void 0),t.includes(n)}function W2(n){const e=n.type;return e==="click"||e==="mousedown"||e==="keydown"||e==="keyup"}const fP=["top","right","bottom","left"],Jo=Math.min,Kn=Math.max,Zo=Math.round,Au=Math.floor,Zr=n=>({x:n,y:n}),dP={left:"right",right:"left",bottom:"top",top:"bottom"},hP={start:"end",end:"start"};function Bm(n,e,t){return Kn(n,Jo(e,t))}function Mi(n,e){return typeof n=="function"?n(e):n}function Bn(n){return n.split("-")[0]}function xs(n){return n.split("-")[1]}function Jg(n){return n==="x"?"y":"x"}function Zg(n){return n==="y"?"height":"width"}const pP=new Set(["top","bottom"]);function sr(n){return pP.has(Bn(n))?"y":"x"}function e0(n){return Jg(sr(n))}function mP(n,e,t){t===void 0&&(t=!1);const r=xs(n),i=e0(n),s=Zg(i);let o=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Mf(o)),[o,Mf(o)]}function gP(n){const e=Mf(n);return[Fm(n),e,Fm(e)]}function Fm(n){return n.replace(/start|end/g,e=>hP[e])}const Zx=["left","right"],e1=["right","left"],yP=["top","bottom"],vP=["bottom","top"];function xP(n,e,t){switch(n){case"top":case"bottom":return t?e?e1:Zx:e?Zx:e1;case"left":case"right":return e?yP:vP;default:return[]}}function wP(n,e,t,r){const i=xs(n);let s=xP(Bn(n),t==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(Fm)))),s}function Mf(n){return n.replace(/left|right|bottom|top/g,e=>dP[e])}function bP(n){return{top:0,right:0,bottom:0,left:0,...n}}function $2(n){return typeof n!="number"?bP(n):{top:n,right:n,bottom:n,left:n}}function Of(n){const{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}/*!
* tabbable 6.3.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/var SP=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],Pf=SP.join(","),H2=typeof Element>"u",el=H2?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Af=!H2&&Element.prototype.getRootNode?function(n){var e;return n==null||(e=n.getRootNode)===null||e===void 0?void 0:e.call(n)}:function(n){return n==null?void 0:n.ownerDocument},Da=function(e,t){var r;t===void 0&&(t=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),s=i===""||i==="true",o=s||t&&e&&Da(e.parentNode);return o},kP=function(e){var t,r=e==null||(t=e.getAttribute)===null||t===void 0?void 0:t.call(e,"contenteditable");return r===""||r==="true"},U2=function(e,t,r){if(Da(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Pf));return t&&el.call(e,Pf)&&i.unshift(e),i=i.filter(r),i},Nf=function(e,t,r){for(var i=[],s=Array.from(e);s.length;){var o=s.shift();if(!Da(o,!1))if(o.tagName==="SLOT"){var a=o.assignedElements(),u=a.length?a:o.children,f=Nf(u,!0,r);r.flatten?i.push.apply(i,f):i.push({scopeParent:o,candidates:f})}else{var h=el.call(o,Pf);h&&r.filter(o)&&(t||!e.includes(o))&&i.push(o);var p=o.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(o),g=!Da(p,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(o));if(p&&g){var y=Nf(p===!0?o.children:p.children,!0,r);r.flatten?i.push.apply(i,y):i.push({scopeParent:o,candidates:y})}else s.unshift.apply(s,o.children)}}return i},q2=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},K2=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||kP(e))&&!q2(e)?0:e.tabIndex},CP=function(e,t){var r=K2(e);return r<0&&t&&!q2(e)?0:r},EP=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},Q2=function(e){return e.tagName==="INPUT"},RP=function(e){return Q2(e)&&e.type==="hidden"},TP=function(e){var t=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return t},MP=function(e,t){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===t)return e[r]},OP=function(e){if(!e.name)return!0;var t=e.form||Af(e),r=function(a){return t.querySelectorAll('input[type="radio"][name="'+a+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var s=MP(i,e.form);return!s||s===e},PP=function(e){return Q2(e)&&e.type==="radio"},AP=function(e){return PP(e)&&!OP(e)},NP=function(e){var t,r=e&&Af(e),i=(t=r)===null||t===void 0?void 0:t.host,s=!1;if(r&&r!==e){var o,a,u;for(s=!!((o=i)!==null&&o!==void 0&&(a=o.ownerDocument)!==null&&a!==void 0&&a.contains(i)||e!=null&&(u=e.ownerDocument)!==null&&u!==void 0&&u.contains(e));!s&&i;){var f,h,p;r=Af(i),i=(f=r)===null||f===void 0?void 0:f.host,s=!!((h=i)!==null&&h!==void 0&&(p=h.ownerDocument)!==null&&p!==void 0&&p.contains(i))}}return s},t1=function(e){var t=e.getBoundingClientRect(),r=t.width,i=t.height;return r===0&&i===0},LP=function(e,t){var r=t.displayCheck,i=t.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var s=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!s}if(getComputedStyle(e).visibility==="hidden")return!0;var o=el.call(e,"details>summary:first-of-type"),a=o?e.parentElement:e;if(el.call(a,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var u=e;e;){var f=e.parentElement,h=Af(e);if(f&&!f.shadowRoot&&i(f)===!0)return t1(e);e.assignedSlot?e=e.assignedSlot:!f&&h!==e.ownerDocument?e=h.host:e=f}e=u}if(NP(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return t1(e);return!1},DP=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if(t.tagName==="FIELDSET"&&t.disabled){for(var r=0;r<t.children.length;r++){var i=t.children.item(r);if(i.tagName==="LEGEND")return el.call(t,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}t=t.parentElement}return!1},zm=function(e,t){return!(t.disabled||Da(t)||RP(t)||LP(t,e)||TP(t)||DP(t))},_m=function(e,t){return!(AP(t)||K2(t)<0||!zm(e,t))},IP=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},G2=function(e){var t=[],r=[];return e.forEach(function(i,s){var o=!!i.scopeParent,a=o?i.scopeParent:i,u=CP(a,o),f=o?G2(i.candidates):a;u===0?o?t.push.apply(t,f):t.push(a):r.push({documentOrder:s,tabIndex:u,item:i,isScope:o,content:f})}),r.sort(EP).reduce(function(i,s){return s.isScope?i.push.apply(i,s.content):i.push(s.content),i},[]).concat(t)},kd=function(e,t){t=t||{};var r;return t.getShadowRoot?r=Nf([e],t.includeContainer,{filter:_m.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:IP}):r=U2(e,t.includeContainer,_m.bind(null,t)),G2(r)},jP=function(e,t){t=t||{};var r;return t.getShadowRoot?r=Nf([e],t.includeContainer,{filter:zm.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):r=U2(e,t.includeContainer,zm.bind(null,t)),r},Y2=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return el.call(e,Pf)===!1?!1:_m(t,e)};const lc=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function X2(n,e){const t=kd(n,lc()),r=t.length;if(r===0)return;const i=ir(qt(n)),s=t.indexOf(i),o=s===-1?e===1?0:r-1:s+e;return t[o]}function J2(n){return X2(qt(n).body,1)||n}function Z2(n){return X2(qt(n).body,-1)||n}function Sa(n,e){const t=e||n.currentTarget,r=n.relatedTarget;return!r||!Xe(t,r)}function BP(n){kd(n,lc()).forEach(t=>{t.dataset.tabindex=t.getAttribute("tabindex")||"",t.setAttribute("tabindex","-1")})}function n1(n){n.querySelectorAll("[data-tabindex]").forEach(t=>{const r=t.dataset.tabindex;delete t.dataset.tabindex,r?t.setAttribute("tabindex",r):t.removeAttribute("tabindex")})}const FP={...Zb};let r1=0;function zP(n,e="mui"){const[t,r]=S.useState(n),i=n||t;return S.useEffect(()=>{t==null&&(r1+=1,r(`${e}-${r1}`))},[t,e]),i}const i1=FP.useId;function lo(n,e){if(i1!==void 0){const t=i1();return n??(e?`${e}-${t}`:t)}return zP(n,e)}function _P(){const n=new Map;return{emit(e,t){var r;(r=n.get(e))==null||r.forEach(i=>i(t))},on(e,t){n.has(e)||n.set(e,new Set),n.get(e).add(t)},off(e,t){var r;(r=n.get(e))==null||r.delete(t)}}}const VP=S.createContext(null),WP=S.createContext(null),Cd=()=>{var n;return((n=S.useContext(VP))==null?void 0:n.id)||null},ac=n=>{const e=S.useContext(WP);return n??e},cc="none",Ys="trigger-press",Kr="trigger-hover",Vm="trigger-focus",eS="outside-press",$P="close-press",tS="focus-out",t0="escape-key",HP="disabled",nS="imperative-action";function yt(n,e,t,r){let i=!1,s=!1;const o=tn;return{reason:n,event:e??new Event("base-ui"),cancel(){i=!0},allowPropagation(){s=!0},get isCanceled(){return i},get isPropagationAllowed(){return s},trigger:t,...o}}function tl(n){return`data-base-ui-${n}`}function hf(n,e,t){if(t&&!eo(t))return 0;if(typeof n=="number")return n;if(typeof n=="function"){const r=n();return typeof r=="number"?r:r==null?void 0:r[e]}return n==null?void 0:n[e]}const rS=S.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new ni,currentIdRef:{current:null},currentContextRef:{current:null}});function UP(n){const{children:e,delay:t,timeoutMs:r=0}=n,i=S.useRef(t),s=S.useRef(t),o=S.useRef(null),a=S.useRef(null),u=Ri();return k.jsx(rS.Provider,{value:S.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:s,currentIdRef:o,timeoutMs:r,currentContextRef:a,timeout:u}),[r,u]),children:e})}function qP(n,e={open:!1}){const t="rootStore"in n?n.rootStore:n,r=t.useState("floatingId"),{enabled:i=!0,open:s}=e,o=S.useContext(rS),{currentIdRef:a,delayRef:u,timeoutMs:f,initialDelayRef:h,currentContextRef:p,hasProvider:g,timeout:y}=o,[x,w]=S.useState(!1);return Be(()=>{function C(){var E;w(!1),(E=p.current)==null||E.setIsInstantPhase(!1),a.current=null,p.current=null,u.current=h.current}if(i&&a.current&&!s&&a.current===r){if(w(!1),f){const E=r;return y.start(f,()=>{t.select("open")||a.current&&a.current!==E||C()}),()=>{y.clear()}}C()}},[i,s,r,a,u,f,h,p,y,t]),Be(()=>{if(!i||!s)return;const C=p.current,E=a.current;y.clear(),p.current={onOpenChange:t.setOpen,setIsInstantPhase:w},a.current=r,u.current={open:0,close:hf(h.current,"close")},E!==null&&E!==r?(w(!0),C==null||C.setIsInstantPhase(!0),C==null||C.onOpenChange(!1,yt(cc))):(w(!1),C==null||C.setIsInstantPhase(!1))},[i,s,r,t,a,u,f,h,p,y]),Be(()=>()=>{p.current=null},[p]),S.useMemo(()=>({hasProvider:g,delayRef:u,isInstantPhase:x}),[g,u,x])}const Ed={clip:"rect(0 0 0 0)",overflow:"hidden",whiteSpace:"nowrap",position:"fixed",top:0,left:0,border:0,padding:0,width:1,height:1,margin:-1},Nu=null;class KP{constructor(){ft(this,"callbacks",[]);ft(this,"callbacksCount",0);ft(this,"nextId",1);ft(this,"startId",1);ft(this,"isScheduled",!1);ft(this,"tick",e=>{var i;this.isScheduled=!1;const t=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s<t.length;s+=1)(i=t[s])==null||i.call(t,e)})}request(e){const t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),t}cancel(e){const t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,this.callbacksCount-=1)}}const Lu=new KP;class qr{constructor(){ft(this,"currentId",Nu);ft(this,"cancel",()=>{this.currentId!==Nu&&(Lu.cancel(this.currentId),this.currentId=Nu)});ft(this,"disposeEffect",()=>this.cancel)}static create(){return new qr}static request(e){return Lu.request(e)}static cancel(e){return Lu.cancel(e)}request(e){this.cancel(),this.currentId=Lu.request(()=>{this.currentId=Nu,e()})}}function uc(){const n=ri(qr.create).current;return L2(n.disposeEffect),n}function or(n){return(n==null?void 0:n.ownerDocument)||document}const Xs=S.forwardRef(function(e,t){const[r,i]=S.useState();Be(()=>{B2&&i("button")},[]);const s={tabIndex:0,role:r};return k.jsx("span",{...e,ref:t,style:Ed,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});let s1=0;function Ip(n,e={}){const{preventScroll:t=!1,cancelPrevious:r=!0,sync:i=!1}=e;r&&cancelAnimationFrame(s1);const s=()=>n==null?void 0:n.focus({preventScroll:t});i?s():s1=requestAnimationFrame(s)}const $o={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function o1(n){return n==="inert"?$o.inert:n==="aria-hidden"?$o["aria-hidden"]:$o.none}let Du=new WeakSet,Iu={},jp=0;const iS=n=>n&&(n.host||iS(n.parentNode)),QP=(n,e)=>e.map(t=>{if(n.contains(t))return t;const r=iS(t);return n.contains(r)?r:null}).filter(t=>t!=null);function GP(n,e,t,r){const i="data-base-ui-inert",s=r?"inert":t?"aria-hidden":null,o=QP(e,n),a=new Set,u=new Set(o),f=[];Iu[i]||(Iu[i]=new WeakMap);const h=Iu[i];o.forEach(p),g(e),a.clear();function p(y){!y||a.has(y)||(a.add(y),y.parentNode&&p(y.parentNode))}function g(y){!y||u.has(y)||[].forEach.call(y.children,x=>{if(vs(x)!=="script")if(a.has(x))g(x);else{const w=s?x.getAttribute(s):null,C=w!==null&&w!=="false",E=o1(s),T=(E.get(x)||0)+1,M=(h.get(x)||0)+1;E.set(x,T),h.set(x,M),f.push(x),T===1&&C&&Du.add(x),M===1&&x.setAttribute(i,""),!C&&s&&x.setAttribute(s,s==="inert"?"":"true")}})}return jp+=1,()=>{f.forEach(y=>{const x=o1(s),C=(x.get(y)||0)-1,E=(h.get(y)||0)-1;x.set(y,C),h.set(y,E),C||(!Du.has(y)&&s&&y.removeAttribute(s),Du.delete(y)),E||y.removeAttribute(i)}),jp-=1,jp||($o.inert=new WeakMap,$o["aria-hidden"]=new WeakMap,$o.none=new WeakMap,Du=new WeakSet,Iu={})}}function YP(n,e=!1,t=!1){const r=qt(n[0]).body;return GP(n.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,e,t)}const sS=S.createContext(null),oS=()=>S.useContext(sS),XP=tl("portal");function lS(n={}){const{ref:e,container:t,componentProps:r=tn,elementProps:i,elementState:s}=n,o=lo(),a=oS(),u=a==null?void 0:a.portalNode,[f,h]=S.useState(null),[p,g]=S.useState(null),y=S.useRef(null);Be(()=>{if(t===null){y.current&&(y.current=null,g(null),h(null));return}if(o==null)return;const C=(t&&(Gg(t)?t:t.current))??u??document.body;if(C==null){y.current&&(y.current=null,g(null),h(null));return}y.current!==C&&(y.current=C,g(null),h(C))},[t,u,o]);const x=At("div",r,{ref:[e,g],state:s,props:[{id:o,[XP]:""},i]});return{portalNode:p,portalSubtree:f&&x?Mr.createPortal(x,f):null}}const JP=S.forwardRef(function(e,t){const{children:r,container:i,className:s,render:o,renderGuards:a,...u}=e,{portalNode:f,portalSubtree:h}=lS({container:i,ref:t,componentProps:e,elementProps:u}),p=S.useRef(null),g=S.useRef(null),y=S.useRef(null),x=S.useRef(null),[w,C]=S.useState(null),E=w==null?void 0:w.modal,T=w==null?void 0:w.open,M=typeof a=="boolean"?a:!!w&&!w.modal&&w.open&&!!f;S.useEffect(()=>{if(!f||E)return;function O(N){f&&Sa(N)&&(N.type==="focusin"?n1:BP)(f)}return f.addEventListener("focusin",O,!0),f.addEventListener("focusout",O,!0),()=>{f.removeEventListener("focusin",O,!0),f.removeEventListener("focusout",O,!0)}},[f,E]),S.useEffect(()=>{!f||T||n1(f)},[T,f]);const P=S.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:g,beforeInsideRef:y,afterInsideRef:x,portalNode:f,setFocusManagerState:C}),[f]);return k.jsxs(S.Fragment,{children:[h,k.jsxs(sS.Provider,{value:P,children:[M&&f&&k.jsx(Xs,{"data-type":"outside",ref:p,onFocus:O=>{var N;if(Sa(O,f))(N=y.current)==null||N.focus();else{const L=w?w.domReference:null,F=Z2(L);F==null||F.focus()}}}),M&&f&&k.jsx("span",{"aria-owns":f.id,style:tO}),f&&Mr.createPortal(r,f),M&&f&&k.jsx(Xs,{"data-type":"outside",ref:g,onFocus:O=>{var N;if(Sa(O,f))(N=x.current)==null||N.focus();else{const L=w?w.domReference:null,F=J2(L);F==null||F.focus(),w!=null&&w.closeOnFocusOut&&(w==null||w.onOpenChange(!1,yt(tS,O.nativeEvent)))}}})]})]})});function Vs(n){return n==null?n:"current"in n?n.current:n}function ZP(n,e){const t=Pt(n.target);return n instanceof t.KeyboardEvent?"keyboard":n instanceof t.FocusEvent?e||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof t.MouseEvent?e||(n.detail===0?"keyboard":"mouse"):""}const l1=20;let os=[];function n0(){os=os.filter(n=>n.isConnected)}function eA(n){n0(),n&&vs(n)!=="body"&&(os.push(n),os.length>l1&&(os=os.slice(-l1)))}function Bp(){return n0(),os[os.length-1]}function tA(n){if(!n)return null;const e=lc();return Y2(n,e)?n:kd(n,e)[0]||n}function nA(n){return!n||!n.isConnected?!1:typeof n.checkVisibility=="function"?n.checkVisibility():Fn(n).display!=="none"}function a1(n,e){var o;if(!e.current.includes("floating")&&!((o=n.getAttribute("role"))!=null&&o.includes("dialog")))return;const t=lc(),i=jP(n,t).filter(a=>{const u=a.getAttribute("data-tabindex")||"";return Y2(a,t)||a.hasAttribute("data-tabindex")&&!u.startsWith("-")}),s=n.getAttribute("tabindex");e.current.includes("floating")||i.length===0?s!=="0"&&n.setAttribute("tabindex","0"):(s!=="-1"||n.hasAttribute("data-tabindex")&&n.getAttribute("data-tabindex")!=="-1")&&(n.setAttribute("tabindex","-1"),n.setAttribute("data-tabindex","-1"))}function rA(n){const{context:e,children:t,disabled:r=!1,order:i=["content"],initialFocus:s=!0,returnFocus:o=!0,restoreFocus:a=!1,modal:u=!0,closeOnFocusOut:f=!0,openInteractionType:h="",getInsideElements:p=()=>[],nextFocusableElement:g,previousFocusableElement:y,beforeContentFocusGuardRef:x,externalTree:w}=n,C="rootStore"in e?e.rootStore:e,E=C.useState("open"),T=C.useState("domReferenceElement"),M=C.useState("floatingElement"),{events:P,dataRef:O}=C.context,N=Ne(()=>{var pe;return(pe=O.current.floatingContext)==null?void 0:pe.nodeId}),L=Ne(p),F=s===!1,U=Xx(T)&&F,Q=Cr(i),q=Cr(s),H=Cr(o),j=Cr(h),Y=ac(w),W=oS(),_=S.useRef(null),X=S.useRef(null),D=S.useRef(!1),B=S.useRef(!1),K=S.useRef(!1),A=S.useRef(-1),$=S.useRef(""),oe=S.useRef(""),ce=Ri(),me=Ri(),le=uc(),de=W!=null,ee=jm(M),fe=Ne((pe=ee)=>pe?kd(pe,lc()):[]),ye=Ne(pe=>{const Re=fe(pe);return Q.current.map(()=>Re).filter(Boolean).flat()});S.useEffect(()=>{if(r||!u)return;function pe(Te){Te.key==="Tab"&&Xe(ee,ir(qt(ee)))&&fe().length===0&&!U&&lP(Te)}const Re=qt(ee);return Re.addEventListener("keydown",pe),()=>{Re.removeEventListener("keydown",pe)}},[r,T,ee,u,Q,U,fe,ye]),S.useEffect(()=>{if(r||!M)return;function pe(Re){const Te=en(Re),We=fe().indexOf(Te);We!==-1&&(A.current=We)}return M.addEventListener("focusin",pe),()=>{M.removeEventListener("focusin",pe)}},[r,M,fe]),S.useEffect(()=>{if(r||!E)return;const pe=qt(ee);function Re(){K.current=!1}function Te(We){const Me=en(We),xe=Xe(M,Me)||Xe(T,Me)||Xe(W==null?void 0:W.portalNode,Me);K.current=!xe,oe.current=We.pointerType||"keyboard"}function Le(){oe.current="keyboard"}return pe.addEventListener("pointerdown",Te,!0),pe.addEventListener("pointerup",Re,!0),pe.addEventListener("pointercancel",Re,!0),pe.addEventListener("keydown",Le,!0),()=>{pe.removeEventListener("pointerdown",Te,!0),pe.removeEventListener("pointerup",Re,!0),pe.removeEventListener("pointercancel",Re,!0),pe.removeEventListener("keydown",Le,!0)}},[r,M,T,ee,E,W]),S.useEffect(()=>{if(r||!f)return;function pe(){B.current=!0,me.start(0,()=>{B.current=!1})}function Re(Me){const xe=Me.relatedTarget,Ve=Me.currentTarget,Ue=en(Me);queueMicrotask(()=>{const Ce=N(),Fe=C.context.triggerElements,it=!(Xe(T,xe)||Xe(M,xe)||Xe(xe,M)||Xe(W==null?void 0:W.portalNode,xe)||xe!=null&&Fe.hasElement(xe)||Fe.hasMatchingElement(qe=>Xe(qe,xe))||xe!=null&&xe.hasAttribute(tl("focus-guard"))||Y&&(Gs(Y.nodesRef.current,Ce).find(qe=>{var Ye,Ke;return Xe((Ye=qe.context)==null?void 0:Ye.elements.floating,xe)||Xe((Ke=qe.context)==null?void 0:Ke.elements.domReference,xe)})||Jx(Y.nodesRef.current,Ce).find(qe=>{var Ye,Ke,tt;return[(Ye=qe.context)==null?void 0:Ye.elements.floating,jm((Ke=qe.context)==null?void 0:Ke.elements.floating)].includes(xe)||((tt=qe.context)==null?void 0:tt.elements.domReference)===xe})));if(Ve===T&&ee&&a1(ee,Q),a&&Ve!==T&&!nA(Ue)&&ir(qt(ee))===qt(ee).body){if(zt(ee)&&(ee.focus(),a==="popup")){le.request(()=>{ee.focus()});return}const qe=A.current,Ye=fe(),Ke=Ye[qe]||Ye[Ye.length-1]||ee;zt(Ke)&&Ke.focus()}if(O.current.insideReactTree){O.current.insideReactTree=!1;return}(U||!u)&&xe&&it&&!B.current&&(U||xe!==Bp())&&(D.current=!0,C.setOpen(!1,yt(tS,Me)))})}function Te(){K.current||(O.current.insideReactTree=!0,ce.start(0,()=>{O.current.insideReactTree=!1}))}const Le=zt(T)?T:null,We=[];if(!(!M&&!Le))return Le&&(Le.addEventListener("focusout",Re),Le.addEventListener("pointerdown",pe),We.push(()=>{Le.removeEventListener("focusout",Re),Le.removeEventListener("pointerdown",pe)})),M&&(M.addEventListener("focusout",Re),W&&(M.addEventListener("focusout",Te,!0),We.push(()=>{M.removeEventListener("focusout",Te,!0)})),We.push(()=>{M.removeEventListener("focusout",Re)})),()=>{We.forEach(Me=>{Me()})}},[r,T,M,ee,u,Y,W,C,f,a,fe,U,N,Q,O,ce,me,le]);const ne=S.useRef(null),he=S.useRef(null),we=La(ne,x,W==null?void 0:W.beforeInsideRef),at=La(he,W==null?void 0:W.afterInsideRef);S.useEffect(()=>{var Me,xe,Ve;if(r||!M||!E)return;const pe=Array.from(((Me=W==null?void 0:W.portalNode)==null?void 0:Me.querySelectorAll(`[${tl("portal")}]`))||[]),Te=(Ve=(xe=(Y?Jx(Y.nodesRef.current,N()):[]).find(Ue=>{var Ce;return Xx(((Ce=Ue.context)==null?void 0:Ce.elements.domReference)||null)}))==null?void 0:xe.context)==null?void 0:Ve.elements.domReference,Le=[M,Te,...pe,...L(),_.current,X.current,ne.current,he.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,Vs(y),Vs(g),U?T:null].filter(Ue=>Ue!=null),We=YP(Le,u||U);return()=>{We()}},[E,r,T,M,u,Q,W,U,Y,N,L,g,y]),Be(()=>{if(!E||r||!zt(ee))return;const pe=qt(ee),Re=ir(pe);queueMicrotask(()=>{const Te=ye(ee),Le=q.current,We=typeof Le=="function"?Le(j.current||""):Le;if(We===void 0||We===!1)return;let Me;We===!0||We===null?Me=Te[0]||ee:Me=Vs(We),Me=Me||Te[0]||ee,!Xe(ee,Re)&&Ip(Me,{preventScroll:Me===ee})})},[r,E,ee,F,ye,q,j]),Be(()=>{if(r||!ee)return;const pe=qt(ee),Re=ir(pe);eA(Re);function Te(Me){if(Me.open||($.current=ZP(Me.nativeEvent,oe.current)),Me.reason===Kr&&Me.nativeEvent.type==="mouseleave"&&(D.current=!0),Me.reason===eS)if(Me.nested)D.current=!1;else if(cP(Me.nativeEvent)||uP(Me.nativeEvent))D.current=!1;else{let xe=!1;document.createElement("div").focus({get preventScroll(){return xe=!0,!1}}),xe?D.current=!1:D.current=!0}}P.on("openchange",Te);const Le=pe.createElement("span");Le.setAttribute("tabindex","-1"),Le.setAttribute("aria-hidden","true"),Object.assign(Le.style,Ed),de&&T&&T.insertAdjacentElement("afterend",Le);function We(){const Me=H.current;let xe=typeof Me=="function"?Me($.current):Me;if(xe===void 0||xe===!1)return null;if(xe===null&&(xe=!0),typeof xe=="boolean"){const Ue=T||Bp();return Ue&&Ue.isConnected?Ue:Le}const Ve=T||Bp()||Le;return Vs(xe)||Ve}return()=>{P.off("openchange",Te);const Me=ir(pe),xe=Xe(M,Me)||Y&&Gs(Y.nodesRef.current,N(),!1).some(Ue=>{var Ce;return Xe((Ce=Ue.context)==null?void 0:Ce.elements.floating,Me)}),Ve=We();queueMicrotask(()=>{const Ue=tA(Ve),Ce=typeof H.current!="boolean";H.current&&!D.current&&zt(Ue)&&(!(!Ce&&Ue!==Me&&Me!==pe.body)||xe)&&Ue.focus({preventScroll:!0}),Le.remove()})}},[r,M,ee,H,O,P,Y,de,T,N]),S.useEffect(()=>{queueMicrotask(()=>{D.current=!1})},[r]),S.useEffect(()=>{if(r||!E)return;function pe(Te){const Le=en(Te);Le!=null&&Le.closest(`[${k2}]`)&&(B.current=!0)}const Re=qt(ee);return Re.addEventListener("pointerdown",pe,!0),()=>{Re.removeEventListener("pointerdown",pe,!0)}},[r,E,ee]),Be(()=>{if(!r&&W)return W.setFocusManagerState({modal:u,closeOnFocusOut:f,open:E,onOpenChange:C.setOpen,domReference:T}),()=>{W.setFocusManagerState(null)}},[r,W,u,E,C,f,T]),Be(()=>{if(!(r||!ee))return a1(ee,Q),()=>{queueMicrotask(n0)}},[r,ee,Q]);const ze=!r&&(u?!U:!0)&&(de||u);return k.jsxs(S.Fragment,{children:[ze&&k.jsx(Xs,{"data-type":"inside",ref:we,onFocus:pe=>{var Re;if(u){const Te=ye();Ip(Te[Te.length-1])}else if(W!=null&&W.portalNode)if(D.current=!1,Sa(pe,W.portalNode)){const Te=J2(T);Te==null||Te.focus()}else(Re=Vs(y??W.beforeOutsideRef))==null||Re.focus()}}),t,ze&&k.jsx(Xs,{"data-type":"inside",ref:at,onFocus:pe=>{var Re;if(u)Ip(ye()[0]);else if(W!=null&&W.portalNode)if(f&&(D.current=!0),Sa(pe,W.portalNode)){const Te=Z2(T);Te==null||Te.focus()}else(Re=Vs(g??W.afterOutsideRef))==null||Re.focus()}})]})}function iA(n,e={}){const t="rootStore"in n?n.rootStore:n,r=t.context.dataRef,{enabled:i=!0,event:s="click",toggle:o=!0,ignoreMouse:a=!1,stickIfOpen:u=!0,touchOpenDelay:f=0}=e,h=S.useRef(void 0),p=uc(),g=Ri(),y=S.useMemo(()=>({onPointerDown(x){h.current=x.pointerType},onMouseDown(x){const w=h.current,C=x.nativeEvent,E=t.select("open");if(x.button!==0||s==="click"||eo(w,!0)&&a)return;const T=r.current.openEvent,M=T==null?void 0:T.type,P=t.select("domReferenceElement")!==x.currentTarget,O=E&&P||!(E&&o&&(!(T&&u)||M==="click"||M==="mousedown"));if(Xg(C.target)){const L=yt(Ys,C,C.target);O&&w==="touch"&&f>0?g.start(f,()=>{t.setOpen(!0,L)}):t.setOpen(O,L);return}const N=x.currentTarget;p.request(()=>{const L=yt(Ys,C,N);O&&w==="touch"&&f>0?g.start(f,()=>{t.setOpen(!0,L)}):t.setOpen(O,L)})},onClick(x){if(s==="mousedown-only")return;const w=h.current;if(s==="mousedown"&&w){h.current=void 0;return}if(eo(w,!0)&&a)return;const C=t.select("open"),E=r.current.openEvent,T=t.select("domReferenceElement")!==x.currentTarget,M=C&&T||!(C&&o&&(!(E&&u)||W2(E))),P=yt(Ys,x.nativeEvent,x.currentTarget);M&&w==="touch"&&f>0?g.start(f,()=>{t.setOpen(!0,P)}):t.setOpen(M,P)},onKeyDown(){h.current=void 0}}),[r,s,a,t,u,o,p,g,f]);return S.useMemo(()=>i?{reference:y}:tn,[i,y])}function sA(n,e){let t=null,r=null,i=!1;return{contextElement:n||void 0,getBoundingClientRect(){var y;const s=(n==null?void 0:n.getBoundingClientRect())||{width:0,height:0,x:0,y:0},o=e.axis==="x"||e.axis==="both",a=e.axis==="y"||e.axis==="both",u=["mouseenter","mousemove"].includes(((y=e.dataRef.current.openEvent)==null?void 0:y.type)||"")&&e.pointerType!=="touch";let f=s.width,h=s.height,p=s.x,g=s.y;return t==null&&e.x&&o&&(t=s.x-e.x),r==null&&e.y&&a&&(r=s.y-e.y),p-=t||0,g-=r||0,f=0,h=0,!i||u?(f=e.axis==="y"?s.width:0,h=e.axis==="x"?s.height:0,p=o&&e.x!=null?e.x:p,g=a&&e.y!=null?e.y:g):i&&!u&&(h=e.axis==="x"?s.height:h,f=e.axis==="y"?s.width:f),i=!0,{width:f,height:h,x:p,y:g,top:g,right:p+f,bottom:g+h,left:p}}}}function c1(n){return n!=null&&n.clientX!=null}function oA(n,e={}){const t="rootStore"in n?n.rootStore:n,r=t.useState("open"),i=t.useState("floatingElement"),s=t.useState("domReferenceElement"),o=t.context.dataRef,{enabled:a=!0,axis:u="both",x:f=null,y:h=null}=e,p=S.useRef(!1),g=S.useRef(null),[y,x]=S.useState(),[w,C]=S.useState([]),E=Ne((N,L)=>{p.current||o.current.openEvent&&!c1(o.current.openEvent)||t.set("positionReference",sA(s,{x:N,y:L,axis:u,dataRef:o,pointerType:y}))}),T=Ne(N=>{f!=null||h!=null||(r?g.current||C([]):E(N.clientX,N.clientY))}),M=eo(y)?i:r,P=S.useCallback(()=>{if(!M||!a||f!=null||h!=null)return;const N=Pt(i);function L(F){const U=en(F);Xe(i,U)?(N.removeEventListener("mousemove",L),g.current=null):E(F.clientX,F.clientY)}if(!o.current.openEvent||c1(o.current.openEvent)){N.addEventListener("mousemove",L);const F=()=>{N.removeEventListener("mousemove",L),g.current=null};return g.current=F,F}t.set("positionReference",s)},[M,a,f,h,i,o,s,t,E]);S.useEffect(()=>P(),[P,w]),S.useEffect(()=>{a&&!i&&(p.current=!1)},[a,i]),S.useEffect(()=>{!a&&r&&(p.current=!0)},[a,r]),Be(()=>{a&&(f!=null||h!=null)&&(p.current=!1,E(f,h))},[a,f,h,E]);const O=S.useMemo(()=>{function N(L){x(L.pointerType)}return{onPointerDown:N,onPointerEnter:N,onMouseMove:T,onMouseEnter:T}},[T]);return S.useMemo(()=>a?{reference:O}:{},[a,O])}function u1(n,e,t){let{reference:r,floating:i}=n;const s=sr(e),o=e0(e),a=Zg(o),u=Bn(e),f=s==="y",h=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,g=r[a]/2-i[a]/2;let y;switch(u){case"top":y={x:h,y:r.y-i.height};break;case"bottom":y={x:h,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:p};break;case"left":y={x:r.x-i.width,y:p};break;default:y={x:r.x,y:r.y}}switch(xs(e)){case"start":y[o]-=g*(t&&f?-1:1);break;case"end":y[o]+=g*(t&&f?-1:1);break}return y}const lA=async(n,e,t)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=t,a=s.filter(Boolean),u=await(o.isRTL==null?void 0:o.isRTL(e));let f=await o.getElementRects({reference:n,floating:e,strategy:i}),{x:h,y:p}=u1(f,r,u),g=r,y={},x=0;for(let w=0;w<a.length;w++){const{name:C,fn:E}=a[w],{x:T,y:M,data:P,reset:O}=await E({x:h,y:p,initialPlacement:r,placement:g,strategy:i,middlewareData:y,rects:f,platform:o,elements:{reference:n,floating:e}});h=T??h,p=M??p,y={...y,[C]:{...y[C],...P}},O&&x<=50&&(x++,typeof O=="object"&&(O.placement&&(g=O.placement),O.rects&&(f=O.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:i}):O.rects),{x:h,y:p}=u1(f,g,u)),w=-1)}return{x:h,y:p,placement:g,strategy:i,middlewareData:y}};async function Ia(n,e){var t;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:u}=n,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:p="floating",altBoundary:g=!1,padding:y=0}=Mi(e,n),x=$2(y),C=a[g?p==="floating"?"reference":"floating":p],E=Of(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(C)))==null||t?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:f,rootBoundary:h,strategy:u})),T=p==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,M=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),P=await(s.isElement==null?void 0:s.isElement(M))?await(s.getScale==null?void 0:s.getScale(M))||{x:1,y:1}:{x:1,y:1},O=Of(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:T,offsetParent:M,strategy:u}):T);return{top:(E.top-O.top+x.top)/P.y,bottom:(O.bottom-E.bottom+x.bottom)/P.y,left:(E.left-O.left+x.left)/P.x,right:(O.right-E.right+x.right)/P.x}}const aA=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:u,elements:f}=e,{mainAxis:h=!0,crossAxis:p=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:w=!0,...C}=Mi(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const E=Bn(i),T=sr(a),M=Bn(a)===a,P=await(u.isRTL==null?void 0:u.isRTL(f.floating)),O=g||(M||!w?[Mf(a)]:gP(a)),N=x!=="none";!g&&N&&O.push(...wP(a,w,x,P));const L=[a,...O],F=await Ia(e,C),U=[];let Q=((r=s.flip)==null?void 0:r.overflows)||[];if(h&&U.push(F[E]),p){const Y=mP(i,o,P);U.push(F[Y[0]],F[Y[1]])}if(Q=[...Q,{placement:i,overflows:U}],!U.every(Y=>Y<=0)){var q,H;const Y=(((q=s.flip)==null?void 0:q.index)||0)+1,W=L[Y];if(W&&(!(p==="alignment"?T!==sr(W):!1)||Q.every(D=>sr(D.placement)===T?D.overflows[0]>0:!0)))return{data:{index:Y,overflows:Q},reset:{placement:W}};let _=(H=Q.filter(X=>X.overflows[0]<=0).sort((X,D)=>X.overflows[1]-D.overflows[1])[0])==null?void 0:H.placement;if(!_)switch(y){case"bestFit":{var j;const X=(j=Q.filter(D=>{if(N){const B=sr(D.placement);return B===T||B==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(B=>B>0).reduce((B,K)=>B+K,0)]).sort((D,B)=>D[1]-B[1])[0])==null?void 0:j[0];X&&(_=X);break}case"initialPlacement":_=a;break}if(i!==_)return{reset:{placement:_}}}return{}}}};function f1(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function d1(n){return fP.some(e=>n[e]>=0)}const cA=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...i}=Mi(n,e);switch(r){case"referenceHidden":{const s=await Ia(e,{...i,elementContext:"reference"}),o=f1(s,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:d1(o)}}}case"escaped":{const s=await Ia(e,{...i,altBoundary:!0}),o=f1(s,t.floating);return{data:{escapedOffsets:o,escaped:d1(o)}}}default:return{}}}}},aS=new Set(["left","top"]);async function uA(n,e){const{placement:t,platform:r,elements:i}=n,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Bn(t),a=xs(t),u=sr(t)==="y",f=aS.has(o)?-1:1,h=s&&u?-1:1,p=Mi(e,n);let{mainAxis:g,crossAxis:y,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof x=="number"&&(y=a==="end"?x*-1:x),u?{x:y*h,y:g*f}:{x:g*f,y:y*h}}const fA=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:i,y:s,placement:o,middlewareData:a}=e,u=await uA(e,n);return o===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:o}}}}},dA=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:C=>{let{x:E,y:T}=C;return{x:E,y:T}}},...u}=Mi(n,e),f={x:t,y:r},h=await Ia(e,u),p=sr(Bn(i)),g=Jg(p);let y=f[g],x=f[p];if(s){const C=g==="y"?"top":"left",E=g==="y"?"bottom":"right",T=y+h[C],M=y-h[E];y=Bm(T,y,M)}if(o){const C=p==="y"?"top":"left",E=p==="y"?"bottom":"right",T=x+h[C],M=x-h[E];x=Bm(T,x,M)}const w=a.fn({...e,[g]:y,[p]:x});return{...w,data:{x:w.x-t,y:w.y-r,enabled:{[g]:s,[p]:o}}}}}},hA=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:u=!0,crossAxis:f=!0}=Mi(n,e),h={x:t,y:r},p=sr(i),g=Jg(p);let y=h[g],x=h[p];const w=Mi(a,e),C=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const M=g==="y"?"height":"width",P=s.reference[g]-s.floating[M]+C.mainAxis,O=s.reference[g]+s.reference[M]-C.mainAxis;y<P?y=P:y>O&&(y=O)}if(f){var E,T;const M=g==="y"?"width":"height",P=aS.has(Bn(i)),O=s.reference[p]-s.floating[M]+(P&&((E=o.offset)==null?void 0:E[p])||0)+(P?0:C.crossAxis),N=s.reference[p]+s.reference[M]+(P?0:((T=o.offset)==null?void 0:T[p])||0)-(P?C.crossAxis:0);x<O?x=O:x>N&&(x=N)}return{[g]:y,[p]:x}}}},pA=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:u=()=>{},...f}=Mi(n,e),h=await Ia(e,f),p=Bn(i),g=xs(i),y=sr(i)==="y",{width:x,height:w}=s.floating;let C,E;p==="top"||p==="bottom"?(C=p,E=g===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(E=p,C=g==="end"?"top":"bottom");const T=w-h.top-h.bottom,M=x-h.left-h.right,P=Jo(w-h[C],T),O=Jo(x-h[E],M),N=!e.middlewareData.shift;let L=P,F=O;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(F=M),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(L=T),N&&!g){const Q=Kn(h.left,0),q=Kn(h.right,0),H=Kn(h.top,0),j=Kn(h.bottom,0);y?F=x-2*(Q!==0||q!==0?Q+q:Kn(h.left,h.right)):L=w-2*(H!==0||j!==0?H+j:Kn(h.top,h.bottom))}await u({...e,availableWidth:F,availableHeight:L});const U=await o.getDimensions(a.floating);return x!==U.width||w!==U.height?{reset:{rects:!0}}:{}}}};function cS(n){const e=Fn(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=zt(n),s=i?n.offsetWidth:t,o=i?n.offsetHeight:r,a=Zo(t)!==s||Zo(r)!==o;return a&&(t=s,r=o),{width:t,height:r,$:a}}function r0(n){return ct(n)?n:n.contextElement}function Ho(n){const e=r0(n);if(!zt(e))return Zr(1);const t=e.getBoundingClientRect(),{width:r,height:i,$:s}=cS(e);let o=(s?Zo(t.width):t.width)/r,a=(s?Zo(t.height):t.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const mA=Zr(0);function uS(n){const e=Pt(n);return!bd()||!e.visualViewport?mA:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function gA(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Pt(n)?!1:e}function to(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const i=n.getBoundingClientRect(),s=r0(n);let o=Zr(1);e&&(r?ct(r)&&(o=Ho(r)):o=Ho(n));const a=gA(s,t,r)?uS(s):Zr(0);let u=(i.left+a.x)/o.x,f=(i.top+a.y)/o.y,h=i.width/o.x,p=i.height/o.y;if(s){const g=Pt(s),y=r&&ct(r)?Pt(r):r;let x=g,w=Lm(x);for(;w&&r&&y!==x;){const C=Ho(w),E=w.getBoundingClientRect(),T=Fn(w),M=E.left+(w.clientLeft+parseFloat(T.paddingLeft))*C.x,P=E.top+(w.clientTop+parseFloat(T.paddingTop))*C.y;u*=C.x,f*=C.y,h*=C.x,p*=C.y,u+=M,f+=P,x=Pt(w),w=Lm(x)}}return Of({width:h,height:p,x:u,y:f})}function Rd(n,e){const t=Sd(n).scrollLeft;return e?e.left+t:to(ii(n)).left+t}function fS(n,e){const t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Rd(n,t),i=t.top+e.scrollTop;return{x:r,y:i}}function yA(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n;const s=i==="fixed",o=ii(r),a=e?wd(e.floating):!1;if(r===o||a&&s)return t;let u={scrollLeft:0,scrollTop:0},f=Zr(1);const h=Zr(0),p=zt(r);if((p||!p&&!s)&&((vs(r)!=="body"||oo(o))&&(u=Sd(r)),zt(r))){const y=to(r);f=Ho(r),h.x=y.x+r.clientLeft,h.y=y.y+r.clientTop}const g=o&&!p&&!s?fS(o,u):Zr(0);return{width:t.width*f.x,height:t.height*f.y,x:t.x*f.x-u.scrollLeft*f.x+h.x+g.x,y:t.y*f.y-u.scrollTop*f.y+h.y+g.y}}function vA(n){return Array.from(n.getClientRects())}function xA(n){const e=ii(n),t=Sd(n),r=n.ownerDocument.body,i=Kn(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Kn(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+Rd(n);const a=-t.scrollTop;return Fn(r).direction==="rtl"&&(o+=Kn(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const h1=25;function wA(n,e){const t=Pt(n),r=ii(n),i=t.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,u=0;if(i){s=i.width,o=i.height;const h=bd();(!h||h&&e==="fixed")&&(a=i.offsetLeft,u=i.offsetTop)}const f=Rd(r);if(f<=0){const h=r.ownerDocument,p=h.body,g=getComputedStyle(p),y=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-y);x<=h1&&(s-=x)}else f<=h1&&(s+=f);return{width:s,height:o,x:a,y:u}}const bA=new Set(["absolute","fixed"]);function SA(n,e){const t=to(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,s=zt(n)?Ho(n):Zr(1),o=n.clientWidth*s.x,a=n.clientHeight*s.y,u=i*s.x,f=r*s.y;return{width:o,height:a,x:u,y:f}}function p1(n,e,t){let r;if(e==="viewport")r=wA(n,t);else if(e==="document")r=xA(ii(n));else if(ct(e))r=SA(e,t);else{const i=uS(n);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Of(r)}function dS(n,e){const t=Ti(n);return t===e||!ct(t)||Ci(t)?!1:Fn(t).position==="fixed"||dS(t,e)}function kA(n,e){const t=e.get(n);if(t)return t;let r=cs(n,[],!1).filter(a=>ct(a)&&vs(a)!=="body"),i=null;const s=Fn(n).position==="fixed";let o=s?Ti(n):n;for(;ct(o)&&!Ci(o);){const a=Fn(o),u=Yg(o);!u&&a.position==="fixed"&&(i=null),(s?!u&&!i:!u&&a.position==="static"&&!!i&&bA.has(i.position)||oo(o)&&!u&&dS(n,o))?r=r.filter(h=>h!==o):i=a,o=Ti(o)}return e.set(n,r),r}function CA(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n;const o=[...t==="clippingAncestors"?wd(e)?[]:kA(e,this._c):[].concat(t),r],a=o[0],u=o.reduce((f,h)=>{const p=p1(e,h,i);return f.top=Kn(p.top,f.top),f.right=Jo(p.right,f.right),f.bottom=Jo(p.bottom,f.bottom),f.left=Kn(p.left,f.left),f},p1(e,a,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function EA(n){const{width:e,height:t}=cS(n);return{width:e,height:t}}function RA(n,e,t){const r=zt(e),i=ii(e),s=t==="fixed",o=to(n,!0,s,e);let a={scrollLeft:0,scrollTop:0};const u=Zr(0);function f(){u.x=Rd(i)}if(r||!r&&!s)if((vs(e)!=="body"||oo(i))&&(a=Sd(e)),r){const y=to(e,!0,s,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else i&&f();s&&!r&&i&&f();const h=i&&!r&&!s?fS(i,a):Zr(0),p=o.left+a.scrollLeft-u.x-h.x,g=o.top+a.scrollTop-u.y-h.y;return{x:p,y:g,width:o.width,height:o.height}}function Fp(n){return Fn(n).position==="static"}function m1(n,e){if(!zt(n)||Fn(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return ii(n)===t&&(t=t.ownerDocument.body),t}function hS(n,e){const t=Pt(n);if(wd(n))return t;if(!zt(n)){let i=Ti(n);for(;i&&!Ci(i);){if(ct(i)&&!Fp(i))return i;i=Ti(i)}return t}let r=m1(n,e);for(;r&&$O(r)&&Fp(r);)r=m1(r,e);return r&&Ci(r)&&Fp(r)&&!Yg(r)?t:r||QO(n)||t}const TA=async function(n){const e=this.getOffsetParent||hS,t=this.getDimensions,r=await t(n.floating);return{reference:RA(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function MA(n){return Fn(n).direction==="rtl"}const OA={convertOffsetParentRelativeRectToViewportRelativeRect:yA,getDocumentElement:ii,getClippingRect:CA,getOffsetParent:hS,getElementRects:TA,getClientRects:vA,getDimensions:EA,getScale:Ho,isElement:ct,isRTL:MA};function pS(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function PA(n,e){let t=null,r;const i=ii(n);function s(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function o(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),s();const f=n.getBoundingClientRect(),{left:h,top:p,width:g,height:y}=f;if(a||e(),!g||!y)return;const x=Au(p),w=Au(i.clientWidth-(h+g)),C=Au(i.clientHeight-(p+y)),E=Au(h),M={rootMargin:-x+"px "+-w+"px "+-C+"px "+-E+"px",threshold:Kn(0,Jo(1,u))||1};let P=!0;function O(N){const L=N[0].intersectionRatio;if(L!==u){if(!P)return o();L?o(!1,L):r=setTimeout(()=>{o(!1,1e-7)},1e3)}L===1&&!pS(f,n.getBoundingClientRect())&&o(),P=!1}try{t=new IntersectionObserver(O,{...M,root:i.ownerDocument})}catch{t=new IntersectionObserver(O,M)}t.observe(n)}return o(!0),s}function g1(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=r0(n),h=i||s?[...f?cs(f):[],...cs(e)]:[];h.forEach(E=>{i&&E.addEventListener("scroll",t,{passive:!0}),s&&E.addEventListener("resize",t)});const p=f&&a?PA(f,t):null;let g=-1,y=null;o&&(y=new ResizeObserver(E=>{let[T]=E;T&&T.target===f&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var M;(M=y)==null||M.observe(e)})),t()}),f&&!u&&y.observe(f),y.observe(e));let x,w=u?to(n):null;u&&C();function C(){const E=to(n);w&&!pS(w,E)&&t(),w=E,x=requestAnimationFrame(C)}return t(),()=>{var E;h.forEach(T=>{i&&T.removeEventListener("scroll",t),s&&T.removeEventListener("resize",t)}),p==null||p(),(E=y)==null||E.disconnect(),y=null,u&&cancelAnimationFrame(x)}}const AA=fA,NA=dA,LA=aA,DA=pA,IA=cA,jA=hA,BA=(n,e,t)=>{const r=new Map,i={platform:OA,...t},s={...i.platform,_c:r};return lA(n,e,{...i,platform:s})};var FA=typeof document<"u",zA=function(){},pf=FA?S.useLayoutEffect:zA;function Lf(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,i;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!Lf(n[r],e[r]))return!1;return!0}if(i=Object.keys(n),t=i.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=t;r--!==0;){const s=i[r];if(!(s==="_owner"&&n.$$typeof)&&!Lf(n[s],e[s]))return!1}return!0}return n!==n&&e!==e}function mS(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function y1(n,e){const t=mS(n);return Math.round(e*t)/t}function zp(n){const e=S.useRef(n);return pf(()=>{e.current=n}),e}function _A(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:u,open:f}=n,[h,p]=S.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=S.useState(r);Lf(g,r)||y(r);const[x,w]=S.useState(null),[C,E]=S.useState(null),T=S.useCallback(D=>{D!==N.current&&(N.current=D,w(D))},[]),M=S.useCallback(D=>{D!==L.current&&(L.current=D,E(D))},[]),P=s||x,O=o||C,N=S.useRef(null),L=S.useRef(null),F=S.useRef(h),U=u!=null,Q=zp(u),q=zp(i),H=zp(f),j=S.useCallback(()=>{if(!N.current||!L.current)return;const D={placement:e,strategy:t,middleware:g};q.current&&(D.platform=q.current),BA(N.current,L.current,D).then(B=>{const K={...B,isPositioned:H.current!==!1};Y.current&&!Lf(F.current,K)&&(F.current=K,Mr.flushSync(()=>{p(K)}))})},[g,e,t,q,H]);pf(()=>{f===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,p(D=>({...D,isPositioned:!1})))},[f]);const Y=S.useRef(!1);pf(()=>(Y.current=!0,()=>{Y.current=!1}),[]),pf(()=>{if(P&&(N.current=P),O&&(L.current=O),P&&O){if(Q.current)return Q.current(P,O,j);j()}},[P,O,j,Q,U]);const W=S.useMemo(()=>({reference:N,floating:L,setReference:T,setFloating:M}),[T,M]),_=S.useMemo(()=>({reference:P,floating:O}),[P,O]),X=S.useMemo(()=>{const D={position:t,left:0,top:0};if(!_.floating)return D;const B=y1(_.floating,h.x),K=y1(_.floating,h.y);return a?{...D,transform:"translate("+B+"px, "+K+"px)",...mS(_.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:B,top:K}},[t,a,_.floating,h.x,h.y]);return S.useMemo(()=>({...h,update:j,refs:W,elements:_,floatingStyles:X}),[h,j,W,_,X])}const VA=(n,e)=>({...AA(n),options:[n,e]}),WA=(n,e)=>({...NA(n),options:[n,e]}),$A=(n,e)=>({...jA(n),options:[n,e]}),HA=(n,e)=>({...LA(n),options:[n,e]}),UA=(n,e)=>({...DA(n),options:[n,e]}),qA=(n,e)=>({...IA(n),options:[n,e]}),KA={intentional:"onClick",sloppy:"onPointerDown"};function QA(n){return{escapeKey:typeof n=="boolean"?n:(n==null?void 0:n.escapeKey)??!1,outsidePress:typeof n=="boolean"?n:(n==null?void 0:n.outsidePress)??!0}}function gS(n,e={}){const t="rootStore"in n?n.rootStore:n,r=t.useState("open"),i=t.useState("floatingElement"),s=t.useState("referenceElement"),o=t.useState("domReferenceElement"),{onOpenChange:a,dataRef:u}=t.context,{enabled:f=!0,escapeKey:h=!0,outsidePress:p=!0,outsidePressEvent:g="sloppy",referencePress:y=!1,referencePressEvent:x="sloppy",ancestorScroll:w=!1,bubbles:C,externalTree:E}=e,T=ac(E),M=Ne(typeof p=="function"?p:()=>!1),P=typeof p=="function"?M:p,O=S.useRef(!1),{escapeKey:N,outsidePress:L}=QA(C),F=S.useRef(null),U=Ri(),Q=Ri(),q=Ne(()=>{Q.clear(),u.current.insideReactTree=!1}),H=S.useRef(!1),j=S.useRef(""),Y=Ne(ne=>{j.current=ne.pointerType}),W=Ne(()=>{const ne=j.current,he=ne==="pen"||!ne?"mouse":ne,we=typeof g=="function"?g():g;return typeof we=="string"?we:we[he]}),_=Ne(ne=>{var pe;if(!r||!f||!h||ne.key!=="Escape"||H.current)return;const he=(pe=u.current.floatingContext)==null?void 0:pe.nodeId,we=T?Gs(T.nodesRef.current,he):[];if(!N&&we.length>0){let Re=!0;if(we.forEach(Te=>{var Le;(Le=Te.context)!=null&&Le.open&&!Te.context.dataRef.current.__escapeKeyBubbles&&(Re=!1)}),!Re)return}const at=aP(ne)?ne.nativeEvent:ne,ze=yt(t0,at);t.setOpen(!1,ze),!N&&!ze.isPropagationAllowed&&ne.stopPropagation()}),X=Ne(ne=>{const he=W();return he==="intentional"&&ne.type!=="click"||he==="sloppy"&&ne.type==="click"}),D=Ne(()=>{u.current.insideReactTree=!0,Q.start(0,q)}),B=Ne((ne,he=!1)=>{var Me;if(X(ne)){q();return}if(u.current.insideReactTree){q();return}if(W()==="intentional"&&he||typeof P=="function"&&!P(ne))return;const we=en(ne),at=`[${tl("inert")}]`,ze=qt(t.select("floatingElement")).querySelectorAll(at),pe=t.context.triggerElements;if(we&&(pe.hasElement(we)||pe.hasMatchingElement(xe=>Xe(xe,we))))return;let Re=ct(we)?we:null;for(;Re&&!Ci(Re);){const xe=Ti(Re);if(Ci(xe)||!ct(xe))break;Re=xe}if(ze.length&&ct(we)&&!oP(we)&&!Xe(we,t.select("floatingElement"))&&Array.from(ze).every(xe=>!Xe(Re,xe)))return;if(zt(we)&&!("touches"in ne)){const xe=Ci(we),Ve=Fn(we),Ue=/auto|scroll/,Ce=xe||Ue.test(Ve.overflowX),Fe=xe||Ue.test(Ve.overflowY),it=Ce&&we.clientWidth>0&&we.scrollWidth>we.clientWidth,qe=Fe&&we.clientHeight>0&&we.scrollHeight>we.clientHeight,Ye=Ve.direction==="rtl",Ke=qe&&(Ye?ne.offsetX<=we.offsetWidth-we.clientWidth:ne.offsetX>we.clientWidth),tt=it&&ne.offsetY>we.clientHeight;if(Ke||tt)return}const Te=(Me=u.current.floatingContext)==null?void 0:Me.nodeId,Le=T&&Gs(T.nodesRef.current,Te).some(xe=>{var Ve;return Sr(ne,(Ve=xe.context)==null?void 0:Ve.elements.floating)});if(Sr(ne,t.select("floatingElement"))||Sr(ne,t.select("domReferenceElement"))||Le)return;const We=T?Gs(T.nodesRef.current,Te):[];if(We.length>0){let xe=!0;if(We.forEach(Ve=>{var Ue;(Ue=Ve.context)!=null&&Ue.open&&!Ve.context.dataRef.current.__outsidePressBubbles&&(xe=!1)}),!xe)return}t.setOpen(!1,yt(eS,ne)),q()}),K=Ne(ne=>{W()!=="sloppy"||ne.pointerType==="touch"||!t.select("open")||!f||Sr(ne,t.select("floatingElement"))||Sr(ne,t.select("domReferenceElement"))||B(ne)}),A=Ne(ne=>{if(W()!=="sloppy"||!t.select("open")||!f||Sr(ne,t.select("floatingElement"))||Sr(ne,t.select("domReferenceElement")))return;const he=ne.touches[0];he&&(F.current={startTime:Date.now(),startX:he.clientX,startY:he.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},U.start(1e3,()=>{F.current&&(F.current.dismissOnTouchEnd=!1,F.current.dismissOnMouseDown=!1)}))}),$=Ne(ne=>{const he=en(ne);function we(){A(ne),he==null||he.removeEventListener(ne.type,we)}he==null||he.addEventListener(ne.type,we)}),oe=Ne(ne=>{const he=O.current;if(O.current=!1,U.clear(),ne.type==="mousedown"&&F.current&&!F.current.dismissOnMouseDown)return;const we=en(ne);function at(){ne.type==="pointerdown"?K(ne):B(ne,he),we==null||we.removeEventListener(ne.type,at)}we==null||we.addEventListener(ne.type,at)}),ce=Ne(ne=>{if(W()!=="sloppy"||!F.current||Sr(ne,t.select("floatingElement"))||Sr(ne,t.select("domReferenceElement")))return;const he=ne.touches[0];if(!he)return;const we=Math.abs(he.clientX-F.current.startX),at=Math.abs(he.clientY-F.current.startY),ze=Math.sqrt(we*we+at*at);ze>5&&(F.current.dismissOnTouchEnd=!0),ze>10&&(B(ne),U.clear(),F.current=null)}),me=Ne(ne=>{const he=en(ne);function we(){ce(ne),he==null||he.removeEventListener(ne.type,we)}he==null||he.addEventListener(ne.type,we)}),le=Ne(ne=>{W()!=="sloppy"||!F.current||Sr(ne,t.select("floatingElement"))||Sr(ne,t.select("domReferenceElement"))||(F.current.dismissOnTouchEnd&&B(ne),U.clear(),F.current=null)}),de=Ne(ne=>{const he=en(ne);function we(){le(ne),he==null||he.removeEventListener(ne.type,we)}he==null||he.addEventListener(ne.type,we)});S.useEffect(()=>{if(!r||!f)return;u.current.__escapeKeyBubbles=N,u.current.__outsidePressBubbles=L;const ne=new ni;function he(Re){t.setOpen(!1,yt(cc,Re))}function we(){ne.clear(),H.current=!0}function at(){ne.start(bd()?5:0,()=>{H.current=!1})}const ze=qt(i);ze.addEventListener("pointerdown",Y,!0),h&&(ze.addEventListener("keydown",_),ze.addEventListener("compositionstart",we),ze.addEventListener("compositionend",at)),P&&(ze.addEventListener("click",oe,!0),ze.addEventListener("pointerdown",oe,!0),ze.addEventListener("touchstart",$,!0),ze.addEventListener("touchmove",me,!0),ze.addEventListener("touchend",de,!0),ze.addEventListener("mousedown",oe,!0));let pe=[];return w&&(ct(o)&&(pe=cs(o)),ct(i)&&(pe=pe.concat(cs(i))),!ct(s)&&s&&s.contextElement&&(pe=pe.concat(cs(s.contextElement)))),pe=pe.filter(Re=>{var Te;return Re!==((Te=ze.defaultView)==null?void 0:Te.visualViewport)}),pe.forEach(Re=>{Re.addEventListener("scroll",he,{passive:!0})}),()=>{ze.removeEventListener("pointerdown",Y,!0),h&&(ze.removeEventListener("keydown",_),ze.removeEventListener("compositionstart",we),ze.removeEventListener("compositionend",at)),P&&(ze.removeEventListener("click",oe,!0),ze.removeEventListener("pointerdown",oe,!0),ze.removeEventListener("touchstart",$,!0),ze.removeEventListener("touchmove",me,!0),ze.removeEventListener("touchend",de,!0),ze.removeEventListener("mousedown",oe,!0)),pe.forEach(Re=>{Re.removeEventListener("scroll",he)}),ne.clear()}},[u,i,s,o,h,P,r,a,w,f,N,L,_,B,oe,K,$,me,de,Y,t]),S.useEffect(q,[P,q]);const ee=S.useMemo(()=>({onKeyDown:_,...y&&{[KA[x]]:ne=>{t.setOpen(!1,yt(Ys,ne.nativeEvent))},...x!=="intentional"&&{onClick(ne){t.setOpen(!1,yt(Ys,ne.nativeEvent))}}}}),[_,t,y,x]),fe=Ne(ne=>{const he=en(ne.nativeEvent);!Xe(t.select("floatingElement"),he)||ne.button!==0||(O.current=!0)}),ye=S.useMemo(()=>({onKeyDown:_,onPointerDown:fe,onMouseDown:fe,onMouseUp:fe,onClickCapture:D,onMouseDownCapture:D,onPointerDownCapture:D,onMouseUpCapture:D,onTouchEndCapture:D,onTouchMoveCapture:D}),[_,fe,D]);return S.useMemo(()=>f?{reference:ee,floating:ye,trigger:ee}:{},[f,ee,ye])}var Df=Symbol("NOT_FOUND");function GA(n,e=`expected a function, instead received ${typeof n}`){if(typeof n!="function")throw new TypeError(e)}function YA(n,e=`expected an object, instead received ${typeof n}`){if(typeof n!="object")throw new TypeError(e)}function XA(n,e="expected all items to be functions, instead received the following types: "){if(!n.every(t=>typeof t=="function")){const t=n.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${e}[${t}]`)}}var v1=n=>Array.isArray(n)?n:[n];function JA(n){const e=Array.isArray(n[0])?n[0]:n;return XA(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function ZA(n,e){const t=[],{length:r}=n;for(let i=0;i<r;i++)t.push(n[i].apply(null,e));return t}function e5(n){let e;return{get(t){return e&&n(e.key,t)?e.value:Df},put(t,r){e={key:t,value:r}},getEntries(){return e?[e]:[]},clear(){e=void 0}}}function t5(n,e){let t=[];function r(a){const u=t.findIndex(f=>e(a,f.key));if(u>-1){const f=t[u];return u>0&&(t.splice(u,1),t.unshift(f)),f.value}return Df}function i(a,u){r(a)===Df&&(t.unshift({key:a,value:u}),t.length>n&&t.pop())}function s(){return t}function o(){t=[]}return{get:r,put:i,getEntries:s,clear:o}}var n5=(n,e)=>n===e;function r5(n){return function(t,r){if(t===null||r===null||t.length!==r.length)return!1;const{length:i}=t;for(let s=0;s<i;s++)if(!n(t[s],r[s]))return!1;return!0}}function i5(n,e){const t=typeof e=="object"?e:{equalityCheck:e},{equalityCheck:r=n5,maxSize:i=1,resultEqualityCheck:s}=t,o=r5(r);let a=0;const u=i<=1?e5(o):t5(i,o);function f(){let h=u.get(arguments);if(h===Df){if(h=n.apply(null,arguments),a++,s){const g=u.getEntries().find(y=>s(y.value,h));g&&(h=g.value,a!==0&&a--)}u.put(arguments,h)}return h}return f.clearCache=()=>{u.clear(),f.resetResultsCount()},f.resultsCount=()=>a,f.resetResultsCount=()=>{a=0},f}var s5=class{constructor(n){this.value=n}deref(){return this.value}},o5=typeof WeakRef<"u"?WeakRef:s5,l5=0,x1=1;function ju(){return{s:l5,v:void 0,o:null,p:null}}function yS(n,e={}){let t=ju();const{resultEqualityCheck:r}=e;let i,s=0;function o(){var p;let a=t;const{length:u}=arguments;for(let g=0,y=u;g<y;g++){const x=arguments[g];if(typeof x=="function"||typeof x=="object"&&x!==null){let w=a.o;w===null&&(a.o=w=new WeakMap);const C=w.get(x);C===void 0?(a=ju(),w.set(x,a)):a=C}else{let w=a.p;w===null&&(a.p=w=new Map);const C=w.get(x);C===void 0?(a=ju(),w.set(x,a)):a=C}}const f=a;let h;if(a.s===x1)h=a.v;else if(h=n.apply(null,arguments),s++,r){const g=((p=i==null?void 0:i.deref)==null?void 0:p.call(i))??i;g!=null&&r(g,h)&&(h=g,s!==0&&s--),i=typeof h=="object"&&h!==null||typeof h=="function"?new o5(h):h}return f.s=x1,f.v=h,h}return o.clearCache=()=>{t=ju(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function vS(n,...e){const t=typeof n=="function"?{memoize:n,memoizeOptions:e}:n,r=(...i)=>{let s=0,o=0,a,u={},f=i.pop();typeof f=="object"&&(u=f,f=i.pop()),GA(f,`createSelector expects an output function after the inputs, but received: [${typeof f}]`);const h={...t,...u},{memoize:p,memoizeOptions:g=[],argsMemoize:y=yS,argsMemoizeOptions:x=[]}=h,w=v1(g),C=v1(x),E=JA(i),T=p(function(){return s++,f.apply(null,arguments)},...w),M=y(function(){o++;const O=ZA(E,arguments);return a=T.apply(null,O),a},...C);return Object.assign(M,{resultFunc:f,memoizedResultFunc:T,dependencies:E,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>a,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:p,argsMemoize:y})};return Object.assign(r,{withTypes:()=>r}),r}var a5=vS(yS),c5=Object.assign((n,e=a5)=>{YA(n,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof n}`);const t=Object.keys(n),r=t.map(s=>n[s]);return e(r,(...s)=>s.reduce((o,a,u)=>(o[t[u]]=a,o),{}))},{withTypes:()=>c5});vS({memoize:i5,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const Je=(n,e,t,r,i,s,...o)=>{if(o.length>0)throw new Error(gn(1));let a;if(n)a=n;else throw new Error("Missing arguments");return a};var _p={exports:{}},Vp={};/**
 * @license React
 * use-sync-external-store-shim.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var w1;function u5(){if(w1)return Vp;w1=1;var n=rc();function e(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,i=n.useEffect,s=n.useLayoutEffect,o=n.useDebugValue;function a(p,g){var y=g(),x=r({inst:{value:y,getSnapshot:g}}),w=x[0].inst,C=x[1];return s(function(){w.value=y,w.getSnapshot=g,u(w)&&C({inst:w})},[p,y,g]),i(function(){return u(w)&&C({inst:w}),p(function(){u(w)&&C({inst:w})})},[p]),o(y),y}function u(p){var g=p.getSnapshot;p=p.value;try{var y=g();return!t(p,y)}catch{return!0}}function f(p,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:a;return Vp.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:h,Vp}var b1;function xS(){return b1||(b1=1,_p.exports=u5()),_p.exports}var f5=xS(),Wp={exports:{}},$p={};/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var S1;function d5(){if(S1)return $p;S1=1;var n=rc(),e=xS();function t(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=n.useRef,o=n.useEffect,a=n.useMemo,u=n.useDebugValue;return $p.useSyncExternalStoreWithSelector=function(f,h,p,g,y){var x=s(null);if(x.current===null){var w={hasValue:!1,value:null};x.current=w}else w=x.current;x=a(function(){function E(N){if(!T){if(T=!0,M=N,N=g(N),y!==void 0&&w.hasValue){var L=w.value;if(y(L,N))return P=L}return P=N}if(L=P,r(M,N))return L;var F=g(N);return y!==void 0&&y(L,F)?(M=N,L):(M=N,P=F)}var T=!1,M,P,O=p===void 0?null:p;return[function(){return E(h())},O===null?void 0:function(){return E(O())}]},[h,p,g,y]);var C=i(f,x[0],x[1]);return o(function(){w.hasValue=!0,w.value=C},[C]),u(C),C},$p}var k1;function h5(){return k1||(k1=1,Wp.exports=d5()),Wp.exports}var p5=h5();const m5=Kg(19),g5=m5?v5:x5;function y5(n,e,t,r,i){return g5(n,e,t,r,i)}function v5(n,e,t,r,i){const s=S.useCallback(()=>e(n.getSnapshot(),t,r,i),[n,e,t,r,i]);return f5.useSyncExternalStore(n.subscribe,s,s)}function x5(n,e,t,r,i){return p5.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getSnapshot,s=>e(s,t,r,i))}class ka{constructor(e){ft(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));ft(this,"getSnapshot",()=>this.state);this.state=e,this.listeners=new Set,this.updateTick=0}setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;const t=this.updateTick;for(const r of this.listeners){if(t!==this.updateTick)return;r(e)}}update(e){for(const t in e)if(!Object.is(this.state[t],e[t])){ka.prototype.setState.call(this,{...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||ka.prototype.setState.call(this,{...this.state,[e]:t})}notifyAll(){const e={...this.state};ka.prototype.setState.call(this,e)}}class i0 extends ka{constructor(t,r={},i){super(t);ft(this,"controlledValues",new Map);ft(this,"select",(t,r,i,s)=>{const o=this.selectors[t];return o(this.state,r,i,s)});ft(this,"useState",(t,r,i,s)=>{S.useDebugValue(t);const o=this.selectors[t];return y5(this,o,r,i,s)});this.context=r,this.selectors=i}useSyncedValue(t,r){S.useDebugValue(t),Be(()=>{this.state[t]!==r&&this.set(t,r)},[t,r])}useSyncedValueWithCleanup(t,r){Be(()=>(this.state[t]!==r&&this.set(t,r),()=>{this.set(t,void 0)}),[t,r])}useSyncedValues(t){const r=Object.values(t);Be(()=>{this.update(t)},r)}useControlledProp(t,r,i){S.useDebugValue(t);const s=r!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,s),!s&&!Object.is(this.state[t],i)&&super.setState({...this.state,[t]:i})),Be(()=>{s&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})},[t,r,i,s])}set(t,r){this.controlledValues.get(t)!==!0&&super.set(t,r)}update(t){const r={...t};for(const i in r)if(Object.hasOwn(r,i)&&this.controlledValues.get(i)===!0){delete r[i];continue}super.update(r)}setState(t){const r={...t};for(const i in r)if(Object.hasOwn(r,i)&&this.controlledValues.get(i)===!0){delete r[i];continue}super.setState({...this.state,...r})}useContextCallback(t,r){S.useDebugValue(t);const i=Ne(r??Nn);this.context[t]=i}useStateSetter(t){const r=S.useRef(void 0);return r.current===void 0&&(r.current=i=>{this.set(t,i)}),r.current}observe(t,r){let i;typeof t=="function"?i=t:i=this.selectors[t];let s=i(this.state);return r(s,s,this),this.subscribe(o=>{const a=i(o);if(!Object.is(s,a)){const u=s;s=a,r(a,u,this)}})}}const w5={open:Je(n=>n.open),domReferenceElement:Je(n=>n.domReferenceElement),referenceElement:Je(n=>n.positionReference??n.referenceElement),floatingElement:Je(n=>n.floatingElement),floatingId:Je(n=>n.floatingId)};class s0 extends i0{constructor(t){const{nested:r,noEmit:i,onOpenChange:s,triggerElements:o,...a}=t;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:_P(),nested:r,noEmit:i,triggerElements:o},w5);ft(this,"setOpen",(t,r)=>{var i,s;if((!t||!this.state.open||W2(r.event))&&(this.context.dataRef.current.openEvent=t?r.event:void 0),!this.context.noEmit){const o={open:t,reason:r.reason,nativeEvent:r.event,nested:this.context.nested,triggerElement:r.trigger};this.context.events.emit("openchange",o)}(s=(i=this.context).onOpenChange)==null||s.call(i,t,r)})}}function wS(n,e=!1,t=!1){const[r,i]=S.useState(n&&e?"idle":void 0),[s,o]=S.useState(n);return n&&!s&&(o(!0),i("starting")),!n&&s&&r!=="ending"&&!t&&i("ending"),!n&&!s&&r==="ending"&&i(void 0),Be(()=>{if(!n&&s&&r!=="ending"&&t){const a=qr.request(()=>{i("ending")});return()=>{qr.cancel(a)}}},[n,s,r,t]),Be(()=>{if(!n||e)return;const a=qr.request(()=>{i(void 0)});return()=>{qr.cancel(a)}},[e,n]),Be(()=>{if(!n||!e)return;n&&s&&r!=="idle"&&i("starting");const a=qr.request(()=>{i("idle")});return()=>{qr.cancel(a)}},[e,n,s,i,r]),S.useMemo(()=>({mounted:s,setMounted:o,transitionStatus:r}),[s,r])}function o0(n,e=!1,t=!0){const r=uc();return Ne((i,s=null)=>{r.cancel();const o=Vs(n);o!=null&&(typeof o.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED?i():r.request(()=>{function a(){o&&Promise.all(o.getAnimations().map(u=>u.finished)).then(()=>{s!=null&&s.aborted||Mr.flushSync(i)}).catch(()=>{if(t){if(s!=null&&s.aborted)return;Mr.flushSync(i)}else o.getAnimations().length>0&&o.getAnimations().some(u=>u.pending||u.playState!=="finished")&&a()})}e?r.request(a):a()}))})}function fc(n){const{enabled:e=!0,open:t,ref:r,onComplete:i}=n,s=Cr(t),o=Ne(i),a=o0(r,t);S.useEffect(()=>{e&&a(()=>{t===s.current&&o()})},[e,t,o,a,s])}function b5(n,e){const t=S.useRef(null);return S.useCallback(r=>{n!==void 0&&(t.current!==null&&(e.context.triggerElements.delete(t.current),t.current=null),r!==null&&(t.current=n,e.context.triggerElements.add(n,r)))},[e,n])}function bS(n,e,t,r){const i=t.useState("isMountedByTrigger",n),s=b5(n,t),o=Ne(a=>{s(a),a!==null&&t.select("open")&&t.select("activeTriggerId")==null&&t.update({activeTriggerId:n,activeTriggerElement:a,...r})});return Be(()=>{i&&t.update({activeTriggerElement:e.current,...r})},[i,t,e,...Object.values(r)]),{registerTrigger:o,isMountedByThisTrigger:i}}function SS(n){const e=n.useState("open");Be(()=>{if(e&&!n.select("activeTriggerId")&&n.context.triggerElements.size===1){const t=n.context.triggerElements.entries().next();if(!t.done){const[r,i]=t.value;n.update({activeTriggerId:r,activeTriggerElement:i})}}},[e,n])}function kS(n,e,t){const{mounted:r,setMounted:i,transitionStatus:s}=wS(n);e.useSyncedValues({mounted:r,transitionStatus:s});const o=Ne(()=>{var u,f;i(!1),e.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),t==null||t(),(f=(u=e.context).onOpenChangeComplete)==null||f.call(u,!1)}),a=e.useState("preventUnmountingOnClose");return fc({enabled:!a,open:n,ref:e.context.popupRef,onComplete(){n||o()}}),{forceUnmount:o,transitionStatus:s}}class Td{constructor(){this.elements=new Set,this.idMap=new Map}add(e,t){const r=this.idMap.get(e);r!==t&&(r!==void 0&&this.elements.delete(r),this.elements.add(t),this.idMap.set(e,t))}delete(e){const t=this.idMap.get(e);t&&(this.elements.delete(t),this.idMap.delete(e))}hasElement(e){return this.elements.has(e)}hasMatchingElement(e){for(const t of this.elements)if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function S5(){return new s0({open:!1,floatingElement:null,referenceElement:null,triggerElements:new Td,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function CS(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:S5(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:tn,inactiveTriggerProps:tn,popupProps:tn}}const ES={open:Je(n=>n.open),mounted:Je(n=>n.mounted),transitionStatus:Je(n=>n.transitionStatus),floatingRootContext:Je(n=>n.floatingRootContext),preventUnmountingOnClose:Je(n=>n.preventUnmountingOnClose),payload:Je(n=>n.payload),activeTriggerId:Je(n=>n.activeTriggerId),activeTriggerElement:Je(n=>n.mounted?n.activeTriggerElement:null),isTriggerActive:Je((n,e)=>e!==void 0&&n.activeTriggerId===e),isOpenedByTrigger:Je((n,e)=>e!==void 0&&n.activeTriggerId===e&&n.open),isMountedByTrigger:Je((n,e)=>e!==void 0&&n.activeTriggerId===e&&n.mounted),triggerProps:Je((n,e)=>e?n.activeTriggerProps:n.inactiveTriggerProps),popupProps:Je(n=>n.popupProps),popupElement:Je(n=>n.popupElement),positionerElement:Je(n=>n.positionerElement)};function k5(n){const{open:e=!1,onOpenChange:t,elements:r={}}=n,i=lo(),s=Cd()!=null,o=ri(()=>new s0({open:e,onOpenChange:t,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new Td,floatingId:i,nested:s,noEmit:n.noEmit||!1})).current;return Be(()=>{const a={open:e,floatingId:i};r.reference!==void 0&&(a.referenceElement=r.reference,a.domReferenceElement=ct(r.reference)?r.reference:null),r.floating!==void 0&&(a.floatingElement=r.floating),o.update(a)},[e,i,r.reference,r.floating,o]),o.context.onOpenChange=t,o.context.nested=s,o.context.noEmit=n.noEmit||!1,o}function C5(n={}){const{nodeId:e,externalTree:t}=n,r=k5(n),i=n.rootContext||r,s={reference:i.useState("referenceElement"),floating:i.useState("floatingElement"),domReference:i.useState("domReferenceElement")},[o,a]=S.useState(null),u=S.useRef(null),f=ac(t);Be(()=>{s.domReference&&(u.current=s.domReference)},[s.domReference]);const h=_A({...n,elements:{...s,...o&&{reference:o}}}),p=S.useCallback(L=>{const F=ct(L)?{getBoundingClientRect:()=>L.getBoundingClientRect(),getClientRects:()=>L.getClientRects(),contextElement:L}:L;a(F),h.refs.setReference(F)},[h.refs]),[g,y]=S.useState(null),[x,w]=S.useState(null);i.useSyncedValue("referenceElement",g),i.useSyncedValue("domReferenceElement",ct(g)?g:null),i.useSyncedValue("floatingElement",x);const C=S.useCallback(L=>{(ct(L)||L===null)&&(u.current=L,y(L)),(ct(h.refs.reference.current)||h.refs.reference.current===null||L!==null&&!ct(L))&&h.refs.setReference(L)},[h.refs,y]),E=S.useCallback(L=>{w(L),h.refs.setFloating(L)},[h.refs]),T=S.useMemo(()=>({...h.refs,setReference:C,setFloating:E,setPositionReference:p,domReference:u}),[h.refs,C,E,p]),M=S.useMemo(()=>({...h.elements,domReference:s.domReference}),[h.elements,s.domReference]),P=i.useState("open"),O=i.useState("floatingId"),N=S.useMemo(()=>({...h,dataRef:i.context.dataRef,open:P,onOpenChange:i.setOpen,events:i.context.events,floatingId:O,refs:T,elements:M,nodeId:e,rootStore:i}),[h,T,M,e,i,P,O]);return Be(()=>{i.context.dataRef.current.floatingContext=N;const L=f==null?void 0:f.nodesRef.current.find(F=>F.id===e);L&&(L.context=N)}),S.useMemo(()=>({...h,context:N,refs:T,elements:M,rootStore:i}),[h,T,M,N,i])}function RS(n){const{popupStore:e,noEmit:t=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:i}=n,s=lo(),o=Cd()!=null,a=e.useState("open"),u=e.useState("activeTriggerElement"),f=e.useState(r?"popupElement":"positionerElement"),h=e.context.triggerElements,p=ri(()=>new s0({open:a,referenceElement:u,floatingElement:f,triggerElements:h,onOpenChange:i,floatingId:s,nested:o,noEmit:t})).current;return Be(()=>{const g={open:a,floatingId:s,referenceElement:u,floatingElement:f};ct(u)&&(g.domReferenceElement=u),p.update(g)},[a,s,u,f,p]),p.context.onOpenChange=i,p.context.nested=o,p.context.noEmit=t,p}const Hp=nP&&B2;function E5(n,e={}){const t="rootStore"in n?n.rootStore:n,{events:r,dataRef:i}=t.context,{enabled:s=!0,visibleOnly:o=!0}=e,a=S.useRef(!1),u=Ri(),f=S.useRef(!0);S.useEffect(()=>{const p=t.select("domReferenceElement");if(!s)return;const g=Pt(p);function y(){!t.select("open")&&zt(p)&&p===ir(qt(p))&&(a.current=!0)}function x(){f.current=!0}function w(){f.current=!1}return g.addEventListener("blur",y),Hp&&(g.addEventListener("keydown",x,!0),g.addEventListener("pointerdown",w,!0)),()=>{g.removeEventListener("blur",y),Hp&&(g.removeEventListener("keydown",x,!0),g.removeEventListener("pointerdown",w,!0))}},[t,s]),S.useEffect(()=>{if(!s)return;function p(g){(g.reason===Ys||g.reason===t0)&&(a.current=!0)}return r.on("openchange",p),()=>{r.off("openchange",p)}},[r,s]);const h=S.useMemo(()=>({onMouseLeave(){a.current=!1},onFocus(p){if(a.current)return;const g=en(p.nativeEvent);if(o&&ct(g)){if(Hp&&!p.relatedTarget){if(!f.current&&!Xg(g))return}else if(!Tf(g))return}t.setOpen(!0,yt(Vm,p.nativeEvent,p.currentTarget))},onBlur(p){a.current=!1;const g=p.relatedTarget,y=p.nativeEvent,x=ct(g)&&g.hasAttribute(tl("focus-guard"))&&g.getAttribute("data-type")==="outside";u.start(0,()=>{var E;const w=t.select("domReferenceElement"),C=ir(w?w.ownerDocument:document);!g&&C===w||Xe((E=i.current.floatingContext)==null?void 0:E.refs.floating.current,C)||Xe(w,C)||x||t.context.triggerElements.hasElement(p.relatedTarget)||t.setOpen(!1,yt(Vm,y))})}}),[i,t,o,u]);return S.useMemo(()=>s?{reference:h,trigger:h}:{},[s,h])}const Wm=tl("safe-polygon"),R5=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${V2}`;function T5(n){return n?!!n.closest(R5):!1}function TS(n){const e=S.useRef(void 0),t=S.useRef(!1),r=S.useRef(void 0),i=S.useRef(!0),s=S.useRef(!1),o=S.useRef(()=>{}),a=S.useRef(!1),u=Ri(),f=Ri(),h=S.useRef(void 0);return S.useMemo(()=>{const p=n.context.dataRef.current;return p.hoverInteractionState||(p.hoverInteractionState={pointerTypeRef:e,interactedInsideRef:t,handlerRef:r,blockMouseMoveRef:i,performedPointerEventsMutationRef:s,unbindMouseMoveRef:o,restTimeoutPendingRef:a,openChangeTimeout:u,restTimeout:f,handleCloseOptionsRef:h}),p.hoverInteractionState},[n,e,t,r,i,s,o,a,u,f,h])}const M5=new Set(["click","mousedown"]);function O5(n,e={}){const t="rootStore"in n?n.rootStore:n,r=t.useState("open"),i=t.useState("floatingElement"),s=t.useState("domReferenceElement"),{dataRef:o}=t.context,{enabled:a=!0,closeDelay:u=0,externalTree:f}=e,{pointerTypeRef:h,interactedInsideRef:p,handlerRef:g,performedPointerEventsMutationRef:y,unbindMouseMoveRef:x,restTimeoutPendingRef:w,openChangeTimeout:C,handleCloseOptionsRef:E}=TS(t),T=ac(f),M=Cd(),P=Ne(()=>p.current?!0:o.current.openEvent?M5.has(o.current.openEvent.type):!1),O=Ne(()=>{var q;const Q=(q=o.current.openEvent)==null?void 0:q.type;return(Q==null?void 0:Q.includes("mouse"))&&Q!=="mousedown"}),N=S.useCallback((Q,q=!0)=>{const H=P5(u,h.current);H&&!g.current?C.start(H,()=>t.setOpen(!1,yt(Kr,Q))):q&&(C.clear(),t.setOpen(!1,yt(Kr,Q)))},[u,g,t,h,C]),L=Ne(()=>{x.current(),g.current=void 0}),F=Ne(()=>{if(y.current){const Q=qt(i).body;Q.style.pointerEvents="",Q.removeAttribute(Wm),y.current=!1}}),U=Ne(Q=>{const q=en(Q);if(!T5(q)){p.current=!1;return}p.current=!0});Be(()=>{r||(h.current=void 0,w.current=!1,p.current=!1,L(),F())},[r,h,w,p,L,F]),S.useEffect(()=>()=>{L()},[L]),S.useEffect(()=>F,[F]),Be(()=>{var Q,q,H;if(a&&r&&(Q=E.current)!=null&&Q.blockPointerEvents&&O()&&ct(s)&&i){y.current=!0;const j=qt(i).body;j.setAttribute(Wm,"");const Y=s,W=i,_=(H=(q=T==null?void 0:T.nodesRef.current.find(X=>X.id===M))==null?void 0:q.context)==null?void 0:H.elements.floating;return _&&(_.style.pointerEvents=""),j.style.pointerEvents="none",Y.style.pointerEvents="auto",W.style.pointerEvents="auto",()=>{j.style.pointerEvents="",Y.style.pointerEvents="",W.style.pointerEvents=""}}},[a,r,s,i,E,O,T,M,y]),S.useEffect(()=>{if(!a)return;function Q(Y){if(P()||!o.current.floatingContext||!t.select("open"))return;const W=t.context.triggerElements;Y.relatedTarget&&W.hasElement(Y.relatedTarget)||(F(),L(),P()||N(Y))}function q(Y){var W;C.clear(),F(),(W=g.current)==null||W.call(g,Y),L()}function H(Y){P()||N(Y,!1)}const j=i;return j&&(j.addEventListener("mouseleave",Q),j.addEventListener("mouseenter",q),j.addEventListener("mouseleave",H),j.addEventListener("pointerdown",U,!0)),()=>{j&&(j.removeEventListener("mouseleave",Q),j.removeEventListener("mouseenter",q),j.removeEventListener("mouseleave",H),j.removeEventListener("pointerdown",U,!0))}})}function P5(n,e){return e&&!eo(e)?0:typeof n=="function"?n():n}function Up(n){return typeof n=="function"?n():n}const A5={current:null};function N5(n,e={}){var X;const t="rootStore"in n?n.rootStore:n,{dataRef:r,events:i}=t.context,{enabled:s=!0,delay:o=0,handleClose:a=null,mouseOnly:u=!1,restMs:f=0,move:h=!0,triggerElementRef:p=A5,externalTree:g,isActiveTrigger:y=!0}=e,x=ac(g),{pointerTypeRef:w,interactedInsideRef:C,handlerRef:E,blockMouseMoveRef:T,performedPointerEventsMutationRef:M,unbindMouseMoveRef:P,restTimeoutPendingRef:O,openChangeTimeout:N,restTimeout:L,handleCloseOptionsRef:F}=TS(t),U=Cr(a),Q=Cr(o),q=Cr(f);y&&(F.current=(X=U.current)==null?void 0:X.__options);const H=Ne(()=>C.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),j=S.useCallback((D,B=!0)=>{const K=hf(Q.current,"close",w.current);K&&!E.current?N.start(K,()=>t.setOpen(!1,yt(Kr,D))):B&&(N.clear(),t.setOpen(!1,yt(Kr,D)))},[Q,E,t,w,N]),Y=Ne(()=>{P.current(),E.current=void 0}),W=Ne(()=>{if(M.current){const D=qt(t.select("domReferenceElement")).body;D.style.pointerEvents="",D.removeAttribute(Wm),M.current=!1}});S.useEffect(()=>{if(!s)return;function D(B){B.open||(N.clear(),L.clear(),T.current=!0,O.current=!1)}return i.on("openchange",D),()=>{i.off("openchange",D)}},[s,i,N,L,T,O]);const _=Ne(D=>{var A;if(H()||!r.current.floatingContext)return;const B=t.context.triggerElements;if(D.relatedTarget&&B.hasElement(D.relatedTarget))return;const K=p.current;(A=U.current)==null||A.call(U,{...r.current.floatingContext,tree:x,x:D.clientX,y:D.clientY,onClose(){W(),Y(),!H()&&K===t.select("domReferenceElement")&&j(D)}})(D)});return S.useEffect(()=>{if(!s)return;const D=p.current??(y?t.select("domReferenceElement"):null);if(!ct(D))return;function B($){if(N.clear(),T.current=!1,u&&!eo(w.current)||Up(q.current)>0&&!hf(Q.current,"open"))return;const oe=hf(Q.current,"open",w.current),ce=t.select("domReferenceElement"),me=t.context.triggerElements,le=(me.hasElement($.target)||me.hasMatchingElement(fe=>Xe(fe,$.target)))&&(!ce||!Xe(ce,$.target)),de=$.currentTarget??null,ee=!t.select("open")||le;oe?N.start(oe,()=>{ee&&t.setOpen(!0,yt(Kr,$,de))}):ee&&t.setOpen(!0,yt(Kr,$,de))}function K($){if(H()){W();return}P.current();const oe=t.select("domReferenceElement"),ce=qt(oe);L.clear(),O.current=!1;const me=t.context.triggerElements;if($.relatedTarget&&me.hasElement($.relatedTarget))return;if(U.current&&r.current.floatingContext){t.select("open")||N.clear();const de=p.current;E.current=U.current({...r.current.floatingContext,tree:x,x:$.clientX,y:$.clientY,onClose(){W(),Y(),!H()&&de===t.select("domReferenceElement")&&j($,!0)}});const ee=E.current;ee($),ce.addEventListener("mousemove",ee),P.current=()=>{ce.removeEventListener("mousemove",ee)};return}(w.current==="touch"?!Xe(t.select("floatingElement"),$.relatedTarget):!0)&&j($)}function A($){_($)}return t.select("open")&&D.addEventListener("mouseleave",A),h&&D.addEventListener("mousemove",B,{once:!0}),D.addEventListener("mouseenter",B),D.addEventListener("mouseleave",K),()=>{D.removeEventListener("mouseleave",A),h&&D.removeEventListener("mousemove",B),D.removeEventListener("mouseenter",B),D.removeEventListener("mouseleave",K)}},[Y,W,T,r,Q,j,t,s,U,_,y,H,u,h,w,q,L,O,N,p,x,P,E]),S.useMemo(()=>{function D(B){w.current=B.pointerType}return{onPointerDown:D,onPointerEnter:D,onMouseMove(B){const{nativeEvent:K}=B,A=B.currentTarget,$=t.select("domReferenceElement"),oe=t.context.triggerElements,ce=t.select("open"),me=(oe.hasElement(B.target)||oe.hasMatchingElement(de=>Xe(de,B.target)))&&(!$||!Xe($,B.target));if(u&&!eo(w.current)||ce&&!me||Up(q.current)===0||!me&&O.current&&B.movementX**2+B.movementY**2<2)return;L.clear();function le(){!T.current&&(!ce||me)&&t.setOpen(!0,yt(Kr,K,A))}w.current==="touch"?Mr.flushSync(()=>{le()}):me&&ce?le():(O.current=!0,L.start(Up(q.current),le))}}},[T,u,t,w,q,L,O])}function l0(n=[]){const e=n.map(f=>f==null?void 0:f.reference),t=n.map(f=>f==null?void 0:f.floating),r=n.map(f=>f==null?void 0:f.item),i=n.map(f=>f==null?void 0:f.trigger),s=S.useCallback(f=>Bu(f,n,"reference"),e),o=S.useCallback(f=>Bu(f,n,"floating"),t),a=S.useCallback(f=>Bu(f,n,"item"),r),u=S.useCallback(f=>Bu(f,n,"trigger"),i);return S.useMemo(()=>({getReferenceProps:s,getFloatingProps:o,getItemProps:a,getTriggerProps:u}),[s,o,a,u])}function Bu(n,e,t){var o;const r=new Map,i=t==="item",s={};t==="floating"&&(s.tabIndex=-1,s[Im]="");for(const a in n)i&&n&&(a===z2||a===_2)||(s[a]=n[a]);for(let a=0;a<e.length;a+=1){let u;const f=(o=e[a])==null?void 0:o[t];typeof f=="function"?u=n?f(n):null:u=f,u&&C1(s,u,i,r)}return C1(s,n,i,r),s}function C1(n,e,t,r){var i;for(const s in e){const o=e[s];t&&(s===z2||s===_2)||(s.startsWith("on")?(r.has(s)||r.set(s,[]),typeof o=="function"&&((i=r.get(s))==null||i.push(o),n[s]=(...a)=>{var u;return(u=r.get(s))==null?void 0:u.map(f=>f(...a)).find(f=>f!==void 0)})):n[s]=o)}}const L5=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function D5(n,e={}){const t="rootStore"in n?n.rootStore:n,r=t.useState("open"),i=t.useState("floatingId"),s=t.useState("domReferenceElement"),o=t.useState("floatingElement"),{enabled:a=!0,role:u="dialog"}=e,f=lo(),h=(s==null?void 0:s.id)||f,p=S.useMemo(()=>{var M;return((M=jm(o))==null?void 0:M.id)||i},[o,i]),g=L5.get(u)??u,x=Cd()!=null,w=S.useMemo(()=>g==="tooltip"||u==="label"?tn:{"aria-haspopup":g==="alertdialog"?"dialog":g,"aria-expanded":"false",...g==="listbox"&&{role:"combobox"},...g==="menu"&&x&&{role:"menuitem"},...u==="select"&&{"aria-autocomplete":"none"},...u==="combobox"&&{"aria-autocomplete":"list"}},[g,x,u]),C=S.useMemo(()=>g==="tooltip"||u==="label"?{[`aria-${u==="label"?"labelledby":"describedby"}`]:r?p:void 0}:{...w,"aria-expanded":r?"true":"false","aria-controls":r?p:void 0,...g==="menu"&&{id:h}},[g,p,r,h,u,w]),E=S.useMemo(()=>{const M={id:p,...g&&{role:g}};return g==="tooltip"||u==="label"?M:{...M,...g==="menu"&&{"aria-labelledby":h}}},[g,p,h,u]),T=S.useCallback(({active:M,selected:P})=>{const O={role:"option",...M&&{id:`${p}-fui-option`}};switch(u){case"select":case"combobox":return{...O,"aria-selected":P}}return{}},[p,u]);return S.useMemo(()=>a?{reference:C,floating:E,item:T,trigger:w}:{},[a,C,E,w,T])}function E1(n,e){const[t,r]=n;let i=!1;const s=e.length;for(let o=0,a=s-1;o<s;a=o++){const[u,f]=e[o]||[0,0],[h,p]=e[a]||[0,0];f>=r!=p>=r&&t<=(h-u)*(r-f)/(p-f)+u&&(i=!i)}return i}function I5(n,e){return n[0]>=e.x&&n[0]<=e.x+e.width&&n[1]>=e.y&&n[1]<=e.y+e.height}function j5(n={}){const{buffer:e=.5,blockPointerEvents:t=!1,requireIntent:r=!0}=n,i=new ni;let s=!1,o=null,a=null,u=typeof performance<"u"?performance.now():0;function f(p,g){const y=performance.now(),x=y-u;if(o===null||a===null||x===0)return o=p,a=g,u=y,null;const w=p-o,C=g-a,T=Math.sqrt(w*w+C*C)/x;return o=p,a=g,u=y,T}const h=({x:p,y:g,placement:y,elements:x,onClose:w,nodeId:C,tree:E})=>function(M){function P(){i.clear(),w()}if(i.clear(),!x.domReference||!x.floating||y==null||p==null||g==null)return;const{clientX:O,clientY:N}=M,L=[O,N],F=en(M),U=M.type==="mouseleave",Q=Xe(x.floating,F),q=Xe(x.domReference,F),H=x.domReference.getBoundingClientRect(),j=x.floating.getBoundingClientRect(),Y=y.split("-")[0],W=p>j.right-j.width/2,_=g>j.bottom-j.height/2,X=I5(L,H),D=j.width>H.width,B=j.height>H.height,K=(D?H:j).left,A=(D?H:j).right,$=(B?H:j).top,oe=(B?H:j).bottom;if(Q&&(s=!0,!U))return;if(q&&(s=!1),q&&!U){s=!0;return}if(U&&ct(M.relatedTarget)&&Xe(x.floating,M.relatedTarget)||E&&Gs(E.nodesRef.current,C).some(({context:le})=>le==null?void 0:le.open))return;if(Y==="top"&&g>=H.bottom-1||Y==="bottom"&&g<=H.top+1||Y==="left"&&p>=H.right-1||Y==="right"&&p<=H.left+1)return P();let ce=[];switch(Y){case"top":ce=[[K,H.top+1],[K,j.bottom-1],[A,j.bottom-1],[A,H.top+1]];break;case"bottom":ce=[[K,j.top+1],[K,H.bottom-1],[A,H.bottom-1],[A,j.top+1]];break;case"left":ce=[[j.right-1,oe],[j.right-1,$],[H.left+1,$],[H.left+1,oe]];break;case"right":ce=[[H.right-1,oe],[H.right-1,$],[j.left+1,$],[j.left+1,oe]];break}function me([le,de]){switch(Y){case"top":{const ee=[D?le+e/2:W?le+e*4:le-e*4,de+e+1],fe=[D?le-e/2:W?le+e*4:le-e*4,de+e+1],ye=[[j.left,W||D?j.bottom-e:j.top],[j.right,W?D?j.bottom-e:j.top:j.bottom-e]];return[ee,fe,...ye]}case"bottom":{const ee=[D?le+e/2:W?le+e*4:le-e*4,de-e],fe=[D?le-e/2:W?le+e*4:le-e*4,de-e],ye=[[j.left,W||D?j.top+e:j.bottom],[j.right,W?D?j.top+e:j.bottom:j.top+e]];return[ee,fe,...ye]}case"left":{const ee=[le+e+1,B?de+e/2:_?de+e*4:de-e*4],fe=[le+e+1,B?de-e/2:_?de+e*4:de-e*4];return[...[[_||B?j.right-e:j.left,j.top],[_?B?j.right-e:j.left:j.right-e,j.bottom]],ee,fe]}case"right":{const ee=[le-e,B?de+e/2:_?de+e*4:de-e*4],fe=[le-e,B?de-e/2:_?de+e*4:de-e*4],ye=[[_||B?j.left+e:j.right,j.top],[_?B?j.left+e:j.right:j.left+e,j.bottom]];return[ee,fe,...ye]}default:return[]}}if(!E1([O,N],ce)){if(s&&!X)return P();if(!U&&r){const le=f(M.clientX,M.clientY);if(le!==null&&le<.1)return P()}E1([O,N],me([p,g]))?!s&&r&&i.start(40,P):P()}};return h.__options={blockPointerEvents:t},h}const B5={...ES,disabled:Je(n=>n.disabled),instantType:Je(n=>n.instantType),isInstantPhase:Je(n=>n.isInstantPhase),trackCursorAxis:Je(n=>n.trackCursorAxis),disableHoverablePopup:Je(n=>n.disableHoverablePopup),lastOpenChangeReason:Je(n=>n.openChangeReason),closeDelay:Je(n=>n.closeDelay)};class a0 extends i0{constructor(t){super({...F5(),...t},{popupRef:S.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new Td},B5);ft(this,"setOpen",(t,r)=>{var f,h;const i=r.reason,s=i===Kr,o=t&&i===Vm,a=!t&&(i===Ys||i===t0);if(r.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},(h=(f=this.context).onOpenChange)==null||h.call(f,t,r),r.isCanceled)return;const u=()=>{var y;const p={open:t,openChangeReason:i};o?p.instantType="focus":a?p.instantType="dismiss":i===Kr&&(p.instantType=void 0);const g=((y=r.trigger)==null?void 0:y.id)??null;(g||t)&&(p.activeTriggerId=g,p.activeTriggerElement=r.trigger??null),this.update(p)};s?Mr.flushSync(u):u()})}static useStore(t,r){const i=ri(()=>t??new a0(r)).current,s=RS({popupStore:i,onOpenChange:i.setOpen});return i.state.floatingRootContext=s,i}}function F5(){return{...CS(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeDelay:0}}function z5(n){const{disabled:e=!1,defaultOpen:t=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:s="none",actionsRef:o,onOpenChange:a,onOpenChangeComplete:u,handle:f,triggerId:h,defaultTriggerId:p=null,children:g}=n,y=a0.useStore(f==null?void 0:f.store,{open:r??t,activeTriggerId:h!==void 0?h:p});y.useControlledProp("open",r,t),y.useControlledProp("activeTriggerId",h,p),y.useContextCallback("onOpenChange",a),y.useContextCallback("onOpenChangeComplete",u);const x=y.useState("open"),w=y.useState("activeTriggerId"),C=y.useState("payload");y.useSyncedValues({trackCursorAxis:s,disableHoverablePopup:i});const E=!e&&x;Be(()=>{x&&e&&y.setOpen(!1,yt(HP))},[x,e,y]),y.useSyncedValue("disabled",e),SS(y);const{forceUnmount:T,transitionStatus:M}=kS(E,y),P=y.useState("isInstantPhase"),O=y.useState("instantType"),N=y.useState("lastOpenChangeReason"),L=S.useRef(null);Be(()=>{M==="ending"&&N===cc||M!=="ending"&&P?(O!=="delay"&&(L.current=O),y.set("instantType","delay")):L.current!==null&&(y.set("instantType",L.current),L.current=null)},[M,P,N,O,y]),Be(()=>{E&&w==null&&y.set("payload",void 0)},[y,w,E]);const F=S.useCallback(()=>{y.setOpen(!1,_5(y,nS))},[y]);S.useImperativeHandle(o,()=>({unmount:T,close:F}),[T,F]);const U=y.useState("floatingRootContext"),Q=E5(U,{enabled:!e}),q=gS(U,{enabled:!e,referencePress:!0}),H=oA(U,{enabled:!e&&s!=="none",axis:s==="none"?void 0:s}),{getReferenceProps:j,getFloatingProps:Y,getTriggerProps:W}=l0([Q,q,H]),_=S.useMemo(()=>j(),[j]),X=S.useMemo(()=>W(),[W]),D=S.useMemo(()=>Y(),[Y]);return y.useSyncedValues({floatingRootContext:U,activeTriggerProps:_,inactiveTriggerProps:X,popupProps:D}),k.jsx(N2.Provider,{value:y,children:typeof g=="function"?g({payload:C}):g})}function _5(n,e){const t=yt(e);return t.preventUnmountOnClose=()=>{n.set("preventUnmountingOnClose",!0)},t}let If=function(n){return n.startingStyle="data-starting-style",n.endingStyle="data-ending-style",n}({});const V5={[If.startingStyle]:""},W5={[If.endingStyle]:""},gl={transitionStatus(n){return n==="starting"?V5:n==="ending"?W5:null}};let Er=function(n){return n.open="data-open",n.closed="data-closed",n[n.startingStyle=If.startingStyle]="startingStyle",n[n.endingStyle=If.endingStyle]="endingStyle",n.anchorHidden="data-anchor-hidden",n}({}),$5=function(n){return n.popupOpen="data-popup-open",n.pressed="data-pressed",n}({});const H5={[$5.popupOpen]:""},U5={[Er.open]:""},q5={[Er.closed]:""},K5={[Er.anchorHidden]:""},MS={open(n){return n?H5:null}},dc={open(n){return n?U5:q5},anchorHidden(n){return n?K5:null}};function no(n){return lo(n,"base-ui")}const OS=S.createContext(void 0);function Q5(){return S.useContext(OS)}const G5=600,Y5=S.forwardRef(function(e,t){const{className:r,render:i,handle:s,payload:o,disabled:a,delay:u,closeDelay:f,id:h,...p}=e,g=oc(!0),y=(s==null?void 0:s.store)??g;if(!y)throw new Error(gn(82));const x=no(h),w=y.useState("isTriggerActive",x),C=y.useState("floatingRootContext"),E=y.useState("isOpenedByTrigger",x),T=S.useRef(null),M=u??G5,P=f??0,{registerTrigger:O,isMountedByThisTrigger:N}=bS(x,T,y,{payload:o,closeDelay:P}),L=Q5(),{delayRef:F,isInstantPhase:U,hasProvider:Q}=qP(C,{open:E});y.useSyncedValue("isInstantPhase",U);const q=y.useState("disabled"),H=a??q,j=y.useState("trackCursorAxis"),Y=y.useState("disableHoverablePopup"),W=N5(C,{enabled:!H,mouseOnly:!0,move:!1,handleClose:!Y&&j!=="both"?j5():null,restMs(){const B=L==null?void 0:L.delay,K=typeof F.current=="object"?F.current.open:void 0;let A=M;return Q&&(K!==0?A=u??B??M:A=0),A},delay(){const B=typeof F.current=="object"?F.current.close:void 0;let K=P;return f==null&&Q&&(K=B),{close:K}},triggerElementRef:T,isActiveTrigger:w}),_=S.useMemo(()=>({open:E}),[E]),X=y.useState("triggerProps",N);return At("button",e,{state:_,ref:[t,O,T],props:[W,X,{id:x},p],stateAttributesMapping:MS})}),PS=S.createContext(void 0);function X5(){const n=S.useContext(PS);if(n===void 0)throw new Error(gn(70));return n}const AS=S.forwardRef(function(e,t){const{children:r,container:i,className:s,render:o,...a}=e,{portalNode:u,portalSubtree:f}=lS({container:i,ref:t,componentProps:e,elementProps:a});return!f&&!u?null:k.jsxs(S.Fragment,{children:[f,u&&Mr.createPortal(r,u)]})}),J5=S.forwardRef(function(e,t){const{keepMounted:r=!1,...i}=e;return oc().useState("mounted")||r?k.jsx(PS.Provider,{value:r,children:k.jsx(AS,{ref:t,...i})}):null}),NS=S.createContext(void 0);function Z5(){const n=S.useContext(NS);if(n===void 0)throw new Error(gn(71));return n}const eN=S.createContext(void 0);function LS(){const n=S.useContext(eN);return(n==null?void 0:n.direction)??"ltr"}const tN=n=>({name:"arrow",options:n,async fn(e){var B,K;const{x:t,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:u}=e,{element:f,padding:h=0,offsetParent:p="real"}=Mi(n,e)||{};if(f==null)return{};const g=$2(h),y={x:t,y:r},x=e0(i),w=Zg(x),C=await o.getDimensions(f),E=x==="y",T=E?"top":"left",M=E?"bottom":"right",P=E?"clientHeight":"clientWidth",O=s.reference[w]+s.reference[x]-y[x]-s.floating[w],N=y[x]-s.reference[x],L=p==="real"?await((B=o.getOffsetParent)==null?void 0:B.call(o,f)):a.floating;let F=a.floating[P]||s.floating[w];(!F||!await((K=o.isElement)==null?void 0:K.call(o,L)))&&(F=a.floating[P]||s.floating[w]);const U=O/2-N/2,Q=F/2-C[w]/2-1,q=Math.min(g[T],Q),H=Math.min(g[M],Q),j=q,Y=F-C[w]-H,W=F/2-C[w]/2+U,_=Bm(j,W,Y),X=!u.arrow&&xs(i)!=null&&W!==_&&s.reference[w]/2-(W<j?q:H)-C[w]/2<0,D=X?W<j?W-j:W-Y:0;return{[x]:y[x]+D,data:{[x]:_,centerOffset:W-_-D,...X&&{alignmentOffset:D}},reset:X}}}),nN=(n,e)=>({...tN(n),options:[n,e]}),rN={name:"hide",async fn(n){var a;const{width:e,height:t,x:r,y:i}=n.rects.reference,s=e===0&&t===0&&r===0&&i===0;return{data:{referenceHidden:((a=(await qA().fn(n)).data)==null?void 0:a.referenceHidden)||s}}}},mf={sideX:"left",sideY:"top"},iN={name:"adaptiveOrigin",async fn(n){var T,M;const{x:e,y:t,rects:{floating:r},elements:{floating:i},platform:s,strategy:o,placement:a}=n,u=Pt(i),f=u.getComputedStyle(i);if(!(f.transitionDuration!=="0s"&&f.transitionDuration!==""))return{x:e,y:t,data:mf};const p=await((T=s.getOffsetParent)==null?void 0:T.call(s,i));let g={width:0,height:0};if(o==="fixed"&&(u!=null&&u.visualViewport))g={width:u.visualViewport.width,height:u.visualViewport.height};else if(p===u){const P=or(i);g={width:P.documentElement.clientWidth,height:P.documentElement.clientHeight}}else await((M=s.isElement)==null?void 0:M.call(s,p))&&(g=await s.getDimensions(p));const y=Bn(a);let x=e,w=t;y==="left"&&(x=g.width-(e+r.width)),y==="top"&&(w=g.height-(t+r.height));const C=y==="left"?"right":mf.sideX,E=y==="top"?"bottom":mf.sideY;return{x,y:w,data:{sideX:C,sideY:E}}}};function DS(n,e,t){const r=n==="inline-start"||n==="inline-end";return{top:"top",right:r?t?"inline-start":"inline-end":"right",bottom:"bottom",left:r?t?"inline-end":"inline-start":"left"}[e]}function R1(n,e,t){const{rects:r,placement:i}=n;return{side:DS(e,Bn(i),t),align:xs(i)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function sN(n){var Yn,Dr;const{anchor:e,positionMethod:t="absolute",side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,collisionBoundary:a,collisionPadding:u=5,sticky:f=!1,arrowPadding:h=5,disableAnchorTracking:p=!1,keepMounted:g=!1,floatingRootContext:y,mounted:x,collisionAvoidance:w,shiftCrossAxis:C=!1,nodeId:E,adaptiveOrigin:T,lazyFlip:M=!1,externalTree:P}=n,[O,N]=S.useState(null);!x&&O!==null&&N(null);const L=w.side||"flip",F=w.align||"flip",U=w.fallbackAxisSide||"end",Q=typeof e=="function"?e:void 0,q=Ne(Q),H=Q?q:e,j=Cr(e),W=LS()==="rtl",_=O||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":W?"left":"right","inline-start":W?"right":"left"}[r],X=s==="center"?_:`${_}-${s}`;let D=u;const B=1,K=r==="bottom"?B:0,A=r==="top"?B:0,$=r==="right"?B:0,oe=r==="left"?B:0;typeof D=="number"?D={top:D+K,right:D+oe,bottom:D+A,left:D+$}:D&&(D={top:(D.top||0)+K,right:(D.right||0)+oe,bottom:(D.bottom||0)+A,left:(D.left||0)+$});const ce={boundary:a==="clipping-ancestors"?"clippingAncestors":a,padding:D},me=S.useRef(null),le=Cr(i),de=Cr(o),ye=[VA(st=>{const Et=R1(st,r,W),$t=typeof le.current=="function"?le.current(Et):le.current,Nt=typeof de.current=="function"?de.current(Et):de.current;return{mainAxis:$t,crossAxis:Nt,alignmentAxis:Nt}},[typeof i!="function"?i:0,typeof o!="function"?o:0,W,r])],ne=F==="none"&&L!=="shift",he=!ne&&(f||C||L==="shift"),we=L==="none"?null:HA({...ce,padding:{top:D.top+B,right:D.right+B,bottom:D.bottom+B,left:D.left+B},mainAxis:!C&&L==="flip",crossAxis:F==="flip"?"alignment":!1,fallbackAxisSideDirection:U}),at=ne?null:WA(st=>{const Et=or(st.elements.floating).documentElement;return{...ce,rootBoundary:C?{x:0,y:0,width:Et.clientWidth,height:Et.clientHeight}:void 0,mainAxis:F!=="none",crossAxis:he,limiter:f||C?void 0:$A($t=>{if(!me.current)return{};const{width:Nt,height:li}=me.current.getBoundingClientRect(),ai=sr(Bn($t.placement)),Ss=ai==="y"?Nt:li,ao=ai==="y"?D.left+D.right:D.top+D.bottom;return{offset:Ss/2+ao/2}})}},[ce,f,C,D,F]);L==="shift"||F==="shift"||s==="center"?ye.push(at,we):ye.push(we,at),ye.push(UA({...ce,apply({elements:{floating:st},rects:{reference:Et},availableWidth:$t,availableHeight:Nt}){Object.entries({"--available-width":`${$t}px`,"--available-height":`${Nt}px`,"--anchor-width":`${Et.width}px`,"--anchor-height":`${Et.height}px`}).forEach(([li,ai])=>{st.style.setProperty(li,ai)})}}),nN(()=>({element:me.current||document.createElement("div"),padding:h,offsetParent:"floating"}),[h]),{name:"transformOrigin",fn(st){var kc,jr,kl;const{elements:Et,middlewareData:$t,placement:Nt,rects:li,y:ai}=st,Ss=Bn(Nt),ao=sr(Ss),ci=me.current,wl=((kc=$t.arrow)==null?void 0:kc.x)||0,bc=((jr=$t.arrow)==null?void 0:jr.y)||0,ks=(ci==null?void 0:ci.clientWidth)||0,bl=(ci==null?void 0:ci.clientHeight)||0,ui=wl+ks/2,Sc=bc+bl/2,Cs=Math.abs(((kl=$t.shift)==null?void 0:kl.y)||0),co=li.reference.height/2,Ir=typeof i=="function"?i(R1(st,r,W)):i,Sl=Cs>Ir,$d={top:`${ui}px calc(100% + ${Ir}px)`,bottom:`${ui}px ${-Ir}px`,left:`calc(100% + ${Ir}px) ${Sc}px`,right:`${-Ir}px ${Sc}px`}[Ss],Hd=`${ui}px ${li.reference.y+co-ai}px`;return Et.floating.style.setProperty("--transform-origin",he&&ao==="y"&&Sl?Hd:$d),{}}},rN,T),Be(()=>{!x&&y&&y.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[x,y]);const ze=S.useMemo(()=>({elementResize:!p&&typeof ResizeObserver<"u",layoutShift:!p&&typeof IntersectionObserver<"u"}),[p]),{refs:pe,elements:Re,x:Te,y:Le,middlewareData:We,update:Me,placement:xe,context:Ve,isPositioned:Ue,floatingStyles:Ce}=C5({rootContext:y,placement:X,middleware:ye,strategy:t,whileElementsMounted:g?void 0:(...st)=>g1(...st,ze),nodeId:E,externalTree:P}),{sideX:Fe,sideY:it}=We.adaptiveOrigin||mf,qe=Ue?t:"fixed",Ye=S.useMemo(()=>T?{position:qe,[Fe]:Te,[it]:Le}:{position:qe,...Ce},[T,qe,Fe,Te,it,Le,Ce]),Ke=S.useRef(null);Be(()=>{if(!x)return;const st=j.current,Et=typeof st=="function"?st():st,Nt=(T1(Et)?Et.current:Et)||null||null;Nt!==Ke.current&&(pe.setPositionReference(Nt),Ke.current=Nt)},[x,pe,H,j]),S.useEffect(()=>{if(!x)return;const st=j.current;typeof st!="function"&&T1(st)&&st.current!==Ke.current&&(pe.setPositionReference(st.current),Ke.current=st.current)},[x,pe,H,j]),S.useEffect(()=>{if(g&&x&&Re.domReference&&Re.floating)return g1(Re.domReference,Re.floating,Me,ze)},[g,x,Re,Me,ze]);const tt=Bn(xe),Di=DS(r,tt,W),Wt=xs(xe)||"center",vt=!!((Yn=We.hide)!=null&&Yn.referenceHidden);Be(()=>{M&&x&&Ue&&N(tt)},[M,x,Ue,tt]);const kn=S.useMemo(()=>{var st,Et;return{position:"absolute",top:(st=We.arrow)==null?void 0:st.y,left:(Et=We.arrow)==null?void 0:Et.x}},[We.arrow]),Gn=((Dr=We.arrow)==null?void 0:Dr.centerOffset)!==0;return S.useMemo(()=>({positionerStyles:Ye,arrowStyles:kn,arrowRef:me,arrowUncentered:Gn,side:Di,align:Wt,physicalSide:tt,anchorHidden:vt,refs:pe,context:Ve,isPositioned:Ue,update:Me}),[Ye,kn,me,Gn,Di,Wt,tt,vt,pe,Ve,Ue,Me])}function T1(n){return n!=null&&"current"in n}function IS(n){return n==="starting"?ZM:tn}const oN=S.forwardRef(function(e,t){const{render:r,className:i,anchor:s,positionMethod:o="absolute",side:a="top",align:u="center",sideOffset:f=0,alignOffset:h=0,collisionBoundary:p="clipping-ancestors",collisionPadding:g=5,arrowPadding:y=5,sticky:x=!1,disableAnchorTracking:w=!1,collisionAvoidance:C=eO,...E}=e,T=oc(),M=X5(),P=T.useState("open"),O=T.useState("mounted"),N=T.useState("trackCursorAxis"),L=T.useState("disableHoverablePopup"),F=T.useState("floatingRootContext"),U=T.useState("instantType"),Q=T.useState("transitionStatus"),q=sN({anchor:s,positionMethod:o,floatingRootContext:F,mounted:O,side:a,sideOffset:f,align:u,alignOffset:h,collisionBoundary:p,collisionPadding:g,sticky:x,arrowPadding:y,disableAnchorTracking:w,keepMounted:M,collisionAvoidance:C,adaptiveOrigin:iN}),H=S.useMemo(()=>{const _={};return(!P||N==="both"||L)&&(_.pointerEvents="none"),{role:"presentation",hidden:!O,style:{...q.positionerStyles,..._}}},[P,N,L,O,q.positionerStyles]),j=S.useMemo(()=>({open:P,side:q.side,align:q.align,anchorHidden:q.anchorHidden,instant:N!=="none"?"tracking-cursor":U}),[P,q.side,q.align,q.anchorHidden,N,U]),Y=S.useMemo(()=>({...j,arrowRef:q.arrowRef,arrowStyles:q.arrowStyles,arrowUncentered:q.arrowUncentered}),[j,q.arrowRef,q.arrowStyles,q.arrowUncentered]),W=At("div",e,{state:j,props:[H,IS(Q),E],ref:[t,T.useStateSetter("positionerElement")],stateAttributesMapping:dc});return k.jsx(NS.Provider,{value:Y,children:W})});function M1(n){const e=Fn(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=zt(n),s=i?n.offsetWidth:t,o=i?n.offsetHeight:r;return(Zo(t)!==s||Zo(r)!==o)&&(t=s,r=o),{width:t,height:r}}const lN=typeof ResizeObserver<"u",aN=()=>!0;function cN(n){const{popupElement:e,positionerElement:t,content:r,mounted:i,enabled:s=aN,onMeasureLayout:o,onMeasureLayoutComplete:a,side:u,direction:f}=n,h=S.useRef(!0),p=o0(e,!0,!1),g=uc(),y=S.useRef(null),x=Ne(o),w=Ne(a),C=S.useMemo(()=>{let E=u==="top",T=u==="left";return f==="rtl"?(E=E||u==="inline-end",T=T||u==="inline-end"):(E=E||u==="inline-start",T=T||u==="inline-start"),E?{position:"absolute",[u==="top"?"bottom":"top"]:"0",[T?"right":"left"]:"0"}:tn},[u,f]);Be(()=>{if(!i||!s()||!lN){h.current=!0,y.current=null;return}if(!e||!t)return;Object.entries(C).forEach(([U,Q])=>{e.style.setProperty(U,Q)});const E=new ResizeObserver(U=>{const Q=U[0];Q&&(y.current===null?y.current={width:Math.ceil(Q.borderBoxSize[0].inlineSize),height:Math.ceil(Q.borderBoxSize[0].blockSize)}:(y.current.width=Math.ceil(Q.borderBoxSize[0].inlineSize),y.current.height=Math.ceil(Q.borderBoxSize[0].blockSize)))});E.observe(e),e.style.setProperty("--popup-width","auto"),e.style.setProperty("--popup-height","auto");const T=aa(e,"position","static"),M=aa(e,"transform","none"),P=aa(e,"scale","1"),O=aa(t,"--available-width","max-content"),N=aa(t,"--available-height","max-content");if(x==null||x(),h.current||y.current===null){t.style.setProperty("--positioner-width","max-content"),t.style.setProperty("--positioner-height","max-content");const U=M1(e);return t.style.setProperty("--positioner-width",`${U.width}px`),t.style.setProperty("--positioner-height",`${U.height}px`),T(),M(),P(),O(),N(),w==null||w(null,U),h.current=!1,()=>{E.disconnect()}}e.style.setProperty("--popup-width","auto"),e.style.setProperty("--popup-height","auto"),t.style.setProperty("--positioner-width","max-content"),t.style.setProperty("--positioner-height","max-content");const L=M1(e);e.style.setProperty("--popup-width",`${y.current.width}px`),e.style.setProperty("--popup-height",`${y.current.height}px`),T(),M(),O(),N(),w==null||w(y.current,L),t.style.setProperty("--positioner-width",`${L.width}px`),t.style.setProperty("--positioner-height",`${L.height}px`);const F=new AbortController;return g.request(()=>{e.style.setProperty("--popup-width",`${L.width}px`),e.style.setProperty("--popup-height",`${L.height}px`),p(()=>{e.style.setProperty("--popup-width","auto"),e.style.setProperty("--popup-height","auto")},F.signal)}),()=>{E.disconnect(),F.abort(),g.cancel()}},[r,e,t,p,g,s,i,x,w,C])}function aa(n,e,t){const r=n.style.getPropertyValue(e);return n.style.setProperty(e,t),()=>{n.style.setProperty(e,r)}}const uN={...dc,...gl},fN=S.forwardRef(function(e,t){const{className:r,render:i,...s}=e,o=oc(),{side:a,align:u}=Z5(),f=o.useState("open"),h=o.useState("mounted"),p=o.useState("instantType"),g=o.useState("transitionStatus"),y=o.useState("popupProps"),x=o.useState("payload"),w=o.useState("popupElement"),C=o.useState("positionerElement"),E=o.useState("floatingRootContext"),T=LS();fc({open:f,ref:o.context.popupRef,onComplete(){var Q,q;f&&((q=(Q=o.context).onOpenChangeComplete)==null||q.call(Q,!0))}});function M(){E.context.events.emit("measure-layout")}function P(Q,q){E.context.events.emit("measure-layout-complete",{previousDimensions:Q,nextDimensions:q})}const O=S.useCallback(()=>o.context.triggerElements.size>1,[o]);cN({popupElement:w,positionerElement:C,mounted:h,content:x,enabled:O,onMeasureLayout:M,onMeasureLayoutComplete:P,side:a,direction:T});const N=o.useState("disabled"),L=o.useState("closeDelay");O5(E,{enabled:!N,closeDelay:L});const F=S.useMemo(()=>({open:f,side:a,align:u,instant:p,transitionStatus:g}),[f,a,u,p,g]);return At("div",e,{state:F,ref:[t,o.context.popupRef,o.useStateSetter("popupElement")],props:[y,IS(g),s],stateAttributesMapping:uN})}),dN=function(e){const{delay:t,closeDelay:r,timeout:i=400}=e,s=S.useMemo(()=>({delay:t,closeDelay:r}),[t,r]),o=S.useMemo(()=>({open:t,close:r}),[t,r]);return k.jsx(OS.Provider,{value:s,children:k.jsx(UP,{delay:o,timeoutMs:i,children:e.children})})};function c0(n){return Kg(19)?n:n?"true":void 0}function hN(n){const[e,t]=S.useState({current:n,previous:null});return n!==e.current&&t({current:n,previous:e.current}),e.previous}let O1=function(n){return n.popupWidth="--popup-width",n.popupHeight="--popup-height",n}({});const pN={activationDirection:n=>n?{"data-activation-direction":n}:null},mN=S.forwardRef(function(e,t){const{render:r,className:i,children:s,...o}=e,a=oc(),u=a.useState("activeTriggerElement"),f=a.useState("open"),h=a.useState("floatingRootContext"),p=a.useState("instantType"),g=hN(f?u:null),y=S.useRef(null),[x,w]=S.useState(null),[C,E]=S.useState(null),T=S.useRef(null),M=S.useRef(null),P=o0(T,!0,!1),O=uc(),[N,L]=S.useState(null),[F,U]=S.useState(!1),Q=Ne(()=>{var _,X,D;(_=T.current)==null||_.style.setProperty("animation","none"),(X=T.current)==null||X.style.setProperty("transition","none"),(D=M.current)==null||D.style.setProperty("display","none")}),q=Ne(_=>{var X,D,B;(X=T.current)==null||X.style.removeProperty("animation"),(D=T.current)==null||D.style.removeProperty("transition"),(B=M.current)==null||B.style.removeProperty("display"),N||L(_.previousDimensions)});S.useEffect(()=>(h.context.events.on("measure-layout",Q),h.context.events.on("measure-layout-complete",q),()=>{h.context.events.off("measure-layout",Q),h.context.events.off("measure-layout-complete",q)}),[h,Q,q]);const H=S.useRef(null);Be(()=>{if(u&&g&&u!==g&&H.current!==u&&y.current){w(y.current),U(!0);const _=yN(g,u);E(_),O.request(()=>{O.request(()=>{U(!1),P(()=>{w(null),L(null),y.current=null})})}),H.current=u}},[u,g,x,P,O]),Be(()=>{const _=T.current;if(!_)return;const X=document.createElement("div");for(const D of Array.from(_.childNodes))X.appendChild(D.cloneNode(!0));y.current=X});const j=x!=null;let Y;j?Y=k.jsxs(S.Fragment,{children:[k.jsx("div",{"data-previous":!0,inert:c0(!0),ref:M,style:{[O1.popupWidth]:`${N==null?void 0:N.width}px`,[O1.popupHeight]:`${N==null?void 0:N.height}px`,position:"absolute"},"data-ending-style":F?void 0:""},"previous"),k.jsx("div",{"data-current":!0,ref:T,"data-starting-style":F?"":void 0,children:s},"current")]}):Y=k.jsx("div",{"data-current":!0,ref:T,children:s},"current"),Be(()=>{const _=M.current;!_||!x||_.replaceChildren(...Array.from(x.childNodes))},[x]);const W=S.useMemo(()=>({activationDirection:gN(C),transitioning:j,instant:p}),[C,j,p]);return At("div",e,{state:W,ref:t,props:[o,{children:Y}],stateAttributesMapping:pN})});function gN(n){if(n)return`${P1(n.horizontal,5,"right","left")} ${P1(n.vertical,5,"down","up")}`}function P1(n,e,t,r){return n>e?t:n<-e?r:""}function yN(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i={x:t.left+t.width/2,y:t.top+t.height/2},s={x:r.left+r.width/2,y:r.top+r.height/2};return{horizontal:s.x-i.x,vertical:s.y-i.y}}const vN=dN,jS=z5;function BS(n){return k.jsx(Y5,{"data-slot":"tooltip-trigger",...n})}function FS({className:n,align:e="center",sideOffset:t=4,side:r="top",children:i,...s}){return k.jsx(J5,{children:k.jsx(oN,{align:e,className:"z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width)","data-slot":"tooltip-positioner",side:r,sideOffset:t,children:k.jsx(fN,{className:et("relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) text-balance rounded-md border bg-popover bg-clip-padding text-popover-foreground text-xs shadow-black/5 shadow-md transition-opacity duration-150 motion-reduce:transition-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:duration-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]",n),"data-slot":"tooltip-popup",...s,children:k.jsx(mN,{className:"relative size-full overflow-clip px-(--viewport-inline-padding) py-1 [--viewport-inline-padding:--spacing(2)] data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:truncate **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity **:duration-150 motion-reduce:**:transition-none","data-slot":"tooltip-viewport",children:i})})})})}function A1({icon:n,tooltip:e,to:t,href:r,expanded:i}){const s=Ar(),o=t?s.pathname===t:!1,a=et("flex w-full items-center rounded-md px-2 py-1.5 touch-manipulation transition-colors motion-reduce:transition-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",i?"min-h-9 justify-start gap-3 pointer-coarse:min-h-11":"min-h-11 justify-center",o?"bg-selection text-selection-foreground":r?"text-brand-accent hover:bg-selection/50 hover:underline underline-offset-4":"text-muted-foreground hover:bg-selection/50 hover:text-foreground"),u=k.jsxs(k.Fragment,{children:[k.jsx("span",{"aria-hidden":"true",children:n}),i&&k.jsx("span",{className:"text-sm",children:e})]});return k.jsxs(jS,{children:[k.jsx(BS,{render:t?k.jsx(ti,{to:t,"aria-label":e,"aria-current":o?"page":void 0,className:a,children:u}):k.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer","aria-label":e,className:a,children:u})}),k.jsx(FS,{side:"right",sideOffset:8,children:e})]})}const xN="/assets/postgres-BpcazhJg.svg",wN="data:image/svg+xml,%3csvg%20width='600'%20height='600'%20viewBox='0%200%20600%20600'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M548.194%20458.47C516.023%20457.594%20491.456%20460.589%20470.451%20469.444C464.484%20471.961%20454.959%20472.031%20453.984%20479.508C457.266%20482.944%20457.776%20488.081%20460.383%20492.309C465.398%20500.419%20473.864%20511.303%20481.42%20517.003C489.68%20523.237%20498.187%20529.898%20507.037%20535.294C522.778%20544.889%20540.352%20550.373%20555.506%20559.987C564.441%20565.659%20573.314%20572.798%20582.028%20579.192C586.341%20582.356%20589.233%20587.273%20594.834%20589.256V588.347C591.891%20584.597%20591.131%20579.45%20588.431%20575.536L576.539%20563.644C564.914%20548.213%20550.153%20534.656%20534.464%20523.402C521.953%20514.42%20493.955%20502.289%20488.737%20487.734L487.823%20486.82C496.692%20485.817%20507.075%20482.611%20515.264%20480.412C529.017%20476.728%20541.308%20477.68%20555.506%20474.014L574.711%20468.525V464.869C567.534%20457.505%20562.416%20447.755%20554.592%20441.089C534.108%20423.652%20511.758%20406.228%20488.742%20391.697C475.973%20383.644%20460.2%20378.408%20446.667%20371.578C442.116%20369.277%20434.119%20368.081%20431.114%20364.256C424.003%20355.2%20420.136%20343.716%20414.656%20333.164C403.177%20311.053%20391.903%20286.908%20381.731%20263.644C374.794%20247.781%20370.261%20232.144%20361.608%20217.912C320.076%20149.63%20275.376%20108.422%20206.128%2067.9125C191.391%2059.2969%20173.648%2055.8984%20154.898%2051.4453C144.844%2050.8406%20134.78%2050.2266%20124.72%2049.6125C118.575%2047.0531%20112.191%2039.5391%20106.43%2035.8922C83.489%2021.3984%2024.6421%20-10.125%207.65463%2031.3219C-3.07506%2057.4828%2023.6906%2083.0016%2033.2578%2096.2625C39.9796%20105.553%2048.5812%20115.983%2053.3812%20126.441C56.5406%20133.317%2057.0843%20140.212%2059.789%20147.483C66.4312%20165.398%2072.2203%20184.889%2080.8218%20201.441C85.1671%20209.822%2089.9578%20218.644%2095.4562%20226.134C98.8218%20230.733%20104.602%20232.758%20105.511%20239.855C99.8671%20247.758%2099.5437%20260.03%2096.3703%20270.042C82.0734%20315.113%2087.4687%20371.138%20108.262%20404.494C114.637%20414.741%20129.67%20436.702%20150.333%20428.273C168.408%20420.914%20164.372%20398.095%20169.542%20377.967C170.709%20373.406%20169.992%20370.05%20172.284%20366.994V367.908L188.751%20400.833C200.939%20420.459%20222.558%20440.967%20240.886%20454.805C250.387%20461.981%20257.869%20474.384%20270.155%20478.584V477.666H269.241C266.859%20473.958%20263.133%20472.42%20260.095%20469.439C252.937%20462.422%20244.978%20453.698%20239.062%20445.659C222.394%20423.033%20207.666%20398.269%20194.245%20372.492C187.833%20360.178%20182.259%20346.603%20176.859%20334.073C174.778%20329.245%20174.806%20321.938%20170.466%20319.439C164.545%20328.617%20155.831%20336.042%20151.256%20346.88C143.939%20364.205%20142.997%20385.336%20140.283%20407.245C138.68%20407.817%20139.392%20407.423%20138.45%20408.155C125.709%20405.084%20121.237%20391.973%20116.498%20380.719C104.527%20352.266%20102.3%20306.459%20112.837%20273.708C115.566%20265.228%20127.884%20238.547%20122.897%20230.714C120.516%20222.905%20112.659%20218.386%20108.267%20212.419C102.825%20205.041%2097.3968%20195.328%2093.6234%20186.806C83.8265%20164.63%2079.2515%20139.725%2068.9343%20117.3C63.9984%20106.58%2055.6593%2095.7281%2048.8109%2086.2031C41.2312%2075.6422%2032.7374%2067.8656%2026.8593%2055.1016C24.7687%2050.5641%2021.9328%2043.2984%2025.0265%2038.6344C26.0109%2035.4891%2027.4078%2034.1766%2030.5156%2033.15C35.8218%2029.0578%2050.5968%2034.5094%2056.1187%2036.8016C70.7859%2042.8953%2083.0296%2048.6984%2095.4562%2056.9297C101.414%2060.8859%20107.452%2068.5312%20114.661%2070.65H122.892C135.769%2073.6078%20150.192%2071.5641%20162.225%2075.2203C183.487%2081.6797%20202.542%2091.7344%20219.844%20102.661C272.559%20135.952%20315.666%20183.333%20345.15%20239.859C349.894%20248.962%20351.947%20257.644%20356.123%20267.3C364.552%20286.767%20375.169%20306.797%20383.555%20325.838C391.926%20344.831%20400.083%20363.998%20411.914%20379.805C418.134%20388.111%20442.153%20392.569%20453.075%20397.186C460.725%20400.416%20473.264%20403.791%20480.516%20408.155C494.358%20416.508%20507.773%20426.45%20520.762%20435.6C527.245%20440.17%20547.2%20450.206%20548.194%20458.47ZM139.355%20109.997C132.647%20109.87%20127.903%20110.728%20122.887%20111.82V112.734H123.802C127.003%20119.306%20132.652%20123.544%20136.603%20129.202C139.65%20135.609%20142.702%20142.008%20145.753%20148.406L146.662%20147.502C152.33%20143.503%20154.922%20137.123%20154.889%20127.373C152.62%20124.987%20152.287%20121.997%20150.319%20119.147C147.712%20115.345%20142.655%20113.184%20139.355%20109.997Z'%20fill='%2300618A'/%3e%3c/svg%3e",bN="data:image/svg+xml,%3csvg%20width='600'%20height='600'%20viewBox='0%200%20600%20600'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M597.196%20105.954C595.566%20104.609%20593.497%20103.916%20591.387%20104.008C585.598%20104.008%20578.111%20107.941%20574.081%20110.051L572.485%20110.87C565.726%20114.147%20558.367%20116.002%20550.863%20116.319C543.172%20116.565%20536.544%20117.016%20527.912%20117.917C476.771%20123.181%20453.963%20162.43%20431.993%20200.387C420.026%20221.035%20407.67%20242.482%20390.733%20258.87C387.228%20262.273%20383.504%20265.441%20379.584%20268.354C362.053%20281.403%20340.042%20290.723%20322.921%20297.319C306.433%20303.628%20288.432%20309.302%20271.044%20314.792C255.108%20319.811%20240.073%20324.563%20226.245%20329.705C220.006%20332.02%20214.708%20333.802%20210.023%20335.358C197.422%20339.455%20188.34%20342.589%20175.064%20351.746C169.888%20355.29%20164.692%20359.12%20161.174%20361.988C150.635%20370.408%20141.308%20380.245%20133.456%20391.219C126.703%20401.343%20118.9%20410.722%20110.177%20419.201C107.374%20421.946%20102.403%20423.298%2094.9574%20423.298C86.2431%20423.298%2075.6673%20421.495%2064.4777%20419.59C52.9405%20417.542%2041.0146%20415.596%2030.7865%20415.596C22.4813%20415.596%2016.1194%20416.948%2011.3736%20419.693C11.3736%20419.693%203.37526%20424.363%200%20430.406L3.3139%20431.901C8.45284%20434.691%2013.2107%20438.134%2017.4695%20442.143C21.913%20446.253%2026.8625%20449.778%2032.198%20452.631C33.9011%20453.257%2035.4499%20454.242%2036.7392%20455.52C35.3482%20457.568%2033.3026%20460.211%2031.1547%20463.038C19.3515%20478.503%2012.4578%20488.274%2016.4058%20493.6C18.2981%20494.584%2020.4115%20495.064%2022.5427%20494.993C48.2765%20494.993%2062.1048%20488.295%2079.5948%20479.814C84.668%20477.356%2089.8229%20474.837%2095.9597%20472.235C106.188%20467.79%20117.193%20460.702%20128.874%20453.205C144.154%20443.229%20160.131%20432.987%20175.636%20428.05C188.379%20424.159%20201.653%20422.293%20214.974%20422.519C231.338%20422.519%20248.563%20424.711%20265.173%20426.842C277.549%20428.439%20290.375%20430.078%20302.955%20430.836C307.844%20431.123%20312.365%20431.266%20316.763%20431.266C322.647%20431.284%20328.527%20430.976%20334.376%20430.344L335.787%20429.853C344.604%20424.424%20348.736%20412.769%20352.746%20401.502C355.323%20394.251%20357.491%20387.737%20360.928%20383.599C361.131%20383.397%20361.35%20383.212%20361.583%20383.046C361.744%20382.956%20361.93%20382.924%20362.112%20382.953C362.294%20382.983%20362.461%20383.074%20362.585%20383.21C362.585%20383.21%20362.585%20383.312%20362.585%20383.538C360.539%20427.6%20342.824%20455.581%20324.905%20480.449L312.938%20493.293C312.938%20493.293%20329.692%20493.293%20339.224%20489.606C374%20479.2%20400.245%20456.257%20419.351%20419.672C424.063%20410.281%20428.276%20400.646%20431.972%20390.81C432.3%20389.99%20435.307%20388.474%20435.02%20392.715C434.918%20393.964%20434.836%20395.357%20434.734%20396.812C434.734%20397.672%20434.734%20398.553%20434.57%20399.434C434.079%20405.579%20432.627%20418.566%20432.627%20418.566L443.366%20412.81C469.264%20396.422%20489.229%20363.361%20504.367%20311.924C510.667%20290.498%20515.29%20269.214%20519.361%20250.471C524.229%20227.939%20528.423%20208.622%20533.23%20201.124C540.778%20189.366%20552.295%20181.419%20563.444%20173.696C564.958%20172.651%20566.492%20171.647%20567.985%20170.541C581.998%20160.688%20595.928%20149.32%20598.997%20128.118V127.647C601.226%20111.833%20599.344%20107.798%20597.196%20105.954Z'%20fill='%23003545'/%3e%3c/svg%3e",SN="/assets/sqlserver-ByfFYYpV.svg",kN="data:image/svg+xml,%3csvg%20width='160'%20height='160'%20viewBox='0%200%20160%20160'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M121.632%208.03622H22.1255C15.4565%208.03622%2010%2013.4937%2010%2020.1625V129.899C10%20136.567%2015.4565%20142.024%2022.1255%20142.024H87.6628C86.9189%20109.415%2098.0545%2046.1304%20121.632%208.03622Z'%20fill='%230F80CC'/%3e%3cpath%20d='M118.016%2011.5737H22.1255C17.3901%2011.5737%2013.5366%2015.4262%2013.5366%2020.1625V121.893C35.2539%20113.558%2067.8488%20106.366%2090.3862%20106.692C94.9151%2083.0114%20108.226%2036.6019%20118.016%2011.5737Z'%20fill='url(%23paint0_linear_2795_134)'/%3e%3cpath%20d='M144.841%204.44498C138.026%20-1.63252%20129.775%200.808728%20121.631%208.03623C120.423%209.10998%20119.216%2010.3012%20118.016%2011.5737C104.085%2026.3525%2091.154%2053.7275%2087.1365%2074.6337C88.7015%2077.8075%2089.924%2081.8575%2090.729%2084.9512C90.9352%2085.745%2091.1215%2086.49%2091.2702%2087.1237C91.624%2088.6236%2091.814%2089.5962%2091.814%2089.5962C91.814%2089.5962%2091.689%2089.1236%2091.1765%2087.6375C91.079%2087.3525%2090.9702%2087.0412%2090.8415%2086.675C90.7865%2086.5237%2090.7102%2086.34%2090.6265%2086.1437C89.7177%2084.0312%2087.204%2079.5725%2086.0977%2077.6312C85.1515%2080.4225%2084.3152%2083.0337%2083.6152%2085.3962C86.809%2091.2397%2088.7552%20101.254%2088.7552%20101.254C88.7552%20101.254%2088.5865%20100.605%2087.784%2098.3399C87.0715%2096.3365%2083.5227%2090.1187%2082.6821%2088.6651C81.2441%2093.9736%2080.6727%2097.5576%2081.188%2098.4302C82.1884%20100.121%2083.1411%20103.039%2083.9777%20106.265C85.8677%20113.534%2087.1815%20122.382%2087.1815%20122.382C87.1815%20122.382%2087.224%20122.969%2087.2952%20123.871C87.0327%20129.975%2087.1902%20136.304%2087.6627%20142.024C88.289%20149.596%2089.4677%20156.101%2090.9702%20159.582L91.9902%20159.026C89.784%20152.167%2088.8877%20143.179%2089.2802%20132.812C89.874%20116.967%2093.5202%2097.8589%20100.258%2077.9425C111.64%2047.8775%20127.433%2023.755%20141.886%2012.235C128.713%2024.1325%20110.883%2062.6437%20105.545%2076.905C99.569%2092.875%2095.334%20107.861%2092.7815%20122.22C97.1852%20108.759%20111.424%20102.973%20111.424%20102.973C111.424%20102.973%20118.408%2094.3599%20126.569%2082.055C121.68%2083.17%20113.653%2085.0787%20110.964%2086.2087C106.998%2087.8725%20105.929%2088.44%20105.929%2088.44C105.929%2088.44%20118.776%2080.6162%20129.799%2077.0737C144.958%2053.1987%20161.473%2019.2812%20144.841%204.44498Z'%20fill='%23003B57'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2795_134'%20x1='73.7814'%20y1='13.8313'%20x2='73.7814'%20y2='115.758'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%2397D9F6'/%3e%3cstop%20offset='0.920245'%20stop-color='%230F80CC'/%3e%3cstop%20offset='1'%20stop-color='%230F80CC'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",CN="data:image/svg+xml,%3csvg%20width='160'%20height='160'%20viewBox='0%200%20160%20160'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='10'%20y='10'%20width='140'%20height='140'%20rx='28'%20fill='%23C74634'/%3e%3cellipse%20cx='80'%20cy='52'%20rx='40'%20ry='14'%20fill='%23FFFFFF'/%3e%3cpath%20d='M40%2052v56c0%207.7%2017.9%2014%2040%2014s40-6.3%2040-14V52c0%207.7-17.9%2014-40%2014s-40-6.3-40-14z'%20fill='%23FFFFFF'%20fill-opacity='0.85'/%3e%3cpath%20d='M40%2080c0%207.7%2017.9%2014%2040%2014s40-6.3%2040-14'%20stroke='%23C74634'%20stroke-width='4'%20fill='none'/%3e%3c/svg%3e",EN="data:image/svg+xml,%3csvg%20width='160'%20height='160'%20viewBox='0%200%20160%20160'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='10'%20y='10'%20width='140'%20height='140'%20rx='28'%20fill='%23FAFF69'/%3e%3crect%20x='38'%20y='40'%20width='12'%20height='80'%20rx='2'%20fill='%23161616'/%3e%3crect%20x='58'%20y='40'%20width='12'%20height='80'%20rx='2'%20fill='%23161616'/%3e%3crect%20x='78'%20y='40'%20width='12'%20height='80'%20rx='2'%20fill='%23161616'/%3e%3crect%20x='98'%20y='40'%20width='12'%20height='80'%20rx='2'%20fill='%23161616'/%3e%3crect%20x='118'%20y='72'%20width='12'%20height='16'%20rx='2'%20fill='%23161616'/%3e%3c/svg%3e",u0={postgres:xN,mysql:wN,mariadb:bN,sqlserver:SN,sqlite:kN,oracle:CN,clickhouse:EN};function zS({children:n}){return n.split(/([_.-])/).map((e,t)=>k.jsxs(S.Fragment,{children:[e,/^[_.-]$/.test(e)&&k.jsx("wbr",{})]},t))}function RN({source:n,expanded:e}){const{sourceId:t}=pd(),r=t===n.id;return k.jsxs(jS,{children:[k.jsx(BS,{render:k.jsxs(ti,{to:`/source/${n.id}`,"aria-label":n.id,"aria-current":r?"location":void 0,className:et("w-full rounded-md flex items-center touch-manipulation transition-colors motion-reduce:transition-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",e?"min-h-9 gap-3 justify-start px-2 py-1.5 pointer-coarse:min-h-11":"min-h-11 flex-col justify-center gap-1.5 p-2",r?"bg-selection text-selection-foreground":"hover:bg-selection/50"),children:[k.jsx("img",{src:u0[n.type],alt:"",width:24,height:24,className:et("shrink-0",e?"size-5":"size-6")}),k.jsx("span",{className:et(e?"min-w-0 text-sm text-start [overflow-wrap:anywhere]":"text-xs w-full text-center line-clamp-2 [overflow-wrap:anywhere]",r?"text-foreground":"text-muted-foreground"),children:k.jsx(zS,{children:n.id})})]})}),k.jsx(FS,{side:"right",sideOffset:8,className:"max-w-64 text-caption [overflow-wrap:anywhere]",children:n.id})]})}function TN({className:n="w-5 h-5"}){return k.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}function MN({className:n="w-5 h-5"}){return k.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function N1({sources:n,hasSidebar:e=!1,expanded:t=!1,onToggleExpanded:r}){const i=S.useId(),s=t?"Collapse navigation":"Expand navigation";return k.jsx(vN,{delay:300,children:k.jsxs("aside",{className:et("shrink-0 min-h-0 flex flex-col bg-sidebar border-e-[length:var(--border-hairline)]",e?"border-border-subtle":"border-border",t?"w-56":"w-20"),"aria-label":"Main navigation",children:[r&&k.jsx("div",{className:et("flex h-16 shrink-0 items-center border-b-[length:var(--border-hairline)] border-border-subtle px-2",t?"justify-end":"justify-center"),children:k.jsx(Dn,{variant:"ghost",size:"icon",className:"size-9 pointer-coarse:size-11","aria-label":s,title:s,"aria-expanded":t,"aria-controls":i,onClick:r,children:t?k.jsx(TM,{"aria-hidden":"true"}):k.jsx(OM,{"aria-hidden":"true"})})}),k.jsx("nav",{id:i,"aria-label":"Data sources",className:"min-h-0 flex-1 space-y-1 overflow-y-auto p-2",children:n.map(o=>k.jsx(RN,{source:o,expanded:t},o.id))}),k.jsxs("div",{className:"flex shrink-0 flex-col gap-1 border-t-[length:var(--border-hairline)] border-border-subtle p-2",children:[k.jsx(A1,{icon:k.jsx(TN,{}),to:"/requests",tooltip:"Requests",expanded:t}),k.jsx(A1,{icon:k.jsx(MN,{}),href:"https://dbhub.ai",tooltip:"Help",expanded:t})]})]})})}function L1(){return k.jsxs(ti,{to:"/","aria-label":"DBHub home",className:"flex min-h-11 min-w-11 justify-center items-center rounded-sm touch-manipulation hover:opacity-80 transition-opacity motion-reduce:transition-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[k.jsx("img",{src:"/logo-full-light.svg",alt:"",width:547,height:132,className:"block w-32 max-w-full h-auto dark:hidden"}),k.jsx("img",{src:"/logo-full-dark.svg",alt:"",width:547,height:132,className:"hidden w-32 max-w-full h-auto dark:block"})]})}function _S({className:n="w-4 h-4"}){return k.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}const D1="flex min-h-9 items-center gap-2 rounded-md px-3 py-1.5 pointer-coarse:min-h-11 text-sm touch-manipulation transition-colors motion-reduce:transition-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring";function I1({sources:n,isLoading:e}){const{sourceId:t,toolName:r}=pd(),i=n.find(o=>o.id===t),s=(i==null?void 0:i.tools.filter(o=>o.name!=="search_objects"))??[];return k.jsxs("aside",{className:"flex min-h-0 min-w-0 flex-1 flex-col border-e-[length:var(--border-hairline)] border-border bg-sidebar md:w-64 md:flex-none","aria-label":"Tools sidebar",children:[k.jsx("div",{className:"flex h-16 shrink-0 flex-col justify-center border-b-[length:var(--border-hairline)] border-border-subtle px-6",children:e?k.jsx("div",{className:"h-5 w-3/4 rounded-sm bg-selection/50","aria-hidden":"true"}):i?k.jsxs(k.Fragment,{children:[k.jsx("p",{className:"truncate text-label",title:i.id,children:i.id}),k.jsx("p",{className:"text-caption text-muted-foreground",children:i.type})]}):k.jsx("p",{className:"text-label",children:"Sources"})}),k.jsx("nav",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-4 pt-3","aria-label":"Source and tools",children:e?k.jsxs("div",{className:"space-y-3 py-4",role:"status","aria-label":"Loading tools",children:[k.jsx("div",{className:"h-9 rounded-md bg-selection/50 pointer-coarse:h-11"}),k.jsx("div",{className:"h-9 rounded-md bg-selection/50 pointer-coarse:h-11"})]}):i?k.jsxs(k.Fragment,{children:[k.jsxs(ti,{to:`/source/${i.id}`,"aria-current":r?void 0:"page",className:et(D1,r?"text-muted-foreground hover:text-foreground hover:bg-selection/50":"bg-selection text-selection-foreground"),children:[k.jsx(AM,{className:"size-4 shrink-0","aria-hidden":"true"}),"Overview"]}),k.jsxs("div",{className:"mb-2 mt-4 flex items-center justify-between px-3",children:[k.jsx("h2",{className:"text-caption font-medium text-muted-foreground",children:"Tools"}),k.jsx("span",{className:"text-caption tabular-nums text-muted-foreground",children:s.length})]}),k.jsxs("div",{className:"space-y-1",children:[s.map(o=>k.jsxs(ti,{to:`/source/${i.id}/tool/${o.name}`,"aria-label":`${o.name}${o.readonly?" (read-only)":""}`,"aria-current":r===o.name?"page":void 0,className:et(D1,r===o.name?"bg-selection text-selection-foreground":"text-muted-foreground hover:text-foreground hover:bg-selection/50"),children:[k.jsx("span",{"aria-hidden":"true",className:"flex size-4 shrink-0 items-center justify-center",children:o.readonly&&k.jsx(_S,{className:"size-3.5"})}),k.jsx("span",{className:"min-w-0 flex-1 font-mono text-sm [overflow-wrap:anywhere]",children:k.jsx(zS,{children:o.name})})]},o.name)),s.length===0&&k.jsx("p",{className:"px-3 text-caption text-muted-foreground text-pretty",children:"No tools configured for this source."})]})]}):k.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground text-pretty",children:"Select a source to browse its tools."})})]})}const VS=S.createContext(void 0);function Ni(n){const e=S.useContext(VS);if(n===!1&&e===void 0)throw new Error(gn(27));return e}const ON={...dc,...gl},WS=S.forwardRef(function(e,t){const{render:r,className:i,forceRender:s=!1,...o}=e,{store:a}=Ni(),u=a.useState("open"),f=a.useState("nested"),h=a.useState("mounted"),p=a.useState("transitionStatus"),g=S.useMemo(()=>({open:u,transitionStatus:p}),[u,p]);return At("div",e,{state:g,ref:[a.context.backdropRef,t],stateAttributesMapping:ON,props:[{role:"presentation",hidden:!h,style:{userSelect:"none",WebkitUserSelect:"none"}},o],enabled:s||!f})}),PN=S.createContext(void 0);function AN(n=!1){const e=S.useContext(PN);if(e===void 0&&!n)throw new Error(gn(16));return e}function NN(n){const{focusableWhenDisabled:e,disabled:t,composite:r=!1,tabIndex:i=0,isNativeButton:s}=n,o=r&&e!==!1,a=r&&e===!1;return{props:S.useMemo(()=>{const f={onKeyDown(h){t&&e&&h.key!=="Tab"&&h.preventDefault()}};return r||(f.tabIndex=i,!s&&t&&(f.tabIndex=e?i:-1)),(s&&(e||o)||!s&&t)&&(f["aria-disabled"]=t),s&&(!e||a)&&(f.disabled=t),f},[r,t,e,o,a,s,i])}}function Md(n={}){const{disabled:e=!1,focusableWhenDisabled:t,tabIndex:r=0,native:i=!0}=n,s=S.useRef(null),o=AN(!0)!==void 0,a=Ne(()=>{const g=s.current;return!!((g==null?void 0:g.tagName)==="A"&&(g!=null&&g.href))}),{props:u}=NN({focusableWhenDisabled:t,disabled:e,composite:o,tabIndex:r,isNativeButton:i}),f=S.useCallback(()=>{const g=s.current;LN(g)&&o&&e&&u.disabled===void 0&&g.disabled&&(g.disabled=!1)},[e,u.disabled,o]);Be(f,[f]);const h=S.useCallback((g={})=>{const{onClick:y,onMouseDown:x,onKeyUp:w,onKeyDown:C,onPointerDown:E,...T}=g;return vd({type:i?"button":void 0,onClick(P){if(e){P.preventDefault();return}y==null||y(P)},onMouseDown(P){e||x==null||x(P)},onKeyDown(P){if(e||(Om(P),C==null||C(P)),P.baseUIHandlerPrevented)return;const O=P.target===P.currentTarget&&!i&&!a()&&!e,N=P.key==="Enter",L=P.key===" ";O&&((L||N)&&P.preventDefault(),N&&(y==null||y(P)))},onKeyUp(P){e||(Om(P),w==null||w(P)),!P.baseUIHandlerPrevented&&P.target===P.currentTarget&&!i&&!e&&P.key===" "&&(y==null||y(P))},onPointerDown(P){if(e){P.preventDefault();return}E==null||E(P)}},i?void 0:{role:"button"},u,T)},[e,u,i,a]),p=Ne(g=>{s.current=g,f()});return{getButtonProps:h,buttonRef:p}}function LN(n){return zt(n)&&n.tagName==="BUTTON"}const Od=S.forwardRef(function(e,t){const{render:r,className:i,disabled:s=!1,nativeButton:o=!0,...a}=e,{store:u}=Ni(),f=u.useState("open");function h(x){f&&u.setOpen(!1,yt($P,x.nativeEvent))}const{getButtonProps:p,buttonRef:g}=Md({disabled:s,native:o}),y=S.useMemo(()=>({disabled:s}),[s]);return At("button",e,{state:y,ref:[t,g],props:[{onClick:h},a,p]})}),DN=S.forwardRef(function(e,t){const{render:r,className:i,id:s,...o}=e,{store:a}=Ni(),u=no(s);return a.useSyncedValueWithCleanup("descriptionElementId",u),At("p",e,{ref:t,props:[{id:u},o]})});let IN=function(n){return n.nestedDialogs="--nested-dialogs",n}({}),jN=function(n){return n[n.open=Er.open]="open",n[n.closed=Er.closed]="closed",n[n.startingStyle=Er.startingStyle]="startingStyle",n[n.endingStyle=Er.endingStyle]="endingStyle",n.nested="data-nested",n.nestedDialogOpen="data-nested-dialog-open",n}({});const $S=S.createContext(void 0);function HS(){const n=S.useContext($S);if(n===void 0)throw new Error(gn(26));return n}const US="ArrowUp",qS="ArrowDown",KS="ArrowLeft",QS="ArrowRight",GS="Home",YS="End",BN=new Set([KS,QS]),FN=new Set([US,qS]),zN=new Set([...BN,...FN]);[...zN];const _N=new Set([US,qS,KS,QS,GS,YS]),VN={...dc,...gl,nestedDialogOpen(n){return n?{[jN.nestedDialogOpen]:""}:null}},XS=S.forwardRef(function(e,t){const{className:r,finalFocus:i,initialFocus:s,render:o,...a}=e,{store:u}=Ni(),f=u.useState("descriptionElementId"),h=u.useState("disablePointerDismissal"),p=u.useState("floatingRootContext"),g=u.useState("popupProps"),y=u.useState("modal"),x=u.useState("mounted"),w=u.useState("nested"),C=u.useState("nestedOpenDialogCount"),E=u.useState("open"),T=u.useState("openMethod"),M=u.useState("titleElementId"),P=u.useState("transitionStatus"),O=u.useState("role");HS(),fc({open:E,ref:u.context.popupRef,onComplete(){var q,H;E&&((H=(q=u.context).onOpenChangeComplete)==null||H.call(q,!0))}});function N(q){return q==="touch"?u.context.popupRef.current:!0}const L=s===void 0?N:s,F=C>0,U=S.useMemo(()=>({open:E,nested:w,transitionStatus:P,nestedDialogOpen:F}),[E,w,P,F]),Q=At("div",e,{state:U,props:[g,{"aria-labelledby":M??void 0,"aria-describedby":f??void 0,role:O,tabIndex:-1,hidden:!x,onKeyDown(q){_N.has(q.key)&&q.stopPropagation()},style:{[IN.nestedDialogs]:C}},a],ref:[t,u.context.popupRef,u.useStateSetter("popupElement")],stateAttributesMapping:VN});return k.jsx(rA,{context:p,openInteractionType:T,disabled:!x,closeOnFocusOut:!h,initialFocus:L,returnFocus:i,modal:y!==!1,restoreFocus:"popup",children:Q})}),WN=S.forwardRef(function(e,t){const{cutout:r,...i}=e;let s;if(r){const o=r==null?void 0:r.getBoundingClientRect();s=`polygon(
      0% 0%,
      100% 0%,
      100% 100%,
      0% 100%,
      0% 0%,
      ${o.left}px ${o.top}px,
      ${o.left}px ${o.bottom}px,
      ${o.right}px ${o.bottom}px,
      ${o.right}px ${o.top}px,
      ${o.left}px ${o.top}px
    )`}return k.jsx("div",{ref:t,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:s}})}),JS=S.forwardRef(function(e,t){const{keepMounted:r=!1,...i}=e,{store:s}=Ni(),o=s.useState("mounted"),a=s.useState("modal");return o||r?k.jsx($S.Provider,{value:r,children:k.jsxs(JP,{ref:t,...i,children:[o&&a===!0&&k.jsx(WN,{ref:s.context.internalBackdropRef,inert:c0(!open)}),e.children]})}):null});let j1={},B1={},F1="";function $N(n){if(typeof document>"u")return!1;const e=or(n);return Pt(e).innerWidth-e.documentElement.clientWidth>0}function HN(n){const e=or(n),t=e.documentElement,r=e.body,i=oo(t)?t:r,s=i.style.overflow;return i.style.overflow="hidden",()=>{i.style.overflow=s}}function UN(n){var g,y;const e=or(n),t=e.documentElement,r=e.body,i=Pt(t);let s=0,o=0;const a=qr.create(),u=typeof CSS<"u"&&((g=CSS.supports)==null?void 0:g.call(CSS,"scrollbar-gutter","stable"));if(eP&&(((y=i.visualViewport)==null?void 0:y.scale)??1)!==1)return()=>{};function f(){const x=i.getComputedStyle(t),w=i.getComputedStyle(r),T=(x.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=t.scrollTop,o=t.scrollLeft,j1={scrollbarGutter:t.style.scrollbarGutter,overflowY:t.style.overflowY,overflowX:t.style.overflowX},F1=t.style.scrollBehavior,B1={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const M=t.scrollHeight>t.clientHeight,P=t.scrollWidth>t.clientWidth,O=x.overflowY==="scroll"||w.overflowY==="scroll",N=x.overflowX==="scroll"||w.overflowX==="scroll",L=Math.max(0,i.innerWidth-t.clientWidth),F=Math.max(0,i.innerHeight-t.clientHeight),U=parseFloat(w.marginTop)+parseFloat(w.marginBottom),Q=parseFloat(w.marginLeft)+parseFloat(w.marginRight),q=oo(t)?t:r;if(u){t.style.scrollbarGutter=T,q.style.overflowY="hidden",q.style.overflowX="hidden";return}Object.assign(t.style,{scrollbarGutter:T,overflowY:"hidden",overflowX:"hidden"}),(M||O)&&(t.style.overflowY="scroll"),(P||N)&&(t.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:U||F?`calc(100dvh - ${U+F}px)`:"100dvh",width:Q||L?`calc(100vw - ${Q+L}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=s,r.scrollLeft=o,t.setAttribute("data-base-ui-scroll-locked",""),t.style.scrollBehavior="unset"}function h(){Object.assign(t.style,j1),Object.assign(r.style,B1),u||(t.scrollTop=s,t.scrollLeft=o,t.removeAttribute("data-base-ui-scroll-locked"),t.style.scrollBehavior=F1)}function p(){h(),a.request(f)}return f(),i.addEventListener("resize",p),()=>{a.cancel(),h(),typeof i.removeEventListener=="function"&&i.removeEventListener("resize",p)}}class qN{constructor(){ft(this,"lockCount",0);ft(this,"restore",null);ft(this,"timeoutLock",ni.create());ft(this,"timeoutUnlock",ni.create());ft(this,"release",()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)});ft(this,"unlock",()=>{var e;this.lockCount===0&&this.restore&&((e=this.restore)==null||e.call(this),this.restore=null)})}acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}lock(e){if(this.lockCount===0||this.restore!==null)return;const r=or(e).documentElement,i=Pt(r).getComputedStyle(r).overflowY;if(i==="hidden"||i==="clip"){this.restore=Nn;return}const s=tP||!$N(e);this.restore=s?HN(e):UN(e)}}const KN=new qN;function QN(n=!0,e=null){Be(()=>{if(n)return KN.acquire(e)},[n,e])}function GN(n){const e=S.useRef(""),t=S.useCallback(i=>{i.defaultPrevented||(e.current=i.pointerType,n(i,i.pointerType))},[n]);return{onClick:S.useCallback(i=>{if(i.detail===0){n(i,"keyboard");return}"pointerType"in i&&n(i,i.pointerType),n(i,e.current),e.current=""},[n]),onPointerDown:t}}function YN(n){const[e,t]=S.useState(null),r=Ne((a,u)=>{n||t(u)}),i=S.useCallback(()=>{t(null)},[]),{onClick:s,onPointerDown:o}=GN(r);return S.useMemo(()=>({openMethod:e,reset:i,triggerProps:{onClick:s,onPointerDown:o}}),[e,i,s,o])}function XN(n){const{store:e,parentContext:t,actionsRef:r}=n,i=e.useState("open"),s=e.useState("disablePointerDismissal"),o=e.useState("modal"),a=e.useState("popupElement"),{openMethod:u,triggerProps:f,reset:h}=YN(i);SS(e);const{forceUnmount:p}=kS(i,e,()=>{h()}),g=Ne(Q=>{const q=yt(Q);return q.preventUnmountOnClose=()=>{e.set("preventUnmountingOnClose",!0)},q}),y=S.useCallback(()=>{e.setOpen(!1,g(nS))},[e,g]);S.useImperativeHandle(r,()=>({unmount:p,close:y}),[p,y]);const x=RS({popupStore:e,onOpenChange:e.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,C]=S.useState(0),E=w===0,T=D5(x),M=gS(x,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(Q){if("button"in Q&&Q.button!==0||"touches"in Q&&Q.touches.length!==1)return!1;const q=en(Q);if(E&&!s){const H=q;return o&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===H||e.context.backdropRef.current===H||Xe(H,a)&&!(H!=null&&H.hasAttribute("data-base-ui-portal")):!0}return!1},escapeKey:E});QN(i&&o===!0,a);const{getReferenceProps:P,getFloatingProps:O,getTriggerProps:N}=l0([T,M]);e.useContextCallback("onNestedDialogOpen",Q=>{C(Q+1)}),e.useContextCallback("onNestedDialogClose",()=>{C(0)}),S.useEffect(()=>(t!=null&&t.onNestedDialogOpen&&i&&t.onNestedDialogOpen(w),t!=null&&t.onNestedDialogClose&&!i&&t.onNestedDialogClose(),()=>{t!=null&&t.onNestedDialogClose&&i&&t.onNestedDialogClose()}),[i,t,w]);const L=S.useMemo(()=>P(f),[P,f]),F=S.useMemo(()=>N(f),[N,f]),U=S.useMemo(()=>O(),[O]);e.useSyncedValues({openMethod:u,activeTriggerProps:L,inactiveTriggerProps:F,popupProps:U,floatingRootContext:x,nestedOpenDialogCount:w})}const JN={...ES,modal:Je(n=>n.modal),nested:Je(n=>n.nested),nestedOpenDialogCount:Je(n=>n.nestedOpenDialogCount),disablePointerDismissal:Je(n=>n.disablePointerDismissal),openMethod:Je(n=>n.openMethod),descriptionElementId:Je(n=>n.descriptionElementId),titleElementId:Je(n=>n.titleElementId),viewportElement:Je(n=>n.viewportElement),role:Je(n=>n.role)};class ZN extends i0{constructor(t){super(e8(t),{popupRef:S.createRef(),backdropRef:S.createRef(),internalBackdropRef:S.createRef(),triggerElements:new Td,onOpenChange:void 0,onOpenChangeComplete:void 0},JN);ft(this,"setOpen",(t,r)=>{var a,u,f,h;if(r.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&r.trigger==null&&this.state.activeTriggerId!=null&&(r.trigger=this.state.activeTriggerElement??void 0),(u=(a=this.context).onOpenChange)==null||u.call(a,t,r),r.isCanceled)return;const i={open:t,nativeEvent:r.event,reason:r.reason,nested:this.state.nested};(f=this.state.floatingRootContext.context.events)==null||f.emit("openchange",i);const s={open:t},o=((h=r.trigger)==null?void 0:h.id)??null;(o||t)&&(s.activeTriggerId=o,s.activeTriggerElement=r.trigger??null),this.update(s)})}}function e8(n={}){return{...CS(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...n}}function ZS(n){const{children:e,open:t,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,disablePointerDismissal:o=!1,modal:a=!0,actionsRef:u,handle:f,triggerId:h,defaultTriggerId:p=null}=n,g=Ni(!0),y=!!g,x=ri(()=>(f==null?void 0:f.store)??new ZN({open:t??r,activeTriggerId:h!==void 0?h:p,modal:a,disablePointerDismissal:o,nested:y})).current;x.useControlledProp("open",t,r),x.useControlledProp("activeTriggerId",h,p),x.useSyncedValues({disablePointerDismissal:o,nested:y,modal:a}),x.useContextCallback("onOpenChange",i),x.useContextCallback("onOpenChangeComplete",s);const w=x.useState("payload");XN({store:x,actionsRef:u,parentContext:g==null?void 0:g.store.context});const C=S.useMemo(()=>({store:x}),[x]);return k.jsx(VS.Provider,{value:C,children:typeof e=="function"?e({payload:w}):e})}let z1=function(n){return n[n.open=Er.open]="open",n[n.closed=Er.closed]="closed",n[n.startingStyle=Er.startingStyle]="startingStyle",n[n.endingStyle=Er.endingStyle]="endingStyle",n.nested="data-nested",n.nestedDialogOpen="data-nested-dialog-open",n}({});const t8={...dc,...gl,nested(n){return n?{[z1.nested]:""}:null},nestedDialogOpen(n){return n?{[z1.nestedDialogOpen]:""}:null}},ek=S.forwardRef(function(e,t){const{className:r,render:i,children:s,...o}=e,a=HS(),{store:u}=Ni(),f=u.useState("open"),h=u.useState("nested"),p=u.useState("transitionStatus"),g=u.useState("nestedOpenDialogCount"),y=u.useState("mounted"),x=g>0,w=S.useMemo(()=>({open:f,nested:h,transitionStatus:p,nestedDialogOpen:x}),[f,h,p,x]);return At("div",e,{enabled:a||y,state:w,ref:[t,u.useStateSetter("viewportElement")],stateAttributesMapping:t8,props:[{role:"presentation",hidden:!y,children:s},o]})}),tk=S.forwardRef(function(e,t){const{render:r,className:i,id:s,...o}=e,{store:a}=Ni(),u=no(s);return a.useSyncedValueWithCleanup("titleElementId",u),At("h2",e,{ref:t,props:[{id:u},o]})}),nk=S.forwardRef(function(e,t){const{render:r,className:i,disabled:s=!1,nativeButton:o=!0,id:a,payload:u,handle:f,...h}=e,p=Ni(!0),g=(f==null?void 0:f.store)??(p==null?void 0:p.store);if(!g)throw new Error(gn(79));const y=no(a),x=g.useState("floatingRootContext"),w=g.useState("isOpenedByTrigger",y),C=S.useRef(null),{registerTrigger:E,isMountedByThisTrigger:T}=bS(y,C,g,{payload:u}),{getButtonProps:M,buttonRef:P}=Md({disabled:s,native:o}),O=iA(x,{enabled:x!=null}),N=l0([O]),L=S.useMemo(()=>({disabled:s,open:w}),[s,w]),F=g.useState("triggerProps",T);return At("button",e,{state:L,ref:[P,t,E,C],props:[N.getReferenceProps(),F,{[k2]:"",id:y},h,M],stateAttributesMapping:MS})}),n8=ZS,r8=JS;function i8(n){return k.jsx(nk,{"data-slot":"sheet-trigger",...n})}function s8(n){return k.jsx(Od,{"data-slot":"sheet-close",...n})}function o8({className:n,...e}){return k.jsx(WS,{className:et("fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-200 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0",n),"data-slot":"sheet-backdrop",...e})}function l8({className:n,side:e,inset:t=!1,...r}){return k.jsx(ek,{className:et("fixed inset-0 z-50 grid",e==="bottom"&&"grid grid-rows-[1fr_auto] pt-12",e==="top"&&"grid grid-rows-[auto_1fr] pb-12",e==="left"&&"flex justify-start",e==="right"&&"flex justify-end",t&&"sm:p-4"),"data-slot":"sheet-viewport",...r})}function a8({className:n,children:e,showCloseButton:t=!0,side:r="right",inset:i=!1,...s}){return k.jsxs(r8,{children:[k.jsx(o8,{}),k.jsx(l8,{inset:i,side:r,children:k.jsxs(XS,{className:et("relative flex max-h-full min-h-0 w-full min-w-0 flex-col bg-popover bg-clip-padding text-popover-foreground shadow-lg transition-[opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:opacity-0 data-starting-style:opacity-0 max-sm:before:hidden dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]",r==="bottom"&&"row-start-2 border-t data-ending-style:translate-y-8 data-starting-style:translate-y-8",r==="top"&&"data-ending-style:-translate-y-8 data-starting-style:-translate-y-8 border-b",r==="left"&&"data-ending-style:-translate-x-8 data-starting-style:-translate-x-8 w-[calc(100%-(--spacing(12)))] max-w-md border-e",r==="right"&&"col-start-2 w-[calc(100%-(--spacing(12)))] max-w-md border-s data-ending-style:translate-x-8 data-starting-style:translate-x-8",i&&"before:hidden sm:rounded-xl sm:border sm:before:rounded-[calc(var(--radius-xl)-1px)] sm:**:data-[slot=sheet-footer]:rounded-b-[calc(var(--radius-xl)-1px)]",n),"data-slot":"sheet-popup",...s,children:[e,t&&k.jsx(Od,{"aria-label":"Close",className:"absolute end-2 top-2",render:k.jsx(Dn,{size:"icon",variant:"ghost"}),children:k.jsx(yd,{})})]})})]})}function c8({className:n,...e}){return k.jsx(tk,{className:et("font-heading text-xl leading-none",n),"data-slot":"sheet-title",...e})}const Fu=768;function u8(){const[n,e]=S.useState(()=>typeof window<"u"&&window.matchMedia(`(max-width: ${Fu-1}px)`).matches);return S.useEffect(()=>{const t=window.matchMedia(`(max-width: ${Fu-1}px)`),r=()=>{e(window.innerWidth<Fu)};return t.addEventListener("change",r),e(window.innerWidth<Fu),()=>t.removeEventListener("change",r)},[]),!!n}function f8({sources:n,isLoading:e}){const t=Ar(),r=t.pathname.startsWith("/source/"),[i,s]=S.useState(!1),o=u8(),[a,u]=S.useState(()=>{try{return window.localStorage.getItem("dbhub.navigation.expanded")==="true"}catch{return!1}}),f=!r||a,h=()=>{const p=!a;u(p);try{window.localStorage.setItem("dbhub.navigation.expanded",String(p))}catch{}};return S.useEffect(()=>{s(!1)},[t.pathname,o]),k.jsxs("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas",children:[k.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:start-4 focus:top-4 focus:z-50 focus:rounded-md focus:bg-background focus:p-3 focus:outline-2 focus:outline-ring",children:"Skip to content"}),k.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-between gap-3 border-b-[length:var(--border-hairline)] border-border bg-sidebar px-4 md:hidden",children:[k.jsx(L1,{}),k.jsxs(n8,{open:i,onOpenChange:s,children:[k.jsx(i8,{render:k.jsx(Dn,{variant:"ghost",size:"icon-xl","aria-label":"Open navigation",className:"touch-manipulation md:hidden"}),children:k.jsx(EM,{"aria-hidden":"true"})}),k.jsxs(a8,{side:"left",showCloseButton:!1,className:"w-[min(24rem,100%)] motion-reduce:transition-none",children:[k.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b-[length:var(--border-hairline)] border-border px-3",children:[k.jsx(c8,{className:"text-label",children:"Navigation"}),k.jsx(s8,{render:k.jsx(Dn,{variant:"ghost",size:"icon-xl","aria-label":"Close navigation",className:"touch-manipulation"}),children:k.jsx(yd,{"aria-hidden":"true"})})]}),k.jsxs("div",{className:"flex min-h-0 flex-1",onClick:p=>{p.target.closest("a[href]")&&s(!1)},children:[k.jsx(N1,{sources:n,hasSidebar:!0}),k.jsx(I1,{sources:n,isLoading:e})]})]})]})]}),k.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[k.jsxs("div",{className:"hidden min-h-0 shrink-0 flex-col bg-sidebar md:flex",children:[k.jsx("header",{className:"flex h-14 shrink-0 items-center justify-between gap-4 border-b-[length:var(--border-hairline)] border-e-[length:var(--border-hairline)] border-border px-4",children:k.jsx(L1,{})}),k.jsxs("div",{className:"flex min-h-0 flex-1",children:[k.jsx(N1,{sources:n,hasSidebar:r,expanded:f,onToggleExpanded:r?h:void 0}),r&&k.jsx(I1,{sources:n,isLoading:e})]})]}),k.jsx("main",{id:"main-content",tabIndex:-1,className:"min-h-0 min-w-0 flex-1 overflow-auto [scrollbar-gutter:stable] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring","aria-label":"Main content",children:k.jsx(vT,{})})]})]})}class _t extends Error{constructor(e,t,r){super(e),this.status=t,this.statusText=r,this.name="ApiError"}}const rk="/api";async function ik(n){const e=n.headers.get("content-type");if(e&&e.includes("application/json"))return n.json();const t=await n.text();throw new _t(t||n.statusText,n.status,n.statusText)}async function f0(){try{const n=await fetch(`${rk}/sources`);if(!n.ok){const e=await ik(n).then(t=>t.error).catch(()=>n.statusText);throw new _t(`Failed to fetch sources: ${e}`,n.status,n.statusText)}return n.json()}catch(n){throw n instanceof _t?n:new _t(n instanceof Error?n.message:"Network error",0)}}async function sk(n){try{if(!n||n.trim()==="")throw new _t("Source ID cannot be empty",400);if(n.includes("/")||n.includes(".."))throw new _t("Invalid source ID format",400);const e=await fetch(`${rk}/sources/${encodeURIComponent(n)}`);if(!e.ok){const t=await ik(e).then(r=>r.error).catch(()=>e.statusText);throw new _t(e.status===404?`Source not found: ${n}`:`Failed to fetch source: ${t}`,e.status,e.statusText)}return e.json()}catch(e){throw e instanceof _t?e:new _t(e instanceof Error?e.message:"Network error",0)}}function d8(){const n=hd();return S.useEffect(()=>{f0().then(e=>{e.length>0?n(`/source/${e[0].id}`,{replace:!0}):n("/requests",{replace:!0})}).catch(()=>{n("/requests",{replace:!0})})},[]),k.jsx("div",{className:"flex items-center justify-center h-full",children:k.jsx("div",{className:"text-muted-foreground",children:"Loading..."})})}const ok=ZS,h8=JS;function lk(n){return k.jsx(nk,{"data-slot":"dialog-trigger",...n})}function p8(n){return k.jsx(Od,{"data-slot":"dialog-close",...n})}function m8({className:n,...e}){return k.jsx(WS,{className:et("fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-200 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0",n),"data-slot":"dialog-backdrop",...e})}function g8({className:n,...e}){return k.jsx(ek,{className:et("fixed inset-0 z-50 grid grid-rows-[1fr_auto_3fr] justify-items-center p-4",n),"data-slot":"dialog-viewport",...e})}function ak({className:n,children:e,showCloseButton:t=!0,bottomStickOnMobile:r=!0,...i}){return k.jsxs(h8,{children:[k.jsx(m8,{}),k.jsx(g8,{className:et(r&&"max-sm:grid-rows-[1fr_auto] max-sm:pt-12"),children:k.jsxs(XS,{className:et("-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-xl bg-popover text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0",r&&"max-sm:rounded-none max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4",n),"data-slot":"dialog-popup",...i,children:[e,t&&k.jsx(Od,{"aria-label":"Close",className:"absolute end-2 top-2",render:k.jsx(Dn,{size:"icon",variant:"ghost"}),children:k.jsx(yd,{})})]})})]})}function y8({className:n,...e}){return k.jsx("div",{className:et("flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4",n),"data-slot":"dialog-header",...e})}function v8({className:n,variant:e="default",...t}){return k.jsx("div",{className:et("flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-xl)-1px)]",e==="default"&&"border-t bg-muted/50 py-4",e==="bare"&&"in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6",n),"data-slot":"dialog-footer",...t})}function ck({className:n,...e}){return k.jsx(tk,{className:et("font-heading text-xl leading-none",n),"data-slot":"dialog-title",...e})}function uk({className:n,...e}){return k.jsx(DN,{className:et("text-muted-foreground text-sm",n),"data-slot":"dialog-description",...e})}const _1="/api";async function x8(n){try{const e=n?`${_1}/requests?source_id=${encodeURIComponent(n)}`:`${_1}/requests`,t=await fetch(e);if(!t.ok){const r=await t.json().then(i=>i.error).catch(()=>t.statusText);throw new _t(`Failed to fetch requests: ${r}`,t.status,t.statusText)}return t.json()}catch(e){throw e instanceof _t?e:new _t(e instanceof Error?e.message:"Network error",0)}}function Lo({className:n,...e}){return k.jsx("div",{className:et("animate-skeleton motion-reduce:animate-none rounded-sm [--skeleton-highlight:--alpha(var(--color-white)/64%)] [background:linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)_var(--color-muted)_0_0/200%_100%_fixed] dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]",n),"data-slot":"skeleton",...e})}function d0({label:n,layout:e="details"}){return k.jsxs("div",{className:et("container mx-auto space-y-6 px-4 py-6 sm:px-8 sm:py-10",e==="table"?"max-w-6xl":"max-w-4xl"),role:"status","aria-label":n,children:[k.jsx("span",{className:"sr-only",children:n}),k.jsxs("div",{"aria-hidden":"true",className:"space-y-3",children:[k.jsx(Lo,{className:"h-7 w-48 max-w-full"}),k.jsx(Lo,{className:"h-4 w-80 max-w-full"})]}),k.jsx("div",{"aria-hidden":"true",className:"space-y-6 rounded-xl border border-border bg-card p-4 sm:p-6",children:e==="table"?k.jsx("div",{className:"space-y-5",children:Array.from({length:7},(t,r)=>k.jsx("div",{className:"grid grid-cols-[1fr_2fr_1fr] gap-4",children:Array.from({length:3},(i,s)=>k.jsx(Lo,{className:"h-4 w-full"},s))},r))}):k.jsxs(k.Fragment,{children:[k.jsx(Lo,{className:"h-5 w-32"}),k.jsx("div",{className:"grid gap-6 sm:grid-cols-2",children:Array.from({length:6},(t,r)=>k.jsxs("div",{className:"space-y-3",children:[k.jsx(Lo,{className:"h-3 w-24"}),k.jsx(Lo,{className:"h-5 w-full"})]},r))})]})})]})}function h0({title:n,message:e,onRetry:t}){return k.jsx("div",{className:"container mx-auto max-w-4xl px-4 py-6 sm:px-8 sm:py-10",children:k.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card p-4 sm:p-6",children:[k.jsxs("div",{role:"alert",className:"flex items-start gap-3",children:[k.jsx(gd,{"aria-hidden":"true",className:"mt-0.5 size-5 shrink-0 text-destructive-foreground"}),k.jsxs("div",{className:"min-w-0 space-y-2",children:[k.jsx("h1",{className:"text-section",children:n}),k.jsx("p",{className:"max-w-prose text-sm text-muted-foreground whitespace-pre-wrap [overflow-wrap:anywhere]",children:e})]})]}),k.jsx(Dn,{variant:"outline",className:"min-h-11",onClick:r=>{var i;(i=r.currentTarget.closest("main"))==null||i.focus(),t()},children:"Try again"})]})})}function w8(n){return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function b8(n){const e=new Date(n),t=new Date;return e.toDateString()===t.toDateString()?"Today":e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function S8(n){const e=n.match(/Edg(?:e|A|iOS)?\/(\d+)/);if(e)return`Edge ${e[1]}`;const t=n.match(/(?:OPR|Opera)\/(\d+)/);if(t)return`Opera ${t[1]}`;const r=n.match(/Chrome\/(\d+)/);if(r&&!n.includes("Edg")&&!n.includes("OPR"))return`Chrome ${r[1]}`;const i=n.match(/Version\/(\d+(?:\.\d+)?)\s+Safari/);if(i)return`Safari ${i[1]}`;const s=n.match(/Firefox\/(\d+)/);if(s)return`Firefox ${s[1]}`;if(n.includes("Claude"))return"Claude Desktop";if(n.includes("Electron"))return"Electron App";if(n.includes("Cursor"))return"Cursor";const o=n.match(/^(\w+)\/[\d.]+/);return o?o[1]:n.length>20?n.substring(0,20)+"...":n}function fk({title:n,text:e,children:t,className:r}){const[i,s]=S.useState("");return k.jsxs(ok,{onOpenChange:()=>s(""),children:[k.jsx(lk,{className:r,"aria-label":`View ${n.toLowerCase()}`,children:t}),k.jsxs(ak,{className:"max-w-2xl motion-reduce:transition-none",children:[k.jsxs(y8,{children:[k.jsx(ck,{className:"text-section pe-8",children:n}),k.jsx(uk,{children:"Select text or copy the full value."})]}),k.jsx("pre",{tabIndex:0,className:"mx-6 max-h-[50dvh] min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-border bg-muted p-3 font-mono text-code [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-ring",children:e}),k.jsxs(v8,{variant:"bare",className:"items-center",children:[k.jsx("p",{role:"status",className:"text-caption text-muted-foreground",children:i}),k.jsxs(Dn,{variant:"outline",className:"min-h-9 pointer-coarse:min-h-11",onClick:async()=>{try{await navigator.clipboard.writeText(e),s("Copied")}catch{s("Could not copy. Select the text and copy it manually.")}},children:[i==="Copied"?k.jsx(lM,{className:"size-4"}):k.jsx(yM,{className:"size-4"}),"Copy"]})]})]})]})}function k8({success:n,error:e}){const t=k.jsx("svg",{"aria-hidden":"true",className:"size-4 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:n?"M5 13l4 4L19 7":"M6 18L18 6M6 6l12 12"})});return!n&&e?k.jsx(fk,{title:"Request error",text:e,className:"inline-flex min-h-9 min-w-9 items-center justify-center rounded-md text-destructive-foreground hover:bg-destructive/10 pointer-coarse:min-h-11 pointer-coarse:min-w-11 focus-visible:outline-2 focus-visible:outline-ring",children:t}):k.jsx("span",{role:"img","aria-label":n?"Succeeded":"Failed",className:n?"text-success-foreground":"text-destructive-foreground",children:t})}function C8(){const[n,e]=S.useState([]),[t,r]=S.useState({}),[i,s]=S.useState({}),[o,a]=S.useState(!0),[u,f]=S.useState(0),[h,p]=S.useState(null),[g,y]=S.useState(null);S.useEffect(()=>{let C=!0;return a(!0),p(null),Promise.all([x8(),f0()]).then(([E,T])=>{if(!C)return;e(E.requests);const M={},P={};for(const O of T){M[O.id]=O.type;for(const N of O.tools)N.readonly&&(P[N.name]=!0)}r(M),s(P),a(!1)}).catch(E=>{if(!C)return;console.error("Failed to fetch data:",E);const T=E instanceof _t?E.message:"Failed to load data";p(T),a(!1)}),()=>{C=!1}},[u]);const x=[...new Set(n.map(C=>C.sourceId))].sort(),w=g?n.filter(C=>C.sourceId===g):n;return o?k.jsx(d0,{label:"Loading recent requests…",layout:"table"}):h?k.jsx(h0,{title:"Could not load recent requests",message:h,onRetry:()=>f(C=>C+1)}):k.jsx("div",{className:"container mx-auto px-4 py-6 sm:px-8 sm:py-10 max-w-6xl",children:k.jsxs("div",{className:"space-y-6",children:[k.jsxs("div",{children:[k.jsx("h1",{className:"text-page text-foreground mb-2",children:"Recent requests"}),k.jsx("p",{className:"text-muted-foreground text-body max-w-prose text-pretty",children:"Up to 100 requests per source"})]}),n.length>0&&k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"flex flex-wrap gap-2",children:[k.jsxs("button",{"aria-pressed":g===null,onClick:()=>y(null),className:`min-h-9 pointer-coarse:min-h-11 px-3 py-1 text-label tabular-nums whitespace-nowrap rounded-md transition-colors motion-reduce:transition-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${g===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:["All (",n.length,")"]}),x.map(C=>{const E=n.filter(M=>M.sourceId===C).length,T=t[C];return k.jsxs("button",{"aria-pressed":g===C,onClick:()=>y(C),className:`min-h-9 pointer-coarse:min-h-11 px-3 py-1 text-label tabular-nums whitespace-nowrap rounded-md transition-colors motion-reduce:transition-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring flex items-center gap-1.5 ${g===C?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[T&&k.jsx("img",{src:u0[T],alt:`${T} logo`,className:"w-4 h-4"}),C," (",E,")"]},C)})]}),k.jsx("div",{className:"overflow-x-auto rounded-xl border border-border bg-card",children:k.jsxs("table",{className:"w-full",children:[k.jsx("thead",{children:k.jsxs("tr",{className:"border-b-[length:var(--border-hairline)] border-border bg-muted",children:[k.jsx("th",{className:"px-4 py-3 text-start text-label text-muted-foreground whitespace-nowrap",children:"Time"}),k.jsx("th",{className:"px-4 py-3 text-start text-label text-muted-foreground whitespace-nowrap",children:"Tool"}),k.jsx("th",{className:"px-4 py-3 text-start text-label text-muted-foreground w-full",children:"SQL"}),k.jsx("th",{className:"px-4 py-3 text-start text-label text-muted-foreground whitespace-nowrap",children:"Result"}),k.jsx("th",{className:"px-4 py-3 text-start text-label text-muted-foreground whitespace-nowrap",children:"Client"})]})}),k.jsx("tbody",{className:"divide-y-[length:var(--border-hairline)] divide-border",children:w.map(C=>k.jsxs("tr",{className:"hover:bg-muted transition-colors",children:[k.jsxs("td",{className:"px-4 py-2 text-caption tabular-nums text-muted-foreground whitespace-nowrap",children:[b8(C.timestamp)," ",w8(C.timestamp)]}),k.jsx("td",{className:"px-4 py-2 text-sm whitespace-nowrap",children:k.jsxs(ti,{to:`/source/${C.sourceId}`,className:"font-mono text-caption text-primary hover:underline underline-offset-4 decoration-from-font inline-flex items-center gap-1",children:[C.toolName,i[C.toolName]&&k.jsx(_S,{className:"w-3 h-3 text-muted-foreground"})]})}),k.jsx("td",{className:"px-4 py-0 text-code font-mono text-foreground max-w-0",children:k.jsx(fk,{title:"Executed SQL",text:C.sql,className:"block min-h-9 w-full truncate rounded-sm text-start underline-offset-4 hover:underline pointer-coarse:min-h-11 focus-visible:outline-2 focus-visible:outline-ring",children:C.sql})}),k.jsx("td",{className:"px-4 py-0 text-sm",children:k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx(k8,{success:C.success,error:C.error}),k.jsxs("span",{className:"text-caption tabular-nums whitespace-nowrap text-muted-foreground",children:[C.durationMs," ms"]})]})}),k.jsx("td",{title:C.client,className:"px-4 py-2 text-caption text-muted-foreground whitespace-nowrap",children:S8(C.client)})]},C.id))})]})})]}),n.length===0&&k.jsxs("div",{className:"space-y-3 rounded-xl border border-border bg-card p-6 sm:p-8",children:[k.jsx(xM,{"aria-hidden":"true",className:"size-5 text-brand-accent"}),k.jsx("h2",{className:"text-label",children:"No requests yet"}),k.jsx("p",{className:"text-sm text-muted-foreground max-w-prose text-pretty",children:"Run a tool in the workbench or through your MCP client. Its request will appear here when you return."}),k.jsx(Dn,{variant:"outline",className:"min-h-11",render:k.jsx(ti,{to:"/"}),children:"Open workbench"})]})]})})}function E8(){var f;const{sourceId:n}=pd(),[e,t]=S.useState(null),[r,i]=S.useState(!0),[s,o]=S.useState(0),[a,u]=S.useState(null);return S.useEffect(()=>{if(!n)return;let h=!0;return i(!0),u(null),sk(n).then(p=>{h&&(t(p),i(!1))}).catch(p=>{h&&(u(p),i(!1))}),()=>{h=!1}},[n,s]),n?r?k.jsx(d0,{label:"Loading source details…"}):a?a.status===404?k.jsx(wa,{to:"/404",replace:!0}):k.jsx(h0,{title:"Could not load this source",message:a.message,onRetry:()=>o(h=>h+1)}):e?k.jsx("div",{className:"container mx-auto px-4 py-6 sm:px-8 sm:py-10 max-w-4xl",children:k.jsxs("div",{className:"space-y-6",children:[k.jsxs("h1",{className:"flex items-start gap-3 text-page text-foreground",children:[k.jsx("img",{src:u0[e.type],alt:`${e.type} logo`,className:"w-8 h-8 shrink-0"}),k.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:e.id})]}),k.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 sm:p-6",children:[k.jsx("h2",{className:"text-section text-foreground mb-4",children:"Connection Details"}),k.jsxs("dl",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"Database type"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.type})]}),e.host&&k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"Host"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.host})]}),e.port&&k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"Port"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.port})]}),e.database&&k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"Database"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.database})]}),e.user&&k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"User"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.user})]})]})]}),((f=e.ssh_tunnel)==null?void 0:f.enabled)&&k.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 sm:p-6",children:[k.jsx("h2",{className:"text-section text-foreground mb-4",children:"SSH Tunnel"}),k.jsxs("dl",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"Status"}),k.jsx("dd",{className:"mt-1 text-sm text-foreground",children:k.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full whitespace-nowrap text-xs font-medium bg-success/10 text-success-foreground",children:"Enabled"})})]}),e.ssh_tunnel.ssh_host&&k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"SSH host"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.ssh_tunnel.ssh_host})]}),e.ssh_tunnel.ssh_port&&k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"SSH port"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.ssh_tunnel.ssh_port})]}),e.ssh_tunnel.ssh_user&&k.jsxs("div",{children:[k.jsx("dt",{className:"text-label text-muted-foreground",children:"SSH user"}),k.jsx("dd",{className:"mt-1 text-code text-foreground font-mono [overflow-wrap:anywhere]",children:e.ssh_tunnel.ssh_user})]})]})]}),k.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 sm:p-6",children:[k.jsx("h2",{className:"text-section text-foreground mb-4",children:"Available tools"}),e.tools.length>0?k.jsx("div",{className:"divide-y-[length:var(--border-hairline)] divide-border",children:e.tools.map(h=>k.jsx("div",{className:"py-6 first:pt-0 last:pb-0",children:k.jsxs("div",{className:"space-y-4",children:[k.jsxs("div",{children:[k.jsx("div",{className:"flex flex-wrap items-baseline gap-2",children:k.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[k.jsx("h3",{className:"text-label text-foreground font-mono [overflow-wrap:anywhere]",children:h.name}),h.readonly&&k.jsx(v2,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground","aria-label":"Read-only"})]})}),k.jsx("div",{className:"mt-2 text-body text-foreground max-w-prose text-pretty [overflow-wrap:anywhere]",children:h.description})]}),h.parameters.length>0&&k.jsxs("table",{role:"table","aria-label":`${h.name} parameters`,className:"block w-full text-start text-sm md:table md:table-fixed",children:[k.jsxs("colgroup",{className:"hidden md:table-column-group",children:[k.jsx("col",{className:"w-[23%]"}),k.jsx("col",{className:"w-[15%]"}),k.jsx("col",{className:"w-[17%]"}),k.jsx("col",{className:"w-[45%]"})]}),k.jsx("thead",{role:"rowgroup",className:"hidden md:table-header-group",children:k.jsx("tr",{role:"row",className:"border-b-[length:var(--border-hairline)] border-border",children:["Name","Type","Requirement","Description"].map(p=>k.jsx("th",{role:"columnheader",scope:"col",className:"pb-2 pe-4 text-start text-caption font-medium text-muted-foreground last:pe-0",children:p},p))})}),k.jsx("tbody",{role:"rowgroup",className:"block md:table-row-group",children:h.parameters.map(p=>k.jsxs("tr",{role:"row",className:"grid grid-cols-[minmax(0,1fr)_auto_auto] items-baseline gap-x-3 gap-y-1.5 py-3 md:table-row md:py-0",children:[k.jsx("th",{role:"rowheader",scope:"row",className:"min-w-0 text-start align-top font-mono font-medium [overflow-wrap:anywhere] md:py-2.5 md:pe-4",children:p.name}),k.jsx("td",{role:"cell",className:"align-top font-mono text-caption text-muted-foreground [overflow-wrap:anywhere] md:py-2.5 md:pe-4",children:p.type}),k.jsx("td",{role:"cell",className:"align-top text-caption text-muted-foreground md:py-2.5 md:pe-4",children:p.required?"Required":"Optional"}),k.jsx("td",{role:"cell",className:"col-span-3 align-top text-foreground [overflow-wrap:anywhere] md:py-2.5",children:p.description||k.jsx("span",{className:"sr-only",children:"No description"})})]},p.name))})]})]})},h.name))}):k.jsx("div",{className:"text-sm text-muted-foreground",children:"No tools available for this source"})]})]})}):k.jsx("div",{className:"container mx-auto px-4 py-6 sm:px-8 sm:py-10",children:k.jsx("div",{className:"text-muted-foreground",children:"Source not found"})}):k.jsx(wa,{to:"/",replace:!0})}function R8(n){if(n.rows.length===0)return{sql:n.sql,columns:[],rows:[],rowCount:n.count};const e=Object.keys(n.rows[0]),t=n.rows.map(r=>e.map(i=>r[i]));return{sql:n.sql,columns:e,rows:t,rowCount:n.count}}async function V1(n,e){var o,a,u,f,h;const t=await fetch("/mcp",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify({jsonrpc:"2.0",id:Am(),method:"tools/call",params:{name:n,arguments:e}})});if(!t.ok)throw new _t(`HTTP error: ${t.status}`,t.status);const r=await t.text();let i;if((o=t.headers.get("content-type"))!=null&&o.includes("text/event-stream")){const p=r.split(`
`).find(g=>g.startsWith("data: "));if(!p)throw new _t("No data event in SSE response",500);i=JSON.parse(p.slice(6))}else i=JSON.parse(r);if(i.error)throw new _t(i.error.message,i.error.code);if(!((f=(u=(a=i.result)==null?void 0:a.content)==null?void 0:u[0])!=null&&f.text))throw new _t("Invalid response format",500);const s=JSON.parse(i.result.content[0].text);if(!s.success||s.error)throw new _t(s.error||"Tool execution failed",500);return!s.data||!((h=s.data.statements)!=null&&h.length)?[{columns:[],rows:[],rowCount:0}]:s.data.statements.map(R8)}let $m=[],dk=[];(()=>{let n="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,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?dk:$m).push(t=t+n[e])})();function T8(n){if(n<768)return!1;for(let e=0,t=$m.length;;){let r=e+t>>1;if(n<$m[r])t=r;else if(n>=dk[r])e=r+1;else return!0;if(e==t)return!1}}function W1(n){return n>=127462&&n<=127487}const $1=8205;function M8(n,e,t=!0,r=!0){return(t?hk:O8)(n,e,r)}function hk(n,e,t){if(e==n.length)return e;e&&pk(n.charCodeAt(e))&&mk(n.charCodeAt(e-1))&&e--;let r=qp(n,e);for(e+=H1(r);e<n.length;){let i=qp(n,e);if(r==$1||i==$1||t&&T8(i))e+=H1(i),r=i;else if(W1(i)){let s=0,o=e-2;for(;o>=0&&W1(qp(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function O8(n,e,t){for(;e>0;){let r=hk(n,e-2,t);if(r<e)return r;e--}return 0}function qp(n,e){let t=n.charCodeAt(e);if(!mk(t)||e+1==n.length)return t;let r=n.charCodeAt(e+1);return pk(r)?(t-55296<<10)+(r-56320)+65536:t}function pk(n){return n>=56320&&n<57344}function mk(n){return n>=55296&&n<56320}function H1(n){return n<65536?1:2}class lt{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,t,r){[e,t]=nl(this,e,t);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(t,this.length,i,1),Qr.from(i,this.length-(t-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=nl(this,e,t);let r=[];return this.decompose(e,t,r,0),Qr.from(r,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Ca(this),s=new Ca(e);for(let o=t,a=t;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(e=1){return new Ca(this,e)}iterRange(e,t=this.length){return new gk(this,e,t)}iterLines(e,t){let r;if(e==null)r=this.iter();else{t==null&&(t=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new yk(r)}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]?lt.empty:e.length<=32?new It(e):Qr.from(It.split(e,[]))}}class It extends lt{constructor(e,t=P8(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,r,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((t?r:a)>=e)return new A8(i,a,r,o);i=a+1,r++}}decompose(e,t,r,i){let s=e<=0&&t>=this.length?this:new It(U1(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=gf(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new It(a,o.length+s.length));else{let u=a.length>>1;r.push(new It(a.slice(0,u)),new It(a.slice(u)))}}else r.push(s)}replace(e,t,r){if(!(r instanceof It))return super.replace(e,t,r);[e,t]=nl(this,e,t);let i=gf(this.text,gf(r.text,U1(this.text,0,e)),t),s=this.length+r.length-(t-e);return i.length<=32?new It(i,s):Qr.from(It.split(i,[]),s)}sliceString(e,t=this.length,r=`
`){[e,t]=nl(this,e,t);let i="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let a=this.text[o],u=s+a.length;s>e&&o&&(i+=r),e<u&&t>s&&(i+=a.slice(Math.max(0,e-s),t-s)),s=u+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(t.push(new It(r,i)),r=[],i=-1);return i>-1&&t.push(new It(r,i)),t}}class Qr extends lt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,t,r,i){for(let s=0;;s++){let o=this.children[s],a=i+o.length,u=r+o.lines-1;if((t?u:a)>=e)return o.lineInner(e,t,r,i);i=a+1,r=u+1}}decompose(e,t,r,i){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let a=this.children[s],u=o+a.length;if(e<=u&&t>=o){let f=i&((o<=e?1:0)|(u>=t?2:0));o>=e&&u<=t&&!f?r.push(a):a.decompose(e-o,t-o,r,f)}o=u+1}}replace(e,t,r){if([e,t]=nl(this,e,t),r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],a=s+o.length;if(e>=s&&t<=a){let u=o.replace(e-s,t-s,r),f=this.lines-o.lines+u.lines;if(u.lines<f>>4&&u.lines>f>>6){let h=this.children.slice();return h[i]=u,new Qr(h,this.length-(t-e)+r.length)}return super.replace(s,a,u)}s=a+1}return super.replace(e,t,r)}sliceString(e,t=this.length,r=`
`){[e,t]=nl(this,e,t);let i="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let a=this.children[s],u=o+a.length;o>e&&s&&(i+=r),e<u&&t>o&&(i+=a.sliceString(e-o,t-o,r)),o=u+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Qr))return 0;let r=0,[i,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,s+=t){if(i==o||s==a)return r;let u=this.children[i],f=e.children[s];if(u!=f)return r+u.scanIdentical(f,t);r+=u.length+1}}static from(e,t=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let y of e)r+=y.lines;if(r<32){let y=[];for(let x of e)x.flatten(y);return new It(y,t)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,a=[],u=0,f=-1,h=[];function p(y){let x;if(y.lines>s&&y instanceof Qr)for(let w of y.children)p(w);else y.lines>o&&(u>o||!u)?(g(),a.push(y)):y instanceof It&&u&&(x=h[h.length-1])instanceof It&&y.lines+x.lines<=32?(u+=y.lines,f+=y.length+1,h[h.length-1]=new It(x.text.concat(y.text),x.length+1+y.length)):(u+y.lines>i&&g(),u+=y.lines,f+=y.length+1,h.push(y))}function g(){u!=0&&(a.push(h.length==1?h[0]:Qr.from(h,f)),f=-1,u=h.length=0)}for(let y of e)p(y);return g(),a.length==1?a[0]:new Qr(a,t)}}lt.empty=new It([""],0);function P8(n){let e=-1;for(let t of n)e+=t.length+1;return e}function gf(n,e,t=0,r=1e9){for(let i=0,s=0,o=!0;s<n.length&&i<=r;s++){let a=n[s],u=i+a.length;u>=t&&(u>r&&(a=a.slice(0,r-i)),i<t&&(a=a.slice(t-i)),o?(e[e.length-1]+=a,o=!1):e.push(a)),i=u+1}return e}function U1(n,e,t){return gf(n,[""],e,t)}class Ca{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof It?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,a=i instanceof It?i.text.length:i.children.length;if(o==(t>0?a:0)){if(r==0)return this.done=!0,this.value="",this;t>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[r]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(i instanceof It){let u=i.text[o+(t<0?-1:0)];if(this.offsets[r]+=t,u.length>Math.max(0,e))return this.value=e==0?u:t>0?u.slice(e):u.slice(0,u.length-e),this;e-=u.length}else{let u=i.children[o+(t<0?-1:0)];e>u.length?(e-=u.length,this.offsets[r]+=t):(t<0&&this.offsets[r]--,this.nodes.push(u),this.offsets.push(t>0?1:(u instanceof It?u.text.length:u.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class gk{constructor(e,t,r){this.value="",this.done=!1,this.cursor=new Ca(e,t>r?-1:1),this.pos=t>r?e.length:0,this.from=Math.min(t,r),this.to=Math.max(t,r)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let r=t<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=r?i:t<0?i.slice(i.length-r):i.slice(0,r),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 yk{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:r,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(lt.prototype[Symbol.iterator]=function(){return this.iter()},Ca.prototype[Symbol.iterator]=gk.prototype[Symbol.iterator]=yk.prototype[Symbol.iterator]=function(){return this});class A8{constructor(e,t,r,i){this.from=e,this.to=t,this.number=r,this.text=i}get length(){return this.to-this.from}}function nl(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Qt(n,e,t=!0,r=!0){return M8(n,e,t,r)}function N8(n){return n>=56320&&n<57344}function L8(n){return n>=55296&&n<56320}function Pn(n,e){let t=n.charCodeAt(e);if(!L8(t)||e+1==n.length)return t;let r=n.charCodeAt(e+1);return N8(r)?(t-55296<<10)+(r-56320)+65536:t}function p0(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Gr(n){return n<65536?1:2}const Hm=/\r\n?|\n/;var bn=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(bn||(bn={}));class ei{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let r=this.sections[t+1];e+=r<0?this.sections[t]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,r=0,i=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(r,i,s),i+=s):i+=o,r+=s}}iterChangedRanges(e,t=!1){Um(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let r=this.sections[t++],i=this.sections[t++];i<0?e.push(r,i):e.push(i,r)}return new ei(e)}composeDesc(e){return this.empty?e:e.empty?this:vk(this,e)}mapDesc(e,t=!1){return e.empty?this:qm(this,e,t)}mapPos(e,t=-1,r=bn.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],u=this.sections[o++],f=i+a;if(u<0){if(f>e)return s+(e-i);s+=a}else{if(r!=bn.Simple&&f>=e&&(r==bn.TrackDel&&i<e&&f>e||r==bn.TrackBefore&&i<e||r==bn.TrackAfter&&f>e))return null;if(f>e||f==e&&t<0&&!a)return e==i||t<0?s:s+u;s+=u}i=f}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,t=e){for(let r=0,i=0;r<this.sections.length&&i<=t;){let s=this.sections[r++],o=this.sections[r++],a=i+s;if(o>=0&&i<=t&&a>=e)return i<e&&a>t?"cover":!0;i=a}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let r=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ei(e)}static create(e){return new ei(e)}}class Kt extends ei{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Um(this,(t,r,i,s,o)=>e=e.replace(i,i+(r-t),o),!1),e}mapDesc(e,t=!1){return qm(this,e,t,!0)}invert(e){let t=this.sections.slice(),r=[];for(let i=0,s=0;i<t.length;i+=2){let o=t[i],a=t[i+1];if(a>=0){t[i]=a,t[i+1]=o;let u=i>>1;for(;r.length<u;)r.push(lt.empty);r.push(o?e.slice(s,s+o):lt.empty)}s+=o}return new Kt(t,r)}compose(e){return this.empty?e:e.empty?this:vk(this,e,!0)}map(e,t=!1){return e.empty?this:qm(this,e,t,!0)}iterChanges(e,t=!1){Um(this,e,t)}get desc(){return ei.create(this.sections)}filter(e){let t=[],r=[],i=[],s=new ja(this);e:for(let o=0,a=0;;){let u=o==e.length?1e9:e[o++];for(;a<u||a==u&&s.len==0;){if(s.done)break e;let h=Math.min(s.len,u-a);mn(i,h,-1);let p=s.ins==-1?-1:s.off==0?s.ins:0;mn(t,h,p),p>0&&ls(r,t,s.text),s.forward(h),a+=h}let f=e[o++];for(;a<f;){if(s.done)break e;let h=Math.min(s.len,f-a);mn(t,h,-1),mn(i,h,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(h),a+=h}}return{changes:new Kt(t,r),filtered:ei.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let r=this.sections[t],i=this.sections[t+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,r){let i=[],s=[],o=0,a=null;function u(h=!1){if(!h&&!i.length)return;o<t&&mn(i,t-o,-1);let p=new Kt(i,s);a=a?a.compose(p.map(a)):p,i=[],s=[],o=0}function f(h){if(Array.isArray(h))for(let p of h)f(p);else if(h instanceof Kt){if(h.length!=t)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${t})`);u(),a=a?a.compose(h.map(a)):h}else{let{from:p,to:g=p,insert:y}=h;if(p>g||p<0||g>t)throw new RangeError(`Invalid change range ${p} to ${g} (in doc of length ${t})`);let x=y?typeof y=="string"?lt.of(y.split(r||Hm)):y:lt.empty,w=x.length;if(p==g&&w==0)return;p<o&&u(),p>o&&mn(i,p-o,-1),mn(i,g-p,w),ls(s,i,x),o=g}}return f(e),u(!a),a}static empty(e){return new Kt(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;r.length<i;)r.push(lt.empty);r[i]=lt.of(s.slice(1)),t.push(s[0],r[i].length)}}}return new Kt(t,r)}static createSet(e,t){return new Kt(e,t)}}function mn(n,e,t,r=!1){if(e==0&&t<=0)return;let i=n.length-2;i>=0&&t<=0&&t==n[i+1]?n[i]+=e:i>=0&&e==0&&n[i]==0?n[i+1]+=t:r?(n[i]+=e,n[i+1]+=t):n.push(e,t)}function ls(n,e,t){if(t.length==0)return;let r=e.length-2>>1;if(r<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<r;)n.push(lt.empty);n.push(t)}}function Um(n,e,t){let r=n.inserted;for(let i=0,s=0,o=0;o<n.sections.length;){let a=n.sections[o++],u=n.sections[o++];if(u<0)i+=a,s+=a;else{let f=i,h=s,p=lt.empty;for(;f+=a,h+=u,u&&r&&(p=p.append(r[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],u=n.sections[o++];e(i,f,s,h,p),i=f,s=h}}}function qm(n,e,t,r=!1){let i=[],s=r?[]:null,o=new ja(n),a=new ja(e);for(let u=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let f=Math.min(o.len,a.len);mn(i,f,-1),o.forward(f),a.forward(f)}else if(a.ins>=0&&(o.ins<0||u==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!t))){let f=a.len;for(mn(i,a.ins,-1);f;){let h=Math.min(o.len,f);o.ins>=0&&u<o.i&&o.len<=h&&(mn(i,0,o.ins),s&&ls(s,i,o.text),u=o.i),o.forward(h),f-=h}a.next()}else if(o.ins>=0){let f=0,h=o.len;for(;h;)if(a.ins==-1){let p=Math.min(h,a.len);f+=p,h-=p,a.forward(p)}else if(a.ins==0&&a.len<h)h-=a.len,a.next();else break;mn(i,f,u<o.i?o.ins:0),s&&u<o.i&&ls(s,i,o.text),u=o.i,o.forward(o.len-h)}else{if(o.done&&a.done)return s?Kt.createSet(i,s):ei.create(i);throw new Error("Mismatched change set lengths")}}}function vk(n,e,t=!1){let r=[],i=t?[]:null,s=new ja(n),o=new ja(e);for(let a=!1;;){if(s.done&&o.done)return i?Kt.createSet(r,i):ei.create(r);if(s.ins==0)mn(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)mn(r,0,o.ins,a),i&&ls(i,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let u=Math.min(s.len2,o.len),f=r.length;if(s.ins==-1){let h=o.ins==-1?-1:o.off?0:o.ins;mn(r,u,h,a),i&&h&&ls(i,r,o.text)}else o.ins==-1?(mn(r,s.off?0:s.len,u,a),i&&ls(i,r,s.textBit(u))):(mn(r,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&ls(i,r,o.text));a=(s.ins>u||o.ins>=0&&o.len>u)&&(a||r.length>f),s.forward2(u),o.forward(u)}}}}class ja{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,t=this.i-2>>1;return t>=e.length?lt.empty:e[t]}textBit(e){let{inserted:t}=this.set,r=this.i-2>>1;return r>=t.length&&!e?lt.empty:t[r].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 qs{constructor(e,t,r){this.from=e,this.to=t,this.flags=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 bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,t):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new qs(r,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return te.range(e,t);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return te.range(this.anchor,r)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!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 te.range(e.anchor,e.head)}static create(e,t,r){return new qs(e,t,r)}}class te{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:te.create(this.ranges.map(r=>r.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new te([this.main],0)}addRange(e,t=!0){return te.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let r=this.ranges.slice();return r[t]=e,te.create(r,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 te(e.ranges.map(t=>qs.fromJSON(t)),e.main)}static single(e,t=e){return new te([te.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=r:s.from<r)return te.normalized(e.slice(),t);r=s.to}return new te(e,t)}static cursor(e,t=0,r,i){return qs.create(e,e,(t==0?0:t<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(e,t,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return t<e?qs.create(t,e,48|s):qs.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let r=e[t];e.sort((i,s)=>i.from-s.from),t=e.indexOf(r);for(let i=1;i<e.length;i++){let s=e[i],o=e[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,u=Math.max(s.to,o.to);i<=t&&t--,e.splice(--i,2,s.anchor>s.head?te.range(u,a):te.range(a,u))}}return new te(e,t)}}function xk(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let m0=0;class ke{constructor(e,t,r,i,s){this.combine=e,this.compareInput=t,this.compare=r,this.isStatic=i,this.id=m0++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new ke(e.combine||(t=>t),e.compareInput||((t,r)=>t===r),e.compare||(e.combine?(t,r)=>t===r:g0),!!e.static,e.enables)}of(e){return new yf([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new yf(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new yf(e,this,2,t)}from(e,t){return t||(t=r=>r),this.compute([e],r=>t(r.field(e)))}}function g0(n,e){return n==e||n.length==e.length&&n.every((t,r)=>t===e[r])}class yf{constructor(e,t,r,i){this.dependencies=e,this.facet=t,this.type=r,this.value=i,this.id=m0++}dynamicSlot(e){var t;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,u=!1,f=!1,h=[];for(let p of this.dependencies)p=="doc"?u=!0:p=="selection"?f=!0:(((t=e[p.id])!==null&&t!==void 0?t:1)&1)==0&&h.push(e[p.id]);return{create(p){return p.values[o]=r(p),1},update(p,g){if(u&&g.docChanged||f&&(g.docChanged||g.selection)||Km(p,h)){let y=r(p);if(a?!q1(y,p.values[o],i):!i(y,p.values[o]))return p.values[o]=y,1}return 0},reconfigure:(p,g)=>{let y,x=g.config.address[s];if(x!=null){let w=Bf(g,x);if(this.dependencies.every(C=>C instanceof ke?g.facet(C)===p.facet(C):C instanceof un?g.field(C,!1)==p.field(C,!1):!0)||(a?q1(y=r(p),w,i):i(y=r(p),w)))return p.values[o]=w,0}else y=r(p);return p.values[o]=y,1}}}}function q1(n,e,t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!t(n[r],e[r]))return!1;return!0}function Km(n,e){let t=!1;for(let r of e)Ea(n,r)&1&&(t=!0);return t}function D8(n,e,t){let r=t.map(u=>n[u.id]),i=t.map(u=>u.type),s=r.filter(u=>!(u&1)),o=n[e.id]>>1;function a(u){let f=[];for(let h=0;h<r.length;h++){let p=Bf(u,r[h]);if(i[h]==2)for(let g of p)f.push(g);else f.push(p)}return e.combine(f)}return{create(u){for(let f of r)Ea(u,f);return u.values[o]=a(u),1},update(u,f){if(!Km(u,s))return 0;let h=a(u);return e.compare(h,u.values[o])?0:(u.values[o]=h,1)},reconfigure(u,f){let h=Km(u,r),p=f.config.facets[e.id],g=f.facet(e);if(p&&!h&&g0(t,p))return u.values[o]=g,0;let y=a(u);return e.compare(y,g)?(u.values[o]=g,0):(u.values[o]=y,1)}}}const zu=ke.define({static:!0});class un{constructor(e,t,r,i,s){this.id=e,this.createF=t,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let t=new un(m0++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(zu).find(r=>r.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:r=>(r.values[t]=this.create(r),1),update:(r,i)=>{let s=r.values[t],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[t]=o,1)},reconfigure:(r,i)=>{let s=r.facet(zu),o=i.facet(zu),a;return(a=s.find(u=>u.field==this))&&a!=o.find(u=>u.field==this)?(r.values[t]=a.create(r),1):i.config.address[this.id]!=null?(r.values[t]=i.field(this),0):(r.values[t]=this.create(r),1)}}}init(e){return[this,zu.of({field:this,create:e})]}get extension(){return this}}const Hs={lowest:4,low:3,default:2,high:1,highest:0};function ca(n){return e=>new wk(e,n)}const ws={highest:ca(Hs.highest),high:ca(Hs.high),default:ca(Hs.default),low:ca(Hs.low),lowest:ca(Hs.lowest)};class wk{constructor(e,t){this.inner=e,this.prec=t}}class Pd{of(e){return new Qm(this,e)}reconfigure(e){return Pd.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Qm{constructor(e,t){this.compartment=e,this.inner=t}}class jf{constructor(e,t,r,i,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,r){let i=[],s=Object.create(null),o=new Map;for(let g of I8(e,t,o))g instanceof un?i.push(g):(s[g.facet.id]||(s[g.facet.id]=[])).push(g);let a=Object.create(null),u=[],f=[];for(let g of i)a[g.id]=f.length<<1,f.push(y=>g.slot(y));let h=r==null?void 0:r.config.facets;for(let g in s){let y=s[g],x=y[0].facet,w=h&&h[g]||[];if(y.every(C=>C.type==0))if(a[x.id]=u.length<<1|1,g0(w,y))u.push(r.facet(x));else{let C=x.combine(y.map(E=>E.value));u.push(r&&x.compare(C,r.facet(x))?r.facet(x):C)}else{for(let C of y)C.type==0?(a[C.id]=u.length<<1|1,u.push(C.value)):(a[C.id]=f.length<<1,f.push(E=>C.dynamicSlot(E)));a[x.id]=f.length<<1,f.push(C=>D8(C,x,y))}}let p=f.map(g=>g(a));return new jf(e,o,p,a,u,s)}}function I8(n,e,t){let r=[[],[],[],[],[]],i=new Map;function s(o,a){let u=i.get(o);if(u!=null){if(u<=a)return;let f=r[u].indexOf(o);f>-1&&r[u].splice(f,1),o instanceof Qm&&t.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let f of o)s(f,a);else if(o instanceof Qm){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let f=e.get(o.compartment)||o.inner;t.set(o.compartment,f),s(f,a)}else if(o instanceof wk)s(o.inner,o.prec);else if(o instanceof un)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof yf)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,Hs.default);else{let f=o.extension;if(!f)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(f,a)}}return s(n,Hs.default),r.reduce((o,a)=>o.concat(a))}function Ea(n,e){if(e&1)return 2;let t=e>>1,r=n.status[t];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;n.status[t]=4;let i=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|i}function Bf(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const bk=ke.define(),Gm=ke.define({combine:n=>n.some(e=>e),static:!0}),Sk=ke.define({combine:n=>n.length?n[0]:void 0,static:!0}),kk=ke.define(),Ck=ke.define(),Ek=ke.define(),Rk=ke.define({combine:n=>n.length?n[0]:!1});class Li{constructor(e,t){this.type=e,this.value=t}static define(){return new j8}}class j8{of(e){return new Li(this,e)}}class B8{constructor(e){this.map=e}of(e){return new He(this,e)}}class He{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new He(this.type,t)}is(e){return this.type==e}static define(e={}){return new B8(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(t);s&&r.push(s)}return r}}He.reconfigure=He.define();He.appendConfig=He.define();class Gt{constructor(e,t,r,i,s,o){this.startState=e,this.changes=t,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&xk(r,t.newLength),s.some(a=>a.type==Gt.time)||(this.annotations=s.concat(Gt.time.of(Date.now())))}static create(e,t,r,i,s,o){return new Gt(e,t,r,i,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 t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Gt.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Gt.time=Li.define();Gt.userEvent=Li.define();Gt.addToHistory=Li.define();Gt.remote=Li.define();function F8(n,e){let t=[];for(let r=0,i=0;;){let s,o;if(r<n.length&&(i==e.length||e[i]>=n[r]))s=n[r++],o=n[r++];else if(i<e.length)s=e[i++],o=e[i++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Tk(n,e,t){var r;let i,s,o;return t?(i=e.changes,s=Kt.empty(e.changes.length),o=n.changes.compose(e.changes)):(i=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(s):(r=n.selection)===null||r===void 0?void 0:r.map(i),effects:He.mapEffects(n.effects,i).concat(He.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function Ym(n,e,t){let r=e.selection,i=Uo(e.annotations);return e.userEvent&&(i=i.concat(Gt.userEvent.of(e.userEvent))),{changes:e.changes instanceof Kt?e.changes:Kt.of(e.changes||[],t,n.facet(Sk)),selection:r&&(r instanceof te?r:te.single(r.anchor,r.head)),effects:Uo(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function Mk(n,e,t){let r=Ym(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;r=Tk(r,Ym(n,e[s],o?r.changes.newLength:n.doc.length),o)}let i=Gt.create(n,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return _8(t?z8(i):i)}function z8(n){let e=n.startState,t=!0;for(let i of e.facet(kk)){let s=i(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:F8(t,s))}if(t!==!0){let i,s;if(t===!1)s=n.changes.invertedDesc,i=Kt.empty(e.doc.length);else{let o=n.changes.filter(t);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=Gt.create(e,i,n.selection&&n.selection.map(s),He.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let r=e.facet(Ck);for(let i=r.length-1;i>=0;i--){let s=r[i](n);s instanceof Gt?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Gt?n=s[0]:n=Mk(e,Uo(s),!1)}return n}function _8(n){let e=n.startState,t=e.facet(Ek),r=n;for(let i=t.length-1;i>=0;i--){let s=t[i](n);s&&Object.keys(s).length&&(r=Tk(r,Ym(e,s,n.changes.newLength),!0))}return r==n?n:Gt.create(e,n.changes,n.selection,r.effects,r.annotations,r.scrollIntoView)}const V8=[];function Uo(n){return n==null?V8:Array.isArray(n)?n:[n]}var kt=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(kt||(kt={}));const W8=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Xm;try{Xm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function $8(n){if(Xm)return Xm.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||W8.test(t)))return!0}return!1}function H8(n){return e=>{if(!/\S/.test(e))return kt.Space;if($8(e))return kt.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return kt.Word;return kt.Other}}class nt{constructor(e,t,r,i,s,o){this.config=e,this.doc=t,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Ea(this,a<<1);this.computeSlot=null}field(e,t=!0){let r=this.config.address[e.id];if(r==null){if(t)throw new RangeError("Field is not present in this state");return}return Ea(this,r),Bf(this,r)}update(...e){return Mk(this,e,!0)}applyTransaction(e){let t=this.config,{base:r,compartments:i}=t;for(let a of e.effects)a.is(Pd.reconfigure)?(t&&(i=new Map,t.compartments.forEach((u,f)=>i.set(f,u)),t=null),i.set(a.value.compartment,a.value.extension)):a.is(He.reconfigure)?(t=null,r=a.value):a.is(He.appendConfig)&&(t=null,r=Uo(r).concat(a.value));let s;t?s=e.startState.values.slice():(t=jf.resolve(r,i,this),s=new nt(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(u,f)=>f.reconfigure(u,this),null).values);let o=e.startState.facet(Gm)?e.newSelection:e.newSelection.asSingle();new nt(t,e.newDoc,o,s,(a,u)=>u.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:te.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,r=e(t.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Uo(r.effects);for(let a=1;a<t.ranges.length;a++){let u=e(t.ranges[a]),f=this.changes(u.changes),h=f.map(i);for(let g=0;g<a;g++)s[g]=s[g].map(h);let p=i.mapDesc(f,!0);s.push(u.range.map(p)),i=i.compose(h),o=He.mapEffects(o,h).concat(He.mapEffects(Uo(u.effects),p))}return{changes:i,selection:te.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Kt?e:Kt.of(e,this.doc.length,this.facet(nt.lineSeparator))}toText(e){return lt.of(e.split(this.facet(nt.lineSeparator)||Hm))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ea(this,t),Bf(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof un&&this.config.address[i.id]!=null&&(t[r]=i.spec.toJSON(this.field(e[r]),this))}return t}static fromJSON(e,t={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],a=e[s];i.push(o.init(u=>o.spec.fromJSON(a,u)))}}return nt.create({doc:e.doc,selection:te.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=jf.resolve(e.extensions||[],new Map),r=e.doc instanceof lt?e.doc:lt.of((e.doc||"").split(t.staticFacet(nt.lineSeparator)||Hm)),i=e.selection?e.selection instanceof te?e.selection:te.single(e.selection.anchor,e.selection.head):te.single(0);return xk(i,r.length),t.staticFacet(Gm)||(i=i.asSingle()),new nt(t,r,i,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(nt.tabSize)}get lineBreak(){return this.facet(nt.lineSeparator)||`
`}get readOnly(){return this.facet(Rk)}phrase(e,...t){for(let r of this.facet(nt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>t.length?r:t[s-1]})),e}languageDataAt(e,t,r=-1){let i=[];for(let s of this.facet(bk))for(let o of s(this,t,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return H8(t.length?t[0]:"")}wordAt(e){let{text:t,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,a=e-r;for(;o>0;){let u=Qt(t,o,!1);if(s(t.slice(u,o))!=kt.Word)break;o=u}for(;a<i;){let u=Qt(t,a);if(s(t.slice(a,u))!=kt.Word)break;a=u}return o==a?null:te.range(o+r,a+r)}}nt.allowMultipleSelections=Gm;nt.tabSize=ke.define({combine:n=>n.length?n[0]:4});nt.lineSeparator=Sk;nt.readOnly=Rk;nt.phrases=ke.define({compare(n,e){let t=Object.keys(n),r=Object.keys(e);return t.length==r.length&&t.every(i=>n[i]==e[i])}});nt.languageData=bk;nt.changeFilter=kk;nt.transactionFilter=Ck;nt.transactionExtender=Ek;Pd.reconfigure=He.define();function si(n,e,t={}){let r={};for(let i of n)for(let s of Object.keys(i)){let o=i[s],a=r[s];if(a===void 0)r[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,s))r[s]=t[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class ds{eq(e){return this==e}range(e,t=e){return Jm.create(e,t,this)}}ds.prototype.startSide=ds.prototype.endSide=0;ds.prototype.point=!1;ds.prototype.mapMode=bn.TrackDel;function y0(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let Jm=class Ok{constructor(e,t,r){this.from=e,this.to=t,this.value=r}static create(e,t,r){return new Ok(e,t,r)}};function Zm(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class v0{constructor(e,t,r,i){this.from=e,this.to=t,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,r,i=0){let s=r?this.to:this.from;for(let o=i,a=s.length;;){if(o==a)return o;let u=o+a>>1,f=s[u]-e||(r?this.value[u].endSide:this.value[u].startSide)-t;if(u==o)return f>=0?o:a;f>=0?a=u:o=u+1}}between(e,t,r,i){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(r,1e9,!1,s);s<o;s++)if(i(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let r=[],i=[],s=[],o=-1,a=-1;for(let u=0;u<this.value.length;u++){let f=this.value[u],h=this.from[u]+e,p=this.to[u]+e,g,y;if(h==p){let x=t.mapPos(h,f.startSide,f.mapMode);if(x==null||(g=y=x,f.startSide!=f.endSide&&(y=t.mapPos(h,f.endSide),y<g)))continue}else if(g=t.mapPos(h,f.startSide),y=t.mapPos(p,f.endSide),g>y||g==y&&f.startSide>0&&f.endSide<=0)continue;(y-g||f.endSide-f.startSide)<0||(o<0&&(o=g),f.point&&(a=Math.max(a,y-g)),r.push(f),i.push(g-o),s.push(y-o))}return{mapped:r.length?new v0(i,s,r,a):null,pos:o}}}class Ze{constructor(e,t,r,i){this.chunkPos=e,this.chunk=t,this.nextLayer=r,this.maxPoint=i}static create(e,t,r,i){return new Ze(e,t,r,i)}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 t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(r&&(t=t.slice().sort(Zm)),this.isEmpty)return t.length?Ze.of(t):this;let a=new Pk(this,null,-1).goto(0),u=0,f=[],h=new Oi;for(;a.value||u<t.length;)if(u<t.length&&(a.from-t[u].from||a.startSide-t[u].value.startSide)>=0){let p=t[u++];h.addInner(p.from,p.to,p.value)||f.push(p)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(u==t.length||this.chunkEnd(a.chunkIndex)<t[u].from)&&(!o||i>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&h.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!o||i>a.to||s<a.from||o(a.from,a.to,a.value))&&(h.addInner(a.from,a.to,a.value)||f.push(Jm.create(a.from,a.to,a.value))),a.next());return h.finishInner(this.nextLayer.isEmpty&&!f.length?Ze.empty:this.nextLayer.update({add:f,filter:o,filterFrom:i,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],r=[],i=-1;for(let o=0;o<this.chunk.length;o++){let a=this.chunkPos[o],u=this.chunk[o],f=e.touchesRange(a,a+u.length);if(f===!1)i=Math.max(i,u.maxPoint),t.push(u),r.push(e.mapPos(a));else if(f===!0){let{mapped:h,pos:p}=u.map(a,e);h&&(i=Math.max(i,h.maxPoint),t.push(h),r.push(p))}}let s=this.nextLayer.map(e);return t.length==0?s:new Ze(r,t,s||Ze.empty,i)}between(e,t,r){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],o=this.chunk[i];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,r)===!1)return}this.nextLayer.between(e,t,r)}}iter(e=0){return Ba.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ba.from(e).goto(t)}static compare(e,t,r,i,s=-1){let o=e.filter(p=>p.maxPoint>0||!p.isEmpty&&p.maxPoint>=s),a=t.filter(p=>p.maxPoint>0||!p.isEmpty&&p.maxPoint>=s),u=K1(o,a,r),f=new ua(o,u,s),h=new ua(a,u,s);r.iterGaps((p,g,y)=>Q1(f,p,h,g,y,i)),r.empty&&r.length==0&&Q1(f,0,h,0,0,i)}static eq(e,t,r=0,i){i==null&&(i=999999999);let s=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=K1(s,o),u=new ua(s,a,0).goto(r),f=new ua(o,a,0).goto(r);for(;;){if(u.to!=f.to||!eg(u.active,f.active)||u.point&&(!f.point||!y0(u.point,f.point)))return!1;if(u.to>i)return!0;u.next(),f.next()}}static spans(e,t,r,i,s=-1){let o=new ua(e,null,s).goto(t),a=t,u=o.openStart;for(;;){let f=Math.min(o.to,r);if(o.point){let h=o.activeForPoint(o.to),p=o.pointFrom<t?h.length+1:o.point.startSide<0?h.length:Math.min(h.length,u);i.point(a,f,o.point,h,p,o.pointRank),u=Math.min(o.openEnd(f),h.length)}else f>a&&(i.span(a,f,o.active,u),u=o.openEnd(f));if(o.to>r)return u+(o.point&&o.to>r?1:0);a=o.to,o.next()}}static of(e,t=!1){let r=new Oi;for(let i of e instanceof Jm?[e]:t?U8(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Ze.empty;let t=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Ze.empty;i=i.nextLayer)t=new Ze(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}Ze.empty=new Ze([],[],null,-1);function U8(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let r=n[t];if(Zm(e,r)>0)return n.slice().sort(Zm);e=r}return n}Ze.empty.nextLayer=Ze.empty;class Oi{finishChunk(e){this.chunks.push(new v0(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,t,r){this.addInner(e,t,r)||(this.nextLayer||(this.nextLayer=new Oi)).add(e,t,r)}addInner(e,t,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=t,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let r=t.value.length-1;return this.last=t.value[r],this.lastFrom=t.from[r]+e,this.lastTo=t.to[r]+e,!0}finish(){return this.finishInner(Ze.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Ze.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function K1(n,e,t){let r=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&r.set(s.chunk[o],s.chunkPos[o]);let i=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let a=r.get(s.chunk[o]);a!=null&&(t?t.mapPos(a):a)==s.chunkPos[o]&&!(t!=null&&t.touchesRange(a,a+s.chunk[o].length))&&i.add(s.chunk[o])}return i}class Pk{constructor(e,t,r,i=0){this.layer=e,this.skip=t,this.minPoint=r,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,r){for(;this.chunkIndex<this.layer.chunk.length;){let i=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(i)||this.layer.chunkEnd(this.chunkIndex)<e||i.maxPoint<this.minPoint))break;this.chunkIndex++,r=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!r||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!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],t=this.layer.chunk[this.chunkIndex],r=e+t.from[this.rangeIndex];if(this.from=r,this.to=e+t.to[this.rangeIndex],this.value=t.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 Ba{constructor(e){this.heap=e}static from(e,t=null,r=-1){let i=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=r&&i.push(new Pk(o,t,r,s));return i.length==1?i[0]:new Ba(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let r of this.heap)r.goto(e,t);for(let r=this.heap.length>>1;r>=0;r--)Kp(this.heap,r);return this.next(),this}forward(e,t){for(let r of this.heap)r.forward(e,t);for(let r=this.heap.length>>1;r>=0;r--)Kp(this.heap,r);(this.to-e||this.value.endSide-t)<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(),Kp(this.heap,0)}}}function Kp(n,e){for(let t=n[e];;){let r=(e<<1)+1;if(r>=n.length)break;let i=n[r];if(r+1<n.length&&i.compare(n[r+1])>=0&&(i=n[r+1],r++),t.compare(i)<0)break;n[r]=t,n[e]=i,e=r}}class ua{constructor(e,t,r){this.minPoint=r,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=Ba.from(e,t,r)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){_u(this.active,e),_u(this.activeTo,e),_u(this.activeRank,e),this.minActive=G1(this.active,this.activeTo)}addActive(e){let t=0,{value:r,to:i,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||i-this.activeTo[t])>0;)t++;Vu(this.active,t,r),Vu(this.activeTo,t,i),Vu(this.activeRank,t,s),e&&Vu(e,t,this.cursor.from),this.minActive=G1(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&_u(r,i)}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(r),this.cursor.next();else if(t&&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(r){this.openStart=0;for(let i=r.length-1;i>=0&&r[i]<e;i--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let r=this.active.length-1;r>=0&&!(this.activeRank[r]<this.pointRank);r--)(this.activeTo[r]>e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&t.push(this.active[r]);return t.reverse()}openEnd(e){let t=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)t++;return t}}function Q1(n,e,t,r,i,s){n.goto(e),t.goto(r);let o=r+i,a=r,u=r-e,f=!!s.boundChange;for(let h=!1;;){let p=n.to+u-t.to,g=p||n.endSide-t.endSide,y=g<0?n.to+u:t.to,x=Math.min(y,o);if(n.point||t.point?(n.point&&t.point&&y0(n.point,t.point)&&eg(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(a,x,n.point,t.point),h=!1):(h&&s.boundChange(a),x>a&&!eg(n.active,t.active)&&s.compareRange(a,x,n.active,t.active),f&&x<o&&(p||n.openEnd(y)!=t.openEnd(y))&&(h=!0)),y>o)break;a=y,g<=0&&n.next(),g>=0&&t.next()}}function eg(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!y0(n[t],e[t]))return!1;return!0}function _u(n,e){for(let t=e,r=n.length-1;t<r;t++)n[t]=n[t+1];n.pop()}function Vu(n,e,t){for(let r=n.length-1;r>=e;r--)n[r+1]=n[r];n[e]=t}function G1(n,e){let t=-1,r=1e9;for(let i=0;i<e.length;i++)(e[i]-r||n[i].endSide-n[t].endSide)<0&&(t=i,r=e[i]);return t}function yl(n,e,t=n.length){let r=0;for(let i=0;i<t&&i<n.length;)n.charCodeAt(i)==9?(r+=e-r%e,i++):(r++,i=Qt(n,i));return r}function tg(n,e,t,r){for(let i=0,s=0;;){if(s>=e)return i;if(i==n.length)break;s+=n.charCodeAt(i)==9?t-s%t:1,i=Qt(n,i)}return r===!0?-1:n.length}const ng="ͼ",Y1=typeof Symbol>"u"?"__"+ng:Symbol.for(ng),rg=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),X1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class hs{constructor(e,t){this.rules=[];let{finish:r}=t||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,u,f){let h=[],p=/^@(\w+)\b/.exec(o[0]),g=p&&p[1]=="keyframes";if(p&&a==null)return u.push(o[0]+";");for(let y in a){let x=a[y];if(/&/.test(y))s(y.split(/,\s*/).map(w=>o.map(C=>w.replace(/&/,C))).reduce((w,C)=>w.concat(C)),x,u);else if(x&&typeof x=="object"){if(!p)throw new RangeError("The value of a property ("+y+") should be a primitive value.");s(i(y),x,h,g)}else x!=null&&h.push(y.replace(/_.*/,"").replace(/[A-Z]/g,w=>"-"+w.toLowerCase())+": "+x+";")}(h.length||g)&&u.push((r&&!p&&!f?o.map(r):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=X1[Y1]||1;return X1[Y1]=e+1,ng+e.toString(36)}static mount(e,t,r){let i=e[rg],s=r&&r.nonce;i?s&&i.setNonce(s):i=new q8(e,s),i.mount(Array.isArray(t)?t:[t],e)}}let J1=new Map;class q8{constructor(e,t){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=J1.get(r);if(s)return e[rg]=s;this.sheet=new i.CSSStyleSheet,J1.set(r,this)}else this.styleTag=r.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[rg]=this}mount(e,t){let r=this.sheet,i=0,s=0;for(let o=0;o<e.length;o++){let a=e[o],u=this.modules.indexOf(a);if(u<s&&u>-1&&(this.modules.splice(u,1),s--,u=-1),u==-1){if(this.modules.splice(s++,0,a),r)for(let f=0;f<a.rules.length;f++)r.insertRule(a.rules[f],i++)}else{for(;s<u;)i+=this.modules[s++].rules.length;i+=a.rules.length,s++}}if(r)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let u=0;u<this.modules.length;u++)o+=this.modules[u].getRules()+`
`;this.styleTag.textContent=o;let a=t.head||t;this.styleTag.parentNode!=a&&a.insertBefore(this.styleTag,a.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var ps={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:"'"},Fa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},K8=typeof navigator<"u"&&/Mac/.test(navigator.platform),Q8=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var an=0;an<10;an++)ps[48+an]=ps[96+an]=String(an);for(var an=1;an<=24;an++)ps[an+111]="F"+an;for(var an=65;an<=90;an++)ps[an]=String.fromCharCode(an+32),Fa[an]=String.fromCharCode(an);for(var Qp in ps)Fa.hasOwnProperty(Qp)||(Fa[Qp]=ps[Qp]);function G8(n){var e=K8&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Q8&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Fa:ps)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function dt(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var i=t[r];typeof i=="string"?n.setAttribute(r,i):i!=null&&(n[r]=i)}e++}for(;e<arguments.length;e++)Ak(n,arguments[e]);return n}function Ak(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Ak(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}let wn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},ig=typeof document<"u"?document:{documentElement:{style:{}}};const sg=/Edge\/(\d+)/.exec(wn.userAgent),Nk=/MSIE \d/.test(wn.userAgent),og=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wn.userAgent),Ad=!!(Nk||og||sg),Z1=!Ad&&/gecko\/(\d+)/i.test(wn.userAgent),Gp=!Ad&&/Chrome\/(\d+)/.exec(wn.userAgent),Y8="webkitFontSmoothing"in ig.documentElement.style,lg=!Ad&&/Apple Computer/.test(wn.vendor),ew=lg&&(/Mobile\/\w+/.test(wn.userAgent)||wn.maxTouchPoints>2);var Se={mac:ew||/Mac/.test(wn.platform),windows:/Win/.test(wn.platform),linux:/Linux|X11/.test(wn.platform),ie:Ad,ie_version:Nk?ig.documentMode||6:og?+og[1]:sg?+sg[1]:0,gecko:Z1,gecko_version:Z1?+(/Firefox\/(\d+)/.exec(wn.userAgent)||[0,0])[1]:0,chrome:!!Gp,chrome_version:Gp?+Gp[1]:0,ios:ew,android:/Android\b/.test(wn.userAgent),webkit_version:Y8?+(/\bAppleWebKit\/(\d+)/.exec(wn.userAgent)||[0,0])[1]:0,safari:lg,safari_version:lg?+(/\bVersion\/(\d+(\.\d+)?)/.exec(wn.userAgent)||[0,0])[1]:0,tabSize:ig.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function x0(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Ff=Object.create(null);function w0(n,e,t){if(n==e)return!0;n||(n=Ff),e||(e=Ff);let r=Object.keys(n),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=t&&(i.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function X8(n,e){for(let t=n.attributes.length-1;t>=0;t--){let r=n.attributes[t].name;e[r]==null&&n.removeAttribute(r)}for(let t in e){let r=e[t];t=="style"?n.style.cssText=r:n.getAttribute(t)!=r&&n.setAttribute(t,r)}}function tw(n,e,t){let r=!1;if(e)for(let i in e)t&&i in t||(r=!0,i=="style"?n.style.cssText="":n.removeAttribute(i));if(t)for(let i in t)e&&e[i]==t[i]||(r=!0,i=="style"?n.style.cssText=t[i]:n.setAttribute(i,t[i]));return r}function J8(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let r=n.attributes[t];e[r.name]=r.value}return e}class oi{eq(e){return!1}updateDOM(e,t){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,t,r){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var cn=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(cn||(cn={}));class De extends ds{constructor(e,t,r,i){super(),this.startSide=e,this.endSide=t,this.widget=r,this.spec=i}get heightRelevant(){return!1}static mark(e){return new hc(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),r=!!e.block;return t+=r&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new ro(e,t,t,r,e.widget||null,!1)}static replace(e){let t=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=Lk(e,t);r=(s?t?-3e8:-1:5e8)-1,i=(o?t?2e8:1:-6e8)+1}return new ro(e,r,i,t,e.widget||null,!0)}static line(e){return new pc(e)}static set(e,t=!1){return Ze.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}De.none=Ze.empty;class hc extends De{constructor(e){let{start:t,end:r}=Lk(e);super(t?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?x0(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ff}eq(e){return this==e||e instanceof hc&&this.tagName==e.tagName&&w0(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}hc.prototype.point=!1;class pc extends De{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof pc&&this.spec.class==e.spec.class&&w0(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}pc.prototype.mapMode=bn.TrackBefore;pc.prototype.point=!0;class ro extends De{constructor(e,t,r,i,s,o){super(t,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?t<=0?bn.TrackBefore:bn.TrackAfter:bn.TrackDel}get type(){return this.startSide!=this.endSide?cn.WidgetRange:this.startSide<=0?cn.WidgetBefore:cn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof ro&&Z8(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}ro.prototype.point=!0;function Lk(n,e=!1){let{inclusiveStart:t,inclusiveEnd:r}=n;return t==null&&(t=n.inclusive),r==null&&(r=n.inclusive),{start:t??e,end:r??e}}function Z8(n,e){return n==e||!!(n&&e&&n.compare(e))}function qo(n,e,t,r=0){let i=t.length-1;i>=0&&t[i]+r>=n?t[i]=Math.max(t[i],e):t.push(n,e)}class za extends ds{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof za&&this.tagName==e.tagName&&w0(this.attributes,e.attributes)}static create(e){return new za(e.tagName,e.attributes||Ff)}static set(e,t=!1){return Ze.of(e,t)}}za.prototype.startSide=za.prototype.endSide=-1;function _a(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function ag(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function vf(n,e){if(!e.anchorNode)return!1;try{return ag(n,e.anchorNode)}catch{return!1}}function Ra(n){return n.nodeType==3?Wa(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Ta(n,e,t,r){return t?nw(n,e,t,r,-1)||nw(n,e,t,r,1):!1}function ms(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function zf(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function nw(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Pi(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=ms(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=i<0?Pi(n):0}else return!1}}function Pi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Va(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function eL(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Dk(n,e){let t=e.width/n.offsetWidth,r=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-n.offsetHeight)<1)&&(r=1),{scaleX:t,scaleY:r}}function tL(n,e,t,r,i,s,o,a){let u=n.ownerDocument,f=u.defaultView||window;for(let h=n,p=!1;h&&!p;)if(h.nodeType==1){let g,y=h==u.body,x=1,w=1;if(y)g=eL(f);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(p=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let T=h.getBoundingClientRect();({scaleX:x,scaleY:w}=Dk(h,T)),g={left:T.left,right:T.left+h.clientWidth*x,top:T.top,bottom:T.top+h.clientHeight*w}}let C=0,E=0;if(i=="nearest")e.top<g.top?(E=e.top-(g.top+o),t>0&&e.bottom>g.bottom+E&&(E=e.bottom-g.bottom+o)):e.bottom>g.bottom&&(E=e.bottom-g.bottom+o,t<0&&e.top-E<g.top&&(E=e.top-(g.top+o)));else{let T=e.bottom-e.top,M=g.bottom-g.top;E=(i=="center"&&T<=M?e.top+T/2-M/2:i=="start"||i=="center"&&t<0?e.top-o:e.bottom-M+o)-g.top}if(r=="nearest"?e.left<g.left?(C=e.left-(g.left+s),t>0&&e.right>g.right+C&&(C=e.right-g.right+s)):e.right>g.right&&(C=e.right-g.right+s,t<0&&e.left<g.left+C&&(C=e.left-(g.left+s))):C=(r=="center"?e.left+(e.right-e.left)/2-(g.right-g.left)/2:r=="start"==a?e.left-s:e.right-(g.right-g.left)+s)-g.left,C||E)if(y)f.scrollBy(C,E);else{let T=0,M=0;if(E){let P=h.scrollTop;h.scrollTop+=E/w,M=(h.scrollTop-P)*w}if(C){let P=h.scrollLeft;h.scrollLeft+=C/x,T=(h.scrollLeft-P)*x}e={left:e.left-T,top:e.top-M,right:e.right-T,bottom:e.bottom-M},T&&Math.abs(T-C)<1&&(r="nearest"),M&&Math.abs(M-E)<1&&(i="nearest")}if(y)break;(e.top<g.top||e.bottom>g.bottom||e.left<g.left||e.right>g.right)&&(e={left:Math.max(e.left,g.left),right:Math.min(e.right,g.right),top:Math.max(e.top,g.top),bottom:Math.min(e.bottom,g.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function nL(n){let e=n.ownerDocument,t,r;for(let i=n.parentNode;i&&!(i==e.body||t&&r);)if(i.nodeType==1)!r&&i.scrollHeight>i.clientHeight&&(r=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;return{x:t,y:r}}class rL{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:t,focusNode:r}=e;this.set(t,Math.min(e.anchorOffset,t?Pi(t):0),r,Math.min(e.focusOffset,r?Pi(r):0))}set(e,t,r,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=i}}let Ws=null;Se.safari&&Se.safari_version>=26&&(Ws=!1);function Ik(n){if(n.setActive)return n.setActive();if(Ws)return n.focus(Ws);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(Ws==null?{get preventScroll(){return Ws={preventScroll:!0},!0}}:void 0),!Ws){Ws=!1;for(let t=0;t<e.length;){let r=e[t++],i=e[t++],s=e[t++];r.scrollTop!=i&&(r.scrollTop=i),r.scrollLeft!=s&&(r.scrollLeft=s)}}}let rw;function Wa(n,e,t=e){let r=rw||(rw=document.createRange());return r.setEnd(n,t),r.setStart(n,e),r}function Ko(n,e,t,r){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,n.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,n.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function iL(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function sL(n,e){let t=e.focusNode,r=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=r)return!1;for(r=Math.min(r,Pi(t));;)if(r){if(t.nodeType!=1)return!1;let i=t.childNodes[r-1];i.contentEditable=="false"?r--:(t=i,r=Pi(t))}else{if(t==n)return!0;r=ms(t),t=t.parentNode}}function jk(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Bk(n,e){for(let t=n,r=e;;){if(t.nodeType==3&&r>0)return{node:t,offset:r};if(t.nodeType==1&&r>0){if(t.contentEditable=="false")return null;t=t.childNodes[r-1],r=Pi(t)}else if(t.parentNode&&!zf(t))r=ms(t),t=t.parentNode;else return null}}function Fk(n,e){for(let t=n,r=e;;){if(t.nodeType==3&&r<t.nodeValue.length)return{node:t,offset:r};if(t.nodeType==1&&r<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[r],r=0}else if(t.parentNode&&!zf(t))r=ms(t)+1,t=t.parentNode;else return null}}class Rr{constructor(e,t,r=!0){this.node=e,this.offset=t,this.precise=r}static before(e,t){return new Rr(e.parentNode,ms(e),t)}static after(e,t){return new Rr(e.parentNode,ms(e)+1,t)}}var pt=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(pt||(pt={}));const io=pt.LTR,b0=pt.RTL;function zk(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}const oL=zk("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),lL=zk("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),cg=Object.create(null),Wr=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);cg[e]=t,cg[t]=-e}function _k(n){return n<=247?oL[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?lL[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}const aL=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Si{get dir(){return this.level%2?b0:io}constructor(e,t,r){this.from=e,this.to=t,this.level=r}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,r,i){let s=-1;for(let o=0;o<e.length;o++){let a=e[o];if(a.from<=t&&a.to>=t){if(a.level==r)return o;(s<0||(i!=0?i<0?a.from<t:a.to>t:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Vk(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],i=e[t];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!Vk(r.inner,i.inner))return!1}return!0}const ht=[];function cL(n,e,t,r,i){for(let s=0;s<=r.length;s++){let o=s?r[s-1].to:e,a=s<r.length?r[s].from:t,u=s?256:i;for(let f=o,h=u,p=u;f<a;f++){let g=_k(n.charCodeAt(f));g==512?g=h:g==8&&p==4&&(g=16),ht[f]=g==4?2:g,g&7&&(p=g),h=g}for(let f=o,h=u,p=u;f<a;f++){let g=ht[f];if(g==128)f<a-1&&h==ht[f+1]&&h&24?g=ht[f]=h:ht[f]=256;else if(g==64){let y=f+1;for(;y<a&&ht[y]==64;)y++;let x=f&&h==8||y<t&&ht[y]==8?p==1?1:8:256;for(let w=f;w<y;w++)ht[w]=x;f=y-1}else g==8&&p==1&&(ht[f]=1);h=g,g&7&&(p=g)}}}function uL(n,e,t,r,i){let s=i==1?2:1;for(let o=0,a=0,u=0;o<=r.length;o++){let f=o?r[o-1].to:e,h=o<r.length?r[o].from:t;for(let p=f,g,y,x;p<h;p++)if(y=cg[g=n.charCodeAt(p)])if(y<0){for(let w=a-3;w>=0;w-=3)if(Wr[w+1]==-y){let C=Wr[w+2],E=C&2?i:C&4?C&1?s:i:0;E&&(ht[p]=ht[Wr[w]]=E),a=w;break}}else{if(Wr.length==189)break;Wr[a++]=p,Wr[a++]=g,Wr[a++]=u}else if((x=ht[p])==2||x==1){let w=x==i;u=w?0:1;for(let C=a-3;C>=0;C-=3){let E=Wr[C+2];if(E&2)break;if(w)Wr[C+2]|=2;else{if(E&4)break;Wr[C+2]|=4}}}}}function fL(n,e,t,r){for(let i=0,s=r;i<=t.length;i++){let o=i?t[i-1].to:n,a=i<t.length?t[i].from:e;for(let u=o;u<a;){let f=ht[u];if(f==256){let h=u+1;for(;;)if(h==a){if(i==t.length)break;h=t[i++].to,a=i<t.length?t[i].from:e}else if(ht[h]==256)h++;else break;let p=s==1,g=(h<e?ht[h]:r)==1,y=p==g?p?1:2:r;for(let x=h,w=i,C=w?t[w-1].to:n;x>u;)x==C&&(x=t[--w].from,C=w?t[w-1].to:n),ht[--x]=y;u=h}else s=f,u++}}}function ug(n,e,t,r,i,s,o){let a=r%2?2:1;if(r%2==i%2)for(let u=e,f=0;u<t;){let h=!0,p=!1;if(f==s.length||u<s[f].from){let w=ht[u];w!=a&&(h=!1,p=w==16)}let g=!h&&a==1?[]:null,y=h?r:r+1,x=u;e:for(;;)if(f<s.length&&x==s[f].from){if(p)break e;let w=s[f];if(!h)for(let C=w.to,E=f+1;;){if(C==t)break e;if(E<s.length&&s[E].from==C)C=s[E++].to;else{if(ht[C]==a)break e;break}}if(f++,g)g.push(w);else{w.from>u&&o.push(new Si(u,w.from,y));let C=w.direction==io!=!(y%2);fg(n,C?r+1:r,i,w.inner,w.from,w.to,o),u=w.to}x=w.to}else{if(x==t||(h?ht[x]!=a:ht[x]==a))break;x++}g?ug(n,u,x,r+1,i,g,o):u<x&&o.push(new Si(u,x,y)),u=x}else for(let u=t,f=s.length;u>e;){let h=!0,p=!1;if(!f||u>s[f-1].to){let w=ht[u-1];w!=a&&(h=!1,p=w==16)}let g=!h&&a==1?[]:null,y=h?r:r+1,x=u;e:for(;;)if(f&&x==s[f-1].to){if(p)break e;let w=s[--f];if(!h)for(let C=w.from,E=f;;){if(C==e)break e;if(E&&s[E-1].to==C)C=s[--E].from;else{if(ht[C-1]==a)break e;break}}if(g)g.push(w);else{w.to<u&&o.push(new Si(w.to,u,y));let C=w.direction==io!=!(y%2);fg(n,C?r+1:r,i,w.inner,w.from,w.to,o),u=w.from}x=w.from}else{if(x==e||(h?ht[x-1]!=a:ht[x-1]==a))break;x--}g?ug(n,x,u,r+1,i,g,o):x<u&&o.push(new Si(x,u,y)),u=x}}function fg(n,e,t,r,i,s,o){let a=e%2?2:1;cL(n,i,s,r,a),uL(n,i,s,r,a),fL(i,s,r,a),ug(n,i,s,e,t,r,o)}function dL(n,e,t){if(!n)return[new Si(0,0,e==b0?1:0)];if(e==io&&!t.length&&!aL.test(n))return Wk(n.length);if(t.length)for(;n.length>ht.length;)ht[ht.length]=256;let r=[],i=e==io?0:1;return fg(n,i,i,t,0,n.length,r),r}function Wk(n){return[new Si(0,n,0)]}let $k="";function hL(n,e,t,r,i){var s;let o=r.head-n.from,a=Si.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),u=e[a],f=u.side(i,t);if(o==f){let g=a+=i?1:-1;if(g<0||g>=e.length)return null;u=e[a=g],o=u.side(!i,t),f=u.side(i,t)}let h=Qt(n.text,o,u.forward(i,t));(h<u.from||h>u.to)&&(h=f),$k=n.text.slice(Math.min(o,h),Math.max(o,h));let p=a==(i?e.length-1:0)?null:e[a+(i?1:-1)];return p&&h==f&&p.level+(i?0:1)<u.level?te.cursor(p.side(!i,t)+n.from,p.forward(i,t)?1:-1,p.level):te.cursor(h+n.from,u.forward(i,t)?-1:1,u.level)}function pL(n,e,t){for(let r=e;r<t;r++){let i=_k(n.charCodeAt(r));if(i==1)return io;if(i==2||i==4)return b0}return io}const Hk=ke.define(),Uk=ke.define(),qk=ke.define(),Kk=ke.define(),dg=ke.define(),Qk=ke.define(),Gk=ke.define(),S0=ke.define(),k0=ke.define(),Yk=ke.define({combine:n=>n.some(e=>e)}),Xk=ke.define({combine:n=>n.some(e=>e)}),Jk=ke.define();class Qo{constructor(e,t="nearest",r="nearest",i=5,s=5,o=!1){this.range=e,this.y=t,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Qo(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 Qo(te.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Wu=He.define({map:(n,e)=>n.map(e)}),Zk=He.define();function In(n,e,t){let r=n.facet(Kk);r.length?r[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const bi=ke.define({combine:n=>n.length?n[0]:!0});let mL=0;const Fo=ke.define({combine(n){return n.filter((e,t)=>{for(let r=0;r<t;r++)if(n[r].plugin==e.plugin)return!1;return!0})}});class Bt{constructor(e,t,r,i,s){this.id=e,this.create=t,this.domEventHandlers=r,this.domEventObservers=i,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Fo.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Fo.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:r,eventObservers:i,provide:s,decorations:o}=t||{};return new Bt(mL++,e,r,i,a=>{let u=[];return o&&u.push($a.of(f=>{let h=f.plugin(a);return h?o(h):De.none})),s&&u.push(s(a)),u})}static fromClass(e,t){return Bt.define((r,i)=>new e(r,i),t)}}class Yp{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 t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(r){if(In(t.state,r,"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(t){In(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(r){In(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const eC=ke.define(),C0=ke.define(),$a=ke.define(),tC=ke.define(),nC=ke.define(),mc=ke.define(),rC=ke.define();function iw(n,e){let t=n.state.facet(rC);if(!t.length)return t;let r=t.map(s=>s instanceof Function?s(n):s),i=[];return Ze.spans(r,e.from,e.to,{point(){},span(s,o,a,u){let f=s-e.from,h=o-e.from,p=i;for(let g=a.length-1;g>=0;g--,u--){let y=a[g].spec.bidiIsolate,x;if(y==null&&(y=pL(e.text,f,h)),u>0&&p.length&&(x=p[p.length-1]).to==f&&x.direction==y)x.to=h,p=x.inner;else{let w={from:f,to:h,direction:y,inner:[]};p.push(w),p=w.inner}}}}),i}const iC=ke.define();function E0(n){let e=0,t=0,r=0,i=0;for(let s of n.state.facet(iC)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:t,top:r,bottom:i}}const ga=ke.define();class lr{constructor(e,t,r,i){this.fromA=e,this.toA=t,this.fromB=r,this.toB=i}join(e){return new lr(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 t=e.length,r=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>r.toA)){if(i.toA<r.fromA)break;r=r.join(i),e.splice(t-1,1)}}return e.splice(t,0,r),e}static extendWithRanges(e,t){if(t.length==0)return e;let r=[];for(let i=0,s=0,o=0;;){let a=i<e.length?e[i].fromB:1e9,u=s<t.length?t[s]:1e9,f=Math.min(a,u);if(f==1e9)break;let h=f+o,p=f,g=h;for(;;)if(s<t.length&&t[s]<=p){let y=t[s+1];s+=2,p=Math.max(p,y);for(let x=i;x<e.length&&e[x].fromB<=p;x++)o=e[x].toA-e[x].toB;g=Math.max(g,y+o)}else if(i<e.length&&e[i].fromB<=p){let y=e[i++];p=Math.max(p,y.toB),g=Math.max(g,y.toA),o=y.toA-y.toB}else break;r.push(new lr(h,g,f,p))}return r}}class _f{constructor(e,t,r){this.view=e,this.state=t,this.transactions=r,this.flags=0,this.startState=e.state,this.changes=Kt.empty(this.startState.doc.length);for(let s of r)this.changes=this.changes.compose(s.changes);let i=[];this.changes.iterChangedRanges((s,o,a,u)=>i.push(new lr(s,o,a,u))),this.changedRanges=i}static create(e,t,r){return new _f(e,t,r)}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 gL=[];class Yt{constructor(e,t,r=0){this.dom=e,this.length=t,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return gL}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 t=this.domAttrs;t&&X8(this.dom,t)}}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,t=this.posAtStart){let r=t;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let r=ms(this.dom),i=this.length?e>0:t>0;return new Rr(this.parent.dom,r+(i?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 Ld)return e;return null}static get(e){return e.cmTile}}class Nd extends Yt{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 t=this.dom,r=null,i,s=(e==null?void 0:e.node)==t?e:null,o=0;for(let a of this.children){if(a.sync(e),o+=a.length+a.breakAfter,i=r?r.nextSibling:t.firstChild,s&&i!=a.dom&&(s.written=!0),a.dom.parentNode==t)for(;i&&i!=a.dom;)i=sw(i);else t.insertBefore(a.dom,i);r=a.dom}for(i=r?r.nextSibling:t.firstChild,s&&i&&(s.written=!0);i;)i=sw(i);this.length=o}}function sw(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Ld extends Nd{constructor(e,t){super(t),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 t=Yt.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!t.length)return;r=r.parent,r.breakAfter&&s++,i=t.pop()}else{let o=r.children[i++];if(o instanceof us)t.push(i),r=o,i=0;else{let a=s+o.length,u=e(o,s);if(u!==void 0)return u;s=a+o.breakAfter}}}resolveBlock(e,t){let r,i=-1,s,o=-1;if(this.blockTiles((a,u)=>{let f=u+a.length;if(e>=u&&e<=f){if(a.isWidget()&&t>=-1&&t<=1){if(a.flags&32)return!0;a.flags&16&&(r=void 0)}(u<e||e==f&&(t<-1?a.length:a.covers(1)))&&(!r||!a.isWidget()&&r.isWidget())&&(r=a,i=e-u),(f>e||e==u&&(t>1?a.length:a.covers(-1)))&&(!s||!a.isWidget()&&s.isWidget())&&(s=a,o=e-u)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&t<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class us extends Nd{constructor(e,t){super(e),this.wrapper=t}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,t){let r=new us(t||document.createElement(e.tagName),e);return t||(r.flags|=4),r}}class rl extends Nd{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,r){let i=new rl(t||document.createElement("div"),e);return(!t||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,r){let i=null,s=-1,o=null,a=-1;function u(h,p){for(let g=0,y=0;g<h.children.length&&y<=p;g++){let x=h.children[g],w=y+x.length;w>=p&&(x.isComposite()?u(x,p-y):(!o||o.isHidden&&(t>0||r&&vL(o,x)))&&(w>p||x.flags&32)?(o=x,a=p-y):(y<p||x.flags&16&&!x.isHidden)&&(i=x,s=p-y)),y=w}}u(this,e);let f=(t<0?i:o)||i||o;return f?{tile:f,offset:f==i?s:a}:null}coordsIn(e,t){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t):yL(this)}domIn(e,t){let r=this.resolveInline(e,t);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Rr(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:t);let o=r.tile.parent,a=!1;for(let u of o.children){if(a)return new Rr(u.dom,0);u==r.tile&&(a=!0)}}return new Rr(this.dom,0)}}function yL(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Ra(e);return t[t.length-1]||null}function vL(n,e){let t=n.coordsIn(0,1),r=e.coordsIn(0,1);return t&&r&&r.top<t.bottom}class Ln extends Nd{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let r=new Ln(t||document.createElement(e.tagName),e);return t||(r.flags|=4),r}}class Ks extends Yt{constructor(e,t){super(e,t.length),this.text=t}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,t){let r=this.dom.nodeValue.length;e>r&&(e=r);let i=e,s=e,o=0;e==0&&t<0||e==r&&t>=0?Se.chrome||Se.gecko||(e?(i--,o=1):s<r&&(s++,o=-1)):t<0?i--:s<r&&s++;let a=Wa(this.dom,i,s).getClientRects();if(!a.length)return null;let u=a[(o?o<0:t>=0)?0:a.length-1];return Se.safari&&!o&&u.width==0&&(u=Array.prototype.find.call(a,f=>f.width)||u),o?Va(u,o<0):u||null}static of(e,t){let r=new Ks(t||document.createTextNode(e),e);return t||(r.flags|=2),r}}class il extends Yt{constructor(e,t,r,i){super(e,t,i),this.widget=r}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,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,r){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(r)return Va(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let u=a?s.length-1:0;o=s[u],!(e>0?u==0:u==s.length-1||o.top<o.bottom);u+=a?-1:1);return Va(o,!a)}}get overrideDOMText(){if(!this.length)return lt.empty;let{root:e}=this;if(!e)return lt.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,r,i,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new il(s,r,e,i)}}class Vf extends Yt{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!1}get overrideDOMText(){return lt.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class xL{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,r){let{tile:i,index:s,beforeBreak:o,parents:a}=this;for(;e||t>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!a.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=a.pop(),s++}else{let u=i.children[s],f=u.breakAfter;(t>0?u.length<=e:u.length<e)&&(!r||r.skip(u,0,u.length)!==!1||!u.isComposite)?(o=!!f,s++,e-=u.length):(a.push({tile:i,index:s}),i=u,s=0,r&&u.isComposite()&&r.enter(u))}else if(s==i.length)o=!!i.breakAfter,{tile:i,index:s}=a.pop(),s++;else if(e){let u=Math.min(e,i.length-s);r&&r.skip(i,s,s+u),e-=u,s+=u}else break;return this.tile=i,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class wL{constructor(e,t,r,i){this.from=e,this.to=t,this.wrapper=r,this.rank=i}}class bL{constructor(e,t,r){this.cache=e,this.root=t,this.blockWrappers=r,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,r,i){var s;this.flushBuffer();let o=this.ensureMarks(t,r),a=o.lastChild;if(a&&a.isText()&&!(a.flags&8)){this.cache.reused.set(a,2);let u=o.children[o.children.length-1]=new Ks(a.dom,a.text+e);u.parent=o}else o.append(i||Ks.of(e,(s=this.cache.find(Ks))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let r=this.curLine;r.dom!=t.line.dom&&(r.setDOM(this.cache.reused.has(t.line)?Xp(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let i=r;for(let o=t.marks.length-1;o>=0;o--){let a=t.marks[o],u=i.lastChild;if(u instanceof Ln&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(Xp(a.dom)),i=u;else{if(this.cache.reused.get(a)){let h=Yt.get(a.dom);h&&h.setDOM(Xp(a.dom))}let f=Ln.of(a.mark,a.dom);i.append(f),i=f}this.cache.reused.set(a,2)}let s=new Ks(e.text,e.text.nodeValue);s.flags|=8,i.append(s)}addInlineWidget(e,t,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(t,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,r){this.flushBuffer(),this.ensureMarks(t,r).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 t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var r;e||(e=sC);let i=rl.start(e,t||((r=this.cache.find(rl))===null||r===void 0?void 0:r.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}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,t){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],a;if(t>0&&(a=i.lastChild)&&a instanceof Ln&&a.mark.eq(o))i=a,t--;else{let u=Ln.of(o,(r=this.cache.find(Ln,f=>f.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(u),i=u,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ow(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Se.ios&&ow(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Jp,0,32)||new il(Jp.toDOM(),0,Jp,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 t=new wL(e.from,e.to,e.value,e.rank),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-t.rank||this.wrappers[r-1].to-t.to)<0;)r--;this.wrappers.splice(r,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let r of this.wrappers){let i=t.lastChild;if(r.from<this.pos&&i instanceof us&&i.wrapper.eq(r.wrapper))t=i;else{let s=us.of(r.wrapper,(e=this.cache.find(us,o=>o.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),r=this.cache.find(Vf,void 0,1);return r&&(r.flags=t),r||new Vf(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class SL{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:i,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=i;let a=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,a)}let t=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,t);return this.textOff=t,r}}const Wf=[il,rl,Ks,Ln,Vf,us,Ld];for(let n=0;n<Wf.length;n++)Wf[n].bucket=n;class kL{constructor(e){this.view=e,this.buckets=Wf.map(()=>[]),this.index=Wf.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,r=this.buckets[t];r.length<6?r.push(e):r[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let a=s.length-1;a>=0;a--){let u=(a+o)%s.length,f=s[u];if((!t||t(f))&&!this.reused.has(f))return s.splice(u,1),u<o&&this.index[i]--,this.reused.set(f,r),f}return null}findWidget(e,t,r){let i=this.buckets[0];if(i.length)for(let s=0,o=0;;s++){if(s==i.length){if(o)return null;o=1,s=0}let a=i[s];if(!this.reused.has(a)&&(o==0?a.widget.compare(e):a.widget.constructor==e.constructor&&e.updateDOM(a.dom,this.view)))return i.splice(s,1),s<this.index[0]&&this.index[0]--,this.reused.set(a,1),a.length=t,a.flags=a.flags&-498|r,a}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}}class CL{constructor(e,t,r,i,s){this.view=e,this.decorations=i,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new kL(e),this.text=new SL(e.state.doc),this.builder=new bL(this.cache,new Ld(e,e.contentDOM),Ze.iter(r)),this.cache.reused.set(t,2),this.old=new xL(t),this.reuseWalker={skip:(o,a,u)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let r=t&&this.getCompositionContext(t.text);for(let i=0,s=0,o=0;;){let a=o<e.length?e[o++]:null,u=a?a.fromA:this.old.root.length;if(u>i){let f=u-i;this.preserve(f,!o,!a),i=u,s+=f}if(!a)break;this.forward(a.fromA,a.toA),t&&a.fromA<=t.range.fromA&&a.toA>=t.range.toA?(this.emit(s,t.range.fromB),this.builder.addComposition(t,r),this.emit(t.range.toB,a.toB)):this.emit(s,a.toB),s=a.toB,i=a.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,r){let i=TL(this.old),s=this.openMarks;this.old.advance(e,r?1:-1,{skip:(o,a,u)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(u-a);else{let f=u>0||a<o.length?il.of(o.widget,this.view,u-a,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);f.flags&256?(f.flags&=-2,this.builder.addBlockWidget(f)):(this.builder.ensureLine(null),this.builder.addInlineWidget(f,i,s),s=i.length)}else if(o.isText())this.builder.ensureLine(null),!a&&u==o.length?this.builder.addText(o.text,i,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(a,u),i,s)),s=i.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Vf)this.cache.add(o);else if(o instanceof Ln)this.builder.ensureLine(null),this.builder.addMark(o,i,s),this.cache.reused.set(o,1),s=i.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 Ln&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Ln&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let r=null,i=this.builder,s=0,o=Ze.spans(this.decorations,e,t,{point:(a,u,f,h,p,g)=>{if(f instanceof ro){if(this.disallowBlockEffectsFor[g]){if(f.block)throw new RangeError("Block decorations may not be specified via plugins");if(u>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=h.length,p>h.length)i.continueWidget(u-a);else{let y=f.widget||(f.block?sl.block:sl.inline),x=EL(f),w=this.cache.findWidget(y,u-a,x)||il.of(y,this.view,u-a,x);f.block?(f.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(w)):(i.ensureLine(r),i.addInlineWidget(w,h,p))}r=null}else r=RL(r,f);u>a&&this.text.skip(u-a)},span:(a,u,f,h)=>{for(let p=a;p<u;){let g=this.text.next(Math.min(512,u-p));g==null?(i.addLineStartIfNotCovered(r),i.addBreak(),p++):(i.ensureLine(r),i.addText(g,f,h),p+=g.length),r=null}}});i.addLineStartIfNotCovered(r),this.openWidget=o>s,this.openMarks=o}forward(e,t){t-e<=10?this.old.advance(t-e,1,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,1,this.reuseWalker))}getCompositionContext(e){let t=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=Yt.get(i);if(i==this.view.contentDOM)break;s instanceof Ln?t.push(s):s!=null&&s.isLine()?r=s:i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new rl(i,sC):t.push(Ln.of(new hc({tagName:i.nodeName.toLowerCase(),attributes:J8(i)}),i))}return{line:r,marks:t}}}function ow(n,e){let t=r=>{for(let i of r.children)if((e?i.isText():i.length)||t(i))return!0;return!1};return t(n)}function EL(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const sC={class:"cm-line"};function RL(n,e){let t=e.spec.attributes,r=e.spec.class;return!t&&!r||(n||(n={class:"cm-line"}),t&&x0(t,n),r&&(n.class+=" "+r)),n}function TL(n){let e=[];for(let t=n.parents.length;t>1;t--){let r=t==n.parents.length?n.tile:n.parents[t].tile;r instanceof Ln&&e.push(r.mark)}return e}function Xp(n){let e=Yt.get(n);return e&&e.setDOM(n.cloneNode()),n}class sl extends oi{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}}sl.inline=new sl("span");sl.block=new sl("div");const Jp=new class extends oi{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class lw{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=De.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 Ld(e,e.contentDOM),this.updateInner([new lr(0,0,0,e.state.doc.length)],null)}update(e){var t;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:h,toA:p})=>p<this.minWidthFrom||h>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 i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?i=this.domChanged.newSel.head:!jL(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?OL(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:p}=this.hasComposition;r=new lr(h,p,e.changes.mapPos(h,-1),e.changes.mapPos(p,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Se.ie||Se.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.blockWrappers;this.updateDeco();let u=NL(o,this.decorations,e.changes);u.length&&(r=lr.extendWithRanges(r,u));let f=DL(a,this.blockWrappers,e.changes);return f.length&&(r=lr.extendWithRanges(r,f)),s&&!r.some(h=>h.fromA<=s.range.fromA&&h.toA>=s.range.toA)&&(r=s.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(t||e.length){let o=this.tile,a=new CL(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=a.run(e,t),hg(o,a.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=Se.chrome||Se.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||r.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];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 Zp&&i.push(s.dom);r.updateGaps(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let r of t.effects)r.is(Zk)&&(this.editContextFormatting=r.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:r}=this.tile,i=this.view.root.activeElement,s=i==r,o=!s&&!(this.view.state.facet(bi)||r.tabIndex>-1)&&vf(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||t||o))return;let a=this.forceSelection;this.forceSelection=!1;let u=this.view.state.selection.main,f,h;if(u.empty?h=f=this.inlineDOMNearPos(u.anchor,u.assoc||1):(h=this.inlineDOMNearPos(u.head,u.head==u.from?1:-1),f=this.inlineDOMNearPos(u.anchor,u.anchor==u.from?1:-1)),Se.gecko&&u.empty&&!this.hasComposition&&ML(f)){let g=document.createTextNode("");this.view.observer.ignore(()=>f.node.insertBefore(g,f.node.childNodes[f.offset]||null)),f=h=new Rr(g,0),a=!0}let p=this.view.observer.selectionRange;(a||!p.focusNode||(!Ta(f.node,f.offset,p.anchorNode,p.anchorOffset)||!Ta(h.node,h.offset,p.focusNode,p.focusOffset))&&!this.suppressWidgetCursorChange(p,u))&&(this.view.observer.ignore(()=>{Se.android&&Se.chrome&&r.contains(p.focusNode)&&IL(p.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let g=_a(this.view.root);if(g)if(u.empty){if(Se.gecko){let y=PL(f.node,f.offset);if(y&&y!=3){let x=(y==1?Bk:Fk)(f.node,f.offset);x&&(f=new Rr(x.node,x.offset))}}g.collapse(f.node,f.offset),u.bidiLevel!=null&&g.caretBidiLevel!==void 0&&(g.caretBidiLevel=u.bidiLevel)}else if(g.extend){g.collapse(f.node,f.offset);try{g.extend(h.node,h.offset)}catch{}}else{let y=document.createRange();u.anchor>u.head&&([f,h]=[h,f]),y.setEnd(h.node,h.offset),y.setStart(f.node,f.offset),g.removeAllRanges(),g.addRange(y)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(f,h)),this.impreciseAnchor=f.precise?null:new Rr(p.anchorNode,p.anchorOffset),this.impreciseHead=h.precise?null:new Rr(p.focusNode,p.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ta(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,r=_a(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!t.empty||!t.assoc||!r.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let u=this.coordsAt(t.head,-1),f=this.coordsAt(t.head,1);if(!u||!f||u.bottom>f.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);r.collapse(h.node,h.offset),r.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let p=e.observer.selectionRange;e.docView.posFromDOM(p.anchorNode,p.anchorOffset)!=t.from&&r.collapse(i,s)}posFromDOM(e,t){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[t];else{let o=Pi(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==r.dom)break;o==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?o=-1:o=1),e=a}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!Yt.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,a=i;;o++){let u=r.children[o];if(u.dom==s)return a;a+=u.length+u.breakAfter}}else return r.isText()?e==r.dom?i+t:i+(t?r.length:0):i}domAtPos(e,t){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.domPosFor(e,t):r.domIn(i,t)}inlineDOMNearPos(e,t){let r,i=-1,s=!1,o,a=-1,u=!1;return this.tile.blockTiles((f,h)=>{if(f.isWidget()){if(f.flags&32&&h>=e)return!0;f.flags&16&&(s=!0)}else{let p=h+f.length;if(h<=e&&(r=f,i=e-h,s=p<e),p>=e&&!o&&(o=f,a=e-h,u=h>e),h>e&&o)return!0}}),!r&&!o?this.domAtPos(e,t):(s&&o?r=null:u&&r&&(o=null),r&&t<0||!o?r.domIn(i,t):o.domIn(a,t))}coordsAt(e,t){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Zp?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t)}lineAt(e,t){let{tile:r}=this.tile.resolveBlock(e,t);return r.isLine()?r:null}coordsForChar(e){let{tile:t,offset:r}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function i(s,o){if(s.isComposite())for(let a of s.children){if(a.length>=o){let u=i(a,o);if(u)return u}if(o-=a.length,o<0)break}else if(s.isText()&&o<s.length){let a=Qt(s.text,o);if(a==o)return null;let u=Wa(s.dom,o,a).getClientRects();for(let f=0;f<u.length;f++){let h=u[f];if(f==u.length-1||h.top<h.bottom&&h.left<h.right)return h}}return null}return i(t,r)}measureVisibleLineHeights(e){let t=[],{from:r,to:i}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,u=this.view.textDirection==pt.LTR,f=0,h=(p,g,y)=>{for(let x=0;x<p.children.length&&!(g>i);x++){let w=p.children[x],C=g+w.length,E=w.dom.getBoundingClientRect(),{height:T}=E;if(y&&!x&&(f+=E.top-y.top),w instanceof us)C>r&&h(w,g,E);else if(g>=r&&(f>0&&t.push(-f),t.push(T+f),f=0,o)){let M=w.dom.lastChild,P=M?Ra(M):[];if(P.length){let O=P[P.length-1],N=u?O.right-E.left:E.right-O.left;N>a&&(a=N,this.minWidth=s,this.minWidthFrom=g,this.minWidthTo=C)}}y&&x==p.children.length-1&&(f+=y.bottom-E.bottom),g=C+w.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?pt.RTL:pt.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let a=0,u;for(let f of o.children){if(!f.isText()||/[^ -~]/.test(f.text))return;let h=Ra(f.dom);if(h.length!=1)return;a+=h[0].width,u=h[0].height}if(a)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:a/o.length,textHeight:u}}});if(e)return e;let t=document.createElement("div"),r,i,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Ra(t.firstChild)[0];r=t.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,t.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let r=0,i=0;;i++){let s=i==t.viewports.length?null:t.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(r).top)/this.view.scaleY;e.push(De.replace({widget:new Zp(a),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return De.set(e)}updateDeco(){let e=1,t=this.view.state.facet($a).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(nC).map((s,o)=>{let a=typeof s=="function";return a&&(r=!0),a?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,t.push(Ze.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(tC).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let f=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=f.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let f of this.view.state.facet(Jk))try{if(f(this.view,e.range,e))return!0}catch(h){In(this.view.state,h,"scroll handler")}let{range:t}=e,r=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),i;if(!r)return;!t.empty&&(i=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=E0(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:a,offsetHeight:u}=this.view.scrollDOM;tL(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,u),-u),this.view.textDirection==pt.LTR)}lineHasWidget(e){let t=r=>r.isWidget()||r.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){hg(this.tile)}}function hg(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let r of n.children)hg(r,e)}}function ML(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function oC(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let r=Bk(t.focusNode,t.focusOffset),i=Fk(t.focusNode,t.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let a=Yt.get(i.node);if(!a||a.isText()&&a.text!=i.node.nodeValue)s=i;else if(n.docView.lastCompositionAfterCursor){let u=Yt.get(r.node);!u||u.isText()&&u.text!=r.node.nodeValue||(s=i)}}if(n.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function OL(n,e,t){let r=oC(n,t);if(!r)return null;let{node:i,from:s,to:o}=r,a=i.nodeValue;if(/[\n\r]/.test(a)||n.state.doc.sliceString(r.from,r.to)!=a)return null;let u=e.invertedDesc;return{range:new lr(u.mapPos(s),u.mapPos(o),s,o),text:i}}function PL(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}let AL=class{constructor(){this.changes=[]}compareRange(e,t){qo(e,t,this.changes)}comparePoint(e,t){qo(e,t,this.changes)}boundChange(e){qo(e,e,this.changes)}};function NL(n,e,t){let r=new AL;return Ze.compare(n,e,t,r),r.changes}class LL{constructor(){this.changes=[]}compareRange(e,t){qo(e,t,this.changes)}comparePoint(){}boundChange(e){qo(e,e,this.changes)}}function DL(n,e,t){let r=new LL;return Ze.compare(n,e,t,r),r.changes}function IL(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function jL(n,e){let t=!1;return e&&n.iterChangedRanges((r,i)=>{r<e.to&&i>e.from&&(t=!0)}),t}class Zp extends oi{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 BL(n,e,t=1){let r=n.charCategorizer(e),i=n.doc.lineAt(e),s=e-i.from;if(i.length==0)return te.cursor(e);s==0?t=1:s==i.length&&(t=-1);let o=s,a=s;t<0?o=Qt(i.text,s,!1):a=Qt(i.text,s);let u=r(i.text.slice(o,a));for(;o>0;){let f=Qt(i.text,o,!1);if(r(i.text.slice(f,o))!=u)break;o=f}for(;a<i.length;){let f=Qt(i.text,a);if(r(i.text.slice(a,f))!=u)break;a=f}return te.range(o+i.from,a+i.from)}function FL(n,e,t,r,i){let s=Math.round((r-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,u=Math.floor((i-t.top-(n.defaultLineHeight-a)*.5)/a);s+=u*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+tg(o,s,n.state.tabSize)}function pg(n,e,t){let r=n.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!i||s.type==cn.Text&&(i.type!=s.type||(t<0?s.from<e:s.to>e)))&&(i=s)}}return i||r}return r}function zL(n,e,t,r){let i=pg(n,e.head,e.assoc||-1),s=!r||i.type!=cn.Text||!(n.lineWrapping||i.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(i.from),u=n.posAtCoords({x:t==(a==pt.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(u!=null)return te.cursor(u,t?-1:1)}return te.cursor(t?i.to:i.from,t?-1:1)}function aw(n,e,t,r){let i=n.state.doc.lineAt(e.head),s=n.bidiSpans(i),o=n.textDirectionAt(i.from);for(let a=e,u=null;;){let f=hL(i,s,o,a,t),h=$k;if(!f){if(i.number==(t?n.state.doc.lines:1))return a;h=`
`,i=n.state.doc.line(i.number+(t?1:-1)),s=n.bidiSpans(i),f=n.visualLineSide(i,!t)}if(u){if(!u(h))return a}else{if(!r)return f;u=r(h)}a=f}}function _L(n,e,t){let r=n.state.charCategorizer(e),i=r(t);return s=>{let o=r(s);return i==kt.Space&&(i=o),i==o}}function VL(n,e,t,r){let i=e.head,s=t?1:-1;if(i==(t?n.state.doc.length:0))return te.cursor(i,e.assoc);let o=e.goalColumn,a,u=n.contentDOM.getBoundingClientRect(),f=n.coordsAtPos(i,e.assoc||-1),h=n.documentTop;if(f)o==null&&(o=f.left-u.left),a=s<0?f.top:f.bottom;else{let y=n.viewState.lineBlockAt(i);o==null&&(o=Math.min(u.right-u.left,n.defaultCharacterWidth*(i-y.from))),a=(s<0?y.top:y.bottom)+h}let p=u.left+o,g=r??n.viewState.heightOracle.textHeight>>1;for(let y=0;;y+=10){let x=a+(g+y)*s,w=mg(n,{x:p,y:x},!1,s);return te.cursor(w.pos,w.assoc,void 0,o)}}function Ma(n,e,t){for(;;){let r=0;for(let i of n)i.between(e-1,e+1,(s,o,a)=>{if(e>s&&e<o){let u=r||t||(e-s<o-e?-1:1);e=u<0?s:o,r=u}});if(!r)return e}}function lC(n,e){let t=null;for(let r=0;r<e.ranges.length;r++){let i=e.ranges[r],s=null;if(i.empty){let o=Ma(n,i.from,0);o!=i.from&&(s=te.cursor(o,-1))}else{let o=Ma(n,i.from,-1),a=Ma(n,i.to,1);(o!=i.from||a!=i.to)&&(s=te.range(i.from==i.anchor?o:a,i.from==i.head?o:a))}s&&(t||(t=e.ranges.slice()),t[r]=s)}return t?te.create(t,e.mainIndex):e}function em(n,e,t){let r=Ma(n.state.facet(mc).map(i=>i(n)),t.from,e.head>t.from?-1:1);return r==t.from?t:te.cursor(r,r<t.from?1:-1)}class Yr{constructor(e,t){this.pos=e,this.assoc=t}}function mg(n,e,t,r){let i=n.contentDOM.getBoundingClientRect(),s=i.top+n.viewState.paddingTop,{x:o,y:a}=e,u=a-s,f;for(;;){if(u<0)return new Yr(0,1);if(u>n.viewState.docHeight)return new Yr(n.state.doc.length,-1);if(f=n.elementAtHeight(u),r==null)break;if(f.type==cn.Text){let g=n.docView.coordsAt(r<0?f.from:f.to,r);if(g&&(r<0?g.top<=u+s:g.bottom>=u+s))break}let p=n.viewState.heightOracle.textHeight/2;u=r>0?f.bottom+p:f.top-p}if(n.viewport.from>=f.to||n.viewport.to<=f.from){if(t)return null;if(f.type==cn.Text){let p=FL(n,i,f,o,a);return new Yr(p,p==f.from?1:-1)}}if(f.type!=cn.Text)return u<(f.top+f.bottom)/2?new Yr(f.from,1):new Yr(f.to,-1);let h=n.docView.lineAt(f.from,2);return(!h||h.length!=f.length)&&(h=n.docView.lineAt(f.from,-2)),aC(n,h,f.from,o,a)}function aC(n,e,t,r,i){let s=-1,o=null,a=1e9,u=1e9,f=i,h=i,p=(g,y)=>{for(let x=0;x<g.length;x++){let w=g[x];if(w.top==w.bottom)continue;let C=w.left>r?w.left-r:w.right<r?r-w.right:0,E=w.top>i?w.top-i:w.bottom<i?i-w.bottom:0;w.top<=h&&w.bottom>=f&&(f=Math.min(w.top,f),h=Math.max(w.bottom,h),E=0),(s<0||(E-u||C-a)<0)&&(s>=0&&u&&a<C&&o.top<=h-2&&o.bottom>=f+2?u=0:(s=y,a=C,u=E,o=w))}};if(e.isText()){for(let y=0;y<e.length;){let x=Qt(e.text,y);if(p(Wa(e.dom,y,x).getClientRects(),y),!a&&!u)break;y=x}return r>(o.left+o.right)/2==(cw(n,s+t)==pt.LTR)?new Yr(t+Qt(e.text,s),-1):new Yr(t+s,1)}else{if(!e.length)return new Yr(t,1);for(let w=0;w<e.children.length;w++){let C=e.children[w];if(C.flags&48)continue;let E=(C.dom.nodeType==1?C.dom:Wa(C.dom,0,C.length)).getClientRects();if(p(E,w),!a&&!u)break}let g=e.children[s],y=e.posBefore(g,t);return g.isComposite()||g.isText()?aC(n,g,y,Math.max(o.left,Math.min(o.right,r)),i):r>(o.left+o.right)/2==(cw(n,s+t)==pt.LTR)?new Yr(y+g.length,-1):new Yr(y,1)}}function cw(n,e){let t=n.state.doc.lineAt(e);return n.bidiSpans(t)[Si.find(n.bidiSpans(t),e-t.from,-1,1)].dir}const ya="￿";class WL{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(nt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ya}readRange(e,t){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=Yt.get(i),a=i.nextSibling;if(a==t){o!=null&&o.breakAfter&&!a&&r!=this.view.contentDOM&&this.lineBreak();break}let u=Yt.get(a);(o&&u?o.breakAfter:(o?o.breakAfter:zf(i))||zf(a)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!HL(a,t)&&this.lineBreak(),i=a}return this.findPointBefore(r,t),this}readTextNode(e){let t=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,t.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(a=i.exec(t))&&(s=a.index,o=a[0].length),this.append(t.slice(r,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let u of this.points)u.node==e&&u.pos>this.text.length&&(u.pos-=o-1);r=s+o}}readNode(e){let t=Yt.get(e),r=t&&t.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.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,t){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==t&&(r.pos=this.text.length)}findPointInside(e,t){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+($L(e,r.node,r.offset)?t:0))}}function $L(n,e,t){for(;;){if(!e||t<Pi(e))return!1;if(e==n)return!0;t=ms(e)+1,e=e.parentNode}}function HL(n,e){let t;for(;!(n==e||!n);n=n.nextSibling){let r=Yt.get(n);if(!(r!=null&&r.isWidget()))return!1;r&&(t||(t=[])).push(r)}if(t)for(let r of t){let i=r.overrideDOMText;if(i!=null&&i.length)return!1}return!0}class uw{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class UL{constructor(e,t,r,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=cC(e.docView.tile,t,r,0))){let a=s||o?[]:KL(e),u=new WL(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=QL(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!ag(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),f=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!ag(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),h=e.viewport;if((Se.ios||Se.chrome)&&e.state.selection.main.empty&&u!=f&&(h.from>0||h.to<e.state.doc.length)){let p=Math.min(u,f),g=Math.max(u,f),y=h.from-p,x=h.to-g;(y==0||y==1||p==0)&&(x==0||x==-1||g==e.state.doc.length)&&(u=0,f=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(te.range(f,u)):this.newSel=te.single(f,u)}}}function cC(n,e,t,r){if(n.isComposite()){let i=-1,s=-1,o=-1,a=-1;for(let u=0,f=r,h=r;u<n.children.length;u++){let p=n.children[u],g=f+p.length;if(f<e&&g>t)return cC(p,e,t,f);if(g>=e&&i==-1&&(i=u,s=f),f>t&&p.dom.parentNode==n.dom){o=u,a=h;break}h=g,f=g+p.breakAfter}return{from:s,to:a<0?r+n.length:a,startDOM:(i?n.children[i-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o<n.children.length&&o>=0?n.children[o].dom:null}}else return n.isText()?{from:r,to:r+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function uC(n,e){let t,{newSel:r}=e,i=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,u=i.from,f=null;(s===8||Se.android&&e.text.length<a-o)&&(u=i.to,f="end");let h=fC(n.state.doc.sliceString(o,a,ya),e.text,u-o,f);h&&(Se.chrome&&s==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==ya+ya&&h.toB--,t={from:o+h.from,to:o+h.toA,insert:lt.of(e.text.slice(h.from,h.toB).split(ya))})}else r&&(!n.hasFocus&&n.state.facet(bi)||r.main.eq(i))&&(r=null);if(!t&&!r)return!1;if(!t&&e.typeOver&&!i.empty&&r&&r.main.empty?t={from:i.from,to:i.to,insert:n.state.doc.slice(i.from,i.to)}:(Se.mac||Se.android)&&t&&t.from==t.to&&t.from==i.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(r&&t.insert.length==2&&(r=te.single(r.main.anchor-1,r.main.head-1)),t={from:t.from,to:t.to,insert:lt.of([t.insert.toString().replace("."," ")])}):t&&t.from>=i.from&&t.to<=i.to&&(t.from!=i.from||t.to!=i.to)&&i.to-i.from-(t.to-t.from)<=4?t={from:i.from,to:i.to,insert:n.state.doc.slice(i.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,i.to))}:n.state.doc.lineAt(i.from).to<i.to&&n.docView.lineHasWidget(i.to)&&n.inputState.insertingTextAt>Date.now()-50?t={from:i.from,to:i.to,insert:n.state.toText(n.inputState.insertingText)}:Se.chrome&&t&&t.from==t.to&&t.from==i.head&&t.insert.toString()==`
 `&&n.lineWrapping&&(r&&(r=te.single(r.main.anchor-1,r.main.head-1)),t={from:i.from,to:i.to,insert:lt.of([" "])}),t)return R0(n,t,r,s);if(r&&!r.main.eq(i)){let o=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=lC(n.state.facet(mc).map(u=>u(n)),r))),n.dispatch({selection:r,scrollIntoView:o,userEvent:a}),!0}else return!1}function R0(n,e,t,r=-1){if(Se.ios&&n.inputState.flushIOSKey(e))return!0;let i=n.state.selection.main;if(Se.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&n.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ko(n.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.length<e.to-e.from&&e.to>i.head)&&Ko(n.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&Ko(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,a=()=>o||(o=qL(n,e,t));return n.state.facet(Qk).some(u=>u(n,e.from,e.to,s,a))||n.dispatch(a()),!0}function qL(n,e,t){let r,i=n.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let u=e.from<s.from?-1:1,f=u<0?s.from:s.to,h=Ma(i.facet(mc).map(p=>p(n)),f,u);e.from==h&&(o=h)}if(o>-1)r={changes:e,selection:te.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&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let u=s.from<e.from?i.sliceDoc(s.from,e.from):"",f=s.to>e.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(n.state.toText(u+e.insert.sliceString(0,void 0,n.state.lineBreak)+f))}else{let u=i.changes(e),f=t&&t.main.to<=u.newLength?t.main:void 0;if(i.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),p,g=t&&oC(n,t.main.head);if(g){let x=e.insert.length-(e.to-e.from);p={from:g.from,to:g.to-x}}else p=n.state.doc.lineAt(s.head);let y=s.to-e.to;r=i.changeByRange(x=>{if(x.from==s.from&&x.to==s.to)return{changes:u,range:f||x.map(u)};let w=x.to-y,C=w-h.length;if(n.state.sliceDoc(C,w)!=h||w>=p.from&&C<=p.to)return{range:x};let E=i.changes({from:C,to:w,insert:e.insert}),T=x.to-s.to;return{changes:E,range:f?te.range(Math.max(0,f.anchor+T),Math.max(0,f.head+T)):x.map(E)}})}else r={changes:u,selection:f&&i.selection.replaceRange(f)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:a,scrollIntoView:!0})}function fC(n,e,t,r){let i=Math.min(n.length,e.length),s=0;for(;s<i&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==i&&n.length==e.length)return null;let o=n.length,a=e.length;for(;o>0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(r=="end"){let u=Math.max(0,s-Math.min(o,a));t-=o+u-s}if(o<s&&n.length<e.length){let u=t<=s&&t>=o?s-t:0;s-=u,a=s+(a-o),o=s}else if(a<s){let u=t<=s&&t>=a?s-t:0;s-=u,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function KL(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new uw(t,r)),(i!=t||s!=r)&&e.push(new uw(i,s))),e}function QL(n,e){if(n.length==0)return null;let t=n[0].pos,r=n.length==2?n[1].pos:t;return t>-1&&r>-1?te.single(t+e,r+e):null}class GL{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 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,Se.safari&&e.contentDOM.addEventListener("input",()=>null),Se.gecko&&uD(e.contentDOM.ownerDocument)}handleEvent(e){!rD(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,t){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,t);for(let i of r.handlers){if(t.defaultPrevented)break;if(i(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=YL(e),r=this.handlers,i=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,a=r[s];a&&o!=!a.handlers.length&&(i.removeEventListener(s,this.handleEvent),a=null),a||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!t[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=t}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&&hC.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Se.android&&Se.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return Se.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=dC.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||XL.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ko(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Se.safari&&!Se.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 fw(n,e){return(t,r)=>{try{return e.call(n,r,t)}catch(i){In(t.state,i)}}}function YL(n){let e=Object.create(null);function t(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of n){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let a in s){let u=s[a];u&&t(a).handlers.push(fw(r.value,u))}if(o)for(let a in o){let u=o[a];u&&t(a).observers.push(fw(r.value,u))}}for(let r in Or)t(r).handlers.push(Or[r]);for(let r in dr)t(r).observers.push(dr[r]);return e}const dC=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],XL="dthko",hC=[16,17,18,20,91,92,224,225],$u=6;function Hu(n){return Math.max(0,n)*.7+8}function JL(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class ZL{constructor(e,t,r,i){this.view=e,this.startEvent=t,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=nL(e.contentDOM),this.atoms=e.state.facet(mc).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=t.shiftKey,this.multiple=e.state.facet(nt.allowMultipleSelections)&&eD(e,t),this.dragging=nD(e,t)&&gC(t)==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&&JL(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,r=0,i=0,s=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:a}=this.scrollParents.y.getBoundingClientRect());let u=E0(this.view);e.clientX-u.left<=i+$u?t=-Hu(i-e.clientX):e.clientX+u.right>=o-$u&&(t=Hu(e.clientX-o)),e.clientY-u.top<=s+$u?r=-Hu(s-e.clientY):e.clientY+u.bottom>=a-$u&&(r=Hu(e.clientY-a)),this.setScrollSpeed(t,r)}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,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,r=lC(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function eD(n,e){let t=n.state.facet(Hk);return t.length?t[0](e):Se.mac?e.metaKey:e.ctrlKey}function tD(n,e){let t=n.state.facet(Uk);return t.length?t[0](e):Se.mac?!e.altKey:!e.ctrlKey}function nD(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let r=_a(n.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s<i.length;s++){let o=i[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function rD(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,r;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(r=Yt.get(t))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Or=Object.create(null),dr=Object.create(null),pC=Se.ie&&Se.ie_version<15||Se.ios&&Se.webkit_version<604;function iD(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),mC(n,t.value)},50)}function Dd(n,e,t){for(let r of n.facet(e))t=r(t,n);return t}function mC(n,e){e=Dd(n.state,S0,e);let{state:t}=n,r,i=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(gg!=null&&t.selection.ranges.every(u=>u.empty)&&gg==s.toString()){let u=-1;r=t.changeByRange(f=>{let h=t.doc.lineAt(f.from);if(h.from==u)return{range:f};u=h.from;let p=t.toText((o?s.line(i++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:p},range:te.cursor(f.from+p.length)}})}else o?r=t.changeByRange(u=>{let f=s.line(i++);return{changes:{from:u.from,to:u.to,insert:f.text},range:te.cursor(u.from+f.length)}}):r=t.replaceSelection(s);n.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}dr.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};Or.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);dr.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};dr.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Or.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let r of n.state.facet(qk))if(t=r(n,e),t)break;if(!t&&e.button==0&&(t=oD(n,e)),t){let r=!n.hasFocus;n.inputState.startMouseSelection(new ZL(n,e,t,r)),r&&n.observer.ignore(()=>{Ik(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let i=n.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function dw(n,e,t,r){if(r==1)return te.cursor(e,t);if(r==2)return BL(n.state,e,t);{let i=n.docView.lineAt(e,t),s=n.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,a=i?i.posAtEnd:s.to;return a<n.state.doc.length&&a==s.to&&a++,te.range(o,a)}}const sD=Se.ie&&Se.ie_version<=11;let hw=null,pw=0,mw=0;function gC(n){if(!sD)return n.detail;let e=hw,t=mw;return hw=n,mw=Date.now(),pw=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(pw+1)%3:1}function oD(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=gC(e),i=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),i=i.map(s.changes))},get(s,o,a){let u=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),f,h=dw(n,u.pos,u.assoc,r);if(t.pos!=u.pos&&!o){let p=dw(n,t.pos,t.assoc,r),g=Math.min(p.from,h.from),y=Math.max(p.to,h.to);h=g<h.from?te.range(g,y):te.range(y,g)}return o?i.replaceRange(i.main.extend(h.from,h.to)):a&&r==1&&i.ranges.length>1&&(f=lD(i,u.pos))?f:a?i.addRange(h):te.create([h])}}}function lD(n,e){for(let t=0;t<n.ranges.length;t++){let{from:r,to:i}=n.ranges[t];if(r<=e&&i>=e)return te.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Or.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let i=n.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=t.to||o<=t.from)&&(t=te.range(s,o))}}let{inputState:r}=n;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Dd(n.state,k0,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Or.dragend=n=>(n.inputState.draggedContent=null,!1);function gw(n,e,t,r){if(t=Dd(n.state,S0,t),!t)return;let i=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=r&&s&&tD(n,e)?{from:s.from,to:s.to}:null,a={from:i,insert:t},u=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:u,selection:{anchor:u.mapPos(i,-1),head:u.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Or.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let r=Array(t.length),i=0,s=()=>{++i==t.length&&gw(n,e,r.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let a=new FileReader;a.onerror=s,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(r[o]=a.result),s()},a.readAsText(t[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return gw(n,e,r,!0),!0}return!1};Or.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=pC?null:e.clipboardData;return t?(mC(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(iD(n),!1)};function aD(n,e){let t=n.dom.parentNode;if(!t)return;let r=t.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),n.focus()},50)}function cD(n){let e=[],t=[],r=!1;for(let i of n.selection.ranges)i.empty||(e.push(n.sliceDoc(i.from,i.to)),t.push(i));if(!e.length){let i=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>i&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Dd(n,k0,e.join(n.lineBreak)),ranges:t,linewise:r}}let gg=null;Or.copy=Or.cut=(n,e)=>{let{text:t,ranges:r,linewise:i}=cD(n.state);if(!t&&!i)return!1;gg=i?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=pC?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(aD(n,t),!1)};const yC=Li.define();function vC(n,e){let t=[];for(let r of n.facet(Gk)){let i=r(n,e);i&&t.push(i)}return t.length?n.update({effects:t,annotations:yC.of(!0)}):null}function xC(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=vC(n.state,e);t?n.dispatch(t):n.update([])}},10)}dr.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),xC(n)};dr.blur=n=>{n.observer.clearSelectionRange(),xC(n)};dr.compositionstart=dr.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};dr.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,Se.chrome&&Se.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};dr.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Or.beforeinput=(n,e)=>{var t,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let a=o[0],u=n.posAtDOM(a.startContainer,a.startOffset),f=n.posAtDOM(a.endContainer,a.endOffset);return R0(n,{from:u,to:f,insert:n.state.toText(s)},null),!0}}let i;if(Se.chrome&&Se.android&&(i=dC.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return Se.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),Se.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>dr.compositionend(n,e),20),!1};const yw=new Set;function uD(n){yw.has(n)||(yw.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const vw=["pre-wrap","normal","pre-line","break-spaces"];let ol=!1;function xw(){ol=!1}class fD{constructor(e){this.lineWrapping=e,this.doc=lt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let r=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((t-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 vw.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let r=0;r<e.length;r++){let i=e[r];i<0?r++:this.heightSamples[Math.floor(i*10)]||(t=!0,this.heightSamples[Math.floor(i*10)]=!0)}return t}refresh(e,t,r,i,s,o){let a=vw.indexOf(e)>-1,u=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=r,this.textHeight=i,this.lineLength=s,u){this.heightSamples={};for(let f=0;f<o.length;f++){let h=o[f];h<0?f++:this.heightSamples[Math.floor(h*10)]=!0}}return u}}class dD{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class kr{constructor(e,t,r,i,s){this.from=e,this.length=t,this.top=r,this.height=i,this._content=s}get type(){return typeof this._content=="number"?cn.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 ro?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new kr(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var gt=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(gt||(gt={}));const xf=.001;class Sn{constructor(e,t,r=2){this.length=e,this.height=t,this.flags=r}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)>xf&&(ol=!0),this.height=e)}replace(e,t,r){return Sn.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,r,i){let s=this,o=r.doc;for(let a=i.length-1;a>=0;a--){let{fromA:u,toA:f,fromB:h,toB:p}=i[a],g=s.lineAt(u,gt.ByPosNoHeight,r.setDoc(t),0,0),y=g.to>=f?g:s.lineAt(f,gt.ByPosNoHeight,r,0,0);for(p+=y.to-f,f=y.to;a>0&&g.from<=i[a-1].toA;)u=i[a-1].fromA,h=i[a-1].fromB,a--,u<g.from&&(g=s.lineAt(u,gt.ByPosNoHeight,r,0,0));h+=g.from-u,u=g.from;let x=T0.build(r.setDoc(o),e,h,p);s=$f(s,s.replace(u,f,x))}return s.updateHeight(r,0)}static empty(){return new qn(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,r=e.length,i=0,s=0;for(;;)if(t==r)if(i>s*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),r+=1+a.break,i-=a.size}else if(s>i*2){let a=e[r];a.break?e.splice(r,1,a.left,null,a.right):e.splice(r,1,a.left,a.right),r+=2+a.break,s-=a.size}else break;else if(i<s){let a=e[t++];a&&(i+=a.size)}else{let a=e[--r];a&&(s+=a.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,r++),new pD(Sn.of(e.slice(0,t)),o,Sn.of(e.slice(r)))}}function $f(n,e){return n==e?n:(n.constructor!=e.constructor&&(ol=!0),e)}Sn.prototype.size=1;const hD=De.replace({});class wC extends Sn{constructor(e,t,r){super(e,t),this.deco=r,this.spaceAbove=0}mainBlock(e,t){return new kr(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,r,i){return this.spaceAbove&&e<r+this.spaceAbove?new kr(i,0,r,this.spaceAbove,hD):this.mainBlock(r,i)}lineAt(e,t,r,i,s){let o=this.mainBlock(i,s);return this.spaceAbove?this.blockAt(0,r,i,s).join(o):o}forEachLine(e,t,r,i,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,gt.ByPos,r,i,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,r=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class qn extends wC{constructor(e,t,r){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,t){return new kr(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,r){let i=r[0];return r.length==1&&(i instanceof qn||i instanceof ln&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ln?i=new qn(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Sn.of(r)}updateHeight(e,t=0,r=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(r||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 ln extends Sn{constructor(e){super(e,0)}heightMetrics(e,t){let r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,s=i-r+1,o,a=0;if(e.lineWrapping){let u=Math.min(this.height,e.lineHeight*s);o=u/s,this.length>s+1&&(a=(this.height-u)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:a}}blockAt(e,t,r,i){let{firstLine:s,lastLine:o,perLine:a,perChar:u}=this.heightMetrics(t,i);if(t.lineWrapping){let f=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-r)/this.height))*this.length)),h=t.doc.lineAt(f),p=a+h.length*u,g=Math.max(r,e-p/2);return new kr(h.from,h.length,g,p,0)}else{let f=Math.max(0,Math.min(o-s,Math.floor((e-r)/a))),{from:h,length:p}=t.doc.line(s+f);return new kr(h,p,r+a*f,a,0)}}lineAt(e,t,r,i,s){if(t==gt.ByHeight)return this.blockAt(e,r,i,s);if(t==gt.ByPosNoHeight){let{from:y,to:x}=r.doc.lineAt(e);return new kr(y,x-y,0,0,0)}let{firstLine:o,perLine:a,perChar:u}=this.heightMetrics(r,s),f=r.doc.lineAt(e),h=a+f.length*u,p=f.number-o,g=i+a*p+u*(f.from-s-p);return new kr(f.from,f.length,Math.max(i,Math.min(g,i+this.height-h)),h,0)}forEachLine(e,t,r,i,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:a,perLine:u,perChar:f}=this.heightMetrics(r,s);for(let h=e,p=i;h<=t;){let g=r.doc.lineAt(h);if(h==e){let x=g.number-a;p+=u*x+f*(e-s-x)}let y=u+f*g.length;o(new kr(g.from,g.length,p,y,0)),p+=y,h=g.to+1}}replace(e,t,r){let i=this.length-t;if(i>0){let s=r[r.length-1];s instanceof ln?r[r.length-1]=new ln(s.length+i):r.push(null,new ln(i-1))}if(e>0){let s=r[0];s instanceof ln?r[0]=new ln(e+s.length):r.unshift(new ln(e-1),null)}return Sn.of(r)}decomposeLeft(e,t){t.push(new ln(e-1),null)}decomposeRight(e,t){t.push(null,new ln(this.length-e-1))}updateHeight(e,t=0,r=!1,i){let s=t+this.length;if(i&&i.from<=t+this.length&&i.more){let o=[],a=Math.max(t,i.from),u=-1;for(i.from>t&&o.push(new ln(i.from-t-1).updateHeight(e,t));a<=s&&i.more;){let h=e.doc.lineAt(a).length;o.length&&o.push(null);let p=i.heights[i.index++],g=0;p<0&&(g=-p,p=i.heights[i.index++]),u==-1?u=p:Math.abs(p-u)>=xf&&(u=-2);let y=new qn(h,p,g);y.outdated=!1,o.push(y),a+=h+1}a<=s&&o.push(null,new ln(s-a).updateHeight(e,a));let f=Sn.of(o);return(u<0||Math.abs(f.height-this.height)>=xf||Math.abs(u-this.heightMetrics(e,t).perLine)>=xf)&&(ol=!0),$f(this,f)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class pD extends Sn{constructor(e,t,r){super(e.length+t+r.length,e.height+r.height,t|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,t,r,i){let s=r+this.left.height;return e<s?this.left.blockAt(e,t,r,i):this.right.blockAt(e,t,s,i+this.left.length+this.break)}lineAt(e,t,r,i,s){let o=i+this.left.height,a=s+this.left.length+this.break,u=t==gt.ByHeight?e<o:e<a,f=u?this.left.lineAt(e,t,r,i,s):this.right.lineAt(e,t,r,o,a);if(this.break||(u?f.to<a:f.from>a))return f;let h=t==gt.ByPosNoHeight?gt.ByPosNoHeight:gt.ByPos;return u?f.join(this.right.lineAt(a,h,r,o,a)):this.left.lineAt(a,h,r,i,s).join(f)}forEachLine(e,t,r,i,s,o){let a=i+this.left.height,u=s+this.left.length+this.break;if(this.break)e<u&&this.left.forEachLine(e,t,r,i,s,o),t>=u&&this.right.forEachLine(e,t,r,a,u,o);else{let f=this.lineAt(u,gt.ByPos,r,i,s);e<f.from&&this.left.forEachLine(e,f.from-1,r,i,s,o),f.to>=e&&f.from<=t&&o(f),t>f.to&&this.right.forEachLine(f.to+1,t,r,a,u,o)}}replace(e,t,r){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,r),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of r)s.push(a);if(e>0&&ww(s,o-1),t<this.length){let a=s.length;this.decomposeRight(t,s),ww(s,a)}return Sn.of(s)}decomposeLeft(e,t){let r=this.left.length;if(e<=r)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(r++,e>=r&&t.push(null)),e>r&&this.right.decomposeLeft(e-r,t)}decomposeRight(e,t){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<r&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Sn.of(this.break?[e,null,t]:[e,t]):(this.left=$f(this.left,e),this.right=$f(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,r=!1,i){let{left:s,right:o}=this,a=t+s.length+this.break,u=null;return i&&i.from<=t+s.length&&i.more?u=s=s.updateHeight(e,t,r,i):s.updateHeight(e,t,r),i&&i.from<=a+o.length&&i.more?u=o=o.updateHeight(e,a,r,i):o.updateHeight(e,a,r),u?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 ww(n,e){let t,r;n[e]==null&&(t=n[e-1])instanceof ln&&(r=n[e+1])instanceof ln&&n.splice(e-1,3,new ln(t.length+1+r.length))}const mD=5;class T0{constructor(e,t){this.pos=e,this.oracle=t,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,t){if(this.lineStart>-1){let r=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof qn?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new qn(r-this.pos,-1,0)),this.writtenTo=r,t>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,r){if(e<t||r.heightRelevant){let i=r.widget?r.widget.estimatedHeight:0,s=r.widget?r.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=t-e;r.block?this.addBlock(new wC(o,i,r)):(o||s||i>=mD)&&this.addLineDeco(i,s,o)}else t>e&&this.span(e,t);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:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,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 qn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let r=new ln(t-e);return this.oracle.doc.lineAt(e).to==t&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof qn)return e;let t=new qn(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+r}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof qn)&&!this.isCovered?this.nodes.push(new qn(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=e;for(let i of this.nodes)i instanceof qn&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(e,t,r,i){let s=new T0(r,e);return Ze.spans(t,r,i,s,0),s.finish(r)}}function gD(n,e,t){let r=new yD;return Ze.compare(n,e,t,r,0),r.changes}class yD{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,r,i){(e<t||r&&r.heightRelevant||i&&i.heightRelevant)&&qo(e,t,this.changes,5)}}function vD(n,e){let t=n.getBoundingClientRect(),r=n.ownerDocument,i=r.defaultView||window,s=Math.max(0,t.left),o=Math.min(i.innerWidth,t.right),a=Math.max(0,t.top),u=Math.min(i.innerHeight,t.bottom);for(let f=n.parentNode;f&&f!=r.body;)if(f.nodeType==1){let h=f,p=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&p.overflow!="visible"){let g=h.getBoundingClientRect();s=Math.max(s,g.left),o=Math.min(o,g.right),a=Math.max(a,g.top),u=Math.min(f==n.parentNode?i.innerHeight:u,g.bottom)}f=p.position=="absolute"||p.position=="fixed"?h.offsetParent:h.parentNode}else if(f.nodeType==11)f=f.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,u)-(t.top+e)}}function xD(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function wD(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class tm{constructor(e,t,r,i){this.from=e,this.to=t,this.size=r,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++){let i=e[r],s=t[r];if(i.from!=s.from||i.to!=s.to||i.size!=s.size)return!1}return!0}draw(e,t){return De.replace({widget:new bD(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class bD extends oi{constructor(e,t){super(),this.size=e,this.vertical=t}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 bw{constructor(e){this.state=e,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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Sw,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=pt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(C0).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new fD(t),this.stateDeco=e.facet($a).filter(r=>typeof r!="function"),this.heightMap=Sn.empty().applyChanges(this.stateDeco,lt.empty,this.heightOracle.setDoc(e.doc),[new lr(0,0,0,e.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=De.set(this.lineGaps.map(r=>r.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let r=0;r<=1;r++){let i=r?t.head:t.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new Uu(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Sw:new M0(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(va(e,this.scaler))})}update(e,t=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=this.state.facet($a).filter(h=>typeof h!="function");let i=e.changedRanges,s=lr.extendWithRanges(i,gD(r,this.stateDeco,e?e.changes:Kt.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);xw(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||ol)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let u=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<u.from||t.range.head>u.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,t));let f=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,e.flags|=this.updateForViewport(),(f||!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),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Xk)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,r=window.getComputedStyle(t),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?pt.RTL:pt.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=t.getBoundingClientRect(),u=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let f=0,h=0;if(a.width&&a.height){let{scaleX:P,scaleY:O}=Dk(t,a);(P>.005&&Math.abs(this.scaleX-P)>.005||O>.005&&Math.abs(this.scaleY-O)>.005)&&(this.scaleX=P,this.scaleY=O,f|=16,o=u=!0)}let p=(parseInt(r.paddingTop)||0)*this.scaleY,g=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=g)&&(this.paddingTop=p,this.paddingBottom=g,f|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(u=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=16);let y=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=y&&(this.scrollAnchorHeight=-1,this.scrollTop=y),this.scrolledToBottom=jk(e.scrollDOM);let x=(this.printing?wD:vD)(t,this.paddingTop),w=x.top-this.pixelViewport.top,C=x.bottom-this.pixelViewport.bottom;this.pixelViewport=x;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(u=!0)),!this.inView&&!this.scrollTarget&&!xD(e.dom))return 0;let T=a.width;if((this.contentDOMWidth!=T||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,f|=16),u){let P=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(P)&&(o=!0),o||i.lineWrapping&&Math.abs(T-this.contentDOMWidth)>i.charWidth){let{lineHeight:O,charWidth:N,textHeight:L}=e.docView.measureTextSize();o=O>0&&i.refresh(s,O,N,L,Math.max(5,T/N),P),o&&(e.docView.minWidth=0,f|=16)}w>0&&C>0?h=Math.max(w,C):w<0&&C<0&&(h=Math.min(w,C)),xw();for(let O of this.viewports){let N=O.from==this.viewport.from?P:e.docView.measureVisibleLineHeights(O);this.heightMap=(o?Sn.empty().applyChanges(this.stateDeco,lt.empty,this.heightOracle,[new lr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new dD(O.from,N))}ol&&(f|=2)}let M=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return M&&(f&2&&(f|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),f|=this.updateForViewport()),(f&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,u=new Uu(i.lineAt(o-r*1e3,gt.ByHeight,s,0,0).from,i.lineAt(a+(1-r)*1e3,gt.ByHeight,s,0,0).to);if(t){let{head:f}=t.range;if(f<u.from||f>u.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),p=i.lineAt(f,gt.ByPos,s,0,0),g;t.y=="center"?g=(p.top+p.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&f<u.from?g=p.top:g=p.bottom-h,u=new Uu(i.lineAt(g-1e3/2,gt.ByHeight,s,0,0).from,i.lineAt(g+h+1e3/2,gt.ByHeight,s,0,0).to)}}return u}mapViewport(e,t){let r=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new Uu(this.heightMap.lineAt(r,gt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,gt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},r=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,gt.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,gt.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:a}=this;return(e==0||i<=o-Math.max(10,Math.min(-r,250)))&&(t==this.state.doc.length||s>=a+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s<a+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let r=[];for(let i of e)t.touchesRange(i.from,i.to)||r.push(new tm(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return r}ensureLineGaps(e,t){let r=this.heightOracle.lineWrapping,i=r?1e4:2e3,s=i>>1,o=i<<1;if(this.defaultTextDirection!=pt.LTR&&!r)return[];let a=[],u=(h,p,g,y)=>{if(p-h<s)return;let x=this.state.selection.main,w=[x.from];x.empty||w.push(x.to);for(let E of w)if(E>h&&E<p){u(h,E-10,g,y),u(E+10,p,g,y);return}let C=kD(e,E=>E.from>=g.from&&E.to<=g.to&&Math.abs(E.from-h)<s&&Math.abs(E.to-p)<s&&!w.some(T=>E.from<T&&E.to>T));if(!C){if(p<g.to&&t&&r&&t.visibleRanges.some(M=>M.from<=p&&M.to>=p)){let M=t.moveToLineBoundary(te.cursor(p),!1,!0).head;M>h&&(p=M)}let E=this.gapSize(g,h,p,y),T=r||E<2e6?E:2e6;C=new tm(h,p,E,T)}a.push(C)},f=h=>{if(h.length<o||h.type!=cn.Text)return;let p=SD(h.from,h.to,this.stateDeco);if(p.total<o)return;let g=this.scrollTarget?this.scrollTarget.range.head:null,y,x;if(r){let w=i/this.heightOracle.lineLength*this.heightOracle.lineHeight,C,E;if(g!=null){let T=Ku(p,g),M=((this.visibleBottom-this.visibleTop)/2+w)/h.height;C=T-M,E=T+M}else C=(this.visibleTop-h.top-w)/h.height,E=(this.visibleBottom-h.top+w)/h.height;y=qu(p,C),x=qu(p,E)}else{let w=p.total*this.heightOracle.charWidth,C=i*this.heightOracle.charWidth,E=0;if(w>2e6)for(let N of e)N.from>=h.from&&N.from<h.to&&N.size!=N.displaySize&&N.from*this.heightOracle.charWidth+E<this.pixelViewport.left&&(E=N.size-N.displaySize);let T=this.pixelViewport.left+E,M=this.pixelViewport.right+E,P,O;if(g!=null){let N=Ku(p,g),L=((M-T)/2+C)/w;P=N-L,O=N+L}else P=(T-C)/w,O=(M+C)/w;y=qu(p,P),x=qu(p,O)}y>h.from&&u(h.from,y,h,p),x<h.to&&u(x,h.to,h,p)};for(let h of this.viewportLines)Array.isArray(h.type)?h.type.forEach(f):f(h);return a}gapSize(e,t,r,i){let s=Ku(i,r)-Ku(i,t);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){tm.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=De.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let r=[];Ze.spans(t,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s<r.length&&!(i&8);s++){let o=this.visibleRanges[s],a=r[s];(o.from!=a.from||o.to!=a.to)&&(i|=4,e&&e.mapPos(o.from,-1)==a.from&&e.mapPos(o.to,1)==a.to||(i|=8))}return this.visibleRanges=r,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||va(this.heightMap.lineAt(e,gt.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(t=>t.top<=e&&t.bottom>=e)||va(this.heightMap.lineAt(this.scaler.fromDOM(e),gt.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return va(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 Uu{constructor(e,t){this.from=e,this.to=t}}function SD(n,e,t){let r=[],i=n,s=0;return Ze.spans(t,n,e,{span(){},point(o,a){o>i&&(r.push({from:i,to:o}),s+=o-i),i=a}},20),i<e&&(r.push({from:i,to:e}),s+=e-i),{total:s,ranges:r}}function qu({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let r=Math.floor(n*t);for(let i=0;;i++){let{from:s,to:o}=e[i],a=o-s;if(r<=a)return s+r;r-=a}}function Ku(n,e){let t=0;for(let{from:r,to:i}of n.ranges){if(e<=i){t+=e-r;break}t+=i-r}return t/n.total}function kD(n,e){for(let t of n)if(e(t))return t}const Sw={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};class M0{constructor(e,t,r){let i=0,s=0,o=0;this.viewports=r.map(({from:a,to:u})=>{let f=t.lineAt(a,gt.ByPos,e,0,0).top,h=t.lineAt(u,gt.ByPos,e,0,0).bottom;return i+=h-f,{from:a,to:u,top:f,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,r=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return i+(e-r)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);r=s.bottom,i=s.domBottom}}fromDOM(e){for(let t=0,r=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return r+(e-i)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);r=s.bottom,i=s.domBottom}}eq(e){return e instanceof M0?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,r)=>t.from==e.viewports[r].from&&t.to==e.viewports[r].to):!1}}function va(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),r=e.toDOM(n.bottom);return new kr(n.from,n.length,t,r-t,Array.isArray(n._content)?n._content.map(i=>va(i,e)):n._content)}const Qu=ke.define({combine:n=>n.join(" ")}),yg=ke.define({combine:n=>n.indexOf(!0)>-1}),vg=hs.newName(),bC=hs.newName(),SC=hs.newName(),kC={"&light":"."+bC,"&dark":"."+SC};function xg(n,e,t){return new hs(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return n;if(!t||!t[i])throw new RangeError(`Unsupported selector: ${i}`);return t[i]}):n+" "+r}})}const CD=xg("."+vg,{"&":{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":{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-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"},"&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"}},kC),ED={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},nm=Se.ie&&Se.ie_version<=11;class RD{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new rL,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(t=>{for(let r of t)this.queue.push(r);(Se.ie&&Se.ie_version<=11||Se.ios&&e.composing)&&t.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Se.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Se.chrome&&Se.chrome_version<126)&&(this.editContext=new MD(e),e.state.facet(bi)&&(e.contentDOM.editContext=this.editContext.editContext)),nm&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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 t;((t=this.view.docView)===null||t===void 0?void 0:t.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(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.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(t=>{t.length>0&&t[t.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((t,r)=>t!=e[r]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(bi)?r.root.activeElement!=this.dom:!vf(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Se.ie&&Se.ie_version<=11||Se.android&&Se.chrome)&&!r.state.selection.main.empty&&i.focusNode&&Ta(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=_a(e.root);if(!t)return!1;let r=Se.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&TD(this.view,t)||t;if(!r||this.selectionRange.eq(r))return!1;let i=vf(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&sL(this.dom,r)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(r),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let r=this.dom;r;)if(r.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==r?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);for(let r of this.scrollTargets=t)r.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,ED),nm&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),nm&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var r;if(!this.delayedAndroidKey){let i=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ko(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((r=this.delayedAndroidKey)===null||r===void 0)&&r.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 t=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),t==-1?{from:t,to:r}=o:(t=Math.min(o.from,t),r=Math.max(o.to,r)))}return{from:t,to:r,typeOver:i}}readChange(){let{from:e,to:t,typeOver:r}=this.processRecords(),i=this.selectionChanged&&vf(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new UL(this.view,e,t,r);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 t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let r=this.view.state,i=uC(this.view,t);return this.view.state==r&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let r=kw(t,e.previousSibling||e.target.previousSibling,-1),i=kw(t,e.nextSibling||e.target.nextSibling,1);return{from:r?t.posAfter(r):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.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(bi)!=e.state.facet(bi)&&(e.view.contentDOM.editContext=e.state.facet(bi)?this.editContext.editContext:null))}destroy(){var e,t,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.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 kw(n,e,t){for(;e;){let r=Yt.get(e);if(r&&r.parent==n)return r;let i=e.parentNode;e=i!=n.dom?i:t>0?e.nextSibling:e.previousSibling}return null}function Cw(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return Ta(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function TD(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Cw(n,i)}let t=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",r,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",r,!0),t?Cw(n,t):null}class MD{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=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=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,a=this.toEditorPos(r.updateRangeStart),u=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:a,drifted:!1});let f=u-a>r.text.length;a==this.from&&s<this.from?a=s:u==this.to&&s>this.to&&(u=s);let h=fC(e.state.sliceDoc(a,u),r.text,(f?i.from:i.to)-a,f?"end":null);if(!h){let g=te.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));g.main.eq(i)||e.dispatch({selection:g,userEvent:"select"});return}let p={from:h.from+a,to:h.toA+a,insert:lt.of(r.text.slice(h.from,h.toB).split(`
`))};if((Se.mac||Se.android)&&p.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(p={from:a,to:u,insert:lt.of([r.text.replace("."," ")])}),this.pendingContextChange=p,!e.state.readOnly){let g=this.to-this.from+(p.to-p.from+p.insert.length);R0(e,p,te.single(this.toEditorPos(r.selectionStart,g),this.toEditorPos(r.selectionEnd,g)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),p.from<p.to&&!p.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(t.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),a=this.toEditorPos(r.rangeEnd);o<a;o++){let u=e.coordsForChar(o);s=u&&new DOMRect(u.left,u.top,u.right-u.left,u.bottom-u.top)||s||new DOMRect,i.push(s)}t.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,a=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let u=this.toEditorPos(s.rangeStart),f=this.toEditorPos(s.rangeEnd);if(u<f){let h=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;i.push(De.mark({attributes:{style:h}}).range(u,f))}}}e.dispatch({effects:Zk.of(De.set(i))})},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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)t.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=_a(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,a,u,f)=>{if(r)return;let h=f.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(f)){i=this.pendingContextChange=null,t+=h,this.to+=h;return}else i=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+f.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),f.toString()),this.to+=h}t+=h}),i&&!r&&this.revertPending(e.state),!r}update(e){let t=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.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||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+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 t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class ve{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 t;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||iL(e.parent)||document,this.viewState=new bw(e.state||nt.create(e)),e.scrollTo&&e.scrollTo.is(Wu)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Fo).map(i=>new Yp(i));for(let i of this.plugins)i.update(this);this.observer=new RD(this),this.inputState=new GL(this),this.inputState.ensureHandlers(this.plugins),this.docView=new lw(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Gt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,r=!1,i,s=this.state;for(let g of e){if(g.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=g.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,u=null;e.some(g=>g.annotation(yC))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,u=vC(s,o),u||(a=1));let f=this.observer.delayedAndroidKey,h=null;if(f?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(nt.phrases)!=this.state.facet(nt.phrases))return this.setState(s);i=_f.create(this,s,e),i.flags|=a;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let g of e){if(p&&(p=p.map(g.changes)),g.scrollIntoView){let{main:y}=g.state.selection;p=new Qo(y.empty?y:te.cursor(y.head,y.head>y.anchor?-1:1))}for(let y of g.effects)y.is(Wu)&&(p=y.value.clip(this.state))}this.viewState.update(i,p),this.bidiCache=Hf.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(ga)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(g=>g.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Qu)!=i.state.facet(Qu)&&(this.viewState.mustMeasureContent=!0),(t||r||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let g of this.state.facet(dg))try{g(i)}catch(y){In(this.state,y,"update listener")}(u||h)&&Promise.resolve().then(()=>{u&&this.state==u.startState&&this.dispatch(u),h&&!uC(this,h)&&f.force&&Ko(this.contentDOM,f.key,f.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 t=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new bw(e),this.plugins=e.facet(Fo).map(r=>new Yp(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new lw(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Fo),r=e.state.facet(Fo);if(t!=r){let i=[];for(let s of r){let o=t.indexOf(s);if(o<0)i.push(new Yp(s));else{let a=this.plugins[o];a.mustUpdate=e,i.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);t!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(r){In(this.state,r,"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 t=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(jk(r))s=-1,o=this.viewState.heightMap.height;else{let y=this.viewState.scrollAnchorAt(i);s=y.from,o=y.top}this.updateState=1;let u=this.viewState.measure(this);if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let f=[];u&4||([this.measureRequests,f]=[f,this.measureRequests]);let h=f.map(y=>{try{return y.read(this)}catch(x){return In(this.state,x),Ew}}),p=_f.create(this,this.state,[]),g=!1;p.flags|=u,t?t.flags|=u:t=p,this.updateState=2,p.empty||(this.updatePlugins(p),this.inputState.update(p),this.updateAttrs(),g=this.docView.update(p),g&&this.docViewUpdate());for(let y=0;y<f.length;y++)if(h[y]!=Ew)try{let x=f[y];x.write&&x.write(h[y],this)}catch(x){In(this.state,x)}if(g&&this.docView.updateSelection(!0),!p.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 x=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(x>1||x<-1){i=i+x,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(dg))a(t)}get themeClasses(){return vg+" "+(this.state.facet(yg)?SC:bC)+" "+this.state.facet(Qu)}updateAttrs(){let e=Rw(this,eC,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(bi)?"true":"false",class:"cm-content",style:`${Se.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Rw(this,C0,t);let r=this.observer.ignore(()=>{let i=tw(this.contentDOM,this.contentAttrs,t),s=tw(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=t,r}showAnnouncements(e){let t=!0;for(let r of e)for(let i of r.effects)if(i.is(ve.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(ga);let e=this.state.facet(ve.cspNonce);hs.mount(this.root,this.styleModules.concat(CD).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 t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(r=>r.plugin==e)||null),t&&t.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,t,r){return em(this,e,aw(this,e,t,r))}moveByGroup(e,t){return em(this,e,aw(this,e,t,r=>_L(this,e.head,r)))}visualLineSide(e,t){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[t?r.length-1:0];return te.cursor(s.side(t,i)+e.from,s.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,r=!0){return zL(this,e,t,r)}moveVertically(e,t,r){return em(this,e,VL(this,e,t,r))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let r=mg(this,e,t);return r&&r.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),mg(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let r=this.docView.coordsAt(e,t);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(e),s=this.bidiSpans(i),o=s[Si.find(s,e-i.from,-1,t)];return Va(r,o.dir==pt.LTR==t>0)}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(Yk)||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>OD)return Wk(e.length);let t=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Vk(s.isolates,r=iw(this,e))))return s.order;r||(r=iw(this,e));let i=dL(e.text,t,r);return this.bidiCache.push(new Hf(e.from,e.to,t,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Se.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ik(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,t={}){return Wu.of(new Qo(typeof e=="number"?te.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return Wu.of(new Qo(te.cursor(r.from),"start","start",r.top-e,t,!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 Bt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Bt.define(()=>({}),{eventObservers:e})}static theme(e,t){let r=hs.newName(),i=[Qu.of(r),ga.of(xg(`.${r}`,e))];return t&&t.dark&&i.push(yg.of(!0)),i}static baseTheme(e){return ws.lowest(ga.of(xg("."+vg,e,kC)))}static findFromDOM(e){var t;let r=e.querySelector(".cm-content"),i=r&&Yt.get(r)||Yt.get(e);return((t=i==null?void 0:i.root)===null||t===void 0?void 0:t.view)||null}}ve.styleModule=ga;ve.inputHandler=Qk;ve.clipboardInputFilter=S0;ve.clipboardOutputFilter=k0;ve.scrollHandler=Jk;ve.focusChangeEffect=Gk;ve.perLineTextDirection=Yk;ve.exceptionSink=Kk;ve.updateListener=dg;ve.editable=bi;ve.mouseSelectionStyle=qk;ve.dragMovesSelection=Uk;ve.clickAddsSelectionRange=Hk;ve.decorations=$a;ve.blockWrappers=tC;ve.outerDecorations=nC;ve.atomicRanges=mc;ve.bidiIsolatedRanges=rC;ve.scrollMargins=iC;ve.darkTheme=yg;ve.cspNonce=ke.define({combine:n=>n.length?n[0]:""});ve.contentAttributes=C0;ve.editorAttributes=eC;ve.lineWrapping=ve.contentAttributes.of({class:"cm-lineWrapping"});ve.announce=He.define();const OD=4096,Ew={};class Hf{constructor(e,t,r,i,s,o){this.from=e,this.to=t,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:pt.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==i&&!t.touchesRange(o.from,o.to)&&r.push(new Hf(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function Rw(n,e,t){for(let r=n.state.facet(e),i=r.length-1;i>=0;i--){let s=r[i],o=typeof s=="function"?s(n):s;o&&x0(o,t)}return t}const PD=Se.mac?"mac":Se.windows?"win":Se.linux?"linux":"key";function AD(n,e){const t=n.split(/-(?!$)/);let r=t[t.length-1];r=="Space"&&(r=" ");let i,s,o,a;for(let u=0;u<t.length-1;++u){const f=t[u];if(/^(cmd|meta|m)$/i.test(f))a=!0;else if(/^a(lt)?$/i.test(f))i=!0;else if(/^(c|ctrl|control)$/i.test(f))s=!0;else if(/^s(hift)?$/i.test(f))o=!0;else if(/^mod$/i.test(f))e=="mac"?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+f)}return i&&(r="Alt-"+r),s&&(r="Ctrl-"+r),a&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function Gu(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}const ND=ws.default(ve.domEventHandlers({keydown(n,e){return EC(CC(e.state),n,e,"editor")}})),Ha=ke.define({enables:ND}),Tw=new WeakMap;function CC(n){let e=n.facet(Ha),t=Tw.get(e);return t||Tw.set(e,t=ID(e.reduce((r,i)=>r.concat(i),[]))),t}function LD(n,e,t){return EC(CC(n.state),e,n,t)}let ss=null;const DD=4e3;function ID(n,e=PD){let t=Object.create(null),r=Object.create(null),i=(o,a)=>{let u=r[o];if(u==null)r[o]=a;else if(u!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,u,f,h)=>{var p,g;let y=t[o]||(t[o]=Object.create(null)),x=a.split(/ (?!$)/).map(E=>AD(E,e));for(let E=1;E<x.length;E++){let T=x.slice(0,E).join(" ");i(T,!0),y[T]||(y[T]={preventDefault:!0,stopPropagation:!1,run:[M=>{let P=ss={view:M,prefix:T,scope:o};return setTimeout(()=>{ss==P&&(ss=null)},DD),!0}]})}let w=x.join(" ");i(w,!1);let C=y[w]||(y[w]={preventDefault:!1,stopPropagation:!1,run:((g=(p=y._any)===null||p===void 0?void 0:p.run)===null||g===void 0?void 0:g.slice())||[]});u&&C.run.push(u),f&&(C.preventDefault=!0),h&&(C.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let f of a){let h=t[f]||(t[f]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=o;for(let g in h)h[g].run.push(y=>p(y,wg))}let u=o[e]||o.key;if(u)for(let f of a)s(f,u,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(f,"Shift-"+u,o.shift,o.preventDefault,o.stopPropagation)}return t}let wg=null;function EC(n,e,t,r){wg=e;let i=G8(e),s=Pn(i,0),o=Gr(s)==i.length&&i!=" ",a="",u=!1,f=!1,h=!1;ss&&ss.view==t&&ss.scope==r&&(a=ss.prefix+" ",hC.indexOf(e.keyCode)<0&&(f=!0,ss=null));let p=new Set,g=C=>{if(C){for(let E of C.run)if(!p.has(E)&&(p.add(E),E(t)))return C.stopPropagation&&(h=!0),!0;C.preventDefault&&(C.stopPropagation&&(h=!0),f=!0)}return!1},y=n[r],x,w;return y&&(g(y[a+Gu(i,e,!o)])?u=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Se.windows&&e.ctrlKey&&e.altKey)&&!(Se.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(x=ps[e.keyCode])&&x!=i?(g(y[a+Gu(x,e,!0)])||e.shiftKey&&(w=Fa[e.keyCode])!=i&&w!=x&&g(y[a+Gu(w,e,!1)]))&&(u=!0):o&&e.shiftKey&&g(y[a+Gu(i,e,!0)])&&(u=!0),!u&&g(y._any)&&(u=!0)),f&&(u=!0),u&&h&&e.stopPropagation(),wg=null,u}class gc{constructor(e,t,r,i,s){this.className=e,this.left=t,this.top=r,this.width=i,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,r){if(r.empty){let i=e.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let s=RC(e);return[new gc(t,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return jD(e,t,r)}}function RC(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==pt.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Mw(n,e,t,r){let i=n.coordsAtPos(e,t*2);if(!i)return r;let s=n.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,a=n.posAtCoords({x:s.left+1,y:o}),u=n.posAtCoords({x:s.right-1,y:o});return a==null||u==null?r:{from:Math.max(r.from,Math.min(a,u)),to:Math.min(r.to,Math.max(a,u))}}function jD(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let r=Math.max(t.from,n.viewport.from),i=Math.min(t.to,n.viewport.to),s=n.textDirection==pt.LTR,o=n.contentDOM,a=o.getBoundingClientRect(),u=RC(n),f=o.querySelector(".cm-line"),h=f&&window.getComputedStyle(f),p=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),g=a.right-(h?parseInt(h.paddingRight):0),y=pg(n,r,1),x=pg(n,i,-1),w=y.type==cn.Text?y:null,C=x.type==cn.Text?x:null;if(w&&(n.lineWrapping||y.widgetLineBreaks)&&(w=Mw(n,r,1,w)),C&&(n.lineWrapping||x.widgetLineBreaks)&&(C=Mw(n,i,-1,C)),w&&C&&w.from==C.from&&w.to==C.to)return T(M(t.from,t.to,w));{let O=w?M(t.from,null,w):P(y,!1),N=C?M(null,t.to,C):P(x,!0),L=[];return(w||y).to<(C||x).from-(w&&C?1:0)||y.widgetLineBreaks>1&&O.bottom+n.defaultLineHeight/2<N.top?L.push(E(p,O.bottom,g,N.top)):O.bottom<N.top&&n.elementAtHeight((O.bottom+N.top)/2).type==cn.Text&&(O.bottom=N.top=(O.bottom+N.top)/2),T(O).concat(L).concat(T(N))}function E(O,N,L,F){return new gc(e,O-u.left,N-u.top,L-O,F-N)}function T({top:O,bottom:N,horizontal:L}){let F=[];for(let U=0;U<L.length;U+=2)F.push(E(L[U],O,L[U+1],N));return F}function M(O,N,L){let F=1e9,U=-1e9,Q=[];function q(Y,W,_,X,D){let B=n.coordsAtPos(Y,Y==L.to?-2:2),K=n.coordsAtPos(_,_==L.from?2:-2);!B||!K||(F=Math.min(B.top,K.top,F),U=Math.max(B.bottom,K.bottom,U),D==pt.LTR?Q.push(s&&W?p:B.left,s&&X?g:K.right):Q.push(!s&&X?p:K.left,!s&&W?g:B.right))}let H=O??L.from,j=N??L.to;for(let Y of n.visibleRanges)if(Y.to>H&&Y.from<j)for(let W=Math.max(Y.from,H),_=Math.min(Y.to,j);;){let X=n.state.doc.lineAt(W);for(let D of n.bidiSpans(X)){let B=D.from+X.from,K=D.to+X.from;if(B>=_)break;K>W&&q(Math.max(B,W),O==null&&B<=H,Math.min(K,_),N==null&&K>=j,D.dir)}if(W=X.to+1,W>=_)break}return Q.length==0&&q(H,O==null,j,N==null,n.textDirection),{top:F,bottom:U,horizontal:Q}}function P(O,N){let L=a.top+(N?O.top:O.bottom);return{top:L,bottom:L,horizontal:[]}}}function BD(n,e){return n.constructor==e.constructor&&n.eq(e)}class FD{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(wf)!=e.state.facet(wf)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,r=e.facet(wf);for(;t<r.length&&r[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,r)=>!BD(t,this.drawn[r]))){let t=this.dom.firstChild,r=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[r].constructor&&i.update(t,this.drawn[r])?(t=t.nextSibling,r++):this.dom.insertBefore(i.draw(),t);for(;t;){let i=t.nextSibling;t.remove(),t=i}this.drawn=e,Se.safari&&Se.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const wf=ke.define();function TC(n){return[Bt.define(e=>new FD(e,n)),wf.of(n)]}const Ua=ke.define({combine(n){return si(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function zD(n={}){return[Ua.of(n),_D,VD,WD,Xk.of(!0)]}function MC(n){return n.startState.facet(Ua)!=n.state.facet(Ua)}const _D=TC({above:!0,markers(n){let{state:e}=n,t=e.facet(Ua),r=[];for(let i of e.selection.ranges){let s=i==e.selection.main;if(i.empty||t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:te.cursor(i.head,i.head>i.anchor?-1:1);for(let u of gc.forRange(n,o,a))r.push(u)}}return r},update(n,e){n.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=MC(n);return t&&Ow(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Ow(e.state,n)},class:"cm-cursorLayer"});function Ow(n,e){e.style.animationDuration=n.facet(Ua).cursorBlinkRate+"ms"}const VD=TC({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:gc.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||MC(n)},class:"cm-selectionLayer"}),WD=ws.highest(ve.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),OC=He.define({map(n,e){return n==null?null:e.mapPos(n)}}),xa=un.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,r)=>r.is(OC)?r.value:t,n)}}),$D=Bt.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(xa);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(xa)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(xa),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let r=n.scrollDOM.getBoundingClientRect();return{left:t.left-r.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-r.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(xa)!=n&&this.view.dispatch({effects:OC.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function HD(){return[xa,$D]}function Pw(n,e,t,r,i){e.lastIndex=0;for(let s=n.iterRange(t,r),o=t,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)i(o+a.index,a)}function UD(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let r=[];for(let{from:i,to:s}of t)i=Math.max(n.state.doc.lineAt(i).from,i-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),r.length&&r[r.length-1].to>=i?r[r.length-1].to=s:r.push({from:i,to:s});return r}class qD{constructor(e){const{regexp:t,decoration:r,decorate:i,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(a,u,f,h)=>i(h,f,f+a[0].length,a,u);else if(typeof r=="function")this.addMatch=(a,u,f,h)=>{let p=r(a,u,f);p&&h(f,f+a[0].length,p)};else if(r)this.addMatch=(a,u,f,h)=>h(f,f+a[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new Oi,r=t.add.bind(t);for(let{from:i,to:s}of UD(e,this.maxLength))Pw(e.state.doc,this.regexp,i,s,(o,a)=>this.addMatch(a,e,o,r));return t.finish()}updateDeco(e,t){let r=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((s,o,a,u)=>{u>=e.view.viewport.from&&a<=e.view.viewport.to&&(r=Math.min(a,r),i=Math.max(u,i))}),e.viewportMoved||i-r>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),r,i):t}updateRange(e,t,r,i){for(let s of e.visibleRanges){let o=Math.max(s.from,r),a=Math.min(s.to,i);if(a>=o){let u=e.state.doc.lineAt(o),f=u.to<a?e.state.doc.lineAt(a):u,h=Math.max(s.from,u.from),p=Math.min(s.to,f.to);if(this.boundary){for(;o>u.from;o--)if(this.boundary.test(u.text[o-1-u.from])){h=o;break}for(;a<f.to;a++)if(this.boundary.test(f.text[a-f.from])){p=a;break}}let g=[],y,x=(w,C,E)=>g.push(E.range(w,C));if(u==f)for(this.regexp.lastIndex=h-u.from;(y=this.regexp.exec(u.text))&&y.index<p-u.from;)this.addMatch(y,e,y.index+u.from,x);else Pw(e.state.doc,this.regexp,h,p,(w,C)=>this.addMatch(C,e,w,x));t=t.update({filterFrom:h,filterTo:p,filter:(w,C)=>w<h||C>p,add:g})}}return t}}const bg=/x/.unicode!=null?"gu":"g",KD=new RegExp(`[\0-\b
--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,bg),QD={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let rm=null;function GD(){var n;if(rm==null&&typeof document<"u"&&document.body){let e=document.body.style;rm=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return rm||!1}const bf=ke.define({combine(n){let e=si(n,{render:null,specialChars:KD,addSpecialChars:null});return(e.replaceTabs=!GD())&&(e.specialChars=new RegExp("	|"+e.specialChars.source,bg)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,bg)),e}});function YD(n={}){return[bf.of(n),XD()]}let Aw=null;function XD(){return Aw||(Aw=Bt.fromClass(class{constructor(n){this.view=n,this.decorations=De.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(bf)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new qD({regexp:n.specialChars,decoration:(e,t,r)=>{let{doc:i}=t.state,s=Pn(e[0],0);if(s==9){let o=i.lineAt(r),a=t.state.tabSize,u=yl(o.text,a,r-o.from);return De.replace({widget:new tI((a-u%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=De.replace({widget:new eI(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(bf);n.startState.facet(bf)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const JD="•";function ZD(n){return n>=32?JD:n==10?"␤":String.fromCharCode(9216+n)}class eI extends oi{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=ZD(this.code),r=e.state.phrase("Control character")+" "+(QD[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,t);if(i)return i;let s=document.createElement("span");return s.textContent=t,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class tI extends oi{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="	",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function nI(){return iI}const rI=De.line({class:"cm-activeLine"}),iI=Bt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let r of n.state.selection.ranges){let i=n.lineBlockAt(r.head);i.from>e&&(t.push(rI.range(i.from)),e=i.from)}return De.set(t)}},{decorations:n=>n.decorations});class sI extends oi{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Ra(e.firstChild):[];if(!t.length)return null;let r=window.getComputedStyle(e.parentNode),i=Va(t[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function oI(n){let e=Bt.fromClass(class{constructor(t){this.view=t,this.placeholder=n?De.set([De.widget({widget:new sI(n),side:1}).range(0)]):De.none}get decorations(){return this.view.state.doc.length?De.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,ve.contentAttributes.of({"aria-placeholder":n})]:e}const Sg=2e3;function lI(n,e,t){let r=Math.min(e.line,t.line),i=Math.max(e.line,t.line),s=[];if(e.off>Sg||t.off>Sg||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let u=r;u<=i;u++){let f=n.doc.line(u);f.length<=a&&s.push(te.range(f.from+o,f.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let u=r;u<=i;u++){let f=n.doc.line(u),h=tg(f.text,o,n.tabSize,!0);if(h<0)s.push(te.cursor(f.to));else{let p=tg(f.text,a,n.tabSize);s.push(te.range(f.from+h,f.from+p))}}}return s}function aI(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Nw(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),r=n.state.doc.lineAt(t),i=t-r.from,s=i>Sg?-1:i==r.length?aI(n,e.clientX):yl(r.text,n.state.tabSize,t-r.from);return{line:r.number,col:s,off:i}}function cI(n,e){let t=Nw(n,e),r=n.state.selection;return t?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(t.line).from),o=i.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},r=r.map(i.changes)}},get(i,s,o){let a=Nw(n,i);if(!a)return r;let u=lI(n.state,t,a);return u.length?o?te.create(u.concat(r.ranges)):te.create(u):r}}:null}function uI(n){let e=t=>t.altKey&&t.button==0;return ve.mouseSelectionStyle.of((t,r)=>e(r)?cI(t,r):null)}const fI={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},dI={style:"cursor: crosshair"};function hI(n={}){let[e,t]=fI[n.key||"Alt"],r=Bt.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||t(i))},keyup(i){(i.keyCode==e||!t(i))&&this.set(!1)},mousemove(i){this.set(t(i))}}});return[r,ve.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?dI:null})]}const Yu="-10000px";class PC{constructor(e,t,r,i){this.facet=t,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,t){var r;let i=e.state.facet(this.facet),s=i.filter(u=>u);if(i===this.input){for(let u of this.tooltipViews)u.update&&u.update(e);return!1}let o=[],a=t?[]:null;for(let u=0;u<s.length;u++){let f=s[u],h=-1;if(f){for(let p=0;p<this.tooltips.length;p++){let g=this.tooltips[p];g&&g.create==f.create&&(h=p)}if(h<0)o[u]=this.createTooltipView(f,u?o[u-1]:null),a&&(a[u]=!!f.above);else{let p=o[u]=this.tooltipViews[h];a&&(a[u]=t[h]),p.update&&p.update(e)}}}for(let u of this.tooltipViews)o.indexOf(u)<0&&(this.removeTooltipView(u),(r=u.destroy)===null||r===void 0||r.call(u));return t&&(a.forEach((u,f)=>t[f]=u),t.length=a.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function pI(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const im=ke.define({combine:n=>{var e,t,r;return{position:Se.ios?"absolute":((e=n.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(i=>i.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((r=n.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||pI}}}),Lw=new WeakMap,O0=Bt.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(im);this.position=e.position,this.parent=e.parent,this.classes=n.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 PC(n,P0,(t,r)=>this.createTooltip(t,r),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.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 n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,r=n.state.facet(im);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;t=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),r=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",t.dom.appendChild(i)}return t.dom.style.position=this.position,t.dom.style.top=Yu,t.dom.style.left="0px",this.container.insertBefore(t.dom,r),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(n=r.destroy)===null||n===void 0||n.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Se.safari){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(n=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=E0(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(im).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:r,scaleX:i,scaleY:s}=n,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let u=this.manager.tooltips[a],f=this.manager.tooltipViews[a],{dom:h}=f,p=n.pos[a],g=n.size[a];if(!p||u.clip!==!1&&(p.bottom<=Math.max(t.top,r.top)||p.top>=Math.min(t.bottom,r.bottom)||p.right<Math.max(t.left,r.left)-.1||p.left>Math.min(t.right,r.right)+.1)){h.style.top=Yu;continue}let y=u.arrow?f.dom.querySelector(".cm-tooltip-arrow"):null,x=y?7:0,w=g.right-g.left,C=(e=Lw.get(f))!==null&&e!==void 0?e:g.bottom-g.top,E=f.offset||gI,T=this.view.textDirection==pt.LTR,M=g.width>r.right-r.left?T?r.left:r.right-g.width:T?Math.max(r.left,Math.min(p.left-(y?14:0)+E.x,r.right-w)):Math.min(Math.max(r.left,p.left-w+(y?14:0)-E.x),r.right-w),P=this.above[a];!u.strictSide&&(P?p.top-C-x-E.y<r.top:p.bottom+C+x+E.y>r.bottom)&&P==r.bottom-p.bottom>p.top-r.top&&(P=this.above[a]=!P);let O=(P?p.top-r.top:r.bottom-p.bottom)-x;if(O<C&&f.resize!==!1){if(O<this.view.defaultLineHeight){h.style.top=Yu;continue}Lw.set(f,C),h.style.height=(C=O)/s+"px"}else h.style.height&&(h.style.height="");let N=P?p.top-C-x-E.y:p.bottom+x+E.y,L=M+w;if(f.overlap!==!0)for(let F of o)F.left<L&&F.right>M&&F.top<N+C&&F.bottom>N&&(N=P?F.top-C-2-x:F.bottom+x+2);if(this.position=="absolute"?(h.style.top=(N-n.parent.top)/s+"px",Dw(h,(M-n.parent.left)/i)):(h.style.top=N/s+"px",Dw(h,M/i)),y){let F=p.left+(T?E.x:-E.x)-(M+14-7);y.style.left=F/i+"px"}f.overlap!==!0&&o.push({left:M,top:N,right:L,bottom:N+C}),h.classList.toggle("cm-tooltip-above",P),h.classList.toggle("cm-tooltip-below",!P),f.positioned&&f.positioned(n.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 n of this.manager.tooltipViews)n.dom.style.top=Yu}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Dw(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const mI=ve.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"}}}),gI={x:0,y:0},P0=ke.define({enables:[O0,mI]}),Uf=ke.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Id{static create(e){return new Id(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new PC(e,Uf,(t,r)=>this.createHostedView(t,r),t=>t.dom.remove())}createHostedView(e,t){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(t===void 0)t=i;else if(t!==i)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const yI=P0.compute([Uf],n=>{let e=n.facet(Uf);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var r;return(r=t.end)!==null&&r!==void 0?r:t.pos})),create:Id.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class vI{constructor(e,t,r,i,s){this.view=e,this.source=t,this.field=r,this.setHover=i,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,r=e.docView.tile.nearest(t.target);if(!r)return;let i,s=1;if(r.isWidget())i=r.posAtStart;else{if(i=e.posAtCoords(t),i==null)return;let a=e.coordsAtPos(i);if(!a||t.y<a.top||t.y>a.bottom||t.x<a.left-e.defaultCharacterWidth||t.x>a.right+e.defaultCharacterWidth)return;let u=e.bidiSpans(e.state.doc.lineAt(i)).find(h=>h.from<=i&&h.to>=i),f=u&&u.dir==pt.RTL?-1:1;s=t.x<a.left?-f:f}let o=this.source(e,i,s);if(o!=null&&o.then){let a=this.pending={pos:i};o.then(u=>{this.pending==a&&(this.pending=null,u&&!(Array.isArray(u)&&!u.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(u)?u:[u])}))},u=>In(e.state,u,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(O0),t=e?e.manager.tooltips.findIndex(r=>r.create==Id.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&s&&!xI(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,a=(r=(t=i[0])===null||t===void 0?void 0:t.end)!==null&&r!==void 0?r:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!wI(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=r=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Xu=4;function xI(n,e){let{left:t,right:r,top:i,bottom:s}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();i=Math.min(a.top,i),s=Math.max(a.bottom,s)}return e.clientX>=t-Xu&&e.clientX<=r+Xu&&e.clientY>=i-Xu&&e.clientY<=s+Xu}function wI(n,e,t,r,i,s){let o=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,a)<i)return!1;let u=n.posAtCoords({x:r,y:i},!1);return u>=e&&u<=t}function bI(n,e={}){let t=He.define(),r=un.define({create(){return[]},update(i,s){if(i.length&&(e.hideOnChange&&(s.docChanged||s.selection)?i=[]:e.hideOn&&(i=i.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of i){let u=s.changes.mapPos(a.pos,-1,bn.TrackDel);if(u!=null){let f=Object.assign(Object.create(null),a);f.pos=u,f.end!=null&&(f.end=s.changes.mapPos(f.end)),o.push(f)}}i=o}for(let o of s.effects)o.is(t)&&(i=o.value),o.is(SI)&&(i=[]);return i},provide:i=>Uf.from(i)});return{active:r,extension:[r,Bt.define(i=>new vI(i,n,r,t,e.hoverTime||300)),yI]}}function AC(n,e){let t=n.plugin(O0);if(!t)return null;let r=t.manager.tooltips.indexOf(e);return r<0?null:t.manager.tooltipViews[r]}const SI=He.define(),Iw=ke.define({combine(n){let e,t;for(let r of n)e=e||r.topContainer,t=t||r.bottomContainer;return{topContainer:e,bottomContainer:t}}});function qa(n,e){let t=n.plugin(NC),r=t?t.specs.indexOf(e):-1;return r>-1?t.panels[r]:null}const NC=Bt.fromClass(class{constructor(n){this.input=n.state.facet(Ka),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Iw);this.top=new Ju(n,!0,e.topContainer),this.bottom=new Ju(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(Iw);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ju(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ju(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Ka);if(t!=this.input){let r=t.filter(u=>u),i=[],s=[],o=[],a=[];for(let u of r){let f=this.specs.indexOf(u),h;f<0?(h=u(n.view),a.push(h)):(h=this.panels[f],h.update&&h.update(n)),i.push(h),(h.top?s:o).push(h)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let u of a)u.dom.classList.add("cm-panel"),u.mount&&u.mount()}else for(let r of this.panels)r.update&&r.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>ve.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Ju{constructor(e,t,r){this.view=e,this.top=t,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=jw(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=jw(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function jw(n){let e=n.nextSibling;return n.remove(),e}const Ka=ke.define({enables:NC});class Ai extends ds{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ai.prototype.elementClass="";Ai.prototype.toDOM=void 0;Ai.prototype.mapMode=bn.TrackBefore;Ai.prototype.startSide=Ai.prototype.endSide=-1;Ai.prototype.point=!0;const Sf=ke.define(),kI=ke.define(),CI={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Ze.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Oa=ke.define();function EI(n){return[LC(),Oa.of({...CI,...n})]}const Bw=ke.define({combine:n=>n.some(e=>e)});function LC(n){return[RI]}const RI=Bt.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(Oa).map(e=>new zw(n,e)),this.fixed=!n.state.facet(Bw);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,r=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(r<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Bw)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=Ze.iter(this.view.state.facet(Sf),this.view.viewport.from),r=[],i=this.gutters.map(s=>new TI(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==cn.Text&&o){kg(t,r,a.from);for(let u of i)u.line(this.view,a,r);o=!1}else if(a.widget)for(let u of i)u.widget(this.view,a)}else if(s.type==cn.Text){kg(t,r,s.from);for(let o of i)o.line(this.view,s,r)}else if(s.widget)for(let o of i)o.widget(this.view,s);for(let s of i)s.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(Oa),t=n.state.facet(Oa),r=n.docChanged||n.heightChanged||n.viewportChanged||!Ze.eq(n.startState.facet(Sf),n.state.facet(Sf),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let i of this.gutters)i.update(n)&&(r=!0);else{r=!0;let i=[];for(let s of t){let o=e.indexOf(s);o<0?i.push(new zw(this.view,s)):(this.gutters[o].update(n),i.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>ve.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let r=t.dom.offsetWidth*e.scaleX,i=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==pt.LTR?{left:r,right:i}:{right:r,left:i}})});function Fw(n){return Array.isArray(n)?n:[n]}function kg(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class TI{constructor(e,t,r){this.gutter=e,this.height=r,this.i=0,this.cursor=Ze.iter(e.markers,t.from)}addElement(e,t,r){let{gutter:i}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==i.elements.length){let a=new DC(e,o,s,r);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,o,s,r);this.height=t.bottom,this.i++}line(e,t,r){let i=[];kg(this.cursor,i,t.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(e,t,i);s&&i.unshift(s);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,i)}widget(e,t){let r=this.gutter.config.widgetMarker(e,t.widget,t),i=r?[r]:null;for(let s of e.state.facet(kI)){let o=s(e,t.widget,t);o&&(i||(i=[])).push(o)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class zw{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in t.domEventHandlers)this.dom.addEventListener(r,i=>{let s=i.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let u=s.getBoundingClientRect();o=(u.top+u.bottom)/2}else o=i.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[r](e,a,i)&&i.preventDefault()});this.markers=Fw(t.markers(e)),t.initialSpacer&&(this.spacer=new DC(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Fw(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let r=e.view.viewport;return!Ze.eq(this.markers,t,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class DC{constructor(e,t,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,r,i)}update(e,t,r,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),MI(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,o=0;;){let a=o,u=s<t.length?t[s++]:null,f=!1;if(u){let h=u.elementClass;h&&(r+=" "+h);for(let p=o;p<this.markers.length;p++)if(this.markers[p].compare(u)){a=p,f=!0;break}}else a=this.markers.length;for(;o<a;){let h=this.markers[o++];if(h.toDOM){h.destroy(i);let p=i.nextSibling;i.remove(),i=p}}if(!u)break;u.toDOM&&(f?i=i.nextSibling:this.dom.insertBefore(u.toDOM(e),i)),f&&o++}this.dom.className=r,this.markers=t}destroy(){this.setMarkers(null,[])}}function MI(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const OI=ke.define(),PI=ke.define(),zo=ke.define({combine(n){return si(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let r=Object.assign({},e);for(let i in t){let s=r[i],o=t[i];r[i]=s?(a,u,f)=>s(a,u,f)||o(a,u,f):o}return r}})}});class sm extends Ai{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function om(n,e){return n.state.facet(zo).formatNumber(e,n.state)}const AI=Oa.compute([zo],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(OI)},lineMarker(e,t,r){return r.some(i=>i.toDOM)?null:new sm(om(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,r)=>{for(let i of e.state.facet(PI)){let s=i(e,t,r);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(zo)!=e.state.facet(zo),initialSpacer(e){return new sm(om(e,_w(e.state.doc.lines)))},updateSpacer(e,t){let r=om(t.view,_w(t.view.state.doc.lines));return r==e.number?e:new sm(r)},domEventHandlers:n.facet(zo).domEventHandlers,side:"before"}));function NI(n={}){return[zo.of(n),LC(),AI]}function _w(n){let e=9;for(;e<n;)e=e*10+9;return e}const LI=new class extends Ai{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},DI=Sf.compute(["selection"],n=>{let e=[],t=-1;for(let r of n.selection.ranges){let i=n.doc.lineAt(r.head).from;i>t&&(t=i,e.push(LI.range(i)))}return Ze.of(e)});function II(){return DI}const IC=1024;let jI=0;class lm{constructor(e,t){this.from=e,this.to=t}}class Ge{constructor(e={}){this.id=jI++,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=zn.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}}Ge.closedBy=new Ge({deserialize:n=>n.split(" ")});Ge.openedBy=new Ge({deserialize:n=>n.split(" ")});Ge.group=new Ge({deserialize:n=>n.split(" ")});Ge.isolate=new Ge({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});Ge.contextHash=new Ge({perNode:!0});Ge.lookAhead=new Ge({perNode:!0});Ge.mounted=new Ge({perNode:!0});class Pa{constructor(e,t,r,i=!1){this.tree=e,this.overlay=t,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[Ge.mounted.id]}}const BI=Object.create(null);class zn{constructor(e,t,r,i=0){this.name=e,this.props=t,this.id=r,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):BI,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new zn(e.name||"",t,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return i}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 t=this.prop(Ge.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let i of r.split(" "))t[i]=e[r];return r=>{for(let i=r.prop(Ge.group),s=-1;s<(i?i.length:0);s++){let o=t[s<0?r.name:i[s]];if(o)return o}}}}zn.none=new zn("",Object.create(null),0,8);class A0{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);if(o){i||(i=Object.assign({},r.props));let a=o[1],u=o[0];u.combine&&u.id in i&&(a=u.combine(i[u.id],a)),i[u.id]=a}}t.push(i?new zn(r.name,i,r.id,r.flags):r)}return new A0(t)}}const Zu=new WeakMap,Vw=new WeakMap;var Ot;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(Ot||(Ot={}));class jt{constructor(e,t,r,i,s){if(this.type=e,this.children=t,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=Pa.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let i=r.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Eg(this.topNode,e)}cursorAt(e,t=0,r=0){let i=Zu.get(this)||this.topNode,s=new Eg(i);return s.moveTo(e,t),Zu.set(this,s._tree),s}get topNode(){return new ur(this,0,0,null)}resolve(e,t=0){let r=Qa(Zu.get(this)||this.topNode,e,t,!1);return Zu.set(this,r),r}resolveInner(e,t=0){let r=Qa(Vw.get(this)||this.topNode,e,t,!0);return Vw.set(this,r),r}resolveStack(e,t=0){return _I(this,e,t)}iterate(e){let{enter:t,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&Ot.IncludeAnonymous)>0;for(let u=this.cursor(o|Ot.IncludeAnonymous);;){let f=!1;if(u.from<=s&&u.to>=i&&(!a&&u.type.isAnonymous||t(u)!==!1)){if(u.firstChild())continue;f=!0}for(;f&&r&&(a||!u.type.isAnonymous)&&r(u),!u.nextSibling();){if(!u.parent())return;f=!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 t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:D0(zn.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,i)=>new jt(this.type,t,r,i,this.propValues),e.makeTree||((t,r,i)=>new jt(zn.none,t,r,i)))}static build(e){return VI(e)}}jt.empty=new jt(zn.none,[],[],0);class N0{constructor(e,t){this.buffer=e,this.index=t}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 N0(this.buffer,this.index)}}class gs{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return zn.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],i=this.set.types[t],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,r,i,s){let{buffer:o}=this,a=-1;for(let u=e;u!=t&&!(jC(s,i,o[u+1],o[u+2])&&(a=u,r>0));u=o[u+3]);return a}slice(e,t,r){let i=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,u=0;a<t;){s[u++]=i[a++],s[u++]=i[a++]-r;let f=s[u++]=i[a++]-r;s[u++]=i[a++]-e,o=Math.max(o,f)}return new gs(s,o,this.set)}}function jC(n,e,t,r){switch(n){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function Qa(n,e,t,r){for(var i;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!r&&n instanceof ur&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=r?0:Ot.IgnoreOverlays;if(r)for(let o=n,a=o.parent;a;o=a,a=o.parent)o instanceof ur&&o.index<0&&((i=a.enter(e,t,s))===null||i===void 0?void 0:i.from)!=o.from&&(n=a);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}class BC{cursor(e=0){return new Eg(this,e)}getChild(e,t=null,r=null){let i=Ww(this,e,t,r);return i.length?i[0]:null}getChildren(e,t=null,r=null){return Ww(this,e,t,r)}resolve(e,t=0){return Qa(this,e,t,!1)}resolveInner(e,t=0){return Qa(this,e,t,!0)}matchContext(e){return Cg(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),r=this;for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(r=t,t=i.prevSibling):t=i}return r}get node(){return this}get next(){return this.parent}}class ur extends BC{constructor(e,t,r,i){super(),this._tree=e,this.from=t,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,i,s=0){var o;for(let a=this;;){for(let{children:u,positions:f}=a._tree,h=t>0?u.length:-1;e!=h;e+=t){let p=u[e],g=f[e]+a.from;if(!(!(s&Ot.EnterBracketed&&p instanceof jt&&((o=Pa.get(p))===null||o===void 0?void 0:o.overlay)===null&&(g>=r||g+p.length<=r))&&!jC(i,r,g,g+p.length))){if(p instanceof gs){if(s&Ot.ExcludeBuffers)continue;let y=p.findChild(0,p.buffer.length,t,r-g,i);if(y>-1)return new as(new FI(a,p,e,g),null,y)}else if(s&Ot.IncludeAnonymous||!p.type.isAnonymous||L0(p)){let y;if(!(s&Ot.IgnoreMounts)&&(y=Pa.get(p))&&!y.overlay)return new ur(y.tree,g,e,a);let x=new ur(p,g,e,a);return s&Ot.IncludeAnonymous||!x.type.isAnonymous?x:x.nextChild(t<0?p.children.length-1:0,t,r,i,s)}}}if(s&Ot.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))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,t,r=0){let i;if(!(r&Ot.IgnoreOverlays)&&(i=Pa.get(this._tree))&&i.overlay){let s=e-this.from,o=r&Ot.EnterBracketed&&i.bracketed;for(let{from:a,to:u}of i.overlay)if((t>0||o?a<=s:a<s)&&(t<0||o?u>=s:u>s))return new ur(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}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 Ww(n,e,t,r){let i=n.cursor(),s=[];if(!i.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=i.type.is(t),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function Cg(n,e,t=e.length-1){for(let r=n;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}class FI{constructor(e,t,r,i){this.parent=e,this.buffer=t,this.index=r,this.start=i}}class as extends BC{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,t,r){super(),this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,r);return s<0?null:new as(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,t,r=0){if(r&Ot.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new as(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,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new as(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new as(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),t.push(0)}return new jt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function FC(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let r=t instanceof ur&&t.index<0?null:t.parent,i=n.slice();return r?i[e]=r:i.splice(e,1),new zI(i,t)}class zI{constructor(e,t){this.heads=e,this.node=t}get next(){return FC(this.heads)}}function _I(n,e,t){let r=n.resolveInner(e,t),i=null;for(let s=r instanceof ur?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,t)),s=o}else{let o=Pa.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new ur(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Qa(a,e,t,!1))}}return i?FC(i):r}class Eg{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Ot.EnterBracketed,e instanceof ur)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,t){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof ur?(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,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,r);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,t,r=this.mode){return this.buffer?r&Ot.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ot.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ot.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:t}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<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 t,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:r}=i)}else({index:t,_parent:r}=this._tree);for(;r;{index:t,_parent:r}=r)if(t>-1)for(let s=t+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&Ot.IncludeAnonymous||a instanceof gs||!a.type.isAnonymous||L0(a))return!1}return!0}move(e,t){if(t&&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,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)t=new as(this.buffer,t,this.stack[i]);return this.bufferNode=new as(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return Cg(this.node.parent,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return Cg(this._tree,e,i);let o=r[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function L0(n){return n.children.some(e=>e instanceof gs||!e.type.isAnonymous||L0(e))}function VI(n){var e;let{buffer:t,nodeSet:r,maxBufferLength:i=IC,reused:s=[],minRepeatType:o=r.types.length}=n,a=Array.isArray(t)?new N0(t,t.length):t,u=r.types,f=0,h=0;function p(O,N,L,F,U,Q){let{id:q,start:H,end:j,size:Y}=a,W=h,_=f;if(Y<0)if(a.next(),Y==-1){let A=s[q];L.push(A),F.push(H-O);return}else if(Y==-3){f=q;return}else if(Y==-4){h=q;return}else throw new RangeError(`Unrecognized record size: ${Y}`);let X=u[q],D,B,K=H-O;if(j-H<=i&&(B=C(a.pos-N,U))){let A=new Uint16Array(B.size-B.skip),$=a.pos-B.size,oe=A.length;for(;a.pos>$;)oe=E(B.start,A,oe);D=new gs(A,j-B.start,r),K=B.start-O}else{let A=a.pos-Y;a.next();let $=[],oe=[],ce=q>=o?q:-1,me=0,le=j;for(;a.pos>A;)ce>=0&&a.id==ce&&a.size>=0?(a.end<=le-i&&(x($,oe,H,me,a.end,le,ce,W,_),me=$.length,le=a.end),a.next()):Q>2500?g(H,A,$,oe):p(H,A,$,oe,ce,Q+1);if(ce>=0&&me>0&&me<$.length&&x($,oe,H,me,H,le,ce,W,_),$.reverse(),oe.reverse(),ce>-1&&me>0){let de=y(X,_);D=D0(X,$,oe,0,$.length,0,j-H,de,de)}else D=w(X,$,oe,j-H,W-j,_)}L.push(D),F.push(K)}function g(O,N,L,F){let U=[],Q=0,q=-1;for(;a.pos>N;){let{id:H,start:j,end:Y,size:W}=a;if(W>4)a.next();else{if(q>-1&&j<q)break;q<0&&(q=Y-i),U.push(H,j,Y),Q++,a.next()}}if(Q){let H=new Uint16Array(Q*4),j=U[U.length-2];for(let Y=U.length-3,W=0;Y>=0;Y-=3)H[W++]=U[Y],H[W++]=U[Y+1]-j,H[W++]=U[Y+2]-j,H[W++]=W;L.push(new gs(H,U[2]-j,r)),F.push(j-O)}}function y(O,N){return(L,F,U)=>{let Q=0,q=L.length-1,H,j;if(q>=0&&(H=L[q])instanceof jt){if(!q&&H.type==O&&H.length==U)return H;(j=H.prop(Ge.lookAhead))&&(Q=F[q]+H.length+j)}return w(O,L,F,U,Q,N)}}function x(O,N,L,F,U,Q,q,H,j){let Y=[],W=[];for(;O.length>F;)Y.push(O.pop()),W.push(N.pop()+L-U);O.push(w(r.types[q],Y,W,Q-U,H-Q,j)),N.push(U-L)}function w(O,N,L,F,U,Q,q){if(Q){let H=[Ge.contextHash,Q];q=q?[H].concat(q):[H]}if(U>25){let H=[Ge.lookAhead,U];q=q?[H].concat(q):[H]}return new jt(O,N,L,F,q)}function C(O,N){let L=a.fork(),F=0,U=0,Q=0,q=L.end-i,H={size:0,start:0,skip:0};e:for(let j=L.pos-O;L.pos>j;){let Y=L.size;if(L.id==N&&Y>=0){H.size=F,H.start=U,H.skip=Q,Q+=4,F+=4,L.next();continue}let W=L.pos-Y;if(Y<0||W<j||L.start<q)break;let _=L.id>=o?4:0,X=L.start;for(L.next();L.pos>W;){if(L.size<0)if(L.size==-3||L.size==-4)_+=4;else break e;else L.id>=o&&(_+=4);L.next()}U=X,F+=Y,Q+=_}return(N<0||F==O)&&(H.size=F,H.start=U,H.skip=Q),H.size>4?H:void 0}function E(O,N,L){let{id:F,start:U,end:Q,size:q}=a;if(a.next(),q>=0&&F<o){let H=L;if(q>4){let j=a.pos-(q-4);for(;a.pos>j;)L=E(O,N,L)}N[--L]=H,N[--L]=Q-O,N[--L]=U-O,N[--L]=F}else q==-3?f=F:q==-4&&(h=F);return L}let T=[],M=[];for(;a.pos>0;)p(n.start||0,n.bufferStart||0,T,M,-1,0);let P=(e=n.length)!==null&&e!==void 0?e:T.length?M[0]+T[0].length:0;return new jt(u[n.topID],T.reverse(),M.reverse(),P)}const $w=new WeakMap;function kf(n,e){if(!n.isAnonymous||e instanceof gs||e.type!=n)return 1;let t=$w.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=n||!(r instanceof jt)){t=1;break}t+=kf(n,r)}$w.set(e,t)}return t}function D0(n,e,t,r,i,s,o,a,u){let f=0;for(let x=r;x<i;x++)f+=kf(n,e[x]);let h=Math.ceil(f*1.5/8),p=[],g=[];function y(x,w,C,E,T){for(let M=C;M<E;){let P=M,O=w[M],N=kf(n,x[M]);for(M++;M<E;M++){let L=kf(n,x[M]);if(N+L>=h)break;N+=L}if(M==P+1){if(N>h){let L=x[P];y(L.children,L.positions,0,L.children.length,w[P]+T);continue}p.push(x[P])}else{let L=w[M-1]+x[M-1].length-O;p.push(D0(n,x,w,P,M,O,L,null,u))}g.push(O+T-s)}}return y(e,t,r,i,0),(a||u)(p,g,o)}class Js{constructor(e,t,r,i,s=!1,o=!1){this.from=e,this.to=t,this.tree=r,this.offset=i,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,t=[],r=!1){let i=[new Js(0,e.length,e,0,!1,r)];for(let s of t)s.to>e.length&&i.push(s);return i}static applyChanges(e,t,r=128){if(!t.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,u=0,f=0;;a++){let h=a<t.length?t[a]:null,p=h?h.fromA:1e9;if(p-u>=r)for(;o&&o.from<p;){let g=o;if(u>=g.from||p<=g.to||f){let y=Math.max(g.from,u)-f,x=Math.min(g.to,p)-f;g=y>=x?null:new Js(y,x,g.tree,g.offset+f,a>0,!!h)}if(g&&i.push(g),o.to>p)break;o=s<e.length?e[s++]:null}if(!h)break;u=h.toA,f=h.toA-h.toB}return i}}class zC{startParse(e,t,r){return typeof e=="string"&&(e=new WI(e)),r=r?r.length?r.map(i=>new lm(i.from,i.to)):[new lm(0,0)]:[new lm(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let i=this.startParse(e,t,r);for(;;){let s=i.advance();if(s)return s}}}class WI{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new Ge({perNode:!0});let $I=0;class rr{constructor(e,t,r,i){this.name=e,this.set=t,this.base=r,this.modified=i,this.id=$I++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let r=typeof e=="string"?e:"?";if(e instanceof rr&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let i=new rr(r,[],null,[]);if(i.set.push(i),t)for(let s of t.set)i.set.push(s);return i}static defineModifier(e){let t=new qf(e);return r=>r.modified.indexOf(t)>-1?r:qf.get(r.base||r,r.modified.concat(t).sort((i,s)=>i.id-s.id))}}let HI=0;class qf{constructor(e){this.name=e,this.instances=[],this.id=HI++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find(a=>a.base==e&&UI(t,a.modified));if(r)return r;let i=[],s=new rr(e.name,i,e,t);for(let a of t)a.instances.push(s);let o=qI(t);for(let a of e.set)if(!a.modified.length)for(let u of o)i.push(qf.get(a,u));return s}}function UI(n,e){return n.length==e.length&&n.every((t,r)=>t==e[r])}function qI(n){let e=[[]];for(let t=0;t<n.length;t++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(n[t]));return e.sort((t,r)=>r.length-t.length)}function _C(n){let e=Object.create(null);for(let t in n){let r=n[t];Array.isArray(r)||(r=[r]);for(let i of t.split(" "))if(i){let s=[],o=2,a=i;for(let p=0;;){if(a=="..."&&p>0&&p+3==i.length){o=1;break}let g=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!g)throw new RangeError("Invalid path: "+i);if(s.push(g[0]=="*"?"":g[0][0]=='"'?JSON.parse(g[0]):g[0]),p+=g[0].length,p==i.length)break;let y=i[p++];if(p==i.length&&y=="!"){o=0;break}if(y!="/")throw new RangeError("Invalid path: "+i);a=i.slice(p)}let u=s.length-1,f=s[u];if(!f)throw new RangeError("Invalid path: "+i);let h=new Ga(r,o,u>0?s.slice(0,u):null);e[f]=h.sort(e[f])}}return VC.add(e)}const VC=new Ge({combine(n,e){let t,r,i;for(;n||e;){if(!n||e&&n.depth>=e.depth?(i=e,e=e.next):(i=n,n=n.next),t&&t.mode==i.mode&&!i.context&&!t.context)continue;let s=new Ga(i.tags,i.mode,i.context);t?t.next=s:r=s,t=s}return r}});class Ga{constructor(e,t,r,i){this.tags=e,this.mode=t,this.context=r,this.next=i}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}}Ga.empty=new Ga([],2,null);function WC(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let u of a.set){let f=t[u.id];if(f){o=o?o+" "+f:f;break}}return o},scope:r}}function KI(n,e){let t=null;for(let r of n){let i=r.style(e);i&&(t=t?t+" "+i:i)}return t}function QI(n,e,t,r=0,i=n.length){let s=new GI(r,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),r,i,"",s.highlighters),s.flush(i)}class GI{constructor(e,t,r){this.at=e,this.highlighters=t,this.span=r,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,r,i,s){let{type:o,from:a,to:u}=e;if(a>=r||u<=t)return;o.isTop&&(s=this.highlighters.filter(y=>!y.scope||y.scope(o)));let f=i,h=YI(e)||Ga.empty,p=KI(s,h.tags);if(p&&(f&&(f+=" "),f+=p,h.mode==1&&(i+=(i?" ":"")+p)),this.startSpan(Math.max(t,a),f),h.opaque)return;let g=e.tree&&e.tree.prop(Ge.mounted);if(g&&g.overlay){let y=e.node.enter(g.overlay[0].from+a,1),x=this.highlighters.filter(C=>!C.scope||C.scope(g.tree.type)),w=e.firstChild();for(let C=0,E=a;;C++){let T=C<g.overlay.length?g.overlay[C]:null,M=T?T.from+a:u,P=Math.max(t,E),O=Math.min(r,M);if(P<O&&w)for(;e.from<O&&(this.highlightRange(e,P,O,i,s),this.startSpan(Math.min(O,e.to),f),!(e.to>=M||!e.nextSibling())););if(!T||M>r)break;E=T.to+a,E>t&&(this.highlightRange(y.cursor(),Math.max(t,T.from+a),Math.min(r,E),"",x),this.startSpan(Math.min(r,E),f))}w&&e.parent()}else if(e.firstChild()){g&&(i="");do if(!(e.to<=t)){if(e.from>=r)break;this.highlightRange(e,t,r,i,s),this.startSpan(Math.min(r,e.to),f)}while(e.nextSibling());e.parent()}}}function YI(n){let e=n.type.prop(VC);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const ge=rr.define,ef=ge(),rs=ge(),Hw=ge(rs),Uw=ge(rs),is=ge(),tf=ge(is),am=ge(is),Ur=ge(),Bs=ge(Ur),$r=ge(),Hr=ge(),Rg=ge(),fa=ge(Rg),nf=ge(),ie={comment:ef,lineComment:ge(ef),blockComment:ge(ef),docComment:ge(ef),name:rs,variableName:ge(rs),typeName:Hw,tagName:ge(Hw),propertyName:Uw,attributeName:ge(Uw),className:ge(rs),labelName:ge(rs),namespace:ge(rs),macroName:ge(rs),literal:is,string:tf,docString:ge(tf),character:ge(tf),attributeValue:ge(tf),number:am,integer:ge(am),float:ge(am),bool:ge(is),regexp:ge(is),escape:ge(is),color:ge(is),url:ge(is),keyword:$r,self:ge($r),null:ge($r),atom:ge($r),unit:ge($r),modifier:ge($r),operatorKeyword:ge($r),controlKeyword:ge($r),definitionKeyword:ge($r),moduleKeyword:ge($r),operator:Hr,derefOperator:ge(Hr),arithmeticOperator:ge(Hr),logicOperator:ge(Hr),bitwiseOperator:ge(Hr),compareOperator:ge(Hr),updateOperator:ge(Hr),definitionOperator:ge(Hr),typeOperator:ge(Hr),controlOperator:ge(Hr),punctuation:Rg,separator:ge(Rg),bracket:fa,angleBracket:ge(fa),squareBracket:ge(fa),paren:ge(fa),brace:ge(fa),content:Ur,heading:Bs,heading1:ge(Bs),heading2:ge(Bs),heading3:ge(Bs),heading4:ge(Bs),heading5:ge(Bs),heading6:ge(Bs),contentSeparator:ge(Ur),list:ge(Ur),quote:ge(Ur),emphasis:ge(Ur),strong:ge(Ur),link:ge(Ur),monospace:ge(Ur),strikethrough:ge(Ur),inserted:ge(),deleted:ge(),changed:ge(),invalid:ge(),meta:nf,documentMeta:ge(nf),annotation:ge(nf),processingInstruction:ge(nf),definition:rr.defineModifier("definition"),constant:rr.defineModifier("constant"),function:rr.defineModifier("function"),standard:rr.defineModifier("standard"),local:rr.defineModifier("local"),special:rr.defineModifier("special")};for(let n in ie){let e=ie[n];e instanceof rr&&(e.name=n)}WC([{tag:ie.link,class:"tok-link"},{tag:ie.heading,class:"tok-heading"},{tag:ie.emphasis,class:"tok-emphasis"},{tag:ie.strong,class:"tok-strong"},{tag:ie.keyword,class:"tok-keyword"},{tag:ie.atom,class:"tok-atom"},{tag:ie.bool,class:"tok-bool"},{tag:ie.url,class:"tok-url"},{tag:ie.labelName,class:"tok-labelName"},{tag:ie.inserted,class:"tok-inserted"},{tag:ie.deleted,class:"tok-deleted"},{tag:ie.literal,class:"tok-literal"},{tag:ie.string,class:"tok-string"},{tag:ie.number,class:"tok-number"},{tag:[ie.regexp,ie.escape,ie.special(ie.string)],class:"tok-string2"},{tag:ie.variableName,class:"tok-variableName"},{tag:ie.local(ie.variableName),class:"tok-variableName tok-local"},{tag:ie.definition(ie.variableName),class:"tok-variableName tok-definition"},{tag:ie.special(ie.variableName),class:"tok-variableName2"},{tag:ie.definition(ie.propertyName),class:"tok-propertyName tok-definition"},{tag:ie.typeName,class:"tok-typeName"},{tag:ie.namespace,class:"tok-namespace"},{tag:ie.className,class:"tok-className"},{tag:ie.macroName,class:"tok-macroName"},{tag:ie.propertyName,class:"tok-propertyName"},{tag:ie.operator,class:"tok-operator"},{tag:ie.comment,class:"tok-comment"},{tag:ie.meta,class:"tok-meta"},{tag:ie.invalid,class:"tok-invalid"},{tag:ie.punctuation,class:"tok-punctuation"}]);var cm;const _o=new Ge;function XI(n){return ke.define({combine:n?e=>e.concat(n):void 0})}const JI=new Ge;class Tr{constructor(e,t,r=[],i=""){this.data=e,this.name=i,nt.prototype.hasOwnProperty("tree")||Object.defineProperty(nt.prototype,"tree",{get(){return rn(this)}}),this.parser=t,this.extension=[ys.of(this),nt.languageData.of((s,o,a)=>{let u=qw(s,o,a),f=u.type.prop(_o);if(!f)return[];let h=s.facet(f),p=u.type.prop(JI);if(p){let g=u.resolve(o-u.from,a);for(let y of p)if(y.test(g,s)){let x=s.facet(y.facet);return y.type=="replace"?x:x.concat(h)}}return h})].concat(r)}isActiveAt(e,t,r=-1){return qw(e,t,r).type.prop(_o)==this.data}findRegions(e){let t=e.facet(ys);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(_o)==this.data){r.push({from:o,to:o+s.length});return}let a=s.prop(Ge.mounted);if(a){if(a.tree.prop(_o)==this.data){if(a.overlay)for(let u of a.overlay)r.push({from:u.from+o,to:u.to+o});else r.push({from:o,to:o+s.length});return}else if(a.overlay){let u=r.length;if(i(a.tree,a.overlay[0].from+o),r.length>u)return}}for(let u=0;u<s.children.length;u++){let f=s.children[u];f instanceof jt&&i(f,s.positions[u]+o)}};return i(rn(e),0),r}get allowsNesting(){return!0}}Tr.setState=He.define();function qw(n,e,t){let r=n.facet(ys),i=rn(n).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(e,t,Ot.ExcludeBuffers|Ot.EnterBracketed))s.type.isTop&&(i=s);return i}class Kf extends Tr{constructor(e,t,r){super(e,t,[],r),this.parser=t}static define(e){let t=XI(e.languageData);return new Kf(t,e.parser.configure({props:[_o.add(r=>r.isTop?t:void 0)]}),e.name)}configure(e,t){return new Kf(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function rn(n){let e=n.field(Tr.state,!1);return e?e.tree:jt.empty}class ZI{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,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let da=null;class Qf{constructor(e,t,r=[],i,s,o,a,u){this.parser=e,this.state=t,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=u,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new Qf(e,t,[],jt.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ZI(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=jt.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(Js.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Js.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=da;da=this;try{return e()}finally{da=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Kw(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let u=[];if(e.iterChangedRanges((f,h,p,g)=>u.push({fromA:f,toA:h,fromB:p,toB:g})),r=Js.applyChanges(r,u),i=jt.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let f of this.skipped){let h=e.mapPos(f.from,1),p=e.mapPos(f.to,-1);h<p&&a.push({from:h,to:p})}}}return new Qf(this.parser,t,r,i,s,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:s}=this.skipped[r];i<e.to&&s>e.from&&(this.fragments=Kw(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends zC{createParse(t,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let u=da;if(u){for(let f of i)u.tempSkipped.push(f);e&&(u.scheduleOn=u.scheduleOn?Promise.all([u.scheduleOn,e]):e)}return this.parsedPos=o,new jt(zn.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return da}}function Kw(n,e,t){return Js.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ll{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new ll(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=Qf.create(e.facet(ys).parser,e,{from:0,to:t});return r.work(20,t)||r.takeTree(),new ll(r)}}Tr.state=un.define({create:ll.init,update(n,e){for(let t of e.effects)if(t.is(Tr.setState))return t.value;return e.startState.facet(ys)!=e.state.facet(ys)?ll.init(e.state):n.apply(e)}});let $C=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&($C=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const um=typeof navigator<"u"&&(!((cm=navigator.scheduling)===null||cm===void 0)&&cm.isInputPending)?()=>navigator.scheduling.isInputPending():null,e6=Bt.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 t=this.view.state.field(Tr.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Tr.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=$C(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,s=r.field(Tr.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!um?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,u=s.context.work(()=>um&&um()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(u||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Tr.setState.of(new ll(s.context))})),this.chunkBudget>0&&!(u&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>In(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ys=ke.define({combine(n){return n.length?n[0]:null},enables:n=>[Tr.state,e6,ve.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class t6{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const n6=ke.define(),I0=ke.define({combine:n=>{if(!n.length)return"  ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Gf(n){let e=n.facet(I0);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Ya(n,e){let t="",r=n.tabSize,i=n.facet(I0)[0];if(i=="	"){for(;e>=r;)t+="	",e-=r;i=" "}for(let s=0;s<e;s++)t+=i;return t}function j0(n,e){n instanceof nt&&(n=new jd(n));for(let r of n.state.facet(n6)){let i=r(n,e);if(i!==void 0)return i}let t=rn(n.state);return t.length>=e?r6(n,t,e):null}class jd{constructor(e,t={}){this.state=e,this.options=t,this.unit=Gf(e)}lineAt(e,t=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,t);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,t=1){let{text:r,from:i}=this.lineAt(e,t),s=this.countColumn(r,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,t=e.length){return yl(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:r,from:i}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const HC=new Ge;function r6(n,e,t){let r=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=r.node){let s=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return UC(r,n,t)}function UC(n,e,t){for(let r=n;r;r=r.next){let i=s6(r.node);if(i)return i(B0.create(e,t,r))}return 0}function i6(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function s6(n){let e=n.type.prop(HC);if(e)return e;let t=n.firstChild,r;if(t&&(r=t.type.prop(Ge.closedBy))){let i=n.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>c6(o,!0,1,void 0,s&&!i6(o)?i.from:void 0)}return n.parent==null?o6:null}function o6(){return 0}class B0 extends jd{constructor(e,t,r){super(e.state,e.options),this.base=e,this.pos=t,this.context=r}get node(){return this.context.node}static create(e,t,r){return new B0(e,t,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(t.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(l6(r,e))break;t=this.state.doc.lineAt(r.from)}return this.lineIndent(t.from)}continue(){return UC(this.context.next,this.base,this.pos)}}function l6(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function a6(n){let e=n.node,t=e.childAfter(e.from),r=e.lastChild;if(!t)return null;let i=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let a=t.to;;){let u=e.childAfter(a);if(!u||u==r)return null;if(!u.type.isSkipped){if(u.from>=o)return null;let f=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+f}}a=u.to}}function c6(n,e,t,r,i){let s=n.textAfter,o=s.match(/^\s*/)[0].length,a=r&&s.slice(o,o+r.length)==r||i==n.pos+o,u=a6(n);return u?a?n.column(u.from):n.column(u.to):n.baseIndent+(a?0:n.unit*t)}function u6({except:n,units:e=1}={}){return t=>{let r=n&&n.test(t.textAfter);return t.baseIndent+(r?0:e*t.unit)}}const f6=200;function d6(){return nt.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:r}=n.newSelection.main,i=t.lineAt(r);if(r>i.from+f6)return n;let s=t.sliceString(i.from,r);if(!e.some(f=>f.test(s)))return n;let{state:o}=n,a=-1,u=[];for(let{head:f}of o.selection.ranges){let h=o.doc.lineAt(f);if(h.from==a)continue;a=h.from;let p=j0(o,h.from);if(p==null)continue;let g=/^\s*/.exec(h.text)[0],y=Ya(o,p);g!=y&&u.push({from:h.from,to:h.from+g.length,insert:y})}return u.length?[n,{changes:u,sequential:!0}]:n})}const h6=ke.define(),qC=new Ge;function p6(n,e,t){let r=rn(n);if(r.length<t)return null;let i=r.resolveStack(t,1),s=null;for(let o=i;o;o=o.next){let a=o.node;if(a.to<=t||a.from>t)continue;if(s&&a.from<e)break;let u=a.type.prop(qC);if(u&&(a.to<r.length-50||r.length==n.doc.length||!m6(a))){let f=u(a,n);f&&f.from<=t&&f.from>=e&&f.to>t&&(s=f)}}return s}function m6(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Yf(n,e,t){for(let r of n.facet(h6)){let i=r(n,e,t);if(i)return i}return p6(n,e,t)}function KC(n,e){let t=e.mapPos(n.from,1),r=e.mapPos(n.to,-1);return t>=r?void 0:{from:t,to:r}}const Bd=He.define({map:KC}),yc=He.define({map:KC});function QC(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(r=>r.from<=t&&r.to>=t)||e.push(n.lineBlockAt(t));return e}const so=un.define({create(){return De.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,r)=>n=Qw(n,t,r)),n=n.map(e.changes);for(let t of e.effects)if(t.is(Bd)&&!g6(n,t.value.from,t.value.to)){let{preparePlaceholder:r}=e.state.facet(XC),i=r?De.replace({widget:new k6(r(e.state,t.value))}):Gw;n=n.update({add:[i.range(t.value.from,t.value.to)]})}else t.is(yc)&&(n=n.update({filter:(r,i)=>t.value.from!=r||t.value.to!=i,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(n=Qw(n,e.selection.main.head)),n},provide:n=>ve.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(r,i)=>{t.push(r,i)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let r=n[t++],i=n[t++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(Gw.range(r,i))}return De.set(e,!0)}});function Qw(n,e,t=e){let r=!1;return n.between(e,t,(i,s)=>{i<t&&s>e&&(r=!0)}),r?n.update({filterFrom:e,filterTo:t,filter:(i,s)=>i>=t||s<=e}):n}function Xf(n,e,t){var r;let i=null;return(r=n.field(so,!1))===null||r===void 0||r.between(e,t,(s,o)=>{(!i||i.from>s)&&(i={from:s,to:o})}),i}function g6(n,e,t){let r=!1;return n.between(e,e,(i,s)=>{i==e&&s==t&&(r=!0)}),r}function GC(n,e){return n.field(so,!1)?e:e.concat(He.appendConfig.of(JC()))}const y6=n=>{for(let e of QC(n)){let t=Yf(n.state,e.from,e.to);if(t)return n.dispatch({effects:GC(n.state,[Bd.of(t),YC(n,t)])}),!0}return!1},v6=n=>{if(!n.state.field(so,!1))return!1;let e=[];for(let t of QC(n)){let r=Xf(n.state,t.from,t.to);r&&e.push(yc.of(r),YC(n,r,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function YC(n,e,t=!0){let r=n.state.doc.lineAt(e.from).number,i=n.state.doc.lineAt(e.to).number;return ve.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${i}.`)}const x6=n=>{let{state:e}=n,t=[];for(let r=0;r<e.doc.length;){let i=n.lineBlockAt(r),s=Yf(e,i.from,i.to);s&&t.push(Bd.of(s)),r=(s?n.lineBlockAt(s.to):i).to+1}return t.length&&n.dispatch({effects:GC(n.state,t)}),!!t.length},w6=n=>{let e=n.state.field(so,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(r,i)=>{t.push(yc.of({from:r,to:i}))}),n.dispatch({effects:t}),!0},b6=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:y6},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:v6},{key:"Ctrl-Alt-[",run:x6},{key:"Ctrl-Alt-]",run:w6}],S6={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},XC=ke.define({combine(n){return si(n,S6)}});function JC(n){return[so,R6]}function ZC(n,e){let{state:t}=n,r=t.facet(XC),i=o=>{let a=n.lineBlockAt(n.posAtDOM(o.target)),u=Xf(n.state,a.from,a.to);u&&n.dispatch({effects:yc.of(u)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,i,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const Gw=De.replace({widget:new class extends oi{toDOM(n){return ZC(n,null)}}});class k6 extends oi{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ZC(e,this.value)}}const C6={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class fm extends Ai{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function E6(n={}){let e={...C6,...n},t=new fm(e,!0),r=new fm(e,!1),i=Bt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ys)!=o.state.facet(ys)||o.startState.field(so,!1)!=o.state.field(so,!1)||rn(o.startState)!=rn(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new Oi;for(let u of o.viewportLineBlocks){let f=Xf(o.state,u.from,u.to)?r:Yf(o.state,u.from,u.to)?t:null;f&&a.add(u.from,u.from,f)}return a.finish()}}),{domEventHandlers:s}=e;return[i,EI({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(i))===null||a===void 0?void 0:a.markers)||Ze.empty},initialSpacer(){return new fm(e,!1)},domEventHandlers:{...s,click:(o,a,u)=>{if(s.click&&s.click(o,a,u))return!0;let f=Xf(o.state,a.from,a.to);if(f)return o.dispatch({effects:yc.of(f)}),!0;let h=Yf(o.state,a.from,a.to);return h?(o.dispatch({effects:Bd.of(h)}),!0):!1}}}),JC()]}const R6=ve.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class vc{constructor(e,t){this.specs=e;let r;function i(a){let u=hs.newName();return(r||(r=Object.create(null)))["."+u]=a,u}const s=typeof t.all=="string"?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof Tr?a=>a.prop(_o)==o.data:o?a=>a==o:void 0,this.style=WC(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=r?new hs(r):null,this.themeType=t.themeType}static define(e,t){return new vc(e,t||{})}}const Tg=ke.define(),eE=ke.define({combine(n){return n.length?[n[0]]:null}});function dm(n){let e=n.facet(Tg);return e.length?e:n.facet(eE)}function tE(n,e){let t=[M6],r;return n instanceof vc&&(n.module&&t.push(ve.styleModule.of(n.module)),r=n.themeType),e!=null&&e.fallback?t.push(eE.of(n)):r?t.push(Tg.computeN([ve.darkTheme],i=>i.facet(ve.darkTheme)==(r=="dark")?[n]:[])):t.push(Tg.of(n)),t}class T6{constructor(e){this.markCache=Object.create(null),this.tree=rn(e.state),this.decorations=this.buildDeco(e,dm(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=rn(e.state),r=dm(e.state),i=r!=dm(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!i&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return De.none;let r=new Oi;for(let{from:i,to:s}of e.visibleRanges)QI(this.tree,t,(o,a,u)=>{r.add(o,a,this.markCache[u]||(this.markCache[u]=De.mark({class:u})))},i,s);return r.finish()}}const M6=ws.high(Bt.fromClass(T6,{decorations:n=>n.decorations})),O6=vc.define([{tag:ie.meta,color:"#404740"},{tag:ie.link,textDecoration:"underline"},{tag:ie.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ie.emphasis,fontStyle:"italic"},{tag:ie.strong,fontWeight:"bold"},{tag:ie.strikethrough,textDecoration:"line-through"},{tag:ie.keyword,color:"#708"},{tag:[ie.atom,ie.bool,ie.url,ie.contentSeparator,ie.labelName],color:"#219"},{tag:[ie.literal,ie.inserted],color:"#164"},{tag:[ie.string,ie.deleted],color:"#a11"},{tag:[ie.regexp,ie.escape,ie.special(ie.string)],color:"#e40"},{tag:ie.definition(ie.variableName),color:"#00f"},{tag:ie.local(ie.variableName),color:"#30a"},{tag:[ie.typeName,ie.namespace],color:"#085"},{tag:ie.className,color:"#167"},{tag:[ie.special(ie.variableName),ie.macroName],color:"#256"},{tag:ie.definition(ie.propertyName),color:"#00c"},{tag:ie.comment,color:"#940"},{tag:ie.invalid,color:"#f00"}]),P6=ve.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),nE=1e4,rE="()[]{}",iE=ke.define({combine(n){return si(n,{afterCursor:!0,brackets:rE,maxScanDistance:nE,renderMatch:L6})}}),A6=De.mark({class:"cm-matchingBracket"}),N6=De.mark({class:"cm-nonmatchingBracket"});function L6(n){let e=[],t=n.matched?A6:N6;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const D6=un.define({create(){return De.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],r=e.state.facet(iE);for(let i of e.state.selection.ranges){if(!i.empty)continue;let s=Xr(e.state,i.head,-1,r)||i.head>0&&Xr(e.state,i.head-1,1,r)||r.afterCursor&&(Xr(e.state,i.head,1,r)||i.head<e.state.doc.length&&Xr(e.state,i.head+1,-1,r));s&&(t=t.concat(r.renderMatch(s,e.state)))}return De.set(t,!0)},provide:n=>ve.decorations.from(n)}),I6=[D6,P6];function j6(n={}){return[iE.of(n),I6]}const B6=new Ge;function Mg(n,e,t){let r=n.prop(e<0?Ge.openedBy:Ge.closedBy);if(r)return r;if(n.name.length==1){let i=t.indexOf(n.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function Og(n){let e=n.type.prop(B6);return e?e(n.node):n}function Xr(n,e,t,r={}){let i=r.maxScanDistance||nE,s=r.brackets||rE,o=rn(n),a=o.resolveInner(e,t);for(let u=a;u;u=u.parent){let f=Mg(u.type,t,s);if(f&&u.from<u.to){let h=Og(u);if(h&&(t>0?e>=h.from&&e<h.to:e>h.from&&e<=h.to))return F6(n,e,t,u,h,f,s)}}return z6(n,e,t,o,a.type,i,s)}function F6(n,e,t,r,i,s,o){let a=r.parent,u={from:i.from,to:i.to},f=0,h=a==null?void 0:a.cursor();if(h&&(t<0?h.childBefore(r.from):h.childAfter(r.to)))do if(t<0?h.to<=r.from:h.from>=r.to){if(f==0&&s.indexOf(h.type.name)>-1&&h.from<h.to){let p=Og(h);return{start:u,end:p?{from:p.from,to:p.to}:void 0,matched:!0}}else if(Mg(h.type,t,o))f++;else if(Mg(h.type,-t,o)){if(f==0){let p=Og(h);return{start:u,end:p&&p.from<p.to?{from:p.from,to:p.to}:void 0,matched:!1}}f--}}while(t<0?h.prevSibling():h.nextSibling());return{start:u,matched:!1}}function z6(n,e,t,r,i,s,o){let a=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),u=o.indexOf(a);if(u<0||u%2==0!=t>0)return null;let f={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),p=0;for(let g=0;!h.next().done&&g<=s;){let y=h.value;t<0&&(g+=y.length);let x=e+g*t;for(let w=t>0?0:y.length-1,C=t>0?y.length:-1;w!=C;w+=t){let E=o.indexOf(y[w]);if(!(E<0||r.resolveInner(x+w,1).type!=i))if(E%2==0==t>0)p++;else{if(p==1)return{start:f,end:{from:x+w,to:x+w+1},matched:E>>1==u>>1};p--}}t>0&&(g+=y.length)}return h.done?{start:f,matched:!1}:null}const _6=Object.create(null),Yw=[zn.none],Xw=[],Jw=Object.create(null),V6=Object.create(null);for(let[n,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"]])V6[n]=W6(_6,e);function hm(n,e){Xw.indexOf(n)>-1||(Xw.push(n),console.warn(e))}function W6(n,e){let t=[];for(let a of e.split(" ")){let u=[];for(let f of a.split(".")){let h=n[f]||ie[f];h?typeof h=="function"?u.length?u=u.map(h):hm(f,`Modifier ${f} used at start of tag`):u.length?hm(f,`Tag ${f} used as modifier`):u=Array.isArray(h)?h:[h]:hm(f,`Unknown highlighting tag ${f}`)}for(let f of u)t.push(f)}if(!t.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+t.map(a=>a.id),s=Jw[i];if(s)return s.id;let o=Jw[i]=zn.define({id:Yw.length,name:r,props:[_C({[r]:t})]});return Yw.push(o),o.id}pt.RTL,pt.LTR;var Zw={};class Jf{constructor(e,t,r,i,s,o,a,u,f,h=0,p){this.p=e,this.stack=t,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=u,this.curContext=f,this.lookAhead=h,this.parent=p}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,r=0){let i=e.parser.context;return new Jf(e,[],t,r,r,0,[],0,i?new eb(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=s.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let u=this.stack.length-(r-1)*3-(e&262144?6:0),f=u?this.stack[u-2]:this.p.ranges[0].from,h=this.reducePos-f;h>=2e3&&!(!((t=this.p.parser.nodeSet.types[i])===null||t===void 0)&&t.isAnonymous)&&(f==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=f,this.p.lastBigReductionSize=h));let p=u?this.stack[u-1]:0,g=this.bufferBase+this.buffer.length-p;if(i<s.minRepeatTerm||e&131072){let y=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,f,y,g+4,!0)}if(e&262144)this.state=this.stack[u];else{let y=this.stack[u-3];this.state=s.getGoto(y,i,!0)}for(;this.stack.length>u;)this.stack.pop();this.reduceContext(i,f)}storeNode(e,t,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==r)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,t,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let u=o;u>0&&this.buffer[u-2]>r;u-=4)if(this.buffer[u-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>r;)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,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,t,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(t,r),t<=o.maxNode&&this.buffer.push(t,r,i,4)}else this.pos=i,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,i,4)}apply(e,t,r,i){e&65536?this.reduce(e):this.shift(e,t,r,i)}useNode(e,t){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(r,i,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,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let r=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new Jf(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,r?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new $6(this);;){let r=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(r==0)return!1;if((r&65536)==0)return!0;t.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(t[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<t.length;s+=2){let o=t[s+1];i.some((a,u)=>u&1&&a==o)||i.push(t[s],o)}t=i}let r=[];for(let i=0;i<t.length&&r.length<4;i+=2){let s=t[i+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(t[i],this.pos),o.reducePos=this.pos,o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let r=t>>19,i=t&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],r=(i,s)=>{if(!t.includes(i))return t.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let u=o&65535,f=this.stack.length-a*3;if(f>=0&&e.getGoto(this.stack[f],u,!1)>=0)return a<<19|65536|u}}else{let a=r(o,s+1);if(a!=null)return a}})};return r(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 t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}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 t=new eb(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}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 eb{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class $6{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class Zf{constructor(e,t,r){this.stack=e,this.pos=t,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Zf(e,t,t-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 Zf(this.stack,this.pos,this.index)}}function rf(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let r=0,i=0;r<n.length;){let s=0;for(;;){let o=n.charCodeAt(r++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,a=!0),s+=u,a)break;s*=46}t?t[i++]=s:t=new e(s)}return t}class Cf{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const tb=new Cf;class H6{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=tb,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<r.from;){if(!i)return null;let o=this.ranges[--i];s-=r.from-o.to,r=o}for(;t<0?s>r.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,r,i;if(t>=0&&t<this.chunk.length)r=this.pos+e,i=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(r=s,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,t=0){let r=t?this.resolveOffset(t,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>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,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=tb,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,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let r="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return r}}class Go{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:r}=t.p;q6(this.data,e,t,this.id,r.data,r.tokenPrecTable)}}Go.prototype.contextual=Go.prototype.fallback=Go.prototype.extend=!1;Go.prototype.fallback=Go.prototype.extend=!1;class U6{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function q6(n,e,t,r,i,s){let o=0,a=1<<r,{dialect:u}=t.p.parser;e:for(;(a&n[o])!=0;){let f=n[o+1];for(let y=o+3;y<f;y+=2)if((n[y+1]&a)>0){let x=n[y];if(u.allows(x)&&(e.token.value==-1||e.token.value==x||K6(x,e.token.value,i,s))){e.acceptToken(x);break}}let h=e.next,p=0,g=n[o+2];if(e.next<0&&g>p&&n[f+g*3-3]==65535){o=n[f+g*3-1];continue e}for(;p<g;){let y=p+g>>1,x=f+y+(y<<1),w=n[x],C=n[x+1]||65536;if(h<w)g=y;else if(h>=C)p=y+1;else{o=n[x+2],e.advance();continue e}}break}}function nb(n,e,t){for(let r=e,i;(i=n[r])!=65535;r++)if(i==t)return r-e;return-1}function K6(n,e,t,r){let i=nb(t,r,e);return i<0||nb(t,r,n)<i}const Hn=typeof process<"u"&&Zw&&/\bparse\b/.test(Zw.LOG);let pm=null;function rb(n,e,t){let r=n.cursor(Ot.IncludeAnonymous);for(r.moveTo(e);;)if(!(t<0?r.childBefore(e):r.childAfter(e)))for(;;){if((t<0?r.to<e:r.from>e)&&!r.type.isError)return t<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(n.length,Math.max(r.from+1,e+25));if(t<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return t<0?0:n.length}}class Q6{constructor(e,t){this.fragments=e,this.nodeSet=t,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?rb(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?rb(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 t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let r=this.trees[t],i=this.index[t];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=r.children[i],o=this.start[t]+r.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof jt){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let u=s.prop(Ge.lookAhead);if(!u||a+u<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class G6{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Cf)}getActions(e){let t=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,u=0;for(let f=0;f<s.length;f++){if((1<<f&o)==0)continue;let h=s[f],p=this.tokens[f];if(!(r&&!h.fallback)&&((h.contextual||p.start!=e.pos||p.mask!=o||p.context!=a)&&(this.updateCachedToken(p,h,e),p.mask=o,p.context=a),p.lookAhead>p.end+25&&(u=Math.max(p.lookAhead,u)),p.value!=0)){let g=t;if(p.extended>-1&&(t=this.addActions(e,p.extended,p.end,t)),t=this.addActions(e,p.value,p.end,t),!h.extend&&(r=p,t>g))break}}for(;this.actions.length>t;)this.actions.pop();return u&&e.setLookAhead(u),!r&&e.pos==this.stream.end&&(r=new Cf,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,t=this.addActions(e,r.value,r.end,t)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Cf,{pos:r,p:i}=e;return t.start=r,t.end=Math.min(r+1,i.stream.end),t.value=r==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,r){let i=this.stream.clipPos(r.pos);if(t.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,r,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=r,i}addActions(e,t,r,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let u=0;u<2;u++)for(let f=o.stateSlot(s,u?2:1);;f+=3){if(a[f]==65535)if(a[f+1]==1)f=wi(a,f+2);else{i==0&&a[f+1]==2&&(i=this.putAction(wi(a,f+2),t,r,i));break}a[f]==t&&(i=this.putAction(wi(a,f+1),t,r,i))}return i}}class Y6{constructor(e,t,r,i){this.parser=e,this.input=t,this.ranges=i,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 H6(t,i),this.tokens=new G6(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Jf.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new Q6(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,r=this.stacks=[],i,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 a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>t)r.push(a);else{if(this.advanceStack(a,r,e))continue;{i||(i=[],s=[]),i.push(a);let u=this.tokens.getMainToken(a);s.push(u.value,u.end)}}break}}if(!r.length){let o=i&&J6(i);if(o)return Hn&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Hn&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return Hn&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,u)=>u.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>t)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let u=o+1;u<r.length;u++){let f=r[u];if(a.sameState(f)||a.buffer.length>500&&f.buffer.length>500)if((a.score-f.score||a.buffer.length-f.buffer.length)>0)r.splice(u--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,a)=>a.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[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,t,r){let i=e.pos,{parser:s}=this,o=Hn?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let f=e.curContext&&e.curContext.tracker.strict,h=f?e.curContext.hash:0;for(let p=this.fragments.nodeAt(i);p;){let g=this.parser.nodeSet.types[p.type.id]==p.type?s.getGoto(e.state,p.type.id):-1;if(g>-1&&p.length&&(!f||(p.prop(Ge.contextHash)||0)==h))return e.useNode(p,g),Hn&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(p.type.id)})`),!0;if(!(p instanceof jt)||p.children.length==0||p.positions[0]>0)break;let y=p.children[0];if(y instanceof jt&&p.positions[0]==0)p=y;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),Hn&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let f=0;f<u.length;){let h=u[f++],p=u[f++],g=u[f++],y=f==u.length||!r,x=y?e:e.split(),w=this.tokens.mainToken;if(x.apply(h,p,w?w.start:x.pos,g),Hn&&console.log(o+this.stackID(x)+` (via ${(h&65536)==0?"shift":`reduce of ${s.getName(h&65535)}`} for ${s.getName(p)} @ ${i}${x==e?"":", split"})`),y)return!0;x.pos>i?t.push(x):r.push(x)}return!1}advanceFully(e,t){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return ib(e,t),!0}}runRecovery(e,t,r){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],u=t[o<<1],f=t[(o<<1)+1],h=Hn?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),Hn&&console.log(h+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let p=a.split(),g=h;for(let y=0;y<10&&p.forceReduce()&&(Hn&&console.log(g+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,r));y++)Hn&&(g=this.stackID(p)+" -> ");for(let y of a.recoverByInsert(u))Hn&&console.log(h+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,r);this.stream.end>a.pos?(f==a.pos&&(f++,u=0),a.recoverByDelete(u,f),Hn&&console.log(h+this.stackID(a)+` (via recover-delete ${this.parser.getName(u)})`),ib(a,r)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),jt.build({buffer:Zf.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 t=(pm||(pm=new WeakMap)).get(e);return t||pm.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function ib(n,e){for(let t=0;t<e.length;t++){let r=e[t];if(r.pos==n.pos&&r.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}class X6{constructor(e,t,r){this.source=e,this.flags=t,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class ed extends zC{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;a<e.repeatNodeCount;a++)t.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<t.length;a++)i.push([]);function s(a,u,f){i[a].push([u,u.deserialize(String(f))])}if(e.nodeProps)for(let a of e.nodeProps){let u=a[0];typeof u=="string"&&(u=Ge[u]);for(let f=1;f<a.length;){let h=a[f++];if(h>=0)s(h,u,a[f++]);else{let p=a[f+-h];for(let g=-h;g>0;g--)s(a[f++],u,p);f++}}}this.nodeSet=new A0(t.map((a,u)=>zn.define({name:u>=this.minRepeatTerm?void 0:a,id:u,props:i[u],top:r.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=IC;let o=rf(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(sb),this.states=rf(e.states,Uint32Array),this.data=rf(e.stateData),this.goto=rf(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Go(o,a):a),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,t,r){let i=new Y6(this,e,t,r);for(let s of this.wrappers)i=s(i,e,t,r);return i}getGoto(e,t,r=!1){let i=this.goto;if(t>=i[0])return-1;for(let s=i[t+1];;){let o=i[s++],a=o&1,u=i[s++];if(a&&r)return u;for(let f=s+(o>>1);s<f;s++)if(i[s]==e)return u;if(a)return-1}}hasAction(e,t){let r=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=r[s])==65535)if(r[s+1]==1)o=r[s=wi(r,s+2)];else{if(r[s+1]==2)return wi(r,s+2);break}if(o==t||o==0)return wi(r,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,r=>r==t?!0:null)}allActions(e,t){let r=this.stateSlot(e,4),i=r?t(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=wi(this.data,s+2);else break;i=t(wi(this.data,s+1))}return i}nextStates(e){let t=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=wi(this.data,r+2);else break;if((this.data[r+2]&1)==0){let i=this.data[r+1];t.some((s,o)=>o&1&&s==i)||t.push(this.data[r],i)}}return t}configure(e){let t=Object.assign(Object.create(ed.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=r}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(a=>a.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return t.specializers[i]=sb(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}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 t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),r=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;s<t.length;s++)if(!r[s])for(let o=this.dialects[t[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new X6(e,r,i)}static deserialize(e){return new ed(e)}}function wi(n,e){return n[e]|n[e+1]<<16}function J6(n){let e=null;for(let t of n){let r=t.p.stoppedAt;(t.pos==t.p.stream.end||r!=null&&t.pos>r)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function sb(n){if(n.external){let e=n.extend?1:0;return(t,r)=>n.external(t,r)<<1|e}return n.get}class sE{constructor(e,t,r,i){this.state=e,this.pos=t,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=rn(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),r=Math.max(t.from,this.pos-250),i=t.text.slice(r-t.from,this.pos-t.from),s=i.search(lE(e,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function ob(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Z6(n){let e=Object.create(null),t=Object.create(null);for(let{label:i}of n){e[i[0]]=!0;for(let s=1;s<i.length;s++)t[i[s]]=!0}let r=ob(e)+ob(t)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function oE(n){let e=n.map(i=>typeof i=="string"?{label:i}:i),[t,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Z6(e);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:t}:null}}function e9(n,e){return t=>{for(let r=rn(t.state).resolveInner(t.pos,-1);r;r=r.parent){if(n.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(t)}}class lb{constructor(e,t,r,i){this.completion=e,this.source=t,this.match=r,this.score=i}}function Zs(n){return n.selection.main.from}function lE(n,e){var t;let{source:r}=n,i=e&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?n:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const aE=Li.define();function t9(n,e,t,r){let{main:i}=n.selection,s=t-i.from,o=r-i.from;return{...n.changeByRange(a=>{if(a!=i&&t!=r&&n.sliceDoc(a.from+s,a.from+o)!=n.sliceDoc(t,r))return{range:a};let u=n.toText(e);return{changes:{from:a.from+s,to:r==i.from?a.to:a.from+o,insert:u},range:te.cursor(a.from+s+u.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const ab=new WeakMap;function n9(n){if(!Array.isArray(n))return n;let e=ab.get(n);return e||ab.set(n,e=oE(n)),e}const td=He.define(),Xa=He.define();class r9{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let r=Pn(e,t),i=Gr(r);this.chars.push(r);let s=e.slice(t,t+i),o=s.toUpperCase();this.folded.push(Pn(o==s?s.toLowerCase():o,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:r,any:i,precise:s,byWord:o}=this;if(t.length==1){let T=Pn(e,0),M=Gr(T),P=M==e.length?0:-100;if(T!=t[0])if(T==r[0])P+=-200;else return null;return this.ret(P,[0,M])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let u=t.length,f=0;if(a<0){for(let T=0,M=Math.min(e.length,200);T<M&&f<u;){let P=Pn(e,T);(P==t[f]||P==r[f])&&(i[f++]=T),T+=Gr(P)}if(f<u)return null}let h=0,p=0,g=!1,y=0,x=-1,w=-1,C=/[a-z]/.test(e),E=!0;for(let T=0,M=Math.min(e.length,200),P=0;T<M&&p<u;){let O=Pn(e,T);a<0&&(h<u&&O==t[h]&&(s[h++]=T),y<u&&(O==t[y]||O==r[y]?(y==0&&(x=T),w=T+1,y++):y=0));let N,L=O<255?O>=48&&O<=57||O>=97&&O<=122?2:O>=65&&O<=90?1:0:(N=p0(O))!=N.toLowerCase()?1:N!=N.toUpperCase()?2:0;(!T||L==1&&C||P==0&&L!=0)&&(t[p]==O||r[p]==O&&(g=!0)?o[p++]=T:o.length&&(E=!1)),P=L,T+=Gr(O)}return p==u&&o[0]==0&&E?this.result(-100+(g?-200:0),o,e):y==u&&x==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):y==u?this.ret(-900-e.length,[x,w]):p==u?this.result(-100+(g?-200:0)+-700+(E?0:-1100),o,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,r){let i=[],s=0;for(let o of t){let a=o+(this.astral?Gr(Pn(r,o)):1);s&&i[s-1]==o?i[s-1]=a:(i[s++]=o,i[s++]=a)}return this.ret(e-r.length,i)}}class i9{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 t=e.slice(0,this.pattern.length),r=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,t.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const nn=ke.define({combine(n){return si(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:s9,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>r=>cb(e(r),t(r)),optionClass:(e,t)=>r=>cb(e(r),t(r)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function cb(n,e){return n?e?n+" "+e:n:e}function s9(n,e,t,r,i,s){let o=n.textDirection==pt.RTL,a=o,u=!1,f="top",h,p,g=e.left-i.left,y=i.right-e.right,x=r.right-r.left,w=r.bottom-r.top;if(a&&g<Math.min(x,y)?a=!1:!a&&y<Math.min(x,g)&&(a=!0),x<=(a?g:y))h=Math.max(i.top,Math.min(t.top,i.bottom-w))-e.top,p=Math.min(400,a?g:y);else{u=!0,p=Math.min(400,(o?e.right:i.right-e.left)-30);let T=i.bottom-e.bottom;T>=w||T>e.top?h=t.bottom-e.top:(f="bottom",h=e.bottom-t.top)}let C=(e.bottom-e.top)/s.offsetHeight,E=(e.right-e.left)/s.offsetWidth;return{style:`${f}: ${h/C}px; max-width: ${p/E}px`,class:"cm-completionInfo-"+(u?o?"left-narrow":"right-narrow":a?"left":"right")}}function o9(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),t.type&&r.classList.add(...t.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(t,r,i,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,u=0;for(let f=0;f<s.length;){let h=s[f++],p=s[f++];h>u&&o.appendChild(document.createTextNode(a.slice(u,h)));let g=o.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(a.slice(h,p))),g.className="cm-completionMatchedText",u=p}return u<a.length&&o.appendChild(document.createTextNode(a.slice(u))),o},position:50},{render(t){if(!t.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=t.detail,r},position:80}),e.sort((t,r)=>t.position-r.position).map(t=>t.render)}function mm(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let i=Math.floor(e/t);return{from:i*t,to:(i+1)*t}}let r=Math.floor((n-e)/t);return{from:n-(r+1)*t,to:n-r*t}}class l9{constructor(e,t,r){this.view=e,this.stateField=t,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:u=>this.placeInfo(u),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:s,selected:o}=i.open,a=e.state.facet(nn);this.optionContent=o9(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=mm(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",u=>{let{options:f}=e.state.field(t).open;for(let h=u.target,p;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(p=/-(\d+)$/.exec(h.id))&&+p[1]<f.length){this.applyCompletion(e,f[+p[1]]),u.preventDefault();return}}),this.dom.addEventListener("focusout",u=>{let f=e.state.field(this.stateField,!1);f&&f.tooltip&&e.state.facet(nn).closeOnBlur&&u.relatedTarget!=e.contentDOM&&e.dispatch({effects:Xa.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:s,selected:o,disabled:a}=r.open;(!i.open||i.open.options!=s)&&(this.range=mm(s.length,o,e.state.facet(nn).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),a!=((t=i.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of t.split(" "))r&&this.dom.classList.add(r);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=mm(t.options.length,t.selected,this.view.state.facet(nn).maxRenderedOptions),this.showOptions(t.options,e.id));let r=this.updateSelectedOption(t.selected);if(r){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(i);if(!o)return;"then"in o?o.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,i)}).catch(a=>In(this.view.state,a,"completion info")):(this.addInfoPane(o,i),r.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",r.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:s}=e;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),t=r):r.hasAttribute("aria-selected")&&(r.removeAttribute("aria-selected"),r.removeAttribute("aria-describedby"));return t&&c9(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=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 i.top>Math.min(s.bottom,t.bottom)-10||i.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(nn).positionInfo(this.view,t,i,r,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,t,r){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let s=null;for(let o=r.from;o<r.to;o++){let{completion:a,match:u}=e[o],{section:f}=a;if(f){let g=typeof f=="string"?f:f.name;if(g!=s&&(o>r.from||r.from==0))if(s=g,typeof f!="string"&&f.header)i.appendChild(f.header(f));else{let y=i.appendChild(document.createElement("completion-section"));y.textContent=g}}const h=i.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let p=this.optionClass(a);p&&(h.className=p);for(let g of this.optionContent){let y=g(a,this.view.state,this.view,u);y&&h.appendChild(y)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function a9(n,e){return t=>new l9(t,n,e)}function c9(n,e){let t=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i=t.height/n.offsetHeight;r.top<t.top?n.scrollTop-=(t.top-r.top)/i:r.bottom>t.bottom&&(n.scrollTop+=(r.bottom-t.bottom)/i)}function ub(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function u9(n,e){let t=[],r=null,i=null,s=h=>{t.push(h);let{section:p}=h.completion;if(p){r||(r=[]);let g=typeof p=="string"?p:p.name;r.some(y=>y.name==g)||r.push(typeof p=="string"?{name:g}:p)}},o=e.facet(nn);for(let h of n)if(h.hasResult()){let p=h.result.getMatch;if(h.result.filter===!1)for(let g of h.result.options)s(new lb(g,h.source,p?p(g):[],1e9-t.length));else{let g=e.sliceDoc(h.from,h.to),y,x=o.filterStrict?new i9(g):new r9(g);for(let w of h.result.options)if(y=x.match(w.label)){let C=w.displayLabel?p?p(w,y.matched):[]:y.matched,E=y.score+(w.boost||0);if(s(new lb(w,h.source,C,E)),typeof w.section=="object"&&w.section.rank==="dynamic"){let{name:T}=w.section;i||(i=Object.create(null)),i[T]=Math.max(E,i[T]||-1e9)}}}}if(r){let h=Object.create(null),p=0,g=(y,x)=>(y.rank==="dynamic"&&x.rank==="dynamic"?i[x.name]-i[y.name]:0)||(typeof y.rank=="number"?y.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(y.name<x.name?-1:1);for(let y of r.sort(g))p-=1e5,h[y.name]=p;for(let y of t){let{section:x}=y.completion;x&&(y.score+=h[typeof x=="string"?x:x.name])}}let a=[],u=null,f=o.compareCompletions;for(let h of t.sort((p,g)=>g.score-p.score||f(p.completion,g.completion))){let p=h.completion;!u||u.label!=p.label||u.detail!=p.detail||u.type!=null&&p.type!=null&&u.type!=p.type||u.apply!=p.apply||u.boost!=p.boost?a.push(h):ub(h.completion)>ub(u)&&(a[a.length-1]=h),u=h.completion}return a}class Vo{constructor(e,t,r,i,s,o){this.options=e,this.attrs=t,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Vo(this.options,fb(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,r,i,s,o){if(i&&!o&&e.some(f=>f.isPending))return i.setDisabled();let a=u9(e,t);if(!a.length)return i&&e.some(f=>f.isPending)?i.setDisabled():null;let u=t.facet(nn).selectOnOpen?0:-1;if(i&&i.selected!=u&&i.selected!=-1){let f=i.options[i.selected].completion;for(let h=0;h<a.length;h++)if(a[h].completion==f){u=h;break}}return new Vo(a,fb(r,u),{pos:e.reduce((f,h)=>h.hasResult()?Math.min(f,h.from):f,1e8),create:g9,above:s.aboveCursor},i?i.timestamp:Date.now(),u,!1)}map(e){return new Vo(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Vo(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class nd{constructor(e,t,r){this.active=e,this.id=t,this.open=r}static start(){return new nd(p9,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,r=t.facet(nn),s=(r.override||t.languageDataAt("autocomplete",Zs(t)).map(n9)).map(u=>(this.active.find(h=>h.source==u)||new ar(u,this.active.some(h=>h.state!=0)?1:0)).update(e,r));s.length==this.active.length&&s.every((u,f)=>u==this.active[f])&&(s=this.active);let o=this.open,a=e.effects.some(u=>u.is(F0));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(u=>u.hasResult()&&e.changes.touchesRange(u.from,u.to))||!f9(s,this.active)||a?o=Vo.build(s,t,this.id,o,r,a):o&&o.disabled&&!s.some(u=>u.isPending)&&(o=null),!o&&s.every(u=>!u.isPending)&&s.some(u=>u.hasResult())&&(s=s.map(u=>u.hasResult()?new ar(u.source,0):u));for(let u of e.effects)u.is(uE)&&(o=o&&o.setSelected(u.value,this.id));return s==this.active&&o==this.open?this:new nd(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?d9:h9}}function f9(n,e){if(n==e)return!0;for(let t=0,r=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;r<e.length&&!e[r].hasResult();)r++;let i=t==n.length,s=r==e.length;if(i||s)return i==s;if(n[t++].result!=e[r++].result)return!1}}const d9={"aria-autocomplete":"list"},h9={};function fb(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const p9=[];function cE(n,e){if(n.isUserEvent("input.complete")){let r=n.annotation(aE);if(r&&e.activateOnCompletion(r))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class ar{constructor(e,t,r=!1){this.source=e,this.state=t,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let r=cE(e,t),i=this;(r&8||r&16&&this.touches(e))&&(i=new ar(i.source,0)),r&4&&i.state==0&&(i=new ar(this.source,1)),i=i.updateFor(e,r);for(let s of e.effects)if(s.is(td))i=new ar(i.source,1,s.value);else if(s.is(Xa))i=new ar(i.source,0);else if(s.is(F0))for(let o of s.value)o.source==i.source&&(i=o);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Zs(e.state))}}class Yo extends ar{constructor(e,t,r,i,s,o){super(e,3,t),this.limit=r,this.result=i,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var r;if(!(t&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=Zs(e.state);if(a>o||!i||t&2&&(Zs(e.startState)==this.from||a<this.limit))return new ar(this.source,t&4?1:0);let u=e.changes.mapPos(this.limit);return m9(i.validFor,e.state,s,o)?new Yo(this.source,this.explicit,u,i,s,o):i.update&&(i=i.update(i,s,o,new sE(e.state,a,!1)))?new Yo(this.source,this.explicit,u,i,i.from,(r=i.to)!==null&&r!==void 0?r:Zs(e.state)):new ar(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Yo(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ar(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function m9(n,e,t,r){if(!n)return!1;let i=e.sliceDoc(t,r);return typeof n=="function"?n(i,t,r,e):lE(n,!0).test(i)}const F0=He.define({map(n,e){return n.map(t=>t.map(e))}}),uE=He.define(),An=un.define({create(){return nd.start()},update(n,e){return n.update(e)},provide:n=>[P0.from(n,e=>e.tooltip),ve.contentAttributes.from(n,e=>e.attrs)]});function z0(n,e){const t=e.completion.apply||e.completion.label;let r=n.state.field(An).active.find(i=>i.source==e.source);return r instanceof Yo?(typeof t=="string"?n.dispatch({...t9(n.state,t,r.from,r.to),annotations:aE.of(e.completion)}):t(n,e.completion,r.from,r.to),!0):!1}const g9=a9(An,z0);function sf(n,e="option"){return t=>{let r=t.state.field(An,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<t.state.facet(nn).interactionDelay)return!1;let i=1,s;e=="page"&&(s=AC(t,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(n?1:-1):n?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:uE.of(a)}),!0}}const y9=n=>{let e=n.state.field(An,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(nn).interactionDelay?!1:z0(n,e.open.options[e.open.selected])},gm=n=>n.state.field(An,!1)?(n.dispatch({effects:td.of(!0)}),!0):!1,v9=n=>{let e=n.state.field(An,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Xa.of(null)}),!0)};class x9{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const w9=50,b9=1e3,S9=Bt.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(An).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(An),t=n.state.facet(nn);if(!n.selectionSet&&!n.docChanged&&n.startState.field(An)==e)return;let r=n.transactions.some(s=>{let o=cE(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(r||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>w9&&Date.now()-o.time>b9){for(let a of o.context.abortListeners)try{a()}catch(u){In(this.view.state,u)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(s=>s.effects.some(o=>o.is(td)))&&(this.pendingStart=!0);let i=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of n.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:n}=this.view,e=n.field(An);for(let t of e.active)t.isPending&&!this.running.some(r=>r.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nn).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Zs(e),r=new sE(e,t,n.explicit,this.view),i=new x9(n,r);this.running.push(i),Promise.resolve(n.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Xa.of(null)}),In(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nn).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(nn),r=this.view.state.field(An);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let a=Zs(s.updates.length?s.updates[0].startState:this.view.state),u=Math.min(a,s.done.from+(s.active.explicit?0:1)),f=new Yo(s.active.source,s.active.explicit,u,s.done,s.done.from,(n=s.done.to)!==null&&n!==void 0?n:a);for(let h of s.updates)f=f.update(h,t);if(f.hasResult()){e.push(f);continue}}let o=r.active.find(a=>a.source==s.active.source);if(o&&o.isPending)if(s.done==null){let a=new ar(s.active.source,0);for(let u of s.updates)a=a.update(u,t);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:F0.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(An,!1);if(e&&e.tooltip&&this.view.state.facet(nn).closeOnBlur){let t=e.open&&AC(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Xa.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:td.of(!1)}),20),this.composing=0}}}),k9=typeof navigator=="object"&&/Win/.test(navigator.platform),C9=ws.highest(ve.domEventHandlers({keydown(n,e){let t=e.state.field(An,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(k9&&n.altKey)||n.metaKey)return!1;let r=t.open.options[t.open.selected],i=t.active.find(o=>o.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(n.key)>-1&&z0(e,r),!1}})),E9=ve.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"},".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"}}}),Ja={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Qs=He.define({map(n,e){let t=e.mapPos(n,-1,bn.TrackAfter);return t??void 0}}),_0=new class extends ds{};_0.startSide=1;_0.endSide=-1;const fE=un.define({create(){return Ze.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:r=>r>=t.from&&r<=t.to})}for(let t of e.effects)t.is(Qs)&&(n=n.update({add:[_0.range(t.value,t.value+1)]}));return n}});function R9(){return[M9,fE]}const ym="()[]{}<>«»»«[]{}";function dE(n){for(let e=0;e<ym.length;e+=2)if(ym.charCodeAt(e)==n)return ym.charAt(e+1);return p0(n<128?n:n+1)}function hE(n,e){return n.languageDataAt("closeBrackets",e)[0]||Ja}const T9=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),M9=ve.inputHandler.of((n,e,t,r)=>{if((T9?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let i=n.state.selection.main;if(r.length>2||r.length==2&&Gr(Pn(r,0))==1||e!=i.from||t!=i.to)return!1;let s=A9(n.state,r);return s?(n.dispatch(s),!0):!1}),O9=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let r=hE(n,n.selection.main.head).brackets||Ja.brackets,i=null,s=n.changeByRange(o=>{if(o.empty){let a=N9(n.doc,o.head);for(let u of r)if(u==a&&Fd(n.doc,o.head)==dE(Pn(u,0)))return{changes:{from:o.head-u.length,to:o.head+u.length},range:te.cursor(o.head-u.length)}}return{range:i=o}});return i||e(n.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},P9=[{key:"Backspace",run:O9}];function A9(n,e){let t=hE(n,n.selection.main.head),r=t.brackets||Ja.brackets;for(let i of r){let s=dE(Pn(i,0));if(e==i)return s==i?I9(n,i,r.indexOf(i+i+i)>-1,t):L9(n,i,s,t.before||Ja.before);if(e==s&&pE(n,n.selection.main.from))return D9(n,i,s)}return null}function pE(n,e){let t=!1;return n.field(fE).between(0,n.doc.length,r=>{r==e&&(t=!0)}),t}function Fd(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Gr(Pn(t,0)))}function N9(n,e){let t=n.sliceString(e-2,e);return Gr(Pn(t,0))==t.length?t:t.slice(1)}function L9(n,e,t,r){let i=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Qs.of(o.to+e.length),range:te.range(o.anchor+e.length,o.head+e.length)};let a=Fd(n.doc,o.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:Qs.of(o.head+e.length),range:te.cursor(o.head+e.length)}:{range:i=o}});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function D9(n,e,t){let r=null,i=n.changeByRange(s=>s.empty&&Fd(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:te.cursor(s.head+t.length)}:r={range:s});return r?null:n.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function I9(n,e,t,r){let i=r.stringPrefixes||Ja.stringPrefixes,s=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Qs.of(a.to+e.length),range:te.range(a.anchor+e.length,a.head+e.length)};let u=a.head,f=Fd(n.doc,u),h;if(f==e){if(db(n,u))return{changes:{insert:e+e,from:u},effects:Qs.of(u+e.length),range:te.cursor(u+e.length)};if(pE(n,u)){let g=t&&n.sliceDoc(u,u+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:u,to:u+g.length,insert:g},range:te.cursor(u+g.length)}}}else{if(t&&n.sliceDoc(u-2*e.length,u)==e+e&&(h=hb(n,u-2*e.length,i))>-1&&db(n,h))return{changes:{insert:e+e+e+e,from:u},effects:Qs.of(u+e.length),range:te.cursor(u+e.length)};if(n.charCategorizer(u)(f)!=kt.Word&&hb(n,u,i)>-1&&!j9(n,u,e,i))return{changes:{insert:e+e,from:u},effects:Qs.of(u+e.length),range:te.cursor(u+e.length)}}return{range:s=a}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function db(n,e){let t=rn(n).resolveInner(e+1);return t.parent&&t.from==e}function j9(n,e,t,r){let i=rn(n).resolveInner(e,-1),s=r.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=n.sliceDoc(i.from,Math.min(i.to,i.from+t.length+s)),u=a.indexOf(t);if(!u||u>-1&&r.indexOf(a.slice(0,u))>-1){let h=i.firstChild;for(;h&&h.from==i.from&&h.to-h.from>t.length+u;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let f=i.to==e&&i.parent;if(!f)break;i=f}return!1}function hb(n,e,t){let r=n.charCategorizer(e);if(r(n.sliceDoc(e-1,e))!=kt.Word)return e;for(let i of t){let s=e-i.length;if(n.sliceDoc(s,e)==i&&r(n.sliceDoc(s-1,s))!=kt.Word)return s}return-1}function B9(n={}){return[C9,An,nn.of(n),S9,F9,E9]}const mE=[{key:"Ctrl-Space",run:gm},{mac:"Alt-`",run:gm},{mac:"Alt-i",run:gm},{key:"Escape",run:v9},{key:"ArrowDown",run:sf(!0)},{key:"ArrowUp",run:sf(!1)},{key:"PageDown",run:sf(!0,"page")},{key:"PageUp",run:sf(!1,"page")},{key:"Enter",run:y9}],F9=ws.highest(Ha.computeN([nn],n=>n.facet(nn).defaultKeymap?[mE]:[])),z9=36,pb=1,_9=2,Do=3,vm=4,V9=5,W9=6,$9=7,H9=8,U9=9,q9=10,K9=11,Q9=12,G9=13,Y9=14,X9=15,J9=16,Z9=17,mb=18,ej=19,gE=20,yE=21,gb=22,tj=23,nj=24;function Pg(n){return n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57}function rj(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function $s(n,e,t){for(let r=!1;;){if(n.next<0)return;if(n.next==e&&!r){n.advance();return}r=t&&!r&&n.next==92,n.advance()}}function ij(n,e){e:for(;;){if(n.next<0)return;if(n.next==36){n.advance();for(let t=0;t<e.length;t++){if(n.next!=e.charCodeAt(t))continue e;n.advance()}if(n.next==36){n.advance();return}}else n.advance()}}function sj(n,e){let t="[{<(".indexOf(String.fromCharCode(e)),r=t<0?e:"]}>)".charCodeAt(t);for(;;){if(n.next<0)return;if(n.next==r&&n.peek(1)==39){n.advance(2);return}n.advance()}}function Ag(n,e){for(;!(n.next!=95&&!Pg(n.next));)e!=null&&(e+=String.fromCharCode(n.next)),n.advance();return e}function oj(n){if(n.next==39||n.next==34||n.next==96){let e=n.next;n.advance(),$s(n,e,!1)}else Ag(n)}function yb(n,e){for(;n.next==48||n.next==49;)n.advance();e&&n.next==e&&n.advance()}function vb(n,e){for(;;){if(n.next==46){if(e)break;e=!0}else if(n.next<48||n.next>57)break;n.advance()}if(n.next==69||n.next==101)for(n.advance(),(n.next==43||n.next==45)&&n.advance();n.next>=48&&n.next<=57;)n.advance()}function xb(n){for(;!(n.next<0||n.next==10);)n.advance()}function Fs(n,e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)==n)return!0;return!1}const xm=` 	\r
`;function vE(n,e,t){let r=Object.create(null);r.true=r.false=V9,r.null=r.unknown=W9;for(let i of n.split(" "))i&&(r[i]=gE);for(let i of e.split(" "))i&&(r[i]=yE);for(let i of(t||"").split(" "))i&&(r[i]=nj);return r}const lj="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",aj="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",Ng={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:vE(aj,lj)};function cj(n,e,t,r){let i={};for(let s in Ng)i[s]=(n.hasOwnProperty(s)?n:Ng)[s];return e&&(i.words=vE(e,t||"",r)),i}function xE(n){return new U6(e=>{var t;let{next:r}=e;if(e.advance(),Fs(r,xm)){for(;Fs(e.next,xm);)e.advance();e.acceptToken(z9)}else if(r==36&&n.doubleDollarQuotedStrings){let i=Ag(e,"");e.next==36&&(e.advance(),ij(e,i),e.acceptToken(Do))}else if(r==39||r==34&&n.doubleQuotedStrings)$s(e,r,n.backslashEscapes),e.acceptToken(Do);else if(r==35&&n.hashComments||r==47&&e.next==47&&n.slashComments)xb(e),e.acceptToken(pb);else if(r==45&&e.next==45&&(!n.spaceAfterDashes||e.peek(1)==32))xb(e),e.acceptToken(pb);else if(r==47&&e.next==42){e.advance();for(let i=1;;){let s=e.next;if(e.next<0)break;if(e.advance(),s==42&&e.next==47){if(i--,e.advance(),!i)break}else s==47&&e.next==42&&(i++,e.advance())}e.acceptToken(_9)}else if((r==101||r==69)&&e.next==39)e.advance(),$s(e,39,!0),e.acceptToken(Do);else if((r==110||r==78)&&e.next==39&&n.charSetCasts)e.advance(),$s(e,39,n.backslashEscapes),e.acceptToken(Do);else if(r==95&&n.charSetCasts)for(let i=0;;i++){if(e.next==39&&i>1){e.advance(),$s(e,39,n.backslashEscapes),e.acceptToken(Do);break}if(!Pg(e.next))break;e.advance()}else if(n.plsqlQuotingMechanism&&(r==113||r==81)&&e.next==39&&e.peek(1)>0&&!Fs(e.peek(1),xm)){let i=e.peek(1);e.advance(2),sj(e,i),e.acceptToken(Do)}else if(Fs(r,n.identifierQuotes)){const i=r==91?93:r;$s(e,i,!1),e.acceptToken(ej)}else if(r==40)e.acceptToken($9);else if(r==41)e.acceptToken(H9);else if(r==123)e.acceptToken(U9);else if(r==125)e.acceptToken(q9);else if(r==91)e.acceptToken(K9);else if(r==93)e.acceptToken(Q9);else if(r==59)e.acceptToken(G9);else if(n.unquotedBitLiterals&&r==48&&e.next==98)e.advance(),yb(e),e.acceptToken(gb);else if((r==98||r==66)&&(e.next==39||e.next==34)){const i=e.next;e.advance(),n.treatBitsAsBytes?($s(e,i,n.backslashEscapes),e.acceptToken(tj)):(yb(e,i),e.acceptToken(gb))}else if(r==48&&(e.next==120||e.next==88)||(r==120||r==88)&&e.next==39){let i=e.next==39;for(e.advance();rj(e.next);)e.advance();i&&e.next==39&&e.advance(),e.acceptToken(vm)}else if(r==46&&e.next>=48&&e.next<=57)vb(e,!0),e.acceptToken(vm);else if(r==46)e.acceptToken(Y9);else if(r>=48&&r<=57)vb(e,!1),e.acceptToken(vm);else if(Fs(r,n.operatorChars)){for(;Fs(e.next,n.operatorChars);)e.advance();e.acceptToken(X9)}else if(Fs(r,n.specialVar))e.next==r&&e.advance(),oj(e),e.acceptToken(Z9);else if(r==58||r==44)e.acceptToken(J9);else if(Pg(r)){let i=Ag(e,String.fromCharCode(r));e.acceptToken(e.next==46||e.peek(-i.length-1)==46?mb:(t=n.words[i.toLowerCase()])!==null&&t!==void 0?t:mb)}})}const wE=xE(Ng),uj=ed.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,wE],topRules:{Script:[0,25]},tokenPrec:0});function Lg(n){let e=n.cursor().moveTo(n.from,-1);for(;/Comment/.test(e.name);)e.moveTo(e.from,-1);return e.node}function Za(n,e){let t=n.sliceString(e.from,e.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(t);return r?r[2]:t}function rd(n){return n&&(n.name=="Identifier"||n.name=="QuotedIdentifier")}function fj(n,e){if(e.name=="CompositeIdentifier"){let t=[];for(let r=e.firstChild;r;r=r.nextSibling)rd(r)&&t.push(Za(n,r));return t}return[Za(n,e)]}function wb(n,e){for(let t=[];;){if(!e||e.name!=".")return t;let r=Lg(e);if(!rd(r))return t;t.unshift(Za(n,r)),e=Lg(r)}}function dj(n,e){let t=rn(n).resolveInner(e,-1),r=pj(n.doc,t);return t.name=="Identifier"||t.name=="QuotedIdentifier"||t.name=="Keyword"?{from:t.from,quoted:t.name=="QuotedIdentifier"?n.doc.sliceString(t.from,t.from+1):null,parents:wb(n.doc,Lg(t)),aliases:r}:t.name=="."?{from:e,quoted:null,parents:wb(n.doc,t),aliases:r}:{from:e,quoted:null,parents:[],empty:!0,aliases:r}}const hj=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function pj(n,e){let t;for(let i=e;!t;i=i.parent){if(!i)return null;i.name=="Statement"&&(t=i)}let r=null;for(let i=t.firstChild,s=!1,o=null;i;i=i.nextSibling){let a=i.name=="Keyword"?n.sliceString(i.from,i.to).toLowerCase():null,u=null;if(!s)s=a=="from";else if(a=="as"&&o&&rd(i.nextSibling))u=Za(n,i.nextSibling);else{if(a&&hj.has(a))break;o&&rd(i)&&(u=Za(n,i))}u&&(r||(r=Object.create(null)),r[u]=fj(n,o)),o=/Identifier$/.test(i.name)?i:null}return r}function mj(n,e,t){return t.map(r=>({...r,label:r.label[0]==n?r.label:n+r.label+e,apply:void 0}))}const gj=/^\w*$/,yj=/^[`'"\[]?\w*[`'"\]]?$/;function bb(n){return n.self&&typeof n.self.label=="string"}class V0{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(e){let t=this.children||(this.children=Object.create(null)),r=t[e];return r||(e&&!this.list.some(i=>i.label==e)&&this.list.push(Sb(e,"type",this.idQuote,this.idCaseInsensitive)),t[e]=new V0(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(r=>r.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t=="string"?Sb(t,"property",this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):bb(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let r=e[t],i=null,s=t.replace(/\\?\./g,a=>a=="."?"\0":a).split("\0"),o=this;bb(r)&&(i=r.self,r=r.children);for(let a=0;a<s.length;a++)i&&a==s.length-1&&o.addCompletion(i),o=o.child(s[a].replace(/\\\./g,"."));o.addNamespace(r)}}}function Sb(n,e,t,r){return new RegExp("^[a-z_][a-z_\\d]*$",r?"i":"").test(n)?{label:n,type:e}:{label:n,type:e,apply:t+n+bE(t)}}function bE(n){return n==="["?"]":n}function vj(n,e,t,r,i,s){var o;let a=((o=s==null?void 0:s.spec.identifierQuotes)===null||o===void 0?void 0:o[0])||'"',u=new V0(a,!!(s!=null&&s.spec.caseInsensitiveIdentifiers)),f=i?u.child(i):null;return u.addNamespace(n),e&&(f||u).addCompletions(e),t&&u.addCompletions(t),f&&u.addCompletions(f.list),r&&u.addCompletions((f||u).child(r).list),h=>{let{parents:p,from:g,quoted:y,empty:x,aliases:w}=dj(h.state,h.pos);if(x&&!h.explicit)return null;w&&p.length==1&&(p=w[p[0]]||p);let C=u;for(let T of p){for(;!C.children||!C.children[T];)if(C==u&&f)C=f;else if(C==f&&r)C=C.child(r);else return null;let M=C.maybeChild(T);if(!M)return null;C=M}let E=C.list;if(C==u&&w&&(E=E.concat(Object.keys(w).map(T=>({label:T,type:"constant"})))),y){let T=y[0],M=bE(T),P=h.state.sliceDoc(h.pos,h.pos+1)==M;return{from:g,to:P?h.pos+1:void 0,options:mj(T,M,E),validFor:yj}}else return{from:g,options:E,validFor:gj}}}function xj(n){return n==yE?"type":n==gE?"keyword":"variable"}function wj(n,e,t){let r=Object.keys(n).map(i=>t(e?i.toUpperCase():i,xj(n[i])));return e9(["QuotedIdentifier","String","LineComment","BlockComment","."],oE(r))}let bj=uj.configure({props:[HC.add({Statement:u6()}),qC.add({Statement(n,e){return{from:Math.min(n.from+100,e.doc.lineAt(n.from).to),to:n.to}},BlockComment(n){return{from:n.from+2,to:n.to-2}}}),_C({Keyword:ie.keyword,Type:ie.typeName,Builtin:ie.standard(ie.name),Bits:ie.number,Bytes:ie.string,Bool:ie.bool,Null:ie.null,Number:ie.number,String:ie.string,Identifier:ie.name,QuotedIdentifier:ie.special(ie.string),SpecialVar:ie.special(ie.name),LineComment:ie.lineComment,BlockComment:ie.blockComment,Operator:ie.operator,"Semi Punctuation":ie.punctuation,"( )":ie.paren,"{ }":ie.brace,"[ ]":ie.squareBracket})]});class id{constructor(e,t,r){this.dialect=e,this.language=t,this.spec=r}get extension(){return this.language.extension}configureLanguage(e,t){return new id(this.dialect,this.language.configure(e,t),this.spec)}static define(e){let t=cj(e,e.keywords,e.types,e.builtin),r=Kf.define({name:"sql",parser:bj.configure({tokenizers:[{from:wE,to:xE(t)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new id(t,r,e)}}function Sj(n,e){return{label:n,type:e,boost:-1}}function kj(n,e=!1,t){return wj(n.dialect.words,e,t||Sj)}function Cj(n){return n.schema?vj(n.schema,n.tables,n.schemas,n.defaultTable,n.defaultSchema,n.dialect||W0):()=>null}function Ej(n){return n.schema?(n.dialect||W0).language.data.of({autocomplete:Cj(n)}):[]}function Rj(n={}){let e=n.dialect||W0;return new t6(e.language,[Ej(n),e.language.data.of({autocomplete:kj(e,n.upperCaseKeywords,n.keywordCompletion)})])}const W0=id.define({}),Tj=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),r=H0(n.state,t.from);return r.line?Mj(n):r.block?Pj(n):!1};function $0(n,e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let i=n(e,t);return i?(r(t.update(i)),!0):!1}}const Mj=$0(Lj,0),Oj=$0(SE,0),Pj=$0((n,e)=>SE(n,e,Nj(e)),0);function H0(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const ha=50;function Aj(n,{open:e,close:t},r,i){let s=n.sliceDoc(r-ha,r),o=n.sliceDoc(i,i+ha),a=/\s*$/.exec(s)[0].length,u=/^\s*/.exec(o)[0].length,f=s.length-a;if(s.slice(f-e.length,f)==e&&o.slice(u,u+t.length)==t)return{open:{pos:r-a,margin:a&&1},close:{pos:i+u,margin:u&&1}};let h,p;i-r<=2*ha?h=p=n.sliceDoc(r,i):(h=n.sliceDoc(r,r+ha),p=n.sliceDoc(i-ha,i));let g=/^\s*/.exec(h)[0].length,y=/\s*$/.exec(p)[0].length,x=p.length-y-t.length;return h.slice(g,g+e.length)==e&&p.slice(x,x+t.length)==t?{open:{pos:r+g+e.length,margin:/\s/.test(h.charAt(g+e.length))?1:0},close:{pos:i-y-t.length,margin:/\s/.test(p.charAt(x-1))?1:0}}:null}function Nj(n){let e=[];for(let t of n.selection.ranges){let r=n.doc.lineAt(t.from),i=t.to<=r.to?r:n.doc.lineAt(t.to);i.from>r.from&&i.from==t.to&&(i=t.to==r.to+1?r:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function SE(n,e,t=e.selection.ranges){let r=t.map(s=>H0(e,s.from).block);if(!r.every(s=>s))return null;let i=t.map((s,o)=>Aj(e,r[o],s.from,s.to));if(n!=2&&!i.every(s=>s))return{changes:e.changes(t.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(n!=1&&i.some(s=>s)){let s=[];for(let o=0,a;o<i.length;o++)if(a=i[o]){let u=r[o],{open:f,close:h}=a;s.push({from:f.pos-u.open.length,to:f.pos+f.margin},{from:h.pos-h.margin,to:h.pos+u.close.length})}return{changes:s}}return null}function Lj(n,e,t=e.selection.ranges){let r=[],i=-1;for(let{from:s,to:o}of t){let a=r.length,u=1e9,f=H0(e,s).line;if(f){for(let h=s;h<=o;){let p=e.doc.lineAt(h);if(p.from>i&&(s==o||o>p.from)){i=p.from;let g=/^\s*/.exec(p.text)[0].length,y=g==p.length,x=p.text.slice(g,g+f.length)==f?g:-1;g<p.text.length&&g<u&&(u=g),r.push({line:p,comment:x,token:f,indent:g,empty:y,single:!1})}h=p.to+1}if(u<1e9)for(let h=a;h<r.length;h++)r[h].indent<r[h].line.text.length&&(r[h].indent=u);r.length==a+1&&(r[a].single=!0)}}if(n!=2&&r.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:u,indent:f,empty:h,single:p}of r)(p||!h)&&s.push({from:a.from+f,insert:u+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:u}of r)if(a>=0){let f=o.from+a,h=f+u.length;o.text[h-o.from]==" "&&h++,s.push({from:f,to:h})}return{changes:s}}return null}const Dg=Li.define(),Dj=Li.define(),Ij=ke.define(),kE=ke.define({combine(n){return si(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(r,i)=>e(r,i)||t(r,i)})}}),CE=un.define({create(){return Jr.empty},update(n,e){let t=e.state.facet(kE),r=e.annotation(Dg);if(r){let u=jn.fromTransaction(e,r.selection),f=r.side,h=f==0?n.undone:n.done;return u?h=sd(h,h.length,t.minDepth,u):h=TE(h,e.startState.selection),new Jr(f==0?r.rest:h,f==0?h:r.rest)}let i=e.annotation(Dj);if((i=="full"||i=="before")&&(n=n.isolate()),e.annotation(Gt.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=jn.fromTransaction(e),o=e.annotation(Gt.time),a=e.annotation(Gt.userEvent);return s?n=n.addChanges(s,o,a,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(i=="full"||i=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Jr(n.done.map(jn.fromJSON),n.undone.map(jn.fromJSON))}});function jj(n={}){return[CE,kE.of(n),ve.domEventHandlers({beforeinput(e,t){let r=e.inputType=="historyUndo"?EE:e.inputType=="historyRedo"?Ig:null;return r?(e.preventDefault(),r(t)):!1}})]}function zd(n,e){return function({state:t,dispatch:r}){if(!e&&t.readOnly)return!1;let i=t.field(CE,!1);if(!i)return!1;let s=i.pop(n,t,e);return s?(r(s),!0):!1}}const EE=zd(0,!1),Ig=zd(1,!1),Bj=zd(0,!0),Fj=zd(1,!0);class jn{constructor(e,t,r,i,s){this.changes=e,this.effects=t,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new jn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new jn(e.changes&&Kt.fromJSON(e.changes),[],e.mapped&&ei.fromJSON(e.mapped),e.startSelection&&te.fromJSON(e.startSelection),e.selectionsAfter.map(te.fromJSON))}static fromTransaction(e,t){let r=cr;for(let i of e.startState.facet(Ij)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new jn(e.changes.invert(e.startState.doc),r,void 0,t||e.startState.selection,cr)}static selection(e){return new jn(void 0,cr,void 0,void 0,e)}}function sd(n,e,t,r){let i=e+1>t+20?e-t-1:0,s=n.slice(i,e);return s.push(r),s}function zj(n,e){let t=[],r=!1;return n.iterChangedRanges((i,s)=>t.push(i,s)),e.iterChangedRanges((i,s,o,a)=>{for(let u=0;u<t.length;){let f=t[u++],h=t[u++];a>=f&&o<=h&&(r=!0)}}),r}function _j(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,r)=>t.empty!=e.ranges[r].empty).length===0}function RE(n,e){return n.length?e.length?n.concat(e):n:e}const cr=[],Vj=200;function TE(n,e){if(n.length){let t=n[n.length-1],r=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Vj));return r.length&&r[r.length-1].eq(e)?n:(r.push(e),sd(n,n.length-1,1e9,t.setSelAfter(r)))}else return[jn.selection([e])]}function Wj(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function wm(n,e){if(!n.length)return n;let t=n.length,r=cr;for(;t;){let i=$j(n[t-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=n.slice(0,t);return s[t-1]=i,s}else e=i.mapped,t--,r=i.selectionsAfter}return r.length?[jn.selection(r)]:cr}function $j(n,e,t){let r=RE(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):cr,t);if(!n.changes)return jn.selection(r);let i=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new jn(i,He.mapEffects(n.effects,e),o,n.startSelection.map(s),r)}const Hj=/^(input\.type|delete)($|\.)/;class Jr{constructor(e,t,r=0,i=void 0){this.done=e,this.undone=t,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new Jr(this.done,this.undone):this}addChanges(e,t,r,i,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||Hj.test(r))&&(!a.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,zj(a.changes,e.changes))||r=="input.type.compose")?o=sd(o,o.length-1,i.minDepth,new jn(e.changes.compose(a.changes),RE(He.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,cr)):o=sd(o,o.length,i.minDepth,e),new Jr(o,cr,t,r)}addSelection(e,t,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:cr;return s.length>0&&t-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&_j(s[s.length-1],e)?this:new Jr(TE(this.done,e),this.undone,t,r)}addMapping(e){return new Jr(wm(this.done,e),wm(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,r){let i=e==0?this.done:this.undone;if(i.length==0)return null;let s=i[i.length-1],o=s.selectionsAfter[0]||t.selection;if(r&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Dg.of({side:e,rest:Wj(i),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?cr:i.slice(0,i.length-1);return s.mapped&&(a=wm(a,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Dg.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Jr.empty=new Jr(cr,cr);const Uj=[{key:"Mod-z",run:EE,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ig,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ig,preventDefault:!0},{key:"Mod-u",run:Bj,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Fj,preventDefault:!0}];function vl(n,e){return te.create(n.ranges.map(e),n.mainIndex)}function Nr(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Lr({state:n,dispatch:e},t){let r=vl(n.selection,t);return r.eq(n.selection,!0)?!1:(e(Nr(n,r)),!0)}function _d(n,e){return te.cursor(e?n.to:n.from)}function ME(n,e){return Lr(n,t=>t.empty?n.moveByChar(t,e):_d(t,e))}function yn(n){return n.textDirectionAt(n.state.selection.main.head)==pt.LTR}const OE=n=>ME(n,!yn(n)),PE=n=>ME(n,yn(n));function AE(n,e){return Lr(n,t=>t.empty?n.moveByGroup(t,e):_d(t,e))}const qj=n=>AE(n,!yn(n)),Kj=n=>AE(n,yn(n));function Qj(n,e,t){if(e.type.prop(t))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Vd(n,e,t){let r=rn(n).resolveInner(e.head),i=t?Ge.closedBy:Ge.openedBy;for(let u=e.head;;){let f=t?r.childAfter(u):r.childBefore(u);if(!f)break;Qj(n,f,i)?r=f:u=t?f.to:f.from}let s=r.type.prop(i),o,a;return s&&(o=t?Xr(n,r.from,1):Xr(n,r.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?r.to:r.from,te.cursor(a,t?-1:1)}const Gj=n=>Lr(n,e=>Vd(n.state,e,!yn(n))),Yj=n=>Lr(n,e=>Vd(n.state,e,yn(n)));function NE(n,e){return Lr(n,t=>{if(!t.empty)return _d(t,e);let r=n.moveVertically(t,e);return r.head!=t.head?r:n.moveToLineBoundary(t,e)})}const LE=n=>NE(n,!1),DE=n=>NE(n,!0);function IE(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,r=0,i;if(e){for(let s of n.state.facet(ve.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(r=Math.max(o==null?void 0:o.bottom,r))}i=n.scrollDOM.clientHeight-t-r}else i=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:r,selfScroll:e,height:Math.max(n.defaultLineHeight,i-5)}}function jE(n,e){let t=IE(n),{state:r}=n,i=vl(r.selection,o=>o.empty?n.moveVertically(o,e,t.height):_d(o,e));if(i.eq(r.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(r.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),u=a.top+t.marginTop,f=a.bottom-t.marginBottom;o&&o.top>u&&o.bottom<f&&(s=ve.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-u}))}return n.dispatch(Nr(r,i),{effects:s}),!0}const kb=n=>jE(n,!1),jg=n=>jE(n,!0);function bs(n,e,t){let r=n.lineBlockAt(e.head),i=n.moveToLineBoundary(e,t);if(i.head==e.head&&i.head!=(t?r.to:r.from)&&(i=n.moveToLineBoundary(e,t,!1)),!t&&i.head==r.from&&r.length){let s=/^\s*/.exec(n.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=te.cursor(r.from+s))}return i}const Xj=n=>Lr(n,e=>bs(n,e,!0)),Jj=n=>Lr(n,e=>bs(n,e,!1)),Zj=n=>Lr(n,e=>bs(n,e,!yn(n))),eB=n=>Lr(n,e=>bs(n,e,yn(n))),tB=n=>Lr(n,e=>te.cursor(n.lineBlockAt(e.head).from,1)),nB=n=>Lr(n,e=>te.cursor(n.lineBlockAt(e.head).to,-1));function rB(n,e,t){let r=!1,i=vl(n.selection,s=>{let o=Xr(n,s.head,-1)||Xr(n,s.head,1)||s.head>0&&Xr(n,s.head-1,1)||s.head<n.doc.length&&Xr(n,s.head+1,-1);if(!o||!o.end)return s;r=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return te.cursor(a)});return r?(e(Nr(n,i)),!0):!1}const iB=({state:n,dispatch:e})=>rB(n,e);function pr(n,e){let t=vl(n.state.selection,r=>{let i=e(r);return te.range(r.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(Nr(n.state,t)),!0)}function BE(n,e){return pr(n,t=>n.moveByChar(t,e))}const FE=n=>BE(n,!yn(n)),zE=n=>BE(n,yn(n));function _E(n,e){return pr(n,t=>n.moveByGroup(t,e))}const sB=n=>_E(n,!yn(n)),oB=n=>_E(n,yn(n)),lB=n=>pr(n,e=>Vd(n.state,e,!yn(n))),aB=n=>pr(n,e=>Vd(n.state,e,yn(n)));function VE(n,e){return pr(n,t=>n.moveVertically(t,e))}const WE=n=>VE(n,!1),$E=n=>VE(n,!0);function HE(n,e){return pr(n,t=>n.moveVertically(t,e,IE(n).height))}const Cb=n=>HE(n,!1),Eb=n=>HE(n,!0),cB=n=>pr(n,e=>bs(n,e,!0)),uB=n=>pr(n,e=>bs(n,e,!1)),fB=n=>pr(n,e=>bs(n,e,!yn(n))),dB=n=>pr(n,e=>bs(n,e,yn(n))),hB=n=>pr(n,e=>te.cursor(n.lineBlockAt(e.head).from)),pB=n=>pr(n,e=>te.cursor(n.lineBlockAt(e.head).to)),Rb=({state:n,dispatch:e})=>(e(Nr(n,{anchor:0})),!0),Tb=({state:n,dispatch:e})=>(e(Nr(n,{anchor:n.doc.length})),!0),Mb=({state:n,dispatch:e})=>(e(Nr(n,{anchor:n.selection.main.anchor,head:0})),!0),Ob=({state:n,dispatch:e})=>(e(Nr(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),mB=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),gB=({state:n,dispatch:e})=>{let t=Wd(n).map(({from:r,to:i})=>te.range(r,Math.min(i+1,n.doc.length)));return e(n.update({selection:te.create(t),userEvent:"select"})),!0},yB=({state:n,dispatch:e})=>{let t=vl(n.selection,r=>{let i=rn(n),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.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:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&o.next)return te.range(a.to,a.from)}return r});return t.eq(n.selection)?!1:(e(Nr(n,t)),!0)};function UE(n,e){let{state:t}=n,r=t.selection,i=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<n.state.doc.length:o.from>0)for(let a=s;;){let u=n.moveVertically(a,e);if(u.head<o.from||u.head>o.to){i.some(f=>f.head==u.head)||i.push(u);break}else{if(u.head==a.head)break;a=u}}}return i.length==r.ranges.length?!1:(n.dispatch(Nr(t,te.create(i,i.length-1))),!0)}const vB=n=>UE(n,!1),xB=n=>UE(n,!0),wB=({state:n,dispatch:e})=>{let t=n.selection,r=null;return t.ranges.length>1?r=te.create([t.main]):t.main.empty||(r=te.create([te.cursor(t.main.head)])),r?(e(Nr(n,r)),!0):!1};function xc(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:r}=n,i=r.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let u=e(s);u<o?(t="delete.backward",u=of(n,u,!1)):u>o&&(t="delete.forward",u=of(n,u,!0)),o=Math.min(o,u),a=Math.max(a,u)}else o=of(n,o,!1),a=of(n,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:te.cursor(o,o<s.head?-1:1)}});return i.changes.empty?!1:(n.dispatch(r.update(i,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?ve.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function of(n,e,t){if(n instanceof ve)for(let r of n.state.facet(ve.atomicRanges).map(i=>i(n)))r.between(e,e,(i,s)=>{i<e&&s>e&&(e=t?s:i)});return e}const qE=(n,e,t)=>xc(n,r=>{let i=r.from,{state:s}=n,o=s.doc.lineAt(i),a,u;if(t&&!e&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,i-o.from))){if(a[a.length-1]=="	")return i-1;let f=yl(a,s.tabSize),h=f%Gf(s)||Gf(s);for(let p=0;p<h&&a[a.length-1-p]==" ";p++)i--;u=i}else u=Qt(o.text,i-o.from,e,e)+o.from,u==i&&o.number!=(e?s.doc.lines:1)?u+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(u-o.from,i-o.from))&&(u=Qt(o.text,u-o.from,!1,!1)+o.from);return u}),Bg=n=>qE(n,!1,!0),KE=n=>qE(n,!0,!1),QE=(n,e)=>xc(n,t=>{let r=t.head,{state:i}=n,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let a=null;;){if(r==(e?s.to:s.from)){r==t.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let u=Qt(s.text,r-s.from,e)+s.from,f=s.text.slice(Math.min(r,u)-s.from,Math.max(r,u)-s.from),h=o(f);if(a!=null&&h!=a)break;(f!=" "||r!=t.head)&&(a=h),r=u}return r}),GE=n=>QE(n,!1),bB=n=>QE(n,!0),SB=n=>xc(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),kB=n=>xc(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),CB=n=>xc(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),EB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:lt.of(["",""])},range:te.cursor(r.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},RB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(r=>{if(!r.empty||r.from==0||r.from==n.doc.length)return{range:r};let i=r.from,s=n.doc.lineAt(i),o=i==s.from?i-1:Qt(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:Qt(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:n.doc.slice(i,a).append(n.doc.slice(o,i))},range:te.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Wd(n){let e=[],t=-1;for(let r of n.selection.ranges){let i=n.doc.lineAt(r.from),s=n.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=n.doc.lineAt(r.to-1)),t>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});t=s.number+1}return e}function YE(n,e,t){if(n.readOnly)return!1;let r=[],i=[];for(let s of Wd(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),a=o.length+1;if(t){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let u of s.ranges)i.push(te.range(Math.min(n.doc.length,u.anchor+a),Math.min(n.doc.length,u.head+a)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let u of s.ranges)i.push(te.range(u.anchor-a,u.head-a))}}return r.length?(e(n.update({changes:r,scrollIntoView:!0,selection:te.create(i,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const TB=({state:n,dispatch:e})=>YE(n,e,!1),MB=({state:n,dispatch:e})=>YE(n,e,!0);function XE(n,e,t){if(n.readOnly)return!1;let r=[];for(let s of Wd(n))t?r.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):r.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let i=n.changes(r);return e(n.update({changes:i,selection:n.selection.map(i,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const OB=({state:n,dispatch:e})=>XE(n,e,!1),PB=({state:n,dispatch:e})=>XE(n,e,!0),AB=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Wd(e).map(({from:i,to:s})=>(i>0?i--:s<e.doc.length&&s++,{from:i,to:s}))),r=vl(e.selection,i=>{let s;if(n.lineWrapping){let o=n.lineBlockAt(i.head),a=n.coordsAtPos(i.head,i.assoc||1);a&&(s=o.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(i,!0,s)}).map(t);return n.dispatch({changes:t,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function NB(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=rn(n).resolveInner(e),r=t.childBefore(e),i=t.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(Ge.closedBy))&&s.indexOf(i.name)>-1&&n.doc.lineAt(r.to).from==n.doc.lineAt(i.from).from&&!/\S/.test(n.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const Pb=JE(!1),LB=JE(!0);function JE(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,a=e.doc.lineAt(s),u=!n&&s==o&&NB(e,s);n&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let f=new jd(e,{simulateBreak:s,simulateDoubleBreak:!!u}),h=j0(f,s);for(h==null&&(h=yl(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;u?{from:s,to:o}=u:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let p=["",Ya(e,h)];return u&&p.push(Ya(e,f.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:lt.of(p)},range:te.cursor(s+1+p[1].length)}});return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function U0(n,e){let t=-1;return n.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let a=n.doc.lineAt(o);a.number>t&&(r.empty||r.to>a.from)&&(e(a,i,r),t=a.number),o=a.to+1}let s=n.changes(i);return{changes:i,range:te.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const DB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),r=new jd(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),i=U0(n,(s,o,a)=>{let u=j0(r,s.from);if(u==null)return;/\S/.test(s.text)||(u=0);let f=/^\s*/.exec(s.text)[0],h=Ya(n,u);(f!=h||a.from<s.from+f.length)&&(t[s.from]=u,o.push({from:s.from,to:s.from+f.length,insert:h}))});return i.changes.empty||e(n.update(i,{userEvent:"indent"})),!0},IB=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(U0(n,(t,r)=>{r.push({from:t.from,insert:n.facet(I0)})}),{userEvent:"input.indent"})),!0),jB=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(U0(n,(t,r)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let s=yl(i,n.tabSize),o=0,a=Ya(n,Math.max(0,s-Gf(n)));for(;o<i.length&&o<a.length&&i.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:t.from+o,to:t.from+i.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),BB=n=>(n.setTabFocusMode(),!0),FB=[{key:"Ctrl-b",run:OE,shift:FE,preventDefault:!0},{key:"Ctrl-f",run:PE,shift:zE},{key:"Ctrl-p",run:LE,shift:WE},{key:"Ctrl-n",run:DE,shift:$E},{key:"Ctrl-a",run:tB,shift:hB},{key:"Ctrl-e",run:nB,shift:pB},{key:"Ctrl-d",run:KE},{key:"Ctrl-h",run:Bg},{key:"Ctrl-k",run:SB},{key:"Ctrl-Alt-h",run:GE},{key:"Ctrl-o",run:EB},{key:"Ctrl-t",run:RB},{key:"Ctrl-v",run:jg}],zB=[{key:"ArrowLeft",run:OE,shift:FE,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:qj,shift:sB,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Zj,shift:fB,preventDefault:!0},{key:"ArrowRight",run:PE,shift:zE,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Kj,shift:oB,preventDefault:!0},{mac:"Cmd-ArrowRight",run:eB,shift:dB,preventDefault:!0},{key:"ArrowUp",run:LE,shift:WE,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Rb,shift:Mb},{mac:"Ctrl-ArrowUp",run:kb,shift:Cb},{key:"ArrowDown",run:DE,shift:$E,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Tb,shift:Ob},{mac:"Ctrl-ArrowDown",run:jg,shift:Eb},{key:"PageUp",run:kb,shift:Cb},{key:"PageDown",run:jg,shift:Eb},{key:"Home",run:Jj,shift:uB,preventDefault:!0},{key:"Mod-Home",run:Rb,shift:Mb},{key:"End",run:Xj,shift:cB,preventDefault:!0},{key:"Mod-End",run:Tb,shift:Ob},{key:"Enter",run:Pb,shift:Pb},{key:"Mod-a",run:mB},{key:"Backspace",run:Bg,shift:Bg,preventDefault:!0},{key:"Delete",run:KE,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:GE,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:bB,preventDefault:!0},{mac:"Mod-Backspace",run:kB,preventDefault:!0},{mac:"Mod-Delete",run:CB,preventDefault:!0}].concat(FB.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),ZE=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Gj,shift:lB},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Yj,shift:aB},{key:"Alt-ArrowUp",run:TB},{key:"Shift-Alt-ArrowUp",run:OB},{key:"Alt-ArrowDown",run:MB},{key:"Shift-Alt-ArrowDown",run:PB},{key:"Mod-Alt-ArrowUp",run:vB},{key:"Mod-Alt-ArrowDown",run:xB},{key:"Escape",run:wB},{key:"Mod-Enter",run:LB},{key:"Alt-l",mac:"Ctrl-l",run:gB},{key:"Mod-i",run:yB,preventDefault:!0},{key:"Mod-[",run:jB},{key:"Mod-]",run:IB},{key:"Mod-Alt-\\",run:DB},{key:"Shift-Mod-k",run:AB},{key:"Shift-Mod-\\",run:iB},{key:"Mod-/",run:Tj},{key:"Alt-A",run:Oj},{key:"Ctrl-m",mac:"Shift-Alt-m",run:BB}].concat(zB),Ab=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class al{constructor(e,t,r=0,i=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=s?a=>s(Ab(a)):Ab,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Pn(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=p0(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Gr(e);let i=this.normalize(t);if(i.length)for(let s=0,o=r;;s++){let a=i.charCodeAt(s),u=this.match(a,o,this.bufferPos+this.bufferStart);if(s==i.length-1){if(u)return this.value=u,this;break}o==r&&s<t.length&&t.charCodeAt(s)==a&&o++}}}match(e,t,r){let i=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],a=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?i={from:this.matches[s+1],to:r}:(this.matches[s]++,a=!0)),a||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:r}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(al.prototype[Symbol.iterator]=function(){return this});const eR={from:-1,to:-1,match:/.*/.exec("")},q0="gm"+(/x/.unicode==null?"":"u");class tR{constructor(e,t,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=eR,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new nR(e,t,r,i,s);this.re=new RegExp(t,q0+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=od(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let r=this.curLineStart+t.index,i=r+t[0].length;if(this.matchPos=od(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,t)))return this.value={from:r,to:i,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const bm=new WeakMap;class Xo{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,r){let i=bm.get(e);if(!i||i.from>=r||i.to<=t){let a=new Xo(t,e.sliceString(t,r));return bm.set(e,a),a}if(i.from==t&&i.to==r)return i;let{text:s,from:o}=i;return o>t&&(s=e.sliceString(t,o)+s,o=t),i.to<r&&(s+=e.sliceString(i.to,r)),bm.set(e,new Xo(o,s)),new Xo(t,s.slice(t-o,r-o))}}class nR{constructor(e,t,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=eR,this.matchPos=od(e,i),this.re=new RegExp(t,q0+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=Xo.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let r=this.flat.from+t.index,i=r+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,t)))return this.value={from:r,to:i,match:t},this.matchPos=od(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Xo.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(tR.prototype[Symbol.iterator]=nR.prototype[Symbol.iterator]=function(){return this});function _B(n){try{return new RegExp(n,q0),!0}catch{return!1}}function od(n,e){if(e>=n.length)return e;let t=n.lineAt(e),r;for(;e<t.to&&(r=t.text.charCodeAt(e-t.from))>=56320&&r<57344;)e++;return e}function Fg(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=dt("input",{class:"cm-textfield",name:"line",value:e}),r=dt("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:Aa.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),i())},onsubmit:s=>{s.preventDefault(),i()}},dt("label",n.state.phrase("Go to line"),": ",t)," ",dt("button",{class:"cm-button",type:"submit"},n.state.phrase("go")),dt("button",{name:"close",onclick:()=>{n.dispatch({effects:Aa.of(!1)}),n.focus()},"aria-label":n.state.phrase("close"),type:"button"},["×"]));function i(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=n,a=o.doc.lineAt(o.selection.main.head),[,u,f,h,p]=s,g=h?+h.slice(1):0,y=f?+f:a.number;if(f&&p){let C=y/100;u&&(C=C*(u=="-"?-1:1)+a.number/o.doc.lines),y=Math.round(o.doc.lines*C)}else f&&u&&(y=y*(u=="-"?-1:1)+a.number);let x=o.doc.line(Math.max(1,Math.min(o.doc.lines,y))),w=te.cursor(x.from+Math.max(0,Math.min(g,x.length)));n.dispatch({effects:[Aa.of(!1),ve.scrollIntoView(w.from,{y:"center"})],selection:w}),n.focus()}return{dom:r}}const Aa=He.define(),Nb=un.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(Aa)&&(n=t.value);return n},provide:n=>Ka.from(n,e=>e?Fg:null)}),VB=n=>{let e=qa(n,Fg);if(!e){let t=[Aa.of(!0)];n.state.field(Nb,!1)==null&&t.push(He.appendConfig.of([Nb,WB])),n.dispatch({effects:t}),e=qa(n,Fg)}return e&&e.dom.querySelector("input").select(),!0},WB=ve.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),$B={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},HB=ke.define({combine(n){return si(n,$B,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function UB(n){return[YB,GB]}const qB=De.mark({class:"cm-selectionMatch"}),KB=De.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Lb(n,e,t,r){return(t==0||n(e.sliceDoc(t-1,t))!=kt.Word)&&(r==e.doc.length||n(e.sliceDoc(r,r+1))!=kt.Word)}function QB(n,e,t,r){return n(e.sliceDoc(t,t+1))==kt.Word&&n(e.sliceDoc(r-1,r))==kt.Word}const GB=Bt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(HB),{state:t}=n,r=t.selection;if(r.ranges.length>1)return De.none;let i=r.main,s,o=null;if(i.empty){if(!e.highlightWordAroundCursor)return De.none;let u=t.wordAt(i.head);if(!u)return De.none;o=t.charCategorizer(i.head),s=t.sliceDoc(u.from,u.to)}else{let u=i.to-i.from;if(u<e.minSelectionLength||u>200)return De.none;if(e.wholeWords){if(s=t.sliceDoc(i.from,i.to),o=t.charCategorizer(i.head),!(Lb(o,t,i.from,i.to)&&QB(o,t,i.from,i.to)))return De.none}else if(s=t.sliceDoc(i.from,i.to),!s)return De.none}let a=[];for(let u of n.visibleRanges){let f=new al(t.doc,s,u.from,u.to);for(;!f.next().done;){let{from:h,to:p}=f.value;if((!o||Lb(o,t,h,p))&&(i.empty&&h<=i.from&&p>=i.to?a.push(KB.range(h,p)):(h>=i.to||p<=i.from)&&a.push(qB.range(h,p)),a.length>e.maxMatches))return De.none}}return De.set(a)}},{decorations:n=>n.decorations}),YB=ve.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),XB=({state:n,dispatch:e})=>{let{selection:t}=n,r=te.create(t.ranges.map(i=>n.wordAt(i.head)||te.cursor(i.head)),t.mainIndex);return r.eq(t)?!1:(e(n.update({selection:r})),!0)};function JB(n,e){let{main:t,ranges:r}=n.selection,i=n.wordAt(t.head),s=i&&i.from==t.from&&i.to==t.to;for(let o=!1,a=new al(n.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new al(n.doc,e,0,Math.max(0,r[r.length-1].from-1)),o=!0}else{if(o&&r.some(u=>u.from==a.value.from))continue;if(s){let u=n.wordAt(a.value.from);if(!u||u.from!=a.value.from||u.to!=a.value.to)continue}return a.value}}const ZB=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return XB({state:n,dispatch:e});let r=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=r))return!1;let i=JB(n,r);return i?(e(n.update({selection:n.selection.addRange(te.range(i.from,i.to),!1),effects:ve.scrollIntoView(i.to)})),!0):!1},xl=ke.define({combine(n){return si(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new f7(e),scrollToMatch:e=>ve.scrollIntoView(e)})}});class rR{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||_B(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,r)=>r=="n"?`
`:r=="r"?"\r":r=="t"?"	":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new r7(this):new t7(this)}getCursor(e,t=0,r){let i=e.doc?e:nt.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?Bo(this,i,t,r):jo(this,i,t,r)}}class iR{constructor(e){this.spec=e}}function jo(n,e,t,r){return new al(e.doc,n.unquoted,t,r,n.caseSensitive?void 0:i=>i.toLowerCase(),n.wholeWord?e7(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function e7(n,e){return(t,r,i,s)=>((s>t||s+i.length<r)&&(s=Math.max(0,t-2),i=n.sliceString(s,Math.min(n.length,r+2))),(e(ld(i,t-s))!=kt.Word||e(ad(i,t-s))!=kt.Word)&&(e(ad(i,r-s))!=kt.Word||e(ld(i,r-s))!=kt.Word))}class t7 extends iR{constructor(e){super(e)}nextMatch(e,t,r){let i=jo(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let s=Math.min(e.doc.length,t+this.spec.unquoted.length);i=jo(this.spec,e,0,s).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==r?null:i.value}prevMatchInRange(e,t,r){for(let i=r;;){let s=Math.max(t,i-1e4-this.spec.unquoted.length),o=jo(this.spec,e,s,i),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(s==t)return null;i-=1e4}}prevMatch(e,t,r){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=r)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let r=jo(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let s=jo(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function Bo(n,e,t,r){return new tR(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?n7(e.charCategorizer(e.selection.main.head)):void 0},t,r)}function ld(n,e){return n.slice(Qt(n,e,!1),e)}function ad(n,e){return n.slice(e,Qt(n,e))}function n7(n){return(e,t,r)=>!r[0].length||(n(ld(r.input,r.index))!=kt.Word||n(ad(r.input,r.index))!=kt.Word)&&(n(ad(r.input,r.index+r[0].length))!=kt.Word||n(ld(r.input,r.index+r[0].length))!=kt.Word)}class r7 extends iR{nextMatch(e,t,r){let i=Bo(this.spec,e,r,e.doc.length).next();return i.done&&(i=Bo(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,r){for(let i=1;;i++){let s=Math.max(t,r-i*1e4),o=Bo(this.spec,e,s,r),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==t||a.from>s+10))return a;if(s==t)return null}}prevMatch(e,t,r){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let s=+r.slice(0,i);if(s>0&&s<e.match.length)return e.match[s]+r.slice(i)}return t})}matchAll(e,t){let r=Bo(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let s=Bo(this.spec,e,Math.max(0,t-250),Math.min(r+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const ec=He.define(),K0=He.define(),fs=un.define({create(n){return new Sm(zg(n).create(),null)},update(n,e){for(let t of e.effects)t.is(ec)?n=new Sm(t.value.create(),n.panel):t.is(K0)&&(n=new Sm(n.query,t.value?Q0:null));return n},provide:n=>Ka.from(n,e=>e.panel)});class Sm{constructor(e,t){this.query=e,this.panel=t}}const i7=De.mark({class:"cm-searchMatch"}),s7=De.mark({class:"cm-searchMatch cm-searchMatch-selected"}),o7=Bt.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(fs))}update(n){let e=n.state.field(fs);(e!=n.startState.field(fs)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return De.none;let{view:t}=this,r=new Oi;for(let i=0,s=t.visibleRanges,o=s.length;i<o;i++){let{from:a,to:u}=s[i];for(;i<o-1&&u>s[i+1].from-2*250;)u=s[++i].to;n.highlight(t.state,a,u,(f,h)=>{let p=t.state.selection.ranges.some(g=>g.from==f&&g.to==h);r.add(f,h,p?s7:i7)})}return r.finish()}},{decorations:n=>n.decorations});function wc(n){return e=>{let t=e.state.field(fs,!1);return t&&t.query.spec.valid?n(e,t):lR(e)}}const cd=wc((n,{query:e})=>{let{to:t}=n.state.selection.main,r=e.nextMatch(n.state,t,t);if(!r)return!1;let i=te.single(r.from,r.to),s=n.state.facet(xl);return n.dispatch({selection:i,effects:[G0(n,r),s.scrollToMatch(i.main,n)],userEvent:"select.search"}),oR(n),!0}),ud=wc((n,{query:e})=>{let{state:t}=n,{from:r}=t.selection.main,i=e.prevMatch(t,r,r);if(!i)return!1;let s=te.single(i.from,i.to),o=n.state.facet(xl);return n.dispatch({selection:s,effects:[G0(n,i),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),oR(n),!0}),l7=wc((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:te.create(t.map(r=>te.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),a7=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:r,to:i}=t.main,s=[],o=0;for(let a=new al(n.doc,n.sliceDoc(r,i));!a.next().done;){if(s.length>1e3)return!1;a.value.from==r&&(o=s.length),s.push(te.range(a.value.from,a.value.to))}return e(n.update({selection:te.create(s,o),userEvent:"select.search.matches"})),!0},Db=wc((n,{query:e})=>{let{state:t}=n,{from:r,to:i}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,r,r);if(!s)return!1;let o=s,a=[],u,f,h=[];o.from==r&&o.to==i&&(f=t.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:f}),o=e.nextMatch(t,o.from,o.to),h.push(ve.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(r).number)+".")));let p=n.state.changes(a);return o&&(u=te.single(o.from,o.to).map(p),h.push(G0(n,o)),h.push(t.facet(xl).scrollToMatch(u.main,n))),n.dispatch({changes:p,selection:u,effects:h,userEvent:"input.replace"}),!0}),c7=wc((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(i=>{let{from:s,to:o}=i;return{from:s,to:o,insert:e.getReplacement(i)}});if(!t.length)return!1;let r=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:ve.announce.of(r),userEvent:"input.replace.all"}),!0});function Q0(n){return n.state.facet(xl).createPanel(n)}function zg(n,e){var t,r,i,s,o;let a=n.selection.main,u=a.empty||a.to>a.from+100?"":n.sliceDoc(a.from,a.to);if(e&&!u)return e;let f=n.facet(xl);return new rR({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:f.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:f.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:f.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:f.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:f.wholeWord})}function sR(n){let e=qa(n,Q0);return e&&e.dom.querySelector("[main-field]")}function oR(n){let e=sR(n);e&&e==n.root.activeElement&&e.select()}const lR=n=>{let e=n.state.field(fs,!1);if(e&&e.panel){let t=sR(n);if(t&&t!=n.root.activeElement){let r=zg(n.state,e.query.spec);r.valid&&n.dispatch({effects:ec.of(r)}),t.focus(),t.select()}}else n.dispatch({effects:[K0.of(!0),e?ec.of(zg(n.state,e.query.spec)):He.appendConfig.of(h7)]});return!0},aR=n=>{let e=n.state.field(fs,!1);if(!e||!e.panel)return!1;let t=qa(n,Q0);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:K0.of(!1)}),!0},u7=[{key:"Mod-f",run:lR,scope:"editor search-panel"},{key:"F3",run:cd,shift:ud,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:cd,shift:ud,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:aR,scope:"editor search-panel"},{key:"Mod-Shift-l",run:a7},{key:"Mod-Alt-g",run:VB},{key:"Mod-d",run:ZB,preventDefault:!0}];class f7{constructor(e){this.view=e;let t=this.query=e.state.field(fs).query.spec;this.commit=this.commit.bind(this),this.searchField=dt("input",{value:t.search,placeholder:Un(e,"Find"),"aria-label":Un(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=dt("input",{value:t.replace,placeholder:Un(e,"Replace"),"aria-label":Un(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=dt("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=dt("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=dt("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function r(i,s,o){return dt("button",{class:"cm-button",name:i,onclick:s,type:"button"},o)}this.dom=dt("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>cd(e),[Un(e,"next")]),r("prev",()=>ud(e),[Un(e,"previous")]),r("select",()=>l7(e),[Un(e,"all")]),dt("label",null,[this.caseField,Un(e,"match case")]),dt("label",null,[this.reField,Un(e,"regexp")]),dt("label",null,[this.wordField,Un(e,"by word")]),...e.state.readOnly?[]:[dt("br"),this.replaceField,r("replace",()=>Db(e),[Un(e,"replace")]),r("replaceAll",()=>c7(e),[Un(e,"replace all")])],dt("button",{name:"close",onclick:()=>aR(e),"aria-label":Un(e,"close"),type:"button"},["×"])])}commit(){let e=new rR({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ec.of(e)}))}keydown(e){LD(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ud:cd)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Db(this.view))}update(e){for(let t of e.transactions)for(let r of t.effects)r.is(ec)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(xl).top}}function Un(n,e){return n.state.phrase(e)}const lf=30,af=/[\s\.,:;?!]/;function G0(n,{from:e,to:t}){let r=n.state.doc.lineAt(e),i=n.state.doc.lineAt(t).to,s=Math.max(r.from,e-lf),o=Math.min(i,t+lf),a=n.state.sliceDoc(s,o);if(s!=r.from){for(let u=0;u<lf;u++)if(!af.test(a[u+1])&&af.test(a[u])){a=a.slice(u);break}}if(o!=i){for(let u=a.length-1;u>a.length-lf;u--)if(!af.test(a[u-1])&&af.test(a[u])){a=a.slice(0,u);break}}return ve.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${r.number}.`)}const d7=ve.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),h7=[fs,ws.low(o7),d7];class Ib{constructor(e,t,r){this.from=e,this.to=t,this.diagnostic=r}}class Us{constructor(e,t,r){this.diagnostics=e,this.panel=t,this.selected=r}static init(e,t,r){let i=r.facet(tc).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((y,x)=>y.from-x.from||y.to-x.to),o=new Oi,a=[],u=0,f=r.doc.iter(),h=0,p=r.doc.length;for(let y=0;;){let x=y==s.length?null:s[y];if(!x&&!a.length)break;let w,C;if(a.length)w=u,C=a.reduce((M,P)=>Math.min(M,P.to),x&&x.from>w?x.from:1e8);else{if(w=x.from,w>p)break;C=x.to,a.push(x),y++}for(;y<s.length;){let M=s[y];if(M.from==w&&(M.to>M.from||M.to==w))a.push(M),y++,C=Math.min(M.to,C);else{C=Math.min(M.from,C);break}}C=Math.min(C,p);let E=!1;if(a.some(M=>M.from==w&&(M.to==C||C==p))&&(E=w==C,!E&&C-w<10)){let M=w-(h+f.value.length);M>0&&(f.next(M),h=w);for(let P=w;;){if(P>=C){E=!0;break}if(!f.lineBreak&&h+f.value.length>P)break;P=h+f.value.length,h+=f.value.length,f.next()}}let T=R7(a);if(E)o.add(w,w,De.widget({widget:new S7(T),diagnostics:a.slice()}));else{let M=a.reduce((P,O)=>O.markClass?P+" "+O.markClass:P,"");o.add(w,C,De.mark({class:"cm-lintRange cm-lintRange-"+T+M,diagnostics:a.slice(),inclusiveEnd:a.some(P=>P.to>C)}))}if(u=C,u==p)break;for(let M=0;M<a.length;M++)a[M].to<=u&&a.splice(M--,1)}let g=o.finish();return new Us(g,t,cl(g))}}function cl(n,e=null,t=0){let r=null;return n.between(t,1e9,(i,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new Ib(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new Ib(r.from,s,r.diagnostic)}}),r}function p7(n,e){let t=e.pos,r=e.end||t,i=n.state.facet(tc).hideOn(n,t,r);if(i!=null)return i;let s=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(cR))||n.changes.touchesRange(s.from,Math.max(s.to,r)))}function m7(n,e){return n.field(Qn,!1)?e:e.concat(He.appendConfig.of(T7))}const cR=He.define(),Y0=He.define(),uR=He.define(),Qn=un.define({create(){return new Us(De.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),r=null,i=n.panel;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);r=cl(t,n.selected.diagnostic,s)||cl(t,null,s)}!t.size&&i&&e.state.facet(tc).autoPanel&&(i=null),n=new Us(t,i,r)}for(let t of e.effects)if(t.is(cR)){let r=e.state.facet(tc).autoPanel?t.value.length?nc.open:null:n.panel;n=Us.init(t.value,r,e.state)}else t.is(Y0)?n=new Us(n.diagnostics,t.value?nc.open:null,n.selected):t.is(uR)&&(n=new Us(n.diagnostics,n.panel,t.value));return n},provide:n=>[Ka.from(n,e=>e.panel),ve.decorations.from(n,e=>e.diagnostics)]}),g7=De.mark({class:"cm-lintRange cm-lintRange-active"});function y7(n,e,t){let{diagnostics:r}=n.state.field(Qn),i,s=-1,o=-1;r.between(e-(t<0?1:0),e+(t>0?1:0),(u,f,{spec:h})=>{if(e>=u&&e<=f&&(u==f||(e>u||t>0)&&(e<f||t<0)))return i=h.diagnostics,s=u,o=f,!1});let a=n.state.facet(tc).tooltipFilter;return i&&a&&(i=a(i,n.state)),i?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:v7(n,i)}}}:null}function v7(n,e){return dt("ul",{class:"cm-tooltip-lint"},e.map(t=>dR(n,t,!1)))}const x7=n=>{let e=n.state.field(Qn,!1);(!e||!e.panel)&&n.dispatch({effects:m7(n.state,[Y0.of(!0)])});let t=qa(n,nc.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},jb=n=>{let e=n.state.field(Qn,!1);return!e||!e.panel?!1:(n.dispatch({effects:Y0.of(!1)}),!0)},w7=n=>{let e=n.state.field(Qn,!1);if(!e)return!1;let t=n.state.selection.main,r=e.diagnostics.iter(t.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==t.from&&r.to==t.to)?!1:(n.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},b7=[{key:"Mod-Shift-m",run:x7,preventDefault:!0},{key:"F8",run:w7}],tc=ke.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...si(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Bb,tooltipFilter:Bb,needsRefresh:(e,t)=>e?t?r=>e(r)||t(r):e:t,hideOn:(e,t)=>e?t?(r,i,s)=>e(r,i,s)||t(r,i,s):e:t,autoPanel:(e,t)=>e||t})}}});function Bb(n,e){return n?e?(t,r)=>e(n(t,r),r):n:e}function fR(n){let e=[];if(n)e:for(let{name:t}of n){for(let r=0;r<t.length;r++){let i=t[r];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function dR(n,e,t){var r;let i=t?fR(e.actions):[];return dt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},dt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let a=!1,u=y=>{if(y.preventDefault(),a)return;a=!0;let x=cl(n.state.field(Qn).diagnostics,e);x&&s.apply(n,x.from,x.to)},{name:f}=s,h=i[o]?f.indexOf(i[o]):-1,p=h<0?f:[f.slice(0,h),dt("u",f.slice(h,h+1)),f.slice(h+1)],g=s.markClass?" "+s.markClass:"";return dt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:u,onmousedown:u,"aria-label":` Action: ${f}${h<0?"":` (access key "${i[o]})"`}.`},p)}),e.source&&dt("div",{class:"cm-diagnosticSource"},e.source))}class S7 extends oi{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return dt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Fb{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=dR(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class nc{constructor(e){this.view=e,this.items=[];let t=i=>{if(i.keyCode==27)jb(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=fR(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==i.keyCode){let u=cl(this.view.state.field(Qn).diagnostics,s);u&&s.actions[a].apply(e,u.from,u.to)}}else return;i.preventDefault()},r=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=dt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:r}),this.dom=dt("div",{class:"cm-panel-lint"},this.list,dt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>jb(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Qn).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Qn),r=0,i=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,u,{spec:f})=>{for(let h of f.diagnostics){if(o.has(h))continue;o.add(h);let p=-1,g;for(let y=r;y<this.items.length;y++)if(this.items[y].diagnostic==h){p=y;break}p<0?(g=new Fb(this.view,h),this.items.splice(r,0,g),i=!0):(g=this.items[p],p>r&&(this.items.splice(r,p-r),i=!0)),t&&g.diagnostic==t.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),s=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new Fb(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:u})=>{let f=u.height/this.list.offsetHeight;a.top<u.top?this.list.scrollTop-=(u.top-a.top)/f:a.bottom>u.bottom&&(this.list.scrollTop+=(a.bottom-u.bottom)/f)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)t();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Qn),r=cl(t.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:uR.of(r)})}static open(e){return new nc(e)}}function k7(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function cf(n){return k7(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const C7=ve.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:cf("#d11")},".cm-lintRange-warning":{backgroundImage:cf("orange")},".cm-lintRange-info":{backgroundImage:cf("#999")},".cm-lintRange-hint":{backgroundImage:cf("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function E7(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function R7(n){let e="hint",t=1;for(let r of n){let i=E7(r.severity);i>t&&(t=i,e=r.severity)}return e}const T7=[Qn,ve.decorations.compute([Qn],n=>{let{selected:e,panel:t}=n.field(Qn);return!e||!t||e.from==e.to?De.none:De.set([g7.range(e.from,e.to)])}),bI(y7,{hideOn:p7}),C7],M7=[NI(),II(),YD(),jj(),E6(),zD(),HD(),nt.allowMultipleSelections.of(!0),d6(),tE(O6,{fallback:!0}),j6(),R9(),B9(),uI(),hI(),nI(),UB(),Ha.of([...P9,...ZE,...u7,...Uj,...b6,...mE,...b7])],O7=vc.define([{tag:ie.keyword,color:"var(--syntax-keyword)"},{tag:ie.string,color:"var(--syntax-string)"},{tag:[ie.number,ie.bool,ie.null],color:"var(--syntax-number)"},{tag:ie.comment,color:"var(--muted-foreground)"},{tag:ie.invalid,color:"var(--destructive-foreground)"}]),P7=S.forwardRef(function({value:e,onChange:t,onRunShortcut:r,disabled:i=!1,readOnly:s=!1,placeholder:o="Enter SQL statement...",ariaLabelledBy:a,error:u},f){const h=S.useRef(null),p=S.useRef(null),g=S.useRef(r),y=S.useRef(i);return S.useEffect(()=>{g.current=r,y.current=i},[r,i]),S.useImperativeHandle(f,()=>({focus:()=>{var x;return(x=p.current)==null?void 0:x.focus()},getSelectedSql:()=>{const x=p.current;if(!x)return"";const{from:w,to:C}=x.state.selection.main;return w!==C?x.state.sliceDoc(w,C):x.state.doc.toString()}}),[]),S.useEffect(()=>{if(!h.current)return;const x=ws.highest(Ha.of([{key:"Mod-Enter",run:()=>(!y.current&&g.current&&g.current(),!0)}])),w=[M7,ve.contentAttributes.of({"aria-labelledby":a||"","aria-readonly":String(s),...s?{tabindex:"0"}:{}}),Rj(),tE(O7),Ha.of(ZE),oI(o),x,ve.theme({"&":{fontSize:"inherit",fontFamily:"var(--font-mono)",color:"var(--foreground)",backgroundColor:"var(--background)"},".cm-content":{padding:"12px",minHeight:"120px"},"&.cm-focused":{outline:"none"},".cm-gutters":{backgroundColor:"var(--background)",color:"var(--muted-foreground)",borderColor:"var(--border-subtle)"},".cm-activeLine":{backgroundColor:"var(--muted)"},".cm-activeLineGutter":{backgroundColor:"var(--muted)",color:"var(--foreground)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"var(--selection)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)"},".cm-placeholder":{color:"var(--muted-foreground)"},".cm-scroller":{overflow:"auto",fontFamily:"inherit",lineHeight:"var(--text-code--line-height)"}})];s?(w.push(nt.readOnly.of(!0)),w.push(ve.editable.of(!1))):t&&w.push(ve.updateListener.of(T=>{T.docChanged&&t(T.state.doc.toString())}));const C=nt.create({doc:e,extensions:w}),E=new ve({state:C,parent:h.current});return p.current=E,()=>{E.destroy(),p.current=null}},[s,o,t,a]),S.useEffect(()=>{var w;const x=(w=p.current)==null?void 0:w.contentDOM;x&&(x.setAttribute("aria-invalid",String(!!u)),u?x.setAttribute("aria-describedby","sql-statement-error"):x.removeAttribute("aria-describedby"))},[u,s,o,t,a]),S.useEffect(()=>{const x=p.current;if(!x)return;const w=x.state.doc.toString();w!==e&&x.dispatch({changes:{from:0,to:w.length,insert:e}})},[e]),k.jsx("div",{ref:h,className:"border border-input rounded-lg bg-background overflow-hidden text-base focus-within:border-ring focus-within:outline-1 focus-within:outline-offset-0 focus-within:outline-ring sm:text-code"})});let zb=function(n){return n.disabled="data-disabled",n.valid="data-valid",n.invalid="data-invalid",n.touched="data-touched",n.dirty="data-dirty",n.filled="data-filled",n.focused="data-focused",n}({});const A7={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},X0={valid(n){return n===null?null:n?{[zb.valid]:""}:{[zb.invalid]:""}}},N7=S.createContext({invalid:void 0,name:void 0,validityData:{state:A7,errors:[],error:"",value:"",initialValue:null},setValidityData:Nn,disabled:void 0,touched:!1,setTouched:Nn,dirty:!1,setDirty:Nn,filled:!1,setFilled:Nn,focused:!1,setFocused:Nn,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(n=tn)=>n,getInputValidationProps:(n=tn)=>n,inputRef:{current:null},commit:async()=>{}}});function fd(n=!0){const e=S.useContext(N7);if(e.setValidityData===Nn&&!n)throw new Error(gn(28));return e}const L7=S.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Nn,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function hR(){return S.useContext(L7)}const D7=S.createContext({controlId:void 0,setControlId:Nn,labelId:void 0,setLabelId:Nn,messageIds:[],setMessageIds:Nn,getDescriptionProps:n=>n});function J0(){return S.useContext(D7)}function I7(n,e){return{...n,state:{...n.state,valid:!e&&n.state.valid}}}function pR({controlled:n,default:e,name:t,state:r="value"}){const{current:i}=S.useRef(n!==void 0),[s,o]=S.useState(e),a=i?n:s,u=S.useCallback(f=>{i||o(f)},[]);return[a,u]}function j7(n={}){const{id:e,implicit:t=!1,controlRef:r}=n,{controlId:i,setControlId:s}=J0(),o=no(e);return Be(()=>{if(!(!t&&!e||s===Nn)){if(t){const a=r==null?void 0:r.current;ct(a)&&a.closest("label")!=null?s(e??null):s(i??o)}else e&&s(e);return()=>{e&&s(void 0)}}},[e,r,i,s,t,o]),i??o}function mR(n){const{enabled:e=!0,value:t,id:r,name:i,controlRef:s,commit:o}=n,{formRef:a}=hR(),{invalid:u,markedDirtyRef:f,validityData:h,setValidityData:p}=fd(),g=Ne(n.getValue);Be(()=>{if(!e)return;let y=t;y===void 0&&(y=g()),h.initialValue===null&&y!==null&&p(x=>({...x,initialValue:y}))},[e,p,t,h.initialValue,g]),Be(()=>{!e||!r||a.current.fields.set(r,{getValue:g,name:i,controlRef:s,validityData:I7(h,u),validate(){let y=t;y===void 0&&(y=g()),f.current=!0,Mr.flushSync(()=>o(y))}})},[o,s,e,a,g,r,u,f,i,h,t]),Be(()=>{const y=a.current.fields;return()=>{r&&y.delete(r)}},[a,r])}const B7=S.forwardRef(function(e,t){const{render:r,className:i,id:s,name:o,value:a,disabled:u=!1,onValueChange:f,defaultValue:h,...p}=e,{state:g,name:y,disabled:x}=fd(),w=x||u,C=y??o,E=S.useMemo(()=>({...g,disabled:w}),[g,w]),{setTouched:T,setDirty:M,validityData:P,setFocused:O,setFilled:N,validationMode:L,validation:F}=fd(),{labelId:U}=J0(),Q=j7({id:s});Be(()=>{var X;const _=a!=null;(X=F.inputRef.current)!=null&&X.value||_&&a!==""?N(!0):_&&a===""&&N(!1)},[F.inputRef,N,a]);const[q,H]=pR({controlled:a,default:h,name:"FieldControl",state:"value"}),j=a!==void 0,Y=Ne((_,X)=>{f==null||f(_,X),!X.isCanceled&&H(_)});return mR({id:Q,name:C,commit:F.commit,value:q,getValue:()=>{var _;return(_=F.inputRef.current)==null?void 0:_.value},controlRef:F.inputRef}),At("input",e,{ref:t,state:E,props:[{id:Q,disabled:w,name:C,ref:F.inputRef,"aria-labelledby":U,...j?{value:q}:{defaultValue:h},onChange(_){const X=_.currentTarget.value;Y(X,yt(cc,_.nativeEvent)),M(X!==P.initialValue),N(X!=="")},onFocus(){O(!0)},onBlur(_){T(!0),O(!1),L==="onBlur"&&F.commit(_.currentTarget.value)},onKeyDown(_){_.currentTarget.tagName==="INPUT"&&_.key==="Enter"&&(T(!0),F.commit(_.currentTarget.value))}},F.getInputValidationProps(),p],stateAttributesMapping:X0})}),F7=S.createContext({disabled:!1});function z7(){return S.useContext(F7)}const _7=S.createContext(void 0);function V7(n=!0){const e=S.useContext(_7);if(e===void 0&&!n)throw new Error(gn(3));return e}const W7=S.forwardRef(function(e,t){return k.jsx(B7,{ref:t,...e})});function $7({className:n,size:e="default",unstyled:t=!1,...r}){return k.jsx("span",{className:et(!t&&"relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:bg-disabled has-disabled:text-disabled-foreground has-focus-visible:ring-[3px] sm:text-sm dark:not-in-data-[slot=group]:bg-clip-border dark:has-aria-invalid:ring-destructive/24",n)||void 0,"data-size":e,"data-slot":"input-control",children:k.jsx(W7,{className:et("h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none placeholder:text-muted-foreground sm:h-7.5 sm:leading-7.5",e==="sm"&&"h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5",e==="lg"&&"h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5",r.type==="search"&&"[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none",r.type==="file"&&"text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm"),"data-slot":"input",size:typeof e=="number"?e:void 0,...r})})}let _b=function(n){return n.checked="data-checked",n.unchecked="data-unchecked",n.disabled="data-disabled",n.readonly="data-readonly",n.required="data-required",n.valid="data-valid",n.invalid="data-invalid",n.touched="data-touched",n.dirty="data-dirty",n.filled="data-filled",n.focused="data-focused",n}({});function gR(n){return S.useMemo(()=>({checked(e){return n.indeterminate?{}:e?{[_b.checked]:""}:{[_b.unchecked]:""}},...X0}),[n.indeterminate])}const yR=S.createContext(void 0);function H7(){const n=S.useContext(yR);if(n===void 0)throw new Error(gn(14));return n}function U7(n,e){const t=S.useRef(n),r=Ne(e);Be(()=>{t.current!==n&&r(t.current)},[n,r]),Be(()=>{t.current=n},[n])}const q7="data-parent",K7=S.forwardRef(function(e,t){const{checked:r,className:i,defaultChecked:s=!1,disabled:o=!1,id:a,indeterminate:u=!1,inputRef:f,name:h,onCheckedChange:p,parent:g=!1,readOnly:y=!1,render:x,required:w=!1,uncheckedValue:C,value:E,nativeButton:T=!1,...M}=e,{clearErrors:P}=hR(),{disabled:O,name:N,setDirty:L,setFilled:F,setFocused:U,setTouched:Q,state:q,validationMode:H,validityData:j,shouldValidateOnChange:Y,validation:W}=fd(),_=z7(),{labelId:X,controlId:D,setControlId:B,getDescriptionProps:K}=J0(),A=V7(),$=A==null?void 0:A.parent,oe=$&&A.allValues,ce=O||_.disabled||(A==null?void 0:A.disabled)||o,me=N??h,le=E??me,de=no(),ee=no();let fe=D;oe?fe=g?ee:`${$.id}-${le}`:a&&(fe=a);let ye={};oe&&(g?ye=A.parent.getParentProps():le&&(ye=A.parent.getChildProps(le)));const ne=Ne(p),{checked:he=r,indeterminate:we=u,onCheckedChange:at,...ze}=ye,pe=A==null?void 0:A.value,Re=A==null?void 0:A.setValue,Te=A==null?void 0:A.defaultValue,Le=S.useRef(null),{getButtonProps:We,buttonRef:Me}=Md({disabled:ce,native:T}),xe=(A==null?void 0:A.validation)??W,[Ve,Ue]=pR({controlled:le&&pe&&!g?pe.includes(le):he,default:le&&Te&&!g?Te.includes(le):s,name:"Checkbox",state:"checked"});Be(()=>{if(B!==Nn)return B(fe),()=>{B(void 0)}},[fe,A,B,g]),mR({enabled:!A,id:de,commit:xe.commit,value:Ve,controlRef:Le,name:me,getValue:()=>Ve});const Ce=S.useRef(null),Fe=La(f,Ce,xe.inputRef);Be(()=>{Ce.current&&(Ce.current.indeterminate=we,Ve&&F(!0))},[Ve,we,F]),U7(Ve,()=>{A&&!g||(P(me),F(Ve),L(Ve!==j.initialValue),Y()?xe.commit(Ve):xe.commit(Ve,!0))});const it=vd({checked:Ve,disabled:ce,name:g?void 0:me,id:fe??void 0,required:w,ref:Fe,style:Ed,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(Wt){if(Wt.nativeEvent.defaultPrevented)return;const vt=Wt.target.checked,kn=yt(cc,Wt.nativeEvent);if(at==null||at(vt,kn),ne(vt,kn),!kn.isCanceled&&(Ue(vt),le&&pe&&Re&&!g)){const Gn=vt?[...pe,le]:pe.filter(Yn=>Yn!==le);Re(Gn,kn)}},onFocus(){var Wt;(Wt=Le.current)==null||Wt.focus()}},E!==void 0?{value:(A?Ve&&E:E)||""}:tn,K,A?xe.getValidationProps:xe.getInputValidationProps),qe=oe?!!he:Ve,Ye=oe&&we||u;S.useEffect(()=>{$&&le&&$.disabledStatesRef.current.set(le,ce)},[$,ce,le]);const Ke=S.useMemo(()=>({...q,checked:qe,disabled:ce,readOnly:y,required:w,indeterminate:Ye}),[q,qe,ce,y,w,Ye]),tt=gR(Ke),Di=At("span",e,{state:Ke,ref:[Me,Le,t,A==null?void 0:A.registerControlRef],props:[{id:de,role:"checkbox","aria-checked":we?"mixed":Ve,"aria-readonly":y||void 0,"aria-required":w||void 0,"aria-labelledby":X,[q7]:g?"":void 0,onFocus(){U(!0)},onBlur(){const Wt=Ce.current;Wt&&(Q(!0),U(!1),H==="onBlur"&&xe.commit(A?pe:Wt.checked))},onClick(Wt){var vt;y||ce||(Wt.preventDefault(),(vt=Ce.current)==null||vt.click())}},K,xe.getValidationProps,M,ze,We],stateAttributesMapping:tt});return k.jsxs(yR.Provider,{value:Ke,children:[Di,!Ve&&!A&&me&&!g&&C!==void 0&&k.jsx("input",{type:"hidden",name:me,value:C}),k.jsx("input",{...it})]})}),Q7=S.forwardRef(function(e,t){const{render:r,className:i,keepMounted:s=!1,...o}=e,a=H7(),u=a.checked||a.indeterminate,{transitionStatus:f,setMounted:h}=wS(u),p=S.useRef(null),g=S.useMemo(()=>({...a,transitionStatus:f}),[a,f]);fc({open:u,ref:p,onComplete(){u||h(!1)}});const y=gR(a),x=S.useMemo(()=>({...y,...gl,...X0}),[y]),w=s||u,C=At("span",e,{enabled:w,ref:[t,p],state:g,stateAttributesMapping:x,props:o});return w?C:null});function G7({className:n,...e}){return k.jsx(K7,{className:et("peer flex size-4 shrink-0 items-center justify-center rounded-sm border border-input outline-none transition-shadow focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:aria-invalid:ring-destructive/40",n),"data-slot":"checkbox",...e,children:k.jsx(Q7,{className:"grid place-content-center text-current","data-slot":"checkbox-indicator",children:e.checked==="indeterminate"?k.jsx("svg",{fill:"currentcolor",height:"9",viewBox:"0 0 9 9",width:"9",children:k.jsx("path",{d:"M0.75 4.5C0.75 4.08579 1.08579 3.75 1.5 3.75H7.5C7.91421 3.75 8.25 4.08579 8.25 4.5C8.25 4.91421 7.91421 5.25 7.5 5.25H1.5C1.08579 5.25 0.75 4.91421 0.75 4.5Z"})}):k.jsx("svg",{fill:"currentcolor",height:"9",viewBox:"0 0 9 9",width:"9",children:k.jsx("path",{d:"M8.53547 0.62293C8.88226 0.849446 8.97976 1.3142 8.75325 1.66099L4.5083 8.1599C4.38833 8.34356 4.19397 8.4655 3.9764 8.49358C3.75883 8.52167 3.53987 8.45309 3.3772 8.30591L0.616113 5.80777C0.308959 5.52987 0.285246 5.05559 0.563148 4.74844C0.84105 4.44128 1.31533 4.41757 1.62249 4.69547L3.73256 6.60459L7.49741 0.840706C7.72393 0.493916 8.18868 0.396414 8.53547 0.62293Z"})})})})}function Vb(n,e){return Object.fromEntries(n.flatMap(({name:t,type:r,required:i})=>{const s=e[t];return r==="boolean"?s===void 0&&!i?[]:[[t,s===!0||s==="true"]]:s===void 0||s===""?[]:["integer","number","float"].includes(r)?[[t,Number(s)]]:r==="array"?[[t,String(s).split(",").map(o=>o.trim()).filter(Boolean)]]:[[t,s]]}))}function Y7({parameters:n,values:e,onChange:t}){return k.jsx("div",{className:"space-y-5",children:n.map(r=>k.jsx(X7,{parameter:r,value:e[r.name],onChange:i=>t({...e,[r.name]:i})},r.name))})}function X7({parameter:n,value:e,onChange:t}){const r=S.useId(),[i,s]=S.useState(""),{name:o,type:a,required:u,description:f}=n,h=a==="boolean",p=["integer","number","float"].includes(a),g=[f,a==="array"?"Separate values with commas.":""].filter(Boolean).join(" "),y=[g&&`${r}-hint`,i&&`${r}-error`].filter(Boolean).join(" ")||void 0,x=k.jsxs("span",{className:"min-w-0 text-label [overflow-wrap:anywhere]",children:[k.jsx("span",{className:"font-mono",children:o}),k.jsxs("span",{className:"ml-2 text-caption font-normal text-muted-foreground",children:[" ",u?"Required":"Optional"]})]});return k.jsxs("div",{className:"space-y-1.5",children:[h?k.jsxs("label",{htmlFor:r,className:"flex min-h-11 cursor-pointer items-center gap-3 rounded-md",children:[k.jsx(G7,{id:r,name:o,checked:e===!0||e==="true",onCheckedChange:t,"aria-describedby":y}),x]}):k.jsxs(k.Fragment,{children:[k.jsx("label",{htmlFor:r,className:"block",children:x}),k.jsx($7,{id:r,name:o,type:p?"number":"text",step:"any",inputMode:p?a==="integer"?"numeric":"decimal":void 0,required:u,value:Array.isArray(e)?e.join(", "):typeof e=="boolean"?String(e):e??"",autoComplete:"off",spellCheck:!1,"data-1p-ignore":!0,"aria-describedby":y,"aria-invalid":i?!0:void 0,className:"[&_input]:min-h-11 sm:text-base",onChange:w=>{const C=Ef(w.currentTarget,n);i&&s(C),t(w.currentTarget.value)},onBlur:w=>s(Ef(w.currentTarget,n)),onInvalid:w=>{w.preventDefault(),s(Ef(w.currentTarget,n))}})]}),g&&k.jsx("p",{id:`${r}-hint`,className:"text-caption text-muted-foreground max-w-prose text-pretty [overflow-wrap:anywhere]",children:g}),i&&k.jsx("p",{id:`${r}-error`,className:"text-caption text-destructive-foreground",role:"alert",children:i})]})}function Ef(n,{type:e,required:t}){return n.setCustomValidity(""),t&&e==="array"&&!n.value.split(",").some(r=>r.trim())&&n.setCustomValidity("Enter at least one value."),e==="integer"&&n.value!==""&&!Number.isInteger(Number(n.value))&&n.setCustomValidity("Enter a whole number."),n.validity.badInput?"Enter a number.":n.validity.valueMissing?"Enter a value.":n.validationMessage}function vR({className:n,...e}){return k.jsx(y2,{"aria-label":"Loading",className:et("animate-spin text-brand-accent motion-reduce:animate-none",n),role:"status",...e})}function J7({onShortcut:n,disabled:e=!1,loading:t=!1}){const r=S.useRef(n),i=S.useRef(e),s=S.useRef(t);S.useEffect(()=>{r.current=n,i.current=e,s.current=t},[n,e,t]),S.useEffect(()=>{const u=f=>{!f.defaultPrevented&&(f.metaKey||f.ctrlKey)&&f.key==="Enter"&&!(f.target.closest(".cm-editor, [role=dialog]")!==null)&&!i.current&&!s.current&&(f.preventDefault(),r.current())};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[]);const a=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)?"⌘":"Ctrl";return k.jsx(Dn,{type:"submit",disabled:e||t,"aria-busy":t,className:"h-9 min-h-9 w-fit pointer-coarse:h-11 pointer-coarse:min-h-11",title:`Run (${a}+Enter)`,children:k.jsxs("span",{className:"grid",children:[k.jsxs("span",{"aria-hidden":t||void 0,className:`col-start-1 row-start-1 inline-flex items-center justify-center gap-2 ${t?"invisible":""}`,children:[k.jsx(IM,{className:"size-4"}),"Run",k.jsxs("span",{className:"ml-2 text-xs opacity-80",children:[a,"+Enter"]})]}),k.jsxs("span",{"aria-hidden":!t||void 0,className:`col-start-1 row-start-1 inline-flex items-center justify-center gap-2 ${t?"":"invisible"}`,children:[k.jsx(vR,{className:"size-4"}),"Running…"]})]})})}function Io(n,e,t){let r=t.initialDeps??[],i,s=!0;function o(){var a,u,f;let h;t.key&&((a=t.debug)!=null&&a.call(t))&&(h=Date.now());const p=n();if(!(p.length!==r.length||p.some((x,w)=>r[w]!==x)))return i;r=p;let y;if(t.key&&((u=t.debug)!=null&&u.call(t))&&(y=Date.now()),i=e(...p),t.key&&((f=t.debug)!=null&&f.call(t))){const x=Math.round((Date.now()-h)*100)/100,w=Math.round((Date.now()-y)*100)/100,C=w/16,E=(T,M)=>{for(T=String(T);T.length<M;)T=" "+T;return T};console.info(`%c⏱ ${E(w,5)} /${E(x,5)} ms`,`
            font-size: .6rem;
            font-weight: bold;
            color: hsl(${Math.max(0,Math.min(120-120*C,120))}deg 100% 31%);`,t==null?void 0:t.key)}return t!=null&&t.onChange&&!(s&&t.skipInitialOnChange)&&t.onChange(i),s=!1,i}return o.updateDeps=a=>{r=a},o}function Wb(n,e){if(n===void 0)throw new Error("Unexpected undefined");return n}const Z7=(n,e)=>Math.abs(n-e)<1.01,eF=(n,e,t)=>{let r;return function(...i){n.clearTimeout(r),r=n.setTimeout(()=>e.apply(this,i),t)}},$b=n=>{const{offsetWidth:e,offsetHeight:t}=n;return{width:e,height:t}},tF=n=>n,nF=n=>{const e=Math.max(n.startIndex-n.overscan,0),t=Math.min(n.endIndex+n.overscan,n.count-1),r=[];for(let i=e;i<=t;i++)r.push(i);return r},rF=(n,e)=>{const t=n.scrollElement;if(!t)return;const r=n.targetWindow;if(!r)return;const i=o=>{const{width:a,height:u}=o;e({width:Math.round(a),height:Math.round(u)})};if(i($b(t)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=()=>{const u=o[0];if(u!=null&&u.borderBoxSize){const f=u.borderBoxSize[0];if(f){i({width:f.inlineSize,height:f.blockSize});return}}i($b(t))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(t,{box:"border-box"}),()=>{s.unobserve(t)}},Hb={passive:!0},Ub=typeof window>"u"?!0:"onscrollend"in window,iF=(n,e)=>{const t=n.scrollElement;if(!t)return;const r=n.targetWindow;if(!r)return;let i=0;const s=n.options.useScrollendEvent&&Ub?()=>{}:eF(r,()=>{e(i,!1)},n.options.isScrollingResetDelay),o=h=>()=>{const{horizontal:p,isRtl:g}=n.options;i=p?t.scrollLeft*(g&&-1||1):t.scrollTop,s(),e(i,h)},a=o(!0),u=o(!1);u(),t.addEventListener("scroll",a,Hb);const f=n.options.useScrollendEvent&&Ub;return f&&t.addEventListener("scrollend",u,Hb),()=>{t.removeEventListener("scroll",a),f&&t.removeEventListener("scrollend",u)}},sF=(n,e,t)=>{if(e!=null&&e.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[t.options.horizontal?"inlineSize":"blockSize"])}return n[t.options.horizontal?"offsetWidth":"offsetHeight"]},oF=(n,{adjustments:e=0,behavior:t},r)=>{var i,s;const o=n+e;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:o,behavior:t})};class lF{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const r=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{this._measureElement(s.target,s)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),t=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([r,i])=>{typeof i>"u"&&delete t[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:tF,rangeExtractor:nF,onChange:()=>{},measureElement:sF,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,t)},this.maybeNotify=Io(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=s,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=t[o];if(i.has(a.lane))continue;const u=s.get(a.lane);if(u==null||a.end>u.end?s.set(a.lane,a):a.end<u.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=Io(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,r,i,s,o,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:a}),{key:!1,skipInitialOnChange:!0,onChange:()=>{this.notify(this.isScrolling)}}),this.getMeasurements=Io(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:a},u)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const g of this.laneAssignments.keys())g>=t&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const f=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const h=this.measurementsCache.slice(0,f),p=new Array(a).fill(void 0);for(let g=0;g<f;g++){const y=h[g];y&&(p[y.lane]=g)}for(let g=f;g<t;g++){const y=s(g),x=this.laneAssignments.get(g);let w,C;if(x!==void 0&&this.options.lanes>1){w=x;const P=p[w],O=P!==void 0?h[P]:void 0;C=O?O.end+this.options.gap:r+i}else{const P=this.options.lanes===1?h[g-1]:this.getFurthestMeasurement(h,g);C=P?P.end+this.options.gap:r+i,w=P?P.lane:g%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(g,w)}const E=u.get(y),T=typeof E=="number"?E:this.options.estimateSize(g),M=C+T;h[g]={index:g,start:C,size:T,end:M,key:y,lane:w},p[w]=g}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Io(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,r,i,s)=>this.range=t.length>0&&r>0?aF({measurements:t,outerSize:r,scrollOffset:i,lanes:s}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Io(()=>{let t=null,r=null;const i=this.calculateRange();return i&&(t=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,r]},(t,r,i,s,o)=>s===null||o===null?[]:t({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const r=this.options.indexAttribute,i=t.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(t,r)=>{const i=this.indexFromElement(t),s=this.measurementsCache[i];if(!s)return;const o=s.key,a=this.elementsCache.get(o);a!==t&&(a&&this.observer.unobserve(a),this.observer.observe(t),this.elementsCache.set(o,t)),t.isConnected&&this.resizeItem(i,this.options.measureElement(t,r,this))},this.resizeItem=(t,r)=>{const i=this.measurementsCache[t];if(!i)return;const s=this.itemSizeCache.get(i.key)??i.size,o=r-s;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,o,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((r,i)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(i))});return}this._measureElement(t,void 0)},this.getVirtualItems=Io(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,r)=>{const i=[];for(let s=0,o=t.length;s<o;s++){const a=t[s],u=r[a];i.push(u)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const r=this.getMeasurements();if(r.length!==0)return Wb(r[xR(0,r.length-1,i=>Wb(r[i]).start,t)])},this.getOffsetForAlignment=(t,r,i=0)=>{const s=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=t>=o+s?"end":"start"),r==="center"?t+=(i-s)/2:r==="end"&&(t-=s);const a=this.getTotalSize()+this.options.scrollMargin-s;return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,r="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.measurementsCache[t];if(!i)return;const s=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(i.end>=o+s-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];const a=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,i.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:r="start",behavior:i}={})=>{i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,r),{adjustments:void 0,behavior:i})},this.scrollToIndex=(t,{align:r="auto",behavior:i}={})=>{i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1));let s=0;const o=10,a=f=>{if(!this.targetWindow)return;const h=this.getOffsetForIndex(t,f);if(!h){console.warn("Failed to get offset for index:",t);return}const[p,g]=h;this._scrollToOffset(p,{adjustments:void 0,behavior:i}),this.targetWindow.requestAnimationFrame(()=>{const y=this.getScrollOffset(),x=this.getOffsetForIndex(t,g);if(!x){console.warn("Failed to get offset for index:",t);return}Z7(x[0],y)||u(g)})},u=f=>{this.targetWindow&&(s++,s<o?this.targetWindow.requestAnimationFrame(()=>a(f)):console.warn(`Failed to scroll to index ${t} after ${o} attempts.`))};a(r)},this.scrollBy=(t,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var t;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1)i=((t=r[r.length-1])==null?void 0:t.end)??0;else{const s=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&s.some(a=>a===null);){const a=r[o];s[a.lane]===null&&(s[a.lane]=a.end),o--}i=Math.max(...s.filter(a=>a!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:r,behavior:i})=>{this.options.scrollToFn(t,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}}const xR=(n,e,t,r)=>{for(;n<=e;){const i=(n+e)/2|0,s=t(i);if(s<r)n=i+1;else if(s>r)e=i-1;else return i}return n>0?n-1:0};function aF({measurements:n,outerSize:e,scrollOffset:t,lanes:r}){const i=n.length-1,s=u=>n[u].start;if(n.length<=r)return{startIndex:0,endIndex:i};let o=xR(0,i,s,t),a=o;if(r===1)for(;a<i&&n[a].end<t+e;)a++;else if(r>1){const u=Array(r).fill(0);for(;a<i&&u.some(h=>h<t+e);){const h=n[a];u[h.lane]=h.end,a++}const f=Array(r).fill(t+e);for(;o>=0&&f.some(h=>h>=t);){const h=n[o];f[h.lane]=h.start,o--}o=Math.max(0,o-o%r),a=Math.min(i,a+(r-1-a%r))}return{startIndex:o,endIndex:a}}const qb=typeof document<"u"?S.useLayoutEffect:S.useEffect;function cF(n){const e=S.useReducer(()=>({}),{})[1],t={...n,onChange:(i,s)=>{var o;s?Mr.flushSync(e):e(),(o=n.onChange)==null||o.call(n,i,s)}},[r]=S.useState(()=>new lF(t));return r.setOptions(t),qb(()=>r._didMount(),[]),qb(()=>r._willUpdate()),r}function uF(n){return cF({observeElementRect:rF,observeElementOffset:iF,scrollToFn:oF,...n})}const Kb=36;function Qb(n){return n<1e3?`${Math.round(n)} ms`:`${(n/1e3).toFixed(2)} s`}function pa(n,e=!1){return n===null?"NULL":typeof n=="object"?JSON.stringify(n,null,e?2:void 0):String(n)}function fF(n,e){if(!e)return n;const t=n.toLowerCase(),r=[];let i=0,s=t.indexOf(e);for(;s!==-1;)s>i&&r.push(n.substring(i,s)),r.push(k.jsx("mark",{className:"bg-selection text-selection-foreground",children:n.substring(s,s+e.length)},s)),i=s+e.length,s=t.indexOf(e,i);return i<n.length&&r.push(n.substring(i)),r}function dF({result:n,error:e,onEditQuery:t,executedSql:r,executionTimeMs:i}){const s=S.useRef(null),o=S.useRef(null),a=S.useRef(null),u=S.useId(),f=S.useId(),h=S.useId(),[p,g]=S.useState(!!e),[y,x]=S.useState(Kb+1),[w,C]=S.useState(""),[E,T]=S.useState(null),[M,P]=S.useState("idle"),O=w.trim().toLowerCase(),N=S.useMemo(()=>(n==null?void 0:n.columns.map((_,X)=>{const D=n.rows.map(B=>B[X]).filter(B=>B!=null);return{name:_,numeric:D.length>0&&D.every(B=>typeof B=="number"),width:Math.min(32,Math.max(12,_.length+4,...D.slice(0,100).map(B=>pa(B).length+4)))}}))??[],[n]),L=S.useMemo(()=>(n==null?void 0:n.rows.map((_,X)=>({values:_,index:X})).filter(({values:_})=>!O||_.some(X=>pa(X).toLowerCase().includes(O))))??[],[n,O]),F=S.useCallback(_=>L[_].index,[L]),U=uF({count:L.length,getScrollElement:()=>s.current,getItemKey:F,estimateSize:()=>Kb+1,measureElement:_=>_.getBoundingClientRect().height,scrollMargin:y,overscan:10});S.useLayoutEffect(()=>{const _=o.current;if(!_)return;const X=new ResizeObserver(()=>x(_.getBoundingClientRect().height));return X.observe(_),()=>X.disconnect()},[n,e]);const Q=()=>{var _,X;C(""),(_=s.current)==null||_.scrollTo({top:0,left:0}),(X=a.current)==null||X.focus()},q=async()=>{if(E)try{await navigator.clipboard.writeText(pa(E.value,!0)),P("copied")}catch{P("error")}},H=r?k.jsxs("button",{type:"button","aria-expanded":p,"aria-controls":h,onClick:()=>g(_=>!_),className:"inline-flex min-h-9 items-center gap-1.5 rounded-sm text-caption text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring pointer-coarse:min-h-11 touch-manipulation",children:[k.jsx(cM,{"aria-hidden":"true",className:et("size-3.5",!p&&"-rotate-90")}),p?"Hide executed SQL":"View executed SQL"]}):null,j=r?k.jsx("pre",{id:h,hidden:!p,"aria-label":"Executed SQL",tabIndex:0,className:"max-h-40 overflow-auto rounded-lg border border-border bg-muted p-3 font-mono text-code whitespace-pre-wrap [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-ring",children:r}):null;if(!n&&!e)return null;if(e||!n||n.rows.length===0)return k.jsx("div",{className:"space-y-3",children:k.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card p-4 sm:p-6",children:[k.jsxs("div",{role:e?"alert":"status",className:"flex items-start gap-3",children:[e?k.jsx(gd,{className:"mt-0.5 size-5 shrink-0 text-destructive-foreground","aria-hidden":"true"}):k.jsx(g2,{className:"mt-0.5 size-5 shrink-0 text-query-complete","aria-hidden":"true"}),k.jsxs("div",{className:"min-w-0 space-y-2",children:[k.jsx("h3",{className:"text-label",children:e?"Query failed":"Query completed"}),k.jsx("p",{className:"text-sm whitespace-pre-wrap [overflow-wrap:anywhere]",children:e||(n&&n.rowCount>0?`${n.rowCount} row${n.rowCount===1?"":"s"} affected.`:"No rows returned.")}),e&&k.jsx("p",{className:"text-caption text-muted-foreground",children:"Review the statement and parameters before running it again."})]})]}),k.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 text-caption tabular-nums text-muted-foreground",children:[i!==void 0&&k.jsx("span",{children:Qb(i)}),H]}),j,e&&k.jsx(Dn,{variant:"outline",className:"min-h-9 pointer-coarse:min-h-11",onClick:t,children:"Edit query"})]})});const Y=`3.5rem ${N.map(_=>`minmax(${_.width}ch, 1fr)`).join(" ")}`,W=`calc(3.5rem + ${N.reduce((_,X)=>_+X.width,0)}ch)`;return k.jsxs(ok,{onOpenChange:()=>P("idle"),children:[k.jsxs("div",{className:"space-y-3",children:[k.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[k.jsxs("div",{className:"w-full sm:w-64",children:[k.jsx("label",{htmlFor:u,className:"sr-only",children:"Filter results"}),k.jsx("input",{ref:a,id:u,type:"search",placeholder:"Filter results…",value:w,onChange:_=>{var X;C(_.target.value),(X=s.current)==null||X.scrollTo({top:0,left:0})},className:"min-h-9 pointer-coarse:min-h-11 w-full rounded-lg border border-input bg-card px-3 text-base text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-1 focus-visible:outline-offset-0 focus-visible:outline-ring sm:text-sm"})]}),k.jsxs("div",{className:"flex flex-wrap items-center min-h-9 gap-x-4 gap-y-1 pointer-coarse:min-h-11 text-caption tabular-nums text-muted-foreground",children:[k.jsxs("span",{role:"status",children:[O?`${L.length} of ${n.rowCount}`:n.rowCount," ",n.rowCount===1?"row":"rows"]}),i!==void 0&&k.jsx("span",{className:"whitespace-nowrap",children:Qb(i)}),H]})]}),j,k.jsxs("div",{ref:s,role:"region","aria-label":"Query results",tabIndex:0,"aria-describedby":f,className:"isolate max-h-[min(28rem,60dvh)] overflow-auto rounded-lg border border-border bg-card focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[k.jsxs("table",{"aria-label":"Query result data","aria-rowcount":L.length+1,"aria-colcount":N.length+1,className:"grid w-full border-separate border-spacing-0 font-mono text-code",style:{minWidth:W},children:[k.jsx("thead",{ref:o,className:"sticky top-0 z-20 grid bg-muted",children:k.jsxs("tr",{className:"grid border-b-[length:var(--border-hairline)] border-border",style:{gridTemplateColumns:Y},children:[k.jsxs("th",{scope:"col",className:"sticky start-0 z-10 flex min-h-9 pointer-coarse:min-h-11 items-center justify-end border-e-[length:var(--border-hairline)] border-border bg-muted px-3 text-caption font-normal text-muted-foreground",children:[k.jsx("span",{"aria-hidden":"true",children:"#"}),k.jsx("span",{className:"sr-only",children:"Row"})]}),N.map((_,X)=>k.jsx("th",{scope:"col",title:_.name,className:et("flex min-h-9 pointer-coarse:min-h-11 min-w-0 items-center border-e-[length:var(--border-hairline)] border-border-subtle px-3 py-1.5 font-sans text-label last:border-e-0",_.numeric?"justify-end text-end":"text-start"),children:k.jsx("span",{className:"truncate",children:_.name})},X))]})}),k.jsx("tbody",{className:"relative grid",style:{height:U.getTotalSize()},children:U.getVirtualItems().map(_=>{const X=L[_.index];return k.jsxs("tr",{"data-index":_.index,"aria-rowindex":_.index+2,ref:U.measureElement,className:"group absolute grid w-full border-b-[length:var(--border-hairline)] border-border-subtle hover:bg-muted last:border-b-0",style:{gridTemplateColumns:Y,transform:`translateY(${_.start-y}px)`},children:[k.jsx("th",{scope:"row",className:"sticky start-0 z-10 flex min-h-9 pointer-coarse:min-h-11 items-center justify-end border-e-[length:var(--border-hairline)] border-border bg-card px-3 text-caption font-normal tabular-nums text-muted-foreground group-hover:bg-muted",children:X.index+1}),N.map((D,B)=>{const K=X.values[B],A=pa(K);return k.jsx("td",{className:"min-w-0 border-e-[length:var(--border-hairline)] border-border-subtle last:border-e-0",children:k.jsx(lk,{render:k.jsx("button",{type:"button"}),onClick:()=>T({column:D.name,row:X.index+1,value:K}),title:`View ${D.name}, row ${X.index+1}`,className:et("block min-h-9 pointer-coarse:min-h-11 w-full cursor-pointer truncate px-3 py-1.5 touch-manipulation hover:bg-accent focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",D.numeric?"text-end tabular-nums":"text-start",(K===null||K==="")&&"text-muted-foreground"),children:K===""?k.jsx("span",{className:"text-caption",children:"Empty string"}):fF(A,O)})},B)})]},_.key)})})]}),L.length===0&&k.jsxs("div",{className:"space-y-2 p-6 text-center",children:[k.jsx("p",{className:"text-label",children:"No matching rows"}),k.jsx("p",{className:"text-sm text-muted-foreground",children:"Try a different search or clear the filter."}),k.jsx(Dn,{variant:"outline",className:"min-h-9 pointer-coarse:min-h-11",onClick:Q,children:"Clear filter"})]})]}),k.jsx("p",{id:f,className:"text-caption text-muted-foreground",children:"Select a cell to view and copy its full value."})]}),k.jsxs(ak,{showCloseButton:!1,bottomStickOnMobile:!1,className:"max-w-2xl motion-reduce:transition-none",children:[k.jsxs("div",{className:"flex items-start justify-between gap-4 border-b-[length:var(--border-hairline)] border-border p-4",children:[k.jsxs("div",{className:"min-w-0 space-y-1",children:[k.jsx(ck,{className:"text-section",children:"Cell value"}),k.jsxs(uk,{className:"font-mono text-caption [overflow-wrap:anywhere]",children:["Row ",E==null?void 0:E.row," · ",E==null?void 0:E.column]})]}),k.jsx(p8,{render:k.jsx(Dn,{variant:"ghost",size:"icon-xl",className:"min-h-9 pointer-coarse:min-h-11 min-w-11","aria-label":"Close cell value"}),children:k.jsx(yd,{"aria-hidden":"true"})})]}),k.jsx("div",{tabIndex:0,role:"region","aria-label":"Full cell value",className:"max-h-[50dvh] overflow-auto p-4 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:k.jsx("pre",{className:"font-mono text-code whitespace-pre-wrap [overflow-wrap:anywhere]",children:(E==null?void 0:E.value)===""?"Empty string (0 characters)":E&&pa(E.value,!0)})}),k.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t-[length:var(--border-hairline)] border-border p-4",children:[k.jsx("span",{role:"status",className:"text-caption text-muted-foreground",children:M==="copied"?"Copied to clipboard":M==="error"?"Could not copy. Select the value and copy it manually.":""}),k.jsx(Dn,{variant:"outline",className:"min-h-9 pointer-coarse:min-h-11",onClick:q,children:"Copy value"})]})]})]})}function hF({className:n="w-4 h-4"}){return k.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}function wR(n){return n.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function pF(n){const e=wR(n.timestamp);return n.statementTotal&&n.statementTotal>1?`${e} · ${n.statementIndex} of ${n.statementTotal}`:e}function mF({tabs:n,activeTabId:e,onTabSelect:t,onTabClose:r,isLoading:i,onEditQuery:s}){const o=S.useId(),a=S.useRef(null),u=S.useRef(new Map),f=S.useRef(null),[h,p]=S.useState(!1),[g,y]=S.useState(!1),x=S.useMemo(()=>n.find(O=>O.id===e),[n,e]),w=S.useCallback(()=>{const O=a.current;O&&(p(O.scrollLeft>1),y(O.scrollLeft+O.clientWidth<O.scrollWidth-1))},[]),C=S.useCallback(O=>{var q;const N=a.current,L=(q=u.current.get(O))==null?void 0:q.parentElement;if(!N||!L)return;const F=N.getBoundingClientRect(),U=L.getBoundingClientRect(),Q=U.left<F.left?U.left-F.left:U.right>F.right?U.right-F.right:0;Q&&(N.scrollLeft+=Q)},[]);S.useLayoutEffect(()=>{var F;const O=a.current;if(!O)return;f.current&&((F=u.current.get(f.current))==null||F.focus({preventScroll:!0}),f.current=null);const N=()=>{e&&C(e),w()};N();const L=new ResizeObserver(N);return L.observe(O),()=>L.disconnect()},[e,n,C,w]);const E=O=>{var F;const N=n.findIndex(U=>U.id===O),L=n.filter(U=>U.id!==O);f.current=O===e?((F=L[Math.min(N,L.length-1)])==null?void 0:F.id)??null:e,r(O),L.length||s()},T=(O,N)=>{var U;let L;switch(O.key){case"ArrowRight":L=(N+1)%n.length;break;case"ArrowLeft":L=(N-1+n.length)%n.length;break;case"Home":L=0;break;case"End":L=n.length-1;break;case"Delete":O.preventDefault(),E(n[N].id);return;default:return}O.preventDefault();const F=n[L];(U=u.current.get(F.id))==null||U.focus({preventScroll:!0}),C(F.id),t(F.id)},M=O=>{const N=a.current;N&&N.scrollBy({left:(O==="left"?-1:1)*N.clientWidth*.75,behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"})},P=k.jsxs("div",{role:"status",className:et("flex items-center gap-3 rounded-xl border border-border bg-card",n.length?"p-4":"min-h-32 p-6"),children:[k.jsx(vR,{"aria-hidden":"true",role:"presentation",className:"mt-0.5 size-4 shrink-0 text-brand-accent"}),k.jsxs("div",{className:"space-y-1",children:[k.jsx("p",{className:"text-label",children:"Running query…"}),k.jsx("p",{className:"text-caption text-muted-foreground",children:n.length?"Previous results remain available below.":"Waiting for the database to respond."})]})]});return n.length===0?i?P:k.jsxs("div",{className:"flex min-h-32 flex-col justify-center gap-2 rounded-xl border border-border bg-card p-6",children:[k.jsx(BM,{"aria-hidden":"true",className:"mb-1 size-5 text-brand-accent"}),k.jsx("h2",{className:"text-label",children:"Results appear here"}),k.jsx("p",{className:"max-w-prose text-sm text-muted-foreground",children:"Enter a SQL statement or fill in the tool parameters, then select Run."})]}):k.jsxs("div",{className:"space-y-3",children:[i&&P,k.jsxs("div",{className:"flex min-w-0 items-start border-b-[length:var(--border-hairline)] border-border",children:[(h||g)&&k.jsx("button",{type:"button",onClick:()=>M("left"),disabled:!h,className:"hidden min-h-9 min-w-9 pointer-coarse:min-h-11 pointer-coarse:min-w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:text-disabled-foreground disabled:cursor-default sm:flex touch-manipulation","aria-label":"Scroll result tabs left","aria-controls":`${o}-list`,children:k.jsx(fM,{className:"size-4","aria-hidden":"true"})}),k.jsx("div",{ref:a,id:`${o}-list`,role:"tablist","aria-label":"Query results",onScroll:w,className:"flex min-w-0 flex-1 items-stretch overflow-x-auto overscroll-x-contain [scrollbar-width:thin]",children:n.map((O,N)=>{const L=O.id===e,F=`Result at ${wR(O.timestamp)}${O.statementTotal&&O.statementTotal>1?`, statement ${O.statementIndex} of ${O.statementTotal}`:""}${O.error?", failed":""}`;return k.jsxs("div",{role:"presentation",className:et("flex shrink-0 items-stretch border-b-2",L?"border-primary bg-selection/50":"border-transparent"),children:[k.jsxs("button",{type:"button",role:"tab",id:`${o}-tab-${O.id}`,"aria-controls":`${o}-panel-${O.id}`,"aria-selected":L,"aria-label":F,title:F,tabIndex:L?0:-1,ref:U=>{U?u.current.set(O.id,U):u.current.delete(O.id)},onClick:()=>t(O.id),onKeyDown:U=>T(U,N),onFocus:()=>C(O.id),className:et("flex min-h-9 min-w-9 pointer-coarse:min-h-11 pointer-coarse:min-w-11 items-center gap-2 whitespace-nowrap px-3 text-caption tabular-nums touch-manipulation hover:bg-accent focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",L?"text-foreground":"text-muted-foreground"),children:[k.jsx("span",{children:pF(O)}),O.error&&k.jsxs("span",{className:"flex items-center gap-1 text-destructive-foreground",children:[k.jsx(gd,{className:"size-3.5","aria-hidden":"true"}),"Failed"]})]}),k.jsx("button",{type:"button",tabIndex:L?0:-1,onClick:()=>E(O.id),"aria-label":`Close ${F.toLowerCase()}`,title:"Close result (Delete when tab is focused)",className:"flex min-h-9 min-w-9 pointer-coarse:min-h-11 pointer-coarse:min-w-11 items-center justify-center text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring touch-manipulation",children:k.jsx(hF,{className:"size-3.5","aria-hidden":"true"})})]},O.id)})}),(h||g)&&k.jsx("button",{type:"button",onClick:()=>M("right"),disabled:!g,className:"hidden min-h-9 min-w-9 pointer-coarse:min-h-11 pointer-coarse:min-w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:text-disabled-foreground disabled:cursor-default sm:flex touch-manipulation","aria-label":"Scroll result tabs right","aria-controls":`${o}-list`,children:k.jsx(hM,{className:"size-4","aria-hidden":"true"})})]}),n.map(O=>k.jsx("div",{role:"tabpanel",id:`${o}-panel-${O.id}`,"aria-labelledby":`${o}-tab-${O.id}`,hidden:O.id!==e,tabIndex:0,className:"min-w-0 rounded-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:O.id===e&&x&&k.jsx(dF,{result:x.result,error:x.error,onEditQuery:s,executedSql:x.executedSql,executionTimeMs:x.executionTimeMs})},O.id))]})}function gF({className:n="w-4 h-4"}){return k.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function Gb({className:n="w-4 h-4"}){return k.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function yF(){const{sourceId:n,toolName:e}=pd(),[t,r]=GT(),[i,s]=S.useState(null),[o,a]=S.useState(!0),[u,f]=S.useState(0),[h,p]=S.useState(null),g=S.useRef(null),[y,x]=S.useState(()=>t.get("sql")||""),[w,C]=S.useState({}),[E,T]=S.useState([]),[M,P]=S.useState(null),[O,N]=S.useState(!1),[L,F]=S.useState(!1),[U,Q]=S.useState(!1),[q,H]=S.useState(""),[j,Y]=S.useState(""),W=S.useRef(null),_=S.useRef(!1),X=S.useRef(0),D=S.useRef(null),B=S.useRef(null);S.useEffect(()=>{if(!L)return;const ee=setTimeout(()=>F(!1),2500);return()=>clearTimeout(ee)},[L]),S.useEffect(()=>{if(!U)return;const ee=setTimeout(()=>Q(!1),2e3);return()=>clearTimeout(ee)},[U]),S.useEffect(()=>{if(!n||!e)return;let ee=!0;return X.current++,_.current=!1,N(!1),F(!1),a(!0),p(null),T([]),P(null),sk(n).then(fe=>{if(!ee)return;const ye=fe.tools.find(ne=>ne.name===e);s(ye||null),a(!1)}).catch(fe=>{ee&&(p(fe),a(!1))}),()=>{ee=!1,X.current++}},[n,e,u]);const A=S.useCallback(()=>i?i.name.startsWith("execute_sql")?"execute_sql":i.name.startsWith("search_objects")?"search_objects":"custom":"custom",[i])();S.useEffect(()=>{if(!i||o)return;const ee=t.toString();B.current===i&&D.current===ee||(B.current=i,D.current=ee,C(Object.fromEntries(i.parameters.flatMap(fe=>{const ye=t.get(fe.name);return ye===null?[]:[[fe.name,ye]]}))),x(t.get("sql")||""),Y(""),H(""),Q(!1))},[i,o,t]),S.useEffect(()=>{if(A!=="execute_sql"||o)return;const ee=setTimeout(()=>{r(fe=>{const ye=new URLSearchParams(fe);return y.trim()?ye.set("sql",y):ye.delete("sql"),D.current=ye.toString(),ye},{replace:!0})},300);return()=>clearTimeout(ee)},[y,A,o,r]),S.useEffect(()=>{if(A!=="custom"||o)return;const ee=setTimeout(()=>{r(fe=>{const ye=new URLSearchParams(fe);return Array.from(ye.keys()).forEach(ne=>{ne!=="sql"&&ye.delete(ne)}),Object.entries(w).forEach(([ne,he])=>{he!=null&&he!==""&&ye.set(ne,String(he))}),D.current=ye.toString(),ye},{replace:!0})},300);return()=>clearTimeout(ee)},[w,A,o,r]);const $=S.useCallback(()=>{if(!(i!=null&&i.statement))return"";let ee=i.statement,fe=0;return ee=ee.replace(/\$(\d+)|\?/g,(ye,ne)=>{let he;return ne?he=i.parameters[parseInt(ne,10)-1]:(he=i.parameters[fe],fe++),he?`:${he.name}`:":?"}),ee},[i]),oe=S.useCallback(()=>{let ee=$();return Object.entries(Vb((i==null?void 0:i.parameters)??[],w)).forEach(([fe,ye])=>{if(ye!==void 0&&ye!==""){const ne=typeof ye=="string"?`'${ye.replace(/'/g,"''")}'`:String(ye);ee=ee.replace(new RegExp(`:${fe}\\b`,"g"),ne)}}),ee},[$,w,i]),ce=S.useCallback(async()=>{var ne,he,we,at,ze,pe,Re;if(!i||!e||_.current)return;for(const Te of i.parameters){const Le=(ne=W.current)==null?void 0:ne.elements.namedItem(Te.name);Le instanceof HTMLInputElement&&Te.type!=="boolean"&&Ef(Le,Te)}if(!((he=W.current)!=null&&he.checkValidity())){(at=(we=W.current)==null?void 0:we.querySelector(":invalid"))==null||at.focus();return}if(A==="execute_sql"&&!y.trim()){Y("Enter a SQL statement to run."),(ze=g.current)==null||ze.focus();return}_.current=!0,N(!0),F(!1);const ee=performance.now(),fe=X.current,ye=A==="execute_sql"?((pe=g.current)==null?void 0:pe.getSelectedSql())??y:oe();try{let Te;if(A==="execute_sql"?Te=await V1(e,{sql:ye}):Te=await V1(e,Vb(i.parameters,w)),fe!==X.current)return;const We=performance.now()-ee,Me=new Date,xe=Te.length>1,Ve=Te.map((Ue,Ce)=>({id:Am(),timestamp:new Date(Me.getTime()+Ce),result:Ue,error:null,executedSql:Ue.sql??ye,executionTimeMs:Ce===0?We:void 0,statementIndex:xe?Ce+1:void 0,statementTotal:xe?Te.length:void 0}));T(Ue=>[...Ve,...Ue]),P(((Re=Ve[0])==null?void 0:Re.id)??null),F(!0)}catch(Te){if(fe!==X.current)return;const Le={id:Am(),timestamp:new Date,result:null,error:Te instanceof Error?Te.message:"Query failed",executedSql:ye,executionTimeMs:performance.now()-ee};T(We=>[Le,...We]),P(Le.id)}finally{fe===X.current&&(_.current=!1,N(!1))}},[i,e,A,y,w,oe]),me=S.useCallback(async()=>{const ee=A==="execute_sql"?y:oe();try{await navigator.clipboard.writeText(ee),H(""),Q(!0)}catch{H("Could not copy SQL. Select the statement and copy it manually.")}},[A,y,oe]),le=S.useCallback(ee=>{x(ee),ee.trim()&&Y("")},[]),de=S.useCallback(ee=>{T(fe=>{const ye=fe.findIndex(he=>he.id===ee),ne=fe.filter(he=>he.id!==ee);if(ee===M&&ne.length>0){const he=Math.min(ye,ne.length-1);P(ne[he].id)}else ne.length===0&&P(null);return ne})},[M]);return!n||!e?k.jsx(wa,{to:"/",replace:!0}):o?k.jsx(d0,{label:"Loading tool details…"}):h?h.status===404?k.jsx(wa,{to:"/404",replace:!0}):k.jsx(h0,{title:"Could not load this tool",message:h.message,onRetry:()=>f(ee=>ee+1)}):i?A==="search_objects"?k.jsx("div",{className:"container mx-auto px-4 py-6 sm:px-8 sm:py-10 max-w-4xl",children:k.jsxs("div",{className:"space-y-4",children:[k.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-2",children:[k.jsx("h1",{className:"min-w-0 text-page text-foreground [overflow-wrap:anywhere]",children:i.name}),k.jsx(Yb,{readonly:i.readonly})]}),k.jsx("p",{className:"text-body text-muted-foreground max-w-prose text-pretty [overflow-wrap:anywhere]",children:i.description}),k.jsx("div",{className:"border border-border rounded-lg bg-card p-8 text-center",children:k.jsx("p",{className:"text-muted-foreground",children:"Interactive UI for this tool is coming soon."})})]})}):k.jsx("div",{className:"container mx-auto px-4 py-6 sm:px-8 sm:py-10 max-w-4xl",children:k.jsxs("div",{className:"space-y-6",children:[k.jsxs("div",{className:"space-y-2",children:[k.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-2",children:[k.jsx("h1",{className:"min-w-0 text-page text-foreground [overflow-wrap:anywhere]",children:i.name}),k.jsx(Yb,{readonly:i.readonly})]}),k.jsx("p",{className:"text-body text-muted-foreground max-w-prose text-pretty [overflow-wrap:anywhere]",children:i.description})]}),k.jsxs("form",{ref:W,noValidate:!0,onSubmit:ee=>{ee.preventDefault(),ce()},className:"space-y-4",children:[A==="custom"&&i.parameters.length>0&&k.jsxs("div",{className:"space-y-2",children:[k.jsx("h2",{className:"text-label text-foreground",children:"Parameters"}),k.jsx("div",{className:"rounded-xl border border-border bg-card p-4 sm:p-6",children:k.jsx(Y7,{parameters:i.parameters,values:w,onChange:C},`${n}/${e}`)})]}),k.jsxs("div",{className:"space-y-2",children:[k.jsxs("div",{className:"flex items-center justify-between",children:[k.jsx("h2",{id:"sql-statement-label",className:"text-label text-foreground",children:"SQL statement"}),k.jsx(Dn,{type:"button",variant:"ghost",onClick:me,className:"min-h-9 min-w-20 pointer-coarse:min-h-11 text-muted-foreground","aria-label":U?"SQL copied":"Copy SQL",title:"Copy SQL",children:U?k.jsxs(k.Fragment,{children:[k.jsx(Gb,{className:"w-3.5 h-3.5"}),"Copied"]}):k.jsxs(k.Fragment,{children:[k.jsx(gF,{className:"w-3.5 h-3.5"}),"Copy"]})})]}),k.jsx(P7,{ref:g,value:A==="execute_sql"?y:oe(),onChange:A==="execute_sql"?le:void 0,onRunShortcut:ce,disabled:O,ariaLabelledBy:"sql-statement-label",error:j,readOnly:A!=="execute_sql",placeholder:A==="execute_sql"?"SELECT * FROM table_name LIMIT 10;":void 0}),j&&k.jsx("p",{id:"sql-statement-error",role:"alert",className:"text-caption text-destructive-foreground",children:j}),q&&k.jsx("p",{role:"alert",className:"text-caption text-destructive-foreground",children:q}),k.jsx("span",{role:"status",className:"sr-only",children:U?"SQL copied to clipboard.":""})]}),k.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[k.jsx(J7,{onShortcut:ce,loading:O}),k.jsx("span",{role:"status",className:"flex items-center gap-1.5 text-caption text-muted-foreground",children:L&&k.jsxs(k.Fragment,{children:[k.jsx("span",{"aria-hidden":"true",className:"text-query-complete",children:k.jsx(Gb,{})}),"Query completed"]})})]})]}),k.jsx(mF,{tabs:E,activeTabId:M,onTabSelect:P,onTabClose:de,isLoading:O,onEditQuery:()=>{var fe,ye;const ee=(fe=W.current)==null?void 0:fe.querySelector('input:not([type="checkbox"]), [role="checkbox"]');ee?ee.focus():(ye=g.current)==null||ye.focus()}})]})}):k.jsx(wa,{to:"/404",replace:!0})}function Yb({readonly:n}){const e=n===!0,t=e?v2:LM;return k.jsxs("span",{title:e?"This tool is restricted to read-only operations.":"This tool allows write operations, subject to database permissions.",className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap ${e?"bg-muted text-muted-foreground":"bg-warning/10 text-warning-foreground"}`,children:[k.jsx(t,{className:"size-3 shrink-0","aria-hidden":"true"}),e?"Read-only":"Write access"]})}function vF(){return k.jsx("div",{className:"container mx-auto px-4 py-6 sm:px-8 sm:py-10 max-w-4xl",children:k.jsxs("div",{className:"space-y-6",children:[k.jsxs("div",{children:[k.jsx("h1",{className:"text-page text-foreground mb-4",children:"404 - Page Not Found"}),k.jsx("p",{className:"text-body text-muted-foreground max-w-prose text-pretty",children:"The page you're looking for doesn't exist."})]}),k.jsxs("div",{className:"bg-muted rounded-lg p-6",children:[k.jsx("p",{className:"text-muted-foreground mb-4",children:"The URL you entered could not be found. This might be because:"}),k.jsxs("ul",{className:"space-y-2 text-muted-foreground list-disc list-inside",children:[k.jsx("li",{children:"The page was moved or deleted"}),k.jsx("li",{children:"You typed the URL incorrectly"}),k.jsx("li",{children:"The resource ID is invalid"})]})]}),k.jsx("div",{children:k.jsx(ti,{to:"/",className:"inline-flex items-center px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"Go to Data Sources"})})]})})}let Xb=0;function bR(n){return Xb+=1,`${n}-${Math.random().toString(36).slice(2,6)}-${Xb}`}const Z0=S.createContext(void 0);function SR(){const n=S.useContext(Z0);if(!n)throw new Error(gn(73));return n}function km(n,e){if(typeof n=="string")return{description:n};if(typeof n=="function"){const t=n(e);return typeof t=="string"?{description:t}:t}return n}const xF=function(e){const{children:t,timeout:r=5e3,limit:i=3,toastManager:s}=e,[o,a]=S.useState([]),[u,f]=S.useState(!1),[h,p]=S.useState(!1),[g,y]=S.useState(null);o.length===0&&(u&&f(!1),h&&p(!1));const x=u||h,w=S.useRef(new Map),C=S.useRef(null),E=S.useRef(!0),T=S.useRef(!1);function M(j){var D,B;const Y=ir(or(C.current));if(!C.current||!Xe(C.current,Y)||!Tf(Y))return;const W=o.findIndex(K=>K.id===j);let _=null,X=W+1;for(;X<o.length;){if(o[X].transitionStatus!=="ending"){_=o[X];break}X+=1}if(!_)for(X=W-1;X>=0;){if(o[X].transitionStatus!=="ending"){_=o[X];break}X-=1}_?(B=(D=_.ref)==null?void 0:D.current)==null||B.focus():g==null||g.focus({preventScroll:!0})}const P=Ne(()=>{T.current||(T.current=!0,w.current.forEach(j=>{if(j.timeout){j.timeout.clear();const Y=Date.now()-j.start,W=j.delay-Y;j.remaining=W>0?W:0}}))}),O=Ne(()=>{T.current&&(T.current=!1,w.current.forEach((j,Y)=>{j.remaining=j.remaining>0?j.remaining:j.delay,j.timeout??(j.timeout=ni.create()),j.timeout.start(j.remaining,()=>{w.current.delete(Y),j.callback()}),j.start=Date.now()}))}),N=Ne(j=>{var _;a(X=>{const D=X.map(K=>K.id===j?{...K,transitionStatus:"ending",height:0}:K),B=D.filter(K=>K.transitionStatus!=="ending");return D.map(K=>{if(K.transitionStatus==="ending")return K;const A=B.indexOf(K)>=i;return{...K,limited:A}})});const Y=w.current.get(j);Y&&Y.timeout&&(Y.timeout.clear(),w.current.delete(j));const W=o.find(X=>X.id===j);(_=W==null?void 0:W.onClose)==null||_.call(W),M(j),o.length===1&&(f(!1),p(!1))}),L=Ne(j=>{var W;a(_=>_.filter(X=>X.id!==j));const Y=o.find(_=>_.id===j);(W=Y==null?void 0:Y.onRemove)==null||W.call(Y)}),F=Ne((j,Y,W)=>{const _=Date.now(),X=E.current&&!u&&!h,D=X?ni.create():void 0;D==null||D.start(Y,()=>{w.current.delete(j),W()}),w.current.set(j,{timeout:D,start:X?_:0,delay:Y,remaining:Y,callback:W})}),U=Ne(j=>{const Y=j.id||bR("toast"),W={...j,id:Y,transitionStatus:"starting"};a(X=>{const D=[W,...X],B=D.filter(K=>K.transitionStatus!=="ending");if(B.length>i){const K=B.length-i,A=B.slice(-K);return D.map($=>A.some(oe=>oe.id===$.id)?{...$,limited:!0}:{...$,limited:!1})}return D.map(K=>({...K,limited:!1}))});const _=W.timeout??r;return W.type!=="loading"&&_>0&&F(Y,_,()=>N(Y)),(u||h||!E.current)&&P(),Y}),Q=Ne((j,Y)=>{a(W=>W.map(_=>_.id===j?{..._,...Y}:_))}),q=Ne((j,Y)=>{const W=km(Y.loading),_=U({...W,type:"loading"}),X=j.then(D=>{const B=km(Y.success,D);Q(_,{...B,type:"success"});const K=B.timeout??r;return K>0&&F(_,K,()=>N(_)),(u||h||!E.current)&&P(),D}).catch(D=>{const B=km(Y.error,D);Q(_,{...B,type:"error"});const K=B.timeout??r;return K>0&&F(_,K,()=>N(_)),(u||h||!E.current)&&P(),Promise.reject(D)});return{}.hasOwnProperty.call(Y,"setPromise")&&Y.setPromise(X),X});S.useEffect(function(){return s?s[" subscribe"](({action:W,options:_})=>{const X=_.id;W==="promise"&&_.promise?q(_.promise,_):W==="update"&&X?Q(X,_):W==="close"&&X?N(X):U(_)}):void 0},[U,Q,F,r,s,q,N]);const H=S.useMemo(()=>({toasts:o,setToasts:a,hovering:u,setHovering:f,focused:h,setFocused:p,expanded:x,add:U,close:N,remove:L,update:Q,promise:q,pauseTimers:P,resumeTimers:O,prevFocusElement:g,setPrevFocusElement:y,viewportRef:C,scheduleTimer:F,windowFocusedRef:E}),[U,N,h,u,x,P,g,q,L,O,F,o,Q]);return k.jsx(Z0.Provider,{value:H,children:t})},wF=S.createContext(void 0);let bF=function(n){return n.frontmostHeight="--toast-frontmost-height",n}({});const SF=S.forwardRef(function(e,t){var D;const{render:r,className:i,children:s,...o}=e,{toasts:a,pauseTimers:u,resumeTimers:f,setHovering:h,setFocused:p,viewportRef:g,windowFocusedRef:y,prevFocusElement:x,setPrevFocusElement:w,expanded:C,focused:E}=SR(),T=S.useRef(!1),M=S.useRef(!1),P=a.length,O=((D=a[0])==null?void 0:D.height)??0,N=S.useMemo(()=>a.some(B=>B.transitionStatus==="ending"),[a]);S.useEffect(()=>{if(!g.current)return;function B(A){var $;P!==0&&A.key==="F6"&&A.target!==g.current&&(A.preventDefault(),w(ir(or(g.current))),($=g.current)==null||$.focus({preventScroll:!0}),u(),p(!0))}const K=Pt(g.current);return K.addEventListener("keydown",B),()=>{K.removeEventListener("keydown",B)}},[u,p,w,P,g]),S.useEffect(()=>{if(!g.current||!P)return;const B=Pt(g.current);function K($){$.target===B&&(y.current=!1,u())}function A($){if($.relatedTarget||$.target===B)return;const oe=en($),ce=ir(or(g.current));(!Xe(g.current,oe)||!Tf(ce))&&f(),setTimeout(()=>{y.current=!0})}return B.addEventListener("blur",K,!0),B.addEventListener("focus",A,!0),()=>{B.removeEventListener("blur",K,!0),B.removeEventListener("focus",A,!0)}},[u,f,g,y,p,P]),S.useEffect(()=>{const B=g.current;if(!B||P===0)return;const K=or(B);function A($){if($.pointerType!=="touch")return;const oe=en($);Xe(B,oe)||(f(),h(!1),p(!1))}return K.addEventListener("pointerdown",A,!0),()=>{K.removeEventListener("pointerdown",A,!0)}},[P,f,p,h,g]);function L(B){var K,A,$;g.current&&(T.current=!0,B.relatedTarget===g.current?($=(A=(K=a[0])==null?void 0:K.ref)==null?void 0:A.current)==null||$.focus():x==null||x.focus({preventScroll:!0}))}function F(B){B.key==="Tab"&&B.shiftKey&&B.target===g.current&&(B.preventDefault(),x==null||x.focus({preventScroll:!0}),f())}S.useEffect(()=>{!y.current||N||!M.current||(f(),h(!1),M.current=!1)},[N,f,h,y]);function U(){u(),h(!0),M.current=!1}function Q(){a.some(B=>B.transitionStatus==="ending")?M.current=!0:(f(),h(!1))}function q(){if(T.current){T.current=!1;return}E||Tf(or(g.current).activeElement)&&(p(!0),u())}function H(B){!E||Xe(g.current,B.relatedTarget)||(p(!1),f())}const j={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:U,onMouseMove:U,onMouseLeave:Q,onFocus:q,onBlur:H,onKeyDown:F,onClick:q},Y=S.useMemo(()=>({expanded:C}),[C]),W=At("div",e,{ref:[t,g],state:Y,props:[j,{style:{[bF.frontmostHeight]:O?`${O}px`:void 0}},o,{children:k.jsxs(S.Fragment,{children:[P>0&&x&&k.jsx(Xs,{onFocus:L}),s,P>0&&x&&k.jsx(Xs,{onFocus:L})]})}]}),_=S.useMemo(()=>({viewportRef:g}),[g]),X=S.useMemo(()=>a.filter(B=>B.priority==="high"),[a]);return k.jsxs(wF.Provider,{value:_,children:[P>0&&x&&k.jsx(Xs,{onFocus:L}),W,!E&&X.length>0&&k.jsx("div",{style:Ed,children:X.map(B=>k.jsxs("div",{role:"alert","aria-atomic":!0,children:[k.jsx("div",{children:B.title}),k.jsx("div",{children:B.description})]},B.id))})]})}),kR=S.createContext(void 0);function ul(){const n=S.useContext(kR);if(!n)throw new Error(gn(66));return n}let zs=function(n){return n.index="--toast-index",n.offsetY="--toast-offset-y",n.height="--toast-height",n.swipeMovementX="--toast-swipe-movement-x",n.swipeMovementY="--toast-swipe-movement-y",n}({});const kF={...gl,swipeDirection(n){return n?{"data-swipe-direction":n}:null}},ma=40,CF=10,ns=.5,EF=1;function Jb(n,e,t){switch(n){case"up":return-t;case"down":return t;case"left":return-e;case"right":return e;default:return 0}}function RF(n){const t=window.getComputedStyle(n).transform;let r=0,i=0,s=1;if(t&&t!=="none"){const o=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(o){const a=o[1].split(", ").map(parseFloat);a.length===6?(r=a[4],i=a[5],s=Math.sqrt(a[0]*a[0]+a[1]*a[1])):a.length===16&&(r=a[12],i=a[13],s=a[0])}}return{x:r,y:i,scale:s}}const TF=S.forwardRef(function(e,t){var Ue;const{toast:r,render:i,className:s,swipeDirection:o=["down","right"],...a}=e,u=((Ue=r.positionerProps)==null?void 0:Ue.anchor)!==void 0;let f=[];u||(f=Array.isArray(o)?o:[o]);const h=f.length>0,{toasts:p,focused:g,close:y,remove:x,setToasts:w,pauseTimers:C,expanded:E,setHovering:T}=SR(),[M,P]=S.useState(void 0),[O,N]=S.useState(!1),[L,F]=S.useState(!1),[U,Q]=S.useState(!1),[q,H]=S.useState({x:0,y:0}),[j,Y]=S.useState({x:0,y:0,scale:1}),[W,_]=S.useState(),[X,D]=S.useState(),[B,K]=S.useState(null),A=S.useRef(null),$=S.useRef({x:0,y:0}),oe=S.useRef({x:0,y:0,scale:1}),ce=S.useRef(void 0),me=S.useRef(0),le=S.useRef(!1),de=S.useRef({x:0,y:0}),ee=S.useRef(!1),fe=S.useMemo(()=>p.indexOf(r),[r,p]),ye=S.useMemo(()=>p.filter(Ce=>Ce.transitionStatus!=="ending").indexOf(r),[r,p]),ne=S.useMemo(()=>p.slice(0,p.indexOf(r)).reduce((Ce,Fe)=>Ce+(Fe.height||0),0),[p,r]);fc({open:r.transitionStatus!=="ending",ref:A,onComplete(){r.transitionStatus==="ending"&&x(r.id)}});const he=Ne((Ce=!1)=>{const Fe=A.current;if(!Fe)return;const it=Fe.style.height;Fe.style.height="auto";const qe=Fe.offsetHeight;Fe.style.height=it;function Ye(){w(Ke=>Ke.map(tt=>tt.id===r.id?{...tt,ref:A,height:qe,transitionStatus:void 0}:tt))}Ce?Mr.flushSync(Ye):Ye()});Be(he,[he]);function we(Ce,Fe){let it=Ce,qe=Fe;return!f.includes("left")&&!f.includes("right")?it=Ce>0?Ce**ns:-(Math.abs(Ce)**ns):(!f.includes("right")&&Ce>0&&(it=Ce**ns),!f.includes("left")&&Ce<0&&(it=-(Math.abs(Ce)**ns))),!f.includes("up")&&!f.includes("down")?qe=Fe>0?Fe**ns:-(Math.abs(Fe)**ns):(!f.includes("down")&&Fe>0&&(qe=Fe**ns),!f.includes("up")&&Fe<0&&(qe=-(Math.abs(Fe)**ns))),{x:it,y:qe}}function at(Ce){var qe;if(Ce.button!==0)return;Ce.pointerType==="touch"&&C();const Fe=en(Ce.nativeEvent);if(!(Fe&&Fe.closest('button,a,input,textarea,[role="button"],[data-swipe-ignore]'))){if(le.current=!1,ce.current=void 0,me.current=0,$.current={x:Ce.clientX,y:Ce.clientY},de.current=$.current,A.current){const Ye=RF(A.current);oe.current=Ye,Y(Ye),H({x:Ye.x,y:Ye.y})}T(!0),N(!0),F(!1),K(null),ee.current=!0,(qe=A.current)==null||qe.setPointerCapture(Ce.pointerId)}}function ze(Ce){if(!O)return;Ce.preventDefault(),ee.current&&($.current={x:Ce.clientX,y:Ce.clientY},ee.current=!1);const{clientY:Fe,clientX:it,movementX:qe,movementY:Ye}=Ce;(Ye<0&&Fe>de.current.y||Ye>0&&Fe<de.current.y)&&(de.current={x:de.current.x,y:Fe}),(qe<0&&it>de.current.x||qe>0&&it<de.current.x)&&(de.current={x:it,y:de.current.y});const Ke=it-$.current.x,tt=Fe-$.current.y,Di=Fe-de.current.y,Wt=it-de.current.x;if(!L&&Math.sqrt(Ke*Ke+tt*tt)>=EF&&(F(!0),B===null)){const st=f.includes("left")||f.includes("right"),Et=f.includes("up")||f.includes("down");if(st&&Et){const $t=Math.abs(Ke),Nt=Math.abs(tt);K($t>Nt?"horizontal":"vertical")}}let vt;if(!ce.current)B==="vertical"?tt>0?vt="down":tt<0&&(vt="up"):B==="horizontal"?Ke>0?vt="right":Ke<0&&(vt="left"):Math.abs(Ke)>=Math.abs(tt)?vt=Ke>0?"right":"left":vt=tt>0?"down":"up",vt&&f.includes(vt)&&(ce.current=vt,me.current=Jb(vt,Ke,tt),P(vt));else{const Dr=ce.current,st=Jb(Dr,Wt,Di);st>ma?(le.current=!1,P(Dr)):!(f.includes("left")&&f.includes("right"))&&!(f.includes("up")&&f.includes("down"))&&me.current-st>=CF&&(le.current=!0)}const kn=we(Ke,tt);let Gn=oe.current.x,Yn=oe.current.y;B==="horizontal"?(f.includes("left")||f.includes("right"))&&(Gn+=kn.x):(B==="vertical"||(f.includes("left")||f.includes("right"))&&(Gn+=kn.x),(f.includes("up")||f.includes("down"))&&(Yn+=kn.y)),H({x:Gn,y:Yn})}function pe(Ce){var Ke;if(!O)return;if(N(!1),F(!1),K(null),(Ke=A.current)==null||Ke.releasePointerCapture(Ce.pointerId),le.current){H({x:j.x,y:j.y}),P(void 0);return}let Fe=!1;const it=q.x-j.x,qe=q.y-j.y;let Ye;for(const tt of f){switch(tt){case"right":it>ma&&(Fe=!0,Ye="right");break;case"left":it<-ma&&(Fe=!0,Ye="left");break;case"down":qe>ma&&(Fe=!0,Ye="down");break;case"up":qe<-ma&&(Fe=!0,Ye="up");break}if(Fe)break}Fe?(P(Ye),Q(!0),y(r.id)):(H({x:j.x,y:j.y}),P(void 0))}function Re(Ce){if(Ce.key==="Escape"){if(!A.current||!Xe(A.current,ir(or(A.current))))return;y(r.id)}}S.useEffect(()=>{if(!h)return;const Ce=A.current;if(!Ce)return;function Fe(it){Xe(Ce,it.target)&&it.preventDefault()}return Ce.addEventListener("touchmove",Fe,{passive:!1}),()=>{Ce.removeEventListener("touchmove",Fe)}},[h]);function Te(){if(!O&&q.x===j.x&&q.y===j.y&&!U)return{[zs.swipeMovementX]:"0px",[zs.swipeMovementY]:"0px"};const Ce=q.x-j.x,Fe=q.y-j.y;return{transition:O?"none":void 0,transform:O?`translateX(${q.x}px) translateY(${q.y}px) scale(${j.scale})`:void 0,[zs.swipeMovementX]:`${Ce}px`,[zs.swipeMovementY]:`${Fe}px`}}const Le=r.priority==="high",We={role:Le?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":W,"aria-describedby":X,"aria-hidden":Le&&!g?!0:void 0,onPointerDown:h?at:void 0,onPointerMove:h?ze:void 0,onPointerUp:h?pe:void 0,onKeyDown:Re,inert:c0(r.limited),style:{...Te(),[zs.index]:r.transitionStatus==="ending"?fe:ye,[zs.offsetY]:`${ne}px`,[zs.height]:r.height?`${r.height}px`:void 0}},Me=S.useMemo(()=>({rootRef:A,toast:r,titleId:W,setTitleId:_,descriptionId:X,setDescriptionId:D,swiping:O,swipeDirection:M,recalculateHeight:he,index:fe,visibleIndex:ye,expanded:E}),[r,W,X,O,M,he,fe,ye,E]),xe=S.useMemo(()=>({transitionStatus:r.transitionStatus,expanded:E,limited:r.limited||!1,type:r.type,swiping:Me.swiping,swipeDirection:Me.swipeDirection}),[E,r.transitionStatus,r.limited,r.type,Me.swiping,Me.swipeDirection]),Ve=At("div",e,{ref:[t,Me.rootRef],state:xe,stateAttributesMapping:kF,props:[We,a]});return k.jsx(kR.Provider,{value:Me,children:Ve})}),MF=S.forwardRef(function(e,t){const{render:r,className:i,...s}=e,{visibleIndex:o,expanded:a,recalculateHeight:u}=ul(),f=S.useRef(null);Be(()=>{const y=f.current;if(!y||(u(),typeof ResizeObserver!="function"||typeof MutationObserver!="function"))return;const x=new ResizeObserver(()=>u(!0)),w=new MutationObserver(()=>u(!0));return x.observe(y),w.observe(y,{childList:!0,subtree:!0,characterData:!0}),()=>{x.disconnect(),w.disconnect()}},[u]);const h=o>0,p=S.useMemo(()=>({expanded:a,behind:h}),[a,h]);return At("div",e,{ref:[t,f],state:p,props:s})}),OF=S.forwardRef(function(e,t){const{render:r,className:i,id:s,children:o,...a}=e,{toast:u}=ul(),f=o??u.description,h=!!f,p=lo(s),{setDescriptionId:g}=ul();Be(()=>{if(h)return g(p),()=>{g(void 0)}},[h,p,g]);const y=S.useMemo(()=>({type:u.type}),[u.type]),x=At("p",e,{ref:t,state:y,props:{...a,id:p,children:f}});return h?x:null}),PF=S.forwardRef(function(e,t){const{render:r,className:i,id:s,children:o,...a}=e,{toast:u}=ul(),f=o??u.title,h=!!f,p=lo(s),{setTitleId:g}=ul();Be(()=>{if(h)return g(p),()=>{g(void 0)}},[h,p,g]);const y=S.useMemo(()=>({type:u.type}),[u.type]),x=At("h2",e,{ref:t,state:y,props:{...a,id:p,children:f}});return h?x:null}),AF=S.forwardRef(function(e,t){var w;const{render:r,className:i,disabled:s,nativeButton:o=!0,...a}=e,{toast:u}=ul(),f=((w=u.actionProps)==null?void 0:w.children)??a.children,h=!!f,{getButtonProps:p,buttonRef:g}=Md({disabled:s,native:o}),y=S.useMemo(()=>({type:u.type}),[u.type]),x=At("button",e,{ref:[t,g],state:y,props:[a,u.actionProps,p,{children:f}]});return h?x:null}),NF=AS;function LF(){const n=S.useContext(Z0);if(!n)throw new Error(gn(73));const{toasts:e,add:t,close:r,update:i,promise:s}=n;return S.useMemo(()=>({toasts:e,add:t,close:r,update:i,promise:s}),[e,t,r,i,s])}function DF(){const n=[];function e(t){n.forEach(r=>r(t))}return{" subscribe":function(r){return n.push(r),()=>{const i=n.indexOf(r);i!==-1&&n.splice(i,1)}},add(t){const r=t.id||bR("toast"),i={...t,id:r,transitionStatus:"starting"};return e({action:"add",options:i}),r},close(t){e({action:"close",options:{id:t}})},update(t,r){e({action:"update",options:{...r,id:t}})},promise(t,r){let i=t;return e({action:"promise",options:{...r,promise:t,setPromise(s){i=s}}}),i}}}const CR=DF(),IF={error:gd,info:bM,loading:y2,success:g2,warning:zM};function jF({children:n,position:e="bottom-right",...t}){return k.jsxs(xF,{toastManager:CR,...t,children:[n,k.jsx(BF,{position:e})]})}function BF({position:n="bottom-right"}){const{toasts:e}=LF(),t=n.startsWith("top");return k.jsx(NF,{"data-slot":"toast-portal",children:k.jsx(SF,{className:et("fixed z-50 mx-auto flex w-[calc(100%-var(--toast-inset)*2)] max-w-90 [--toast-inset:--spacing(4)] sm:[--toast-inset:--spacing(8)]","data-[position*=top]:top-(--toast-inset)","data-[position*=bottom]:bottom-(--toast-inset)","data-[position*=left]:left-(--toast-inset)","data-[position*=right]:right-(--toast-inset)","data-[position*=center]:-translate-x-1/2 data-[position*=center]:left-1/2"),"data-position":n,"data-slot":"toast-viewport",children:e.map(r=>{const i=r.type?IF[r.type]:null;return k.jsx(TF,{className:et("absolute z-[calc(9999-var(--toast-index))] h-(--toast-calc-height) w-full select-none rounded-lg border bg-popover bg-clip-padding text-popover-foreground shadow-lg [transition:transform_.5s_cubic-bezier(.22,1,.36,1),opacity_.5s,height_.15s] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]","data-[position*=right]:right-0 data-[position*=right]:left-auto","data-[position*=left]:right-auto data-[position*=left]:left-0","data-[position*=center]:right-0 data-[position*=center]:left-0","data-[position*=top]:top-0 data-[position*=top]:bottom-auto data-[position*=top]:origin-top","data-[position*=bottom]:top-auto data-[position*=bottom]:bottom-0 data-[position*=bottom]:origin-bottom","after:absolute after:left-0 after:h-[calc(var(--toast-gap)+1px)] after:w-full","data-[position*=top]:after:top-full","data-[position*=bottom]:after:bottom-full","[--toast-calc-height:var(--toast-frontmost-height,var(--toast-height))] [--toast-gap:--spacing(3)] [--toast-peek:--spacing(3)] [--toast-scale:calc(max(0,1-(var(--toast-index)*.1)))] [--toast-shrink:calc(1-var(--toast-scale))]","data-[position*=top]:[--toast-calc-offset-y:calc(var(--toast-offset-y)+var(--toast-index)*var(--toast-gap)+var(--toast-swipe-movement-y))]","data-[position*=bottom]:[--toast-calc-offset-y:calc(var(--toast-offset-y)*-1+var(--toast-index)*var(--toast-gap)*-1+var(--toast-swipe-movement-y))]","data-[position*=top]:transform-[translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)+(var(--toast-index)*var(--toast-peek))+(var(--toast-shrink)*var(--toast-calc-height))))_scale(var(--toast-scale))]","data-[position*=bottom]:transform-[translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--toast-peek))-(var(--toast-shrink)*var(--toast-calc-height))))_scale(var(--toast-scale))]","data-limited:opacity-0","data-expanded:h-(--toast-height)","data-position:data-expanded:transform-[translateX(var(--toast-swipe-movement-x))_translateY(var(--toast-calc-offset-y))]","data-[position*=top]:data-starting-style:transform-[translateY(calc(-100%-var(--toast-inset)))]","data-[position*=bottom]:data-starting-style:transform-[translateY(calc(100%+var(--toast-inset)))]","data-ending-style:opacity-0","data-ending-style:not-data-limited:not-data-swipe-direction:transform-[translateY(calc(100%+var(--toast-inset)))]","data-ending-style:data-[swipe-direction=left]:transform-[translateX(calc(var(--toast-swipe-movement-x)-100%-var(--toast-inset)))_translateY(var(--toast-calc-offset-y))]","data-ending-style:data-[swipe-direction=right]:transform-[translateX(calc(var(--toast-swipe-movement-x)+100%+var(--toast-inset)))_translateY(var(--toast-calc-offset-y))]","data-ending-style:data-[swipe-direction=up]:transform-[translateY(calc(var(--toast-swipe-movement-y)-100%-var(--toast-inset)))]","data-ending-style:data-[swipe-direction=down]:transform-[translateY(calc(var(--toast-swipe-movement-y)+100%+var(--toast-inset)))]","data-expanded:data-ending-style:data-[swipe-direction=left]:transform-[translateX(calc(var(--toast-swipe-movement-x)-100%-var(--toast-inset)))_translateY(var(--toast-calc-offset-y))]","data-expanded:data-ending-style:data-[swipe-direction=right]:transform-[translateX(calc(var(--toast-swipe-movement-x)+100%+var(--toast-inset)))_translateY(var(--toast-calc-offset-y))]","data-expanded:data-ending-style:data-[swipe-direction=up]:transform-[translateY(calc(var(--toast-swipe-movement-y)-100%-var(--toast-inset)))]","data-expanded:data-ending-style:data-[swipe-direction=down]:transform-[translateY(calc(var(--toast-swipe-movement-y)+100%+var(--toast-inset)))]"),"data-position":n,swipeDirection:n.includes("center")?[t?"up":"down"]:n.includes("left")?["left",t?"up":"down"]:["right",t?"up":"down"],toast:r,children:k.jsxs(MF,{className:"pointer-events-auto flex items-center justify-between gap-1.5 overflow-hidden px-3.5 py-3 text-sm transition-opacity duration-250 data-behind:pointer-events-none data-behind:opacity-0 data-expanded:opacity-100",children:[k.jsxs("div",{className:"flex gap-2",children:[i&&k.jsx("div",{className:"[&>svg]:h-lh [&>svg]:w-4 [&_svg]:pointer-events-none [&_svg]:shrink-0","data-slot":"toast-icon",children:k.jsx(i,{className:"in-data-[type=loading]:animate-spin in-data-[type=error]:text-destructive in-data-[type=info]:text-info in-data-[type=success]:text-success in-data-[type=warning]:text-warning in-data-[type=loading]:opacity-80"})}),k.jsxs("div",{className:"flex flex-col gap-0.5",children:[k.jsx(PF,{className:"font-medium","data-slot":"toast-title"}),k.jsx(OF,{className:"text-muted-foreground","data-slot":"toast-description"})]})]}),r.actionProps&&k.jsx(AF,{className:A2({size:"xs"}),"data-slot":"toast-action",children:r.actionProps.children})]})},r.id)})})})}class FF extends S.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("Uncaught error:",e,t)}render(){if(this.state.error){const e=this.state.error,t=e instanceof _t;return k.jsx("div",{className:"flex h-dvh overflow-auto bg-background px-4 py-6",children:k.jsx("div",{className:"m-auto w-full max-w-md shrink-0",children:k.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-6",children:[k.jsx("h1",{className:"text-page text-foreground mb-4",children:"Something went wrong"}),k.jsx("p",{className:"text-body text-destructive-foreground mb-4 [overflow-wrap:anywhere]",children:e.message}),t&&k.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Error code: ",e.status]}),k.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"Reload page"})]})})})}return this.props.children}}function zF(){const[n,e]=S.useState([]),[t,r]=S.useState(!0);return S.useEffect(()=>{f0().then(i=>{e(i),r(!1)}).catch(i=>{console.error("Failed to fetch sources:",i);const s=i instanceof _t?i.message:"Failed to load data sources";CR.add({title:s,type:"error"}),r(!1)})},[]),k.jsx(FF,{children:k.jsx(jF,{children:k.jsx(HT,{children:k.jsx(wT,{children:k.jsxs(_s,{path:"/",element:k.jsx(f8,{sources:n,isLoading:t}),children:[k.jsx(_s,{index:!0,element:k.jsx(d8,{})}),k.jsx(_s,{path:"requests",element:k.jsx(C8,{})}),k.jsx(_s,{path:"source/:sourceId",element:k.jsx(E8,{})}),k.jsx(_s,{path:"source/:sourceId/tool/:toolName",element:k.jsx(yF,{})}),k.jsx(_s,{path:"*",element:k.jsx(vF,{})})]})})})})})}T3.createRoot(document.getElementById("root")).render(k.jsx(S.StrictMode,{children:k.jsx(zF,{})}));