From 443b449fac313c91bafe767474621792047b5df5 Mon Sep 17 00:00:00 2001 From: Obvious Date: Tue, 8 Sep 2026 04:16:35 +0000 Subject: [PATCH 1/3] feat(table): row/column deletion actions + readable selected headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Input table only (output stays read-only): toolbar actions and keyboard Delete/Backspace remove selected rows or columns from the parsed table, serialize through the CSV serializer, and commit through the same guarded reconversion path as a cell edit — raw text stays the single source of truth. Deleting the last remaining column is blocked with an explanatory tooltip; deleting all rows falls through to the existing empty state; hand-edited raw routes through the guarded prompt like any cell edit. Selected column headers switch from the inverted-ink fill (white-on- white / black-on-black) to a wash treatment with contrasting text in both themes; idle header rendering is untouched. Changelog entry 10; no new undo stack — recovery is the existing guard/revert affordances. --- ...s => data-grid-overlay-editor-Cscy33Rw.js} | 2 +- .../{index-D1Vhxl5v.js => index-BIOflrBp.js} | 160 +++++++------- ...C.js => number-overlay-editor-BQY5aYke.js} | 2 +- app/dist/index.html | 2 +- app/src/changelog/entries.ts | 8 + app/src/components/CsvTable.test.tsx | 179 +++++++++++++++- app/src/components/CsvTable.tsx | 198 ++++++++++++++++-- app/src/lib/__tests__/tableDeletion.test.ts | 55 +++++ app/src/lib/tableDeletion.ts | 42 ++++ app/src/outputEditing.test.tsx | 22 ++ app/src/test/glideDataEditorMock.tsx | 55 ++++- 11 files changed, 626 insertions(+), 99 deletions(-) rename app/dist/assets/{data-grid-overlay-editor-D3k0cr0z.js => data-grid-overlay-editor-Cscy33Rw.js} (98%) rename app/dist/assets/{index-D1Vhxl5v.js => index-BIOflrBp.js} (50%) rename app/dist/assets/{number-overlay-editor-CTQ0oWgC.js => number-overlay-editor-BQY5aYke.js} (99%) create mode 100644 app/src/lib/__tests__/tableDeletion.test.ts create mode 100644 app/src/lib/tableDeletion.ts diff --git a/app/dist/assets/data-grid-overlay-editor-D3k0cr0z.js b/app/dist/assets/data-grid-overlay-editor-Cscy33Rw.js similarity index 98% rename from app/dist/assets/data-grid-overlay-editor-D3k0cr0z.js rename to app/dist/assets/data-grid-overlay-editor-Cscy33Rw.js index ab49027..1ba242c 100644 --- a/app/dist/assets/data-grid-overlay-editor-D3k0cr0z.js +++ b/app/dist/assets/data-grid-overlay-editor-Cscy33Rw.js @@ -1 +1 @@ -import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-D1Vhxl5v.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; +import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-BIOflrBp.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; diff --git a/app/dist/assets/index-D1Vhxl5v.js b/app/dist/assets/index-BIOflrBp.js similarity index 50% rename from app/dist/assets/index-D1Vhxl5v.js rename to app/dist/assets/index-BIOflrBp.js index c77affd..89020bf 100644 --- a/app/dist/assets/index-D1Vhxl5v.js +++ b/app/dist/assets/index-BIOflrBp.js @@ -1,4 +1,4 @@ -var eR=Object.defineProperty;var tR=(t,e,n)=>e in t?eR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var at=(t,e,n)=>tR(t,typeof e!="symbol"?e+"":e,n);(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 n(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=n(i);fetch(i.href,s)}})();var no=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ri(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mS={exports:{}},Hd={},yS={exports:{}},gt={};/** +var rR=Object.defineProperty;var iR=(t,e,n)=>e in t?rR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ft=(t,e,n)=>iR(t,typeof e!="symbol"?e+"":e,n);(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 n(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=n(i);fetch(i.href,s)}})();var no=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wS={exports:{}},Wd={},xS={exports:{}},wt={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var eR=Object.defineProperty;var tR=(t,e,n)=>e in t?eR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Oc=Symbol.for("react.element"),nR=Symbol.for("react.portal"),rR=Symbol.for("react.fragment"),iR=Symbol.for("react.strict_mode"),sR=Symbol.for("react.profiler"),oR=Symbol.for("react.provider"),lR=Symbol.for("react.context"),aR=Symbol.for("react.forward_ref"),uR=Symbol.for("react.suspense"),cR=Symbol.for("react.memo"),fR=Symbol.for("react.lazy"),Dw=Symbol.iterator;function hR(t){return t===null||typeof t!="object"?null:(t=Dw&&t[Dw]||t["@@iterator"],typeof t=="function"?t:null)}var vS={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},wS=Object.assign,xS={};function Na(t,e,n){this.props=t,this.context=e,this.refs=xS,this.updater=n||vS}Na.prototype.isReactComponent={};Na.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Na.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function bS(){}bS.prototype=Na.prototype;function ky(t,e,n){this.props=t,this.context=e,this.refs=xS,this.updater=n||vS}var Sy=ky.prototype=new bS;Sy.constructor=ky;wS(Sy,Na.prototype);Sy.isPureReactComponent=!0;var _w=Array.isArray,kS=Object.prototype.hasOwnProperty,Cy={current:null},SS={key:!0,ref:!0,__self:!0,__source:!0};function CS(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)kS.call(e,r)&&!SS.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1e in t?eR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var yR=w,vR=Symbol.for("react.element"),wR=Symbol.for("react.fragment"),xR=Object.prototype.hasOwnProperty,bR=yR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,kR={key:!0,ref:!0,__self:!0,__source:!0};function ES(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)xR.call(e,r)&&!kR.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:vR,type:t,key:s,ref:o,props:i,_owner:bR.current}}Hd.Fragment=wR;Hd.jsx=ES;Hd.jsxs=ES;mS.exports=Hd;var R=mS.exports,MS={exports:{}},Lr={},AS={exports:{}},RS={};/** + */var xR=w,bR=Symbol.for("react.element"),kR=Symbol.for("react.fragment"),SR=Object.prototype.hasOwnProperty,CR=xR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,TR={key:!0,ref:!0,__self:!0,__source:!0};function RS(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)SR.call(e,r)&&!TR.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:bR,type:t,key:s,ref:o,props:i,_owner:CR.current}}Wd.Fragment=kR;Wd.jsx=RS;Wd.jsxs=RS;wS.exports=Wd;var R=wS.exports,OS={exports:{}},Fr={},PS={exports:{}},IS={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var eR=Object.defineProperty;var tR=(t,e,n)=>e in t?eR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(t){function e(H,te){var G=H.length;H.push(te);e:for(;0>>1,F=H[M];if(0>>1;Mi(B,G))gei(we,B)?(H[M]=we,H[ge]=G,M=ge):(H[M]=B,H[j]=G,M=j);else if(gei(we,G))H[M]=we,H[ge]=G,M=ge;else break e}}return te}function i(H,te){var G=H.sortIndex-te.sortIndex;return G!==0?G:H.id-te.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,h=3,d=!1,p=!1,m=!1,x=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(H){for(var te=n(u);te!==null;){if(te.callback===null)r(u);else if(te.startTime<=H)r(u),te.sortIndex=te.expirationTime,e(a,te);else break;te=n(u)}}function k(H){if(m=!1,y(H),!p)if(n(a)!==null)p=!0,U(b);else{var te=n(u);te!==null&&ae(k,te.startTime-H)}}function b(H,te){p=!1,m&&(m=!1,v(E),E=-1),d=!0;var G=h;try{for(y(te),f=n(a);f!==null&&(!(f.expirationTime>te)||H&&!D());){var M=f.callback;if(typeof M=="function"){f.callback=null,h=f.priorityLevel;var F=M(f.expirationTime<=te);te=t.unstable_now(),typeof F=="function"?f.callback=F:f===n(a)&&r(a),y(te)}else r(a);f=n(a)}if(f!==null)var z=!0;else{var j=n(u);j!==null&&ae(k,j.startTime-te),z=!1}return z}finally{f=null,h=G,d=!1}}var C=!1,T=null,E=-1,A=5,P=-1;function D(){return!(t.unstable_now()-PH||125M?(H.sortIndex=G,e(u,H),n(a)===null&&H===n(u)&&(m?(v(E),E=-1):m=!0,ae(k,G-M))):(H.sortIndex=F,e(a,H),p||d||(p=!0,U(b))),H},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(H){var te=h;return function(){var G=h;h=te;try{return H.apply(this,arguments)}finally{h=G}}}})(RS);AS.exports=RS;var SR=AS.exports;/** + */(function(t){function e(j,ne){var Y=j.length;j.push(ne);e:for(;0>>1,F=j[M];if(0>>1;Mi(B,Y))dei(ge,B)?(j[M]=ge,j[de]=Y,M=de):(j[M]=B,j[W]=Y,M=W);else if(dei(ge,Y))j[M]=ge,j[de]=Y,M=de;else break e}}return ne}function i(j,ne){var Y=j.sortIndex-ne.sortIndex;return Y!==0?Y:j.id-ne.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,h=3,d=!1,p=!1,m=!1,x=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(j){for(var ne=n(u);ne!==null;){if(ne.callback===null)r(u);else if(ne.startTime<=j)r(u),ne.sortIndex=ne.expirationTime,e(a,ne);else break;ne=n(u)}}function k(j){if(m=!1,y(j),!p)if(n(a)!==null)p=!0,X(b);else{var ne=n(u);ne!==null&&le(k,ne.startTime-j)}}function b(j,ne){p=!1,m&&(m=!1,v(E),E=-1),d=!0;var Y=h;try{for(y(ne),f=n(a);f!==null&&(!(f.expirationTime>ne)||j&&!_());){var M=f.callback;if(typeof M=="function"){f.callback=null,h=f.priorityLevel;var F=M(f.expirationTime<=ne);ne=t.unstable_now(),typeof F=="function"?f.callback=F:f===n(a)&&r(a),y(ne)}else r(a);f=n(a)}if(f!==null)var z=!0;else{var W=n(u);W!==null&&le(k,W.startTime-ne),z=!1}return z}finally{f=null,h=Y,d=!1}}var C=!1,T=null,E=-1,A=5,P=-1;function _(){return!(t.unstable_now()-Pj||125M?(j.sortIndex=Y,e(u,j),n(a)===null&&j===n(u)&&(m?(v(E),E=-1):m=!0,le(k,Y-M))):(j.sortIndex=F,e(a,j),p||d||(p=!0,X(b))),j},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(j){var ne=h;return function(){var Y=h;h=ne;try{return j.apply(this,arguments)}finally{h=Y}}}})(IS);PS.exports=IS;var ER=PS.exports;/** * @license React * react-dom.production.min.js * @@ -30,151 +30,151 @@ var eR=Object.defineProperty;var tR=(t,e,n)=>e in t?eR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var CR=w,Nr=SR;function de(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vm=Object.prototype.hasOwnProperty,TR=/^[: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]*$/,Lw={},Fw={};function ER(t){return vm.call(Fw,t)?!0:vm.call(Lw,t)?!1:TR.test(t)?Fw[t]=!0:(Lw[t]=!0,!1)}function MR(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function AR(t,e,n,r){if(e===null||typeof e>"u"||MR(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ar(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Ln={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ln[t]=new ar(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ln[e]=new ar(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ln[t]=new ar(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ln[t]=new ar(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ln[t]=new ar(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Ln[t]=new ar(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Ln[t]=new ar(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Ln[t]=new ar(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Ln[t]=new ar(t,5,!1,t.toLowerCase(),null,!1,!1)});var Ey=/[\-:]([a-z])/g;function My(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ey,My);Ln[e]=new ar(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ey,My);Ln[e]=new ar(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ey,My);Ln[e]=new ar(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Ln[t]=new ar(t,1,!1,t.toLowerCase(),null,!1,!1)});Ln.xlinkHref=new ar("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Ln[t]=new ar(t,1,!1,t.toLowerCase(),null,!0,!0)});function Ay(t,e,n,r){var i=Ln.hasOwnProperty(e)?Ln[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wm=Object.prototype.hasOwnProperty,AR=/^[: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]*$/,Bw={},zw={};function RR(t){return wm.call(zw,t)?!0:wm.call(Bw,t)?!1:AR.test(t)?zw[t]=!0:(Bw[t]=!0,!1)}function OR(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function PR(t,e,n,r){if(e===null||typeof e>"u"||OR(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function cr(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Hn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Hn[t]=new cr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Hn[e]=new cr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Hn[t]=new cr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Hn[t]=new cr(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Hn[t]=new cr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Hn[t]=new cr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Hn[t]=new cr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Hn[t]=new cr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Hn[t]=new cr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Ay=/[\-:]([a-z])/g;function Ry(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ay,Ry);Hn[e]=new cr(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ay,Ry);Hn[e]=new cr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ay,Ry);Hn[e]=new cr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Hn[t]=new cr(t,1,!1,t.toLowerCase(),null,!1,!1)});Hn.xlinkHref=new cr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Hn[t]=new cr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Oy(t,e,n,r){var i=Hn.hasOwnProperty(e)?Hn[e]:null;(i!==null?i.type!==0:r||!(2l||i[o]!==s[l]){var a=` -`+i[o].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{Zp=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Tu(t):""}function RR(t){switch(t.tag){case 5:return Tu(t.type);case 16:return Tu("Lazy");case 13:return Tu("Suspense");case 19:return Tu("SuspenseList");case 0:case 2:case 15:return t=eg(t.type,!1),t;case 11:return t=eg(t.type.render,!1),t;case 1:return t=eg(t.type,!0),t;default:return""}}function km(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Hl:return"Fragment";case $l:return"Portal";case wm:return"Profiler";case Ry:return"StrictMode";case xm:return"Suspense";case bm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case IS:return(t.displayName||"Context")+".Consumer";case PS:return(t._context.displayName||"Context")+".Provider";case Oy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Py:return e=t.displayName||null,e!==null?e:km(t.type)||"Memo";case Gs:e=t._payload,t=t._init;try{return km(t(e))}catch{}}return null}function OR(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return km(e);case 8:return e===Ry?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function yo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function _S(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function PR(t){var e=_S(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function xf(t){t._valueTracker||(t._valueTracker=PR(t))}function NS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=_S(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function _h(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Sm(t,e){var n=e.checked;return tn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function zw(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=yo(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function LS(t,e){e=e.checked,e!=null&&Ay(t,"checked",e,!1)}function Cm(t,e){LS(t,e);var n=yo(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Tm(t,e.type,n):e.hasOwnProperty("defaultValue")&&Tm(t,e.type,yo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function $w(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Tm(t,e,n){(e!=="number"||_h(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Eu=Array.isArray;function ia(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=bf.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function rc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var _u={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},IR=["Webkit","ms","Moz","O"];Object.keys(_u).forEach(function(t){IR.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),_u[e]=_u[t]})});function $S(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||_u.hasOwnProperty(t)&&_u[t]?(""+e).trim():e+"px"}function HS(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=$S(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var DR=tn({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 Am(t,e){if(e){if(DR[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(de(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(de(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(de(61))}if(e.style!=null&&typeof e.style!="object")throw Error(de(62))}}function Rm(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Om=null;function Iy(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Pm=null,sa=null,oa=null;function Ww(t){if(t=Dc(t)){if(typeof Pm!="function")throw Error(de(280));var e=t.stateNode;e&&(e=Kd(e),Pm(t.stateNode,t.type,e))}}function jS(t){sa?oa?oa.push(t):oa=[t]:sa=t}function WS(){if(sa){var t=sa,e=oa;if(oa=sa=null,Ww(t),e)for(t=0;t>>=0,t===0?32:31-(VR(t)/UR|0)|0}var kf=64,Sf=4194304;function Mu(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Bh(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~i;l!==0?r=Mu(l):(s&=o,s!==0&&(r=Mu(s)))}else o=n&~i,o!==0?r=Mu(o):s!==0&&(r=Mu(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Pc(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Ti(e),t[e]=n}function qR(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Lu),Jw=" ",Zw=!1;function uC(t,e){switch(t){case"keyup":return SO.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var jl=!1;function TO(t,e){switch(t){case"compositionend":return cC(e);case"keypress":return e.which!==32?null:(Zw=!0,Jw);case"textInput":return t=e.data,t===Jw&&Zw?null:t;default:return null}}function EO(t,e){if(jl)return t==="compositionend"||!$y&&uC(t,e)?(t=lC(),yh=Fy=ro=null,jl=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=r1(n)}}function pC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?pC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function gC(){for(var t=window,e=_h();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=_h(t.document)}return e}function Hy(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function NO(t){var e=gC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&pC(n.ownerDocument.documentElement,n)){if(r!==null&&Hy(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=i1(n,s);var o=i1(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Wl=null,Fm=null,Bu=null,Bm=!1;function s1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Bm||Wl==null||Wl!==_h(r)||(r=Wl,"selectionStart"in r&&Hy(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Bu&&uc(Bu,r)||(Bu=r,r=Hh(Fm,"onSelect"),0Kl||(t.current=Vm[Kl],Vm[Kl]=null,Kl--)}function zt(t,e){Kl++,Vm[Kl]=t.current,t.current=e}var vo={},Gn=To(vo),mr=To(!1),el=vo;function ya(t,e){var n=t.type.contextTypes;if(!n)return vo;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function yr(t){return t=t.childContextTypes,t!=null}function Wh(){Ut(mr),Ut(Gn)}function h1(t,e,n){if(Gn.current!==vo)throw Error(de(168));zt(Gn,e),zt(mr,n)}function CC(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(de(108,OR(t)||"Unknown",i));return tn({},n,r)}function Vh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||vo,el=Gn.current,zt(Gn,t),zt(mr,mr.current),!0}function d1(t,e,n){var r=t.stateNode;if(!r)throw Error(de(169));n?(t=CC(t,e,el),r.__reactInternalMemoizedMergedChildContext=t,Ut(mr),Ut(Gn),zt(Gn,t)):Ut(mr),zt(mr,n)}var ms=null,Xd=!1,pg=!1;function TC(t){ms===null?ms=[t]:ms.push(t)}function XO(t){Xd=!0,TC(t)}function Eo(){if(!pg&&ms!==null){pg=!0;var t=0,e=At;try{var n=ms;for(At=1;t>=o,i-=o,bs=1<<32-Ti(e)+i|n<E?(A=T,T=null):A=T.sibling;var P=h(v,T,y[E],k);if(P===null){T===null&&(T=A);break}t&&T&&P.alternate===null&&e(v,T),g=s(P,g,E),C===null?b=P:C.sibling=P,C=P,T=A}if(E===y.length)return n(v,T),Qt&&zo(v,E),b;if(T===null){for(;EE?(A=T,T=null):A=T.sibling;var D=h(v,T,P.value,k);if(D===null){T===null&&(T=A);break}t&&T&&D.alternate===null&&e(v,T),g=s(D,g,E),C===null?b=D:C.sibling=D,C=D,T=A}if(P.done)return n(v,T),Qt&&zo(v,E),b;if(T===null){for(;!P.done;E++,P=y.next())P=f(v,P.value,k),P!==null&&(g=s(P,g,E),C===null?b=P:C.sibling=P,C=P);return Qt&&zo(v,E),b}for(T=r(v,T);!P.done;E++,P=y.next())P=d(T,v,E,P.value,k),P!==null&&(t&&P.alternate!==null&&T.delete(P.key===null?E:P.key),g=s(P,g,E),C===null?b=P:C.sibling=P,C=P);return t&&T.forEach(function(O){return e(v,O)}),Qt&&zo(v,E),b}function x(v,g,y,k){if(typeof y=="object"&&y!==null&&y.type===Hl&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case wf:e:{for(var b=y.key,C=g;C!==null;){if(C.key===b){if(b=y.type,b===Hl){if(C.tag===7){n(v,C.sibling),g=i(C,y.props.children),g.return=v,v=g;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===Gs&&m1(b)===C.type){n(v,C.sibling),g=i(C,y.props),g.ref=cu(v,C,y),g.return=v,v=g;break e}n(v,C);break}else e(v,C);C=C.sibling}y.type===Hl?(g=Jo(y.props.children,v.mode,k,y.key),g.return=v,v=g):(k=Th(y.type,y.key,y.props,null,v.mode,k),k.ref=cu(v,g,y),k.return=v,v=k)}return o(v);case $l:e:{for(C=y.key;g!==null;){if(g.key===C)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(v,g.sibling),g=i(g,y.children||[]),g.return=v,v=g;break e}else{n(v,g);break}else e(v,g);g=g.sibling}g=kg(y,v.mode,k),g.return=v,v=g}return o(v);case Gs:return C=y._init,x(v,g,C(y._payload),k)}if(Eu(y))return p(v,g,y,k);if(su(y))return m(v,g,y,k);Of(v,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(v,g.sibling),g=i(g,y),g.return=v,v=g):(n(v,g),g=bg(y,v.mode,k),g.return=v,v=g),o(v)):n(v,g)}return x}var wa=RC(!0),OC=RC(!1),Xh=To(null),Gh=null,ql=null,Uy=null;function Ky(){Uy=ql=Gh=null}function Xy(t){var e=Xh.current;Ut(Xh),t._currentValue=e}function Xm(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function aa(t,e){Gh=t,Uy=ql=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(pr=!0),t.firstContext=null)}function ti(t){var e=t._currentValue;if(Uy!==t)if(t={context:t,memoizedValue:e,next:null},ql===null){if(Gh===null)throw Error(de(308));ql=t,Gh.dependencies={lanes:0,firstContext:t}}else ql=ql.next=t;return e}var Go=null;function Gy(t){Go===null?Go=[t]:Go.push(t)}function PC(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,Gy(e)):(n.next=i.next,i.next=n),e.interleaved=n,As(t,r)}function As(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var qs=!1;function qy(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function IC(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Cs(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function fo(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,bt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,As(t,n)}return i=r.interleaved,i===null?(e.next=e,Gy(r)):(e.next=i.next,i.next=e),r.interleaved=e,As(t,n)}function wh(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,_y(t,n)}}function y1(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function qh(t,e,n,r){var i=t.updateQueue;qs=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var f=i.baseState;o=0,c=u=a=null,l=s;do{var h=l.lane,d=l.eventTime;if((r&h)===h){c!==null&&(c=c.next={eventTime:d,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,m=l;switch(h=e,d=n,m.tag){case 1:if(p=m.payload,typeof p=="function"){f=p.call(d,f,h);break e}f=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=m.payload,h=typeof p=="function"?p.call(d,f,h):p,h==null)break e;f=tn({},f,h);break e;case 2:qs=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,h=i.effects,h===null?i.effects=[l]:h.push(l))}else d={eventTime:d,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=d,a=f):c=c.next=d,o|=h;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;h=l,l=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(c===null&&(a=f),i.baseState=a,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);rl|=o,t.lanes=o,t.memoizedState=f}}function v1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=mg.transition;mg.transition={};try{t(!1),e()}finally{At=n,mg.transition=r}}function qC(){return ni().memoizedState}function QO(t,e,n){var r=po(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},YC(t))QC(e,n);else if(n=PC(t,e,n,r),n!==null){var i=ir();Ei(n,t,r,i),JC(n,e,r)}}function JO(t,e,n){var r=po(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(YC(t))QC(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(i.hasEagerState=!0,i.eagerState=l,Mi(l,o)){var a=e.interleaved;a===null?(i.next=i,Gy(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=PC(t,e,i,r),n!==null&&(i=ir(),Ei(n,t,r,i),JC(n,e,r))}}function YC(t){var e=t.alternate;return t===en||e!==null&&e===en}function QC(t,e){zu=Qh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function JC(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,_y(t,n)}}var Jh={readContext:ti,useCallback:Hn,useContext:Hn,useEffect:Hn,useImperativeHandle:Hn,useInsertionEffect:Hn,useLayoutEffect:Hn,useMemo:Hn,useReducer:Hn,useRef:Hn,useState:Hn,useDebugValue:Hn,useDeferredValue:Hn,useTransition:Hn,useMutableSource:Hn,useSyncExternalStore:Hn,useId:Hn,unstable_isNewReconciler:!1},ZO={readContext:ti,useCallback:function(t,e){return ji().memoizedState=[t,e===void 0?null:e],t},useContext:ti,useEffect:x1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,bh(4194308,4,VC.bind(null,e,t),n)},useLayoutEffect:function(t,e){return bh(4194308,4,t,e)},useInsertionEffect:function(t,e){return bh(4,2,t,e)},useMemo:function(t,e){var n=ji();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=ji();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=QO.bind(null,en,t),[r.memoizedState,t]},useRef:function(t){var e=ji();return t={current:t},e.memoizedState=t},useState:w1,useDebugValue:rv,useDeferredValue:function(t){return ji().memoizedState=t},useTransition:function(){var t=w1(!1),e=t[0];return t=YO.bind(null,t[1]),ji().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=en,i=ji();if(Qt){if(n===void 0)throw Error(de(407));n=n()}else{if(n=e(),Mn===null)throw Error(de(349));nl&30||LC(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,x1(BC.bind(null,r,s,t),[t]),r.flags|=2048,yc(9,FC.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=ji(),e=Mn.identifierPrefix;if(Qt){var n=ks,r=bs;n=(r&~(1<<32-Ti(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=gc++,0")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{tg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Eu(t):""}function IR(t){switch(t.tag){case 5:return Eu(t.type);case 16:return Eu("Lazy");case 13:return Eu("Suspense");case 19:return Eu("SuspenseList");case 0:case 2:case 15:return t=ng(t.type,!1),t;case 11:return t=ng(t.type.render,!1),t;case 1:return t=ng(t.type,!0),t;default:return""}}function Sm(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Hl:return"Fragment";case $l:return"Portal";case xm:return"Profiler";case Py:return"StrictMode";case bm:return"Suspense";case km:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case NS:return(t.displayName||"Context")+".Consumer";case _S:return(t._context.displayName||"Context")+".Provider";case Iy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Dy:return e=t.displayName||null,e!==null?e:Sm(t.type)||"Memo";case Gs:e=t._payload,t=t._init;try{return Sm(t(e))}catch{}}return null}function DR(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Sm(e);case 8:return e===Py?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function yo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function FS(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function _R(t){var e=FS(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function kf(t){t._valueTracker||(t._valueTracker=_R(t))}function BS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=FS(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Lh(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Cm(t,e){var n=e.checked;return tn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Hw(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=yo(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function zS(t,e){e=e.checked,e!=null&&Oy(t,"checked",e,!1)}function Tm(t,e){zS(t,e);var n=yo(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Em(t,e.type,n):e.hasOwnProperty("defaultValue")&&Em(t,e.type,yo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function jw(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Em(t,e,n){(e!=="number"||Lh(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Mu=Array.isArray;function ia(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Sf.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function sc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Nu={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},NR=["Webkit","ms","Moz","O"];Object.keys(Nu).forEach(function(t){NR.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Nu[e]=Nu[t]})});function WS(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Nu.hasOwnProperty(t)&&Nu[t]?(""+e).trim():e+"px"}function VS(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=WS(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var LR=tn({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 Rm(t,e){if(e){if(LR[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(he(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(he(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(he(61))}if(e.style!=null&&typeof e.style!="object")throw Error(he(62))}}function Om(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Pm=null;function _y(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Im=null,sa=null,oa=null;function Uw(t){if(t=Nc(t)){if(typeof Im!="function")throw Error(he(280));var e=t.stateNode;e&&(e=Gd(e),Im(t.stateNode,t.type,e))}}function US(t){sa?oa?oa.push(t):oa=[t]:sa=t}function KS(){if(sa){var t=sa,e=oa;if(oa=sa=null,Uw(t),e)for(t=0;t>>=0,t===0?32:31-(XR(t)/GR|0)|0}var Cf=64,Tf=4194304;function Au(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function $h(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~i;l!==0?r=Au(l):(s&=o,s!==0&&(r=Au(s)))}else o=n&~i,o!==0?r=Au(o):s!==0&&(r=Au(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Dc(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Mi(e),t[e]=n}function JR(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Fu),e1=" ",t1=!1;function hC(t,e){switch(t){case"keyup":return EO.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function dC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var jl=!1;function AO(t,e){switch(t){case"compositionend":return dC(e);case"keypress":return e.which!==32?null:(t1=!0,e1);case"textInput":return t=e.data,t===e1&&t1?null:t;default:return null}}function RO(t,e){if(jl)return t==="compositionend"||!jy&&hC(t,e)?(t=cC(),wh=zy=ro=null,jl=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=s1(n)}}function yC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?yC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function vC(){for(var t=window,e=Lh();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Lh(t.document)}return e}function Wy(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function BO(t){var e=vC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&yC(n.ownerDocument.documentElement,n)){if(r!==null&&Wy(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=o1(n,s);var o=o1(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Wl=null,Bm=null,zu=null,zm=!1;function l1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;zm||Wl==null||Wl!==Lh(r)||(r=Wl,"selectionStart"in r&&Wy(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),zu&&fc(zu,r)||(zu=r,r=Wh(Bm,"onSelect"),0Kl||(t.current=Um[Kl],Um[Kl]=null,Kl--)}function Ht(t,e){Kl++,Um[Kl]=t.current,t.current=e}var vo={},Zn=To(vo),vr=To(!1),el=vo;function ya(t,e){var n=t.type.contextTypes;if(!n)return vo;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function wr(t){return t=t.childContextTypes,t!=null}function Uh(){Xt(vr),Xt(Zn)}function p1(t,e,n){if(Zn.current!==vo)throw Error(he(168));Ht(Zn,e),Ht(vr,n)}function MC(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(he(108,DR(t)||"Unknown",i));return tn({},n,r)}function Kh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||vo,el=Zn.current,Ht(Zn,t),Ht(vr,vr.current),!0}function g1(t,e,n){var r=t.stateNode;if(!r)throw Error(he(169));n?(t=MC(t,e,el),r.__reactInternalMemoizedMergedChildContext=t,Xt(vr),Xt(Zn),Ht(Zn,t)):Xt(vr),Ht(vr,n)}var ms=null,qd=!1,mg=!1;function AC(t){ms===null?ms=[t]:ms.push(t)}function YO(t){qd=!0,AC(t)}function Eo(){if(!mg&&ms!==null){mg=!0;var t=0,e=Pt;try{var n=ms;for(Pt=1;t>=o,i-=o,bs=1<<32-Mi(e)+i|n<E?(A=T,T=null):A=T.sibling;var P=h(v,T,y[E],k);if(P===null){T===null&&(T=A);break}t&&T&&P.alternate===null&&e(v,T),g=s(P,g,E),C===null?b=P:C.sibling=P,C=P,T=A}if(E===y.length)return n(v,T),Jt&&zo(v,E),b;if(T===null){for(;EE?(A=T,T=null):A=T.sibling;var _=h(v,T,P.value,k);if(_===null){T===null&&(T=A);break}t&&T&&_.alternate===null&&e(v,T),g=s(_,g,E),C===null?b=_:C.sibling=_,C=_,T=A}if(P.done)return n(v,T),Jt&&zo(v,E),b;if(T===null){for(;!P.done;E++,P=y.next())P=f(v,P.value,k),P!==null&&(g=s(P,g,E),C===null?b=P:C.sibling=P,C=P);return Jt&&zo(v,E),b}for(T=r(v,T);!P.done;E++,P=y.next())P=d(T,v,E,P.value,k),P!==null&&(t&&P.alternate!==null&&T.delete(P.key===null?E:P.key),g=s(P,g,E),C===null?b=P:C.sibling=P,C=P);return t&&T.forEach(function(O){return e(v,O)}),Jt&&zo(v,E),b}function x(v,g,y,k){if(typeof y=="object"&&y!==null&&y.type===Hl&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case bf:e:{for(var b=y.key,C=g;C!==null;){if(C.key===b){if(b=y.type,b===Hl){if(C.tag===7){n(v,C.sibling),g=i(C,y.props.children),g.return=v,v=g;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===Gs&&v1(b)===C.type){n(v,C.sibling),g=i(C,y.props),g.ref=cu(v,C,y),g.return=v,v=g;break e}n(v,C);break}else e(v,C);C=C.sibling}y.type===Hl?(g=Jo(y.props.children,v.mode,k,y.key),g.return=v,v=g):(k=Mh(y.type,y.key,y.props,null,v.mode,k),k.ref=cu(v,g,y),k.return=v,v=k)}return o(v);case $l:e:{for(C=y.key;g!==null;){if(g.key===C)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(v,g.sibling),g=i(g,y.children||[]),g.return=v,v=g;break e}else{n(v,g);break}else e(v,g);g=g.sibling}g=Cg(y,v.mode,k),g.return=v,v=g}return o(v);case Gs:return C=y._init,x(v,g,C(y._payload),k)}if(Mu(y))return p(v,g,y,k);if(su(y))return m(v,g,y,k);If(v,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(v,g.sibling),g=i(g,y),g.return=v,v=g):(n(v,g),g=Sg(y,v.mode,k),g.return=v,v=g),o(v)):n(v,g)}return x}var wa=IC(!0),DC=IC(!1),qh=To(null),Yh=null,ql=null,Xy=null;function Gy(){Xy=ql=Yh=null}function qy(t){var e=qh.current;Xt(qh),t._currentValue=e}function Gm(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function aa(t,e){Yh=t,Xy=ql=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(mr=!0),t.firstContext=null)}function ri(t){var e=t._currentValue;if(Xy!==t)if(t={context:t,memoizedValue:e,next:null},ql===null){if(Yh===null)throw Error(he(308));ql=t,Yh.dependencies={lanes:0,firstContext:t}}else ql=ql.next=t;return e}var Go=null;function Yy(t){Go===null?Go=[t]:Go.push(t)}function _C(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,Yy(e)):(n.next=i.next,i.next=n),e.interleaved=n,As(t,r)}function As(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var qs=!1;function Qy(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function NC(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Cs(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function fo(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Tt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,As(t,n)}return i=r.interleaved,i===null?(e.next=e,Yy(r)):(e.next=i.next,i.next=e),r.interleaved=e,As(t,n)}function bh(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ly(t,n)}}function w1(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Qh(t,e,n,r){var i=t.updateQueue;qs=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var f=i.baseState;o=0,c=u=a=null,l=s;do{var h=l.lane,d=l.eventTime;if((r&h)===h){c!==null&&(c=c.next={eventTime:d,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,m=l;switch(h=e,d=n,m.tag){case 1:if(p=m.payload,typeof p=="function"){f=p.call(d,f,h);break e}f=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=m.payload,h=typeof p=="function"?p.call(d,f,h):p,h==null)break e;f=tn({},f,h);break e;case 2:qs=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,h=i.effects,h===null?i.effects=[l]:h.push(l))}else d={eventTime:d,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=d,a=f):c=c.next=d,o|=h;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;h=l,l=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(c===null&&(a=f),i.baseState=a,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);rl|=o,t.lanes=o,t.memoizedState=f}}function x1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=vg.transition;vg.transition={};try{t(!1),e()}finally{Pt=n,vg.transition=r}}function JC(){return ii().memoizedState}function eP(t,e,n){var r=po(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ZC(t))e2(e,n);else if(n=_C(t,e,n,r),n!==null){var i=or();Ai(n,t,r,i),t2(n,e,r)}}function tP(t,e,n){var r=po(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ZC(t))e2(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(i.hasEagerState=!0,i.eagerState=l,Ri(l,o)){var a=e.interleaved;a===null?(i.next=i,Yy(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=_C(t,e,i,r),n!==null&&(i=or(),Ai(n,t,r,i),t2(n,e,r))}}function ZC(t){var e=t.alternate;return t===en||e!==null&&e===en}function e2(t,e){$u=Zh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function t2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ly(t,n)}}var ed={readContext:ri,useCallback:Kn,useContext:Kn,useEffect:Kn,useImperativeHandle:Kn,useInsertionEffect:Kn,useLayoutEffect:Kn,useMemo:Kn,useReducer:Kn,useRef:Kn,useState:Kn,useDebugValue:Kn,useDeferredValue:Kn,useTransition:Kn,useMutableSource:Kn,useSyncExternalStore:Kn,useId:Kn,unstable_isNewReconciler:!1},nP={readContext:ri,useCallback:function(t,e){return Vi().memoizedState=[t,e===void 0?null:e],t},useContext:ri,useEffect:k1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Sh(4194308,4,XC.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Sh(4194308,4,t,e)},useInsertionEffect:function(t,e){return Sh(4,2,t,e)},useMemo:function(t,e){var n=Vi();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Vi();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=eP.bind(null,en,t),[r.memoizedState,t]},useRef:function(t){var e=Vi();return t={current:t},e.memoizedState=t},useState:b1,useDebugValue:sv,useDeferredValue:function(t){return Vi().memoizedState=t},useTransition:function(){var t=b1(!1),e=t[0];return t=ZO.bind(null,t[1]),Vi().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=en,i=Vi();if(Jt){if(n===void 0)throw Error(he(407));n=n()}else{if(n=e(),Pn===null)throw Error(he(349));nl&30||zC(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,k1(HC.bind(null,r,s,t),[t]),r.flags|=2048,wc(9,$C.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=Vi(),e=Pn.identifierPrefix;if(Jt){var n=ks,r=bs;n=(r&~(1<<32-Mi(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=yc++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Wi]=e,t[hc]=r,a2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Rm(n,r),n){case"dialog":Wt("cancel",t),Wt("close",t),i=r;break;case"iframe":case"object":case"embed":Wt("load",t),i=r;break;case"video":case"audio":for(i=0;ika&&(e.flags|=128,r=!0,fu(s,!1),e.lanes=4194304)}else{if(!r)if(t=Yh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),fu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Qt)return jn(e),null}else 2*pn()-s.renderingStartTime>ka&&n!==1073741824&&(e.flags|=128,r=!0,fu(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=pn(),e.sibling=null,n=Zt.current,zt(Zt,r?n&1|2:n&1),e):(jn(e),null);case 22:case 23:return uv(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Mr&1073741824&&(jn(e),e.subtreeFlags&6&&(e.flags|=8192)):jn(e),null;case 24:return null;case 25:return null}throw Error(de(156,e.tag))}function lP(t,e){switch(Wy(e),e.tag){case 1:return yr(e.type)&&Wh(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return xa(),Ut(mr),Ut(Gn),Jy(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Qy(e),null;case 13:if(Ut(Zt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(de(340));va()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Ut(Zt),null;case 4:return xa(),null;case 10:return Xy(e.type._context),null;case 22:case 23:return uv(),null;case 24:return null;default:return null}}var If=!1,Kn=!1,aP=typeof WeakSet=="function"?WeakSet:Set,Oe=null;function Yl(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){sn(t,e,r)}else n.current=null}function n0(t,e,n){try{n()}catch(r){sn(t,e,r)}}var P1=!1;function uP(t,e){if(zm=zh,t=gC(),Hy(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,f=t,h=null;t:for(;;){for(var d;f!==n||i!==0&&f.nodeType!==3||(l=o+i),f!==s||r!==0&&f.nodeType!==3||(a=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(d=f.firstChild)!==null;)h=f,f=d;for(;;){if(f===t)break t;if(h===n&&++u===i&&(l=o),h===s&&++c===r&&(a=o),(d=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=d}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for($m={focusedElem:t,selectionRange:n},zh=!1,Oe=e;Oe!==null;)if(e=Oe,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Oe=t;else for(;Oe!==null;){e=Oe;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var m=p.memoizedProps,x=p.memoizedState,v=e.stateNode,g=v.getSnapshotBeforeUpdate(e.elementType===e.type?m:mi(e.type,m),x);v.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=e.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(de(163))}}catch(k){sn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Oe=t;break}Oe=e.return}return p=P1,P1=!1,p}function $u(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&n0(e,n,s)}i=i.next}while(i!==r)}}function Yd(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function r0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function f2(t){var e=t.alternate;e!==null&&(t.alternate=null,f2(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Wi],delete e[hc],delete e[Wm],delete e[UO],delete e[KO])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function h2(t){return t.tag===5||t.tag===3||t.tag===4}function I1(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||h2(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function i0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=jh));else if(r!==4&&(t=t.child,t!==null))for(i0(t,e,n),t=t.sibling;t!==null;)i0(t,e,n),t=t.sibling}function s0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(s0(t,e,n),t=t.sibling;t!==null;)s0(t,e,n),t=t.sibling}var Pn=null,yi=!1;function $s(t,e,n){for(n=n.child;n!==null;)d2(t,e,n),n=n.sibling}function d2(t,e,n){if(Zi&&typeof Zi.onCommitFiberUnmount=="function")try{Zi.onCommitFiberUnmount(jd,n)}catch{}switch(n.tag){case 5:Kn||Yl(n,e);case 6:var r=Pn,i=yi;Pn=null,$s(t,e,n),Pn=r,yi=i,Pn!==null&&(yi?(t=Pn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Pn.removeChild(n.stateNode));break;case 18:Pn!==null&&(yi?(t=Pn,n=n.stateNode,t.nodeType===8?dg(t.parentNode,n):t.nodeType===1&&dg(t,n),lc(t)):dg(Pn,n.stateNode));break;case 4:r=Pn,i=yi,Pn=n.stateNode.containerInfo,yi=!0,$s(t,e,n),Pn=r,yi=i;break;case 0:case 11:case 14:case 15:if(!Kn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&n0(n,e,o),i=i.next}while(i!==r)}$s(t,e,n);break;case 1:if(!Kn&&(Yl(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){sn(n,e,l)}$s(t,e,n);break;case 21:$s(t,e,n);break;case 22:n.mode&1?(Kn=(r=Kn)||n.memoizedState!==null,$s(t,e,n),Kn=r):$s(t,e,n);break;default:$s(t,e,n)}}function D1(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new aP),e.forEach(function(r){var i=vP.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function di(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=pn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*fP(r/1960))-r,10t?16:t,io===null)var r=!1;else{if(t=io,io=null,td=0,bt&6)throw Error(de(331));var i=bt;for(bt|=4,Oe=t.current;Oe!==null;){var s=Oe,o=s.child;if(Oe.flags&16){var l=s.deletions;if(l!==null){for(var a=0;apn()-lv?Qo(t,0):ov|=n),vr(t,e)}function b2(t,e){e===0&&(t.mode&1?(e=Sf,Sf<<=1,!(Sf&130023424)&&(Sf=4194304)):e=1);var n=ir();t=As(t,e),t!==null&&(Pc(t,e,n),vr(t,n))}function yP(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),b2(t,n)}function vP(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(de(314))}r!==null&&r.delete(e),b2(t,n)}var k2;k2=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||mr.current)pr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return pr=!1,sP(t,e,n);pr=!!(t.flags&131072)}else pr=!1,Qt&&e.flags&1048576&&EC(e,Kh,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;kh(t,e),t=e.pendingProps;var i=ya(e,Gn.current);aa(e,n),i=ev(null,e,r,t,i,n);var s=tv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,yr(r)?(s=!0,Vh(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,qy(e),i.updater=qd,e.stateNode=i,i._reactInternals=e,qm(e,r,t,n),e=Jm(null,e,r,!0,s,n)):(e.tag=0,Qt&&s&&jy(e),nr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(kh(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=xP(r),t=mi(r,t),i){case 0:e=Qm(null,e,r,t,n);break e;case 1:e=A1(null,e,r,t,n);break e;case 11:e=E1(null,e,r,t,n);break e;case 14:e=M1(null,e,r,mi(r.type,t),n);break e}throw Error(de(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:mi(r,i),Qm(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:mi(r,i),A1(t,e,r,i,n);case 3:e:{if(s2(e),t===null)throw Error(de(387));r=e.pendingProps,s=e.memoizedState,i=s.element,IC(t,e),qh(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=ba(Error(de(423)),e),e=R1(t,e,r,n,i);break e}else if(r!==i){i=ba(Error(de(424)),e),e=R1(t,e,r,n,i);break e}else for(Dr=co(e.stateNode.containerInfo.firstChild),_r=e,Qt=!0,vi=null,n=OC(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(va(),r===i){e=Rs(t,e,n);break e}nr(t,e,r,n)}e=e.child}return e;case 5:return DC(e),t===null&&Km(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,Hm(r,i)?o=null:s!==null&&Hm(r,s)&&(e.flags|=32),i2(t,e),nr(t,e,o,n),e.child;case 6:return t===null&&Km(e),null;case 13:return o2(t,e,n);case 4:return Yy(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=wa(e,null,r,n):nr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:mi(r,i),E1(t,e,r,i,n);case 7:return nr(t,e,e.pendingProps,n),e.child;case 8:return nr(t,e,e.pendingProps.children,n),e.child;case 12:return nr(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,zt(Xh,r._currentValue),r._currentValue=o,s!==null)if(Mi(s.value,o)){if(s.children===i.children&&!mr.current){e=Rs(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(s.tag===1){a=Cs(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Xm(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(de(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Xm(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}nr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,aa(e,n),i=ti(i),r=r(i),e.flags|=1,nr(t,e,r,n),e.child;case 14:return r=e.type,i=mi(r,e.pendingProps),i=mi(r.type,i),M1(t,e,r,i,n);case 15:return n2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:mi(r,i),kh(t,e),e.tag=1,yr(r)?(t=!0,Vh(e)):t=!1,aa(e,n),ZC(e,r,i),qm(e,r,i,n),Jm(null,e,r,!0,t,n);case 19:return l2(t,e,n);case 22:return r2(t,e,n)}throw Error(de(156,e.tag))};function S2(t,e){return YS(t,e)}function wP(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xr(t,e,n,r){return new wP(t,e,n,r)}function fv(t){return t=t.prototype,!(!t||!t.isReactComponent)}function xP(t){if(typeof t=="function")return fv(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Oy)return 11;if(t===Py)return 14}return 2}function go(t,e){var n=t.alternate;return n===null?(n=Xr(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Th(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")fv(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Hl:return Jo(n.children,i,s,e);case Ry:o=8,i|=8;break;case wm:return t=Xr(12,n,e,i|2),t.elementType=wm,t.lanes=s,t;case xm:return t=Xr(13,n,e,i),t.elementType=xm,t.lanes=s,t;case bm:return t=Xr(19,n,e,i),t.elementType=bm,t.lanes=s,t;case DS:return Jd(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case PS:o=10;break e;case IS:o=9;break e;case Oy:o=11;break e;case Py:o=14;break e;case Gs:o=16,r=null;break e}throw Error(de(130,t==null?t:typeof t,""))}return e=Xr(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Jo(t,e,n,r){return t=Xr(7,t,r,e),t.lanes=n,t}function Jd(t,e,n,r){return t=Xr(22,t,r,e),t.elementType=DS,t.lanes=n,t.stateNode={isHidden:!1},t}function bg(t,e,n){return t=Xr(6,t,null,e),t.lanes=n,t}function kg(t,e,n){return e=Xr(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function bP(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ng(0),this.expirationTimes=ng(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ng(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function hv(t,e,n,r,i,s,o,l,a){return t=new bP(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Xr(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},qy(s),t}function kP(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(M2)}catch(t){console.error(t)}}M2(),MS.exports=Lr;var MP=MS.exports,A2,H1=MP;A2=H1.createRoot,H1.hydrateRoot;function R2(){return""}function AP(){return/^G-[A-Z0-9]+$/.test(R2())}function RP(){const t=window.gtag;typeof t=="function"&&AP()&&t("config",R2(),{send_page_view:!1})}function OP(){var t,e;(t=window.gtag)==null||t.call(window,"event","page_view",{page_path:window.location.pathname,page_location:window.location.href}),(e=window.plausible)==null||e.call(window,"pageview")}function PP(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function IP(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function DP(t){var e,n;(e=window.gtag)==null||e.call(window,"event","changelog_vote",{...t}),(n=window.plausible)==null||n.call(window,"Changelog Vote",{props:{...t}})}function _P(t){return t.charAt(0).toUpperCase()+t.slice(1)}function mv(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,_P(t),{props:{...e}})}function NP(t){mv("conversion",t)}function Nf(t){mv("export",t)}function LP(t){mv("feedback",t)}function FP(t){return new TextEncoder().encode(t).length}function BP(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function zP(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function $P(t={}){const e=t.settleMs??2e3,n=t.minWindowMs??2e3,r=t.now??(()=>Date.now()),i=t.isValid??(()=>!0);let s=null,o,l=null,a=0;function u(f){if(f.text.trim()==="")return!1;const h=FP(f.text),d=`${f.direction}:${f.input}:${h}:${zP(f.text)}`;if(d===l||!i(f.direction,f.text))return!1;const p=r();return p-a{o=void 0,s&&u(s)},e)}return{edit(f,h){s={direction:f,input:"paste",text:h},c()},discrete(f,h,d){s={direction:f,input:h,text:d},c(),u(s)},cancel(){s=null,l=null,o&&(clearTimeout(o),o=void 0)}}}/** +`+s.stack}return{value:t,source:e,stack:i,digest:null}}function bg(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Qm(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var sP=typeof WeakMap=="function"?WeakMap:Map;function r2(t,e,n){n=Cs(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){nd||(nd=!0,l0=r),Qm(t,e)},n}function i2(t,e,n){n=Cs(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){Qm(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Qm(t,e),typeof r!="function"&&(ho===null?ho=new Set([this]):ho.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function T1(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new sP;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=wP.bind(null,t,e,n),e.then(t,t))}function E1(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function M1(t,e,n,r,i){return t.mode&1?(t.flags|=65536,t.lanes=i,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Cs(-1,1),e.tag=2,fo(n,e,1))),n.lanes|=1),t)}var oP=Ps.ReactCurrentOwner,mr=!1;function ir(t,e,n,r){e.child=t===null?DC(e,null,n,r):wa(e,t.child,n,r)}function A1(t,e,n,r,i){n=n.render;var s=e.ref;return aa(e,i),r=nv(t,e,n,r,s,i),n=rv(),t!==null&&!mr?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Rs(t,e,i)):(Jt&&n&&Vy(e),e.flags|=1,ir(t,e,r,i),e.child)}function R1(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!dv(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,s2(t,e,s,r,i)):(t=Mh(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,!(t.lanes&i)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:fc,n(o,r)&&t.ref===e.ref)return Rs(t,e,i)}return e.flags|=1,t=go(s,r),t.ref=e.ref,t.return=e,e.child=t}function s2(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(fc(s,r)&&t.ref===e.ref)if(mr=!1,e.pendingProps=r=s,(t.lanes&i)!==0)t.flags&131072&&(mr=!0);else return e.lanes=t.lanes,Rs(t,e,i)}return Jm(t,e,n,r,i)}function o2(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ht(Ql,Ar),Ar|=n;else{if(!(n&1073741824))return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,Ht(Ql,Ar),Ar|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Ht(Ql,Ar),Ar|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,Ht(Ql,Ar),Ar|=r;return ir(t,e,i,n),e.child}function l2(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Jm(t,e,n,r,i){var s=wr(n)?el:Zn.current;return s=ya(e,s),aa(e,i),n=nv(t,e,n,r,s,i),r=rv(),t!==null&&!mr?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Rs(t,e,i)):(Jt&&r&&Vy(e),e.flags|=1,ir(t,e,n,i),e.child)}function O1(t,e,n,r,i){if(wr(n)){var s=!0;Kh(e)}else s=!1;if(aa(e,i),e.stateNode===null)Ch(t,e),n2(e,n,r),Ym(e,n,r,i),r=!0;else if(t===null){var o=e.stateNode,l=e.memoizedProps;o.props=l;var a=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=ri(u):(u=wr(n)?el:Zn.current,u=ya(e,u));var c=n.getDerivedStateFromProps,f=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";f||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||a!==u)&&C1(e,o,r,u),qs=!1;var h=e.memoizedState;o.state=h,Qh(e,r,o,i),a=e.memoizedState,l!==r||h!==a||vr.current||qs?(typeof c=="function"&&(qm(e,n,c,r),a=e.memoizedState),(l=qs||S1(e,n,l,r,h,a,u))?(f||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=a),o.props=r,o.state=a,o.context=u,r=l):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,NC(t,e),l=e.memoizedProps,u=e.type===e.elementType?l:vi(e.type,l),o.props=u,f=e.pendingProps,h=o.context,a=n.contextType,typeof a=="object"&&a!==null?a=ri(a):(a=wr(n)?el:Zn.current,a=ya(e,a));var d=n.getDerivedStateFromProps;(c=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==f||h!==a)&&C1(e,o,r,a),qs=!1,h=e.memoizedState,o.state=h,Qh(e,r,o,i);var p=e.memoizedState;l!==f||h!==p||vr.current||qs?(typeof d=="function"&&(qm(e,n,d,r),p=e.memoizedState),(u=qs||S1(e,n,u,r,h,p,a)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,p,a),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,p,a)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&h===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&h===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=p),o.props=r,o.state=p,o.context=a,r=u):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&h===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&h===t.memoizedState||(e.flags|=1024),r=!1)}return Zm(t,e,n,r,s,i)}function Zm(t,e,n,r,i,s){l2(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&g1(e,n,!1),Rs(t,e,s);r=e.stateNode,oP.current=e;var l=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=wa(e,t.child,null,s),e.child=wa(e,null,l,s)):ir(t,e,l,s),e.memoizedState=r.state,i&&g1(e,n,!0),e.child}function a2(t){var e=t.stateNode;e.pendingContext?p1(t,e.pendingContext,e.pendingContext!==e.context):e.context&&p1(t,e.context,!1),Jy(t,e.containerInfo)}function P1(t,e,n,r,i){return va(),Ky(i),e.flags|=256,ir(t,e,n,r),e.child}var e0={dehydrated:null,treeContext:null,retryLane:0};function t0(t){return{baseLanes:t,cachePool:null,transitions:null}}function u2(t,e,n){var r=e.pendingProps,i=Zt.current,s=!1,o=(e.flags&128)!==0,l;if((l=o)||(l=t!==null&&t.memoizedState===null?!1:(i&2)!==0),l?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),Ht(Zt,i&1),t===null)return Xm(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,t=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=ep(o,r,0,null),t=Jo(t,r,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=t0(n),e.memoizedState=e0,t):ov(e,o));if(i=t.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return lP(t,e,o,r,l,i,n);if(s){s=r.fallback,o=e.mode,i=t.child,l=i.sibling;var a={mode:"hidden",children:r.children};return!(o&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=a,e.deletions=null):(r=go(i,a),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?s=go(l,s):(s=Jo(s,o,n,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=t.child.memoizedState,o=o===null?t0(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=e0,r}return s=t.child,t=s.sibling,r=go(s,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function ov(t,e){return e=ep({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Df(t,e,n,r){return r!==null&&Ky(r),wa(e,t.child,null,n),t=ov(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function lP(t,e,n,r,i,s,o){if(n)return e.flags&256?(e.flags&=-257,r=bg(Error(he(422))),Df(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=ep({mode:"visible",children:r.children},i,0,null),s=Jo(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,e.mode&1&&wa(e,t.child,null,o),e.child.memoizedState=t0(o),e.memoizedState=e0,s);if(!(e.mode&1))return Df(t,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,s=Error(he(419)),r=bg(s,r,void 0),Df(t,e,o,r)}if(l=(o&t.childLanes)!==0,mr||l){if(r=Pn,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,As(t,i),Ai(r,t,i,-1))}return hv(),r=bg(Error(he(421))),Df(t,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=xP.bind(null,t),i._reactRetry=e,null):(t=s.treeContext,_r=co(i.nextSibling),Nr=e,Jt=!0,xi=null,t!==null&&(Kr[Xr++]=bs,Kr[Xr++]=ks,Kr[Xr++]=tl,bs=t.id,ks=t.overflow,tl=e),e=ov(e,r.children),e.flags|=4096,e)}function I1(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),Gm(t.return,e,n)}function kg(t,e,n,r,i){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function c2(t,e,n){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(ir(t,e,r.children,n),r=Zt.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&I1(t,n,e);else if(t.tag===19)I1(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(Ht(Zt,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&Jh(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),kg(e,!1,i,n,s);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&Jh(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}kg(e,!0,n,null,s);break;case"together":kg(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Ch(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Rs(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),rl|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(he(153));if(e.child!==null){for(t=e.child,n=go(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=go(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function aP(t,e,n){switch(e.tag){case 3:a2(e),va();break;case 5:LC(e);break;case 1:wr(e.type)&&Kh(e);break;case 4:Jy(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;Ht(qh,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(Ht(Zt,Zt.current&1),e.flags|=128,null):n&e.child.childLanes?u2(t,e,n):(Ht(Zt,Zt.current&1),t=Rs(t,e,n),t!==null?t.sibling:null);Ht(Zt,Zt.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return c2(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ht(Zt,Zt.current),r)break;return null;case 22:case 23:return e.lanes=0,o2(t,e,n)}return Rs(t,e,n)}var f2,n0,h2,d2;f2=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};n0=function(){};h2=function(t,e,n,r){var i=t.memoizedProps;if(i!==r){t=e.stateNode,qo(ns.current);var s=null;switch(n){case"input":i=Cm(t,i),r=Cm(t,r),s=[];break;case"select":i=tn({},i,{value:void 0}),r=tn({},r,{value:void 0}),s=[];break;case"textarea":i=Mm(t,i),r=Mm(t,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Vh)}Rm(n,r);var o;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(ic.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var a=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&a!==l&&(a!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||a&&a.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in a)a.hasOwnProperty(o)&&l[o]!==a[o]&&(n||(n={}),n[o]=a[o])}else n||(s||(s=[]),s.push(u,n)),n=a;else u==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,l=l?l.__html:void 0,a!=null&&l!==a&&(s=s||[]).push(u,a)):u==="children"?typeof a!="string"&&typeof a!="number"||(s=s||[]).push(u,""+a):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(ic.hasOwnProperty(u)?(a!=null&&u==="onScroll"&&Ut("scroll",t),s||l===a||(s=[])):(s=s||[]).push(u,a))}n&&(s=s||[]).push("style",n);var u=s;(e.updateQueue=u)&&(e.flags|=4)}};d2=function(t,e,n,r){n!==r&&(e.flags|=4)};function fu(t,e){if(!Jt)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function Xn(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function uP(t,e,n){var r=e.pendingProps;switch(Uy(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xn(e),null;case 1:return wr(e.type)&&Uh(),Xn(e),null;case 3:return r=e.stateNode,xa(),Xt(vr),Xt(Zn),ev(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Pf(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,xi!==null&&(c0(xi),xi=null))),n0(t,e),Xn(e),null;case 5:Zy(e);var i=qo(mc.current);if(n=e.type,t!==null&&e.stateNode!=null)h2(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(he(166));return Xn(e),null}if(t=qo(ns.current),Pf(e)){r=e.stateNode,n=e.type;var s=e.memoizedProps;switch(r[Ui]=e,r[pc]=s,t=(e.mode&1)!==0,n){case"dialog":Ut("cancel",r),Ut("close",r);break;case"iframe":case"object":case"embed":Ut("load",r);break;case"video":case"audio":for(i=0;i<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Ui]=e,t[pc]=r,f2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Om(n,r),n){case"dialog":Ut("cancel",t),Ut("close",t),i=r;break;case"iframe":case"object":case"embed":Ut("load",t),i=r;break;case"video":case"audio":for(i=0;ika&&(e.flags|=128,r=!0,fu(s,!1),e.lanes=4194304)}else{if(!r)if(t=Jh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),fu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Jt)return Xn(e),null}else 2*mn()-s.renderingStartTime>ka&&n!==1073741824&&(e.flags|=128,r=!0,fu(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=mn(),e.sibling=null,n=Zt.current,Ht(Zt,r?n&1|2:n&1),e):(Xn(e),null);case 22:case 23:return fv(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ar&1073741824&&(Xn(e),e.subtreeFlags&6&&(e.flags|=8192)):Xn(e),null;case 24:return null;case 25:return null}throw Error(he(156,e.tag))}function cP(t,e){switch(Uy(e),e.tag){case 1:return wr(e.type)&&Uh(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return xa(),Xt(vr),Xt(Zn),ev(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Zy(e),null;case 13:if(Xt(Zt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(he(340));va()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Xt(Zt),null;case 4:return xa(),null;case 10:return qy(e.type._context),null;case 22:case 23:return fv(),null;case 24:return null;default:return null}}var _f=!1,Qn=!1,fP=typeof WeakSet=="function"?WeakSet:Set,Oe=null;function Yl(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){sn(t,e,r)}else n.current=null}function r0(t,e,n){try{n()}catch(r){sn(t,e,r)}}var D1=!1;function hP(t,e){if($m=Hh,t=vC(),Wy(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,f=t,h=null;t:for(;;){for(var d;f!==n||i!==0&&f.nodeType!==3||(l=o+i),f!==s||r!==0&&f.nodeType!==3||(a=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(d=f.firstChild)!==null;)h=f,f=d;for(;;){if(f===t)break t;if(h===n&&++u===i&&(l=o),h===s&&++c===r&&(a=o),(d=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=d}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(Hm={focusedElem:t,selectionRange:n},Hh=!1,Oe=e;Oe!==null;)if(e=Oe,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Oe=t;else for(;Oe!==null;){e=Oe;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var m=p.memoizedProps,x=p.memoizedState,v=e.stateNode,g=v.getSnapshotBeforeUpdate(e.elementType===e.type?m:vi(e.type,m),x);v.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=e.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(he(163))}}catch(k){sn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Oe=t;break}Oe=e.return}return p=D1,D1=!1,p}function Hu(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&r0(e,n,s)}i=i.next}while(i!==r)}}function Jd(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function i0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function p2(t){var e=t.alternate;e!==null&&(t.alternate=null,p2(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Ui],delete e[pc],delete e[Vm],delete e[GO],delete e[qO])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function g2(t){return t.tag===5||t.tag===3||t.tag===4}function _1(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||g2(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function s0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Vh));else if(r!==4&&(t=t.child,t!==null))for(s0(t,e,n),t=t.sibling;t!==null;)s0(t,e,n),t=t.sibling}function o0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(o0(t,e,n),t=t.sibling;t!==null;)o0(t,e,n),t=t.sibling}var Ln=null,wi=!1;function $s(t,e,n){for(n=n.child;n!==null;)m2(t,e,n),n=n.sibling}function m2(t,e,n){if(ts&&typeof ts.onCommitFiberUnmount=="function")try{ts.onCommitFiberUnmount(Vd,n)}catch{}switch(n.tag){case 5:Qn||Yl(n,e);case 6:var r=Ln,i=wi;Ln=null,$s(t,e,n),Ln=r,wi=i,Ln!==null&&(wi?(t=Ln,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Ln.removeChild(n.stateNode));break;case 18:Ln!==null&&(wi?(t=Ln,n=n.stateNode,t.nodeType===8?gg(t.parentNode,n):t.nodeType===1&&gg(t,n),uc(t)):gg(Ln,n.stateNode));break;case 4:r=Ln,i=wi,Ln=n.stateNode.containerInfo,wi=!0,$s(t,e,n),Ln=r,wi=i;break;case 0:case 11:case 14:case 15:if(!Qn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&r0(n,e,o),i=i.next}while(i!==r)}$s(t,e,n);break;case 1:if(!Qn&&(Yl(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){sn(n,e,l)}$s(t,e,n);break;case 21:$s(t,e,n);break;case 22:n.mode&1?(Qn=(r=Qn)||n.memoizedState!==null,$s(t,e,n),Qn=r):$s(t,e,n);break;default:$s(t,e,n)}}function N1(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new fP),e.forEach(function(r){var i=bP.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function gi(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=mn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*pP(r/1960))-r,10t?16:t,io===null)var r=!1;else{if(t=io,io=null,rd=0,Tt&6)throw Error(he(331));var i=Tt;for(Tt|=4,Oe=t.current;Oe!==null;){var s=Oe,o=s.child;if(Oe.flags&16){var l=s.deletions;if(l!==null){for(var a=0;amn()-uv?Qo(t,0):av|=n),xr(t,e)}function C2(t,e){e===0&&(t.mode&1?(e=Tf,Tf<<=1,!(Tf&130023424)&&(Tf=4194304)):e=1);var n=or();t=As(t,e),t!==null&&(Dc(t,e,n),xr(t,n))}function xP(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),C2(t,n)}function bP(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(he(314))}r!==null&&r.delete(e),C2(t,n)}var T2;T2=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||vr.current)mr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return mr=!1,aP(t,e,n);mr=!!(t.flags&131072)}else mr=!1,Jt&&e.flags&1048576&&RC(e,Gh,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Ch(t,e),t=e.pendingProps;var i=ya(e,Zn.current);aa(e,n),i=nv(null,e,r,t,i,n);var s=rv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,wr(r)?(s=!0,Kh(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Qy(e),i.updater=Qd,e.stateNode=i,i._reactInternals=e,Ym(e,r,t,n),e=Zm(null,e,r,!0,s,n)):(e.tag=0,Jt&&s&&Vy(e),ir(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Ch(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=SP(r),t=vi(r,t),i){case 0:e=Jm(null,e,r,t,n);break e;case 1:e=O1(null,e,r,t,n);break e;case 11:e=A1(null,e,r,t,n);break e;case 14:e=R1(null,e,r,vi(r.type,t),n);break e}throw Error(he(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:vi(r,i),Jm(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:vi(r,i),O1(t,e,r,i,n);case 3:e:{if(a2(e),t===null)throw Error(he(387));r=e.pendingProps,s=e.memoizedState,i=s.element,NC(t,e),Qh(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=ba(Error(he(423)),e),e=P1(t,e,r,n,i);break e}else if(r!==i){i=ba(Error(he(424)),e),e=P1(t,e,r,n,i);break e}else for(_r=co(e.stateNode.containerInfo.firstChild),Nr=e,Jt=!0,xi=null,n=DC(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(va(),r===i){e=Rs(t,e,n);break e}ir(t,e,r,n)}e=e.child}return e;case 5:return LC(e),t===null&&Xm(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,jm(r,i)?o=null:s!==null&&jm(r,s)&&(e.flags|=32),l2(t,e),ir(t,e,o,n),e.child;case 6:return t===null&&Xm(e),null;case 13:return u2(t,e,n);case 4:return Jy(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=wa(e,null,r,n):ir(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:vi(r,i),A1(t,e,r,i,n);case 7:return ir(t,e,e.pendingProps,n),e.child;case 8:return ir(t,e,e.pendingProps.children,n),e.child;case 12:return ir(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,Ht(qh,r._currentValue),r._currentValue=o,s!==null)if(Ri(s.value,o)){if(s.children===i.children&&!vr.current){e=Rs(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(s.tag===1){a=Cs(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Gm(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(he(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Gm(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ir(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,aa(e,n),i=ri(i),r=r(i),e.flags|=1,ir(t,e,r,n),e.child;case 14:return r=e.type,i=vi(r,e.pendingProps),i=vi(r.type,i),R1(t,e,r,i,n);case 15:return s2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:vi(r,i),Ch(t,e),e.tag=1,wr(r)?(t=!0,Kh(e)):t=!1,aa(e,n),n2(e,r,i),Ym(e,r,i,n),Zm(null,e,r,!0,t,n);case 19:return c2(t,e,n);case 22:return o2(t,e,n)}throw Error(he(156,e.tag))};function E2(t,e){return ZS(t,e)}function kP(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qr(t,e,n,r){return new kP(t,e,n,r)}function dv(t){return t=t.prototype,!(!t||!t.isReactComponent)}function SP(t){if(typeof t=="function")return dv(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Iy)return 11;if(t===Dy)return 14}return 2}function go(t,e){var n=t.alternate;return n===null?(n=qr(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Mh(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")dv(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Hl:return Jo(n.children,i,s,e);case Py:o=8,i|=8;break;case xm:return t=qr(12,n,e,i|2),t.elementType=xm,t.lanes=s,t;case bm:return t=qr(13,n,e,i),t.elementType=bm,t.lanes=s,t;case km:return t=qr(19,n,e,i),t.elementType=km,t.lanes=s,t;case LS:return ep(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _S:o=10;break e;case NS:o=9;break e;case Iy:o=11;break e;case Dy:o=14;break e;case Gs:o=16,r=null;break e}throw Error(he(130,t==null?t:typeof t,""))}return e=qr(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Jo(t,e,n,r){return t=qr(7,t,r,e),t.lanes=n,t}function ep(t,e,n,r){return t=qr(22,t,r,e),t.elementType=LS,t.lanes=n,t.stateNode={isHidden:!1},t}function Sg(t,e,n){return t=qr(6,t,null,e),t.lanes=n,t}function Cg(t,e,n){return e=qr(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function CP(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ig(0),this.expirationTimes=ig(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ig(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function pv(t,e,n,r,i,s,o,l,a){return t=new CP(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=qr(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qy(s),t}function TP(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(O2)}catch(t){console.error(t)}}O2(),OS.exports=Fr;var OP=OS.exports,P2,W1=OP;P2=W1.createRoot,W1.hydrateRoot;function I2(){return""}function PP(){return/^G-[A-Z0-9]+$/.test(I2())}function IP(){const t=window.gtag;typeof t=="function"&&PP()&&t("config",I2(),{send_page_view:!1})}function DP(){var t,e;(t=window.gtag)==null||t.call(window,"event","page_view",{page_path:window.location.pathname,page_location:window.location.href}),(e=window.plausible)==null||e.call(window,"pageview")}function _P(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function NP(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function LP(t){var e,n;(e=window.gtag)==null||e.call(window,"event","changelog_vote",{...t}),(n=window.plausible)==null||n.call(window,"Changelog Vote",{props:{...t}})}function FP(t){return t.charAt(0).toUpperCase()+t.slice(1)}function vv(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,FP(t),{props:{...e}})}function BP(t){vv("conversion",t)}function Ff(t){vv("export",t)}function zP(t){vv("feedback",t)}function $P(t){return new TextEncoder().encode(t).length}function HP(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function jP(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function WP(t={}){const e=t.settleMs??2e3,n=t.minWindowMs??2e3,r=t.now??(()=>Date.now()),i=t.isValid??(()=>!0);let s=null,o,l=null,a=0;function u(f){if(f.text.trim()==="")return!1;const h=$P(f.text),d=`${f.direction}:${f.input}:${h}:${jP(f.text)}`;if(d===l||!i(f.direction,f.text))return!1;const p=r();return p-a{o=void 0,s&&u(s)},e)}return{edit(f,h){s={direction:f,input:"paste",text:h},c()},discrete(f,h,d){s={direction:f,input:h,text:d},c(),u(s)},cancel(){s=null,l=null,o&&(clearTimeout(o),o=void 0)}}}/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const O2=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** + */const D2=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const HP=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + */const VP=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const jP=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** + */const UP=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const j1=t=>{const e=jP(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** + */const V1=t=>{const e=UP(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */var Sg={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"};/** + */var Tg={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 v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const WP=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},VP=w.createContext({}),UP=()=>w.useContext(VP),KP=w.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>{const{size:u=24,strokeWidth:c=2,absoluteStrokeWidth:f=!1,color:h="currentColor",className:d=""}=UP()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return w.createElement("svg",{ref:a,...Sg,width:e??u??Sg.width,height:e??u??Sg.height,stroke:t??h,strokeWidth:p,className:O2("lucide",d,i),...!s&&!WP(l)&&{"aria-hidden":"true"},...l},[...o.map(([m,x])=>w.createElement(m,x)),...Array.isArray(s)?s:[s]])});/** + */const KP=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},XP=w.createContext({}),GP=()=>w.useContext(XP),qP=w.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>{const{size:u=24,strokeWidth:c=2,absoluteStrokeWidth:f=!1,color:h="currentColor",className:d=""}=GP()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return w.createElement("svg",{ref:a,...Tg,width:e??u??Tg.width,height:e??u??Tg.height,stroke:t??h,strokeWidth:p,className:D2("lucide",d,i),...!s&&!KP(l)&&{"aria-hidden":"true"},...l},[...o.map(([m,x])=>w.createElement(m,x)),...Array.isArray(s)?s:[s]])});/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Fn=(t,e)=>{const n=w.forwardRef(({className:r,...i},s)=>w.createElement(KP,{ref:s,iconNode:e,className:O2(`lucide-${HP(j1(t))}`,`lucide-${t}`,r),...i}));return n.displayName=j1(t),n};/** + */const jn=(t,e)=>{const n=w.forwardRef(({className:r,...i},s)=>w.createElement(qP,{ref:s,iconNode:e,className:D2(`lucide-${VP(V1(t))}`,`lucide-${t}`,r),...i}));return n.displayName=V1(t),n};/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const XP=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],GP=Fn("arrow-left-right",XP);/** + */const YP=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],QP=jn("arrow-left-right",YP);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const qP=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],YP=Fn("braces",qP);/** + */const JP=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],ZP=jn("braces",JP);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const QP=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],JP=Fn("clipboard",QP);/** + */const eI=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],tI=jn("clipboard",eI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ZP=[["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"}]],yv=Fn("copy",ZP);/** + */const nI=[["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"}]],wv=jn("copy",nI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const eI=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],P2=Fn("download",eI);/** + */const rI=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],_2=jn("download",rI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const tI=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],I2=Fn("file-up",tI);/** + */const iI=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],N2=jn("file-up",iI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const nI=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],rI=Fn("moon",nI);/** + */const sI=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],oI=jn("moon",sI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const iI=[["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"}]],sI=Fn("rotate-ccw-clock",iI);/** + */const lI=[["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"}]],aI=jn("rotate-ccw-clock",lI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const oI=[["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"}]],W1=Fn("rotate-ccw",oI);/** + */const uI=[["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"}]],U1=jn("rotate-ccw",uI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const lI=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],aI=Fn("search",lI);/** + */const cI=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],fI=jn("search",cI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const uI=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],cI=Fn("sparkles",uI);/** + */const hI=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],dI=jn("sparkles",hI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const fI=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],hI=Fn("sun",fI);/** + */const pI=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],gI=jn("sun",pI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const dI=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],pI=Fn("table",dI);/** + */const mI=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],yI=jn("table",mI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const gI=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],mI=Fn("thumbs-down",gI);/** + */const vI=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],wI=jn("thumbs-down",vI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const yI=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],vI=Fn("thumbs-up",yI);/** + */const xI=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],bI=jn("thumbs-up",xI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const wI=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],xI=Fn("trash",wI);/** + */const kI=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],f0=jn("trash",kI);/** * @license lucide-react v1.41.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const bI=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],D2=Fn("x",bI);function _2(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=TI(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(vv);return l[0]===""&&l.length!==1&&l.shift(),N2(l,e)||CI(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},N2=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?N2(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(vv);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},V1=/^\[(.+)\]$/,CI=t=>{if(V1.test(t)){const e=V1.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},TI=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return MI(Object.entries(t.classGroups),n).forEach(([s,o])=>{c0(o,r,s,e)}),r},c0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:U1(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(EI(i)){c0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{c0(o,U1(e,s),n,r)})})},U1=(t,e)=>{let n=t;return e.split(vv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},EI=t=>t.isThemeGetter,MI=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[e+o,l])):s);return[n,i]}):t,AI=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},L2="!",RI=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=l=>{const a=[];let u=0,c=0,f;for(let x=0;xc?f-c:void 0;return{modifiers:a,hasImportantModifier:d,baseClassName:p,maybePostfixModifierPosition:m}};return n?l=>n({className:l,parseClassName:o}):o},OI=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},PI=t=>({cache:AI(t.cacheSize),parseClassName:RI(t),...SI(t)}),II=/\s+/,DI=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(II);let l="";for(let a=o.length-1;a>=0;a-=1){const u=o[a],{modifiers:c,hasImportantModifier:f,baseClassName:h,maybePostfixModifierPosition:d}=n(u);let p=!!d,m=r(p?h.substring(0,d):h);if(!m){if(!p){l=u+(l.length>0?" "+l:l);continue}if(m=r(h),!m){l=u+(l.length>0?" "+l:l);continue}p=!1}const x=OI(c).join(":"),v=f?x+L2:x,g=v+m;if(s.includes(g))continue;s.push(g);const y=i(m,p);for(let k=0;k0?" "+l:l)}return l};function _I(){let t=0,e,n,r="";for(;t{if(typeof t=="string")return t;let e,n="";for(let r=0;rf(c),t());return n=PI(u),r=n.cache.get,i=n.cache.set,s=l,l(a)}function l(a){const u=r(a);if(u)return u;const c=DI(a,n);return i(a,c),c}return function(){return s(_I.apply(null,arguments))}}const jt=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},B2=/^\[(?:([a-z-]+):)?(.+)\]$/i,LI=/^\d+\/\d+$/,FI=new Set(["px","full","screen"]),BI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,zI=/\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$/,$I=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,HI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,jI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ds=t=>ca(t)||FI.has(t)||LI.test(t),Hs=t=>Ba(t,"length",YI),ca=t=>!!t&&!Number.isNaN(Number(t)),Cg=t=>Ba(t,"number",ca),du=t=>!!t&&Number.isInteger(Number(t)),WI=t=>t.endsWith("%")&&ca(t.slice(0,-1)),st=t=>B2.test(t),js=t=>BI.test(t),VI=new Set(["length","size","percentage"]),UI=t=>Ba(t,VI,z2),KI=t=>Ba(t,"position",z2),XI=new Set(["image","url"]),GI=t=>Ba(t,XI,JI),qI=t=>Ba(t,"",QI),pu=()=>!0,Ba=(t,e,n)=>{const r=B2.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},YI=t=>zI.test(t)&&!$I.test(t),z2=()=>!1,QI=t=>HI.test(t),JI=t=>jI.test(t),ZI=()=>{const t=jt("colors"),e=jt("spacing"),n=jt("blur"),r=jt("brightness"),i=jt("borderColor"),s=jt("borderRadius"),o=jt("borderSpacing"),l=jt("borderWidth"),a=jt("contrast"),u=jt("grayscale"),c=jt("hueRotate"),f=jt("invert"),h=jt("gap"),d=jt("gradientColorStops"),p=jt("gradientColorStopPositions"),m=jt("inset"),x=jt("margin"),v=jt("opacity"),g=jt("padding"),y=jt("saturate"),k=jt("scale"),b=jt("sepia"),C=jt("skew"),T=jt("space"),E=jt("translate"),A=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",st,e],O=()=>[st,e],_=()=>["",ds,Hs],I=()=>["auto",ca,st],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],te=()=>["","0",st],G=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>[ca,st];return{cacheSize:500,separator:":",theme:{colors:[pu],spacing:[ds,Hs],blur:["none","",js,st],brightness:M(),borderColor:[t],borderRadius:["none","","full",js,st],borderSpacing:O(),borderWidth:_(),contrast:M(),grayscale:te(),hueRotate:M(),invert:te(),gap:O(),gradientColorStops:[t],gradientColorStopPositions:[WI,Hs],inset:D(),margin:D(),opacity:M(),padding:O(),saturate:M(),scale:M(),sepia:te(),skew:M(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",st]}],container:["container"],columns:[{columns:[js]}],"break-after":[{"break-after":G()}],"break-before":[{"break-before":G()}],"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:[...Y(),st]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",du,st]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",st]}],grow:[{grow:te()}],shrink:[{shrink:te()}],order:[{order:["first","last","none",du,st]}],"grid-cols":[{"grid-cols":[pu]}],"col-start-end":[{col:["auto",{span:["full",du,st]},st]}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":[pu]}],"row-start-end":[{row:["auto",{span:[du,st]},st]}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",st]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",st]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",st,e]}],"min-w":[{"min-w":[st,e,"min","max","fit"]}],"max-w":[{"max-w":[st,e,"none","full","min","max","fit","prose",{screen:[js]},js]}],h:[{h:[st,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[st,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[st,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[st,e,"auto","min","max","fit"]}],"font-size":[{text:["base",js,Hs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Cg]}],"font-family":[{font:[pu]}],"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",st]}],"line-clamp":[{"line-clamp":["none",ca,Cg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ds,st]}],"list-image":[{"list-image":["none",st]}],"list-style-type":[{list:["none","disc","decimal",st]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ds,Hs]}],"underline-offset":[{"underline-offset":["auto",ds,st]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",st]}],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",st]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Y(),KI]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",UI]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},GI]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[d]}],"gradient-via":[{via:[d]}],"gradient-to":[{to:[d]}],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:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:U()}],"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:["",...U()]}],"outline-offset":[{"outline-offset":[ds,st]}],"outline-w":[{outline:[ds,Hs]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[ds,Hs]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",js,qI]}],"shadow-color":[{shadow:[pu]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",js,st]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[y]}],sepia:[{sepia:[b]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[b]}],"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",st]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",st]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",st]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[du,st]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",st]}],accent:[{accent:["auto",t]}],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",st]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"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",st]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ds,Hs,Cg]}],stroke:[{stroke:[t,"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"]}}},eD=NI(ZI);function Xi(...t){return eD(kI(t))}function K1(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function tD({flipped:t}){return R.jsx(GP,{size:18,strokeWidth:2,"aria-hidden":"true",className:Xi("transition-transform duration-300",t&&"rotate-180")})}function nD({direction:t,onFlip:e}){return R.jsx("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${K1(t)})`,"aria-label":`Switch conversion direction (currently ${K1(t)})`,className:"flex size-9 cursor-pointer items-center justify-center rounded-full border border-border bg-background text-muted-foreground shadow-sm transition-colors hover:border-muted-foreground/50 hover:text-foreground",children:R.jsx(tD,{flipped:t==="json2csv"})})}const $2=[{question:"How does it work?",answer:"Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode."},{question:"What do the options do?",answer:"Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys."},{question:"TSV vs CSV — what changes?",answer:"Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them."},{question:"Does my data ever leave the browser?",answer:"No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else."}],rD={"@context":"https://schema.org","@type":"FAQPage",mainEntity:$2.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function iD(){const[t,e]=w.useState(!1),n=w.useId();return R.jsxs("section",{"data-testid":"faq","aria-label":"How it works and frequently asked questions",className:"flex-shrink-0 border-t border-border bg-panel px-4",children:[R.jsxs("button",{type:"button","data-testid":"faq-toggle","aria-expanded":t,"aria-controls":n,onClick:()=>e(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground",children:[R.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),R.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:$2.map(r=>R.jsxs("div",{className:"mb-3 last:mb-0",children:[R.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),R.jsx("p",{children:r.answer})]},r.question))}),R.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(rD)}})]})}const sD="https://github.com/FlatFilers/csvjson-app/discussions/163";function oD(){return R.jsx("div",{"data-testid":"feedback-banner",className:"flex flex-shrink-0 items-center justify-center border-b border-border bg-muted px-4 py-1.5 text-sm text-muted-foreground",children:R.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",R.jsx("a",{"data-testid":"feedback-link",href:sD,target:"_blank",rel:"noopener noreferrer",className:"rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Leave feedback or ask for features here"}),"."]})})}const H2="csvjson:feedback.v1",lD=[{value:"wrong_output",label:"The conversion is wrong"},{value:"hard_to_use",label:"Hard to use"},{value:"missing_feature",label:"Missing a feature"},{value:"slower",label:"Slower than the old site"},{value:"looks_worse",label:"Looks worse"},{value:"other",label:"Other"}];function aD(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.clientId=="string"&&e.clientId.length<=64&&(e.vote===1||e.vote===-1)&&(typeof e.reasonCode=="string"||e.reasonCode===null)&&(typeof e.reasonText=="string"||e.reasonText===null)&&typeof e.pending=="boolean"}function X1(){try{const t=window.localStorage.getItem(H2);if(t===null)return null;const e=JSON.parse(t);return aD(e)?e:null}catch{return null}}function G1(t){try{window.localStorage.setItem(H2,JSON.stringify(t))}catch{}}function q1(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.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)}`}function uD(t){const e=window.location.pathname;return t.vote===1?{clientId:t.clientId,vote:1,path:e}:{clientId:t.clientId,vote:-1,reasonCode:t.reasonCode,reasonText:t.reasonText,path:e}}async function cD(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(uD(t))})).ok?"ok":"failed"}catch{return"failed"}}function Y1(t){return["flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function fD(){const[t,e]=w.useState(X1),[n,r]=w.useState(!1),[i,s]=w.useState(null),[o,l]=w.useState(""),[a,u]=w.useState(!1),[c,f]=w.useState(!1),h=w.useRef(null),d=w.useRef(0),p=w.useCallback((b,C)=>{const T={...b,pending:C==="failed"};G1(T),e(T),C==="ok"?LP({vote:b.vote,with_reason:b.reasonCode!==null}):u(!1)},[]),m=w.useCallback((b,C)=>{const T=++d.current;C&&f(!0),cD(b).then(E=>{d.current===T&&(p(b,E),E==="ok"&&u(!0))}).finally(()=>{C&&d.current===T&&f(!1)})},[p]),x=b=>{const C={...b,pending:!0};G1(C),e(C),m(C,!0)},v=w.useRef(!1);w.useEffect(()=>{if(v.current)return;v.current=!0;const b=X1();b!=null&&b.pending&&m(b,!1)},[m]),w.useEffect(()=>{if(!a)return;const b=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(b)},[a]),w.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&r(!1)},C=T=>{const E=h.current;E===null||!(T.target instanceof Node)||E.contains(T.target)||r(!1)};return document.addEventListener("keydown",b),document.addEventListener("mousedown",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("mousedown",C)}},[n]);const g=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}x({clientId:(t==null?void 0:t.clientId)??q1(),vote:1,reasonCode:null,reasonText:null})},y=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const b=o.trim();x({clientId:(t==null?void 0:t.clientId)??q1(),vote:-1,reasonCode:i,reasonText:b===""?null:b}),r(!1)};return R.jsxs("div",{"data-testid":"feedback-vote",ref:h,className:"relative flex items-center gap-1",children:[R.jsx("button",{type:"button","data-testid":"feedback-up",onClick:g,"aria-pressed":(t==null?void 0:t.vote)===1,"aria-label":"Helpful — send an upvote",title:"Helpful",className:Y1((t==null?void 0:t.vote)===1),children:R.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[R.jsx("path",{d:"M7 10v12"}),R.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),R.jsx("button",{type:"button","data-testid":"feedback-down",onClick:y,"aria-pressed":(t==null?void 0:t.vote)===-1,"aria-haspopup":"dialog","aria-expanded":n,"aria-label":"Not helpful — send a downvote",title:"Not helpful",className:Y1((t==null?void 0:t.vote)===-1),children:R.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[R.jsx("path",{d:"M17 14V2"}),R.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})}),a&&R.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&R.jsx("span",{"data-testid":"feedback-pending",role:"status",className:"max-w-44 text-right text-xs text-muted-foreground sm:max-w-none",children:"Feedback couldn't send — your vote is kept on this device and will send automatically once the service is back."}),n&&R.jsxs("div",{"data-testid":"feedback-popover",role:"dialog","aria-label":"What went wrong?",className:"absolute right-0 top-9 z-50 w-72 rounded-md border border-border bg-panel p-3 shadow-md",children:[R.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),R.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:lD.map(b=>R.jsx("button",{type:"button","data-testid":`feedback-reason-${b.value}`,"aria-pressed":i===b.value,onClick:()=>s(b.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===b.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:b.label},b.value))}),R.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:b=>l(b.target.value),placeholder:"Anything more? (optional)",className:"mb-2 w-full resize-none rounded-sm border border-border bg-panel px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"}),R.jsxs("div",{className:"flex items-center justify-end gap-2",children:[R.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),R.jsx("button",{type:"button","data-testid":"feedback-submit",onClick:k,disabled:i===null,className:"cursor-pointer rounded-sm border border-border px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Send"})]})]})]})}function j2(t="This should not happen"){throw new Error(t)}function Or(t,e="Assertion failed"){if(!t)return j2(e)}function wc(t,e){return j2(e??"Hell froze over")}function hD(t,e){try{return t()}catch{return e}}const Q1=Object.prototype.hasOwnProperty;function Sa(t,e){let n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&Sa(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(Q1.call(t,n)&&++r&&!Q1.call(e,n)||!(n in e)||!Sa(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var dD=Object.prototype,pD=dD.hasOwnProperty;function gD(t,e){return t!=null&&pD.call(t,e)}var mD=gD,yD=Array.isArray,is=yD,vD=typeof no=="object"&&no&&no.Object===Object&&no,W2=vD,wD=W2,xD=typeof self=="object"&&self&&self.Object===Object&&self,bD=wD||xD||Function("return this")(),ss=bD,kD=ss,SD=kD.Symbol,Nc=SD,J1=Nc,V2=Object.prototype,CD=V2.hasOwnProperty,TD=V2.toString,gu=J1?J1.toStringTag:void 0;function ED(t){var e=CD.call(t,gu),n=t[gu];try{t[gu]=void 0;var r=!0}catch{}var i=TD.call(t);return r&&(e?t[gu]=n:delete t[gu]),i}var MD=ED,AD=Object.prototype,RD=AD.toString;function OD(t){return RD.call(t)}var PD=OD,Z1=Nc,ID=MD,DD=PD,_D="[object Null]",ND="[object Undefined]",ex=Z1?Z1.toStringTag:void 0;function LD(t){return t==null?t===void 0?ND:_D:ex&&ex in Object(t)?ID(t):DD(t)}var Lc=LD;function FD(t){return t!=null&&typeof t=="object"}var Fc=FD,BD=Lc,zD=Fc,$D="[object Symbol]";function HD(t){return typeof t=="symbol"||zD(t)&&BD(t)==$D}var rp=HD,jD=is,WD=rp,VD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,UD=/^\w*$/;function KD(t,e){if(jD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||WD(t)?!0:UD.test(t)||!VD.test(t)||e!=null&&t in Object(e)}var wv=KD;function XD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var hl=XD,GD=Lc,qD=hl,YD="[object AsyncFunction]",QD="[object Function]",JD="[object GeneratorFunction]",ZD="[object Proxy]";function e_(t){if(!qD(t))return!1;var e=GD(t);return e==QD||e==JD||e==YD||e==ZD}var U2=e_,t_=ss,n_=t_["__core-js_shared__"],r_=n_,Tg=r_,tx=function(){var t=/[^.]+$/.exec(Tg&&Tg.keys&&Tg.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function i_(t){return!!tx&&tx in t}var s_=i_,o_=Function.prototype,l_=o_.toString;function a_(t){if(t!=null){try{return l_.call(t)}catch{}try{return t+""}catch{}}return""}var K2=a_,u_=U2,c_=s_,f_=hl,h_=K2,d_=/[\\^$.*+?()[\]{}|]/g,p_=/^\[object .+?Constructor\]$/,g_=Function.prototype,m_=Object.prototype,y_=g_.toString,v_=m_.hasOwnProperty,w_=RegExp("^"+y_.call(v_).replace(d_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function x_(t){if(!f_(t)||c_(t))return!1;var e=u_(t)?w_:p_;return e.test(h_(t))}var b_=x_;function k_(t,e){return t==null?void 0:t[e]}var S_=k_,C_=b_,T_=S_;function E_(t,e){var n=T_(t,e);return C_(n)?n:void 0}var dl=E_,M_=dl,A_=M_(Object,"create"),ip=A_,nx=ip;function R_(){this.__data__=nx?nx(null):{},this.size=0}var O_=R_;function P_(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var I_=P_,D_=ip,__="__lodash_hash_undefined__",N_=Object.prototype,L_=N_.hasOwnProperty;function F_(t){var e=this.__data__;if(D_){var n=e[t];return n===__?void 0:n}return L_.call(e,t)?e[t]:void 0}var B_=F_,z_=ip,$_=Object.prototype,H_=$_.hasOwnProperty;function j_(t){var e=this.__data__;return z_?e[t]!==void 0:H_.call(e,t)}var W_=j_,V_=ip,U_="__lodash_hash_undefined__";function K_(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=V_&&e===void 0?U_:e,this}var X_=K_,G_=O_,q_=I_,Y_=B_,Q_=W_,J_=X_;function za(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var gN=pN,mN=sp;function yN(t,e){var n=this.__data__,r=mN(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var vN=yN,wN=tN,xN=uN,bN=hN,kN=gN,SN=vN;function $a(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=NL}var Ev=LL,FL=rp;function BL(t){if(typeof t=="string"||FL(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var ap=BL,zL=q2,$L=Cv,HL=is,jL=Tv,WL=Ev,VL=ap;function UL(t,e,n){e=zL(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new gs(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=JL([...this.items,n]);return new gs(r)}remove(e){const n=[...this.items],r=typeof e=="number"?e:e[0],i=typeof e=="number"?e+1:e[1];for(const[s,o]of n.entries()){const[l,a]=o;if(l<=i&&r<=a){const u=[];l=r&&ecx??(cx=new gs([]))),at(gs,"fromSingleSelection",e=>gs.empty().add(e));let wt=gs;function ZL(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var e3=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Eg=ZL(function(t){return e3.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),t3=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];e.forEach(s=>{(s?s.split(" "):[]).forEach(l=>{if(l.startsWith("atm_")){const[,a]=l.split("_");n[a]=l}else r.push(l)})});const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(n[s]);return i.push(...r),i.join(" ")},fx=t3,n3=t=>t.toUpperCase()===t,r3=t=>e=>t.indexOf(e)===-1,J2=(t,e)=>{const n={};return Object.keys(t).filter(r3(e)).forEach(r=>{n[r]=t[r]}),n};function i3(t,e,n){const r=J2(e,n);if(!t){const i=typeof Eg=="function"?{default:Eg}:Eg;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var s3=(t,e)=>{};function o3(t){let e="";return n=>{const r=(s,o)=>{const{as:l=t,class:a=e}=s,u=n.propsAsIs===void 0?!(typeof l=="string"&&l.indexOf("-")===-1&&!n3(l[0])):n.propsAsIs,c=i3(u,s,["as","class"]);c.ref=o,c.className=n.atomic?fx(n.class,c.className||a):fx(c.className||a,n.class);const{vars:f}=n;if(f){const h={};for(const m in f){const x=f[m],v=x[0],g=x[1]||"",y=typeof v=="function"?v(s):v;s3(y,n.name),h[`--${m}`]=`${y}${g}`}const d=c.style||{},p=Object.keys(d);p.length>0&&p.forEach(m=>{h[m]=d[m]}),c.style=h}return t.__linaria&&t!==l?(c.as=l,kn.createElement(t,c)):kn.createElement(l,c)},i=kn.forwardRef?kn.forwardRef(r):s=>{const o=J2(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var Br=o3;const l3=Br("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var Z2={},up={},Av={},Mg={},Ag={exports:{}},Rg,hx;function a3(){if(hx)return Rg;hx=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Rg=t,Rg}var Og,dx;function u3(){if(dx)return Og;dx=1;var t=a3();function e(){}function n(){}return n.resetWarningCache=e,Og=function(){function r(o,l,a,u,c,f){if(f!==t){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Og}var px;function c3(){return px||(px=1,Ag.exports=u3()()),Ag.exports}var gx;function f3(){return gx||(gx=1,function(t){(function(e,n){n(t,w,c3())})(no,function(e,n,r){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var i=o(n),s=o(r);function o(g){return g&&g.__esModule?g:{default:g}}var l=Object.assign||function(g){for(var y=1;y=0||Object.prototype.hasOwnProperty.call(g,b)&&(k[b]=g[b]);return k}function u(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")}var c=function(){function g(y,k){for(var b=0;b0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return d?g:g.capture}function x(g){if("touches"in g){var y=g.touches[0],k=y.pageX,b=y.pageY;return{x:k,y:b}}var C=g.screenX,T=g.screenY;return{x:C,y:T}}var v=function(g){h(y,g);function y(){var k;u(this,y);for(var b=arguments.length,C=Array(b),T=0;TC&&this.props.onSwipeRight(1,b),this.movePosition.deltaY<-C?this.props.onSwipeUp(1,b):this.movePosition.deltaY>C&&this.props.onSwipeDown(1,b)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(b){this.swiper=b,this.props.innerRef(b)}},{key:"render",value:function(){var b=this.props;b.tagName;var C=b.className,T=b.style,E=b.children;b.allowMouseEvents,b.onSwipeUp,b.onSwipeDown,b.onSwipeLeft,b.onSwipeRight,b.onSwipeStart,b.onSwipeMove,b.onSwipeEnd,b.innerRef,b.tolerance;var A=a(b,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return i.default.createElement(this.props.tagName,l({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:C,style:T},A),E)}}]),y}(n.Component);v.displayName="ReactSwipe",v.propTypes={tagName:s.default.string,className:s.default.string,style:s.default.object,children:s.default.node,allowMouseEvents:s.default.bool,onSwipeUp:s.default.func,onSwipeDown:s.default.func,onSwipeLeft:s.default.func,onSwipeRight:s.default.func,onSwipeStart:s.default.func,onSwipeMove:s.default.func,onSwipeEnd:s.default.func,innerRef:s.default.func,tolerance:s.default.number.isRequired},v.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=v})}(Mg)),Mg}(function(t){(function(e,n){n(t,f3())})(no,function(e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n);function i(s){return s&&s.__esModule?s:{default:s}}e.default=r.default})})(Av);var Bc={},eT={exports:{}};/*! + */const SI=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],L2=jn("x",SI);function F2(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=MI(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(xv);return l[0]===""&&l.length!==1&&l.shift(),B2(l,e)||EI(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},B2=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?B2(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(xv);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},K1=/^\[(.+)\]$/,EI=t=>{if(K1.test(t)){const e=K1.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},MI=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return RI(Object.entries(t.classGroups),n).forEach(([s,o])=>{h0(o,r,s,e)}),r},h0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:X1(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(AI(i)){h0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{h0(o,X1(e,s),n,r)})})},X1=(t,e)=>{let n=t;return e.split(xv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},AI=t=>t.isThemeGetter,RI=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[e+o,l])):s);return[n,i]}):t,OI=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},z2="!",PI=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=l=>{const a=[];let u=0,c=0,f;for(let x=0;xc?f-c:void 0;return{modifiers:a,hasImportantModifier:d,baseClassName:p,maybePostfixModifierPosition:m}};return n?l=>n({className:l,parseClassName:o}):o},II=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},DI=t=>({cache:OI(t.cacheSize),parseClassName:PI(t),...TI(t)}),_I=/\s+/,NI=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(_I);let l="";for(let a=o.length-1;a>=0;a-=1){const u=o[a],{modifiers:c,hasImportantModifier:f,baseClassName:h,maybePostfixModifierPosition:d}=n(u);let p=!!d,m=r(p?h.substring(0,d):h);if(!m){if(!p){l=u+(l.length>0?" "+l:l);continue}if(m=r(h),!m){l=u+(l.length>0?" "+l:l);continue}p=!1}const x=II(c).join(":"),v=f?x+z2:x,g=v+m;if(s.includes(g))continue;s.push(g);const y=i(m,p);for(let k=0;k0?" "+l:l)}return l};function LI(){let t=0,e,n,r="";for(;t{if(typeof t=="string")return t;let e,n="";for(let r=0;rf(c),t());return n=DI(u),r=n.cache.get,i=n.cache.set,s=l,l(a)}function l(a){const u=r(a);if(u)return u;const c=NI(a,n);return i(a,c),c}return function(){return s(LI.apply(null,arguments))}}const Vt=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},H2=/^\[(?:([a-z-]+):)?(.+)\]$/i,BI=/^\d+\/\d+$/,zI=new Set(["px","full","screen"]),$I=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,HI=/\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$/,jI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,WI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,VI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ds=t=>ca(t)||zI.has(t)||BI.test(t),Hs=t=>Ba(t,"length",JI),ca=t=>!!t&&!Number.isNaN(Number(t)),Eg=t=>Ba(t,"number",ca),du=t=>!!t&&Number.isInteger(Number(t)),UI=t=>t.endsWith("%")&&ca(t.slice(0,-1)),lt=t=>H2.test(t),js=t=>$I.test(t),KI=new Set(["length","size","percentage"]),XI=t=>Ba(t,KI,j2),GI=t=>Ba(t,"position",j2),qI=new Set(["image","url"]),YI=t=>Ba(t,qI,eD),QI=t=>Ba(t,"",ZI),pu=()=>!0,Ba=(t,e,n)=>{const r=H2.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},JI=t=>HI.test(t)&&!jI.test(t),j2=()=>!1,ZI=t=>WI.test(t),eD=t=>VI.test(t),tD=()=>{const t=Vt("colors"),e=Vt("spacing"),n=Vt("blur"),r=Vt("brightness"),i=Vt("borderColor"),s=Vt("borderRadius"),o=Vt("borderSpacing"),l=Vt("borderWidth"),a=Vt("contrast"),u=Vt("grayscale"),c=Vt("hueRotate"),f=Vt("invert"),h=Vt("gap"),d=Vt("gradientColorStops"),p=Vt("gradientColorStopPositions"),m=Vt("inset"),x=Vt("margin"),v=Vt("opacity"),g=Vt("padding"),y=Vt("saturate"),k=Vt("scale"),b=Vt("sepia"),C=Vt("skew"),T=Vt("space"),E=Vt("translate"),A=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",lt,e],O=()=>[lt,e],D=()=>["",ds,Hs],I=()=>["auto",ca,lt],Q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],X=()=>["solid","dashed","dotted","double","none"],le=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],j=()=>["start","end","center","between","around","evenly","stretch"],ne=()=>["","0",lt],Y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>[ca,lt];return{cacheSize:500,separator:":",theme:{colors:[pu],spacing:[ds,Hs],blur:["none","",js,lt],brightness:M(),borderColor:[t],borderRadius:["none","","full",js,lt],borderSpacing:O(),borderWidth:D(),contrast:M(),grayscale:ne(),hueRotate:M(),invert:ne(),gap:O(),gradientColorStops:[t],gradientColorStopPositions:[UI,Hs],inset:_(),margin:_(),opacity:M(),padding:O(),saturate:M(),scale:M(),sepia:ne(),skew:M(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",lt]}],container:["container"],columns:[{columns:[js]}],"break-after":[{"break-after":Y()}],"break-before":[{"break-before":Y()}],"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:[...Q(),lt]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",du,lt]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",lt]}],grow:[{grow:ne()}],shrink:[{shrink:ne()}],order:[{order:["first","last","none",du,lt]}],"grid-cols":[{"grid-cols":[pu]}],"col-start-end":[{col:["auto",{span:["full",du,lt]},lt]}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":[pu]}],"row-start-end":[{row:["auto",{span:[du,lt]},lt]}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",lt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",lt]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...j()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...j(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...j(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",lt,e]}],"min-w":[{"min-w":[lt,e,"min","max","fit"]}],"max-w":[{"max-w":[lt,e,"none","full","min","max","fit","prose",{screen:[js]},js]}],h:[{h:[lt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[lt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[lt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[lt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",js,Hs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Eg]}],"font-family":[{font:[pu]}],"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",lt]}],"line-clamp":[{"line-clamp":["none",ca,Eg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ds,lt]}],"list-image":[{"list-image":["none",lt]}],"list-style-type":[{list:["none","disc","decimal",lt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...X(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ds,Hs]}],"underline-offset":[{"underline-offset":["auto",ds,lt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",lt]}],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",lt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Q(),GI]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",XI]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},YI]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[d]}],"gradient-via":[{via:[d]}],"gradient-to":[{to:[d]}],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:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:[...X(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:X()}],"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:["",...X()]}],"outline-offset":[{"outline-offset":[ds,lt]}],"outline-w":[{outline:[ds,Hs]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[ds,Hs]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",js,QI]}],"shadow-color":[{shadow:[pu]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":[...le(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":le()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",js,lt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[y]}],sepia:[{sepia:[b]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[b]}],"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",lt]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",lt]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",lt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[du,lt]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",lt]}],accent:[{accent:["auto",t]}],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",lt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"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",lt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ds,Hs,Eg]}],stroke:[{stroke:[t,"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"]}}},nD=FI(tD);function qi(...t){return nD(CI(t))}function G1(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function rD({flipped:t}){return R.jsx(QP,{size:18,strokeWidth:2,"aria-hidden":"true",className:qi("transition-transform duration-300",t&&"rotate-180")})}function iD({direction:t,onFlip:e}){return R.jsx("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${G1(t)})`,"aria-label":`Switch conversion direction (currently ${G1(t)})`,className:"flex size-9 cursor-pointer items-center justify-center rounded-full border border-border bg-background text-muted-foreground shadow-sm transition-colors hover:border-muted-foreground/50 hover:text-foreground",children:R.jsx(rD,{flipped:t==="json2csv"})})}const W2=[{question:"How does it work?",answer:"Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode."},{question:"What do the options do?",answer:"Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys."},{question:"TSV vs CSV — what changes?",answer:"Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them."},{question:"Does my data ever leave the browser?",answer:"No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else."}],sD={"@context":"https://schema.org","@type":"FAQPage",mainEntity:W2.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function oD(){const[t,e]=w.useState(!1),n=w.useId();return R.jsxs("section",{"data-testid":"faq","aria-label":"How it works and frequently asked questions",className:"flex-shrink-0 border-t border-border bg-panel px-4",children:[R.jsxs("button",{type:"button","data-testid":"faq-toggle","aria-expanded":t,"aria-controls":n,onClick:()=>e(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground",children:[R.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),R.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:W2.map(r=>R.jsxs("div",{className:"mb-3 last:mb-0",children:[R.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),R.jsx("p",{children:r.answer})]},r.question))}),R.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(sD)}})]})}const lD="https://github.com/FlatFilers/csvjson-app/discussions/163";function aD(){return R.jsx("div",{"data-testid":"feedback-banner",className:"flex flex-shrink-0 items-center justify-center border-b border-border bg-muted px-4 py-1.5 text-sm text-muted-foreground",children:R.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",R.jsx("a",{"data-testid":"feedback-link",href:lD,target:"_blank",rel:"noopener noreferrer",className:"rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Leave feedback or ask for features here"}),"."]})})}const V2="csvjson:feedback.v1",uD=[{value:"wrong_output",label:"The conversion is wrong"},{value:"hard_to_use",label:"Hard to use"},{value:"missing_feature",label:"Missing a feature"},{value:"slower",label:"Slower than the old site"},{value:"looks_worse",label:"Looks worse"},{value:"other",label:"Other"}];function cD(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.clientId=="string"&&e.clientId.length<=64&&(e.vote===1||e.vote===-1)&&(typeof e.reasonCode=="string"||e.reasonCode===null)&&(typeof e.reasonText=="string"||e.reasonText===null)&&typeof e.pending=="boolean"}function q1(){try{const t=window.localStorage.getItem(V2);if(t===null)return null;const e=JSON.parse(t);return cD(e)?e:null}catch{return null}}function Y1(t){try{window.localStorage.setItem(V2,JSON.stringify(t))}catch{}}function Q1(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.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)}`}function fD(t){const e=window.location.pathname;return t.vote===1?{clientId:t.clientId,vote:1,path:e}:{clientId:t.clientId,vote:-1,reasonCode:t.reasonCode,reasonText:t.reasonText,path:e}}async function hD(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fD(t))})).ok?"ok":"failed"}catch{return"failed"}}function J1(t){return["flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function dD(){const[t,e]=w.useState(q1),[n,r]=w.useState(!1),[i,s]=w.useState(null),[o,l]=w.useState(""),[a,u]=w.useState(!1),[c,f]=w.useState(!1),h=w.useRef(null),d=w.useRef(0),p=w.useCallback((b,C)=>{const T={...b,pending:C==="failed"};Y1(T),e(T),C==="ok"?zP({vote:b.vote,with_reason:b.reasonCode!==null}):u(!1)},[]),m=w.useCallback((b,C)=>{const T=++d.current;C&&f(!0),hD(b).then(E=>{d.current===T&&(p(b,E),E==="ok"&&u(!0))}).finally(()=>{C&&d.current===T&&f(!1)})},[p]),x=b=>{const C={...b,pending:!0};Y1(C),e(C),m(C,!0)},v=w.useRef(!1);w.useEffect(()=>{if(v.current)return;v.current=!0;const b=q1();b!=null&&b.pending&&m(b,!1)},[m]),w.useEffect(()=>{if(!a)return;const b=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(b)},[a]),w.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&r(!1)},C=T=>{const E=h.current;E===null||!(T.target instanceof Node)||E.contains(T.target)||r(!1)};return document.addEventListener("keydown",b),document.addEventListener("mousedown",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("mousedown",C)}},[n]);const g=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}x({clientId:(t==null?void 0:t.clientId)??Q1(),vote:1,reasonCode:null,reasonText:null})},y=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const b=o.trim();x({clientId:(t==null?void 0:t.clientId)??Q1(),vote:-1,reasonCode:i,reasonText:b===""?null:b}),r(!1)};return R.jsxs("div",{"data-testid":"feedback-vote",ref:h,className:"relative flex items-center gap-1",children:[R.jsx("button",{type:"button","data-testid":"feedback-up",onClick:g,"aria-pressed":(t==null?void 0:t.vote)===1,"aria-label":"Helpful — send an upvote",title:"Helpful",className:J1((t==null?void 0:t.vote)===1),children:R.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[R.jsx("path",{d:"M7 10v12"}),R.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),R.jsx("button",{type:"button","data-testid":"feedback-down",onClick:y,"aria-pressed":(t==null?void 0:t.vote)===-1,"aria-haspopup":"dialog","aria-expanded":n,"aria-label":"Not helpful — send a downvote",title:"Not helpful",className:J1((t==null?void 0:t.vote)===-1),children:R.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[R.jsx("path",{d:"M17 14V2"}),R.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})}),a&&R.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&R.jsx("span",{"data-testid":"feedback-pending",role:"status",className:"max-w-44 text-right text-xs text-muted-foreground sm:max-w-none",children:"Feedback couldn't send — your vote is kept on this device and will send automatically once the service is back."}),n&&R.jsxs("div",{"data-testid":"feedback-popover",role:"dialog","aria-label":"What went wrong?",className:"absolute right-0 top-9 z-50 w-72 rounded-md border border-border bg-panel p-3 shadow-md",children:[R.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),R.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:uD.map(b=>R.jsx("button",{type:"button","data-testid":`feedback-reason-${b.value}`,"aria-pressed":i===b.value,onClick:()=>s(b.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===b.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:b.label},b.value))}),R.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:b=>l(b.target.value),placeholder:"Anything more? (optional)",className:"mb-2 w-full resize-none rounded-sm border border-border bg-panel px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"}),R.jsxs("div",{className:"flex items-center justify-end gap-2",children:[R.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),R.jsx("button",{type:"button","data-testid":"feedback-submit",onClick:k,disabled:i===null,className:"cursor-pointer rounded-sm border border-border px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Send"})]})]})]})}function U2(t="This should not happen"){throw new Error(t)}function Pr(t,e="Assertion failed"){if(!t)return U2(e)}function bc(t,e){return U2(e??"Hell froze over")}function pD(t,e){try{return t()}catch{return e}}const Z1=Object.prototype.hasOwnProperty;function Sa(t,e){let n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&Sa(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(Z1.call(t,n)&&++r&&!Z1.call(e,n)||!(n in e)||!Sa(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var gD=Object.prototype,mD=gD.hasOwnProperty;function yD(t,e){return t!=null&&mD.call(t,e)}var vD=yD,wD=Array.isArray,os=wD,xD=typeof no=="object"&&no&&no.Object===Object&&no,K2=xD,bD=K2,kD=typeof self=="object"&&self&&self.Object===Object&&self,SD=bD||kD||Function("return this")(),ls=SD,CD=ls,TD=CD.Symbol,Fc=TD,ex=Fc,X2=Object.prototype,ED=X2.hasOwnProperty,MD=X2.toString,gu=ex?ex.toStringTag:void 0;function AD(t){var e=ED.call(t,gu),n=t[gu];try{t[gu]=void 0;var r=!0}catch{}var i=MD.call(t);return r&&(e?t[gu]=n:delete t[gu]),i}var RD=AD,OD=Object.prototype,PD=OD.toString;function ID(t){return PD.call(t)}var DD=ID,tx=Fc,_D=RD,ND=DD,LD="[object Null]",FD="[object Undefined]",nx=tx?tx.toStringTag:void 0;function BD(t){return t==null?t===void 0?FD:LD:nx&&nx in Object(t)?_D(t):ND(t)}var Bc=BD;function zD(t){return t!=null&&typeof t=="object"}var zc=zD,$D=Bc,HD=zc,jD="[object Symbol]";function WD(t){return typeof t=="symbol"||HD(t)&&$D(t)==jD}var sp=WD,VD=os,UD=sp,KD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,XD=/^\w*$/;function GD(t,e){if(VD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||UD(t)?!0:XD.test(t)||!KD.test(t)||e!=null&&t in Object(e)}var bv=GD;function qD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var hl=qD,YD=Bc,QD=hl,JD="[object AsyncFunction]",ZD="[object Function]",e_="[object GeneratorFunction]",t_="[object Proxy]";function n_(t){if(!QD(t))return!1;var e=YD(t);return e==ZD||e==e_||e==JD||e==t_}var G2=n_,r_=ls,i_=r_["__core-js_shared__"],s_=i_,Mg=s_,rx=function(){var t=/[^.]+$/.exec(Mg&&Mg.keys&&Mg.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function o_(t){return!!rx&&rx in t}var l_=o_,a_=Function.prototype,u_=a_.toString;function c_(t){if(t!=null){try{return u_.call(t)}catch{}try{return t+""}catch{}}return""}var q2=c_,f_=G2,h_=l_,d_=hl,p_=q2,g_=/[\\^$.*+?()[\]{}|]/g,m_=/^\[object .+?Constructor\]$/,y_=Function.prototype,v_=Object.prototype,w_=y_.toString,x_=v_.hasOwnProperty,b_=RegExp("^"+w_.call(x_).replace(g_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function k_(t){if(!d_(t)||h_(t))return!1;var e=f_(t)?b_:m_;return e.test(p_(t))}var S_=k_;function C_(t,e){return t==null?void 0:t[e]}var T_=C_,E_=S_,M_=T_;function A_(t,e){var n=M_(t,e);return E_(n)?n:void 0}var dl=A_,R_=dl,O_=R_(Object,"create"),op=O_,ix=op;function P_(){this.__data__=ix?ix(null):{},this.size=0}var I_=P_;function D_(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var __=D_,N_=op,L_="__lodash_hash_undefined__",F_=Object.prototype,B_=F_.hasOwnProperty;function z_(t){var e=this.__data__;if(N_){var n=e[t];return n===L_?void 0:n}return B_.call(e,t)?e[t]:void 0}var $_=z_,H_=op,j_=Object.prototype,W_=j_.hasOwnProperty;function V_(t){var e=this.__data__;return H_?e[t]!==void 0:W_.call(e,t)}var U_=V_,K_=op,X_="__lodash_hash_undefined__";function G_(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=K_&&e===void 0?X_:e,this}var q_=G_,Y_=I_,Q_=__,J_=$_,Z_=U_,eN=q_;function za(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var yN=mN,vN=lp;function wN(t,e){var n=this.__data__,r=vN(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var xN=wN,bN=rN,kN=fN,SN=pN,CN=yN,TN=xN;function $a(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=FL}var Av=BL,zL=sp;function $L(t){if(typeof t=="string"||zL(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var cp=$L,HL=J2,jL=Ev,WL=os,VL=Mv,UL=Av,KL=cp;function XL(t,e,n){e=HL(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new gs(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=e3([...this.items,n]);return new gs(r)}remove(e){const n=[...this.items],r=typeof e=="number"?e:e[0],i=typeof e=="number"?e+1:e[1];for(const[s,o]of n.entries()){const[l,a]=o;if(l<=i&&r<=a){const u=[];l=r&&ehx??(hx=new gs([]))),ft(gs,"fromSingleSelection",e=>gs.empty().add(e));let St=gs;function t3(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var n3=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Ag=t3(function(t){return n3.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),r3=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];e.forEach(s=>{(s?s.split(" "):[]).forEach(l=>{if(l.startsWith("atm_")){const[,a]=l.split("_");n[a]=l}else r.push(l)})});const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(n[s]);return i.push(...r),i.join(" ")},dx=r3,i3=t=>t.toUpperCase()===t,s3=t=>e=>t.indexOf(e)===-1,tT=(t,e)=>{const n={};return Object.keys(t).filter(s3(e)).forEach(r=>{n[r]=t[r]}),n};function o3(t,e,n){const r=tT(e,n);if(!t){const i=typeof Ag=="function"?{default:Ag}:Ag;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var l3=(t,e)=>{};function a3(t){let e="";return n=>{const r=(s,o)=>{const{as:l=t,class:a=e}=s,u=n.propsAsIs===void 0?!(typeof l=="string"&&l.indexOf("-")===-1&&!i3(l[0])):n.propsAsIs,c=o3(u,s,["as","class"]);c.ref=o,c.className=n.atomic?dx(n.class,c.className||a):dx(c.className||a,n.class);const{vars:f}=n;if(f){const h={};for(const m in f){const x=f[m],v=x[0],g=x[1]||"",y=typeof v=="function"?v(s):v;l3(y,n.name),h[`--${m}`]=`${y}${g}`}const d=c.style||{},p=Object.keys(d);p.length>0&&p.forEach(m=>{h[m]=d[m]}),c.style=h}return t.__linaria&&t!==l?(c.as=l,Tn.createElement(t,c)):Tn.createElement(l,c)},i=Tn.forwardRef?Tn.forwardRef(r):s=>{const o=tT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var zr=a3;const u3=zr("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var nT={},fp={},Ov={},Rg={},Og={exports:{}},Pg,px;function c3(){if(px)return Pg;px=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Pg=t,Pg}var Ig,gx;function f3(){if(gx)return Ig;gx=1;var t=c3();function e(){}function n(){}return n.resetWarningCache=e,Ig=function(){function r(o,l,a,u,c,f){if(f!==t){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Ig}var mx;function h3(){return mx||(mx=1,Og.exports=f3()()),Og.exports}var yx;function d3(){return yx||(yx=1,function(t){(function(e,n){n(t,w,h3())})(no,function(e,n,r){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var i=o(n),s=o(r);function o(g){return g&&g.__esModule?g:{default:g}}var l=Object.assign||function(g){for(var y=1;y=0||Object.prototype.hasOwnProperty.call(g,b)&&(k[b]=g[b]);return k}function u(g,y){if(!(g instanceof y))throw new TypeError("Cannot call a class as a function")}var c=function(){function g(y,k){for(var b=0;b0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return d?g:g.capture}function x(g){if("touches"in g){var y=g.touches[0],k=y.pageX,b=y.pageY;return{x:k,y:b}}var C=g.screenX,T=g.screenY;return{x:C,y:T}}var v=function(g){h(y,g);function y(){var k;u(this,y);for(var b=arguments.length,C=Array(b),T=0;TC&&this.props.onSwipeRight(1,b),this.movePosition.deltaY<-C?this.props.onSwipeUp(1,b):this.movePosition.deltaY>C&&this.props.onSwipeDown(1,b)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(b){this.swiper=b,this.props.innerRef(b)}},{key:"render",value:function(){var b=this.props;b.tagName;var C=b.className,T=b.style,E=b.children;b.allowMouseEvents,b.onSwipeUp,b.onSwipeDown,b.onSwipeLeft,b.onSwipeRight,b.onSwipeStart,b.onSwipeMove,b.onSwipeEnd,b.innerRef,b.tolerance;var A=a(b,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return i.default.createElement(this.props.tagName,l({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:C,style:T},A),E)}}]),y}(n.Component);v.displayName="ReactSwipe",v.propTypes={tagName:s.default.string,className:s.default.string,style:s.default.object,children:s.default.node,allowMouseEvents:s.default.bool,onSwipeUp:s.default.func,onSwipeDown:s.default.func,onSwipeLeft:s.default.func,onSwipeRight:s.default.func,onSwipeStart:s.default.func,onSwipeMove:s.default.func,onSwipeEnd:s.default.func,innerRef:s.default.func,tolerance:s.default.number.isRequired},v.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=v})}(Rg)),Rg}(function(t){(function(e,n){n(t,d3())})(no,function(e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n);function i(s){return s&&s.__esModule?s:{default:s}}e.default=r.default})})(Ov);var $c={},rT={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function od(t){return od=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},od(t)}function Wn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var R3=function(e){return e.hasOwnProperty("key")},Rv=function(t){T3(n,t);var e=E3(n);function n(r){var i;return k3(this,n),i=e.call(this,r),Wn(tr(i),"itemsWrapperRef",void 0),Wn(tr(i),"itemsListRef",void 0),Wn(tr(i),"thumbsRef",void 0),Wn(tr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),Wn(tr(i),"setItemsListRef",function(s){i.itemsListRef=s}),Wn(tr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),Wn(tr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=pi.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,w3.outerWidth)(i.thumbsRef[0]),a=Math.floor(o/l),u=a0&&(o=0),u===f&&o<0&&(o=0);var h=i.itemsWrapperRef.clientWidth,d=u+100/(h/o);return i.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(p){i.itemsListRef.style[p]=(0,mx.default)(d,"%",i.props.axis)}),!0}),Wn(tr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),Wn(tr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),Wn(tr(i),"moveTo",function(s){s=s<0?0:s,s=s>=i.state.lastPosition?i.state.lastPosition:s,i.setState({firstItem:s})}),i.state={selectedItem:r.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},i}return C3(n,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(i){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==i.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,Ff.default)().addEventListener("resize",this.updateSizes),(0,Ff.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,Ff.default)().removeEventListener("resize",this.updateSizes),(0,Ff.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(i){var s=i;return i>=this.state.lastPosition&&(s=this.state.lastPosition),i1,o=this.state.showArrows&&this.state.firstItem>0,l=this.state.showArrows&&this.state.firstItemo);if(l)return s<0?e.centerMode&&e.centerSlidePercentage&&e.axis==="horizontal"?r.itemListStyle=(0,qi.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,qi.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,qi.setPosition)(0,e.axis)),r;var a=(0,qi.getPosition)(i,e),u=(0,z3.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=Wo(Wo({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};Gi.slideAnimationHandler=j3;var W3=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=nT.Children.count(n.children),a=0,u=(0,qi.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,qi.getPosition)(l-1,n)-100:(0,qi.getPosition)(l-1,n),f=o?e.x:e.y,h=f;u===a&&f>0&&(h=0),u===c&&f<0&&(h=0);var d=u+100/(r.itemSize/h),p=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&p&&(r.selectedItem===0&&d>-100?d-=l*100:r.selectedItem===l-1&&d<-l*100&&(d+=l*100)),(!n.preventMovementUntilSwipeScrollTolerance||p||r.swipeMovementStarted)&&(r.swipeMovementStarted||i({swipeMovementStarted:!0}),s.itemListStyle=(0,qi.setPosition)(d,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};Gi.slideSwipeAnimationHandler=W3;var V3=function(e,n){var r=(0,qi.getPosition)(n.selectedItem,e),i=(0,qi.setPosition)(r,e.axis);return{itemListStyle:i}};Gi.slideStopSwipingHandler=V3;var U3=function(e,n){var r=e.transitionTime+"ms",i="ease-in-out",s={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:i,msTransitionTimingFunction:i,MozTransitionTimingFunction:i,WebkitTransitionTimingFunction:i,OTransitionTimingFunction:i};return n.swiping||(s=Wo(Wo({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:Wo(Wo({},s),{},{opacity:1,position:"relative"}),prevStyle:Wo({},s)}};Gi.fadeAnimationHandler=U3;Object.defineProperty(up,"__esModule",{value:!0});up.default=void 0;var Et=G3(w),K3=Hc(Av),ys=Hc(Bc),X3=Hc(zc),Bf=Hc(hp),zf=Hc($c),Ou=Ir,ld=Gi;function Hc(t){return t&&t.__esModule?t:{default:t}}function rT(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return rT=function(){return t},t}function G3(t){if(t&&t.__esModule)return t;if(t===null||Vu(t)!=="object"&&typeof t!="function")return{default:t};var e=rT();if(e&&e.has(t))return e.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=r?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=t[i]}return n.default=t,e&&e.set(t,n),n}function Vu(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Vu=function(n){return typeof n}:Vu=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Vu(t)}function p0(){return p0=Object.assign||function(t){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function ad(t){return ad=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},ad(t)}function ut(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Ov=function(t){J3(n,t);var e=Z3(n);function n(r){var i;q3(this,n),i=e.call(this,r),ut(ht(i),"thumbsRef",void 0),ut(ht(i),"carouselWrapperRef",void 0),ut(ht(i),"listRef",void 0),ut(ht(i),"itemsRef",void 0),ut(ht(i),"timer",void 0),ut(ht(i),"animationHandler",void 0),ut(ht(i),"setThumbsRef",function(o){i.thumbsRef=o}),ut(ht(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),ut(ht(i),"setListRef",function(o){i.listRef=o}),ut(ht(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),ut(ht(i),"autoPlay",function(){Et.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),ut(ht(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),ut(ht(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),ut(ht(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),ut(ht(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),ut(ht(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,Bf.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,Bf.default)().activeElement)):!1}),ut(ht(i),"navigateWithKeyboard",function(o){if(i.isFocusWithinTheCarousel()){var l=i.props.axis,a=l==="horizontal",u={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},c=a?u.ArrowRight:u.ArrowDown,f=a?u.ArrowLeft:u.ArrowUp;c===o.keyCode?i.increment():f===o.keyCode&&i.decrement()}}),ut(ht(i),"updateSizes",function(){if(!(!i.state.initialized||!i.itemsRef||i.itemsRef.length===0)){var o=i.props.axis==="horizontal",l=i.itemsRef[0];if(l){var a=o?l.clientWidth:l.clientHeight;i.setState({itemSize:a}),i.thumbsRef&&i.thumbsRef.updateSizes()}}}),ut(ht(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),ut(ht(i),"handleClickItem",function(o,l){if(Et.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),ut(ht(i),"handleOnChange",function(o,l){Et.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),ut(ht(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),ut(ht(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),ut(ht(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),ut(ht(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(ht(i)));return i.setState(gi({},a)),!!Object.keys(a).length}),ut(ht(i),"decrement",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem-(typeof o=="number"?o:1))}),ut(ht(i),"increment",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem+(typeof o=="number"?o:1))}),ut(ht(i),"moveTo",function(o){if(typeof o=="number"){var l=Et.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),ut(ht(i),"onClickNext",function(){i.increment(1)}),ut(ht(i),"onClickPrev",function(){i.decrement(1)}),ut(ht(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),ut(ht(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),ut(ht(i),"changeItem",function(o){return function(l){(!(0,Ou.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),ut(ht(i),"selectItem",function(o){i.setState(gi({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,Et.Children.toArray(i.props.children)[o.selectedItem])}),ut(ht(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),ut(ht(i),"getVariableItemHeight",function(o){var l=i.itemsRef&&i.itemsRef[o];if(i.state.hasMount&&l&&l.children.length){var a=l.children[0].getElementsByTagName("img")||[];if(a.length>0){var u=a[0];if(!u.complete){var c=function d(){i.forceUpdate(),u.removeEventListener("load",d)};u.addEventListener("load",c)}}var f=a[0]||l.children[0],h=f.clientHeight;return h>0?h:null}return null});var s={initialized:!1,previousItem:r.selectedItem,selectedItem:r.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:r.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return i.animationHandler=typeof r.animationHandler=="function"&&r.animationHandler||r.animationHandler==="fade"&&ld.fadeAnimationHandler||ld.slideAnimationHandler,i.state=gi(gi({},s),i.animationHandler(r,s)),i}return Q3(n,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(i,s){!i.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!i.autoFocus&&this.props.autoFocus&&this.forceFocus(),s.swiping&&!this.state.swiping&&this.setState(gi({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&Et.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,zf.default)().addEventListener("resize",this.updateSizes),(0,zf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,Bf.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,zf.default)().removeEventListener("resize",this.updateSizes),(0,zf.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,Bf.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?Et.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=gi(gi({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=gi(gi({},c),{},{pointerEvents:"none"}));var f={ref:function(d){return s.setItemsRef(d,l)},key:"itemKey"+l+(i?"clone":""),className:ys.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return Et.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?Et.default.createElement("ul",{className:"control-dots"},Et.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?Et.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,Et.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||Et.Children.count(this.props.children)===0?null:Et.default.createElement(X3.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||Et.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&Et.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&Et.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&E>=s}function v(){var C=Pg();if(x(C))return g(C);l=setTimeout(v,m(C))}function g(C){return l=void 0,h&&r?d(C):(r=i=void 0,o)}function y(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function k(){return l===void 0?o:g(Pg())}function b(){var C=Pg(),T=x(C);if(r=arguments,i=this,a=C,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(v,e),d(a)}return l===void 0&&(l=setTimeout(v,e)),o}return b.cancel=y,b.flush=k,b}var iT=CF;const sT=Ri(iT);function In(t,e,n,r,i=!1){const s=w.useRef();s.current=e,w.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const o=n,l=a=>{var u;(u=s.current)==null||u.call(o,a)};return o.addEventListener(t,l,{passive:r,capture:i}),()=>{o.removeEventListener(t,l,{capture:i})}},[t,n,r,i])}function _l(t,e){return t===void 0?void 0:e}const TF=Math.PI;function kx(t){return t*TF/180}const oT=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),lT=(t,e,n,r,i)=>{switch(t){case"left":return Math.floor(e)+r+i/2;case"center":return Math.floor(e+n/2);case"right":return Math.floor(e+n)-r-i/2}},aT=(t,e,n)=>Math.min(t,e-n*2),uT=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,Iv=t=>{const e=t.fgColor??"currentColor";return w.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},w.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),w.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},EF=t=>{const e=t.fgColor??"currentColor";return w.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},w.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function MF(t,e,n){const[r,i]=w.useState(t),s=w.useRef(!0);w.useEffect(()=>()=>{s.current=!1},[]);const o=w.useRef(sT(l=>{s.current&&i(l)},n));return w.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const AF="֑-߿יִ-﷽ﹰ-ﻼ",RF="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",OF=new RegExp("^[^"+RF+"]*["+AF+"]");function Dv(t){return OF.test(t)?"rtl":"not-rtl"}let $f;function m0(){if(typeof document>"u")return 0;if($f!==void 0)return $f;const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.id="testScrollbar",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.append(t),document.body.append(e);const n=t.offsetWidth;e.style.overflow="scroll";let r=t.offsetWidth;return n===r&&(r=e.clientWidth),e.remove(),$f=n-r,$f}const Fo=Symbol();function PF(t){const e=w.useRef([Fo,t]);e.current[1]!==t&&(e.current[0]=t),e.current[1]=t;const[n,r]=w.useState(t),[,i]=w.useState(),s=w.useCallback(l=>{const a=e.current[0];a!==Fo&&(l=typeof l=="function"?l(a):l,l===a)||(a!==Fo&&i({}),r(u=>typeof l=="function"?l(a===Fo?u:a):l),e.current[0]=Fo)},[]),o=w.useCallback(()=>{e.current[0]=Fo,i({})},[]);return[e.current[0]===Fo?n:e.current[0],s,o]}function cT(t){if(t.length===0)return"";let e=0,n=0;for(const r of t){if(n+=r.length,n>1e4)break;e++}return t.slice(0,e).join(", ")}function IF(t){const e=w.useRef(t);return Sa(t,e.current)||(e.current=t),e.current}const DF=t=>{const{urls:e,canWrite:n,onEditClick:r,renderImage:i}=t,s=e.filter(l=>l!=="");if(s.length===0)return null;const o=s.length>1;return w.createElement(l3,{"data-testid":"GDG-default-image-overlay-editor"},w.createElement(Z2.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},s.map(l=>{const a=(i==null?void 0:i(l))??w.createElement("img",{draggable:!1,src:l});return w.createElement("div",{className:"gdg-centering-container",key:l},a)})),n&&r&&w.createElement("button",{className:"gdg-edit-icon",onClick:r},w.createElement(Iv,null)))};function fT(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let pl=fT();function _F(t){pl=t}const hT=/[&<>"']/,NF=new RegExp(hT.source,"g"),dT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,LF=new RegExp(dT.source,"g"),FF={"&":"&","<":"<",">":">",'"':""","'":"'"},Sx=t=>FF[t];function Vn(t,e){if(e){if(hT.test(t))return t.replace(NF,Sx)}else if(dT.test(t))return t.replace(LF,Sx);return t}const BF=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function pT(t){return t.replace(BF,(e,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const zF=/(^|[^\[])\^/g;function Nt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(zF,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const $F=/[^\w:]/g,HF=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Cx(t,e,n){if(t){let r;try{r=decodeURIComponent(pT(n)).replace($F,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!HF.test(n)&&(n=UF(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Hf={},jF=/^[^:]+:\/*[^/]*$/,WF=/^([^:]+:)[\s\S]*$/,VF=/^([^:]+:\/*[^/]*)[\s\S]*$/;function UF(t,e){Hf[" "+t]||(jF.test(t)?Hf[" "+t]=t+"/":Hf[" "+t]=Eh(t,"/",!0)),t=Hf[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(WF,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(VF,"$1")+e:t+e}const ud={exec:function(){}};function Tx(t,e){const n=t.replace(/\|/g,(s,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(/ \|/);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length1;)e&1&&(n+=t),e>>=1,t+=t;return n+t}function Mx(t,e,n,r){const i=e.href,s=e.title?Vn(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:i,title:s,text:Vn(o)}}function GF(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` +*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function ad(t){return ad=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},ad(t)}function Gn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var P3=function(e){return e.hasOwnProperty("key")},Pv=function(t){M3(n,t);var e=A3(n);function n(r){var i;return C3(this,n),i=e.call(this,r),Gn(rr(i),"itemsWrapperRef",void 0),Gn(rr(i),"itemsListRef",void 0),Gn(rr(i),"thumbsRef",void 0),Gn(rr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),Gn(rr(i),"setItemsListRef",function(s){i.itemsListRef=s}),Gn(rr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),Gn(rr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=mi.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,b3.outerWidth)(i.thumbsRef[0]),a=Math.floor(o/l),u=a0&&(o=0),u===f&&o<0&&(o=0);var h=i.itemsWrapperRef.clientWidth,d=u+100/(h/o);return i.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(p){i.itemsListRef.style[p]=(0,vx.default)(d,"%",i.props.axis)}),!0}),Gn(rr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),Gn(rr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),Gn(rr(i),"moveTo",function(s){s=s<0?0:s,s=s>=i.state.lastPosition?i.state.lastPosition:s,i.setState({firstItem:s})}),i.state={selectedItem:r.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},i}return E3(n,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(i){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==i.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,zf.default)().addEventListener("resize",this.updateSizes),(0,zf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,zf.default)().removeEventListener("resize",this.updateSizes),(0,zf.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(i){var s=i;return i>=this.state.lastPosition&&(s=this.state.lastPosition),i1,o=this.state.showArrows&&this.state.firstItem>0,l=this.state.showArrows&&this.state.firstItemo);if(l)return s<0?e.centerMode&&e.centerSlidePercentage&&e.axis==="horizontal"?r.itemListStyle=(0,Qi.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,Qi.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,Qi.setPosition)(0,e.axis)),r;var a=(0,Qi.getPosition)(i,e),u=(0,H3.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=Wo(Wo({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};Yi.slideAnimationHandler=V3;var U3=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=sT.Children.count(n.children),a=0,u=(0,Qi.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,Qi.getPosition)(l-1,n)-100:(0,Qi.getPosition)(l-1,n),f=o?e.x:e.y,h=f;u===a&&f>0&&(h=0),u===c&&f<0&&(h=0);var d=u+100/(r.itemSize/h),p=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&p&&(r.selectedItem===0&&d>-100?d-=l*100:r.selectedItem===l-1&&d<-l*100&&(d+=l*100)),(!n.preventMovementUntilSwipeScrollTolerance||p||r.swipeMovementStarted)&&(r.swipeMovementStarted||i({swipeMovementStarted:!0}),s.itemListStyle=(0,Qi.setPosition)(d,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};Yi.slideSwipeAnimationHandler=U3;var K3=function(e,n){var r=(0,Qi.getPosition)(n.selectedItem,e),i=(0,Qi.setPosition)(r,e.axis);return{itemListStyle:i}};Yi.slideStopSwipingHandler=K3;var X3=function(e,n){var r=e.transitionTime+"ms",i="ease-in-out",s={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:i,msTransitionTimingFunction:i,MozTransitionTimingFunction:i,WebkitTransitionTimingFunction:i,OTransitionTimingFunction:i};return n.swiping||(s=Wo(Wo({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:Wo(Wo({},s),{},{opacity:1,position:"relative"}),prevStyle:Wo({},s)}};Yi.fadeAnimationHandler=X3;Object.defineProperty(fp,"__esModule",{value:!0});fp.default=void 0;var Rt=Y3(w),G3=Wc(Ov),ys=Wc($c),q3=Wc(Hc),$f=Wc(pp),Hf=Wc(jc),Pu=Dr,ud=Yi;function Wc(t){return t&&t.__esModule?t:{default:t}}function oT(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return oT=function(){return t},t}function Y3(t){if(t&&t.__esModule)return t;if(t===null||Uu(t)!=="object"&&typeof t!="function")return{default:t};var e=oT();if(e&&e.has(t))return e.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=r?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=t[i]}return n.default=t,e&&e.set(t,n),n}function Uu(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Uu=function(n){return typeof n}:Uu=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Uu(t)}function m0(){return m0=Object.assign||function(t){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function cd(t){return cd=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},cd(t)}function ht(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Iv=function(t){eF(n,t);var e=tF(n);function n(r){var i;Q3(this,n),i=e.call(this,r),ht(mt(i),"thumbsRef",void 0),ht(mt(i),"carouselWrapperRef",void 0),ht(mt(i),"listRef",void 0),ht(mt(i),"itemsRef",void 0),ht(mt(i),"timer",void 0),ht(mt(i),"animationHandler",void 0),ht(mt(i),"setThumbsRef",function(o){i.thumbsRef=o}),ht(mt(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),ht(mt(i),"setListRef",function(o){i.listRef=o}),ht(mt(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),ht(mt(i),"autoPlay",function(){Rt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),ht(mt(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),ht(mt(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),ht(mt(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),ht(mt(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),ht(mt(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,$f.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,$f.default)().activeElement)):!1}),ht(mt(i),"navigateWithKeyboard",function(o){if(i.isFocusWithinTheCarousel()){var l=i.props.axis,a=l==="horizontal",u={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},c=a?u.ArrowRight:u.ArrowDown,f=a?u.ArrowLeft:u.ArrowUp;c===o.keyCode?i.increment():f===o.keyCode&&i.decrement()}}),ht(mt(i),"updateSizes",function(){if(!(!i.state.initialized||!i.itemsRef||i.itemsRef.length===0)){var o=i.props.axis==="horizontal",l=i.itemsRef[0];if(l){var a=o?l.clientWidth:l.clientHeight;i.setState({itemSize:a}),i.thumbsRef&&i.thumbsRef.updateSizes()}}}),ht(mt(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),ht(mt(i),"handleClickItem",function(o,l){if(Rt.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),ht(mt(i),"handleOnChange",function(o,l){Rt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),ht(mt(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),ht(mt(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),ht(mt(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),ht(mt(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(mt(i)));return i.setState(yi({},a)),!!Object.keys(a).length}),ht(mt(i),"decrement",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem-(typeof o=="number"?o:1))}),ht(mt(i),"increment",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem+(typeof o=="number"?o:1))}),ht(mt(i),"moveTo",function(o){if(typeof o=="number"){var l=Rt.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),ht(mt(i),"onClickNext",function(){i.increment(1)}),ht(mt(i),"onClickPrev",function(){i.decrement(1)}),ht(mt(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),ht(mt(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),ht(mt(i),"changeItem",function(o){return function(l){(!(0,Pu.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),ht(mt(i),"selectItem",function(o){i.setState(yi({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,Rt.Children.toArray(i.props.children)[o.selectedItem])}),ht(mt(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),ht(mt(i),"getVariableItemHeight",function(o){var l=i.itemsRef&&i.itemsRef[o];if(i.state.hasMount&&l&&l.children.length){var a=l.children[0].getElementsByTagName("img")||[];if(a.length>0){var u=a[0];if(!u.complete){var c=function d(){i.forceUpdate(),u.removeEventListener("load",d)};u.addEventListener("load",c)}}var f=a[0]||l.children[0],h=f.clientHeight;return h>0?h:null}return null});var s={initialized:!1,previousItem:r.selectedItem,selectedItem:r.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:r.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return i.animationHandler=typeof r.animationHandler=="function"&&r.animationHandler||r.animationHandler==="fade"&&ud.fadeAnimationHandler||ud.slideAnimationHandler,i.state=yi(yi({},s),i.animationHandler(r,s)),i}return Z3(n,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(i,s){!i.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!i.autoFocus&&this.props.autoFocus&&this.forceFocus(),s.swiping&&!this.state.swiping&&this.setState(yi({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&Rt.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,Hf.default)().addEventListener("resize",this.updateSizes),(0,Hf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,$f.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,Hf.default)().removeEventListener("resize",this.updateSizes),(0,Hf.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,$f.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?Rt.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=yi(yi({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=yi(yi({},c),{},{pointerEvents:"none"}));var f={ref:function(d){return s.setItemsRef(d,l)},key:"itemKey"+l+(i?"clone":""),className:ys.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return Rt.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?Rt.default.createElement("ul",{className:"control-dots"},Rt.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?Rt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,Rt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||Rt.Children.count(this.props.children)===0?null:Rt.default.createElement(q3.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||Rt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&Rt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&Rt.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&E>=s}function v(){var C=Dg();if(x(C))return g(C);l=setTimeout(v,m(C))}function g(C){return l=void 0,h&&r?d(C):(r=i=void 0,o)}function y(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function k(){return l===void 0?o:g(Dg())}function b(){var C=Dg(),T=x(C);if(r=arguments,i=this,a=C,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(v,e),d(a)}return l===void 0&&(l=setTimeout(v,e)),o}return b.cancel=y,b.flush=k,b}var lT=EF;const aT=Pi(lT);function Fn(t,e,n,r,i=!1){const s=w.useRef();s.current=e,w.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const o=n,l=a=>{var u;(u=s.current)==null||u.call(o,a)};return o.addEventListener(t,l,{passive:r,capture:i}),()=>{o.removeEventListener(t,l,{capture:i})}},[t,n,r,i])}function _l(t,e){return t===void 0?void 0:e}const MF=Math.PI;function Cx(t){return t*MF/180}const uT=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),cT=(t,e,n,r,i)=>{switch(t){case"left":return Math.floor(e)+r+i/2;case"center":return Math.floor(e+n/2);case"right":return Math.floor(e+n)-r-i/2}},fT=(t,e,n)=>Math.min(t,e-n*2),hT=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,_v=t=>{const e=t.fgColor??"currentColor";return w.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},w.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),w.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},AF=t=>{const e=t.fgColor??"currentColor";return w.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},w.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function RF(t,e,n){const[r,i]=w.useState(t),s=w.useRef(!0);w.useEffect(()=>()=>{s.current=!1},[]);const o=w.useRef(aT(l=>{s.current&&i(l)},n));return w.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const OF="֑-߿יִ-﷽ﹰ-ﻼ",PF="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",IF=new RegExp("^[^"+PF+"]*["+OF+"]");function Nv(t){return IF.test(t)?"rtl":"not-rtl"}let jf;function v0(){if(typeof document>"u")return 0;if(jf!==void 0)return jf;const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.id="testScrollbar",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.append(t),document.body.append(e);const n=t.offsetWidth;e.style.overflow="scroll";let r=t.offsetWidth;return n===r&&(r=e.clientWidth),e.remove(),jf=n-r,jf}const Fo=Symbol();function DF(t){const e=w.useRef([Fo,t]);e.current[1]!==t&&(e.current[0]=t),e.current[1]=t;const[n,r]=w.useState(t),[,i]=w.useState(),s=w.useCallback(l=>{const a=e.current[0];a!==Fo&&(l=typeof l=="function"?l(a):l,l===a)||(a!==Fo&&i({}),r(u=>typeof l=="function"?l(a===Fo?u:a):l),e.current[0]=Fo)},[]),o=w.useCallback(()=>{e.current[0]=Fo,i({})},[]);return[e.current[0]===Fo?n:e.current[0],s,o]}function dT(t){if(t.length===0)return"";let e=0,n=0;for(const r of t){if(n+=r.length,n>1e4)break;e++}return t.slice(0,e).join(", ")}function _F(t){const e=w.useRef(t);return Sa(t,e.current)||(e.current=t),e.current}const NF=t=>{const{urls:e,canWrite:n,onEditClick:r,renderImage:i}=t,s=e.filter(l=>l!=="");if(s.length===0)return null;const o=s.length>1;return w.createElement(u3,{"data-testid":"GDG-default-image-overlay-editor"},w.createElement(nT.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},s.map(l=>{const a=(i==null?void 0:i(l))??w.createElement("img",{draggable:!1,src:l});return w.createElement("div",{className:"gdg-centering-container",key:l},a)})),n&&r&&w.createElement("button",{className:"gdg-edit-icon",onClick:r},w.createElement(_v,null)))};function pT(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let pl=pT();function LF(t){pl=t}const gT=/[&<>"']/,FF=new RegExp(gT.source,"g"),mT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,BF=new RegExp(mT.source,"g"),zF={"&":"&","<":"<",">":">",'"':""","'":"'"},Tx=t=>zF[t];function qn(t,e){if(e){if(gT.test(t))return t.replace(FF,Tx)}else if(mT.test(t))return t.replace(BF,Tx);return t}const $F=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function yT(t){return t.replace($F,(e,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const HF=/(^|[^\[])\^/g;function Bt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(HF,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const jF=/[^\w:]/g,WF=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ex(t,e,n){if(t){let r;try{r=decodeURIComponent(yT(n)).replace(jF,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!WF.test(n)&&(n=XF(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Wf={},VF=/^[^:]+:\/*[^/]*$/,UF=/^([^:]+:)[\s\S]*$/,KF=/^([^:]+:\/*[^/]*)[\s\S]*$/;function XF(t,e){Wf[" "+t]||(VF.test(t)?Wf[" "+t]=t+"/":Wf[" "+t]=Ah(t,"/",!0)),t=Wf[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(UF,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(KF,"$1")+e:t+e}const fd={exec:function(){}};function Mx(t,e){const n=t.replace(/\|/g,(s,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(/ \|/);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length1;)e&1&&(n+=t),e>>=1,t+=t;return n+t}function Rx(t,e,n,r){const i=e.href,s=e.title?qn(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:i,title:s,text:qn(o)}}function YF(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` `).map(i=>{const s=i.match(/^\s+/);if(s===null)return i;const[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(` -`)}class _v{constructor(e){this.options=e||pl}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Eh(r,` -`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=GF(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:i}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const i=Eh(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:n[0]}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r,i,s,o,l,a,u,c,f,h,d,p,m=n[1].trim();const x=m.length>1,v={type:"list",raw:"",ordered:x,start:x?+m.slice(0,-1):"",loose:!1,items:[]};m=x?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=x?m:"[*+-]");const g=new RegExp(`^( {0,3}${m})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(n=g.exec(e))||this.rules.block.hr.test(e)));){if(r=n[0],e=e.substring(r.length),c=n[2].split(` +`)}class Lv{constructor(e){this.options=e||pl}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Ah(r,` +`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=YF(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:i}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const i=Ah(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:n[0]}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r,i,s,o,l,a,u,c,f,h,d,p,m=n[1].trim();const x=m.length>1,v={type:"list",raw:"",ordered:x,start:x?+m.slice(0,-1):"",loose:!1,items:[]};m=x?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=x?m:"[*+-]");const g=new RegExp(`^( {0,3}${m})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(n=g.exec(e))||this.rules.block.hr.test(e)));){if(r=n[0],e=e.substring(r.length),c=n[2].split(` `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=e.split(` `,1)[0],this.options.pedantic?(o=2,d=c.trimLeft()):(o=n[2].search(/[^ ]/),o=o>4?1:o,d=c.slice(o),o+=n[1].length),a=!1,!c&&/^ *$/.test(f)&&(r+=f+` `,e=e.substring(f.length+1),p=!0),!p){const k=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),T=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(h=e.split(` `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(C.test(f)||T.test(f)||k.test(f)||b.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())d+=` `+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||C.test(c)||T.test(c)||b.test(c))break;d+=` `+f}!a&&!f.trim()&&(a=!0),r+=h+` -`,e=e.substring(h.length+1),c=f.slice(o)}}v.loose||(u?v.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(d),i&&(s=i[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),v.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:d}),v.raw+=r}v.items[v.items.length-1].raw=r.trimRight(),v.items[v.items.length-1].text=d.trimRight(),v.raw=v.raw.trimRight();const y=v.items.length;for(l=0;lC.type==="space"),b=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));v.loose=b}if(v.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:i,title:s}}}table(e){const n=this.rules.block.table.exec(e);if(n){const r={type:"table",header:Tx(n[1]).map(i=>({text:i})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(` -`):[]};if(r.header.length===r.align.length){r.raw=n[0];let i=r.align.length,s,o,l,a;for(s=0;s({text:u}));for(i=r.header.length,o=0;o/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Vn(n[0]):n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;const o=Eh(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=KF(n[2],"()");if(o>-1){const a=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let i=n[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=n[3]?n[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),Mx(n,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=n[i.toLowerCase()],!i){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return Mx(r,i,r[0],this.lexer)}}emStrong(e,n,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const o=i[0].length-1;let l,a,u=o,c=0;const f=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*e.length+o);(i=f.exec(n))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=l.length,i[3]||i[4]){u+=a;continue}else if((i[5]||i[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const h=e.slice(0,o+i.index+(i[0].length-l.length)+a);if(Math.min(o,a)%2){const p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}const d=h.slice(2,-2);return{type:"strong",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=Vn(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e,n){const r=this.rules.inline.autolink.exec(e);if(r){let i,s;return r[2]==="@"?(i=Vn(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=Vn(r[1]),s=i),{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e,n){let r;if(r=this.rules.inline.url.exec(e)){let i,s;if(r[2]==="@")i=Vn(this.options.mangle?n(r[0]):r[0]),s="mailto:"+i;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);i=Vn(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,n){const r=this.rules.inline.text.exec(e);if(r){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Vn(r[0]):r[0]:i=Vn(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const Ve={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:ud,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Ve.def=Nt(Ve.def).replace("label",Ve._label).replace("title",Ve._title).getRegex();Ve.bullet=/(?:[*+-]|\d{1,9}[.)])/;Ve.listItemStart=Nt(/^( *)(bull) */).replace("bull",Ve.bullet).getRegex();Ve.list=Nt(Ve.list).replace(/bull/g,Ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ve.def.source+")").getRegex();Ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";Ve._comment=/|$)/;Ve.html=Nt(Ve.html,"i").replace("comment",Ve._comment).replace("tag",Ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Ve.paragraph=Nt(Ve._paragraph).replace("hr",Ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ve._tag).getRegex();Ve.blockquote=Nt(Ve.blockquote).replace("paragraph",Ve.paragraph).getRegex();Ve.normal={...Ve};Ve.gfm={...Ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Ve.gfm.table=Nt(Ve.gfm.table).replace("hr",Ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ve._tag).getRegex();Ve.gfm.paragraph=Nt(Ve._paragraph).replace("hr",Ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ve.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ve._tag).getRegex();Ve.pedantic={...Ve.normal,html:Nt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ud,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Nt(Ve.normal._paragraph).replace("hr",Ve.hr).replace("heading",` *#{1,6} *[^ -]`).replace("lheading",Ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const Pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ud,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ud,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Pe.punctuation=Nt(Pe.punctuation).replace(/punctuation/g,Pe._punctuation).getRegex();Pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Pe._comment=Nt(Ve._comment).replace("(?:-->|$)","-->").getRegex();Pe.emStrong.lDelim=Nt(Pe.emStrong.lDelim).replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimAst=Nt(Pe.emStrong.rDelimAst,"g").replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimUnd=Nt(Pe.emStrong.rDelimUnd,"g").replace(/punct/g,Pe._punctuation).getRegex();Pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;Pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;Pe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;Pe.autolink=Nt(Pe.autolink).replace("scheme",Pe._scheme).replace("email",Pe._email).getRegex();Pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;Pe.tag=Nt(Pe.tag).replace("comment",Pe._comment).replace("attribute",Pe._attribute).getRegex();Pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Pe.link=Nt(Pe.link).replace("label",Pe._label).replace("href",Pe._href).replace("title",Pe._title).getRegex();Pe.reflink=Nt(Pe.reflink).replace("label",Pe._label).replace("ref",Ve._label).getRegex();Pe.nolink=Nt(Pe.nolink).replace("ref",Ve._label).getRegex();Pe.reflinkSearch=Nt(Pe.reflinkSearch,"g").replace("reflink",Pe.reflink).replace("nolink",Pe.nolink).getRegex();Pe.normal={...Pe};Pe.pedantic={...Pe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Nt(/^!?\[(label)\]\((.*?)\)/).replace("label",Pe._label).getRegex(),reflink:Nt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Pe._label).getRegex()};Pe.gfm={...Pe.normal,escape:Nt(Pe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class wo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pl,this.options.tokenizer=this.options.tokenizer||new _v,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Ve.normal,inline:Pe.normal};this.options.pedantic?(n.block=Ve.pedantic,n.inline=Pe.pedantic):this.options.gfm&&(n.block=Ve.gfm,this.options.breaks?n.inline=Pe.breaks:n.inline=Pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ve,inline:Pe}}static lex(e,n){return new wo(n).lex(e)}static lexInline(e,n){return new wo(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` +`,e=e.substring(h.length+1),c=f.slice(o)}}v.loose||(u?v.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(d),i&&(s=i[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),v.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:d}),v.raw+=r}v.items[v.items.length-1].raw=r.trimRight(),v.items[v.items.length-1].text=d.trimRight(),v.raw=v.raw.trimRight();const y=v.items.length;for(l=0;lC.type==="space"),b=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));v.loose=b}if(v.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:i,title:s}}}table(e){const n=this.rules.block.table.exec(e);if(n){const r={type:"table",header:Mx(n[1]).map(i=>({text:i})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(` +`):[]};if(r.header.length===r.align.length){r.raw=n[0];let i=r.align.length,s,o,l,a;for(s=0;s({text:u}));for(i=r.header.length,o=0;o/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):qn(n[0]):n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;const o=Ah(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=GF(n[2],"()");if(o>-1){const a=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let i=n[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=n[3]?n[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),Rx(n,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=n[i.toLowerCase()],!i){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return Rx(r,i,r[0],this.lexer)}}emStrong(e,n,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const o=i[0].length-1;let l,a,u=o,c=0;const f=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*e.length+o);(i=f.exec(n))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=l.length,i[3]||i[4]){u+=a;continue}else if((i[5]||i[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const h=e.slice(0,o+i.index+(i[0].length-l.length)+a);if(Math.min(o,a)%2){const p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}const d=h.slice(2,-2);return{type:"strong",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=qn(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e,n){const r=this.rules.inline.autolink.exec(e);if(r){let i,s;return r[2]==="@"?(i=qn(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=qn(r[1]),s=i),{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e,n){let r;if(r=this.rules.inline.url.exec(e)){let i,s;if(r[2]==="@")i=qn(this.options.mangle?n(r[0]):r[0]),s="mailto:"+i;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);i=qn(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,n){const r=this.rules.inline.text.exec(e);if(r){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):qn(r[0]):r[0]:i=qn(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const We={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:fd,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};We._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;We._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;We.def=Bt(We.def).replace("label",We._label).replace("title",We._title).getRegex();We.bullet=/(?:[*+-]|\d{1,9}[.)])/;We.listItemStart=Bt(/^( *)(bull) */).replace("bull",We.bullet).getRegex();We.list=Bt(We.list).replace(/bull/g,We.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+We.def.source+")").getRegex();We._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";We._comment=/|$)/;We.html=Bt(We.html,"i").replace("comment",We._comment).replace("tag",We._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();We.paragraph=Bt(We._paragraph).replace("hr",We.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",We._tag).getRegex();We.blockquote=Bt(We.blockquote).replace("paragraph",We.paragraph).getRegex();We.normal={...We};We.gfm={...We.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};We.gfm.table=Bt(We.gfm.table).replace("hr",We.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",We._tag).getRegex();We.gfm.paragraph=Bt(We._paragraph).replace("hr",We.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",We.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",We._tag).getRegex();We.pedantic={...We.normal,html:Bt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",We._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:fd,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Bt(We.normal._paragraph).replace("hr",We.hr).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",We.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const Pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:fd,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:fd,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Pe.punctuation=Bt(Pe.punctuation).replace(/punctuation/g,Pe._punctuation).getRegex();Pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Pe._comment=Bt(We._comment).replace("(?:-->|$)","-->").getRegex();Pe.emStrong.lDelim=Bt(Pe.emStrong.lDelim).replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimAst=Bt(Pe.emStrong.rDelimAst,"g").replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimUnd=Bt(Pe.emStrong.rDelimUnd,"g").replace(/punct/g,Pe._punctuation).getRegex();Pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;Pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;Pe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;Pe.autolink=Bt(Pe.autolink).replace("scheme",Pe._scheme).replace("email",Pe._email).getRegex();Pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;Pe.tag=Bt(Pe.tag).replace("comment",Pe._comment).replace("attribute",Pe._attribute).getRegex();Pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Pe.link=Bt(Pe.link).replace("label",Pe._label).replace("href",Pe._href).replace("title",Pe._title).getRegex();Pe.reflink=Bt(Pe.reflink).replace("label",Pe._label).replace("ref",We._label).getRegex();Pe.nolink=Bt(Pe.nolink).replace("ref",We._label).getRegex();Pe.reflinkSearch=Bt(Pe.reflinkSearch,"g").replace("reflink",Pe.reflink).replace("nolink",Pe.nolink).getRegex();Pe.normal={...Pe};Pe.pedantic={...Pe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Bt(/^!?\[(label)\]\((.*?)\)/).replace("label",Pe._label).getRegex(),reflink:Bt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Pe._label).getRegex()};Pe.gfm={...Pe.normal,escape:Bt(Pe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class wo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pl,this.options.tokenizer=this.options.tokenizer||new Lv,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:We.normal,inline:Pe.normal};this.options.pedantic?(n.block=We.pedantic,n.inline=Pe.pedantic):this.options.gfm&&(n.block=We.gfm,this.options.breaks?n.inline=Pe.breaks:n.inline=Pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:We,inline:Pe}}static lex(e,n){return new wo(n).lex(e)}static lexInline(e,n){return new wo(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` `),this.blockTokens(e,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(e,n=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,a,u)=>a+" ".repeat(u.length));let r,i,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(r=l.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=` `:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` `+r.raw,i.text+=` @@ -184,9 +184,9 @@ Error generating stack: `+s.message+` `+r.raw,i.text+=` `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&i.type==="text"?(i.raw+=` `+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+Ex("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+Ex("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,Ax)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,Ax))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let h;this.options.extensions.startInline.forEach(function(d){h=d.call({lexer:this},f),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,qF)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),a=!0,i=n[n.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}}class Nv{constructor(e){this.options=e||pl}code(e,n,r){const i=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(e,i);s!=null&&s!==e&&(r=!0,e=s)}return e=e.replace(/\n$/,"")+` -`,i?'
'+(r?e:Vn(e,!0))+`
-`:"
"+(r?e:Vn(e,!0))+`
+`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+Ax("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+Ax("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,Ox)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,Ox))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let h;this.options.extensions.startInline.forEach(function(d){h=d.call({lexer:this},f),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,QF)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),a=!0,i=n[n.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}}class Fv{constructor(e){this.options=e||pl}code(e,n,r){const i=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(e,i);s!=null&&s!==e&&(r=!0,e=s)}return e=e.replace(/\n$/,"")+` +`,i?'
'+(r?e:qn(e,!0))+`
+`:"
"+(r?e:qn(e,!0))+`
`}blockquote(e){return`
${e}
`}html(e){return e}heading(e,n,r,i){if(this.options.headerIds){const s=this.options.headerPrefix+i.slug(r);return`${e} @@ -204,56 +204,56 @@ ${e} `}tablerow(e){return` ${e} `}tablecell(e,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+` -`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
":"
"}del(e){return`${e}`}link(e,n,r){if(e=Cx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='",i}image(e,n,r){if(e=Cx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class gT{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,n,r){return""+r}image(e,n,r){return""+r}br(){return""}}class mT{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,n){let r=e,i=0;if(this.seen.hasOwnProperty(r)){i=this.seen[e];do i++,r=e+"-"+i;while(this.seen.hasOwnProperty(r))}return n||(this.seen[e]=i,this.seen[r]=0),r}slug(e,n={}){const r=this.serialize(e);return this.getNextSafeSlug(r,n.dryrun)}}let jc=class y0{constructor(e){this.options=e||pl,this.options.renderer=this.options.renderer||new Nv,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new gT,this.slugger=new mT}static parse(e,n){return new y0(n).parse(e)}static parseInline(e,n){return new y0(n).parseInline(e)}parse(e,n=!0){let r="",i,s,o,l,a,u,c,f,h,d,p,m,x,v,g,y,k,b,C;const T=e.length;for(i=0;i0&&g.tokens[0].type==="paragraph"?(g.tokens[0].text=b+" "+g.tokens[0].text,g.tokens[0].tokens&&g.tokens[0].tokens.length>0&&g.tokens[0].tokens[0].type==="text"&&(g.tokens[0].tokens[0].text=b+" "+g.tokens[0].tokens[0].text)):g.tokens.unshift({type:"text",text:b}):v+=b),v+=this.parse(g.tokens,x),h+=this.renderer.listitem(v,k,y);r+=this.renderer.list(h,p,m);continue}case"html":{r+=this.renderer.html(d.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(d.tokens));continue}case"text":{for(h=d.tokens?this.parseInline(d.tokens):d.text;i+1{if(r.message+=` -Please report this to https://github.com/markedjs/marked.`,t){const i="

An error occurred:

"+Vn(r.message+"",!0)+"
";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function yT(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...Ke.defaults,...s};const o=YF(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(XF(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Ke.walkTokens(a,r.walkTokens),h=e(a,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(d){f=d}return r.highlight=l,f?o(f):i(null,h)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;Ke.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(h,d){if(h)return u(h);d!=null&&d!==f.text&&(f.text=d,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(Ke.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&Ke.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function Ke(t,e,n){return yT(wo.lex,jc.parse)(t,e,n)}Ke.options=Ke.setOptions=function(t){return Ke.defaults={...Ke.defaults,...t},_F(Ke.defaults),Ke};Ke.getDefaults=fT;Ke.defaults=pl;Ke.use=function(...t){const e=Ke.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=Ke.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=Ke.defaults.renderer||new Nv;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=Ke.defaults.tokenizer||new _v;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=Ke.defaults.hooks||new cd;for(const s in n.hooks){const o=i[s];cd.passThroughHooks.has(s)?i[s]=l=>{if(Ke.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=Ke.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}Ke.setOptions(r)})};Ke.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(Ke,r)),r.type){case"table":{for(const i of r.header)n=n.concat(Ke.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(Ke.walkTokens(s.tokens,e));break}case"list":{n=n.concat(Ke.walkTokens(r.items,e));break}default:Ke.defaults.extensions&&Ke.defaults.extensions.childTokens&&Ke.defaults.extensions.childTokens[r.type]?Ke.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(Ke.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(Ke.walkTokens(r.tokens,e)))}return n};Ke.parseInline=yT(wo.lexInline,jc.parseInline);Ke.Parser=jc;Ke.parser=jc.parse;Ke.Renderer=Nv;Ke.TextRenderer=gT;Ke.Lexer=wo;Ke.lexer=wo.lex;Ke.Tokenizer=_v;Ke.Slugger=mT;Ke.Hooks=cd;Ke.parse=Ke;Ke.options;Ke.setOptions;Ke.use;Ke.walkTokens;Ke.parseInline;jc.parse;wo.lex;const QF=Br("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class JF extends kn.PureComponent{constructor(){super(...arguments);at(this,"targetElement",null);at(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=Ke(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),kn.createElement(QF,{ref:this.containerRefHook})}}const ZF=Br("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),e4=Br("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),t4=Br("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let Rx=0;const dp=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=w.useRef(null),f=n??"";Or(a!==void 0,"GrowingEntry must be a controlled input area");const[h]=w.useState(()=>"input-box-"+(Rx=(Rx+1)%1e7));w.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const m=f.toString().length;p.focus(),p.setSelectionRange(i?0:m,m)},[]),w.useLayoutEffect(()=>{var p;if(o!==void 0){const m=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(m[0],m[1])}},[o]);const d=w.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return w.createElement(t4,{className:"gdg-growing-entry"},w.createElement(e4,{className:u},f+` -`),w.createElement(ZF,{...l,className:(u??"")+" gdg-input",id:h,ref:c,onKeyDown:d,value:f,placeholder:e,dir:"auto"}))},Ig={};let Vs=null;function n4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function v0(t){const e=t.toLowerCase().trim();if(Ig[e]!==void 0)return Ig[e];Vs=Vs||n4(),Vs.style.color="#000",Vs.style.color=e;const n=getComputedStyle(Vs).color;Vs.style.color="#fff",Vs.style.color=e;const r=getComputedStyle(Vs).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),Ig[e]=i,i}function sl(t,e){const[n,r,i]=v0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const Ox=new Map;function Px(t,e){const n=`${t}-${e}`,r=Ox.get(n);if(r!==void 0)return r;const i=Pr(t,e);return Ox.set(n,i),i}function Pr(t,e){if(e===void 0)return t;const[n,r,i,s]=v0(t);if(s===1)return t;const[o,l,a,u]=v0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,h=(s*r+u*l*(1-s))/c,d=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${h}, ${d}, ${c})`}var Bl=new Map,Zl=new Map,w0=new Map;function r4(){Bl.clear(),w0.clear(),Zl.clear()}function i4(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let h=u[f],d=(l=n.get(f))!=null?l:i,p=d*h/a,m=c*p*r/h,x=d+m;n.set(f,x)}}function s4(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function Uu(t,e,n,r){var i,s;let o=Zl.get(n);if(r&&o!==void 0&&o.count>2e4){let u=w0.get(n);if(u===void 0&&(u=s4(t,o.size),w0.set(n,u)),o.count>5e5){let f=0;for(let h of e)f+=(i=u.get(h))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return i4(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),Zl.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)Zl.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;Zl.set(n,{count:o.count+e.length,size:f})}return l.width}function o4(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=Uu(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function l4(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Bl.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` -`),c=Zl.get(n),f=c===void 0?e.length:r/c.size*1.5,h=i&&c!==void 0&&c.count>2e4;for(let d of u){let p=Uu(t,d.slice(0,Math.max(0,f)),n,h),m=Math.min(d.length,f);if(p<=r)a.push(d);else{for(;p>r;){let x=o4(t,d,r,n,p,m,h),v=d.slice(0,Math.max(0,x));d=d.slice(v.length),a.push(v),p=Uu(t,d.slice(0,Math.max(0,f)),n,h),m=Math.min(d.length,f)}p>0&&a.push(d)}}return a=a.map((d,p)=>p===0?d.trimEnd():d.trim()),Bl.set(o,a),Bl.size>500&&Bl.delete(Bl.keys().next().value),a}function a4(t,e){return kn.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function vT(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function f4(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&Ix(t,e,s)&&i++;for(const o of n.current.rangeStack)Ix(t,e,o)&&i++;return i}function xT(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function Ca(t,e){let n=0;const r=xT(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return m}const h=s-u,d=t-(a??0);if(typeof o=="number"){const p=Math.floor((d-c)/o)+l;return p>=h?void 0:p}else{let p=c;for(let m=l;m"u";async function g4(){var t;p4||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Mh=0,Xu={},r4())}g4();function bT(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function Wc(t,e,n,r="middle"){const i=bT(t,e,r,n);let s=Xu[i];return s===void 0&&(s=e.measureText(t),Xu[i]=s,Mh++),Mh>1e4&&(Xu={},Mh=0),s}function m4(t,e){const n=bT(t,void 0,"middle",e);return Xu[n]}function Is(t,e){return typeof e!="string"&&(e=e.baseFontFull),y4(t,e)}function Dx(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const _x=[];function y4(t,e){for(const s of _x)if(s.key===e)return s.val;const n=Dx(t,"alphabetic"),i=-(Dx(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return _x.push({key:e,val:i}),i}function v4(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function x4(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=l4(t,e,c,i-l.cellHorizontalPadding*2,u??!1),h=ST(t,c),d=l.lineHeight*h,p=h+d*(f.length-1),m=p+l.cellVerticalPadding>s;m&&(t.save(),t.rect(n,r,i,s),t.clip());const x=r+s/2-p/2;let v=Math.max(r+l.cellVerticalPadding,x);for(const g of f)if(kT(t,g,n,v,i,h,o,l,a),v+=d,v>r+s)break;m&&t.restore()}function ws(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=w4(e,c));const h=Is(s,l),d=Dv(e)==="rtl";if(n===void 0&&d&&(n="right"),d&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?x4(s,e,a,u,c,f,h,l,n,i):kT(s,e,a,u,c,f,h,l,n),p&&(s.textAlign="start"),d&&(s.direction="inherit")}}function ts(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function b4(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function k4(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),h=u/f,d=c/f;return{x:u,y:a.y-l.y,len:f,nx:h,ny:d,ang:Math.atan2(d,h)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:h),m=1,x=!1;d<0?p<0?p=Math.PI+p:(p=Math.PI-p,m=-1,x=!0):p>0&&(m=-1,x=!0),i=a.radius!==void 0?a.radius:n;const v=p/2;let g=Math.abs(Math.cos(v)*i/Math.sin(v)),y;g>Math.min(c.len/2,f.len/2)?(g=Math.min(c.len/2,f.len/2),y=Math.abs(g*Math.sin(v)/Math.cos(v))):y=i;let k=a.x+f.nx*g,b=a.y+f.ny*g;k+=-f.ny*y*m,b+=f.nx*y*m,t.arc(k,b,y,c.ang+Math.PI/2*m,f.ang-Math.PI/2*m,x),o=a,a=u}t.closePath()}function b0(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p){const m={x:0,y:s+u,width:0,height:0};if(t>=d.length||e>=c||e<-2||t<0)return m;const x=s-i;if(t>=f){const v=o>t?-1:1,g=Ca(d);m.x+=g+a;for(let y=o;y!==t;y+=v)m.x+=d[v===1?y:y-1].width*v}else for(let v=0;v0&&xc(d[v-1].group,g)&&d[v-1].sticky===y;){const b=d[v-1];m.x-=b.width,m.width+=b.width,v--}let k=t;for(;k+1n&&(m.width=n-m.x)}}else if(e>=c-h){let v=c-e;for(m.y=r;v>0;){const g=e+v-1;m.height=typeof p=="number"?p:p(g),m.y-=m.height,v--}m.height+=1}else{const v=l>e?-1:1;if(typeof p=="number"){const g=e-l;m.y+=g*p}else for(let g=l;g!==e;g+=v)m.y+=p(g)*v;m.height=(typeof p=="number"?p:p(e))+1}return m}const Lv=1<<21;function xi(t,e){return(e+2)*Lv+t}function CT(t){return t%Lv}function Fv(t){return Math.floor(t/Lv)-2}function Bv(t){const e=CT(t),n=Fv(t);return[e,n]}class TT{constructor(){at(this,"visibleWindow",{x:0,y:0,width:0,height:0});at(this,"freezeCols",0);at(this,"freezeRows",[]);at(this,"isInWindow",e=>{const n=CT(e),r=Fv(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&Sa(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class S4 extends TT{constructor(){super(...arguments);at(this,"cache",new Map);at(this,"setValue",(n,r)=>{this.cache.set(xi(n[0],n[1]),r)});at(this,"getValue",n=>this.cache.get(xi(n[0],n[1])));at(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class Gu{constructor(e=[]){at(this,"cells");this.cells=new Set(e.map(n=>xi(n[0],n[1])))}add(e){this.cells.add(xi(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(xi(e[0],e[1]))}remove(e){this.cells.delete(xi(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(Fv(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const d=E4(t,h[r],e,a);return u=Math.max(u,d),d});if(c.length>5&&l){u=0;let h=0;for(const p of c)h+=p;const d=h/c.length;for(let p=0;p=d*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function M4(t,e,n,r,i,s,o,l,a){const u=w.useRef(e),c=w.useRef(n),f=w.useRef(o);u.current=e,c.current=n,f.current=o;const[h,d]=w.useMemo(()=>{if(typeof window>"u")return[null,null];const g=document.createElement("canvas");return g.style.display="none",g.style.opacity="0",g.style.position="fixed",[g,g.getContext("2d",{alpha:!1})]},[]);w.useLayoutEffect(()=>(h&&document.documentElement.append(h),()=>{h==null||h.remove()}),[h]);const p=w.useRef({}),m=w.useRef(),[x,v]=w.useState();return w.useLayoutEffect(()=>{const g=c.current;if(g===void 0||t.every(Lf))return;let y=Math.max(1,10-Math.floor(t.length/1e4)),k=0;y1&&(y--,k=1);const b={x:0,y:0,width:t.length,height:Math.min(u.current,y)},C={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const E=g(b,a.signal),A=k>0?g(C,a.signal):void 0;let P;typeof E=="object"?P=E:P=await ux(E),A!==void 0&&(typeof A=="object"?P=[...P,...A]:P=[...P,...await ux(A)]),m.current=t,v(P)})()},[a.signal,t]),w.useMemo(()=>{let y=t.every(Lf)?t:d===null?t.map(T=>Lf(T)?T:{...T,width:k0}):(d.font=f.current.baseFontFull,t.map((T,E)=>{if(Lf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(x===void 0||m.current!==t||T.id===void 0)return{...T,width:k0};const A=AT(d,o,T,E,x,i,s,!0,l);return p.current[T.id]=A.width,A})),k=0,b=0;const C=[];for(const[T,E]of y.entries())k+=E.width,E.grow!==void 0&&E.grow>0&&(b+=E.grow,C.push(T));if(k0){const T=[...y],E=r-k;let A=E;for(let P=0;P0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=R4(a),a in Nx)return;Nx[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":A4,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((h,d)=>{f.addEventListener("load",h),f.addEventListener("error",()=>d(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function O4(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var P4=O4,I4=P4,Dg=Pv;function D4(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Dg(n),n=n===n?n:0),e!==void 0&&(e=Dg(e),e=e===e?e:0),I4(Dg(t),e,n)}var _4=D4;const wi=Ri(_4);var N4="__lodash_hash_undefined__";function L4(t){return this.__data__.set(t,N4),this}var F4=L4;function B4(t){return this.__data__.has(t)}var z4=B4,$4=kv,H4=F4,j4=z4;function fd(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new $4;++e-1}var nB=tB;function rB(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=SB){var u=e?null:bB(t);if(u)return kB(u);o=!1,i=xB,a=new yB}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?_T(l,e-1,n,r,i):NB(i,l):r||(i[i.length]=l)}return i}var FB=_T,BB=FB;function zB(t){var e=t==null?0:t.length;return e?BB(t,1):[]}var $B=zB;const Bx=Ri($B);var HB=Math.ceil,jB=Math.max;function WB(t,e,n,r){for(var i=-1,s=jB(HB((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var VB=WB,UB=U2,KB=Ev;function XB(t){return t!=null&&KB(t.length)&&!UB(t)}var $v=XB,GB=xv,qB=$v,YB=Tv,QB=hl;function JB(t,e,n){if(!QB(n))return!1;var r=typeof e;return(r=="number"?qB(n)&&YB(e,n.length):r=="string"&&e in n)?GB(n[e],t):!1}var ZB=JB,ez=Pv,zx=1/0,tz=17976931348623157e292;function nz(t){if(!t)return t===0?t:0;if(t=ez(t),t===zx||t===-zx){var e=t<0?-1:1;return e*tz}return t===t?t:0}var rz=nz,iz=VB,sz=ZB,Ng=rz;function oz(t){return function(e,n,r){return r&&typeof r!="number"&&sz(e,n,r)&&(n=r=void 0),e=Ng(e),n===void 0?(n=e,e=0):n=Ng(n),r=r===void 0?e{m.drawImage(x,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(d,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function NT(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function pp(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let h=!1;for(;ul&&a(u,c,d,!1,o&&c===r-1)===!0){h=!0;break}u+=d,c++}if(!h){u=n;for(let d=0;d!d.sticky))==null?void 0:h.sourceIndex)??0;if(a>f){const d=Math.max(l,f);let p=e,m=r;for(let x=s.sourceIndex-1;x>=d;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=a;x++)m+=o[x].width;c={x:p,y:n,width:m,height:i}}if(f>l){const d=Math.min(a,f-1);let p=e,m=r;for(let x=s.sourceIndex-1;x>=l;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=d;x++)m+=o[x].width;u={x:p,y:n,width:m,height:i}}return[u,c]}function dz(t,e,n,r){if(r==="any")return BT(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),vT([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function hd(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function gp(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function BT(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function pz(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function gz(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,h=a>0?t.x+Math.floor(a/r)*r:t.x,d=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,m=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:h,y:p,width:d-h,height:m-p}}function mz(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,h]=i,{x:d,y:p,width:m,height:x}=t,v=[];if(m<=0||x<=0)return v;const g=d+m,y=p+x,k=dl,T=p+x>a,E=d>=s&&ds&&g<=l||dl,A=p>=o&&po&&y<=a||pa;if(E&&A){const D=Math.max(d,s),O=Math.max(p,o),_=Math.min(g,l),I=Math.min(y,a);v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:u,y:c,width:f-u+1,height:h-c+1}})}if(k&&b){const D=d,O=p,_=Math.min(g,s),I=Math.min(y,o);v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:0,y:0,width:u+1,height:c+1}})}if(b&&E){const D=Math.max(d,s),O=p,_=Math.min(g,l),I=Math.min(y,o);v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(b&&C){const D=Math.max(d,l),O=p,_=g,I=Math.min(y,o);v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&A){const D=d,O=Math.max(p,o),_=Math.min(g,s),I=Math.min(y,a);v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:0,y:c,width:u+1,height:h-c+1}})}if(C&&A){const D=Math.max(d,l),O=Math.max(p,o),_=g,I=Math.min(y,a);v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:f,y:c,width:n-f+1,height:h-c+1}})}if(k&&T){const D=d,O=Math.max(p,a),_=Math.min(g,s),I=y;v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:0,y:h,width:u+1,height:r-h+1}})}if(T&&E){const D=Math.max(d,s),O=Math.max(p,a),_=Math.min(g,l),I=y;v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:u,y:h,width:f-u+1,height:r-h+1}})}if(C&&T){const D=Math.max(d,l),O=Math.max(p,a),_=g,I=y;v.push({rect:{x:D,y:O,width:_-D,height:I-O},clip:{x:f,y:h,width:n-f+1,height:r-h+1}})}return v}const yz={kind:Se.Loading,allowOverlay:!1};function $x(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g,y,k,b,C,T,E,A,P,D,O,_,I,Y,U,ae,H){let te=(y==null?void 0:y.size)??Number.MAX_SAFE_INTEGER;const G=performance.now();let M=_.baseFontFull;t.font=M;const F={ctx:t},z=[0,0],j=x>0?gl(a,x,u):0;let B,ge;const we=NT(g);return Mo(e,l,s,o,i,(ue,_e,Je,qe,Ye)=>{const Qe=Math.max(0,qe-_e),et=_e+Qe,Ze=i+1,Ot=ue.width-Qe,Ie=r-i-1;if(g.length>0){let ve=!1;for(let pe=0;pe{t.save(),t.beginPath(),t.rect(et,Ze,Ot,Ie),t.clip()},Q=k.columns.hasIndex(ue.sourceIndex),ce=f(ue.group??"").overrideTheme,ne=ue.themeOverride===void 0&&ce===void 0?_:mo(_,ce,ue.themeOverride),oe=ne.baseFontFull;oe!==M&&(M=oe,t.font=oe),Te();let q;return pp(Ye,Je,r,a,u,x,v,we,(ve,pe,se,ke,Ne)=>{var nn,Tn,si;if(pe<0||(z[0]=ue.sourceIndex,z[1]=pe,y!==void 0&&!y.has(z)))return;if(g.length>0){let pt=!1;for(let Xt=0;Xttt.span!==void 0&&pt>=tt.span[0]&&pt<=tt.span[1]);Qn&&!p&&m?Jn=0:Qn&&m&&(Jn=Math.max(Jn,1)),ls&&Jn++,Qn||(De&&Jn++,Q&&!Ne&&Jn++);const as=tt.kind===Se.Protected?Kt.bgCellMedium:Kt.bgCell;let $t;if((ke||as!==_.bgCell)&&($t=Pr(as,$t)),Jn>0||Lt){Lt&&($t=Pr(Kt.bgHeader,$t));for(let pt=0;ptH&&!Jt){const pt=Kt.baseFontFull;pt!==M&&(t.font=pt,M=pt),q=zT(t,tt,ue.sourceIndex,pe,mt,An,ze,ve,rt,se,Jn>0,Kt,$t??Kt.bgCell,T,E,(Rn==null?void 0:Rn.hoverAmount)??0,P,O,G,D,q,I,Y,U,ae)}return ct&&t.restore(),tt.style==="faded"&&(t.globalAlpha=1),te--,Tt&&(t.restore(),(si=q==null?void 0:q.deprep)==null||si.call(q,F),q=void 0,Te(),M=oe,t.font=oe),te<=0}),t.restore(),te<=0}),B}const mu=[0,0],yu={x:0,y:0,width:0,height:0},Lg=[void 0,()=>{}];let S0=!1;function vz(){S0=!0}function zT(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g,y,k,b,C,T,E){var Y,U;let A,P;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(A=x[1][0],P=x[1][1]);let D;mu[0]=n,mu[1]=r,yu.x=o,yu.y=l,yu.width=a,yu.height=u,Lg[0]=C.getValue(mu),Lg[1]=ae=>C.setValue(mu,ae),S0=!1;const O={ctx:t,theme:f,col:n,row:r,cell:e,rect:yu,highlighted:c,cellFillColor:h,hoverAmount:m,frameTime:g,hoverX:A,drawState:Lg,hoverY:P,imageLoader:d,spriteManager:p,hyperWrapping:v,overrideCursor:A!==void 0?E:void 0,requestAnimationFrame:vz},_=v4(O,e.lastUpdated,g,k,i,s),I=T(e);if(I!==void 0){(k==null?void 0:k.renderer)!==I&&((Y=k==null?void 0:k.deprep)==null||Y.call(k,O),k=void 0);const ae=(U=I.drawPrep)==null?void 0:U.call(I,O,k);y!==void 0&&!Jl(O.cell)?y(O,()=>I.draw(O,e)):I.draw(O,e),D=ae===void 0?void 0:{deprep:ae==null?void 0:ae.deprep,fillStyle:ae==null?void 0:ae.fillStyle,font:ae==null?void 0:ae.font,renderer:I}}return(_||S0)&&(b==null||b(mu)),D}function Hv(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",h="square"){const d=Math.floor(i+o/2),p=h==="circle"?1e4:e.roundingRadius??4;let m=aT(c,o,e.cellVerticalPadding),x=m/2;const v=lT(f,r,s,e.cellHorizontalPadding,m),g=oT(v,d,m),y=uT(r+a,i+u,g);switch(n){case!0:{t.beginPath(),ts(t,v-m/2,d-m/2,m,m,p),h==="circle"&&(x*=.8,m*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(v-x+m/4.23,d-x+m/1.97),t.lineTo(v-x+m/2.42,d-x+m/1.44),t.lineTo(v-x+m/1.29,d-x+m/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case id:case!1:{t.beginPath(),ts(t,v-m/2+.5,d-m/2+.5,m-1,m-1,p),t.lineWidth=1,t.strokeStyle=y?e.textDark:e.textMedium,t.stroke();break}case Mv:{t.beginPath(),ts(t,v-m/2,d-m/2,m,m,p),t.fillStyle=y?e.textMedium:e.textLight,t.fill(),h==="circle"&&(x*=.8,m*=.8),t.beginPath(),t.moveTo(v-m/3,d),t.lineTo(v+m/3,d),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:wc()}}function wz(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g){const y=o+l;if(y<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,y);const[k,b]=(r==null?void 0:r[0])??[],C=f.headerFontFull;t.font=C,Mo(e,0,s,0,y,(T,E,A,P)=>{var F;if(x!==void 0&&!x.has([T.sourceIndex,-1]))return;const D=Math.max(0,P-E);t.save(),t.beginPath(),t.rect(E+D,l,T.width-D,o),t.clip();const O=m(T.group??"").overrideTheme,_=T.themeOverride===void 0&&O===void 0?f:mo(f,O,T.themeOverride);_.bgHeader!==f.bgHeader&&(t.fillStyle=_.bgHeader,t.fill()),_!==f&&(t.font=_.baseFontFull);const I=c.columns.hasIndex(T.sourceIndex),Y=a!==void 0||u,U=!Y&&b===-1&&k===T.sourceIndex,ae=Y?0:((F=d.find(z=>z.item[0]===T.sourceIndex&&z.item[1]===-1))==null?void 0:F.hoverAmount)??0,H=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,te=I?_.accentColor:H?_.bgHeaderHasFocus:_.bgHeader,G=n?l:0,M=T.sourceIndex===0?0:1;I?(t.fillStyle=te,t.fillRect(E+M,G,T.width-M,o)):(H||ae>0)&&(t.beginPath(),t.rect(E+M,G,T.width-M,o),H&&(t.fillStyle=_.bgHeaderHasFocus,t.fill()),ae>0&&(t.globalAlpha=ae,t.fillStyle=_.bgHeaderHovered,t.fill(),t.globalAlpha=1)),jT(t,E,G,T.width,o,T,I,_,U,H,ae,h,v,g),t.restore()}),n&&xz(t,e,i,s,l,r,f,h,d,p,m,x)}function xz(t,e,n,r,i,s,o,l,a,u,c,f){const[d,p]=(s==null?void 0:s[0])??[];let m=0;LT(e,n,r,i,(x,v,g,y,k,b)=>{if(f!==void 0&&!f.hasItemInRectangle({x:x[0],y:-2,width:x[1]-x[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(g,y,k,b),t.clip();const C=c(v),T=(C==null?void 0:C.overrideTheme)===void 0?o:mo(o,C.overrideTheme),E=p===-2&&d!==void 0&&d>=x[0]&&d<=x[1],A=E?T.bgHeaderHovered:T.bgHeader;if(A!==o.bgHeader&&(t.fillStyle=A,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,C!==void 0){let P=g;if(C.icon!==void 0&&(l.drawSprite(C.icon,"normal",t,P+8,(i-20)/2,20,T),P+=26),t.fillText(C.name,P+8,i/2+Is(t,o.headerFontFull)),C.actions!==void 0&&E){const D=HT({x:g,y,width:k,height:b},C.actions);t.beginPath();const O=D[0].x-10,_=g+k-O;t.rect(O,0,_,i);const I=t.createLinearGradient(O,0,O+_,0),Y=sl(A,0);I.addColorStop(0,Y),I.addColorStop(10/_,A),I.addColorStop(1,A),t.fillStyle=I,t.fill(),t.globalAlpha=.6;const[U,ae]=(s==null?void 0:s[1])??[-1,-1];for(let H=0;H35){const k=h?35:r-35,b=h?35*.7:r-35*.7,C=k/r,T=b/r,E=t.createLinearGradient(e,0,e+r,0),A=sl(m,0);E.addColorStop(h?1:0,m),E.addColorStop(C,m),E.addColorStop(T,A),E.addColorStop(h?0:1,A),t.fillStyle=E}else t.fillStyle=m;if(h&&(t.textAlign="right"),t.fillText(s.title,g,n+i/2+Is(t,l.headerFontFull)),h&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===sd.Triangle){t.beginPath();const y=d.x+d.width/2-5.5,k=d.y+d.height/2-3;k4(t,[{x:y,y:k},{x:y+11,y:k},{x:y+5.5,y:k+6}],1),t.fillStyle=m,t.fill()}else if(s.menuIcon===sd.Dots){t.beginPath();const y=d.x+d.width/2,k=d.y+d.height/2;b4(t,y,k),t.fillStyle=m,t.fill()}else{const y=d.x+(d.width-l.headerIconSize)/2,k=d.y+(d.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,y,k,l.headerIconSize,l)}}function jT(t,e,n,r,i,s,o,l,a,u,c,f,h,d){const p=Dv(s.title)==="rtl",m=$T(e,n,r,i,p);h!==void 0?h({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:m},()=>Hx(t,e,n,r,i,s,o,l,a,c,f,d,p,m)):Hx(t,e,n,r,i,s,o,l,a,c,f,d,p,m)}var bz=dl,kz=function(){try{var t=bz(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Sz=kz,jx=Sz;function Cz(t,e,n){e=="__proto__"&&jx?jx(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var Tz=Cz;function Ez(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,h=!0,d=n&D5?new R5:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;b+=k.width;const A=Math.max(b,T);A>r||(t.save(),t.beginPath(),t.rect(A,s+1,1e4,i-s-1),t.clip(),pp(E,C,i,u,c,p,m,y,(P,D,O,_)=>{if(!_&&x.length>0&&!x.some(H=>hd(b,P,1e4,O,H.x,H.y,H.width,H.height)))return;const I=h.hasIndex(D),Y=d.hasIndex(D);t.beginPath();const U=f==null?void 0:f(D),ae=U===void 0?g:mo(g,U);ae.bgCell!==g.bgCell&&(t.fillStyle=ae.bgCell,t.fillRect(b,P,1e4,O)),Y&&(t.fillStyle=ae.bgHeader,t.fillRect(b,P,1e4,O)),I&&(t.fillStyle=ae.accentLight,t.fillRect(b,P,1e4,O))}),t.restore())})}function C8(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,h=u?Ca(e):0;let d;if(h!==0&&(d=Px(f,a.bgCell),t.beginPath(),t.moveTo(h+.5,0),t.lineTo(h+.5,r),t.strokeStyle=d,t.stroke()),i>0){const p=f===c&&d!==void 0?d:Px(c,a.bgCell),m=gl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const ZT=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function T8(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p){var O;const m=p.bgCell,{minX:x,maxX:v,minY:g,maxY:y}=ZT(l,s,o),k=[],b=o-gl(d,h,u);let C=a,T=n,E=0;for(;C+i=g&&_<=y-1){const Y=c==null?void 0:c(T),U=Y==null?void 0:Y.bgCell;U!==void 0&&U!==m&&T>=d-h&&k.push({x,y:_,w:v-x,h:I,color:U})}C+=I,T0)for(let _=0;_=x&&Y<=v&&f(_+1)&&k.push({x:Y,y:E,w:I.width,h:P,color:U}),A+=I.width}if(k.length===0)return;let D;t.beginPath();for(let _=k.length-1;_>=0;_--){const I=k[_];D===void 0?D=I.color:I.color!==D&&(t.fillStyle=D,t.fill(),t.beginPath(),D=I.color),t.rect(I.x,I.y,I.w,I.h)}D!==void 0&&(t.fillStyle=D,t.fill()),t.beginPath()}function ab(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const O of a)t.rect(O.x+1,O.y+1,O.width-1,O.height-1);t.clip("evenodd")}const g=x.horizontalBorderColor??x.borderColor,y=x.borderColor,{minX:k,maxX:b,minY:C,maxY:T}=ZT(l,s,o),E=[];t.beginPath();let A=.5;for(let O=0;O=k&&I<=b&&d(O+1)&&E.push({x1:I,y1:Math.max(u,C),x2:I,y2:Math.min(o,T),color:y})}let P=o+.5;for(let O=m-p;O=C&&Y<=T-1){const U=h==null?void 0:h(_);E.push({x1:k,y1:Y,x2:b,y2:Y,color:(U==null?void 0:U.horizontalBorderColor)??(U==null?void 0:U.borderColor)??g})}O+=f(_),_++}}const D=k8(E,O=>O.color);for(const O of Object.keys(D)){t.strokeStyle=O;for(const _ of D[O])t.moveTo(_.x1,_.y1),t.lineTo(_.x2,_.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function E8(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g){const y=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),b=Math.max(i.cellYOffset,o);let C=0;if(typeof v=="number")C+=(b-k)*v;else for(let I=k;Ii.cellYOffset&&(C=-C),C+=a-i.translateY;const T=Math.min(i.cellXOffset,s),E=Math.max(i.cellXOffset,s);let A=0;for(let I=T;Ii.cellXOffset&&(A=-A),A+=l-i.translateX;const P=Ca(x);if(A!==0&&C!==0)return{regions:[]};const D=u>0?gl(h,u,v):0,O=c-P-Math.abs(A),_=f-d-D-Math.abs(C)-1;if(O>150&&_>150){const I={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(C>0?(I.sy=(d+1)*p,I.sh=_*p,I.dy=(C+d+1)*p,I.dh=_*p,y.push({x:0,y:d,width:c,height:C+1})):C<0&&(I.sy=(-C+d+1)*p,I.sh=_*p,I.dy=(d+1)*p,I.dh=_*p,y.push({x:0,y:f+C-D,width:c,height:-C+D})),A>0?(I.sx=P*p,I.sw=O*p,I.dx=(A+P)*p,I.dw=O*p,y.push({x:P-1,y:0,width:A+2,height:f})):A<0&&(I.sx=(P-A)*p,I.sw=O*p,I.dx=P*p,I.dw=O*p,y.push({x:c+A,y:0,width:-A,height:f})),t.setTransform(1,0,0,1,0,0),g){if(P>0&&A!==0&&C===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const Y=P*p,U=f*p;t.drawImage(e,0,0,Y,U,0,0,Y,U)}if(D>0&&A===0&&C!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const Y=(f-D)*p,U=c*p,ae=D*p;t.drawImage(e,0,Y,U,ae,0,Y,U,ae)}}t.drawImage(e,I.sx,I.sy,I.sw,I.sh,I.dx,I.dy,I.dw,I.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:y}}function M8(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Mo(a,n,r,i,l,(f,h,d,p)=>{if(f.sourceIndex===u){const m=Math.max(h,p)+1;return c.push({x:m,y:0,width:s-m,height:o}),!0}}),c}function A8(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(x===void 0||x.length===0)return;const v=Ca(l),g=gl(d,h,f),y=[a,0,l.length,d-h],k=[v,0,e,n-g],b=x.map(T=>{const E=T.range,A=T.style??"dashed";return mz(E,y,e,n,k).map(P=>{const D=P.rect,O=b0(D.x,D.y,e,n,c,u+c,r,i,s,o,d,a,h,l,f),_=D.width===1&&D.height===1?O:b0(D.x+D.width-1,D.y+D.height-1,e,n,c,u+c,r,i,s,o,d,a,h,l,f);return D.x+D.width>=l.length&&(_.width-=1),D.y+D.height>=d&&(_.height-=1),{color:T.color,style:A,clip:P.clip,rect:gz({x:O.x,y:O.y,width:_.x+_.width-O.x,height:_.y+_.height-O.y},e,n,8)}})}),C=()=>{t.lineWidth=1;let T=!1;for(const E of b)for(const A of E)if((A==null?void 0:A.rect)!==void 0&&hd(0,0,e,n,A.rect.x,A.rect.y,A.rect.width,A.rect.height)){const P=T,D=!pz(A.clip,A.rect);D&&(t.save(),t.rect(A.clip.x,A.clip.y,A.clip.width,A.clip.height),t.clip()),A.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(A.style==="solid"||A.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=A.style==="solid-outline"?Pr(Pr(A.color,m.borderColor),m.bgCell):sl(A.color,1),t.strokeRect(A.rect.x+.5,A.rect.y+.5,A.rect.width-1,A.rect.height-1),D&&(t.restore(),T=P)}T&&t.setLineDash([])};return C(),C}function cb(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function zg(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x){if(c.current===void 0)return;const v=c.current.range,g=c.current.cell,y=[v.x+v.width-1,v.y+v.height-1];if(g[1]>=x&&y[1]>=x||!o.some(I=>I.sourceIndex===g[0]||I.sourceIndex===y[0]))return;const[b,C]=c.current.cell,T=h(c.current.cell),E=T.span??[b,b],A=C>=x-d,P=d>0&&!A?gl(x,d,f)-1:0,D=y[1];let O;if(Mo(o,r,i,s,u,(I,Y,U,ae,H)=>{if(I.sticky&&b>I.sourceIndex)return;const te=I.sourceIndexE[1],M=I.sourceIndex===y[0];if(!(!M&&(te||G)))return pp(H,U,n,x,f,d,p,void 0,(F,z,j)=>{if(z!==C&&z!==D)return;let B=Y,ge=I.width;if(T.span!==void 0){const ue=FT(T.span,Y,F,I.width,j,I,l),_e=I.sticky?ue[0]:ue[1];_e!==void 0&&(B=_e.x,ge=_e.width)}return z===D&&M&&m&&(O=()=>{var ue;ae>B&&!I.sticky&&(t.beginPath(),t.rect(ae,0,e-ae,n),t.clip()),t.beginPath(),t.rect(B+ge-4,F+j-4,4,4),t.fillStyle=((ue=I.themeOverride)==null?void 0:ue.accentColor)??a.accentColor,t.fill()}),O!==void 0}),O!==void 0}),O===void 0)return;const _=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-P),t.clip(),O==null||O(),t.restore()};return _(),_}function R8(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),LT(e,n,s,r,(u,c,f,h,d,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,h,d,p)}),Mo(e,l,s,o,i,(u,c,f,h)=>{const d=Math.max(0,h-c),p=c+d+1,m=u.width-d-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,m,i-r)}),t.clip())}function O8(t,e,n,r,i,s,o,l,a,u){let c=0;return Mo(t,s,r,i,n,(f,h,d,p,m)=>(pp(m,d,e,o,l,a,u,void 0,(x,v,g,y)=>{y||(c=Math.max(v,c))}),!0)),c}function fb(t,e){var ct;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:h,dragAndDropState:d,theme:p,drawFocus:m,headerHeight:x,groupHeaderHeight:v,disabledRows:g,rowHeight:y,verticalBorder:k,overrideCursor:b,isResizing:C,selection:T,fillHandle:E,freezeTrailingRows:A,rows:P,getCellContent:D,getGroupDetails:O,getRowThemeOverride:_,isFocused:I,drawHeaderCallback:Y,prelightCells:U,drawCellCallback:ae,highlightRegions:H,resizeCol:te,imageLoader:G,lastBlitData:M,hoverValues:F,hyperWrapping:z,hoverInfo:j,spriteManager:B,maxScaleFactor:ge,hasAppendRow:we,touchMode:ue,enqueue:_e,renderStateProvider:Je,getCellRenderer:qe,renderStrategy:Ye,bufferACtx:Qe,bufferBCtx:et,damage:Ze,minimumCellWidth:Ot}=t;if(i===0||s===0)return;const Ie=Ye==="double-buffer",Te=Math.min(ge,Math.ceil(window.devicePixelRatio??1)),Q=Ye!=="direct"&&A8(t,e),ce=n.canvas;(ce.width!==i*Te||ce.height!==s*Te)&&(ce.width=i*Te,ce.height=s*Te,ce.style.width=i+"px",ce.style.height=s+"px");const ne=r.canvas,oe=f?v+x:x,q=oe+1;(ne.width!==i*Te||ne.height!==q*Te)&&(ne.width=i*Te,ne.height=q*Te,ne.style.width=i+"px",ne.style.height=q+"px");const ve=Qe.canvas,pe=et.canvas;Ie&&(ve.width!==i*Te||ve.height!==s*Te)&&(ve.width=i*Te,ve.height=s*Te,M.current!==void 0&&(M.current.aBufferScroll=void 0)),Ie&&(pe.width!==i*Te||pe.height!==s*Te)&&(pe.width=i*Te,pe.height=s*Te,M.current!==void 0&&(M.current.bBufferScroll=void 0));const se=M.current;if(Q===!0&&o===(se==null?void 0:se.cellXOffset)&&l===(se==null?void 0:se.cellYOffset)&&a===(se==null?void 0:se.translateX)&&u===(se==null?void 0:se.translateY))return;let ke=null;Ie&&(ke=n);const Ne=r;let De;Ie?Ze!==void 0?De=(se==null?void 0:se.lastBuffer)==="b"?et:Qe:De=(se==null?void 0:se.lastBuffer)==="b"?Qe:et:De=n;const Lt=De.canvas,tt=Ie?Lt===ve?pe:ve:ce,ze=typeof y=="number"?()=>y:y;Ne.save(),De.save(),Ne.beginPath(),De.beginPath(),Ne.textBaseline="middle",De.textBaseline="middle",Te!==1&&(Ne.scale(Te,Te),De.scale(Te,Te));const rt=x0(c,o,i,d,a);let Tt=[];const Jt=m&&((ct=T.current)==null?void 0:ct.cell[1])===l&&u===0;let Yn=!1;if(H!==void 0){for(const mt of H)if(mt.style!=="no-outline"&&mt.range.y===l&&u===0){Yn=!0;break}}const xr=()=>{wz(Ne,rt,f,j,i,a,x,v,d,C,T,p,B,F,k,O,Ze,Y,ue),ab(Ne,rt,l,a,u,i,s,void 0,void 0,v,oe,ze,_,k,A,P,p,!0),Ne.beginPath(),Ne.moveTo(0,q-.5),Ne.lineTo(i,q-.5),Ne.strokeStyle=Pr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),Ne.stroke(),Yn&&ub(Ne,i,s,o,l,a,u,c,h,x,v,y,A,P,H,p),Jt&&zg(Ne,i,s,l,a,u,rt,c,p,oe,T,ze,D,A,we,E,P)};if(Ze!==void 0){const mt=rt[rt.length-1].sourceIndex+1,An=Ze.hasItemInRegion([{x:o,y:-2,width:mt,height:2},{x:o,y:l,width:mt,height:300},{x:0,y:l,width:h,height:300},{x:0,y:-2,width:h,height:2},{x:o,y:P-A,width:mt,height:A,when:A>0}]),Rn=nn=>{$x(nn,rt,c,s,oe,a,u,l,P,ze,D,O,_,g,I,m,A,we,Tt,Ze,T,U,H,G,B,F,j,ae,z,p,_e,Je,qe,b,Ot);const Tn=T.current;E&&m&&Tn!==void 0&&Ze.has(wT(Tn.range))&&zg(nn,i,s,l,a,u,rt,c,p,oe,T,ze,D,A,we,E,P)};An&&(Rn(De),ke!==null&&(ke.save(),ke.scale(Te,Te),ke.textBaseline="middle",Rn(ke),ke.restore()),Ze.hasHeader()&&(R8(Ne,rt,i,v,oe,a,u,l,Ze),xr())),De.restore(),Ne.restore();return}if((Q!==!0||o!==(se==null?void 0:se.cellXOffset)||a!==(se==null?void 0:se.translateX)||Jt!==(se==null?void 0:se.mustDrawFocusOnHeader)||Yn!==(se==null?void 0:se.mustDrawHighlightRingsOnHeader))&&xr(),Q===!0){Or(tt!==void 0&&se!==void 0);const{regions:mt}=E8(De,tt,tt===ve?se.aBufferScroll:se.bBufferScroll,tt===ve?se.bBufferScroll:se.aBufferScroll,se,o,l,a,u,A,i,s,P,oe,Te,c,rt,y,Ie);Tt=mt}else Q!==!1&&(Or(se!==void 0),Tt=M8(se,o,l,a,u,i,s,oe,rt,Q));C8(De,rt,i,s,A,P,k,ze,p);const Kt=ub(De,i,s,o,l,a,u,c,h,x,v,y,A,P,H,p),Qn=m?zg(De,i,s,l,a,u,rt,c,p,oe,T,ze,D,A,we,E,P):void 0;if(De.fillStyle=p.bgCell,Tt.length>0){De.beginPath();for(const mt of Tt)De.rect(mt.x,mt.y,mt.width,mt.height);De.clip(),De.fill(),De.beginPath()}else De.fillRect(0,0,i,s);const Jn=$x(De,rt,c,s,oe,a,u,l,P,ze,D,O,_,g,I,m,A,we,Tt,Ze,T,U,H,G,B,F,j,ae,z,p,_e,Je,qe,b,Ot);S8(De,rt,c,i,s,oe,a,u,l,P,ze,_,T.rows,g,A,we,Tt,Ze,p),T8(De,rt,l,a,u,i,s,Tt,oe,ze,_,k,A,P,p),ab(De,rt,l,a,u,i,s,Tt,Jn,v,oe,ze,_,k,A,P,p),Kt==null||Kt(),Qn==null||Qn(),C&&Mo(rt,0,a,0,oe,(mt,An)=>mt.sourceIndex===te?(cb(Ne,An+mt.width,0,oe+1,Pr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),cb(De,An+mt.width,oe,s,Pr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),ke!==null&&(ke.fillStyle=p.bgCell,ke.fillRect(0,0,i,s),ke.drawImage(De.canvas,0,0));const ls=O8(rt,s,oe,a,u,l,P,ze,A,we);G==null||G.setWindow({x:o,y:l,width:rt.length,height:ls-l},h,Array.from({length:A},(mt,An)=>P-1-An));const as=se!==void 0&&(o!==se.cellXOffset||a!==se.translateX),$t=se!==void 0&&(l!==se.cellYOffset||u!==se.translateY);M.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Jt,mustDrawHighlightRingsOnHeader:Yn,lastBuffer:Ie?Lt===ve?"a":"b":void 0,aBufferScroll:Lt===ve?[as,$t]:se==null?void 0:se.aBufferScroll,bBufferScroll:Lt===pe?[as,$t]:se==null?void 0:se.bBufferScroll},De.restore(),Ne.restore()}const P8=80;function I8(t){const e=t-1;return e*e*e+1}class D8{constructor(e){at(this,"callback");at(this,"currentHoveredItem");at(this,"leavingItems",[]);at(this,"lastAnimationTime");at(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>Ku(r.item,e.item))||this.leavingItems.push(e)});at(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>Ku(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});at(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});at(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});at(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:I8(e.hoverAmount)})));at(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/P8;for(const s of this.leavingItems)s.hoverAmount=wi(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=wi(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});at(this,"setHovered",e=>{var n;if(!Ku((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class _8{constructor(e){at(this,"fn");at(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function Wv(t){return new _8(t)}const N8=Wv(()=>window.navigator.userAgent.includes("Firefox")),gd=Wv(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),md=Wv(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function L8(t){const e=w.useRef([]),n=w.useRef(0),r=w.useRef(t);r.current=t;const i=w.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map(Bv);e.current=[],r.current(new Gu(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return w.useCallback(s=>{e.current.length===0&&i();const o=xi(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const Xs="header",Rr="group-header",yd="out-of-bounds";var ea;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(ea||(ea={}));function eE(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const hb=6,F8=(t,e)=>{if(t.kind===Se.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},B8=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:h,getCellContent:d,getRowThemeOverride:p,onHeaderMenuClick:m,enableGroups:x,isFilling:v,onCanvasFocused:g,onCanvasBlur:y,isFocused:k,selection:b,freezeColumns:C,onContextMenu:T,freezeTrailingRows:E,fixedShadowX:A=!0,fixedShadowY:P=!0,drawFocusRing:D,onMouseDown:O,onMouseUp:_,onMouseMoveRaw:I,onMouseMove:Y,onItemHovered:U,dragAndDropState:ae,firstColAccessible:H,onKeyDown:te,onKeyUp:G,highlightRegions:M,canvasRef:F,onDragStart:z,onDragEnd:j,eventTargetRef:B,isResizing:ge,resizeColumn:we,isDragging:ue,isDraggable:_e=!1,allowResize:Je,disabledRows:qe,hasAppendRow:Ye,getGroupDetails:Qe,theme:et,prelightCells:Ze,headerIcons:Ot,verticalBorder:Ie,drawCell:Te,drawHeader:Q,onCellFocused:ce,onDragOverCell:ne,onDrop:oe,onDragLeave:q,imageWindowLoader:ve,smoothScrollX:pe=!1,smoothScrollY:se=!1,experimental:ke,getCellRenderer:Ne}=t,De=t.translateX??0,Lt=t.translateY??0,tt=Math.max(C,Math.min(s.length-1,o)),ze=w.useRef(null),rt=ve,Tt=w.useRef(),[Jt,Yn]=w.useState(!1),xr=w.useRef([]),Kt=w.useRef(),[Qn,Jn]=w.useState(),[ls,as]=w.useState(),$t=w.useRef(null),[ct,mt]=w.useState(),[An,Rn]=w.useState(!1),nn=w.useRef(An);nn.current=An;const Tn=w.useMemo(()=>new hz(Ot,()=>{Ii.current=void 0,Oo.current()}),[Ot]),si=x?c+a:a,pt=w.useRef(-1),Xt=((ke==null?void 0:ke.enableFirefoxRescaling)??!1)&&N8.value,Pt=((ke==null?void 0:ke.enableSafariRescaling)??!1)&&gd.value;w.useLayoutEffect(()=>{window.devicePixelRatio===1||!Xt&&!Pt||(pt.current!==-1&&Yn(!0),window.clearTimeout(pt.current),pt.current=window.setTimeout(()=>{Yn(!1),pt.current=-1},200))},[l,tt,De,Lt,Xt,Pt]);const It=a4(s,C),On=A?Ca(It,ae):0,Ht=w.useCallback(($,ie,xe)=>{const me=$.getBoundingClientRect();if(ie>=It.length||xe>=h)return;const fe=me.width/n,Ae=b0(ie,xe,n,r,c,si,tt,l,De,Lt,h,C,E,It,f);return fe!==1&&(Ae.x*=fe,Ae.y*=fe,Ae.width*=fe,Ae.height*=fe),Ae.x+=me.x,Ae.y+=me.y,Ae},[n,r,c,si,tt,l,De,Lt,h,C,E,It,f]),wn=w.useCallback(($,ie,xe,me)=>{const fe=$.getBoundingClientRect(),Ae=fe.width/n,Xe=(ie-fe.left)/Ae,Ge=(xe-fe.top)/Ae,Ee=5,kt=x0(It,tt,n,void 0,De);let Le=0,Ct=0;me instanceof MouseEvent&&(Le=me.button,Ct=me.buttons);const nt=h4(Xe,kt,De),ft=d4(Ge,r,x,a,c,h,f,l,Lt,E),un=(me==null?void 0:me.shiftKey)===!0,it=(me==null?void 0:me.ctrlKey)===!0,rn=(me==null?void 0:me.metaKey)===!0,$r=me!==void 0&&!(me instanceof MouseEvent)||(me==null?void 0:me.pointerType)==="touch",Yt=[Xe<0?-1:nn||Ge>r){const vt=Xe>n?1:Xe<0?-1:0,cn=Ge>r?1:Ge<0?-1:0;let Cr=vt*2,Di=cn*2;vt===0&&(Cr=nt===-1?ea.EndPadding:ea.Center),cn===0&&(Di=ft===void 0?ea.EndPadding:ea.Center);let ui=!1;if(nt===-1&&ft===-1){const Io=Ht($,It.length-1,-1);Or(Io!==void 0),ui=ien&&Xer&&Ge=0?(cn=!0,vt=Ht($,Cr,ft),Or(vt!==void 0),Sr={kind:x&&ft===-2?Rr:Xs,location:[Cr,ft],bounds:vt,group:It[Cr].group??"",isEdge:cn,shiftKey:un,ctrlKey:it,metaKey:rn,isTouch:$r,localEventX:ie-vt.x,localEventY:xe-vt.y,button:Le,buttons:Ct,scrollEdge:Yt}):Sr={kind:x&&ft===-2?Rr:Xs,group:It[nt].group??"",location:[nt,ft],bounds:vt,isEdge:cn,shiftKey:un,ctrlKey:it,metaKey:rn,isTouch:$r,localEventX:ie-vt.x,localEventY:xe-vt.y,button:Le,buttons:Ct,scrollEdge:Yt}}else{const vt=Ht($,nt,ft);Or(vt!==void 0);const cn=vt!==void 0&&vt.x+vt.width-ie{}),Ds=w.useRef(Qn);Ds.current=Qn;const[us,cs]=w.useMemo(()=>{const $=document.createElement("canvas"),ie=document.createElement("canvas");return $.style.display="none",$.style.opacity="0",$.style.position="fixed",ie.style.display="none",ie.style.opacity="0",ie.style.position="fixed",[$.getContext("2d",{alpha:!1}),ie.getContext("2d",{alpha:!1})]},[]);w.useLayoutEffect(()=>{if(!(us===null||cs===null))return document.documentElement.append(us.canvas),document.documentElement.append(cs.canvas),()=>{us.canvas.remove(),cs.canvas.remove()}},[us,cs]);const ml=w.useMemo(()=>new S4,[]),Yc=Xt&&Jt?1:Pt&&Jt?2:5,Qc=(ke==null?void 0:ke.disableMinimumCellWidth)===!0?1:10,Ii=w.useRef(),yl=w.useRef(null),vl=w.useRef(null),wl=w.useCallback(()=>{var Xe;const $=ze.current,ie=$t.current;if($===null||ie===null||(yl.current===null&&(yl.current=$.getContext("2d",{alpha:!1}),$.width=0,$.height=0),vl.current===null&&(vl.current=ie.getContext("2d",{alpha:!1}),ie.width=0,ie.height=0),yl.current===null||vl.current===null||us===null||cs===null))return;let xe=!1;const me=Ge=>{xe=!0,mt(Ge)},fe=Ii.current,Ae={headerCanvasCtx:vl.current,canvasCtx:yl.current,bufferACtx:us,bufferBCtx:cs,width:n,height:r,cellXOffset:tt,cellYOffset:l,translateX:Math.round(De),translateY:Math.round(Lt),mappedColumns:It,enableGroups:x,freezeColumns:C,dragAndDropState:ae,theme:et,headerHeight:a,groupHeaderHeight:c,disabledRows:qe??wt.empty(),rowHeight:f,verticalBorder:Ie,isResizing:ge,resizeCol:we,isFocused:k,selection:b,fillHandle:u,drawCellCallback:Te,hasAppendRow:Ye,overrideCursor:me,maxScaleFactor:Yc,freezeTrailingRows:E,rows:h,drawFocus:D,getCellContent:d,getGroupDetails:Qe??(Ge=>({name:Ge})),getRowThemeOverride:p,drawHeaderCallback:Q,prelightCells:Ze,highlightRegions:M,imageLoader:rt,lastBlitData:Kt,damage:Tt.current,hoverValues:xr.current,hoverInfo:Ds.current,spriteManager:Tn,scrolling:Jt,hyperWrapping:(ke==null?void 0:ke.hyperWrapping)??!1,touchMode:An,enqueue:qc.current,renderStateProvider:ml,renderStrategy:(ke==null?void 0:ke.renderStrategy)??(gd.value?"double-buffer":"single-buffer"),getCellRenderer:Ne,minimumCellWidth:Qc};Ae.damage===void 0?(Ii.current=Ae,fb(Ae,fe)):fb(Ae,void 0),!xe&&(Ae.damage===void 0||Ae.damage.has((Xe=Ds==null?void 0:Ds.current)==null?void 0:Xe[0]))&&mt(void 0)},[us,cs,n,r,tt,l,De,Lt,It,x,C,ae,et,a,c,qe,f,Ie,ge,Ye,we,k,b,u,E,h,D,Yc,d,Qe,p,Te,Q,Ze,M,rt,Tn,Jt,ke==null?void 0:ke.hyperWrapping,ke==null?void 0:ke.renderStrategy,An,ml,Ne,Qc]),Oo=w.useRef(wl);w.useLayoutEffect(()=>{wl(),Oo.current=wl},[wl]),w.useLayoutEffect(()=>{(async()=>{var ie;((ie=document==null?void 0:document.fonts)==null?void 0:ie.ready)!==void 0&&(await document.fonts.ready,Ii.current=void 0,Oo.current())})()},[]);const _s=w.useCallback($=>{Tt.current=$,Oo.current(),Tt.current=void 0},[]),Jc=L8(_s);qc.current=Jc;const Zc=w.useCallback($=>{_s(new Gu($.map(ie=>ie.cell)))},[_s]);rt.setCallback(_s);const[Op,Pp]=w.useState(!1),[xl,fs]=Gt??[],Ip=xl!==void 0&&fs===-1,Dp=xl!==void 0&&fs===-2;let ef=!1,bl=!1,mn=ct;if(mn===void 0&&xl!==void 0&&fs!==void 0&&fs>-1&&fs({contain:"strict",display:"block",cursor:tf}),[tf]),Xa=w.useRef("default"),Ns=B==null?void 0:B.current;Ns!=null&&Xa.current!==kl.cursor&&(Ns.style.cursor=Xa.current=kl.cursor);const br=w.useCallback(($,ie,xe,me)=>{if(Qe===void 0)return;const fe=Qe($);if(fe.actions!==void 0){const Ae=HT(ie,fe.actions);for(const[Xe,Ge]of Ae.entries())if(gp(Ge,xe+ie.x,me+Ge.y))return fe.actions[Xe]}},[Qe]),oi=w.useCallback(($,ie,xe,me)=>{const fe=s[ie];if(!ue&&!ge&&fe.hasMenu===!0&&!(ls??!1)){const Ae=Ht($,ie,-1);Or(Ae!==void 0);const Xe=$T(Ae.x,Ae.y,Ae.width,Ae.height,Dv(fe.title)==="rtl");if(xe>Xe.x&&xeXe.y&&me{const ie=ze.current,xe=B==null?void 0:B.current;if(ie===null||$.target!==ie&&$.target!==xe)return;qa.current=!0;let me,fe;if($ instanceof MouseEvent?(me=$.clientX,fe=$.clientY):(me=$.touches[0].clientX,fe=$.touches[0].clientY),$.target===xe&&xe!==null){const Xe=xe.getBoundingClientRect();if(me>Xe.right||fe>Xe.bottom)return}const Ae=wn(ie,me,fe,$);Ls.current=Ae.location,Ae.isTouch&&(Ga.current=Date.now()),nn.current!==Ae.isTouch&&Rn(Ae.isTouch),!(Ae.kind===Xs&&oi(ie,Ae.location[0],me,fe)!==void 0)&&(Ae.kind===Rr&&br(Ae.group,Ae.bounds,Ae.localEventX,Ae.localEventY)!==void 0||(O==null||O(Ae),!Ae.isTouch&&_e!==!0&&_e!==Ae.kind&&Ae.button<3&&Ae.button!==1&&$.preventDefault()))},[B,_e,wn,br,oi,O]);In("touchstart",Zn,window,!1),In("mousedown",Zn,window,!1);const Sl=w.useRef(0),Ya=w.useCallback($=>{var Ct,nt;const ie=Sl.current;Sl.current=Date.now();const xe=ze.current;if(qa.current=!1,_===void 0||xe===null)return;const me=B==null?void 0:B.current,fe=$.target!==xe&&$.target!==me;let Ae,Xe,Ge=!0;if($ instanceof MouseEvent){if(Ae=$.clientX,Xe=$.clientY,Ge=$.button<3,$.pointerType==="touch")return}else Ae=$.changedTouches[0].clientX,Xe=$.changedTouches[0].clientY;let Ee=wn(xe,Ae,Xe,$);Ee.isTouch&&Ga.current!==0&&Date.now()-Ga.current>500&&(Ee={...Ee,isLongTouch:!0}),ie!==0&&Date.now()-ie<(Ee.isTouch?1e3:500)&&(Ee={...Ee,isDoubleClick:!0}),nn.current!==Ee.isTouch&&Rn(Ee.isTouch),!fe&&$.cancelable&&Ge&&$.preventDefault();const[kt]=Ee.location,Le=oi(xe,kt,Ae,Xe);if(Ee.kind===Xs&&Le!==void 0){(Ee.button!==0||((Ct=Ls.current)==null?void 0:Ct[0])!==kt||((nt=Ls.current)==null?void 0:nt[1])!==-1)&&_(Ee,!0);return}else if(Ee.kind===Rr){const ft=br(Ee.group,Ee.bounds,Ee.localEventX,Ee.localEventY);if(ft!==void 0){Ee.button===0&&ft.onClick(Ee);return}}_(Ee,fe)},[_,B,wn,oi,br]);In("mouseup",Ya,window,!1),In("touchend",Ya,window,!1);const nf=w.useCallback($=>{var Le,Ct;const ie=ze.current;if(ie===null)return;const xe=B==null?void 0:B.current,me=$.target!==ie&&$.target!==xe;let fe,Ae,Xe=!0;$ instanceof MouseEvent?(fe=$.clientX,Ae=$.clientY,Xe=$.button<3):(fe=$.changedTouches[0].clientX,Ae=$.changedTouches[0].clientY);const Ge=wn(ie,fe,Ae,$);nn.current!==Ge.isTouch&&Rn(Ge.isTouch),!me&&$.cancelable&&Xe&&$.preventDefault();const[Ee]=Ge.location,kt=oi(ie,Ee,fe,Ae);if(Ge.kind===Xs&&kt!==void 0)Ge.button===0&&((Le=Ls.current)==null?void 0:Le[0])===Ee&&((Ct=Ls.current)==null?void 0:Ct[1])===-1&&(m==null||m(Ee,kt));else if(Ge.kind===Rr){const nt=br(Ge.group,Ge.bounds,Ge.localEventX,Ge.localEventY);nt!==void 0&&Ge.button===0&&nt.onClick(Ge)}},[B,wn,oi,m,br]);In("click",nf,window,!1);const _p=w.useCallback($=>{const ie=ze.current,xe=B==null?void 0:B.current;if(ie===null||$.target!==ie&&$.target!==xe||T===void 0)return;const me=wn(ie,$.clientX,$.clientY,$);T(me,()=>{$.cancelable&&$.preventDefault()})},[B,wn,T]);In("contextmenu",_p,(B==null?void 0:B.current)??null,!1);const rf=w.useCallback($=>{Tt.current=new Gu($.map(ie=>ie.item)),xr.current=$,Oo.current(),Tt.current=void 0},[]),li=w.useMemo(()=>new D8(rf),[rf]),hs=w.useRef(li);hs.current=li,w.useLayoutEffect(()=>{const $=hs.current;if(Gt===void 0||Gt[1]<0){$.setHovered(Gt);return}const ie=d(Gt,!0),xe=Ne(ie),me=xe===void 0&&ie.kind===Se.Custom||(xe==null?void 0:xe.needsHover)!==void 0&&(typeof xe.needsHover=="boolean"?xe.needsHover:xe.needsHover(ie));$.setHovered(me?Gt:void 0)},[d,Ne,Gt]);const kr=w.useRef(),K=w.useCallback($=>{var Ge;const ie=ze.current;if(ie===null)return;const xe=B==null?void 0:B.current,me=$.target!==ie&&$.target!==xe,fe=wn(ie,$.clientX,$.clientY,$);if(fe.kind!=="out-of-bounds"&&me&&!qa.current&&!fe.isTouch)return;const Ae=(Ee,kt)=>{Jn(Le=>Le===Ee||(Le==null?void 0:Le[0][0])===(Ee==null?void 0:Ee[0][0])&&(Le==null?void 0:Le[0][1])===(Ee==null?void 0:Ee[0][1])&&((Le==null?void 0:Le[1][0])===(Ee==null?void 0:Ee[1][0])&&(Le==null?void 0:Le[1][1])===(Ee==null?void 0:Ee[1][1])||!kt)?Le:Ee)};if(!eE(fe,kr.current))mt(void 0),U==null||U(fe),Ae(fe.kind===yd?void 0:[fe.location,[fe.localEventX,fe.localEventY]],!0),kr.current=fe;else if(fe.kind==="cell"||fe.kind===Xs||fe.kind===Rr){let Ee=!1,kt=!0;if(fe.kind==="cell"){const Ct=d(fe.location);kt=((Ge=Ne(Ct))==null?void 0:Ge.needsHoverPosition)??Ct.kind===Se.Custom,Ee=kt}else fe.kind===Rr&&(Ee=!0);const Le=[fe.location,[fe.localEventX,fe.localEventY]];Ae(Le,kt),Ds.current=Le,Ee&&_s(new Gu([fe.location]))}const Xe=fe.location[0]>=(H?0:1);as(fe.kind===Xs&&fe.isEdge&&Xe&&Je===!0),Pp(fe.kind==="cell"&&fe.isFillHandle),I==null||I($),Y(fe)},[B,wn,H,Je,I,Y,U,d,Ne,_s]);In("mousemove",K,window,!0);const qt=w.useCallback($=>{const ie=ze.current;if(ie===null)return;let xe,me;b.current!==void 0&&(xe=Ht(ie,b.current.cell[0],b.current.cell[1]),me=b.current.cell),te==null||te({bounds:xe,stopPropagation:()=>$.stopPropagation(),preventDefault:()=>$.preventDefault(),cancel:()=>{},ctrlKey:$.ctrlKey,metaKey:$.metaKey,shiftKey:$.shiftKey,altKey:$.altKey,key:$.key,keyCode:$.keyCode,rawEvent:$,location:me})},[te,b,Ht]),Po=w.useCallback($=>{const ie=ze.current;if(ie===null)return;let xe,me;b.current!==void 0&&(xe=Ht(ie,b.current.cell[0],b.current.cell[1]),me=b.current.cell),G==null||G({bounds:xe,stopPropagation:()=>$.stopPropagation(),preventDefault:()=>$.preventDefault(),cancel:()=>{},ctrlKey:$.ctrlKey,metaKey:$.metaKey,shiftKey:$.shiftKey,altKey:$.altKey,key:$.key,keyCode:$.keyCode,rawEvent:$,location:me})},[G,b,Ht]),Np=w.useCallback($=>{ze.current=$,F!==void 0&&(F.current=$)},[F]),sf=w.useCallback($=>{const ie=ze.current;if(ie===null||_e===!1||ge){$.preventDefault();return}let xe,me;const fe=wn(ie,$.clientX,$.clientY);if(_e!==!0&&fe.kind!==_e){$.preventDefault();return}const Ae=(Ct,nt)=>{xe=Ct,me=nt};let Xe,Ge,Ee;const kt=(Ct,nt,ft)=>{Xe=Ct,Ge=nt,Ee=ft};let Le=!1;if(z==null||z({...fe,setData:Ae,setDragImage:kt,preventDefault:()=>Le=!0,defaultPrevented:()=>Le}),!Le&&xe!==void 0&&me!==void 0&&$.dataTransfer!==null)if($.dataTransfer.setData(xe,me),$.dataTransfer.effectAllowed="copyLink",Xe!==void 0&&Ge!==void 0&&Ee!==void 0)$.dataTransfer.setDragImage(Xe,Ge,Ee);else{const[Ct,nt]=fe.location;if(nt!==void 0){const ft=document.createElement("canvas"),un=Ht(ie,Ct,nt);Or(un!==void 0);const it=Math.ceil(window.devicePixelRatio??1);ft.width=un.width*it,ft.height=un.height*it;const rn=ft.getContext("2d");rn!==null&&(rn.scale(it,it),rn.textBaseline="middle",nt===-1?(rn.font=et.headerFontFull,rn.fillStyle=et.bgHeader,rn.fillRect(0,0,ft.width,ft.height),jT(rn,0,0,un.width,un.height,It[Ct],!1,et,!1,!1,0,Tn,Q,!1)):(rn.font=et.baseFontFull,rn.fillStyle=et.bgCell,rn.fillRect(0,0,ft.width,ft.height),zT(rn,d([Ct,nt]),0,nt,!1,!1,0,0,un.width,un.height,!1,et,et.bgCell,rt,Tn,1,void 0,!1,0,void 0,void 0,void 0,ml,Ne,()=>{}))),ft.style.left="-100%",ft.style.position="absolute",ft.style.width=`${un.width}px`,ft.style.height=`${un.height}px`,document.body.append(ft),$.dataTransfer.setDragImage(ft,un.width/2,un.height/2),window.setTimeout(()=>{ft.remove()},0)}}else $.preventDefault()},[_e,ge,wn,z,Ht,et,It,Tn,Q,d,rt,ml,Ne]);In("dragstart",sf,(B==null?void 0:B.current)??null,!1,!1);const Qa=w.useRef(),Lp=w.useCallback($=>{const ie=ze.current;if(oe!==void 0&&$.preventDefault(),ie===null||ne===void 0)return;const xe=wn(ie,$.clientX,$.clientY),[me,fe]=xe.location,Ae=me-(H?0:1),[Xe,Ge]=Qa.current??[];(Xe!==Ae||Ge!==fe)&&(Qa.current=[Ae,fe],ne([Ae,fe],$.dataTransfer))},[H,wn,ne,oe]);In("dragover",Lp,(B==null?void 0:B.current)??null,!1,!1);const mw=w.useCallback(()=>{Qa.current=void 0,j==null||j()},[j]);In("dragend",mw,(B==null?void 0:B.current)??null,!1,!1);const J=w.useCallback($=>{const ie=ze.current;if(ie===null||oe===void 0)return;$.preventDefault();const xe=wn(ie,$.clientX,$.clientY),[me,fe]=xe.location,Ae=me-(H?0:1);oe([Ae,fe],$.dataTransfer)},[H,wn,oe]);In("drop",J,(B==null?void 0:B.current)??null,!1,!1);const Bn=w.useCallback(()=>{q==null||q()},[q]);In("dragleave",Bn,(B==null?void 0:B.current)??null,!1,!1);const yn=w.useRef(b);yn.current=b;const Cl=w.useRef(null),Ja=w.useCallback($=>{var ie;ze.current===null||!ze.current.contains(document.activeElement)||($===null&&yn.current.current!==void 0?(ie=F==null?void 0:F.current)==null||ie.focus({preventScroll:!0}):$!==null&&$.focus({preventScroll:!0}),Cl.current=$)},[F]);w.useImperativeHandle(e,()=>({focus:()=>{var ie;const $=Cl.current;$===null||!document.contains($)?(ie=F==null?void 0:F.current)==null||ie.focus({preventScroll:!0}):$.focus({preventScroll:!0})},getBounds:($,ie)=>{if(!(F===void 0||F.current===null))return Ht(F.current,$??0,ie??-1)},damage:Zc}),[F,Zc,Ht]);const Fs=w.useRef(),ur=MF(()=>{var Ge,Ee,kt;if(n<50||(ke==null?void 0:ke.disableAccessibilityTree)===!0)return null;let $=x0(It,tt,n,ae,De);const ie=H?0:-1;!H&&((Ge=$[0])==null?void 0:Ge.sourceIndex)===0&&($=$.slice(1));const[xe,me]=((Ee=b.current)==null?void 0:Ee.cell)??[],fe=(kt=b.current)==null?void 0:kt.range,Ae=$.map(Le=>Le.sourceIndex),Xe=Vo(l,Math.min(h,l+i));return xe!==void 0&&me!==void 0&&!(Ae.includes(xe)&&Xe.includes(me))&&Ja(null),w.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":h+1,"aria-multiselectable":"true","aria-colcount":It.length+ie},w.createElement("thead",{role:"rowgroup"},w.createElement("tr",{role:"row","aria-rowindex":1},$.map(Le=>w.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex(Le.sourceIndex),"aria-colindex":Le.sourceIndex+1+ie,tabIndex:-1,onFocus:Ct=>{if(Ct.target!==Cl.current)return ce==null?void 0:ce([Le.sourceIndex,-1])},key:Le.sourceIndex},Le.title)))),w.createElement("tbody",{role:"rowgroup"},Xe.map(Le=>w.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex(Le),key:Le,"aria-rowindex":Le+2},$.map(Ct=>{const nt=Ct.sourceIndex,ft=xi(nt,Le),un=xe===nt&&me===Le,it=fe!==void 0&&nt>=fe.x&&nt=fe.y&&Le{const Sr=F==null?void 0:F.current;if(Sr!=null)return te==null?void 0:te({bounds:Ht(Sr,nt,Le),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:$r})},onFocusCapture:Sr=>{var vt,cn;if(!(Sr.target===Cl.current||((vt=Fs.current)==null?void 0:vt[0])===nt&&((cn=Fs.current)==null?void 0:cn[1])===Le))return Fs.current=$r,ce==null?void 0:ce($r)},ref:un?Ja:void 0,tabIndex:-1},F8(Yt,Ne))})))))},[n,It,tt,ae,De,h,l,i,b,Ja,d,F,te,Ht,ce],200),ai=C===0||!A?0:tt>C?1:wi(-De/100,0,1),Fp=-l*32+Lt,Tl=P?wi(-Fp/100,0,1):0,Bp=w.useMemo(()=>{if(!ai&&!Tl)return null;const $={position:"absolute",top:0,left:On,width:n-On,height:r,opacity:ai,pointerEvents:"none",transition:pe?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},ie={position:"absolute",top:si,left:0,width:n,height:r,opacity:Tl,pointerEvents:"none",transition:se?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return w.createElement(w.Fragment,null,ai>0&&w.createElement("div",{id:"shadow-x",style:$}),Tl>0&&w.createElement("div",{id:"shadow-y",style:ie}))},[ai,Tl,On,n,pe,si,r,se]),zp=w.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return w.createElement(w.Fragment,null,w.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:qt,onKeyUp:Po,onFocus:g,onBlur:y,ref:Np,style:kl},ur),w.createElement("canvas",{ref:$t,style:zp}),Bp)},z8=w.memo(w.forwardRef(B8));function vu(t,e,n,r){return wi(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const $8=t=>{const[e,n]=w.useState(),[r,i]=w.useState(),[s,o]=w.useState(),[l,a]=w.useState(),[u,c]=w.useState(!1),[f,h]=w.useState(),[d,p]=w.useState(),[m,x]=w.useState(),[v,g]=w.useState(!1),[y,k]=w.useState(),{onHeaderMenuClick:b,getCellContent:C,onColumnMoved:T,onColumnResize:E,onColumnResizeStart:A,onColumnResizeEnd:P,gridRef:D,maxColumnWidth:O,minColumnWidth:_,onRowMoved:I,lockColumns:Y,onColumnProposeMove:U,onMouseDown:ae,onMouseUp:H,onItemHovered:te,onDragStart:G,canvasRef:M}=t,F=(E??P??A)!==void 0,{columns:z,selection:j}=t,B=j.columns,ge=w.useCallback(Ie=>{const[Te,Q]=Ie.location;s!==void 0&&l!==Te&&Te>=Y?(c(!0),a(Te)):d!==void 0&&Q!==void 0?(g(!0),x(Math.max(0,Q))):r===void 0&&!u&&!v&&(te==null||te(Ie))},[s,d,l,te,Y,r,u,v]),we=T!==void 0,ue=w.useCallback(Ie=>{var Te;if(Ie.button===0){const[Q,ce]=Ie.location;if(Ie.kind==="out-of-bounds"&&Ie.isEdge&&F){const ne=(Te=D==null?void 0:D.current)==null?void 0:Te.getBounds(z.length-1,-1);ne!==void 0&&(n(ne.x),i(z.length-1))}else if(Ie.kind==="header"&&Q>=Y){const ne=M==null?void 0:M.current;if(Ie.isEdge&&F&&ne){n(Ie.bounds.x),i(Q);const q=ne.getBoundingClientRect().width/ne.offsetWidth,ve=Ie.bounds.width/q;A==null||A(z[Q],ve,Q,ve+(z[Q].growOffset??0))}else Ie.kind==="header"&&we&&(h(Ie.bounds.x),o(Q))}else Ie.kind==="cell"&&Y>0&&Q===0&&ce!==void 0&&I!==void 0&&(k(Ie.bounds.y),p(ce))}ae==null||ae(Ie)},[ae,F,Y,I,D,z,we,A,M]),_e=w.useCallback((Ie,Te)=>{u||v||b==null||b(Ie,Te)},[u,v,b]),Je=w.useRef(-1),qe=w.useCallback(()=>{Je.current=-1,p(void 0),x(void 0),k(void 0),g(!1),o(void 0),a(void 0),h(void 0),c(!1),i(void 0),n(void 0)},[]),Ye=w.useCallback((Ie,Te)=>{if(Ie.button===0){if(r!==void 0){if((B==null?void 0:B.hasIndex(r))===!0)for(const ce of B){if(ce===r)continue;const ne=z[ce],oe=vu(ne,Je.current,_,O);E==null||E(ne,oe,ce,oe+(ne.growOffset??0))}const Q=vu(z[r],Je.current,_,O);if(P==null||P(z[r],Q,r,Q+(z[r].growOffset??0)),B.hasIndex(r))for(const ce of B){if(ce===r)continue;const ne=z[ce],oe=vu(ne,Je.current,_,O);P==null||P(ne,oe,ce,oe+(ne.growOffset??0))}}qe(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),d!==void 0&&m!==void 0&&(I==null||I(d,m))}H==null||H(Ie,Te)},[H,r,s,l,d,m,B,P,z,_,O,E,T,I,qe]),Qe=w.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(U==null?void 0:U(s,l))!==!1)return{src:s,dest:l}},[s,l,U]),et=w.useCallback(Ie=>{const Te=M==null?void 0:M.current;if(s!==void 0&&f!==void 0)Math.abs(Ie.clientX-f)>20&&c(!0);else if(d!==void 0&&y!==void 0)Math.abs(Ie.clientY-y)>20&&g(!0);else if(r!==void 0&&e!==void 0&&Te){const ce=Te.getBoundingClientRect().width/Te.offsetWidth,ne=(Ie.clientX-e)/ce,oe=z[r],q=vu(oe,ne,_,O);if(E==null||E(oe,q,r,q+(oe.growOffset??0)),Je.current=ne,(B==null?void 0:B.first())===r)for(const ve of B){if(ve===r)continue;const pe=z[ve],se=vu(pe,Je.current,_,O);E==null||E(pe,se,ve,se+(pe.growOffset??0))}}},[s,f,d,y,r,e,z,_,O,E,B,M]),Ze=w.useCallback((Ie,Te)=>{if(d===void 0||m===void 0)return C(Ie,Te);let[Q,ce]=Ie;return ce===m?ce=d:(ce>m&&(ce-=1),ce>=d&&(ce+=1)),C([Q,ce],Te)},[d,m,C]),Ot=w.useCallback(Ie=>{G==null||G(Ie),Ie.defaultPrevented()||qe()},[qe,G]);return w.createElement(z8,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:Ze,isResizing:r!==void 0,onHeaderMenuClick:_e,isDragging:u,onItemHovered:ge,onDragStart:Ot,onMouseDown:ue,allowResize:F,onMouseUp:Ye,dragAndDropState:Qe,onMouseMoveRaw:et,ref:D})};function H8(t){const e=w.useRef(null),[n,r]=w.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return w.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const j8=(t,e,n)=>{const r=w.useRef(null),i=w.useRef(null),s=w.useRef(null),o=w.useRef(0),l=w.useRef(e);l.current=e;const a=n.current;w.useEffect(()=>{const u=()=>{var h,d;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((h=s.current)==null?void 0:h[0])===p[0]&&((d=s.current)==null?void 0:d[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=h=>{h.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const h=a;return h.addEventListener("touchstart",c),h.addEventListener("touchend",f),()=>{h.removeEventListener("touchstart",c),h.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},W8=()=>t=>t.isSafari?"scroll":"auto",V8=Br("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[W8()]}});function U8(t){const[e,n]=w.useState(!1),r=typeof window>"u"?null:window,i=w.useRef(0);return In("touchstart",w.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),In("touchend",w.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const K8=t=>{var z,j;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:h,kineticScrollPerfHack:d=!1,scrollRef:p,initialSize:m}=t,x=[],v=(h==null?void 0:h.sticky)??!1,g=(h==null?void 0:h.fill)??!1,y=w.useRef(0),k=w.useRef(0),b=w.useRef(null),C=typeof window>"u"?1:window.devicePixelRatio,T=w.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),E=w.useRef(null),A=U8(200),[P,D]=w.useState(!0),O=w.useRef(0);w.useLayoutEffect(()=>{if(!P||A||T.current.lockDirection===void 0)return;const B=b.current;if(B===null)return;const[ge,we]=T.current.lockDirection;ge!==void 0?B.scrollLeft=ge:we!==void 0&&(B.scrollTop=we),T.current.lockDirection=void 0},[A,P]);const _=w.useCallback((B,ge)=>{var Te;const we=b.current;if(we===null)return;ge=ge??we.scrollTop,B=B??we.scrollLeft;const ue=T.current.scrollTop,_e=T.current.scrollLeft,Je=B-_e,qe=ge-ue;A&&Je!==0&&qe!==0&&(Math.abs(Je)>3||Math.abs(qe)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(Je)0&&(Math.abs(Ot)>2e3||Ze===0||Ze===Ie)&&r>we.scrollHeight+5){const Q=Ze/Ie,ce=(r-et)*Q;y.current=ce-Ze}Ye!==void 0&&(window.clearTimeout(O.current),D(!1),O.current=window.setTimeout(()=>D(!0),200)),s({x:B,y:Ze+y.current,width:Qe-c,height:et-u,paddingRight:((Te=E.current)==null?void 0:Te.clientWidth)??0})},[u,c,r,s,a,A]);j8(d&&gd.value,_,b);const I=w.useRef(_);I.current=_;const Y=w.useRef(),U=w.useRef(!1);w.useLayoutEffect(()=>{U.current?_():U.current=!0},[_,u,c]);const ae=w.useCallback(B=>{b.current=B,p!==void 0&&(p.current=B)},[p]);let H=0,te=0;for(x.push(w.createElement("div",{key:H++,style:{width:i,height:0}}));teI.current(),0),Y.current={width:M,height:F}),(M??0)===0||(F??0)===0?w.createElement("div",{ref:G}):w.createElement("div",{ref:G},w.createElement(V8,{isSafari:gd.value},w.createElement("div",{className:"dvn-underlay"},e),w.createElement("div",{ref:ae,style:Y.current,draggable:o,onDragStart:B=>{o||(B.stopPropagation(),B.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>_()},w.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},w.createElement("div",{className:"dvn-stack"},x),f!==void 0&&w.createElement(w.Fragment,null,!g&&w.createElement("div",{className:"dvn-spacer"}),w.createElement("div",{ref:E,style:{height:F,maxHeight:n-Math.ceil(C%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:g?1:void 0,right:v?c??0:void 0,pointerEvents:"auto"}},f))))))},X8=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:h,scrollRef:d,preventDiagonalScrolling:p,rightElement:m,rightElementProps:x,overscrollX:v,overscrollY:g,initialSize:y,smoothScrollX:k=!1,smoothScrollY:b=!1,isDraggable:C}=t,{paddingRight:T,paddingBottom:E}=a??{},[A,P]=c,D=w.useRef(),O=w.useRef(),_=w.useRef(),I=w.useRef(),Y=u+Math.max(0,v??0);let U=o?i+s:i;if(typeof r=="number")U+=n*r;else for(let G=0;G{var qe,Ye;if(ae.current===void 0)return;const G={...ae.current};let M=0,F=G.x<0?-G.x:0,z=0,j=0;G.x=G.x<0?0:G.x;let B=0;for(let Qe=0;Qe=et+Qe.width)M+=Qe.width,j++,z++;else if(G.x>et)M+=Qe.width,k?F+=et-G.x:j++,z++;else if(G.x+G.width>et)M+=Qe.width,z++;else break}let ge=0,we=0,ue=0;if(typeof r=="number")b?(we=Math.floor(G.y/r),ge=we*r-G.y):we=Math.ceil(G.y/r),ue=Math.ceil(G.height/r)+we,ge<0&&ue++;else{let Qe=0;for(let et=0;et=Qe+Ze)Qe+=Ze,we++,ue++;else if(G.y>Ot)Qe+=Ze,b?ge+=Ot-G.y:we++,ue++;else if(G.y+G.height>Ze/2+Qe)Qe+=Ze,ue++;else break}}const _e={x:j,y:we,width:z-j,height:ue-we},Je=D.current;(Je===void 0||Je.y!==_e.y||Je.x!==_e.x||Je.height!==_e.height||Je.width!==_e.width||O.current!==F||_.current!==ge||G.width!==((qe=I.current)==null?void 0:qe[0])||G.height!==((Ye=I.current)==null?void 0:Ye[1]))&&(h==null||h({x:j,y:we,width:z-j,height:ue-we},G.width,G.height,G.paddingRight??0,F,ge),D.current=_e,O.current=F,_.current=ge,I.current=[G.width,G.height])},[e,r,n,h,l,k,b]),te=w.useCallback(G=>{ae.current=G,H()},[H]);return w.useEffect(()=>{H()},[H]),w.createElement(K8,{scrollRef:d,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:C===!0||typeof C=="string",scrollWidth:Y+(T??0),scrollHeight:U+(E??0),clientHeight:P,rightElement:m,paddingBottom:E,paddingRight:T,rightElementProps:x,update:te,initialSize:y},w.createElement($8,{eventTargetRef:d,width:A,height:P,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},G8=Br("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),q8=w.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},w.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),Y8=w.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},w.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),Q8=w.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},w.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),J8=10,Z8=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:h}=t,[d]=w.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,m]=w.useState(""),x=o??p,v=w.useCallback(M=>{m(M),a==null||a(M)},[a]),[g,y]=w.useState(),k=w.useRef(g);k.current=g,w.useEffect(()=>{l!==void 0&&(l.length>0?y(M=>({rowsSearched:r,results:l.length,selectedIndex:(M==null?void 0:M.selectedIndex)??-1})):y(void 0))},[r,l]);const b=w.useRef();b.current===void 0&&(b.current=new AbortController);const C=w.useRef(),[T,E]=w.useState([]),A=l??T,P=w.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,b.current.abort())},[]),D=w.useRef(n);D.current=n;const O=w.useCallback(M=>{const F=new RegExp(M.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let z=D.current,j=Math.min(10,r),B=0;y(void 0),E([]);const ge=[],we=async()=>{var Ie;if(u===void 0)return;const ue=performance.now(),_e=r-B;let Je=u({x:0,y:z,width:i.length,height:Math.min(j,_e,r-z)},b.current.signal);typeof Je=="function"&&(Je=await Je());let qe=!1;for(const[Te,Q]of Je.entries())for(const[ce,ne]of Q.entries()){let oe;switch(ne.kind){case Se.Text:case Se.Number:oe=ne.displayData;break;case Se.Uri:case Se.Markdown:oe=ne.data;break;case Se.Boolean:oe=typeof ne.data=="boolean"?ne.data.toString():void 0;break;case Se.Image:case Se.Bubble:oe=ne.data.join("🐳");break;case Se.Custom:oe=ne.copyData;break}oe!==void 0&&F.test(oe)&&(ge.push([ce,Te+z]),qe=!0)}const Ye=performance.now();qe&&E([...ge]),B+=Je.length,Or(B<=r);const Qe=((Ie=k.current)==null?void 0:Ie.selectedIndex)??-1;y({results:ge.length,rowsSearched:B,selectedIndex:Qe}),c==null||c(ge,Qe),z+j>=r?z=0:z+=j;const et=Ye-ue,Ze=Math.max(et,1),Ot=J8/Ze;j=Math.ceil(j*Ot),B{var M;h==null||h(),y(void 0),E([]),c==null||c([],-1),P(),(M=e==null?void 0:e.current)==null||M.focus()},[P,e,h,c]),I=w.useCallback(M=>{v(M.target.value),l===void 0&&(M.target.value===""?(y(void 0),E([]),P()):O(M.target.value))},[O,P,v,l]);w.useEffect(()=>{f&&s.current!==null&&(v(""),s.current.focus({preventScroll:!0}))},[f,s,v]);const Y=w.useCallback(M=>{var z;if((z=M==null?void 0:M.stopPropagation)==null||z.call(M),g===void 0)return;const F=(g.selectedIndex+1)%g.results;y({...g,selectedIndex:F}),c==null||c(A,F)},[g,c,A]),U=w.useCallback(M=>{var z;if((z=M==null?void 0:M.stopPropagation)==null||z.call(M),g===void 0)return;let F=(g.selectedIndex-1)%g.results;F<0&&(F+=g.results),y({...g,selectedIndex:F}),c==null||c(A,F)},[c,A,g]),ae=w.useCallback(M=>{(M.ctrlKey||M.metaKey)&&M.nativeEvent.code==="KeyF"||M.key==="Escape"?(_(),M.stopPropagation(),M.preventDefault()):M.key==="Enter"&&(M.shiftKey?U():Y())},[_,Y,U]);w.useEffect(()=>()=>{P()},[P]);const[H,te]=w.useState(!1);w.useEffect(()=>{if(f)te(!0);else{const M=setTimeout(()=>te(!1),150);return()=>clearTimeout(M)}},[f]);const G=w.useMemo(()=>{if(!f&&!H)return null;let M;g!==void 0&&(M=g.results>=1e3?"over 1000":`${g.results} result${g.results!==1?"s":""}`,g.selectedIndex>=0&&(M=`${g.selectedIndex+1} of ${M}`));const F=B=>{B.stopPropagation()},j={width:`${Math.floor(((g==null?void 0:g.rowsSearched)??0)/r*100)}%`};return w.createElement(G8,{className:f?"":"out",onMouseDown:F,onMouseMove:F,onMouseUp:F,onClick:F},w.createElement("div",{className:"gdg-search-bar-inner"},w.createElement("input",{id:d,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:I,value:x,tabIndex:f?void 0:-1,onKeyDownCapture:ae}),w.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:U,disabled:((g==null?void 0:g.results)??0)===0},q8),w.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:Y,disabled:((g==null?void 0:g.results)??0)===0},Y8),h!==void 0&&w.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:_},Q8)),g!==void 0?w.createElement(w.Fragment,null,w.createElement("div",{className:"gdg-search-status"},w.createElement("div",{"data-testid":"search-result-area"},M)),w.createElement("div",{className:"gdg-search-progress",style:j})):w.createElement("div",{className:"gdg-search-status"},w.createElement("label",{htmlFor:d},"Type to search")))},[f,H,g,r,d,s,I,x,ae,U,Y,h,_]);return w.createElement(w.Fragment,null,w.createElement(X8,{prelightCells:A,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),G)};class eW extends w.PureComponent{constructor(){super(...arguments);at(this,"wrapperRef",w.createRef());at(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return w.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const tW=()=>t=>Math.max(16,t.targetHeight-10),nW=Br("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[tW(),"px"]}}),rW=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=kn.useState(n);return kn.createElement(eW,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},kn.createElement(nW,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function iW(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function ot(t,e,n){const r=tE(t,e);return r&&(n.didMatch=!0),r}function tE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(tE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!iW(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":md.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function sW(t,e,n,r,i,s){const o=kn.useCallback((u,c,f,h)=>{var g;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const d=n==="mixed"&&(f||h==="drag"),p=r==="mixed"&&d,m=i==="mixed"&&d;let x={current:u===void 0?void 0:{...u,rangeStack:h==="drag"?((g=t.current)==null?void 0:g.rangeStack)??[]:[]},columns:p?t.columns:wt.empty(),rows:m?t.rows:wt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&x.current!==void 0&&t.current!==void 0&&(x={...x,current:{...x.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(x,c)},[r,t,n,s,i,e]),l=kn.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let h;if(i==="exclusive"&&u.length>0)h={current:void 0,columns:wt.empty(),rows:u};else{const d=f&&n==="mixed",p=f&&r==="mixed";h={current:d?t.current:void 0,columns:p?t.columns:wt.empty(),rows:u}}e(h,!1)},[r,t,n,i,e]),a=kn.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let h;if(r==="exclusive"&&u.length>0)h={current:void 0,rows:wt.empty(),columns:u};else{const d=f&&n==="mixed",p=f&&i==="mixed";h={current:d?t.current:void 0,rows:p?t.rows:wt.empty(),columns:u}}e(h,!1)},[r,t,n,i,e]);return[o,l,a]}function oW(t,e,n,r,i){const s=w.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?h.push({kind:Se.Loading,allowOverlay:!1}):h.push(e([d,f]));c.push(h)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=w.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(h=>[{kind:Se.Loading,allowOverlay:!1},...h]):f.map(h=>[{kind:Se.Loading,allowOverlay:!1},...h])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function lW(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case Se.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Mv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case Se.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case Se.Image:case Se.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case Se.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case Se.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case Se.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case Se.Markdown:case Se.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case Se.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case Se.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case Se.Protected:return{formatted:"************",rawValue:"",format:"string"};default:wc()}}function aW(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:lW(o))})}function db(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function uW(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>db(o,!0)).join(",")):i.push(db(s.formatted,!1));e.push(i.join(" "))}return e.join(` -`)}function $g(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function pb(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function cW(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function fW(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
${$g(i.formatted)}
    ${i.formatted.map((o,l)=>`
  1. `+$g(o)+"
  2. ").join("")}
${$g(i.formatted)}
"),e.join("")}function hW(t,e){const n=aW(t,e),r=uW(n),i=fW(n);return{textPlain:r,textHtml:i}}function gb(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",h=a.querySelectorAll("br");for(const m of h)m.replaceWith(` -`);const d=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const m=a.querySelectorAll("li");s==null||s.push({rawValue:[...m].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...m].map(x=>x.textContent??""),format:"string-array"})}else if(d!==null)s==null||s.push({rawValue:cW(d),formatted:a.textContent??"",format:p});else{let m=a.textContent??"";f&&(m=m.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:m??"",formatted:m??"",format:p})}}}return s!==void 0&&i.push(s),i}function dW(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const h=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h);const d=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}else{const h=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}let c=a.x-n,f=a.x+a.width-1-n;for(const h of u)for(const d of h)d.span!==void 0&&(c=Math.min(d.span[0],c),f=Math.max(d.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function mb(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function pW(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` +`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
":"
"}del(e){return`${e}`}link(e,n,r){if(e=Ex(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='
",i}image(e,n,r){if(e=Ex(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class vT{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,n,r){return""+r}image(e,n,r){return""+r}br(){return""}}class wT{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,n){let r=e,i=0;if(this.seen.hasOwnProperty(r)){i=this.seen[e];do i++,r=e+"-"+i;while(this.seen.hasOwnProperty(r))}return n||(this.seen[e]=i,this.seen[r]=0),r}slug(e,n={}){const r=this.serialize(e);return this.getNextSafeSlug(r,n.dryrun)}}let Vc=class w0{constructor(e){this.options=e||pl,this.options.renderer=this.options.renderer||new Fv,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new vT,this.slugger=new wT}static parse(e,n){return new w0(n).parse(e)}static parseInline(e,n){return new w0(n).parseInline(e)}parse(e,n=!0){let r="",i,s,o,l,a,u,c,f,h,d,p,m,x,v,g,y,k,b,C;const T=e.length;for(i=0;i0&&g.tokens[0].type==="paragraph"?(g.tokens[0].text=b+" "+g.tokens[0].text,g.tokens[0].tokens&&g.tokens[0].tokens.length>0&&g.tokens[0].tokens[0].type==="text"&&(g.tokens[0].tokens[0].text=b+" "+g.tokens[0].tokens[0].text)):g.tokens.unshift({type:"text",text:b}):v+=b),v+=this.parse(g.tokens,x),h+=this.renderer.listitem(v,k,y);r+=this.renderer.list(h,p,m);continue}case"html":{r+=this.renderer.html(d.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(d.tokens));continue}case"text":{for(h=d.tokens?this.parseInline(d.tokens):d.text;i+1{if(r.message+=` +Please report this to https://github.com/markedjs/marked.`,t){const i="

An error occurred:

"+qn(r.message+"",!0)+"
";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function xT(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...Ke.defaults,...s};const o=JF(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(qF(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Ke.walkTokens(a,r.walkTokens),h=e(a,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(d){f=d}return r.highlight=l,f?o(f):i(null,h)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;Ke.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(h,d){if(h)return u(h);d!=null&&d!==f.text&&(f.text=d,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(Ke.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&Ke.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function Ke(t,e,n){return xT(wo.lex,Vc.parse)(t,e,n)}Ke.options=Ke.setOptions=function(t){return Ke.defaults={...Ke.defaults,...t},LF(Ke.defaults),Ke};Ke.getDefaults=pT;Ke.defaults=pl;Ke.use=function(...t){const e=Ke.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=Ke.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=Ke.defaults.renderer||new Fv;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=Ke.defaults.tokenizer||new Lv;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=Ke.defaults.hooks||new hd;for(const s in n.hooks){const o=i[s];hd.passThroughHooks.has(s)?i[s]=l=>{if(Ke.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=Ke.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}Ke.setOptions(r)})};Ke.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(Ke,r)),r.type){case"table":{for(const i of r.header)n=n.concat(Ke.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(Ke.walkTokens(s.tokens,e));break}case"list":{n=n.concat(Ke.walkTokens(r.items,e));break}default:Ke.defaults.extensions&&Ke.defaults.extensions.childTokens&&Ke.defaults.extensions.childTokens[r.type]?Ke.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(Ke.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(Ke.walkTokens(r.tokens,e)))}return n};Ke.parseInline=xT(wo.lexInline,Vc.parseInline);Ke.Parser=Vc;Ke.parser=Vc.parse;Ke.Renderer=Fv;Ke.TextRenderer=vT;Ke.Lexer=wo;Ke.lexer=wo.lex;Ke.Tokenizer=Lv;Ke.Slugger=wT;Ke.Hooks=hd;Ke.parse=Ke;Ke.options;Ke.setOptions;Ke.use;Ke.walkTokens;Ke.parseInline;Vc.parse;wo.lex;const ZF=zr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class e4 extends Tn.PureComponent{constructor(){super(...arguments);ft(this,"targetElement",null);ft(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=Ke(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),Tn.createElement(ZF,{ref:this.containerRefHook})}}const t4=zr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),n4=zr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),r4=zr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let Px=0;const gp=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=w.useRef(null),f=n??"";Pr(a!==void 0,"GrowingEntry must be a controlled input area");const[h]=w.useState(()=>"input-box-"+(Px=(Px+1)%1e7));w.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const m=f.toString().length;p.focus(),p.setSelectionRange(i?0:m,m)},[]),w.useLayoutEffect(()=>{var p;if(o!==void 0){const m=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(m[0],m[1])}},[o]);const d=w.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return w.createElement(r4,{className:"gdg-growing-entry"},w.createElement(n4,{className:u},f+` +`),w.createElement(t4,{...l,className:(u??"")+" gdg-input",id:h,ref:c,onKeyDown:d,value:f,placeholder:e,dir:"auto"}))},_g={};let Vs=null;function i4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function x0(t){const e=t.toLowerCase().trim();if(_g[e]!==void 0)return _g[e];Vs=Vs||i4(),Vs.style.color="#000",Vs.style.color=e;const n=getComputedStyle(Vs).color;Vs.style.color="#fff",Vs.style.color=e;const r=getComputedStyle(Vs).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),_g[e]=i,i}function sl(t,e){const[n,r,i]=x0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const Ix=new Map;function Dx(t,e){const n=`${t}-${e}`,r=Ix.get(n);if(r!==void 0)return r;const i=Ir(t,e);return Ix.set(n,i),i}function Ir(t,e){if(e===void 0)return t;const[n,r,i,s]=x0(t);if(s===1)return t;const[o,l,a,u]=x0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,h=(s*r+u*l*(1-s))/c,d=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${h}, ${d}, ${c})`}var Bl=new Map,Zl=new Map,b0=new Map;function s4(){Bl.clear(),b0.clear(),Zl.clear()}function o4(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let h=u[f],d=(l=n.get(f))!=null?l:i,p=d*h/a,m=c*p*r/h,x=d+m;n.set(f,x)}}function l4(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function Ku(t,e,n,r){var i,s;let o=Zl.get(n);if(r&&o!==void 0&&o.count>2e4){let u=b0.get(n);if(u===void 0&&(u=l4(t,o.size),b0.set(n,u)),o.count>5e5){let f=0;for(let h of e)f+=(i=u.get(h))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return o4(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),Zl.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)Zl.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;Zl.set(n,{count:o.count+e.length,size:f})}return l.width}function a4(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=Ku(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function u4(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Bl.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` +`),c=Zl.get(n),f=c===void 0?e.length:r/c.size*1.5,h=i&&c!==void 0&&c.count>2e4;for(let d of u){let p=Ku(t,d.slice(0,Math.max(0,f)),n,h),m=Math.min(d.length,f);if(p<=r)a.push(d);else{for(;p>r;){let x=a4(t,d,r,n,p,m,h),v=d.slice(0,Math.max(0,x));d=d.slice(v.length),a.push(v),p=Ku(t,d.slice(0,Math.max(0,f)),n,h),m=Math.min(d.length,f)}p>0&&a.push(d)}}return a=a.map((d,p)=>p===0?d.trimEnd():d.trim()),Bl.set(o,a),Bl.size>500&&Bl.delete(Bl.keys().next().value),a}function c4(t,e){return Tn.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function bT(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function d4(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&_x(t,e,s)&&i++;for(const o of n.current.rangeStack)_x(t,e,o)&&i++;return i}function ST(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function Ca(t,e){let n=0;const r=ST(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return m}const h=s-u,d=t-(a??0);if(typeof o=="number"){const p=Math.floor((d-c)/o)+l;return p>=h?void 0:p}else{let p=c;for(let m=l;m"u";async function y4(){var t;m4||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Rh=0,Gu={},s4())}y4();function CT(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function Uc(t,e,n,r="middle"){const i=CT(t,e,r,n);let s=Gu[i];return s===void 0&&(s=e.measureText(t),Gu[i]=s,Rh++),Rh>1e4&&(Gu={},Rh=0),s}function v4(t,e){const n=CT(t,void 0,"middle",e);return Gu[n]}function Is(t,e){return typeof e!="string"&&(e=e.baseFontFull),w4(t,e)}function Nx(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const Lx=[];function w4(t,e){for(const s of Lx)if(s.key===e)return s.val;const n=Nx(t,"alphabetic"),i=-(Nx(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return Lx.push({key:e,val:i}),i}function x4(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function k4(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=u4(t,e,c,i-l.cellHorizontalPadding*2,u??!1),h=ET(t,c),d=l.lineHeight*h,p=h+d*(f.length-1),m=p+l.cellVerticalPadding>s;m&&(t.save(),t.rect(n,r,i,s),t.clip());const x=r+s/2-p/2;let v=Math.max(r+l.cellVerticalPadding,x);for(const g of f)if(TT(t,g,n,v,i,h,o,l,a),v+=d,v>r+s)break;m&&t.restore()}function ws(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=b4(e,c));const h=Is(s,l),d=Nv(e)==="rtl";if(n===void 0&&d&&(n="right"),d&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?k4(s,e,a,u,c,f,h,l,n,i):TT(s,e,a,u,c,f,h,l,n),p&&(s.textAlign="start"),d&&(s.direction="inherit")}}function rs(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function S4(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function C4(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),h=u/f,d=c/f;return{x:u,y:a.y-l.y,len:f,nx:h,ny:d,ang:Math.atan2(d,h)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:h),m=1,x=!1;d<0?p<0?p=Math.PI+p:(p=Math.PI-p,m=-1,x=!0):p>0&&(m=-1,x=!0),i=a.radius!==void 0?a.radius:n;const v=p/2;let g=Math.abs(Math.cos(v)*i/Math.sin(v)),y;g>Math.min(c.len/2,f.len/2)?(g=Math.min(c.len/2,f.len/2),y=Math.abs(g*Math.sin(v)/Math.cos(v))):y=i;let k=a.x+f.nx*g,b=a.y+f.ny*g;k+=-f.ny*y*m,b+=f.nx*y*m,t.arc(k,b,y,c.ang+Math.PI/2*m,f.ang-Math.PI/2*m,x),o=a,a=u}t.closePath()}function S0(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p){const m={x:0,y:s+u,width:0,height:0};if(t>=d.length||e>=c||e<-2||t<0)return m;const x=s-i;if(t>=f){const v=o>t?-1:1,g=Ca(d);m.x+=g+a;for(let y=o;y!==t;y+=v)m.x+=d[v===1?y:y-1].width*v}else for(let v=0;v0&&kc(d[v-1].group,g)&&d[v-1].sticky===y;){const b=d[v-1];m.x-=b.width,m.width+=b.width,v--}let k=t;for(;k+1n&&(m.width=n-m.x)}}else if(e>=c-h){let v=c-e;for(m.y=r;v>0;){const g=e+v-1;m.height=typeof p=="number"?p:p(g),m.y-=m.height,v--}m.height+=1}else{const v=l>e?-1:1;if(typeof p=="number"){const g=e-l;m.y+=g*p}else for(let g=l;g!==e;g+=v)m.y+=p(g)*v;m.height=(typeof p=="number"?p:p(e))+1}return m}const Bv=1<<21;function ki(t,e){return(e+2)*Bv+t}function MT(t){return t%Bv}function zv(t){return Math.floor(t/Bv)-2}function $v(t){const e=MT(t),n=zv(t);return[e,n]}class AT{constructor(){ft(this,"visibleWindow",{x:0,y:0,width:0,height:0});ft(this,"freezeCols",0);ft(this,"freezeRows",[]);ft(this,"isInWindow",e=>{const n=MT(e),r=zv(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&Sa(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class T4 extends AT{constructor(){super(...arguments);ft(this,"cache",new Map);ft(this,"setValue",(n,r)=>{this.cache.set(ki(n[0],n[1]),r)});ft(this,"getValue",n=>this.cache.get(ki(n[0],n[1])));ft(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class qu{constructor(e=[]){ft(this,"cells");this.cells=new Set(e.map(n=>ki(n[0],n[1])))}add(e){this.cells.add(ki(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(ki(e[0],e[1]))}remove(e){this.cells.delete(ki(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(zv(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const d=A4(t,h[r],e,a);return u=Math.max(u,d),d});if(c.length>5&&l){u=0;let h=0;for(const p of c)h+=p;const d=h/c.length;for(let p=0;p=d*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function R4(t,e,n,r,i,s,o,l,a){const u=w.useRef(e),c=w.useRef(n),f=w.useRef(o);u.current=e,c.current=n,f.current=o;const[h,d]=w.useMemo(()=>{if(typeof window>"u")return[null,null];const g=document.createElement("canvas");return g.style.display="none",g.style.opacity="0",g.style.position="fixed",[g,g.getContext("2d",{alpha:!1})]},[]);w.useLayoutEffect(()=>(h&&document.documentElement.append(h),()=>{h==null||h.remove()}),[h]);const p=w.useRef({}),m=w.useRef(),[x,v]=w.useState();return w.useLayoutEffect(()=>{const g=c.current;if(g===void 0||t.every(Bf))return;let y=Math.max(1,10-Math.floor(t.length/1e4)),k=0;y1&&(y--,k=1);const b={x:0,y:0,width:t.length,height:Math.min(u.current,y)},C={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const E=g(b,a.signal),A=k>0?g(C,a.signal):void 0;let P;typeof E=="object"?P=E:P=await fx(E),A!==void 0&&(typeof A=="object"?P=[...P,...A]:P=[...P,...await fx(A)]),m.current=t,v(P)})()},[a.signal,t]),w.useMemo(()=>{let y=t.every(Bf)?t:d===null?t.map(T=>Bf(T)?T:{...T,width:C0}):(d.font=f.current.baseFontFull,t.map((T,E)=>{if(Bf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(x===void 0||m.current!==t||T.id===void 0)return{...T,width:C0};const A=PT(d,o,T,E,x,i,s,!0,l);return p.current[T.id]=A.width,A})),k=0,b=0;const C=[];for(const[T,E]of y.entries())k+=E.width,E.grow!==void 0&&E.grow>0&&(b+=E.grow,C.push(T));if(k0){const T=[...y],E=r-k;let A=E;for(let P=0;P0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=P4(a),a in Fx)return;Fx[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":O4,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((h,d)=>{f.addEventListener("load",h),f.addEventListener("error",()=>d(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function I4(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var D4=I4,_4=D4,Ng=Dv;function N4(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Ng(n),n=n===n?n:0),e!==void 0&&(e=Ng(e),e=e===e?e:0),_4(Ng(t),e,n)}var L4=N4;const bi=Pi(L4);var F4="__lodash_hash_undefined__";function B4(t){return this.__data__.set(t,F4),this}var z4=B4;function $4(t){return this.__data__.has(t)}var H4=$4,j4=Cv,W4=z4,V4=H4;function dd(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new j4;++e-1}var iB=rB;function sB(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=TB){var u=e?null:SB(t);if(u)return CB(u);o=!1,i=kB,a=new wB}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?FT(l,e-1,n,r,i):FB(i,l):r||(i[i.length]=l)}return i}var zB=FT,$B=zB;function HB(t){var e=t==null?0:t.length;return e?$B(t,1):[]}var jB=HB;const $x=Pi(jB);var WB=Math.ceil,VB=Math.max;function UB(t,e,n,r){for(var i=-1,s=VB(WB((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var KB=UB,XB=G2,GB=Av;function qB(t){return t!=null&&GB(t.length)&&!XB(t)}var jv=qB,YB=kv,QB=jv,JB=Mv,ZB=hl;function ez(t,e,n){if(!ZB(n))return!1;var r=typeof e;return(r=="number"?QB(n)&&JB(e,n.length):r=="string"&&e in n)?YB(n[e],t):!1}var tz=ez,nz=Dv,Hx=1/0,rz=17976931348623157e292;function iz(t){if(!t)return t===0?t:0;if(t=nz(t),t===Hx||t===-Hx){var e=t<0?-1:1;return e*rz}return t===t?t:0}var sz=iz,oz=KB,lz=tz,Fg=sz;function az(t){return function(e,n,r){return r&&typeof r!="number"&&lz(e,n,r)&&(n=r=void 0),e=Fg(e),n===void 0?(n=e,e=0):n=Fg(n),r=r===void 0?e{m.drawImage(x,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(d,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function BT(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function mp(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let h=!1;for(;ul&&a(u,c,d,!1,o&&c===r-1)===!0){h=!0;break}u+=d,c++}if(!h){u=n;for(let d=0;d!d.sticky))==null?void 0:h.sourceIndex)??0;if(a>f){const d=Math.max(l,f);let p=e,m=r;for(let x=s.sourceIndex-1;x>=d;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=a;x++)m+=o[x].width;c={x:p,y:n,width:m,height:i}}if(f>l){const d=Math.min(a,f-1);let p=e,m=r;for(let x=s.sourceIndex-1;x>=l;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=d;x++)m+=o[x].width;u={x:p,y:n,width:m,height:i}}return[u,c]}function gz(t,e,n,r){if(r==="any")return HT(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),bT([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function pd(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function yp(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function HT(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function mz(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function yz(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,h=a>0?t.x+Math.floor(a/r)*r:t.x,d=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,m=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:h,y:p,width:d-h,height:m-p}}function vz(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,h]=i,{x:d,y:p,width:m,height:x}=t,v=[];if(m<=0||x<=0)return v;const g=d+m,y=p+x,k=dl,T=p+x>a,E=d>=s&&ds&&g<=l||dl,A=p>=o&&po&&y<=a||pa;if(E&&A){const _=Math.max(d,s),O=Math.max(p,o),D=Math.min(g,l),I=Math.min(y,a);v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:u,y:c,width:f-u+1,height:h-c+1}})}if(k&&b){const _=d,O=p,D=Math.min(g,s),I=Math.min(y,o);v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:0,y:0,width:u+1,height:c+1}})}if(b&&E){const _=Math.max(d,s),O=p,D=Math.min(g,l),I=Math.min(y,o);v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(b&&C){const _=Math.max(d,l),O=p,D=g,I=Math.min(y,o);v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&A){const _=d,O=Math.max(p,o),D=Math.min(g,s),I=Math.min(y,a);v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:0,y:c,width:u+1,height:h-c+1}})}if(C&&A){const _=Math.max(d,l),O=Math.max(p,o),D=g,I=Math.min(y,a);v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:f,y:c,width:n-f+1,height:h-c+1}})}if(k&&T){const _=d,O=Math.max(p,a),D=Math.min(g,s),I=y;v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:0,y:h,width:u+1,height:r-h+1}})}if(T&&E){const _=Math.max(d,s),O=Math.max(p,a),D=Math.min(g,l),I=y;v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:u,y:h,width:f-u+1,height:r-h+1}})}if(C&&T){const _=Math.max(d,l),O=Math.max(p,a),D=g,I=y;v.push({rect:{x:_,y:O,width:D-_,height:I-O},clip:{x:f,y:h,width:n-f+1,height:r-h+1}})}return v}const wz={kind:ke.Loading,allowOverlay:!1};function jx(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g,y,k,b,C,T,E,A,P,_,O,D,I,Q,X,le,j){let ne=(y==null?void 0:y.size)??Number.MAX_SAFE_INTEGER;const Y=performance.now();let M=D.baseFontFull;t.font=M;const F={ctx:t},z=[0,0],W=x>0?gl(a,x,u):0;let B,de;const ge=BT(g);return Mo(e,l,s,o,i,(ae,Re,nt,Ze,Ge)=>{const Ye=Math.max(0,Ze-Re),it=Re+Ye,rt=i+1,Dt=ae.width-Ye,Ie=r-i-1;if(g.length>0){let _e=!1;for(let H=0;H{t.save(),t.beginPath(),t.rect(it,rt,Dt,Ie),t.clip()},Xe=k.columns.hasIndex(ae.sourceIndex),qe=f(ae.group??"").overrideTheme,et=ae.themeOverride===void 0&&qe===void 0?D:mo(D,qe,ae.themeOverride),Be=et.baseFontFull;Be!==M&&(M=Be,t.font=Be),be();let ye;return mp(Ge,nt,r,a,u,x,v,ge,(_e,H,V,Z,ue)=>{var nn,Rn,li;if(H<0||(z[0]=ae.sourceIndex,z[1]=H,y!==void 0&&!y.has(z)))return;if(g.length>0){let vt=!1;for(let Gt=0;Gtpe.span!==void 0&&vt>=pe.span[0]&&vt<=pe.span[1]);vn&&!p&&m?cn=0:vn&&m&&(cn=Math.max(cn,1)),$r&&cn++,vn||(se&&cn++,Xe&&!ue&&cn++);const Hr=pe.kind===ke.Protected?ct.bgCellMedium:ct.bgCell;let jt;if((Z||Hr!==D.bgCell)&&(jt=Ir(Hr,jt)),cn>0||tt){tt&&(jt=Ir(ct.bgHeader,jt));for(let vt=0;vtj&&!dt){const vt=ct.baseFontFull;vt!==M&&(t.font=vt,M=vt),ye=jT(t,pe,ae.sourceIndex,H,xt,In,De,_e,Me,V,cn>0,ct,jt??ct.bgCell,T,E,(Dn==null?void 0:Dn.hoverAmount)??0,P,O,Y,_,ye,I,Q,X,le)}return pt&&t.restore(),pe.style==="faded"&&(t.globalAlpha=1),ne--,Ve&&(t.restore(),(li=ye==null?void 0:ye.deprep)==null||li.call(ye,F),ye=void 0,be(),M=Be,t.font=Be),ne<=0}),t.restore(),ne<=0}),B}const mu=[0,0],yu={x:0,y:0,width:0,height:0},Bg=[void 0,()=>{}];let T0=!1;function xz(){T0=!0}function jT(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g,y,k,b,C,T,E){var Q,X;let A,P;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(A=x[1][0],P=x[1][1]);let _;mu[0]=n,mu[1]=r,yu.x=o,yu.y=l,yu.width=a,yu.height=u,Bg[0]=C.getValue(mu),Bg[1]=le=>C.setValue(mu,le),T0=!1;const O={ctx:t,theme:f,col:n,row:r,cell:e,rect:yu,highlighted:c,cellFillColor:h,hoverAmount:m,frameTime:g,hoverX:A,drawState:Bg,hoverY:P,imageLoader:d,spriteManager:p,hyperWrapping:v,overrideCursor:A!==void 0?E:void 0,requestAnimationFrame:xz},D=x4(O,e.lastUpdated,g,k,i,s),I=T(e);if(I!==void 0){(k==null?void 0:k.renderer)!==I&&((Q=k==null?void 0:k.deprep)==null||Q.call(k,O),k=void 0);const le=(X=I.drawPrep)==null?void 0:X.call(I,O,k);y!==void 0&&!Jl(O.cell)?y(O,()=>I.draw(O,e)):I.draw(O,e),_=le===void 0?void 0:{deprep:le==null?void 0:le.deprep,fillStyle:le==null?void 0:le.fillStyle,font:le==null?void 0:le.font,renderer:I}}return(D||T0)&&(b==null||b(mu)),_}function Wv(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",h="square"){const d=Math.floor(i+o/2),p=h==="circle"?1e4:e.roundingRadius??4;let m=fT(c,o,e.cellVerticalPadding),x=m/2;const v=cT(f,r,s,e.cellHorizontalPadding,m),g=uT(v,d,m),y=hT(r+a,i+u,g);switch(n){case!0:{t.beginPath(),rs(t,v-m/2,d-m/2,m,m,p),h==="circle"&&(x*=.8,m*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(v-x+m/4.23,d-x+m/1.97),t.lineTo(v-x+m/2.42,d-x+m/1.44),t.lineTo(v-x+m/1.29,d-x+m/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case od:case!1:{t.beginPath(),rs(t,v-m/2+.5,d-m/2+.5,m-1,m-1,p),t.lineWidth=1,t.strokeStyle=y?e.textDark:e.textMedium,t.stroke();break}case Rv:{t.beginPath(),rs(t,v-m/2,d-m/2,m,m,p),t.fillStyle=y?e.textMedium:e.textLight,t.fill(),h==="circle"&&(x*=.8,m*=.8),t.beginPath(),t.moveTo(v-m/3,d),t.lineTo(v+m/3,d),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:bc()}}function bz(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g){const y=o+l;if(y<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,y);const[k,b]=(r==null?void 0:r[0])??[],C=f.headerFontFull;t.font=C,Mo(e,0,s,0,y,(T,E,A,P)=>{var F;if(x!==void 0&&!x.has([T.sourceIndex,-1]))return;const _=Math.max(0,P-E);t.save(),t.beginPath(),t.rect(E+_,l,T.width-_,o),t.clip();const O=m(T.group??"").overrideTheme,D=T.themeOverride===void 0&&O===void 0?f:mo(f,O,T.themeOverride);D.bgHeader!==f.bgHeader&&(t.fillStyle=D.bgHeader,t.fill()),D!==f&&(t.font=D.baseFontFull);const I=c.columns.hasIndex(T.sourceIndex),Q=a!==void 0||u,X=!Q&&b===-1&&k===T.sourceIndex,le=Q?0:((F=d.find(z=>z.item[0]===T.sourceIndex&&z.item[1]===-1))==null?void 0:F.hoverAmount)??0,j=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,ne=I?D.accentColor:j?D.bgHeaderHasFocus:D.bgHeader,Y=n?l:0,M=T.sourceIndex===0?0:1;I?(t.fillStyle=ne,t.fillRect(E+M,Y,T.width-M,o)):(j||le>0)&&(t.beginPath(),t.rect(E+M,Y,T.width-M,o),j&&(t.fillStyle=D.bgHeaderHasFocus,t.fill()),le>0&&(t.globalAlpha=le,t.fillStyle=D.bgHeaderHovered,t.fill(),t.globalAlpha=1)),UT(t,E,Y,T.width,o,T,I,D,X,j,le,h,v,g),t.restore()}),n&&kz(t,e,i,s,l,r,f,h,d,p,m,x)}function kz(t,e,n,r,i,s,o,l,a,u,c,f){const[d,p]=(s==null?void 0:s[0])??[];let m=0;zT(e,n,r,i,(x,v,g,y,k,b)=>{if(f!==void 0&&!f.hasItemInRectangle({x:x[0],y:-2,width:x[1]-x[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(g,y,k,b),t.clip();const C=c(v),T=(C==null?void 0:C.overrideTheme)===void 0?o:mo(o,C.overrideTheme),E=p===-2&&d!==void 0&&d>=x[0]&&d<=x[1],A=E?T.bgHeaderHovered:T.bgHeader;if(A!==o.bgHeader&&(t.fillStyle=A,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,C!==void 0){let P=g;if(C.icon!==void 0&&(l.drawSprite(C.icon,"normal",t,P+8,(i-20)/2,20,T),P+=26),t.fillText(C.name,P+8,i/2+Is(t,o.headerFontFull)),C.actions!==void 0&&E){const _=VT({x:g,y,width:k,height:b},C.actions);t.beginPath();const O=_[0].x-10,D=g+k-O;t.rect(O,0,D,i);const I=t.createLinearGradient(O,0,O+D,0),Q=sl(A,0);I.addColorStop(0,Q),I.addColorStop(10/D,A),I.addColorStop(1,A),t.fillStyle=I,t.fill(),t.globalAlpha=.6;const[X,le]=(s==null?void 0:s[1])??[-1,-1];for(let j=0;j35){const k=h?35:r-35,b=h?35*.7:r-35*.7,C=k/r,T=b/r,E=t.createLinearGradient(e,0,e+r,0),A=sl(m,0);E.addColorStop(h?1:0,m),E.addColorStop(C,m),E.addColorStop(T,A),E.addColorStop(h?0:1,A),t.fillStyle=E}else t.fillStyle=m;if(h&&(t.textAlign="right"),t.fillText(s.title,g,n+i/2+Is(t,l.headerFontFull)),h&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===ld.Triangle){t.beginPath();const y=d.x+d.width/2-5.5,k=d.y+d.height/2-3;C4(t,[{x:y,y:k},{x:y+11,y:k},{x:y+5.5,y:k+6}],1),t.fillStyle=m,t.fill()}else if(s.menuIcon===ld.Dots){t.beginPath();const y=d.x+d.width/2,k=d.y+d.height/2;S4(t,y,k),t.fillStyle=m,t.fill()}else{const y=d.x+(d.width-l.headerIconSize)/2,k=d.y+(d.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,y,k,l.headerIconSize,l)}}function UT(t,e,n,r,i,s,o,l,a,u,c,f,h,d){const p=Nv(s.title)==="rtl",m=WT(e,n,r,i,p);h!==void 0?h({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:m},()=>Wx(t,e,n,r,i,s,o,l,a,c,f,d,p,m)):Wx(t,e,n,r,i,s,o,l,a,c,f,d,p,m)}var Sz=dl,Cz=function(){try{var t=Sz(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Tz=Cz,Vx=Tz;function Ez(t,e,n){e=="__proto__"&&Vx?Vx(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var Mz=Ez;function Az(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,h=!0,d=n&N5?new P5:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;b+=k.width;const A=Math.max(b,T);A>r||(t.save(),t.beginPath(),t.rect(A,s+1,1e4,i-s-1),t.clip(),mp(E,C,i,u,c,p,m,y,(P,_,O,D)=>{if(!D&&x.length>0&&!x.some(j=>pd(b,P,1e4,O,j.x,j.y,j.width,j.height)))return;const I=h.hasIndex(_),Q=d.hasIndex(_);t.beginPath();const X=f==null?void 0:f(_),le=X===void 0?g:mo(g,X);le.bgCell!==g.bgCell&&(t.fillStyle=le.bgCell,t.fillRect(b,P,1e4,O)),Q&&(t.fillStyle=le.bgHeader,t.fillRect(b,P,1e4,O)),I&&(t.fillStyle=le.accentLight,t.fillRect(b,P,1e4,O))}),t.restore())})}function E8(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,h=u?Ca(e):0;let d;if(h!==0&&(d=Dx(f,a.bgCell),t.beginPath(),t.moveTo(h+.5,0),t.lineTo(h+.5,r),t.strokeStyle=d,t.stroke()),i>0){const p=f===c&&d!==void 0?d:Dx(c,a.bgCell),m=gl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const nE=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function M8(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p){var O;const m=p.bgCell,{minX:x,maxX:v,minY:g,maxY:y}=nE(l,s,o),k=[],b=o-gl(d,h,u);let C=a,T=n,E=0;for(;C+i=g&&D<=y-1){const Q=c==null?void 0:c(T),X=Q==null?void 0:Q.bgCell;X!==void 0&&X!==m&&T>=d-h&&k.push({x,y:D,w:v-x,h:I,color:X})}C+=I,T0)for(let D=0;D=x&&Q<=v&&f(D+1)&&k.push({x:Q,y:E,w:I.width,h:P,color:X}),A+=I.width}if(k.length===0)return;let _;t.beginPath();for(let D=k.length-1;D>=0;D--){const I=k[D];_===void 0?_=I.color:I.color!==_&&(t.fillStyle=_,t.fill(),t.beginPath(),_=I.color),t.rect(I.x,I.y,I.w,I.h)}_!==void 0&&(t.fillStyle=_,t.fill()),t.beginPath()}function cb(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const O of a)t.rect(O.x+1,O.y+1,O.width-1,O.height-1);t.clip("evenodd")}const g=x.horizontalBorderColor??x.borderColor,y=x.borderColor,{minX:k,maxX:b,minY:C,maxY:T}=nE(l,s,o),E=[];t.beginPath();let A=.5;for(let O=0;O=k&&I<=b&&d(O+1)&&E.push({x1:I,y1:Math.max(u,C),x2:I,y2:Math.min(o,T),color:y})}let P=o+.5;for(let O=m-p;O=C&&Q<=T-1){const X=h==null?void 0:h(D);E.push({x1:k,y1:Q,x2:b,y2:Q,color:(X==null?void 0:X.horizontalBorderColor)??(X==null?void 0:X.borderColor)??g})}O+=f(D),D++}}const _=C8(E,O=>O.color);for(const O of Object.keys(_)){t.strokeStyle=O;for(const D of _[O])t.moveTo(D.x1,D.y1),t.lineTo(D.x2,D.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function A8(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x,v,g){const y=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),b=Math.max(i.cellYOffset,o);let C=0;if(typeof v=="number")C+=(b-k)*v;else for(let I=k;Ii.cellYOffset&&(C=-C),C+=a-i.translateY;const T=Math.min(i.cellXOffset,s),E=Math.max(i.cellXOffset,s);let A=0;for(let I=T;Ii.cellXOffset&&(A=-A),A+=l-i.translateX;const P=Ca(x);if(A!==0&&C!==0)return{regions:[]};const _=u>0?gl(h,u,v):0,O=c-P-Math.abs(A),D=f-d-_-Math.abs(C)-1;if(O>150&&D>150){const I={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(C>0?(I.sy=(d+1)*p,I.sh=D*p,I.dy=(C+d+1)*p,I.dh=D*p,y.push({x:0,y:d,width:c,height:C+1})):C<0&&(I.sy=(-C+d+1)*p,I.sh=D*p,I.dy=(d+1)*p,I.dh=D*p,y.push({x:0,y:f+C-_,width:c,height:-C+_})),A>0?(I.sx=P*p,I.sw=O*p,I.dx=(A+P)*p,I.dw=O*p,y.push({x:P-1,y:0,width:A+2,height:f})):A<0&&(I.sx=(P-A)*p,I.sw=O*p,I.dx=P*p,I.dw=O*p,y.push({x:c+A,y:0,width:-A,height:f})),t.setTransform(1,0,0,1,0,0),g){if(P>0&&A!==0&&C===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const Q=P*p,X=f*p;t.drawImage(e,0,0,Q,X,0,0,Q,X)}if(_>0&&A===0&&C!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const Q=(f-_)*p,X=c*p,le=_*p;t.drawImage(e,0,Q,X,le,0,Q,X,le)}}t.drawImage(e,I.sx,I.sy,I.sw,I.sh,I.dx,I.dy,I.dw,I.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:y}}function R8(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Mo(a,n,r,i,l,(f,h,d,p)=>{if(f.sourceIndex===u){const m=Math.max(h,p)+1;return c.push({x:m,y:0,width:s-m,height:o}),!0}}),c}function O8(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(x===void 0||x.length===0)return;const v=Ca(l),g=gl(d,h,f),y=[a,0,l.length,d-h],k=[v,0,e,n-g],b=x.map(T=>{const E=T.range,A=T.style??"dashed";return vz(E,y,e,n,k).map(P=>{const _=P.rect,O=S0(_.x,_.y,e,n,c,u+c,r,i,s,o,d,a,h,l,f),D=_.width===1&&_.height===1?O:S0(_.x+_.width-1,_.y+_.height-1,e,n,c,u+c,r,i,s,o,d,a,h,l,f);return _.x+_.width>=l.length&&(D.width-=1),_.y+_.height>=d&&(D.height-=1),{color:T.color,style:A,clip:P.clip,rect:yz({x:O.x,y:O.y,width:D.x+D.width-O.x,height:D.y+D.height-O.y},e,n,8)}})}),C=()=>{t.lineWidth=1;let T=!1;for(const E of b)for(const A of E)if((A==null?void 0:A.rect)!==void 0&&pd(0,0,e,n,A.rect.x,A.rect.y,A.rect.width,A.rect.height)){const P=T,_=!mz(A.clip,A.rect);_&&(t.save(),t.rect(A.clip.x,A.clip.y,A.clip.width,A.clip.height),t.clip()),A.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(A.style==="solid"||A.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=A.style==="solid-outline"?Ir(Ir(A.color,m.borderColor),m.bgCell):sl(A.color,1),t.strokeRect(A.rect.x+.5,A.rect.y+.5,A.rect.width-1,A.rect.height-1),_&&(t.restore(),T=P)}T&&t.setLineDash([])};return C(),C}function hb(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function Hg(t,e,n,r,i,s,o,l,a,u,c,f,h,d,p,m,x){if(c.current===void 0)return;const v=c.current.range,g=c.current.cell,y=[v.x+v.width-1,v.y+v.height-1];if(g[1]>=x&&y[1]>=x||!o.some(I=>I.sourceIndex===g[0]||I.sourceIndex===y[0]))return;const[b,C]=c.current.cell,T=h(c.current.cell),E=T.span??[b,b],A=C>=x-d,P=d>0&&!A?gl(x,d,f)-1:0,_=y[1];let O;if(Mo(o,r,i,s,u,(I,Q,X,le,j)=>{if(I.sticky&&b>I.sourceIndex)return;const ne=I.sourceIndexE[1],M=I.sourceIndex===y[0];if(!(!M&&(ne||Y)))return mp(j,X,n,x,f,d,p,void 0,(F,z,W)=>{if(z!==C&&z!==_)return;let B=Q,de=I.width;if(T.span!==void 0){const ae=$T(T.span,Q,F,I.width,W,I,l),Re=I.sticky?ae[0]:ae[1];Re!==void 0&&(B=Re.x,de=Re.width)}return z===_&&M&&m&&(O=()=>{var ae;le>B&&!I.sticky&&(t.beginPath(),t.rect(le,0,e-le,n),t.clip()),t.beginPath(),t.rect(B+de-4,F+W-4,4,4),t.fillStyle=((ae=I.themeOverride)==null?void 0:ae.accentColor)??a.accentColor,t.fill()}),O!==void 0}),O!==void 0}),O===void 0)return;const D=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-P),t.clip(),O==null||O(),t.restore()};return D(),D}function P8(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),zT(e,n,s,r,(u,c,f,h,d,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,h,d,p)}),Mo(e,l,s,o,i,(u,c,f,h)=>{const d=Math.max(0,h-c),p=c+d+1,m=u.width-d-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,m,i-r)}),t.clip())}function I8(t,e,n,r,i,s,o,l,a,u){let c=0;return Mo(t,s,r,i,n,(f,h,d,p,m)=>(mp(m,d,e,o,l,a,u,void 0,(x,v,g,y)=>{y||(c=Math.max(v,c))}),!0)),c}function db(t,e){var pt;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:h,dragAndDropState:d,theme:p,drawFocus:m,headerHeight:x,groupHeaderHeight:v,disabledRows:g,rowHeight:y,verticalBorder:k,overrideCursor:b,isResizing:C,selection:T,fillHandle:E,freezeTrailingRows:A,rows:P,getCellContent:_,getGroupDetails:O,getRowThemeOverride:D,isFocused:I,drawHeaderCallback:Q,prelightCells:X,drawCellCallback:le,highlightRegions:j,resizeCol:ne,imageLoader:Y,lastBlitData:M,hoverValues:F,hyperWrapping:z,hoverInfo:W,spriteManager:B,maxScaleFactor:de,hasAppendRow:ge,touchMode:ae,enqueue:Re,renderStateProvider:nt,getCellRenderer:Ze,renderStrategy:Ge,bufferACtx:Ye,bufferBCtx:it,damage:rt,minimumCellWidth:Dt}=t;if(i===0||s===0)return;const Ie=Ge==="double-buffer",be=Math.min(de,Math.ceil(window.devicePixelRatio??1)),Xe=Ge!=="direct"&&O8(t,e),qe=n.canvas;(qe.width!==i*be||qe.height!==s*be)&&(qe.width=i*be,qe.height=s*be,qe.style.width=i+"px",qe.style.height=s+"px");const et=r.canvas,Be=f?v+x:x,ye=Be+1;(et.width!==i*be||et.height!==ye*be)&&(et.width=i*be,et.height=ye*be,et.style.width=i+"px",et.style.height=ye+"px");const _e=Ye.canvas,H=it.canvas;Ie&&(_e.width!==i*be||_e.height!==s*be)&&(_e.width=i*be,_e.height=s*be,M.current!==void 0&&(M.current.aBufferScroll=void 0)),Ie&&(H.width!==i*be||H.height!==s*be)&&(H.width=i*be,H.height=s*be,M.current!==void 0&&(M.current.bBufferScroll=void 0));const V=M.current;if(Xe===!0&&o===(V==null?void 0:V.cellXOffset)&&l===(V==null?void 0:V.cellYOffset)&&a===(V==null?void 0:V.translateX)&&u===(V==null?void 0:V.translateY))return;let Z=null;Ie&&(Z=n);const ue=r;let se;Ie?rt!==void 0?se=(V==null?void 0:V.lastBuffer)==="b"?it:Ye:se=(V==null?void 0:V.lastBuffer)==="b"?Ye:it:se=n;const tt=se.canvas,pe=Ie?tt===_e?H:_e:qe,De=typeof y=="number"?()=>y:y;ue.save(),se.save(),ue.beginPath(),se.beginPath(),ue.textBaseline="middle",se.textBaseline="middle",be!==1&&(ue.scale(be,be),se.scale(be,be));const Me=k0(c,o,i,d,a);let Ve=[];const dt=m&&((pt=T.current)==null?void 0:pt.cell[1])===l&&u===0;let An=!1;if(j!==void 0){for(const xt of j)if(xt.style!=="no-outline"&&xt.range.y===l&&u===0){An=!0;break}}const un=()=>{bz(ue,Me,f,W,i,a,x,v,d,C,T,p,B,F,k,O,rt,Q,ae),cb(ue,Me,l,a,u,i,s,void 0,void 0,v,Be,De,D,k,A,P,p,!0),ue.beginPath(),ue.moveTo(0,ye-.5),ue.lineTo(i,ye-.5),ue.strokeStyle=Ir(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),ue.stroke(),An&&fb(ue,i,s,o,l,a,u,c,h,x,v,y,A,P,j,p),dt&&Hg(ue,i,s,l,a,u,Me,c,p,Be,T,De,_,A,ge,E,P)};if(rt!==void 0){const xt=Me[Me.length-1].sourceIndex+1,In=rt.hasItemInRegion([{x:o,y:-2,width:xt,height:2},{x:o,y:l,width:xt,height:300},{x:0,y:l,width:h,height:300},{x:0,y:-2,width:h,height:2},{x:o,y:P-A,width:xt,height:A,when:A>0}]),Dn=nn=>{jx(nn,Me,c,s,Be,a,u,l,P,De,_,O,D,g,I,m,A,ge,Ve,rt,T,X,j,Y,B,F,W,le,z,p,Re,nt,Ze,b,Dt);const Rn=T.current;E&&m&&Rn!==void 0&&rt.has(kT(Rn.range))&&Hg(nn,i,s,l,a,u,Me,c,p,Be,T,De,_,A,ge,E,P)};In&&(Dn(se),Z!==null&&(Z.save(),Z.scale(be,be),Z.textBaseline="middle",Dn(Z),Z.restore()),rt.hasHeader()&&(P8(ue,Me,i,v,Be,a,u,l,rt),un())),se.restore(),ue.restore();return}if((Xe!==!0||o!==(V==null?void 0:V.cellXOffset)||a!==(V==null?void 0:V.translateX)||dt!==(V==null?void 0:V.mustDrawFocusOnHeader)||An!==(V==null?void 0:V.mustDrawHighlightRingsOnHeader))&&un(),Xe===!0){Pr(pe!==void 0&&V!==void 0);const{regions:xt}=A8(se,pe,pe===_e?V.aBufferScroll:V.bBufferScroll,pe===_e?V.bBufferScroll:V.aBufferScroll,V,o,l,a,u,A,i,s,P,Be,be,c,Me,y,Ie);Ve=xt}else Xe!==!1&&(Pr(V!==void 0),Ve=R8(V,o,l,a,u,i,s,Be,Me,Xe));E8(se,Me,i,s,A,P,k,De,p);const ct=fb(se,i,s,o,l,a,u,c,h,x,v,y,A,P,j,p),vn=m?Hg(se,i,s,l,a,u,Me,c,p,Be,T,De,_,A,ge,E,P):void 0;if(se.fillStyle=p.bgCell,Ve.length>0){se.beginPath();for(const xt of Ve)se.rect(xt.x,xt.y,xt.width,xt.height);se.clip(),se.fill(),se.beginPath()}else se.fillRect(0,0,i,s);const cn=jx(se,Me,c,s,Be,a,u,l,P,De,_,O,D,g,I,m,A,ge,Ve,rt,T,X,j,Y,B,F,W,le,z,p,Re,nt,Ze,b,Dt);T8(se,Me,c,i,s,Be,a,u,l,P,De,D,T.rows,g,A,ge,Ve,rt,p),M8(se,Me,l,a,u,i,s,Ve,Be,De,D,k,A,P,p),cb(se,Me,l,a,u,i,s,Ve,cn,v,Be,De,D,k,A,P,p),ct==null||ct(),vn==null||vn(),C&&Mo(Me,0,a,0,Be,(xt,In)=>xt.sourceIndex===ne?(hb(ue,In+xt.width,0,Be+1,Ir(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),hb(se,In+xt.width,Be,s,Ir(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),Z!==null&&(Z.fillStyle=p.bgCell,Z.fillRect(0,0,i,s),Z.drawImage(se.canvas,0,0));const $r=I8(Me,s,Be,a,u,l,P,De,A,ge);Y==null||Y.setWindow({x:o,y:l,width:Me.length,height:$r-l},h,Array.from({length:A},(xt,In)=>P-1-In));const Hr=V!==void 0&&(o!==V.cellXOffset||a!==V.translateX),jt=V!==void 0&&(l!==V.cellYOffset||u!==V.translateY);M.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:dt,mustDrawHighlightRingsOnHeader:An,lastBuffer:Ie?tt===_e?"a":"b":void 0,aBufferScroll:tt===_e?[Hr,jt]:V==null?void 0:V.aBufferScroll,bBufferScroll:tt===H?[Hr,jt]:V==null?void 0:V.bBufferScroll},se.restore(),ue.restore()}const D8=80;function _8(t){const e=t-1;return e*e*e+1}class N8{constructor(e){ft(this,"callback");ft(this,"currentHoveredItem");ft(this,"leavingItems",[]);ft(this,"lastAnimationTime");ft(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>Xu(r.item,e.item))||this.leavingItems.push(e)});ft(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>Xu(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});ft(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});ft(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});ft(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:_8(e.hoverAmount)})));ft(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/D8;for(const s of this.leavingItems)s.hoverAmount=bi(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=bi(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});ft(this,"setHovered",e=>{var n;if(!Xu((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class L8{constructor(e){ft(this,"fn");ft(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function Uv(t){return new L8(t)}const F8=Uv(()=>window.navigator.userAgent.includes("Firefox")),yd=Uv(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),vd=Uv(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function B8(t){const e=w.useRef([]),n=w.useRef(0),r=w.useRef(t);r.current=t;const i=w.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map($v);e.current=[],r.current(new qu(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return w.useCallback(s=>{e.current.length===0&&i();const o=ki(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const Xs="header",Or="group-header",wd="out-of-bounds";var ea;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(ea||(ea={}));function rE(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const pb=6,z8=(t,e)=>{if(t.kind===ke.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},$8=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:h,getCellContent:d,getRowThemeOverride:p,onHeaderMenuClick:m,enableGroups:x,isFilling:v,onCanvasFocused:g,onCanvasBlur:y,isFocused:k,selection:b,freezeColumns:C,onContextMenu:T,freezeTrailingRows:E,fixedShadowX:A=!0,fixedShadowY:P=!0,drawFocusRing:_,onMouseDown:O,onMouseUp:D,onMouseMoveRaw:I,onMouseMove:Q,onItemHovered:X,dragAndDropState:le,firstColAccessible:j,onKeyDown:ne,onKeyUp:Y,highlightRegions:M,canvasRef:F,onDragStart:z,onDragEnd:W,eventTargetRef:B,isResizing:de,resizeColumn:ge,isDragging:ae,isDraggable:Re=!1,allowResize:nt,disabledRows:Ze,hasAppendRow:Ge,getGroupDetails:Ye,theme:it,prelightCells:rt,headerIcons:Dt,verticalBorder:Ie,drawCell:be,drawHeader:Xe,onCellFocused:qe,onDragOverCell:et,onDrop:Be,onDragLeave:ye,imageWindowLoader:_e,smoothScrollX:H=!1,smoothScrollY:V=!1,experimental:Z,getCellRenderer:ue}=t,se=t.translateX??0,tt=t.translateY??0,pe=Math.max(C,Math.min(s.length-1,o)),De=w.useRef(null),Me=_e,Ve=w.useRef(),[dt,An]=w.useState(!1),un=w.useRef([]),ct=w.useRef(),[vn,cn]=w.useState(),[$r,Hr]=w.useState(),jt=w.useRef(null),[pt,xt]=w.useState(),[In,Dn]=w.useState(!1),nn=w.useRef(In);nn.current=In;const Rn=w.useMemo(()=>new pz(Dt,()=>{_i.current=void 0,Oo.current()}),[Dt]),li=x?c+a:a,vt=w.useRef(-1),Gt=((Z==null?void 0:Z.enableFirefoxRescaling)??!1)&&F8.value,_t=((Z==null?void 0:Z.enableSafariRescaling)??!1)&&yd.value;w.useLayoutEffect(()=>{window.devicePixelRatio===1||!Gt&&!_t||(vt.current!==-1&&An(!0),window.clearTimeout(vt.current),vt.current=window.setTimeout(()=>{An(!1),vt.current=-1},200))},[l,pe,se,tt,Gt,_t]);const Nt=c4(s,C),_n=A?Ca(Nt,le):0,Wt=w.useCallback(($,ie,we)=>{const me=$.getBoundingClientRect();if(ie>=Nt.length||we>=h)return;const ce=me.width/n,Ee=S0(ie,we,n,r,c,li,pe,l,se,tt,h,C,E,Nt,f);return ce!==1&&(Ee.x*=ce,Ee.y*=ce,Ee.width*=ce,Ee.height*=ce),Ee.x+=me.x,Ee.y+=me.y,Ee},[n,r,c,li,pe,l,se,tt,h,C,E,Nt,f]),kn=w.useCallback(($,ie,we,me)=>{const ce=$.getBoundingClientRect(),Ee=ce.width/n,Qe=(ie-ce.left)/Ee,Je=(we-ce.top)/Ee,Ce=5,Et=k0(Nt,pe,n,void 0,se);let Ne=0,At=0;me instanceof MouseEvent&&(Ne=me.button,At=me.buttons);const st=p4(Qe,Et,se),gt=g4(Je,r,x,a,c,h,f,l,tt,E),fn=(me==null?void 0:me.shiftKey)===!0,ot=(me==null?void 0:me.ctrlKey)===!0,rn=(me==null?void 0:me.metaKey)===!0,Wr=me!==void 0&&!(me instanceof MouseEvent)||(me==null?void 0:me.pointerType)==="touch",Qt=[Qe<0?-1:nn||Je>r){const kt=Qe>n?1:Qe<0?-1:0,hn=Je>r?1:Je<0?-1:0;let Tr=kt*2,Ni=hn*2;kt===0&&(Tr=st===-1?ea.EndPadding:ea.Center),hn===0&&(Ni=gt===void 0?ea.EndPadding:ea.Center);let fi=!1;if(st===-1&>===-1){const Io=Wt($,Nt.length-1,-1);Pr(Io!==void 0),fi=ien&&Qer&&Je=0?(hn=!0,kt=Wt($,Tr,gt),Pr(kt!==void 0),Cr={kind:x&>===-2?Or:Xs,location:[Tr,gt],bounds:kt,group:Nt[Tr].group??"",isEdge:hn,shiftKey:fn,ctrlKey:ot,metaKey:rn,isTouch:Wr,localEventX:ie-kt.x,localEventY:we-kt.y,button:Ne,buttons:At,scrollEdge:Qt}):Cr={kind:x&>===-2?Or:Xs,group:Nt[st].group??"",location:[st,gt],bounds:kt,isEdge:hn,shiftKey:fn,ctrlKey:ot,metaKey:rn,isTouch:Wr,localEventX:ie-kt.x,localEventY:we-kt.y,button:Ne,buttons:At,scrollEdge:Qt}}else{const kt=Wt($,st,gt);Pr(kt!==void 0);const hn=kt!==void 0&&kt.x+kt.width-ie{}),Ds=w.useRef(vn);Ds.current=vn;const[us,cs]=w.useMemo(()=>{const $=document.createElement("canvas"),ie=document.createElement("canvas");return $.style.display="none",$.style.opacity="0",$.style.position="fixed",ie.style.display="none",ie.style.opacity="0",ie.style.position="fixed",[$.getContext("2d",{alpha:!1}),ie.getContext("2d",{alpha:!1})]},[]);w.useLayoutEffect(()=>{if(!(us===null||cs===null))return document.documentElement.append(us.canvas),document.documentElement.append(cs.canvas),()=>{us.canvas.remove(),cs.canvas.remove()}},[us,cs]);const ml=w.useMemo(()=>new T4,[]),Jc=Gt&&dt?1:_t&&dt?2:5,Zc=(Z==null?void 0:Z.disableMinimumCellWidth)===!0?1:10,_i=w.useRef(),yl=w.useRef(null),vl=w.useRef(null),wl=w.useCallback(()=>{var Qe;const $=De.current,ie=jt.current;if($===null||ie===null||(yl.current===null&&(yl.current=$.getContext("2d",{alpha:!1}),$.width=0,$.height=0),vl.current===null&&(vl.current=ie.getContext("2d",{alpha:!1}),ie.width=0,ie.height=0),yl.current===null||vl.current===null||us===null||cs===null))return;let we=!1;const me=Je=>{we=!0,xt(Je)},ce=_i.current,Ee={headerCanvasCtx:vl.current,canvasCtx:yl.current,bufferACtx:us,bufferBCtx:cs,width:n,height:r,cellXOffset:pe,cellYOffset:l,translateX:Math.round(se),translateY:Math.round(tt),mappedColumns:Nt,enableGroups:x,freezeColumns:C,dragAndDropState:le,theme:it,headerHeight:a,groupHeaderHeight:c,disabledRows:Ze??St.empty(),rowHeight:f,verticalBorder:Ie,isResizing:de,resizeCol:ge,isFocused:k,selection:b,fillHandle:u,drawCellCallback:be,hasAppendRow:Ge,overrideCursor:me,maxScaleFactor:Jc,freezeTrailingRows:E,rows:h,drawFocus:_,getCellContent:d,getGroupDetails:Ye??(Je=>({name:Je})),getRowThemeOverride:p,drawHeaderCallback:Xe,prelightCells:rt,highlightRegions:M,imageLoader:Me,lastBlitData:ct,damage:Ve.current,hoverValues:un.current,hoverInfo:Ds.current,spriteManager:Rn,scrolling:dt,hyperWrapping:(Z==null?void 0:Z.hyperWrapping)??!1,touchMode:In,enqueue:Qc.current,renderStateProvider:ml,renderStrategy:(Z==null?void 0:Z.renderStrategy)??(yd.value?"double-buffer":"single-buffer"),getCellRenderer:ue,minimumCellWidth:Zc};Ee.damage===void 0?(_i.current=Ee,db(Ee,ce)):db(Ee,void 0),!we&&(Ee.damage===void 0||Ee.damage.has((Qe=Ds==null?void 0:Ds.current)==null?void 0:Qe[0]))&&xt(void 0)},[us,cs,n,r,pe,l,se,tt,Nt,x,C,le,it,a,c,Ze,f,Ie,de,Ge,ge,k,b,u,E,h,_,Jc,d,Ye,p,be,Xe,rt,M,Me,Rn,dt,Z==null?void 0:Z.hyperWrapping,Z==null?void 0:Z.renderStrategy,In,ml,ue,Zc]),Oo=w.useRef(wl);w.useLayoutEffect(()=>{wl(),Oo.current=wl},[wl]),w.useLayoutEffect(()=>{(async()=>{var ie;((ie=document==null?void 0:document.fonts)==null?void 0:ie.ready)!==void 0&&(await document.fonts.ready,_i.current=void 0,Oo.current())})()},[]);const _s=w.useCallback($=>{Ve.current=$,Oo.current(),Ve.current=void 0},[]),ef=B8(_s);Qc.current=ef;const tf=w.useCallback($=>{_s(new qu($.map(ie=>ie.cell)))},[_s]);Me.setCallback(_s);const[Ip,Dp]=w.useState(!1),[xl,fs]=qt??[],_p=xl!==void 0&&fs===-1,Np=xl!==void 0&&fs===-2;let nf=!1,bl=!1,wn=pt;if(wn===void 0&&xl!==void 0&&fs!==void 0&&fs>-1&&fs({contain:"strict",display:"block",cursor:rf}),[rf]),Xa=w.useRef("default"),Ns=B==null?void 0:B.current;Ns!=null&&Xa.current!==kl.cursor&&(Ns.style.cursor=Xa.current=kl.cursor);const kr=w.useCallback(($,ie,we,me)=>{if(Ye===void 0)return;const ce=Ye($);if(ce.actions!==void 0){const Ee=VT(ie,ce.actions);for(const[Qe,Je]of Ee.entries())if(yp(Je,we+ie.x,me+Je.y))return ce.actions[Qe]}},[Ye]),ai=w.useCallback(($,ie,we,me)=>{const ce=s[ie];if(!ae&&!de&&ce.hasMenu===!0&&!($r??!1)){const Ee=Wt($,ie,-1);Pr(Ee!==void 0);const Qe=WT(Ee.x,Ee.y,Ee.width,Ee.height,Nv(ce.title)==="rtl");if(we>Qe.x&&weQe.y&&me{const ie=De.current,we=B==null?void 0:B.current;if(ie===null||$.target!==ie&&$.target!==we)return;qa.current=!0;let me,ce;if($ instanceof MouseEvent?(me=$.clientX,ce=$.clientY):(me=$.touches[0].clientX,ce=$.touches[0].clientY),$.target===we&&we!==null){const Qe=we.getBoundingClientRect();if(me>Qe.right||ce>Qe.bottom)return}const Ee=kn(ie,me,ce,$);Ls.current=Ee.location,Ee.isTouch&&(Ga.current=Date.now()),nn.current!==Ee.isTouch&&Dn(Ee.isTouch),!(Ee.kind===Xs&&ai(ie,Ee.location[0],me,ce)!==void 0)&&(Ee.kind===Or&&kr(Ee.group,Ee.bounds,Ee.localEventX,Ee.localEventY)!==void 0||(O==null||O(Ee),!Ee.isTouch&&Re!==!0&&Re!==Ee.kind&&Ee.button<3&&Ee.button!==1&&$.preventDefault()))},[B,Re,kn,kr,ai,O]);Fn("touchstart",tr,window,!1),Fn("mousedown",tr,window,!1);const Sl=w.useRef(0),Ya=w.useCallback($=>{var At,st;const ie=Sl.current;Sl.current=Date.now();const we=De.current;if(qa.current=!1,D===void 0||we===null)return;const me=B==null?void 0:B.current,ce=$.target!==we&&$.target!==me;let Ee,Qe,Je=!0;if($ instanceof MouseEvent){if(Ee=$.clientX,Qe=$.clientY,Je=$.button<3,$.pointerType==="touch")return}else Ee=$.changedTouches[0].clientX,Qe=$.changedTouches[0].clientY;let Ce=kn(we,Ee,Qe,$);Ce.isTouch&&Ga.current!==0&&Date.now()-Ga.current>500&&(Ce={...Ce,isLongTouch:!0}),ie!==0&&Date.now()-ie<(Ce.isTouch?1e3:500)&&(Ce={...Ce,isDoubleClick:!0}),nn.current!==Ce.isTouch&&Dn(Ce.isTouch),!ce&&$.cancelable&&Je&&$.preventDefault();const[Et]=Ce.location,Ne=ai(we,Et,Ee,Qe);if(Ce.kind===Xs&&Ne!==void 0){(Ce.button!==0||((At=Ls.current)==null?void 0:At[0])!==Et||((st=Ls.current)==null?void 0:st[1])!==-1)&&D(Ce,!0);return}else if(Ce.kind===Or){const gt=kr(Ce.group,Ce.bounds,Ce.localEventX,Ce.localEventY);if(gt!==void 0){Ce.button===0&>.onClick(Ce);return}}D(Ce,ce)},[D,B,kn,ai,kr]);Fn("mouseup",Ya,window,!1),Fn("touchend",Ya,window,!1);const sf=w.useCallback($=>{var Ne,At;const ie=De.current;if(ie===null)return;const we=B==null?void 0:B.current,me=$.target!==ie&&$.target!==we;let ce,Ee,Qe=!0;$ instanceof MouseEvent?(ce=$.clientX,Ee=$.clientY,Qe=$.button<3):(ce=$.changedTouches[0].clientX,Ee=$.changedTouches[0].clientY);const Je=kn(ie,ce,Ee,$);nn.current!==Je.isTouch&&Dn(Je.isTouch),!me&&$.cancelable&&Qe&&$.preventDefault();const[Ce]=Je.location,Et=ai(ie,Ce,ce,Ee);if(Je.kind===Xs&&Et!==void 0)Je.button===0&&((Ne=Ls.current)==null?void 0:Ne[0])===Ce&&((At=Ls.current)==null?void 0:At[1])===-1&&(m==null||m(Ce,Et));else if(Je.kind===Or){const st=kr(Je.group,Je.bounds,Je.localEventX,Je.localEventY);st!==void 0&&Je.button===0&&st.onClick(Je)}},[B,kn,ai,m,kr]);Fn("click",sf,window,!1);const Lp=w.useCallback($=>{const ie=De.current,we=B==null?void 0:B.current;if(ie===null||$.target!==ie&&$.target!==we||T===void 0)return;const me=kn(ie,$.clientX,$.clientY,$);T(me,()=>{$.cancelable&&$.preventDefault()})},[B,kn,T]);Fn("contextmenu",Lp,(B==null?void 0:B.current)??null,!1);const of=w.useCallback($=>{Ve.current=new qu($.map(ie=>ie.item)),un.current=$,Oo.current(),Ve.current=void 0},[]),ui=w.useMemo(()=>new N8(of),[of]),hs=w.useRef(ui);hs.current=ui,w.useLayoutEffect(()=>{const $=hs.current;if(qt===void 0||qt[1]<0){$.setHovered(qt);return}const ie=d(qt,!0),we=ue(ie),me=we===void 0&&ie.kind===ke.Custom||(we==null?void 0:we.needsHover)!==void 0&&(typeof we.needsHover=="boolean"?we.needsHover:we.needsHover(ie));$.setHovered(me?qt:void 0)},[d,ue,qt]);const Sr=w.useRef(),G=w.useCallback($=>{var Je;const ie=De.current;if(ie===null)return;const we=B==null?void 0:B.current,me=$.target!==ie&&$.target!==we,ce=kn(ie,$.clientX,$.clientY,$);if(ce.kind!=="out-of-bounds"&&me&&!qa.current&&!ce.isTouch)return;const Ee=(Ce,Et)=>{cn(Ne=>Ne===Ce||(Ne==null?void 0:Ne[0][0])===(Ce==null?void 0:Ce[0][0])&&(Ne==null?void 0:Ne[0][1])===(Ce==null?void 0:Ce[0][1])&&((Ne==null?void 0:Ne[1][0])===(Ce==null?void 0:Ce[1][0])&&(Ne==null?void 0:Ne[1][1])===(Ce==null?void 0:Ce[1][1])||!Et)?Ne:Ce)};if(!rE(ce,Sr.current))xt(void 0),X==null||X(ce),Ee(ce.kind===wd?void 0:[ce.location,[ce.localEventX,ce.localEventY]],!0),Sr.current=ce;else if(ce.kind==="cell"||ce.kind===Xs||ce.kind===Or){let Ce=!1,Et=!0;if(ce.kind==="cell"){const At=d(ce.location);Et=((Je=ue(At))==null?void 0:Je.needsHoverPosition)??At.kind===ke.Custom,Ce=Et}else ce.kind===Or&&(Ce=!0);const Ne=[ce.location,[ce.localEventX,ce.localEventY]];Ee(Ne,Et),Ds.current=Ne,Ce&&_s(new qu([ce.location]))}const Qe=ce.location[0]>=(j?0:1);Hr(ce.kind===Xs&&ce.isEdge&&Qe&&nt===!0),Dp(ce.kind==="cell"&&ce.isFillHandle),I==null||I($),Q(ce)},[B,kn,j,nt,I,Q,X,d,ue,_s]);Fn("mousemove",G,window,!0);const Yt=w.useCallback($=>{const ie=De.current;if(ie===null)return;let we,me;b.current!==void 0&&(we=Wt(ie,b.current.cell[0],b.current.cell[1]),me=b.current.cell),ne==null||ne({bounds:we,stopPropagation:()=>$.stopPropagation(),preventDefault:()=>$.preventDefault(),cancel:()=>{},ctrlKey:$.ctrlKey,metaKey:$.metaKey,shiftKey:$.shiftKey,altKey:$.altKey,key:$.key,keyCode:$.keyCode,rawEvent:$,location:me})},[ne,b,Wt]),Po=w.useCallback($=>{const ie=De.current;if(ie===null)return;let we,me;b.current!==void 0&&(we=Wt(ie,b.current.cell[0],b.current.cell[1]),me=b.current.cell),Y==null||Y({bounds:we,stopPropagation:()=>$.stopPropagation(),preventDefault:()=>$.preventDefault(),cancel:()=>{},ctrlKey:$.ctrlKey,metaKey:$.metaKey,shiftKey:$.shiftKey,altKey:$.altKey,key:$.key,keyCode:$.keyCode,rawEvent:$,location:me})},[Y,b,Wt]),Fp=w.useCallback($=>{De.current=$,F!==void 0&&(F.current=$)},[F]),lf=w.useCallback($=>{const ie=De.current;if(ie===null||Re===!1||de){$.preventDefault();return}let we,me;const ce=kn(ie,$.clientX,$.clientY);if(Re!==!0&&ce.kind!==Re){$.preventDefault();return}const Ee=(At,st)=>{we=At,me=st};let Qe,Je,Ce;const Et=(At,st,gt)=>{Qe=At,Je=st,Ce=gt};let Ne=!1;if(z==null||z({...ce,setData:Ee,setDragImage:Et,preventDefault:()=>Ne=!0,defaultPrevented:()=>Ne}),!Ne&&we!==void 0&&me!==void 0&&$.dataTransfer!==null)if($.dataTransfer.setData(we,me),$.dataTransfer.effectAllowed="copyLink",Qe!==void 0&&Je!==void 0&&Ce!==void 0)$.dataTransfer.setDragImage(Qe,Je,Ce);else{const[At,st]=ce.location;if(st!==void 0){const gt=document.createElement("canvas"),fn=Wt(ie,At,st);Pr(fn!==void 0);const ot=Math.ceil(window.devicePixelRatio??1);gt.width=fn.width*ot,gt.height=fn.height*ot;const rn=gt.getContext("2d");rn!==null&&(rn.scale(ot,ot),rn.textBaseline="middle",st===-1?(rn.font=it.headerFontFull,rn.fillStyle=it.bgHeader,rn.fillRect(0,0,gt.width,gt.height),UT(rn,0,0,fn.width,fn.height,Nt[At],!1,it,!1,!1,0,Rn,Xe,!1)):(rn.font=it.baseFontFull,rn.fillStyle=it.bgCell,rn.fillRect(0,0,gt.width,gt.height),jT(rn,d([At,st]),0,st,!1,!1,0,0,fn.width,fn.height,!1,it,it.bgCell,Me,Rn,1,void 0,!1,0,void 0,void 0,void 0,ml,ue,()=>{}))),gt.style.left="-100%",gt.style.position="absolute",gt.style.width=`${fn.width}px`,gt.style.height=`${fn.height}px`,document.body.append(gt),$.dataTransfer.setDragImage(gt,fn.width/2,fn.height/2),window.setTimeout(()=>{gt.remove()},0)}}else $.preventDefault()},[Re,de,kn,z,Wt,it,Nt,Rn,Xe,d,Me,ml,ue]);Fn("dragstart",lf,(B==null?void 0:B.current)??null,!1,!1);const Qa=w.useRef(),Bp=w.useCallback($=>{const ie=De.current;if(Be!==void 0&&$.preventDefault(),ie===null||et===void 0)return;const we=kn(ie,$.clientX,$.clientY),[me,ce]=we.location,Ee=me-(j?0:1),[Qe,Je]=Qa.current??[];(Qe!==Ee||Je!==ce)&&(Qa.current=[Ee,ce],et([Ee,ce],$.dataTransfer))},[j,kn,et,Be]);Fn("dragover",Bp,(B==null?void 0:B.current)??null,!1,!1);const vw=w.useCallback(()=>{Qa.current=void 0,W==null||W()},[W]);Fn("dragend",vw,(B==null?void 0:B.current)??null,!1,!1);const J=w.useCallback($=>{const ie=De.current;if(ie===null||Be===void 0)return;$.preventDefault();const we=kn(ie,$.clientX,$.clientY),[me,ce]=we.location,Ee=me-(j?0:1);Be([Ee,ce],$.dataTransfer)},[j,kn,Be]);Fn("drop",J,(B==null?void 0:B.current)??null,!1,!1);const Wn=w.useCallback(()=>{ye==null||ye()},[ye]);Fn("dragleave",Wn,(B==null?void 0:B.current)??null,!1,!1);const xn=w.useRef(b);xn.current=b;const Cl=w.useRef(null),Ja=w.useCallback($=>{var ie;De.current===null||!De.current.contains(document.activeElement)||($===null&&xn.current.current!==void 0?(ie=F==null?void 0:F.current)==null||ie.focus({preventScroll:!0}):$!==null&&$.focus({preventScroll:!0}),Cl.current=$)},[F]);w.useImperativeHandle(e,()=>({focus:()=>{var ie;const $=Cl.current;$===null||!document.contains($)?(ie=F==null?void 0:F.current)==null||ie.focus({preventScroll:!0}):$.focus({preventScroll:!0})},getBounds:($,ie)=>{if(!(F===void 0||F.current===null))return Wt(F.current,$??0,ie??-1)},damage:tf}),[F,tf,Wt]);const Fs=w.useRef(),fr=RF(()=>{var Je,Ce,Et;if(n<50||(Z==null?void 0:Z.disableAccessibilityTree)===!0)return null;let $=k0(Nt,pe,n,le,se);const ie=j?0:-1;!j&&((Je=$[0])==null?void 0:Je.sourceIndex)===0&&($=$.slice(1));const[we,me]=((Ce=b.current)==null?void 0:Ce.cell)??[],ce=(Et=b.current)==null?void 0:Et.range,Ee=$.map(Ne=>Ne.sourceIndex),Qe=Vo(l,Math.min(h,l+i));return we!==void 0&&me!==void 0&&!(Ee.includes(we)&&Qe.includes(me))&&Ja(null),w.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":h+1,"aria-multiselectable":"true","aria-colcount":Nt.length+ie},w.createElement("thead",{role:"rowgroup"},w.createElement("tr",{role:"row","aria-rowindex":1},$.map(Ne=>w.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex(Ne.sourceIndex),"aria-colindex":Ne.sourceIndex+1+ie,tabIndex:-1,onFocus:At=>{if(At.target!==Cl.current)return qe==null?void 0:qe([Ne.sourceIndex,-1])},key:Ne.sourceIndex},Ne.title)))),w.createElement("tbody",{role:"rowgroup"},Qe.map(Ne=>w.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex(Ne),key:Ne,"aria-rowindex":Ne+2},$.map(At=>{const st=At.sourceIndex,gt=ki(st,Ne),fn=we===st&&me===Ne,ot=ce!==void 0&&st>=ce.x&&st=ce.y&&Ne{const Cr=F==null?void 0:F.current;if(Cr!=null)return ne==null?void 0:ne({bounds:Wt(Cr,st,Ne),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:Wr})},onFocusCapture:Cr=>{var kt,hn;if(!(Cr.target===Cl.current||((kt=Fs.current)==null?void 0:kt[0])===st&&((hn=Fs.current)==null?void 0:hn[1])===Ne))return Fs.current=Wr,qe==null?void 0:qe(Wr)},ref:fn?Ja:void 0,tabIndex:-1},z8(Qt,ue))})))))},[n,Nt,pe,le,se,h,l,i,b,Ja,d,F,ne,Wt,qe],200),ci=C===0||!A?0:pe>C?1:bi(-se/100,0,1),zp=-l*32+tt,Tl=P?bi(-zp/100,0,1):0,$p=w.useMemo(()=>{if(!ci&&!Tl)return null;const $={position:"absolute",top:0,left:_n,width:n-_n,height:r,opacity:ci,pointerEvents:"none",transition:H?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},ie={position:"absolute",top:li,left:0,width:n,height:r,opacity:Tl,pointerEvents:"none",transition:V?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return w.createElement(w.Fragment,null,ci>0&&w.createElement("div",{id:"shadow-x",style:$}),Tl>0&&w.createElement("div",{id:"shadow-y",style:ie}))},[ci,Tl,_n,n,H,li,r,V]),Hp=w.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return w.createElement(w.Fragment,null,w.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:Yt,onKeyUp:Po,onFocus:g,onBlur:y,ref:Fp,style:kl},fr),w.createElement("canvas",{ref:jt,style:Hp}),$p)},H8=w.memo(w.forwardRef($8));function vu(t,e,n,r){return bi(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const j8=t=>{const[e,n]=w.useState(),[r,i]=w.useState(),[s,o]=w.useState(),[l,a]=w.useState(),[u,c]=w.useState(!1),[f,h]=w.useState(),[d,p]=w.useState(),[m,x]=w.useState(),[v,g]=w.useState(!1),[y,k]=w.useState(),{onHeaderMenuClick:b,getCellContent:C,onColumnMoved:T,onColumnResize:E,onColumnResizeStart:A,onColumnResizeEnd:P,gridRef:_,maxColumnWidth:O,minColumnWidth:D,onRowMoved:I,lockColumns:Q,onColumnProposeMove:X,onMouseDown:le,onMouseUp:j,onItemHovered:ne,onDragStart:Y,canvasRef:M}=t,F=(E??P??A)!==void 0,{columns:z,selection:W}=t,B=W.columns,de=w.useCallback(Ie=>{const[be,Xe]=Ie.location;s!==void 0&&l!==be&&be>=Q?(c(!0),a(be)):d!==void 0&&Xe!==void 0?(g(!0),x(Math.max(0,Xe))):r===void 0&&!u&&!v&&(ne==null||ne(Ie))},[s,d,l,ne,Q,r,u,v]),ge=T!==void 0,ae=w.useCallback(Ie=>{var be;if(Ie.button===0){const[Xe,qe]=Ie.location;if(Ie.kind==="out-of-bounds"&&Ie.isEdge&&F){const et=(be=_==null?void 0:_.current)==null?void 0:be.getBounds(z.length-1,-1);et!==void 0&&(n(et.x),i(z.length-1))}else if(Ie.kind==="header"&&Xe>=Q){const et=M==null?void 0:M.current;if(Ie.isEdge&&F&&et){n(Ie.bounds.x),i(Xe);const ye=et.getBoundingClientRect().width/et.offsetWidth,_e=Ie.bounds.width/ye;A==null||A(z[Xe],_e,Xe,_e+(z[Xe].growOffset??0))}else Ie.kind==="header"&&ge&&(h(Ie.bounds.x),o(Xe))}else Ie.kind==="cell"&&Q>0&&Xe===0&&qe!==void 0&&I!==void 0&&(k(Ie.bounds.y),p(qe))}le==null||le(Ie)},[le,F,Q,I,_,z,ge,A,M]),Re=w.useCallback((Ie,be)=>{u||v||b==null||b(Ie,be)},[u,v,b]),nt=w.useRef(-1),Ze=w.useCallback(()=>{nt.current=-1,p(void 0),x(void 0),k(void 0),g(!1),o(void 0),a(void 0),h(void 0),c(!1),i(void 0),n(void 0)},[]),Ge=w.useCallback((Ie,be)=>{if(Ie.button===0){if(r!==void 0){if((B==null?void 0:B.hasIndex(r))===!0)for(const qe of B){if(qe===r)continue;const et=z[qe],Be=vu(et,nt.current,D,O);E==null||E(et,Be,qe,Be+(et.growOffset??0))}const Xe=vu(z[r],nt.current,D,O);if(P==null||P(z[r],Xe,r,Xe+(z[r].growOffset??0)),B.hasIndex(r))for(const qe of B){if(qe===r)continue;const et=z[qe],Be=vu(et,nt.current,D,O);P==null||P(et,Be,qe,Be+(et.growOffset??0))}}Ze(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),d!==void 0&&m!==void 0&&(I==null||I(d,m))}j==null||j(Ie,be)},[j,r,s,l,d,m,B,P,z,D,O,E,T,I,Ze]),Ye=w.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(X==null?void 0:X(s,l))!==!1)return{src:s,dest:l}},[s,l,X]),it=w.useCallback(Ie=>{const be=M==null?void 0:M.current;if(s!==void 0&&f!==void 0)Math.abs(Ie.clientX-f)>20&&c(!0);else if(d!==void 0&&y!==void 0)Math.abs(Ie.clientY-y)>20&&g(!0);else if(r!==void 0&&e!==void 0&&be){const qe=be.getBoundingClientRect().width/be.offsetWidth,et=(Ie.clientX-e)/qe,Be=z[r],ye=vu(Be,et,D,O);if(E==null||E(Be,ye,r,ye+(Be.growOffset??0)),nt.current=et,(B==null?void 0:B.first())===r)for(const _e of B){if(_e===r)continue;const H=z[_e],V=vu(H,nt.current,D,O);E==null||E(H,V,_e,V+(H.growOffset??0))}}},[s,f,d,y,r,e,z,D,O,E,B,M]),rt=w.useCallback((Ie,be)=>{if(d===void 0||m===void 0)return C(Ie,be);let[Xe,qe]=Ie;return qe===m?qe=d:(qe>m&&(qe-=1),qe>=d&&(qe+=1)),C([Xe,qe],be)},[d,m,C]),Dt=w.useCallback(Ie=>{Y==null||Y(Ie),Ie.defaultPrevented()||Ze()},[Ze,Y]);return w.createElement(H8,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:rt,isResizing:r!==void 0,onHeaderMenuClick:Re,isDragging:u,onItemHovered:de,onDragStart:Dt,onMouseDown:ae,allowResize:F,onMouseUp:Ge,dragAndDropState:Ye,onMouseMoveRaw:it,ref:_})};function W8(t){const e=w.useRef(null),[n,r]=w.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return w.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const V8=(t,e,n)=>{const r=w.useRef(null),i=w.useRef(null),s=w.useRef(null),o=w.useRef(0),l=w.useRef(e);l.current=e;const a=n.current;w.useEffect(()=>{const u=()=>{var h,d;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((h=s.current)==null?void 0:h[0])===p[0]&&((d=s.current)==null?void 0:d[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=h=>{h.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const h=a;return h.addEventListener("touchstart",c),h.addEventListener("touchend",f),()=>{h.removeEventListener("touchstart",c),h.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},U8=()=>t=>t.isSafari?"scroll":"auto",K8=zr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[U8()]}});function X8(t){const[e,n]=w.useState(!1),r=typeof window>"u"?null:window,i=w.useRef(0);return Fn("touchstart",w.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),Fn("touchend",w.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const G8=t=>{var z,W;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:h,kineticScrollPerfHack:d=!1,scrollRef:p,initialSize:m}=t,x=[],v=(h==null?void 0:h.sticky)??!1,g=(h==null?void 0:h.fill)??!1,y=w.useRef(0),k=w.useRef(0),b=w.useRef(null),C=typeof window>"u"?1:window.devicePixelRatio,T=w.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),E=w.useRef(null),A=X8(200),[P,_]=w.useState(!0),O=w.useRef(0);w.useLayoutEffect(()=>{if(!P||A||T.current.lockDirection===void 0)return;const B=b.current;if(B===null)return;const[de,ge]=T.current.lockDirection;de!==void 0?B.scrollLeft=de:ge!==void 0&&(B.scrollTop=ge),T.current.lockDirection=void 0},[A,P]);const D=w.useCallback((B,de)=>{var be;const ge=b.current;if(ge===null)return;de=de??ge.scrollTop,B=B??ge.scrollLeft;const ae=T.current.scrollTop,Re=T.current.scrollLeft,nt=B-Re,Ze=de-ae;A&&nt!==0&&Ze!==0&&(Math.abs(nt)>3||Math.abs(Ze)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(nt)0&&(Math.abs(Dt)>2e3||rt===0||rt===Ie)&&r>ge.scrollHeight+5){const Xe=rt/Ie,qe=(r-it)*Xe;y.current=qe-rt}Ge!==void 0&&(window.clearTimeout(O.current),_(!1),O.current=window.setTimeout(()=>_(!0),200)),s({x:B,y:rt+y.current,width:Ye-c,height:it-u,paddingRight:((be=E.current)==null?void 0:be.clientWidth)??0})},[u,c,r,s,a,A]);V8(d&&yd.value,D,b);const I=w.useRef(D);I.current=D;const Q=w.useRef(),X=w.useRef(!1);w.useLayoutEffect(()=>{X.current?D():X.current=!0},[D,u,c]);const le=w.useCallback(B=>{b.current=B,p!==void 0&&(p.current=B)},[p]);let j=0,ne=0;for(x.push(w.createElement("div",{key:j++,style:{width:i,height:0}}));neI.current(),0),Q.current={width:M,height:F}),(M??0)===0||(F??0)===0?w.createElement("div",{ref:Y}):w.createElement("div",{ref:Y},w.createElement(K8,{isSafari:yd.value},w.createElement("div",{className:"dvn-underlay"},e),w.createElement("div",{ref:le,style:Q.current,draggable:o,onDragStart:B=>{o||(B.stopPropagation(),B.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>D()},w.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},w.createElement("div",{className:"dvn-stack"},x),f!==void 0&&w.createElement(w.Fragment,null,!g&&w.createElement("div",{className:"dvn-spacer"}),w.createElement("div",{ref:E,style:{height:F,maxHeight:n-Math.ceil(C%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:g?1:void 0,right:v?c??0:void 0,pointerEvents:"auto"}},f))))))},q8=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:h,scrollRef:d,preventDiagonalScrolling:p,rightElement:m,rightElementProps:x,overscrollX:v,overscrollY:g,initialSize:y,smoothScrollX:k=!1,smoothScrollY:b=!1,isDraggable:C}=t,{paddingRight:T,paddingBottom:E}=a??{},[A,P]=c,_=w.useRef(),O=w.useRef(),D=w.useRef(),I=w.useRef(),Q=u+Math.max(0,v??0);let X=o?i+s:i;if(typeof r=="number")X+=n*r;else for(let Y=0;Y{var Ze,Ge;if(le.current===void 0)return;const Y={...le.current};let M=0,F=Y.x<0?-Y.x:0,z=0,W=0;Y.x=Y.x<0?0:Y.x;let B=0;for(let Ye=0;Ye=it+Ye.width)M+=Ye.width,W++,z++;else if(Y.x>it)M+=Ye.width,k?F+=it-Y.x:W++,z++;else if(Y.x+Y.width>it)M+=Ye.width,z++;else break}let de=0,ge=0,ae=0;if(typeof r=="number")b?(ge=Math.floor(Y.y/r),de=ge*r-Y.y):ge=Math.ceil(Y.y/r),ae=Math.ceil(Y.height/r)+ge,de<0&&ae++;else{let Ye=0;for(let it=0;it=Ye+rt)Ye+=rt,ge++,ae++;else if(Y.y>Dt)Ye+=rt,b?de+=Dt-Y.y:ge++,ae++;else if(Y.y+Y.height>rt/2+Ye)Ye+=rt,ae++;else break}}const Re={x:W,y:ge,width:z-W,height:ae-ge},nt=_.current;(nt===void 0||nt.y!==Re.y||nt.x!==Re.x||nt.height!==Re.height||nt.width!==Re.width||O.current!==F||D.current!==de||Y.width!==((Ze=I.current)==null?void 0:Ze[0])||Y.height!==((Ge=I.current)==null?void 0:Ge[1]))&&(h==null||h({x:W,y:ge,width:z-W,height:ae-ge},Y.width,Y.height,Y.paddingRight??0,F,de),_.current=Re,O.current=F,D.current=de,I.current=[Y.width,Y.height])},[e,r,n,h,l,k,b]),ne=w.useCallback(Y=>{le.current=Y,j()},[j]);return w.useEffect(()=>{j()},[j]),w.createElement(G8,{scrollRef:d,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:C===!0||typeof C=="string",scrollWidth:Q+(T??0),scrollHeight:X+(E??0),clientHeight:P,rightElement:m,paddingBottom:E,paddingRight:T,rightElementProps:x,update:ne,initialSize:y},w.createElement(j8,{eventTargetRef:d,width:A,height:P,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},Y8=zr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),Q8=w.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},w.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),J8=w.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},w.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),Z8=w.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},w.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),eW=10,tW=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:h}=t,[d]=w.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,m]=w.useState(""),x=o??p,v=w.useCallback(M=>{m(M),a==null||a(M)},[a]),[g,y]=w.useState(),k=w.useRef(g);k.current=g,w.useEffect(()=>{l!==void 0&&(l.length>0?y(M=>({rowsSearched:r,results:l.length,selectedIndex:(M==null?void 0:M.selectedIndex)??-1})):y(void 0))},[r,l]);const b=w.useRef();b.current===void 0&&(b.current=new AbortController);const C=w.useRef(),[T,E]=w.useState([]),A=l??T,P=w.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,b.current.abort())},[]),_=w.useRef(n);_.current=n;const O=w.useCallback(M=>{const F=new RegExp(M.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let z=_.current,W=Math.min(10,r),B=0;y(void 0),E([]);const de=[],ge=async()=>{var Ie;if(u===void 0)return;const ae=performance.now(),Re=r-B;let nt=u({x:0,y:z,width:i.length,height:Math.min(W,Re,r-z)},b.current.signal);typeof nt=="function"&&(nt=await nt());let Ze=!1;for(const[be,Xe]of nt.entries())for(const[qe,et]of Xe.entries()){let Be;switch(et.kind){case ke.Text:case ke.Number:Be=et.displayData;break;case ke.Uri:case ke.Markdown:Be=et.data;break;case ke.Boolean:Be=typeof et.data=="boolean"?et.data.toString():void 0;break;case ke.Image:case ke.Bubble:Be=et.data.join("🐳");break;case ke.Custom:Be=et.copyData;break}Be!==void 0&&F.test(Be)&&(de.push([qe,be+z]),Ze=!0)}const Ge=performance.now();Ze&&E([...de]),B+=nt.length,Pr(B<=r);const Ye=((Ie=k.current)==null?void 0:Ie.selectedIndex)??-1;y({results:de.length,rowsSearched:B,selectedIndex:Ye}),c==null||c(de,Ye),z+W>=r?z=0:z+=W;const it=Ge-ae,rt=Math.max(it,1),Dt=eW/rt;W=Math.ceil(W*Dt),B{var M;h==null||h(),y(void 0),E([]),c==null||c([],-1),P(),(M=e==null?void 0:e.current)==null||M.focus()},[P,e,h,c]),I=w.useCallback(M=>{v(M.target.value),l===void 0&&(M.target.value===""?(y(void 0),E([]),P()):O(M.target.value))},[O,P,v,l]);w.useEffect(()=>{f&&s.current!==null&&(v(""),s.current.focus({preventScroll:!0}))},[f,s,v]);const Q=w.useCallback(M=>{var z;if((z=M==null?void 0:M.stopPropagation)==null||z.call(M),g===void 0)return;const F=(g.selectedIndex+1)%g.results;y({...g,selectedIndex:F}),c==null||c(A,F)},[g,c,A]),X=w.useCallback(M=>{var z;if((z=M==null?void 0:M.stopPropagation)==null||z.call(M),g===void 0)return;let F=(g.selectedIndex-1)%g.results;F<0&&(F+=g.results),y({...g,selectedIndex:F}),c==null||c(A,F)},[c,A,g]),le=w.useCallback(M=>{(M.ctrlKey||M.metaKey)&&M.nativeEvent.code==="KeyF"||M.key==="Escape"?(D(),M.stopPropagation(),M.preventDefault()):M.key==="Enter"&&(M.shiftKey?X():Q())},[D,Q,X]);w.useEffect(()=>()=>{P()},[P]);const[j,ne]=w.useState(!1);w.useEffect(()=>{if(f)ne(!0);else{const M=setTimeout(()=>ne(!1),150);return()=>clearTimeout(M)}},[f]);const Y=w.useMemo(()=>{if(!f&&!j)return null;let M;g!==void 0&&(M=g.results>=1e3?"over 1000":`${g.results} result${g.results!==1?"s":""}`,g.selectedIndex>=0&&(M=`${g.selectedIndex+1} of ${M}`));const F=B=>{B.stopPropagation()},W={width:`${Math.floor(((g==null?void 0:g.rowsSearched)??0)/r*100)}%`};return w.createElement(Y8,{className:f?"":"out",onMouseDown:F,onMouseMove:F,onMouseUp:F,onClick:F},w.createElement("div",{className:"gdg-search-bar-inner"},w.createElement("input",{id:d,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:I,value:x,tabIndex:f?void 0:-1,onKeyDownCapture:le}),w.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:X,disabled:((g==null?void 0:g.results)??0)===0},Q8),w.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:Q,disabled:((g==null?void 0:g.results)??0)===0},J8),h!==void 0&&w.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:D},Z8)),g!==void 0?w.createElement(w.Fragment,null,w.createElement("div",{className:"gdg-search-status"},w.createElement("div",{"data-testid":"search-result-area"},M)),w.createElement("div",{className:"gdg-search-progress",style:W})):w.createElement("div",{className:"gdg-search-status"},w.createElement("label",{htmlFor:d},"Type to search")))},[f,j,g,r,d,s,I,x,le,X,Q,h,D]);return w.createElement(w.Fragment,null,w.createElement(q8,{prelightCells:A,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),Y)};class nW extends w.PureComponent{constructor(){super(...arguments);ft(this,"wrapperRef",w.createRef());ft(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return w.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const rW=()=>t=>Math.max(16,t.targetHeight-10),iW=zr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[rW(),"px"]}}),sW=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Tn.useState(n);return Tn.createElement(nW,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},Tn.createElement(iW,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function oW(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function at(t,e,n){const r=iE(t,e);return r&&(n.didMatch=!0),r}function iE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(iE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!oW(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":vd.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function lW(t,e,n,r,i,s){const o=Tn.useCallback((u,c,f,h)=>{var g;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const d=n==="mixed"&&(f||h==="drag"),p=r==="mixed"&&d,m=i==="mixed"&&d;let x={current:u===void 0?void 0:{...u,rangeStack:h==="drag"?((g=t.current)==null?void 0:g.rangeStack)??[]:[]},columns:p?t.columns:St.empty(),rows:m?t.rows:St.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&x.current!==void 0&&t.current!==void 0&&(x={...x,current:{...x.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(x,c)},[r,t,n,s,i,e]),l=Tn.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let h;if(i==="exclusive"&&u.length>0)h={current:void 0,columns:St.empty(),rows:u};else{const d=f&&n==="mixed",p=f&&r==="mixed";h={current:d?t.current:void 0,columns:p?t.columns:St.empty(),rows:u}}e(h,!1)},[r,t,n,i,e]),a=Tn.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let h;if(r==="exclusive"&&u.length>0)h={current:void 0,rows:St.empty(),columns:u};else{const d=f&&n==="mixed",p=f&&i==="mixed";h={current:d?t.current:void 0,rows:p?t.rows:St.empty(),columns:u}}e(h,!1)},[r,t,n,i,e]);return[o,l,a]}function aW(t,e,n,r,i){const s=w.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?h.push({kind:ke.Loading,allowOverlay:!1}):h.push(e([d,f]));c.push(h)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=w.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(h=>[{kind:ke.Loading,allowOverlay:!1},...h]):f.map(h=>[{kind:ke.Loading,allowOverlay:!1},...h])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function uW(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case ke.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Rv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case ke.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case ke.Image:case ke.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case ke.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case ke.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case ke.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case ke.Markdown:case ke.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case ke.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case ke.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case ke.Protected:return{formatted:"************",rawValue:"",format:"string"};default:bc()}}function cW(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:uW(o))})}function gb(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function fW(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>gb(o,!0)).join(",")):i.push(gb(s.formatted,!1));e.push(i.join(" "))}return e.join(` +`)}function jg(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function mb(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function hW(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function dW(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
${jg(i.formatted)}
    ${i.formatted.map((o,l)=>`
  1. `+jg(o)+"
  2. ").join("")}
${jg(i.formatted)}
"),e.join("")}function pW(t,e){const n=cW(t,e),r=fW(n),i=dW(n);return{textPlain:r,textHtml:i}}function yb(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",h=a.querySelectorAll("br");for(const m of h)m.replaceWith(` +`);const d=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const m=a.querySelectorAll("li");s==null||s.push({rawValue:[...m].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...m].map(x=>x.textContent??""),format:"string-array"})}else if(d!==null)s==null||s.push({rawValue:hW(d),formatted:a.textContent??"",format:p});else{let m=a.textContent??"";f&&(m=m.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:m??"",formatted:m??"",format:p})}}}return s!==void 0&&i.push(s),i}function gW(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const h=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h);const d=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}else{const h=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}let c=a.x-n,f=a.x+a.width-1-n;for(const h of u)for(const d of h)d.span!==void 0&&(c=Math.min(d.span[0],c),f=Math.max(d.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function vb(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function mW(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` `);let o=0;for(const l of t){switch(s){case e.None:l===" "||l===` `?(r.push(t.slice(i,o)),i=o+1,l===` `&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` -`)&&(r.push(mb(t.slice(i,o))),i=o+1,l===` -`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function yb(t,e,n){var l;const r=hW(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function nE(t){return t!==!0}function vb(t){return typeof t=="string"?t:`${t}px`}const gW=()=>t=>t.innerWidth,mW=()=>t=>t.innerHeight,yW=Br("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[gW()],"wmyidgi-1":[mW()]}}),vW=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return w.createElement(yW,{innerHeight:vb(n),innerWidth:vb(e),...i},r)},wW=2,xW=1300;function bW(t,e,n){const r=kn.useRef(0),[i,s]=t??[0,0];kn.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/xW);const h=r.current**1.618*f*wW;(c=e.current)==null||c.scrollBy(i*h,s*h),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function kW({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,h,d]=kn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=MT();return[typeof m=="number"?m*p:v=>Math.ceil(m(v)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:h,overscrollY:d}}const Us={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function lt(t,e){return t===!0?e:t===!1?"":t}function wb(t){const e=md.value;return{activateCell:lt(t.activateCell," |Enter|shift+Enter"),clear:lt(t.clear,"any+Escape"),closeOverlay:lt(t.closeOverlay,"any+Escape"),acceptOverlayDown:lt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:lt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:lt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:lt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:lt(t.delete,e?"Backspace|Delete":"Delete"),downFill:lt(t.downFill,"primary+_68"),scrollToSelectedCell:lt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:lt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:lt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:lt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:lt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:lt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:lt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:lt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:lt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:lt(t.goToFirstCell,"primary+Home"),goToFirstColumn:lt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:lt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:lt(t.goToLastCell,"primary+End"),goToLastColumn:lt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:lt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:lt(t.goToNextPage,"PageDown"),goToPreviousPage:lt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:lt(t.rightFill,"primary+_82"),search:lt(t.search,"primary+f"),selectAll:lt(t.selectAll,"primary+a"),selectColumn:lt(t.selectColumn,"ctrl+ "),selectGrowDown:lt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:lt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:lt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:lt(t.selectGrowUp,"shift+ArrowUp"),selectRow:lt(t.selectRow,"shift+ "),selectToFirstCell:lt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:lt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:lt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:lt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:lt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:lt(t.selectToLastRow,"primary+shift+ArrowDown")}}function SW(t){const e=IF(t);return kn.useMemo(()=>{if(e===void 0)return wb(Us);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Us.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Us.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Us.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Us.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Us.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Us.selectToLastCell};return wb({...Us,...n})},[e])}const CW=w.lazy(async()=>await RT(()=>import("./data-grid-overlay-editor-D3k0cr0z.js"),[]));let TW=0;function EW(t){return RB(Bx(Bx(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return Vo((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Wf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const Hg={kind:Se.Loading,allowOverlay:!1},Vf={columns:wt.empty(),rows:wt.empty(),current:void 0},MW=(t,e)=>{var Ow,Pw,Iw;const[n,r]=w.useState(Vf),[i,s]=w.useState(),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(),c=w.useRef(null),f=w.useRef(),h=typeof window>"u"?null:window,{imageEditorOverride:d,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:v,columns:g,rows:y,getCellContent:k,onCellClicked:b,onCellActivated:C,onFillPattern:T,onFinishedEditing:E,coercePasteValue:A,drawHeader:P,drawCell:D,editorBloom:O,onHeaderClicked:_,onColumnProposeMove:I,spanRangeBehavior:Y="default",onGroupHeaderClicked:U,onCellContextMenu:ae,className:H,onHeaderContextMenu:te,getCellsForSelection:G,onGroupHeaderContextMenu:M,onGroupHeaderRenamed:F,onCellEdited:z,onCellsEdited:j,onSearchResultsChanged:B,searchResults:ge,onSearchValueChange:we,searchValue:ue,onKeyDown:_e,onKeyUp:Je,keybindings:qe,editOnType:Ye=!0,onRowAppended:Qe,onColumnMoved:et,validateCell:Ze,highlightRegions:Ot,rangeSelect:Ie="rect",columnSelect:Te="multi",rowSelect:Q="multi",rangeSelectionBlending:ce="exclusive",columnSelectionBlending:ne="exclusive",rowSelectionBlending:oe="exclusive",onDelete:q,onDragStart:ve,onMouseMove:pe,onPaste:se,copyHeaders:ke=!1,freezeColumns:Ne=0,cellActivationBehavior:De="second-click",rowSelectionMode:Lt="auto",onHeaderMenuClick:tt,getGroupDetails:ze,onSearchClose:rt,onItemHovered:Tt,onSelectionCleared:Jt,showSearch:Yn,onVisibleRegionChanged:xr,gridSelection:Kt,onGridSelectionChange:Qn,minColumnWidth:Jn=50,maxColumnWidth:ls=500,maxColumnAutoWidth:as,provideEditor:$t,trailingRowOptions:ct,freezeTrailingRows:mt=0,allowedFillDirections:An="orthogonal",scrollOffsetX:Rn,scrollOffsetY:nn,verticalBorder:Tn,onDragOverCell:si,onDrop:pt,onColumnResize:Xt,onColumnResizeEnd:Pt,onColumnResizeStart:It,customRenderers:On,fillHandle:Ht,drawFocusRing:wn=!0,experimental:Gt,fixedShadowX:qc,fixedShadowY:Ds,headerIcons:us,imageWindowLoader:cs,initialSize:ml,isDraggable:Yc,onDragLeave:Qc,onRowMoved:Ii,overscrollX:yl,overscrollY:vl,preventDiagonalScrolling:wl,rightElement:Oo,rightElementProps:_s,trapFocus:Jc=!1,smoothScrollX:Zc,smoothScrollY:Op,scaleToRem:Pp=!1,rowHeight:xl=34,headerHeight:fs=36,groupHeaderHeight:Ip=fs,theme:Dp,isOutsideClick:ef,renderers:bl}=t,mn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,zr=(mn==null?void 0:mn.kind)??t.rowMarkers??"none",tf=(mn==null?void 0:mn.width)??t.rowMarkerWidth,kl=(mn==null?void 0:mn.startIndex)??t.rowMarkerStartIndex??1,Xa=(mn==null?void 0:mn.theme)??t.rowMarkerTheme,Ns=(mn==null?void 0:mn.checkboxStyle)??"square",br=Math.max(Jn,20),oi=Math.max(ls,br),Ga=Math.max(as??oi,br),Ls=w.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),qa=w.useMemo(()=>Number.parseFloat(Ls.fontSize),[Ls]),{rowHeight:Zn,headerHeight:Sl,groupHeaderHeight:Ya,theme:nf,overscrollX:_p,overscrollY:rf}=kW({groupHeaderHeight:Ip,headerHeight:fs,overscrollX:yl,overscrollY:vl,remSize:qa,rowHeight:xl,scaleToRem:Pp,theme:Dp}),li=SW(qe),hs=tf??(y>1e4?48:y>1e3?44:y>100?36:32),kr=zr!=="none",K=kr?1:0,qt=Qe!==void 0,Po=(ct==null?void 0:ct.sticky)===!0,[Np,sf]=w.useState(!1),Qa=Yn??Np,Lp=w.useCallback(()=>{rt!==void 0?rt():sf(!1)},[rt]),J=w.useMemo(()=>Kt===void 0?void 0:Wf(Kt,K),[Kt,K])??n,Bn=w.useRef();Bn.current===void 0&&(Bn.current=new AbortController),w.useEffect(()=>()=>Bn==null?void 0:Bn.current.abort(),[]);const[yn,Cl]=oW(G,k,K,Bn.current,y),Ja=w.useCallback((S,L,N)=>{if(Ze===void 0)return!0;const W=[S[0]-K,S[1]];return Ze==null?void 0:Ze(W,L,N)},[K,Ze]),Fs=w.useRef(Kt),ur=w.useCallback((S,L)=>{L&&(S=dW(S,yn,K,Y,Bn.current)),Qn!==void 0?(Fs.current=Wf(S,-K),Qn(Fs.current)):r(S)},[Qn,yn,K,Y]),ai=_l(Xt,w.useCallback((S,L,N,W)=>{Xt==null||Xt(g[N-K],L,N-K,W)},[Xt,K,g])),Fp=_l(Pt,w.useCallback((S,L,N,W)=>{Pt==null||Pt(g[N-K],L,N-K,W)},[Pt,K,g])),Tl=_l(It,w.useCallback((S,L,N,W)=>{It==null||It(g[N-K],L,N-K,W)},[It,K,g])),Bp=_l(P,w.useCallback((S,L)=>(P==null?void 0:P({...S,columnIndex:S.columnIndex-K},L))??!1,[P,K])),zp=_l(D,w.useCallback((S,L)=>(D==null?void 0:D({...S,col:S.col-K},L))??!1,[D,K])),$=w.useCallback(S=>{if(q!==void 0){const L=q(Wf(S,-K));return typeof L=="boolean"?L:Wf(L,K)}return!0},[q,K]),[ie,xe,me]=sW(J,ur,ce,ne,oe,Ie),fe=w.useMemo(()=>mo(MT(),nf),[nf]),[Ae,Xe]=w.useState([0,0,0]),Ge=w.useMemo(()=>{if(bl===void 0)return{};const S={};for(const L of bl)S[L.kind]=L;return S},[bl]),Ee=w.useCallback(S=>S.kind!==Se.Custom?Ge[S.kind]:On==null?void 0:On.find(L=>L.isMatch(S)),[On,Ge]);let{sizedColumns:kt,nonGrowWidth:Le}=M4(g,y,Cl,Ae[0]-(K===0?0:hs)-Ae[2],br,Ga,fe,Ee,Bn.current);zr!=="none"&&(Le+=hs);const Ct=w.useMemo(()=>kt.some(S=>S.group!==void 0),[kt]),nt=Ct?Sl+Ya:Sl,ft=J.rows.length,un=zr==="none"?void 0:ft===0?!1:ft===y?!0:void 0,it=w.useMemo(()=>zr==="none"?kt:[{title:"",width:hs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Xa,rowMarker:Ns,rowMarkerChecked:un},...kt],[zr,kt,hs,Xa,Ns,un]),[rn,$r]=w.useMemo(()=>[nn!==void 0&&typeof Zn=="number"?Math.floor(nn/Zn):0,nn!==void 0&&typeof Zn=="number"?-(nn%Zn):0],[nn,Zn]),Yt=w.useRef({height:1,width:1,x:0,y:0}),Sr=w.useMemo(()=>({x:Yt.current.x,y:rn,width:Yt.current.width??1,height:Yt.current.height??1,ty:$r}),[$r,rn]),vt=w.useRef(!1),[cn,Cr,Di]=PF(Sr);Yt.current=cn;const ui=(cn.height??1)>1;w.useLayoutEffect(()=>{if(nn!==void 0&&c.current!==null&&ui){if(c.current.scrollTop===nn)return;c.current.scrollTop=nn,c.current.scrollTop!==nn&&Di(),vt.current=!0}},[nn,ui,Di]);const El=(cn.width??1)>1;w.useLayoutEffect(()=>{if(Rn!==void 0&&c.current!==null&&El){if(c.current.scrollLeft===Rn)return;c.current.scrollLeft=Rn,c.current.scrollLeft!==Rn&&Di(),vt.current=!0}},[Rn,El,Di]);const Io=cn.x+K,of=cn.y,cr=w.useRef(null),er=w.useCallback(S=>{var L;S===!0?(L=cr.current)==null||L.focus():window.requestAnimationFrame(()=>{var N;(N=cr.current)==null||N.focus()})},[]),zn=qt?y+1:y,Hr=w.useCallback(S=>{const L=K===0?S:S.map(W=>({...W,location:[W.location[0]-K,W.location[1]]})),N=j==null?void 0:j(L);if(N!==!0)for(const W of L)z==null||z(W.location,W.value);return N},[z,j,K]),[Do,$p]=w.useState(),lf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,Ml=wn?(Ow=J.current)==null?void 0:Ow.cell:void 0,af=Ml==null?void 0:Ml[0],uf=Ml==null?void 0:Ml[1],EA=w.useMemo(()=>{if((Ot===void 0||Ot.length===0)&&(lf??af??uf??Do)===void 0)return;const S=[];if(Ot!==void 0)for(const L of Ot){const N=it.length-L.range.x-K;N>0&&S.push({color:L.color,range:{...L.range,x:L.range.x+K,width:Math.min(N,L.range.width)},style:L.style})}return Do!==void 0&&S.push({color:sl(fe.accentColor,0),range:Do,style:"dashed"}),lf!==void 0&&S.push({color:sl(fe.accentColor,.5),range:lf,style:"solid-outline"}),af!==void 0&&uf!==void 0&&S.push({color:fe.accentColor,range:{x:af,y:uf,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Do,lf,af,uf,Ot,it.length,fe.accentColor,K]),yw=w.useRef(it);yw.current=it;const Tr=w.useCallback(([S,L],N=!1)=>{var ee,X,Z,le,re,Ce,Re;const W=qt&&L===zn-1;if(S===0&&kr)return W?Hg:{kind:Gr.Marker,allowOverlay:!1,checkboxStyle:Ns,checked:(J==null?void 0:J.rows.hasIndex(L))===!0,markerKind:zr==="clickable-number"?"number":zr,row:kl+L,drawHandle:Ii!==void 0,cursor:zr==="clickable-number"?"pointer":void 0};if(W){const $e=S===K?(ct==null?void 0:ct.hint)??"":"",We=yw.current[S];if(((ee=We==null?void 0:We.trailingRowOptions)==null?void 0:ee.disabled)===!0)return Hg;{const yt=((X=We==null?void 0:We.trailingRowOptions)==null?void 0:X.hint)??$e,Ue=((Z=We==null?void 0:We.trailingRowOptions)==null?void 0:Z.addIcon)??(ct==null?void 0:ct.addIcon);return{kind:Gr.NewRow,hint:yt,allowOverlay:!1,icon:Ue}}}else{const be=S-K;if(N||(Gt==null?void 0:Gt.strict)===!0){const We=Yt.current,yt=We.x>be||be>We.x+We.width||We.y>L||L>We.y+We.height||L>=jp.current,Ue=be===((re=(le=We.extras)==null?void 0:le.selected)==null?void 0:re[0])&&L===((Ce=We.extras)==null?void 0:Ce.selected[1]);let Be=!1;if(((Re=We.extras)==null?void 0:Re.freezeRegions)!==void 0){for(const Ft of We.extras.freezeRegions)if(gp(Ft,be,L)){Be=!0;break}}if(yt&&!Ue&&!Be)return Hg}let $e=k([be,L]);return K!==0&&$e.span!==void 0&&($e={...$e,span:[$e.span[0]+K,$e.span[1]+K]}),$e}},[qt,zn,kr,Ns,J==null?void 0:J.rows,zr,kl,Ii,K,ct==null?void 0:ct.hint,ct==null?void 0:ct.addIcon,Gt==null?void 0:Gt.strict,k]),Hp=w.useCallback(S=>{let L=(ze==null?void 0:ze(S))??{name:S};return F!==void 0&&S!==""&&(L={icon:L.icon,name:L.name,overrideTheme:L.overrideTheme,actions:[...L.actions??[],{title:"Rename",icon:"renameIcon",onClick:N=>Vp({group:L.name,bounds:N.bounds})}]}),L},[ze,F]),cf=w.useCallback(S=>{var Z;const[L,N]=S.cell,W=it[L],V=(W==null?void 0:W.group)!==void 0?(Z=Hp(W.group))==null?void 0:Z.overrideTheme:void 0,ee=W==null?void 0:W.themeOverride,X=p==null?void 0:p(N);s({...S,theme:mo(fe,V,ee,X,S.content.themeOverride)})},[p,it,Hp,fe]),Al=w.useCallback((S,L,N)=>{var X;if(J.current===void 0)return;const[W,V]=J.current.cell,ee=Tr([W,V]);if(ee.kind!==Se.Boolean&&ee.allowOverlay){let Z=ee;if(N!==void 0)switch(Z.kind){case Se.Number:{const le=hD(()=>N==="-"?-0:Number.parseFloat(N),0);Z={...Z,data:Number.isNaN(le)?0:le};break}case Se.Text:case Se.Markdown:case Se.Uri:Z={...Z,data:N};break}cf({target:S,content:Z,initialValue:N,cell:[W,V],highlight:N===void 0,forceEditMode:N!==void 0})}else ee.kind===Se.Boolean&&L&&ee.readonly!==!0&&(Hr([{location:J.current.cell,value:{...ee,data:nE(ee.data)}}]),(X=cr.current)==null||X.damage([{cell:J.current.cell}]))},[Tr,J,Hr,cf]),vw=w.useCallback((S,L)=>{var V;const N=(V=cr.current)==null?void 0:V.getBounds(S,L);if(N===void 0||c.current===null)return;const W=Tr([S,L]);W.allowOverlay&&cf({target:N,content:W,initialValue:void 0,highlight:!0,cell:[S,L],forceEditMode:!0})},[Tr,cf]),fn=w.useCallback((S,L,N="both",W=0,V=0,ee=void 0)=>{if(c.current!==null){const X=cr.current,Z=l.current,le=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,re=typeof L!="number"?L.unit==="cell"?L.amount:void 0:L,Ce=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Re=typeof L!="number"&&L.unit==="px"?L.amount:void 0;if(X!==null&&Z!==null){let be={x:0,y:0,width:0,height:0},$e=0,We=0;if((le!==void 0||re!==void 0)&&(be=X.getBounds((le??0)+K,re??0)??be,be.width===0||be.height===0))return;const yt=Z.getBoundingClientRect(),Ue=yt.width/Z.offsetWidth;if(Ce!==void 0&&(be={...be,x:Ce-yt.left-c.current.scrollLeft,width:1}),Re!==void 0&&(be={...be,y:Re+yt.top-c.current.scrollTop,height:1}),be!==void 0){const Be={x:be.x-W,y:be.y-V,width:be.width+2*W,height:be.height+2*V};let Ft=0;for(let Yp=0;Yp0&&($n=gl(zn,hn,Zn));let fi=Ft*Ue+yt.left+K*hs*Ue,Ni=yt.right,hi=yt.top+nt*Ue,Li=yt.bottom-$n*Ue;const mf=be.width+W*2;switch(ee==null?void 0:ee.hAlign){case"start":Ni=fi+mf;break;case"end":fi=Ni-mf;break;case"center":fi=Math.floor((fi+Ni)/2)-mf/2,Ni=fi+mf;break}const yf=be.height+V*2;switch(ee==null?void 0:ee.vAlign){case"start":Li=hi+yf;break;case"end":hi=Li-yf;break;case"center":hi=Math.floor((hi+Li)/2)-yf/2,Li=hi+yf;break}fi>Be.x?$e=Be.x-fi:NiBe.y?We=Be.y-hi:Li=zn-hn)&&(We=0),($e!==0||We!==0)&&(Ue!==1&&($e/=Ue,We/=Ue),c.current.scrollTo($e+c.current.scrollLeft,We+c.current.scrollTop))}}}},[K,mt,hs,nt,Ne,kt,zn,Po,Zn]),ww=w.useRef(vw),xw=w.useRef(k),jp=w.useRef(y);ww.current=vw,xw.current=k,jp.current=y;const Rl=w.useCallback(async(S,L=!0)=>{var le;const N=it[S];if(((le=N==null?void 0:N.trailingRowOptions)==null?void 0:le.disabled)===!0)return;const W=Qe==null?void 0:Qe();let V,ee=!0;W!==void 0&&(V=await W,V==="top"&&(ee=!1),typeof V=="number"&&(ee=!1));let X=0;const Z=()=>{if(jp.current<=y){X<500&&window.setTimeout(Z,X),X=50+X*2;return}const re=typeof V=="number"?V:ee?y:0;gf.current(S-K,re),ie({cell:[S,re],range:{x:S,y:re,width:1,height:1}},!1,!1,"edit");const Ce=xw.current([S-K,re]);Ce.allowOverlay&&Ru(Ce)&&Ce.readonly!==!0&&L&&window.setTimeout(()=>{ww.current(S,re)},0)};Z()},[it,Qe,K,y,ie]),ff=w.useCallback(S=>{var N,W;const L=((W=(N=kt[S])==null?void 0:N.trailingRowOptions)==null?void 0:W.targetColumn)??(ct==null?void 0:ct.targetColumn);if(typeof L=="number")return L+(kr?1:0);if(typeof L=="object"){const V=g.indexOf(L);if(V>=0)return V+(kr?1:0)}},[kt,g,kr,ct==null?void 0:ct.targetColumn]),Bs=w.useRef(),Ol=w.useRef(),Za=w.useCallback((S,L)=>{var V;const[N,W]=L;return mo(fe,(V=it[N])==null?void 0:V.themeOverride,p==null?void 0:p(W),S.themeOverride)},[p,it,fe]),eu=w.useCallback(S=>{var Ce,Re,be;const L=md.value?S.metaKey:S.ctrlKey,N=L&&Q==="multi",W=L&&Te==="multi",[V,ee]=S.location,X=J.columns,Z=J.rows,[le,re]=((Ce=J.current)==null?void 0:Ce.cell)??[];if(S.kind==="cell"){if(Ol.current=void 0,_o.current=[V,ee],V===0&&kr){if(qt===!0&&ee===y||zr==="number"||Q==="none")return;const $e=Tr(S.location);if($e.kind!==Gr.Marker)return;if(Ii!==void 0){const Ue=Ee($e);Or((Ue==null?void 0:Ue.kind)===Gr.Marker);const Be=(Re=Ue==null?void 0:Ue.onClick)==null?void 0:Re.call(Ue,{...S,cell:$e,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:Za($e,S.location),preventDefault:()=>{}});if(Be===void 0||Be.checked===$e.checked)return}s(void 0),er();const We=Z.hasIndex(ee),yt=Bs.current;if(Q==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&yt!==void 0&&Z.hasIndex(yt)){const Ue=[Math.min(yt,ee),Math.max(yt,ee)+1];N||Lt==="multi"?xe(void 0,Ue,!0):xe(wt.fromSingleSelection(Ue),void 0,N)}else N||S.isTouch||Lt==="multi"?We?xe(Z.remove(ee),void 0,!0):(xe(void 0,ee,!0),Bs.current=ee):We&&Z.length===1?xe(wt.empty(),void 0,L):(xe(wt.fromSingleSelection(ee),void 0,L),Bs.current=ee)}else if(V>=K&&qt&&ee===y){const $e=ff(V);Rl($e??V)}else if(le!==V||re!==ee){const $e=Tr(S.location),We=Ee($e);if((We==null?void 0:We.onSelect)!==void 0){let Be=!1;if(We.onSelect({...S,cell:$e,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>Be=!0,theme:Za($e,S.location)}),Be)return}const yt=Po&&ee===y,Ue=Po&&J!==void 0&&((be=J.current)==null?void 0:be.cell[1])===y;if((S.shiftKey||S.isLongTouch===!0)&&le!==void 0&&re!==void 0&&J.current!==void 0&&!Ue){if(yt)return;const Be=Math.min(V,le),Ft=Math.max(V,le),$n=Math.min(ee,re),hn=Math.max(ee,re);ie({...J.current,range:{x:Be,y:$n,width:Ft-Be+1,height:hn-$n+1}},!0,L,"click"),Bs.current=void 0,er()}else ie({cell:[V,ee],range:{x:V,y:ee,width:1,height:1}},!0,L,"click"),Bs.current=void 0,s(void 0),er()}}else if(S.kind==="header")if(_o.current=[V,ee],s(void 0),kr&&V===0)Bs.current=void 0,Ol.current=void 0,Q==="multi"&&(Z.length!==y?xe(wt.fromSingleSelection([0,y]),void 0,L):xe(wt.empty(),void 0,L),er());else{const $e=Ol.current;if(Te==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&$e!==void 0&&X.hasIndex($e)){const We=[Math.min($e,V),Math.max($e,V)+1];W?me(void 0,We,L):me(wt.fromSingleSelection(We),void 0,L)}else W?(X.hasIndex(V)?me(X.remove(V),void 0,L):me(void 0,V,L),Ol.current=V):Te!=="none"&&(me(wt.fromSingleSelection(V),void 0,L),Ol.current=V);Bs.current=void 0,er()}else S.kind===Rr?_o.current=[V,ee]:S.kind===yd&&!S.isMaybeScrollbar&&(ur(Vf,!1),s(void 0),er(),Jt==null||Jt(),Bs.current=void 0,Ol.current=void 0)},[Rl,Te,er,Ee,ff,Tr,J,kr,Po,Jt,Ii,K,zr,Q,Lt,y,ie,ur,me,xe,qt,Za]),tu=w.useRef(!1),_o=w.useRef(),bw=w.useRef(cn),jr=w.useRef(),MA=w.useCallback(S=>{if(Pl.current=!1,bw.current=Yt.current,S.button!==0&&S.button!==1){jr.current=void 0;return}const L=performance.now();jr.current={button:S.button,time:L,location:S.location},(S==null?void 0:S.kind)==="header"&&(tu.current=!0);const N=S.kind==="cell"&&S.isFillHandle;!N&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:J,fillHandle:N}),_o.current=void 0,!S.isTouch&&S.button===0&&!N?eu(S):!S.isTouch&&S.button===1&&(_o.current=S.location))},[J,eu]),[Wp,Vp]=w.useState(),kw=w.useCallback(S=>{if(S.kind!==Rr||Te!=="multi")return;const L=md.value?S.metaKey:S.ctrlKey,[N]=S.location,W=J.columns;if(N=K&&xc(V.group,it[Z].group);Z--)ee--;for(let Z=N+1;Z{if(yn!==void 0&&ai!==void 0){const L=Yt.current.y,N=Yt.current.height;let W=yn({x:S,y:L,width:1,height:Math.min(N,y-L)},Bn.current.signal);typeof W!="object"&&(W=await W());const V=kt[S-K],X=document.createElement("canvas").getContext("2d",{alpha:!1});if(X!==null){X.font=fe.baseFontFull;const Z=AT(X,fe,V,0,W,br,oi,!1,Ee);ai==null||ai(V,Z.width,S,Z.width)}}},[kt,yn,oi,fe,br,ai,K,y,Ee]),[AA,Up]=w.useState(),Il=w.useCallback(async(S,L)=>{var Z,le;const N=(Z=S.current)==null?void 0:Z.range;if(N===void 0||yn===void 0||L.current===void 0)return;const W=L.current.range;if(T!==void 0){let re=!1;if(T({fillDestination:{...W,x:W.x-K},patternSource:{...N,x:N.x-K},preventDefault:()=>re=!0}),re)return}let V=yn(N,Bn.current.signal);typeof V!="object"&&(V=await V());const ee=V,X=[];for(let re=0;re({cell:re.location})))},[yn,Hr,T,K]),Sw=w.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,width:1}}};Il(S,J)},[Il,J]),Cw=w.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,height:1}}};Il(S,J)},[Il,J]),RA=w.useCallback((S,L)=>{var Ce,Re;const N=a;if(u(void 0),$p(void 0),Up(void 0),tu.current=!1,L)return;if((N==null?void 0:N.fillHandle)===!0&&J.current!==void 0&&((Ce=N.previousSelection)==null?void 0:Ce.current)!==void 0){if(Do===void 0)return;const be={...J,current:{...J.current,range:BT(N.previousSelection.current.range,Do)}};Il(N.previousSelection,be),ur(be,!0);return}const[W,V]=S.location,[ee,X]=_o.current??[],Z=()=>{Pl.current=!0},le=be=>{var We,yt,Ue;const $e=be.isTouch||ee===W&&X===V;if($e&&(b==null||b([W-K,V],{...be,preventDefault:Z})),be.button===1)return!Pl.current;if(!Pl.current){const Be=Tr(S.location),Ft=Ee(Be);if(Ft!==void 0&&Ft.onClick!==void 0&&$e){const hn=Ft.onClick({...be,cell:Be,posX:be.localEventX,posY:be.localEventY,bounds:be.bounds,theme:Za(Be,S.location),preventDefault:Z});hn!==void 0&&!Jl(hn)&&Fl(hn)&&(Hr([{location:be.location,value:hn}]),(We=cr.current)==null||We.damage([{cell:be.location}]))}if(Pl.current||J.current===void 0)return!1;let $n=!1;switch(Be.activationBehaviorOverride??De){case"double-click":case"second-click":{if(((Ue=(yt=N==null?void 0:N.previousSelection)==null?void 0:yt.current)==null?void 0:Ue.cell)===void 0)break;const[hn,fi]=J.current.cell,[Ni,hi]=N.previousSelection.current.cell;$n=W===hn&&W===Ni&&V===fi&&V===hi&&(be.isDoubleClick===!0||De==="second-click");break}case"single-click":{$n=!0;break}}if($n)return C==null||C([W-K,V]),Al(be.bounds,!1),!0}return!1},re=S.location[0]-K;if(S.isTouch){const be=Yt.current,$e=bw.current;if(be.x!==$e.x||be.y!==$e.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&Ku((Re=J.current)==null?void 0:Re.cell,S.location)){ae==null||ae([re,S.location[1]],{...S,preventDefault:Z});return}else if(S.kind==="header"&&J.columns.hasIndex(W)){te==null||te(re,{...S,preventDefault:Z});return}else if(S.kind===Rr){if(re<0)return;M==null||M(re,{...S,preventDefault:Z});return}}S.kind==="cell"?le(S)||eu(S):S.kind===Rr?U==null||U(re,{...S,preventDefault:Z}):(S.kind===Xs&&(_==null||_(re,{...S,preventDefault:Z})),eu(S));return}if(S.kind==="header"){if(re<0)return;S.isEdge?S.isDoubleClick===!0&&hf(W):S.button===0&&W===ee&&V===X&&(_==null||_(re,{...S,preventDefault:Z}))}if(S.kind===Rr){if(re<0)return;S.button===0&&W===ee&&V===X&&(U==null||U(re,{...S,preventDefault:Z}),Pl.current||kw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&le(S),_o.current=void 0},[a,J,K,Do,Il,ur,b,Tr,Ee,De,Za,Hr,C,Al,ae,te,M,eu,U,_,hf,kw]),OA=w.useCallback(S=>{const L={...S,location:[S.location[0]-K,S.location[1]]};pe==null||pe(L),a!==void 0&&S.buttons===0&&(u(void 0),$p(void 0),Up(void 0),tu.current=!1),Up(N=>{var W;return tu.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===(N==null?void 0:N[0])&&S.scrollEdge[1]===N[1]?N:a===void 0||(((W=jr.current)==null?void 0:W.location[0])??0){tt==null||tt(S-K,L)},[tt,K]),_i=(Pw=J==null?void 0:J.current)==null?void 0:Pw.cell,IA=w.useCallback((S,L,N,W,V,ee)=>{vt.current=!1;let X=_i;X!==void 0&&(X=[X[0]-K,X[1]]);const Z=Ne===0?void 0:{x:0,y:S.y,width:Ne,height:S.height},le=[];Z!==void 0&&le.push(Z),mt>0&&(le.push({x:S.x-K,y:y-mt,width:S.width,height:mt}),Ne>0&&le.push({x:0,y:y-mt,width:Ne,height:mt}));const re={x:S.x-K,y:S.y,width:S.width,height:qt&&S.y+S.height>=y?S.height-1:S.height,tx:V,ty:ee,extras:{selected:X,freezeRegion:Z,freezeRegions:le}};Yt.current=re,Cr(re),Xe([L,N,W]),xr==null||xr(re,re.tx,re.ty,re.extras)},[_i,K,qt,y,Ne,mt,Cr,xr]),DA=_l(et,w.useCallback((S,L)=>{et==null||et(S-K,L-K),Te!=="none"&&me(wt.fromSingleSelection(L),void 0,!0)},[Te,et,K,me])),Kp=w.useRef(!1),_A=w.useCallback(S=>{if(S.location[0]===0&&K>0){S.preventDefault();return}ve==null||ve({...S,location:[S.location[0]-K,S.location[1]]}),S.defaultPrevented()||(Kp.current=!0),u(void 0)},[ve,K]),NA=w.useCallback(()=>{Kp.current=!1},[]),Xp=w.useRef(),Gp=w.useCallback(S=>{var L,N,W;if(!eE(S,Xp.current)&&(Xp.current=S,!(((L=jr==null?void 0:jr.current)==null?void 0:L.button)!==void 0&&jr.current.button>=1))){if(S.buttons!==0&&a!==void 0&&((N=jr.current)==null?void 0:N.location[0])===0&&S.location[0]===0&&K===1&&Q==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(jr.current.location[1])&&J.rows.hasIndex(jr.current.location[1])){const V=Math.min(jr.current.location[1],S.location[1]),ee=Math.max(jr.current.location[1],S.location[1])+1;xe(wt.fromSingleSelection([V,ee]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&J.current!==void 0&&!Kp.current&&!tu.current&&(Ie==="rect"||Ie==="multi-rect")){const[V,ee]=J.current.cell;let[X,Z]=S.location;if(Z<0&&(Z=Yt.current.y),a.fillHandle===!0&&((W=a.previousSelection)==null?void 0:W.current)!==void 0){const le=a.previousSelection.current.range;Z=Math.min(Z,qt?y-1:y);const re=dz(le,X,Z,An);$p(re)}else{if(qt&&ee===y)return;if(qt&&Z===y)if(S.kind===yd)Z--;else return;X=Math.max(X,K);const Ce=X-V,Re=Z-ee,be={x:Ce>=0?V:X,y:Re>=0?ee:Z,width:Math.abs(Ce)+1,height:Math.abs(Re)+1};ie({...J.current,range:be},!0,!1,"drag")}}Tt==null||Tt({...S,location:[S.location[0]-K,S.location[1]]})}},[An,a,K,Q,J,Ie,Tt,xe,qt,y,ie]),LA=w.useCallback(()=>{var X,Z;const S=Xp.current;if(S===void 0)return;const[L,N]=S.scrollEdge;let[W,V]=S.location;const ee=Yt.current;L===-1?W=((Z=(X=ee.extras)==null?void 0:X.freezeRegion)==null?void 0:Z.x)??ee.x:L===1&&(W=ee.x+ee.width),N===-1?V=Math.max(0,ee.y):N===1&&(V=Math.min(y-1,ee.y+ee.height)),W=wi(W,0,it.length-1),V=wi(V,0,y-1),Gp({...S,location:[W,V]})},[it.length,Gp,y]);bW(AA,c,LA);const ci=w.useCallback(S=>{if(J.current===void 0)return;const[L,N]=S,[W,V]=J.current.cell,ee=J.current.range;let X=ee.x,Z=ee.x+ee.width,le=ee.y,re=ee.y+ee.height;if(N!==0)switch(N){case 2:{re=y,le=V,fn(0,re,"vertical");break}case-2:{le=0,re=V+1,fn(0,le,"vertical");break}case 1:{leV+1?(re--,fn(0,re,"vertical")):(le=Math.max(0,le-1),fn(0,le,"vertical"));break}default:wc()}if(L!==0)if(L===2)Z=it.length,X=W,fn(Z-1-K,0,"horizontal");else if(L===-2)X=K,Z=W+1,fn(X-K,0,"horizontal");else{let Ce=[];if(yn!==void 0){const Re=yn({x:X,y:le,width:Z-X-K,height:re-le},Bn.current.signal);typeof Re=="object"&&(Ce=EW(Re))}if(L===1){let Re=!1;if(X0){const be=Vo(X+1,W+1).find($e=>!Ce.includes($e-K));be!==void 0&&(X=be,Re=!0)}else X++,Re=!0;Re&&fn(X,0,"horizontal")}Re||(Z=Math.min(it.length,Z+1),fn(Z-1-K,0,"horizontal"))}else if(L===-1){let Re=!1;if(Z>W+1){if(Ce.length>0){const be=Vo(Z-1,W,-1).find($e=>!Ce.includes($e-K));be!==void 0&&(Z=be,Re=!0)}else Z--,Re=!0;Re&&fn(Z-K,0,"horizontal")}Re||(X=Math.max(K,X-1),fn(X-K,0,"horizontal"))}else wc()}ie({cell:J.current.cell,range:{x:X,y:le,width:Z-X,height:re-le}},!0,!1,"keyboard-select")},[yn,J,it.length,K,y,fn,ie]),zs=w.useCallback((S,L,N,W)=>{const V=zn-(N?0:1);if(S=wi(S,K,kt.length-1+K),L=wi(L,0,V),S===(_i==null?void 0:_i[0])&&L===(_i==null?void 0:_i[1]))return!1;if(W&&J.current!==void 0){const ee=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&ee.push(J.current.range),ur({...J,current:{cell:[S,L],range:{x:S,y:L,width:1,height:1},rangeStack:ee}},!0)}else ie({cell:[S,L],range:{x:S,y:L,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===L&&(f.current=void 0),fn(S-K,L),!0},[zn,K,kt.length,_i,J,fn,ur,ie]),FA=w.useCallback((S,L)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&Fl(S)&&(Hr([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var V;(V=cr.current)==null||V.damage([{cell:i.cell}])})),er(!0),s(void 0);const[N,W]=L;if(J.current!==void 0&&(N!==0||W!==0)){const V=J.current.cell[1]===zn-1&&S!==void 0;zs(wi(J.current.cell[0]+N,0,it.length-1),wi(J.current.cell[1]+W,0,zn-1),V,!1)}E==null||E(S,L)},[i==null?void 0:i.cell,er,J,E,Hr,zn,zs,it.length]),BA=w.useMemo(()=>`gdg-overlay-${TW++}`,[]),No=w.useCallback(S=>{var N,W,V,ee;er();const L=[];for(let X=S.x;X({cell:X.location})))},[er,k,Ee,Hr,K]),nu=i!==void 0,Tw=w.useCallback(S=>{var $e,We;const L=()=>{S.stopPropagation(),S.preventDefault()},N={didMatch:!1},{bounds:W}=S,V=J.columns,ee=J.rows,X=li;if(!nu&&ot(X.clear,S,N))ur(Vf,!1),Jt==null||Jt();else if(!nu&&ot(X.selectAll,S,N))ur({columns:wt.empty(),rows:wt.empty(),current:{cell:(($e=J.current)==null?void 0:$e.cell)??[K,0],range:{x:K,y:0,width:g.length,height:y},rangeStack:[]}},!1);else if(ot(X.search,S,N))(We=o==null?void 0:o.current)==null||We.focus({preventScroll:!0}),sf(!0);else if(ot(X.delete,S,N)){const yt=($==null?void 0:$(J))??!0;if(yt!==!1){const Ue=yt===!0?J:yt;if(Ue.current!==void 0){No(Ue.current.range);for(const Be of Ue.current.rangeStack)No(Be)}for(const Be of Ue.rows)No({x:K,y:Be,width:g.length,height:1});for(const Be of Ue.columns)No({x:Be,y:0,width:1,height:y})}}if(N.didMatch)return L(),!0;if(J.current===void 0)return!1;let[Z,le]=J.current.cell,re=!1,Ce=!1;ot(X.scrollToSelectedCell,S,N)?gf.current(Z-K,le):Te!=="none"&&ot(X.selectColumn,S,N)?V.hasIndex(Z)?me(V.remove(Z),void 0,!0):Te==="single"?me(wt.fromSingleSelection(Z),void 0,!0):me(void 0,Z,!0):Q!=="none"&&ot(X.selectRow,S,N)?ee.hasIndex(le)?xe(ee.remove(le),void 0,!0):Q==="single"?xe(wt.fromSingleSelection(le),void 0,!0):xe(void 0,le,!0):!nu&&W!==void 0&&ot(X.activateCell,S,N)?le===y&&qt?window.setTimeout(()=>{const yt=ff(Z);Rl(yt??Z)},0):(C==null||C([Z-K,le]),Al(W,!0)):J.current.range.height>1&&ot(X.downFill,S,N)?Cw():J.current.range.width>1&&ot(X.rightFill,S,N)?Sw():ot(X.goToNextPage,S,N)?le+=Math.max(1,Yt.current.height-4):ot(X.goToPreviousPage,S,N)?le-=Math.max(1,Yt.current.height-4):ot(X.goToFirstCell,S,N)?(s(void 0),le=0,Z=0):ot(X.goToLastCell,S,N)?(s(void 0),le=Number.MAX_SAFE_INTEGER,Z=Number.MAX_SAFE_INTEGER):ot(X.selectToFirstCell,S,N)?(s(void 0),ci([-2,-2])):ot(X.selectToLastCell,S,N)?(s(void 0),ci([2,2])):nu?(ot(X.closeOverlay,S,N)&&s(void 0),ot(X.acceptOverlayDown,S,N)&&(s(void 0),le++),ot(X.acceptOverlayUp,S,N)&&(s(void 0),le--),ot(X.acceptOverlayLeft,S,N)&&(s(void 0),Z--),ot(X.acceptOverlayRight,S,N)&&(s(void 0),Z++)):(ot(X.goDownCell,S,N)?le+=1:ot(X.goUpCell,S,N)?le-=1:ot(X.goRightCell,S,N)?Z+=1:ot(X.goLeftCell,S,N)?Z-=1:ot(X.goDownCellRetainSelection,S,N)?(le+=1,re=!0):ot(X.goUpCellRetainSelection,S,N)?(le-=1,re=!0):ot(X.goRightCellRetainSelection,S,N)?(Z+=1,re=!0):ot(X.goLeftCellRetainSelection,S,N)?(Z-=1,re=!0):ot(X.goToLastRow,S,N)?le=y-1:ot(X.goToFirstRow,S,N)?le=Number.MIN_SAFE_INTEGER:ot(X.goToLastColumn,S,N)?Z=Number.MAX_SAFE_INTEGER:ot(X.goToFirstColumn,S,N)?Z=Number.MIN_SAFE_INTEGER:(Ie==="rect"||Ie==="multi-rect")&&(ot(X.selectGrowDown,S,N)?ci([0,1]):ot(X.selectGrowUp,S,N)?ci([0,-1]):ot(X.selectGrowRight,S,N)?ci([1,0]):ot(X.selectGrowLeft,S,N)?ci([-1,0]):ot(X.selectToLastRow,S,N)?ci([0,2]):ot(X.selectToFirstRow,S,N)?ci([0,-2]):ot(X.selectToLastColumn,S,N)?ci([2,0]):ot(X.selectToFirstColumn,S,N)&&ci([-2,0])),Ce=N.didMatch);const Re=zs(Z,le,!1,re),be=N.didMatch;return be&&(Re||!Ce||Jc)&&L(),be},[nu,J,li,Te,Q,Ie,K,y,zs,ur,Jt,g.length,$,Jc,No,me,xe,qt,ff,Rl,C,Al,Cw,Sw,ci]),ru=w.useCallback(S=>{let L=!1;if(_e!==void 0&&_e({...S,cancel:()=>{L=!0}}),L||Tw(S)||J.current===void 0)return;const[N,W]=J.current.cell,V=Yt.current;if(Ye&&!S.metaKey&&!S.ctrlKey&&J.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Ru(k([N-K,Math.max(0,Math.min(W,y-1))]))){if((!qt||W!==y)&&(V.y>W||W>V.y+V.height||V.x>N||N>V.x+V.width))return;Al(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[Ye,_e,Tw,J,k,K,y,qt,Al]),zA=w.useCallback((S,L)=>{const N=S.location[0]-K;if(S.kind==="header"&&(te==null||te(N,{...S,preventDefault:L})),S.kind===Rr){if(N<0)return;M==null||M(N,{...S,preventDefault:L})}if(S.kind==="cell"){const[W,V]=S.location;ae==null||ae([N,V],{...S,preventDefault:L}),u4(J,S.location)||zs(W,V,!1,!1)}},[J,ae,M,te,K,zs]),qp=w.useCallback(async S=>{var X,Z,le;if(!li.paste)return;function L(re,Ce,Re,be){var We,yt;const $e=typeof Re=="object"?(Re==null?void 0:Re.join(` -`))??"":(Re==null?void 0:Re.toString())??"";if(!Jl(re)&&Ru(re)&&re.readonly!==!0){const Ue=A==null?void 0:A($e,re);if(Ue!==void 0&&Fl(Ue))return{location:Ce,value:Ue};const Be=Ee(re);if(Be===void 0)return;if(Be.kind===Se.Custom){Or(re.kind===Se.Custom);const Ft=(We=Be.onPaste)==null?void 0:We.call(Be,$e,re.data);return Ft===void 0?void 0:{location:Ce,value:{...re,data:Ft}}}else{const Ft=(yt=Be.onPaste)==null?void 0:yt.call(Be,$e,re,{formatted:be,formattedString:typeof be=="string"?be:be==null?void 0:be.join(` -`),rawValue:Re});return Ft===void 0?void 0:(Or(Ft.kind===re.kind),{location:Ce,value:Ft})}}}const N=J.columns,W=J.rows,V=((X=c.current)==null?void 0:X.contains(document.activeElement))===!0||((Z=l.current)==null?void 0:Z.contains(document.activeElement))===!0;let ee;if(J.current!==void 0?ee=[J.current.range.x,J.current.range.y]:N.length===1?ee=[N.first()??0,0]:W.length===1&&(ee=[K,W.first()??0]),V&&ee!==void 0){let re,Ce;const Re="text/plain",be="text/html";if(navigator.clipboard.read!==void 0){const Ue=await navigator.clipboard.read();for(const Be of Ue){if(Be.types.includes(be)){const $n=await(await Be.getType(be)).text(),hn=gb($n);if(hn!==void 0){re=hn;break}}Be.types.includes(Re)&&(Ce=await(await Be.getType(Re)).text())}}else if(navigator.clipboard.readText!==void 0)Ce=await navigator.clipboard.readText();else if(S!==void 0&&(S==null?void 0:S.clipboardData)!==null){if(S.clipboardData.types.includes(be)){const Ue=S.clipboardData.getData(be);re=gb(Ue)}re===void 0&&S.clipboardData.types.includes(Re)&&(Ce=S.clipboardData.getData(Re))}else return;const[$e,We]=ee,yt=[];do{if(se===void 0){const Ue=Tr(ee),Be=Ce??(re==null?void 0:re.map($n=>$n.map(hn=>hn.rawValue).join(" ")).join(" "))??"",Ft=L(Ue,ee,Be,void 0);Ft!==void 0&&yt.push(Ft);break}if(re===void 0){if(Ce===void 0)return;re=pW(Ce)}if(se===!1||typeof se=="function"&&(se==null?void 0:se([ee[0]-K,ee[1]],re.map(Ue=>Ue.map(Be=>{var Ft;return((Ft=Be.rawValue)==null?void 0:Ft.toString())??""}))))!==!0)return;for(const[Ue,Be]of re.entries()){if(Ue+We>=y)break;for(const[Ft,$n]of Be.entries()){const hn=[Ft+$e,Ue+We],[fi,Ni]=hn;if(fi>=it.length||Ni>=zn)continue;const hi=Tr(hn),Li=L(hi,hn,$n.rawValue,$n.formatted);Li!==void 0&&yt.push(Li)}}}while(!1);Hr(yt),(le=cr.current)==null||le.damage(yt.map(Ue=>({cell:Ue.location})))}},[A,Ee,Tr,J,li.paste,it.length,Hr,zn,se,K,y]);In("paste",qp,h,!1,!0);const iu=w.useCallback(async(S,L)=>{var X,Z;if(!li.copy)return;const N=L===!0||((X=c.current)==null?void 0:X.contains(document.activeElement))===!0||((Z=l.current)==null?void 0:Z.contains(document.activeElement))===!0,W=J.columns,V=J.rows,ee=(le,re)=>{if(!ke)yb(le,re,S);else{const Ce=re.map(Re=>({kind:Se.Text,data:g[Re].title,displayData:g[Re].title,allowOverlay:!1}));yb([Ce,...le],re,S)}};if(N&&yn!==void 0){if(J.current!==void 0){let le=yn(J.current.range,Bn.current.signal);typeof le!="object"&&(le=await le()),ee(le,Vo(J.current.range.x-K,J.current.range.x+J.current.range.width-K))}else if(V!==void 0&&V.length>0){const re=[...V].map(Ce=>{const Re=yn({x:K,y:Ce,width:g.length,height:1},Bn.current.signal);return typeof Re=="object"?Re[0]:Re().then(be=>be[0])});if(re.some(Ce=>Ce instanceof Promise)){const Ce=await Promise.all(re);ee(Ce,Vo(g.length))}else ee(re,Vo(g.length))}else if(W.length>0){const le=[],re=[];for(const Ce of W){let Re=yn({x:Ce,y:0,width:1,height:y},Bn.current.signal);typeof Re!="object"&&(Re=await Re()),le.push(Re),re.push(Ce-K)}if(le.length===1)ee(le[0],re);else{const Ce=le.reduce((Re,be)=>Re.map(($e,We)=>[...$e,...be[We]]));ee(Ce,re)}}}},[g,yn,J,li.copy,K,y,ke]);In("copy",iu,h,!1,!1);const $A=w.useCallback(async S=>{var N,W;if(!(!li.cut||!(((N=c.current)==null?void 0:N.contains(document.activeElement))===!0||((W=l.current)==null?void 0:W.contains(document.activeElement))===!0))&&(await iu(S),J.current!==void 0)){let V={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:wt.empty(),columns:wt.empty()};const ee=$==null?void 0:$(V);if(ee===!1||(V=ee===!0?V:ee,V.current===void 0))return;No(V.current.range)}},[No,J,li.cut,iu,$]);In("cut",$A,h,!1,!1);const HA=w.useCallback((S,L)=>{if(B!==void 0){K!==0&&(S=S.map(V=>[V[0]-K,V[1]])),B(S,L);return}if(S.length===0||L===-1)return;const[N,W]=S[L];f.current!==void 0&&f.current[0]===N&&f.current[1]===W||(f.current=[N,W],zs(N,W,!1,!1))},[B,K,zs]),[df,pf]=((Iw=Kt==null?void 0:Kt.current)==null?void 0:Iw.cell)??[],gf=w.useRef(fn);gf.current=fn,w.useLayoutEffect(()=>{var S,L,N,W;!vt.current&&df!==void 0&&pf!==void 0&&(df!==((L=(S=Fs.current)==null?void 0:S.current)==null?void 0:L.cell[0])||pf!==((W=(N=Fs.current)==null?void 0:N.current)==null?void 0:W.cell[1]))&&gf.current(df,pf),vt.current=!1},[df,pf]);const Ew=J.current!==void 0&&(J.current.cell[0]>=it.length||J.current.cell[1]>=zn);w.useLayoutEffect(()=>{Ew&&ur(Vf,!1)},[Ew,ur]);const jA=w.useMemo(()=>qt===!0&&(ct==null?void 0:ct.tint)===!0?wt.fromSingleSelection(zn-1):wt.empty(),[zn,qt,ct==null?void 0:ct.tint]),WA=w.useCallback(S=>typeof Tn=="boolean"?Tn:(Tn==null?void 0:Tn(S-K))??!0,[K,Tn]),VA=w.useMemo(()=>{if(Wp===void 0||l.current===null)return null;const{bounds:S,group:L}=Wp,N=l.current.getBoundingClientRect();return w.createElement(rW,{bounds:S,group:L,canvasBounds:N,onClose:()=>Vp(void 0),onFinish:W=>{Vp(void 0),F==null||F(L,W)}})},[F,Wp]),UA=Math.min(it.length,Ne+(kr?1:0));w.useImperativeHandle(e,()=>({appendRow:(S,L)=>Rl(S+K,L),updateCells:S=>{var L;return K!==0&&(S=S.map(N=>({cell:[N.cell[0]+K,N.cell[1]]}))),(L=cr.current)==null?void 0:L.damage(S)},getBounds:(S,L)=>{var N;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(S===void 0&&L===void 0){const W=l.current.getBoundingClientRect(),V=W.width/c.current.clientWidth;return{x:W.x-c.current.scrollLeft*V,y:W.y-c.current.scrollTop*V,width:c.current.scrollWidth*V,height:c.current.scrollHeight*V}}return(N=cr.current)==null?void 0:N.getBounds((S??0)+K,L)}},focus:()=>{var S;return(S=cr.current)==null?void 0:S.focus()},emit:async S=>{switch(S){case"delete":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await iu(void 0,!0);break;case"paste":await qp();break}},scrollTo:fn,remeasureColumns:S=>{for(const L of S)hf(L+K)}}),[Rl,hf,iu,ru,qp,K,fn]);const[Mw,Aw]=_i??[],KA=w.useCallback(S=>{const[L,N]=S;if(N===-1){Te!=="none"&&(me(wt.fromSingleSelection(L),void 0,!1),er());return}Mw===L&&Aw===N||(ie({cell:S,range:{x:L,y:N,width:1,height:1}},!0,!1,"keyboard-nav"),fn(L,N))},[Te,er,fn,Mw,Aw,ie,me]),[XA,GA]=w.useState(!1),Rw=w.useRef(sT(S=>{GA(S)},5)),qA=w.useCallback(()=>{Rw.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&ie({cell:[K,of],range:{x:K,y:of,width:1,height:1}},!0,!1,"keyboard-select")},[of,J,a,K,ie]),YA=w.useCallback(()=>{Rw.current(!1)},[]),[QA,JA]=w.useMemo(()=>{let S;const L=(Gt==null?void 0:Gt.scrollbarWidthOverride)??m0(),N=y+(qt?1:0);if(typeof Zn=="number")S=nt+N*Zn;else{let V=0;const ee=Math.min(N,10);for(let X=0;Xee.width+V,0)+L;return[`${Math.min(1e5,W)}px`,`${Math.min(1e5,S)}px`]},[it,Gt==null?void 0:Gt.scrollbarWidthOverride,Zn,y,qt,nt]),ZA=w.useMemo(()=>C4(fe),[fe]);return w.createElement(T4.Provider,{value:fe},w.createElement(vW,{style:ZA,className:H,inWidth:x??QA,inHeight:v??JA},w.createElement(Z8,{fillHandle:Ht,drawFocusRing:wn,experimental:Gt,fixedShadowX:qc,fixedShadowY:Ds,getRowThemeOverride:p,headerIcons:us,imageWindowLoader:cs,initialSize:ml,isDraggable:Yc,onDragLeave:Qc,onRowMoved:Ii,overscrollX:_p,overscrollY:rf,preventDiagonalScrolling:wl,rightElement:Oo,rightElementProps:_s,smoothScrollX:Zc,smoothScrollY:Op,className:H,enableGroups:Ct,onCanvasFocused:qA,onCanvasBlur:YA,canvasRef:l,onContextMenu:zA,theme:fe,cellXOffset:Io,cellYOffset:of,accessibilityHeight:cn.height,onDragEnd:NA,columns:it,nonGrowWidth:Le,drawHeader:Bp,onColumnProposeMove:I,drawCell:zp,disabledRows:jA,freezeColumns:UA,lockColumns:K,firstColAccessible:K===0,getCellContent:Tr,minColumnWidth:br,maxColumnWidth:oi,searchInputRef:o,showSearch:Qa,onSearchClose:Lp,highlightRegions:EA,getCellsForSelection:yn,getGroupDetails:Hp,headerHeight:Sl,isFocused:XA,groupHeaderHeight:Ct?Ya:0,freezeTrailingRows:mt+(qt&&(ct==null?void 0:ct.sticky)===!0?1:0),hasAppendRow:qt,onColumnResize:ai,onColumnResizeEnd:Fp,onColumnResizeStart:Tl,onCellFocused:KA,onColumnMoved:DA,onDragStart:_A,onHeaderMenuClick:PA,onItemHovered:Gp,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:OA,onKeyDown:ru,onKeyUp:Je,onMouseDown:MA,onMouseUp:RA,onDragOverCell:si,onDrop:pt,onSearchResultsChanged:HA,onVisibleRegionChanged:IA,clientSize:Ae,rowHeight:Zn,searchResults:ge,searchValue:ue,onSearchValueChange:we,rows:zn,scrollRef:c,selection:J,translateX:cn.tx,translateY:cn.ty,verticalBorder:WA,gridRef:cr,getCellRenderer:Ee}),VA,i!==void 0&&w.createElement(w.Suspense,{fallback:null},w.createElement(CW,{...i,validateCell:Ja,bloom:O,id:BA,getCellRenderer:Ee,className:(Gt==null?void 0:Gt.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:$t,imageEditorOverride:d,onFinishEditing:FA,markdownDivCreateNode:m,isOutsideClick:ef}))))},AW=w.forwardRef(MW),xb=20,RW={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:Se.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>OW(t,t.cell.data,f0(t.cell),t.cell.maxSize??xb),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??xb,f=Math.floor(i.y+l/2),h=aT(c,l,s.cellVerticalPadding),d=lT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,h),p=oT(d,f,h),m=uT(a+n,u+r,p);if(f0(e)&&m)return{...e,data:nE(e.data)}},onPaste:(t,e)=>{let n=id;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Mv),n===e.data?void 0:{...e,data:n}}};function OW(t,e,n,r){if(!n&&e===id)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:h,y:d,width:p,height:m}=l,x=.35;let v=n?1-x+x*s:.4;e===id&&(v*=s),v!==0&&(i.globalAlpha=v,Hv(i,o,e,h,d,p,m,a,u,c,r,f),i.globalAlpha=1)}const PW=Br("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),IW=t=>{const{bubbles:e}=t;return w.createElement(PW,null,e.map((n,r)=>w.createElement("div",{key:r,className:"boe-bubble"},n)),w.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},DW={getAccessibilityString:t=>cT(t.data),kind:Se.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>NW(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return w.createElement(IW,{bubbles:e.data})},onPaste:()=>{}},_W=4;function NW(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,h=_W;let d=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(d>o+a)break;const x=Wc(m,i,r.baseFontFull).width;p.push({x:d,width:x}),d+=x+f*2+h}i.beginPath();for(const m of p)ts(i,m.x,l+(u-c)/2,m.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[m,x]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[m],x.x+f,l+u/2+Is(i,r))}const LW=Br("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),FW=t=>{const{drilldowns:e}=t;return w.createElement(LW,null,e.map((n,r)=>w.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&w.createElement("img",{src:n.img}),w.createElement("div",null,n.text))))},BW={getAccessibilityString:t=>cT(t.data.map(e=>e.text)),kind:Se.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>HW(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return w.createElement(FW,{drilldowns:e.data})},onPaste:()=>{}},zW=4,jg={};function $W(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,h=`${t},${e},${i},${n}`;if(jg[h]!==void 0)return{el:jg[h],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const d=document.createElement("canvas"),p=d.getContext("2d");return p===null?null:(d.width=f,d.height=a,p.scale(i,i),jg[h]=d,p.beginPath(),ts(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),ts(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:d,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function HW(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=ST(i,c),h=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),d=Math.floor(n.y+(n.height-h)/2),p=h-10,m=8,x=zW;let v=a+r.cellHorizontalPadding;const g=r.roundingRadius??6,y=$W(r.bgCell,r.drilldownBorder,h,g),k=[];for(const b of e){if(v>a+u)break;const T=Wc(b.text,i,c).width;let E=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(E=p-8+4);const A=T+E+m*2;k.push({x:v,width:A}),v+=A+x}if(y!==null){const{el:b,height:C,middleWidth:T,sideWidth:E,width:A,dpr:P,padding:D}=y,O=E/P,_=D/P;for(const I of k){const Y=Math.floor(I.x),U=Math.floor(I.width),ae=U-(O-_)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,E,C,Y-_,d,O,h),ae>0&&i.drawImage(b,E,0,T,C,Y+(O-_),d,ae,h),i.drawImage(b,A-E,0,E,C,Y+U-(O-_),d,O,h),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,C]of k.entries()){const T=e[b];let E=C.x+m;if(T.img!==void 0){const A=s.loadOrGetImage(T.img,o,l);if(A!==void 0){const P=p-8;let D=0,O=0,_=A.width,I=A.height;_>I?(D+=(_-I)/2,_=I):I>_&&(O+=(I-_)/2,I=_),i.beginPath(),ts(i,E,d+h/2-P/2,P,P,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(A,D,O,_,I,E,d+h/2-P/2,P,P),i.restore(),E+=P+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,E,d+h/2+Is(i,r))}}const jW={getAccessibilityString:t=>t.data.join(", "),kind:Se.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>WW(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??DF;return w.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},Wg=4;function WW(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:h,width:d}=i,p=h-l.cellVerticalPadding*2,m=[];let x=0;for(let g=0;g0&&(a.beginPath(),ts(a,v,f+l.cellVerticalPadding,y,p,n),a.save(),a.clip()),a.drawImage(g,v,f+l.cellVerticalPadding,y,p),n>0&&a.restore(),v+=y+Wg}}function VW(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const UW={getAccessibilityString:()=>"",kind:Se.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(VW(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);ts(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=sl(o.textDark,.1),i.fill()},onPaste:()=>{}},KW=()=>t=>t.targetWidth,bb=Br("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[KW(),"px"]}}),XW=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=w.useState(a===""||r),h=w.useCallback(()=>{f(p=>!p)},[]),d=a?"gdg-ml-6":"";return c?w.createElement(bb,{targetWidth:s.width-20},w.createElement(dp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),w.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${d}`,onClick:()=>o(e)},w.createElement(EF,null))):w.createElement(bb,{targetWidth:s.width},w.createElement(JF,{contents:a,createNode:i}),!u&&w.createElement(w.Fragment,null,w.createElement("div",{className:"spacer"}),w.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${d}`,onClick:h},w.createElement(Iv,null))),w.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},GW={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:Vc,measure:(t,e,n)=>{const r=e.data.split(` -`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>ws(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return w.createElement(XW,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},qW={getAccessibilityString:t=>t.row.toString(),kind:Gr.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:YW,measure:()=>44,draw:t=>JW(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function YW(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=QW,n.textAlign="center",s}function QW(t){const{ctx:e}=t;e.textAlign="start"}function JW(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:h,height:d}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(Hv(o,u,n,i?c+m:c,f,i?h-m:h,d,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const v of[-5,-1,3])o.rect(c+x,f+d/2+v,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,v=c+h/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,v,f+d/2+Is(o,x)),a!==0&&(o.globalAlpha=1)}}const ZW={getAccessibilityString:()=>"",kind:Gr.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>e6(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function e6(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const h=e!=="";let d=0;if(n!==void 0){const m=f-8,x=a+8/2,v=u+8/2;l.drawSprite(n,"normal",r,x,v,m,o,h?1:s),d=m}else{d=24;const p=12,m=h?p:s*p,x=h?0:(1-s)*p*.5,v=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+v+x,u+f/2),r.lineTo(a+v+x+m,u+f/2),r.moveTo(a+v+x+m*.5,u+f/2-m*.5),r.lineTo(a+v+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,d+a+o.cellHorizontalPadding+.5,u+f/2+Is(r,o)),r.beginPath()}const t6=w.lazy(async()=>await RT(()=>import("./number-overlay-editor-CTQ0oWgC.js"),[])),n6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:Vc,draw:t=>ws(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return w.createElement(w.Suspense,{fallback:null},w.createElement(t6,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},r6={getAccessibilityString:()=>"",measure:()=>108,kind:Se.Protected,needsHover:!1,needsHoverPosition:!1,draw:i6,onPaste:()=>{}};function i6(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(kx(30))*l,f=Math.sin(kx(30))*l;for(let h=0;h<12;h++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const s6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>Vc(t,e,t.theme.textLight),draw:t=>ws(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return kn.createElement(dp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},o6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Vc,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const h=o.cellHorizontalPadding,d=o.cellVerticalPadding,p=Wc(a,i,o.baseFontFull,"alphabetic"),m=s.height-d,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),ts(i,s.x+h/2,s.y+(s.height-x)/2+1,p.width+h*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=sl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}ws(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` -`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return w.createElement(dp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},l6=Br("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),a6=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=w.useState(!i&&(e===""||r)),u=w.useCallback(()=>{a(!0)},[]);return l?w.createElement(dp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):w.createElement(l6,null,w.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&w.createElement("div",{className:"gdg-edit-icon",onClick:u},w.createElement(Iv,null)),w.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function kb(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const u6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:Vc,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=Wc(a,l,n.baseFontFull),f=kb(c,o,n,e.contentAlign),{x:h,y:d,width:p,height:m}=f;if(i>=h-4&&i<=h-4+p+8&&s>=d-4&&s<=d-4+m+8){const x=Is(l,n.baseFontFull);r("pointer");const v=5,g=d-x;l.beginPath(),l.moveTo(o.x+h,Math.floor(o.y+g+m+v)+.5),l.lineTo(o.x+h+p,Math.floor(o.y+g+m+v)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,ws({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,ws(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=m4(o,s.baseFontFull);if(l===void 0)return;const a=kb(l,n,s,e.contentAlign);gp({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return w.createElement(a6,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},c6=[qW,ZW,RW,DW,BW,jW,UW,GW,n6,r6,s6,o6,u6];var f6=iT,h6=hl,d6="Expected a function";function p6(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(d6);return h6(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),f6(t,e,{leading:r,maxWait:e,trailing:i})}var g6=p6;const m6=Ri(g6),Vg=[];class y6 extends TT{constructor(){super(...arguments);at(this,"imageLoaded",()=>{});at(this,"loadedLocations",[]);at(this,"cache",{});at(this,"sendLoaded",m6(()=>{this.imageLoaded(new Gu(this.loadedLocations)),this.loadedLocations=[]},20));at(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,Vg.length<12?Vg.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const h of f.cells)this.loadedLocations.push(Bv(h));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=xi(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const Ug="\uFEFF";function v6(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function w6(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;sl.map(a=>({rawValue:a,formatted:a,format:"string"})))}function wb(t,e,n){var l;const r=pW(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function sE(t){return t!==!0}function xb(t){return typeof t=="string"?t:`${t}px`}const yW=()=>t=>t.innerWidth,vW=()=>t=>t.innerHeight,wW=zr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[yW()],"wmyidgi-1":[vW()]}}),xW=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return w.createElement(wW,{innerHeight:xb(n),innerWidth:xb(e),...i},r)},bW=2,kW=1300;function SW(t,e,n){const r=Tn.useRef(0),[i,s]=t??[0,0];Tn.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/kW);const h=r.current**1.618*f*bW;(c=e.current)==null||c.scrollBy(i*h,s*h),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function CW({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,h,d]=Tn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=OT();return[typeof m=="number"?m*p:v=>Math.ceil(m(v)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:h,overscrollY:d}}const Us={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function ut(t,e){return t===!0?e:t===!1?"":t}function bb(t){const e=vd.value;return{activateCell:ut(t.activateCell," |Enter|shift+Enter"),clear:ut(t.clear,"any+Escape"),closeOverlay:ut(t.closeOverlay,"any+Escape"),acceptOverlayDown:ut(t.acceptOverlayDown,"Enter"),acceptOverlayUp:ut(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:ut(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:ut(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:ut(t.delete,e?"Backspace|Delete":"Delete"),downFill:ut(t.downFill,"primary+_68"),scrollToSelectedCell:ut(t.scrollToSelectedCell,"primary+Enter"),goDownCell:ut(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:ut(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:ut(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:ut(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:ut(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:ut(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:ut(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:ut(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:ut(t.goToFirstCell,"primary+Home"),goToFirstColumn:ut(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:ut(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:ut(t.goToLastCell,"primary+End"),goToLastColumn:ut(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:ut(t.goToLastRow,"primary+ArrowDown"),goToNextPage:ut(t.goToNextPage,"PageDown"),goToPreviousPage:ut(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:ut(t.rightFill,"primary+_82"),search:ut(t.search,"primary+f"),selectAll:ut(t.selectAll,"primary+a"),selectColumn:ut(t.selectColumn,"ctrl+ "),selectGrowDown:ut(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:ut(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:ut(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:ut(t.selectGrowUp,"shift+ArrowUp"),selectRow:ut(t.selectRow,"shift+ "),selectToFirstCell:ut(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:ut(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:ut(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:ut(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:ut(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:ut(t.selectToLastRow,"primary+shift+ArrowDown")}}function TW(t){const e=_F(t);return Tn.useMemo(()=>{if(e===void 0)return bb(Us);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Us.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Us.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Us.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Us.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Us.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Us.selectToLastCell};return bb({...Us,...n})},[e])}const EW=w.lazy(async()=>await IT(()=>import("./data-grid-overlay-editor-Cscy33Rw.js"),[]));let MW=0;function AW(t){return PB($x($x(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return Vo((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Uf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const Wg={kind:ke.Loading,allowOverlay:!1},Kf={columns:St.empty(),rows:St.empty(),current:void 0},RW=(t,e)=>{var Iw,Dw,_w;const[n,r]=w.useState(Kf),[i,s]=w.useState(),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(),c=w.useRef(null),f=w.useRef(),h=typeof window>"u"?null:window,{imageEditorOverride:d,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:v,columns:g,rows:y,getCellContent:k,onCellClicked:b,onCellActivated:C,onFillPattern:T,onFinishedEditing:E,coercePasteValue:A,drawHeader:P,drawCell:_,editorBloom:O,onHeaderClicked:D,onColumnProposeMove:I,spanRangeBehavior:Q="default",onGroupHeaderClicked:X,onCellContextMenu:le,className:j,onHeaderContextMenu:ne,getCellsForSelection:Y,onGroupHeaderContextMenu:M,onGroupHeaderRenamed:F,onCellEdited:z,onCellsEdited:W,onSearchResultsChanged:B,searchResults:de,onSearchValueChange:ge,searchValue:ae,onKeyDown:Re,onKeyUp:nt,keybindings:Ze,editOnType:Ge=!0,onRowAppended:Ye,onColumnMoved:it,validateCell:rt,highlightRegions:Dt,rangeSelect:Ie="rect",columnSelect:be="multi",rowSelect:Xe="multi",rangeSelectionBlending:qe="exclusive",columnSelectionBlending:et="exclusive",rowSelectionBlending:Be="exclusive",onDelete:ye,onDragStart:_e,onMouseMove:H,onPaste:V,copyHeaders:Z=!1,freezeColumns:ue=0,cellActivationBehavior:se="second-click",rowSelectionMode:tt="auto",onHeaderMenuClick:pe,getGroupDetails:De,onSearchClose:Me,onItemHovered:Ve,onSelectionCleared:dt,showSearch:An,onVisibleRegionChanged:un,gridSelection:ct,onGridSelectionChange:vn,minColumnWidth:cn=50,maxColumnWidth:$r=500,maxColumnAutoWidth:Hr,provideEditor:jt,trailingRowOptions:pt,freezeTrailingRows:xt=0,allowedFillDirections:In="orthogonal",scrollOffsetX:Dn,scrollOffsetY:nn,verticalBorder:Rn,onDragOverCell:li,onDrop:vt,onColumnResize:Gt,onColumnResizeEnd:_t,onColumnResizeStart:Nt,customRenderers:_n,fillHandle:Wt,drawFocusRing:kn=!0,experimental:qt,fixedShadowX:Qc,fixedShadowY:Ds,headerIcons:us,imageWindowLoader:cs,initialSize:ml,isDraggable:Jc,onDragLeave:Zc,onRowMoved:_i,overscrollX:yl,overscrollY:vl,preventDiagonalScrolling:wl,rightElement:Oo,rightElementProps:_s,trapFocus:ef=!1,smoothScrollX:tf,smoothScrollY:Ip,scaleToRem:Dp=!1,rowHeight:xl=34,headerHeight:fs=36,groupHeaderHeight:_p=fs,theme:Np,isOutsideClick:nf,renderers:bl}=t,wn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,jr=(wn==null?void 0:wn.kind)??t.rowMarkers??"none",rf=(wn==null?void 0:wn.width)??t.rowMarkerWidth,kl=(wn==null?void 0:wn.startIndex)??t.rowMarkerStartIndex??1,Xa=(wn==null?void 0:wn.theme)??t.rowMarkerTheme,Ns=(wn==null?void 0:wn.checkboxStyle)??"square",kr=Math.max(cn,20),ai=Math.max($r,kr),Ga=Math.max(Hr??ai,kr),Ls=w.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),qa=w.useMemo(()=>Number.parseFloat(Ls.fontSize),[Ls]),{rowHeight:tr,headerHeight:Sl,groupHeaderHeight:Ya,theme:sf,overscrollX:Lp,overscrollY:of}=CW({groupHeaderHeight:_p,headerHeight:fs,overscrollX:yl,overscrollY:vl,remSize:qa,rowHeight:xl,scaleToRem:Dp,theme:Np}),ui=TW(Ze),hs=rf??(y>1e4?48:y>1e3?44:y>100?36:32),Sr=jr!=="none",G=Sr?1:0,Yt=Ye!==void 0,Po=(pt==null?void 0:pt.sticky)===!0,[Fp,lf]=w.useState(!1),Qa=An??Fp,Bp=w.useCallback(()=>{Me!==void 0?Me():lf(!1)},[Me]),J=w.useMemo(()=>ct===void 0?void 0:Uf(ct,G),[ct,G])??n,Wn=w.useRef();Wn.current===void 0&&(Wn.current=new AbortController),w.useEffect(()=>()=>Wn==null?void 0:Wn.current.abort(),[]);const[xn,Cl]=aW(Y,k,G,Wn.current,y),Ja=w.useCallback((S,L,N)=>{if(rt===void 0)return!0;const U=[S[0]-G,S[1]];return rt==null?void 0:rt(U,L,N)},[G,rt]),Fs=w.useRef(ct),fr=w.useCallback((S,L)=>{L&&(S=gW(S,xn,G,Q,Wn.current)),vn!==void 0?(Fs.current=Uf(S,-G),vn(Fs.current)):r(S)},[vn,xn,G,Q]),ci=_l(Gt,w.useCallback((S,L,N,U)=>{Gt==null||Gt(g[N-G],L,N-G,U)},[Gt,G,g])),zp=_l(_t,w.useCallback((S,L,N,U)=>{_t==null||_t(g[N-G],L,N-G,U)},[_t,G,g])),Tl=_l(Nt,w.useCallback((S,L,N,U)=>{Nt==null||Nt(g[N-G],L,N-G,U)},[Nt,G,g])),$p=_l(P,w.useCallback((S,L)=>(P==null?void 0:P({...S,columnIndex:S.columnIndex-G},L))??!1,[P,G])),Hp=_l(_,w.useCallback((S,L)=>(_==null?void 0:_({...S,col:S.col-G},L))??!1,[_,G])),$=w.useCallback(S=>{if(ye!==void 0){const L=ye(Uf(S,-G));return typeof L=="boolean"?L:Uf(L,G)}return!0},[ye,G]),[ie,we,me]=lW(J,fr,qe,et,Be,Ie),ce=w.useMemo(()=>mo(OT(),sf),[sf]),[Ee,Qe]=w.useState([0,0,0]),Je=w.useMemo(()=>{if(bl===void 0)return{};const S={};for(const L of bl)S[L.kind]=L;return S},[bl]),Ce=w.useCallback(S=>S.kind!==ke.Custom?Je[S.kind]:_n==null?void 0:_n.find(L=>L.isMatch(S)),[_n,Je]);let{sizedColumns:Et,nonGrowWidth:Ne}=R4(g,y,Cl,Ee[0]-(G===0?0:hs)-Ee[2],kr,Ga,ce,Ce,Wn.current);jr!=="none"&&(Ne+=hs);const At=w.useMemo(()=>Et.some(S=>S.group!==void 0),[Et]),st=At?Sl+Ya:Sl,gt=J.rows.length,fn=jr==="none"?void 0:gt===0?!1:gt===y?!0:void 0,ot=w.useMemo(()=>jr==="none"?Et:[{title:"",width:hs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Xa,rowMarker:Ns,rowMarkerChecked:fn},...Et],[jr,Et,hs,Xa,Ns,fn]),[rn,Wr]=w.useMemo(()=>[nn!==void 0&&typeof tr=="number"?Math.floor(nn/tr):0,nn!==void 0&&typeof tr=="number"?-(nn%tr):0],[nn,tr]),Qt=w.useRef({height:1,width:1,x:0,y:0}),Cr=w.useMemo(()=>({x:Qt.current.x,y:rn,width:Qt.current.width??1,height:Qt.current.height??1,ty:Wr}),[Wr,rn]),kt=w.useRef(!1),[hn,Tr,Ni]=DF(Cr);Qt.current=hn;const fi=(hn.height??1)>1;w.useLayoutEffect(()=>{if(nn!==void 0&&c.current!==null&&fi){if(c.current.scrollTop===nn)return;c.current.scrollTop=nn,c.current.scrollTop!==nn&&Ni(),kt.current=!0}},[nn,fi,Ni]);const El=(hn.width??1)>1;w.useLayoutEffect(()=>{if(Dn!==void 0&&c.current!==null&&El){if(c.current.scrollLeft===Dn)return;c.current.scrollLeft=Dn,c.current.scrollLeft!==Dn&&Ni(),kt.current=!0}},[Dn,El,Ni]);const Io=hn.x+G,af=hn.y,hr=w.useRef(null),nr=w.useCallback(S=>{var L;S===!0?(L=hr.current)==null||L.focus():window.requestAnimationFrame(()=>{var N;(N=hr.current)==null||N.focus()})},[]),Vn=Yt?y+1:y,Vr=w.useCallback(S=>{const L=G===0?S:S.map(U=>({...U,location:[U.location[0]-G,U.location[1]]})),N=W==null?void 0:W(L);if(N!==!0)for(const U of L)z==null||z(U.location,U.value);return N},[z,W,G]),[Do,jp]=w.useState(),uf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,Ml=kn?(Iw=J.current)==null?void 0:Iw.cell:void 0,cf=Ml==null?void 0:Ml[0],ff=Ml==null?void 0:Ml[1],RA=w.useMemo(()=>{if((Dt===void 0||Dt.length===0)&&(uf??cf??ff??Do)===void 0)return;const S=[];if(Dt!==void 0)for(const L of Dt){const N=ot.length-L.range.x-G;N>0&&S.push({color:L.color,range:{...L.range,x:L.range.x+G,width:Math.min(N,L.range.width)},style:L.style})}return Do!==void 0&&S.push({color:sl(ce.accentColor,0),range:Do,style:"dashed"}),uf!==void 0&&S.push({color:sl(ce.accentColor,.5),range:uf,style:"solid-outline"}),cf!==void 0&&ff!==void 0&&S.push({color:ce.accentColor,range:{x:cf,y:ff,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Do,uf,cf,ff,Dt,ot.length,ce.accentColor,G]),ww=w.useRef(ot);ww.current=ot;const Er=w.useCallback(([S,L],N=!1)=>{var te,q,ee,oe,re,Se,Ae;const U=Yt&&L===Vn-1;if(S===0&&Sr)return U?Wg:{kind:Yr.Marker,allowOverlay:!1,checkboxStyle:Ns,checked:(J==null?void 0:J.rows.hasIndex(L))===!0,markerKind:jr==="clickable-number"?"number":jr,row:kl+L,drawHandle:_i!==void 0,cursor:jr==="clickable-number"?"pointer":void 0};if(U){const ze=S===G?(pt==null?void 0:pt.hint)??"":"",je=ww.current[S];if(((te=je==null?void 0:je.trailingRowOptions)==null?void 0:te.disabled)===!0)return Wg;{const bt=((q=je==null?void 0:je.trailingRowOptions)==null?void 0:q.hint)??ze,Ue=((ee=je==null?void 0:je.trailingRowOptions)==null?void 0:ee.addIcon)??(pt==null?void 0:pt.addIcon);return{kind:Yr.NewRow,hint:bt,allowOverlay:!1,icon:Ue}}}else{const xe=S-G;if(N||(qt==null?void 0:qt.strict)===!0){const je=Qt.current,bt=je.x>xe||xe>je.x+je.width||je.y>L||L>je.y+je.height||L>=Vp.current,Ue=xe===((re=(oe=je.extras)==null?void 0:oe.selected)==null?void 0:re[0])&&L===((Se=je.extras)==null?void 0:Se.selected[1]);let Fe=!1;if(((Ae=je.extras)==null?void 0:Ae.freezeRegions)!==void 0){for(const zt of je.extras.freezeRegions)if(yp(zt,xe,L)){Fe=!0;break}}if(bt&&!Ue&&!Fe)return Wg}let ze=k([xe,L]);return G!==0&&ze.span!==void 0&&(ze={...ze,span:[ze.span[0]+G,ze.span[1]+G]}),ze}},[Yt,Vn,Sr,Ns,J==null?void 0:J.rows,jr,kl,_i,G,pt==null?void 0:pt.hint,pt==null?void 0:pt.addIcon,qt==null?void 0:qt.strict,k]),Wp=w.useCallback(S=>{let L=(De==null?void 0:De(S))??{name:S};return F!==void 0&&S!==""&&(L={icon:L.icon,name:L.name,overrideTheme:L.overrideTheme,actions:[...L.actions??[],{title:"Rename",icon:"renameIcon",onClick:N=>Kp({group:L.name,bounds:N.bounds})}]}),L},[De,F]),hf=w.useCallback(S=>{var ee;const[L,N]=S.cell,U=ot[L],K=(U==null?void 0:U.group)!==void 0?(ee=Wp(U.group))==null?void 0:ee.overrideTheme:void 0,te=U==null?void 0:U.themeOverride,q=p==null?void 0:p(N);s({...S,theme:mo(ce,K,te,q,S.content.themeOverride)})},[p,ot,Wp,ce]),Al=w.useCallback((S,L,N)=>{var q;if(J.current===void 0)return;const[U,K]=J.current.cell,te=Er([U,K]);if(te.kind!==ke.Boolean&&te.allowOverlay){let ee=te;if(N!==void 0)switch(ee.kind){case ke.Number:{const oe=pD(()=>N==="-"?-0:Number.parseFloat(N),0);ee={...ee,data:Number.isNaN(oe)?0:oe};break}case ke.Text:case ke.Markdown:case ke.Uri:ee={...ee,data:N};break}hf({target:S,content:ee,initialValue:N,cell:[U,K],highlight:N===void 0,forceEditMode:N!==void 0})}else te.kind===ke.Boolean&&L&&te.readonly!==!0&&(Vr([{location:J.current.cell,value:{...te,data:sE(te.data)}}]),(q=hr.current)==null||q.damage([{cell:J.current.cell}]))},[Er,J,Vr,hf]),xw=w.useCallback((S,L)=>{var K;const N=(K=hr.current)==null?void 0:K.getBounds(S,L);if(N===void 0||c.current===null)return;const U=Er([S,L]);U.allowOverlay&&hf({target:N,content:U,initialValue:void 0,highlight:!0,cell:[S,L],forceEditMode:!0})},[Er,hf]),dn=w.useCallback((S,L,N="both",U=0,K=0,te=void 0)=>{if(c.current!==null){const q=hr.current,ee=l.current,oe=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,re=typeof L!="number"?L.unit==="cell"?L.amount:void 0:L,Se=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Ae=typeof L!="number"&&L.unit==="px"?L.amount:void 0;if(q!==null&&ee!==null){let xe={x:0,y:0,width:0,height:0},ze=0,je=0;if((oe!==void 0||re!==void 0)&&(xe=q.getBounds((oe??0)+G,re??0)??xe,xe.width===0||xe.height===0))return;const bt=ee.getBoundingClientRect(),Ue=bt.width/ee.offsetWidth;if(Se!==void 0&&(xe={...xe,x:Se-bt.left-c.current.scrollLeft,width:1}),Ae!==void 0&&(xe={...xe,y:Ae+bt.top-c.current.scrollTop,height:1}),xe!==void 0){const Fe={x:xe.x-U,y:xe.y-K,width:xe.width+2*U,height:xe.height+2*K};let zt=0;for(let Jp=0;Jp0&&(Un=gl(Vn,pn,tr));let di=zt*Ue+bt.left+G*hs*Ue,Fi=bt.right,pi=bt.top+st*Ue,Bi=bt.bottom-Un*Ue;const vf=xe.width+U*2;switch(te==null?void 0:te.hAlign){case"start":Fi=di+vf;break;case"end":di=Fi-vf;break;case"center":di=Math.floor((di+Fi)/2)-vf/2,Fi=di+vf;break}const wf=xe.height+K*2;switch(te==null?void 0:te.vAlign){case"start":Bi=pi+wf;break;case"end":pi=Bi-wf;break;case"center":pi=Math.floor((pi+Bi)/2)-wf/2,Bi=pi+wf;break}di>Fe.x?ze=Fe.x-di:FiFe.y?je=Fe.y-pi:Bi=Vn-pn)&&(je=0),(ze!==0||je!==0)&&(Ue!==1&&(ze/=Ue,je/=Ue),c.current.scrollTo(ze+c.current.scrollLeft,je+c.current.scrollTop))}}}},[G,xt,hs,st,ue,Et,Vn,Po,tr]),bw=w.useRef(xw),kw=w.useRef(k),Vp=w.useRef(y);bw.current=xw,kw.current=k,Vp.current=y;const Rl=w.useCallback(async(S,L=!0)=>{var oe;const N=ot[S];if(((oe=N==null?void 0:N.trailingRowOptions)==null?void 0:oe.disabled)===!0)return;const U=Ye==null?void 0:Ye();let K,te=!0;U!==void 0&&(K=await U,K==="top"&&(te=!1),typeof K=="number"&&(te=!1));let q=0;const ee=()=>{if(Vp.current<=y){q<500&&window.setTimeout(ee,q),q=50+q*2;return}const re=typeof K=="number"?K:te?y:0;yf.current(S-G,re),ie({cell:[S,re],range:{x:S,y:re,width:1,height:1}},!1,!1,"edit");const Se=kw.current([S-G,re]);Se.allowOverlay&&Ou(Se)&&Se.readonly!==!0&&L&&window.setTimeout(()=>{bw.current(S,re)},0)};ee()},[ot,Ye,G,y,ie]),df=w.useCallback(S=>{var N,U;const L=((U=(N=Et[S])==null?void 0:N.trailingRowOptions)==null?void 0:U.targetColumn)??(pt==null?void 0:pt.targetColumn);if(typeof L=="number")return L+(Sr?1:0);if(typeof L=="object"){const K=g.indexOf(L);if(K>=0)return K+(Sr?1:0)}},[Et,g,Sr,pt==null?void 0:pt.targetColumn]),Bs=w.useRef(),Ol=w.useRef(),Za=w.useCallback((S,L)=>{var K;const[N,U]=L;return mo(ce,(K=ot[N])==null?void 0:K.themeOverride,p==null?void 0:p(U),S.themeOverride)},[p,ot,ce]),eu=w.useCallback(S=>{var Se,Ae,xe;const L=vd.value?S.metaKey:S.ctrlKey,N=L&&Xe==="multi",U=L&&be==="multi",[K,te]=S.location,q=J.columns,ee=J.rows,[oe,re]=((Se=J.current)==null?void 0:Se.cell)??[];if(S.kind==="cell"){if(Ol.current=void 0,_o.current=[K,te],K===0&&Sr){if(Yt===!0&&te===y||jr==="number"||Xe==="none")return;const ze=Er(S.location);if(ze.kind!==Yr.Marker)return;if(_i!==void 0){const Ue=Ce(ze);Pr((Ue==null?void 0:Ue.kind)===Yr.Marker);const Fe=(Ae=Ue==null?void 0:Ue.onClick)==null?void 0:Ae.call(Ue,{...S,cell:ze,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:Za(ze,S.location),preventDefault:()=>{}});if(Fe===void 0||Fe.checked===ze.checked)return}s(void 0),nr();const je=ee.hasIndex(te),bt=Bs.current;if(Xe==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&bt!==void 0&&ee.hasIndex(bt)){const Ue=[Math.min(bt,te),Math.max(bt,te)+1];N||tt==="multi"?we(void 0,Ue,!0):we(St.fromSingleSelection(Ue),void 0,N)}else N||S.isTouch||tt==="multi"?je?we(ee.remove(te),void 0,!0):(we(void 0,te,!0),Bs.current=te):je&&ee.length===1?we(St.empty(),void 0,L):(we(St.fromSingleSelection(te),void 0,L),Bs.current=te)}else if(K>=G&&Yt&&te===y){const ze=df(K);Rl(ze??K)}else if(oe!==K||re!==te){const ze=Er(S.location),je=Ce(ze);if((je==null?void 0:je.onSelect)!==void 0){let Fe=!1;if(je.onSelect({...S,cell:ze,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>Fe=!0,theme:Za(ze,S.location)}),Fe)return}const bt=Po&&te===y,Ue=Po&&J!==void 0&&((xe=J.current)==null?void 0:xe.cell[1])===y;if((S.shiftKey||S.isLongTouch===!0)&&oe!==void 0&&re!==void 0&&J.current!==void 0&&!Ue){if(bt)return;const Fe=Math.min(K,oe),zt=Math.max(K,oe),Un=Math.min(te,re),pn=Math.max(te,re);ie({...J.current,range:{x:Fe,y:Un,width:zt-Fe+1,height:pn-Un+1}},!0,L,"click"),Bs.current=void 0,nr()}else ie({cell:[K,te],range:{x:K,y:te,width:1,height:1}},!0,L,"click"),Bs.current=void 0,s(void 0),nr()}}else if(S.kind==="header")if(_o.current=[K,te],s(void 0),Sr&&K===0)Bs.current=void 0,Ol.current=void 0,Xe==="multi"&&(ee.length!==y?we(St.fromSingleSelection([0,y]),void 0,L):we(St.empty(),void 0,L),nr());else{const ze=Ol.current;if(be==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&ze!==void 0&&q.hasIndex(ze)){const je=[Math.min(ze,K),Math.max(ze,K)+1];U?me(void 0,je,L):me(St.fromSingleSelection(je),void 0,L)}else U?(q.hasIndex(K)?me(q.remove(K),void 0,L):me(void 0,K,L),Ol.current=K):be!=="none"&&(me(St.fromSingleSelection(K),void 0,L),Ol.current=K);Bs.current=void 0,nr()}else S.kind===Or?_o.current=[K,te]:S.kind===wd&&!S.isMaybeScrollbar&&(fr(Kf,!1),s(void 0),nr(),dt==null||dt(),Bs.current=void 0,Ol.current=void 0)},[Rl,be,nr,Ce,df,Er,J,Sr,Po,dt,_i,G,jr,Xe,tt,y,ie,fr,me,we,Yt,Za]),tu=w.useRef(!1),_o=w.useRef(),Sw=w.useRef(hn),Ur=w.useRef(),OA=w.useCallback(S=>{if(Pl.current=!1,Sw.current=Qt.current,S.button!==0&&S.button!==1){Ur.current=void 0;return}const L=performance.now();Ur.current={button:S.button,time:L,location:S.location},(S==null?void 0:S.kind)==="header"&&(tu.current=!0);const N=S.kind==="cell"&&S.isFillHandle;!N&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:J,fillHandle:N}),_o.current=void 0,!S.isTouch&&S.button===0&&!N?eu(S):!S.isTouch&&S.button===1&&(_o.current=S.location))},[J,eu]),[Up,Kp]=w.useState(),Cw=w.useCallback(S=>{if(S.kind!==Or||be!=="multi")return;const L=vd.value?S.metaKey:S.ctrlKey,[N]=S.location,U=J.columns;if(N=G&&kc(K.group,ot[ee].group);ee--)te--;for(let ee=N+1;ee{if(xn!==void 0&&ci!==void 0){const L=Qt.current.y,N=Qt.current.height;let U=xn({x:S,y:L,width:1,height:Math.min(N,y-L)},Wn.current.signal);typeof U!="object"&&(U=await U());const K=Et[S-G],q=document.createElement("canvas").getContext("2d",{alpha:!1});if(q!==null){q.font=ce.baseFontFull;const ee=PT(q,ce,K,0,U,kr,ai,!1,Ce);ci==null||ci(K,ee.width,S,ee.width)}}},[Et,xn,ai,ce,kr,ci,G,y,Ce]),[PA,Xp]=w.useState(),Il=w.useCallback(async(S,L)=>{var ee,oe;const N=(ee=S.current)==null?void 0:ee.range;if(N===void 0||xn===void 0||L.current===void 0)return;const U=L.current.range;if(T!==void 0){let re=!1;if(T({fillDestination:{...U,x:U.x-G},patternSource:{...N,x:N.x-G},preventDefault:()=>re=!0}),re)return}let K=xn(N,Wn.current.signal);typeof K!="object"&&(K=await K());const te=K,q=[];for(let re=0;re({cell:re.location})))},[xn,Vr,T,G]),Tw=w.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,width:1}}};Il(S,J)},[Il,J]),Ew=w.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,height:1}}};Il(S,J)},[Il,J]),IA=w.useCallback((S,L)=>{var Se,Ae;const N=a;if(u(void 0),jp(void 0),Xp(void 0),tu.current=!1,L)return;if((N==null?void 0:N.fillHandle)===!0&&J.current!==void 0&&((Se=N.previousSelection)==null?void 0:Se.current)!==void 0){if(Do===void 0)return;const xe={...J,current:{...J.current,range:HT(N.previousSelection.current.range,Do)}};Il(N.previousSelection,xe),fr(xe,!0);return}const[U,K]=S.location,[te,q]=_o.current??[],ee=()=>{Pl.current=!0},oe=xe=>{var je,bt,Ue;const ze=xe.isTouch||te===U&&q===K;if(ze&&(b==null||b([U-G,K],{...xe,preventDefault:ee})),xe.button===1)return!Pl.current;if(!Pl.current){const Fe=Er(S.location),zt=Ce(Fe);if(zt!==void 0&&zt.onClick!==void 0&&ze){const pn=zt.onClick({...xe,cell:Fe,posX:xe.localEventX,posY:xe.localEventY,bounds:xe.bounds,theme:Za(Fe,S.location),preventDefault:ee});pn!==void 0&&!Jl(pn)&&Fl(pn)&&(Vr([{location:xe.location,value:pn}]),(je=hr.current)==null||je.damage([{cell:xe.location}]))}if(Pl.current||J.current===void 0)return!1;let Un=!1;switch(Fe.activationBehaviorOverride??se){case"double-click":case"second-click":{if(((Ue=(bt=N==null?void 0:N.previousSelection)==null?void 0:bt.current)==null?void 0:Ue.cell)===void 0)break;const[pn,di]=J.current.cell,[Fi,pi]=N.previousSelection.current.cell;Un=U===pn&&U===Fi&&K===di&&K===pi&&(xe.isDoubleClick===!0||se==="second-click");break}case"single-click":{Un=!0;break}}if(Un)return C==null||C([U-G,K]),Al(xe.bounds,!1),!0}return!1},re=S.location[0]-G;if(S.isTouch){const xe=Qt.current,ze=Sw.current;if(xe.x!==ze.x||xe.y!==ze.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&Xu((Ae=J.current)==null?void 0:Ae.cell,S.location)){le==null||le([re,S.location[1]],{...S,preventDefault:ee});return}else if(S.kind==="header"&&J.columns.hasIndex(U)){ne==null||ne(re,{...S,preventDefault:ee});return}else if(S.kind===Or){if(re<0)return;M==null||M(re,{...S,preventDefault:ee});return}}S.kind==="cell"?oe(S)||eu(S):S.kind===Or?X==null||X(re,{...S,preventDefault:ee}):(S.kind===Xs&&(D==null||D(re,{...S,preventDefault:ee})),eu(S));return}if(S.kind==="header"){if(re<0)return;S.isEdge?S.isDoubleClick===!0&&pf(U):S.button===0&&U===te&&K===q&&(D==null||D(re,{...S,preventDefault:ee}))}if(S.kind===Or){if(re<0)return;S.button===0&&U===te&&K===q&&(X==null||X(re,{...S,preventDefault:ee}),Pl.current||Cw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&oe(S),_o.current=void 0},[a,J,G,Do,Il,fr,b,Er,Ce,se,Za,Vr,C,Al,le,ne,M,eu,X,D,pf,Cw]),DA=w.useCallback(S=>{const L={...S,location:[S.location[0]-G,S.location[1]]};H==null||H(L),a!==void 0&&S.buttons===0&&(u(void 0),jp(void 0),Xp(void 0),tu.current=!1),Xp(N=>{var U;return tu.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===(N==null?void 0:N[0])&&S.scrollEdge[1]===N[1]?N:a===void 0||(((U=Ur.current)==null?void 0:U.location[0])??0){pe==null||pe(S-G,L)},[pe,G]),Li=(Dw=J==null?void 0:J.current)==null?void 0:Dw.cell,NA=w.useCallback((S,L,N,U,K,te)=>{kt.current=!1;let q=Li;q!==void 0&&(q=[q[0]-G,q[1]]);const ee=ue===0?void 0:{x:0,y:S.y,width:ue,height:S.height},oe=[];ee!==void 0&&oe.push(ee),xt>0&&(oe.push({x:S.x-G,y:y-xt,width:S.width,height:xt}),ue>0&&oe.push({x:0,y:y-xt,width:ue,height:xt}));const re={x:S.x-G,y:S.y,width:S.width,height:Yt&&S.y+S.height>=y?S.height-1:S.height,tx:K,ty:te,extras:{selected:q,freezeRegion:ee,freezeRegions:oe}};Qt.current=re,Tr(re),Qe([L,N,U]),un==null||un(re,re.tx,re.ty,re.extras)},[Li,G,Yt,y,ue,xt,Tr,un]),LA=_l(it,w.useCallback((S,L)=>{it==null||it(S-G,L-G),be!=="none"&&me(St.fromSingleSelection(L),void 0,!0)},[be,it,G,me])),Gp=w.useRef(!1),FA=w.useCallback(S=>{if(S.location[0]===0&&G>0){S.preventDefault();return}_e==null||_e({...S,location:[S.location[0]-G,S.location[1]]}),S.defaultPrevented()||(Gp.current=!0),u(void 0)},[_e,G]),BA=w.useCallback(()=>{Gp.current=!1},[]),qp=w.useRef(),Yp=w.useCallback(S=>{var L,N,U;if(!rE(S,qp.current)&&(qp.current=S,!(((L=Ur==null?void 0:Ur.current)==null?void 0:L.button)!==void 0&&Ur.current.button>=1))){if(S.buttons!==0&&a!==void 0&&((N=Ur.current)==null?void 0:N.location[0])===0&&S.location[0]===0&&G===1&&Xe==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(Ur.current.location[1])&&J.rows.hasIndex(Ur.current.location[1])){const K=Math.min(Ur.current.location[1],S.location[1]),te=Math.max(Ur.current.location[1],S.location[1])+1;we(St.fromSingleSelection([K,te]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&J.current!==void 0&&!Gp.current&&!tu.current&&(Ie==="rect"||Ie==="multi-rect")){const[K,te]=J.current.cell;let[q,ee]=S.location;if(ee<0&&(ee=Qt.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const oe=a.previousSelection.current.range;ee=Math.min(ee,Yt?y-1:y);const re=gz(oe,q,ee,In);jp(re)}else{if(Yt&&te===y)return;if(Yt&&ee===y)if(S.kind===wd)ee--;else return;q=Math.max(q,G);const Se=q-K,Ae=ee-te,xe={x:Se>=0?K:q,y:Ae>=0?te:ee,width:Math.abs(Se)+1,height:Math.abs(Ae)+1};ie({...J.current,range:xe},!0,!1,"drag")}}Ve==null||Ve({...S,location:[S.location[0]-G,S.location[1]]})}},[In,a,G,Xe,J,Ie,Ve,we,Yt,y,ie]),zA=w.useCallback(()=>{var q,ee;const S=qp.current;if(S===void 0)return;const[L,N]=S.scrollEdge;let[U,K]=S.location;const te=Qt.current;L===-1?U=((ee=(q=te.extras)==null?void 0:q.freezeRegion)==null?void 0:ee.x)??te.x:L===1&&(U=te.x+te.width),N===-1?K=Math.max(0,te.y):N===1&&(K=Math.min(y-1,te.y+te.height)),U=bi(U,0,ot.length-1),K=bi(K,0,y-1),Yp({...S,location:[U,K]})},[ot.length,Yp,y]);SW(PA,c,zA);const hi=w.useCallback(S=>{if(J.current===void 0)return;const[L,N]=S,[U,K]=J.current.cell,te=J.current.range;let q=te.x,ee=te.x+te.width,oe=te.y,re=te.y+te.height;if(N!==0)switch(N){case 2:{re=y,oe=K,dn(0,re,"vertical");break}case-2:{oe=0,re=K+1,dn(0,oe,"vertical");break}case 1:{oeK+1?(re--,dn(0,re,"vertical")):(oe=Math.max(0,oe-1),dn(0,oe,"vertical"));break}default:bc()}if(L!==0)if(L===2)ee=ot.length,q=U,dn(ee-1-G,0,"horizontal");else if(L===-2)q=G,ee=U+1,dn(q-G,0,"horizontal");else{let Se=[];if(xn!==void 0){const Ae=xn({x:q,y:oe,width:ee-q-G,height:re-oe},Wn.current.signal);typeof Ae=="object"&&(Se=AW(Ae))}if(L===1){let Ae=!1;if(q0){const xe=Vo(q+1,U+1).find(ze=>!Se.includes(ze-G));xe!==void 0&&(q=xe,Ae=!0)}else q++,Ae=!0;Ae&&dn(q,0,"horizontal")}Ae||(ee=Math.min(ot.length,ee+1),dn(ee-1-G,0,"horizontal"))}else if(L===-1){let Ae=!1;if(ee>U+1){if(Se.length>0){const xe=Vo(ee-1,U,-1).find(ze=>!Se.includes(ze-G));xe!==void 0&&(ee=xe,Ae=!0)}else ee--,Ae=!0;Ae&&dn(ee-G,0,"horizontal")}Ae||(q=Math.max(G,q-1),dn(q-G,0,"horizontal"))}else bc()}ie({cell:J.current.cell,range:{x:q,y:oe,width:ee-q,height:re-oe}},!0,!1,"keyboard-select")},[xn,J,ot.length,G,y,dn,ie]),zs=w.useCallback((S,L,N,U)=>{const K=Vn-(N?0:1);if(S=bi(S,G,Et.length-1+G),L=bi(L,0,K),S===(Li==null?void 0:Li[0])&&L===(Li==null?void 0:Li[1]))return!1;if(U&&J.current!==void 0){const te=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&te.push(J.current.range),fr({...J,current:{cell:[S,L],range:{x:S,y:L,width:1,height:1},rangeStack:te}},!0)}else ie({cell:[S,L],range:{x:S,y:L,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===L&&(f.current=void 0),dn(S-G,L),!0},[Vn,G,Et.length,Li,J,dn,fr,ie]),$A=w.useCallback((S,L)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&Fl(S)&&(Vr([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var K;(K=hr.current)==null||K.damage([{cell:i.cell}])})),nr(!0),s(void 0);const[N,U]=L;if(J.current!==void 0&&(N!==0||U!==0)){const K=J.current.cell[1]===Vn-1&&S!==void 0;zs(bi(J.current.cell[0]+N,0,ot.length-1),bi(J.current.cell[1]+U,0,Vn-1),K,!1)}E==null||E(S,L)},[i==null?void 0:i.cell,nr,J,E,Vr,Vn,zs,ot.length]),HA=w.useMemo(()=>`gdg-overlay-${MW++}`,[]),No=w.useCallback(S=>{var N,U,K,te;nr();const L=[];for(let q=S.x;q({cell:q.location})))},[nr,k,Ce,Vr,G]),nu=i!==void 0,Mw=w.useCallback(S=>{var ze,je;const L=()=>{S.stopPropagation(),S.preventDefault()},N={didMatch:!1},{bounds:U}=S,K=J.columns,te=J.rows,q=ui;if(!nu&&at(q.clear,S,N))fr(Kf,!1),dt==null||dt();else if(!nu&&at(q.selectAll,S,N))fr({columns:St.empty(),rows:St.empty(),current:{cell:((ze=J.current)==null?void 0:ze.cell)??[G,0],range:{x:G,y:0,width:g.length,height:y},rangeStack:[]}},!1);else if(at(q.search,S,N))(je=o==null?void 0:o.current)==null||je.focus({preventScroll:!0}),lf(!0);else if(at(q.delete,S,N)){const bt=($==null?void 0:$(J))??!0;if(bt!==!1){const Ue=bt===!0?J:bt;if(Ue.current!==void 0){No(Ue.current.range);for(const Fe of Ue.current.rangeStack)No(Fe)}for(const Fe of Ue.rows)No({x:G,y:Fe,width:g.length,height:1});for(const Fe of Ue.columns)No({x:Fe,y:0,width:1,height:y})}}if(N.didMatch)return L(),!0;if(J.current===void 0)return!1;let[ee,oe]=J.current.cell,re=!1,Se=!1;at(q.scrollToSelectedCell,S,N)?yf.current(ee-G,oe):be!=="none"&&at(q.selectColumn,S,N)?K.hasIndex(ee)?me(K.remove(ee),void 0,!0):be==="single"?me(St.fromSingleSelection(ee),void 0,!0):me(void 0,ee,!0):Xe!=="none"&&at(q.selectRow,S,N)?te.hasIndex(oe)?we(te.remove(oe),void 0,!0):Xe==="single"?we(St.fromSingleSelection(oe),void 0,!0):we(void 0,oe,!0):!nu&&U!==void 0&&at(q.activateCell,S,N)?oe===y&&Yt?window.setTimeout(()=>{const bt=df(ee);Rl(bt??ee)},0):(C==null||C([ee-G,oe]),Al(U,!0)):J.current.range.height>1&&at(q.downFill,S,N)?Ew():J.current.range.width>1&&at(q.rightFill,S,N)?Tw():at(q.goToNextPage,S,N)?oe+=Math.max(1,Qt.current.height-4):at(q.goToPreviousPage,S,N)?oe-=Math.max(1,Qt.current.height-4):at(q.goToFirstCell,S,N)?(s(void 0),oe=0,ee=0):at(q.goToLastCell,S,N)?(s(void 0),oe=Number.MAX_SAFE_INTEGER,ee=Number.MAX_SAFE_INTEGER):at(q.selectToFirstCell,S,N)?(s(void 0),hi([-2,-2])):at(q.selectToLastCell,S,N)?(s(void 0),hi([2,2])):nu?(at(q.closeOverlay,S,N)&&s(void 0),at(q.acceptOverlayDown,S,N)&&(s(void 0),oe++),at(q.acceptOverlayUp,S,N)&&(s(void 0),oe--),at(q.acceptOverlayLeft,S,N)&&(s(void 0),ee--),at(q.acceptOverlayRight,S,N)&&(s(void 0),ee++)):(at(q.goDownCell,S,N)?oe+=1:at(q.goUpCell,S,N)?oe-=1:at(q.goRightCell,S,N)?ee+=1:at(q.goLeftCell,S,N)?ee-=1:at(q.goDownCellRetainSelection,S,N)?(oe+=1,re=!0):at(q.goUpCellRetainSelection,S,N)?(oe-=1,re=!0):at(q.goRightCellRetainSelection,S,N)?(ee+=1,re=!0):at(q.goLeftCellRetainSelection,S,N)?(ee-=1,re=!0):at(q.goToLastRow,S,N)?oe=y-1:at(q.goToFirstRow,S,N)?oe=Number.MIN_SAFE_INTEGER:at(q.goToLastColumn,S,N)?ee=Number.MAX_SAFE_INTEGER:at(q.goToFirstColumn,S,N)?ee=Number.MIN_SAFE_INTEGER:(Ie==="rect"||Ie==="multi-rect")&&(at(q.selectGrowDown,S,N)?hi([0,1]):at(q.selectGrowUp,S,N)?hi([0,-1]):at(q.selectGrowRight,S,N)?hi([1,0]):at(q.selectGrowLeft,S,N)?hi([-1,0]):at(q.selectToLastRow,S,N)?hi([0,2]):at(q.selectToFirstRow,S,N)?hi([0,-2]):at(q.selectToLastColumn,S,N)?hi([2,0]):at(q.selectToFirstColumn,S,N)&&hi([-2,0])),Se=N.didMatch);const Ae=zs(ee,oe,!1,re),xe=N.didMatch;return xe&&(Ae||!Se||ef)&&L(),xe},[nu,J,ui,be,Xe,Ie,G,y,zs,fr,dt,g.length,$,ef,No,me,we,Yt,df,Rl,C,Al,Ew,Tw,hi]),ru=w.useCallback(S=>{let L=!1;if(Re!==void 0&&Re({...S,cancel:()=>{L=!0}}),L||Mw(S)||J.current===void 0)return;const[N,U]=J.current.cell,K=Qt.current;if(Ge&&!S.metaKey&&!S.ctrlKey&&J.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Ou(k([N-G,Math.max(0,Math.min(U,y-1))]))){if((!Yt||U!==y)&&(K.y>U||U>K.y+K.height||K.x>N||N>K.x+K.width))return;Al(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[Ge,Re,Mw,J,k,G,y,Yt,Al]),jA=w.useCallback((S,L)=>{const N=S.location[0]-G;if(S.kind==="header"&&(ne==null||ne(N,{...S,preventDefault:L})),S.kind===Or){if(N<0)return;M==null||M(N,{...S,preventDefault:L})}if(S.kind==="cell"){const[U,K]=S.location;le==null||le([N,K],{...S,preventDefault:L}),f4(J,S.location)||zs(U,K,!1,!1)}},[J,le,M,ne,G,zs]),Qp=w.useCallback(async S=>{var q,ee,oe;if(!ui.paste)return;function L(re,Se,Ae,xe){var je,bt;const ze=typeof Ae=="object"?(Ae==null?void 0:Ae.join(` +`))??"":(Ae==null?void 0:Ae.toString())??"";if(!Jl(re)&&Ou(re)&&re.readonly!==!0){const Ue=A==null?void 0:A(ze,re);if(Ue!==void 0&&Fl(Ue))return{location:Se,value:Ue};const Fe=Ce(re);if(Fe===void 0)return;if(Fe.kind===ke.Custom){Pr(re.kind===ke.Custom);const zt=(je=Fe.onPaste)==null?void 0:je.call(Fe,ze,re.data);return zt===void 0?void 0:{location:Se,value:{...re,data:zt}}}else{const zt=(bt=Fe.onPaste)==null?void 0:bt.call(Fe,ze,re,{formatted:xe,formattedString:typeof xe=="string"?xe:xe==null?void 0:xe.join(` +`),rawValue:Ae});return zt===void 0?void 0:(Pr(zt.kind===re.kind),{location:Se,value:zt})}}}const N=J.columns,U=J.rows,K=((q=c.current)==null?void 0:q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0;let te;if(J.current!==void 0?te=[J.current.range.x,J.current.range.y]:N.length===1?te=[N.first()??0,0]:U.length===1&&(te=[G,U.first()??0]),K&&te!==void 0){let re,Se;const Ae="text/plain",xe="text/html";if(navigator.clipboard.read!==void 0){const Ue=await navigator.clipboard.read();for(const Fe of Ue){if(Fe.types.includes(xe)){const Un=await(await Fe.getType(xe)).text(),pn=yb(Un);if(pn!==void 0){re=pn;break}}Fe.types.includes(Ae)&&(Se=await(await Fe.getType(Ae)).text())}}else if(navigator.clipboard.readText!==void 0)Se=await navigator.clipboard.readText();else if(S!==void 0&&(S==null?void 0:S.clipboardData)!==null){if(S.clipboardData.types.includes(xe)){const Ue=S.clipboardData.getData(xe);re=yb(Ue)}re===void 0&&S.clipboardData.types.includes(Ae)&&(Se=S.clipboardData.getData(Ae))}else return;const[ze,je]=te,bt=[];do{if(V===void 0){const Ue=Er(te),Fe=Se??(re==null?void 0:re.map(Un=>Un.map(pn=>pn.rawValue).join(" ")).join(" "))??"",zt=L(Ue,te,Fe,void 0);zt!==void 0&&bt.push(zt);break}if(re===void 0){if(Se===void 0)return;re=mW(Se)}if(V===!1||typeof V=="function"&&(V==null?void 0:V([te[0]-G,te[1]],re.map(Ue=>Ue.map(Fe=>{var zt;return((zt=Fe.rawValue)==null?void 0:zt.toString())??""}))))!==!0)return;for(const[Ue,Fe]of re.entries()){if(Ue+je>=y)break;for(const[zt,Un]of Fe.entries()){const pn=[zt+ze,Ue+je],[di,Fi]=pn;if(di>=ot.length||Fi>=Vn)continue;const pi=Er(pn),Bi=L(pi,pn,Un.rawValue,Un.formatted);Bi!==void 0&&bt.push(Bi)}}}while(!1);Vr(bt),(oe=hr.current)==null||oe.damage(bt.map(Ue=>({cell:Ue.location})))}},[A,Ce,Er,J,ui.paste,ot.length,Vr,Vn,V,G,y]);Fn("paste",Qp,h,!1,!0);const iu=w.useCallback(async(S,L)=>{var q,ee;if(!ui.copy)return;const N=L===!0||((q=c.current)==null?void 0:q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0,U=J.columns,K=J.rows,te=(oe,re)=>{if(!Z)wb(oe,re,S);else{const Se=re.map(Ae=>({kind:ke.Text,data:g[Ae].title,displayData:g[Ae].title,allowOverlay:!1}));wb([Se,...oe],re,S)}};if(N&&xn!==void 0){if(J.current!==void 0){let oe=xn(J.current.range,Wn.current.signal);typeof oe!="object"&&(oe=await oe()),te(oe,Vo(J.current.range.x-G,J.current.range.x+J.current.range.width-G))}else if(K!==void 0&&K.length>0){const re=[...K].map(Se=>{const Ae=xn({x:G,y:Se,width:g.length,height:1},Wn.current.signal);return typeof Ae=="object"?Ae[0]:Ae().then(xe=>xe[0])});if(re.some(Se=>Se instanceof Promise)){const Se=await Promise.all(re);te(Se,Vo(g.length))}else te(re,Vo(g.length))}else if(U.length>0){const oe=[],re=[];for(const Se of U){let Ae=xn({x:Se,y:0,width:1,height:y},Wn.current.signal);typeof Ae!="object"&&(Ae=await Ae()),oe.push(Ae),re.push(Se-G)}if(oe.length===1)te(oe[0],re);else{const Se=oe.reduce((Ae,xe)=>Ae.map((ze,je)=>[...ze,...xe[je]]));te(Se,re)}}}},[g,xn,J,ui.copy,G,y,Z]);Fn("copy",iu,h,!1,!1);const WA=w.useCallback(async S=>{var N,U;if(!(!ui.cut||!(((N=c.current)==null?void 0:N.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await iu(S),J.current!==void 0)){let K={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:St.empty(),columns:St.empty()};const te=$==null?void 0:$(K);if(te===!1||(K=te===!0?K:te,K.current===void 0))return;No(K.current.range)}},[No,J,ui.cut,iu,$]);Fn("cut",WA,h,!1,!1);const VA=w.useCallback((S,L)=>{if(B!==void 0){G!==0&&(S=S.map(K=>[K[0]-G,K[1]])),B(S,L);return}if(S.length===0||L===-1)return;const[N,U]=S[L];f.current!==void 0&&f.current[0]===N&&f.current[1]===U||(f.current=[N,U],zs(N,U,!1,!1))},[B,G,zs]),[gf,mf]=((_w=ct==null?void 0:ct.current)==null?void 0:_w.cell)??[],yf=w.useRef(dn);yf.current=dn,w.useLayoutEffect(()=>{var S,L,N,U;!kt.current&&gf!==void 0&&mf!==void 0&&(gf!==((L=(S=Fs.current)==null?void 0:S.current)==null?void 0:L.cell[0])||mf!==((U=(N=Fs.current)==null?void 0:N.current)==null?void 0:U.cell[1]))&&yf.current(gf,mf),kt.current=!1},[gf,mf]);const Aw=J.current!==void 0&&(J.current.cell[0]>=ot.length||J.current.cell[1]>=Vn);w.useLayoutEffect(()=>{Aw&&fr(Kf,!1)},[Aw,fr]);const UA=w.useMemo(()=>Yt===!0&&(pt==null?void 0:pt.tint)===!0?St.fromSingleSelection(Vn-1):St.empty(),[Vn,Yt,pt==null?void 0:pt.tint]),KA=w.useCallback(S=>typeof Rn=="boolean"?Rn:(Rn==null?void 0:Rn(S-G))??!0,[G,Rn]),XA=w.useMemo(()=>{if(Up===void 0||l.current===null)return null;const{bounds:S,group:L}=Up,N=l.current.getBoundingClientRect();return w.createElement(sW,{bounds:S,group:L,canvasBounds:N,onClose:()=>Kp(void 0),onFinish:U=>{Kp(void 0),F==null||F(L,U)}})},[F,Up]),GA=Math.min(ot.length,ue+(Sr?1:0));w.useImperativeHandle(e,()=>({appendRow:(S,L)=>Rl(S+G,L),updateCells:S=>{var L;return G!==0&&(S=S.map(N=>({cell:[N.cell[0]+G,N.cell[1]]}))),(L=hr.current)==null?void 0:L.damage(S)},getBounds:(S,L)=>{var N;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(S===void 0&&L===void 0){const U=l.current.getBoundingClientRect(),K=U.width/c.current.clientWidth;return{x:U.x-c.current.scrollLeft*K,y:U.y-c.current.scrollTop*K,width:c.current.scrollWidth*K,height:c.current.scrollHeight*K}}return(N=hr.current)==null?void 0:N.getBounds((S??0)+G,L)}},focus:()=>{var S;return(S=hr.current)==null?void 0:S.focus()},emit:async S=>{switch(S){case"delete":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await iu(void 0,!0);break;case"paste":await Qp();break}},scrollTo:dn,remeasureColumns:S=>{for(const L of S)pf(L+G)}}),[Rl,pf,iu,ru,Qp,G,dn]);const[Rw,Ow]=Li??[],qA=w.useCallback(S=>{const[L,N]=S;if(N===-1){be!=="none"&&(me(St.fromSingleSelection(L),void 0,!1),nr());return}Rw===L&&Ow===N||(ie({cell:S,range:{x:L,y:N,width:1,height:1}},!0,!1,"keyboard-nav"),dn(L,N))},[be,nr,dn,Rw,Ow,ie,me]),[YA,QA]=w.useState(!1),Pw=w.useRef(aT(S=>{QA(S)},5)),JA=w.useCallback(()=>{Pw.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&ie({cell:[G,af],range:{x:G,y:af,width:1,height:1}},!0,!1,"keyboard-select")},[af,J,a,G,ie]),ZA=w.useCallback(()=>{Pw.current(!1)},[]),[eR,tR]=w.useMemo(()=>{let S;const L=(qt==null?void 0:qt.scrollbarWidthOverride)??v0(),N=y+(Yt?1:0);if(typeof tr=="number")S=st+N*tr;else{let K=0;const te=Math.min(N,10);for(let q=0;qte.width+K,0)+L;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,S)}px`]},[ot,qt==null?void 0:qt.scrollbarWidthOverride,tr,y,Yt,st]),nR=w.useMemo(()=>E4(ce),[ce]);return w.createElement(M4.Provider,{value:ce},w.createElement(xW,{style:nR,className:j,inWidth:x??eR,inHeight:v??tR},w.createElement(tW,{fillHandle:Wt,drawFocusRing:kn,experimental:qt,fixedShadowX:Qc,fixedShadowY:Ds,getRowThemeOverride:p,headerIcons:us,imageWindowLoader:cs,initialSize:ml,isDraggable:Jc,onDragLeave:Zc,onRowMoved:_i,overscrollX:Lp,overscrollY:of,preventDiagonalScrolling:wl,rightElement:Oo,rightElementProps:_s,smoothScrollX:tf,smoothScrollY:Ip,className:j,enableGroups:At,onCanvasFocused:JA,onCanvasBlur:ZA,canvasRef:l,onContextMenu:jA,theme:ce,cellXOffset:Io,cellYOffset:af,accessibilityHeight:hn.height,onDragEnd:BA,columns:ot,nonGrowWidth:Ne,drawHeader:$p,onColumnProposeMove:I,drawCell:Hp,disabledRows:UA,freezeColumns:GA,lockColumns:G,firstColAccessible:G===0,getCellContent:Er,minColumnWidth:kr,maxColumnWidth:ai,searchInputRef:o,showSearch:Qa,onSearchClose:Bp,highlightRegions:RA,getCellsForSelection:xn,getGroupDetails:Wp,headerHeight:Sl,isFocused:YA,groupHeaderHeight:At?Ya:0,freezeTrailingRows:xt+(Yt&&(pt==null?void 0:pt.sticky)===!0?1:0),hasAppendRow:Yt,onColumnResize:ci,onColumnResizeEnd:zp,onColumnResizeStart:Tl,onCellFocused:qA,onColumnMoved:LA,onDragStart:FA,onHeaderMenuClick:_A,onItemHovered:Yp,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:DA,onKeyDown:ru,onKeyUp:nt,onMouseDown:OA,onMouseUp:IA,onDragOverCell:li,onDrop:vt,onSearchResultsChanged:VA,onVisibleRegionChanged:NA,clientSize:Ee,rowHeight:tr,searchResults:de,searchValue:ae,onSearchValueChange:ge,rows:Vn,scrollRef:c,selection:J,translateX:hn.tx,translateY:hn.ty,verticalBorder:KA,gridRef:hr,getCellRenderer:Ce}),XA,i!==void 0&&w.createElement(w.Suspense,{fallback:null},w.createElement(EW,{...i,validateCell:Ja,bloom:O,id:HA,getCellRenderer:Ce,className:(qt==null?void 0:qt.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:jt,imageEditorOverride:d,onFinishEditing:$A,markdownDivCreateNode:m,isOutsideClick:nf}))))},OW=w.forwardRef(RW),kb=20,PW={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:ke.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>IW(t,t.cell.data,d0(t.cell),t.cell.maxSize??kb),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??kb,f=Math.floor(i.y+l/2),h=fT(c,l,s.cellVerticalPadding),d=cT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,h),p=uT(d,f,h),m=hT(a+n,u+r,p);if(d0(e)&&m)return{...e,data:sE(e.data)}},onPaste:(t,e)=>{let n=od;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Rv),n===e.data?void 0:{...e,data:n}}};function IW(t,e,n,r){if(!n&&e===od)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:h,y:d,width:p,height:m}=l,x=.35;let v=n?1-x+x*s:.4;e===od&&(v*=s),v!==0&&(i.globalAlpha=v,Wv(i,o,e,h,d,p,m,a,u,c,r,f),i.globalAlpha=1)}const DW=zr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),_W=t=>{const{bubbles:e}=t;return w.createElement(DW,null,e.map((n,r)=>w.createElement("div",{key:r,className:"boe-bubble"},n)),w.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},NW={getAccessibilityString:t=>dT(t.data),kind:ke.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>FW(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return w.createElement(_W,{bubbles:e.data})},onPaste:()=>{}},LW=4;function FW(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,h=LW;let d=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(d>o+a)break;const x=Uc(m,i,r.baseFontFull).width;p.push({x:d,width:x}),d+=x+f*2+h}i.beginPath();for(const m of p)rs(i,m.x,l+(u-c)/2,m.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[m,x]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[m],x.x+f,l+u/2+Is(i,r))}const BW=zr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),zW=t=>{const{drilldowns:e}=t;return w.createElement(BW,null,e.map((n,r)=>w.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&w.createElement("img",{src:n.img}),w.createElement("div",null,n.text))))},$W={getAccessibilityString:t=>dT(t.data.map(e=>e.text)),kind:ke.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>WW(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return w.createElement(zW,{drilldowns:e.data})},onPaste:()=>{}},HW=4,Vg={};function jW(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,h=`${t},${e},${i},${n}`;if(Vg[h]!==void 0)return{el:Vg[h],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const d=document.createElement("canvas"),p=d.getContext("2d");return p===null?null:(d.width=f,d.height=a,p.scale(i,i),Vg[h]=d,p.beginPath(),rs(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),rs(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:d,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function WW(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=ET(i,c),h=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),d=Math.floor(n.y+(n.height-h)/2),p=h-10,m=8,x=HW;let v=a+r.cellHorizontalPadding;const g=r.roundingRadius??6,y=jW(r.bgCell,r.drilldownBorder,h,g),k=[];for(const b of e){if(v>a+u)break;const T=Uc(b.text,i,c).width;let E=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(E=p-8+4);const A=T+E+m*2;k.push({x:v,width:A}),v+=A+x}if(y!==null){const{el:b,height:C,middleWidth:T,sideWidth:E,width:A,dpr:P,padding:_}=y,O=E/P,D=_/P;for(const I of k){const Q=Math.floor(I.x),X=Math.floor(I.width),le=X-(O-D)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,E,C,Q-D,d,O,h),le>0&&i.drawImage(b,E,0,T,C,Q+(O-D),d,le,h),i.drawImage(b,A-E,0,E,C,Q+X-(O-D),d,O,h),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,C]of k.entries()){const T=e[b];let E=C.x+m;if(T.img!==void 0){const A=s.loadOrGetImage(T.img,o,l);if(A!==void 0){const P=p-8;let _=0,O=0,D=A.width,I=A.height;D>I?(_+=(D-I)/2,D=I):I>D&&(O+=(I-D)/2,I=D),i.beginPath(),rs(i,E,d+h/2-P/2,P,P,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(A,_,O,D,I,E,d+h/2-P/2,P,P),i.restore(),E+=P+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,E,d+h/2+Is(i,r))}}const VW={getAccessibilityString:t=>t.data.join(", "),kind:ke.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>UW(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??NF;return w.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},Ug=4;function UW(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:h,width:d}=i,p=h-l.cellVerticalPadding*2,m=[];let x=0;for(let g=0;g0&&(a.beginPath(),rs(a,v,f+l.cellVerticalPadding,y,p,n),a.save(),a.clip()),a.drawImage(g,v,f+l.cellVerticalPadding,y,p),n>0&&a.restore(),v+=y+Ug}}function KW(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const XW={getAccessibilityString:()=>"",kind:ke.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(KW(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);rs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=sl(o.textDark,.1),i.fill()},onPaste:()=>{}},GW=()=>t=>t.targetWidth,Sb=zr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[GW(),"px"]}}),qW=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=w.useState(a===""||r),h=w.useCallback(()=>{f(p=>!p)},[]),d=a?"gdg-ml-6":"";return c?w.createElement(Sb,{targetWidth:s.width-20},w.createElement(gp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),w.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${d}`,onClick:()=>o(e)},w.createElement(AF,null))):w.createElement(Sb,{targetWidth:s.width},w.createElement(e4,{contents:a,createNode:i}),!u&&w.createElement(w.Fragment,null,w.createElement("div",{className:"spacer"}),w.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${d}`,onClick:h},w.createElement(_v,null))),w.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},YW={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:Kc,measure:(t,e,n)=>{const r=e.data.split(` +`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>ws(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return w.createElement(qW,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},QW={getAccessibilityString:t=>t.row.toString(),kind:Yr.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:JW,measure:()=>44,draw:t=>e6(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function JW(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=ZW,n.textAlign="center",s}function ZW(t){const{ctx:e}=t;e.textAlign="start"}function e6(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:h,height:d}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(Wv(o,u,n,i?c+m:c,f,i?h-m:h,d,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const v of[-5,-1,3])o.rect(c+x,f+d/2+v,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,v=c+h/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,v,f+d/2+Is(o,x)),a!==0&&(o.globalAlpha=1)}}const t6={getAccessibilityString:()=>"",kind:Yr.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>n6(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function n6(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const h=e!=="";let d=0;if(n!==void 0){const m=f-8,x=a+8/2,v=u+8/2;l.drawSprite(n,"normal",r,x,v,m,o,h?1:s),d=m}else{d=24;const p=12,m=h?p:s*p,x=h?0:(1-s)*p*.5,v=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+v+x,u+f/2),r.lineTo(a+v+x+m,u+f/2),r.moveTo(a+v+x+m*.5,u+f/2-m*.5),r.lineTo(a+v+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,d+a+o.cellHorizontalPadding+.5,u+f/2+Is(r,o)),r.beginPath()}const r6=w.lazy(async()=>await IT(()=>import("./number-overlay-editor-BQY5aYke.js"),[])),i6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:Kc,draw:t=>ws(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return w.createElement(w.Suspense,{fallback:null},w.createElement(r6,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},s6={getAccessibilityString:()=>"",measure:()=>108,kind:ke.Protected,needsHover:!1,needsHoverPosition:!1,draw:o6,onPaste:()=>{}};function o6(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Cx(30))*l,f=Math.sin(Cx(30))*l;for(let h=0;h<12;h++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const l6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>Kc(t,e,t.theme.textLight),draw:t=>ws(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Tn.createElement(gp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},a6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Kc,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const h=o.cellHorizontalPadding,d=o.cellVerticalPadding,p=Uc(a,i,o.baseFontFull,"alphabetic"),m=s.height-d,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),rs(i,s.x+h/2,s.y+(s.height-x)/2+1,p.width+h*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=sl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}ws(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` +`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return w.createElement(gp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},u6=zr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),c6=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=w.useState(!i&&(e===""||r)),u=w.useCallback(()=>{a(!0)},[]);return l?w.createElement(gp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):w.createElement(u6,null,w.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&w.createElement("div",{className:"gdg-edit-icon",onClick:u},w.createElement(_v,null)),w.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Cb(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const f6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:Kc,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=Uc(a,l,n.baseFontFull),f=Cb(c,o,n,e.contentAlign),{x:h,y:d,width:p,height:m}=f;if(i>=h-4&&i<=h-4+p+8&&s>=d-4&&s<=d-4+m+8){const x=Is(l,n.baseFontFull);r("pointer");const v=5,g=d-x;l.beginPath(),l.moveTo(o.x+h,Math.floor(o.y+g+m+v)+.5),l.lineTo(o.x+h+p,Math.floor(o.y+g+m+v)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,ws({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,ws(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=v4(o,s.baseFontFull);if(l===void 0)return;const a=Cb(l,n,s,e.contentAlign);yp({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return w.createElement(c6,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},h6=[QW,t6,PW,NW,$W,VW,XW,YW,i6,s6,l6,a6,f6];var d6=lT,p6=hl,g6="Expected a function";function m6(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(g6);return p6(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),d6(t,e,{leading:r,maxWait:e,trailing:i})}var y6=m6;const v6=Pi(y6),Kg=[];class w6 extends AT{constructor(){super(...arguments);ft(this,"imageLoaded",()=>{});ft(this,"loadedLocations",[]);ft(this,"cache",{});ft(this,"sendLoaded",v6(()=>{this.imageLoaded(new qu(this.loadedLocations)),this.loadedLocations=[]},20));ft(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,Kg.length<12?Kg.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const h of f.cells)this.loadedLocations.push($v(h));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=ki(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const Xg="\uFEFF";function x6(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function b6(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;s=r.length)break;if(r[g]===s){c=g+1,f=!0;continue}c=r[g]==="\r"&&r[g+1]===` -`?g+2:g+1,o.push(a),l.push({start:u+i,end:g+i}),a=[]}a.length>0?(o.push(a),l.push({start:u+i,end:r.length+i})):o.length===0&&a.length===0&&r.length>0&&(o.push([""]),l.push({start:0+i,end:r.length+i}));const h=o.length>0?o[0]:[],d=h.length,p=o.slice(1),m=p.map(v=>v.length),x=p.map(v=>v.length===d?v:v.length>d?v.slice(0,d):[...v,...Array(d-v.length).fill("")]);return{headers:h,rows:x,delimiter:s,rowWidths:m,rowSpans:l.slice(1)}}function rE(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` -`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function Kg(t,e,n=","){return[t,...e].map(r=>rE(r,n)).join(` -`)}function x6(t,e){return mp(t,e).headers}function b6(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}const Sb=/^[+-]?\d{16,}$/;function k6(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const h=a===""?NaN:Number(a),d=u===""?NaN:Number(u),p=Number.isNaN(h),m=Number.isNaN(d);if(p||m)return p&&m?0:p?1:-1;if(Sb.test(a)&&Sb.test(u)){const x=BigInt(a),v=BigInt(u);return s*(xv?1:0)}return s*(h-d)}return s*a.localeCompare(u)})}const C6=` +`&&t[r]!=="\r";)r++;return[t.slice(e,r),r]}function vp(t,e){const n=t.startsWith(Xg),r=n?t.slice(Xg.length):t,i=n?Xg.length:0,s=e??x6(r),o=[],l=[];let a=[],u=0,c=0,f=!1;for(;c=r.length)break;if(r[g]===s){c=g+1,f=!0;continue}c=r[g]==="\r"&&r[g+1]===` +`?g+2:g+1,o.push(a),l.push({start:u+i,end:g+i}),a=[]}a.length>0?(o.push(a),l.push({start:u+i,end:r.length+i})):o.length===0&&a.length===0&&r.length>0&&(o.push([""]),l.push({start:0+i,end:r.length+i}));const h=o.length>0?o[0]:[],d=h.length,p=o.slice(1),m=p.map(v=>v.length),x=p.map(v=>v.length===d?v:v.length>d?v.slice(0,d):[...v,...Array(d-v.length).fill("")]);return{headers:h,rows:x,delimiter:s,rowWidths:m,rowSpans:l.slice(1)}}function oE(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` +`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function Yu(t,e,n=","){return[t,...e].map(r=>oE(r,n)).join(` +`)}function k6(t,e){return vp(t,e).headers}function S6(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function Gg(t,e){const n=new Set(e),r=t.rows.filter((i,s)=>!n.has(s));return Yu(t.headers,r,t.delimiter)}function Tb(t,e){const n=new Set(e),r=t.headers.filter((s,o)=>!n.has(o)),i=t.rows.map(s=>s.filter((o,l)=>!n.has(l)));return Yu(r,i,t.delimiter)}const Eb=/^[+-]?\d{16,}$/;function C6(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const h=a===""?NaN:Number(a),d=u===""?NaN:Number(u),p=Number.isNaN(h),m=Number.isNaN(d);if(p||m)return p&&m?0:p?1:-1;if(Eb.test(a)&&Eb.test(u)){const x=BigInt(a),v=BigInt(u);return s*(xv?1:0)}return s*(h-d)}return s*a.localeCompare(u)})}const E6=` -`;function Uf(t,e){return Math.max(0,Math.min(t,e))}function Cb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Uf(a.x,r+i),c=Uf(a.x+a.width,r+i);if(c<=r)continue;const f=u-r,h=c-r;if(h<=f)continue;const d=Uf(a.y,e.length),p=Uf(a.y+a.height,e.length);if(p<=d)continue;const m=t.headers.slice(f,h),x=[];for(let v=d;vy[f+b]??""))}x.length!==0&&s.push(Kg(m,x,t.delimiter))}if(s.length>0)return s.join(C6);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return Kg(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(h=>f[h-r]??"")});return Kg(a,u,t.delimiter)}return null}const Tb=24,Eb=26,Mb=110,Ab=40,T6=12,Wr=1,Rb='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',Ob='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',Xg="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50";function E6(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Ob,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Ob,lineHeight:1}}function M6(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function iE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i}){const s=w.useRef(null),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(""),[c,f]=w.useState(""),[h,d]=w.useState(null),[p,m]=w.useState(void 0),[x,v]=w.useState(()=>new Set),g=w.useRef(x),[y,k]=w.useState(0),b=i!==void 0,C=w.useMemo(()=>E6(r),[r]),T=M6(r),E=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",A=w.useRef();A.current===void 0&&(A.current=new y6);const P=w.useMemo(()=>mp(t,e),[t,e]),D=w.useMemo(()=>b6(P),[P]),O=P.headers.length,_=w.useRef({text:t,table:P});_.current={text:t,table:P};const I=w.useRef(p);I.current=p,w.useEffect(()=>{const Q=window.setTimeout(()=>f(a),150);return()=>window.clearTimeout(Q)},[a]);const Y=w.useMemo(()=>{const Q=k6(P.rows,c);return h?S6(Q,P.rows,h.col,h.dir,D[h.col]??!1):Q},[P,c,h,D]),U=w.useRef(Y);U.current=Y,w.useEffect(()=>{const Q=o.current;if(!Q||typeof ResizeObserver>"u")return;const ce=new ResizeObserver(()=>k(Q.clientWidth));return ce.observe(Q),k(Q.clientWidth),()=>ce.disconnect()},[]);const ae=Math.max(Mb,Math.floor((y-Ab)/Math.max(1,O)));w.useEffect(()=>{v(Q=>{let ce=!1;const ne=new Set;for(const oe of Q)oe{m(Q=>{if(!Q||Q.rows.length===0)return Q;const ce=[];for(const oe of g.current){const q=Y.indexOf(oe);q!==-1&&ce.push(q)}ce.sort((oe,q)=>oe-q);const ne=ce.reduce((oe,q)=>oe.add(q),wt.empty());return ne.equals(Q.rows)?Q:{...Q,rows:ne}})},[Y]);const H=c!=="",te=P.rows.length,G=Eb+Math.min(Y.length,T6)*Tb,M=()=>{u(""),f("")},F=w.useCallback(Q=>{if(Q!ne||ne.col!==ce?{col:ce,dir:"asc"}:ne.dir==="asc"?{col:ce,dir:"desc"}:null)},[]),z=w.useCallback((Q,ce)=>{const ne=U.current,oe=ne[ce];if(oe===void 0)return;const q=g.current,ve=l.current;let pe;if(Q.shiftKey&&ve!==null&&ve!==oe){const ke=ne.indexOf(ve),Ne=ne.indexOf(oe),De=ke===-1?Ne:ke,[Lt,tt]=De<=Ne?[De,Ne]:[Ne,De];pe=Q.metaKey||Q.ctrlKey?new Set(q):new Set;for(let ze=Lt;ze<=tt;ze++){const rt=ne[ze];rt!==void 0&&pe.add(rt)}}else Q.metaKey||Q.ctrlKey?(pe=new Set(q),pe.has(oe)?pe.delete(oe):pe.add(oe)):pe=new Set([oe]);l.current=oe,g.current=pe,v(pe);const se=[...pe].map(ke=>ne.indexOf(ke)).filter(ke=>ke!==-1).sort((ke,Ne)=>ke-Ne);m(ke=>({current:ke==null?void 0:ke.current,columns:(ke==null?void 0:ke.columns)??wt.empty(),rows:se.reduce((Ne,De)=>Ne.add(De),wt.empty())}))},[]),j=()=>{l.current=null,g.current=new Set,v(new Set),m(void 0)},B=w.useCallback(Q=>{const ce=new Set;for(const ne of Q.rows){const oe=U.current[ne];oe!==void 0&&ce.add(oe)}g.current=ce,v(ce),m(Q)},[]),ge=w.useCallback(()=>{j()},[]),we=w.useMemo(()=>Y.filter(Q=>x.has(Q)),[Y,x]),ue=(p==null?void 0:p.columns.length)??0,_e=we.length>0||ue>0,Je=()=>{var ne;const Q=I.current,ce=Cb(_.current.table,U.current,{ranges:Q!=null&&Q.current?[Q.current.range,...Q.current.rangeStack]:[],columns:Q?[...Q.columns]:[],rows:Q?[...Q.rows]:[]},Wr);ce!==null&&((ne=navigator.clipboard)==null||ne.writeText(ce).catch(()=>{}))};w.useEffect(()=>{const Q=ce=>{var pe;const ne=s.current;if(!ne||!ne.contains(document.activeElement))return;const oe=document.activeElement;if(oe&&(oe.tagName==="INPUT"||oe.tagName==="TEXTAREA"||oe.isContentEditable))return;const q=I.current,ve=Cb(_.current.table,U.current,{ranges:q!=null&&q.current?[q.current.range,...q.current.rangeStack]:[],columns:q?[...q.columns]:[],rows:q?[...q.rows]:[]},Wr);ve!==null&&(ce.preventDefault(),ce.stopImmediatePropagation(),(pe=ce.clipboardData)==null||pe.setData("text/plain",ve))};return window.addEventListener("copy",Q,{capture:!0}),()=>window.removeEventListener("copy",Q,{capture:!0})},[]);const qe=w.useCallback(Q=>{const ce=i;if(!ce)return!1;const{text:ne,table:oe}=_.current,q=U.current,ve=[...Q].sort((ke,Ne)=>ke.location[1]-Ne.location[1]);let pe=ne,se=0;for(const{location:ke,value:Ne}of ve){const De=ke[0]-Wr,Lt=ke[1];if(De<0||Ne.kind!==Se.Text)continue;const tt=q[Lt],ze=tt===void 0?void 0:oe.rowSpans[tt];if(!ze)continue;const rt=pe.slice(ze.start+se,ze.end+se),Tt=x6(rt,oe.delimiter);for(;Tt.length<=De;)Tt.push("");const Jt=Ne.data??"";if(Tt[De]===Jt)continue;Tt[De]=Jt;const Yn=rE(Tt,oe.delimiter);pe=pe.slice(0,ze.start+se)+Yn+pe.slice(ze.end+se),se+=Yn.length-(ze.end-ze.start)}return pe!==ne&&ce(pe),!0},[i]),Ye=w.useCallback(Q=>{var ve;const[ce,ne]=Q,oe=U.current[ne];if(ce{const ce=[];for(let ne=Q.y;ne{Q[0]>=Wr||z(ce,Q[1])},[z]),Ze=w.useMemo(()=>{const Q={title:"#",id:"__gutter",width:Ab,themeOverride:{baseFontStyle:`11px ${Rb}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},ce=P.headers.map((ne,oe)=>({title:ne.toUpperCase(),id:`c${oe}`,width:ae,themeOverride:D[oe]?{baseFontStyle:`12px ${Rb}`}:void 0}));return[Q,...ce]},[P.headers,D,ae]),Ot=w.useCallback((Q,ce)=>{const{ctx:ne,columnIndex:oe,rect:q,theme:ve}=Q;ne.save();try{if(ne.letterSpacing="0.5px",oe{const{ctx:ne,cell:oe,rect:q,col:ve,theme:pe}=Q,se=ve-Wr;if(se>=0&&H&&oe.kind===Se.Text){const ke=A6(oe.data,c);if(ke!==null){ne.save();try{const Ne=`${pe.baseFontStyle} ${pe.fontFamily}`;ne.font=Ne;let De=q.x+pe.cellHorizontalPadding;const Lt=q.y+q.height/2+Is(ne,Ne);for(const tt of ke){const ze=ne.measureText(tt.text).width;tt.hit&&ze>0&&(ne.fillStyle=T,ne.fillRect(De-1,Lt-7,ze+2,14)),De+=ze}}finally{ne.restore()}}}if(ce(),se>=0&&oe.kind===Se.Text&&oe.data===""){ne.save();try{ne.font=`${pe.baseFontStyle} ${pe.fontFamily}`,ne.fillStyle=pe.textLight,ne.fillText("—",q.x+pe.cellHorizontalPadding,q.y+q.height/2+.5)}finally{ne.restore()}}},[H,c,T]),Te=w.useCallback(Q=>{const ce=U.current[Q];return ce!==void 0&&g.current.has(ce)?{bgCell:E,bgCellMedium:E}:void 0},[E]);return O===0?R.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):R.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:s,children:[R.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[R.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[R.jsx(aI,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),R.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:a,onChange:Q=>u(Q.target.value),onKeyDown:Q=>{Q.key==="Escape"&&M()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),a!==""&&R.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:M,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx(D2,{"aria-hidden":"true",className:"size-3"})})]}),R.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:H?`${Y.length.toLocaleString()} of ${te.toLocaleString()}`:`${te.toLocaleString()} rows`}),_e&&R.jsxs("span",{className:"flex items-center gap-1.5",children:[R.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:we.length>0?`${we.length.toLocaleString()} selected`:`${ue.toLocaleString()} ${ue===1?"column":"columns"} selected`}),R.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Je,className:Xg,children:[R.jsx(yv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),R.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:j,className:Xg,children:"Clear"})]})]}),R.jsxs("div",{ref:o,"data-testid":n,role:"grid","aria-rowcount":Y.length+1,className:"relative min-h-0 flex-1",style:{minHeight:G},children:[R.jsx("div",{className:"absolute inset-0",children:R.jsx(AW,{imageWindowLoader:A.current,renderers:c6,columns:Ze,rows:Y.length,getCellContent:Ye,getCellsForSelection:Qe,onCellsEdited:b?qe:void 0,onCellClicked:et,onHeaderClicked:F,onGridSelectionChange:B,onSelectionCleared:ge,gridSelection:p,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:Tb,headerHeight:Eb,freezeColumns:Wr,fillHandle:b,onPaste:b?()=>!0:!1,keybindings:{search:!1},theme:C,drawHeader:Ot,drawCell:Ie,getRowThemeOverride:Te,minColumnWidth:Mb,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),H&&Y.length===0&&R.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[R.jsxs("span",{children:["No rows matching “",c,"”."]}),R.jsx("button",{type:"button",onClick:M,className:Xg,children:"Show all rows"})]})]})]})}function A6(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=w.useRef(null);w.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return R.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3",children:R.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-3",children:[R.jsx("div",{"aria-hidden":"true",className:"flex size-11 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground",children:R.jsx(JP,{className:"size-5"})}),R.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),R.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=I6(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),R.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",R.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),R.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[R.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[R.jsx(I2,{"aria-hidden":"true"}),"Choose file"]}),R.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[R.jsx(cI,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let R0=[],sE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=sE[r])e=r+1;else return!0;if(e==n)return!1}}function Pb(t){return t>=127462&&t<=127487}const Ib=8205;function N6(t,e,n=!0,r=!0){return(n?oE:L6)(t,e,r)}function oE(t,e,n){if(e==t.length)return e;e&&lE(t.charCodeAt(e))&&aE(t.charCodeAt(e-1))&&e--;let r=Gg(t,e);for(e+=Db(r);e=0&&Pb(Gg(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function L6(t,e,n){for(;e>1;){let r=oE(t,e-2,n);if(r=56320&&t<57344}function aE(t){return t>=55296&&t<56320}function Db(t){return t<65536?1:2}class xt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Ta(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Vi.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Ta(this,e,n);let r=[];return this.decompose(e,n,r,0),Vi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new qu(this),s=new qu(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new qu(this,e)}iterRange(e,n=this.length){return new uE(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new cE(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]?xt.empty:e.length<=32?new dn(e):Vi.from(dn.split(e,[]))}}class dn extends xt{constructor(e,n=F6(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new B6(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new dn(_b(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Ah(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new dn(l,o.length+s.length));else{let a=l.length>>1;r.push(new dn(l.slice(0,a)),new dn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof dn))return super.replace(e,n,r);[e,n]=Ta(this,e,n);let i=Ah(this.text,Ah(r.text,_b(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new dn(i,s):Vi.from(dn.split(i,[]),s)}sliceString(e,n=this.length,r=` -`){[e,n]=Ta(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new dn(r,i)),r=[],i=-1);return i>-1&&n.push(new dn(r,i)),n}}class Vi extends xt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Ta(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new Vi(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=Ta(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Vi))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new dn(d,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof Vi)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(h(),l.push(d)):d instanceof dn&&a&&(p=c[c.length-1])instanceof dn&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new dn(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>i&&h(),a+=d.lines,u+=d.length+1,c.push(d))}function h(){a!=0&&(l.push(c.length==1?c[0]:Vi.from(c,u)),u=-1,a=c.length=0)}for(let d of e)f(d);return h(),l.length==1?l[0]:new Vi(l,n)}}xt.empty=new dn([""],0);function F6(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ah(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof dn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof dn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(i instanceof dn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof dn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class uE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new qu(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<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)*n,this.value=i.length<=r?i:n<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 cE{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(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"&&(xt.prototype[Symbol.iterator]=function(){return this.iter()},qu.prototype[Symbol.iterator]=uE.prototype[Symbol.iterator]=cE.prototype[Symbol.iterator]=function(){return this});class B6{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Ta(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function Xn(t,e,n=!0,r=!0){return N6(t,e,n,r)}function z6(t){return t>=56320&&t<57344}function $6(t){return t>=55296&&t<56320}function H6(t,e){let n=t.charCodeAt(e);if(!$6(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return z6(r)?(n-55296<<10)+(r-56320)+65536:n}function j6(t){return t<65536?1:2}const O0=/\r\n?|\n/;var hr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(hr||(hr={}));class ns{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=hr.Simple&&u>=e&&(r==hr.TrackDel&&ie||r==hr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ns(e)}static create(e){return new ns(e)}}class bn extends ns{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return P0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return I0(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&so(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;oh||f<0||h>n)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${n})`);let p=d?typeof d=="string"?xt.of(d.split(r||O0)):d:xt.empty,m=p.length;if(f==h&&m==0)return;fo&&Un(i,f-o,-1),Un(i,h-f,m),so(s,i,p),o=h}}return u(e),a(!l),l}static empty(e){return new bn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function so(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function I0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new bc(t),l=new bc(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);Un(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class bc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?xt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?xt.empty:n[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 eo{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new eo(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return he.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return he.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return he.range(e.anchor,e.head)}static create(e,n,r,i){return new eo(e,n,r,i)}}class he{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:he.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.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 he(e.ranges.map(n=>eo.fromJSON(n)),e.main)}static single(e,n=e){return new he([he.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?he.range(a,l):he.range(l,a))}}return new he(e,n)}}function hE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Vv=0;class Fe{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Vv++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Fe(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Uv),!!e.static,e.enables)}of(e){return new Rh([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rh(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rh(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Uv(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Rh{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Vv++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,h){if(a&&h.docChanged||u&&(h.docChanged||h.selection)||D0(f,c)){let d=r(f);if(l?!Nb(d,f.values[o],i):!i(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[s];if(p!=null){let m=wd(h,p);if(this.dependencies.every(x=>x instanceof Fe?h.facet(x)===f.facet(x):x instanceof os?h.field(x,!1)==f.field(x,!1):!0)||(l?Nb(d=r(f),m,i):i(d=r(f),m)))return f.values[o]=m,0}else d=r(f);return f.values[o]=d,1}}}get extension(){return this}}function Nb(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Kf).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(Kf),o=i.facet(Kf),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Kf.of({field:this,create:e})]}get extension(){return this}}const Uo={lowest:4,low:3,default:2,high:1,highest:0};function wu(t){return e=>new dE(e,t)}const Kv={highest:wu(Uo.highest),high:wu(Uo.high),default:wu(Uo.default),low:wu(Uo.low),lowest:wu(Uo.lowest)};class dE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class Ea{of(e){return new _0(this,e)}reconfigure(e){return Ea.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class _0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class vd{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let h of V6(e,n,o))h instanceof os?i.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let l=Object.create(null),a=[],u=[];for(let h of i)l[h.id]=u.length<<1,u.push(d=>h.slot(d));let c=r==null?void 0:r.config.facets;for(let h in s){let d=s[h],p=d[0].facet,m=c&&c[h]||[];if(d.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,Uv(m,d))a.push(r.facet(p));else{let x=p.combine(d.map(v=>v.value));a.push(r&&p.compare(x,r.facet(p))?r.facet(p):x)}else{for(let x of d)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(v=>x.dynamicSlot(v)));l[p.id]=u.length<<1,u.push(x=>W6(x,p,d))}}let f=u.map(h=>h(l));return new vd(e,o,f,l,a,s)}}function V6(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof _0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof _0){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof dE)s(o.inner,o.prec);else if(o instanceof os)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Rh)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,Uo.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,Uo.default),r.reduce((o,l)=>o.concat(l))}function Yu(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function wd(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const pE=Fe.define(),N0=Fe.define({combine:t=>t.some(e=>e),static:!0}),gE=Fe.define({combine:t=>t.length?t[0]:void 0,static:!0}),mE=Fe.define(),yE=Fe.define(),vE=Fe.define(),wE=Fe.define({combine:t=>t.length?t[0]:!1});class Ao{constructor(e,n){this.type=e,this.value=n}static define(){return new U6}}class U6{of(e){return new Ao(this,e)}}class K6{constructor(e){this.map=e}of(e){return new _t(this,e)}}class _t{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new _t(this.type,n)}is(e){return this.type==e}static define(e={}){return new K6(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}_t.reconfigure=_t.define();_t.appendConfig=_t.define();class Cn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&hE(r,n.newLength),s.some(l=>l.type==Cn.time)||(this.annotations=s.concat(Cn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new Cn(e,n,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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Cn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Cn.time=Ao.define();Cn.userEvent=Ao.define();Cn.addToHistory=Ao.define();Cn.remote=Ao.define();function X6(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof Cn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Cn?t=s[0]:t=bE(e,fa(s),!1)}return t}function q6(t){let e=t.startState,n=e.facet(vE),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=xE(r,L0(e,s,t.changes.newLength),!0))}return r==t?t:Cn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const Y6=[];function fa(t){return t==null?Y6:Array.isArray(t)?t:[t]}var Ss=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ss||(Ss={}));const Q6=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let F0;try{F0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function J6(t){if(F0)return F0.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||Q6.test(n)))return!0}return!1}function Z6(t){return e=>{if(!/\S/.test(e))return Ss.Space;if(J6(e))return Ss.Word;for(let n=0;n-1)return Ss.Word;return Ss.Other}}class St{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(_t.reconfigure)?(n=null,r=l.value):l.is(_t.appendConfig)&&(n=null,r=fa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=vd.resolve(r,i,this),s=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(N0)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:he.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=fa(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return St.create({doc:e.doc,selection:he.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=vd.resolve(e.extensions||[],new Map),r=e.doc instanceof xt?e.doc:xt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||O0)),i=e.selection?e.selection instanceof he?e.selection:he.single(e.selection.anchor,e.selection.head):he.single(0);return hE(i,r.length),n.staticFacet(N0)||(i=i.asSingle()),new St(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(wE)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(pE))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return Z6(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=Xn(n,o,!1);if(s(n.slice(a,o))!=Ss.Word)break;o=a}for(;lt.length?t[0]:4});St.lineSeparator=gE;St.readOnly=wE;St.phrases=Fe.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});St.languageData=pE;St.changeFilter=mE;St.transactionFilter=yE;St.transactionExtender=vE;Ea.reconfigure=_t.define();function kE(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,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 ol{eq(e){return this==e}range(e,n=e){return B0.create(e,n,this)}}ol.prototype.startSide=ol.prototype.endSide=0;ol.prototype.point=!1;ol.prototype.mapMode=hr.TrackDel;function Xv(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let B0=class SE{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new SE(e,n,r)}};function z0(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Gv{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sd||h==d&&u.startSide>0&&u.endSide<=0)continue;(d-h||u.endSide-u.startSide)<0||(o<0&&(o=h),u.point&&(l=Math.max(l,d-h)),r.push(u),i.push(h-o),s.push(d-o))}return{mapped:r.length?new Gv(i,s,r,l):null,pos:o}}}class Mt{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Mt(e,n,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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(z0)),this.isEmpty)return n.length?Mt.of(n):this;let l=new CE(this,null,-1).goto(0),a=0,u=[],c=new Ma;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return kc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return kc.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=Lb(o,l,r),u=new xu(o,a,s),c=new xu(l,a,s);r.iterGaps((f,h,d)=>Fb(u,f,c,h,d,i)),r.empty&&r.length==0&&Fb(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Lb(s,o),a=new xu(s,l,0).goto(r),u=new xu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!$0(a.active,u.active)||a.point&&(!u.point||!Xv(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new xu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new Ma;for(let i of e instanceof B0?[e]:n?e9(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Mt.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Mt.empty;i=i.nextLayer)n=new Mt(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Mt.empty=new Mt([],[],null,-1);function e9(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(z0);e=r}return t}Mt.empty.nextLayer=Mt.empty;class Ma{finishChunk(e){this.chunks.push(new Gv(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new Ma)).add(e,n,r)}addInner(e,n,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(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Lb(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new CE(o,n,r,s));return i.length==1?i[0]:new kc(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qg(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qg(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),qg(this.heap,0)}}}function qg(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class xu{constructor(e,n,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=kc.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Xf(this.active,e),Xf(this.activeTo,e),Xf(this.activeRank,e),this.minActive=Bb(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;Gf(this.active,n,r),Gf(this.activeTo,n,i),Gf(this.activeRank,n,s),e&&Gf(e,n,this.cursor.from),this.minActive=Bb(this.active,this.activeTo)}next(){let e=this.to,n=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&&Xf(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(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Fb(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,h=f||t.endSide-n.endSide,d=h<0?t.to+a:n.to,p=Math.min(d,o);if(t.point||n.point?(t.point&&n.point&&Xv(t.point,n.point)&&$0(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!$0(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=d,h<=0&&t.next(),h>=0&&n.next()}}function $0(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Bb(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=Xn(t,i)}return t.length}const H0="ͼ",zb=typeof Symbol>"u"?"__"+H0:Symbol.for(H0),j0=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),$b=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class xo{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),h=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(i(d),p,c,h)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||h)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=$b[zb]||1;return $b[zb]=e+1,H0+e.toString(36)}static mount(e,n,r){let i=e[j0],s=r&&r.nonce;i?s&&i.setNonce(s):i=new n9(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let Hb=new Map;class n9{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=Hb.get(r);if(s)return e[j0]=s;this.sheet=new i.CSSStyleSheet,Hb.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[j0]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},r9=typeof navigator<"u"&&/Mac/.test(navigator.platform),i9=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _n=0;_n<10;_n++)bo[48+_n]=bo[96+_n]=String(_n);for(var _n=1;_n<=24;_n++)bo[_n+111]="F"+_n;for(var _n=65;_n<=90;_n++)bo[_n]=String.fromCharCode(_n+32),Sc[_n]=String.fromCharCode(_n);for(var Yg in bo)Sc.hasOwnProperty(Yg)||(Sc[Yg]=bo[Yg]);function s9(t){var e=r9&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||i9&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sc:bo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function Ui(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Me={mac:Vb||/Mac/.test(rr.platform),windows:/Win/.test(rr.platform),linux:/Linux|X11/.test(rr.platform),ie:vp,ie_version:EE?W0.documentMode||6:U0?+U0[1]:V0?+V0[1]:0,gecko:jb,gecko_version:jb?+(/Firefox\/(\d+)/.exec(rr.userAgent)||[0,0])[1]:0,chrome:!!Qg,chrome_version:Qg?+Qg[1]:0,ios:Vb,android:/Android\b/.test(rr.userAgent),webkit:Wb,webkit_version:Wb?+(/\bAppleWebKit\/(\d+)/.exec(rr.userAgent)||[0,0])[1]:0,safari:K0,safari_version:K0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(rr.userAgent)||[0,0])[1]:0,tabSize:W0.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function qv(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const xd=Object.create(null);function Yv(t,e,n){if(t==e)return!0;t||(t=xd),e||(e=xd);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function o9(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function Ub(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function l9(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new ll(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=ME(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new ll(e,r,i,n,e.widget||null,!0)}static line(e){return new Kc(e)}static set(e,n=!1){return Mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Rt.none=Mt.empty;class Uc extends Rt{constructor(e){let{start:n,end:r}=ME(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?qv(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||xd}eq(e){return this==e||e instanceof Uc&&this.tagName==e.tagName&&Yv(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Uc.prototype.point=!1;class Kc extends Rt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Kc&&this.spec.class==e.spec.class&&Yv(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Kc.prototype.mapMode=hr.TrackBefore;Kc.prototype.point=!0;class ll extends Rt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?hr.TrackBefore:hr.TrackAfter:hr.TrackDel}get type(){return this.startSide!=this.endSide?Zr.WidgetRange:this.startSide<=0?Zr.WidgetBefore:Zr.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof ll&&a9(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}ll.prototype.point=!0;function ME(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function a9(t,e){return t==e||!!(t&&e&&t.compare(e))}function ha(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class Cc extends ol{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Cc&&this.tagName==e.tagName&&Yv(this.attributes,e.attributes)}static create(e){return new Cc(e.tagName,e.attributes||xd,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Mt.of(e,n)}}Cc.prototype.startSide=Cc.prototype.endSide=-1;function Tc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function X0(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Qu(t,e){if(!e.anchorNode)return!1;try{return X0(t,e.anchorNode)}catch{return!1}}function Ju(t){return t.nodeType==3?Mc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Zu(t,e,n,r){return n?Kb(t,e,n,r,-1)||Kb(t,e,n,r,1):!1}function ko(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function bd(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Kb(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Os(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=ko(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?Os(t):0}else return!1}}function Os(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ec(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function u9(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function AE(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function c9(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let h,d=c==a.body,p=1,m=1;if(d)h=u9(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let g=c.getBoundingClientRect();({scaleX:p,scaleY:m}=AE(c,g)),h={left:g.left,right:g.left+c.clientWidth*p,top:g.top,bottom:g.top+c.clientHeight*m}}let x=0,v=0;if(i=="nearest")e.top0&&e.bottom>h.bottom+v&&(v=e.bottom-h.bottom+o)):e.bottom>h.bottom-o&&(v=e.bottom-h.bottom+o,n<0&&e.top-v0&&e.right>h.right+x&&(x=e.right-h.right+s)):e.right>h.right-s&&(x=e.right-h.right+s,n<0&&e.lefth.bottom||e.lefth.right)&&(e={left:Math.max(e.left,h.left),right:Math.min(e.right,h.right),top:Math.max(e.top,h.top),bottom:Math.min(e.bottom,h.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function RE(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class f9{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?Os(n):0),r,Math.min(e.focusOffset,r?Os(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function OE(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function PE(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let jo=null;Me.safari&&Me.safari_version>=26&&(jo=!1);function IE(t){if(t.setActive)return t.setActive();if(jo)return t.focus(jo);let e=OE(t);t.focus(jo==null?{get preventScroll(){return jo={preventScroll:!0},!0}}:void 0),jo||(jo=!1,PE(e))}let Xb;function Mc(t,e,n=e){let r=Xb||(Xb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function da(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,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,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function h9(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function d9(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,Os(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=Os(n))}else{if(n==t)return!0;r=ko(n),n=n.parentNode}}function DE(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function _E(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=Os(n)}else if(n.parentNode&&!bd(n))r=ko(n),n=n.parentNode;else return null}}function NE(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function BE(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if(Bi[m+1]==-d){let x=Bi[m+2],v=x&2?i:x&4?x&1?s:i:0;v&&(Dt[f]=Dt[Bi[m]]=v),l=m;break}}else{if(Bi.length==189)break;Bi[l++]=f,Bi[l++]=h,Bi[l++]=a}else if((p=Dt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let v=Bi[x+2];if(v&2)break;if(m)Bi[x+2]|=2;else{if(v&4)break;Bi[x+2]|=4}}}}}function w9(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==x&&(p=n[--m].from,x=m?n[m-1].to:t),Dt[--p]=d;a=c}else s=u,a++}}}function q0(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new Yi(a,m.from,d));let x=m.direction==al!=!(d%2);Y0(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Dt[p]!=l:Dt[p]==l))break;p++}h?q0(t,a,p,r+1,i,h,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Dt[a-1];m!=l&&(c=!1,f=m==16)}let h=!c&&l==1?[]:null,d=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let m=s[--u];if(!c)for(let x=m.from,v=u;;){if(x==e)break e;if(v&&s[v-1].to==x)x=s[--v].from;else{if(Dt[x-1]==l)break e;break}}if(h)h.push(m);else{m.toDt.length;)Dt[Dt.length]=256;let r=[],i=e==al?0:1;return Y0(t,i,i,n,0,t.length,r),r}function zE(t){return[new Yi(0,t,0)]}let $E="";function b9(t,e,n,r,i){var s;let o=r.head-t.from,l=Yi.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let h=l+=i?1:-1;if(h<0||h>=e.length)return null;a=e[l=h],o=a.side(!i,n),u=a.side(i,n)}let c=Xn(t.text,o,a.forward(i,n));(ca.to)&&(c=u),$E=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),S9=Fe.define({combine:t=>t.some(e=>e)}),GE=Fe.define();class pa{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new pa(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 pa(he.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const qf=_t.define({map:(t,e)=>t.map(e)}),qE=_t.define();function qr(t,e,n){let r=t.facet(VE);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const xs=Fe.define({combine:t=>t.length?t[0]:!0});let C9=0;const ta=Fe.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(wp.of(u=>{let c=u.plugin(l);return c?o(c):Rt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return ri.define((r,i)=>new e(r,i),n)}}class Jg{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(qr(n.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(n){qr(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){qr(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const YE=Fe.define(),ew=Fe.define(),wp=Fe.define(),QE=Fe.define(),tw=Fe.define(),Xc=Fe.define(),JE=Fe.define();function Gb(t,e){let n=t.state.facet(JE);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Mt.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let h=l.length-1;h>=0;h--,a--){let d=l[h].spec.bidiIsolate,p;if(d==null&&(d=k9(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==d)p.to=c,f=p.inner;else{let m={from:u,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),i}const ZE=Fe.define();function nw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(ZE)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const Pu=Fe.define();class Yr{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new Yr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new Yr(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new kd(e,n,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 T9=[];class an{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return T9}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&o9(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;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,n,r){return null}domPosFor(e,n){let r=ko(this.dom),i=this.length?e>0:n>0;return new ki(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 bp)return e;return null}static get(e){return e.cmTile}}class xp extends an{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=qb(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=qb(i);this.length=o}}function qb(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class bp extends xp{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=an.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ts)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ts extends xp{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ts(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class Aa extends xp{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new Aa(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let h=0,d=0;h=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&M9(o,p)))&&(m>f||p.flags&32&&n<=1)?(o=p,l=f-d):(d=-1)&&(i=p,s=f-d)),d=m}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):E9(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new ki(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new ki(a.dom,0);a==r.tile&&(l=!0)}}return new ki(this.dom,0)}}function E9(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=Ju(e);return n[n.length-1]||null}function M9(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Me.chrome||Me.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Me.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Ec(u,(l?l>0:n<0)==r)}static of(e,n){let r=new Yo(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class ul extends an{constructor(e,n,r,i){super(e,n,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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return Ec(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class A9{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof dr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(Zg(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=an.get(a.dom);f&&f.setDOM(Zg(a.dom))}let c=dr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=an.get(e.text);s&&this.cache.reused.set(s,2);let o=new Yo(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=eM);let i=Aa.start(e,n||((r=this.cache.find(Aa))===null||r===void 0?void 0:r.dom),!!n);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,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof dr&&l.mark.eq(o))i=l,n--;else{let a=dr.of(o,(r=this.cache.find(dr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Yb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Yb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(em,0,32)||new ul(em.toDOM(),0,em,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){let n=e.rank*102+e.value.rank,r=new R9(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(Sd,void 0,1);return r&&(r.flags=n),r||new Sd(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class P9{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 l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const Cd=[ul,Aa,Yo,dr,Sd,Ts,bp];for(let t=0;t[]),this.index=Cd.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof dr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof dr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Mt.spans(this.decorations,e,n,{point:(l,a,u,c,f,h)=>{if(u instanceof ll){if(this.disallowBlockEffectsFor[h]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let d=u.widget||(u.block?Ra.block:Ra.inline),p=_9(u),m=this.cache.findWidget(d,a-l,p)||ul.of(d,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(m)):(i.ensureLine(r),i.addInlineWidget(m,c,f))}r=null}else r=N9(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=an.get(i);if(i==this.view.contentDOM)break;s instanceof dr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ts||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new Aa(i,eM):r||n.push(dr.of(new Uc({tagName:i.nodeName.toLowerCase(),attributes:l9(i)}),i)))}return{line:r,marks:n}}}function Yb(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function _9(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const eM={class:"cm-line"};function N9(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&qv(n,t),r&&(t.class+=" "+r)),t}function L9(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof dr&&e.push(r.mark)}return e}function Zg(t){let e=an.get(t);return e&&e.setDOM(t.cloneNode()),t}class Ra extends Ua{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}}Ra.inline=new Ra("span");Ra.block=new Ra("div");const em=new class extends Ua{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Qb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Rt.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 bp(e,e.contentDOM),this.updateInner([new Yr(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.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&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!U9(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?B9(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new Yr(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Me.ie||Me.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=H9(o,this.decorations,e.changes);a.length&&(r=Yr.extendWithRanges(r,a));let u=W9(l,this.blockWrappers,e.changes);return u.length&&(r=Yr.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.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,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new D9(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&an.get(n.text)&&l.cache.reused.set(an.get(n.text),2),this.tile=l.run(e,n),J0(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Me.chrome||Me.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-1)&&Qu(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Me.gecko&&a.empty&&!this.hasComposition&&F9(u)){let h=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(h,u.node.childNodes[u.offset]||null)),u=c=new ki(h,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!Zu(u.node,u.offset,f.anchorNode,f.anchorOffset)||!Zu(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(f.focusNode)&&V9(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let h=Tc(this.view.root);if(h)if(a.empty){if(Me.gecko){let d=z9(u.node,u.offset);if(d&&d!=3){let p=(d==1?_E:NE)(u.node,u.offset);p&&(u=new ki(p.node,p.offset))}}h.collapse(u.node,u.offset),a.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=a.bidiLevel)}else if(h.extend){h.collapse(u.node,u.offset);try{h.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),d.setEnd(c.node,c.offset),d.setStart(u.node,u.offset),h.removeAllRanges(),h.addRange(d)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new ki(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new ki(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Zu(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Tc(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){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[n];else{let o=Os(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!an.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof tm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ln.LTR,u=0,c=(f,h,d)=>{for(let p=0;pi);p++){let m=f.children[p],x=h+m.length,v=m.dom.getBoundingClientRect(),{height:g}=v;if(d&&!p&&(u+=v.top-d.top),m instanceof Ts)x>r&&c(m,h,v);else if(h>=r&&(u>0&&n.push(-u),n.push(g+u),u=0,o)){let y=m.dom.lastChild,k=y?Ju(y):[];if(k.length){let b=k[k.length-1],C=a?b.right-v.left:v.right-b.left;C>l&&(l=C,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=x)}}d&&p==f.children.length-1&&(u+=d.bottom-v.bottom),h=x+m.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?ln.RTL:ln.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=Ju(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=Ju(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(Rt.replace({widget:new tm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Rt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(wp).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(tw).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Mt.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(GE))try{if(u(this.view,e.range,e))return!0}catch(c){qr(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.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=nw(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(c9(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){J0(this.tile)}}function J0(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)J0(r,e)}}function F9(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function tM(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=_E(n.focusNode,n.focusOffset),i=NE(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=an.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=an.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.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 B9(t,e,n){let r=tM(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new Yr(a.mapPos(s),a.mapPos(o),s,o),text:i}}function z9(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class tm extends Ua{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 K9(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return he.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=Xn(i.text,s,!1):l=Xn(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=Xn(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+t9(o,s,t.state.tabSize)}function G9(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==Zr.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function q9(t,e,n,r){let i=G9(t,e.head,e.assoc||-1),s=!r||i.type!=Zr.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==ln.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return he.cursor(a,n?-1:1)}return he.cursor(n?i.to:i.from,n?-1:1)}function Jb(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=b9(i,s,o,l,n),c=$E;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` -`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function Y9(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Ss.Space&&(i=o),i==o}}function Q9(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return he.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,h=t.viewState.heightOracle.textHeight>>1,d=r??h;for(let p=0;;p+=h){let m=l+(d+p)*s,x=Z0(t,{x:f,y:m},!1,s);if(n?m>a.bottom:ml:g{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:he.cursor(r,rt.viewState.docHeight)return new Ki(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==Zr.Text){if(r<0?u.tot.viewport.to)break;let h=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(h&&(r<0?h.top<=a+s:h.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==Zr.Text){let f=X9(t,i,u,o,l);return new Ki(f,f==u.from?1:-1)}}if(u.type!=Zr.Text)return a<(u.top+u.bottom)/2?new Ki(u.from,1):new Ki(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new J9(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class J9{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(m)){for(let g=1;g=s&&(y-=p),!o.has(y)){m=y;break t}}break e}o.add(m);let x=n(m),v=0;if(x)for(let g=0;g1))if(y.bottomthis.y)(!u||u.top>y.top)&&(u=y),v=-1;else{let k=y.left>this.x?this.x-y.left:y.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+m+m)/3)return this.y=u.top+1,this.scan(e,n,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==ln.LTR;return{i:c,after:this.x>(h.left+h.right)/2==d}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return Mc(e.dom,o,l).getClientRects()});return i.after?new Ki(r[i.i+1],-1):new Ki(r[i.i],1)}scanTile(e,n){if(!e.length)return new Ki(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Mc(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new Ki(r[i.i+1],-1):new Ki(o,1)}}const zl="￿";class Z9{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=zl}readRange(e,n){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=an.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=an.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:bd(i))||bd(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!tV(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=an.get(e),r=n&&n.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(eV(e,r.node,r.offset)?n:0))}}function eV(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=rM(e.docView.tile,n,r,0))){let a=s||o?[]:iV(e),u=new Z9(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=sV(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!X0(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!X0(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Me.ios||Me.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(he.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let h=e.coordsAtPos(u,-1),d=0;h&&(d=e.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=he.create([he.cursor(u,d)])}else this.newSel=he.single(c,u)}}}function rM(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return rM(f,e,n,u);if(h>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=h,u=h+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function iM(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Me.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(h=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:xt.of(e.text.slice(s.from-l,h).split(zl))}:(d=sM(f,e.text,u-l,c))&&(Me.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==zl+zl&&d.toB--,n={from:l+d.from,to:l+d.toA,insert:xt.of(e.text.slice(d.from,d.toB).split(zl))})}else r&&(!t.hasFocus&&i.facet(xs)||Td(r,s))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:xt.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:xt.of([" "])}),n)return rw(t,n,r,o);if(r&&!Td(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=nM(i.facet(Xc).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function rw(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Me.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&da(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&da(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&da(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=rV(t,e,n));return t.state.facet(UE).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function rV(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:he.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,h=n&&tM(t,n.main.head);if(h){let p=e.insert.length-(e.to-e.from);f={from:h.from,to:h.to-p}}else f=t.state.doc.lineAt(s.head);let d=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let m=p.to-d,x=m-c.length;if(t.state.sliceDoc(x,m)!=c||m>=f.from&&x<=f.to)return{range:p};let v=i.changes({from:x,to:m,insert:e.insert}),g=p.to-s.to;return{changes:v,range:u?he.range(Math.max(0,u.anchor+g),Math.max(0,u.head+g)):p.map(v)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function sM(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function iV(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Zb(n,r)),(i!=n||s!=r)&&e.push(new Zb(i,s))),e}function sV(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?he.single(n+e,r+e):null}function Td(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class oV{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&kV(e.contentDOM.ownerDocument)}handleEvent(e){!gV(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=aV(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&lM.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(oM.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||uV.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&lV(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.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 lV(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function ek(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){qr(n.state,i)}}}function aV(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(ek(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(ek(r.value,a))}}for(let r in Ai)n(r).handlers.push(Ai[r]);for(let r in or)n(r).observers.push(or[r]);return e}const oM=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],uV="dthko",lM=[16,17,18,20,91,92,224,225],Yf=6;function Qf(t){return Math.max(0,t)*.7+8}function cV(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class fV{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=RE(e.contentDOM),this.atoms=e.state.facet(Xc).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&hV(e,n),this.dragging=pV(e,n)&&cM(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&cV(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=nw(this.view);e.clientX-a.left<=i+Yf?n=-Qf(i-e.clientX):e.clientX+a.right>=o-Yf&&(n=Qf(e.clientX-o)),e.clientY-a.top<=s+Yf?r=-Qf(s-e.clientY):e.clientY+a.bottom>=l-Yf&&(r=Qf(e.clientY-l)),this.setScrollSpeed(n,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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=nM(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function hV(t,e){let n=t.state.facet(HE);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function dV(t,e){let n=t.state.facet(jE);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function pV(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Tc(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function gV(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=an.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Ai=Object.create(null),or=Object.create(null),aM=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function mV(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),uM(t,n.value)},50)}function kp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function uM(t,e){e=kp(t.state,Jv,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(ey!=null&&n.selection.ranges.every(a=>a.empty)&&ey==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:he.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:he.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}or.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};or.wheel=or.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Ai.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);or.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};or.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};or.touchend=(t,e)=>{t.inputState.touchActive=!1};Ai.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(WE))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=vV(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new fV(t,e,n,r)),r&&t.observer.ignore(()=>{IE(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function tk(t,e,n,r){if(r==1)return he.cursor(e,n);if(r==2)return K9(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(rk+1)%3:1}function vV(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=cM(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=tk(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=tk(t,n.pos,n.assoc,r),h=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=h1&&(u=wV(i,a.pos))?u:l?i.addRange(c):he.create([c])}}}function wV(t,e){for(let n=0;n=e)return he.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Ai.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=he.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",kp(t.state,Zv,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ai.dragend=t=>(t.inputState.draggedContent=null,!1);function sk(t,e,n,r){if(n=kp(t.state,Jv,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&dV(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Ai.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&sk(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return sk(t,e,r,!0),!0}return!1};Ai.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=aM?null:e.clipboardData;return n?(uM(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(mV(t),!1)};function xV(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.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(),t.focus()},50)}function bV(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:kp(t,Zv,e.join(t.lineBreak)),ranges:n,linewise:r}}let ey=null;Ai.copy=Ai.cut=(t,e)=>{if(!Qu(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=bV(t.state);if(!n&&!i)return!1;ey=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=aM?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(xV(t,n),!1)};const fM=Ao.define();function hM(t,e){let n=[];for(let r of t.facet(KE)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:fM.of(!0)}):null}function dM(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=hM(t.state,e);n?t.dispatch(n):t.update([])}},10)}or.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),dM(t)};or.blur=t=>{t.observer.clearSelectionRange(),dM(t)};or.compositionstart=or.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};or.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};or.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Ai.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return rw(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Me.chrome&&Me.android&&(i=oM.find(s=>s.inputType==e.inputType))&&(t.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&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>or.compositionend(t,e),20),!1};const ok=new Set;function kV(t){ok.has(t)||(ok.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lk=["pre-wrap","normal","pre-line","break-spaces"];let Oa=!1;function ak(){Oa=!1}class SV{constructor(e){this.lineWrapping=e,this.doc=xt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-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 lk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Oh&&(Oa=!0),this.height=e)}replace(e,n,r){return sr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],h=s.lineAt(a,Bt.ByPosNoHeight,r.setDoc(n),0,0),d=h.to>=u?h:s.lineAt(u,Bt.ByPosNoHeight,r,0,0);for(f+=d.to-u,u=d.to;l>0&&h.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,Bt.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ar extends pM{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new bi(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof Ar||i instanceof Dn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Dn?i=new Ar(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):sr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&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 Dn extends sr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof Dn?r[r.length-1]=new Dn(s.length+i):r.push(null,new Dn(i-1))}if(e>0){let s=r[0];s instanceof Dn?r[0]=new Dn(e+s.length):r.unshift(new Dn(e-1),null)}return sr.of(r)}decomposeLeft(e,n){n.push(new Dn(e-1),null)}decomposeRight(e,n){n.push(null,new Dn(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new Dn(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],h=0;f<0&&(h=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=Oh&&(a=-2);let d=new Ar(c,f,h);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new Dn(s-l).updateHeight(e,l));let u=sr.of(o);return(a<0||Math.abs(u.height-this.height)>=Oh||Math.abs(a-this.heightMetrics(e,n).perLine)>=Oh)&&(Oa=!0),Ed(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class EV extends sr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(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,n,r,i){let s=r+this.left.height;return el))return u;let c=n==Bt.ByPosNoHeight?Bt.ByPosNoHeight:Bt.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,Bt.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&uk(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?sr.of(this.break?[e,null,n]:[e,n]):(this.left=Ed(this.left,e),this.right=Ed(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function uk(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Dn&&(r=t[e+1])instanceof Dn&&t.splice(e-1,3,new Dn(n.length+1+r.length))}const MV=5;class iw{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Ar?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Ar(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=MV)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Ar(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Dn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ar)return e;let n=new Ar(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Ar)&&!this.isCovered?this.nodes.push(new Ar(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let h=c.getBoundingClientRect();s=Math.max(s,h.left),o=Math.min(o,h.right),l=Math.max(l,h.top),a=Math.min(u==t.parentNode?i.innerHeight:a,h.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function PV(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function IV(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class rm{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new SV(r),this.stateDeco=hk(n),this.heightMap=sr.empty().applyChanges(this.stateDeco,xt.empty,this.heightOracle.setDoc(n.doc),[new Yr(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Rt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new Jf(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?fk:new sw(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(Iu(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=hk(this.state);let i=e.changedRanges,s=Yr.extendWithRanges(i,AV(r,this.stateDeco,e?e.changes:bn.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ak(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Oa)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(S9)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?ln.RTL:ln.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:b,scaleY:C}=AE(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=b,this.scaleY=C,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,h=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let d=RE(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=DE(this.scrollParent||e.win);let m=(this.printing?IV:OV)(n,this.paddingTop),x=m.top-this.pixelViewport.top,v=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!PV(e.dom))return 0;let y=l.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let b=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(b)&&(o=!0),o||i.lineWrapping&&Math.abs(y-this.contentDOMWidth)>i.charWidth){let{lineHeight:C,charWidth:T,textHeight:E}=e.docView.measureTextSize();o=C>0&&i.refresh(s,C,T,E,Math.max(5,y/T),b),o&&(e.docView.minWidth=0,u|=16)}x>0&&v>0?c=Math.max(x,v):x<0&&v<0&&(c=Math.min(x,v)),ak();for(let C of this.viewports){let T=C.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?sr.empty().applyChanges(this.stateDeco,xt.empty,this.heightOracle,[new Yr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new CV(C.from,T))}Oa&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Jf(i.lineAt(o-r*1e3,Bt.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,Bt.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,Bt.ByPos,s,0,0),h;n.y=="center"?h=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=ln.LTR&&!r)return[];let l=[],a=(c,f,h,d)=>{if(f-cc&&vv.from>=h.from&&v.to<=h.to&&Math.abs(v.from-c)v.fromg));if(!x){if(fy.from<=f&&y.to>=f)){let y=n.moveToLineBoundary(he.cursor(f),!1,!0).head;y>c&&(f=y)}let v=this.gapSize(h,c,f,d),g=r||v<2e6?v:2e6;x=new rm(c,f,v,g)}l.push(x)},u=c=>{if(c.length2e6)for(let C of e)C.from>=c.from&&C.fromc.from&&a(c.from,d,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Mt.spans(n,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=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Iu(this.heightMap.lineAt(e,Bt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Iu(this.heightMap.lineAt(this.scaler.fromDOM(e),Bt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Iu(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 Jf{constructor(e,n){this.from=e,this.to=n}}function _V(t,e,n){let r=[],i=t,s=0;return Mt.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function eh(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function NV(t,e){for(let n of t)if(e(n))return n}const fk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function hk(t){let e=t.facet(wp).filter(r=>typeof r!="function"),n=t.facet(tw).filter(r=>typeof r!="function");return n.length&&e.push(Mt.join(n)),e}class sw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,Bt.ByPos,e,0,0).top,c=n.lineAt(a,Bt.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Iu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new bi(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Iu(i,e)):t._content)}const th=Fe.define({combine:t=>t.join(" ")}),ty=Fe.define({combine:t=>t.indexOf(!0)>-1}),ny=xo.newName(),gM=xo.newName(),mM=xo.newName(),yM={"&light":"."+gM,"&dark":"."+mM};function ry(t,e,n){return new xo(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const LV=ry("."+ny,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},yM),FV={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},im=Me.ie&&Me.ie_version<=11;class BV{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new f9,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new $V(e),e.state.facet(xs)&&(e.contentDOM.editContext=this.editContext.editContext)),im&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(xs)?r.root.activeElement!=this.dom:!Qu(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&i.focusNode&&Zu(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Tc(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&zV(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=Qu(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&da(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&Qu(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 nV(this.view,e,n,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 n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=iM(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Td(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=dk(n,e.previousSibling||e.target.previousSibling,-1),i=dk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(xs)!=e.state.facet(xs)&&(e.view.contentDOM.editContext=e.state.facet(xs)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.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 dk(t,e,n){for(;e;){let r=an.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function pk(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return Zu(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function zV(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return pk(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?pk(t,n):null}class $V{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=sM(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let h=he.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Td(h,i)||e.dispatch({selection:h,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:xt.of(r.text.slice(c.from,c.toB).split(` -`))};if((Me.mac||Me.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:xt.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);rw(e,f,he.single(this.toEditorPos(r.selectionStart,h),this.toEditorPos(r.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{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)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=Tc(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class je{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch: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||h9(e.parent)||document,this.viewState=new ck(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(qf)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ta).map(i=>new Jg(i));for(let i of this.plugins)i.update(this);this.observer=new BV(this),this.inputState=new oV(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Qb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Cn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let h of e){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(h=>h.annotation(fM))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=hM(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(s);i=kd.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection,{x:p,y:m}=this.state.facet(je.cursorScrollMargin);f=new pa(d.empty?d:he.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of h.effects)d.is(qf)&&(f=d.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=Md.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Pu)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(th)!=i.state.facet(th)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(Q0))try{h(i)}catch(d){qr(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!iM(this,c)&&u.force&&da(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ck(this,e),this.plugins=e.facet(ta).map(r=>new Jg(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Qb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ta),r=e.state.facet(ta);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new Jg(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}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-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(DE(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(i);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(d=>{try{return d.read(this)}catch(p){return qr(this.state,p),gk}}),f=kd.create(this,this.state,[]),h=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let d=0;d1||p<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(Q0))l(n)}get themeClasses(){return ny+" "+(this.state.facet(ty)?mM:gM)+" "+this.state.facet(th)}updateAttrs(){let e=mk(this,YE,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(xs)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),mk(this,ew,n);let r=this.observer.ignore(()=>{let i=Ub(this.contentDOM,this.contentAttrs,n),s=Ub(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(je.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Pu);let e=this.state.facet(je.cspNonce);xo.mount(this.root,this.styleModules.concat(LV).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return nm(this,e,Jb(this,e,n,r))}moveByGroup(e,n){return nm(this,e,Jb(this,e,n,r=>Y9(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return he.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return q9(this,e,n,r)}moveVertically(e,n,r){return nm(this,e,Q9(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=Z0(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Z0(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[Yi.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==ln.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(XE)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>HV)return zE(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||BE(s.isolates,r=Gb(this,e))))return s.order;r||(r=Gb(this,e));let i=x9(e.text,n,r);return this.bidiCache.push(new Md(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{IE(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return qf.of(new pa(typeof e=="number"?he.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return qf.of(new pa(he.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ri.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ri.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=xo.newName(),i=[th.of(r),Pu.of(ry(`.${r}`,e))];return n&&n.dark&&i.push(ty.of(!0)),i}static baseTheme(e){return Kv.lowest(Pu.of(ry("."+ny,e,yM)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&an.get(r)||an.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}je.styleModule=Pu;je.inputHandler=UE;je.clipboardInputFilter=Jv;je.clipboardOutputFilter=Zv;je.scrollHandler=GE;je.focusChangeEffect=KE;je.perLineTextDirection=XE;je.exceptionSink=VE;je.updateListener=Q0;je.editable=xs;je.mouseSelectionStyle=WE;je.dragMovesSelection=jE;je.clickAddsSelectionRange=HE;je.decorations=wp;je.blockWrappers=QE;je.outerDecorations=tw;je.atomicRanges=Xc;je.bidiIsolatedRanges=JE;je.cursorScrollMargin=Fe.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});je.scrollMargins=ZE;je.darkTheme=ty;je.cspNonce=Fe.define({combine:t=>t.length?t[0]:""});je.contentAttributes=ew;je.editorAttributes=YE;je.lineWrapping=je.contentAttributes.of({class:"cm-lineWrapping"});je.announce=_t.define();const HV=4096,gk={};class Md{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:ln.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&qv(o,n)}return n}const jV=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function WV(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let to=null;const KV=4e3;function XV(t,e=jV){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,h;let d=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(v=>WV(v,e));for(let v=1;v{let k=to={view:y,prefix:g,scope:o};return setTimeout(()=>{to==k&&(to=null)},KV),!0}]})}let m=p.join(" ");i(m,!1);let x=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((h=(f=d._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let h in c)c[h].run.push(d=>f(d,iy))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let iy=null;function GV(t,e,n,r){iy=e;let i=s9(e),s=H6(i,0),o=j6(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;to&&to.view==n&&to.scope==r&&(l=to.prefix+" ",lM.indexOf(e.keyCode)<0&&(u=!0,to=null));let f=new Set,h=x=>{if(x){for(let v of x.run)if(!f.has(v)&&(f.add(v),v(n)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},d=t[r],p,m;return d&&(h(d[l+nh(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=bo[e.keyCode])&&p!=i?(h(d[l+nh(p,e,!0)])||e.shiftKey&&(m=Sc[e.keyCode])!=i&&m!=p&&h(d[l+nh(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&h(d[l+nh(i,e,!0)])&&(a=!0),!a&&h(d._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),iy=null,a}class qV extends Ua{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?Ju(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Ec(n[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 YV(t){let e=ri.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Rt.set([Rt.widget({widget:new qV(t),side:1}).range(0)]):Rt.none}get decorations(){return this.view.state.doc.length?Rt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,je.contentAttributes.of({"aria-placeholder":t})]:e}const rh="-10000px";class wM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function QV(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const sm=Fe.define({combine:t=>{var e,n,r;return{position:Me.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||QV}}}),vk=new WeakMap,xM=ri.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(sm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new wM(t,bM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(sm);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!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);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=rh,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Me.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=nw(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 l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(sm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=rh;continue}let d=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,x=(e=vk.get(u))!==null&&e!==void 0?e:h.bottom-h.top,v=u.offset||ZV,g=this.view.textDirection==ln.LTR,y=h.width>r.right-r.left?g?r.left:r.right-h.width:g?Math.max(r.left,Math.min(f.left-(d?14:0)+v.x,r.right-m)):Math.min(Math.max(r.left,f.left-m+(d?14:0)-v.x),r.right-m),k=this.above[l];!a.strictSide&&(k?f.top-x-p-v.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let b=(k?f.top-r.top:r.bottom-f.bottom)-p;if(by&&E.topC&&(C=k?E.top-x-2-p:E.bottom+p+2);if(this.position=="absolute"?(c.style.top=(C-t.parent.top)/s+"px",wk(c,(y-t.parent.left)/i)):(c.style.top=C/s+"px",wk(c,y/i)),d){let E=f.left+(g?v.x:-v.x)-(y+14-7);d.style.left=E/i+"px"}u.overlap!==!0&&o.push({left:y,top:C,right:T,bottom:C+x}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=rh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function wk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const JV=je.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"}}}),ZV={x:0,y:0},bM=Fe.define({enables:[xM,JV]}),Ad=Fe.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Sp{static create(e){return new Sp(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new wM(e,Ad,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}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 eU=bM.compute([Ad],t=>{let e=t.facet(Ad);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Sp.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),tU=Fe.define();class nU{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,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(e){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;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==ln.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>qr(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(xM),n=e?e.manager.tooltips.findIndex(r=>r.create==Sp.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,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&&!this.locked.has(i)&&s&&!rU(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!iU(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ih=4;function rU(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-ih&&e.clientX<=r+ih&&e.clientY>=i-ih&&e.clientY<=s+ih}function iU(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function sU(t,e={}){let n=_t.define(),r=new WeakMap,i=os.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,hr.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),c);h.pos=f,h.end!=null&&(h.end=l.changes.mapPos(h.end)),u.push(h)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(oU)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>Ad.from(o)});const s=ri.define(o=>new nU(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,tU.of(s),eU]}}const oU=_t.define(),xk=Fe.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),lU=ri.fromClass(class{constructor(t){this.input=t.state.facet(sy),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(xk);this.top=new sh(t,!0,e.topContainer),this.bottom=new sh(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(xk);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new sh(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new sh(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(sy);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>je.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class sh{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.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";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=bk(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=bk(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 bk(t){let e=t.nextSibling;return t.remove(),e}const sy=Fe.define({enables:lU});class Pa extends ol{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Pa.prototype.elementClass="";Pa.prototype.toDOM=void 0;Pa.prototype.mapMode=hr.TrackBefore;Pa.prototype.startSide=Pa.prototype.endSide=-1;Pa.prototype.point=!0;const kM=1024;let aU=0;class om{constructor(e,n){this.from=e,this.to=n}}class dt{constructor(e={}){this.id=aU++,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=wr.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}dt.closedBy=new dt({deserialize:t=>t.split(" ")});dt.openedBy=new dt({deserialize:t=>t.split(" ")});dt.group=new dt({deserialize:t=>t.split(" ")});dt.isolate=new dt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});dt.contextHash=new dt({perNode:!0});dt.lookAhead=new dt({perNode:!0});dt.mounted=new dt({perNode:!0});class tc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[dt.mounted.id]}}const uU=Object.create(null);class wr{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):uU,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new wr(e.name||"",n,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");n[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 n=this.prop(dt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(dt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}wr.none=new wr("",Object.create(null),0,8);class ow{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|on.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:uw(wr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new gn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new gn(wr.none,n,r,i)))}static build(e){return dU(e)}}gn.empty=new gn(wr.none,[],[],0);class lw{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new lw(this.buffer,this.index)}}class So{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return wr.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function Ac(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,h;if(!(!(s&on.EnterBracketed&&c instanceof gn&&(h=tc.get(c))&&!h.overlay&&h.bracketed&&r>=f&&r<=f+c.length)&&!SM(i,r,f,f+c.length))){if(c instanceof So){if(s&on.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,n,r-f,i);if(d>-1)return new oo(new cU(o,c,e,f),null,d)}else if(s&on.IncludeAnonymous||!c.type.isAnonymous||aw(c)){let d;if(!(s&on.IgnoreMounts)&&(d=tc.get(c))&&!d.overlay)return new ei(d.tree,f,e,o);let p=new ei(c,f,e,o);return s&on.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&on.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&on.IgnoreOverlays)&&(i=tc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&on.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new ei(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,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 Sk(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!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 oy(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class cU{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class oo extends CM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new oo(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&on.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new oo(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new oo(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new oo(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{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)),n.push(0)}return new gn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function TM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new ei(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Ac(l,e,n,!1))}}return i?TM(i):r}class ly{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~on.EnterBracketed,e instanceof ei)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,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||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 ei?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-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,n,r=this.mode){return this.buffer?r&on.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&on.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&on.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.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 n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&on.IncludeAnonymous||l instanceof So||!l.type.isAnonymous||aw(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return oy(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function aw(t){return t.children.some(e=>e instanceof So||!e.type.isAnonymous||aw(e))}function dU(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=kM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new lw(n,n.length):n,a=r.types,u=0,c=0;function f(b,C,T,E,A,P){let{id:D,start:O,end:_,size:I}=l,Y=c,U=u;if(I<0)if(l.next(),I==-1){let M=s[D];T.push(M),E.push(O-b);return}else if(I==-3){u=D;return}else if(I==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${I}`);let ae=a[D],H,te,G=O-b;if(_-O<=i&&(te=x(l.pos-C,A))){let M=new Uint16Array(te.size-te.skip),F=l.pos-te.size,z=M.length;for(;l.pos>F;)z=v(te.start,M,z);H=new So(M,_-te.start,r),G=te.start-b}else{let M=l.pos-I;l.next();let F=[],z=[],j=D>=o?D:-1,B=0,ge=_;for(;l.pos>M;)j>=0&&l.id==j&&l.size>=0?(l.end<=ge-i&&(p(F,z,O,B,l.end,ge,j,Y,U),B=F.length,ge=l.end),l.next()):P>2500?h(O,M,F,z):f(O,M,F,z,j,P+1);if(j>=0&&B>0&&B-1&&B>0){let we=d(ae,U);H=uw(ae,F,z,0,F.length,0,_-O,we,we)}else H=m(ae,F,z,_-O,Y-_,U)}T.push(H),E.push(G)}function h(b,C,T,E){let A=[],P=0,D=-1;for(;l.pos>C;){let{id:O,start:_,end:I,size:Y}=l;if(Y>4)l.next();else{if(D>-1&&_=0;I-=3)O[Y++]=A[I],O[Y++]=A[I+1]-_,O[Y++]=A[I+2]-_,O[Y++]=Y;T.push(new So(O,A[2]-_,r)),E.push(_-b)}}function d(b,C){return(T,E,A)=>{let P=0,D=T.length-1,O,_;if(D>=0&&(O=T[D])instanceof gn){if(!D&&O.type==b&&O.length==A)return O;(_=O.prop(dt.lookAhead))&&(P=E[D]+O.length+_)}return m(b,T,E,A,P,C)}}function p(b,C,T,E,A,P,D,O,_){let I=[],Y=[];for(;b.length>E;)I.push(b.pop()),Y.push(C.pop()+T-A);b.push(m(r.types[D],I,Y,P-A,O-P,_)),C.push(A-T)}function m(b,C,T,E,A,P,D){if(P){let O=[dt.contextHash,P];D=D?[O].concat(D):[O]}if(A>25){let O=[dt.lookAhead,A];D=D?[O].concat(D):[O]}return new gn(b,C,T,E,D)}function x(b,C){let T=l.fork(),E=0,A=0,P=0,D=T.end-i,O={size:0,start:0,skip:0};e:for(let _=T.pos-b;T.pos>_;){let I=T.size;if(T.id==C&&I>=0){O.size=E,O.start=A,O.skip=P,P+=4,E+=4,T.next();continue}let Y=T.pos-I;if(I<0||Y<_||T.start=o?4:0,ae=T.start;for(T.next();T.pos>Y;){if(T.size<0)if(T.size==-3||T.size==-4)U+=4;else break e;else T.id>=o&&(U+=4);T.next()}A=ae,E+=I,P+=U}return(C<0||E==b)&&(O.size=E,O.start=A,O.skip=P),O.size>4?O:void 0}function v(b,C,T){let{id:E,start:A,end:P,size:D}=l;if(l.next(),D>=0&&E4){let _=l.pos-(D-4);for(;l.pos>_;)T=v(b,C,T)}C[--T]=O,C[--T]=P-b,C[--T]=A-b,C[--T]=E}else D==-3?u=E:D==-4&&(c=E);return T}let g=[],y=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,g,y,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:g.length?y[0]+g[0].length:0;return new gn(a[t.topID],g.reverse(),y.reverse(),k)}const Ck=new WeakMap;function Ph(t,e){if(!t.isAnonymous||e instanceof So||e.type!=t)return 1;let n=Ck.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof gn)){n=1;break}n+=Ph(t,r)}Ck.set(e,n)}return n}function uw(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;C+=T}if(y==k+1){if(C>c){let T=p[k];d(T.children,T.positions,0,T.children.length,m[k]+g);continue}f.push(p[k])}else{let T=m[y-1]+p[y-1].length-b;f.push(uw(t,p,m,k,y,b,T,null,a))}h.push(b+g-s)}}return d(e,n,r,i,0),(l||a)(f,h,o)}class Zo{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,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,n=[],r=!1){let i=[new Zo(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=h.from||f<=h.to||u){let d=Math.max(h.from,a)-u,p=Math.min(h.to,f)-u;h=d>=p?null:new Zo(d,p,h.tree,h.offset+u,l>0,!!c)}if(h&&i.push(h),o.to>f)break;o=snew om(i.from,i.to)):[new om(0,0)]:[new om(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class pU{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new dt({perNode:!0});let gU=0;class Kr{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=gU++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Kr&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Kr(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new Rd(e);return r=>r.modified.indexOf(n)>-1?r:Rd.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let mU=0;class Rd{constructor(e){this.name=e,this.instances=[],this.id=mU++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&yU(n,l.modified));if(r)return r;let i=[],s=new Kr(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=vU(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Rd.get(l,a));return s}}function yU(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function vU(t){let e=[[]];for(let n=0;nr.length-n.length)}function MM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==i.length)break;let d=i[f++];if(f==i.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new Rc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return AM.add(e)}const AM=new dt({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new Rc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Rc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function wU(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function xU(t,e,n,r=0,i=t.length){let s=new bU(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class bU{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let u=i,c=kU(e)||Rc.empty,f=wU(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let h=e.tree&&e.tree.prop(dt.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+l,1),p=this.highlighters.filter(x=>!x.scope||x.scope(h.tree.type)),m=e.firstChild();for(let x=0,v=l;;x++){let g=x=y||!e.nextSibling())););if(!g||y>r)break;v=g.to+l,v>n&&(this.highlightRange(d.cursor(),Math.max(n,g.from+l),Math.min(r,v),"",p),this.startSpan(Math.min(r,v),u))}m&&e.parent()}else if(e.firstChild()){h&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function kU(t){let e=t.type.prop(AM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ye=Kr.define,lh=ye(),Ys=ye(),Tk=ye(Ys),Ek=ye(Ys),Qs=ye(),ah=ye(Qs),lm=ye(Qs),Hi=ye(),Bo=ye(Hi),zi=ye(),$i=ye(),ay=ye(),bu=ye(ay),uh=ye(),He={comment:lh,lineComment:ye(lh),blockComment:ye(lh),docComment:ye(lh),name:Ys,variableName:ye(Ys),typeName:Tk,tagName:ye(Tk),propertyName:Ek,attributeName:ye(Ek),className:ye(Ys),labelName:ye(Ys),namespace:ye(Ys),macroName:ye(Ys),literal:Qs,string:ah,docString:ye(ah),character:ye(ah),attributeValue:ye(ah),number:lm,integer:ye(lm),float:ye(lm),bool:ye(Qs),regexp:ye(Qs),escape:ye(Qs),color:ye(Qs),url:ye(Qs),keyword:zi,self:ye(zi),null:ye(zi),atom:ye(zi),unit:ye(zi),modifier:ye(zi),operatorKeyword:ye(zi),controlKeyword:ye(zi),definitionKeyword:ye(zi),moduleKeyword:ye(zi),operator:$i,derefOperator:ye($i),arithmeticOperator:ye($i),logicOperator:ye($i),bitwiseOperator:ye($i),compareOperator:ye($i),updateOperator:ye($i),definitionOperator:ye($i),typeOperator:ye($i),controlOperator:ye($i),punctuation:ay,separator:ye(ay),bracket:bu,angleBracket:ye(bu),squareBracket:ye(bu),paren:ye(bu),brace:ye(bu),content:Hi,heading:Bo,heading1:ye(Bo),heading2:ye(Bo),heading3:ye(Bo),heading4:ye(Bo),heading5:ye(Bo),heading6:ye(Bo),contentSeparator:ye(Hi),list:ye(Hi),quote:ye(Hi),emphasis:ye(Hi),strong:ye(Hi),link:ye(Hi),monospace:ye(Hi),strikethrough:ye(Hi),inserted:ye(),deleted:ye(),changed:ye(),invalid:ye(),meta:uh,documentMeta:ye(uh),annotation:ye(uh),processingInstruction:ye(uh),definition:Kr.defineModifier("definition"),constant:Kr.defineModifier("constant"),function:Kr.defineModifier("function"),standard:Kr.defineModifier("standard"),local:Kr.defineModifier("local"),special:Kr.defineModifier("special")};for(let t in He){let e=He[t];e instanceof Kr&&(e.name=t)}RM([{tag:He.link,class:"tok-link"},{tag:He.heading,class:"tok-heading"},{tag:He.emphasis,class:"tok-emphasis"},{tag:He.strong,class:"tok-strong"},{tag:He.keyword,class:"tok-keyword"},{tag:He.atom,class:"tok-atom"},{tag:He.bool,class:"tok-bool"},{tag:He.url,class:"tok-url"},{tag:He.labelName,class:"tok-labelName"},{tag:He.inserted,class:"tok-inserted"},{tag:He.deleted,class:"tok-deleted"},{tag:He.literal,class:"tok-literal"},{tag:He.string,class:"tok-string"},{tag:He.number,class:"tok-number"},{tag:[He.regexp,He.escape,He.special(He.string)],class:"tok-string2"},{tag:He.variableName,class:"tok-variableName"},{tag:He.local(He.variableName),class:"tok-variableName tok-local"},{tag:He.definition(He.variableName),class:"tok-variableName tok-definition"},{tag:He.special(He.variableName),class:"tok-variableName2"},{tag:He.definition(He.propertyName),class:"tok-propertyName tok-definition"},{tag:He.typeName,class:"tok-typeName"},{tag:He.namespace,class:"tok-namespace"},{tag:He.className,class:"tok-className"},{tag:He.macroName,class:"tok-macroName"},{tag:He.propertyName,class:"tok-propertyName"},{tag:He.operator,class:"tok-operator"},{tag:He.comment,class:"tok-comment"},{tag:He.meta,class:"tok-meta"},{tag:He.invalid,class:"tok-invalid"},{tag:He.punctuation,class:"tok-punctuation"}]);var am;const na=new dt;function SU(t){return Fe.define({combine:t?e=>e.concat(t):void 0})}const CU=new dt;class Si{constructor(e,n,r=[],i=""){this.data=e,this.name=i,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return rs(this)}}),this.parser=n,this.extension=[Da.of(this),St.languageData.of((s,o,l)=>{let a=Mk(s,o,l),u=a.type.prop(na);if(!u)return[];let c=s.facet(u),f=a.type.prop(CU);if(f){let h=a.resolve(o-a.from,l);for(let d of f)if(d.test(h,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return Mk(e,n,r).type.prop(na)==this.data}findRegions(e){let n=e.facet(Da);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(na)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(dt.mounted);if(l){if(l.tree.prop(na)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new Od(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function rs(t){let e=t.field(Si.state,!1);return e?e.tree:gn.empty}class TU{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let ku=null;class Pd{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Pd(e,n,[],gn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new TU(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=gn.empty&&this.isDone(n??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()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Zo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=ku;ku=this;try{return e()}finally{ku=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Ak(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,h)=>a.push({fromA:u,toA:c,fromB:f,toB:h})),r=Zo.applyChanges(r,a),i=gn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=Ak(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends EM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=ku;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new gn(wr.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return ku}}function Ak(t,e,n){return Zo.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Ia{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Ia(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Pd.create(e.facet(Da).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Ia(r)}}Si.state=os.define({create:Ia.init,update(t,e){for(let n of e.effects)if(n.is(Si.setState))return n.value;return e.startState.facet(Da)!=e.state.facet(Da)?Ia.init(e.state):t.apply(e)}});let OM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(OM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const um=typeof navigator<"u"&&(!((am=navigator.scheduling)===null||am===void 0)&&am.isInputPending)?()=>navigator.scheduling.isInputPending():null,EU=ri.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Si.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Si.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=OM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>um&&um()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Si.setState.of(new Ia(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>qr(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Da=Fe.define({combine(t){return t.length?t[0]:null},enables:t=>[Si.state,EU,je.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class MU{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const AU=Fe.define(),cw=Fe.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Id(t){let e=t.facet(cw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Dd(t,e){let n="",r=t.tabSize,i=t.facet(cw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?RU(t,n,e):null}class Cp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Id(e)}lineAt(e,n=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}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return yp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),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 IM=new dt;function RU(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.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 DM(r,t,n)}function DM(t,e,n){for(let r=t;r;r=r.next){let i=PU(r.node);if(i)return i(fw.create(e,n,r))}return 0}function OU(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function PU(t){let e=t.type.prop(IM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(dt.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>NU(o,!0,1,void 0,s&&!OU(o)?i.from:void 0)}return t.parent==null?IU:null}function IU(){return 0}class fw extends Cp{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new fw(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(DU(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return DM(this.context.next,this.base,this.pos)}}function DU(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function _U(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function NU(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=_U(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function Rk({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const LU=new dt;function FU(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(na)==o.data:o?l=>l==o:void 0,this.style=RM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new xo(r):null,this.themeType=n.themeType}static define(e,n){return new Tp(e,n||{})}}const uy=Fe.define(),BU=Fe.define({combine(t){return t.length?[t[0]]:null}});function cm(t){let e=t.facet(uy);return e.length?e:t.facet(BU)}function Ok(t,e){let n=[$U],r;return t instanceof Tp&&(t.module&&n.push(je.styleModule.of(t.module)),r=t.themeType),r?n.push(uy.computeN([je.darkTheme],i=>i.facet(je.darkTheme)==(r=="dark")?[t]:[])):n.push(uy.of(t)),n}class zU{constructor(e){this.markCache=Object.create(null),this.tree=rs(e.state),this.decorations=this.buildDeco(e,cm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=rs(e.state),r=cm(e.state),i=r!=cm(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Rt.none;let r=new Ma;for(let{from:i,to:s}of e.visibleRanges)xU(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Rt.mark({class:a})))},i,s);return r.finish()}}const $U=Kv.high(ri.fromClass(zU,{decorations:t=>t.decorations})),HU=1e4,jU="()[]{}",WU=new dt;function cy(t,e,n){let r=t.prop(e<0?dt.openedBy:dt.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function fy(t){let e=t.type.prop(WU);return e?e(t.node):t}function ra(t,e,n,r={}){let i=r.maxScanDistance||HU,s=r.brackets||jU,o=rs(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=cy(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return VU(t,e,n,a,c,u,s)}}return UU(t,e,n,o,l.type,i,s)}function VU(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let h=0;!c.next().done&&h<=s;){let d=c.value;n<0&&(h+=d.length);let p=e+h*n;for(let m=n>0?0:d.length-1,x=n>0?d.length:-1;m!=x;m+=n){let v=o.indexOf(d[m]);if(!(v<0||r.resolveInner(p+m,1).type!=i))if(v%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+m,to:p+m+1},matched:v>>1==a>>1};f--}}n>0&&(h+=d.length)}return c.done?{start:u,matched:!1}:null}const KU=Object.create(null),Pk=[wr.none],Ik=[],Dk=Object.create(null),XU=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])XU[t]=GU(KU,e);function fm(t,e){Ik.indexOf(t)>-1||(Ik.push(t),console.warn(e))}function GU(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||He[u];c?typeof c=="function"?a.length?a=a.map(c):fm(u,`Modifier ${u} used at start of tag`):a.length?fm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:fm(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=Dk[i];if(s)return s.id;let o=Dk[i]=wr.define({id:Pk.length,name:r,props:[MM({[r]:n})]});return Pk.push(o),o.id}ln.RTL,ln.LTR;const qU=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=dw(t.state,n.from);return r.line?YU(t):r.block?JU(t):!1};function hw(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const YU=hw(t7,0),QU=hw(_M,0),JU=hw((t,e)=>_M(t,e,e7(e)),0);function dw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Su=50;function ZU(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Su,r),o=t.sliceDoc(i,i+Su),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Su?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Su),f=t.sliceDoc(i-Su,i));let h=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-n.length;return c.slice(h,h+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+h+e.length,margin:/\s/.test(c.charAt(h+e.length))?1:0},close:{pos:i-d-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function e7(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.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 _M(t,e,n=e.selection.ranges){let r=n.map(s=>dw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>ZU(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+u.length)==u?h:-1;hs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const hy=Ao.define(),n7=Ao.define(),r7=Fe.define(),NM=Fe.define({combine(t){return kE(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),LM=os.define({create(){return Qi.empty},update(t,e){let n=e.state.facet(NM),r=e.annotation(hy);if(r){let a=gr.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=_d(c,c.length,n.minDepth,a):c=zM(c,e.startState.selection),new Qi(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(n7);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Cn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=gr.fromTransaction(e),o=e.annotation(Cn.time),l=e.annotation(Cn.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Qi(t.done.map(gr.fromJSON),t.undone.map(gr.fromJSON))}});function i7(t={}){return[LM,NM.of(t),je.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?FM:e.inputType=="historyRedo"?dy:null;return r?(e.preventDefault(),r(n)):!1}})]}function Ep(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(LM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const FM=Ep(0,!1),dy=Ep(1,!1),s7=Ep(0,!0),o7=Ep(1,!0);class gr{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new gr(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new gr(e.changes&&bn.fromJSON(e.changes),[],e.mapped&&ns.fromJSON(e.mapped),e.startSelection&&he.fromJSON(e.startSelection),e.selectionsAfter.map(he.fromJSON))}static fromTransaction(e,n){let r=Qr;for(let i of e.startState.facet(r7)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new gr(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,Qr)}static selection(e){return new gr(void 0,Qr,void 0,void 0,e)}}function _d(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function l7(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function a7(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function BM(t,e){return t.length?e.length?t.concat(e):t:e}const Qr=[],u7=200;function zM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-u7));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),_d(t,t.length-1,1e9,n.setSelAfter(r)))}else return[gr.selection([e])]}function c7(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function hm(t,e){if(!t.length)return t;let n=t.length,r=Qr;for(;n;){let i=f7(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[gr.selection(r)]:Qr}function f7(t,e,n){let r=BM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):Qr,n);if(!t.changes)return gr.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new gr(i,_t.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const h7=/^(input\.type|delete)($|\.)/;class Qi{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new Qi(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||h7.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Mp(n,e))}function qn(t){return t.textDirectionAt(t.state.selection.main.head)==ln.LTR}const HM=t=>$M(t,!qn(t)),jM=t=>$M(t,qn(t));function WM(t,e){return Pi(t,n=>n.empty?t.moveByGroup(n,e):Mp(n,e))}const p7=t=>WM(t,!qn(t)),g7=t=>WM(t,qn(t));function m7(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Ap(t,e,n){let r=rs(t).resolveInner(e.head),i=n?dt.closedBy:dt.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;m7(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?ra(t,r.from,1):ra(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,he.cursor(l,n?-1:1)}const y7=t=>Pi(t,e=>Ap(t.state,e,!qn(t))),v7=t=>Pi(t,e=>Ap(t.state,e,qn(t)));function VM(t,e){return Pi(t,n=>{if(!n.empty)return Mp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const UM=t=>VM(t,!1),KM=t=>VM(t,!0);function XM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):Mp(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomGM(t,!1),py=t=>GM(t,!0);function Ro(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=he.cursor(r.from+s))}return i}const w7=t=>Pi(t,e=>Ro(t,e,!0)),x7=t=>Pi(t,e=>Ro(t,e,!1)),b7=t=>Pi(t,e=>Ro(t,e,!qn(t))),k7=t=>Pi(t,e=>Ro(t,e,qn(t))),S7=t=>Pi(t,e=>he.cursor(t.lineBlockAt(e.head).from,1)),C7=t=>Pi(t,e=>he.cursor(t.lineBlockAt(e.head).to,-1));function T7(t,e,n){let r=!1,i=Ka(t.selection,s=>{let o=ra(t,s.head,-1)||ra(t,s.head,1)||s.head>0&&ra(t,s.head-1,1)||s.headT7(t,e);function ii(t,e,n){let r=Ka(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=he.range(i.head,i.anchor));let s=n(i);return he.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Oi(t.state,r)),!0)}function qM(t,e){return ii(t,e,n=>t.moveByChar(n,e))}const YM=t=>qM(t,!qn(t)),QM=t=>qM(t,qn(t));function JM(t,e){return ii(t,e,n=>t.moveByGroup(n,e))}const M7=t=>JM(t,!qn(t)),A7=t=>JM(t,qn(t)),R7=t=>{let e=!qn(t);return ii(t,e,n=>Ap(t.state,n,e))},O7=t=>{let e=qn(t);return ii(t,e,n=>Ap(t.state,n,e))};function ZM(t,e){return ii(t,e,n=>t.moveVertically(n,e))}const eA=t=>ZM(t,!1),tA=t=>ZM(t,!0);function nA(t,e){return ii(t,e,n=>t.moveVertically(n,e,XM(t).height))}const Nk=t=>nA(t,!1),Lk=t=>nA(t,!0),P7=t=>ii(t,!0,e=>Ro(t,e,!0)),I7=t=>ii(t,!1,e=>Ro(t,e,!1)),D7=t=>{let e=!qn(t);return ii(t,e,n=>Ro(t,n,e))},_7=t=>{let e=qn(t);return ii(t,e,n=>Ro(t,n,e))},N7=t=>ii(t,!1,e=>he.cursor(t.lineBlockAt(e.head).from)),L7=t=>ii(t,!0,e=>he.cursor(t.lineBlockAt(e.head).to)),Fk=({state:t,dispatch:e})=>(e(Oi(t,{anchor:0})),!0),Bk=({state:t,dispatch:e})=>(e(Oi(t,{anchor:t.doc.length})),!0),zk=({state:t,dispatch:e})=>(e(Oi(t,{anchor:t.selection.main.anchor,head:0})),!0),$k=({state:t,dispatch:e})=>(e(Oi(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),F7=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),B7=({state:t,dispatch:e})=>{let n=Rp(t).map(({from:r,to:i})=>he.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:he.create(n),userEvent:"select"})),!0},z7=({state:t,dispatch:e})=>{let n=Ka(t.selection,r=>{let i=rs(t),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:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return he.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(Oi(t,n)),!0)};function rA(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(Oi(n,he.create(i,i.length-1))),!0)}const $7=t=>rA(t,!1),H7=t=>rA(t,!0),j7=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=he.create([n.main]):n.main.empty||(r=he.create([he.cursor(n.main.head)])),r?(e(Oi(t,r)),!0):!1};function Gc(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=ch(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=ch(t,o,!1),l=ch(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:he.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const iA=(t,e,n)=>Gc(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&iiA(t,!1,!0),sA=t=>iA(t,!0,!1),oA=(t,e)=>Gc(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=Xn(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),lA=t=>oA(t,!1),W7=t=>oA(t,!0),V7=t=>Gc(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headGc(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),K7=t=>Gc(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:xt.of(["",""])},range:he.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},G7=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:Xn(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:Xn(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:he.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Rp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=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]});n=s.number+1}return e}function aA(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Rp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(he.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(he.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:he.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const q7=({state:t,dispatch:e})=>aA(t,e,!1),Y7=({state:t,dispatch:e})=>aA(t,e,!0);function uA(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Rp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Q7=({state:t,dispatch:e})=>uA(t,e,!1),J7=({state:t,dispatch:e})=>uA(t,e,!0),Z7=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Rp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function eK(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=rs(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(dt.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const Hk=cA(!1),tK=cA(!0);function cA(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&eK(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Cp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=PM(u,s);for(c==null&&(c=yp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:he.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const nK=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Cp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=pw(t,(s,o,l)=>{let a=PM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Dd(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(pw(t,(n,r)=>{r.push({from:n.from,insert:t.facet(cw)})}),{userEvent:"input.indent"})),!0),hA=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(pw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=yp(i,t.tabSize),o=0,l=Dd(t,Math.max(0,s-Id(t)));for(;o(t.setTabFocusMode(),!0),iK=[{key:"Ctrl-b",run:HM,shift:YM,preventDefault:!0},{key:"Ctrl-f",run:jM,shift:QM},{key:"Ctrl-p",run:UM,shift:eA},{key:"Ctrl-n",run:KM,shift:tA},{key:"Ctrl-a",run:S7,shift:N7},{key:"Ctrl-e",run:C7,shift:L7},{key:"Ctrl-d",run:sA},{key:"Ctrl-h",run:gy},{key:"Ctrl-k",run:V7},{key:"Ctrl-Alt-h",run:lA},{key:"Ctrl-o",run:X7},{key:"Ctrl-t",run:G7},{key:"Ctrl-v",run:py}],sK=[{key:"ArrowLeft",run:HM,shift:YM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:p7,shift:M7,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:b7,shift:D7,preventDefault:!0},{key:"ArrowRight",run:jM,shift:QM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:g7,shift:A7,preventDefault:!0},{mac:"Cmd-ArrowRight",run:k7,shift:_7,preventDefault:!0},{key:"ArrowUp",run:UM,shift:eA,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Fk,shift:zk},{mac:"Ctrl-ArrowUp",run:_k,shift:Nk},{key:"ArrowDown",run:KM,shift:tA,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Bk,shift:$k},{mac:"Ctrl-ArrowDown",run:py,shift:Lk},{key:"PageUp",run:_k,shift:Nk},{key:"PageDown",run:py,shift:Lk},{key:"Home",run:x7,shift:I7,preventDefault:!0},{key:"Mod-Home",run:Fk,shift:zk},{key:"End",run:w7,shift:P7,preventDefault:!0},{key:"Mod-End",run:Bk,shift:$k},{key:"Enter",run:Hk,shift:Hk},{key:"Mod-a",run:F7},{key:"Backspace",run:gy,shift:gy,preventDefault:!0},{key:"Delete",run:sA,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:lA,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:W7,preventDefault:!0},{mac:"Mod-Backspace",run:U7,preventDefault:!0},{mac:"Mod-Delete",run:K7,preventDefault:!0}].concat(iK.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),oK=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:y7,shift:R7},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:v7,shift:O7},{key:"Alt-ArrowUp",run:q7},{key:"Shift-Alt-ArrowUp",run:Q7},{key:"Alt-ArrowDown",run:Y7},{key:"Shift-Alt-ArrowDown",run:J7},{key:"Mod-Alt-ArrowUp",run:$7},{key:"Mod-Alt-ArrowDown",run:H7},{key:"Escape",run:j7},{key:"Mod-Enter",run:tK},{key:"Alt-l",mac:"Ctrl-l",run:B7},{key:"Mod-i",run:z7,preventDefault:!0},{key:"Mod-[",run:hA},{key:"Mod-]",run:fA},{key:"Mod-Alt-\\",run:nK},{key:"Shift-Mod-k",run:Z7},{key:"Shift-Mod-\\",run:E7},{key:"Mod-/",run:qU},{key:"Alt-A",mac:"Ctrl-A",run:QU},{key:"Ctrl-m",mac:"Shift-Alt-m",run:rK}].concat(sK),lK={key:"Tab",run:fA,shift:hA};var jk={};class Nd{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Nd(e,[],n,r,r,0,[],0,i?new Wk(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)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]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){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(n,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,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Nd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new aK(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&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;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};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 n=0;n0&&this.emitLookAhead()}}class Wk{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class aK{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=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],n,!0);this.state=i}}class Ld{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Ld(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Ld(this.stack,this.pos,this.index)}}function fh(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class Ih{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Vk=new Ih;class uK{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Vk,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.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&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=Vk,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class ga{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;cK(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}ga.prototype.contextual=ga.prototype.fallback=ga.prototype.extend=!1;ga.prototype.fallback=ga.prototype.extend=!1;function cK(t,e,n,r,i,s){let o=0,l=1<0){let p=t[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||fK(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,h=t[o+2];if(e.next<0&&h>f&&t[u+h*3-3]==65535){o=t[u+h*3-1];continue e}for(;f>1,p=u+d+(d<<1),m=t[p],x=t[p+1]||65536;if(c=x)f=d+1;else{o=t[p+2],e.advance();continue e}}break}}function Uk(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function fK(t,e,n,r){let i=Uk(n,r,e);return i<0||Uk(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class hK{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Kk(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Kk(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(ee)return this.nextStart=o,null;if(s instanceof gn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class dK{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Ih)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let h=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new Ih,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Ih,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new hK(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=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;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&mK(i);if(o)return Er&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Er&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return Er&&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((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(h>-1&&f.length&&(!u||(f.prop(dt.contextHash)||0)==c))return e.useNode(f,h),Er&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof gn)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof gn&&f.positions[0]==0)f=d;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Er&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return Xk(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),Er&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),h=c;for(let d=0;d<10&&f.forceReduce()&&(Er&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));d++)Er&&(h=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))Er&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),Er&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Xk(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let h=-c;h>0;h--)s(l[u++],a,f);u++}}}this.nodeSet=new ow(n.map((l,a)=>wr.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=kM;let o=fh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new ga(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new pK(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(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=vs(this.data,s+2);else break;i=n(vs(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=vs(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(Fd.prototype),this);if(e.props&&(n.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}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=Gk(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const yK=MM({String:He.string,Number:He.number,"True False":He.bool,PropertyName:He.propertyName,Null:He.null,", :":He.separator,"[ ]":He.squareBracket,"{ }":He.brace}),vK=Fd.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[yK],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),wK=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=xK(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function xK(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const bK=Od.define({name:"json",parser:vK.configure({props:[IM.add({Object:Rk({except:/^\s*\}/}),Array:Rk({except:/^\s*\]/})}),LU.add({"Object Array":FU})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function kK(){return new MU(bK)}class qk{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Ko{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(Ji).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Ma,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((y,k)=>Math.min(y,k.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;x=p.to,l.push(p),d++}for(;dy.from||y.to==m))l.push(y),d++,x=Math.min(y.to,x);else{x=Math.min(y.from,x);break}}x=Math.min(x,f);let v=!1;if(l.some(y=>y.from==m&&(y.to==x||x==f))&&(v=m==x,!v&&x-m<10)){let y=m-(c+u.value.length);y>0&&(u.next(y),c=m);for(let k=m;;){if(k>=x){v=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let g=LK(l);if(v)o.add(m,m,Rt.widget({widget:new IK(g),diagnostics:l.slice()}));else{let y=l.reduce((k,b)=>b.markClass?k+" "+b.markClass:k,"");o.add(m,x,Rt.mark({class:"cm-lintRange cm-lintRange-"+g+y,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>x)}))}if(a=x,a==f)break;for(let y=0;y{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new qk(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new qk(r.from,s,r.diagnostic)}}),r}function SK(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(Ji).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(gw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function CK(t,e){return t.field(Ci,!1)?e:e.concat(_t.appendConfig.of(yA))}function TK(t,e){return{effects:CK(t,[gw.of(e)])}}const gw=_t.define(),dA=_t.define(),pA=_t.define(),Ci=os.define({create(){return new Ko(Rt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=_a(n,t.selected.diagnostic,s)||_a(n,null,s)}!n.size&&i&&e.state.facet(Ji).autoPanel&&(i=null),t=new Ko(n,i,r)}for(let n of e.effects)if(n.is(gw)){let r=e.state.facet(Ji).autoPanel?n.value.length?Bd.open:null:t.panel;t=Ko.init(n.value,r,e.state)}else n.is(dA)?t=new Ko(t.diagnostics,n.value?Bd.open:null,t.selected):n.is(pA)&&(t=new Ko(t.diagnostics,t.panel,n.value));return t},provide:t=>[sy.from(t,e=>e.panel),je.decorations.from(t,e=>e.diagnostics)]}),EK=Rt.mark({class:"cm-lintRange cm-lintRange-active"});function MK(t,e,n){let{diagnostics:r}=t.state.field(Ci),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(emA(t,n,!1)))}const Yk=t=>{let e=t.state.field(Ci,!1);return!e||!e.panel?!1:(t.dispatch({effects:dA.of(!1)}),!0)},RK=ri.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(Ji);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(TK(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{qr(this.view.state,r)})}}update(t){let e=t.state.facet(Ji);(t.docChanged||e!=t.startState.facet(Ji)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function OK(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const Ji=Fe.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...kE(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Qk,tooltipFilter:Qk,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function Qk(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function PK(t,e={}){return[Ji.of({source:t,config:e}),RK,yA]}function gA(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function mA(t,e,n){var r;let i=n?gA(e.actions):[];return Ui("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ui("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=_a(t.state.field(Ci).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),Ui("u",u.slice(c,c+1)),u.slice(c+1)],h=s.markClass?" "+s.markClass:"";return Ui("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&Ui("div",{class:"cm-diagnosticSource"},e.source))}class IK extends Ua{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Ui("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Jk{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=mA(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Bd{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)Yk(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=gA(s.actions);for(let l=0;l{for(let s=0;sYk(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ci).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,h;for(let d=r;dr&&(this.items.splice(r,f-r),i=!0)),n&&h.diagnostic==n.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),s=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(Ci),r=_a(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:pA.of(r)})}static open(e){return new Bd(e)}}function DK(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function hh(t){return DK(``,'width="6" height="3"')}const _K=je.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:hh("#f11")},".cm-lintRange-warning":{backgroundImage:hh("orange")},".cm-lintRange-info":{backgroundImage:hh("#999")},".cm-lintRange-hint":{backgroundImage:hh("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function NK(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function LK(t){let e="hint",n=1;for(let r of t){let i=NK(r.severity);i>n&&(n=i,e=r.severity)}return e}const FK=sU(MK,{hideOn:SK}),yA=[Ci,je.decorations.compute([Ci],t=>{let{selected:e,panel:n}=t.field(Ci);return!e||!n||e.from==e.to?Rt.none:Rt.set([EK.range(e.from,e.to)])}),FK,_K],BK=512*1024,zK=t=>t.state.doc.length>BK?[]:wK()(t);function Zk(t){return Tp.define([{tag:He.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:He.string,color:t?"#86efac":"#15803d"},{tag:He.number,color:t?"#fcd34d":"#b45309"},{tag:He.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:He.null,color:t?"#a1a1aa":"#71717a"}])}const $K=je.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function vA({value:t,onChange:e,editable:n,dark:r,placeholder:i,testId:s="json-editor",className:o,onReady:l}){const a=w.useRef(null),u=w.useRef(null),c=w.useRef(e);c.current=e;const f=w.useRef(r),h=w.useRef(null),d=w.useRef(null),p=n??e!==void 0,m=w.useRef(p),x=w.useRef(!1),v=w.useCallback(g=>g?[je.updateListener.of(y=>{var k;y.docChanged&&!x.current&&((k=c.current)==null||k.call(c,y.state.doc.toString()))}),PK(zK,{delay:300})]:[St.readOnly.of(!0),je.editable.of(!1)],[]);return w.useEffect(()=>{const g=a.current;if(!g)return;const y=new Ea,k=new Ea,b=St.create({doc:t,extensions:[kK(),je.lineWrapping,i7(),vM.of([...oK,...d7,lK]),$K,y.of(Ok(Zk(r))),k.of(v(p)),...i?[YV(i)]:[]]}),C=new je({state:b,parent:g});return h.current=y,d.current=k,l==null||l(C),u.current=C,()=>{C.destroy(),u.current=null}},[]),w.useEffect(()=>{const g=u.current;if(g&&g.state.doc.toString()!==t){x.current=!0;try{g.dispatch({changes:{from:0,to:g.state.doc.length,insert:t}})}finally{x.current=!1}}},[t]),w.useEffect(()=>{const g=u.current,y=d.current;!g||!y||p!==m.current&&(m.current=p,g.dispatch({effects:y.reconfigure(v(p))}))},[p,v]),w.useEffect(()=>{const g=u.current;if(!g||r===f.current)return;f.current=r;const y=h.current;y&&g.dispatch({effects:y.reconfigure(Ok(Zk(r)))})},[r]),R.jsx("div",{"data-testid":s,className:Xi("min-h-0 flex-1 overflow-hidden px-5 py-4 font-mono",o),ref:a})}function wA({title:t,meta:e,actions:n,status:r,children:i}){return R.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[R.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-3 border-b border-border px-3 py-2 pl-5 max-md:gap-2 md:h-12 md:py-0",children:[R.jsxs("div",{className:"flex items-center gap-3",children:[R.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?R.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),R.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),R.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?R.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const Du="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";function HK(){return R.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:R.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function dh({label:t,testId:e,onClick:n,disabled:r,Icon:i}){return R.jsxs("button",{type:"button","data-testid":e,disabled:r,onClick:n,title:t,className:Du,children:[i?R.jsx(i,{"aria-hidden":"true"}):null,t]})}function jK({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onDownload:l,filename:a,reading:u,meta:c,error:f,notice:h,dark:d,delimiter:p,onCellCommit:m}){const[x,v]=w.useState(!1),[g,y]=w.useState(!1),k=w.useRef(0),b=w.useRef(null),C=e.trim()==="",T=t==="CSV",E=I=>{var Y;I.preventDefault(),Array.from(((Y=I.dataTransfer)==null?void 0:Y.types)??[]).includes("Files")&&(k.current++,y(!0))},A=()=>{k.current=Math.max(0,k.current-1),k.current===0&&y(!1)},P=I=>{var U,ae;I.preventDefault(),k.current=0,y(!1);const Y=(ae=(U=I.dataTransfer)==null?void 0:U.files)==null?void 0:ae[0];Y&&r(Y,"drop")},D=I=>{var U;if(!C||I.defaultPrevented||I.target instanceof HTMLTextAreaElement||I.target instanceof HTMLInputElement)return;const Y=(U=I.clipboardData)==null?void 0:U.getData("text/plain");Y&&(I.preventDefault(),n(Y))},O=T?R.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[R.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!x,onClick:()=>v(!1),className:Xi("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2.5 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50",x?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[R.jsx(pI,{"aria-hidden":"true",className:"size-3.5"}),"Table"]}),R.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":x,onClick:()=>v(!0),className:Xi("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2.5 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50",x?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[R.jsx(YP,{"aria-hidden":"true",className:"size-3.5"}),"Raw"]})]}):null,_=u&&a?R.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[R.jsx(HK,{})," ",a]}):a?c?`${a} · ${c}`:a:c;return R.jsx("div",{"data-testid":"input-pane",onDragEnter:E,onDragOver:I=>I.preventDefault(),onDragLeave:A,onDrop:P,onPaste:D,"data-drag-over":g||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:R.jsxs(wA,{title:t,meta:_,actions:R.jsxs(R.Fragment,{children:[O,R.jsx("input",{ref:b,type:"file","data-testid":"file-input",accept:T?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:I=>{var U;const Y=(U=I.target.files)==null?void 0:U[0];Y&&r(Y,"picker"),I.target.value=""}}),R.jsx(dh,{label:"Upload",testId:"upload",onClick:()=>{var I;return(I=b.current)==null?void 0:I.click()},Icon:I2}),R.jsx(dh,{label:"Copy",testId:"copy-input",onClick:o,Icon:yv}),R.jsx(dh,{label:"Clear",testId:"clear-input",onClick:s,disabled:C,Icon:xI}),R.jsx(dh,{label:"Download",testId:"download-input",onClick:l,disabled:C,Icon:P2})]}),status:f?{kind:"error",message:f}:h?{kind:"notice",message:h}:null,children:[C?R.jsx(D6,{format:t,onIngest:n,onBrowse:()=>{var I;return(I=b.current)==null?void 0:I.click()},onTryExample:i}):T&&x?R.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:I=>n(I.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):T?R.jsx(iE,{text:e,delimiter:p,testId:"input-table",dark:d,onCellCommit:m}):R.jsx(vA,{value:e,onChange:n,dark:d,testId:"input-editor"}),g?R.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:R.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const WK=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function VK(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:WK.test(t.name)}const UK=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function eS(t,e){const n=new TextDecoder(e,{fatal:!1}),r=t.stream().getReader();let i="";try{for(;;){const{done:s,value:o}=await r.read();if(s)break;i+=n.decode(o,{stream:!0})}}finally{r.releaseLock()}return i+n.decode()}const KK=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function tS(){return R.jsx("div",{className:"h-5 w-px shrink-0 bg-border","aria-hidden":"true"})}function nS(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function rS(){return R.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:R.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function iS({children:t}){return R.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function Ks({label:t,checked:e,onChange:n,hint:r}){return R.jsxs("span",{className:"inline-flex items-center gap-1",children:[R.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[R.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx("span",{className:Xi("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:R.jsx("span",{className:Xi("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),R.jsx("span",{className:"select-none",children:t})]}),r?R.jsx(my,{text:r}):null]})}function my({text:t}){const e=w.useId(),[n,r]=w.useState(!1);return R.jsxs("span",{className:"relative inline-flex items-center",children:[R.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),R.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function XK({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const o=t==="csv2json";return R.jsxs("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-wrap items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:[R.jsxs("span",{className:"inline-flex items-center gap-2",children:[R.jsxs("label",{className:"flex items-center gap-2",children:[R.jsx(iS,{children:"Separator"}),R.jsxs("span",{className:"relative inline-flex",children:[R.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:l=>n({separator:l.target.value}),className:nS(),children:KK.map(l=>R.jsx("option",{value:l.value,children:l.label},l.value))}),R.jsx(rS,{})]})]}),R.jsx(my,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?R.jsxs(R.Fragment,{children:[R.jsx(tS,{}),R.jsxs("span",{className:"inline-flex items-center gap-2",children:[R.jsxs("label",{className:"flex items-center gap-2",children:[R.jsx(iS,{children:"Encoding"}),R.jsxs("span",{className:"relative inline-flex",children:[R.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:l=>s(l.target.value),className:nS(),children:UK.map(l=>R.jsx("option",{value:l.value,children:l.label},l.value))}),R.jsx(rS,{})]})]}),R.jsx(my,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,R.jsx(tS,{}),o?R.jsxs(R.Fragment,{children:[R.jsx(Ks,{label:"Parse numbers",checked:e.parseNumbers,onChange:l=>n({parseNumbers:l}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),R.jsx(Ks,{label:"Parse JSON",checked:e.parseJSON,onChange:l=>n({parseJSON:l}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),R.jsx(Ks,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:l=>n({emptyFields:l?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),R.jsx(Ks,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:l=>n({nullLiterals:l?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),R.jsx(Ks,{label:"Transpose",checked:e.transpose,onChange:l=>n({transpose:l}),hint:"Flip rows and columns — the first column becomes the header row."}),R.jsx(Ks,{label:"Hash output",checked:e.hash,onChange:l=>n({hash:l}),hint:"The first column becomes the object key instead of a field."}),R.jsx(Ks,{label:"Minify",checked:e.minify,onChange:l=>n({minify:l}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):R.jsx(Ks,{label:"Flatten nested arrays",checked:e.flatten,onChange:l=>n({flatten:l}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."}),R.jsx("div",{className:"flex-1"}),r?R.jsx("span",{"data-testid":"options-notice",className:"text-muted-foreground",children:r}):null]})}const GK=3;function qK(t){const e=t.slice(0,GK),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` -`)}function YK({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,dark:u,onCopy:c,onDownload:f,onOutputChange:h,onRevert:d,onDiscardReconvert:p}){const m=t==="JSON";return R.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:R.jsx(wA,{title:t,meta:e?null:l?R.jsxs("span",{className:"flex items-center gap-1.5",children:[R.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),R.jsxs("button",{type:"button","data-testid":"revert-output",onClick:d,className:Du,children:[R.jsx(W1,{"aria-hidden":"true"}),"Revert"]})]}):s?R.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:R.jsxs(R.Fragment,{children:[R.jsxs("button",{type:"button","data-testid":"copy-output",onClick:c,disabled:!n,className:Du,children:[R.jsx(yv,{"aria-hidden":"true"}),"Copy"]}),R.jsxs("button",{type:"button","data-testid":"download-output",onClick:f,disabled:!n,className:Du,children:[R.jsx(P2,{"aria-hidden":"true"}),"Download"]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:p?R.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:p,className:Du+" ml-2",children:[R.jsx(W1,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:qK(o)}:null,children:e?R.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?m?R.jsx(vA,{value:n,editable:a,onChange:h,dark:u,testId:"output-view"}):R.jsx(iE,{text:n,testId:"output-table",dark:u}):R.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."})})})}function QK({phase:t,message:e,onRetry:n}){return t==="loading"?R.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?R.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[R.jsx("span",{children:"This data doesn't exist (or was deleted)."}),R.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?R.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[R.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),R.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):R.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[R.jsx("span",{children:e||"Couldn't load this data."}),R.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const yy=20,vy=80,sS=50;function pm(t){return Math.min(vy,Math.max(yy,t))}function JK({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=w.useRef(null),[l,a]=w.useState(!1),u=t==="stacked";w.useEffect(()=>{if(!l)return;const f=d=>{var x;const p=(x=o.current)==null?void 0:x.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const m=u?(d.clientY-p.top)/p.height:(d.clientX-p.left)/p.width;n(pm(m*100))},h=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)}},[l,u,n]);const c=f=>{const h=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(pm(e-h));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(pm(e+h));break;case"Home":f.preventDefault(),n(yy);break;case"End":f.preventDefault(),n(vy);break;case"Enter":case" ":f.preventDefault(),n(sS);break}};return R.jsxs("div",{ref:o,className:Xi("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[R.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:Xi("flex min-h-0 min-w-0 flex-col border-border bg-panel","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),R.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-panel",children:i}),R.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":yy,"aria-valuemax":vy,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var h,d;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(d=(h=f.currentTarget).setPointerCapture)==null||d.call(h,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(sS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:Xi("absolute z-10","top-[var(--split)] left-0 right-0 h-0 cursor-row-resize","md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:cursor-col-resize"),children:[R.jsx("div",{className:Xi("absolute","left-0 right-0 -top-1.5 h-3","md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?R.jsx("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:s}):null]})]})}function ZK({theme:t}){return t==="dark"?R.jsx(hI,{size:15,strokeWidth:2,"aria-hidden":"true"}):R.jsx(rI,{size:15,strokeWidth:2,"aria-hidden":"true"})}function eX({theme:t,onToggleTheme:e,slot:n}){return R.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[R.jsxs("div",{className:"flex items-baseline gap-2",children:[R.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),R.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),R.jsx("div",{className:"flex-1"}),R.jsx("div",{"data-testid":"topbar-slot",children:n}),R.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx(ZK,{theme:t})})]})}function tX(t){return[...t].sort((e,n)=>n.id-e.id)}const xA=[{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],nX=864e5;function oS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function rX(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((oS(r)-oS(n))/nX);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const bA="csvjson:changelog.v1",Dh=Math.max(...xA.map(t=>t.id),0),iX=tX(xA);function sX(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!oX(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function oX(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function kA(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Dh).sort((e,n)=>e-n)}function lS(t,e,n){const r=kA(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function lX(){try{const t=window.localStorage.getItem(bA);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return sX(e)?{...e,pendingIds:kA(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function aX(t){try{window.localStorage.setItem(bA,JSON.stringify(t))}catch{}}function uX(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.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)}`}async function cX(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function aS(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function fX({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return R.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[R.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&R.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),R.jsx("span",{className:"text-[11px] text-muted-foreground",children:rX(t.date)})]}),R.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),R.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),R.jsxs("div",{className:"mt-1.5 flex gap-1",children:[R.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:aS(e===1),children:R.jsx(vI,{size:13,strokeWidth:2,"aria-hidden":"true"})}),R.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:aS(e===-1),children:R.jsx(mI,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&R.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function hX(){const[t,e]=w.useState(lX),[n,r]=w.useState(!1),i=w.useRef(t),s=w.useCallback(b=>{aX(b),i.current=b,e(b)},[]),[o,l]=w.useState(()=>new Set),a=w.useRef(new Set),u=w.useRef(null),c=w.useRef(null),f=w.useRef(new Map),h=t.lastSeenId!==null&&Dh>t.lastSeenId,d=w.useCallback((b,C)=>{l(T=>{const E=new Set(T);return C?E.add(b):E.delete(b),E})},[]),p=w.useCallback((b,C,T,E)=>{const A=(f.current.get(b)??0)+1;f.current.set(b,A),a.current.add(b),E&&d(b,!0),cX(T,b,C).then(P=>{f.current.get(b)===A&&(a.current.delete(b),P==="ok"&&(DP({entry_id:b,vote:C}),s(lS(i.current,b,!1))),E&&d(b,!1))})},[s,d]),m=w.useCallback(b=>{const{clientId:C,pendingIds:T,votes:E}=i.current,A=T??[];if(A.length!==0&&C!==void 0)for(const P of A){if(P===b||a.current.has(P))continue;const D=E[P];D!==void 0&&p(P,D,C,!1)}},[p]),x=(b,C)=>{if(t.votes[b]===C){m();return}const T=t.clientId??uX();s(lS({...t,votes:{...t.votes,[b]:C},clientId:T},b,!0)),p(b,C,T,!0),m(b)},v=()=>{r(!0),IP(),t.lastSeenId!==Dh&&s({...t,lastSeenId:Dh}),m()},g=w.useCallback(()=>{r(!1)},[]),y=w.useRef(!1);w.useEffect(()=>{var b;y.current&&!n&&((b=c.current)==null||b.focus()),y.current=n},[n]);const k=w.useRef(!1);return w.useEffect(()=>{k.current||(k.current=!0,m())},[m]),w.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&g()},C=T=>{const E=u.current;E===null||!(T.target instanceof Node)||E.contains(T.target)||g()};return document.addEventListener("keydown",b),document.addEventListener("click",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",C)}},[n,g]),R.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[R.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?g():v(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[R.jsx(sI,{size:15,strokeWidth:2,"aria-hidden":"true"}),h&&R.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&R.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[R.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[R.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),R.jsx("button",{type:"button","data-testid":"changelog-close",onClick:g,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:R.jsx(D2,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),R.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:iX.map(b=>{var C;return R.jsx(fX,{entry:b,vote:t.votes[b.id],queued:((C=t.pendingIds)==null?void 0:C.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function dX(t,e){const[n,r]=w.useState(t);return w.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function pX(t){const[e,n]=w.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return w.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const gX={},mX=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],yX=["csv2json","json2csv","csvjson2json"];function vX(t){return yX.includes(t)}const wX=/^[0-9a-f]{32}$/i,xX=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,gm=gX,bX=((gm==null?void 0:gm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function kX(t){const e=xX.exec(t);if(!e)return null;const n=e[1].toLowerCase();return mX.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class wy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class mm extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const ym={csv:(t,e)=>{t.direction="csv2json",t.input=zd(e)},json:(t,e)=>{t.input=zd(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function zd(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function uS(t){return typeof t=="string"&&t.trim()!==""}function Ll(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function SX(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function CX(t){var i;if(!SX(t))return null;const e=uS(t.csv),n=uS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=ym[s])==null||i.call(ym,r,o);return r.input=zd(e?t.csv:t.json),r}async function TX(t){if(!wX.test(t))throw new wy;let e;try{e=await fetch(`${bX}${t}`,{mode:"cors"})}catch(r){throw new mm("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new wy;if(!e.ok)throw new mm(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new mm("Stored data for this link is malformed")}return n}function EX(t){const e=w.useMemo(()=>t&&vX(t.tool)?t.id:null,[t]),[n,r]=w.useState(0),[i,s]=w.useState(e?"loading":"idle"),[o,l]=w.useState(null),[a,u]=w.useState("");return w.useEffect(()=>{if(!e)return;let c=!1;return TX(e).then(f=>{if(c)return;const h=CX(f);h?(l(h),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof wy?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}var xy={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var p={},m;return s.forEach(function(x,v){var g=new RegExp(x,"g");p[x]=(d.match(g)||[]).length,m=!m||p[x]>p[m]?x:m}),m}function u(){var d=[].slice.call(arguments),p=d.reduce(function(m,x){return m.length>x.length?m:x},[]);return p.map(function(m,x){return d.map(function(v){return v[x]})})}function c(d){for(var p={},m=0;m=0;m--){var x=d[m];p[x]>0&&(x=x+"__"+p[x]--),v.unshift(x)}return v}function f(d,p){if(p||(p={}),d.length==0)throw r;var m=p.separator||a(d);if(!m)throw n;var x=[];try{o=p.trim!==!1;var x=h.parse(d,l[m])}catch(O){var v=d.lastIndexOf(` +`;function Xf(t,e){return Math.max(0,Math.min(t,e))}function Mb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Xf(a.x,r+i),c=Xf(a.x+a.width,r+i);if(c<=r)continue;const f=u-r,h=c-r;if(h<=f)continue;const d=Xf(a.y,e.length),p=Xf(a.y+a.height,e.length);if(p<=d)continue;const m=t.headers.slice(f,h),x=[];for(let v=d;vy[f+b]??""))}x.length!==0&&s.push(Yu(m,x,t.delimiter))}if(s.length>0)return s.join(E6);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return Yu(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(h=>f[h-r]??"")});return Yu(a,u,t.delimiter)}return null}const Ab=24,Rb=26,Ob=110,Pb=40,M6=12,Nn=1,Ib='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',Db='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',wu="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50";function A6(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Db,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Db,lineHeight:1}}function R6(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function lE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i}){const s=w.useRef(null),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(""),[c,f]=w.useState(""),[h,d]=w.useState(null),[p,m]=w.useState(void 0),[x,v]=w.useState(()=>new Set),g=w.useRef(x),[y,k]=w.useState(0),b=i!==void 0,C=w.useMemo(()=>A6(r),[r]),T=R6(r),E=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",A=w.useRef();A.current===void 0&&(A.current=new w6);const P=w.useMemo(()=>vp(t,e),[t,e]),_=w.useMemo(()=>S6(P),[P]),O=P.headers.length,D=w.useRef({text:t,table:P});D.current={text:t,table:P};const I=w.useRef(p);I.current=p,w.useEffect(()=>{const H=window.setTimeout(()=>f(a),150);return()=>window.clearTimeout(H)},[a]);const Q=w.useMemo(()=>{const H=C6(P.rows,c);return h?T6(H,P.rows,h.col,h.dir,_[h.col]??!1):H},[P,c,h,_]),X=w.useRef(Q);X.current=Q,w.useEffect(()=>{const H=o.current;if(!H||typeof ResizeObserver>"u")return;const V=new ResizeObserver(()=>k(H.clientWidth));return V.observe(H),k(H.clientWidth),()=>V.disconnect()},[]);const le=Math.max(Ob,Math.floor((y-Pb)/Math.max(1,O)));w.useEffect(()=>{v(H=>{let V=!1;const Z=new Set;for(const ue of H)ue{m(H=>{if(!H||H.rows.length===0)return H;const V=[];for(const ue of g.current){const se=Q.indexOf(ue);se!==-1&&V.push(se)}V.sort((ue,se)=>ue-se);const Z=V.reduce((ue,se)=>ue.add(se),St.empty());return Z.equals(H.rows)?H:{...H,rows:Z}})},[Q]),w.useEffect(()=>{d(H=>H!==null&&H.col>=O?null:H)},[O]);const j=c!=="",ne=P.rows.length,Y=Rb+Math.min(Q.length,M6)*Ab,M=()=>{u(""),f("")},F=w.useCallback(H=>{if(H!Z||Z.col!==V?{col:V,dir:"asc"}:Z.dir==="asc"?{col:V,dir:"desc"}:null)},[]),z=w.useCallback((H,V)=>{const Z=X.current,ue=Z[V];if(ue===void 0)return;const se=g.current,tt=l.current;let pe;if(H.shiftKey&&tt!==null&&tt!==ue){const Me=Z.indexOf(tt),Ve=Z.indexOf(ue),dt=Me===-1?Ve:Me,[An,un]=dt<=Ve?[dt,Ve]:[Ve,dt];pe=H.metaKey||H.ctrlKey?new Set(se):new Set;for(let ct=An;ct<=un;ct++){const vn=Z[ct];vn!==void 0&&pe.add(vn)}}else H.metaKey||H.ctrlKey?(pe=new Set(se),pe.has(ue)?pe.delete(ue):pe.add(ue)):pe=new Set([ue]);l.current=ue,g.current=pe,v(pe);const De=[...pe].map(Me=>Z.indexOf(Me)).filter(Me=>Me!==-1).sort((Me,Ve)=>Me-Ve);m(Me=>({current:Me==null?void 0:Me.current,columns:(Me==null?void 0:Me.columns)??St.empty(),rows:De.reduce((Ve,dt)=>Ve.add(dt),St.empty())}))},[]),W=w.useCallback(()=>{l.current=null,g.current=new Set,v(new Set),m(void 0)},[]),B=w.useCallback(H=>{const V=new Set;for(const Z of H.rows){const ue=X.current[Z];ue!==void 0&&V.add(ue)}g.current=V,v(V),m(H)},[]),de=w.useCallback(()=>{W()},[W]),ge=w.useMemo(()=>Q.filter(H=>x.has(H)),[Q,x]),ae=w.useMemo(()=>[...(p==null?void 0:p.columns)??[]].filter(H=>H>=Nn).map(H=>H-Nn),[p]),Re=ae.length,nt=ge.length>0||Re>0,Ze=()=>{var Z;const H=I.current,V=Mb(D.current.table,X.current,{ranges:H!=null&&H.current?[H.current.range,...H.current.rangeStack]:[],columns:H?[...H.columns]:[],rows:H?[...H.rows]:[]},Nn);V!==null&&((Z=navigator.clipboard)==null||Z.writeText(V).catch(()=>{}))};w.useEffect(()=>{const H=V=>{var pe;const Z=s.current;if(!Z||!Z.contains(document.activeElement))return;const ue=document.activeElement;if(ue&&(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.isContentEditable))return;const se=I.current,tt=Mb(D.current.table,X.current,{ranges:se!=null&&se.current?[se.current.range,...se.current.rangeStack]:[],columns:se?[...se.columns]:[],rows:se?[...se.rows]:[]},Nn);tt!==null&&(V.preventDefault(),V.stopImmediatePropagation(),(pe=V.clipboardData)==null||pe.setData("text/plain",tt))};return window.addEventListener("copy",H,{capture:!0}),()=>window.removeEventListener("copy",H,{capture:!0})},[]);const Ge=w.useCallback(H=>{W(),i==null||i(H)},[W,i]),Ye=O>0&&ae.length>=O,it=()=>{!b||ge.length===0||Ge(Gg(D.current.table,ge))},rt=()=>{!b||Ye||ae.length===0||Ge(Tb(D.current.table,ae))},Dt=w.useCallback(H=>{if(!i)return!1;const{table:Z}=D.current,ue=X.current;if(H.rows.length>0){const pe=[...H.rows].map(De=>ue[De]).filter(De=>De!==void 0);if(pe.length>0)return Ge(Gg(Z,pe)),!1}if(H.columns.length>0){const pe=[...H.columns].filter(De=>De>=Nn&&DeDe-Nn);return pe.length>0&&pe.length0&&Ge(Gg(Z,tt)),!1},[Ge,i]),Ie=w.useCallback(H=>{const V=i;if(!V)return!1;const{text:Z,table:ue}=D.current,se=X.current,tt=[...H].sort((Me,Ve)=>Me.location[1]-Ve.location[1]);let pe=Z,De=0;for(const{location:Me,value:Ve}of tt){const dt=Me[0]-Nn,An=Me[1];if(dt<0||Ve.kind!==ke.Text)continue;const un=se[An],ct=un===void 0?void 0:ue.rowSpans[un];if(!ct)continue;const vn=pe.slice(ct.start+De,ct.end+De),cn=k6(vn,ue.delimiter);for(;cn.length<=dt;)cn.push("");const $r=Ve.data??"";if(cn[dt]===$r)continue;cn[dt]=$r;const Hr=oE(cn,ue.delimiter);pe=pe.slice(0,ct.start+De)+Hr+pe.slice(ct.end+De),De+=Hr.length-(ct.end-ct.start)}return pe!==Z&&V(pe),!0},[i]),be=w.useCallback(H=>{var tt;const[V,Z]=H,ue=X.current[Z];if(V{const V=[];for(let Z=H.y;Z{H[0]>=Nn||z(V,H[1])},[z]),et=w.useMemo(()=>{const H={title:"#",id:"__gutter",width:Pb,themeOverride:{baseFontStyle:`11px ${Ib}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},V=P.headers.map((Z,ue)=>({title:Z.toUpperCase(),id:`c${ue}`,width:le,themeOverride:_[ue]?{baseFontStyle:`12px ${Ib}`}:void 0}));return[H,...V]},[P.headers,_,le]),Be=w.useCallback((H,V)=>{const{ctx:Z,columnIndex:ue,rect:se,theme:tt,isSelected:pe}=H;Z.save();try{if(Z.letterSpacing="0.5px",pe&&(Z.fillStyle=tt.bgHeaderHovered,Z.fillRect(se.x,se.y,se.width,se.height),Z.fillStyle=tt.accentColor,Z.fillRect(se.x,se.y+se.height-2,se.width,2)),ue{const{ctx:Z,cell:ue,rect:se,col:tt,theme:pe}=H,De=tt-Nn;if(De>=0&&j&&ue.kind===ke.Text){const Me=O6(ue.data,c);if(Me!==null){Z.save();try{const Ve=`${pe.baseFontStyle} ${pe.fontFamily}`;Z.font=Ve;let dt=se.x+pe.cellHorizontalPadding;const An=se.y+se.height/2+Is(Z,Ve);for(const un of Me){const ct=Z.measureText(un.text).width;un.hit&&ct>0&&(Z.fillStyle=T,Z.fillRect(dt-1,An-7,ct+2,14)),dt+=ct}}finally{Z.restore()}}}if(V(),De>=0&&ue.kind===ke.Text&&ue.data===""){Z.save();try{Z.font=`${pe.baseFontStyle} ${pe.fontFamily}`,Z.fillStyle=pe.textLight,Z.fillText("—",se.x+pe.cellHorizontalPadding,se.y+se.height/2+.5)}finally{Z.restore()}}},[j,c,T]),_e=w.useCallback(H=>{const V=X.current[H];return V!==void 0&&g.current.has(V)?{bgCell:E,bgCellMedium:E}:void 0},[E]);return O===0?R.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):R.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:s,children:[R.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[R.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[R.jsx(fI,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),R.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:a,onChange:H=>u(H.target.value),onKeyDown:H=>{H.key==="Escape"&&M()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),a!==""&&R.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:M,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx(L2,{"aria-hidden":"true",className:"size-3"})})]}),R.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:j?`${Q.length.toLocaleString()} of ${ne.toLocaleString()}`:`${ne.toLocaleString()} rows`}),nt&&R.jsxs("span",{className:"flex items-center gap-1.5",children:[R.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:ge.length>0?`${ge.length.toLocaleString()} selected`:`${Re.toLocaleString()} ${Re===1?"column":"columns"} selected`}),R.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Ze,className:wu,children:[R.jsx(wv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),b&&ge.length>0&&R.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:it,title:`Deletes the ${ge.length} selected ${ge.length===1?"row":"rows"} from the source CSV`,className:wu,children:[R.jsx(f0,{"aria-hidden":"true",className:"size-3"}),"Delete ",ge.length.toLocaleString()," ",ge.length===1?"row":"rows"]}),b&&Re>0&&R.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:rt,disabled:Ye,title:Ye?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Re} selected ${Re===1?"column":"columns"} from the source CSV`,className:`${wu} disabled:cursor-not-allowed disabled:opacity-50`,children:[R.jsx(f0,{"aria-hidden":"true",className:"size-3"}),"Delete ",Re.toLocaleString()," ",Re===1?"column":"columns"]}),R.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:W,className:wu,children:"Clear"})]})]}),R.jsxs("div",{ref:o,"data-testid":n,role:"grid","aria-rowcount":Q.length+1,className:"relative min-h-0 flex-1",style:{minHeight:Y},children:[R.jsx("div",{className:"absolute inset-0",children:R.jsx(OW,{imageWindowLoader:A.current,renderers:h6,columns:et,rows:Q.length,getCellContent:be,getCellsForSelection:Xe,onCellsEdited:b?Ie:void 0,onDelete:b?Dt:void 0,onCellClicked:qe,onHeaderClicked:F,onGridSelectionChange:B,onSelectionCleared:de,gridSelection:p,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:Ab,headerHeight:Rb,freezeColumns:Nn,fillHandle:b,onPaste:b?()=>!0:!1,keybindings:{search:!1},theme:C,drawHeader:Be,drawCell:ye,getRowThemeOverride:_e,minColumnWidth:Ob,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),j&&Q.length===0&&R.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[R.jsxs("span",{children:["No rows matching “",c,"”."]}),R.jsx("button",{type:"button",onClick:M,className:wu,children:"Show all rows"})]}),!j&&Q.length===0&&R.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:R.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function O6(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=w.useRef(null);w.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return R.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3",children:R.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-3",children:[R.jsx("div",{"aria-hidden":"true",className:"flex size-11 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground",children:R.jsx(tI,{className:"size-5"})}),R.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),R.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=_6(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),R.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",R.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),R.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[R.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[R.jsx(N2,{"aria-hidden":"true"}),"Choose file"]}),R.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[R.jsx(dI,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let P0=[],aE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=aE[r])e=r+1;else return!0;if(e==n)return!1}}function _b(t){return t>=127462&&t<=127487}const Nb=8205;function F6(t,e,n=!0,r=!0){return(n?uE:B6)(t,e,r)}function uE(t,e,n){if(e==t.length)return e;e&&cE(t.charCodeAt(e))&&fE(t.charCodeAt(e-1))&&e--;let r=qg(t,e);for(e+=Lb(r);e=0&&_b(qg(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function B6(t,e,n){for(;e>1;){let r=uE(t,e-2,n);if(r=56320&&t<57344}function fE(t){return t>=55296&&t<56320}function Lb(t){return t<65536?1:2}class Ct{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Ta(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Ki.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Ta(this,e,n);let r=[];return this.decompose(e,n,r,0),Ki.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Qu(this),s=new Qu(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new Qu(this,e)}iterRange(e,n=this.length){return new hE(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new dE(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]?Ct.empty:e.length<=32?new gn(e):Ki.from(gn.split(e,[]))}}class gn extends Ct{constructor(e,n=z6(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new $6(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new gn(Fb(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Oh(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new gn(l,o.length+s.length));else{let a=l.length>>1;r.push(new gn(l.slice(0,a)),new gn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof gn))return super.replace(e,n,r);[e,n]=Ta(this,e,n);let i=Oh(this.text,Oh(r.text,Fb(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new gn(i,s):Ki.from(gn.split(i,[]),s)}sliceString(e,n=this.length,r=` +`){[e,n]=Ta(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new gn(r,i)),r=[],i=-1);return i>-1&&n.push(new gn(r,i)),n}}class Ki extends Ct{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Ta(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new Ki(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=Ta(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Ki))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new gn(d,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof Ki)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(h(),l.push(d)):d instanceof gn&&a&&(p=c[c.length-1])instanceof gn&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new gn(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>i&&h(),a+=d.lines,u+=d.length+1,c.push(d))}function h(){a!=0&&(l.push(c.length==1?c[0]:Ki.from(c,u)),u=-1,a=c.length=0)}for(let d of e)f(d);return h(),l.length==1?l[0]:new Ki(l,n)}}Ct.empty=new gn([""],0);function z6(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Oh(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof gn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof gn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(i instanceof gn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof gn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class hE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new Qu(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<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)*n,this.value=i.length<=r?i:n<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 dE{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(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"&&(Ct.prototype[Symbol.iterator]=function(){return this.iter()},Qu.prototype[Symbol.iterator]=hE.prototype[Symbol.iterator]=dE.prototype[Symbol.iterator]=function(){return this});class $6{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Ta(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function Jn(t,e,n=!0,r=!0){return F6(t,e,n,r)}function H6(t){return t>=56320&&t<57344}function j6(t){return t>=55296&&t<56320}function W6(t,e){let n=t.charCodeAt(e);if(!j6(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return H6(r)?(n-55296<<10)+(r-56320)+65536:n}function V6(t){return t<65536?1:2}const I0=/\r\n?|\n/;var pr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(pr||(pr={}));class is{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=pr.Simple&&u>=e&&(r==pr.TrackDel&&ie||r==pr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new is(e)}static create(e){return new is(e)}}class Cn extends is{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return D0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return _0(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&so(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;oh||f<0||h>n)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${n})`);let p=d?typeof d=="string"?Ct.of(d.split(r||I0)):d:Ct.empty,m=p.length;if(f==h&&m==0)return;fo&&Yn(i,f-o,-1),Yn(i,h-f,m),so(s,i,p),o=h}}return u(e),a(!l),l}static empty(e){return new Cn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function so(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function _0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Sc(t),l=new Sc(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);Yn(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Sc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Ct.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Ct.empty:n[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 eo{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new eo(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return fe.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return fe.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return fe.range(e.anchor,e.head)}static create(e,n,r,i){return new eo(e,n,r,i)}}class fe{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:fe.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.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 fe(e.ranges.map(n=>eo.fromJSON(n)),e.main)}static single(e,n=e){return new fe([fe.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?fe.range(a,l):fe.range(l,a))}}return new fe(e,n)}}function gE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Kv=0;class Le{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Kv++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Le(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Xv),!!e.static,e.enables)}of(e){return new Ph([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ph(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ph(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Xv(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Ph{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Kv++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,h){if(a&&h.docChanged||u&&(h.docChanged||h.selection)||N0(f,c)){let d=r(f);if(l?!Bb(d,f.values[o],i):!i(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[s];if(p!=null){let m=bd(h,p);if(this.dependencies.every(x=>x instanceof Le?h.facet(x)===f.facet(x):x instanceof as?h.field(x,!1)==f.field(x,!1):!0)||(l?Bb(d=r(f),m,i):i(d=r(f),m)))return f.values[o]=m,0}else d=r(f);return f.values[o]=d,1}}}get extension(){return this}}function Bb(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Gf).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(Gf),o=i.facet(Gf),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Gf.of({field:this,create:e})]}get extension(){return this}}const Uo={lowest:4,low:3,default:2,high:1,highest:0};function xu(t){return e=>new mE(e,t)}const Gv={highest:xu(Uo.highest),high:xu(Uo.high),default:xu(Uo.default),low:xu(Uo.low),lowest:xu(Uo.lowest)};class mE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class Ea{of(e){return new L0(this,e)}reconfigure(e){return Ea.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class L0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class xd{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let h of K6(e,n,o))h instanceof as?i.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let l=Object.create(null),a=[],u=[];for(let h of i)l[h.id]=u.length<<1,u.push(d=>h.slot(d));let c=r==null?void 0:r.config.facets;for(let h in s){let d=s[h],p=d[0].facet,m=c&&c[h]||[];if(d.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,Xv(m,d))a.push(r.facet(p));else{let x=p.combine(d.map(v=>v.value));a.push(r&&p.compare(x,r.facet(p))?r.facet(p):x)}else{for(let x of d)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(v=>x.dynamicSlot(v)));l[p.id]=u.length<<1,u.push(x=>U6(x,p,d))}}let f=u.map(h=>h(l));return new xd(e,o,f,l,a,s)}}function K6(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof L0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof L0){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof mE)s(o.inner,o.prec);else if(o instanceof as)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Ph)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,Uo.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,Uo.default),r.reduce((o,l)=>o.concat(l))}function Ju(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function bd(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const yE=Le.define(),F0=Le.define({combine:t=>t.some(e=>e),static:!0}),vE=Le.define({combine:t=>t.length?t[0]:void 0,static:!0}),wE=Le.define(),xE=Le.define(),bE=Le.define(),kE=Le.define({combine:t=>t.length?t[0]:!1});class Ao{constructor(e,n){this.type=e,this.value=n}static define(){return new X6}}class X6{of(e){return new Ao(this,e)}}class G6{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new G6(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}Ft.reconfigure=Ft.define();Ft.appendConfig=Ft.define();class Mn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&gE(r,n.newLength),s.some(l=>l.type==Mn.time)||(this.annotations=s.concat(Mn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new Mn(e,n,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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Mn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Mn.time=Ao.define();Mn.userEvent=Ao.define();Mn.addToHistory=Ao.define();Mn.remote=Ao.define();function q6(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof Mn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Mn?t=s[0]:t=CE(e,fa(s),!1)}return t}function Q6(t){let e=t.startState,n=e.facet(bE),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=SE(r,B0(e,s,t.changes.newLength),!0))}return r==t?t:Mn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const J6=[];function fa(t){return t==null?J6:Array.isArray(t)?t:[t]}var Ss=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ss||(Ss={}));const Z6=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let z0;try{z0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function e9(t){if(z0)return z0.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||Z6.test(n)))return!0}return!1}function t9(t){return e=>{if(!/\S/.test(e))return Ss.Space;if(e9(e))return Ss.Word;for(let n=0;n-1)return Ss.Word;return Ss.Other}}class Mt{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(Ft.reconfigure)?(n=null,r=l.value):l.is(Ft.appendConfig)&&(n=null,r=fa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=xd.resolve(r,i,this),s=new Mt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(F0)?e.newSelection:e.newSelection.asSingle();new Mt(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:fe.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=fa(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return Mt.create({doc:e.doc,selection:fe.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=xd.resolve(e.extensions||[],new Map),r=e.doc instanceof Ct?e.doc:Ct.of((e.doc||"").split(n.staticFacet(Mt.lineSeparator)||I0)),i=e.selection?e.selection instanceof fe?e.selection:fe.single(e.selection.anchor,e.selection.head):fe.single(0);return gE(i,r.length),n.staticFacet(F0)||(i=i.asSingle()),new Mt(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Mt.tabSize)}get lineBreak(){return this.facet(Mt.lineSeparator)||` +`}get readOnly(){return this.facet(kE)}phrase(e,...n){for(let r of this.facet(Mt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(yE))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return t9(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=Jn(n,o,!1);if(s(n.slice(a,o))!=Ss.Word)break;o=a}for(;lt.length?t[0]:4});Mt.lineSeparator=vE;Mt.readOnly=kE;Mt.phrases=Le.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});Mt.languageData=yE;Mt.changeFilter=wE;Mt.transactionFilter=xE;Mt.transactionExtender=bE;Ea.reconfigure=Ft.define();function TE(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,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 ol{eq(e){return this==e}range(e,n=e){return $0.create(e,n,this)}}ol.prototype.startSide=ol.prototype.endSide=0;ol.prototype.point=!1;ol.prototype.mapMode=pr.TrackDel;function qv(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let $0=class EE{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new EE(e,n,r)}};function H0(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Yv{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sd||h==d&&u.startSide>0&&u.endSide<=0)continue;(d-h||u.endSide-u.startSide)<0||(o<0&&(o=h),u.point&&(l=Math.max(l,d-h)),r.push(u),i.push(h-o),s.push(d-o))}return{mapped:r.length?new Yv(i,s,r,l):null,pos:o}}}class Ot{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Ot(e,n,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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(H0)),this.isEmpty)return n.length?Ot.of(n):this;let l=new ME(this,null,-1).goto(0),a=0,u=[],c=new Ma;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return Cc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Cc.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=zb(o,l,r),u=new bu(o,a,s),c=new bu(l,a,s);r.iterGaps((f,h,d)=>$b(u,f,c,h,d,i)),r.empty&&r.length==0&&$b(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=zb(s,o),a=new bu(s,l,0).goto(r),u=new bu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!j0(a.active,u.active)||a.point&&(!u.point||!qv(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new bu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new Ma;for(let i of e instanceof $0?[e]:n?n9(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Ot.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Ot.empty;i=i.nextLayer)n=new Ot(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Ot.empty=new Ot([],[],null,-1);function n9(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(H0);e=r}return t}Ot.empty.nextLayer=Ot.empty;class Ma{finishChunk(e){this.chunks.push(new Yv(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new Ma)).add(e,n,r)}addInner(e,n,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(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Ot.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Ot.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function zb(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new ME(o,n,r,s));return i.length==1?i[0]:new Cc(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Yg(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Yg(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Yg(this.heap,0)}}}function Yg(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class bu{constructor(e,n,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=Cc.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){qf(this.active,e),qf(this.activeTo,e),qf(this.activeRank,e),this.minActive=Hb(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;Yf(this.active,n,r),Yf(this.activeTo,n,i),Yf(this.activeRank,n,s),e&&Yf(e,n,this.cursor.from),this.minActive=Hb(this.active,this.activeTo)}next(){let e=this.to,n=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&&qf(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(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function $b(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,h=f||t.endSide-n.endSide,d=h<0?t.to+a:n.to,p=Math.min(d,o);if(t.point||n.point?(t.point&&n.point&&qv(t.point,n.point)&&j0(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!j0(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=d,h<=0&&t.next(),h>=0&&n.next()}}function j0(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Hb(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=Jn(t,i)}return t.length}const W0="ͼ",jb=typeof Symbol>"u"?"__"+W0:Symbol.for(W0),V0=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Wb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class xo{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),h=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(i(d),p,c,h)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||h)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Wb[jb]||1;return Wb[jb]=e+1,W0+e.toString(36)}static mount(e,n,r){let i=e[V0],s=r&&r.nonce;i?s&&i.setNonce(s):i=new i9(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let Vb=new Map;class i9{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=Vb.get(r);if(s)return e[V0]=s;this.sheet=new i.CSSStyleSheet,Vb.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[V0]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},s9=typeof navigator<"u"&&/Mac/.test(navigator.platform),o9=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var zn=0;zn<10;zn++)bo[48+zn]=bo[96+zn]=String(zn);for(var zn=1;zn<=24;zn++)bo[zn+111]="F"+zn;for(var zn=65;zn<=90;zn++)bo[zn]=String.fromCharCode(zn+32),Tc[zn]=String.fromCharCode(zn);for(var Qg in bo)Tc.hasOwnProperty(Qg)||(Tc[Qg]=bo[Qg]);function l9(t){var e=s9&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||o9&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Tc:bo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function Xi(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Te={mac:Xb||/Mac/.test(sr.platform),windows:/Win/.test(sr.platform),linux:/Linux|X11/.test(sr.platform),ie:xp,ie_version:RE?U0.documentMode||6:X0?+X0[1]:K0?+K0[1]:0,gecko:Ub,gecko_version:Ub?+(/Firefox\/(\d+)/.exec(sr.userAgent)||[0,0])[1]:0,chrome:!!Jg,chrome_version:Jg?+Jg[1]:0,ios:Xb,android:/Android\b/.test(sr.userAgent),webkit:Kb,webkit_version:Kb?+(/\bAppleWebKit\/(\d+)/.exec(sr.userAgent)||[0,0])[1]:0,safari:G0,safari_version:G0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(sr.userAgent)||[0,0])[1]:0,tabSize:U0.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Qv(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const kd=Object.create(null);function Jv(t,e,n){if(t==e)return!0;t||(t=kd),e||(e=kd);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function a9(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function Gb(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function u9(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new ll(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=OE(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new ll(e,r,i,n,e.widget||null,!0)}static line(e){return new Gc(e)}static set(e,n=!1){return Ot.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}It.none=Ot.empty;class Xc extends It{constructor(e){let{start:n,end:r}=OE(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Qv(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||kd}eq(e){return this==e||e instanceof Xc&&this.tagName==e.tagName&&Jv(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Xc.prototype.point=!1;class Gc extends It{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Gc&&this.spec.class==e.spec.class&&Jv(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Gc.prototype.mapMode=pr.TrackBefore;Gc.prototype.point=!0;class ll extends It{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?pr.TrackBefore:pr.TrackAfter:pr.TrackDel}get type(){return this.startSide!=this.endSide?ti.WidgetRange:this.startSide<=0?ti.WidgetBefore:ti.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof ll&&c9(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}ll.prototype.point=!0;function OE(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function c9(t,e){return t==e||!!(t&&e&&t.compare(e))}function ha(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class Ec extends ol{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ec&&this.tagName==e.tagName&&Jv(this.attributes,e.attributes)}static create(e){return new Ec(e.tagName,e.attributes||kd,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Ot.of(e,n)}}Ec.prototype.startSide=Ec.prototype.endSide=-1;function Mc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function q0(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Zu(t,e){if(!e.anchorNode)return!1;try{return q0(t,e.anchorNode)}catch{return!1}}function ec(t){return t.nodeType==3?Rc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function tc(t,e,n,r){return n?qb(t,e,n,r,-1)||qb(t,e,n,r,1):!1}function ko(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Sd(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function qb(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Os(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=ko(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?Os(t):0}else return!1}}function Os(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function f9(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function PE(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function h9(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let h,d=c==a.body,p=1,m=1;if(d)h=f9(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let g=c.getBoundingClientRect();({scaleX:p,scaleY:m}=PE(c,g)),h={left:g.left,right:g.left+c.clientWidth*p,top:g.top,bottom:g.top+c.clientHeight*m}}let x=0,v=0;if(i=="nearest")e.top0&&e.bottom>h.bottom+v&&(v=e.bottom-h.bottom+o)):e.bottom>h.bottom-o&&(v=e.bottom-h.bottom+o,n<0&&e.top-v0&&e.right>h.right+x&&(x=e.right-h.right+s)):e.right>h.right-s&&(x=e.right-h.right+s,n<0&&e.lefth.bottom||e.lefth.right)&&(e={left:Math.max(e.left,h.left),right:Math.min(e.right,h.right),top:Math.max(e.top,h.top),bottom:Math.min(e.bottom,h.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function IE(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class d9{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?Os(n):0),r,Math.min(e.focusOffset,r?Os(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function DE(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function _E(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let jo=null;Te.safari&&Te.safari_version>=26&&(jo=!1);function NE(t){if(t.setActive)return t.setActive();if(jo)return t.focus(jo);let e=DE(t);t.focus(jo==null?{get preventScroll(){return jo={preventScroll:!0},!0}}:void 0),jo||(jo=!1,_E(e))}let Yb;function Rc(t,e,n=e){let r=Yb||(Yb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function da(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,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,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function p9(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function g9(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,Os(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=Os(n))}else{if(n==t)return!0;r=ko(n),n=n.parentNode}}function LE(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function FE(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=Os(n)}else if(n.parentNode&&!Sd(n))r=ko(n),n=n.parentNode;else return null}}function BE(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function HE(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if($i[m+1]==-d){let x=$i[m+2],v=x&2?i:x&4?x&1?s:i:0;v&&(Lt[f]=Lt[$i[m]]=v),l=m;break}}else{if($i.length==189)break;$i[l++]=f,$i[l++]=h,$i[l++]=a}else if((p=Lt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let v=$i[x+2];if(v&2)break;if(m)$i[x+2]|=2;else{if(v&4)break;$i[x+2]|=4}}}}}function b9(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==x&&(p=n[--m].from,x=m?n[m-1].to:t),Lt[--p]=d;a=c}else s=u,a++}}}function Q0(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new Ji(a,m.from,d));let x=m.direction==al!=!(d%2);J0(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Lt[p]!=l:Lt[p]==l))break;p++}h?Q0(t,a,p,r+1,i,h,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Lt[a-1];m!=l&&(c=!1,f=m==16)}let h=!c&&l==1?[]:null,d=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let m=s[--u];if(!c)for(let x=m.from,v=u;;){if(x==e)break e;if(v&&s[v-1].to==x)x=s[--v].from;else{if(Lt[x-1]==l)break e;break}}if(h)h.push(m);else{m.toLt.length;)Lt[Lt.length]=256;let r=[],i=e==al?0:1;return J0(t,i,i,n,0,t.length,r),r}function jE(t){return[new Ji(0,t,0)]}let WE="";function S9(t,e,n,r,i){var s;let o=r.head-t.from,l=Ji.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let h=l+=i?1:-1;if(h<0||h>=e.length)return null;a=e[l=h],o=a.side(!i,n),u=a.side(i,n)}let c=Jn(t.text,o,a.forward(i,n));(ca.to)&&(c=u),WE=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),T9=Le.define({combine:t=>t.some(e=>e)}),QE=Le.define();class pa{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new pa(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 pa(fe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Qf=Ft.define({map:(t,e)=>t.map(e)}),JE=Ft.define();function Qr(t,e,n){let r=t.facet(XE);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const xs=Le.define({combine:t=>t.length?t[0]:!0});let E9=0;const ta=Le.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(bp.of(u=>{let c=u.plugin(l);return c?o(c):It.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return si.define((r,i)=>new e(r,i),n)}}class Zg{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Qr(n.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(n){Qr(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Qr(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ZE=Le.define(),nw=Le.define(),bp=Le.define(),eM=Le.define(),rw=Le.define(),qc=Le.define(),tM=Le.define();function Qb(t,e){let n=t.state.facet(tM);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Ot.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let h=l.length-1;h>=0;h--,a--){let d=l[h].spec.bidiIsolate,p;if(d==null&&(d=C9(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==d)p.to=c,f=p.inner;else{let m={from:u,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),i}const nM=Le.define();function iw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(nM)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const Iu=Le.define();class Jr{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new Jr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new Jr(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Cd(e,n,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 M9=[];class an{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return M9}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&a9(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;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,n,r){return null}domPosFor(e,n){let r=ko(this.dom),i=this.length?e>0:n>0;return new Ci(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 Sp)return e;return null}static get(e){return e.cmTile}}class kp extends an{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=Jb(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=Jb(i);this.length=o}}function Jb(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Sp extends kp{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=an.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ts)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ts extends kp{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ts(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class Aa extends kp{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new Aa(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let h=0,d=0;h=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&R9(o,p)))&&(m>f||p.flags&32&&n<=1)?(o=p,l=f-d):(d=-1)&&(i=p,s=f-d)),d=m}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):A9(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Ci(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new Ci(a.dom,0);a==r.tile&&(l=!0)}}return new Ci(this.dom,0)}}function A9(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ec(e);return n[n.length-1]||null}function R9(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Te.chrome||Te.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Te.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Ac(u,(l?l>0:n<0)==r)}static of(e,n){let r=new Yo(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class ul extends an{constructor(e,n,r,i){super(e,n,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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return Ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class O9{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof gr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(em(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=an.get(a.dom);f&&f.setDOM(em(a.dom))}let c=gr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=an.get(e.text);s&&this.cache.reused.set(s,2);let o=new Yo(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=rM);let i=Aa.start(e,n||((r=this.cache.find(Aa))===null||r===void 0?void 0:r.dom),!!n);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,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof gr&&l.mark.eq(o))i=l,n--;else{let a=gr.of(o,(r=this.cache.find(gr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Zb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Te.ios&&Zb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(tm,0,32)||new ul(tm.toDOM(),0,tm,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){let n=e.rank*102+e.value.rank,r=new P9(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(Td,void 0,1);return r&&(r.flags=n),r||new Td(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class D9{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 l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const Ed=[ul,Aa,Yo,gr,Td,Ts,Sp];for(let t=0;t[]),this.index=Ed.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof gr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof gr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Ot.spans(this.decorations,e,n,{point:(l,a,u,c,f,h)=>{if(u instanceof ll){if(this.disallowBlockEffectsFor[h]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let d=u.widget||(u.block?Ra.block:Ra.inline),p=L9(u),m=this.cache.findWidget(d,a-l,p)||ul.of(d,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(m)):(i.ensureLine(r),i.addInlineWidget(m,c,f))}r=null}else r=F9(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=an.get(i);if(i==this.view.contentDOM)break;s instanceof gr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ts||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new Aa(i,rM):r||n.push(gr.of(new Xc({tagName:i.nodeName.toLowerCase(),attributes:u9(i)}),i)))}return{line:r,marks:n}}}function Zb(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function L9(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const rM={class:"cm-line"};function F9(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Qv(n,t),r&&(t.class+=" "+r)),t}function B9(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof gr&&e.push(r.mark)}return e}function em(t){let e=an.get(t);return e&&e.setDOM(t.cloneNode()),t}class Ra extends Ua{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}}Ra.inline=new Ra("span");Ra.block=new Ra("div");const tm=new class extends Ua{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class ek{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=It.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 Sp(e,e.contentDOM),this.updateInner([new Jr(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.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&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!X9(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?$9(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new Jr(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Te.ie||Te.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=W9(o,this.decorations,e.changes);a.length&&(r=Jr.extendWithRanges(r,a));let u=U9(l,this.blockWrappers,e.changes);return u.length&&(r=Jr.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.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,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new N9(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&an.get(n.text)&&l.cache.reused.set(an.get(n.text),2),this.tile=l.run(e,n),ey(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Te.chrome||Te.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-1)&&Zu(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Te.gecko&&a.empty&&!this.hasComposition&&z9(u)){let h=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(h,u.node.childNodes[u.offset]||null)),u=c=new Ci(h,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!tc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!tc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Te.android&&Te.chrome&&r.contains(f.focusNode)&&K9(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let h=Mc(this.view.root);if(h)if(a.empty){if(Te.gecko){let d=H9(u.node,u.offset);if(d&&d!=3){let p=(d==1?FE:BE)(u.node,u.offset);p&&(u=new Ci(p.node,p.offset))}}h.collapse(u.node,u.offset),a.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=a.bidiLevel)}else if(h.extend){h.collapse(u.node,u.offset);try{h.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),d.setEnd(c.node,c.offset),d.setStart(u.node,u.offset),h.removeAllRanges(),h.addRange(d)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new Ci(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ci(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&tc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Mc(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){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[n];else{let o=Os(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!an.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof nm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ln.LTR,u=0,c=(f,h,d)=>{for(let p=0;pi);p++){let m=f.children[p],x=h+m.length,v=m.dom.getBoundingClientRect(),{height:g}=v;if(d&&!p&&(u+=v.top-d.top),m instanceof Ts)x>r&&c(m,h,v);else if(h>=r&&(u>0&&n.push(-u),n.push(g+u),u=0,o)){let y=m.dom.lastChild,k=y?ec(y):[];if(k.length){let b=k[k.length-1],C=a?b.right-v.left:v.right-b.left;C>l&&(l=C,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=x)}}d&&p==f.children.length-1&&(u+=d.bottom-v.bottom),h=x+m.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?ln.RTL:ln.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=ec(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=ec(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(It.replace({widget:new nm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return It.set(e)}updateDeco(){let e=1,n=this.view.state.facet(bp).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(rw).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Ot.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(QE))try{if(u(this.view,e.range,e))return!0}catch(c){Qr(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.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=iw(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(h9(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ey(this.tile)}}function ey(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ey(r,e)}}function z9(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function iM(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=FE(n.focusNode,n.focusOffset),i=BE(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=an.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=an.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.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 $9(t,e,n){let r=iM(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new Jr(a.mapPos(s),a.mapPos(o),s,o),text:i}}function H9(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class nm extends Ua{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 G9(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return fe.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=Jn(i.text,s,!1):l=Jn(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=Jn(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+r9(o,s,t.state.tabSize)}function Y9(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==ti.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function Q9(t,e,n,r){let i=Y9(t,e.head,e.assoc||-1),s=!r||i.type!=ti.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==ln.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return fe.cursor(a,n?-1:1)}return fe.cursor(n?i.to:i.from,n?-1:1)}function tk(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=S9(i,s,o,l,n),c=WE;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` +`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function J9(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Ss.Space&&(i=o),i==o}}function Z9(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return fe.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,h=t.viewState.heightOracle.textHeight>>1,d=r??h;for(let p=0;;p+=h){let m=l+(d+p)*s,x=ty(t,{x:f,y:m},!1,s);if(n?m>a.bottom:ml:g{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:fe.cursor(r,rt.viewState.docHeight)return new Gi(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==ti.Text){if(r<0?u.tot.viewport.to)break;let h=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(h&&(r<0?h.top<=a+s:h.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==ti.Text){let f=q9(t,i,u,o,l);return new Gi(f,f==u.from?1:-1)}}if(u.type!=ti.Text)return a<(u.top+u.bottom)/2?new Gi(u.from,1):new Gi(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new eV(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class eV{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(m)){for(let g=1;g=s&&(y-=p),!o.has(y)){m=y;break t}}break e}o.add(m);let x=n(m),v=0;if(x)for(let g=0;g1))if(y.bottomthis.y)(!u||u.top>y.top)&&(u=y),v=-1;else{let k=y.left>this.x?this.x-y.left:y.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+m+m)/3)return this.y=u.top+1,this.scan(e,n,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==ln.LTR;return{i:c,after:this.x>(h.left+h.right)/2==d}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return Rc(e.dom,o,l).getClientRects()});return i.after?new Gi(r[i.i+1],-1):new Gi(r[i.i],1)}scanTile(e,n){if(!e.length)return new Gi(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Rc(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new Gi(r[i.i+1],-1):new Gi(o,1)}}const zl="￿";class tV{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(Mt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=zl}readRange(e,n){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=an.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=an.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Sd(i))||Sd(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!rV(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=an.get(e),r=n&&n.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(nV(e,r.node,r.offset)?n:0))}}function nV(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=oM(e.docView.tile,n,r,0))){let a=s||o?[]:oV(e),u=new tV(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=lV(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!q0(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!q0(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Te.ios||Te.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(fe.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let h=e.coordsAtPos(u,-1),d=0;h&&(d=e.inputState.lastTouchY<=h.bottom?-1:1),this.newSel=fe.create([fe.cursor(u,d)])}else this.newSel=fe.single(c,u)}}}function oM(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return oM(f,e,n,u);if(h>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=h,u=h+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function lM(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Te.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(h=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Ct.of(e.text.slice(s.from-l,h).split(zl))}:(d=aM(f,e.text,u-l,c))&&(Te.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==zl+zl&&d.toB--,n={from:l+d.from,to:l+d.toA,insert:Ct.of(e.text.slice(d.from,d.toB).split(zl))})}else r&&(!t.hasFocus&&i.facet(xs)||Md(r,s))&&(r=null);if(!n&&!r)return!1;if((Te.mac||Te.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=fe.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Ct.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Te.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=fe.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:Ct.of([" "])}),n)return sw(t,n,r,o);if(r&&!Md(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=sM(i.facet(qc).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function sw(t,e,n,r=-1){if(Te.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Te.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&da(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&da(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&da(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=sV(t,e,n));return t.state.facet(GE).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function sV(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:fe.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,h=n&&iM(t,n.main.head);if(h){let p=e.insert.length-(e.to-e.from);f={from:h.from,to:h.to-p}}else f=t.state.doc.lineAt(s.head);let d=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let m=p.to-d,x=m-c.length;if(t.state.sliceDoc(x,m)!=c||m>=f.from&&x<=f.to)return{range:p};let v=i.changes({from:x,to:m,insert:e.insert}),g=p.to-s.to;return{changes:v,range:u?fe.range(Math.max(0,u.anchor+g),Math.max(0,u.head+g)):p.map(v)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function aM(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function oV(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new nk(n,r)),(i!=n||s!=r)&&e.push(new nk(i,s))),e}function lV(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?fe.single(n+e,r+e):null}function Md(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class aV{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Te.safari&&e.contentDOM.addEventListener("input",()=>null),Te.gecko&&CV(e.contentDOM.ownerDocument)}handleEvent(e){!yV(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=cV(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&cM.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Te.android&&Te.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Te.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(uM.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||fV.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Te.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&uV(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Te.safari&&!Te.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 uV(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function rk(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){Qr(n.state,i)}}}function cV(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(rk(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(rk(r.value,a))}}for(let r in Oi)n(r).handlers.push(Oi[r]);for(let r in ar)n(r).observers.push(ar[r]);return e}const uM=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],fV="dthko",cM=[16,17,18,20,91,92,224,225],Jf=6;function Zf(t){return Math.max(0,t)*.7+8}function hV(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class dV{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=IE(e.contentDOM),this.atoms=e.state.facet(qc).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Mt.allowMultipleSelections)&&pV(e,n),this.dragging=mV(e,n)&&dM(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&hV(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=iw(this.view);e.clientX-a.left<=i+Jf?n=-Zf(i-e.clientX):e.clientX+a.right>=o-Jf&&(n=Zf(e.clientX-o)),e.clientY-a.top<=s+Jf?r=-Zf(s-e.clientY):e.clientY+a.bottom>=l-Jf&&(r=Zf(e.clientY-l)),this.setScrollSpeed(n,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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=sM(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function pV(t,e){let n=t.state.facet(VE);return n.length?n[0](e):Te.mac?e.metaKey:e.ctrlKey}function gV(t,e){let n=t.state.facet(UE);return n.length?n[0](e):Te.mac?!e.altKey:!e.ctrlKey}function mV(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Mc(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function yV(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=an.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Oi=Object.create(null),ar=Object.create(null),fM=Te.ie&&Te.ie_version<15||Te.ios&&Te.webkit_version<604;function vV(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),hM(t,n.value)},50)}function Cp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function hM(t,e){e=Cp(t.state,ew,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(ny!=null&&n.selection.ranges.every(a=>a.empty)&&ny==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:fe.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:fe.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}ar.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Te.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};ar.wheel=ar.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Oi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);ar.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};ar.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};ar.touchend=(t,e)=>{t.inputState.touchActive=!1};Oi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(KE))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=xV(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new dV(t,e,n,r)),r&&t.observer.ignore(()=>{NE(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function ik(t,e,n,r){if(r==1)return fe.cursor(e,n);if(r==2)return G9(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(ok+1)%3:1}function xV(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=dM(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=ik(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=ik(t,n.pos,n.assoc,r),h=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=h1&&(u=bV(i,a.pos))?u:l?i.addRange(c):fe.create([c])}}}function bV(t,e){for(let n=0;n=e)return fe.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Oi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=fe.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Cp(t.state,tw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Oi.dragend=t=>(t.inputState.draggedContent=null,!1);function ak(t,e,n,r){if(n=Cp(t.state,ew,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&gV(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Oi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&ak(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return ak(t,e,r,!0),!0}return!1};Oi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=fM?null:e.clipboardData;return n?(hM(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(vV(t),!1)};function kV(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.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(),t.focus()},50)}function SV(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Cp(t,tw,e.join(t.lineBreak)),ranges:n,linewise:r}}let ny=null;Oi.copy=Oi.cut=(t,e)=>{if(!Zu(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=SV(t.state);if(!n&&!i)return!1;ny=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=fM?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(kV(t,n),!1)};const pM=Ao.define();function gM(t,e){let n=[];for(let r of t.facet(qE)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:pM.of(!0)}):null}function mM(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=gM(t.state,e);n?t.dispatch(n):t.update([])}},10)}ar.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),mM(t)};ar.blur=t=>{t.observer.clearSelectionRange(),mM(t)};ar.compositionstart=ar.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};ar.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Te.chrome&&Te.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};ar.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Oi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return sw(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Te.chrome&&Te.android&&(i=uM.find(s=>s.inputType==e.inputType))&&(t.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&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Te.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Te.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>ar.compositionend(t,e),20),!1};const uk=new Set;function CV(t){uk.has(t)||(uk.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const ck=["pre-wrap","normal","pre-line","break-spaces"];let Oa=!1;function fk(){Oa=!1}class TV{constructor(e){this.lineWrapping=e,this.doc=Ct.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-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 ck.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Ih&&(Oa=!0),this.height=e)}replace(e,n,r){return lr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],h=s.lineAt(a,$t.ByPosNoHeight,r.setDoc(n),0,0),d=h.to>=u?h:s.lineAt(u,$t.ByPosNoHeight,r,0,0);for(f+=d.to-u,u=d.to;l>0&&h.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,$t.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Rr extends yM{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Si(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof Rr||i instanceof Bn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Bn?i=new Rr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):lr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&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 Bn extends lr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof Bn?r[r.length-1]=new Bn(s.length+i):r.push(null,new Bn(i-1))}if(e>0){let s=r[0];s instanceof Bn?r[0]=new Bn(e+s.length):r.unshift(new Bn(e-1),null)}return lr.of(r)}decomposeLeft(e,n){n.push(new Bn(e-1),null)}decomposeRight(e,n){n.push(null,new Bn(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new Bn(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],h=0;f<0&&(h=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=Ih&&(a=-2);let d=new Rr(c,f,h);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new Bn(s-l).updateHeight(e,l));let u=lr.of(o);return(a<0||Math.abs(u.height-this.height)>=Ih||Math.abs(a-this.heightMetrics(e,n).perLine)>=Ih)&&(Oa=!0),Ad(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class AV extends lr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(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,n,r,i){let s=r+this.left.height;return el))return u;let c=n==$t.ByPosNoHeight?$t.ByPosNoHeight:$t.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,$t.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&hk(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?lr.of(this.break?[e,null,n]:[e,n]):(this.left=Ad(this.left,e),this.right=Ad(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function hk(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Bn&&(r=t[e+1])instanceof Bn&&t.splice(e-1,3,new Bn(n.length+1+r.length))}const RV=5;class ow{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Rr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Rr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=RV)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Rr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Bn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Rr)return e;let n=new Rr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Rr)&&!this.isCovered?this.nodes.push(new Rr(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let h=c.getBoundingClientRect();s=Math.max(s,h.left),o=Math.min(o,h.right),l=Math.max(l,h.top),a=Math.min(u==t.parentNode?i.innerHeight:a,h.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function DV(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function _V(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class im{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new TV(r),this.stateDeco=gk(n),this.heightMap=lr.empty().applyChanges(this.stateDeco,Ct.empty,this.heightOracle.setDoc(n.doc),[new Jr(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=It.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new eh(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?pk:new lw(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(Du(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=gk(this.state);let i=e.changedRanges,s=Jr.extendWithRanges(i,OV(r,this.stateDeco,e?e.changes:Cn.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);fk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Oa)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(T9)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?ln.RTL:ln.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:b,scaleY:C}=PE(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=b,this.scaleY=C,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,h=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let d=IE(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=LE(this.scrollParent||e.win);let m=(this.printing?_V:IV)(n,this.paddingTop),x=m.top-this.pixelViewport.top,v=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!DV(e.dom))return 0;let y=l.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let b=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(b)&&(o=!0),o||i.lineWrapping&&Math.abs(y-this.contentDOMWidth)>i.charWidth){let{lineHeight:C,charWidth:T,textHeight:E}=e.docView.measureTextSize();o=C>0&&i.refresh(s,C,T,E,Math.max(5,y/T),b),o&&(e.docView.minWidth=0,u|=16)}x>0&&v>0?c=Math.max(x,v):x<0&&v<0&&(c=Math.min(x,v)),fk();for(let C of this.viewports){let T=C.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?lr.empty().applyChanges(this.stateDeco,Ct.empty,this.heightOracle,[new Jr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new EV(C.from,T))}Oa&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new eh(i.lineAt(o-r*1e3,$t.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,$t.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,$t.ByPos,s,0,0),h;n.y=="center"?h=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=ln.LTR&&!r)return[];let l=[],a=(c,f,h,d)=>{if(f-cc&&vv.from>=h.from&&v.to<=h.to&&Math.abs(v.from-c)v.fromg));if(!x){if(fy.from<=f&&y.to>=f)){let y=n.moveToLineBoundary(fe.cursor(f),!1,!0).head;y>c&&(f=y)}let v=this.gapSize(h,c,f,d),g=r||v<2e6?v:2e6;x=new im(c,f,v,g)}l.push(x)},u=c=>{if(c.length2e6)for(let C of e)C.from>=c.from&&C.fromc.from&&a(c.from,d,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Ot.spans(n,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=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Du(this.heightMap.lineAt(e,$t.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Du(this.heightMap.lineAt(this.scaler.fromDOM(e),$t.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Du(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 eh{constructor(e,n){this.from=e,this.to=n}}function LV(t,e,n){let r=[],i=t,s=0;return Ot.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function nh(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function FV(t,e){for(let n of t)if(e(n))return n}const pk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function gk(t){let e=t.facet(bp).filter(r=>typeof r!="function"),n=t.facet(rw).filter(r=>typeof r!="function");return n.length&&e.push(Ot.join(n)),e}class lw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,$t.ByPos,e,0,0).top,c=n.lineAt(a,$t.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Du(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Si(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Du(i,e)):t._content)}const rh=Le.define({combine:t=>t.join(" ")}),ry=Le.define({combine:t=>t.indexOf(!0)>-1}),iy=xo.newName(),vM=xo.newName(),wM=xo.newName(),xM={"&light":"."+vM,"&dark":"."+wM};function sy(t,e,n){return new xo(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const BV=sy("."+iy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},xM),zV={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},sm=Te.ie&&Te.ie_version<=11;class $V{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new d9,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Te.ie&&Te.ie_version<=11||Te.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Te.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Te.chrome&&Te.chrome_version<126)&&(this.editContext=new jV(e),e.state.facet(xs)&&(e.contentDOM.editContext=this.editContext.editContext)),sm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(xs)?r.root.activeElement!=this.dom:!Zu(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Te.ie&&Te.ie_version<=11||Te.android&&Te.chrome)&&!r.state.selection.main.empty&&i.focusNode&&tc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Mc(e.root);if(!n)return!1;let r=Te.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&HV(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=Zu(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&da(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&Zu(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 iV(this.view,e,n,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 n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=lM(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Md(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=mk(n,e.previousSibling||e.target.previousSibling,-1),i=mk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(xs)!=e.state.facet(xs)&&(e.view.contentDOM.editContext=e.state.facet(xs)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.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 mk(t,e,n){for(;e;){let r=an.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function yk(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return tc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function HV(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return yk(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yk(t,n):null}class jV{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=aM(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let h=fe.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Md(h,i)||e.dispatch({selection:h,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:Ct.of(r.text.slice(c.from,c.toB).split(` +`))};if((Te.mac||Te.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:Ct.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);sw(e,f,fe.single(this.toEditorPos(r.selectionStart,h),this.toEditorPos(r.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{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)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=Mc(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class He{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch: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||p9(e.parent)||document,this.viewState=new dk(this,e.state||Mt.create(e)),e.scrollTo&&e.scrollTo.is(Qf)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ta).map(i=>new Zg(i));for(let i of this.plugins)i.update(this);this.observer=new $V(this),this.inputState=new aV(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ek(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Mn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let h of e){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(h=>h.annotation(pM))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=gM(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(Mt.phrases)!=this.state.facet(Mt.phrases))return this.setState(s);i=Cd.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection,{x:p,y:m}=this.state.facet(He.cursorScrollMargin);f=new pa(d.empty?d:fe.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of h.effects)d.is(Qf)&&(f=d.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=Rd.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Iu)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(rh)!=i.state.facet(rh)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(Z0))try{h(i)}catch(d){Qr(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!lM(this,c)&&u.force&&da(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new dk(this,e),this.plugins=e.facet(ta).map(r=>new Zg(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new ek(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ta),r=e.state.facet(ta);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new Zg(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}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-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(LE(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(i);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(d=>{try{return d.read(this)}catch(p){return Qr(this.state,p),vk}}),f=Cd.create(this,this.state,[]),h=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let d=0;d1||p<-1)&&!(Te.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(Z0))l(n)}get themeClasses(){return iy+" "+(this.state.facet(ry)?wM:vM)+" "+this.state.facet(rh)}updateAttrs(){let e=wk(this,ZE,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(xs)?"true":"false",class:"cm-content",style:`${Te.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),wk(this,nw,n);let r=this.observer.ignore(()=>{let i=Gb(this.contentDOM,this.contentAttrs,n),s=Gb(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(He.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Iu);let e=this.state.facet(He.cspNonce);xo.mount(this.root,this.styleModules.concat(BV).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return rm(this,e,tk(this,e,n,r))}moveByGroup(e,n){return rm(this,e,tk(this,e,n,r=>J9(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return fe.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return Q9(this,e,n,r)}moveVertically(e,n,r){return rm(this,e,Z9(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=ty(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),ty(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[Ji.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==ln.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(YE)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>WV)return jE(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||HE(s.isolates,r=Qb(this,e))))return s.order;r||(r=Qb(this,e));let i=k9(e.text,n,r);return this.bidiCache.push(new Rd(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Te.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{NE(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return Qf.of(new pa(typeof e=="number"?fe.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return Qf.of(new pa(fe.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return si.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return si.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=xo.newName(),i=[rh.of(r),Iu.of(sy(`.${r}`,e))];return n&&n.dark&&i.push(ry.of(!0)),i}static baseTheme(e){return Gv.lowest(Iu.of(sy("."+iy,e,xM)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&an.get(r)||an.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}He.styleModule=Iu;He.inputHandler=GE;He.clipboardInputFilter=ew;He.clipboardOutputFilter=tw;He.scrollHandler=QE;He.focusChangeEffect=qE;He.perLineTextDirection=YE;He.exceptionSink=XE;He.updateListener=Z0;He.editable=xs;He.mouseSelectionStyle=KE;He.dragMovesSelection=UE;He.clickAddsSelectionRange=VE;He.decorations=bp;He.blockWrappers=eM;He.outerDecorations=rw;He.atomicRanges=qc;He.bidiIsolatedRanges=tM;He.cursorScrollMargin=Le.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});He.scrollMargins=nM;He.darkTheme=ry;He.cspNonce=Le.define({combine:t=>t.length?t[0]:""});He.contentAttributes=nw;He.editorAttributes=ZE;He.lineWrapping=He.contentAttributes.of({class:"cm-lineWrapping"});He.announce=Ft.define();const WV=4096,vk={};class Rd{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:ln.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&Qv(o,n)}return n}const VV=Te.mac?"mac":Te.windows?"win":Te.linux?"linux":"key";function UV(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let to=null;const GV=4e3;function qV(t,e=VV){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,h;let d=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(v=>UV(v,e));for(let v=1;v{let k=to={view:y,prefix:g,scope:o};return setTimeout(()=>{to==k&&(to=null)},GV),!0}]})}let m=p.join(" ");i(m,!1);let x=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((h=(f=d._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let h in c)c[h].run.push(d=>f(d,oy))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let oy=null;function YV(t,e,n,r){oy=e;let i=l9(e),s=W6(i,0),o=V6(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;to&&to.view==n&&to.scope==r&&(l=to.prefix+" ",cM.indexOf(e.keyCode)<0&&(u=!0,to=null));let f=new Set,h=x=>{if(x){for(let v of x.run)if(!f.has(v)&&(f.add(v),v(n)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},d=t[r],p,m;return d&&(h(d[l+ih(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Te.windows&&e.ctrlKey&&e.altKey)&&!(Te.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=bo[e.keyCode])&&p!=i?(h(d[l+ih(p,e,!0)])||e.shiftKey&&(m=Tc[e.keyCode])!=i&&m!=p&&h(d[l+ih(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&h(d[l+ih(i,e,!0)])&&(a=!0),!a&&h(d._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),oy=null,a}class QV extends Ua{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?ec(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Ac(n[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 JV(t){let e=si.fromClass(class{constructor(n){this.view=n,this.placeholder=t?It.set([It.widget({widget:new QV(t),side:1}).range(0)]):It.none}get decorations(){return this.view.state.doc.length?It.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,He.contentAttributes.of({"aria-placeholder":t})]:e}const sh="-10000px";class kM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function ZV(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const om=Le.define({combine:t=>{var e,n,r;return{position:Te.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||ZV}}}),bk=new WeakMap,SM=si.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(om);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new kM(t,CM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(om);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!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);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=sh,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Te.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=iw(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 l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(om).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=sh;continue}let d=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,x=(e=bk.get(u))!==null&&e!==void 0?e:h.bottom-h.top,v=u.offset||tU,g=this.view.textDirection==ln.LTR,y=h.width>r.right-r.left?g?r.left:r.right-h.width:g?Math.max(r.left,Math.min(f.left-(d?14:0)+v.x,r.right-m)):Math.min(Math.max(r.left,f.left-m+(d?14:0)-v.x),r.right-m),k=this.above[l];!a.strictSide&&(k?f.top-x-p-v.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let b=(k?f.top-r.top:r.bottom-f.bottom)-p;if(by&&E.topC&&(C=k?E.top-x-2-p:E.bottom+p+2);if(this.position=="absolute"?(c.style.top=(C-t.parent.top)/s+"px",kk(c,(y-t.parent.left)/i)):(c.style.top=C/s+"px",kk(c,y/i)),d){let E=f.left+(g?v.x:-v.x)-(y+14-7);d.style.left=E/i+"px"}u.overlap!==!0&&o.push({left:y,top:C,right:T,bottom:C+x}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=sh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function kk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const eU=He.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"}}}),tU={x:0,y:0},CM=Le.define({enables:[SM,eU]}),Od=Le.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Tp{static create(e){return new Tp(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new kM(e,Od,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}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 nU=CM.compute([Od],t=>{let e=t.facet(Od);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Tp.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),rU=Le.define();class iU{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,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(e){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;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==ln.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>Qr(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(SM),n=e?e.manager.tooltips.findIndex(r=>r.create==Tp.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,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&&!this.locked.has(i)&&s&&!sU(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!oU(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const oh=4;function sU(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-oh&&e.clientX<=r+oh&&e.clientY>=i-oh&&e.clientY<=s+oh}function oU(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function lU(t,e={}){let n=Ft.define(),r=new WeakMap,i=as.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,pr.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),c);h.pos=f,h.end!=null&&(h.end=l.changes.mapPos(h.end)),u.push(h)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(aU)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>Od.from(o)});const s=si.define(o=>new iU(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,rU.of(s),nU]}}const aU=Ft.define(),Sk=Le.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),uU=si.fromClass(class{constructor(t){this.input=t.state.facet(ly),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Sk);this.top=new lh(t,!0,e.topContainer),this.bottom=new lh(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(Sk);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new lh(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new lh(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(ly);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>He.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class lh{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.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";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=Ck(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=Ck(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 Ck(t){let e=t.nextSibling;return t.remove(),e}const ly=Le.define({enables:uU});class Pa extends ol{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Pa.prototype.elementClass="";Pa.prototype.toDOM=void 0;Pa.prototype.mapMode=pr.TrackBefore;Pa.prototype.startSide=Pa.prototype.endSide=-1;Pa.prototype.point=!0;const TM=1024;let cU=0;class lm{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=cU++,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=br.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")});yt.openedBy=new yt({deserialize:t=>t.split(" ")});yt.group=new yt({deserialize:t=>t.split(" ")});yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});yt.contextHash=new yt({perNode:!0});yt.lookAhead=new yt({perNode:!0});yt.mounted=new yt({perNode:!0});class rc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const fU=Object.create(null);class br{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):fU,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new br(e.name||"",n,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");n[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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(yt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}br.none=new br("",Object.create(null),0,8);class aw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|on.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:fw(br.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new yn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new yn(br.none,n,r,i)))}static build(e){return gU(e)}}yn.empty=new yn(br.none,[],[],0);class uw{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new uw(this.buffer,this.index)}}class So{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return br.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function Oc(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,h;if(!(!(s&on.EnterBracketed&&c instanceof yn&&(h=rc.get(c))&&!h.overlay&&h.bracketed&&r>=f&&r<=f+c.length)&&!EM(i,r,f,f+c.length))){if(c instanceof So){if(s&on.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,n,r-f,i);if(d>-1)return new oo(new hU(o,c,e,f),null,d)}else if(s&on.IncludeAnonymous||!c.type.isAnonymous||cw(c)){let d;if(!(s&on.IgnoreMounts)&&(d=rc.get(c))&&!d.overlay)return new ni(d.tree,f,e,o);let p=new ni(c,f,e,o);return s&on.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&on.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&on.IgnoreOverlays)&&(i=rc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&on.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new ni(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,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 Ek(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!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 ay(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class hU{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class oo extends MM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new oo(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&on.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new oo(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new oo(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new oo(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{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)),n.push(0)}return new yn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function AM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new ni(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Oc(l,e,n,!1))}}return i?AM(i):r}class uy{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~on.EnterBracketed,e instanceof ni)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,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||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 ni?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-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,n,r=this.mode){return this.buffer?r&on.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&on.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&on.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.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 n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&on.IncludeAnonymous||l instanceof So||!l.type.isAnonymous||cw(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return ay(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function cw(t){return t.children.some(e=>e instanceof So||!e.type.isAnonymous||cw(e))}function gU(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=TM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new uw(n,n.length):n,a=r.types,u=0,c=0;function f(b,C,T,E,A,P){let{id:_,start:O,end:D,size:I}=l,Q=c,X=u;if(I<0)if(l.next(),I==-1){let M=s[_];T.push(M),E.push(O-b);return}else if(I==-3){u=_;return}else if(I==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${I}`);let le=a[_],j,ne,Y=O-b;if(D-O<=i&&(ne=x(l.pos-C,A))){let M=new Uint16Array(ne.size-ne.skip),F=l.pos-ne.size,z=M.length;for(;l.pos>F;)z=v(ne.start,M,z);j=new So(M,D-ne.start,r),Y=ne.start-b}else{let M=l.pos-I;l.next();let F=[],z=[],W=_>=o?_:-1,B=0,de=D;for(;l.pos>M;)W>=0&&l.id==W&&l.size>=0?(l.end<=de-i&&(p(F,z,O,B,l.end,de,W,Q,X),B=F.length,de=l.end),l.next()):P>2500?h(O,M,F,z):f(O,M,F,z,W,P+1);if(W>=0&&B>0&&B-1&&B>0){let ge=d(le,X);j=fw(le,F,z,0,F.length,0,D-O,ge,ge)}else j=m(le,F,z,D-O,Q-D,X)}T.push(j),E.push(Y)}function h(b,C,T,E){let A=[],P=0,_=-1;for(;l.pos>C;){let{id:O,start:D,end:I,size:Q}=l;if(Q>4)l.next();else{if(_>-1&&D<_)break;_<0&&(_=I-i),A.push(O,D,I),P++,l.next()}}if(P){let O=new Uint16Array(P*4),D=A[A.length-2];for(let I=A.length-3,Q=0;I>=0;I-=3)O[Q++]=A[I],O[Q++]=A[I+1]-D,O[Q++]=A[I+2]-D,O[Q++]=Q;T.push(new So(O,A[2]-D,r)),E.push(D-b)}}function d(b,C){return(T,E,A)=>{let P=0,_=T.length-1,O,D;if(_>=0&&(O=T[_])instanceof yn){if(!_&&O.type==b&&O.length==A)return O;(D=O.prop(yt.lookAhead))&&(P=E[_]+O.length+D)}return m(b,T,E,A,P,C)}}function p(b,C,T,E,A,P,_,O,D){let I=[],Q=[];for(;b.length>E;)I.push(b.pop()),Q.push(C.pop()+T-A);b.push(m(r.types[_],I,Q,P-A,O-P,D)),C.push(A-T)}function m(b,C,T,E,A,P,_){if(P){let O=[yt.contextHash,P];_=_?[O].concat(_):[O]}if(A>25){let O=[yt.lookAhead,A];_=_?[O].concat(_):[O]}return new yn(b,C,T,E,_)}function x(b,C){let T=l.fork(),E=0,A=0,P=0,_=T.end-i,O={size:0,start:0,skip:0};e:for(let D=T.pos-b;T.pos>D;){let I=T.size;if(T.id==C&&I>=0){O.size=E,O.start=A,O.skip=P,P+=4,E+=4,T.next();continue}let Q=T.pos-I;if(I<0||Q=o?4:0,le=T.start;for(T.next();T.pos>Q;){if(T.size<0)if(T.size==-3||T.size==-4)X+=4;else break e;else T.id>=o&&(X+=4);T.next()}A=le,E+=I,P+=X}return(C<0||E==b)&&(O.size=E,O.start=A,O.skip=P),O.size>4?O:void 0}function v(b,C,T){let{id:E,start:A,end:P,size:_}=l;if(l.next(),_>=0&&E4){let D=l.pos-(_-4);for(;l.pos>D;)T=v(b,C,T)}C[--T]=O,C[--T]=P-b,C[--T]=A-b,C[--T]=E}else _==-3?u=E:_==-4&&(c=E);return T}let g=[],y=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,g,y,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:g.length?y[0]+g[0].length:0;return new yn(a[t.topID],g.reverse(),y.reverse(),k)}const Mk=new WeakMap;function Dh(t,e){if(!t.isAnonymous||e instanceof So||e.type!=t)return 1;let n=Mk.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof yn)){n=1;break}n+=Dh(t,r)}Mk.set(e,n)}return n}function fw(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;C+=T}if(y==k+1){if(C>c){let T=p[k];d(T.children,T.positions,0,T.children.length,m[k]+g);continue}f.push(p[k])}else{let T=m[y-1]+p[y-1].length-b;f.push(fw(t,p,m,k,y,b,T,null,a))}h.push(b+g-s)}}return d(e,n,r,i,0),(l||a)(f,h,o)}class Zo{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,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,n=[],r=!1){let i=[new Zo(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=h.from||f<=h.to||u){let d=Math.max(h.from,a)-u,p=Math.min(h.to,f)-u;h=d>=p?null:new Zo(d,p,h.tree,h.offset+u,l>0,!!c)}if(h&&i.push(h),o.to>f)break;o=snew lm(i.from,i.to)):[new lm(0,0)]:[new lm(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class mU{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let yU=0;class Gr{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=yU++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Gr&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Gr(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new Pd(e);return r=>r.modified.indexOf(n)>-1?r:Pd.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let vU=0;class Pd{constructor(e){this.name=e,this.instances=[],this.id=vU++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&wU(n,l.modified));if(r)return r;let i=[],s=new Gr(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=xU(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Pd.get(l,a));return s}}function wU(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function xU(t){let e=[[]];for(let n=0;nr.length-n.length)}function OM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==i.length)break;let d=i[f++];if(f==i.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new Pc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return PM.add(e)}const PM=new yt({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new Pc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Pc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function bU(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function kU(t,e,n,r=0,i=t.length){let s=new SU(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class SU{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let u=i,c=CU(e)||Pc.empty,f=bU(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let h=e.tree&&e.tree.prop(yt.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+l,1),p=this.highlighters.filter(x=>!x.scope||x.scope(h.tree.type)),m=e.firstChild();for(let x=0,v=l;;x++){let g=x=y||!e.nextSibling())););if(!g||y>r)break;v=g.to+l,v>n&&(this.highlightRange(d.cursor(),Math.max(n,g.from+l),Math.min(r,v),"",p),this.startSpan(Math.min(r,v),u))}m&&e.parent()}else if(e.firstChild()){h&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function CU(t){let e=t.type.prop(PM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ve=Gr.define,uh=ve(),Ys=ve(),Ak=ve(Ys),Rk=ve(Ys),Qs=ve(),ch=ve(Qs),am=ve(Qs),Wi=ve(),Bo=ve(Wi),Hi=ve(),ji=ve(),cy=ve(),ku=ve(cy),fh=ve(),$e={comment:uh,lineComment:ve(uh),blockComment:ve(uh),docComment:ve(uh),name:Ys,variableName:ve(Ys),typeName:Ak,tagName:ve(Ak),propertyName:Rk,attributeName:ve(Rk),className:ve(Ys),labelName:ve(Ys),namespace:ve(Ys),macroName:ve(Ys),literal:Qs,string:ch,docString:ve(ch),character:ve(ch),attributeValue:ve(ch),number:am,integer:ve(am),float:ve(am),bool:ve(Qs),regexp:ve(Qs),escape:ve(Qs),color:ve(Qs),url:ve(Qs),keyword:Hi,self:ve(Hi),null:ve(Hi),atom:ve(Hi),unit:ve(Hi),modifier:ve(Hi),operatorKeyword:ve(Hi),controlKeyword:ve(Hi),definitionKeyword:ve(Hi),moduleKeyword:ve(Hi),operator:ji,derefOperator:ve(ji),arithmeticOperator:ve(ji),logicOperator:ve(ji),bitwiseOperator:ve(ji),compareOperator:ve(ji),updateOperator:ve(ji),definitionOperator:ve(ji),typeOperator:ve(ji),controlOperator:ve(ji),punctuation:cy,separator:ve(cy),bracket:ku,angleBracket:ve(ku),squareBracket:ve(ku),paren:ve(ku),brace:ve(ku),content:Wi,heading:Bo,heading1:ve(Bo),heading2:ve(Bo),heading3:ve(Bo),heading4:ve(Bo),heading5:ve(Bo),heading6:ve(Bo),contentSeparator:ve(Wi),list:ve(Wi),quote:ve(Wi),emphasis:ve(Wi),strong:ve(Wi),link:ve(Wi),monospace:ve(Wi),strikethrough:ve(Wi),inserted:ve(),deleted:ve(),changed:ve(),invalid:ve(),meta:fh,documentMeta:ve(fh),annotation:ve(fh),processingInstruction:ve(fh),definition:Gr.defineModifier("definition"),constant:Gr.defineModifier("constant"),function:Gr.defineModifier("function"),standard:Gr.defineModifier("standard"),local:Gr.defineModifier("local"),special:Gr.defineModifier("special")};for(let t in $e){let e=$e[t];e instanceof Gr&&(e.name=t)}IM([{tag:$e.link,class:"tok-link"},{tag:$e.heading,class:"tok-heading"},{tag:$e.emphasis,class:"tok-emphasis"},{tag:$e.strong,class:"tok-strong"},{tag:$e.keyword,class:"tok-keyword"},{tag:$e.atom,class:"tok-atom"},{tag:$e.bool,class:"tok-bool"},{tag:$e.url,class:"tok-url"},{tag:$e.labelName,class:"tok-labelName"},{tag:$e.inserted,class:"tok-inserted"},{tag:$e.deleted,class:"tok-deleted"},{tag:$e.literal,class:"tok-literal"},{tag:$e.string,class:"tok-string"},{tag:$e.number,class:"tok-number"},{tag:[$e.regexp,$e.escape,$e.special($e.string)],class:"tok-string2"},{tag:$e.variableName,class:"tok-variableName"},{tag:$e.local($e.variableName),class:"tok-variableName tok-local"},{tag:$e.definition($e.variableName),class:"tok-variableName tok-definition"},{tag:$e.special($e.variableName),class:"tok-variableName2"},{tag:$e.definition($e.propertyName),class:"tok-propertyName tok-definition"},{tag:$e.typeName,class:"tok-typeName"},{tag:$e.namespace,class:"tok-namespace"},{tag:$e.className,class:"tok-className"},{tag:$e.macroName,class:"tok-macroName"},{tag:$e.propertyName,class:"tok-propertyName"},{tag:$e.operator,class:"tok-operator"},{tag:$e.comment,class:"tok-comment"},{tag:$e.meta,class:"tok-meta"},{tag:$e.invalid,class:"tok-invalid"},{tag:$e.punctuation,class:"tok-punctuation"}]);var um;const na=new yt;function TU(t){return Le.define({combine:t?e=>e.concat(t):void 0})}const EU=new yt;class Ti{constructor(e,n,r=[],i=""){this.data=e,this.name=i,Mt.prototype.hasOwnProperty("tree")||Object.defineProperty(Mt.prototype,"tree",{get(){return ss(this)}}),this.parser=n,this.extension=[Da.of(this),Mt.languageData.of((s,o,l)=>{let a=Ok(s,o,l),u=a.type.prop(na);if(!u)return[];let c=s.facet(u),f=a.type.prop(EU);if(f){let h=a.resolve(o-a.from,l);for(let d of f)if(d.test(h,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return Ok(e,n,r).type.prop(na)==this.data}findRegions(e){let n=e.facet(Da);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(na)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(yt.mounted);if(l){if(l.tree.prop(na)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new Id(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ss(t){let e=t.field(Ti.state,!1);return e?e.tree:yn.empty}class MU{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Su=null;class Dd{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Dd(e,n,[],yn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new MU(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=yn.empty&&this.isDone(n??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()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Zo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Su;Su=this;try{return e()}finally{Su=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Pk(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,h)=>a.push({fromA:u,toA:c,fromB:f,toB:h})),r=Zo.applyChanges(r,a),i=yn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=Pk(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends RM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Su;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new yn(br.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Su}}function Pk(t,e,n){return Zo.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Ia{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Ia(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Dd.create(e.facet(Da).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Ia(r)}}Ti.state=as.define({create:Ia.init,update(t,e){for(let n of e.effects)if(n.is(Ti.setState))return n.value;return e.startState.facet(Da)!=e.state.facet(Da)?Ia.init(e.state):t.apply(e)}});let DM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(DM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const cm=typeof navigator<"u"&&(!((um=navigator.scheduling)===null||um===void 0)&&um.isInputPending)?()=>navigator.scheduling.isInputPending():null,AU=si.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Ti.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Ti.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=DM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>cm&&cm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ti.setState.of(new Ia(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Qr(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Da=Le.define({combine(t){return t.length?t[0]:null},enables:t=>[Ti.state,AU,He.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class RU{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const OU=Le.define(),hw=Le.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function _d(t){let e=t.facet(hw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Nd(t,e){let n="",r=t.tabSize,i=t.facet(hw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?PU(t,n,e):null}class Ep{constructor(e,n={}){this.state=e,this.options=n,this.unit=_d(e)}lineAt(e,n=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}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return wp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),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 NM=new yt;function PU(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.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 LM(r,t,n)}function LM(t,e,n){for(let r=t;r;r=r.next){let i=DU(r.node);if(i)return i(dw.create(e,n,r))}return 0}function IU(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function DU(t){let e=t.type.prop(NM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>FU(o,!0,1,void 0,s&&!IU(o)?i.from:void 0)}return t.parent==null?_U:null}function _U(){return 0}class dw extends Ep{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new dw(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(NU(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return LM(this.context.next,this.base,this.pos)}}function NU(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function LU(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function FU(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=LU(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function Ik({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const BU=new yt;function zU(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(na)==o.data:o?l=>l==o:void 0,this.style=IM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new xo(r):null,this.themeType=n.themeType}static define(e,n){return new Mp(e,n||{})}}const fy=Le.define(),$U=Le.define({combine(t){return t.length?[t[0]]:null}});function fm(t){let e=t.facet(fy);return e.length?e:t.facet($U)}function Dk(t,e){let n=[jU],r;return t instanceof Mp&&(t.module&&n.push(He.styleModule.of(t.module)),r=t.themeType),r?n.push(fy.computeN([He.darkTheme],i=>i.facet(He.darkTheme)==(r=="dark")?[t]:[])):n.push(fy.of(t)),n}class HU{constructor(e){this.markCache=Object.create(null),this.tree=ss(e.state),this.decorations=this.buildDeco(e,fm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=ss(e.state),r=fm(e.state),i=r!=fm(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return It.none;let r=new Ma;for(let{from:i,to:s}of e.visibleRanges)kU(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=It.mark({class:a})))},i,s);return r.finish()}}const jU=Gv.high(si.fromClass(HU,{decorations:t=>t.decorations})),WU=1e4,VU="()[]{}",UU=new yt;function hy(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function dy(t){let e=t.type.prop(UU);return e?e(t.node):t}function ra(t,e,n,r={}){let i=r.maxScanDistance||WU,s=r.brackets||VU,o=ss(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=hy(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return KU(t,e,n,a,c,u,s)}}return XU(t,e,n,o,l.type,i,s)}function KU(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let h=0;!c.next().done&&h<=s;){let d=c.value;n<0&&(h+=d.length);let p=e+h*n;for(let m=n>0?0:d.length-1,x=n>0?d.length:-1;m!=x;m+=n){let v=o.indexOf(d[m]);if(!(v<0||r.resolveInner(p+m,1).type!=i))if(v%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+m,to:p+m+1},matched:v>>1==a>>1};f--}}n>0&&(h+=d.length)}return c.done?{start:u,matched:!1}:null}const GU=Object.create(null),_k=[br.none],Nk=[],Lk=Object.create(null),qU=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])qU[t]=YU(GU,e);function hm(t,e){Nk.indexOf(t)>-1||(Nk.push(t),console.warn(e))}function YU(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||$e[u];c?typeof c=="function"?a.length?a=a.map(c):hm(u,`Modifier ${u} used at start of tag`):a.length?hm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:hm(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=Lk[i];if(s)return s.id;let o=Lk[i]=br.define({id:_k.length,name:r,props:[OM({[r]:n})]});return _k.push(o),o.id}ln.RTL,ln.LTR;const QU=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=gw(t.state,n.from);return r.line?JU(t):r.block?e7(t):!1};function pw(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const JU=pw(r7,0),ZU=pw(FM,0),e7=pw((t,e)=>FM(t,e,n7(e)),0);function gw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Cu=50;function t7(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Cu,r),o=t.sliceDoc(i,i+Cu),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Cu?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Cu),f=t.sliceDoc(i-Cu,i));let h=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-n.length;return c.slice(h,h+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+h+e.length,margin:/\s/.test(c.charAt(h+e.length))?1:0},close:{pos:i-d-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function n7(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.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 FM(t,e,n=e.selection.ranges){let r=n.map(s=>gw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>t7(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+u.length)==u?h:-1;hs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const py=Ao.define(),i7=Ao.define(),s7=Le.define(),BM=Le.define({combine(t){return TE(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),zM=as.define({create(){return Zi.empty},update(t,e){let n=e.state.facet(BM),r=e.annotation(py);if(r){let a=yr.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=Ld(c,c.length,n.minDepth,a):c=jM(c,e.startState.selection),new Zi(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(i7);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Mn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=yr.fromTransaction(e),o=e.annotation(Mn.time),l=e.annotation(Mn.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Zi(t.done.map(yr.fromJSON),t.undone.map(yr.fromJSON))}});function o7(t={}){return[zM,BM.of(t),He.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?$M:e.inputType=="historyRedo"?gy:null;return r?(e.preventDefault(),r(n)):!1}})]}function Ap(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(zM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const $M=Ap(0,!1),gy=Ap(1,!1),l7=Ap(0,!0),a7=Ap(1,!0);class yr{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new yr(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new yr(e.changes&&Cn.fromJSON(e.changes),[],e.mapped&&is.fromJSON(e.mapped),e.startSelection&&fe.fromJSON(e.startSelection),e.selectionsAfter.map(fe.fromJSON))}static fromTransaction(e,n){let r=Zr;for(let i of e.startState.facet(s7)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new yr(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,Zr)}static selection(e){return new yr(void 0,Zr,void 0,void 0,e)}}function Ld(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function u7(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function c7(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function HM(t,e){return t.length?e.length?t.concat(e):t:e}const Zr=[],f7=200;function jM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-f7));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Ld(t,t.length-1,1e9,n.setSelAfter(r)))}else return[yr.selection([e])]}function h7(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function dm(t,e){if(!t.length)return t;let n=t.length,r=Zr;for(;n;){let i=d7(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[yr.selection(r)]:Zr}function d7(t,e,n){let r=HM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):Zr,n);if(!t.changes)return yr.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new yr(i,Ft.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const p7=/^(input\.type|delete)($|\.)/;class Zi{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new Zi(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||p7.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Rp(n,e))}function er(t){return t.textDirectionAt(t.state.selection.main.head)==ln.LTR}const VM=t=>WM(t,!er(t)),UM=t=>WM(t,er(t));function KM(t,e){return Di(t,n=>n.empty?t.moveByGroup(n,e):Rp(n,e))}const m7=t=>KM(t,!er(t)),y7=t=>KM(t,er(t));function v7(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Op(t,e,n){let r=ss(t).resolveInner(e.head),i=n?yt.closedBy:yt.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;v7(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?ra(t,r.from,1):ra(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,fe.cursor(l,n?-1:1)}const w7=t=>Di(t,e=>Op(t.state,e,!er(t))),x7=t=>Di(t,e=>Op(t.state,e,er(t)));function XM(t,e){return Di(t,n=>{if(!n.empty)return Rp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const GM=t=>XM(t,!1),qM=t=>XM(t,!0);function YM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):Rp(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomQM(t,!1),my=t=>QM(t,!0);function Ro(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=fe.cursor(r.from+s))}return i}const b7=t=>Di(t,e=>Ro(t,e,!0)),k7=t=>Di(t,e=>Ro(t,e,!1)),S7=t=>Di(t,e=>Ro(t,e,!er(t))),C7=t=>Di(t,e=>Ro(t,e,er(t))),T7=t=>Di(t,e=>fe.cursor(t.lineBlockAt(e.head).from,1)),E7=t=>Di(t,e=>fe.cursor(t.lineBlockAt(e.head).to,-1));function M7(t,e,n){let r=!1,i=Ka(t.selection,s=>{let o=ra(t,s.head,-1)||ra(t,s.head,1)||s.head>0&&ra(t,s.head-1,1)||s.headM7(t,e);function oi(t,e,n){let r=Ka(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=fe.range(i.head,i.anchor));let s=n(i);return fe.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Ii(t.state,r)),!0)}function JM(t,e){return oi(t,e,n=>t.moveByChar(n,e))}const ZM=t=>JM(t,!er(t)),eA=t=>JM(t,er(t));function tA(t,e){return oi(t,e,n=>t.moveByGroup(n,e))}const R7=t=>tA(t,!er(t)),O7=t=>tA(t,er(t)),P7=t=>{let e=!er(t);return oi(t,e,n=>Op(t.state,n,e))},I7=t=>{let e=er(t);return oi(t,e,n=>Op(t.state,n,e))};function nA(t,e){return oi(t,e,n=>t.moveVertically(n,e))}const rA=t=>nA(t,!1),iA=t=>nA(t,!0);function sA(t,e){return oi(t,e,n=>t.moveVertically(n,e,YM(t).height))}const Bk=t=>sA(t,!1),zk=t=>sA(t,!0),D7=t=>oi(t,!0,e=>Ro(t,e,!0)),_7=t=>oi(t,!1,e=>Ro(t,e,!1)),N7=t=>{let e=!er(t);return oi(t,e,n=>Ro(t,n,e))},L7=t=>{let e=er(t);return oi(t,e,n=>Ro(t,n,e))},F7=t=>oi(t,!1,e=>fe.cursor(t.lineBlockAt(e.head).from)),B7=t=>oi(t,!0,e=>fe.cursor(t.lineBlockAt(e.head).to)),$k=({state:t,dispatch:e})=>(e(Ii(t,{anchor:0})),!0),Hk=({state:t,dispatch:e})=>(e(Ii(t,{anchor:t.doc.length})),!0),jk=({state:t,dispatch:e})=>(e(Ii(t,{anchor:t.selection.main.anchor,head:0})),!0),Wk=({state:t,dispatch:e})=>(e(Ii(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),z7=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),$7=({state:t,dispatch:e})=>{let n=Pp(t).map(({from:r,to:i})=>fe.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:fe.create(n),userEvent:"select"})),!0},H7=({state:t,dispatch:e})=>{let n=Ka(t.selection,r=>{let i=ss(t),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:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return fe.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(Ii(t,n)),!0)};function oA(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(Ii(n,fe.create(i,i.length-1))),!0)}const j7=t=>oA(t,!1),W7=t=>oA(t,!0),V7=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=fe.create([n.main]):n.main.empty||(r=fe.create([fe.cursor(n.main.head)])),r?(e(Ii(t,r)),!0):!1};function Yc(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=hh(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=hh(t,o,!1),l=hh(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:fe.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const lA=(t,e,n)=>Yc(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&ilA(t,!1,!0),aA=t=>lA(t,!0,!1),uA=(t,e)=>Yc(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=Jn(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),cA=t=>uA(t,!1),U7=t=>uA(t,!0),K7=t=>Yc(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headYc(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),G7=t=>Yc(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Ct.of(["",""])},range:fe.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Y7=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:Jn(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:Jn(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:fe.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Pp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=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]});n=s.number+1}return e}function fA(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Pp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(fe.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(fe.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:fe.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Q7=({state:t,dispatch:e})=>fA(t,e,!1),J7=({state:t,dispatch:e})=>fA(t,e,!0);function hA(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Pp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Z7=({state:t,dispatch:e})=>hA(t,e,!1),eK=({state:t,dispatch:e})=>hA(t,e,!0),tK=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Pp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function nK(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=ss(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(yt.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const Vk=dA(!1),rK=dA(!0);function dA(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&nK(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Ep(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=_M(u,s);for(c==null&&(c=wp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:fe.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const iK=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Ep(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=mw(t,(s,o,l)=>{let a=_M(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Nd(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(mw(t,(n,r)=>{r.push({from:n.from,insert:t.facet(hw)})}),{userEvent:"input.indent"})),!0),gA=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(mw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=wp(i,t.tabSize),o=0,l=Nd(t,Math.max(0,s-_d(t)));for(;o(t.setTabFocusMode(),!0),oK=[{key:"Ctrl-b",run:VM,shift:ZM,preventDefault:!0},{key:"Ctrl-f",run:UM,shift:eA},{key:"Ctrl-p",run:GM,shift:rA},{key:"Ctrl-n",run:qM,shift:iA},{key:"Ctrl-a",run:T7,shift:F7},{key:"Ctrl-e",run:E7,shift:B7},{key:"Ctrl-d",run:aA},{key:"Ctrl-h",run:yy},{key:"Ctrl-k",run:K7},{key:"Ctrl-Alt-h",run:cA},{key:"Ctrl-o",run:q7},{key:"Ctrl-t",run:Y7},{key:"Ctrl-v",run:my}],lK=[{key:"ArrowLeft",run:VM,shift:ZM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:m7,shift:R7,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:S7,shift:N7,preventDefault:!0},{key:"ArrowRight",run:UM,shift:eA,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:y7,shift:O7,preventDefault:!0},{mac:"Cmd-ArrowRight",run:C7,shift:L7,preventDefault:!0},{key:"ArrowUp",run:GM,shift:rA,preventDefault:!0},{mac:"Cmd-ArrowUp",run:$k,shift:jk},{mac:"Ctrl-ArrowUp",run:Fk,shift:Bk},{key:"ArrowDown",run:qM,shift:iA,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Hk,shift:Wk},{mac:"Ctrl-ArrowDown",run:my,shift:zk},{key:"PageUp",run:Fk,shift:Bk},{key:"PageDown",run:my,shift:zk},{key:"Home",run:k7,shift:_7,preventDefault:!0},{key:"Mod-Home",run:$k,shift:jk},{key:"End",run:b7,shift:D7,preventDefault:!0},{key:"Mod-End",run:Hk,shift:Wk},{key:"Enter",run:Vk,shift:Vk},{key:"Mod-a",run:z7},{key:"Backspace",run:yy,shift:yy,preventDefault:!0},{key:"Delete",run:aA,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:cA,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:U7,preventDefault:!0},{mac:"Mod-Backspace",run:X7,preventDefault:!0},{mac:"Mod-Delete",run:G7,preventDefault:!0}].concat(oK.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),aK=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:w7,shift:P7},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:x7,shift:I7},{key:"Alt-ArrowUp",run:Q7},{key:"Shift-Alt-ArrowUp",run:Z7},{key:"Alt-ArrowDown",run:J7},{key:"Shift-Alt-ArrowDown",run:eK},{key:"Mod-Alt-ArrowUp",run:j7},{key:"Mod-Alt-ArrowDown",run:W7},{key:"Escape",run:V7},{key:"Mod-Enter",run:rK},{key:"Alt-l",mac:"Ctrl-l",run:$7},{key:"Mod-i",run:H7,preventDefault:!0},{key:"Mod-[",run:gA},{key:"Mod-]",run:pA},{key:"Mod-Alt-\\",run:iK},{key:"Shift-Mod-k",run:tK},{key:"Shift-Mod-\\",run:A7},{key:"Mod-/",run:QU},{key:"Alt-A",mac:"Ctrl-A",run:ZU},{key:"Ctrl-m",mac:"Shift-Alt-m",run:sK}].concat(lK),uK={key:"Tab",run:pA,shift:gA};var Uk={};class Fd{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Fd(e,[],n,r,r,0,[],0,i?new Kk(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)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]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){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(n,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,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Fd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new cK(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&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;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};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 n=0;n0&&this.emitLookAhead()}}class Kk{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class cK{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=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],n,!0);this.state=i}}class Bd{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Bd(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Bd(this.stack,this.pos,this.index)}}function dh(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class _h{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Xk=new _h;class fK{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Xk,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.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&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=Xk,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class ga{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;hK(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}ga.prototype.contextual=ga.prototype.fallback=ga.prototype.extend=!1;ga.prototype.fallback=ga.prototype.extend=!1;function hK(t,e,n,r,i,s){let o=0,l=1<0){let p=t[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||dK(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,h=t[o+2];if(e.next<0&&h>f&&t[u+h*3-3]==65535){o=t[u+h*3-1];continue e}for(;f>1,p=u+d+(d<<1),m=t[p],x=t[p+1]||65536;if(c=x)f=d+1;else{o=t[p+2],e.advance();continue e}}break}}function Gk(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function dK(t,e,n,r){let i=Gk(n,r,e);return i<0||Gk(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class pK{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?qk(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?qk(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(ee)return this.nextStart=o,null;if(s instanceof yn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class gK{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new _h)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let h=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new _h,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new _h,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new pK(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=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;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&vK(i);if(o)return Mr&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Mr&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return Mr&&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((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(h>-1&&f.length&&(!u||(f.prop(yt.contextHash)||0)==c))return e.useNode(f,h),Mr&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof yn)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof yn&&f.positions[0]==0)f=d;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Mr&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return Yk(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),Mr&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),h=c;for(let d=0;d<10&&f.forceReduce()&&(Mr&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));d++)Mr&&(h=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))Mr&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),Mr&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Yk(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let h=-c;h>0;h--)s(l[u++],a,f);u++}}}this.nodeSet=new aw(n.map((l,a)=>br.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=TM;let o=dh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new ga(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new mK(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(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=vs(this.data,s+2);else break;i=n(vs(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=vs(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(zd.prototype),this);if(e.props&&(n.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}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=Qk(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const wK=OM({String:$e.string,Number:$e.number,"True False":$e.bool,PropertyName:$e.propertyName,Null:$e.null,", :":$e.separator,"[ ]":$e.squareBracket,"{ }":$e.brace}),xK=zd.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[wK],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),bK=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=kK(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function kK(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const SK=Id.define({name:"json",parser:xK.configure({props:[NM.add({Object:Ik({except:/^\s*\}/}),Array:Ik({except:/^\s*\]/})}),BU.add({"Object Array":zU})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function CK(){return new RU(SK)}class Jk{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Ko{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(es).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Ma,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((y,k)=>Math.min(y,k.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;x=p.to,l.push(p),d++}for(;dy.from||y.to==m))l.push(y),d++,x=Math.min(y.to,x);else{x=Math.min(y.from,x);break}}x=Math.min(x,f);let v=!1;if(l.some(y=>y.from==m&&(y.to==x||x==f))&&(v=m==x,!v&&x-m<10)){let y=m-(c+u.value.length);y>0&&(u.next(y),c=m);for(let k=m;;){if(k>=x){v=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let g=BK(l);if(v)o.add(m,m,It.widget({widget:new _K(g),diagnostics:l.slice()}));else{let y=l.reduce((k,b)=>b.markClass?k+" "+b.markClass:k,"");o.add(m,x,It.mark({class:"cm-lintRange cm-lintRange-"+g+y,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>x)}))}if(a=x,a==f)break;for(let y=0;y{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new Jk(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new Jk(r.from,s,r.diagnostic)}}),r}function TK(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(es).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(yw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function EK(t,e){return t.field(Ei,!1)?e:e.concat(Ft.appendConfig.of(xA))}function MK(t,e){return{effects:EK(t,[yw.of(e)])}}const yw=Ft.define(),mA=Ft.define(),yA=Ft.define(),Ei=as.define({create(){return new Ko(It.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=_a(n,t.selected.diagnostic,s)||_a(n,null,s)}!n.size&&i&&e.state.facet(es).autoPanel&&(i=null),t=new Ko(n,i,r)}for(let n of e.effects)if(n.is(yw)){let r=e.state.facet(es).autoPanel?n.value.length?$d.open:null:t.panel;t=Ko.init(n.value,r,e.state)}else n.is(mA)?t=new Ko(t.diagnostics,n.value?$d.open:null,t.selected):n.is(yA)&&(t=new Ko(t.diagnostics,t.panel,n.value));return t},provide:t=>[ly.from(t,e=>e.panel),He.decorations.from(t,e=>e.diagnostics)]}),AK=It.mark({class:"cm-lintRange cm-lintRange-active"});function RK(t,e,n){let{diagnostics:r}=t.state.field(Ei),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(ewA(t,n,!1)))}const Zk=t=>{let e=t.state.field(Ei,!1);return!e||!e.panel?!1:(t.dispatch({effects:mA.of(!1)}),!0)},PK=si.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(es);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(MK(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{Qr(this.view.state,r)})}}update(t){let e=t.state.facet(es);(t.docChanged||e!=t.startState.facet(es)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function IK(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const es=Le.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...TE(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:eS,tooltipFilter:eS,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function eS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function DK(t,e={}){return[es.of({source:t,config:e}),PK,xA]}function vA(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function wA(t,e,n){var r;let i=n?vA(e.actions):[];return Xi("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Xi("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=_a(t.state.field(Ei).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),Xi("u",u.slice(c,c+1)),u.slice(c+1)],h=s.markClass?" "+s.markClass:"";return Xi("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&Xi("div",{class:"cm-diagnosticSource"},e.source))}class _K extends Ua{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Xi("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class tS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=wA(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class $d{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)Zk(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=vA(s.actions);for(let l=0;l{for(let s=0;sZk(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ei).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,h;for(let d=r;dr&&(this.items.splice(r,f-r),i=!0)),n&&h.diagnostic==n.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),s=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(Ei),r=_a(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:yA.of(r)})}static open(e){return new $d(e)}}function NK(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function ph(t){return NK(``,'width="6" height="3"')}const LK=He.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:ph("#f11")},".cm-lintRange-warning":{backgroundImage:ph("orange")},".cm-lintRange-info":{backgroundImage:ph("#999")},".cm-lintRange-hint":{backgroundImage:ph("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function FK(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function BK(t){let e="hint",n=1;for(let r of t){let i=FK(r.severity);i>n&&(n=i,e=r.severity)}return e}const zK=lU(RK,{hideOn:TK}),xA=[Ei,He.decorations.compute([Ei],t=>{let{selected:e,panel:n}=t.field(Ei);return!e||!n||e.from==e.to?It.none:It.set([AK.range(e.from,e.to)])}),zK,LK],$K=512*1024,HK=t=>t.state.doc.length>$K?[]:bK()(t);function nS(t){return Mp.define([{tag:$e.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:$e.string,color:t?"#86efac":"#15803d"},{tag:$e.number,color:t?"#fcd34d":"#b45309"},{tag:$e.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:$e.null,color:t?"#a1a1aa":"#71717a"}])}const jK=He.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function bA({value:t,onChange:e,editable:n,dark:r,placeholder:i,testId:s="json-editor",className:o,onReady:l}){const a=w.useRef(null),u=w.useRef(null),c=w.useRef(e);c.current=e;const f=w.useRef(r),h=w.useRef(null),d=w.useRef(null),p=n??e!==void 0,m=w.useRef(p),x=w.useRef(!1),v=w.useCallback(g=>g?[He.updateListener.of(y=>{var k;y.docChanged&&!x.current&&((k=c.current)==null||k.call(c,y.state.doc.toString()))}),DK(HK,{delay:300})]:[Mt.readOnly.of(!0),He.editable.of(!1)],[]);return w.useEffect(()=>{const g=a.current;if(!g)return;const y=new Ea,k=new Ea,b=Mt.create({doc:t,extensions:[CK(),He.lineWrapping,o7(),bM.of([...aK,...g7,uK]),jK,y.of(Dk(nS(r))),k.of(v(p)),...i?[JV(i)]:[]]}),C=new He({state:b,parent:g});return h.current=y,d.current=k,l==null||l(C),u.current=C,()=>{C.destroy(),u.current=null}},[]),w.useEffect(()=>{const g=u.current;if(g&&g.state.doc.toString()!==t){x.current=!0;try{g.dispatch({changes:{from:0,to:g.state.doc.length,insert:t}})}finally{x.current=!1}}},[t]),w.useEffect(()=>{const g=u.current,y=d.current;!g||!y||p!==m.current&&(m.current=p,g.dispatch({effects:y.reconfigure(v(p))}))},[p,v]),w.useEffect(()=>{const g=u.current;if(!g||r===f.current)return;f.current=r;const y=h.current;y&&g.dispatch({effects:y.reconfigure(Dk(nS(r)))})},[r]),R.jsx("div",{"data-testid":s,className:qi("min-h-0 flex-1 overflow-hidden px-5 py-4 font-mono",o),ref:a})}function kA({title:t,meta:e,actions:n,status:r,children:i}){return R.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[R.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-3 border-b border-border px-3 py-2 pl-5 max-md:gap-2 md:h-12 md:py-0",children:[R.jsxs("div",{className:"flex items-center gap-3",children:[R.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?R.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),R.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),R.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?R.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const _u="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";function WK(){return R.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:R.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function gh({label:t,testId:e,onClick:n,disabled:r,Icon:i}){return R.jsxs("button",{type:"button","data-testid":e,disabled:r,onClick:n,title:t,className:_u,children:[i?R.jsx(i,{"aria-hidden":"true"}):null,t]})}function VK({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onDownload:l,filename:a,reading:u,meta:c,error:f,notice:h,dark:d,delimiter:p,onCellCommit:m}){const[x,v]=w.useState(!1),[g,y]=w.useState(!1),k=w.useRef(0),b=w.useRef(null),C=e.trim()==="",T=t==="CSV",E=I=>{var Q;I.preventDefault(),Array.from(((Q=I.dataTransfer)==null?void 0:Q.types)??[]).includes("Files")&&(k.current++,y(!0))},A=()=>{k.current=Math.max(0,k.current-1),k.current===0&&y(!1)},P=I=>{var X,le;I.preventDefault(),k.current=0,y(!1);const Q=(le=(X=I.dataTransfer)==null?void 0:X.files)==null?void 0:le[0];Q&&r(Q,"drop")},_=I=>{var X;if(!C||I.defaultPrevented||I.target instanceof HTMLTextAreaElement||I.target instanceof HTMLInputElement)return;const Q=(X=I.clipboardData)==null?void 0:X.getData("text/plain");Q&&(I.preventDefault(),n(Q))},O=T?R.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[R.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!x,onClick:()=>v(!1),className:qi("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2.5 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50",x?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[R.jsx(yI,{"aria-hidden":"true",className:"size-3.5"}),"Table"]}),R.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":x,onClick:()=>v(!0),className:qi("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2.5 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50",x?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[R.jsx(ZP,{"aria-hidden":"true",className:"size-3.5"}),"Raw"]})]}):null,D=u&&a?R.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[R.jsx(WK,{})," ",a]}):a?c?`${a} · ${c}`:a:c;return R.jsx("div",{"data-testid":"input-pane",onDragEnter:E,onDragOver:I=>I.preventDefault(),onDragLeave:A,onDrop:P,onPaste:_,"data-drag-over":g||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:R.jsxs(kA,{title:t,meta:D,actions:R.jsxs(R.Fragment,{children:[O,R.jsx("input",{ref:b,type:"file","data-testid":"file-input",accept:T?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:I=>{var X;const Q=(X=I.target.files)==null?void 0:X[0];Q&&r(Q,"picker"),I.target.value=""}}),R.jsx(gh,{label:"Upload",testId:"upload",onClick:()=>{var I;return(I=b.current)==null?void 0:I.click()},Icon:N2}),R.jsx(gh,{label:"Copy",testId:"copy-input",onClick:o,Icon:wv}),R.jsx(gh,{label:"Clear",testId:"clear-input",onClick:s,disabled:C,Icon:f0}),R.jsx(gh,{label:"Download",testId:"download-input",onClick:l,disabled:C,Icon:_2})]}),status:f?{kind:"error",message:f}:h?{kind:"notice",message:h}:null,children:[C?R.jsx(N6,{format:t,onIngest:n,onBrowse:()=>{var I;return(I=b.current)==null?void 0:I.click()},onTryExample:i}):T&&x?R.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:I=>n(I.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):T?R.jsx(lE,{text:e,delimiter:p,testId:"input-table",dark:d,onCellCommit:m}):R.jsx(bA,{value:e,onChange:n,dark:d,testId:"input-editor"}),g?R.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:R.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const UK=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function KK(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:UK.test(t.name)}const XK=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function rS(t,e){const n=new TextDecoder(e,{fatal:!1}),r=t.stream().getReader();let i="";try{for(;;){const{done:s,value:o}=await r.read();if(s)break;i+=n.decode(o,{stream:!0})}}finally{r.releaseLock()}return i+n.decode()}const GK=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function iS(){return R.jsx("div",{className:"h-5 w-px shrink-0 bg-border","aria-hidden":"true"})}function sS(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function oS(){return R.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:R.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function lS({children:t}){return R.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function Ks({label:t,checked:e,onChange:n,hint:r}){return R.jsxs("span",{className:"inline-flex items-center gap-1",children:[R.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[R.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx("span",{className:qi("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:R.jsx("span",{className:qi("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),R.jsx("span",{className:"select-none",children:t})]}),r?R.jsx(vy,{text:r}):null]})}function vy({text:t}){const e=w.useId(),[n,r]=w.useState(!1);return R.jsxs("span",{className:"relative inline-flex items-center",children:[R.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),R.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function qK({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const o=t==="csv2json";return R.jsxs("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-wrap items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:[R.jsxs("span",{className:"inline-flex items-center gap-2",children:[R.jsxs("label",{className:"flex items-center gap-2",children:[R.jsx(lS,{children:"Separator"}),R.jsxs("span",{className:"relative inline-flex",children:[R.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:l=>n({separator:l.target.value}),className:sS(),children:GK.map(l=>R.jsx("option",{value:l.value,children:l.label},l.value))}),R.jsx(oS,{})]})]}),R.jsx(vy,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?R.jsxs(R.Fragment,{children:[R.jsx(iS,{}),R.jsxs("span",{className:"inline-flex items-center gap-2",children:[R.jsxs("label",{className:"flex items-center gap-2",children:[R.jsx(lS,{children:"Encoding"}),R.jsxs("span",{className:"relative inline-flex",children:[R.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:l=>s(l.target.value),className:sS(),children:XK.map(l=>R.jsx("option",{value:l.value,children:l.label},l.value))}),R.jsx(oS,{})]})]}),R.jsx(vy,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,R.jsx(iS,{}),o?R.jsxs(R.Fragment,{children:[R.jsx(Ks,{label:"Parse numbers",checked:e.parseNumbers,onChange:l=>n({parseNumbers:l}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),R.jsx(Ks,{label:"Parse JSON",checked:e.parseJSON,onChange:l=>n({parseJSON:l}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),R.jsx(Ks,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:l=>n({emptyFields:l?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),R.jsx(Ks,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:l=>n({nullLiterals:l?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),R.jsx(Ks,{label:"Transpose",checked:e.transpose,onChange:l=>n({transpose:l}),hint:"Flip rows and columns — the first column becomes the header row."}),R.jsx(Ks,{label:"Hash output",checked:e.hash,onChange:l=>n({hash:l}),hint:"The first column becomes the object key instead of a field."}),R.jsx(Ks,{label:"Minify",checked:e.minify,onChange:l=>n({minify:l}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):R.jsx(Ks,{label:"Flatten nested arrays",checked:e.flatten,onChange:l=>n({flatten:l}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."}),R.jsx("div",{className:"flex-1"}),r?R.jsx("span",{"data-testid":"options-notice",className:"text-muted-foreground",children:r}):null]})}const YK=3;function QK(t){const e=t.slice(0,YK),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` +`)}function JK({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,dark:u,onCopy:c,onDownload:f,onOutputChange:h,onRevert:d,onDiscardReconvert:p}){const m=t==="JSON";return R.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:R.jsx(kA,{title:t,meta:e?null:l?R.jsxs("span",{className:"flex items-center gap-1.5",children:[R.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),R.jsxs("button",{type:"button","data-testid":"revert-output",onClick:d,className:_u,children:[R.jsx(U1,{"aria-hidden":"true"}),"Revert"]})]}):s?R.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:R.jsxs(R.Fragment,{children:[R.jsxs("button",{type:"button","data-testid":"copy-output",onClick:c,disabled:!n,className:_u,children:[R.jsx(wv,{"aria-hidden":"true"}),"Copy"]}),R.jsxs("button",{type:"button","data-testid":"download-output",onClick:f,disabled:!n,className:_u,children:[R.jsx(_2,{"aria-hidden":"true"}),"Download"]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:p?R.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:p,className:_u+" ml-2",children:[R.jsx(U1,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:QK(o)}:null,children:e?R.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?m?R.jsx(bA,{value:n,editable:a,onChange:h,dark:u,testId:"output-view"}):R.jsx(lE,{text:n,testId:"output-table",dark:u}):R.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."})})})}function ZK({phase:t,message:e,onRetry:n}){return t==="loading"?R.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?R.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[R.jsx("span",{children:"This data doesn't exist (or was deleted)."}),R.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?R.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[R.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),R.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):R.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[R.jsx("span",{children:e||"Couldn't load this data."}),R.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const wy=20,xy=80,aS=50;function gm(t){return Math.min(xy,Math.max(wy,t))}function eX({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=w.useRef(null),[l,a]=w.useState(!1),u=t==="stacked";w.useEffect(()=>{if(!l)return;const f=d=>{var x;const p=(x=o.current)==null?void 0:x.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const m=u?(d.clientY-p.top)/p.height:(d.clientX-p.left)/p.width;n(gm(m*100))},h=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)}},[l,u,n]);const c=f=>{const h=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(gm(e-h));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(gm(e+h));break;case"Home":f.preventDefault(),n(wy);break;case"End":f.preventDefault(),n(xy);break;case"Enter":case" ":f.preventDefault(),n(aS);break}};return R.jsxs("div",{ref:o,className:qi("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[R.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:qi("flex min-h-0 min-w-0 flex-col border-border bg-panel","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),R.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-panel",children:i}),R.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":wy,"aria-valuemax":xy,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var h,d;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(d=(h=f.currentTarget).setPointerCapture)==null||d.call(h,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(aS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:qi("absolute z-10","top-[var(--split)] left-0 right-0 h-0 cursor-row-resize","md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:cursor-col-resize"),children:[R.jsx("div",{className:qi("absolute","left-0 right-0 -top-1.5 h-3","md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?R.jsx("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:s}):null]})]})}function tX({theme:t}){return t==="dark"?R.jsx(gI,{size:15,strokeWidth:2,"aria-hidden":"true"}):R.jsx(oI,{size:15,strokeWidth:2,"aria-hidden":"true"})}function nX({theme:t,onToggleTheme:e,slot:n}){return R.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[R.jsxs("div",{className:"flex items-baseline gap-2",children:[R.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),R.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),R.jsx("div",{className:"flex-1"}),R.jsx("div",{"data-testid":"topbar-slot",children:n}),R.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx(tX,{theme:t})})]})}function rX(t){return[...t].sort((e,n)=>n.id-e.id)}const SA=[{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],iX=864e5;function uS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function sX(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((uS(r)-uS(n))/iX);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const CA="csvjson:changelog.v1",Nh=Math.max(...SA.map(t=>t.id),0),oX=rX(SA);function lX(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!aX(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function aX(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function TA(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Nh).sort((e,n)=>e-n)}function cS(t,e,n){const r=TA(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function uX(){try{const t=window.localStorage.getItem(CA);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return lX(e)?{...e,pendingIds:TA(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function cX(t){try{window.localStorage.setItem(CA,JSON.stringify(t))}catch{}}function fX(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.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)}`}async function hX(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function fS(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function dX({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return R.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[R.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&R.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),R.jsx("span",{className:"text-[11px] text-muted-foreground",children:sX(t.date)})]}),R.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),R.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),R.jsxs("div",{className:"mt-1.5 flex gap-1",children:[R.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:fS(e===1),children:R.jsx(bI,{size:13,strokeWidth:2,"aria-hidden":"true"})}),R.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:fS(e===-1),children:R.jsx(wI,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&R.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function pX(){const[t,e]=w.useState(uX),[n,r]=w.useState(!1),i=w.useRef(t),s=w.useCallback(b=>{cX(b),i.current=b,e(b)},[]),[o,l]=w.useState(()=>new Set),a=w.useRef(new Set),u=w.useRef(null),c=w.useRef(null),f=w.useRef(new Map),h=t.lastSeenId!==null&&Nh>t.lastSeenId,d=w.useCallback((b,C)=>{l(T=>{const E=new Set(T);return C?E.add(b):E.delete(b),E})},[]),p=w.useCallback((b,C,T,E)=>{const A=(f.current.get(b)??0)+1;f.current.set(b,A),a.current.add(b),E&&d(b,!0),hX(T,b,C).then(P=>{f.current.get(b)===A&&(a.current.delete(b),P==="ok"&&(LP({entry_id:b,vote:C}),s(cS(i.current,b,!1))),E&&d(b,!1))})},[s,d]),m=w.useCallback(b=>{const{clientId:C,pendingIds:T,votes:E}=i.current,A=T??[];if(A.length!==0&&C!==void 0)for(const P of A){if(P===b||a.current.has(P))continue;const _=E[P];_!==void 0&&p(P,_,C,!1)}},[p]),x=(b,C)=>{if(t.votes[b]===C){m();return}const T=t.clientId??fX();s(cS({...t,votes:{...t.votes,[b]:C},clientId:T},b,!0)),p(b,C,T,!0),m(b)},v=()=>{r(!0),NP(),t.lastSeenId!==Nh&&s({...t,lastSeenId:Nh}),m()},g=w.useCallback(()=>{r(!1)},[]),y=w.useRef(!1);w.useEffect(()=>{var b;y.current&&!n&&((b=c.current)==null||b.focus()),y.current=n},[n]);const k=w.useRef(!1);return w.useEffect(()=>{k.current||(k.current=!0,m())},[m]),w.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&g()},C=T=>{const E=u.current;E===null||!(T.target instanceof Node)||E.contains(T.target)||g()};return document.addEventListener("keydown",b),document.addEventListener("click",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",C)}},[n,g]),R.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[R.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?g():v(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[R.jsx(aI,{size:15,strokeWidth:2,"aria-hidden":"true"}),h&&R.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&R.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[R.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[R.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),R.jsx("button",{type:"button","data-testid":"changelog-close",onClick:g,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:R.jsx(L2,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),R.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:oX.map(b=>{var C;return R.jsx(dX,{entry:b,vote:t.votes[b.id],queued:((C=t.pendingIds)==null?void 0:C.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function gX(t,e){const[n,r]=w.useState(t);return w.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function mX(t){const[e,n]=w.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return w.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const yX={},vX=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],wX=["csv2json","json2csv","csvjson2json"];function xX(t){return wX.includes(t)}const bX=/^[0-9a-f]{32}$/i,kX=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,mm=yX,SX=((mm==null?void 0:mm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function CX(t){const e=kX.exec(t);if(!e)return null;const n=e[1].toLowerCase();return vX.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class by extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class ym extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const vm={csv:(t,e)=>{t.direction="csv2json",t.input=Hd(e)},json:(t,e)=>{t.input=Hd(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Ll(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function Hd(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function hS(t){return typeof t=="string"&&t.trim()!==""}function Ll(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function TX(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function EX(t){var i;if(!TX(t))return null;const e=hS(t.csv),n=hS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=vm[s])==null||i.call(vm,r,o);return r.input=Hd(e?t.csv:t.json),r}async function MX(t){if(!bX.test(t))throw new by;let e;try{e=await fetch(`${SX}${t}`,{mode:"cors"})}catch(r){throw new ym("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new by;if(!e.ok)throw new ym(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new ym("Stored data for this link is malformed")}return n}function AX(t){const e=w.useMemo(()=>t&&xX(t.tool)?t.id:null,[t]),[n,r]=w.useState(0),[i,s]=w.useState(e?"loading":"idle"),[o,l]=w.useState(null),[a,u]=w.useState("");return w.useEffect(()=>{if(!e)return;let c=!1;return MX(e).then(f=>{if(c)return;const h=EX(f);h?(l(h),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof by?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}var ky={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var p={},m;return s.forEach(function(x,v){var g=new RegExp(x,"g");p[x]=(d.match(g)||[]).length,m=!m||p[x]>p[m]?x:m}),m}function u(){var d=[].slice.call(arguments),p=d.reduce(function(m,x){return m.length>x.length?m:x},[]);return p.map(function(m,x){return d.map(function(v){return v[x]})})}function c(d){for(var p={},m=0;m=0;m--){var x=d[m];p[x]>0&&(x=x+"__"+p[x]--),v.unshift(x)}return v}function f(d,p){if(p||(p={}),d.length==0)throw r;var m=p.separator||a(d);if(!m)throw n;var x=[];try{o=p.trim!==!1;var x=h.parse(d,l[m])}catch(O){var v=d.lastIndexOf(` `,O.offset),g=d.indexOf(` `,O.offset),y=d.substring(v>=-1?v:0,g>-1?g:d.length);throw O.message+" On line "+O.line+" and column "+O.column+`. -`+y}p.transpose&&(x=u.apply(this,x));var k=x.shift();if(k.length==0)throw i;k=k.map(function(O){return O.trim()}),k=c(k);for(var b=p.hash?{}:[],C=0;Cy&&(y=g,k=[]),k.push(M))}function C(){var M,F,z,j;return z=g,j=g,M=function(B){return U=","}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=j)):(M=null,g=j),M!==null&&(M=function(B,ge){return ge}(z,M[1])),M===null&&(g=z),M}function T(){var M,F,z,j;return z=g,j=g,M=function(B){return U=";"}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=j)):(M=null,g=j),M!==null&&(M=function(B,ge){return ge}(z,M[1])),M===null&&(g=z),M}function E(){var M,F,z,j;return z=g,j=g,M=function(B){return U="|"}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=j)):(M=null,g=j),M!==null&&(M=function(B,ge){return ge}(z,M[1])),M===null&&(g=z),M}function A(){var M,F,z,j;return z=g,j=g,M=function(B){return U=" "}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=j)):(M=null,g=j),M!==null&&(M=function(B,ge){return ge}(z,M[1])),M===null&&(g=z),M}function P(){var M,F,z,j,B,ge,we,ue,_e;for(ge=g,we=g,M=[],/^[\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[\\n\\r]"));F!==null;)M.push(F),/^[\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[\\n\\r]"));if(M!==null)if(F=D(),F!==null){if(z=[],ue=g,_e=g,/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]")),B!==null)for(j=[];B!==null;)j.push(B),/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));else j=null;for(j!==null?(B=D(),B!==null?j=[j,B]:(j=null,g=_e)):(j=null,g=_e),j!==null&&(j=function(Je,qe){return qe}(ue,j[1])),j===null&&(g=ue);j!==null;){if(z.push(j),ue=g,_e=g,/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]")),B!==null)for(j=[];B!==null;)j.push(B),/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));else j=null;j!==null?(B=D(),B!==null?j=[j,B]:(j=null,g=_e)):(j=null,g=_e),j!==null&&(j=function(Je,qe){return qe}(ue,j[1])),j===null&&(g=ue)}if(z!==null){for(j=[],/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));B!==null;)j.push(B),/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));j!==null?M=[M,F,z,j]:(M=null,g=we)}else M=null,g=we}else M=null,g=we;else M=null,g=we;return M!==null&&(M=function(Je,qe,Ye){return Ye.unshift(qe),Ye}(ge,M[1],M[2])),M===null&&(g=ge),M}function D(){var M,F,z,j,B,ge,we,ue,_e;if(ge=g,we=g,M=O(),M!==null){for(F=[],ue=g,_e=g,m.length>g?(z=m.charAt(g),g++):(z=null,b("any character")),z!==null?(j=function(Je,qe){return qe==U}(g,z)?"":null,j!==null?(B=O(),B!==null?z=[z,j,B]:(z=null,g=_e)):(z=null,g=_e)):(z=null,g=_e),z!==null&&(z=function(Je,qe,Ye){return Ye}(ue,z[0],z[2])),z===null&&(g=ue);z!==null;)F.push(z),ue=g,_e=g,m.length>g?(z=m.charAt(g),g++):(z=null,b("any character")),z!==null?(j=function(Je,qe){return qe==U}(g,z)?"":null,j!==null?(B=O(),B!==null?z=[z,j,B]:(z=null,g=_e)):(z=null,g=_e)):(z=null,g=_e),z!==null&&(z=function(Je,qe,Ye){return Ye}(ue,z[0],z[2])),z===null&&(g=ue);F!==null?(z=function(Je,qe,Ye){return!!qe||Ye.length}(g,M,F)?"":null,z!==null?M=[M,F,z]:(M=null,g=we)):(M=null,g=we)}else M=null,g=we;return M!==null&&(M=function(Je,qe,Ye){return Ye.unshift(qe),Ye}(ge,M[0],M[1])),M===null&&(g=ge),M}function O(){var M,F,z,j,B,ge;if(j=g,B=g,m.charCodeAt(g)===34?(M='"',g++):(M=null,b('"\\""')),M!==null){for(F=[],z=_();z!==null;)F.push(z),z=_();F!==null?(m.charCodeAt(g)===34?(z='"',g++):(z=null,b('"\\""')),z!==null?M=[M,F,z]:(M=null,g=B)):(M=null,g=B)}else M=null,g=B;if(M!==null&&(M=function(we,ue){return ue.join("")}(j,M[1])),M===null&&(g=j),M===null){for(j=g,M=[],B=g,ge=g,/^[^\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[^\\n\\r]")),F!==null?(z=function(we,ue){return ue!=U}(g,F)?"":null,z!==null?F=[F,z]:(F=null,g=ge)):(F=null,g=ge),F!==null&&(F=function(we,ue){return ue}(B,F[0])),F===null&&(g=B);F!==null;)M.push(F),B=g,ge=g,/^[^\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[^\\n\\r]")),F!==null?(z=function(we,ue){return ue!=U}(g,F)?"":null,z!==null?F=[F,z]:(F=null,g=ge)):(F=null,g=ge),F!==null&&(F=function(we,ue){return ue}(B,F[0])),F===null&&(g=B);M!==null&&(M=function(we,ue){return(o?ue.join("").trim():ue.join("")).replace(/(^")|("$)/g,"")}(j,M)),M===null&&(g=j)}return M}function _(){var M,F,z,j;return z=g,j=g,m.charCodeAt(g)===34?(M='"',g++):(M=null,b('"\\""')),M!==null?(m.charCodeAt(g)===34?(F='"',g++):(F=null,b('"\\""')),F!==null?M=[M,F]:(M=null,g=j)):(M=null,g=j),M!==null&&(M=function(B){return'"'}()),M===null&&(g=z),M===null&&(/^[^"]/.test(m.charAt(g))?(M=m.charAt(g),g++):(M=null,b('[^"]'))),M}function I(M){M.sort();for(var F=null,z=[],j=0;jy&&(y=g,k=[]),k.push(M))}function C(){var M,F,z,W;return z=g,W=g,M=function(B){return X=","}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=W)):(M=null,g=W),M!==null&&(M=function(B,de){return de}(z,M[1])),M===null&&(g=z),M}function T(){var M,F,z,W;return z=g,W=g,M=function(B){return X=";"}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=W)):(M=null,g=W),M!==null&&(M=function(B,de){return de}(z,M[1])),M===null&&(g=z),M}function E(){var M,F,z,W;return z=g,W=g,M=function(B){return X="|"}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=W)):(M=null,g=W),M!==null&&(M=function(B,de){return de}(z,M[1])),M===null&&(g=z),M}function A(){var M,F,z,W;return z=g,W=g,M=function(B){return X=" "}()?"":null,M!==null?(F=P(),F!==null?M=[M,F]:(M=null,g=W)):(M=null,g=W),M!==null&&(M=function(B,de){return de}(z,M[1])),M===null&&(g=z),M}function P(){var M,F,z,W,B,de,ge,ae,Re;for(de=g,ge=g,M=[],/^[\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[\\n\\r]"));F!==null;)M.push(F),/^[\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[\\n\\r]"));if(M!==null)if(F=_(),F!==null){if(z=[],ae=g,Re=g,/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]")),B!==null)for(W=[];B!==null;)W.push(B),/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));else W=null;for(W!==null?(B=_(),B!==null?W=[W,B]:(W=null,g=Re)):(W=null,g=Re),W!==null&&(W=function(nt,Ze){return Ze}(ae,W[1])),W===null&&(g=ae);W!==null;){if(z.push(W),ae=g,Re=g,/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]")),B!==null)for(W=[];B!==null;)W.push(B),/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));else W=null;W!==null?(B=_(),B!==null?W=[W,B]:(W=null,g=Re)):(W=null,g=Re),W!==null&&(W=function(nt,Ze){return Ze}(ae,W[1])),W===null&&(g=ae)}if(z!==null){for(W=[],/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));B!==null;)W.push(B),/^[\n\r]/.test(m.charAt(g))?(B=m.charAt(g),g++):(B=null,b("[\\n\\r]"));W!==null?M=[M,F,z,W]:(M=null,g=ge)}else M=null,g=ge}else M=null,g=ge;else M=null,g=ge;return M!==null&&(M=function(nt,Ze,Ge){return Ge.unshift(Ze),Ge}(de,M[1],M[2])),M===null&&(g=de),M}function _(){var M,F,z,W,B,de,ge,ae,Re;if(de=g,ge=g,M=O(),M!==null){for(F=[],ae=g,Re=g,m.length>g?(z=m.charAt(g),g++):(z=null,b("any character")),z!==null?(W=function(nt,Ze){return Ze==X}(g,z)?"":null,W!==null?(B=O(),B!==null?z=[z,W,B]:(z=null,g=Re)):(z=null,g=Re)):(z=null,g=Re),z!==null&&(z=function(nt,Ze,Ge){return Ge}(ae,z[0],z[2])),z===null&&(g=ae);z!==null;)F.push(z),ae=g,Re=g,m.length>g?(z=m.charAt(g),g++):(z=null,b("any character")),z!==null?(W=function(nt,Ze){return Ze==X}(g,z)?"":null,W!==null?(B=O(),B!==null?z=[z,W,B]:(z=null,g=Re)):(z=null,g=Re)):(z=null,g=Re),z!==null&&(z=function(nt,Ze,Ge){return Ge}(ae,z[0],z[2])),z===null&&(g=ae);F!==null?(z=function(nt,Ze,Ge){return!!Ze||Ge.length}(g,M,F)?"":null,z!==null?M=[M,F,z]:(M=null,g=ge)):(M=null,g=ge)}else M=null,g=ge;return M!==null&&(M=function(nt,Ze,Ge){return Ge.unshift(Ze),Ge}(de,M[0],M[1])),M===null&&(g=de),M}function O(){var M,F,z,W,B,de;if(W=g,B=g,m.charCodeAt(g)===34?(M='"',g++):(M=null,b('"\\""')),M!==null){for(F=[],z=D();z!==null;)F.push(z),z=D();F!==null?(m.charCodeAt(g)===34?(z='"',g++):(z=null,b('"\\""')),z!==null?M=[M,F,z]:(M=null,g=B)):(M=null,g=B)}else M=null,g=B;if(M!==null&&(M=function(ge,ae){return ae.join("")}(W,M[1])),M===null&&(g=W),M===null){for(W=g,M=[],B=g,de=g,/^[^\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[^\\n\\r]")),F!==null?(z=function(ge,ae){return ae!=X}(g,F)?"":null,z!==null?F=[F,z]:(F=null,g=de)):(F=null,g=de),F!==null&&(F=function(ge,ae){return ae}(B,F[0])),F===null&&(g=B);F!==null;)M.push(F),B=g,de=g,/^[^\n\r]/.test(m.charAt(g))?(F=m.charAt(g),g++):(F=null,b("[^\\n\\r]")),F!==null?(z=function(ge,ae){return ae!=X}(g,F)?"":null,z!==null?F=[F,z]:(F=null,g=de)):(F=null,g=de),F!==null&&(F=function(ge,ae){return ae}(B,F[0])),F===null&&(g=B);M!==null&&(M=function(ge,ae){return(o?ae.join("").trim():ae.join("")).replace(/(^")|("$)/g,"")}(W,M)),M===null&&(g=W)}return M}function D(){var M,F,z,W;return z=g,W=g,m.charCodeAt(g)===34?(M='"',g++):(M=null,b('"\\""')),M!==null?(m.charCodeAt(g)===34?(F='"',g++):(F=null,b('"\\""')),F!==null?M=[M,F]:(M=null,g=W)):(M=null,g=W),M!==null&&(M=function(B){return'"'}()),M===null&&(g=z),M===null&&(/^[^"]/.test(m.charAt(g))?(M=m.charAt(g),g++):(M=null,b('[^"]'))),M}function I(M){M.sort();for(var F=null,z=[],W=0;W{if(!$d(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(FX)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):$d(t)?e(t):t}function zX(t,e){if(e.parseJSON){const n=LX(t);if(n.ok&&typeof n.value!="number")return n.value}return e.parseNumbers?NX(t):t}function $X(t,e){const n=i=>{const s={};for(const o of Object.keys(i)){const l=i[o];if(typeof l!="string"){s[o]=l;continue}const a=zX(l,e);if(!(e.emptyFields==="skip"&&a==="")){if(e.nullLiterals==="null"&&a==="NULL"){s[o]=null;continue}s[o]=a}}return s};if(Array.isArray(t))return t.map(i=>$d(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=$d(s)?n(s):s;return r}function fS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string"},r=t.startsWith(cS)?t.slice(cS.length):t;try{const i=AX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1});return $X(i,n)}catch(i){throw new Error(SA(i))}}function HX(t,e={}){try{const n=e.flatten?BX(t):t;return OX(n,e)}catch(n){const r=SA(n);throw DX.some(i=>r.startsWith(i))?new PX(IX(r,e.flatten??!1)):new Error(r)}}function jX(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const CA={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1};function WX(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const hS=t=>t==="auto"?void 0:t;function VX(t){let e=!1,n=1;for(let r=0;r{if(!jd(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(zX)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):jd(t)?e(t):t}function HX(t,e){if(e.parseJSON){const n=BX(t);if(n.ok&&typeof n.value!="number")return n.value}return e.parseNumbers?FX(t):t}function jX(t,e){const n=i=>{const s={};for(const o of Object.keys(i)){const l=i[o];if(typeof l!="string"){s[o]=l;continue}const a=HX(l,e);if(!(e.emptyFields==="skip"&&a==="")){if(e.nullLiterals==="null"&&a==="NULL"){s[o]=null;continue}s[o]=a}}return s};if(Array.isArray(t))return t.map(i=>jd(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=jd(s)?n(s):s;return r}function pS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string"},r=t.startsWith(dS)?t.slice(dS.length):t;try{const i=OX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1});return jX(i,n)}catch(i){throw new Error(EA(i))}}function WX(t,e={}){try{const n=e.flatten?$X(t):t;return IX(n,e)}catch(n){const r=EA(n);throw NX.some(i=>r.startsWith(i))?new DX(_X(r,e.flatten??!1)):new Error(r)}}function VX(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const MA={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1};function UX(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const gS=t=>t==="auto"?void 0:t;function KX(t){let e=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:a}:{}}}let r;try{r=JSON.parse(e)}catch(o){return{ok:!1,error:`Invalid JSON — ${o instanceof Error?o.message:String(o)}`}}const i=HX(r,{separator:hS(n.separator),flatten:n.flatten}),s=mp(i);return{ok:!0,text:i,rows:s.rows.length,cols:s.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}async function dS(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const XX="\uFEFF";function GX(t,e){return e?XX+t:t}function qX(t,e,n){const r=GX(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const YX=new Set(["csv","tsv","json","txt"]);function QX(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!YX.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function JX(t,e){const n=e==="csv2json"?"json":"csv";return t?`${QX(t)}.${n}`:`data.${n}`}function pS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=qX(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function ZX(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const eG=`album,year,US_peak_chart_post +`&&r++,n++)}return e?n:null}function XX(t,e){const n=[],r=KX(t);r!==null&&n.push(`Unbalanced quote on line ${r} — parsed as plain text`);const i=vp(t,e),s=r!==null&&i.rows.length>0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:a}:{}}}let r;try{r=JSON.parse(e)}catch(o){return{ok:!1,error:`Invalid JSON — ${o instanceof Error?o.message:String(o)}`}}const i=WX(r,{separator:gS(n.separator),flatten:n.flatten}),s=vp(i);return{ok:!0,text:i,rows:s.rows.length,cols:s.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}async function mS(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const qX="\uFEFF";function YX(t,e){return e?qX+t:t}function QX(t,e,n){const r=YX(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const JX=new Set(["csv","tsv","json","txt"]);function ZX(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!JX.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function eG(t,e){const n=e==="csv2json"?"json":"csv";return t?`${ZX(t)}.${n}`:`data.${n}`}function yS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=QX(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function tG(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const nG=`album,year,US_peak_chart_post The White Stripes,1999, De Stijl,2000, White Blood Cells,2001,61 Elephant,2003,6 Get Behind Me Satan,2005,3 -Icky Thump,2007,2`,tG=`[ +Icky Thump,2007,2`,rG=`[ { "album": "Elephant", "year": 2003, @@ -264,4 +264,4 @@ Icky Thump,2007,2`,tG=`[ "year": 2007, "label": "XL Recordings" } -]`,TA="csvjson-theme";function nG(){try{const t=localStorage.getItem(TA);return t==="dark"||t==="light"?t:null}catch{return null}}function rG(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function iG(){return nG()??rG()}function sG(t){try{localStorage.setItem(TA,t)}catch{}}const gS=2*1024*1024,oG=150,lG=1e3,aG=2e3,uG=2e3;function cG(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function fG(t){try{return JSON.parse(t),!0}catch{return!1}}function hG(){const[t,e]=w.useState(iG);w.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(q=>{const ve=q==="dark"?"light":"dark";return sG(ve),ve}),[r,i]=w.useState("csv2json"),[s,o]=w.useState(""),[l,a]=w.useState(CA),[u,c]=w.useState(50),[f,h]=w.useState(null),[d,p]=w.useState(!1),[m,x]=w.useState(null),[v,g]=w.useState("utf-8"),y=w.useRef({direction:r,options:l,input:s,resultOk:!0}),k=w.useRef(null);k.current||(k.current=$P({settleMs:aG,minWindowMs:uG,isValid:(q,ve)=>{const pe=y.current;return ve===pe.input?pe.resultOk:Cu(q==="csv_to_json"?"csv2json":"json2csv",ve,pe.options).ok}}));const b=k.current,T=pX("(min-width: 48rem)")?"side-by-side":"stacked",E=r==="csv2json",A=E?"CSV":"JSON",P=E?"JSON":"CSV",D=s.trim()==="",O=s.length>gS?lG:oG,_=dX(s,D?0:O),I=w.useMemo(()=>typeof window>"u"?null:kX(window.location.pathname),[]),Y=EX(I),U=w.useMemo(()=>Cu(r,_,l),[r,_,l]);y.current={direction:r,options:l,input:s,resultOk:U.ok};const[ae,H]=w.useState(null);w.useEffect(()=>{_.trim()!==""&&U.ok&&H(U.text)},[U,_]);const[te,G]=w.useState(!1),[M,F]=w.useState(null),z=te?M:ae,j=E&&!D&&z!==null&&(te||U.ok),B=w.useCallback(q=>{if(q===ae){G(!1),F(null);return}G(!0),F(q)},[ae]),ge=w.useCallback(()=>{const q=Cu(r,s,l);q.ok&&H(q.text),G(!1),F(null)},[r,s,l]),we=()=>{if(te){const q=M??"";fG(q)&&o(q),i(ve=>ve==="csv2json"?"json2csv":"csv2json"),G(!1),F(null);return}if(i(q=>q==="csv2json"?"json2csv":"csv2json"),!D){const q=Cu(r,s,l);q.ok&&o(q.text)}},ue=Y.hydrated;w.useEffect(()=>{if(ue===null)return;const q={...y.current.options,...ue.options};y.current={direction:ue.direction,options:q,input:ue.input,resultOk:Cu(ue.direction,ue.input,q).ok},i(ue.direction),o(ue.input),a(ve=>({...ve,...ue.options})),G(!1),F(null),PP(),b.discrete(ue.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",ue.input)},[ue,b]);const _e=w.useRef(null),Je=async(q,ve)=>{if(!VK(q)){x(`Can't read "${q.name}" as text — drop a ${E?".csv / .tsv":".json"} file.`);return}x(null),p(!0);try{const pe=await eS(q,v);_e.current={file:q,source:ve,text:pe},o(pe),h(q.name),p(!1),b.discrete(E?"csv_to_json":"json_to_csv",ve==="drop"?"drag":"file",pe)}catch{p(!1),x(`Couldn't read "${q.name}".`)}},qe=async q=>{const ve=v;g(q);const pe=_e.current;if(!(!pe||s!==pe.text)){p(!0);try{const se=await eS(pe.file,q);_e.current={...pe,text:se},o(se),p(!1),b.discrete(E?"csv_to_json":"json_to_csv",pe.source==="drop"?"drag":"file",se)}catch{p(!1),g(ve),x(`Couldn't read "${pe.file.name}".`)}}},Ye=w.useCallback(q=>{x(null),o(q),b.edit(E?"csv_to_json":"json_to_csv",q)},[E,b]);w.useEffect(()=>{const q=ve=>{var se;const pe=(se=ve.clipboardData)==null?void 0:se.getData("text/plain");!pe||ZX(ve.target)||(ve.preventDefault(),ve.stopPropagation(),h(null),Ye(pe))};return document.addEventListener("paste",q,!0),()=>document.removeEventListener("paste",q,!0)},[Ye]);const Qe=U.ok?cG(U.rows,U.cols):null,et=!U.ok&&ae?"Last valid result — input has errors":null,Ze=U.ok&&U.warnings&&U.warnings.length>0?U.warnings:null,Ot=s.length>gS,Ie=()=>{Nf({via:"copy",format:E?"csv":"json"}),dS(s)},Te=()=>{Nf({via:"copy",format:E?"json":"csv"});const q=te?M:ae;q&&dS(q)},Q=()=>{Nf({via:"download",format:E?"csv":"json"}),pS(s,f??(E?"data.csv":"data.json"),{mime:E?"text/csv":"application/json",bom:E})},ce=()=>{Nf({via:"download",format:E?"json":"csv"}),pS((te?M:ae)??"",JX(f,E?"csv2json":"json2csv"),{mime:E?"application/json":"text/csv",bom:!E})},ne=R.jsx(jK,{format:A,input:s,onInputChange:Ye,onCellCommit:Ye,onFile:Je,onTryExample:()=>{x(null);const q=E?eG:tG;o(q),b.edit(E?"csv_to_json":"json_to_csv",q)},onClear:()=>{o(""),h(null),G(!1),F(null),b.cancel()},onCopy:Ie,onDownload:Q,filename:f,reading:d,meta:Qe,error:null,notice:m,delimiter:l.separator==="auto"?void 0:l.separator,dark:t==="dark"}),oe=R.jsx(YK,{format:P,inputEmpty:D,outputText:z,error:U.ok?null:U.error,meta:Qe,staleNotice:et,warnings:Ze,edited:te,editable:j,dark:t==="dark",onCopy:Te,onDownload:ce,onOutputChange:B,onRevert:ge,onDiscardReconvert:ge});return R.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[R.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),R.jsxs("div",{className:"flex h-svh min-h-0 flex-col",children:[R.jsx(oD,{}),R.jsx(eX,{theme:t,onToggleTheme:n,slot:R.jsxs("div",{className:"flex items-center gap-1",children:[R.jsx(hX,{}),R.jsx(fD,{})]})}),I&&(Y.phase==="loading"||Y.phase==="not-found"||Y.phase==="unsupported"||Y.phase==="error")?R.jsx(QK,{phase:Y.phase,message:Y.phase==="error"?Y.message:void 0,onRetry:Y.retry}):null,R.jsx(JK,{layout:T,split:u,onSplitChange:c,left:ne,right:oe,children:R.jsx(nD,{direction:r,onFlip:we})}),R.jsx(XK,{direction:r,options:l,onChange:q=>a(ve=>({...ve,...q})),uploadEncoding:v,onUploadEncodingChange:qe,notice:Ot?"Large file — converting on pause":null})]}),R.jsx(iD,{})]})}A2(document.getElementById("root")).render(R.jsx(w.StrictMode,{children:R.jsx(hG,{})}));document.getElementById("root").removeAttribute("inert");RP();OP();export{eW as C,kn as R,T4 as T,Jl as a,QL as b,MP as c,Fl as i,C4 as m,w as r,Br as s}; +]`,AA="csvjson-theme";function iG(){try{const t=localStorage.getItem(AA);return t==="dark"||t==="light"?t:null}catch{return null}}function sG(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function oG(){return iG()??sG()}function lG(t){try{localStorage.setItem(AA,t)}catch{}}const vS=2*1024*1024,aG=150,uG=1e3,cG=2e3,fG=2e3;function hG(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function dG(t){try{return JSON.parse(t),!0}catch{return!1}}function pG(){const[t,e]=w.useState(oG);w.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(ye=>{const _e=ye==="dark"?"light":"dark";return lG(_e),_e}),[r,i]=w.useState("csv2json"),[s,o]=w.useState(""),[l,a]=w.useState(MA),[u,c]=w.useState(50),[f,h]=w.useState(null),[d,p]=w.useState(!1),[m,x]=w.useState(null),[v,g]=w.useState("utf-8"),y=w.useRef({direction:r,options:l,input:s,resultOk:!0}),k=w.useRef(null);k.current||(k.current=WP({settleMs:cG,minWindowMs:fG,isValid:(ye,_e)=>{const H=y.current;return _e===H.input?H.resultOk:Tu(ye==="csv_to_json"?"csv2json":"json2csv",_e,H.options).ok}}));const b=k.current,T=mX("(min-width: 48rem)")?"side-by-side":"stacked",E=r==="csv2json",A=E?"CSV":"JSON",P=E?"JSON":"CSV",_=s.trim()==="",O=s.length>vS?uG:aG,D=gX(s,_?0:O),I=w.useMemo(()=>typeof window>"u"?null:CX(window.location.pathname),[]),Q=AX(I),X=w.useMemo(()=>Tu(r,D,l),[r,D,l]);y.current={direction:r,options:l,input:s,resultOk:X.ok};const[le,j]=w.useState(null);w.useEffect(()=>{D.trim()!==""&&X.ok&&j(X.text)},[X,D]);const[ne,Y]=w.useState(!1),[M,F]=w.useState(null),z=ne?M:le,W=E&&!_&&z!==null&&(ne||X.ok),B=w.useCallback(ye=>{if(ye===le){Y(!1),F(null);return}Y(!0),F(ye)},[le]),de=w.useCallback(()=>{const ye=Tu(r,s,l);ye.ok&&j(ye.text),Y(!1),F(null)},[r,s,l]),ge=()=>{if(ne){const ye=M??"";dG(ye)&&o(ye),i(_e=>_e==="csv2json"?"json2csv":"csv2json"),Y(!1),F(null);return}if(i(ye=>ye==="csv2json"?"json2csv":"csv2json"),!_){const ye=Tu(r,s,l);ye.ok&&o(ye.text)}},ae=Q.hydrated;w.useEffect(()=>{if(ae===null)return;const ye={...y.current.options,...ae.options};y.current={direction:ae.direction,options:ye,input:ae.input,resultOk:Tu(ae.direction,ae.input,ye).ok},i(ae.direction),o(ae.input),a(_e=>({..._e,...ae.options})),Y(!1),F(null),_P(),b.discrete(ae.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",ae.input)},[ae,b]);const Re=w.useRef(null),nt=async(ye,_e)=>{if(!KK(ye)){x(`Can't read "${ye.name}" as text — drop a ${E?".csv / .tsv":".json"} file.`);return}x(null),p(!0);try{const H=await rS(ye,v);Re.current={file:ye,source:_e,text:H},o(H),h(ye.name),p(!1),b.discrete(E?"csv_to_json":"json_to_csv",_e==="drop"?"drag":"file",H)}catch{p(!1),x(`Couldn't read "${ye.name}".`)}},Ze=async ye=>{const _e=v;g(ye);const H=Re.current;if(!(!H||s!==H.text)){p(!0);try{const V=await rS(H.file,ye);Re.current={...H,text:V},o(V),p(!1),b.discrete(E?"csv_to_json":"json_to_csv",H.source==="drop"?"drag":"file",V)}catch{p(!1),g(_e),x(`Couldn't read "${H.file.name}".`)}}},Ge=w.useCallback(ye=>{x(null),o(ye),b.edit(E?"csv_to_json":"json_to_csv",ye)},[E,b]);w.useEffect(()=>{const ye=_e=>{var V;const H=(V=_e.clipboardData)==null?void 0:V.getData("text/plain");!H||tG(_e.target)||(_e.preventDefault(),_e.stopPropagation(),h(null),Ge(H))};return document.addEventListener("paste",ye,!0),()=>document.removeEventListener("paste",ye,!0)},[Ge]);const Ye=X.ok?hG(X.rows,X.cols):null,it=!X.ok&&le?"Last valid result — input has errors":null,rt=X.ok&&X.warnings&&X.warnings.length>0?X.warnings:null,Dt=s.length>vS,Ie=()=>{Ff({via:"copy",format:E?"csv":"json"}),mS(s)},be=()=>{Ff({via:"copy",format:E?"json":"csv"});const ye=ne?M:le;ye&&mS(ye)},Xe=()=>{Ff({via:"download",format:E?"csv":"json"}),yS(s,f??(E?"data.csv":"data.json"),{mime:E?"text/csv":"application/json",bom:E})},qe=()=>{Ff({via:"download",format:E?"json":"csv"}),yS((ne?M:le)??"",eG(f,E?"csv2json":"json2csv"),{mime:E?"application/json":"text/csv",bom:!E})},et=R.jsx(VK,{format:A,input:s,onInputChange:Ge,onCellCommit:Ge,onFile:nt,onTryExample:()=>{x(null);const ye=E?nG:rG;o(ye),b.edit(E?"csv_to_json":"json_to_csv",ye)},onClear:()=>{o(""),h(null),Y(!1),F(null),b.cancel()},onCopy:Ie,onDownload:Xe,filename:f,reading:d,meta:Ye,error:null,notice:m,delimiter:l.separator==="auto"?void 0:l.separator,dark:t==="dark"}),Be=R.jsx(JK,{format:P,inputEmpty:_,outputText:z,error:X.ok?null:X.error,meta:Ye,staleNotice:it,warnings:rt,edited:ne,editable:W,dark:t==="dark",onCopy:be,onDownload:qe,onOutputChange:B,onRevert:de,onDiscardReconvert:de});return R.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[R.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),R.jsxs("div",{className:"flex h-svh min-h-0 flex-col",children:[R.jsx(aD,{}),R.jsx(nX,{theme:t,onToggleTheme:n,slot:R.jsxs("div",{className:"flex items-center gap-1",children:[R.jsx(pX,{}),R.jsx(dD,{})]})}),I&&(Q.phase==="loading"||Q.phase==="not-found"||Q.phase==="unsupported"||Q.phase==="error")?R.jsx(ZK,{phase:Q.phase,message:Q.phase==="error"?Q.message:void 0,onRetry:Q.retry}):null,R.jsx(eX,{layout:T,split:u,onSplitChange:c,left:et,right:Be,children:R.jsx(iD,{direction:r,onFlip:ge})}),R.jsx(qK,{direction:r,options:l,onChange:ye=>a(_e=>({..._e,...ye})),uploadEncoding:v,onUploadEncodingChange:Ze,notice:Dt?"Large file — converting on pause":null})]}),R.jsx(oD,{})]})}P2(document.getElementById("root")).render(R.jsx(w.StrictMode,{children:R.jsx(pG,{})}));document.getElementById("root").removeAttribute("inert");IP();DP();export{nW as C,Tn as R,M4 as T,Jl as a,ZL as b,OP as c,Fl as i,E4 as m,w as r,zr as s}; diff --git a/app/dist/assets/number-overlay-editor-CTQ0oWgC.js b/app/dist/assets/number-overlay-editor-BQY5aYke.js similarity index 99% rename from app/dist/assets/number-overlay-editor-CTQ0oWgC.js rename to app/dist/assets/number-overlay-editor-BQY5aYke.js index e51e50c..8574d9c 100644 --- a/app/dist/assets/number-overlay-editor-CTQ0oWgC.js +++ b/app/dist/assets/number-overlay-editor-BQY5aYke.js @@ -1,4 +1,4 @@ -import{s as Be,R as Y,r as O}from"./index-D1Vhxl5v.js";const Fe=Be("div")({name:"NumberOverlayEditorStyle",class:"gdg-n15fjm3e",propsAsIs:!1});function pe(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start - + diff --git a/app/src/changelog/entries.ts b/app/src/changelog/entries.ts index 8f16540..2a31754 100644 --- a/app/src/changelog/entries.ts +++ b/app/src/changelog/entries.ts @@ -34,6 +34,14 @@ export function newestFirst(entries: ChangelogEntry[]): ChangelogEntry[] { } export const changelogEntries: ChangelogEntry[] = [ + { + id: 10, + date: "2026-09-08", + tag: "new", + title: "Delete rows and columns from the table", + summary: + "Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes.", + }, { id: 9, date: "2026-09-08", diff --git a/app/src/components/CsvTable.test.tsx b/app/src/components/CsvTable.test.tsx index 3a73048..ace7b65 100644 --- a/app/src/components/CsvTable.test.tsx +++ b/app/src/components/CsvTable.test.tsx @@ -1,6 +1,7 @@ -import { fireEvent, render, screen, waitFor } from "@testing-library/react"; +import { fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { afterEach, describe, expect, it, vi } from "vitest"; +import { useState } from "react"; import "../test/glideDataEditorMock"; import { CsvTable } from "./CsvTable"; @@ -358,3 +359,179 @@ describe("CsvTable editing (input table only)", () => { expect(screen.getByTestId("output-table").querySelector('[data-testid^="glide-edit-"]')).toBeNull(); }); }); + +describe("CsvTable deletion actions (input table only)", () => { + /** Harness owning the text, so a committed deletion actually re-parses. */ + function DeletionHarness({ initial, editable = true }: { initial: string; editable?: boolean }) { + const [text, setText] = useState(initial); + return editable ? : ; + } + + it("shows no delete actions without a selection", () => { + render( {}} />); + expect(screen.queryByTestId("csv-table-delete-rows")).toBeNull(); + expect(screen.queryByTestId("csv-table-delete-columns")).toBeNull(); + }); + + it("renders delete actions for the input table but never the output table", () => { + render( + <> + {}} /> + + + ); + // The toolbar is a sibling of the grid element, not a child. + const inputToolbar = screen.getByTestId("input-table-toolbar"); + fireEvent.click(within(screen.getByTestId("input-table")).getByTestId("glide-row-select-0")); + expect(within(inputToolbar).getByTestId("input-table-delete-rows")).toBeInTheDocument(); + + const outputToolbar = screen.getByTestId("output-table-toolbar"); + fireEvent.click(within(screen.getByTestId("output-table")).getByTestId("glide-row-select-0")); + // Same selection state, no deletion affordance: the output is read-only. + expect(within(outputToolbar).getByTestId("output-table-selected-count")).toBeInTheDocument(); + expect(outputToolbar.querySelector('[data-testid$="-delete-rows"]')).toBeNull(); + expect(outputToolbar.querySelector('[data-testid$="-delete-columns"]')).toBeNull(); + }); + + it("deletes a selected row from the source and clears the selection", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-row-select-1")); // Elephant, source row 2 + expect(screen.getByTestId("csv-table-delete-rows")).toHaveTextContent("Delete 1 row"); + await user.click(screen.getByTestId("csv-table-delete-rows")); + await waitFor(() => expect(screen.getByTestId("csv-table-count")).toHaveTextContent("3 rows")); + // The raw text re-parsed: source row numbers renumber to the new text. + expect(viewSourceRows()).toEqual([1, 2, 3]); + expect(cellText(0, 1)).toBe("De Stijl"); + expect(cellText(1, 1)).toBe("White Blood Cells"); + expect(screen.queryByTestId("csv-table-selected-count")).toBeNull(); + }); + + it("deletes a multi-row view range (source rows 1-3)", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-row-select-0")); + // Modifier clicks go through fireEvent — the established convention in + // this suite (userEvent does not deliver shiftKey to the mock's onClick). + fireEvent.click(screen.getByTestId("glide-row-select-2"), { shiftKey: true }); + expect(screen.getByTestId("csv-table-delete-rows")).toHaveTextContent("Delete 3 rows"); + await user.click(screen.getByTestId("csv-table-delete-rows")); + await waitFor(() => expect(screen.getByTestId("csv-table-count")).toHaveTextContent("1 row")); + expect(viewSourceRows()).toEqual([1]); + expect(cellText(0, 1)).toBe("Get Behind Me Satan"); + }); + + it("deletes the correct source rows when the view is sorted", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-header-2")); // year asc: De Stijl first + await user.click(screen.getByTestId("glide-row-select-0")); // view row 0 = source row 1 + await user.click(screen.getByTestId("csv-table-delete-rows")); + await waitFor(() => expect(screen.getByTestId("csv-table-count")).toHaveTextContent("3 rows")); + // Source row 1 (De Stijl, first in the sorted view) was dropped — not + // view row 0's post-parse neighbor. The year-ascending sort persists, + // so the surviving rows re-sort into the same view order. + expect(screen.getByTestId("csv-table").textContent).not.toContain("De Stijl"); + expect(cellText(0, 1)).toBe("White Blood Cells"); + expect(cellText(1, 1)).toBe("Elephant"); + expect(cellText(2, 1)).toBe("Get Behind Me Satan"); + }); + + it("deletes a selected column's header and every row's cell", async () => { + const user = userEvent.setup(); + render(); + // Grid column 2 = the YEAR data column (the gutter is grid column 0). + await user.click(screen.getByTestId("glide-select-column-2")); + expect(screen.getByTestId("csv-table-delete-columns")).toHaveTextContent("Delete 1 column"); + await user.click(screen.getByTestId("csv-table-delete-columns")); + await waitFor(() => expect(screen.getByTestId("csv-table-count")).toHaveTextContent("4 rows")); + expect(screen.getByTestId("glide-grid-headers")).toHaveTextContent("#ALBUM"); + expect(screen.getByTestId("glide-grid-headers")).not.toHaveTextContent("YEAR"); + expect(cellText(0, 1)).toBe("De Stijl"); + }); + + it("blocks deleting the last remaining column with a disabled action and tooltip", async () => { + const user = userEvent.setup(); + render(); + // Grid column 1 is the table's only DATA column (grid column 0 is the + // gutter, which is not a data column and never counts). + await user.click(screen.getByTestId("glide-select-column-1")); + const deleteColumns = screen.getByTestId("csv-table-delete-columns"); + expect(deleteColumns).toBeDisabled(); + expect(deleteColumns).toHaveAttribute( + "title", + "At least one column must remain — the converter needs a column to detect" + ); + await user.click(deleteColumns); // no-op + expect(screen.getByTestId("glide-grid-headers")).toHaveTextContent("#ALBUM"); + }); + + it("disables column deletion when every column is selected", () => { + render(); + // Blend-select both DATA columns (grid columns 1-2; the gutter is 0). + fireEvent.click(screen.getByTestId("glide-select-column-1"), { metaKey: true }); + fireEvent.click(screen.getByTestId("glide-select-column-2"), { metaKey: true }); + const deleteColumns = screen.getByTestId("csv-table-delete-columns"); + expect(deleteColumns).toHaveTextContent("Delete 2 columns"); + expect(deleteColumns).toBeDisabled(); + }); + + it("keyboard Delete on selected rows deletes them via onDelete and suppresses cell-clearing", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-row-select-0")); + fireEvent.click(screen.getByTestId("glide-row-select-2"), { shiftKey: true }); // rows 0-2 + const deleteKey = screen.getByTestId("glide-delete-key"); + fireEvent.click(deleteKey); + // false tells Glide the handler owns the deletion: no cell-clearing pass. + expect(deleteKey.getAttribute("data-delete-result")).toBe("false"); + await waitFor(() => expect(screen.getByTestId("csv-table-count")).toHaveTextContent("1 row")); + expect(cellText(0, 1)).toBe("Get Behind Me Satan"); + }); + + it("keyboard Delete on a selected column deletes it", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-select-column-2")); // YEAR data column + fireEvent.click(screen.getByTestId("glide-delete-key")); + await waitFor(() => + expect(screen.getByTestId("glide-grid-headers")).toHaveTextContent("#ALBUM") + ); + expect(screen.getByTestId("glide-grid-headers")).not.toHaveTextContent("YEAR"); + }); + + it("keyboard Delete over a cell range deletes the encompassed rows", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-select-range")); // 1x2 range: view rows 0-1 + const deleteKey = screen.getByTestId("glide-delete-key"); + fireEvent.click(deleteKey); + expect(deleteKey.getAttribute("data-delete-result")).toBe("false"); + await waitFor(() => expect(screen.getByTestId("csv-table-count")).toHaveTextContent("2 rows")); + expect(cellText(0, 1)).toBe("White Blood Cells"); + expect(cellText(1, 1)).toBe("Get Behind Me Satan"); + }); + + it("keyboard Delete refuses to delete the only column", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-select-column-1")); // the only data column + fireEvent.click(screen.getByTestId("glide-delete-key")); + expect(screen.getByTestId("glide-delete-key").getAttribute("data-delete-result")).toBe("false"); + // Nothing committed: same headers, same rows, no empty-column state. + expect(screen.getByTestId("glide-grid-headers")).toHaveTextContent("#ALBUM"); + expect(screen.getByTestId("csv-table-count")).toHaveTextContent("2 rows"); + }); + + it("falls through to the empty state when every row is deleted", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-row-select-0")); + fireEvent.click(screen.getByTestId("glide-row-select-3"), { shiftKey: true }); + await user.click(screen.getByTestId("csv-table-delete-rows")); + expect(await screen.findByTestId("csv-table-empty-rows")).toHaveTextContent("No rows"); + // Headers survive: a headers-only table is valid and still convertible. + expect(screen.getByTestId("glide-grid-headers")).toHaveTextContent("#ALBUMYEAR"); + expect(screen.getByTestId("csv-table-count")).toHaveTextContent("0 rows"); + }); +}); diff --git a/app/src/components/CsvTable.tsx b/app/src/components/CsvTable.tsx index 10915d6..ea448c3 100644 --- a/app/src/components/CsvTable.tsx +++ b/app/src/components/CsvTable.tsx @@ -17,8 +17,9 @@ import { ImageWindowLoaderImpl, } from "@glideapps/glide-data-grid"; import "@glideapps/glide-data-grid/dist/index.css"; -import { Copy, Search, X } from "lucide-react"; +import { Copy, Search, Trash2, X } from "lucide-react"; import { numericColumns, parseCsvRecord, parseCsvTable, serializeCsvRow } from "@/lib/csvTable"; +import { serializeTableWithoutColumns, serializeTableWithoutRows } from "@/lib/tableDeletion"; import { filterRowIndices, sortRowIndices, type SortDir } from "@/lib/tableView"; import { serializeGridSelection } from "@/lib/tableSelection"; @@ -38,11 +39,14 @@ import { serializeGridSelection } from "@/lib/tableSelection"; * virtualization, drag/keyboard range selection, cell editors, the fill * handle, paste splitting, and column resizing. Ours stays everything the * canvas can't take from the raw text: the search toolbar, the numeric- - * aware sort (BigInt-safe), RFC 4180 copy serialization, and the guarded + * aware sort (BigInt-safe), RFC 4180 copy serialization, the guarded * reconversion path — every cell edit splices the edited row's exact bytes * and hands the result to onCellCommit, so the raw CSV is the single - * source of truth. The output pane renders this same component with no - * onCellCommit: strictly read-only, no editor, no editing affordances. + * source of truth — and, on the input table only, row/column deletion + * (toolbar buttons and the keyboard Delete path via Glide's onDelete), + * which mutates the parsed table and reconverts through the same guard. + * The output pane renders this same component with no onCellCommit: + * strictly read-only, no editor, no editing or deletion affordances. */ const ROW_HEIGHT = 24; @@ -85,7 +89,20 @@ type GutterClickEvent = { shiftKey?: boolean; metaKey?: boolean; ctrlKey?: boole const TOOLBAR_BUTTON = "inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50"; -/** Canvas has no CSS variables — resolve the palette per theme explicitly. */ +/** Canvas has no CSS variables — resolve the palette per theme explicitly. + * + * Selected-header contract (contrast fix, 2026-09-08): Glide pre-fills a + * selected column header with `accentColor` before the drawHeader callback + * runs, and paints the title text in `textHeaderSelected`. Those two must + * therefore CONTRAST — but both were mapped to the theme's inverted ink + * (dark: near-white; light: near-black), so a selected header rendered as + * a solid inverted block with invisible same-on-same text. The fix is the + * wash treatment in drawHeader: an opaque `bgHeaderHovered` fill painted + * over the accentColor block plus an `accentColor` bottom border, which + * makes the existing textHeaderSelected values (kept as-is) genuinely + * contrasting in both themes. accentColor itself stays untouched — cell + * ranges, row markers, and the fill handle still use it. + */ function buildTheme(dark: boolean): Partial { if (dark) { return { @@ -259,6 +276,13 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false, }); }, [view]); + // A column deletion (or any column-shrinking edit) can strand the sort + // state past the last header — drop it rather than keep a glyph target + // that no longer exists. Filter/search re-derive on their own. + useEffect(() => { + setSort((prev) => (prev !== null && prev.col >= columnsCount ? null : prev)); + }, [columnsCount]); + const isFiltered = query !== ""; const total = table.rows.length; @@ -327,12 +351,12 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false, })); }, []); - const clearSelection = () => { + const clearSelection = useCallback(() => { anchorRef.current = null; selectedSourcesRef.current = new Set(); setSelectedSources(new Set()); setGridSelection(undefined); - }; + }, []); const handleGridSelectionChange = useCallback((next: GridSelection) => { const sources = new Set(); @@ -347,14 +371,24 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false, const handleSelectionCleared = useCallback(() => { clearSelection(); - }, []); + }, [clearSelection]); // Selected rows currently visible in the view. The chip counts THESE — // never the raw selection set — so the number always matches what Copy // as CSV emits. Hidden selections stay keyed by source index and come // back when the filter clears. const selectedInView = useMemo(() => view.filter((source) => selectedSources.has(source)), [view, selectedSources]); - const selectedColumnCount = gridSelection?.columns.length ?? 0; + // Selected columns as 0-based DATA column indices (the grid selection + // counts the gutter as column 0, and the gutter is not a data column — + // the chip, Copy, and deletion all count data columns only). + const selectedDataColumns = useMemo( + () => + [...(gridSelection?.columns ?? [])] + .filter((c) => c >= GUTTER_COLUMNS) + .map((c) => c - GUTTER_COLUMNS), + [gridSelection] + ); + const selectedColumnCount = selectedDataColumns.length; const showSelectionChip = selectedInView.length > 0 || selectedColumnCount > 0; const copySelection = () => { @@ -407,6 +441,89 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false, return () => window.removeEventListener("copy", onCopy, { capture: true }); }, []); + // Deletion commit path (input table only): a deletion mutates the parsed + // table, re-serializes the whole grid, and hands the text to the same + // guarded reconversion a cell edit takes — the raw CSV stays the single + // source of truth. A deletion changes row/column counts, so the + // selection (keyed by source indices that shift or vanish) is cleared + // with the commit; filter, sort, and the count chip re-derive from the + // new parse. + const commitDeletion = useCallback( + (nextText: string) => { + clearSelection(); + onCellCommit?.(nextText); + }, + [clearSelection, onCellCommit] + ); + + const allColumnsSelected = columnsCount > 0 && selectedDataColumns.length >= columnsCount; + + const deleteSelectedRows = () => { + if (!editable || selectedInView.length === 0) return; + commitDeletion(serializeTableWithoutRows(latestRef.current.table, selectedInView)); + }; + + const deleteSelectedColumns = () => { + // Last-column guard: the serializer needs ≥1 column to reconvert. + if (!editable || allColumnsSelected || selectedDataColumns.length === 0) return; + commitDeletion(serializeTableWithoutColumns(latestRef.current.table, selectedDataColumns)); + }; + + // Keyboard Delete/Backspace (Glide onDelete, verified against the pinned + // 6.0.3 source): whole selected rows first, then whole selected columns, + // then the rows spanned by the current cell range(s). Returns false in + // every case — a boolean true would make Glide ALSO clear the selection's + // cells by splicing empty strings through onCellsEdited over the fresh + // text, and a returned GridSelection would re-target stale geometry. + // In 6.0.3, `onDelete` returning false is the documented way to say + // "already handled — do nothing further". + const onDeleteSelection = useCallback( + (selection: GridSelection): boolean => { + const commit = onCellCommit; + if (!commit) return false; + const { table: current } = latestRef.current; + const view = viewRef.current; + + if (selection.rows.length > 0) { + const sources = [...selection.rows] + .map((viewRow) => view[viewRow]) + .filter((source): source is number => source !== undefined); + if (sources.length > 0) { + commitDeletion(serializeTableWithoutRows(current, sources)); + return false; + } + } + if (selection.columns.length > 0) { + const dataCols = [...selection.columns] + .filter((c) => c >= GUTTER_COLUMNS && c < GUTTER_COLUMNS + current.headers.length) + .map((c) => c - GUTTER_COLUMNS); + // Last-column guard — same rule as the toolbar action. + if (dataCols.length > 0 && dataCols.length < current.headers.length) { + commitDeletion(serializeTableWithoutColumns(current, dataCols)); + } + return false; + } + // A plain cell range (drag or shift+arrow) deletes the rows it + // spans — the primary range plus any stacked multi-rect ranges. + const ranges = + selection.current === undefined ? [] : [selection.current.range, ...selection.current.rangeStack]; + const sources: number[] = []; + for (const range of ranges) { + const from = Math.max(0, Math.min(range.y, view.length)); + const to = Math.max(0, Math.min(range.y + range.height, view.length)); + for (let v = from; v < to; v++) { + const source = view[v]; + if (source !== undefined && !sources.includes(source)) sources.push(source); + } + } + if (sources.length > 0) { + commitDeletion(serializeTableWithoutRows(current, sources)); + } + return false; + }, + [commitDeletion, onCellCommit] + ); + // Cell-edit commit path: splice each edited row's exact byte span out of // the source and hand the new text to onCellCommit — the same guarded // reconversion any raw-view keystroke takes. Paste and fill arrive here @@ -518,16 +635,27 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false, }, [table.headers, numeric, columnWidth]); // Header strip: mono uppercase muted text, sort glyph on the sorted - // column, right-aligned "#" in the gutter. + // column, right-aligned "#" in the gutter. A selected column header + // gets the wash treatment — see the buildTheme contract note: Glide + // pre-fills it with accentColor (inverted ink), so paint the opaque + // bgHeaderHovered wash over that block plus a 2px accentColor bottom + // border; the title then draws in textHeaderSelected, which contrasts + // with the wash in both themes. const drawHeader = useCallback( (args, drawContent) => { - const { ctx, columnIndex, rect, theme } = args; + const { ctx, columnIndex, rect, theme, isSelected } = args; ctx.save(); try { (ctx as unknown as WithLetterSpacing).letterSpacing = "0.5px"; + if (isSelected) { + ctx.fillStyle = theme.bgHeaderHovered; + ctx.fillRect(rect.x, rect.y, rect.width, rect.height); + ctx.fillStyle = theme.accentColor; + ctx.fillRect(rect.x, rect.y + rect.height - 2, rect.width, 2); + } if (columnIndex < GUTTER_COLUMNS) { ctx.fillStyle = theme.bgHeader; - ctx.fillRect(rect.x, rect.y, rect.width, rect.height); + if (!isSelected) ctx.fillRect(rect.x, rect.y, rect.width, rect.height); ctx.fillStyle = theme.textLight; ctx.fillText("#", rect.x + rect.width - 8, rect.y + rect.height / 2 + 0.5); return; @@ -537,7 +665,7 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false, if (sortDir !== null) { const cx = rect.x + rect.width - 11; const cy = rect.y + rect.height / 2; - ctx.fillStyle = theme.textHeader; + ctx.fillStyle = isSelected ? theme.textHeaderSelected : theme.textHeader; ctx.beginPath(); if (sortDir === "asc") { ctx.moveTo(cx, cy - 2.5); @@ -683,6 +811,41 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false,
)} + {!isFiltered && view.length === 0 && ( +
+ No rows. Paste or upload data to start over. +
+ )}
); diff --git a/app/src/lib/__tests__/tableDeletion.test.ts b/app/src/lib/__tests__/tableDeletion.test.ts new file mode 100644 index 0000000..04581f3 --- /dev/null +++ b/app/src/lib/__tests__/tableDeletion.test.ts @@ -0,0 +1,55 @@ +import { describe, expect, it } from "vitest"; +import { parseCsvTable } from "../csvTable"; +import { serializeTableWithoutColumns, serializeTableWithoutRows } from "../tableDeletion"; + +describe("serializeTableWithoutRows", () => { + it("drops the selected source rows and keeps the rest verbatim", () => { + const table = parseCsvTable("a,b\n1,2\n3,4\n5,6"); + expect(serializeTableWithoutRows(table, [1])).toBe("a,b\n1,2\n5,6"); + }); + + it("drops multiple non-adjacent rows regardless of index order", () => { + const table = parseCsvTable("a\nx\ny\nz"); + expect(serializeTableWithoutRows(table, [2, 0])).toBe("a\ny"); + }); + + it("produces a headers-only table when every row is dropped", () => { + const table = parseCsvTable("a,b\n1,2"); + // serializeCsvTable joins records with newlines — no trailing terminator. + expect(serializeTableWithoutRows(table, [0])).toBe("a,b"); + }); + + it("preserves RFC 4180 quoting on surviving cells", () => { + const table = parseCsvTable('a,b\n"1,2",3\n4,5'); + expect(serializeTableWithoutRows(table, [1])).toBe('a,b\n"1,2",3'); + }); + + it("ignores out-of-range indices", () => { + const table = parseCsvTable("a\n1\n2"); + expect(serializeTableWithoutRows(table, [5, -1])).toBe("a\n1\n2"); + }); +}); + +describe("serializeTableWithoutColumns", () => { + it("drops the selected columns' headers and cells", () => { + const table = parseCsvTable("a,b,c\n1,2,3\n4,5,6"); + expect(serializeTableWithoutColumns(table, [1])).toBe("a,c\n1,3\n4,6"); + }); + + it("drops multiple non-adjacent columns", () => { + const table = parseCsvTable("a,b,c,d\n1,2,3,4"); + expect(serializeTableWithoutColumns(table, [0, 3])).toBe("b,c\n2,3"); + }); + + it("preserves RFC 4180 quoting on surviving cells", () => { + const table = parseCsvTable('a,b,c\n"1,2",3,4'); + expect(serializeTableWithoutColumns(table, [1])).toBe('a,c\n"1,2",4'); + }); + + it("round-trips through parseCsvTable", () => { + const table = parseCsvTable("a,b,c\n1,2,3\n4,5,6"); + const next = parseCsvTable(serializeTableWithoutColumns(table, [0, 2])); + expect(next.headers).toEqual(["b"]); + expect(next.rows).toEqual([["2"], ["5"]]); + }); +}); diff --git a/app/src/lib/tableDeletion.ts b/app/src/lib/tableDeletion.ts new file mode 100644 index 0000000..58fe3f5 --- /dev/null +++ b/app/src/lib/tableDeletion.ts @@ -0,0 +1,42 @@ +import { serializeCsvTable, type CsvTableData } from "./csvTable"; + +/** + * Whole-table deletion transforms (spec increment: row/column deletion). + * + * A deletion mutates the parsed grid and re-serializes it — the same + * serializeCsvTable → setInput → guarded-reconversion path a cell edit + * takes, so the raw CSV text stays the single source of truth. Both + * transforms are total: indices outside the table are ignored, and the + * result re-parses to exactly the grid described here (the RFC 4180 + * round-trip is stable). + * + * Deleting rows keeps their exact source positions meaningful only until + * the re-parse: the caller must drop any selection keyed by source index + * (positions shift after a middle-row deletion). The output's rowWidths + * re-derive from the new parse, so serialized rows all match the header + * width and never trip the malformed-CSV warning detector. + */ + +/** + * CSV text for `table` minus the given SOURCE row indices. Headers are + * kept even when every data row is dropped — the caller guards the + * column count, not the row count; a headers-only table is valid. + */ +export function serializeTableWithoutRows(table: CsvTableData, sources: readonly number[]): string { + const dropped = new Set(sources); + const rows = table.rows.filter((_, source) => !dropped.has(source)); + return serializeCsvTable(table.headers, rows, table.delimiter); +} + +/** + * CSV text for `table` minus the given DATA column indices (0-based, + * excluding the row-number gutter). Drops each selected header and the + * matching cell from every row. Callers must guarantee at least one + * column survives — the converter needs a column to detect. + */ +export function serializeTableWithoutColumns(table: CsvTableData, dataCols: readonly number[]): string { + const dropped = new Set(dataCols); + const headers = table.headers.filter((_, col) => !dropped.has(col)); + const rows = table.rows.map((row) => row.filter((_, col) => !dropped.has(col))); + return serializeCsvTable(headers, rows, table.delimiter); +} diff --git a/app/src/outputEditing.test.tsx b/app/src/outputEditing.test.tsx index 60ce3ff..faac257 100644 --- a/app/src/outputEditing.test.tsx +++ b/app/src/outputEditing.test.tsx @@ -252,6 +252,28 @@ describe("freeze while edited", () => { expect(outputStatus()).toHaveTextContent(/Output edited/); }); + it("table row deletion does not regenerate the output", async () => { + render(); + await populate(); + await editOutput(replaceDoc(EDITED_TEXT)); + + // A deletion is an input change: the guard must treat it exactly like a + // cell edit — the frozen edited output stays untouched. The toolbar is + // a sibling of the grid element, so query it separately. + const inputToolbar = within(screen.getByTestId("input-pane")).getByTestId("input-table-toolbar"); + fireEvent.click(within(screen.getByTestId("input-table")).getByTestId("glide-row-select-0")); + fireEvent.click(within(inputToolbar).getByTestId("input-table-delete-rows")); + await waitFor(() => + expect(within(screen.getByTestId("input-pane")).getByTestId("input-table-count")).toHaveTextContent( + "5 rows" + ) + ); + await settle(); + + expect(outputEditorView().state.doc.toString()).toBe(EDITED_TEXT); + expect(outputStatus()).toHaveTextContent(/Output edited/); + }); + it("uploads do not regenerate the output", async () => { render(); await populate(); diff --git a/app/src/test/glideDataEditorMock.tsx b/app/src/test/glideDataEditorMock.tsx index 6e8a78c..8998c7e 100644 --- a/app/src/test/glideDataEditorMock.tsx +++ b/app/src/test/glideDataEditorMock.tsx @@ -31,6 +31,8 @@ interface MockGridProps { newValues: readonly { location: readonly [number, number]; value: { kind: string; data: string } }[] ) => void; onGridSelectionChange?: (newSelection: GridSelection) => void; + onDelete?: (selection: GridSelection) => boolean | GridSelection; + gridSelection?: GridSelection; } /** GridCell unions include LoadingCell, which carries no data. */ @@ -129,11 +131,14 @@ vi.mock("@glideapps/glide-data-grid", async (importOriginal) => { key: `colsel${x}`, type: "button", "data-testid": `glide-select-column-${x}`, - onClick: () => { + onClick: (event: { shiftKey: boolean; ctrlKey: boolean; metaKey: boolean }) => { const empty = actual.CompactSelection.empty(); + // The real grid blends columns on ctrl/cmd+click. + const columns = + event.ctrlKey || event.metaKey ? (props.gridSelection?.columns ?? empty).add(x) : empty.add(x); props.onGridSelectionChange?.({ current: undefined, - columns: empty.add(x), + columns, rows: empty, }); }, @@ -142,11 +147,57 @@ vi.mock("@glideapps/glide-data-grid", async (importOriginal) => { ) ); + // Keyboard-path triggers. Canvas gestures can't be simulated, but the + // component's real handlers can: one button injects a 1x2 range + // selection through the controlled onGridSelectionChange (what the real + // grid produces for a two-row drag), and one fires the onDelete + // contract with the live gridSelection — recording its return value so + // tests can assert the component suppresses Glide's own cell-clearing. + const emptySelection = actual.CompactSelection.empty(); + const keyTriggers = React.createElement( + "div", + { "data-testid": "glide-key-triggers" }, + React.createElement( + "button", + { + type: "button", + "data-testid": "glide-select-range", + onClick: () => + props.onGridSelectionChange?.({ + current: { cell: [1, 0], range: { x: 1, y: 0, width: 1, height: 2 }, rangeStack: [] }, + rows: emptySelection, + columns: emptySelection, + }), + }, + "select-range" + ), + React.createElement( + "button", + { + type: "button", + "data-testid": "glide-delete-key", + onClick: (event: { currentTarget: { dataset: { deleteResult?: string } } }) => { + if (!props.onDelete) return; + const result = props.onDelete( + props.gridSelection ?? { + current: undefined, + rows: emptySelection, + columns: emptySelection, + } + ); + event.currentTarget.dataset.deleteResult = result === false ? "false" : String(result); + }, + }, + "delete-key" + ) + ); + return React.createElement( "div", { "data-testid": "glide-grid-mock", tabIndex: 0 }, React.createElement("div", { "data-testid": "glide-grid-headers" }, headerCells), React.createElement("div", { "data-testid": "glide-column-selects" }, columnSelectButtons), + keyTriggers, bodyRows ); }; From 94318330261ca998764462e2b94405fc6e5f110f Mon Sep 17 00:00:00 2001 From: Obvious Date: Tue, 8 Sep 2026 04:23:51 +0000 Subject: [PATCH 2/3] fix(table): gate the empty-rows overlay on editable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Headers-only output — what deleting all input rows produces — rendered "No rows. Paste or upload data to start over." in the read-only output pane, which accepts neither paste nor upload. The overlay now renders only for the editable input table, matching the delete buttons' gate. Review finding: obvious-autobuild-staging[bot] Medium · reliability (PR #207). Adds the output-pane absence assertion it asked for. --- ...tor-Cscy33Rw.js => data-grid-overlay-editor-DSzdLLB9.js} | 2 +- app/dist/assets/{index-BIOflrBp.js => index-BG4BJA8Z.js} | 6 +++--- ...editor-BQY5aYke.js => number-overlay-editor-BELyYPco.js} | 2 +- app/dist/index.html | 2 +- app/src/components/CsvTable.test.tsx | 5 +++++ app/src/components/CsvTable.tsx | 5 ++++- 6 files changed, 15 insertions(+), 7 deletions(-) rename app/dist/assets/{data-grid-overlay-editor-Cscy33Rw.js => data-grid-overlay-editor-DSzdLLB9.js} (98%) rename app/dist/assets/{index-BIOflrBp.js => index-BG4BJA8Z.js} (99%) rename app/dist/assets/{number-overlay-editor-BQY5aYke.js => number-overlay-editor-BELyYPco.js} (99%) diff --git a/app/dist/assets/data-grid-overlay-editor-Cscy33Rw.js b/app/dist/assets/data-grid-overlay-editor-DSzdLLB9.js similarity index 98% rename from app/dist/assets/data-grid-overlay-editor-Cscy33Rw.js rename to app/dist/assets/data-grid-overlay-editor-DSzdLLB9.js index 1ba242c..42946e9 100644 --- a/app/dist/assets/data-grid-overlay-editor-Cscy33Rw.js +++ b/app/dist/assets/data-grid-overlay-editor-DSzdLLB9.js @@ -1 +1 @@ -import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-BIOflrBp.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; +import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-BG4BJA8Z.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; diff --git a/app/dist/assets/index-BIOflrBp.js b/app/dist/assets/index-BG4BJA8Z.js similarity index 99% rename from app/dist/assets/index-BIOflrBp.js rename to app/dist/assets/index-BG4BJA8Z.js index 89020bf..4397ada 100644 --- a/app/dist/assets/index-BIOflrBp.js +++ b/app/dist/assets/index-BG4BJA8Z.js @@ -216,10 +216,10 @@ Please report this to https://github.com/markedjs/marked.`,t){const i="

An err `?(r.push(t.slice(i,o)),i=o+1,l===` `&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` `)&&(r.push(vb(t.slice(i,o))),i=o+1,l===` -`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function wb(t,e,n){var l;const r=pW(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function sE(t){return t!==!0}function xb(t){return typeof t=="string"?t:`${t}px`}const yW=()=>t=>t.innerWidth,vW=()=>t=>t.innerHeight,wW=zr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[yW()],"wmyidgi-1":[vW()]}}),xW=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return w.createElement(wW,{innerHeight:xb(n),innerWidth:xb(e),...i},r)},bW=2,kW=1300;function SW(t,e,n){const r=Tn.useRef(0),[i,s]=t??[0,0];Tn.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/kW);const h=r.current**1.618*f*bW;(c=e.current)==null||c.scrollBy(i*h,s*h),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function CW({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,h,d]=Tn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=OT();return[typeof m=="number"?m*p:v=>Math.ceil(m(v)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:h,overscrollY:d}}const Us={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function ut(t,e){return t===!0?e:t===!1?"":t}function bb(t){const e=vd.value;return{activateCell:ut(t.activateCell," |Enter|shift+Enter"),clear:ut(t.clear,"any+Escape"),closeOverlay:ut(t.closeOverlay,"any+Escape"),acceptOverlayDown:ut(t.acceptOverlayDown,"Enter"),acceptOverlayUp:ut(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:ut(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:ut(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:ut(t.delete,e?"Backspace|Delete":"Delete"),downFill:ut(t.downFill,"primary+_68"),scrollToSelectedCell:ut(t.scrollToSelectedCell,"primary+Enter"),goDownCell:ut(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:ut(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:ut(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:ut(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:ut(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:ut(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:ut(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:ut(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:ut(t.goToFirstCell,"primary+Home"),goToFirstColumn:ut(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:ut(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:ut(t.goToLastCell,"primary+End"),goToLastColumn:ut(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:ut(t.goToLastRow,"primary+ArrowDown"),goToNextPage:ut(t.goToNextPage,"PageDown"),goToPreviousPage:ut(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:ut(t.rightFill,"primary+_82"),search:ut(t.search,"primary+f"),selectAll:ut(t.selectAll,"primary+a"),selectColumn:ut(t.selectColumn,"ctrl+ "),selectGrowDown:ut(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:ut(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:ut(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:ut(t.selectGrowUp,"shift+ArrowUp"),selectRow:ut(t.selectRow,"shift+ "),selectToFirstCell:ut(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:ut(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:ut(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:ut(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:ut(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:ut(t.selectToLastRow,"primary+shift+ArrowDown")}}function TW(t){const e=_F(t);return Tn.useMemo(()=>{if(e===void 0)return bb(Us);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Us.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Us.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Us.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Us.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Us.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Us.selectToLastCell};return bb({...Us,...n})},[e])}const EW=w.lazy(async()=>await IT(()=>import("./data-grid-overlay-editor-Cscy33Rw.js"),[]));let MW=0;function AW(t){return PB($x($x(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return Vo((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Uf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const Wg={kind:ke.Loading,allowOverlay:!1},Kf={columns:St.empty(),rows:St.empty(),current:void 0},RW=(t,e)=>{var Iw,Dw,_w;const[n,r]=w.useState(Kf),[i,s]=w.useState(),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(),c=w.useRef(null),f=w.useRef(),h=typeof window>"u"?null:window,{imageEditorOverride:d,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:v,columns:g,rows:y,getCellContent:k,onCellClicked:b,onCellActivated:C,onFillPattern:T,onFinishedEditing:E,coercePasteValue:A,drawHeader:P,drawCell:_,editorBloom:O,onHeaderClicked:D,onColumnProposeMove:I,spanRangeBehavior:Q="default",onGroupHeaderClicked:X,onCellContextMenu:le,className:j,onHeaderContextMenu:ne,getCellsForSelection:Y,onGroupHeaderContextMenu:M,onGroupHeaderRenamed:F,onCellEdited:z,onCellsEdited:W,onSearchResultsChanged:B,searchResults:de,onSearchValueChange:ge,searchValue:ae,onKeyDown:Re,onKeyUp:nt,keybindings:Ze,editOnType:Ge=!0,onRowAppended:Ye,onColumnMoved:it,validateCell:rt,highlightRegions:Dt,rangeSelect:Ie="rect",columnSelect:be="multi",rowSelect:Xe="multi",rangeSelectionBlending:qe="exclusive",columnSelectionBlending:et="exclusive",rowSelectionBlending:Be="exclusive",onDelete:ye,onDragStart:_e,onMouseMove:H,onPaste:V,copyHeaders:Z=!1,freezeColumns:ue=0,cellActivationBehavior:se="second-click",rowSelectionMode:tt="auto",onHeaderMenuClick:pe,getGroupDetails:De,onSearchClose:Me,onItemHovered:Ve,onSelectionCleared:dt,showSearch:An,onVisibleRegionChanged:un,gridSelection:ct,onGridSelectionChange:vn,minColumnWidth:cn=50,maxColumnWidth:$r=500,maxColumnAutoWidth:Hr,provideEditor:jt,trailingRowOptions:pt,freezeTrailingRows:xt=0,allowedFillDirections:In="orthogonal",scrollOffsetX:Dn,scrollOffsetY:nn,verticalBorder:Rn,onDragOverCell:li,onDrop:vt,onColumnResize:Gt,onColumnResizeEnd:_t,onColumnResizeStart:Nt,customRenderers:_n,fillHandle:Wt,drawFocusRing:kn=!0,experimental:qt,fixedShadowX:Qc,fixedShadowY:Ds,headerIcons:us,imageWindowLoader:cs,initialSize:ml,isDraggable:Jc,onDragLeave:Zc,onRowMoved:_i,overscrollX:yl,overscrollY:vl,preventDiagonalScrolling:wl,rightElement:Oo,rightElementProps:_s,trapFocus:ef=!1,smoothScrollX:tf,smoothScrollY:Ip,scaleToRem:Dp=!1,rowHeight:xl=34,headerHeight:fs=36,groupHeaderHeight:_p=fs,theme:Np,isOutsideClick:nf,renderers:bl}=t,wn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,jr=(wn==null?void 0:wn.kind)??t.rowMarkers??"none",rf=(wn==null?void 0:wn.width)??t.rowMarkerWidth,kl=(wn==null?void 0:wn.startIndex)??t.rowMarkerStartIndex??1,Xa=(wn==null?void 0:wn.theme)??t.rowMarkerTheme,Ns=(wn==null?void 0:wn.checkboxStyle)??"square",kr=Math.max(cn,20),ai=Math.max($r,kr),Ga=Math.max(Hr??ai,kr),Ls=w.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),qa=w.useMemo(()=>Number.parseFloat(Ls.fontSize),[Ls]),{rowHeight:tr,headerHeight:Sl,groupHeaderHeight:Ya,theme:sf,overscrollX:Lp,overscrollY:of}=CW({groupHeaderHeight:_p,headerHeight:fs,overscrollX:yl,overscrollY:vl,remSize:qa,rowHeight:xl,scaleToRem:Dp,theme:Np}),ui=TW(Ze),hs=rf??(y>1e4?48:y>1e3?44:y>100?36:32),Sr=jr!=="none",G=Sr?1:0,Yt=Ye!==void 0,Po=(pt==null?void 0:pt.sticky)===!0,[Fp,lf]=w.useState(!1),Qa=An??Fp,Bp=w.useCallback(()=>{Me!==void 0?Me():lf(!1)},[Me]),J=w.useMemo(()=>ct===void 0?void 0:Uf(ct,G),[ct,G])??n,Wn=w.useRef();Wn.current===void 0&&(Wn.current=new AbortController),w.useEffect(()=>()=>Wn==null?void 0:Wn.current.abort(),[]);const[xn,Cl]=aW(Y,k,G,Wn.current,y),Ja=w.useCallback((S,L,N)=>{if(rt===void 0)return!0;const U=[S[0]-G,S[1]];return rt==null?void 0:rt(U,L,N)},[G,rt]),Fs=w.useRef(ct),fr=w.useCallback((S,L)=>{L&&(S=gW(S,xn,G,Q,Wn.current)),vn!==void 0?(Fs.current=Uf(S,-G),vn(Fs.current)):r(S)},[vn,xn,G,Q]),ci=_l(Gt,w.useCallback((S,L,N,U)=>{Gt==null||Gt(g[N-G],L,N-G,U)},[Gt,G,g])),zp=_l(_t,w.useCallback((S,L,N,U)=>{_t==null||_t(g[N-G],L,N-G,U)},[_t,G,g])),Tl=_l(Nt,w.useCallback((S,L,N,U)=>{Nt==null||Nt(g[N-G],L,N-G,U)},[Nt,G,g])),$p=_l(P,w.useCallback((S,L)=>(P==null?void 0:P({...S,columnIndex:S.columnIndex-G},L))??!1,[P,G])),Hp=_l(_,w.useCallback((S,L)=>(_==null?void 0:_({...S,col:S.col-G},L))??!1,[_,G])),$=w.useCallback(S=>{if(ye!==void 0){const L=ye(Uf(S,-G));return typeof L=="boolean"?L:Uf(L,G)}return!0},[ye,G]),[ie,we,me]=lW(J,fr,qe,et,Be,Ie),ce=w.useMemo(()=>mo(OT(),sf),[sf]),[Ee,Qe]=w.useState([0,0,0]),Je=w.useMemo(()=>{if(bl===void 0)return{};const S={};for(const L of bl)S[L.kind]=L;return S},[bl]),Ce=w.useCallback(S=>S.kind!==ke.Custom?Je[S.kind]:_n==null?void 0:_n.find(L=>L.isMatch(S)),[_n,Je]);let{sizedColumns:Et,nonGrowWidth:Ne}=R4(g,y,Cl,Ee[0]-(G===0?0:hs)-Ee[2],kr,Ga,ce,Ce,Wn.current);jr!=="none"&&(Ne+=hs);const At=w.useMemo(()=>Et.some(S=>S.group!==void 0),[Et]),st=At?Sl+Ya:Sl,gt=J.rows.length,fn=jr==="none"?void 0:gt===0?!1:gt===y?!0:void 0,ot=w.useMemo(()=>jr==="none"?Et:[{title:"",width:hs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Xa,rowMarker:Ns,rowMarkerChecked:fn},...Et],[jr,Et,hs,Xa,Ns,fn]),[rn,Wr]=w.useMemo(()=>[nn!==void 0&&typeof tr=="number"?Math.floor(nn/tr):0,nn!==void 0&&typeof tr=="number"?-(nn%tr):0],[nn,tr]),Qt=w.useRef({height:1,width:1,x:0,y:0}),Cr=w.useMemo(()=>({x:Qt.current.x,y:rn,width:Qt.current.width??1,height:Qt.current.height??1,ty:Wr}),[Wr,rn]),kt=w.useRef(!1),[hn,Tr,Ni]=DF(Cr);Qt.current=hn;const fi=(hn.height??1)>1;w.useLayoutEffect(()=>{if(nn!==void 0&&c.current!==null&&fi){if(c.current.scrollTop===nn)return;c.current.scrollTop=nn,c.current.scrollTop!==nn&&Ni(),kt.current=!0}},[nn,fi,Ni]);const El=(hn.width??1)>1;w.useLayoutEffect(()=>{if(Dn!==void 0&&c.current!==null&&El){if(c.current.scrollLeft===Dn)return;c.current.scrollLeft=Dn,c.current.scrollLeft!==Dn&&Ni(),kt.current=!0}},[Dn,El,Ni]);const Io=hn.x+G,af=hn.y,hr=w.useRef(null),nr=w.useCallback(S=>{var L;S===!0?(L=hr.current)==null||L.focus():window.requestAnimationFrame(()=>{var N;(N=hr.current)==null||N.focus()})},[]),Vn=Yt?y+1:y,Vr=w.useCallback(S=>{const L=G===0?S:S.map(U=>({...U,location:[U.location[0]-G,U.location[1]]})),N=W==null?void 0:W(L);if(N!==!0)for(const U of L)z==null||z(U.location,U.value);return N},[z,W,G]),[Do,jp]=w.useState(),uf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,Ml=kn?(Iw=J.current)==null?void 0:Iw.cell:void 0,cf=Ml==null?void 0:Ml[0],ff=Ml==null?void 0:Ml[1],RA=w.useMemo(()=>{if((Dt===void 0||Dt.length===0)&&(uf??cf??ff??Do)===void 0)return;const S=[];if(Dt!==void 0)for(const L of Dt){const N=ot.length-L.range.x-G;N>0&&S.push({color:L.color,range:{...L.range,x:L.range.x+G,width:Math.min(N,L.range.width)},style:L.style})}return Do!==void 0&&S.push({color:sl(ce.accentColor,0),range:Do,style:"dashed"}),uf!==void 0&&S.push({color:sl(ce.accentColor,.5),range:uf,style:"solid-outline"}),cf!==void 0&&ff!==void 0&&S.push({color:ce.accentColor,range:{x:cf,y:ff,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Do,uf,cf,ff,Dt,ot.length,ce.accentColor,G]),ww=w.useRef(ot);ww.current=ot;const Er=w.useCallback(([S,L],N=!1)=>{var te,q,ee,oe,re,Se,Ae;const U=Yt&&L===Vn-1;if(S===0&&Sr)return U?Wg:{kind:Yr.Marker,allowOverlay:!1,checkboxStyle:Ns,checked:(J==null?void 0:J.rows.hasIndex(L))===!0,markerKind:jr==="clickable-number"?"number":jr,row:kl+L,drawHandle:_i!==void 0,cursor:jr==="clickable-number"?"pointer":void 0};if(U){const ze=S===G?(pt==null?void 0:pt.hint)??"":"",je=ww.current[S];if(((te=je==null?void 0:je.trailingRowOptions)==null?void 0:te.disabled)===!0)return Wg;{const bt=((q=je==null?void 0:je.trailingRowOptions)==null?void 0:q.hint)??ze,Ue=((ee=je==null?void 0:je.trailingRowOptions)==null?void 0:ee.addIcon)??(pt==null?void 0:pt.addIcon);return{kind:Yr.NewRow,hint:bt,allowOverlay:!1,icon:Ue}}}else{const xe=S-G;if(N||(qt==null?void 0:qt.strict)===!0){const je=Qt.current,bt=je.x>xe||xe>je.x+je.width||je.y>L||L>je.y+je.height||L>=Vp.current,Ue=xe===((re=(oe=je.extras)==null?void 0:oe.selected)==null?void 0:re[0])&&L===((Se=je.extras)==null?void 0:Se.selected[1]);let Fe=!1;if(((Ae=je.extras)==null?void 0:Ae.freezeRegions)!==void 0){for(const zt of je.extras.freezeRegions)if(yp(zt,xe,L)){Fe=!0;break}}if(bt&&!Ue&&!Fe)return Wg}let ze=k([xe,L]);return G!==0&&ze.span!==void 0&&(ze={...ze,span:[ze.span[0]+G,ze.span[1]+G]}),ze}},[Yt,Vn,Sr,Ns,J==null?void 0:J.rows,jr,kl,_i,G,pt==null?void 0:pt.hint,pt==null?void 0:pt.addIcon,qt==null?void 0:qt.strict,k]),Wp=w.useCallback(S=>{let L=(De==null?void 0:De(S))??{name:S};return F!==void 0&&S!==""&&(L={icon:L.icon,name:L.name,overrideTheme:L.overrideTheme,actions:[...L.actions??[],{title:"Rename",icon:"renameIcon",onClick:N=>Kp({group:L.name,bounds:N.bounds})}]}),L},[De,F]),hf=w.useCallback(S=>{var ee;const[L,N]=S.cell,U=ot[L],K=(U==null?void 0:U.group)!==void 0?(ee=Wp(U.group))==null?void 0:ee.overrideTheme:void 0,te=U==null?void 0:U.themeOverride,q=p==null?void 0:p(N);s({...S,theme:mo(ce,K,te,q,S.content.themeOverride)})},[p,ot,Wp,ce]),Al=w.useCallback((S,L,N)=>{var q;if(J.current===void 0)return;const[U,K]=J.current.cell,te=Er([U,K]);if(te.kind!==ke.Boolean&&te.allowOverlay){let ee=te;if(N!==void 0)switch(ee.kind){case ke.Number:{const oe=pD(()=>N==="-"?-0:Number.parseFloat(N),0);ee={...ee,data:Number.isNaN(oe)?0:oe};break}case ke.Text:case ke.Markdown:case ke.Uri:ee={...ee,data:N};break}hf({target:S,content:ee,initialValue:N,cell:[U,K],highlight:N===void 0,forceEditMode:N!==void 0})}else te.kind===ke.Boolean&&L&&te.readonly!==!0&&(Vr([{location:J.current.cell,value:{...te,data:sE(te.data)}}]),(q=hr.current)==null||q.damage([{cell:J.current.cell}]))},[Er,J,Vr,hf]),xw=w.useCallback((S,L)=>{var K;const N=(K=hr.current)==null?void 0:K.getBounds(S,L);if(N===void 0||c.current===null)return;const U=Er([S,L]);U.allowOverlay&&hf({target:N,content:U,initialValue:void 0,highlight:!0,cell:[S,L],forceEditMode:!0})},[Er,hf]),dn=w.useCallback((S,L,N="both",U=0,K=0,te=void 0)=>{if(c.current!==null){const q=hr.current,ee=l.current,oe=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,re=typeof L!="number"?L.unit==="cell"?L.amount:void 0:L,Se=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Ae=typeof L!="number"&&L.unit==="px"?L.amount:void 0;if(q!==null&&ee!==null){let xe={x:0,y:0,width:0,height:0},ze=0,je=0;if((oe!==void 0||re!==void 0)&&(xe=q.getBounds((oe??0)+G,re??0)??xe,xe.width===0||xe.height===0))return;const bt=ee.getBoundingClientRect(),Ue=bt.width/ee.offsetWidth;if(Se!==void 0&&(xe={...xe,x:Se-bt.left-c.current.scrollLeft,width:1}),Ae!==void 0&&(xe={...xe,y:Ae+bt.top-c.current.scrollTop,height:1}),xe!==void 0){const Fe={x:xe.x-U,y:xe.y-K,width:xe.width+2*U,height:xe.height+2*K};let zt=0;for(let Jp=0;Jp0&&(Un=gl(Vn,pn,tr));let di=zt*Ue+bt.left+G*hs*Ue,Fi=bt.right,pi=bt.top+st*Ue,Bi=bt.bottom-Un*Ue;const vf=xe.width+U*2;switch(te==null?void 0:te.hAlign){case"start":Fi=di+vf;break;case"end":di=Fi-vf;break;case"center":di=Math.floor((di+Fi)/2)-vf/2,Fi=di+vf;break}const wf=xe.height+K*2;switch(te==null?void 0:te.vAlign){case"start":Bi=pi+wf;break;case"end":pi=Bi-wf;break;case"center":pi=Math.floor((pi+Bi)/2)-wf/2,Bi=pi+wf;break}di>Fe.x?ze=Fe.x-di:FiFe.y?je=Fe.y-pi:Bi=Vn-pn)&&(je=0),(ze!==0||je!==0)&&(Ue!==1&&(ze/=Ue,je/=Ue),c.current.scrollTo(ze+c.current.scrollLeft,je+c.current.scrollTop))}}}},[G,xt,hs,st,ue,Et,Vn,Po,tr]),bw=w.useRef(xw),kw=w.useRef(k),Vp=w.useRef(y);bw.current=xw,kw.current=k,Vp.current=y;const Rl=w.useCallback(async(S,L=!0)=>{var oe;const N=ot[S];if(((oe=N==null?void 0:N.trailingRowOptions)==null?void 0:oe.disabled)===!0)return;const U=Ye==null?void 0:Ye();let K,te=!0;U!==void 0&&(K=await U,K==="top"&&(te=!1),typeof K=="number"&&(te=!1));let q=0;const ee=()=>{if(Vp.current<=y){q<500&&window.setTimeout(ee,q),q=50+q*2;return}const re=typeof K=="number"?K:te?y:0;yf.current(S-G,re),ie({cell:[S,re],range:{x:S,y:re,width:1,height:1}},!1,!1,"edit");const Se=kw.current([S-G,re]);Se.allowOverlay&&Ou(Se)&&Se.readonly!==!0&&L&&window.setTimeout(()=>{bw.current(S,re)},0)};ee()},[ot,Ye,G,y,ie]),df=w.useCallback(S=>{var N,U;const L=((U=(N=Et[S])==null?void 0:N.trailingRowOptions)==null?void 0:U.targetColumn)??(pt==null?void 0:pt.targetColumn);if(typeof L=="number")return L+(Sr?1:0);if(typeof L=="object"){const K=g.indexOf(L);if(K>=0)return K+(Sr?1:0)}},[Et,g,Sr,pt==null?void 0:pt.targetColumn]),Bs=w.useRef(),Ol=w.useRef(),Za=w.useCallback((S,L)=>{var K;const[N,U]=L;return mo(ce,(K=ot[N])==null?void 0:K.themeOverride,p==null?void 0:p(U),S.themeOverride)},[p,ot,ce]),eu=w.useCallback(S=>{var Se,Ae,xe;const L=vd.value?S.metaKey:S.ctrlKey,N=L&&Xe==="multi",U=L&&be==="multi",[K,te]=S.location,q=J.columns,ee=J.rows,[oe,re]=((Se=J.current)==null?void 0:Se.cell)??[];if(S.kind==="cell"){if(Ol.current=void 0,_o.current=[K,te],K===0&&Sr){if(Yt===!0&&te===y||jr==="number"||Xe==="none")return;const ze=Er(S.location);if(ze.kind!==Yr.Marker)return;if(_i!==void 0){const Ue=Ce(ze);Pr((Ue==null?void 0:Ue.kind)===Yr.Marker);const Fe=(Ae=Ue==null?void 0:Ue.onClick)==null?void 0:Ae.call(Ue,{...S,cell:ze,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:Za(ze,S.location),preventDefault:()=>{}});if(Fe===void 0||Fe.checked===ze.checked)return}s(void 0),nr();const je=ee.hasIndex(te),bt=Bs.current;if(Xe==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&bt!==void 0&&ee.hasIndex(bt)){const Ue=[Math.min(bt,te),Math.max(bt,te)+1];N||tt==="multi"?we(void 0,Ue,!0):we(St.fromSingleSelection(Ue),void 0,N)}else N||S.isTouch||tt==="multi"?je?we(ee.remove(te),void 0,!0):(we(void 0,te,!0),Bs.current=te):je&&ee.length===1?we(St.empty(),void 0,L):(we(St.fromSingleSelection(te),void 0,L),Bs.current=te)}else if(K>=G&&Yt&&te===y){const ze=df(K);Rl(ze??K)}else if(oe!==K||re!==te){const ze=Er(S.location),je=Ce(ze);if((je==null?void 0:je.onSelect)!==void 0){let Fe=!1;if(je.onSelect({...S,cell:ze,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>Fe=!0,theme:Za(ze,S.location)}),Fe)return}const bt=Po&&te===y,Ue=Po&&J!==void 0&&((xe=J.current)==null?void 0:xe.cell[1])===y;if((S.shiftKey||S.isLongTouch===!0)&&oe!==void 0&&re!==void 0&&J.current!==void 0&&!Ue){if(bt)return;const Fe=Math.min(K,oe),zt=Math.max(K,oe),Un=Math.min(te,re),pn=Math.max(te,re);ie({...J.current,range:{x:Fe,y:Un,width:zt-Fe+1,height:pn-Un+1}},!0,L,"click"),Bs.current=void 0,nr()}else ie({cell:[K,te],range:{x:K,y:te,width:1,height:1}},!0,L,"click"),Bs.current=void 0,s(void 0),nr()}}else if(S.kind==="header")if(_o.current=[K,te],s(void 0),Sr&&K===0)Bs.current=void 0,Ol.current=void 0,Xe==="multi"&&(ee.length!==y?we(St.fromSingleSelection([0,y]),void 0,L):we(St.empty(),void 0,L),nr());else{const ze=Ol.current;if(be==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&ze!==void 0&&q.hasIndex(ze)){const je=[Math.min(ze,K),Math.max(ze,K)+1];U?me(void 0,je,L):me(St.fromSingleSelection(je),void 0,L)}else U?(q.hasIndex(K)?me(q.remove(K),void 0,L):me(void 0,K,L),Ol.current=K):be!=="none"&&(me(St.fromSingleSelection(K),void 0,L),Ol.current=K);Bs.current=void 0,nr()}else S.kind===Or?_o.current=[K,te]:S.kind===wd&&!S.isMaybeScrollbar&&(fr(Kf,!1),s(void 0),nr(),dt==null||dt(),Bs.current=void 0,Ol.current=void 0)},[Rl,be,nr,Ce,df,Er,J,Sr,Po,dt,_i,G,jr,Xe,tt,y,ie,fr,me,we,Yt,Za]),tu=w.useRef(!1),_o=w.useRef(),Sw=w.useRef(hn),Ur=w.useRef(),OA=w.useCallback(S=>{if(Pl.current=!1,Sw.current=Qt.current,S.button!==0&&S.button!==1){Ur.current=void 0;return}const L=performance.now();Ur.current={button:S.button,time:L,location:S.location},(S==null?void 0:S.kind)==="header"&&(tu.current=!0);const N=S.kind==="cell"&&S.isFillHandle;!N&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:J,fillHandle:N}),_o.current=void 0,!S.isTouch&&S.button===0&&!N?eu(S):!S.isTouch&&S.button===1&&(_o.current=S.location))},[J,eu]),[Up,Kp]=w.useState(),Cw=w.useCallback(S=>{if(S.kind!==Or||be!=="multi")return;const L=vd.value?S.metaKey:S.ctrlKey,[N]=S.location,U=J.columns;if(N=G&&kc(K.group,ot[ee].group);ee--)te--;for(let ee=N+1;ee{if(xn!==void 0&&ci!==void 0){const L=Qt.current.y,N=Qt.current.height;let U=xn({x:S,y:L,width:1,height:Math.min(N,y-L)},Wn.current.signal);typeof U!="object"&&(U=await U());const K=Et[S-G],q=document.createElement("canvas").getContext("2d",{alpha:!1});if(q!==null){q.font=ce.baseFontFull;const ee=PT(q,ce,K,0,U,kr,ai,!1,Ce);ci==null||ci(K,ee.width,S,ee.width)}}},[Et,xn,ai,ce,kr,ci,G,y,Ce]),[PA,Xp]=w.useState(),Il=w.useCallback(async(S,L)=>{var ee,oe;const N=(ee=S.current)==null?void 0:ee.range;if(N===void 0||xn===void 0||L.current===void 0)return;const U=L.current.range;if(T!==void 0){let re=!1;if(T({fillDestination:{...U,x:U.x-G},patternSource:{...N,x:N.x-G},preventDefault:()=>re=!0}),re)return}let K=xn(N,Wn.current.signal);typeof K!="object"&&(K=await K());const te=K,q=[];for(let re=0;re({cell:re.location})))},[xn,Vr,T,G]),Tw=w.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,width:1}}};Il(S,J)},[Il,J]),Ew=w.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,height:1}}};Il(S,J)},[Il,J]),IA=w.useCallback((S,L)=>{var Se,Ae;const N=a;if(u(void 0),jp(void 0),Xp(void 0),tu.current=!1,L)return;if((N==null?void 0:N.fillHandle)===!0&&J.current!==void 0&&((Se=N.previousSelection)==null?void 0:Se.current)!==void 0){if(Do===void 0)return;const xe={...J,current:{...J.current,range:HT(N.previousSelection.current.range,Do)}};Il(N.previousSelection,xe),fr(xe,!0);return}const[U,K]=S.location,[te,q]=_o.current??[],ee=()=>{Pl.current=!0},oe=xe=>{var je,bt,Ue;const ze=xe.isTouch||te===U&&q===K;if(ze&&(b==null||b([U-G,K],{...xe,preventDefault:ee})),xe.button===1)return!Pl.current;if(!Pl.current){const Fe=Er(S.location),zt=Ce(Fe);if(zt!==void 0&&zt.onClick!==void 0&&ze){const pn=zt.onClick({...xe,cell:Fe,posX:xe.localEventX,posY:xe.localEventY,bounds:xe.bounds,theme:Za(Fe,S.location),preventDefault:ee});pn!==void 0&&!Jl(pn)&&Fl(pn)&&(Vr([{location:xe.location,value:pn}]),(je=hr.current)==null||je.damage([{cell:xe.location}]))}if(Pl.current||J.current===void 0)return!1;let Un=!1;switch(Fe.activationBehaviorOverride??se){case"double-click":case"second-click":{if(((Ue=(bt=N==null?void 0:N.previousSelection)==null?void 0:bt.current)==null?void 0:Ue.cell)===void 0)break;const[pn,di]=J.current.cell,[Fi,pi]=N.previousSelection.current.cell;Un=U===pn&&U===Fi&&K===di&&K===pi&&(xe.isDoubleClick===!0||se==="second-click");break}case"single-click":{Un=!0;break}}if(Un)return C==null||C([U-G,K]),Al(xe.bounds,!1),!0}return!1},re=S.location[0]-G;if(S.isTouch){const xe=Qt.current,ze=Sw.current;if(xe.x!==ze.x||xe.y!==ze.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&Xu((Ae=J.current)==null?void 0:Ae.cell,S.location)){le==null||le([re,S.location[1]],{...S,preventDefault:ee});return}else if(S.kind==="header"&&J.columns.hasIndex(U)){ne==null||ne(re,{...S,preventDefault:ee});return}else if(S.kind===Or){if(re<0)return;M==null||M(re,{...S,preventDefault:ee});return}}S.kind==="cell"?oe(S)||eu(S):S.kind===Or?X==null||X(re,{...S,preventDefault:ee}):(S.kind===Xs&&(D==null||D(re,{...S,preventDefault:ee})),eu(S));return}if(S.kind==="header"){if(re<0)return;S.isEdge?S.isDoubleClick===!0&&pf(U):S.button===0&&U===te&&K===q&&(D==null||D(re,{...S,preventDefault:ee}))}if(S.kind===Or){if(re<0)return;S.button===0&&U===te&&K===q&&(X==null||X(re,{...S,preventDefault:ee}),Pl.current||Cw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&oe(S),_o.current=void 0},[a,J,G,Do,Il,fr,b,Er,Ce,se,Za,Vr,C,Al,le,ne,M,eu,X,D,pf,Cw]),DA=w.useCallback(S=>{const L={...S,location:[S.location[0]-G,S.location[1]]};H==null||H(L),a!==void 0&&S.buttons===0&&(u(void 0),jp(void 0),Xp(void 0),tu.current=!1),Xp(N=>{var U;return tu.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===(N==null?void 0:N[0])&&S.scrollEdge[1]===N[1]?N:a===void 0||(((U=Ur.current)==null?void 0:U.location[0])??0){pe==null||pe(S-G,L)},[pe,G]),Li=(Dw=J==null?void 0:J.current)==null?void 0:Dw.cell,NA=w.useCallback((S,L,N,U,K,te)=>{kt.current=!1;let q=Li;q!==void 0&&(q=[q[0]-G,q[1]]);const ee=ue===0?void 0:{x:0,y:S.y,width:ue,height:S.height},oe=[];ee!==void 0&&oe.push(ee),xt>0&&(oe.push({x:S.x-G,y:y-xt,width:S.width,height:xt}),ue>0&&oe.push({x:0,y:y-xt,width:ue,height:xt}));const re={x:S.x-G,y:S.y,width:S.width,height:Yt&&S.y+S.height>=y?S.height-1:S.height,tx:K,ty:te,extras:{selected:q,freezeRegion:ee,freezeRegions:oe}};Qt.current=re,Tr(re),Qe([L,N,U]),un==null||un(re,re.tx,re.ty,re.extras)},[Li,G,Yt,y,ue,xt,Tr,un]),LA=_l(it,w.useCallback((S,L)=>{it==null||it(S-G,L-G),be!=="none"&&me(St.fromSingleSelection(L),void 0,!0)},[be,it,G,me])),Gp=w.useRef(!1),FA=w.useCallback(S=>{if(S.location[0]===0&&G>0){S.preventDefault();return}_e==null||_e({...S,location:[S.location[0]-G,S.location[1]]}),S.defaultPrevented()||(Gp.current=!0),u(void 0)},[_e,G]),BA=w.useCallback(()=>{Gp.current=!1},[]),qp=w.useRef(),Yp=w.useCallback(S=>{var L,N,U;if(!rE(S,qp.current)&&(qp.current=S,!(((L=Ur==null?void 0:Ur.current)==null?void 0:L.button)!==void 0&&Ur.current.button>=1))){if(S.buttons!==0&&a!==void 0&&((N=Ur.current)==null?void 0:N.location[0])===0&&S.location[0]===0&&G===1&&Xe==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(Ur.current.location[1])&&J.rows.hasIndex(Ur.current.location[1])){const K=Math.min(Ur.current.location[1],S.location[1]),te=Math.max(Ur.current.location[1],S.location[1])+1;we(St.fromSingleSelection([K,te]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&J.current!==void 0&&!Gp.current&&!tu.current&&(Ie==="rect"||Ie==="multi-rect")){const[K,te]=J.current.cell;let[q,ee]=S.location;if(ee<0&&(ee=Qt.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const oe=a.previousSelection.current.range;ee=Math.min(ee,Yt?y-1:y);const re=gz(oe,q,ee,In);jp(re)}else{if(Yt&&te===y)return;if(Yt&&ee===y)if(S.kind===wd)ee--;else return;q=Math.max(q,G);const Se=q-K,Ae=ee-te,xe={x:Se>=0?K:q,y:Ae>=0?te:ee,width:Math.abs(Se)+1,height:Math.abs(Ae)+1};ie({...J.current,range:xe},!0,!1,"drag")}}Ve==null||Ve({...S,location:[S.location[0]-G,S.location[1]]})}},[In,a,G,Xe,J,Ie,Ve,we,Yt,y,ie]),zA=w.useCallback(()=>{var q,ee;const S=qp.current;if(S===void 0)return;const[L,N]=S.scrollEdge;let[U,K]=S.location;const te=Qt.current;L===-1?U=((ee=(q=te.extras)==null?void 0:q.freezeRegion)==null?void 0:ee.x)??te.x:L===1&&(U=te.x+te.width),N===-1?K=Math.max(0,te.y):N===1&&(K=Math.min(y-1,te.y+te.height)),U=bi(U,0,ot.length-1),K=bi(K,0,y-1),Yp({...S,location:[U,K]})},[ot.length,Yp,y]);SW(PA,c,zA);const hi=w.useCallback(S=>{if(J.current===void 0)return;const[L,N]=S,[U,K]=J.current.cell,te=J.current.range;let q=te.x,ee=te.x+te.width,oe=te.y,re=te.y+te.height;if(N!==0)switch(N){case 2:{re=y,oe=K,dn(0,re,"vertical");break}case-2:{oe=0,re=K+1,dn(0,oe,"vertical");break}case 1:{oeK+1?(re--,dn(0,re,"vertical")):(oe=Math.max(0,oe-1),dn(0,oe,"vertical"));break}default:bc()}if(L!==0)if(L===2)ee=ot.length,q=U,dn(ee-1-G,0,"horizontal");else if(L===-2)q=G,ee=U+1,dn(q-G,0,"horizontal");else{let Se=[];if(xn!==void 0){const Ae=xn({x:q,y:oe,width:ee-q-G,height:re-oe},Wn.current.signal);typeof Ae=="object"&&(Se=AW(Ae))}if(L===1){let Ae=!1;if(q0){const xe=Vo(q+1,U+1).find(ze=>!Se.includes(ze-G));xe!==void 0&&(q=xe,Ae=!0)}else q++,Ae=!0;Ae&&dn(q,0,"horizontal")}Ae||(ee=Math.min(ot.length,ee+1),dn(ee-1-G,0,"horizontal"))}else if(L===-1){let Ae=!1;if(ee>U+1){if(Se.length>0){const xe=Vo(ee-1,U,-1).find(ze=>!Se.includes(ze-G));xe!==void 0&&(ee=xe,Ae=!0)}else ee--,Ae=!0;Ae&&dn(ee-G,0,"horizontal")}Ae||(q=Math.max(G,q-1),dn(q-G,0,"horizontal"))}else bc()}ie({cell:J.current.cell,range:{x:q,y:oe,width:ee-q,height:re-oe}},!0,!1,"keyboard-select")},[xn,J,ot.length,G,y,dn,ie]),zs=w.useCallback((S,L,N,U)=>{const K=Vn-(N?0:1);if(S=bi(S,G,Et.length-1+G),L=bi(L,0,K),S===(Li==null?void 0:Li[0])&&L===(Li==null?void 0:Li[1]))return!1;if(U&&J.current!==void 0){const te=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&te.push(J.current.range),fr({...J,current:{cell:[S,L],range:{x:S,y:L,width:1,height:1},rangeStack:te}},!0)}else ie({cell:[S,L],range:{x:S,y:L,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===L&&(f.current=void 0),dn(S-G,L),!0},[Vn,G,Et.length,Li,J,dn,fr,ie]),$A=w.useCallback((S,L)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&Fl(S)&&(Vr([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var K;(K=hr.current)==null||K.damage([{cell:i.cell}])})),nr(!0),s(void 0);const[N,U]=L;if(J.current!==void 0&&(N!==0||U!==0)){const K=J.current.cell[1]===Vn-1&&S!==void 0;zs(bi(J.current.cell[0]+N,0,ot.length-1),bi(J.current.cell[1]+U,0,Vn-1),K,!1)}E==null||E(S,L)},[i==null?void 0:i.cell,nr,J,E,Vr,Vn,zs,ot.length]),HA=w.useMemo(()=>`gdg-overlay-${MW++}`,[]),No=w.useCallback(S=>{var N,U,K,te;nr();const L=[];for(let q=S.x;q({cell:q.location})))},[nr,k,Ce,Vr,G]),nu=i!==void 0,Mw=w.useCallback(S=>{var ze,je;const L=()=>{S.stopPropagation(),S.preventDefault()},N={didMatch:!1},{bounds:U}=S,K=J.columns,te=J.rows,q=ui;if(!nu&&at(q.clear,S,N))fr(Kf,!1),dt==null||dt();else if(!nu&&at(q.selectAll,S,N))fr({columns:St.empty(),rows:St.empty(),current:{cell:((ze=J.current)==null?void 0:ze.cell)??[G,0],range:{x:G,y:0,width:g.length,height:y},rangeStack:[]}},!1);else if(at(q.search,S,N))(je=o==null?void 0:o.current)==null||je.focus({preventScroll:!0}),lf(!0);else if(at(q.delete,S,N)){const bt=($==null?void 0:$(J))??!0;if(bt!==!1){const Ue=bt===!0?J:bt;if(Ue.current!==void 0){No(Ue.current.range);for(const Fe of Ue.current.rangeStack)No(Fe)}for(const Fe of Ue.rows)No({x:G,y:Fe,width:g.length,height:1});for(const Fe of Ue.columns)No({x:Fe,y:0,width:1,height:y})}}if(N.didMatch)return L(),!0;if(J.current===void 0)return!1;let[ee,oe]=J.current.cell,re=!1,Se=!1;at(q.scrollToSelectedCell,S,N)?yf.current(ee-G,oe):be!=="none"&&at(q.selectColumn,S,N)?K.hasIndex(ee)?me(K.remove(ee),void 0,!0):be==="single"?me(St.fromSingleSelection(ee),void 0,!0):me(void 0,ee,!0):Xe!=="none"&&at(q.selectRow,S,N)?te.hasIndex(oe)?we(te.remove(oe),void 0,!0):Xe==="single"?we(St.fromSingleSelection(oe),void 0,!0):we(void 0,oe,!0):!nu&&U!==void 0&&at(q.activateCell,S,N)?oe===y&&Yt?window.setTimeout(()=>{const bt=df(ee);Rl(bt??ee)},0):(C==null||C([ee-G,oe]),Al(U,!0)):J.current.range.height>1&&at(q.downFill,S,N)?Ew():J.current.range.width>1&&at(q.rightFill,S,N)?Tw():at(q.goToNextPage,S,N)?oe+=Math.max(1,Qt.current.height-4):at(q.goToPreviousPage,S,N)?oe-=Math.max(1,Qt.current.height-4):at(q.goToFirstCell,S,N)?(s(void 0),oe=0,ee=0):at(q.goToLastCell,S,N)?(s(void 0),oe=Number.MAX_SAFE_INTEGER,ee=Number.MAX_SAFE_INTEGER):at(q.selectToFirstCell,S,N)?(s(void 0),hi([-2,-2])):at(q.selectToLastCell,S,N)?(s(void 0),hi([2,2])):nu?(at(q.closeOverlay,S,N)&&s(void 0),at(q.acceptOverlayDown,S,N)&&(s(void 0),oe++),at(q.acceptOverlayUp,S,N)&&(s(void 0),oe--),at(q.acceptOverlayLeft,S,N)&&(s(void 0),ee--),at(q.acceptOverlayRight,S,N)&&(s(void 0),ee++)):(at(q.goDownCell,S,N)?oe+=1:at(q.goUpCell,S,N)?oe-=1:at(q.goRightCell,S,N)?ee+=1:at(q.goLeftCell,S,N)?ee-=1:at(q.goDownCellRetainSelection,S,N)?(oe+=1,re=!0):at(q.goUpCellRetainSelection,S,N)?(oe-=1,re=!0):at(q.goRightCellRetainSelection,S,N)?(ee+=1,re=!0):at(q.goLeftCellRetainSelection,S,N)?(ee-=1,re=!0):at(q.goToLastRow,S,N)?oe=y-1:at(q.goToFirstRow,S,N)?oe=Number.MIN_SAFE_INTEGER:at(q.goToLastColumn,S,N)?ee=Number.MAX_SAFE_INTEGER:at(q.goToFirstColumn,S,N)?ee=Number.MIN_SAFE_INTEGER:(Ie==="rect"||Ie==="multi-rect")&&(at(q.selectGrowDown,S,N)?hi([0,1]):at(q.selectGrowUp,S,N)?hi([0,-1]):at(q.selectGrowRight,S,N)?hi([1,0]):at(q.selectGrowLeft,S,N)?hi([-1,0]):at(q.selectToLastRow,S,N)?hi([0,2]):at(q.selectToFirstRow,S,N)?hi([0,-2]):at(q.selectToLastColumn,S,N)?hi([2,0]):at(q.selectToFirstColumn,S,N)&&hi([-2,0])),Se=N.didMatch);const Ae=zs(ee,oe,!1,re),xe=N.didMatch;return xe&&(Ae||!Se||ef)&&L(),xe},[nu,J,ui,be,Xe,Ie,G,y,zs,fr,dt,g.length,$,ef,No,me,we,Yt,df,Rl,C,Al,Ew,Tw,hi]),ru=w.useCallback(S=>{let L=!1;if(Re!==void 0&&Re({...S,cancel:()=>{L=!0}}),L||Mw(S)||J.current===void 0)return;const[N,U]=J.current.cell,K=Qt.current;if(Ge&&!S.metaKey&&!S.ctrlKey&&J.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Ou(k([N-G,Math.max(0,Math.min(U,y-1))]))){if((!Yt||U!==y)&&(K.y>U||U>K.y+K.height||K.x>N||N>K.x+K.width))return;Al(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[Ge,Re,Mw,J,k,G,y,Yt,Al]),jA=w.useCallback((S,L)=>{const N=S.location[0]-G;if(S.kind==="header"&&(ne==null||ne(N,{...S,preventDefault:L})),S.kind===Or){if(N<0)return;M==null||M(N,{...S,preventDefault:L})}if(S.kind==="cell"){const[U,K]=S.location;le==null||le([N,K],{...S,preventDefault:L}),f4(J,S.location)||zs(U,K,!1,!1)}},[J,le,M,ne,G,zs]),Qp=w.useCallback(async S=>{var q,ee,oe;if(!ui.paste)return;function L(re,Se,Ae,xe){var je,bt;const ze=typeof Ae=="object"?(Ae==null?void 0:Ae.join(` +`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function wb(t,e,n){var l;const r=pW(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function sE(t){return t!==!0}function xb(t){return typeof t=="string"?t:`${t}px`}const yW=()=>t=>t.innerWidth,vW=()=>t=>t.innerHeight,wW=zr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[yW()],"wmyidgi-1":[vW()]}}),xW=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return w.createElement(wW,{innerHeight:xb(n),innerWidth:xb(e),...i},r)},bW=2,kW=1300;function SW(t,e,n){const r=Tn.useRef(0),[i,s]=t??[0,0];Tn.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/kW);const h=r.current**1.618*f*bW;(c=e.current)==null||c.scrollBy(i*h,s*h),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function CW({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,h,d]=Tn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=OT();return[typeof m=="number"?m*p:v=>Math.ceil(m(v)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:h,overscrollY:d}}const Us={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function ut(t,e){return t===!0?e:t===!1?"":t}function bb(t){const e=vd.value;return{activateCell:ut(t.activateCell," |Enter|shift+Enter"),clear:ut(t.clear,"any+Escape"),closeOverlay:ut(t.closeOverlay,"any+Escape"),acceptOverlayDown:ut(t.acceptOverlayDown,"Enter"),acceptOverlayUp:ut(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:ut(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:ut(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:ut(t.delete,e?"Backspace|Delete":"Delete"),downFill:ut(t.downFill,"primary+_68"),scrollToSelectedCell:ut(t.scrollToSelectedCell,"primary+Enter"),goDownCell:ut(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:ut(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:ut(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:ut(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:ut(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:ut(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:ut(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:ut(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:ut(t.goToFirstCell,"primary+Home"),goToFirstColumn:ut(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:ut(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:ut(t.goToLastCell,"primary+End"),goToLastColumn:ut(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:ut(t.goToLastRow,"primary+ArrowDown"),goToNextPage:ut(t.goToNextPage,"PageDown"),goToPreviousPage:ut(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:ut(t.rightFill,"primary+_82"),search:ut(t.search,"primary+f"),selectAll:ut(t.selectAll,"primary+a"),selectColumn:ut(t.selectColumn,"ctrl+ "),selectGrowDown:ut(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:ut(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:ut(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:ut(t.selectGrowUp,"shift+ArrowUp"),selectRow:ut(t.selectRow,"shift+ "),selectToFirstCell:ut(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:ut(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:ut(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:ut(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:ut(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:ut(t.selectToLastRow,"primary+shift+ArrowDown")}}function TW(t){const e=_F(t);return Tn.useMemo(()=>{if(e===void 0)return bb(Us);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Us.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Us.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Us.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Us.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Us.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Us.selectToLastCell};return bb({...Us,...n})},[e])}const EW=w.lazy(async()=>await IT(()=>import("./data-grid-overlay-editor-DSzdLLB9.js"),[]));let MW=0;function AW(t){return PB($x($x(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return Vo((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Uf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const Wg={kind:ke.Loading,allowOverlay:!1},Kf={columns:St.empty(),rows:St.empty(),current:void 0},RW=(t,e)=>{var Iw,Dw,_w;const[n,r]=w.useState(Kf),[i,s]=w.useState(),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(),c=w.useRef(null),f=w.useRef(),h=typeof window>"u"?null:window,{imageEditorOverride:d,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:v,columns:g,rows:y,getCellContent:k,onCellClicked:b,onCellActivated:C,onFillPattern:T,onFinishedEditing:E,coercePasteValue:A,drawHeader:P,drawCell:_,editorBloom:O,onHeaderClicked:D,onColumnProposeMove:I,spanRangeBehavior:Q="default",onGroupHeaderClicked:X,onCellContextMenu:le,className:j,onHeaderContextMenu:ne,getCellsForSelection:Y,onGroupHeaderContextMenu:M,onGroupHeaderRenamed:F,onCellEdited:z,onCellsEdited:W,onSearchResultsChanged:B,searchResults:de,onSearchValueChange:ge,searchValue:ae,onKeyDown:Re,onKeyUp:nt,keybindings:Ze,editOnType:Ge=!0,onRowAppended:Ye,onColumnMoved:it,validateCell:rt,highlightRegions:Dt,rangeSelect:Ie="rect",columnSelect:be="multi",rowSelect:Xe="multi",rangeSelectionBlending:qe="exclusive",columnSelectionBlending:et="exclusive",rowSelectionBlending:Be="exclusive",onDelete:ye,onDragStart:_e,onMouseMove:H,onPaste:V,copyHeaders:Z=!1,freezeColumns:ue=0,cellActivationBehavior:se="second-click",rowSelectionMode:tt="auto",onHeaderMenuClick:pe,getGroupDetails:De,onSearchClose:Me,onItemHovered:Ve,onSelectionCleared:dt,showSearch:An,onVisibleRegionChanged:un,gridSelection:ct,onGridSelectionChange:vn,minColumnWidth:cn=50,maxColumnWidth:$r=500,maxColumnAutoWidth:Hr,provideEditor:jt,trailingRowOptions:pt,freezeTrailingRows:xt=0,allowedFillDirections:In="orthogonal",scrollOffsetX:Dn,scrollOffsetY:nn,verticalBorder:Rn,onDragOverCell:li,onDrop:vt,onColumnResize:Gt,onColumnResizeEnd:_t,onColumnResizeStart:Nt,customRenderers:_n,fillHandle:Wt,drawFocusRing:kn=!0,experimental:qt,fixedShadowX:Qc,fixedShadowY:Ds,headerIcons:us,imageWindowLoader:cs,initialSize:ml,isDraggable:Jc,onDragLeave:Zc,onRowMoved:_i,overscrollX:yl,overscrollY:vl,preventDiagonalScrolling:wl,rightElement:Oo,rightElementProps:_s,trapFocus:ef=!1,smoothScrollX:tf,smoothScrollY:Ip,scaleToRem:Dp=!1,rowHeight:xl=34,headerHeight:fs=36,groupHeaderHeight:_p=fs,theme:Np,isOutsideClick:nf,renderers:bl}=t,wn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,jr=(wn==null?void 0:wn.kind)??t.rowMarkers??"none",rf=(wn==null?void 0:wn.width)??t.rowMarkerWidth,kl=(wn==null?void 0:wn.startIndex)??t.rowMarkerStartIndex??1,Xa=(wn==null?void 0:wn.theme)??t.rowMarkerTheme,Ns=(wn==null?void 0:wn.checkboxStyle)??"square",kr=Math.max(cn,20),ai=Math.max($r,kr),Ga=Math.max(Hr??ai,kr),Ls=w.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),qa=w.useMemo(()=>Number.parseFloat(Ls.fontSize),[Ls]),{rowHeight:tr,headerHeight:Sl,groupHeaderHeight:Ya,theme:sf,overscrollX:Lp,overscrollY:of}=CW({groupHeaderHeight:_p,headerHeight:fs,overscrollX:yl,overscrollY:vl,remSize:qa,rowHeight:xl,scaleToRem:Dp,theme:Np}),ui=TW(Ze),hs=rf??(y>1e4?48:y>1e3?44:y>100?36:32),Sr=jr!=="none",G=Sr?1:0,Yt=Ye!==void 0,Po=(pt==null?void 0:pt.sticky)===!0,[Fp,lf]=w.useState(!1),Qa=An??Fp,Bp=w.useCallback(()=>{Me!==void 0?Me():lf(!1)},[Me]),J=w.useMemo(()=>ct===void 0?void 0:Uf(ct,G),[ct,G])??n,Wn=w.useRef();Wn.current===void 0&&(Wn.current=new AbortController),w.useEffect(()=>()=>Wn==null?void 0:Wn.current.abort(),[]);const[xn,Cl]=aW(Y,k,G,Wn.current,y),Ja=w.useCallback((S,L,N)=>{if(rt===void 0)return!0;const U=[S[0]-G,S[1]];return rt==null?void 0:rt(U,L,N)},[G,rt]),Fs=w.useRef(ct),fr=w.useCallback((S,L)=>{L&&(S=gW(S,xn,G,Q,Wn.current)),vn!==void 0?(Fs.current=Uf(S,-G),vn(Fs.current)):r(S)},[vn,xn,G,Q]),ci=_l(Gt,w.useCallback((S,L,N,U)=>{Gt==null||Gt(g[N-G],L,N-G,U)},[Gt,G,g])),zp=_l(_t,w.useCallback((S,L,N,U)=>{_t==null||_t(g[N-G],L,N-G,U)},[_t,G,g])),Tl=_l(Nt,w.useCallback((S,L,N,U)=>{Nt==null||Nt(g[N-G],L,N-G,U)},[Nt,G,g])),$p=_l(P,w.useCallback((S,L)=>(P==null?void 0:P({...S,columnIndex:S.columnIndex-G},L))??!1,[P,G])),Hp=_l(_,w.useCallback((S,L)=>(_==null?void 0:_({...S,col:S.col-G},L))??!1,[_,G])),$=w.useCallback(S=>{if(ye!==void 0){const L=ye(Uf(S,-G));return typeof L=="boolean"?L:Uf(L,G)}return!0},[ye,G]),[ie,we,me]=lW(J,fr,qe,et,Be,Ie),ce=w.useMemo(()=>mo(OT(),sf),[sf]),[Ee,Qe]=w.useState([0,0,0]),Je=w.useMemo(()=>{if(bl===void 0)return{};const S={};for(const L of bl)S[L.kind]=L;return S},[bl]),Ce=w.useCallback(S=>S.kind!==ke.Custom?Je[S.kind]:_n==null?void 0:_n.find(L=>L.isMatch(S)),[_n,Je]);let{sizedColumns:Et,nonGrowWidth:Ne}=R4(g,y,Cl,Ee[0]-(G===0?0:hs)-Ee[2],kr,Ga,ce,Ce,Wn.current);jr!=="none"&&(Ne+=hs);const At=w.useMemo(()=>Et.some(S=>S.group!==void 0),[Et]),st=At?Sl+Ya:Sl,gt=J.rows.length,fn=jr==="none"?void 0:gt===0?!1:gt===y?!0:void 0,ot=w.useMemo(()=>jr==="none"?Et:[{title:"",width:hs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Xa,rowMarker:Ns,rowMarkerChecked:fn},...Et],[jr,Et,hs,Xa,Ns,fn]),[rn,Wr]=w.useMemo(()=>[nn!==void 0&&typeof tr=="number"?Math.floor(nn/tr):0,nn!==void 0&&typeof tr=="number"?-(nn%tr):0],[nn,tr]),Qt=w.useRef({height:1,width:1,x:0,y:0}),Cr=w.useMemo(()=>({x:Qt.current.x,y:rn,width:Qt.current.width??1,height:Qt.current.height??1,ty:Wr}),[Wr,rn]),kt=w.useRef(!1),[hn,Tr,Ni]=DF(Cr);Qt.current=hn;const fi=(hn.height??1)>1;w.useLayoutEffect(()=>{if(nn!==void 0&&c.current!==null&&fi){if(c.current.scrollTop===nn)return;c.current.scrollTop=nn,c.current.scrollTop!==nn&&Ni(),kt.current=!0}},[nn,fi,Ni]);const El=(hn.width??1)>1;w.useLayoutEffect(()=>{if(Dn!==void 0&&c.current!==null&&El){if(c.current.scrollLeft===Dn)return;c.current.scrollLeft=Dn,c.current.scrollLeft!==Dn&&Ni(),kt.current=!0}},[Dn,El,Ni]);const Io=hn.x+G,af=hn.y,hr=w.useRef(null),nr=w.useCallback(S=>{var L;S===!0?(L=hr.current)==null||L.focus():window.requestAnimationFrame(()=>{var N;(N=hr.current)==null||N.focus()})},[]),Vn=Yt?y+1:y,Vr=w.useCallback(S=>{const L=G===0?S:S.map(U=>({...U,location:[U.location[0]-G,U.location[1]]})),N=W==null?void 0:W(L);if(N!==!0)for(const U of L)z==null||z(U.location,U.value);return N},[z,W,G]),[Do,jp]=w.useState(),uf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,Ml=kn?(Iw=J.current)==null?void 0:Iw.cell:void 0,cf=Ml==null?void 0:Ml[0],ff=Ml==null?void 0:Ml[1],RA=w.useMemo(()=>{if((Dt===void 0||Dt.length===0)&&(uf??cf??ff??Do)===void 0)return;const S=[];if(Dt!==void 0)for(const L of Dt){const N=ot.length-L.range.x-G;N>0&&S.push({color:L.color,range:{...L.range,x:L.range.x+G,width:Math.min(N,L.range.width)},style:L.style})}return Do!==void 0&&S.push({color:sl(ce.accentColor,0),range:Do,style:"dashed"}),uf!==void 0&&S.push({color:sl(ce.accentColor,.5),range:uf,style:"solid-outline"}),cf!==void 0&&ff!==void 0&&S.push({color:ce.accentColor,range:{x:cf,y:ff,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Do,uf,cf,ff,Dt,ot.length,ce.accentColor,G]),ww=w.useRef(ot);ww.current=ot;const Er=w.useCallback(([S,L],N=!1)=>{var te,q,ee,oe,re,Se,Ae;const U=Yt&&L===Vn-1;if(S===0&&Sr)return U?Wg:{kind:Yr.Marker,allowOverlay:!1,checkboxStyle:Ns,checked:(J==null?void 0:J.rows.hasIndex(L))===!0,markerKind:jr==="clickable-number"?"number":jr,row:kl+L,drawHandle:_i!==void 0,cursor:jr==="clickable-number"?"pointer":void 0};if(U){const ze=S===G?(pt==null?void 0:pt.hint)??"":"",je=ww.current[S];if(((te=je==null?void 0:je.trailingRowOptions)==null?void 0:te.disabled)===!0)return Wg;{const bt=((q=je==null?void 0:je.trailingRowOptions)==null?void 0:q.hint)??ze,Ue=((ee=je==null?void 0:je.trailingRowOptions)==null?void 0:ee.addIcon)??(pt==null?void 0:pt.addIcon);return{kind:Yr.NewRow,hint:bt,allowOverlay:!1,icon:Ue}}}else{const xe=S-G;if(N||(qt==null?void 0:qt.strict)===!0){const je=Qt.current,bt=je.x>xe||xe>je.x+je.width||je.y>L||L>je.y+je.height||L>=Vp.current,Ue=xe===((re=(oe=je.extras)==null?void 0:oe.selected)==null?void 0:re[0])&&L===((Se=je.extras)==null?void 0:Se.selected[1]);let Fe=!1;if(((Ae=je.extras)==null?void 0:Ae.freezeRegions)!==void 0){for(const zt of je.extras.freezeRegions)if(yp(zt,xe,L)){Fe=!0;break}}if(bt&&!Ue&&!Fe)return Wg}let ze=k([xe,L]);return G!==0&&ze.span!==void 0&&(ze={...ze,span:[ze.span[0]+G,ze.span[1]+G]}),ze}},[Yt,Vn,Sr,Ns,J==null?void 0:J.rows,jr,kl,_i,G,pt==null?void 0:pt.hint,pt==null?void 0:pt.addIcon,qt==null?void 0:qt.strict,k]),Wp=w.useCallback(S=>{let L=(De==null?void 0:De(S))??{name:S};return F!==void 0&&S!==""&&(L={icon:L.icon,name:L.name,overrideTheme:L.overrideTheme,actions:[...L.actions??[],{title:"Rename",icon:"renameIcon",onClick:N=>Kp({group:L.name,bounds:N.bounds})}]}),L},[De,F]),hf=w.useCallback(S=>{var ee;const[L,N]=S.cell,U=ot[L],K=(U==null?void 0:U.group)!==void 0?(ee=Wp(U.group))==null?void 0:ee.overrideTheme:void 0,te=U==null?void 0:U.themeOverride,q=p==null?void 0:p(N);s({...S,theme:mo(ce,K,te,q,S.content.themeOverride)})},[p,ot,Wp,ce]),Al=w.useCallback((S,L,N)=>{var q;if(J.current===void 0)return;const[U,K]=J.current.cell,te=Er([U,K]);if(te.kind!==ke.Boolean&&te.allowOverlay){let ee=te;if(N!==void 0)switch(ee.kind){case ke.Number:{const oe=pD(()=>N==="-"?-0:Number.parseFloat(N),0);ee={...ee,data:Number.isNaN(oe)?0:oe};break}case ke.Text:case ke.Markdown:case ke.Uri:ee={...ee,data:N};break}hf({target:S,content:ee,initialValue:N,cell:[U,K],highlight:N===void 0,forceEditMode:N!==void 0})}else te.kind===ke.Boolean&&L&&te.readonly!==!0&&(Vr([{location:J.current.cell,value:{...te,data:sE(te.data)}}]),(q=hr.current)==null||q.damage([{cell:J.current.cell}]))},[Er,J,Vr,hf]),xw=w.useCallback((S,L)=>{var K;const N=(K=hr.current)==null?void 0:K.getBounds(S,L);if(N===void 0||c.current===null)return;const U=Er([S,L]);U.allowOverlay&&hf({target:N,content:U,initialValue:void 0,highlight:!0,cell:[S,L],forceEditMode:!0})},[Er,hf]),dn=w.useCallback((S,L,N="both",U=0,K=0,te=void 0)=>{if(c.current!==null){const q=hr.current,ee=l.current,oe=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,re=typeof L!="number"?L.unit==="cell"?L.amount:void 0:L,Se=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Ae=typeof L!="number"&&L.unit==="px"?L.amount:void 0;if(q!==null&&ee!==null){let xe={x:0,y:0,width:0,height:0},ze=0,je=0;if((oe!==void 0||re!==void 0)&&(xe=q.getBounds((oe??0)+G,re??0)??xe,xe.width===0||xe.height===0))return;const bt=ee.getBoundingClientRect(),Ue=bt.width/ee.offsetWidth;if(Se!==void 0&&(xe={...xe,x:Se-bt.left-c.current.scrollLeft,width:1}),Ae!==void 0&&(xe={...xe,y:Ae+bt.top-c.current.scrollTop,height:1}),xe!==void 0){const Fe={x:xe.x-U,y:xe.y-K,width:xe.width+2*U,height:xe.height+2*K};let zt=0;for(let Jp=0;Jp0&&(Un=gl(Vn,pn,tr));let di=zt*Ue+bt.left+G*hs*Ue,Fi=bt.right,pi=bt.top+st*Ue,Bi=bt.bottom-Un*Ue;const vf=xe.width+U*2;switch(te==null?void 0:te.hAlign){case"start":Fi=di+vf;break;case"end":di=Fi-vf;break;case"center":di=Math.floor((di+Fi)/2)-vf/2,Fi=di+vf;break}const wf=xe.height+K*2;switch(te==null?void 0:te.vAlign){case"start":Bi=pi+wf;break;case"end":pi=Bi-wf;break;case"center":pi=Math.floor((pi+Bi)/2)-wf/2,Bi=pi+wf;break}di>Fe.x?ze=Fe.x-di:FiFe.y?je=Fe.y-pi:Bi=Vn-pn)&&(je=0),(ze!==0||je!==0)&&(Ue!==1&&(ze/=Ue,je/=Ue),c.current.scrollTo(ze+c.current.scrollLeft,je+c.current.scrollTop))}}}},[G,xt,hs,st,ue,Et,Vn,Po,tr]),bw=w.useRef(xw),kw=w.useRef(k),Vp=w.useRef(y);bw.current=xw,kw.current=k,Vp.current=y;const Rl=w.useCallback(async(S,L=!0)=>{var oe;const N=ot[S];if(((oe=N==null?void 0:N.trailingRowOptions)==null?void 0:oe.disabled)===!0)return;const U=Ye==null?void 0:Ye();let K,te=!0;U!==void 0&&(K=await U,K==="top"&&(te=!1),typeof K=="number"&&(te=!1));let q=0;const ee=()=>{if(Vp.current<=y){q<500&&window.setTimeout(ee,q),q=50+q*2;return}const re=typeof K=="number"?K:te?y:0;yf.current(S-G,re),ie({cell:[S,re],range:{x:S,y:re,width:1,height:1}},!1,!1,"edit");const Se=kw.current([S-G,re]);Se.allowOverlay&&Ou(Se)&&Se.readonly!==!0&&L&&window.setTimeout(()=>{bw.current(S,re)},0)};ee()},[ot,Ye,G,y,ie]),df=w.useCallback(S=>{var N,U;const L=((U=(N=Et[S])==null?void 0:N.trailingRowOptions)==null?void 0:U.targetColumn)??(pt==null?void 0:pt.targetColumn);if(typeof L=="number")return L+(Sr?1:0);if(typeof L=="object"){const K=g.indexOf(L);if(K>=0)return K+(Sr?1:0)}},[Et,g,Sr,pt==null?void 0:pt.targetColumn]),Bs=w.useRef(),Ol=w.useRef(),Za=w.useCallback((S,L)=>{var K;const[N,U]=L;return mo(ce,(K=ot[N])==null?void 0:K.themeOverride,p==null?void 0:p(U),S.themeOverride)},[p,ot,ce]),eu=w.useCallback(S=>{var Se,Ae,xe;const L=vd.value?S.metaKey:S.ctrlKey,N=L&&Xe==="multi",U=L&&be==="multi",[K,te]=S.location,q=J.columns,ee=J.rows,[oe,re]=((Se=J.current)==null?void 0:Se.cell)??[];if(S.kind==="cell"){if(Ol.current=void 0,_o.current=[K,te],K===0&&Sr){if(Yt===!0&&te===y||jr==="number"||Xe==="none")return;const ze=Er(S.location);if(ze.kind!==Yr.Marker)return;if(_i!==void 0){const Ue=Ce(ze);Pr((Ue==null?void 0:Ue.kind)===Yr.Marker);const Fe=(Ae=Ue==null?void 0:Ue.onClick)==null?void 0:Ae.call(Ue,{...S,cell:ze,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:Za(ze,S.location),preventDefault:()=>{}});if(Fe===void 0||Fe.checked===ze.checked)return}s(void 0),nr();const je=ee.hasIndex(te),bt=Bs.current;if(Xe==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&bt!==void 0&&ee.hasIndex(bt)){const Ue=[Math.min(bt,te),Math.max(bt,te)+1];N||tt==="multi"?we(void 0,Ue,!0):we(St.fromSingleSelection(Ue),void 0,N)}else N||S.isTouch||tt==="multi"?je?we(ee.remove(te),void 0,!0):(we(void 0,te,!0),Bs.current=te):je&&ee.length===1?we(St.empty(),void 0,L):(we(St.fromSingleSelection(te),void 0,L),Bs.current=te)}else if(K>=G&&Yt&&te===y){const ze=df(K);Rl(ze??K)}else if(oe!==K||re!==te){const ze=Er(S.location),je=Ce(ze);if((je==null?void 0:je.onSelect)!==void 0){let Fe=!1;if(je.onSelect({...S,cell:ze,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>Fe=!0,theme:Za(ze,S.location)}),Fe)return}const bt=Po&&te===y,Ue=Po&&J!==void 0&&((xe=J.current)==null?void 0:xe.cell[1])===y;if((S.shiftKey||S.isLongTouch===!0)&&oe!==void 0&&re!==void 0&&J.current!==void 0&&!Ue){if(bt)return;const Fe=Math.min(K,oe),zt=Math.max(K,oe),Un=Math.min(te,re),pn=Math.max(te,re);ie({...J.current,range:{x:Fe,y:Un,width:zt-Fe+1,height:pn-Un+1}},!0,L,"click"),Bs.current=void 0,nr()}else ie({cell:[K,te],range:{x:K,y:te,width:1,height:1}},!0,L,"click"),Bs.current=void 0,s(void 0),nr()}}else if(S.kind==="header")if(_o.current=[K,te],s(void 0),Sr&&K===0)Bs.current=void 0,Ol.current=void 0,Xe==="multi"&&(ee.length!==y?we(St.fromSingleSelection([0,y]),void 0,L):we(St.empty(),void 0,L),nr());else{const ze=Ol.current;if(be==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&ze!==void 0&&q.hasIndex(ze)){const je=[Math.min(ze,K),Math.max(ze,K)+1];U?me(void 0,je,L):me(St.fromSingleSelection(je),void 0,L)}else U?(q.hasIndex(K)?me(q.remove(K),void 0,L):me(void 0,K,L),Ol.current=K):be!=="none"&&(me(St.fromSingleSelection(K),void 0,L),Ol.current=K);Bs.current=void 0,nr()}else S.kind===Or?_o.current=[K,te]:S.kind===wd&&!S.isMaybeScrollbar&&(fr(Kf,!1),s(void 0),nr(),dt==null||dt(),Bs.current=void 0,Ol.current=void 0)},[Rl,be,nr,Ce,df,Er,J,Sr,Po,dt,_i,G,jr,Xe,tt,y,ie,fr,me,we,Yt,Za]),tu=w.useRef(!1),_o=w.useRef(),Sw=w.useRef(hn),Ur=w.useRef(),OA=w.useCallback(S=>{if(Pl.current=!1,Sw.current=Qt.current,S.button!==0&&S.button!==1){Ur.current=void 0;return}const L=performance.now();Ur.current={button:S.button,time:L,location:S.location},(S==null?void 0:S.kind)==="header"&&(tu.current=!0);const N=S.kind==="cell"&&S.isFillHandle;!N&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:J,fillHandle:N}),_o.current=void 0,!S.isTouch&&S.button===0&&!N?eu(S):!S.isTouch&&S.button===1&&(_o.current=S.location))},[J,eu]),[Up,Kp]=w.useState(),Cw=w.useCallback(S=>{if(S.kind!==Or||be!=="multi")return;const L=vd.value?S.metaKey:S.ctrlKey,[N]=S.location,U=J.columns;if(N=G&&kc(K.group,ot[ee].group);ee--)te--;for(let ee=N+1;ee{if(xn!==void 0&&ci!==void 0){const L=Qt.current.y,N=Qt.current.height;let U=xn({x:S,y:L,width:1,height:Math.min(N,y-L)},Wn.current.signal);typeof U!="object"&&(U=await U());const K=Et[S-G],q=document.createElement("canvas").getContext("2d",{alpha:!1});if(q!==null){q.font=ce.baseFontFull;const ee=PT(q,ce,K,0,U,kr,ai,!1,Ce);ci==null||ci(K,ee.width,S,ee.width)}}},[Et,xn,ai,ce,kr,ci,G,y,Ce]),[PA,Xp]=w.useState(),Il=w.useCallback(async(S,L)=>{var ee,oe;const N=(ee=S.current)==null?void 0:ee.range;if(N===void 0||xn===void 0||L.current===void 0)return;const U=L.current.range;if(T!==void 0){let re=!1;if(T({fillDestination:{...U,x:U.x-G},patternSource:{...N,x:N.x-G},preventDefault:()=>re=!0}),re)return}let K=xn(N,Wn.current.signal);typeof K!="object"&&(K=await K());const te=K,q=[];for(let re=0;re({cell:re.location})))},[xn,Vr,T,G]),Tw=w.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,width:1}}};Il(S,J)},[Il,J]),Ew=w.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const S={...J,current:{...J.current,range:{...J.current.range,height:1}}};Il(S,J)},[Il,J]),IA=w.useCallback((S,L)=>{var Se,Ae;const N=a;if(u(void 0),jp(void 0),Xp(void 0),tu.current=!1,L)return;if((N==null?void 0:N.fillHandle)===!0&&J.current!==void 0&&((Se=N.previousSelection)==null?void 0:Se.current)!==void 0){if(Do===void 0)return;const xe={...J,current:{...J.current,range:HT(N.previousSelection.current.range,Do)}};Il(N.previousSelection,xe),fr(xe,!0);return}const[U,K]=S.location,[te,q]=_o.current??[],ee=()=>{Pl.current=!0},oe=xe=>{var je,bt,Ue;const ze=xe.isTouch||te===U&&q===K;if(ze&&(b==null||b([U-G,K],{...xe,preventDefault:ee})),xe.button===1)return!Pl.current;if(!Pl.current){const Fe=Er(S.location),zt=Ce(Fe);if(zt!==void 0&&zt.onClick!==void 0&&ze){const pn=zt.onClick({...xe,cell:Fe,posX:xe.localEventX,posY:xe.localEventY,bounds:xe.bounds,theme:Za(Fe,S.location),preventDefault:ee});pn!==void 0&&!Jl(pn)&&Fl(pn)&&(Vr([{location:xe.location,value:pn}]),(je=hr.current)==null||je.damage([{cell:xe.location}]))}if(Pl.current||J.current===void 0)return!1;let Un=!1;switch(Fe.activationBehaviorOverride??se){case"double-click":case"second-click":{if(((Ue=(bt=N==null?void 0:N.previousSelection)==null?void 0:bt.current)==null?void 0:Ue.cell)===void 0)break;const[pn,di]=J.current.cell,[Fi,pi]=N.previousSelection.current.cell;Un=U===pn&&U===Fi&&K===di&&K===pi&&(xe.isDoubleClick===!0||se==="second-click");break}case"single-click":{Un=!0;break}}if(Un)return C==null||C([U-G,K]),Al(xe.bounds,!1),!0}return!1},re=S.location[0]-G;if(S.isTouch){const xe=Qt.current,ze=Sw.current;if(xe.x!==ze.x||xe.y!==ze.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&Xu((Ae=J.current)==null?void 0:Ae.cell,S.location)){le==null||le([re,S.location[1]],{...S,preventDefault:ee});return}else if(S.kind==="header"&&J.columns.hasIndex(U)){ne==null||ne(re,{...S,preventDefault:ee});return}else if(S.kind===Or){if(re<0)return;M==null||M(re,{...S,preventDefault:ee});return}}S.kind==="cell"?oe(S)||eu(S):S.kind===Or?X==null||X(re,{...S,preventDefault:ee}):(S.kind===Xs&&(D==null||D(re,{...S,preventDefault:ee})),eu(S));return}if(S.kind==="header"){if(re<0)return;S.isEdge?S.isDoubleClick===!0&&pf(U):S.button===0&&U===te&&K===q&&(D==null||D(re,{...S,preventDefault:ee}))}if(S.kind===Or){if(re<0)return;S.button===0&&U===te&&K===q&&(X==null||X(re,{...S,preventDefault:ee}),Pl.current||Cw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&oe(S),_o.current=void 0},[a,J,G,Do,Il,fr,b,Er,Ce,se,Za,Vr,C,Al,le,ne,M,eu,X,D,pf,Cw]),DA=w.useCallback(S=>{const L={...S,location:[S.location[0]-G,S.location[1]]};H==null||H(L),a!==void 0&&S.buttons===0&&(u(void 0),jp(void 0),Xp(void 0),tu.current=!1),Xp(N=>{var U;return tu.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===(N==null?void 0:N[0])&&S.scrollEdge[1]===N[1]?N:a===void 0||(((U=Ur.current)==null?void 0:U.location[0])??0){pe==null||pe(S-G,L)},[pe,G]),Li=(Dw=J==null?void 0:J.current)==null?void 0:Dw.cell,NA=w.useCallback((S,L,N,U,K,te)=>{kt.current=!1;let q=Li;q!==void 0&&(q=[q[0]-G,q[1]]);const ee=ue===0?void 0:{x:0,y:S.y,width:ue,height:S.height},oe=[];ee!==void 0&&oe.push(ee),xt>0&&(oe.push({x:S.x-G,y:y-xt,width:S.width,height:xt}),ue>0&&oe.push({x:0,y:y-xt,width:ue,height:xt}));const re={x:S.x-G,y:S.y,width:S.width,height:Yt&&S.y+S.height>=y?S.height-1:S.height,tx:K,ty:te,extras:{selected:q,freezeRegion:ee,freezeRegions:oe}};Qt.current=re,Tr(re),Qe([L,N,U]),un==null||un(re,re.tx,re.ty,re.extras)},[Li,G,Yt,y,ue,xt,Tr,un]),LA=_l(it,w.useCallback((S,L)=>{it==null||it(S-G,L-G),be!=="none"&&me(St.fromSingleSelection(L),void 0,!0)},[be,it,G,me])),Gp=w.useRef(!1),FA=w.useCallback(S=>{if(S.location[0]===0&&G>0){S.preventDefault();return}_e==null||_e({...S,location:[S.location[0]-G,S.location[1]]}),S.defaultPrevented()||(Gp.current=!0),u(void 0)},[_e,G]),BA=w.useCallback(()=>{Gp.current=!1},[]),qp=w.useRef(),Yp=w.useCallback(S=>{var L,N,U;if(!rE(S,qp.current)&&(qp.current=S,!(((L=Ur==null?void 0:Ur.current)==null?void 0:L.button)!==void 0&&Ur.current.button>=1))){if(S.buttons!==0&&a!==void 0&&((N=Ur.current)==null?void 0:N.location[0])===0&&S.location[0]===0&&G===1&&Xe==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(Ur.current.location[1])&&J.rows.hasIndex(Ur.current.location[1])){const K=Math.min(Ur.current.location[1],S.location[1]),te=Math.max(Ur.current.location[1],S.location[1])+1;we(St.fromSingleSelection([K,te]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&J.current!==void 0&&!Gp.current&&!tu.current&&(Ie==="rect"||Ie==="multi-rect")){const[K,te]=J.current.cell;let[q,ee]=S.location;if(ee<0&&(ee=Qt.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const oe=a.previousSelection.current.range;ee=Math.min(ee,Yt?y-1:y);const re=gz(oe,q,ee,In);jp(re)}else{if(Yt&&te===y)return;if(Yt&&ee===y)if(S.kind===wd)ee--;else return;q=Math.max(q,G);const Se=q-K,Ae=ee-te,xe={x:Se>=0?K:q,y:Ae>=0?te:ee,width:Math.abs(Se)+1,height:Math.abs(Ae)+1};ie({...J.current,range:xe},!0,!1,"drag")}}Ve==null||Ve({...S,location:[S.location[0]-G,S.location[1]]})}},[In,a,G,Xe,J,Ie,Ve,we,Yt,y,ie]),zA=w.useCallback(()=>{var q,ee;const S=qp.current;if(S===void 0)return;const[L,N]=S.scrollEdge;let[U,K]=S.location;const te=Qt.current;L===-1?U=((ee=(q=te.extras)==null?void 0:q.freezeRegion)==null?void 0:ee.x)??te.x:L===1&&(U=te.x+te.width),N===-1?K=Math.max(0,te.y):N===1&&(K=Math.min(y-1,te.y+te.height)),U=bi(U,0,ot.length-1),K=bi(K,0,y-1),Yp({...S,location:[U,K]})},[ot.length,Yp,y]);SW(PA,c,zA);const hi=w.useCallback(S=>{if(J.current===void 0)return;const[L,N]=S,[U,K]=J.current.cell,te=J.current.range;let q=te.x,ee=te.x+te.width,oe=te.y,re=te.y+te.height;if(N!==0)switch(N){case 2:{re=y,oe=K,dn(0,re,"vertical");break}case-2:{oe=0,re=K+1,dn(0,oe,"vertical");break}case 1:{oeK+1?(re--,dn(0,re,"vertical")):(oe=Math.max(0,oe-1),dn(0,oe,"vertical"));break}default:bc()}if(L!==0)if(L===2)ee=ot.length,q=U,dn(ee-1-G,0,"horizontal");else if(L===-2)q=G,ee=U+1,dn(q-G,0,"horizontal");else{let Se=[];if(xn!==void 0){const Ae=xn({x:q,y:oe,width:ee-q-G,height:re-oe},Wn.current.signal);typeof Ae=="object"&&(Se=AW(Ae))}if(L===1){let Ae=!1;if(q0){const xe=Vo(q+1,U+1).find(ze=>!Se.includes(ze-G));xe!==void 0&&(q=xe,Ae=!0)}else q++,Ae=!0;Ae&&dn(q,0,"horizontal")}Ae||(ee=Math.min(ot.length,ee+1),dn(ee-1-G,0,"horizontal"))}else if(L===-1){let Ae=!1;if(ee>U+1){if(Se.length>0){const xe=Vo(ee-1,U,-1).find(ze=>!Se.includes(ze-G));xe!==void 0&&(ee=xe,Ae=!0)}else ee--,Ae=!0;Ae&&dn(ee-G,0,"horizontal")}Ae||(q=Math.max(G,q-1),dn(q-G,0,"horizontal"))}else bc()}ie({cell:J.current.cell,range:{x:q,y:oe,width:ee-q,height:re-oe}},!0,!1,"keyboard-select")},[xn,J,ot.length,G,y,dn,ie]),zs=w.useCallback((S,L,N,U)=>{const K=Vn-(N?0:1);if(S=bi(S,G,Et.length-1+G),L=bi(L,0,K),S===(Li==null?void 0:Li[0])&&L===(Li==null?void 0:Li[1]))return!1;if(U&&J.current!==void 0){const te=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&te.push(J.current.range),fr({...J,current:{cell:[S,L],range:{x:S,y:L,width:1,height:1},rangeStack:te}},!0)}else ie({cell:[S,L],range:{x:S,y:L,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===L&&(f.current=void 0),dn(S-G,L),!0},[Vn,G,Et.length,Li,J,dn,fr,ie]),$A=w.useCallback((S,L)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&Fl(S)&&(Vr([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var K;(K=hr.current)==null||K.damage([{cell:i.cell}])})),nr(!0),s(void 0);const[N,U]=L;if(J.current!==void 0&&(N!==0||U!==0)){const K=J.current.cell[1]===Vn-1&&S!==void 0;zs(bi(J.current.cell[0]+N,0,ot.length-1),bi(J.current.cell[1]+U,0,Vn-1),K,!1)}E==null||E(S,L)},[i==null?void 0:i.cell,nr,J,E,Vr,Vn,zs,ot.length]),HA=w.useMemo(()=>`gdg-overlay-${MW++}`,[]),No=w.useCallback(S=>{var N,U,K,te;nr();const L=[];for(let q=S.x;q({cell:q.location})))},[nr,k,Ce,Vr,G]),nu=i!==void 0,Mw=w.useCallback(S=>{var ze,je;const L=()=>{S.stopPropagation(),S.preventDefault()},N={didMatch:!1},{bounds:U}=S,K=J.columns,te=J.rows,q=ui;if(!nu&&at(q.clear,S,N))fr(Kf,!1),dt==null||dt();else if(!nu&&at(q.selectAll,S,N))fr({columns:St.empty(),rows:St.empty(),current:{cell:((ze=J.current)==null?void 0:ze.cell)??[G,0],range:{x:G,y:0,width:g.length,height:y},rangeStack:[]}},!1);else if(at(q.search,S,N))(je=o==null?void 0:o.current)==null||je.focus({preventScroll:!0}),lf(!0);else if(at(q.delete,S,N)){const bt=($==null?void 0:$(J))??!0;if(bt!==!1){const Ue=bt===!0?J:bt;if(Ue.current!==void 0){No(Ue.current.range);for(const Fe of Ue.current.rangeStack)No(Fe)}for(const Fe of Ue.rows)No({x:G,y:Fe,width:g.length,height:1});for(const Fe of Ue.columns)No({x:Fe,y:0,width:1,height:y})}}if(N.didMatch)return L(),!0;if(J.current===void 0)return!1;let[ee,oe]=J.current.cell,re=!1,Se=!1;at(q.scrollToSelectedCell,S,N)?yf.current(ee-G,oe):be!=="none"&&at(q.selectColumn,S,N)?K.hasIndex(ee)?me(K.remove(ee),void 0,!0):be==="single"?me(St.fromSingleSelection(ee),void 0,!0):me(void 0,ee,!0):Xe!=="none"&&at(q.selectRow,S,N)?te.hasIndex(oe)?we(te.remove(oe),void 0,!0):Xe==="single"?we(St.fromSingleSelection(oe),void 0,!0):we(void 0,oe,!0):!nu&&U!==void 0&&at(q.activateCell,S,N)?oe===y&&Yt?window.setTimeout(()=>{const bt=df(ee);Rl(bt??ee)},0):(C==null||C([ee-G,oe]),Al(U,!0)):J.current.range.height>1&&at(q.downFill,S,N)?Ew():J.current.range.width>1&&at(q.rightFill,S,N)?Tw():at(q.goToNextPage,S,N)?oe+=Math.max(1,Qt.current.height-4):at(q.goToPreviousPage,S,N)?oe-=Math.max(1,Qt.current.height-4):at(q.goToFirstCell,S,N)?(s(void 0),oe=0,ee=0):at(q.goToLastCell,S,N)?(s(void 0),oe=Number.MAX_SAFE_INTEGER,ee=Number.MAX_SAFE_INTEGER):at(q.selectToFirstCell,S,N)?(s(void 0),hi([-2,-2])):at(q.selectToLastCell,S,N)?(s(void 0),hi([2,2])):nu?(at(q.closeOverlay,S,N)&&s(void 0),at(q.acceptOverlayDown,S,N)&&(s(void 0),oe++),at(q.acceptOverlayUp,S,N)&&(s(void 0),oe--),at(q.acceptOverlayLeft,S,N)&&(s(void 0),ee--),at(q.acceptOverlayRight,S,N)&&(s(void 0),ee++)):(at(q.goDownCell,S,N)?oe+=1:at(q.goUpCell,S,N)?oe-=1:at(q.goRightCell,S,N)?ee+=1:at(q.goLeftCell,S,N)?ee-=1:at(q.goDownCellRetainSelection,S,N)?(oe+=1,re=!0):at(q.goUpCellRetainSelection,S,N)?(oe-=1,re=!0):at(q.goRightCellRetainSelection,S,N)?(ee+=1,re=!0):at(q.goLeftCellRetainSelection,S,N)?(ee-=1,re=!0):at(q.goToLastRow,S,N)?oe=y-1:at(q.goToFirstRow,S,N)?oe=Number.MIN_SAFE_INTEGER:at(q.goToLastColumn,S,N)?ee=Number.MAX_SAFE_INTEGER:at(q.goToFirstColumn,S,N)?ee=Number.MIN_SAFE_INTEGER:(Ie==="rect"||Ie==="multi-rect")&&(at(q.selectGrowDown,S,N)?hi([0,1]):at(q.selectGrowUp,S,N)?hi([0,-1]):at(q.selectGrowRight,S,N)?hi([1,0]):at(q.selectGrowLeft,S,N)?hi([-1,0]):at(q.selectToLastRow,S,N)?hi([0,2]):at(q.selectToFirstRow,S,N)?hi([0,-2]):at(q.selectToLastColumn,S,N)?hi([2,0]):at(q.selectToFirstColumn,S,N)&&hi([-2,0])),Se=N.didMatch);const Ae=zs(ee,oe,!1,re),xe=N.didMatch;return xe&&(Ae||!Se||ef)&&L(),xe},[nu,J,ui,be,Xe,Ie,G,y,zs,fr,dt,g.length,$,ef,No,me,we,Yt,df,Rl,C,Al,Ew,Tw,hi]),ru=w.useCallback(S=>{let L=!1;if(Re!==void 0&&Re({...S,cancel:()=>{L=!0}}),L||Mw(S)||J.current===void 0)return;const[N,U]=J.current.cell,K=Qt.current;if(Ge&&!S.metaKey&&!S.ctrlKey&&J.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Ou(k([N-G,Math.max(0,Math.min(U,y-1))]))){if((!Yt||U!==y)&&(K.y>U||U>K.y+K.height||K.x>N||N>K.x+K.width))return;Al(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[Ge,Re,Mw,J,k,G,y,Yt,Al]),jA=w.useCallback((S,L)=>{const N=S.location[0]-G;if(S.kind==="header"&&(ne==null||ne(N,{...S,preventDefault:L})),S.kind===Or){if(N<0)return;M==null||M(N,{...S,preventDefault:L})}if(S.kind==="cell"){const[U,K]=S.location;le==null||le([N,K],{...S,preventDefault:L}),f4(J,S.location)||zs(U,K,!1,!1)}},[J,le,M,ne,G,zs]),Qp=w.useCallback(async S=>{var q,ee,oe;if(!ui.paste)return;function L(re,Se,Ae,xe){var je,bt;const ze=typeof Ae=="object"?(Ae==null?void 0:Ae.join(` `))??"":(Ae==null?void 0:Ae.toString())??"";if(!Jl(re)&&Ou(re)&&re.readonly!==!0){const Ue=A==null?void 0:A(ze,re);if(Ue!==void 0&&Fl(Ue))return{location:Se,value:Ue};const Fe=Ce(re);if(Fe===void 0)return;if(Fe.kind===ke.Custom){Pr(re.kind===ke.Custom);const zt=(je=Fe.onPaste)==null?void 0:je.call(Fe,ze,re.data);return zt===void 0?void 0:{location:Se,value:{...re,data:zt}}}else{const zt=(bt=Fe.onPaste)==null?void 0:bt.call(Fe,ze,re,{formatted:xe,formattedString:typeof xe=="string"?xe:xe==null?void 0:xe.join(` `),rawValue:Ae});return zt===void 0?void 0:(Pr(zt.kind===re.kind),{location:Se,value:zt})}}}const N=J.columns,U=J.rows,K=((q=c.current)==null?void 0:q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0;let te;if(J.current!==void 0?te=[J.current.range.x,J.current.range.y]:N.length===1?te=[N.first()??0,0]:U.length===1&&(te=[G,U.first()??0]),K&&te!==void 0){let re,Se;const Ae="text/plain",xe="text/html";if(navigator.clipboard.read!==void 0){const Ue=await navigator.clipboard.read();for(const Fe of Ue){if(Fe.types.includes(xe)){const Un=await(await Fe.getType(xe)).text(),pn=yb(Un);if(pn!==void 0){re=pn;break}}Fe.types.includes(Ae)&&(Se=await(await Fe.getType(Ae)).text())}}else if(navigator.clipboard.readText!==void 0)Se=await navigator.clipboard.readText();else if(S!==void 0&&(S==null?void 0:S.clipboardData)!==null){if(S.clipboardData.types.includes(xe)){const Ue=S.clipboardData.getData(xe);re=yb(Ue)}re===void 0&&S.clipboardData.types.includes(Ae)&&(Se=S.clipboardData.getData(Ae))}else return;const[ze,je]=te,bt=[];do{if(V===void 0){const Ue=Er(te),Fe=Se??(re==null?void 0:re.map(Un=>Un.map(pn=>pn.rawValue).join(" ")).join(" "))??"",zt=L(Ue,te,Fe,void 0);zt!==void 0&&bt.push(zt);break}if(re===void 0){if(Se===void 0)return;re=mW(Se)}if(V===!1||typeof V=="function"&&(V==null?void 0:V([te[0]-G,te[1]],re.map(Ue=>Ue.map(Fe=>{var zt;return((zt=Fe.rawValue)==null?void 0:zt.toString())??""}))))!==!0)return;for(const[Ue,Fe]of re.entries()){if(Ue+je>=y)break;for(const[zt,Un]of Fe.entries()){const pn=[zt+ze,Ue+je],[di,Fi]=pn;if(di>=ot.length||Fi>=Vn)continue;const pi=Er(pn),Bi=L(pi,pn,Un.rawValue,Un.formatted);Bi!==void 0&&bt.push(Bi)}}}while(!1);Vr(bt),(oe=hr.current)==null||oe.damage(bt.map(Ue=>({cell:Ue.location})))}},[A,Ce,Er,J,ui.paste,ot.length,Vr,Vn,V,G,y]);Fn("paste",Qp,h,!1,!0);const iu=w.useCallback(async(S,L)=>{var q,ee;if(!ui.copy)return;const N=L===!0||((q=c.current)==null?void 0:q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0,U=J.columns,K=J.rows,te=(oe,re)=>{if(!Z)wb(oe,re,S);else{const Se=re.map(Ae=>({kind:ke.Text,data:g[Ae].title,displayData:g[Ae].title,allowOverlay:!1}));wb([Se,...oe],re,S)}};if(N&&xn!==void 0){if(J.current!==void 0){let oe=xn(J.current.range,Wn.current.signal);typeof oe!="object"&&(oe=await oe()),te(oe,Vo(J.current.range.x-G,J.current.range.x+J.current.range.width-G))}else if(K!==void 0&&K.length>0){const re=[...K].map(Se=>{const Ae=xn({x:G,y:Se,width:g.length,height:1},Wn.current.signal);return typeof Ae=="object"?Ae[0]:Ae().then(xe=>xe[0])});if(re.some(Se=>Se instanceof Promise)){const Se=await Promise.all(re);te(Se,Vo(g.length))}else te(re,Vo(g.length))}else if(U.length>0){const oe=[],re=[];for(const Se of U){let Ae=xn({x:Se,y:0,width:1,height:y},Wn.current.signal);typeof Ae!="object"&&(Ae=await Ae()),oe.push(Ae),re.push(Se-G)}if(oe.length===1)te(oe[0],re);else{const Se=oe.reduce((Ae,xe)=>Ae.map((ze,je)=>[...ze,...xe[je]]));te(Se,re)}}}},[g,xn,J,ui.copy,G,y,Z]);Fn("copy",iu,h,!1,!1);const WA=w.useCallback(async S=>{var N,U;if(!(!ui.cut||!(((N=c.current)==null?void 0:N.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await iu(S),J.current!==void 0)){let K={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:St.empty(),columns:St.empty()};const te=$==null?void 0:$(K);if(te===!1||(K=te===!0?K:te,K.current===void 0))return;No(K.current.range)}},[No,J,ui.cut,iu,$]);Fn("cut",WA,h,!1,!1);const VA=w.useCallback((S,L)=>{if(B!==void 0){G!==0&&(S=S.map(K=>[K[0]-G,K[1]])),B(S,L);return}if(S.length===0||L===-1)return;const[N,U]=S[L];f.current!==void 0&&f.current[0]===N&&f.current[1]===U||(f.current=[N,U],zs(N,U,!1,!1))},[B,G,zs]),[gf,mf]=((_w=ct==null?void 0:ct.current)==null?void 0:_w.cell)??[],yf=w.useRef(dn);yf.current=dn,w.useLayoutEffect(()=>{var S,L,N,U;!kt.current&&gf!==void 0&&mf!==void 0&&(gf!==((L=(S=Fs.current)==null?void 0:S.current)==null?void 0:L.cell[0])||mf!==((U=(N=Fs.current)==null?void 0:N.current)==null?void 0:U.cell[1]))&&yf.current(gf,mf),kt.current=!1},[gf,mf]);const Aw=J.current!==void 0&&(J.current.cell[0]>=ot.length||J.current.cell[1]>=Vn);w.useLayoutEffect(()=>{Aw&&fr(Kf,!1)},[Aw,fr]);const UA=w.useMemo(()=>Yt===!0&&(pt==null?void 0:pt.tint)===!0?St.fromSingleSelection(Vn-1):St.empty(),[Vn,Yt,pt==null?void 0:pt.tint]),KA=w.useCallback(S=>typeof Rn=="boolean"?Rn:(Rn==null?void 0:Rn(S-G))??!0,[G,Rn]),XA=w.useMemo(()=>{if(Up===void 0||l.current===null)return null;const{bounds:S,group:L}=Up,N=l.current.getBoundingClientRect();return w.createElement(sW,{bounds:S,group:L,canvasBounds:N,onClose:()=>Kp(void 0),onFinish:U=>{Kp(void 0),F==null||F(L,U)}})},[F,Up]),GA=Math.min(ot.length,ue+(Sr?1:0));w.useImperativeHandle(e,()=>({appendRow:(S,L)=>Rl(S+G,L),updateCells:S=>{var L;return G!==0&&(S=S.map(N=>({cell:[N.cell[0]+G,N.cell[1]]}))),(L=hr.current)==null?void 0:L.damage(S)},getBounds:(S,L)=>{var N;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(S===void 0&&L===void 0){const U=l.current.getBoundingClientRect(),K=U.width/c.current.clientWidth;return{x:U.x-c.current.scrollLeft*K,y:U.y-c.current.scrollTop*K,width:c.current.scrollWidth*K,height:c.current.scrollHeight*K}}return(N=hr.current)==null?void 0:N.getBounds((S??0)+G,L)}},focus:()=>{var S;return(S=hr.current)==null?void 0:S.focus()},emit:async S=>{switch(S){case"delete":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":ru({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await iu(void 0,!0);break;case"paste":await Qp();break}},scrollTo:dn,remeasureColumns:S=>{for(const L of S)pf(L+G)}}),[Rl,pf,iu,ru,Qp,G,dn]);const[Rw,Ow]=Li??[],qA=w.useCallback(S=>{const[L,N]=S;if(N===-1){be!=="none"&&(me(St.fromSingleSelection(L),void 0,!1),nr());return}Rw===L&&Ow===N||(ie({cell:S,range:{x:L,y:N,width:1,height:1}},!0,!1,"keyboard-nav"),dn(L,N))},[be,nr,dn,Rw,Ow,ie,me]),[YA,QA]=w.useState(!1),Pw=w.useRef(aT(S=>{QA(S)},5)),JA=w.useCallback(()=>{Pw.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&ie({cell:[G,af],range:{x:G,y:af,width:1,height:1}},!0,!1,"keyboard-select")},[af,J,a,G,ie]),ZA=w.useCallback(()=>{Pw.current(!1)},[]),[eR,tR]=w.useMemo(()=>{let S;const L=(qt==null?void 0:qt.scrollbarWidthOverride)??v0(),N=y+(Yt?1:0);if(typeof tr=="number")S=st+N*tr;else{let K=0;const te=Math.min(N,10);for(let q=0;qte.width+K,0)+L;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,S)}px`]},[ot,qt==null?void 0:qt.scrollbarWidthOverride,tr,y,Yt,st]),nR=w.useMemo(()=>E4(ce),[ce]);return w.createElement(M4.Provider,{value:ce},w.createElement(xW,{style:nR,className:j,inWidth:x??eR,inHeight:v??tR},w.createElement(tW,{fillHandle:Wt,drawFocusRing:kn,experimental:qt,fixedShadowX:Qc,fixedShadowY:Ds,getRowThemeOverride:p,headerIcons:us,imageWindowLoader:cs,initialSize:ml,isDraggable:Jc,onDragLeave:Zc,onRowMoved:_i,overscrollX:Lp,overscrollY:of,preventDiagonalScrolling:wl,rightElement:Oo,rightElementProps:_s,smoothScrollX:tf,smoothScrollY:Ip,className:j,enableGroups:At,onCanvasFocused:JA,onCanvasBlur:ZA,canvasRef:l,onContextMenu:jA,theme:ce,cellXOffset:Io,cellYOffset:af,accessibilityHeight:hn.height,onDragEnd:BA,columns:ot,nonGrowWidth:Ne,drawHeader:$p,onColumnProposeMove:I,drawCell:Hp,disabledRows:UA,freezeColumns:GA,lockColumns:G,firstColAccessible:G===0,getCellContent:Er,minColumnWidth:kr,maxColumnWidth:ai,searchInputRef:o,showSearch:Qa,onSearchClose:Bp,highlightRegions:RA,getCellsForSelection:xn,getGroupDetails:Wp,headerHeight:Sl,isFocused:YA,groupHeaderHeight:At?Ya:0,freezeTrailingRows:xt+(Yt&&(pt==null?void 0:pt.sticky)===!0?1:0),hasAppendRow:Yt,onColumnResize:ci,onColumnResizeEnd:zp,onColumnResizeStart:Tl,onCellFocused:qA,onColumnMoved:LA,onDragStart:FA,onHeaderMenuClick:_A,onItemHovered:Yp,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:DA,onKeyDown:ru,onKeyUp:nt,onMouseDown:OA,onMouseUp:IA,onDragOverCell:li,onDrop:vt,onSearchResultsChanged:VA,onVisibleRegionChanged:NA,clientSize:Ee,rowHeight:tr,searchResults:de,searchValue:ae,onSearchValueChange:ge,rows:Vn,scrollRef:c,selection:J,translateX:hn.tx,translateY:hn.ty,verticalBorder:KA,gridRef:hr,getCellRenderer:Ce}),XA,i!==void 0&&w.createElement(w.Suspense,{fallback:null},w.createElement(EW,{...i,validateCell:Ja,bloom:O,id:HA,getCellRenderer:Ce,className:(qt==null?void 0:qt.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:jt,imageEditorOverride:d,onFinishEditing:$A,markdownDivCreateNode:m,isOutsideClick:nf}))))},OW=w.forwardRef(RW),kb=20,PW={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:ke.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>IW(t,t.cell.data,d0(t.cell),t.cell.maxSize??kb),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??kb,f=Math.floor(i.y+l/2),h=fT(c,l,s.cellVerticalPadding),d=cT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,h),p=uT(d,f,h),m=hT(a+n,u+r,p);if(d0(e)&&m)return{...e,data:sE(e.data)}},onPaste:(t,e)=>{let n=od;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Rv),n===e.data?void 0:{...e,data:n}}};function IW(t,e,n,r){if(!n&&e===od)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:h,y:d,width:p,height:m}=l,x=.35;let v=n?1-x+x*s:.4;e===od&&(v*=s),v!==0&&(i.globalAlpha=v,Wv(i,o,e,h,d,p,m,a,u,c,r,f),i.globalAlpha=1)}const DW=zr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),_W=t=>{const{bubbles:e}=t;return w.createElement(DW,null,e.map((n,r)=>w.createElement("div",{key:r,className:"boe-bubble"},n)),w.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},NW={getAccessibilityString:t=>dT(t.data),kind:ke.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>FW(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return w.createElement(_W,{bubbles:e.data})},onPaste:()=>{}},LW=4;function FW(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,h=LW;let d=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(d>o+a)break;const x=Uc(m,i,r.baseFontFull).width;p.push({x:d,width:x}),d+=x+f*2+h}i.beginPath();for(const m of p)rs(i,m.x,l+(u-c)/2,m.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[m,x]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[m],x.x+f,l+u/2+Is(i,r))}const BW=zr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),zW=t=>{const{drilldowns:e}=t;return w.createElement(BW,null,e.map((n,r)=>w.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&w.createElement("img",{src:n.img}),w.createElement("div",null,n.text))))},$W={getAccessibilityString:t=>dT(t.data.map(e=>e.text)),kind:ke.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>WW(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return w.createElement(zW,{drilldowns:e.data})},onPaste:()=>{}},HW=4,Vg={};function jW(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,h=`${t},${e},${i},${n}`;if(Vg[h]!==void 0)return{el:Vg[h],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const d=document.createElement("canvas"),p=d.getContext("2d");return p===null?null:(d.width=f,d.height=a,p.scale(i,i),Vg[h]=d,p.beginPath(),rs(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),rs(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:d,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function WW(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=ET(i,c),h=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),d=Math.floor(n.y+(n.height-h)/2),p=h-10,m=8,x=HW;let v=a+r.cellHorizontalPadding;const g=r.roundingRadius??6,y=jW(r.bgCell,r.drilldownBorder,h,g),k=[];for(const b of e){if(v>a+u)break;const T=Uc(b.text,i,c).width;let E=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(E=p-8+4);const A=T+E+m*2;k.push({x:v,width:A}),v+=A+x}if(y!==null){const{el:b,height:C,middleWidth:T,sideWidth:E,width:A,dpr:P,padding:_}=y,O=E/P,D=_/P;for(const I of k){const Q=Math.floor(I.x),X=Math.floor(I.width),le=X-(O-D)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,E,C,Q-D,d,O,h),le>0&&i.drawImage(b,E,0,T,C,Q+(O-D),d,le,h),i.drawImage(b,A-E,0,E,C,Q+X-(O-D),d,O,h),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,C]of k.entries()){const T=e[b];let E=C.x+m;if(T.img!==void 0){const A=s.loadOrGetImage(T.img,o,l);if(A!==void 0){const P=p-8;let _=0,O=0,D=A.width,I=A.height;D>I?(_+=(D-I)/2,D=I):I>D&&(O+=(I-D)/2,I=D),i.beginPath(),rs(i,E,d+h/2-P/2,P,P,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(A,_,O,D,I,E,d+h/2-P/2,P,P),i.restore(),E+=P+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,E,d+h/2+Is(i,r))}}const VW={getAccessibilityString:t=>t.data.join(", "),kind:ke.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>UW(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??NF;return w.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},Ug=4;function UW(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:h,width:d}=i,p=h-l.cellVerticalPadding*2,m=[];let x=0;for(let g=0;g0&&(a.beginPath(),rs(a,v,f+l.cellVerticalPadding,y,p,n),a.save(),a.clip()),a.drawImage(g,v,f+l.cellVerticalPadding,y,p),n>0&&a.restore(),v+=y+Ug}}function KW(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const XW={getAccessibilityString:()=>"",kind:ke.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(KW(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);rs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=sl(o.textDark,.1),i.fill()},onPaste:()=>{}},GW=()=>t=>t.targetWidth,Sb=zr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[GW(),"px"]}}),qW=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=w.useState(a===""||r),h=w.useCallback(()=>{f(p=>!p)},[]),d=a?"gdg-ml-6":"";return c?w.createElement(Sb,{targetWidth:s.width-20},w.createElement(gp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),w.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${d}`,onClick:()=>o(e)},w.createElement(AF,null))):w.createElement(Sb,{targetWidth:s.width},w.createElement(e4,{contents:a,createNode:i}),!u&&w.createElement(w.Fragment,null,w.createElement("div",{className:"spacer"}),w.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${d}`,onClick:h},w.createElement(_v,null))),w.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},YW={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:Kc,measure:(t,e,n)=>{const r=e.data.split(` -`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>ws(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return w.createElement(qW,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},QW={getAccessibilityString:t=>t.row.toString(),kind:Yr.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:JW,measure:()=>44,draw:t=>e6(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function JW(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=ZW,n.textAlign="center",s}function ZW(t){const{ctx:e}=t;e.textAlign="start"}function e6(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:h,height:d}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(Wv(o,u,n,i?c+m:c,f,i?h-m:h,d,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const v of[-5,-1,3])o.rect(c+x,f+d/2+v,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,v=c+h/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,v,f+d/2+Is(o,x)),a!==0&&(o.globalAlpha=1)}}const t6={getAccessibilityString:()=>"",kind:Yr.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>n6(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function n6(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const h=e!=="";let d=0;if(n!==void 0){const m=f-8,x=a+8/2,v=u+8/2;l.drawSprite(n,"normal",r,x,v,m,o,h?1:s),d=m}else{d=24;const p=12,m=h?p:s*p,x=h?0:(1-s)*p*.5,v=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+v+x,u+f/2),r.lineTo(a+v+x+m,u+f/2),r.moveTo(a+v+x+m*.5,u+f/2-m*.5),r.lineTo(a+v+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,d+a+o.cellHorizontalPadding+.5,u+f/2+Is(r,o)),r.beginPath()}const r6=w.lazy(async()=>await IT(()=>import("./number-overlay-editor-BQY5aYke.js"),[])),i6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:Kc,draw:t=>ws(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return w.createElement(w.Suspense,{fallback:null},w.createElement(r6,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},s6={getAccessibilityString:()=>"",measure:()=>108,kind:ke.Protected,needsHover:!1,needsHoverPosition:!1,draw:o6,onPaste:()=>{}};function o6(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Cx(30))*l,f=Math.sin(Cx(30))*l;for(let h=0;h<12;h++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const l6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>Kc(t,e,t.theme.textLight),draw:t=>ws(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Tn.createElement(gp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},a6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Kc,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const h=o.cellHorizontalPadding,d=o.cellVerticalPadding,p=Uc(a,i,o.baseFontFull,"alphabetic"),m=s.height-d,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),rs(i,s.x+h/2,s.y+(s.height-x)/2+1,p.width+h*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=sl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}ws(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` +`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>ws(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return w.createElement(qW,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},QW={getAccessibilityString:t=>t.row.toString(),kind:Yr.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:JW,measure:()=>44,draw:t=>e6(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function JW(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=ZW,n.textAlign="center",s}function ZW(t){const{ctx:e}=t;e.textAlign="start"}function e6(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:h,height:d}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(Wv(o,u,n,i?c+m:c,f,i?h-m:h,d,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const v of[-5,-1,3])o.rect(c+x,f+d/2+v,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,v=c+h/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,v,f+d/2+Is(o,x)),a!==0&&(o.globalAlpha=1)}}const t6={getAccessibilityString:()=>"",kind:Yr.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>n6(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function n6(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const h=e!=="";let d=0;if(n!==void 0){const m=f-8,x=a+8/2,v=u+8/2;l.drawSprite(n,"normal",r,x,v,m,o,h?1:s),d=m}else{d=24;const p=12,m=h?p:s*p,x=h?0:(1-s)*p*.5,v=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+v+x,u+f/2),r.lineTo(a+v+x+m,u+f/2),r.moveTo(a+v+x+m*.5,u+f/2-m*.5),r.lineTo(a+v+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,d+a+o.cellHorizontalPadding+.5,u+f/2+Is(r,o)),r.beginPath()}const r6=w.lazy(async()=>await IT(()=>import("./number-overlay-editor-BELyYPco.js"),[])),i6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:Kc,draw:t=>ws(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return w.createElement(w.Suspense,{fallback:null},w.createElement(r6,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},s6={getAccessibilityString:()=>"",measure:()=>108,kind:ke.Protected,needsHover:!1,needsHoverPosition:!1,draw:o6,onPaste:()=>{}};function o6(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Cx(30))*l,f=Math.sin(Cx(30))*l;for(let h=0;h<12;h++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const l6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>Kc(t,e,t.theme.textLight),draw:t=>ws(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Tn.createElement(gp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},a6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Kc,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const h=o.cellHorizontalPadding,d=o.cellVerticalPadding,p=Uc(a,i,o.baseFontFull,"alphabetic"),m=s.height-d,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),rs(i,s.x+h/2,s.y+(s.height-x)/2+1,p.width+h*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=sl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}ws(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` `,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return w.createElement(gp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},u6=zr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),c6=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=w.useState(!i&&(e===""||r)),u=w.useCallback(()=>{a(!0)},[]);return l?w.createElement(gp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):w.createElement(u6,null,w.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&w.createElement("div",{className:"gdg-edit-icon",onClick:u},w.createElement(_v,null)),w.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Cb(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const f6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:Kc,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=Uc(a,l,n.baseFontFull),f=Cb(c,o,n,e.contentAlign),{x:h,y:d,width:p,height:m}=f;if(i>=h-4&&i<=h-4+p+8&&s>=d-4&&s<=d-4+m+8){const x=Is(l,n.baseFontFull);r("pointer");const v=5,g=d-x;l.beginPath(),l.moveTo(o.x+h,Math.floor(o.y+g+m+v)+.5),l.lineTo(o.x+h+p,Math.floor(o.y+g+m+v)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,ws({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),ws({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,ws(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=v4(o,s.baseFontFull);if(l===void 0)return;const a=Cb(l,n,s,e.contentAlign);yp({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return w.createElement(c6,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},h6=[QW,t6,PW,NW,$W,VW,XW,YW,i6,s6,l6,a6,f6];var d6=lT,p6=hl,g6="Expected a function";function m6(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(g6);return p6(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),d6(t,e,{leading:r,maxWait:e,trailing:i})}var y6=m6;const v6=Pi(y6),Kg=[];class w6 extends AT{constructor(){super(...arguments);ft(this,"imageLoaded",()=>{});ft(this,"loadedLocations",[]);ft(this,"cache",{});ft(this,"sendLoaded",v6(()=>{this.imageLoaded(new qu(this.loadedLocations)),this.loadedLocations=[]},20));ft(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,Kg.length<12?Kg.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const h of f.cells)this.loadedLocations.push($v(h));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=ki(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const Xg="\uFEFF";function x6(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function b6(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;soE(r,n)).join(` `)}function k6(t,e){return vp(t,e).headers}function S6(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function Gg(t,e){const n=new Set(e),r=t.rows.filter((i,s)=>!n.has(s));return Yu(t.headers,r,t.delimiter)}function Tb(t,e){const n=new Set(e),r=t.headers.filter((s,o)=>!n.has(o)),i=t.rows.map(s=>s.filter((o,l)=>!n.has(l)));return Yu(r,i,t.delimiter)}const Eb=/^[+-]?\d{16,}$/;function C6(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const h=a===""?NaN:Number(a),d=u===""?NaN:Number(u),p=Number.isNaN(h),m=Number.isNaN(d);if(p||m)return p&&m?0:p?1:-1;if(Eb.test(a)&&Eb.test(u)){const x=BigInt(a),v=BigInt(u);return s*(xv?1:0)}return s*(h-d)}return s*a.localeCompare(u)})}const E6=` -`;function Xf(t,e){return Math.max(0,Math.min(t,e))}function Mb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Xf(a.x,r+i),c=Xf(a.x+a.width,r+i);if(c<=r)continue;const f=u-r,h=c-r;if(h<=f)continue;const d=Xf(a.y,e.length),p=Xf(a.y+a.height,e.length);if(p<=d)continue;const m=t.headers.slice(f,h),x=[];for(let v=d;vy[f+b]??""))}x.length!==0&&s.push(Yu(m,x,t.delimiter))}if(s.length>0)return s.join(E6);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return Yu(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(h=>f[h-r]??"")});return Yu(a,u,t.delimiter)}return null}const Ab=24,Rb=26,Ob=110,Pb=40,M6=12,Nn=1,Ib='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',Db='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',wu="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50";function A6(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Db,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Db,lineHeight:1}}function R6(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function lE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i}){const s=w.useRef(null),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(""),[c,f]=w.useState(""),[h,d]=w.useState(null),[p,m]=w.useState(void 0),[x,v]=w.useState(()=>new Set),g=w.useRef(x),[y,k]=w.useState(0),b=i!==void 0,C=w.useMemo(()=>A6(r),[r]),T=R6(r),E=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",A=w.useRef();A.current===void 0&&(A.current=new w6);const P=w.useMemo(()=>vp(t,e),[t,e]),_=w.useMemo(()=>S6(P),[P]),O=P.headers.length,D=w.useRef({text:t,table:P});D.current={text:t,table:P};const I=w.useRef(p);I.current=p,w.useEffect(()=>{const H=window.setTimeout(()=>f(a),150);return()=>window.clearTimeout(H)},[a]);const Q=w.useMemo(()=>{const H=C6(P.rows,c);return h?T6(H,P.rows,h.col,h.dir,_[h.col]??!1):H},[P,c,h,_]),X=w.useRef(Q);X.current=Q,w.useEffect(()=>{const H=o.current;if(!H||typeof ResizeObserver>"u")return;const V=new ResizeObserver(()=>k(H.clientWidth));return V.observe(H),k(H.clientWidth),()=>V.disconnect()},[]);const le=Math.max(Ob,Math.floor((y-Pb)/Math.max(1,O)));w.useEffect(()=>{v(H=>{let V=!1;const Z=new Set;for(const ue of H)ue{m(H=>{if(!H||H.rows.length===0)return H;const V=[];for(const ue of g.current){const se=Q.indexOf(ue);se!==-1&&V.push(se)}V.sort((ue,se)=>ue-se);const Z=V.reduce((ue,se)=>ue.add(se),St.empty());return Z.equals(H.rows)?H:{...H,rows:Z}})},[Q]),w.useEffect(()=>{d(H=>H!==null&&H.col>=O?null:H)},[O]);const j=c!=="",ne=P.rows.length,Y=Rb+Math.min(Q.length,M6)*Ab,M=()=>{u(""),f("")},F=w.useCallback(H=>{if(H!Z||Z.col!==V?{col:V,dir:"asc"}:Z.dir==="asc"?{col:V,dir:"desc"}:null)},[]),z=w.useCallback((H,V)=>{const Z=X.current,ue=Z[V];if(ue===void 0)return;const se=g.current,tt=l.current;let pe;if(H.shiftKey&&tt!==null&&tt!==ue){const Me=Z.indexOf(tt),Ve=Z.indexOf(ue),dt=Me===-1?Ve:Me,[An,un]=dt<=Ve?[dt,Ve]:[Ve,dt];pe=H.metaKey||H.ctrlKey?new Set(se):new Set;for(let ct=An;ct<=un;ct++){const vn=Z[ct];vn!==void 0&&pe.add(vn)}}else H.metaKey||H.ctrlKey?(pe=new Set(se),pe.has(ue)?pe.delete(ue):pe.add(ue)):pe=new Set([ue]);l.current=ue,g.current=pe,v(pe);const De=[...pe].map(Me=>Z.indexOf(Me)).filter(Me=>Me!==-1).sort((Me,Ve)=>Me-Ve);m(Me=>({current:Me==null?void 0:Me.current,columns:(Me==null?void 0:Me.columns)??St.empty(),rows:De.reduce((Ve,dt)=>Ve.add(dt),St.empty())}))},[]),W=w.useCallback(()=>{l.current=null,g.current=new Set,v(new Set),m(void 0)},[]),B=w.useCallback(H=>{const V=new Set;for(const Z of H.rows){const ue=X.current[Z];ue!==void 0&&V.add(ue)}g.current=V,v(V),m(H)},[]),de=w.useCallback(()=>{W()},[W]),ge=w.useMemo(()=>Q.filter(H=>x.has(H)),[Q,x]),ae=w.useMemo(()=>[...(p==null?void 0:p.columns)??[]].filter(H=>H>=Nn).map(H=>H-Nn),[p]),Re=ae.length,nt=ge.length>0||Re>0,Ze=()=>{var Z;const H=I.current,V=Mb(D.current.table,X.current,{ranges:H!=null&&H.current?[H.current.range,...H.current.rangeStack]:[],columns:H?[...H.columns]:[],rows:H?[...H.rows]:[]},Nn);V!==null&&((Z=navigator.clipboard)==null||Z.writeText(V).catch(()=>{}))};w.useEffect(()=>{const H=V=>{var pe;const Z=s.current;if(!Z||!Z.contains(document.activeElement))return;const ue=document.activeElement;if(ue&&(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.isContentEditable))return;const se=I.current,tt=Mb(D.current.table,X.current,{ranges:se!=null&&se.current?[se.current.range,...se.current.rangeStack]:[],columns:se?[...se.columns]:[],rows:se?[...se.rows]:[]},Nn);tt!==null&&(V.preventDefault(),V.stopImmediatePropagation(),(pe=V.clipboardData)==null||pe.setData("text/plain",tt))};return window.addEventListener("copy",H,{capture:!0}),()=>window.removeEventListener("copy",H,{capture:!0})},[]);const Ge=w.useCallback(H=>{W(),i==null||i(H)},[W,i]),Ye=O>0&&ae.length>=O,it=()=>{!b||ge.length===0||Ge(Gg(D.current.table,ge))},rt=()=>{!b||Ye||ae.length===0||Ge(Tb(D.current.table,ae))},Dt=w.useCallback(H=>{if(!i)return!1;const{table:Z}=D.current,ue=X.current;if(H.rows.length>0){const pe=[...H.rows].map(De=>ue[De]).filter(De=>De!==void 0);if(pe.length>0)return Ge(Gg(Z,pe)),!1}if(H.columns.length>0){const pe=[...H.columns].filter(De=>De>=Nn&&DeDe-Nn);return pe.length>0&&pe.length0&&Ge(Gg(Z,tt)),!1},[Ge,i]),Ie=w.useCallback(H=>{const V=i;if(!V)return!1;const{text:Z,table:ue}=D.current,se=X.current,tt=[...H].sort((Me,Ve)=>Me.location[1]-Ve.location[1]);let pe=Z,De=0;for(const{location:Me,value:Ve}of tt){const dt=Me[0]-Nn,An=Me[1];if(dt<0||Ve.kind!==ke.Text)continue;const un=se[An],ct=un===void 0?void 0:ue.rowSpans[un];if(!ct)continue;const vn=pe.slice(ct.start+De,ct.end+De),cn=k6(vn,ue.delimiter);for(;cn.length<=dt;)cn.push("");const $r=Ve.data??"";if(cn[dt]===$r)continue;cn[dt]=$r;const Hr=oE(cn,ue.delimiter);pe=pe.slice(0,ct.start+De)+Hr+pe.slice(ct.end+De),De+=Hr.length-(ct.end-ct.start)}return pe!==Z&&V(pe),!0},[i]),be=w.useCallback(H=>{var tt;const[V,Z]=H,ue=X.current[Z];if(V{const V=[];for(let Z=H.y;Z{H[0]>=Nn||z(V,H[1])},[z]),et=w.useMemo(()=>{const H={title:"#",id:"__gutter",width:Pb,themeOverride:{baseFontStyle:`11px ${Ib}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},V=P.headers.map((Z,ue)=>({title:Z.toUpperCase(),id:`c${ue}`,width:le,themeOverride:_[ue]?{baseFontStyle:`12px ${Ib}`}:void 0}));return[H,...V]},[P.headers,_,le]),Be=w.useCallback((H,V)=>{const{ctx:Z,columnIndex:ue,rect:se,theme:tt,isSelected:pe}=H;Z.save();try{if(Z.letterSpacing="0.5px",pe&&(Z.fillStyle=tt.bgHeaderHovered,Z.fillRect(se.x,se.y,se.width,se.height),Z.fillStyle=tt.accentColor,Z.fillRect(se.x,se.y+se.height-2,se.width,2)),ue{const{ctx:Z,cell:ue,rect:se,col:tt,theme:pe}=H,De=tt-Nn;if(De>=0&&j&&ue.kind===ke.Text){const Me=O6(ue.data,c);if(Me!==null){Z.save();try{const Ve=`${pe.baseFontStyle} ${pe.fontFamily}`;Z.font=Ve;let dt=se.x+pe.cellHorizontalPadding;const An=se.y+se.height/2+Is(Z,Ve);for(const un of Me){const ct=Z.measureText(un.text).width;un.hit&&ct>0&&(Z.fillStyle=T,Z.fillRect(dt-1,An-7,ct+2,14)),dt+=ct}}finally{Z.restore()}}}if(V(),De>=0&&ue.kind===ke.Text&&ue.data===""){Z.save();try{Z.font=`${pe.baseFontStyle} ${pe.fontFamily}`,Z.fillStyle=pe.textLight,Z.fillText("—",se.x+pe.cellHorizontalPadding,se.y+se.height/2+.5)}finally{Z.restore()}}},[j,c,T]),_e=w.useCallback(H=>{const V=X.current[H];return V!==void 0&&g.current.has(V)?{bgCell:E,bgCellMedium:E}:void 0},[E]);return O===0?R.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):R.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:s,children:[R.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[R.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[R.jsx(fI,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),R.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:a,onChange:H=>u(H.target.value),onKeyDown:H=>{H.key==="Escape"&&M()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),a!==""&&R.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:M,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx(L2,{"aria-hidden":"true",className:"size-3"})})]}),R.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:j?`${Q.length.toLocaleString()} of ${ne.toLocaleString()}`:`${ne.toLocaleString()} rows`}),nt&&R.jsxs("span",{className:"flex items-center gap-1.5",children:[R.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:ge.length>0?`${ge.length.toLocaleString()} selected`:`${Re.toLocaleString()} ${Re===1?"column":"columns"} selected`}),R.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Ze,className:wu,children:[R.jsx(wv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),b&&ge.length>0&&R.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:it,title:`Deletes the ${ge.length} selected ${ge.length===1?"row":"rows"} from the source CSV`,className:wu,children:[R.jsx(f0,{"aria-hidden":"true",className:"size-3"}),"Delete ",ge.length.toLocaleString()," ",ge.length===1?"row":"rows"]}),b&&Re>0&&R.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:rt,disabled:Ye,title:Ye?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Re} selected ${Re===1?"column":"columns"} from the source CSV`,className:`${wu} disabled:cursor-not-allowed disabled:opacity-50`,children:[R.jsx(f0,{"aria-hidden":"true",className:"size-3"}),"Delete ",Re.toLocaleString()," ",Re===1?"column":"columns"]}),R.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:W,className:wu,children:"Clear"})]})]}),R.jsxs("div",{ref:o,"data-testid":n,role:"grid","aria-rowcount":Q.length+1,className:"relative min-h-0 flex-1",style:{minHeight:Y},children:[R.jsx("div",{className:"absolute inset-0",children:R.jsx(OW,{imageWindowLoader:A.current,renderers:h6,columns:et,rows:Q.length,getCellContent:be,getCellsForSelection:Xe,onCellsEdited:b?Ie:void 0,onDelete:b?Dt:void 0,onCellClicked:qe,onHeaderClicked:F,onGridSelectionChange:B,onSelectionCleared:de,gridSelection:p,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:Ab,headerHeight:Rb,freezeColumns:Nn,fillHandle:b,onPaste:b?()=>!0:!1,keybindings:{search:!1},theme:C,drawHeader:Be,drawCell:ye,getRowThemeOverride:_e,minColumnWidth:Ob,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),j&&Q.length===0&&R.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[R.jsxs("span",{children:["No rows matching “",c,"”."]}),R.jsx("button",{type:"button",onClick:M,className:wu,children:"Show all rows"})]}),!j&&Q.length===0&&R.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:R.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function O6(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return sy[f+b]??""))}x.length!==0&&s.push(Yu(m,x,t.delimiter))}if(s.length>0)return s.join(E6);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return Yu(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(h=>f[h-r]??"")});return Yu(a,u,t.delimiter)}return null}const Ab=24,Rb=26,Ob=110,Pb=40,M6=12,Nn=1,Ib='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',Db='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',wu="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50";function A6(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Db,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Db,lineHeight:1}}function R6(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function lE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i}){const s=w.useRef(null),o=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(""),[c,f]=w.useState(""),[h,d]=w.useState(null),[p,m]=w.useState(void 0),[x,v]=w.useState(()=>new Set),g=w.useRef(x),[y,k]=w.useState(0),b=i!==void 0,C=w.useMemo(()=>A6(r),[r]),T=R6(r),E=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",A=w.useRef();A.current===void 0&&(A.current=new w6);const P=w.useMemo(()=>vp(t,e),[t,e]),_=w.useMemo(()=>S6(P),[P]),O=P.headers.length,D=w.useRef({text:t,table:P});D.current={text:t,table:P};const I=w.useRef(p);I.current=p,w.useEffect(()=>{const H=window.setTimeout(()=>f(a),150);return()=>window.clearTimeout(H)},[a]);const Q=w.useMemo(()=>{const H=C6(P.rows,c);return h?T6(H,P.rows,h.col,h.dir,_[h.col]??!1):H},[P,c,h,_]),X=w.useRef(Q);X.current=Q,w.useEffect(()=>{const H=o.current;if(!H||typeof ResizeObserver>"u")return;const V=new ResizeObserver(()=>k(H.clientWidth));return V.observe(H),k(H.clientWidth),()=>V.disconnect()},[]);const le=Math.max(Ob,Math.floor((y-Pb)/Math.max(1,O)));w.useEffect(()=>{v(H=>{let V=!1;const Z=new Set;for(const ue of H)ue{m(H=>{if(!H||H.rows.length===0)return H;const V=[];for(const ue of g.current){const se=Q.indexOf(ue);se!==-1&&V.push(se)}V.sort((ue,se)=>ue-se);const Z=V.reduce((ue,se)=>ue.add(se),St.empty());return Z.equals(H.rows)?H:{...H,rows:Z}})},[Q]),w.useEffect(()=>{d(H=>H!==null&&H.col>=O?null:H)},[O]);const j=c!=="",ne=P.rows.length,Y=Rb+Math.min(Q.length,M6)*Ab,M=()=>{u(""),f("")},F=w.useCallback(H=>{if(H!Z||Z.col!==V?{col:V,dir:"asc"}:Z.dir==="asc"?{col:V,dir:"desc"}:null)},[]),z=w.useCallback((H,V)=>{const Z=X.current,ue=Z[V];if(ue===void 0)return;const se=g.current,tt=l.current;let pe;if(H.shiftKey&&tt!==null&&tt!==ue){const Me=Z.indexOf(tt),Ve=Z.indexOf(ue),dt=Me===-1?Ve:Me,[An,un]=dt<=Ve?[dt,Ve]:[Ve,dt];pe=H.metaKey||H.ctrlKey?new Set(se):new Set;for(let ct=An;ct<=un;ct++){const vn=Z[ct];vn!==void 0&&pe.add(vn)}}else H.metaKey||H.ctrlKey?(pe=new Set(se),pe.has(ue)?pe.delete(ue):pe.add(ue)):pe=new Set([ue]);l.current=ue,g.current=pe,v(pe);const De=[...pe].map(Me=>Z.indexOf(Me)).filter(Me=>Me!==-1).sort((Me,Ve)=>Me-Ve);m(Me=>({current:Me==null?void 0:Me.current,columns:(Me==null?void 0:Me.columns)??St.empty(),rows:De.reduce((Ve,dt)=>Ve.add(dt),St.empty())}))},[]),W=w.useCallback(()=>{l.current=null,g.current=new Set,v(new Set),m(void 0)},[]),B=w.useCallback(H=>{const V=new Set;for(const Z of H.rows){const ue=X.current[Z];ue!==void 0&&V.add(ue)}g.current=V,v(V),m(H)},[]),de=w.useCallback(()=>{W()},[W]),ge=w.useMemo(()=>Q.filter(H=>x.has(H)),[Q,x]),ae=w.useMemo(()=>[...(p==null?void 0:p.columns)??[]].filter(H=>H>=Nn).map(H=>H-Nn),[p]),Re=ae.length,nt=ge.length>0||Re>0,Ze=()=>{var Z;const H=I.current,V=Mb(D.current.table,X.current,{ranges:H!=null&&H.current?[H.current.range,...H.current.rangeStack]:[],columns:H?[...H.columns]:[],rows:H?[...H.rows]:[]},Nn);V!==null&&((Z=navigator.clipboard)==null||Z.writeText(V).catch(()=>{}))};w.useEffect(()=>{const H=V=>{var pe;const Z=s.current;if(!Z||!Z.contains(document.activeElement))return;const ue=document.activeElement;if(ue&&(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.isContentEditable))return;const se=I.current,tt=Mb(D.current.table,X.current,{ranges:se!=null&&se.current?[se.current.range,...se.current.rangeStack]:[],columns:se?[...se.columns]:[],rows:se?[...se.rows]:[]},Nn);tt!==null&&(V.preventDefault(),V.stopImmediatePropagation(),(pe=V.clipboardData)==null||pe.setData("text/plain",tt))};return window.addEventListener("copy",H,{capture:!0}),()=>window.removeEventListener("copy",H,{capture:!0})},[]);const Ge=w.useCallback(H=>{W(),i==null||i(H)},[W,i]),Ye=O>0&&ae.length>=O,it=()=>{!b||ge.length===0||Ge(Gg(D.current.table,ge))},rt=()=>{!b||Ye||ae.length===0||Ge(Tb(D.current.table,ae))},Dt=w.useCallback(H=>{if(!i)return!1;const{table:Z}=D.current,ue=X.current;if(H.rows.length>0){const pe=[...H.rows].map(De=>ue[De]).filter(De=>De!==void 0);if(pe.length>0)return Ge(Gg(Z,pe)),!1}if(H.columns.length>0){const pe=[...H.columns].filter(De=>De>=Nn&&DeDe-Nn);return pe.length>0&&pe.length0&&Ge(Gg(Z,tt)),!1},[Ge,i]),Ie=w.useCallback(H=>{const V=i;if(!V)return!1;const{text:Z,table:ue}=D.current,se=X.current,tt=[...H].sort((Me,Ve)=>Me.location[1]-Ve.location[1]);let pe=Z,De=0;for(const{location:Me,value:Ve}of tt){const dt=Me[0]-Nn,An=Me[1];if(dt<0||Ve.kind!==ke.Text)continue;const un=se[An],ct=un===void 0?void 0:ue.rowSpans[un];if(!ct)continue;const vn=pe.slice(ct.start+De,ct.end+De),cn=k6(vn,ue.delimiter);for(;cn.length<=dt;)cn.push("");const $r=Ve.data??"";if(cn[dt]===$r)continue;cn[dt]=$r;const Hr=oE(cn,ue.delimiter);pe=pe.slice(0,ct.start+De)+Hr+pe.slice(ct.end+De),De+=Hr.length-(ct.end-ct.start)}return pe!==Z&&V(pe),!0},[i]),be=w.useCallback(H=>{var tt;const[V,Z]=H,ue=X.current[Z];if(V{const V=[];for(let Z=H.y;Z{H[0]>=Nn||z(V,H[1])},[z]),et=w.useMemo(()=>{const H={title:"#",id:"__gutter",width:Pb,themeOverride:{baseFontStyle:`11px ${Ib}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},V=P.headers.map((Z,ue)=>({title:Z.toUpperCase(),id:`c${ue}`,width:le,themeOverride:_[ue]?{baseFontStyle:`12px ${Ib}`}:void 0}));return[H,...V]},[P.headers,_,le]),Be=w.useCallback((H,V)=>{const{ctx:Z,columnIndex:ue,rect:se,theme:tt,isSelected:pe}=H;Z.save();try{if(Z.letterSpacing="0.5px",pe&&(Z.fillStyle=tt.bgHeaderHovered,Z.fillRect(se.x,se.y,se.width,se.height),Z.fillStyle=tt.accentColor,Z.fillRect(se.x,se.y+se.height-2,se.width,2)),ue{const{ctx:Z,cell:ue,rect:se,col:tt,theme:pe}=H,De=tt-Nn;if(De>=0&&j&&ue.kind===ke.Text){const Me=O6(ue.data,c);if(Me!==null){Z.save();try{const Ve=`${pe.baseFontStyle} ${pe.fontFamily}`;Z.font=Ve;let dt=se.x+pe.cellHorizontalPadding;const An=se.y+se.height/2+Is(Z,Ve);for(const un of Me){const ct=Z.measureText(un.text).width;un.hit&&ct>0&&(Z.fillStyle=T,Z.fillRect(dt-1,An-7,ct+2,14)),dt+=ct}}finally{Z.restore()}}}if(V(),De>=0&&ue.kind===ke.Text&&ue.data===""){Z.save();try{Z.font=`${pe.baseFontStyle} ${pe.fontFamily}`,Z.fillStyle=pe.textLight,Z.fillText("—",se.x+pe.cellHorizontalPadding,se.y+se.height/2+.5)}finally{Z.restore()}}},[j,c,T]),_e=w.useCallback(H=>{const V=X.current[H];return V!==void 0&&g.current.has(V)?{bgCell:E,bgCellMedium:E}:void 0},[E]);return O===0?R.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):R.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:s,children:[R.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[R.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[R.jsx(fI,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),R.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:a,onChange:H=>u(H.target.value),onKeyDown:H=>{H.key==="Escape"&&M()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),a!==""&&R.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:M,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:R.jsx(L2,{"aria-hidden":"true",className:"size-3"})})]}),R.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:j?`${Q.length.toLocaleString()} of ${ne.toLocaleString()}`:`${ne.toLocaleString()} rows`}),nt&&R.jsxs("span",{className:"flex items-center gap-1.5",children:[R.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:ge.length>0?`${ge.length.toLocaleString()} selected`:`${Re.toLocaleString()} ${Re===1?"column":"columns"} selected`}),R.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Ze,className:wu,children:[R.jsx(wv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),b&&ge.length>0&&R.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:it,title:`Deletes the ${ge.length} selected ${ge.length===1?"row":"rows"} from the source CSV`,className:wu,children:[R.jsx(f0,{"aria-hidden":"true",className:"size-3"}),"Delete ",ge.length.toLocaleString()," ",ge.length===1?"row":"rows"]}),b&&Re>0&&R.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:rt,disabled:Ye,title:Ye?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Re} selected ${Re===1?"column":"columns"} from the source CSV`,className:`${wu} disabled:cursor-not-allowed disabled:opacity-50`,children:[R.jsx(f0,{"aria-hidden":"true",className:"size-3"}),"Delete ",Re.toLocaleString()," ",Re===1?"column":"columns"]}),R.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:W,className:wu,children:"Clear"})]})]}),R.jsxs("div",{ref:o,"data-testid":n,role:"grid","aria-rowcount":Q.length+1,className:"relative min-h-0 flex-1",style:{minHeight:Y},children:[R.jsx("div",{className:"absolute inset-0",children:R.jsx(OW,{imageWindowLoader:A.current,renderers:h6,columns:et,rows:Q.length,getCellContent:be,getCellsForSelection:Xe,onCellsEdited:b?Ie:void 0,onDelete:b?Dt:void 0,onCellClicked:qe,onHeaderClicked:F,onGridSelectionChange:B,onSelectionCleared:de,gridSelection:p,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:Ab,headerHeight:Rb,freezeColumns:Nn,fillHandle:b,onPaste:b?()=>!0:!1,keybindings:{search:!1},theme:C,drawHeader:Be,drawCell:ye,getRowThemeOverride:_e,minColumnWidth:Ob,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),j&&Q.length===0&&R.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[R.jsxs("span",{children:["No rows matching “",c,"”."]}),R.jsx("button",{type:"button",onClick:M,className:wu,children:"Show all rows"})]}),b&&!j&&Q.length===0&&R.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:R.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function O6(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=w.useRef(null);w.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return R.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3",children:R.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-3",children:[R.jsx("div",{"aria-hidden":"true",className:"flex size-11 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground",children:R.jsx(tI,{className:"size-5"})}),R.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),R.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=_6(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),R.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",R.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),R.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[R.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[R.jsx(N2,{"aria-hidden":"true"}),"Choose file"]}),R.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[R.jsx(dI,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let P0=[],aE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=aE[r])e=r+1;else return!0;if(e==n)return!1}}function _b(t){return t>=127462&&t<=127487}const Nb=8205;function F6(t,e,n=!0,r=!0){return(n?uE:B6)(t,e,r)}function uE(t,e,n){if(e==t.length)return e;e&&cE(t.charCodeAt(e))&&fE(t.charCodeAt(e-1))&&e--;let r=qg(t,e);for(e+=Lb(r);e=0&&_b(qg(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function B6(t,e,n){for(;e>1;){let r=uE(t,e-2,n);if(r=56320&&t<57344}function fE(t){return t>=55296&&t<56320}function Lb(t){return t<65536?1:2}class Ct{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Ta(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Ki.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Ta(this,e,n);let r=[];return this.decompose(e,n,r,0),Ki.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Qu(this),s=new Qu(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new Qu(this,e)}iterRange(e,n=this.length){return new hE(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new dE(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]?Ct.empty:e.length<=32?new gn(e):Ki.from(gn.split(e,[]))}}class gn extends Ct{constructor(e,n=z6(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new $6(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new gn(Fb(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Oh(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new gn(l,o.length+s.length));else{let a=l.length>>1;r.push(new gn(l.slice(0,a)),new gn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof gn))return super.replace(e,n,r);[e,n]=Ta(this,e,n);let i=Oh(this.text,Oh(r.text,Fb(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new gn(i,s):Ki.from(gn.split(i,[]),s)}sliceString(e,n=this.length,r=` `){[e,n]=Ta(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new gn(r,i)),r=[],i=-1);return i>-1&&n.push(new gn(r,i)),n}}class Ki extends Ct{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Ta(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new Ki(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` `){[e,n]=Ta(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Ki))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new gn(d,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof Ki)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(h(),l.push(d)):d instanceof gn&&a&&(p=c[c.length-1])instanceof gn&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new gn(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>i&&h(),a+=d.lines,u+=d.length+1,c.push(d))}function h(){a!=0&&(l.push(c.length==1?c[0]:Ki.from(c,u)),u=-1,a=c.length=0)}for(let d of e)f(d);return h(),l.length==1?l[0]:new Ki(l,n)}}Ct.empty=new gn([""],0);function z6(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Oh(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof gn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof gn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` diff --git a/app/dist/assets/number-overlay-editor-BQY5aYke.js b/app/dist/assets/number-overlay-editor-BELyYPco.js similarity index 99% rename from app/dist/assets/number-overlay-editor-BQY5aYke.js rename to app/dist/assets/number-overlay-editor-BELyYPco.js index 8574d9c..118ab54 100644 --- a/app/dist/assets/number-overlay-editor-BQY5aYke.js +++ b/app/dist/assets/number-overlay-editor-BELyYPco.js @@ -1,4 +1,4 @@ -import{s as Be,R as Y,r as O}from"./index-BIOflrBp.js";const Fe=Be("div")({name:"NumberOverlayEditorStyle",class:"gdg-n15fjm3e",propsAsIs:!1});function pe(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start - + diff --git a/app/src/components/CsvTable.test.tsx b/app/src/components/CsvTable.test.tsx index ace7b65..1bcd0fc 100644 --- a/app/src/components/CsvTable.test.tsx +++ b/app/src/components/CsvTable.test.tsx @@ -534,4 +534,9 @@ describe("CsvTable deletion actions (input table only)", () => { expect(screen.getByTestId("glide-grid-headers")).toHaveTextContent("#ALBUMYEAR"); expect(screen.getByTestId("csv-table-count")).toHaveTextContent("0 rows"); }); + + it("keeps the empty-rows overlay out of the read-only output table", () => { + render(); + expect(screen.queryByTestId("csv-table-empty-rows")).toBeNull(); + }); }); diff --git a/app/src/components/CsvTable.tsx b/app/src/components/CsvTable.tsx index ea448c3..2f81651 100644 --- a/app/src/components/CsvTable.tsx +++ b/app/src/components/CsvTable.tsx @@ -912,7 +912,10 @@ export function CsvTable({ text, delimiter, testId = "csv-table", dark = false,

)} - {!isFiltered && view.length === 0 && ( + {/* Input-pane guidance only — the read-only output pane accepts + neither paste nor upload, so headers-only output (what deleting + all input rows produces) shows no overlay at all. */} + {editable && !isFiltered && view.length === 0 && (
Date: Tue, 8 Sep 2026 04:27:40 +0000 Subject: [PATCH 3/3] test(table): pin the empty-rows gate with a headers-only fixture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The regression test used a 2-row fixture, so csv-table-empty-rows was absent under the ungated code too — reverting the editable gate would still pass. A headers-only fixture makes the ungated code render the overlay (verified: reverting the gate fails this test), and the output table keeps it absent only under the gate. --- app/src/components/CsvTable.test.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/components/CsvTable.test.tsx b/app/src/components/CsvTable.test.tsx index 1bcd0fc..a9352e6 100644 --- a/app/src/components/CsvTable.test.tsx +++ b/app/src/components/CsvTable.test.tsx @@ -536,7 +536,10 @@ describe("CsvTable deletion actions (input table only)", () => { }); it("keeps the empty-rows overlay out of the read-only output table", () => { - render(); + // Headers-only fixture: view.length === 0, so the ungated code WOULD + // render the overlay here — this pins the editable gate. + render(); + expect(screen.getByTestId("glide-grid-headers")).toHaveTextContent("#ALBUM"); expect(screen.queryByTestId("csv-table-empty-rows")).toBeNull(); }); });