@wecode-team/we0-cms 1.0.35 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -12,5 +12,5 @@ var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toS
|
|
|
12
12
|
*
|
|
13
13
|
* This source code is licensed under the ISC license.
|
|
14
14
|
* See the LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/const T=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),M=(e,t)=>{const i=n(({color:n="currentColor",size:i=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:a="",children:l,...c},h)=>r("svg",{ref:h,...A,width:i,height:i,stroke:n,strokeWidth:s?24*Number(o)/Number(i):o,className:["lucide",`lucide-${T(e)}`,a].join(" "),...c},[...t.map(([e,t])=>r(e,t)),...Array.isArray(l)?l:[l]]));return i.displayName=`${e}`,i},R=M("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),D=M("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),P=M("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),L=M("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),B=M("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),I=M("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),_=M("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),j=M("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),F=M("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),W=M("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),z=M("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),H=M("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),V=M("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),q=M("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),U=M("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),$=M("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]),K=M("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),Y=M("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),G=M("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),X=M("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),J=M("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Q=M("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]]),Z=M("Table",[["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"}]]),ee=M("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),te=M("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),ne=M("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),re=M("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var ie=function(){return ie=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ie.apply(this,arguments)};function oe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function se(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=se(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ae(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=se(e))&&(r&&(r+=" "),r+=t);return r}"function"==typeof SuppressedError&&SuppressedError;const le=e=>{const t=de(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),ce(n,t)||ue(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},ce=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?ce(e.slice(1),r):void 0;if(i)return i;if(0===t.validators.length)return;const o=e.join("-");return t.validators.find(({validator:e})=>e(o))?.classGroupId},he=/^\[(.+)\]$/,ue=e=>{if(he.test(e)){const t=he.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},de=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return ge(Object.entries(e.classGroups),n).forEach(([e,n])=>{fe(n,r,e,t)}),r},fe=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:pe(t,e)).classGroupId=n)}if("function"==typeof e)return me(e)?void fe(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{fe(i,pe(t,e),n,r)})})},pe=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},me=e=>e.isThemeGetter,ge=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,ve=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(i(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},be=e=>{const{separator:t,experimentalParseClassName:n}=e,r=1===t.length,i=t[0],o=t.length,s=e=>{const n=[];let s,a=0,l=0;for(let c=0;c<e.length;c++){let h=e[c];if(0===a){if(h===i&&(r||e.slice(c,c+o)===t)){n.push(e.slice(l,c)),l=c+o;continue}if("/"===h){s=c;continue}}"["===h?a++:"]"===h&&a--}const c=0===n.length?e:e.substring(l),h=c.startsWith("!");return{modifiers:n,hasImportantModifier:h,baseClassName:h?c.substring(1):c,maybePostfixModifierPosition:s&&s>l?s-l:void 0}};return n?e=>n({className:e,parseClassName:s}):s},ye=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(e=>{"["===e[0]?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},we=/\s+/;function xe(){let e,t,n=0,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=ke(e))&&(r&&(r+=" "),r+=t);return r}const ke=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=ke(e[r]))&&(n&&(n+=" "),n+=t);return n};function Se(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:ve(e.cacheSize),parseClassName:be(e),...le(e)}))(l),r=n.cache.get,i=n.cache.set,o=s,s(a)};function s(e){const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,o=[],s=e.trim().split(we);let a="";for(let e=s.length-1;e>=0;e-=1){const t=s[e],{modifiers:l,hasImportantModifier:c,baseClassName:h,maybePostfixModifierPosition:u}=n(t);let d=Boolean(u),f=r(d?h.substring(0,u):h);if(!f){if(!d){a=t+(a.length>0?" "+a:a);continue}if(f=r(h),!f){a=t+(a.length>0?" "+a:a);continue}d=!1}const p=ye(l).join(":"),m=c?p+"!":p,g=m+f;if(o.includes(g))continue;o.push(g);const v=i(f,d);for(let e=0;e<v.length;++e){const t=v[e];o.push(m+t)}a=t+(a.length>0?" "+a:a)}return a})(e,n);return i(e,o),o}return function(){return o(xe.apply(null,arguments))}}const Ee=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},Ce=/^\[(?:([a-z-]+):)?(.+)\]$/i,Ne=/^\d+\/\d+$/,Oe=new Set(["px","full","screen"]),Ae=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Te=/\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$/,Me=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Re=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,De=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pe=e=>Be(e)||Oe.has(e)||Ne.test(e),Le=e=>Ye(e,"length",Ge),Be=e=>Boolean(e)&&!Number.isNaN(Number(e)),Ie=e=>Ye(e,"number",Be),_e=e=>Boolean(e)&&Number.isInteger(Number(e)),je=e=>e.endsWith("%")&&Be(e.slice(0,-1)),Fe=e=>Ce.test(e),We=e=>Ae.test(e),ze=new Set(["length","size","percentage"]),He=e=>Ye(e,ze,Xe),Ve=e=>Ye(e,"position",Xe),qe=new Set(["image","url"]),Ue=e=>Ye(e,qe,Qe),$e=e=>Ye(e,"",Je),Ke=()=>!0,Ye=(e,t,n)=>{const r=Ce.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},Ge=e=>Te.test(e)&&!Me.test(e),Xe=()=>!1,Je=e=>Re.test(e),Qe=e=>De.test(e),Ze=Se(()=>{const e=Ee("colors"),t=Ee("spacing"),n=Ee("blur"),r=Ee("brightness"),i=Ee("borderColor"),o=Ee("borderRadius"),s=Ee("borderSpacing"),a=Ee("borderWidth"),l=Ee("contrast"),c=Ee("grayscale"),h=Ee("hueRotate"),u=Ee("invert"),d=Ee("gap"),f=Ee("gradientColorStops"),p=Ee("gradientColorStopPositions"),m=Ee("inset"),g=Ee("margin"),v=Ee("opacity"),b=Ee("padding"),y=Ee("saturate"),w=Ee("scale"),x=Ee("sepia"),k=Ee("skew"),S=Ee("space"),E=Ee("translate"),C=()=>["auto",Fe,t],N=()=>[Fe,t],O=()=>["",Pe,Le],A=()=>["auto",Be,Fe],T=()=>["","0",Fe],M=()=>[Be,Fe];return{cacheSize:500,separator:":",theme:{colors:[Ke],spacing:[Pe,Le],blur:["none","",We,Fe],brightness:M(),borderColor:[e],borderRadius:["none","","full",We,Fe],borderSpacing:N(),borderWidth:O(),contrast:M(),grayscale:T(),hueRotate:M(),invert:T(),gap:N(),gradientColorStops:[e],gradientColorStopPositions:[je,Le],inset:C(),margin:C(),opacity:M(),padding:N(),saturate:M(),scale:M(),sepia:T(),skew:M(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",Fe]}],container:["container"],columns:[{columns:[We]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"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:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Fe]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],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",_e,Fe]}],basis:[{basis:C()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Fe]}],grow:[{grow:T()}],shrink:[{shrink:T()}],order:[{order:["first","last","none",_e,Fe]}],"grid-cols":[{"grid-cols":[Ke]}],"col-start-end":[{col:["auto",{span:["full",_e,Fe]},Fe]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[Ke]}],"row-start-end":[{row:["auto",{span:[_e,Fe]},Fe]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Fe]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Fe]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Fe,t]}],"min-w":[{"min-w":[Fe,t,"min","max","fit"]}],"max-w":[{"max-w":[Fe,t,"none","full","min","max","fit","prose",{screen:[We]},We]}],h:[{h:[Fe,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Fe,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Fe,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Fe,t,"auto","min","max","fit"]}],"font-size":[{text:["base",We,Le]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ie]}],"font-family":[{font:[Ke]}],"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",Fe]}],"line-clamp":[{"line-clamp":["none",Be,Ie]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Pe,Fe]}],"list-image":[{"list-image":["none",Fe]}],"list-style-type":[{list:["none","disc","decimal",Fe]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Pe,Le]}],"underline-offset":[{"underline-offset":["auto",Pe,Fe]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Fe]}],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",Fe]}],"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:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Ve]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",He]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Ue]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"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:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[Pe,Fe]}],"outline-w":[{outline:[Pe,Le]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:O()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Pe,Le]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",We,$e]}],"shadow-color":[{shadow:[Ke]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",We,Fe]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[u]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Fe]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",Fe]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",Fe]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[_e,Fe]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Fe]}],accent:[{accent:["auto",e]}],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",Fe]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"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",Fe]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Pe,Le,Ie]}],stroke:[{stroke:[e,"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"]}}});function et(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ze(ae(t))}function tt(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("animate-pulse rounded-md bg-muted",n)},r))}function nt(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function rt(...e){return t=>{let n=!1;const r=e.map(e=>{const r=nt(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():nt(e[t],null)}}}}function it(...t){return e.useCallback(rt(...t),t)}var ot=Symbol.for("react.lazy"),st=e[" use ".trim().toString()];function at(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===ot&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function lt(t){const n=ht(t),r=e.forwardRef((t,r)=>{let{children:i,...o}=t;at(i)&&"function"==typeof st&&(i=st(i._payload));const s=e.Children.toArray(i),a=s.find(dt);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}var ct=lt("Slot");function ht(t){const n=e.forwardRef((t,n)=>{let{children:r,...i}=t;if(at(r)&&"function"==typeof st&&(r=st(r._payload)),e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var ut=Symbol("radix.slottable");function dt(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===ut}const ft=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,pt=ae,mt=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return pt(e,null==n?void 0:n.class,null==n?void 0:n.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(e=>{const t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;const s=ft(t)||ft(r);return i[e][s]}),a=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{}),l=null==t||null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:n,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...o,...a}[t]):{...o,...a}[t]===n})?[...e,n,r]:e},[]);return pt(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var gt=mt("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),vt=e.forwardRef(function(t,n){var r=t.className,i=t.variant,o=t.size,s=t.asChild,a=void 0!==s&&s,l=oe(t,["className","variant","size","asChild"]),c=a?ct:"button";return e.createElement(c,Object.assign({className:et(gt({variant:i,size:o,className:r})),ref:n},l))});vt.displayName="Button";var bt=e.forwardRef(function(t,n){var r=t.className,i=t.type,o=oe(t,["className","type"]);return e.createElement("input",Object.assign({type:i,className:et("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:n},o))});bt.displayName="Input";var yt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=lt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),wt="horizontal",xt=["horizontal","vertical"],kt=e.forwardRef((e,t)=>{const{decorative:n,orientation:r=wt,...i}=e,o=function(e){return xt.includes(e)}(r)?r:wt,s=n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"};return u(yt.div,{"data-orientation":o,...s,...i,ref:t})});kt.displayName="Separator";var St=kt,Et=e.forwardRef(function(t,n){var r=t.className,i=t.orientation,o=void 0===i?"horizontal":i,s=t.decorative,a=void 0===s||s,l=oe(t,["className","orientation","decorative"]);return e.createElement(St,Object.assign({ref:n,decorative:a,orientation:o,className:et("shrink-0 bg-border","horizontal"===o?"h-[1px] w-full":"h-full w-[1px]",r)},l))});function Ct(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Nt(t,n=[]){let r=[];const i=()=>{const n=r.map(t=>e.createContext(t));return function(r){const i=r?.[t]||n;return e.useMemo(()=>({[`__scope${t}`]:{...r,[t]:i}}),[r,i])}};return i.scopeName=t,[function(n,i){const o=e.createContext(i),s=r.length;r=[...r,i];const a=n=>{const{scope:r,children:i,...a}=n,l=r?.[t]?.[s]||o,c=e.useMemo(()=>a,Object.values(a));return u(l.Provider,{value:c,children:i})};return a.displayName=n+"Provider",[a,function(r,a){const l=a?.[t]?.[s]||o,c=e.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},Ot(i,...n)]}function Ot(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const i=r.reduce((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]}),{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return r.scopeName=n.scopeName,r}Et.displayName=St.displayName;var At=globalThis?.document?e.useLayoutEffect:()=>{},Tt=e[" useId ".trim().toString()]||(()=>{}),Mt=0;function Rt(t){const[n,r]=e.useState(Tt());return At(()=>{t||r(e=>e??String(Mt++))},[t]),t||(n?`radix-${n}`:"")}var Dt=e[" useInsertionEffect ".trim().toString()]||At;function Pt({prop:t,defaultProp:n,onChange:r=()=>{},caller:i}){const[o,s,a]=function({defaultProp:t,onChange:n}){const[r,i]=e.useState(t),o=e.useRef(r),s=e.useRef(n);return Dt(()=>{s.current=n},[n]),e.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,i,s]}({defaultProp:n,onChange:r}),l=void 0!==t,c=l?t:o;{const n=e.useRef(void 0!==t);e.useEffect(()=>{const e=n.current;if(e!==l){}n.current=l},[l,i])}const h=e.useCallback(e=>{if(l){const n=function(e){return"function"==typeof e}(e)?e(t):e;n!==t&&a.current?.(n)}else s(e)},[l,t,s,a]);return[c,h]}function Lt(t){const n=Bt(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(_t);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function Bt(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var It=Symbol("radix.slottable");function _t(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===It}var jt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=Lt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});function Ft(t){const n=e.useRef(t);return e.useEffect(()=>{n.current=t}),e.useMemo(()=>(...e)=>n.current?.(...e),[])}function Wt(t,n=globalThis?.document){const r=Ft(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&r(e)};return n.addEventListener("keydown",e,{capture:!0}),()=>n.removeEventListener("keydown",e,{capture:!0})},[r,n])}var zt,Ht="dismissableLayer.update",Vt="dismissableLayer.pointerDownOutside",qt="dismissableLayer.focusOutside",Ut=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),$t=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,h=e.useContext(Ut),[d,f]=e.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=it(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){Yt(Vt,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){Yt(qt,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Wt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(zt=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),Kt(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=zt)}},[d,p,r,h]),e.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),Kt())},[d,h]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(Ht,e),()=>document.removeEventListener(Ht,e)},[]),u(jt.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Ct(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Ct(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ct(t.onPointerDownCapture,S.onPointerDownCapture)})});$t.displayName="DismissableLayer";function Kt(){const e=new CustomEvent(Ht);document.dispatchEvent(e)}function Yt(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(Ut),i=e.useRef(null),o=it(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),u(jt.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var Gt="focusScope.autoFocusOnMount",Xt="focusScope.autoFocusOnUnmount",Jt={bubbles:!1,cancelable:!0},Qt=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),h=Ft(o),d=Ft(s),f=e.useRef(null),p=it(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?f.current=t:nn(f.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||nn(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&nn(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){rn.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(Gt,Jt);l.addEventListener(Gt,h),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(nn(r,{select:t}),document.activeElement!==n)return}((e=Zt(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&nn(l))}return()=>{l.removeEventListener(Gt,h),setTimeout(()=>{const e=new CustomEvent(Xt,Jt);l.addEventListener(Xt,d),l.dispatchEvent(e),e.defaultPrevented||nn(t??document.body,{select:!0}),l.removeEventListener(Xt,d),rn.remove(m)},0)}}var e},[l,h,d,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Zt(e),n=en(t,e),r=en(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&nn(o,{select:!0})):(e.preventDefault(),r&&nn(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return u(jt.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function Zt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function en(e,t){for(const n of e)if(!tn(n,{upTo:t}))return n}function tn(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function nn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Qt.displayName="FocusScope";var rn=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=on(e,t),e.unshift(t)},remove(t){e=on(e,t),e[0]?.resume()}}}();function on(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var sn=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);At(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?m.createPortal(u(jt.div,{...i,ref:n}),a):null});sn.displayName="Portal";var an=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=ln(i.current);s.current="mounted"===l?e:"none"},[l]),At(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=ln(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),At(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=ln(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=ln(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=it(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function ln(e){return e?.animationName||"none"}an.displayName="Presence";var cn=0;function hn(){e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??un()),document.body.insertAdjacentElement("beforeend",e[1]??un()),cn++,()=>{1===cn&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),cn--}},[])}function un(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var dn="right-scroll-bar-position",fn="width-before-scroll-bar";function pn(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var mn="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,gn=new WeakMap;function vn(e,t){var n,r,o,s=(n=t||null,r=function(t){return e.forEach(function(e){return pn(e,t)})},(o=i(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return mn(function(){var t=gn.get(s);if(t){var n=new Set(t),r=new Set(e),i=s.current;n.forEach(function(e){r.has(e)||pn(e,null)}),r.forEach(function(e){n.has(e)||pn(e,i)})}gn.set(s,e)},[e]),s}function bn(e){return e}var yn=function(t){var n=t.sideCar,r=oe(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=n.read();if(!i)throw new Error("Sidecar medium not found");return e.createElement(i,ie({},r))};yn.isSideCarExport=!0;var wn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=bn);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var o=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(o)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=ie({async:!0,ssr:!1},e),t}(),xn=function(){},kn=e.forwardRef(function(t,n){var r=e.useRef(null),i=e.useState({onScrollCapture:xn,onWheelCapture:xn,onTouchMoveCapture:xn}),o=i[0],s=i[1],a=t.forwardProps,l=t.children,c=t.className,h=t.removeScrollBar,u=t.enabled,d=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,b=t.as,y=void 0===b?"div":b,w=t.gapMode,x=oe(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=vn([r,n]),E=ie(ie({},x),o);return e.createElement(e.Fragment,null,u&&e.createElement(k,{sideCar:wn,removeScrollBar:h,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:r,gapMode:w}),a?e.cloneElement(e.Children.only(l),ie(ie({},E),{ref:S})):e.createElement(y,ie({},E,{className:c,ref:S}),l))});kn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},kn.classNames={fullWidth:fn,zeroRight:dn};function Sn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var En=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=Sn())&&(i=n,(r=t).styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cn=function(){var t,n=(t=En(),function(n,r){e.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&r])});return function(e){var t=e.styles,r=e.dynamic;return n(t,r),null}},Nn={left:0,top:0,right:0,gap:0},On=function(e){return parseInt(e||"",10)||0},An=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Nn;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],i=t["padding"===e?"paddingRight":"marginRight"];return[On(n),On(r),On(i)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Tn=Cn(),Mn="data-scroll-locked",Rn=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(a,"px ").concat(r,";\n }\n body[").concat(Mn,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(a,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(dn," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(fn," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(dn," .").concat(dn," {\n right: 0 ").concat(r,";\n }\n \n .").concat(fn," .").concat(fn," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(Mn,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},Dn=function(){var e=parseInt(document.body.getAttribute(Mn)||"0",10);return isFinite(e)?e:0},Pn=function(t){var n=t.noRelative,r=t.noImportant,i=t.gapMode,o=void 0===i?"margin":i;e.useEffect(function(){return document.body.setAttribute(Mn,(Dn()+1).toString()),function(){var e=Dn()-1;e<=0?document.body.removeAttribute(Mn):document.body.setAttribute(Mn,e.toString())}},[]);var s=e.useMemo(function(){return An(o)},[o]);return e.createElement(Tn,{styles:Rn(s,!n,o,r?"":"!important")})},Ln=!1;if("undefined"!=typeof window)try{var Bn=Object.defineProperty({},"passive",{get:function(){return Ln=!0,!0}});window.addEventListener("test",Bn,Bn),window.removeEventListener("test",Bn,Bn)}catch(e){Ln=!1}var In=!!Ln&&{passive:!1},_n=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},jn=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),Fn(e,r)){var i=Wn(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Fn=function(e,t){return"v"===e?function(e){return _n(e,"overflowY")}(t):function(e){return _n(e,"overflowX")}(t)},Wn=function(e,t){return"v"===e?function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]}(t):function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t)},zn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Hn=function(e){return[e.deltaX,e.deltaY]},Vn=function(e){return e&&"current"in e?e.current:e},qn=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Un=0,$n=[];function Kn(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Yn,Gn=(Yn=function(t){var n=e.useRef([]),r=e.useRef([0,0]),i=e.useRef(),o=e.useState(Un++)[0],s=e.useState(Cn)[0],a=e.useRef(t);e.useEffect(function(){a.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var e=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(Vn),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var n,o=zn(e),s=r.current,l="deltaX"in e?e.deltaX:s[0]-o[0],c="deltaY"in e?e.deltaY:s[1]-o[1],h=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===h.type)return!1;var d=window.getSelection(),f=d&&d.anchorNode;if(f&&(f===h||f.contains(h)))return!1;var p=jn(u,h);if(!p)return!0;if(p?n=u:(n="v"===u?"h":"v",p=jn(u,h)),!p)return!1;if(!i.current&&"changedTouches"in e&&(l||c)&&(i.current=n),!n)return!0;var m=i.current||n;return function(e,t,n,r,i){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),c=!1,h=s>0,u=0,d=0;do{if(!a)break;var f=Wn(e,a),p=f[0],m=f[1]-f[2]-o*p;(p||m)&&Fn(e,a)&&(u+=m,d+=p);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(h&&(i&&Math.abs(u)<1||!i&&s>u)||!h&&(i&&Math.abs(d)<1||!i&&-s>d))&&(c=!0),c}(m,t,e,"h"===m?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if($n.length&&$n[$n.length-1]===s){var r="deltaY"in t?Hn(t):zn(t),i=n.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&(n=e.delta,i=r,n[0]===i[0]&&n[1]===i[1]);var n,i})[0];if(i&&i.should)t.cancelable&&t.preventDefault();else if(!i){var o=(a.current.shards||[]).map(Vn).filter(Boolean).filter(function(e){return e.contains(t.target)});(o.length>0?l(t,o[0]):!a.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),h=e.useCallback(function(e,t,r,i){var o={name:e,delta:t,target:r,should:i,shadowParent:Kn(r)};n.current.push(o),setTimeout(function(){n.current=n.current.filter(function(e){return e!==o})},1)},[]),u=e.useCallback(function(e){r.current=zn(e),i.current=void 0},[]),d=e.useCallback(function(e){h(e.type,Hn(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){h(e.type,zn(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return $n.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,In),document.addEventListener("touchmove",c,In),document.addEventListener("touchstart",u,In),function(){$n=$n.filter(function(e){return e!==s}),document.removeEventListener("wheel",c,In),document.removeEventListener("touchmove",c,In),document.removeEventListener("touchstart",u,In)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(s,{styles:qn(o)}):null,p?e.createElement(Pn,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},wn.useMedium(Yn),yn),Xn=e.forwardRef(function(t,n){return e.createElement(kn,ie({},t,{ref:n,sideCar:Gn}))});Xn.classNames=kn.classNames;var Jn=Xn,Qn=new WeakMap,Zn=new WeakMap,er={},tr=0,nr=function(e){return e&&(e.host||nr(e.parentNode))},rr=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=nr(t);return n&&e.contains(n)?n:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);er[n]||(er[n]=new WeakMap);var o=er[n],s=[],a=new Set,l=new Set(i),c=function(e){e&&!a.has(e)&&(a.add(e),c(e.parentNode))};i.forEach(c);var h=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(a.has(e))h(e);else try{var t=e.getAttribute(r),i=null!==t&&"false"!==t,l=(Qn.get(e)||0)+1,c=(o.get(e)||0)+1;Qn.set(e,l),o.set(e,c),s.push(e),1===l&&i&&Zn.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return h(t),a.clear(),tr++,function(){s.forEach(function(e){var t=Qn.get(e)-1,i=o.get(e)-1;Qn.set(e,t),o.set(e,i),t||(Zn.has(e)||e.removeAttribute(r),Zn.delete(e)),i||e.removeAttribute(n)}),--tr||(Qn=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,er={})}},ir=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),rr(r,i,n,"aria-hidden")):function(){return null}},or="Dialog",[sr,ar]=Nt(or),[lr,cr]=sr(or),hr=t=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=t,l=e.useRef(null),c=e.useRef(null),[h,d]=Pt({prop:i,defaultProp:o??!1,onChange:s,caller:or});return u(lr,{scope:n,triggerRef:l,contentRef:c,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:h,onOpenChange:d,onOpenToggle:e.useCallback(()=>d(e=>!e),[d]),modal:a,children:r})};hr.displayName=or;var ur="DialogTrigger",dr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(ur,n),o=it(t,i.triggerRef);return u(jt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Dr(i.open),...r,ref:o,onClick:Ct(e.onClick,i.onOpenToggle)})});dr.displayName=ur;var fr="DialogPortal",[pr,mr]=sr(fr,{forceMount:void 0}),gr=t=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=t,s=cr(fr,n);return u(pr,{scope:n,forceMount:r,children:e.Children.map(i,e=>u(an,{present:r||s.open,children:u(sn,{asChild:!0,container:o,children:e})}))})};gr.displayName=fr;var vr="DialogOverlay",br=e.forwardRef((e,t)=>{const n=mr(vr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=cr(vr,e.__scopeDialog);return o.modal?u(an,{present:r||o.open,children:u(wr,{...i,ref:t})}):null});br.displayName=vr;var yr=Lt("DialogOverlay.RemoveScroll"),wr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(vr,n);return u(Jn,{as:yr,allowPinchZoom:!0,shards:[i.contentRef],children:u(jt.div,{"data-state":Dr(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),xr="DialogContent",kr=e.forwardRef((e,t)=>{const n=mr(xr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=cr(xr,e.__scopeDialog);return u(an,{present:r||o.open,children:o.modal?u(Sr,{...i,ref:t}):u(Er,{...i,ref:t})})});kr.displayName=xr;var Sr=e.forwardRef((t,n)=>{const r=cr(xr,t.__scopeDialog),i=e.useRef(null),o=it(n,r.contentRef,i);return e.useEffect(()=>{const e=i.current;if(e)return ir(e)},[]),u(Cr,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ct(t.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Ct(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:Ct(t.onFocusOutside,e=>e.preventDefault())})}),Er=e.forwardRef((t,n)=>{const r=cr(xr,t.__scopeDialog),i=e.useRef(!1),o=e.useRef(!1);return u(Cr,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(i.current||r.triggerRef.current?.focus(),e.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(i.current=!0,"pointerdown"===e.detail.originalEvent.type&&(o.current=!0));const n=e.target,s=r.triggerRef.current?.contains(n);s&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&o.current&&e.preventDefault()}})}),Cr=e.forwardRef((t,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=t,l=cr(xr,r),c=e.useRef(null),h=it(n,c);return hn(),d(f,{children:[u(Qt,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u($t,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Dr(l.open),...a,ref:h,onDismiss:()=>l.onOpenChange(!1)})}),d(f,{children:[u(Ir,{titleId:l.titleId}),u(_r,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Nr="DialogTitle",Or=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(Nr,n);return u(jt.h2,{id:i.titleId,...r,ref:t})});Or.displayName=Nr;var Ar="DialogDescription",Tr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(Ar,n);return u(jt.p,{id:i.descriptionId,...r,ref:t})});Tr.displayName=Ar;var Mr="DialogClose",Rr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(Mr,n);return u(jt.button,{type:"button",...r,ref:t,onClick:Ct(e.onClick,()=>i.onOpenChange(!1))})});function Dr(e){return e?"open":"closed"}Rr.displayName=Mr;var Pr="DialogTitleWarning",[Lr,Br]=function(t,n){const r=e.createContext(n),i=t=>{const{children:n,...i}=t,o=e.useMemo(()=>i,Object.values(i));return u(r.Provider,{value:o,children:n})};return i.displayName=t+"Provider",[i,function(i){const o=e.useContext(r);if(o)return o;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${t}\``)}]}(Pr,{contentName:xr,titleName:Nr,docsSlug:"dialog"}),Ir=({titleId:t})=>{const n=Br(Pr),r=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)}},[r,t]),null},_r=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Br("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(n&&e){document.getElementById(n)}},[r,t,n]),null},jr=hr,Fr=dr,Wr=gr,zr=br,Hr=kr,Vr=Or,qr=Tr,Ur=Rr,$r=jr,Kr=Wr,Yr=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(zr,Object.assign({className:et("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i,{ref:n}))});Yr.displayName=zr.displayName;var Gr=mt("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Xr=e.forwardRef(function(t,n){var r=t.side,i=void 0===r?"right":r,o=t.className,s=t.children,a=oe(t,["side","className","children"]);return e.createElement(Kr,null,e.createElement(Yr,null),e.createElement(Hr,Object.assign({ref:n,className:et(Gr({side:i}),o)},a),s,e.createElement(Ur,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"},e.createElement(re,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});Xr.displayName=Hr.displayName;var Jr=function(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col space-y-2 text-center sm:text-left",n)},r))};Jr.displayName="SheetHeader";var Qr=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Vr,Object.assign({ref:n,className:et("text-lg font-semibold text-foreground",r)},i))});Qr.displayName=Vr.displayName;var Zr=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(qr,Object.assign({ref:n,className:et("text-sm text-muted-foreground",r)},i))});function ei(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}Zr.displayName=qr.displayName;var ti=Symbol("radix.slottable");function ni(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===ti}var ri=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=function(t){const n=ei(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(ni);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});var ii,oi="dismissableLayer.update",si="dismissableLayer.pointerDownOutside",ai="dismissableLayer.focusOutside",li=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ci=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,h=e.useContext(li),[d,f]=e.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=it(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){ui(si,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){ui(ai,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Wt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(ii=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),hi(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=ii)}},[d,p,r,h]),e.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),hi())},[d,h]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(oi,e),()=>document.removeEventListener(oi,e)},[]),u(ri.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Ct(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Ct(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ct(t.onPointerDownCapture,S.onPointerDownCapture)})});ci.displayName="DismissableLayer";function hi(){const e=new CustomEvent(oi);document.dispatchEvent(e)}function ui(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(li),i=e.useRef(null),o=it(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),u(ri.div,{...t,ref:o})}).displayName="DismissableLayerBranch";const di=["top","right","bottom","left"],fi=Math.min,pi=Math.max,mi=Math.round,gi=Math.floor,vi=e=>({x:e,y:e}),bi={left:"right",right:"left",bottom:"top",top:"bottom"},yi={start:"end",end:"start"};function wi(e,t,n){return pi(e,fi(t,n))}function xi(e,t){return"function"==typeof e?e(t):e}function ki(e){return e.split("-")[0]}function Si(e){return e.split("-")[1]}function Ei(e){return"x"===e?"y":"x"}function Ci(e){return"y"===e?"height":"width"}const Ni=new Set(["top","bottom"]);function Oi(e){return Ni.has(ki(e))?"y":"x"}function Ai(e){return Ei(Oi(e))}function Ti(e){return e.replace(/start|end/g,e=>yi[e])}const Mi=["left","right"],Ri=["right","left"],Di=["top","bottom"],Pi=["bottom","top"];function Li(e,t,n,r){const i=Si(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?Ri:Mi:t?Mi:Ri;case"left":case"right":return t?Di:Pi;default:return[]}}(ki(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(Ti)))),o}function Bi(e){return e.replace(/left|right|bottom|top/g,e=>bi[e])}function Ii(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function _i(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ji(e,t,n){let{reference:r,floating:i}=e;const o=Oi(t),s=Ai(t),a=Ci(s),l=ki(t),c="y"===o,h=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let f;switch(l){case"top":f={x:h,y:r.y-i.height};break;case"bottom":f={x:h,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-i.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Si(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function Fi(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:d=!1,padding:f=0}=xi(t,e),p=Ii(f),m=a[d?"floating"===u?"reference":"floating":u],g=_i(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:h,strategy:l})),v="floating"===u?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,b=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),y=await(null==o.isElement?void 0:o.isElement(b))&&await(null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},w=_i(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(g.top-w.top+p.top)/y.y,bottom:(w.bottom-g.bottom+p.bottom)/y.y,left:(g.left-w.left+p.left)/y.x,right:(w.right-g.right+p.right)/y.x}}function Wi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function zi(e){return di.some(t=>e[t]>=0)}const Hi=new Set(["left","top"]);function Vi(){return"undefined"!=typeof window}function qi(e){return Ki(e)?(e.nodeName||"").toLowerCase():"#document"}function Ui(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function $i(e){var t;return null==(t=(Ki(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Ki(e){return!!Vi()&&(e instanceof Node||e instanceof Ui(e).Node)}function Yi(e){return!!Vi()&&(e instanceof Element||e instanceof Ui(e).Element)}function Gi(e){return!!Vi()&&(e instanceof HTMLElement||e instanceof Ui(e).HTMLElement)}function Xi(e){return!(!Vi()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Ui(e).ShadowRoot)}const Ji=new Set(["inline","contents"]);function Qi(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=ho(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ji.has(i)}const Zi=new Set(["table","td","th"]);function eo(e){return Zi.has(qi(e))}const to=[":popover-open",":modal"];function no(e){return to.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const ro=["transform","translate","scale","rotate","perspective"],io=["transform","translate","scale","rotate","perspective","filter"],oo=["paint","layout","strict","content"];function so(e){const t=ao(),n=Yi(e)?ho(e):e;return ro.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||io.some(e=>(n.willChange||"").includes(e))||oo.some(e=>(n.contain||"").includes(e))}function ao(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const lo=new Set(["html","body","#document"]);function co(e){return lo.has(qi(e))}function ho(e){return Ui(e).getComputedStyle(e)}function uo(e){return Yi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function fo(e){if("html"===qi(e))return e;const t=e.assignedSlot||e.parentNode||Xi(e)&&e.host||$i(e);return Xi(t)?t.host:t}function po(e){const t=fo(e);return co(t)?e.ownerDocument?e.ownerDocument.body:e.body:Gi(t)&&Qi(t)?t:po(t)}function mo(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=po(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Ui(i);if(o){const e=go(s);return t.concat(s,s.visualViewport||[],Qi(i)?i:[],e&&n?mo(e):[])}return t.concat(i,mo(i,[],n))}function go(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vo(e){const t=ho(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Gi(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=mi(n)!==o||mi(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function bo(e){return Yi(e)?e:e.contextElement}function yo(e){const t=bo(e);if(!Gi(t))return vi(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=vo(t);let s=(o?mi(n.width):n.width)/r,a=(o?mi(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const wo=vi(0);function xo(e){const t=Ui(e);return ao()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:wo}function ko(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=bo(e);let s=vi(1);t&&(r?Yi(r)&&(s=yo(r)):s=yo(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Ui(e))&&t}(o,n,r)?xo(o):vi(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,h=i.width/s.x,u=i.height/s.y;if(o){const e=Ui(o),t=r&&Yi(r)?Ui(r):r;let n=e,i=go(n);for(;i&&r&&t!==n;){const e=yo(i),t=i.getBoundingClientRect(),r=ho(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,h*=e.x,u*=e.y,l+=o,c+=s,n=Ui(i),i=go(n)}}return _i({width:h,height:u,x:l,y:c})}function So(e,t){const n=uo(e).scrollLeft;return t?t.left+n:ko($i(e)).left+n}function Eo(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-So(e,n),y:n.top+t.scrollTop}}const Co=new Set(["absolute","fixed"]);function No(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Ui(e),r=$i(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=ao();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}const c=So(r);if(c<=0){const e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,s=Math.abs(r.clientWidth-t.clientWidth-i);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=$i(e),n=uo(e),r=e.ownerDocument.body,i=pi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=pi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+So(e);const a=-n.scrollTop;return"rtl"===ho(r).direction&&(s+=pi(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}($i(e));else if(Yi(t))r=function(e,t){const n=ko(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Gi(e)?yo(e):vi(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=xo(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _i(r)}function Oo(e,t){const n=fo(e);return!(n===t||!Yi(n)||co(n))&&("fixed"===ho(n).position||Oo(n,t))}function Ao(e,t,n){const r=Gi(t),i=$i(t),o="fixed"===n,s=ko(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=vi(0);function c(){l.x=So(i)}if(r||!r&&!o)if(("body"!==qi(t)||Qi(i))&&(a=uo(t)),r){const e=ko(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const h=!i||r||o?vi(0):Eo(i,a);return{x:s.left+a.scrollLeft-l.x-h.x,y:s.top+a.scrollTop-l.y-h.y,width:s.width,height:s.height}}function To(e){return"static"===ho(e).position}function Mo(e,t){if(!Gi(e)||"fixed"===ho(e).position)return null;if(t)return t(e);let n=e.offsetParent;return $i(e)===n&&(n=n.ownerDocument.body),n}function Ro(e,t){const n=Ui(e);if(no(e))return n;if(!Gi(e)){let t=fo(e);for(;t&&!co(t);){if(Yi(t)&&!To(t))return t;t=fo(t)}return n}let r=Mo(e,t);for(;r&&eo(r)&&To(r);)r=Mo(r,t);return r&&co(r)&&To(r)&&!so(r)?n:r||function(e){let t=fo(e);for(;Gi(t)&&!co(t);){if(so(t))return t;if(no(t))return null;t=fo(t)}return null}(e)||n}const Do={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=$i(r),a=!!t&&no(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=vi(1);const h=vi(0),u=Gi(r);if((u||!u&&!o)&&(("body"!==qi(r)||Qi(s))&&(l=uo(r)),Gi(r))){const e=ko(r);c=yo(r),h.x=e.x+r.clientLeft,h.y=e.y+r.clientTop}const d=!s||u||o?vi(0):Eo(s,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+h.x+d.x,y:n.y*c.y-l.scrollTop*c.y+h.y+d.y}},getDocumentElement:$i,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?no(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=mo(e,[],!1).filter(e=>Yi(e)&&"body"!==qi(e)),i=null;const o="fixed"===ho(e).position;let s=o?fo(e):e;for(;Yi(s)&&!co(s);){const t=ho(s),n=so(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&Co.has(i.position)||Qi(s)&&!n&&Oo(e,s))?r=r.filter(e=>e!==s):i=t,s=fo(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((e,n)=>{const r=No(t,n,i);return e.top=pi(r.top,e.top),e.right=fi(r.right,e.right),e.bottom=fi(r.bottom,e.bottom),e.left=pi(r.left,e.left),e},No(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Ro,getElementRects:async function(e){const t=this.getOffsetParent||Ro,n=this.getDimensions,r=await n(e.floating);return{reference:Ao(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=vo(e);return{width:t,height:n}},getScale:yo,isElement:Yi,isRTL:function(e){return"rtl"===ho(e).direction}};function Po(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Lo(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=bo(e),h=i||o?[...c?mo(c):[],...mo(t)]:[];h.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)});const u=c&&a?function(e,t){let n,r=null;const i=$i(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:h,top:u,width:d,height:f}=c;if(a||t(),!d||!f)return;const p={rootMargin:-gi(u)+"px "+-gi(i.clientWidth-(h+d))+"px "+-gi(i.clientHeight-(u+f))+"px "+-gi(h)+"px",threshold:pi(0,fi(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==r||Po(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let d,f=-1,p=null;s&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m=l?ko(e):null;return l&&function t(){const r=ko(e);m&&!Po(m,r)&&n();m=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;h.forEach(e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)}),null==u||u(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}const Bo=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=ki(n),a=Si(n),l="y"===Oi(n),c=Hi.has(s)?-1:1,h=o&&l?-1:1,u=xi(t,e);let{mainAxis:d,crossAxis:f,alignmentAxis:p}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof p&&(f="end"===a?-1*p:p),l?{x:f*h,y:d*c}:{x:d*c,y:f*h}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Io=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=xi(e,t),c={x:n,y:r},h=await Fi(t,l),u=Oi(ki(i)),d=Ei(u);let f=c[d],p=c[u];if(o){const e="y"===d?"bottom":"right";f=wi(f+h["y"===d?"top":"left"],f,f-h[e])}if(s){const e="y"===u?"bottom":"right";p=wi(p+h["y"===u?"top":"left"],p,p-h[e])}const m=a.fn({...t,[d]:f,[u]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[d]:o,[u]:s}}}}}},_o=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=xi(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=ki(i),b=Oi(a),y=ki(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),x=d||(y||!m?[Bi(a)]:function(e){const t=Bi(e);return[Ti(e),t,Ti(t)]}(a)),k="none"!==p;!d&&k&&x.push(...Li(a,m,p,w));const S=[a,...x],E=await Fi(t,g),C=[];let N=(null==(r=o.flip)?void 0:r.overflows)||[];if(h&&C.push(E[v]),u){const e=function(e,t,n){void 0===n&&(n=!1);const r=Si(e),i=Ai(e),o=Ci(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Bi(s)),[s,Bi(s)]}(i,s,w);C.push(E[e[0]],E[e[1]])}if(N=[...N,{placement:i,overflows:C}],!C.every(e=>e<=0)){var O,A;const e=((null==(O=o.flip)?void 0:O.index)||0)+1,t=S[e];if(t){if(!("alignment"===u&&b!==Oi(t))||N.every(e=>Oi(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:N},reset:{placement:t}}}let n=null==(A=N.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:A.placement;if(!n)switch(f){case"bestFit":{var T;const e=null==(T=N.filter(e=>{if(k){const t=Oi(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:T[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},jo=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:s,elements:a}=t,{apply:l=()=>{},...c}=xi(e,t),h=await Fi(t,c),u=ki(i),d=Si(i),f="y"===Oi(i),{width:p,height:m}=o.floating;let g,v;"top"===u||"bottom"===u?(g=u,v=d===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(v=u,g="end"===d?"top":"bottom");const b=m-h.top-h.bottom,y=p-h.left-h.right,w=fi(m-h[g],b),x=fi(p-h[v],y),k=!t.middlewareData.shift;let S=w,E=x;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(E=y),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(S=b),k&&!d){const e=pi(h.left,0),t=pi(h.right,0),n=pi(h.top,0),r=pi(h.bottom,0);f?E=p-2*(0!==e||0!==t?e+t:pi(h.left,h.right)):S=m-2*(0!==n||0!==r?n+r:pi(h.top,h.bottom))}await l({...t,availableWidth:E,availableHeight:S});const C=await s.getDimensions(a.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}},Fo=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=xi(e,t);switch(r){case"referenceHidden":{const e=Wi(await Fi(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:zi(e)}}}case"escaped":{const e=Wi(await Fi(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:zi(e)}}}default:return{}}}}},Wo=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:h=0}=xi(e,t)||{};if(null==c)return{};const u=Ii(h),d={x:n,y:r},f=Ai(i),p=Ci(f),m=await s.getDimensions(c),g="y"===f,v=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",w=o.reference[p]+o.reference[f]-d[f]-o.floating[p],x=d[f]-o.reference[f],k=await(null==s.getOffsetParent?void 0:s.getOffsetParent(c));let S=k?k[y]:0;S&&await(null==s.isElement?void 0:s.isElement(k))||(S=a.floating[y]||o.floating[p]);const E=w/2-x/2,C=S/2-m[p]/2-1,N=fi(u[v],C),O=fi(u[b],C),A=N,T=S-m[p]-O,M=S/2-m[p]/2+E,R=wi(A,M,T),D=!l.arrow&&null!=Si(i)&&M!==R&&o.reference[p]/2-(M<A?N:O)-m[p]/2<0,P=D?M<A?M-A:M-T:0;return{[f]:d[f]+P,data:{[f]:R,centerOffset:M-R-P,...D&&{alignmentOffset:P}},reset:D}}}),zo=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=xi(e,t),h={x:n,y:r},u=Oi(i),d=Ei(u);let f=h[d],p=h[u];const m=xi(a,t),g="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const e="y"===d?"height":"width",t=o.reference[d]-o.floating[e]+g.mainAxis,n=o.reference[d]+o.reference[e]-g.mainAxis;f<t?f=t:f>n&&(f=n)}if(c){var v,b;const e="y"===d?"width":"height",t=Hi.has(ki(i)),n=o.reference[u]-o.floating[e]+(t&&(null==(v=s.offset)?void 0:v[u])||0)+(t?0:g.crossAxis),r=o.reference[u]+o.reference[e]+(t?0:(null==(b=s.offset)?void 0:b[u])||0)-(t?g.crossAxis:0);p<n?p=n:p>r&&(p=r)}return{[d]:f,[u]:p}}}},Ho=(e,t,n)=>{const r=new Map,i={platform:Do,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:u}=ji(c,r,l),d=r,f={},p=0;for(let n=0;n<a.length;n++){const{name:o,fn:m}=a[n],{x:g,y:v,data:b,reset:y}=await m({x:h,y:u,initialPlacement:r,placement:d,strategy:i,middlewareData:f,rects:c,platform:s,elements:{reference:e,floating:t}});h=null!=g?g:h,u=null!=v?v:u,f={...f,[o]:{...f[o],...b}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await s.getElementRects({reference:e,floating:t,strategy:i}):y.rects),({x:h,y:u}=ji(c,d,l))),n=-1)}return{x:h,y:u,placement:d,strategy:i,middlewareData:f}})(e,t,{...i,platform:o})};var Vo="undefined"!=typeof document?o:function(){};function qo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!==r--;)if(!qo(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;0!==r--;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!==r--;){const n=i[r];if(("_owner"!==n||!e.$$typeof)&&!qo(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Uo(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $o(e,t){const n=Uo(e);return Math.round(t*n)/n}function Ko(t){const n=e.useRef(t);return Vo(()=>{n.current=t}),n}function Yo(t){void 0===t&&(t={});const{placement:n="bottom",strategy:r="absolute",middleware:i=[],platform:o,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:h}=t,[u,d]=e.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[f,m]=e.useState(i);qo(f,i)||m(i);const[g,v]=e.useState(null),[b,y]=e.useState(null),w=e.useCallback(e=>{e!==E.current&&(E.current=e,v(e))},[]),x=e.useCallback(e=>{e!==C.current&&(C.current=e,y(e))},[]),k=s||g,S=a||b,E=e.useRef(null),C=e.useRef(null),N=e.useRef(u),O=null!=c,A=Ko(c),T=Ko(o),M=Ko(h),R=e.useCallback(()=>{if(!E.current||!C.current)return;const e={placement:n,strategy:r,middleware:f};T.current&&(e.platform=T.current),Ho(E.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==M.current};D.current&&!qo(N.current,t)&&(N.current=t,p.flushSync(()=>{d(t)}))})},[f,n,r,T,M]);Vo(()=>{!1===h&&N.current.isPositioned&&(N.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[h]);const D=e.useRef(!1);Vo(()=>(D.current=!0,()=>{D.current=!1}),[]),Vo(()=>{if(k&&(E.current=k),S&&(C.current=S),k&&S){if(A.current)return A.current(k,S,R);R()}},[k,S,R,A,O]);const P=e.useMemo(()=>({reference:E,floating:C,setReference:w,setFloating:x}),[w,x]),L=e.useMemo(()=>({reference:k,floating:S}),[k,S]),B=e.useMemo(()=>{const e={position:r,left:0,top:0};if(!L.floating)return e;const t=$o(L.floating,u.x),n=$o(L.floating,u.y);return l?{...e,transform:"translate("+t+"px, "+n+"px)",...Uo(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}},[r,l,L.floating,u.x,u.y]);return e.useMemo(()=>({...u,update:R,refs:P,elements:L,floatingStyles:B}),[u,R,P,L,B])}const Go=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}="function"==typeof e?e(t):e;return n&&(i=n,{}.hasOwnProperty.call(i,"current"))?null!=n.current?Wo({element:n.current,padding:r}).fn(t):{}:n?Wo({element:n,padding:r}).fn(t):{};var i}}),Xo=(e,t)=>({...Bo(e),options:[e,t]}),Jo=(e,t)=>({...Io(e),options:[e,t]}),Qo=(e,t)=>({...zo(e),options:[e,t]}),Zo=(e,t)=>({..._o(e),options:[e,t]}),es=(e,t)=>({...jo(e),options:[e,t]}),ts=(e,t)=>({...Fo(e),options:[e,t]}),ns=(e,t)=>({...Go(e),options:[e,t]});var rs=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return u(ri.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u("polygon",{points:"0,0 30,0 15,10"})})});rs.displayName="Arrow";var is=rs;function os(t){const[n,r]=e.useState(void 0);return At(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const n=e[0];let i,o;if("borderBoxSize"in n){const e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=t.offsetWidth,o=t.offsetHeight;r({width:i,height:o})});return e.observe(t,{box:"border-box"}),()=>e.unobserve(t)}r(void 0)},[t]),n}var ss="Popper",[as,ls]=Nt(ss),[cs,hs]=as(ss),us=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return u(cs,{scope:n,anchor:i,onAnchorChange:o,children:r})};us.displayName=ss;var ds="PopperAnchor",fs=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=hs(ds,r),a=e.useRef(null),l=it(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:u(ri.div,{...o,ref:l})});fs.displayName=ds;var ps="PopperContent",[ms,gs]=as(ps),vs=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:h=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=t,b=hs(ps,r),[y,w]=e.useState(null),x=it(n,e=>w(e)),[k,S]=e.useState(null),E=os(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==s?"-"+s:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(h)?h:[h],M=T.length>0,R={padding:A,boundary:T.filter(xs),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=Yo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>Lo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Xo({mainAxis:o+N,alignmentAxis:a}),c&&Jo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Qo():void 0,...R}),c&&Zo({...R}),es({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&ns({element:k,padding:l}),ks({arrowWidth:C,arrowHeight:N}),p&&ts({strategy:"referenceHidden",...R})]}),[_,j]=Ss(L),F=Ft(g);At(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=e.useState();return At(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),u("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:u(ms,{scope:r,placedSide:_,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:u(ri.div,{"data-side":_,"data-align":j,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});vs.displayName=ps;var bs="PopperArrow",ys={top:"bottom",right:"left",bottom:"top",left:"right"},ws=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=gs(bs,n),o=ys[i.placedSide];return u("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:u(is,{...r,ref:t,style:{...r.style,display:"block"}})})});function xs(e){return null!==e}ws.displayName=bs;var ks=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=Ss(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function Ss(e){const[t,n="center"]=e.split("-");return[t,n]}var Es=us,Cs=fs,Ns=vs,Os=ws;var As=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Ts(i.current);s.current="mounted"===l?e:"none"},[l]),At(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=Ts(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),At(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=Ts(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=Ts(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=it(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function Ts(e){return e?.animationName||"none"}As.displayName="Presence";var Ms=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Rs=e.forwardRef((e,t)=>u(ri.span,{...e,ref:t,style:{...Ms,...e.style}}));Rs.displayName="VisuallyHidden";var Ds=Rs,[Ps,Ls]=Nt("Tooltip",[ls]),Bs=ls(),Is="TooltipProvider",_s=700,js="tooltip.open",[Fs,Ws]=Ps(Is),zs=t=>{const{__scopeTooltip:n,delayDuration:r=_s,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:s}=t,a=e.useRef(!0),l=e.useRef(!1),c=e.useRef(0);return e.useEffect(()=>{const e=c.current;return()=>window.clearTimeout(e)},[]),u(Fs,{scope:n,isOpenDelayedRef:a,delayDuration:r,onOpen:e.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:e.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:e.useCallback(e=>{l.current=e},[]),disableHoverableContent:o,children:s})};zs.displayName=Is;var Hs="Tooltip",[Vs,qs]=Ps(Hs),Us=t=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=t,c=Ws(Hs,t.__scopeTooltip),h=Bs(n),[d,f]=e.useState(null),p=Rt(),m=e.useRef(0),g=a??c.disableHoverableContent,v=l??c.delayDuration,b=e.useRef(!1),[y,w]=Pt({prop:i,defaultProp:o??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(js))):c.onClose(),s?.(e)},caller:Hs}),x=e.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),k=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,w(!0)},[w]),S=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),E=e.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,w(!0),m.current=0},v)},[v,w]);return e.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),u(Es,{...h,children:u(Vs,{scope:n,contentId:p,open:y,stateAttribute:x,trigger:d,onTriggerChange:f,onTriggerEnter:e.useCallback(()=>{c.isOpenDelayedRef.current?E():k()},[c.isOpenDelayedRef,E,k]),onTriggerLeave:e.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:k,onClose:S,disableHoverableContent:g,children:r})})};Us.displayName=Hs;var $s="TooltipTrigger",Ks=e.forwardRef((t,n)=>{const{__scopeTooltip:r,...i}=t,o=qs($s,r),s=Ws($s,r),a=Bs(r),l=it(n,e.useRef(null),o.onTriggerChange),c=e.useRef(!1),h=e.useRef(!1),d=e.useCallback(()=>c.current=!1,[]);return e.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),u(Cs,{asChild:!0,...a,children:u(ri.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:l,onPointerMove:Ct(t.onPointerMove,e=>{"touch"!==e.pointerType&&(h.current||s.isPointerInTransitRef.current||(o.onTriggerEnter(),h.current=!0))}),onPointerLeave:Ct(t.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Ct(t.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Ct(t.onFocus,()=>{c.current||o.onOpen()}),onBlur:Ct(t.onBlur,o.onClose),onClick:Ct(t.onClick,o.onClose)})})});Ks.displayName=$s;var[Ys,Gs]=Ps("TooltipPortal",{forceMount:void 0}),Xs="TooltipContent",Js=e.forwardRef((e,t)=>{const n=Gs(Xs,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,s=qs(Xs,e.__scopeTooltip);return u(As,{present:r||s.open,children:s.disableHoverableContent?u(na,{side:i,...o,ref:t}):u(Qs,{side:i,...o,ref:t})})}),Qs=e.forwardRef((t,n)=>{const r=qs(Xs,t.__scopeTooltip),i=Ws(Xs,t.__scopeTooltip),o=e.useRef(null),s=it(n,o),[a,l]=e.useState(null),{trigger:c,onClose:h}=r,d=o.current,{onPointerInTransitChange:f}=i,p=e.useCallback(()=>{l(null),f(!1)},[f]),m=e.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect()),o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,i),s=function(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}(t.getBoundingClientRect()),a=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...s]);l(a),f(!0)},[f]);return e.useEffect(()=>()=>p(),[p]),e.useEffect(()=>{if(c&&d){const e=e=>m(e,d),t=e=>m(e,c);return c.addEventListener("pointerleave",e),d.addEventListener("pointerleave",t),()=>{c.removeEventListener("pointerleave",e),d.removeEventListener("pointerleave",t)}}},[c,d,m,p]),e.useEffect(()=>{if(a){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||d?.contains(t),i=!function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,h=a.x,u=a.y;c>r!=u>r&&n<(h-l)*(r-c)/(u-c)+l&&(i=!i)}return i}(n,a);r?p():i&&(p(),h())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,d,a,h,p]),u(na,{...t,ref:s})}),[Zs,ea]=Ps(Hs,{isInside:!1}),ta=function(e){const t=({children:e})=>u(f,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=ti,t}("TooltipContent"),na=e.forwardRef((t,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=t,c=qs(Xs,r),h=Bs(r),{onClose:f}=c;return e.useEffect(()=>(document.addEventListener(js,f),()=>document.removeEventListener(js,f)),[f]),e.useEffect(()=>{if(c.trigger){const e=e=>{const t=e.target;t?.contains(c.trigger)&&f()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,f]),u(ci,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:f,children:d(Ns,{"data-state":c.stateAttribute,...h,...l,ref:n,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u(ta,{children:i}),u(Zs,{scope:r,isInside:!0,children:u(Ds,{id:c.contentId,role:"tooltip",children:o||i})})]})})});Js.displayName=Xs;var ra="TooltipArrow";e.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Bs(n);return ea(ra,n).isInside?null:u(Os,{...i,...r,ref:t})}).displayName=ra;var ia=Js,oa=zs,sa=Us,aa=Ks,la=e.forwardRef(function(t,n){var r=t.className,i=t.sideOffset,o=void 0===i?4:i,s=oe(t,["className","sideOffset"]);return e.createElement(ia,Object.assign({ref:n,sideOffset:o,className:et("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",r)},s))});la.displayName=ia.displayName;var ca=e.createContext(null);function ha(){var t=e.useContext(ca);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function ua(t){var n=t.defaultOpen,r=void 0===n||n,i=t.open,o=t.onOpenChange,s=t.className,a=t.style,l=t.children,c=oe(t,["defaultOpen","open","onOpenChange","className","style","children"]),h=function(){var t=C(e.useState(void 0),2),n=t[0],r=t[1];return e.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){r(window.innerWidth<768)};return e.addEventListener("change",t),r(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!n}(),u=C(e.useState(!1),2),d=u[0],f=u[1],p=C(e.useState(r),2),m=p[0],g=p[1],v=null!=i?i:m,b=e.useCallback(function(e){var t="function"==typeof e?e(v):e;o?o(t):g(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[o,v]),y=e.useCallback(function(){return h?f(function(e){return!e}):b(function(e){return!e})},[h,b,f]);e.useEffect(function(){var e=function(e){"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[y]);var w=v?"expanded":"collapsed",x=e.useMemo(function(){return{state:w,open:v,setOpen:b,isMobile:h,openMobile:d,setOpenMobile:f,toggleSidebar:y}},[w,v,b,h,d,f,y]);return e.createElement(ca.Provider,{value:x},e.createElement(oa,{delayDuration:0},e.createElement("div",Object.assign({style:Object.assign({"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"},a),className:et("group/sidebar-wrapper flex min-h-svh w-full",s)},c),l)))}function da(t){var n=t.side,r=void 0===n?"left":n,i=t.variant,o=void 0===i?"sidebar":i,s=t.collapsible,a=void 0===s?"offcanvas":s,l=t.className,c=t.children,h=oe(t,["side","variant","collapsible","className","children"]),u=ha(),d=u.isMobile,f=u.state,p=u.openMobile,m=u.setOpenMobile;return"none"===a?e.createElement("div",Object.assign({className:et("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},h),c):d?e.createElement($r,Object.assign({open:p,onOpenChange:m},h),e.createElement(Xr,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:r},e.createElement(Jr,{className:"sr-only"},e.createElement(Qr,null,"Sidebar"),e.createElement(Zr,null,"Displays the mobile sidebar.")),e.createElement("div",{className:"flex h-full w-full flex-col"},c))):e.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":f,"data-collapsible":"collapsed"===f?a:"","data-variant":o,"data-side":r},e.createElement("div",{className:et("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===o||"inset"===o?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),e.createElement("div",Object.assign({className:et("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex","left"===r?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===o||"inset"===o?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",l)},h),e.createElement("div",{className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"},c)))}function fa(t){var n=t.className,r=t.onClick,i=oe(t,["className","onClick"]),o=ha().toggleSidebar;return e.createElement(vt,Object.assign({variant:"ghost",size:"icon",className:et("h-7 w-7",n),onClick:function(e){null==r||r(e),o()}},i),e.createElement(Y,null),e.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function pa(t){var n=t.className,r=oe(t,["className"]);return e.createElement("main",Object.assign({className:et("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",n)},r))}function ma(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col gap-2 p-2",n)},r))}function ga(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col gap-2 p-2",n)},r))}function va(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",n)},r))}function ba(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("relative flex w-full min-w-0 flex-col p-2",n)},r))}function ya(t){var n=t.className,r=t.asChild,i=void 0!==r&&r,o=oe(t,["className","asChild"]),s=i?ct:"div";return e.createElement(s,Object.assign({className:et("text-sidebar-foreground/70 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",n)},o))}function wa(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("w-full text-sm",n)},r))}function xa(t){var n=t.className,r=oe(t,["className"]);return e.createElement("ul",Object.assign({className:et("flex w-full min-w-0 flex-col gap-1",n)},r))}function ka(t){var n=t.className,r=oe(t,["className"]);return e.createElement("li",Object.assign({className:et("group/menu-item relative",n)},r))}var Sa=mt("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Ea(t){var n=t.asChild,r=void 0!==n&&n,i=t.isActive,o=void 0!==i&&i,s=t.variant,a=void 0===s?"default":s,l=t.size,c=void 0===l?"default":l,h=t.tooltip,u=t.className,d=oe(t,["asChild","isActive","variant","size","tooltip","className"]),f=r?ct:"button",p=ha(),m=p.isMobile,g=p.state,v=e.createElement(f,Object.assign({"data-size":c,"data-active":o,className:et(Sa({variant:a,size:c}),u)},d));return h?("string"==typeof h&&(h={children:h}),e.createElement(sa,null,e.createElement(aa,{asChild:!0},v),e.createElement(la,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},h)))):v}var Ca=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=lt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),Na=e.forwardRef((e,t)=>u(Ca.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Na.displayName="Label";var Oa=Na,Aa=mt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ta=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Oa,Object.assign({ref:n,className:et(Aa(),r)},i))});Ta.displayName=Oa.displayName;var Ma=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("rounded-lg border bg-card text-card-foreground shadow-sm",r)},i))});Ma.displayName="Card";var Ra=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("flex flex-col space-y-1.5 p-6",r)},i))});Ra.displayName="CardHeader";var Da=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("text-2xl font-semibold leading-none tracking-tight",r)},i))});Da.displayName="CardTitle";var Pa=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("text-sm text-muted-foreground",r)},i))});Pa.displayName="CardDescription";var La=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("p-6 pt-0",r)},i))});La.displayName="CardContent";var Ba=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("flex items-center p-6 pt-0",r)},i))});Ba.displayName="CardFooter";var Ia={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},_a=new Set;function ja(){_a.forEach(function(e){return e(Ia.items.slice())})}function Fa(e){switch(e){case"success":return t.createElement(D,null);case"error":return t.createElement(ne,null);case"warning":return t.createElement(R,null);case"loading":return t.createElement(q,{className:"animate-spin"});default:return t.createElement(V,null)}}function Wa(e){var t,n,r;qa();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=Ia.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:Ia.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:Fa(e.type),className:e.className,createdAt:i};return s>=0?Ia.items[s]=Object.assign({},Ia.items[s],a):(Ia.items.length>=Ia.config.maxCount&&Ia.items.shift(),Ia.items.push(a)),ja(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){za(o)},1e3*a.duration),{close:function(){return za(o)}}}function za(e){var t;if(void 0===e)return Ia.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),Ia.items=[],void ja();var n=Ia.items.findIndex(function(t){return t.key===e});if(n>=0){var r=C(Ia.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),ja()}}var Ha=null,Va=null;function qa(){"undefined"!=typeof window&&(Va||((Va=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(Va)),Ha||(Ha=g(Va)).render(t.createElement(Ua,null)))}function Ua(){var e=function(){var e=C(i(Ia.items),2),t=e[0],n=e[1];return a(function(){var e=n;return _a.add(e),function(){_a.delete(e)}},[]),t}(),n=Ia.config.top;return t.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},t.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},e.map(function(e){var n,r,i=function(e){switch(e){case"success":return{container:"border-green-200 bg-green-50/90 text-green-800 border-l-4 border-l-green-500",icon:"text-green-500",text:"text-green-800"};case"error":return{container:"border-red-200 bg-red-50/90 text-red-800 border-l-4 border-l-red-500",icon:"text-red-500",text:"text-red-800"};case"warning":return{container:"border-yellow-200 bg-yellow-50/90 text-yellow-800 border-l-4 border-l-yellow-500",icon:"text-yellow-500",text:"text-yellow-800"};default:return{container:"border-blue-200 bg-blue-50/90 text-blue-800 border-l-4 border-l-blue-500",icon:"text-blue-500",text:"text-blue-800"}}}(e.type);return t.createElement("div",{key:e.key,className:"pointer-events-auto flex w-full items-center gap-2 rounded-md border px-3 py-2 backdrop-blur ".concat(i.container," ").concat(null!==(n=e.className)&&void 0!==n?n:"")},t.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=e.icon)&&void 0!==r?r:Fa(e.type)),t.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof e.content?t.createElement("span",{className:"break-words align-middle"},e.content):e.content))})))}function $a(e,n,r,i){if(t.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:e,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:e})}var Ka,Ya,Ga=(Ya={open:function(e){var t;return Wa(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return Wa($a("info",e,t,n))},success:function(e,t,n){return Wa($a("success",e,t,n))},error:function(e,t,n){return Wa($a("error",e,t,n))},warning:function(e,t,n){return Wa($a("warning",e,t,n))},loading:function(e,t,n){return Wa($a("loading",e,null!=t?t:0,n))},destroy:function(e){return za(e)},config:function(e){return t=e,Ia.config=Object.assign({},Ia.config,t),void ja();var t},useMessage:function(){var e=s(function(){return"undefined"!=typeof window&&qa(),t.createElement(t.Fragment,null)},[]);return[Ka.current,e]}},(Ka={}).current=Ya,Ya);function Xa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ja}=Object.prototype,{getPrototypeOf:Qa}=Object,{iterator:Za,toStringTag:el}=Symbol,tl=(nl=Object.create(null),e=>{const t=Ja.call(e);return nl[t]||(nl[t]=t.slice(8,-1).toLowerCase())});var nl;const rl=e=>(e=e.toLowerCase(),t=>tl(t)===e),il=e=>t=>typeof t===e,{isArray:ol}=Array,sl=il("undefined");function al(e){return null!==e&&!sl(e)&&null!==e.constructor&&!sl(e.constructor)&&hl(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ll=rl("ArrayBuffer");const cl=il("string"),hl=il("function"),ul=il("number"),dl=e=>null!==e&&"object"==typeof e,fl=e=>{if("object"!==tl(e))return!1;const t=Qa(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||el in e||Za in e)},pl=rl("Date"),ml=rl("File"),gl=rl("Blob"),vl=rl("FileList"),bl=rl("URLSearchParams"),[yl,wl,xl,kl]=["ReadableStream","Request","Response","Headers"].map(rl);function Sl(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),ol(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(al(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(r=0;r<o;r++)s=i[r],t.call(null,e[s],s,e)}}function El(e,t){if(al(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,i=n.length;for(;i-- >0;)if(r=n[i],t===r.toLowerCase())return r;return null}const Cl="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Nl=e=>!sl(e)&&e!==Cl;const Ol=(Al="undefined"!=typeof Uint8Array&&Qa(Uint8Array),e=>Al&&e instanceof Al);var Al;const Tl=rl("HTMLFormElement"),Ml=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Rl=rl("RegExp"),Dl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Sl(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)};const Pl=rl("AsyncFunction"),Ll=(Bl="function"==typeof setImmediate,Il=hl(Cl.postMessage),Bl?setImmediate:Il?(_l=`axios@${Math.random()}`,jl=[],Cl.addEventListener("message",({source:e,data:t})=>{e===Cl&&t===_l&&jl.length&&jl.shift()()},!1),e=>{jl.push(e),Cl.postMessage(_l,"*")}):e=>setTimeout(e));var Bl,Il,_l,jl;const Fl="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Cl):"undefined"!=typeof process&&process.nextTick||Ll;var Wl={isArray:ol,isArrayBuffer:ll,isBuffer:al,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||hl(e.append)&&("formdata"===(t=tl(e))||"object"===t&&hl(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&ll(e.buffer),t},isString:cl,isNumber:ul,isBoolean:e=>!0===e||!1===e,isObject:dl,isPlainObject:fl,isEmptyObject:e=>{if(!dl(e)||al(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:yl,isRequest:wl,isResponse:xl,isHeaders:kl,isUndefined:sl,isDate:pl,isFile:ml,isBlob:gl,isRegExp:Rl,isFunction:hl,isStream:e=>dl(e)&&hl(e.pipe),isURLSearchParams:bl,isTypedArray:Ol,isFileList:vl,forEach:Sl,merge:function e(){const{caseless:t,skipUndefined:n}=Nl(this)&&this||{},r={},i=(i,o)=>{const s=t&&El(r,o)||o;fl(r[s])&&fl(i)?r[s]=e(r[s],i):fl(i)?r[s]=e({},i):ol(i)?r[s]=i.slice():n&&sl(i)||(r[s]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Sl(arguments[e],i);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(Sl(t,(t,r)=>{n&&hl(t)?e[r]=Xa(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,o,s;const a={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&Qa(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:tl,kindOfTest:rl,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(ol(e))return e;let t=e.length;if(!ul(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Za]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Tl,hasOwnProperty:Ml,hasOwnProp:Ml,reduceDescriptors:Dl,freezeMethods:e=>{Dl(e,(t,n)=>{if(hl(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];hl(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return ol(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:El,global:Cl,isContextDefined:Nl,isSpecCompliantForm:function(e){return!!(e&&hl(e.append)&&"FormData"===e[el]&&e[Za])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(dl(e)){if(t.indexOf(e)>=0)return;if(al(e))return e;if(!("toJSON"in e)){t[r]=e;const i=ol(e)?[]:{};return Sl(e,(e,t)=>{const o=n(e,r+1);!sl(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:Pl,isThenable:e=>e&&(dl(e)||hl(e))&&hl(e.then)&&hl(e.catch),setImmediate:Ll,asap:Fl,isIterable:e=>null!=e&&hl(e[Za])};function zl(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}Wl.inherits(zl,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Wl.toJSONObject(this.config),code:this.code,status:this.status}}});const Hl=zl.prototype,Vl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Vl[e]={value:e}}),Object.defineProperties(zl,Vl),Object.defineProperty(Hl,"isAxiosError",{value:!0}),zl.from=(e,t,n,r,i,o)=>{const s=Object.create(Hl);Wl.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return zl.call(s,a,l,n,r,i),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",o&&Object.assign(s,o),s};function ql(e){return Wl.isPlainObject(e)||Wl.isArray(e)}function Ul(e){return Wl.endsWith(e,"[]")?e.slice(0,-2):e}function $l(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ul(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Kl=Wl.toFlatObject(Wl,{},null,function(e){return/^is[A-Z]/.test(e)});function Yl(e,t,n){if(!Wl.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Wl.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Wl.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Wl.isSpecCompliantForm(t);if(!Wl.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Wl.isDate(e))return e.toISOString();if(Wl.isBoolean(e))return e.toString();if(!a&&Wl.isBlob(e))throw new zl("Blob is not supported. Use a Buffer instead.");return Wl.isArrayBuffer(e)||Wl.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,i){let a=e;if(e&&!i&&"object"==typeof e)if(Wl.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Wl.isArray(e)&&function(e){return Wl.isArray(e)&&!e.some(ql)}(e)||(Wl.isFileList(e)||Wl.endsWith(n,"[]"))&&(a=Wl.toArray(e)))return n=Ul(n),a.forEach(function(e,r){!Wl.isUndefined(e)&&null!==e&&t.append(!0===s?$l([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!ql(e)||(t.append($l(i,n,o),l(e)),!1)}const h=[],u=Object.assign(Kl,{defaultVisitor:c,convertValue:l,isVisitable:ql});if(!Wl.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Wl.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+r.join("."));h.push(n),Wl.forEach(n,function(n,o){!0===(!(Wl.isUndefined(n)||null===n)&&i.call(t,n,Wl.isString(o)?o.trim():o,r,u))&&e(n,r?r.concat(o):[o])}),h.pop()}}(e),t}function Gl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Xl(e,t){this._pairs=[],e&&Yl(e,this,t)}const Jl=Xl.prototype;function Ql(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Zl(e,t,n){if(!t)return e;const r=n&&n.encode||Ql;Wl.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(o=i?i(t,n):Wl.isURLSearchParams(t)?t.toString():new Xl(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}Jl.append=function(e,t){this._pairs.push([e,t])},Jl.toString=function(e){const t=e?function(t){return e.call(this,t,Gl)}:Gl;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ec=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Wl.forEach(this.handlers,function(t){null!==t&&e(t)})}},tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},nc={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Xl,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const rc="undefined"!=typeof window&&"undefined"!=typeof document,ic="object"==typeof navigator&&navigator||void 0,oc=rc&&(!ic||["ReactNative","NativeScript","NS"].indexOf(ic.product)<0),sc="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ac=rc&&window.location.href||"http://localhost";var lc={...Object.freeze({__proto__:null,hasBrowserEnv:rc,hasStandardBrowserEnv:oc,hasStandardBrowserWebWorkerEnv:sc,navigator:ic,origin:ac}),...nc};function cc(e){function t(e,n,r,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;if(o=!o&&Wl.isArray(r)?r.length:o,a)return Wl.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s;r[o]&&Wl.isObject(r[o])||(r[o]=[]);return t(e,n,r[o],i)&&Wl.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],t[o]=e[o];return t}(r[o])),!s}if(Wl.isFormData(e)&&Wl.isFunction(e.entries)){const n={};return Wl.forEachEntry(e,(e,r)=>{t(function(e){return Wl.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const hc={transitional:tc,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=Wl.isObject(e);i&&Wl.isHTMLForm(e)&&(e=new FormData(e));if(Wl.isFormData(e))return r?JSON.stringify(cc(e)):e;if(Wl.isArrayBuffer(e)||Wl.isBuffer(e)||Wl.isStream(e)||Wl.isFile(e)||Wl.isBlob(e)||Wl.isReadableStream(e))return e;if(Wl.isArrayBufferView(e))return e.buffer;if(Wl.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Yl(e,new lc.classes.URLSearchParams,{visitor:function(e,t,n,r){return lc.isNode&&Wl.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Wl.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Yl(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e,t,n){if(Wl.isString(e))try{return(t||JSON.parse)(e),Wl.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||hc.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Wl.isResponse(e)||Wl.isReadableStream(e))return e;if(e&&Wl.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw zl.from(e,zl.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lc.classes.FormData,Blob:lc.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Wl.forEach(["delete","get","head","post","put","patch"],e=>{hc.headers[e]={}});var uc=hc;const dc=Wl.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const fc=Symbol("internals");function pc(e){return e&&String(e).trim().toLowerCase()}function mc(e){return!1===e||null==e?e:Wl.isArray(e)?e.map(mc):String(e)}function gc(e,t,n,r,i){return Wl.isFunction(r)?r.call(this,t,n):(i&&(t=n),Wl.isString(t)?Wl.isString(r)?-1!==t.indexOf(r):Wl.isRegExp(r)?r.test(t):void 0:void 0)}class vc{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=pc(t);if(!i)throw new Error("header name must be a non-empty string");const o=Wl.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=mc(e))}const o=(e,t)=>Wl.forEach(e,(e,n)=>i(e,n,t));if(Wl.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Wl.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&dc[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Wl.isObject(e)&&Wl.isIterable(e)){let n,r,i={};for(const t of e){if(!Wl.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[r=t[0]]=(n=i[r])?Wl.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=pc(e)){const n=Wl.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Wl.isFunction(t))return t.call(this,e,n);if(Wl.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=pc(e)){const n=Wl.findKey(this,e);return!(!n||void 0===this[n]||t&&!gc(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=pc(e)){const i=Wl.findKey(n,e);!i||t&&!gc(0,n[i],i,t)||(delete n[i],r=!0)}}return Wl.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!gc(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return Wl.forEach(this,(r,i)=>{const o=Wl.findKey(n,i);if(o)return t[o]=mc(r),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();s!==i&&delete t[i],t[s]=mc(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Wl.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Wl.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[fc]=this[fc]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=pc(e);t[r]||(!function(e,t){const n=Wl.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return Wl.isArray(e)?e.forEach(r):r(e),this}}vc.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Wl.reduceDescriptors(vc.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Wl.freezeMethods(vc);var bc=vc;function yc(e,t){const n=this||uc,r=t||n,i=bc.from(r.headers);let o=r.data;return Wl.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function wc(e){return!(!e||!e.__CANCEL__)}function xc(e,t,n){zl.call(this,null==e?"canceled":e,zl.ERR_CANCELED,t,n),this.name="CanceledError"}function kc(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new zl("Request failed with status code "+n.status,[zl.ERR_BAD_REQUEST,zl.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Wl.inherits(xc,zl,{__CANCEL__:!0});const Sc=(e,t,n=3)=>{let r=0;const i=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=r[s];i||(i=l),n[o]=a,r[o]=l;let h=s,u=0;for(;h!==o;)u+=n[h++],h%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const d=c&&l-c;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(e,t){let n,r,i=0,o=1e3/t;const s=(t,o=Date.now())=>{i=o,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=o?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},o-a)))},()=>n&&s(n)]}(n=>{const o=n.loaded,s=n.lengthComputable?n.total:void 0,a=o-r,l=i(a);r=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&o<=s?(s-o)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},Ec=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Cc=e=>(...t)=>Wl.asap(()=>e(...t));var Nc=lc.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,lc.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(lc.origin),lc.navigator&&/(msie|trident)/i.test(lc.navigator.userAgent)):()=>!0,Oc=lc.hasStandardBrowserEnv?{write(e,t,n,r,i,o,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Wl.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Wl.isString(r)&&a.push(`path=${r}`),Wl.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),Wl.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function Ac(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Tc=e=>e instanceof bc?{...e}:e;function Mc(e,t){t=t||{};const n={};function r(e,t,n,r){return Wl.isPlainObject(e)&&Wl.isPlainObject(t)?Wl.merge.call({caseless:r},e,t):Wl.isPlainObject(t)?Wl.merge({},t):Wl.isArray(t)?t.slice():t}function i(e,t,n,i){return Wl.isUndefined(t)?Wl.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!Wl.isUndefined(t))return r(void 0,t)}function s(e,t){return Wl.isUndefined(t)?Wl.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>i(Tc(e),Tc(t),0,!0)};return Wl.forEach(Object.keys({...e,...t}),function(r){const o=l[r]||i,s=o(e[r],t[r],r);Wl.isUndefined(s)&&o!==a||(n[r]=s)}),n}var Rc=e=>{const t=Mc({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=bc.from(s),t.url=Zl(Ac(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Wl.isFormData(n))if(lc.hasStandardBrowserEnv||lc.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Wl.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(lc.hasStandardBrowserEnv&&(r&&Wl.isFunction(r)&&(r=r(t)),r||!1!==r&&Nc(t.url))){const e=i&&o&&Oc.read(o);e&&s.set(i,e)}return t};var Dc="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Rc(e);let i=r.data;const o=bc.from(r.headers).normalize();let s,a,l,c,h,{responseType:u,onUploadProgress:d,onDownloadProgress:f}=r;function p(){c&&c(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=bc.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());kc(function(e){t(e),p()},function(e){n(e),p()},{data:u&&"text"!==u&&"json"!==u?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new zl("Request aborted",zl.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=new zl(t&&t.message?t.message:"Network Error",zl.ERR_NETWORK,e,m);r.event=t||null,n(r),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||tc;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new zl(t,i.clarifyTimeoutError?zl.ETIMEDOUT:zl.ECONNABORTED,e,m)),m=null},void 0===i&&o.setContentType(null),"setRequestHeader"in m&&Wl.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Wl.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),u&&"json"!==u&&(m.responseType=r.responseType),f&&([l,h]=Sc(f,!0),m.addEventListener("progress",l)),d&&m.upload&&([a,c]=Sc(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new xc(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);v&&-1===lc.protocols.indexOf(v)?n(new zl("Unsupported protocol "+v+":",zl.ERR_BAD_REQUEST,e)):m.send(i||null)})};var Pc=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const i=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof zl?t:new xc(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new zl(`timeout ${t} of ms exceeded`,zl.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:a}=r;return a.unsubscribe=()=>Wl.asap(s),a}};const Lc=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,i=0;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},Bc=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Ic=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of Bc(e))yield*Lc(n,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return a(),void e.close();let o=r.byteLength;if(n){let e=s+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},{isFunction:_c}=Wl,jc=(({Request:e,Response:t})=>({Request:e,Response:t}))(Wl.global),{ReadableStream:Fc,TextEncoder:Wc}=Wl.global,zc=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Hc=e=>{e=Wl.merge.call({skipUndefined:!0},jc,e);const{fetch:t,Request:n,Response:r}=e,i=t?_c(t):"function"==typeof fetch,o=_c(n),s=_c(r);if(!i)return!1;const a=i&&_c(Fc),l=i&&("function"==typeof Wc?(c=new Wc,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const h=o&&a&&zc(()=>{let e=!1;const t=new n(lc.origin,{body:new Fc,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),u=s&&a&&zc(()=>Wl.isReadableStream(new r("").body)),d={stream:u&&(e=>e.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new zl(`Response type '${e}' is not supported`,zl.ERR_NOT_SUPPORT,n)})});const f=async(e,t)=>{const r=Wl.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Wl.isBlob(e))return e.size;if(Wl.isSpecCompliantForm(e)){const t=new n(lc.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Wl.isArrayBufferView(e)||Wl.isArrayBuffer(e)?e.byteLength:(Wl.isURLSearchParams(e)&&(e+=""),Wl.isString(e)?(await l(e)).byteLength:void 0)})(t):r};return async e=>{let{url:i,method:s,data:a,signal:l,cancelToken:c,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:v,headers:b,withCredentials:y="same-origin",fetchOptions:w}=Rc(e),x=t||fetch;v=v?(v+"").toLowerCase():"text";let k=Pc([l,c&&c.toAbortSignal()],p),S=null;const E=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let C;try{if(g&&h&&"get"!==s&&"head"!==s&&0!==(C=await f(b,a))){let e,t=new n(i,{method:"POST",body:a,duplex:"half"});if(Wl.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=Ec(C,Sc(Cc(g)));a=Ic(t.body,65536,e,n)}}Wl.isString(y)||(y=y?"include":"omit");const t=o&&"credentials"in n.prototype,l={...w,signal:k,method:s.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?y:void 0};S=o&&new n(i,l);let c=await(o?x(S,w):x(i,l));const p=u&&("stream"===v||"response"===v);if(u&&(m||p&&E)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=c[t]});const t=Wl.toFiniteNumber(c.headers.get("content-length")),[n,i]=m&&Ec(t,Sc(Cc(m),!0))||[];c=new r(Ic(c.body,65536,n,()=>{i&&i(),E&&E()}),e)}v=v||"text";let N=await d[Wl.findKey(d,v)||"text"](c,e);return!p&&E&&E(),await new Promise((t,n)=>{kc(t,n,{data:N,headers:bc.from(c.headers),status:c.status,statusText:c.statusText,config:e,request:S})})}catch(t){if(E&&E(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new zl("Network Error",zl.ERR_NETWORK,e,S),{cause:t.cause||t});throw zl.from(t,t&&t.code,e,S)}}},Vc=new Map,qc=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:i}=t,o=[r,i,n];let s,a,l=o.length,c=Vc;for(;l--;)s=o[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:Hc(t)),c=a;return a};qc();const Uc={http:null,xhr:Dc,fetch:{get:qc}};Wl.forEach(Uc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const $c=e=>`- ${e}`,Kc=e=>Wl.isFunction(e)||null===e||!1===e;var Yc={getAdapter:function(e,t){e=Wl.isArray(e)?e:[e];const{length:n}=e;let r,i;const o={};for(let s=0;s<n;s++){let n;if(r=e[s],i=r,!Kc(r)&&(i=Uc[(n=String(r)).toLowerCase()],void 0===i))throw new zl(`Unknown adapter '${n}'`);if(i&&(Wl.isFunction(i)||(i=i.get(t))))break;o[n||"#"+s]=i}if(!i){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new zl("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map($c).join("\n"):" "+$c(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i},adapters:Uc};function Gc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xc(null,e)}function Xc(e){Gc(e),e.headers=bc.from(e.headers),e.data=yc.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Yc.getAdapter(e.adapter||uc.adapter,e)(e).then(function(t){return Gc(e),t.data=yc.call(e,e.transformResponse,t),t.headers=bc.from(t.headers),t},function(t){return wc(t)||(Gc(e),t&&t.response&&(t.response.data=yc.call(e,e.transformResponse,t.response),t.response.headers=bc.from(t.response.headers))),Promise.reject(t)})}const Jc="1.13.2",Qc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Qc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Zc={};Qc.transitional=function(e,t,n){return(r,i,o)=>{if(!1===e)throw new zl(function(e,t){return"[Axios v"+Jc+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),zl.ERR_DEPRECATED);return t&&!Zc[i]&&(Zc[i]=!0),!e||e(r,i,o)}},Qc.spelling=function(e){return(e,t)=>!0};var eh={assertOptions:function(e,t,n){if("object"!=typeof e)throw new zl("options must be an object",zl.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],s=t[o];if(s){const t=e[o],n=void 0===t||s(t,o,e);if(!0!==n)throw new zl("option "+o+" must be "+n,zl.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new zl("Unknown option "+o,zl.ERR_BAD_OPTION)}},validators:Qc};const th=eh.validators;class nh{constructor(e){this.defaults=e||{},this.interceptors={request:new ec,response:new ec}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Mc(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&eh.assertOptions(n,{silentJSONParsing:th.transitional(th.boolean),forcedJSONParsing:th.transitional(th.boolean),clarifyTimeoutError:th.transitional(th.boolean)},!1),null!=r&&(Wl.isFunction(r)?t.paramsSerializer={serialize:r}:eh.assertOptions(r,{encode:th.function,serialize:th.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),eh.assertOptions(t,{baseUrl:th.spelling("baseURL"),withXsrfToken:th.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&Wl.merge(i.common,i[t.method]);i&&Wl.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=bc.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let h,u=0;if(!a){const e=[Xc.bind(this),void 0];for(e.unshift(...s),e.push(...l),h=e.length,c=Promise.resolve(t);u<h;)c=c.then(e[u++],e[u++]);return c}h=s.length;let d=t;for(;u<h;){const e=s[u++],t=s[u++];try{d=e(d)}catch(e){t.call(this,e);break}}try{c=Xc.call(this,d)}catch(e){return Promise.reject(e)}for(u=0,h=l.length;u<h;)c=c.then(l[u++],l[u++]);return c}getUri(e){return Zl(Ac((e=Mc(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Wl.forEach(["delete","get","head","options"],function(e){nh.prototype[e]=function(t,n){return this.request(Mc(n||{},{method:e,url:t,data:(n||{}).data}))}}),Wl.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(Mc(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}nh.prototype[e]=t(),nh.prototype[e+"Form"]=t(!0)});var rh=nh;class ih{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new xc(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ih(function(t){e=t}),cancel:e}}}var oh=ih;const sh={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(sh).forEach(([e,t])=>{sh[t]=e});var ah=sh;const lh=function e(t){const n=new rh(t),r=Xa(rh.prototype.request,n);return Wl.extend(r,rh.prototype,n,{allOwnKeys:!0}),Wl.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Mc(t,n))},r}(uc);lh.Axios=rh,lh.CanceledError=xc,lh.CancelToken=oh,lh.isCancel=wc,lh.VERSION=Jc,lh.toFormData=Yl,lh.AxiosError=zl,lh.Cancel=lh.CanceledError,lh.all=function(e){return Promise.all(e)},lh.spread=function(e){return function(t){return e.apply(null,t)}},lh.isAxiosError=function(e){return Wl.isObject(e)&&!0===e.isAxiosError},lh.mergeConfig=Mc,lh.AxiosHeaders=bc,lh.formToJSON=e=>cc(Wl.isHTMLForm(e)?new FormData(e):e),lh.getAdapter=Yc.getAdapter,lh.HttpStatusCode=ah,lh.default=lh;var ch=lh.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),hh=new Map;ch.interceptors.request.use(function(e){e.url&&e.url.startsWith("http")&&(e.baseURL="");var t=localStorage.getItem("cms_token");t&&(e.headers.Authorization="Bearer ".concat(t));var n=localStorage.getItem("cms_session_id");return n&&(e.headers["X-Session-Id"]=n),e},function(e){return Promise.reject(e)}),ch.interceptors.response.use(function(e){return e},function(e){var t="请求错误",n=!1;if(e.response){var r=e.response.status,i=e.response.data;401===r?"登录已过期,请重新登录"===(null==i?void 0:i.message)?(t="登录已过期,请重新登录",n=!0):"认证信息无效"===(null==i?void 0:i.message)?(t="认证信息无效,请重新登录",n=!0):(t="认证失败,请登录",n=!0):t=(null==i?void 0:i.message)||"HTTP ".concat(r,": ").concat(e.response.statusText)}else t=e.request?"网络连接失败,请检查网络状态":e.message||"请求错误";return n?(localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),"/login"!==window.location.pathname&&"/"!==window.location.pathname&&(Ga.error(t),setTimeout(function(){window.location.reload()},1e3))):Ga.error(t),Promise.reject(e)});var uh,dh=function(e,t,n){var r=e;if(t){var i=new URLSearchParams(t).toString();r=r+(r.includes("?")?"&":"?")+i}var o="GET ".concat(r),s=hh.get(o);if(s)return s;var a=ch.get(r,n).then(function(e){return e.data}).finally(function(){hh.delete(o)});return hh.set(o,a),a},fh=function(e,t,n){return ch.post(e,t,n).then(function(e){return e.data})},ph=function(e,t,n){return ch.put(e,t,n).then(function(e){return e.data})},mh=function(e,t){return ch.delete(e,t).then(function(e){return e.data})};try{var gh=localStorage.getItem("cms_session_id")||void 0;uh=gh}catch(rS){}function vh(e){uh=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}}var bh=function(){return dh("/models")},yh=function(){return dh("/auth/signup/status/".concat(uh?uh+"_":"","cms_users"))},wh=function(e){return fh("/auth/signup/".concat(uh?uh+"_":"","cms_users"),e)},xh=function(e){return fh("/auth/login/".concat(uh?uh+"_":"","cms_users"),e)},kh=function(){return fh("/auth/verify/".concat(uh?uh+"_":"","cms_users"))},Sh=function(){return dh("/auth/user/".concat(uh?uh+"_":"","cms_users"))},Eh=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},Ch=function(){return localStorage.getItem("cms_token")},Nh=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},Oh=function(e,t){var n=t?Object.assign({},t):void 0;return(null==n?void 0:n.filters)&&Array.isArray(n.filters)&&(n.filters=JSON.stringify(n.filters)),dh("/data/".concat(uh?uh+"_":"").concat(e),n)},Ah=function(e,t){return dh("/relation/".concat(uh?uh+"_":"").concat(e,"/options"),t)},Th=function(e,t){return fh("/data/".concat(uh?uh+"_":"").concat(e),t)},Mh=function(e,t){return ph("/data/".concat(uh?uh+"_":"").concat(e),t)},Rh=function(e,t){return mh("/data/".concat(uh?uh+"_":"").concat(e,"?id=").concat(t))};function Dh(e){var n=e.onLoginSuccess,r=C(i(""),2),o=r[0],s=r[1],l=C(i(""),2),c=l[0],h=l[1],u=C(i(!1),2),d=u[0],f=u[1],p=C(i("login"),2),m=p[0],g=p[1];a(function(){var e=Ch();if(e){var t=function(){var t=w(S().m(function t(){var r;return S().w(function(t){for(;;)switch(t.p=t.n){case 0:return f(!0),t.p=1,t.n=2,kh();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,Sh();case 4:if(!(r=t.v).success||!r.data){t.n=5;break}localStorage.setItem("cms_user",JSON.stringify(r.data)),null==n||n(e,r.data),t.n=6;break;case 5:throw new Error("获取用户信息失败");case 6:t.n=8;break;case 7:t.p=7,t.v,Eh();case 8:return t.p=8,f(!1),t.f(8);case 9:return t.a(2)}},t,null,[[1,7,8,9]])}));return function(){return t.apply(this,arguments)}}();t()}},[n]),a(function(){if(!Ch()){var e=function(){var e=w(S().m(function e(){var t,n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return f(!0),e.p=1,e.n=2,yh();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?g("signup"):g("login"),e.n=4;break;case 3:e.p=3,e.v,g("login");case 4:return e.p=4,f(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}();e()}},[]);var v=function(){var e=w(S().m(function e(t){var r,i,s,a,l;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),o&&c){e.n=1;break}return Ga.error("请完善登录信息"),e.a(2);case 1:if(f(!0),e.p=2,"signup"!==m){e.n=4;break}return e.n=3,wh({username:o,password:c});case 3:a=e.v,e.n=6;break;case 4:return e.n=5,xh({username:o,password:c});case 5:a=e.v;case 6:if((s=a).success&&(null===(r=s.data)||void 0===r?void 0:r.token)){e.n=7;break}return Ga.error(s.message||"登录失败"),"signup"===m&&(null===(i=s.message)||void 0===i?void 0:i.includes("已存在管理员"))&&g("login"),e.a(2);case 7:localStorage.setItem("cms_token",s.data.token),localStorage.setItem("cms_user",JSON.stringify(s.data.user)),null==n||n(s.data.token,s.data.user),e.n=9;break;case 8:e.p=8,l=e.v,Ga.error("登陆失败,".concat(l.message||"网络错误,请稍后重试"));case 9:return e.p=9,f(!1),e.f(9);case 10:return e.a(2)}},e,null,[[2,8,9,10]])}));return function(t){return e.apply(this,arguments)}}();return t.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},t.createElement("div",{className:"pointer-events-none absolute inset-0"},t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),t.createElement("div",{className:"absolute inset-0 bg-[radial-gradient(1200px_600px_at_-10%_-10%,rgba(59,130,246,0.12),transparent),radial-gradient(900px_500px_at_110%_20%,rgba(147,51,234,0.10),transparent),radial-gradient(700px_400px_at_60%_120%,rgba(99,102,241,0.10),transparent)]"}),t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(115deg,rgba(255,255,255,0.6)_0%,rgba(255,255,255,0.15)_32%,transparent_32%,transparent_68%,rgba(255,255,255,0.15)_68%,rgba(255,255,255,0.6)_100%)]"})),t.createElement("div",{className:"flex-1 relative flex items-center justify-center"},t.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},t.createElement("div",{className:"mb-12"},t.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},t.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},"CMS 管理后台")),t.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"内容管理平台"),t.createElement("p",{className:"mt-6 text-2xl text-gray-600"},"一站式管理、协作与发布")),t.createElement("div",{className:"mt-8 flex items-center text-gray-500 gap-6"},t.createElement("span",{className:"flex items-center gap-2"},t.createElement("span",{className:"h-2 w-2 rounded-full bg-blue-500"}),"多角色权限"),t.createElement("span",{className:"flex items-center gap-2"},t.createElement("span",{className:"h-2 w-2 rounded-full bg-violet-500"}),"结构化内容"),t.createElement("span",{className:"flex items-center gap-2"},t.createElement("span",{className:"h-2 w-2 rounded-full bg-indigo-500"}),"可扩展 API")))),t.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},t.createElement("div",{className:"w-full max-w-sm"},d?t.createElement(Ma,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(La,{className:"p-8"},t.createElement("div",{className:"space-y-4"},t.createElement(tt,{className:"h-12 w-48"}),t.createElement(tt,{className:"h-4 w-64"}),t.createElement(tt,{className:"h-10 w-full"}),t.createElement(tt,{className:"h-10 w-full"})))):t.createElement(Ma,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(Ra,{className:"p-8 pb-6"},t.createElement(Da,{className:"text-center text-2xl mb-2 text-gray-800"},"signup"===m?"创建管理员账号":"欢迎使用 CMS 管理后台"),t.createElement(Pa,{className:"text-center text-gray-500"},"signup"===m?"首次进入需要先创建一个管理员账号":"请输入账号和密码登录")),t.createElement(La,{className:"p-8 pt-0"},t.createElement("form",{onSubmit:v,className:"space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement(Ta,{htmlFor:"username"},"账号/邮箱"),t.createElement("div",{className:"relative"},t.createElement(te,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(bt,{id:"username",type:"text",placeholder:"邮箱",value:o,onChange:function(e){return s(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:2}))),t.createElement("div",{className:"space-y-2"},t.createElement(Ta,{htmlFor:"password"},"密码"),t.createElement("div",{className:"relative"},t.createElement(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(bt,{id:"password",type:"password",placeholder:"密码",value:c,onChange:function(e){return h(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:6}))),t.createElement(vt,{type:"submit",className:"w-full h-12 rounded-xl transition-all duration-200 font-semibold text-base shadow-lg hover:brightness-[1.03] active:scale-[0.99]",style:{backgroundImage:"linear-gradient(135deg, rgba(236, 248, 255, 0.78) 0%, rgba(221, 238, 255, 0.78) 100%)",color:"rgba(0, 0, 0, 0.7)",border:"none",boxShadow:"0 6px 24px rgba(37, 99, 235, 0.12)"},disabled:d},t.createElement($,{className:"h-4 w-4 mr-2"}),d?"signup"===m?"创建中...":"登录中...":"signup"===m?"创建账号并进入":"登录"),t.createElement("div",{className:"text-center text-sm text-gray-500"},"signup"===m?t.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return g("login")},disabled:d},"已有账号?去登录"):t.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return g("signup")},disabled:d},"首次使用?创建管理员"))))))))}function Ph(e,[t,n]){return Math.min(n,Math.max(t,e))}function Lh(t){const n=Bh(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(_h);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function Bh(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var Ih=Symbol("radix.slottable");function _h(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Ih}var jh=e.createContext(void 0);var Fh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=Lh(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});var Wh,zh="dismissableLayer.update",Hh="dismissableLayer.pointerDownOutside",Vh="dismissableLayer.focusOutside",qh=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Uh=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,h=e.useContext(qh),[d,f]=e.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=it(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){Kh(Hh,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){Kh(Vh,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Wt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(Wh=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),$h(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Wh)}},[d,p,r,h]),e.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),$h())},[d,h]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(zh,e),()=>document.removeEventListener(zh,e)},[]),u(Fh.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Ct(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Ct(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ct(t.onPointerDownCapture,S.onPointerDownCapture)})});Uh.displayName="DismissableLayer";function $h(){const e=new CustomEvent(zh);document.dispatchEvent(e)}function Kh(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(qh),i=e.useRef(null),o=it(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),u(Fh.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var Yh="focusScope.autoFocusOnMount",Gh="focusScope.autoFocusOnUnmount",Xh={bubbles:!1,cancelable:!0},Jh=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),h=Ft(o),d=Ft(s),f=e.useRef(null),p=it(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?f.current=t:tu(f.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||tu(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&tu(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){nu.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(Yh,Xh);l.addEventListener(Yh,h),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(tu(r,{select:t}),document.activeElement!==n)return}((e=Qh(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&tu(l))}return()=>{l.removeEventListener(Yh,h),setTimeout(()=>{const e=new CustomEvent(Gh,Xh);l.addEventListener(Gh,d),l.dispatchEvent(e),e.defaultPrevented||tu(t??document.body,{select:!0}),l.removeEventListener(Gh,d),nu.remove(m)},0)}}var e},[l,h,d,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Qh(e),n=Zh(t,e),r=Zh(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&tu(o,{select:!0})):(e.preventDefault(),r&&tu(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return u(Fh.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function Qh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Zh(e,t){for(const n of e)if(!eu(n,{upTo:t}))return n}function eu(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function tu(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Jh.displayName="FocusScope";var nu=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=ru(e,t),e.unshift(t)},remove(t){e=ru(e,t),e[0]?.resume()}}}();function ru(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var iu=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return u(Fh.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u("polygon",{points:"0,0 30,0 15,10"})})});iu.displayName="Arrow";var ou=iu,su="Popper",[au,lu]=Nt(su),[cu,hu]=au(su),uu=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return u(cu,{scope:n,anchor:i,onAnchorChange:o,children:r})};uu.displayName=su;var du="PopperAnchor",fu=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=hu(du,r),a=e.useRef(null),l=it(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:u(Fh.div,{...o,ref:l})});fu.displayName=du;var pu="PopperContent",[mu,gu]=au(pu),vu=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:h=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=t,b=hu(pu,r),[y,w]=e.useState(null),x=it(n,e=>w(e)),[k,S]=e.useState(null),E=os(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==s?"-"+s:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(h)?h:[h],M=T.length>0,R={padding:A,boundary:T.filter(xu),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=Yo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>Lo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Xo({mainAxis:o+N,alignmentAxis:a}),c&&Jo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Qo():void 0,...R}),c&&Zo({...R}),es({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&ns({element:k,padding:l}),ku({arrowWidth:C,arrowHeight:N}),p&&ts({strategy:"referenceHidden",...R})]}),[_,j]=Su(L),F=Ft(g);At(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=e.useState();return At(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),u("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:u(mu,{scope:r,placedSide:_,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:u(Fh.div,{"data-side":_,"data-align":j,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});vu.displayName=pu;var bu="PopperArrow",yu={top:"bottom",right:"left",bottom:"top",left:"right"},wu=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=gu(bu,n),o=yu[i.placedSide];return u("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:u(ou,{...r,ref:t,style:{...r.style,display:"block"}})})});function xu(e){return null!==e}wu.displayName=bu;var ku=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=Su(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function Su(e){const[t,n="center"]=e.split("-");return[t,n]}var Eu=uu,Cu=fu,Nu=vu,Ou=wu,Au=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);At(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?m.createPortal(u(Fh.div,{...i,ref:n}),a):null});function Tu(t){const n=e.useRef({value:t,previous:t});return e.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}Au.displayName="Portal";var Mu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});e.forwardRef((e,t)=>u(Fh.span,{...e,ref:t,style:{...Mu,...e.style}})).displayName="VisuallyHidden";var Ru=[" ","Enter","ArrowUp","ArrowDown"],Du=[" ","Enter"],Pu="Select",[Lu,Bu,Iu]=function(e){const n=e+"CollectionProvider",[r,i]=Nt(n),[o,s]=r(n,{collectionRef:{current:null},itemMap:new Map}),a=e=>{const{scope:n,children:r}=e,i=t.useRef(null),s=t.useRef(new Map).current;return u(o,{scope:n,itemMap:s,collectionRef:i,children:r})};a.displayName=n;const l=e+"CollectionSlot",c=Lh(l),h=t.forwardRef((e,t)=>{const{scope:n,children:r}=e,i=it(t,s(l,n).collectionRef);return u(c,{ref:i,children:r})});h.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Lh(d),m=t.forwardRef((e,n)=>{const{scope:r,children:i,...o}=e,a=t.useRef(null),l=it(n,a),c=s(d,r);return t.useEffect(()=>(c.itemMap.set(a,{ref:a,...o}),()=>{c.itemMap.delete(a)})),u(p,{[f]:"",ref:l,children:i})});return m.displayName=d,[{Provider:a,Slot:h,ItemSlot:m},function(n){const r=s(e+"CollectionConsumer",n);return t.useCallback(()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},i]}(Pu),[_u,ju]=Nt(Pu,[Iu,lu]),Fu=lu(),[Wu,zu]=_u(Pu),[Hu,Vu]=_u(Pu),qu=t=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:s,value:a,defaultValue:l,onValueChange:c,dir:h,name:f,autoComplete:p,disabled:m,required:g,form:v}=t,b=Fu(n),[y,w]=e.useState(null),[x,k]=e.useState(null),[S,E]=e.useState(!1),C=function(t){const n=e.useContext(jh);return t||n||"ltr"}(h),[N,O]=Pt({prop:i,defaultProp:o??!1,onChange:s,caller:Pu}),[A,T]=Pt({prop:a,defaultProp:l,onChange:c,caller:Pu}),M=e.useRef(null),R=!y||(v||!!y.closest("form")),[D,P]=e.useState(new Set),L=Array.from(D).map(e=>e.props.value).join(";");return u(Eu,{...b,children:d(Wu,{required:g,scope:n,trigger:y,onTriggerChange:w,valueNode:x,onValueNodeChange:k,valueNodeHasChildren:S,onValueNodeHasChildrenChange:E,contentId:Rt(),value:A,onValueChange:T,open:N,onOpenChange:O,dir:C,triggerPointerDownPosRef:M,disabled:m,children:[u(Lu.Provider,{scope:n,children:u(Hu,{scope:t.__scopeSelect,onNativeOptionAdd:e.useCallback(e=>{P(t=>new Set(t).add(e))},[]),onNativeOptionRemove:e.useCallback(e=>{P(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),R?d(Md,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:p,value:A,onChange:e=>T(e.target.value),disabled:m,form:v,children:[void 0===A?u("option",{value:""}):null,Array.from(D)]},L):null]})})};qu.displayName=Pu;var Uu="SelectTrigger",$u=e.forwardRef((t,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=t,s=Fu(r),a=zu(Uu,r),l=a.disabled||i,c=it(n,a.onTriggerChange),h=Bu(r),d=e.useRef("touch"),[f,p,m]=Dd(e=>{const t=h().filter(e=>!e.disabled),n=t.find(e=>e.value===a.value),r=Pd(t,e,n);void 0!==r&&a.onValueChange(r.value)}),g=e=>{l||(a.onOpenChange(!0),m()),e&&(a.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return u(Cu,{asChild:!0,...s,children:u(Fh.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Rd(a.value)?"":void 0,...o,ref:c,onClick:Ct(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==d.current&&g(e)}),onPointerDown:Ct(o.onPointerDown,e=>{d.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(g(e),e.preventDefault())}),onKeyDown:Ct(o.onKeyDown,e=>{const t=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||Ru.includes(e.key)&&(g(),e.preventDefault())})})})});$u.displayName=Uu;var Ku="SelectValue",Yu=e.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=zu(Ku,n),{onValueNodeHasChildrenChange:c}=l,h=void 0!==o,d=it(t,l.onValueNodeChange);return At(()=>{c(h)},[c,h]),u(Fh.span,{...a,ref:d,style:{pointerEvents:"none"},children:Rd(l.value)?u(f,{children:s}):o})});Yu.displayName=Ku;var Gu=e.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return u(Fh.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});Gu.displayName="SelectIcon";var Xu=e=>u(Au,{asChild:!0,...e});Xu.displayName="SelectPortal";var Ju="SelectContent",Qu=e.forwardRef((t,n)=>{const r=zu(Ju,t.__scopeSelect),[i,o]=e.useState();if(At(()=>{o(new DocumentFragment)},[]),!r.open){const e=i;return e?p.createPortal(u(ed,{scope:t.__scopeSelect,children:u(Lu.Slot,{scope:t.__scopeSelect,children:u("div",{children:t.children})})}),e):null}return u(rd,{...t,ref:n})});Qu.displayName=Ju;var Zu=10,[ed,td]=_u(Ju),nd=Lh("SelectContent.RemoveScroll"),rd=e.forwardRef((t,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:l,sideOffset:c,align:h,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b,...y}=t,w=zu(Ju,r),[x,k]=e.useState(null),[S,E]=e.useState(null),C=it(n,e=>k(e)),[N,O]=e.useState(null),[A,T]=e.useState(null),M=Bu(r),[R,D]=e.useState(!1),P=e.useRef(!1);e.useEffect(()=>{if(x)return ir(x)},[x]),hn();const L=e.useCallback(e=>{const[t,...n]=M().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(const n of e){if(n===i)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i)return}},[M,S]),B=e.useCallback(()=>L([N,x]),[L,N,x]);e.useEffect(()=>{R&&B()},[R,B]);const{onOpenChange:I,triggerPointerDownPosRef:_}=w;e.useEffect(()=>{if(x){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(_.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(_.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():x.contains(n.target)||I(!1),document.removeEventListener("pointermove",t),_.current=null};return null!==_.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[x,I,_]),e.useEffect(()=>{const e=()=>I(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[I]);const[j,F]=Dd(e=>{const t=M().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=Pd(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),W=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&(O(e),r&&(P.current=!0))},[w.value]),z=e.useCallback(()=>x?.focus(),[x]),H=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&T(e)},[w.value]),V="popper"===i?od:id,q=V===od?{side:l,sideOffset:c,align:h,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b}:{};return u(ed,{scope:r,content:x,viewport:S,onViewportChange:E,itemRefCallback:W,selectedItem:N,onItemLeave:z,itemTextRefCallback:H,focusSelectedItem:B,selectedItemText:A,position:i,isPositioned:R,searchRef:j,children:u(Jn,{as:nd,allowPinchZoom:!0,children:u(Jh,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Ct(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:u(Uh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u(V,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:e=>e.preventDefault(),...y,...q,onPlaced:()=>D(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:Ct(y.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||F(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=M().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});rd.displayName="SelectContentImpl";var id=e.forwardRef((t,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=t,s=zu(Ju,r),a=td(Ju,r),[l,c]=e.useState(null),[h,d]=e.useState(null),f=it(n,e=>d(e)),p=Bu(r),m=e.useRef(!1),g=e.useRef(!0),{viewport:v,selectedItem:b,selectedItemText:y,focusSelectedItem:w}=a,x=e.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&h&&v&&b&&y){const e=s.trigger.getBoundingClientRect(),t=h.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),r=y.getBoundingClientRect();if("rtl"!==s.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,c=Math.max(a,t.width),h=window.innerWidth-Zu,u=Ph(o,[Zu,Math.max(Zu,h-c)]);l.style.minWidth=a+"px",l.style.left=u+"px"}else{const i=t.right-r.right,o=window.innerWidth-n.right-i,s=window.innerWidth-e.right-o,a=e.width+s,c=Math.max(a,t.width),h=window.innerWidth-Zu,u=Ph(o,[Zu,Math.max(Zu,h-c)]);l.style.minWidth=a+"px",l.style.right=u+"px"}const o=p(),a=window.innerHeight-2*Zu,c=v.scrollHeight,u=window.getComputedStyle(h),d=parseInt(u.borderTopWidth,10),f=parseInt(u.paddingTop,10),g=parseInt(u.borderBottomWidth,10),w=d+f+c+parseInt(u.paddingBottom,10)+g,x=Math.min(5*b.offsetHeight,w),k=window.getComputedStyle(v),S=parseInt(k.paddingTop,10),E=parseInt(k.paddingBottom,10),C=e.top+e.height/2-Zu,N=a-C,O=b.offsetHeight/2,A=d+f+(b.offsetTop+O),T=w-A;if(A<=C){const e=o.length>0&&b===o[o.length-1].ref.current;l.style.bottom="0px";const t=h.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(N,O+(e?E:0)+t+g);l.style.height=n+"px"}else{const e=o.length>0&&b===o[0].ref.current;l.style.top="0px";const t=Math.max(C,d+v.offsetTop+(e?S:0)+O)+T;l.style.height=t+"px",v.scrollTop=A-C+v.offsetTop}l.style.margin=`${Zu}px 0`,l.style.minHeight=x+"px",l.style.maxHeight=a+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,l,h,v,b,y,s.dir,i]);At(()=>x(),[x]);const[k,S]=e.useState();At(()=>{h&&S(window.getComputedStyle(h).zIndex)},[h]);const E=e.useCallback(e=>{e&&!0===g.current&&(x(),w?.(),g.current=!1)},[x,w]);return u(sd,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:u("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u(Fh.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});id.displayName="SelectItemAlignedPosition";var od=e.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Zu,...o}=e,s=Fu(n);return u(Nu,{...s,...o,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});od.displayName="SelectPopperPosition";var[sd,ad]=_u(Ju,{}),ld="SelectViewport",cd=e.forwardRef((t,n)=>{const{__scopeSelect:r,nonce:i,...o}=t,s=td(ld,r),a=ad(ld,r),l=it(n,s.onViewportChange),c=e.useRef(0);return d(f,{children:[u("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),u(Lu.Slot,{scope:r,children:u(Fh.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ct(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=a;if(r?.current&&n){const e=Math.abs(c.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*Zu,i=parseFloat(n.style.minHeight),o=parseFloat(n.style.height),s=Math.max(i,o);if(s<r){const i=s+e,o=Math.min(r,i),a=i-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=a>0?a:0,n.style.justifyContent="flex-end")}}}c.current=t.scrollTop})})})]})});cd.displayName=ld;var hd="SelectGroup",[ud,dd]=_u(hd);e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Rt();return u(ud,{scope:n,id:i,children:u(Fh.div,{role:"group","aria-labelledby":i,...r,ref:t})})}).displayName=hd;var fd="SelectLabel",pd=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=dd(fd,n);return u(Fh.div,{id:i.id,...r,ref:t})});pd.displayName=fd;var md="SelectItem",[gd,vd]=_u(md),bd=e.forwardRef((t,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:s,...a}=t,l=zu(md,r),c=td(md,r),h=l.value===i,[d,f]=e.useState(s??""),[p,m]=e.useState(!1),g=it(n,e=>c.itemRefCallback?.(e,i,o)),v=Rt(),b=e.useRef("touch"),y=()=>{o||(l.onValueChange(i),l.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u(gd,{scope:r,value:i,disabled:o,textId:v,isSelected:h,onItemTextChange:e.useCallback(e=>{f(t=>t||(e?.textContent??"").trim())},[]),children:u(Lu.ItemSlot,{scope:r,value:i,disabled:o,textValue:d,children:u(Fh.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":h&&p,"data-state":h?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:Ct(a.onFocus,()=>m(!0)),onBlur:Ct(a.onBlur,()=>m(!1)),onClick:Ct(a.onClick,()=>{"mouse"!==b.current&&y()}),onPointerUp:Ct(a.onPointerUp,()=>{"mouse"===b.current&&y()}),onPointerDown:Ct(a.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:Ct(a.onPointerMove,e=>{b.current=e.pointerType,o?c.onItemLeave?.():"mouse"===b.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ct(a.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Ct(a.onKeyDown,e=>{""!==c.searchRef?.current&&" "===e.key||(Du.includes(e.key)&&y()," "===e.key&&e.preventDefault())})})})})});bd.displayName=md;var yd="SelectItemText",wd=e.forwardRef((t,n)=>{const{__scopeSelect:r,className:i,style:o,...s}=t,a=zu(yd,r),l=td(yd,r),c=vd(yd,r),h=Vu(yd,r),[m,g]=e.useState(null),v=it(n,e=>g(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),b=m?.textContent,y=e.useMemo(()=>u("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:w,onNativeOptionRemove:x}=h;return At(()=>(w(y),()=>x(y)),[w,x,y]),d(f,{children:[u(Fh.span,{id:c.textId,...s,ref:v}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?p.createPortal(s.children,a.valueNode):null]})});wd.displayName=yd;var xd="SelectItemIndicator",kd=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return vd(xd,n).isSelected?u(Fh.span,{"aria-hidden":!0,...r,ref:t}):null});kd.displayName=xd;var Sd="SelectScrollUpButton",Ed=e.forwardRef((t,n)=>{const r=td(Sd,t.__scopeSelect),i=ad(Sd,t.__scopeSelect),[o,s]=e.useState(!1),a=it(n,i.onScrollButtonChange);return At(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;s(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?u(Od,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});Ed.displayName=Sd;var Cd="SelectScrollDownButton",Nd=e.forwardRef((t,n)=>{const r=td(Cd,t.__scopeSelect),i=ad(Cd,t.__scopeSelect),[o,s]=e.useState(!1),a=it(n,i.onScrollButtonChange);return At(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;s(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?u(Od,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});Nd.displayName=Cd;var Od=e.forwardRef((t,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=t,s=td("SelectScrollButton",r),a=e.useRef(null),l=Bu(r),c=e.useCallback(()=>{null!==a.current&&(window.clearInterval(a.current),a.current=null)},[]);return e.useEffect(()=>()=>c(),[c]),At(()=>{const e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),u(Fh.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:Ct(o.onPointerDown,()=>{null===a.current&&(a.current=window.setInterval(i,50))}),onPointerMove:Ct(o.onPointerMove,()=>{s.onItemLeave?.(),null===a.current&&(a.current=window.setInterval(i,50))}),onPointerLeave:Ct(o.onPointerLeave,()=>{c()})})}),Ad=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u(Fh.div,{"aria-hidden":!0,...r,ref:t})});Ad.displayName="SelectSeparator";var Td="SelectArrow";e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Fu(n),o=zu(Td,n),s=td(Td,n);return o.open&&"popper"===s.position?u(Ou,{...i,...r,ref:t}):null}).displayName=Td;var Md=e.forwardRef(({__scopeSelect:t,value:n,...r},i)=>{const o=e.useRef(null),s=it(i,o),a=Tu(n);return e.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(a!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[a,n]),u(Fh.select,{...r,style:{...Mu,...r.style},ref:s,defaultValue:n})});function Rd(e){return""===e||void 0===e}function Dd(t){const n=Ft(t),r=e.useRef(""),i=e.useRef(0),o=e.useCallback(e=>{const t=r.current+e;n(t),function e(t){r.current=t,window.clearTimeout(i.current),""!==t&&(i.current=window.setTimeout(()=>e(""),1e3))}(t)},[n]),s=e.useCallback(()=>{r.current="",window.clearTimeout(i.current)},[]);return e.useEffect(()=>()=>window.clearTimeout(i.current),[]),[r,o,s]}function Pd(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=(s=e,a=Math.max(i,0),s.map((e,t)=>s[(a+t)%s.length]));var s,a;1===r.length&&(o=o.filter(e=>e!==n));const l=o.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}Md.displayName="SelectBubbleInput";var Ld=$u,Bd=Gu,Id=Xu,_d=Qu,jd=cd,Fd=pd,Wd=bd,zd=wd,Hd=kd,Vd=Ed,qd=Nd,Ud=Ad,$d=qu,Kd=Yu,Yd=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=oe(t,["className","children"]);return e.createElement(Ld,Object.assign({ref:n,className:et("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",r)},o),i,e.createElement(Bd,{asChild:!0},e.createElement(L,{className:"h-4 w-4 opacity-50"})))});Yd.displayName=Ld.displayName;var Gd=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Vd,Object.assign({ref:n,className:et("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(_,{className:"h-4 w-4"}))});Gd.displayName=Vd.displayName;var Xd=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(qd,Object.assign({ref:n,className:et("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(L,{className:"h-4 w-4"}))});Xd.displayName=qd.displayName;var Jd=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=t.position,s=void 0===o?"popper":o,a=oe(t,["className","children","position"]);return e.createElement(Id,null,e.createElement(_d,Object.assign({ref:n,className:et("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",r),position:s},a),e.createElement(Gd,null),e.createElement(jd,{className:et("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},i),e.createElement(Xd,null)))});Jd.displayName=_d.displayName;var Qd=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Fd,Object.assign({ref:n,className:et("py-1.5 pl-8 pr-2 text-sm font-semibold",r)},i))});Qd.displayName=Fd.displayName;var Zd=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=oe(t,["className","children"]);return e.createElement(Wd,Object.assign({ref:n,className:et("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(Hd,null,e.createElement(P,{className:"h-4 w-4"}))),e.createElement(zd,null,i))});Zd.displayName=Wd.displayName;var ef=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Ud,Object.assign({ref:n,className:et("-mx-1 my-1 h-px bg-muted",r)},i))});function tf(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}ef.displayName=Ud.displayName;var nf=Symbol("radix.slottable");function rf(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===nf}var of=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=function(t){const n=tf(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(rf);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),sf="Switch",[af,lf]=Nt(sf),[cf,hf]=af(sf),uf=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:s,required:a,disabled:l,value:c="on",onCheckedChange:h,form:f,...p}=t,[m,g]=e.useState(null),v=it(n,e=>g(e)),b=e.useRef(!1),y=!m||(f||!!m.closest("form")),[w,x]=Pt({prop:o,defaultProp:s??!1,onChange:h,caller:sf});return d(cf,{scope:r,checked:w,disabled:l,children:[u(of.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":mf(w),"data-disabled":l?"":void 0,disabled:l,value:c,...p,ref:v,onClick:Ct(t.onClick,e=>{x(e=>!e),y&&(b.current=e.isPropagationStopped(),b.current||e.stopPropagation())})}),y&&u(pf,{control:m,bubbles:!b.current,name:i,value:c,checked:w,required:a,disabled:l,form:f,style:{transform:"translateX(-100%)"}})]})});uf.displayName=sf;var df="SwitchThumb",ff=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=hf(df,n);return u(of.span,{"data-state":mf(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});ff.displayName=df;var pf=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:i=!0,...o},s)=>{const a=e.useRef(null),l=it(a,s),c=Tu(r),h=os(n);return e.useEffect(()=>{const e=a.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(c!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[c,r,i]),u("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:l,style:{...o.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function mf(e){return e?"checked":"unchecked"}pf.displayName="SwitchBubbleInput";var gf=uf,vf=ff,bf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(gf,Object.assign({className:et("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",r)},i,{ref:n}),e.createElement(vf,{className:et("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}))});bf.displayName=gf.displayName;var yf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("textarea",Object.assign({className:et("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:n},i))});yf.displayName="Textarea";var wf=jr,xf=Fr,kf=Wr,Sf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(zr,Object.assign({ref:n,className:et("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i))});Sf.displayName=zr.displayName;var Ef=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=oe(t,["className","children"]);return e.createElement(kf,null,e.createElement(Sf,null),e.createElement(Hr,Object.assign({ref:n,className:et("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",r)},o),i,e.createElement(Ur,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"},e.createElement(re,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});Ef.displayName=Hr.displayName;var Cf=function(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col space-y-1.5 text-center sm:text-left",n)},r))};Cf.displayName="DialogHeader";var Nf=function(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n)},r))};Nf.displayName="DialogFooter";var Of=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Vr,Object.assign({ref:n,className:et("text-lg font-semibold leading-none tracking-tight",r)},i))});Of.displayName=Vr.displayName;var Af,Tf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(qr,Object.assign({ref:n,className:et("text-sm text-muted-foreground",r)},i))});function Mf(e,t=!1){const n=e.length;let r=0,i="",o=0,s=16,a=0,l=0,c=0,h=0,u=0;function d(t,n){let i=0,o=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)o=16*o+t-48;else if(t>=65&&t<=70)o=16*o+t-65+10;else{if(!(t>=97&&t<=102))break;o=16*o+t-97+10}r++,i++}return i<t&&(o=-1),o}function f(){if(i="",u=0,o=r,l=a,h=c,r>=n)return o=n,s=17;let t=e.charCodeAt(r);if(Rf(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(Rf(t));return s=15}if(Df(t))return r++,i+=String.fromCharCode(t),13===t&&10===e.charCodeAt(r)&&(r++,i+="\n"),a++,c=r,s=14;switch(t){case 123:return r++,s=1;case 125:return r++,s=2;case 91:return r++,s=3;case 93:return r++,s=4;case 58:return r++,s=6;case 44:return r++,s=5;case 34:return r++,i=function(){let t="",i=r;for(;;){if(r>=n){t+=e.substring(i,r),u=2;break}const o=e.charCodeAt(r);if(34===o){t+=e.substring(i,r),r++;break}if(92!==o){if(o>=0&&o<=31){if(Df(o)){t+=e.substring(i,r),u=2;break}u=6}r++}else{if(t+=e.substring(i,r),r++,r>=n){u=2;break}switch(e.charCodeAt(r++)){case 34:t+='"';break;case 92:t+="\\";break;case 47:t+="/";break;case 98:t+="\b";break;case 102:t+="\f";break;case 110:t+="\n";break;case 114:t+="\r";break;case 116:t+="\t";break;case 117:const e=d(4,!0);e>=0?t+=String.fromCharCode(e):u=4;break;default:u=5}i=r}}return t}(),s=10;case 47:const l=r-1;if(47===e.charCodeAt(r+1)){for(r+=2;r<n&&!Df(e.charCodeAt(r));)r++;return i=e.substring(l,r),s=12}if(42===e.charCodeAt(r+1)){r+=2;const t=n-1;let o=!1;for(;r<t;){const t=e.charCodeAt(r);if(42===t&&47===e.charCodeAt(r+1)){r+=2,o=!0;break}r++,Df(t)&&(13===t&&10===e.charCodeAt(r)&&r++,a++,c=r)}return o||(r++,u=1),i=e.substring(l,r),s=13}return i+=String.fromCharCode(t),r++,s=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!Pf(e.charCodeAt(r)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=function(){let t=r;if(48===e.charCodeAt(r))r++;else for(r++;r<e.length&&Pf(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(r++,!(r<e.length&&Pf(e.charCodeAt(r))))return u=3,e.substring(t,r);for(r++;r<e.length&&Pf(e.charCodeAt(r));)r++}let n=r;if(r<e.length&&(69===e.charCodeAt(r)||101===e.charCodeAt(r)))if(r++,(r<e.length&&43===e.charCodeAt(r)||45===e.charCodeAt(r))&&r++,r<e.length&&Pf(e.charCodeAt(r))){for(r++;r<e.length&&Pf(e.charCodeAt(r));)r++;n=r}else u=3;return e.substring(t,n)}(),s=11;default:for(;r<n&&p(t);)r++,t=e.charCodeAt(r);if(o!==r){switch(i=e.substring(o,r),i){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return i+=String.fromCharCode(t),r++,s=16}}function p(e){if(Rf(e)||Df(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}return{setPosition:function(e){r=e,i="",o=0,s=16,u=0},getPosition:()=>r,scan:t?function(){let e;do{e=f()}while(e>=12&&e<=15);return e}:f,getToken:()=>s,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>r-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-h,getTokenError:()=>u}}function Rf(e){return 32===e||9===e}function Df(e){return 10===e||13===e}function Pf(e){return e>=48&&e<=57}Tf.displayName=qr.displayName,function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"}(Af||(Af={}));const Lf=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),Bf=200,If={" ":{"\n":new Array(Bf).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":new Array(Bf).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(Bf).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))},"\t":{"\n":new Array(Bf).fill(0).map((e,t)=>"\n"+"\t".repeat(t)),"\r":new Array(Bf).fill(0).map((e,t)=>"\r"+"\t".repeat(t)),"\r\n":new Array(Bf).fill(0).map((e,t)=>"\r\n"+"\t".repeat(t))}},_f=["\n","\r","\r\n"];function jf(e,t,n){let r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!Wf(e,o-1);)o--;let l=a;for(;l<e.length&&!Wf(e,l);)l++;i=e.substring(o,l),r=function(e,t){let n=0,r=0;const i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===Lf[1])r++;else{if("\t"!==t)break;r+=i}n++}return Math.floor(r/i)}(i,n)}else i=e,r=0,o=0,s=0,a=e.length;const l=function(e,t){for(let e=0;e<t.length;e++){const n=t.charAt(e);if("\r"===n)return e+1<t.length&&"\n"===t.charAt(e+1)?"\r\n":"\r";if("\n"===n)return"\n"}return e&&e.eol||"\n"}(n,e),c=_f.includes(l);let h,u=0,d=0;h=n.insertSpaces?Lf[n.tabSize||4]??Ff(Lf[1],n.tabSize||4):"\t";const f="\t"===h?"\t":" ";let p=Mf(i,!1),m=!1;function g(){if(u>1)return Ff(l,u)+Ff(h,r+d);const e=h.length*(r+d);return!c||e>If[f][l].length?l+Ff(h,r+d):e<=0?l:If[f][l][e]}function v(){let e=p.scan();for(u=0;15===e||14===e;)14===e&&n.keepLines?u+=1:14===e&&(u=1),e=p.scan();return m=16===e||0!==p.getTokenError(),e}const b=[];function y(n,r,i){m||t&&!(r<a&&i>s)||e.substring(r,i)===n||b.push({offset:r,length:i-r,content:n})}let w=v();if(n.keepLines&&u>0&&y(Ff(l,u),0,0),17!==w){let e=p.getTokenOffset()+o;y(h.length*r<20&&n.insertSpaces?Lf[h.length*r]:Ff(h,r),o,e)}for(;17!==w;){let e=p.getTokenOffset()+p.getTokenLength()+o,t=v(),r="",i=!1;for(;0===u&&(12===t||13===t);){let n=p.getTokenOffset()+o;y(Lf[1],e,n),e=p.getTokenOffset()+p.getTokenLength()+o,i=12===t,r=i?g():"",t=v()}if(2===t)1!==w&&d--,n.keepLines&&u>0||!n.keepLines&&1!==w?r=g():n.keepLines&&(r=Lf[1]);else if(4===t)3!==w&&d--,n.keepLines&&u>0||!n.keepLines&&3!==w?r=g():n.keepLines&&(r=Lf[1]);else{switch(w){case 3:case 1:d++,r=n.keepLines&&u>0||!n.keepLines?g():Lf[1];break;case 5:r=n.keepLines&&u>0||!n.keepLines?g():Lf[1];break;case 12:r=g();break;case 13:u>0?r=g():i||(r=Lf[1]);break;case 6:n.keepLines&&u>0?r=g():i||(r=Lf[1]);break;case 10:n.keepLines&&u>0?r=g():6!==t||i||(r="");break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&u>0?r=g():12!==t&&13!==t||i?5!==t&&17!==t&&(m=!0):r=Lf[1];break;case 16:m=!0}u>0&&(12===t||13===t)&&(r=g())}17===t&&(r=n.keepLines&&u>0?g():n.insertFinalNewline?l:"");y(r,e,p.getTokenOffset()+o),w=t}return b}function Ff(e,t){let n="";for(let r=0;r<t;r++)n+=e;return n}function Wf(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}var zf,Hf,Vf;!function(e){e.DEFAULT={allowTrailingComma:!1}}(zf||(zf={})),function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"}(Hf||(Hf={})),function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"}(Vf||(Vf={}));const qf=function(e,t=[],n=zf.DEFAULT){let r=null,i=[];const o=[];function s(e){Array.isArray(i)?i.push(e):null!==r&&(i[r]=e)}const a={onObjectBegin:()=>{const e={};s(e),o.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{const e=[];s(e),o.push(i),i=e,r=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:s,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}};return function(e,t,n=zf.DEFAULT){const r=Mf(e,!1),i=[];let o=0;function s(e){return e?()=>0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(e){return e?()=>{if(o>0)o++;else{!1===e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())&&(o=1)}}:()=>!0}function h(e){return e?()=>{o>0&&o--,0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const u=c(t.onObjectBegin),d=l(t.onObjectProperty),f=h(t.onObjectEnd),p=c(t.onArrayBegin),m=h(t.onArrayEnd),g=l(t.onLiteralValue),v=a(t.onSeparator),b=s(t.onComment),y=a(t.onError),w=n&&n.disallowComments,x=n&&n.allowTrailingComma;function k(){for(;;){const e=r.scan();switch(r.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:w||S(11);break;case 2:S(12);break;case 6:S(16)}switch(e){case 12:case 13:w?S(10):b();break;case 16:S(1);break;case 15:case 14:break;default:return e}}}function S(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;17!==e;){if(-1!==t.indexOf(e)){k();break}if(-1!==n.indexOf(e))break;e=k()}}}function E(e){const t=r.getTokenValue();return e?g(t):(d(t),i.push(t)),k(),!0}function C(){switch(r.getToken()){case 11:const e=r.getTokenValue();let t=Number(e);isNaN(t)&&(S(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return k(),!0}function N(){return 10!==r.getToken()?(S(3,[],[2,5]),!1):(E(!1),6===r.getToken()?(v(":"),k(),T()||S(4,[],[2,5])):S(5,[],[2,5]),i.pop(),!0)}function O(){u(),k();let e=!1;for(;2!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(e||S(4,[],[]),v(","),k(),2===r.getToken()&&x)break}else e&&S(6,[],[]);N()||S(4,[],[2,5]),e=!0}return f(),2!==r.getToken()?S(7,[2],[]):k(),!0}function A(){p(),k();let e=!0,t=!1;for(;4!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(t||S(4,[],[]),v(","),k(),4===r.getToken()&&x)break}else t&&S(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,T()||S(4,[],[4,5]),t=!0}return m(),e||i.pop(),4!==r.getToken()?S(8,[4],[]):k(),!0}function T(){switch(r.getToken()){case 3:return A();case 1:return O();case 10:return E(!0);default:return C()}}if(k(),17===r.getToken())return!!n.allowEmptyContent||(S(4,[],[]),!1);if(!T())return S(4,[],[]),!1;17!==r.getToken()&&S(9,[],[])}(e,a,n),i[0]};var Uf;function $f(e,t){if(!t.length)return"JSON 格式不正确";var n=t[0],r=function(e,t){for(var n=1,r=1,i=Math.max(0,Math.min(t,e.length)),o=0;o<i;o++){"\n"===e.charAt(o)?(n++,r=1):r++}return{line:n,col:r}}(e,n.offset),i=r.line,o=r.col,s=function(e){switch(e){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}(n.error);return"JSON 格式不正确(".concat(s,",行 ").concat(i," 列 ").concat(o,")")}function Kf(e){if(null==e||""===e)return{ok:!0,value:null,pretty:"null",compact:"null"};try{if("string"!=typeof e)return{ok:!0,value:e,pretty:JSON.stringify(e,null,2),compact:JSON.stringify(e)};var t=e,n=[],r=qf(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:$f(t,n),pretty:t,compact:t}:{ok:!0,value:r,pretty:JSON.stringify(r,null,2),compact:JSON.stringify(r)}}catch(t){var i="string"==typeof e?e:String(e);return{ok:!1,message:"JSON 格式不正确",pretty:i,compact:i}}}function Yf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(qf(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:$f(n,r)};for(var i=function(e,t,n){return jf(e,t,n)}(n,void 0,{insertSpaces:!0,tabSize:t}),o=n,s=i.length-1;s>=0;s--){var a=i[s];o=o.slice(0,a.offset)+a.content+o.slice(a.offset+a.length)}return{ok:!0,formatted:o}}function Gf(){return Gf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gf.apply(null,arguments)}!function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"}(Uf||(Uf={}));let Xf=[],Jf=[];function Qf(e){if(e<768)return!1;for(let t=0,n=Xf.length;;){let r=t+n>>1;if(e<Xf[r])n=r;else{if(!(e>=Jf[r]))return!0;t=r+1}if(t==n)return!1}}function Zf(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Jf:Xf).push(n+=e[t])})();function ep(e,t,n=!0,r=!0){return(n?tp:np)(e,t,r)}function tp(e,t,n){if(t==e.length)return t;t&&ip(e.charCodeAt(t))&&op(e.charCodeAt(t-1))&&t--;let r=rp(e,t);for(t+=sp(r);t<e.length;){let i=rp(e,t);if(8205==r||8205==i||n&&Qf(i))t+=sp(i),r=i;else{if(!Zf(i))break;{let n=0,r=t-2;for(;r>=0&&Zf(rp(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function np(e,t,n){for(;t>0;){let r=tp(e,t-2,n);if(r<t)return r;t--}return 0}function rp(e,t){let n=e.charCodeAt(t);if(!op(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ip(r)?r-56320+(n-55296<<10)+65536:n}function ip(e){return e>=56320&&e<57344}function op(e){return e>=55296&&e<56320}function sp(e){return e<65536?1:2}class ap{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=gp(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),cp.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=gp(this,e,t);let n=[];return this.decompose(e,t,n,0),cp.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new dp(this),i=new dp(e);for(let e=t,o=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(o+=r.value.length,r.done||o>=n)return!0}}iter(e=1){return new dp(this,e)}iterRange(e,t=this.length){return new fp(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new pp(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new lp(e):cp.from(lp.split(e,[])):ap.empty}}class lp extends ap{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new mp(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new lp(up(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=hp(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new lp(t,e.length+i.length));else{let e=t.length>>1;n.push(new lp(t.slice(0,e)),new lp(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof lp))return super.replace(e,t,n);[e,t]=gp(this,e,t);let r=hp(this.text,hp(n.text,up(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new lp(r,i):cp.from(lp.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=gp(this,e,t);let r="";for(let i=0,o=0;i<=t&&o<this.text.length;o++){let s=this.text[o],a=i+s.length;i>e&&o&&(r+=n),e<a&&t>i&&(r+=s.slice(Math.max(0,e-i),t-i)),i=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new lp(n,r)),n=[],r=-1);return r>-1&&t.push(new lp(n,r)),t}}class cp extends ap{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}decompose(e,t,n,r){for(let i=0,o=0;o<=t&&i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e<=a&&t>=o){let i=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!i?n.push(s):s.decompose(e-o,t-o,n,i)}o=a+1}}replace(e,t,n){if([e,t]=gp(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let o=this.children[r],s=i+o.length;if(e>=i&&t<=s){let a=o.replace(e-i,t-i,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let i=this.children.slice();return i[r]=a,new cp(i,this.length-(t-e)+n.length)}return super.replace(i,s,a)}i=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=gp(this,e,t);let r="";for(let i=0,o=0;i<this.children.length&&o<=t;i++){let s=this.children[i],a=o+s.length;o>e&&i&&(r+=n),e<a&&t>o&&(r+=s.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof cp))return 0;let n=0,[r,i,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==o||i==s)return n;let a=this.children[r],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new lp(n,t)}let r=Math.max(32,n>>5),i=r<<1,o=r>>1,s=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>i&&e instanceof cp)for(let t of e.children)h(t);else e.lines>o&&(a>o||!a)?(u(),s.push(e)):e instanceof lp&&a&&(t=c[c.length-1])instanceof lp&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new lp(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>r&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(s.push(1==c.length?c[0]:cp.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==s.length?s[0]:new cp(s,t)}}function hp(e,t,n=0,r=1e9){for(let i=0,o=0,s=!0;o<e.length&&i<=r;o++){let a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function up(e,t,n){return hp(e,[""],t,n)}ap.empty=new lp([""],0);class dp{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof lp?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof lp?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof lp){let i=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[o+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof lp?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class fp{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new dp(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),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 pp{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(ap.prototype[Symbol.iterator]=function(){return this.iter()},dp.prototype[Symbol.iterator]=fp.prototype[Symbol.iterator]=pp.prototype[Symbol.iterator]=function(){return this});class mp{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function gp(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function vp(e,t,n=!0,r=!0){return ep(e,t,n,r)}function bp(e,t){let n=e.charCodeAt(t);if(!(r=n,r>=55296&&r<56320&&t+1!=e.length))return n;var r;let i=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(i)?i-56320+(n-55296<<10)+65536:n}function yp(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function wp(e){return e<65536?1:2}const xp=/\r\n?|\n/;var kp=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(kp||(kp={}));class Sp{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,i),r+=i):r+=o,n+=i}}iterChangedRanges(e,t=!1){Op(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new Sp(e)}composeDesc(e){return this.empty?e:e.empty?this:Tp(this,e)}mapDesc(e,t=!1){return e.empty?this:Ap(this,e,t)}mapPos(e,t=-1,n=kp.Simple){let r=0,i=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=r+s;if(a<0){if(l>e)return i+(e-r);i+=s}else{if(n!=kp.Simple&&l>=e&&(n==kp.TrackDel&&r<e&&l>e||n==kp.TrackBefore&&r<e||n==kp.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=r+this.sections[n++];if(this.sections[n++]>=0&&r<=t&&i>=e)return!(r<e&&i>t)||"cover";r=i}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Sp(e)}static create(e){return new Sp(e)}}class Ep extends Sp{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Op(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Ap(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let o=t[r],s=t[r+1];if(s>=0){t[r]=s,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(ap.empty);n.push(o?e.slice(i,i+o):ap.empty)}i+=o}return new Ep(t,n)}compose(e){return this.empty?e:e.empty?this:Tp(this,e,!0)}map(e,t=!1){return e.empty?this:Ap(this,e,t,!0)}iterChanges(e,t=!1){Op(this,e,t)}get desc(){return Sp.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new Mp(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==i.len;){if(i.done)break e;let e=Math.min(i.len,a-s);Cp(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;Cp(t,e,o),o>0&&Np(n,t,i.text),i.forward(e),s+=e}let l=e[o++];for(;s<l;){if(i.done)break e;let e=Math.min(i.len,l-s);Cp(t,e,-1),Cp(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new Ep(t,n),filtered:Sp.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],o=0,s=null;function a(e=!1){if(!e&&!r.length)return;o<t&&Cp(r,t-o,-1);let n=new Ep(r,i);s=s?s.compose(n.map(s)):n,r=[],i=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof Ep){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=c?"string"==typeof c?ap.of(c.split(n||xp)):c:ap.empty,u=h.length;if(e==s&&0==u)return;e<o&&a(),e>o&&Cp(r,e-o,-1),Cp(r,s-e,u),Np(i,r,h),o=s}}(e),a(!s),s}static empty(e){return new Ep(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else{if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(ap.empty);n[r]=ap.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new Ep(t,n)}static createSet(e,t){return new Ep(e,t)}}function Cp(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Np(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(ap.empty);e.push(n)}}function Op(e,t,n){let r=e.inserted;for(let i=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{let c=i,h=o,u=ap.empty;for(;c+=a,h+=l,l&&r&&(u=u.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,h,u),i=c,o=h}}}function Ap(e,t,n,r=!1){let i=[],o=r?[]:null,s=new Mp(e),a=new Mp(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);Cp(i,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(Cp(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(Cp(i,0,s.ins),o&&Np(o,i,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?Ep.createSet(i,o):Sp.create(i);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}Cp(i,t,e<s.i?s.ins:0),o&&e<s.i&&Np(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function Tp(e,t,n=!1){let r=[],i=n?[]:null,o=new Mp(e),s=new Mp(t);for(let e=!1;;){if(o.done&&s.done)return i?Ep.createSet(r,i):Sp.create(r);if(0==o.ins)Cp(r,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=r.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;Cp(r,t,n,e),i&&n&&Np(i,r,s.text)}else-1==s.ins?(Cp(r,o.off?0:o.len,t,e),i&&Np(i,r,o.textBit(t))):(Cp(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&Np(i,r,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||r.length>n),o.forward2(t),s.forward(t)}}else Cp(r,0,s.ins,e),i&&Np(i,r,s.text),s.next()}}class Mp{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ap.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ap.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Rp{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new Rp(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return Dp.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Dp.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Dp.range(e.anchor,e.head)}static create(e,t,n){return new Rp(e,t,n)}}class Dp{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:Dp.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new Dp([this.main],0)}addRange(e,t=!0){return Dp.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,Dp.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Dp(e.ranges.map(e=>Rp.fromJSON(e)),e.main)}static single(e,t=e){return new Dp([Dp.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return Dp.normalized(e.slice(),t);n=i.to}return new Dp(e,t)}static cursor(e,t=0,n,r){return Rp.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:16777215)<<6)}static range(e,t,n,r){let i=(null!=n?n:16777215)<<6|(null==r?7:Math.min(6,r));return t<e?Rp.create(t,e,48|i):Rp.create(e,t,(t>e?8:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let o=i.from,s=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?Dp.range(s,o):Dp.range(o,s))}}return new Dp(e,t)}}function Pp(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let Lp=0;class Bp{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Lp++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new Bp(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:Ip),!!e.static,e.enables)}of(e){return new _p([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _p(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _p(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function Ip(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class _p{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Lp++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||Fp(e,c)){let t=n(e);if(s?!jp(t,e.values[o],r):!r(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=em(t,l);if(this.dependencies.every(n=>n instanceof Bp?t.facet(n)===e.facet(n):!(n instanceof Hp)||t.field(n,!1)==e.field(n,!1))||(s?jp(a=n(e),i,r):r(a=n(e),i)))return e.values[o]=i,0}else a=n(e);return e.values[o]=a,1}}}}function jp(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Fp(e,t){let n=!1;for(let r of t)1&Zp(e,r)&&(n=!0);return n}function Wp(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),o=r.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<r.length;t++){let o=em(e,r[t]);if(2==i[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of r)Zp(e,t);return e.values[s]=a(e),1},update(e,n){if(!Fp(e,o))return 0;let r=a(e);return t.compare(r,e.values[s])?0:(e.values[s]=r,1)},reconfigure(e,i){let o=Fp(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&Ip(n,l))return e.values[s]=c,0;let h=a(e);return t.compare(h,c)?(e.values[s]=c,0):(e.values[s]=h,1)}}}const zp=Bp.define({static:!0});class Hp{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new Hp(Lp++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(zp).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r,i=e.facet(zp),o=n.facet(zp);return(r=i.find(e=>e.field==this))&&r!=o.find(e=>e.field==this)?(e.values[t]=r.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,zp.of({field:this,create:e})]}get extension(){return this}}const Vp=4,qp=3,Up=2,$p=1;function Kp(e){return t=>new Gp(t,e)}const Yp={highest:Kp(0),high:Kp($p),default:Kp(Up),low:Kp(qp),lowest:Kp(Vp)};class Gp{constructor(e,t){this.inner=e,this.prec=t}}class Xp{of(e){return new Jp(this,e)}reconfigure(e){return Xp.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Jp{constructor(e,t){this.compartment=e,this.inner=t}}class Qp{constructor(e,t,n,r,i,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],i=Object.create(null),o=new Map;for(let n of function(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(e,s){let a=i.get(e);if(null!=a){if(a<=s)return;let t=r[a].indexOf(e);t>-1&&r[a].splice(t,1),e instanceof Jp&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Jp){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),o(r,s)}else if(e instanceof Gp)o(e.inner,e.prec);else if(e instanceof Hp)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof _p)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Up);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,Up),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof Hp?r.push(n):(i[n.facet.id]||(i[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of r)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in i){let t=i[e],r=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[r.id]=a.length<<1|1,Ip(o,t))a.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));a.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[r.id]=l.length<<1,l.push(e=>Wp(e,r,t))}}let h=l.map(e=>e(s));return new Qp(e,o,h,s,a,i)}}function Zp(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function em(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const tm=Bp.define(),nm=Bp.define({combine:e=>e.some(e=>e),static:!0}),rm=Bp.define({combine:e=>e.length?e[0]:void 0,static:!0}),im=Bp.define(),om=Bp.define(),sm=Bp.define(),am=Bp.define({combine:e=>!!e.length&&e[0]});class lm{constructor(e,t){this.type=e,this.value=t}static define(){return new cm}}class cm{of(e){return new lm(this,e)}}class hm{constructor(e){this.map=e}of(e){return new um(this,e)}}class um{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new um(this.type,t)}is(e){return this.type==e}static define(e={}){return new hm(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}um.reconfigure=um.define(),um.appendConfig=um.define();class dm{constructor(e,t,n,r,i,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Pp(n,t.newLength),i.some(e=>e.type==dm.time)||(this.annotations=i.concat(dm.time.of(Date.now())))}static create(e,t,n,r,i,o){return new dm(e,t,n,r,i,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(dm.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function fm(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else{if(!(i<t.length))return n;o=t[i++],s=t[i++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function pm(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=Ep.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):null===(r=e.selection)||void 0===r?void 0:r.map(i),effects:um.mapEffects(e.effects,i).concat(um.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function mm(e,t,n){let r=t.selection,i=bm(t.annotations);return t.userEvent&&(i=i.concat(dm.userEvent.of(t.userEvent))),{changes:t.changes instanceof Ep?t.changes:Ep.of(t.changes||[],n,e.facet(rm)),selection:r&&(r instanceof Dp?r:Dp.single(r.anchor,r.head)),effects:bm(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function gm(e,t,n){let r=mm(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let i=1;i<t.length;i++){!1===t[i].filter&&(n=!1);let o=!!t[i].sequential;r=pm(r,mm(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=dm.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(sm),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=pm(r,mm(t,o,e.changes.newLength),!0))}return r==e?e:dm.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let r of t.facet(im)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:fm(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=Ep.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=dm.create(t,r,e.selection&&e.selection.map(i),um.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(om);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof dm?i:Array.isArray(i)&&1==i.length&&i[0]instanceof dm?i[0]:gm(t,bm(i),!1)}return e}(i):i)}dm.time=lm.define(),dm.userEvent=lm.define(),dm.addToHistory=lm.define(),dm.remote=lm.define();const vm=[];function bm(e){return null==e?vm:Array.isArray(e)?e:[e]}var ym=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(ym||(ym={}));const wm=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let xm;try{xm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function km(e){return t=>{if(!/\S/.test(t))return ym.Space;if(function(e){if(xm)return xm.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||wm.test(n)))return!0}return!1}(t))return ym.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ym.Word;return ym.Other}}class Sm{constructor(e,t,n,r,i,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Zp(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Zp(this,n),em(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return gm(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(Xp.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(um.reconfigure)?(n=null,r=t.value):t.is(um.appendConfig)&&(n=null,r=bm(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=Qp.resolve(r,i,this);let e=new Sm(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(nm)?e.newSelection:e.newSelection.asSingle();new Sm(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Dp.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=bm(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(l);let c=r.mapDesc(a,!0);i.push(s.range.map(c)),r=r.compose(l),o=um.mapEffects(o,l).concat(um.mapEffects(bm(s.effects),c))}return{changes:r,selection:Dp.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ep?e:Ep.of(e,this.doc.length,this.facet(Sm.lineSeparator))}toText(e){return ap.of(e.split(this.facet(Sm.lineSeparator)||xp))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(Zp(this,t),em(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Hp&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],o=e[t];r.push(i.init(e=>i.spec.fromJSON(o,e)))}return Sm.create({doc:e.doc,selection:Dp.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Qp.resolve(e.extensions||[],new Map),n=e.doc instanceof ap?e.doc:ap.of((e.doc||"").split(t.staticFacet(Sm.lineSeparator)||xp)),r=e.selection?e.selection instanceof Dp?e.selection:Dp.single(e.selection.anchor,e.selection.head):Dp.single(0);return Pp(r,n.length),t.staticFacet(nm)||(r=r.asSingle()),new Sm(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(Sm.tabSize)}get lineBreak(){return this.facet(Sm.lineSeparator)||"\n"}get readOnly(){return this.facet(am)}phrase(e,...t){for(let t of this.facet(Sm.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(tm))for(let o of i(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return km(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=vp(t,o,!1);if(i(t.slice(e,o))!=ym.Word)break;o=e}for(;s<r;){let e=vp(t,s);if(i(t.slice(s,e))!=ym.Word)break;s=e}return o==s?null:Dp.range(o+n,s+n)}}function Em(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],o=r[e];if(void 0===o)r[e]=i;else if(o===i||void 0===i);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);r[e]=n[e](o,i)}}for(let e in t)void 0===r[e]&&(r[e]=t[e]);return r}Sm.allowMultipleSelections=nm,Sm.tabSize=Bp.define({combine:e=>e.length?e[0]:4}),Sm.lineSeparator=rm,Sm.readOnly=am,Sm.phrases=Bp.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),Sm.languageData=tm,Sm.changeFilter=im,Sm.transactionFilter=om,Sm.transactionExtender=sm,Xp.reconfigure=um.define();class Cm{eq(e){return this==e}range(e,t=e){return Om.create(e,t,this)}}function Nm(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}Cm.prototype.startSide=Cm.prototype.endSide=0,Cm.prototype.point=!1,Cm.prototype.mapMode=kp.TrackDel;let Om=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function Am(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Tm{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let o=r,s=i.length;;){if(o==s)return o;let r=o+s>>1,a=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==o)return a>=0?o:s;a>=0?s=r:o=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);i<o;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),r.push(l-o),i.push(c-o))}return{mapped:n.length?new Tm(r,i,n,s):null,pos:o}}}class Mm{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new Mm(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(Am)),this.isEmpty)return t.length?Mm.of(t):this;let s=new Pm(this,null,-1).goto(0),a=0,l=[],c=new Rm;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(s.chunkIndex)||i<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||r>s.to||i<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(Om.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?Mm.empty:this.nextLayer.update({add:l,filter:o,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],s=this.chunk[i],a=e.touchesRange(o,o+s.length);if(!1===a)r=Math.max(r,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:i,pos:a}=s.map(o,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(a))}}let i=this.nextLayer.map(e);return 0==t.length?i:new Mm(n,t,i||Mm.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],o=this.chunk[r];if(t>=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return Lm.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Lm.from(e).goto(t)}static compare(e,t,n,r,i=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),a=Dm(o,s,n),l=new Im(o,a,i),c=new Im(s,a,i);n.iterGaps((e,t,n)=>_m(l,e,c,t,n,r)),n.empty&&0==n.length&&_m(l,0,c,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=999999999);let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=o.length)return!1;if(!i.length)return!0;let s=Dm(i,o),a=new Im(i,s,0).goto(n),l=new Im(o,s,0).goto(n);for(;;){if(a.to!=l.to||!jm(a.active,l.active)||a.point&&(!l.point||!Nm(a.point,l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}static spans(e,t,n,r,i=-1){let o=new Im(e,null,i).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),i=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);r.point(s,e,o.point,n,i,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(r.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new Rm;for(let r of e instanceof Om?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(Am(t,r)>0)return e.slice().sort(Am);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return Mm.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=Mm.empty;r=r.nextLayer)t=new Mm(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}Mm.empty=new Mm([],[],null,-1),Mm.empty.nextLayer=Mm.empty;class Rm{finishChunk(e){this.chunks.push(new Tm(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Rm)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(Mm.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Mm.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Dm(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=r.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||i.add(e.chunk[t])}return i}class Pm{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Lm{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let o=e[i];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new Pm(o,t,n,i));return 1==r.length?r[0]:new Lm(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Bm(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Bm(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)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(),Bm(this.heap,0)}}}function Bm(e,t){for(let n=e[t];;){let r=1+(t<<1);if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class Im{constructor(e,t,n){this.minPoint=n,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=Lm.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Fm(this.active,e),Fm(this.activeTo,e),Fm(this.activeRank,e),this.minActive=zm(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Wm(this.active,t,n),Wm(this.activeTo,t,r),Wm(this.activeRank,t,i),e&&Wm(e,t,this.cursor.from),this.minActive=zm(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Fm(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function _m(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t,c=!!o.boundChange;for(let t=!1;;){let r=e.to+l-n.to,i=r||e.endSide-n.endSide,h=i<0?e.to+l:n.to,u=Math.min(h,s);if(e.point||n.point?(e.point&&n.point&&Nm(e.point,n.point)&&jm(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,u,e.point,n.point),t=!1):(t&&o.boundChange(a),u>a&&!jm(e.active,n.active)&&o.compareRange(a,u,e.active,n.active),c&&u<s&&(r||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>s)break;a=h,i<=0&&e.next(),i>=0&&n.next()}}function jm(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!Nm(e[n],t[n]))return!1;return!0}function Fm(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Wm(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function zm(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Hm(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=vp(e,i));return r}function Vm(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=9==e.charCodeAt(r)?n-i%n:1,r=vp(e,r)}return!0===r?-1:e.length}const qm="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Um="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),$m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Km{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=$m[qm]||1;return $m[qm]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[Um],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Gm(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let Ym=new Map;class Gm{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Ym.get(n);if(t)return e[Um]=t;this.sheet=new r.CSSStyleSheet,Ym.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Um]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Xm={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Jm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Qm="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zm="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),eg=0;eg<10;eg++)Xm[48+eg]=Xm[96+eg]=String(eg);for(eg=1;eg<=24;eg++)Xm[eg+111]="F"+eg;for(eg=65;eg<=90;eg++)Xm[eg]=String.fromCharCode(eg+32),Jm[eg]=String.fromCharCode(eg);for(var tg in Xm)Jm.hasOwnProperty(tg)||(Jm[tg]=Xm[tg]);function ng(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)rg(e,arguments[t]);return e}function rg(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)rg(e,t[n])}}let ig="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},og="undefined"!=typeof document?document:{documentElement:{style:{}}};const sg=/Edge\/(\d+)/.exec(ig.userAgent),ag=/MSIE \d/.test(ig.userAgent),lg=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ig.userAgent),cg=!!(ag||lg||sg),hg=!cg&&/gecko\/(\d+)/i.test(ig.userAgent),ug=!cg&&/Chrome\/(\d+)/.exec(ig.userAgent),dg="webkitFontSmoothing"in og.documentElement.style,fg=!cg&&/Apple Computer/.test(ig.vendor),pg=fg&&(/Mobile\/\w+/.test(ig.userAgent)||ig.maxTouchPoints>2);var mg={mac:pg||/Mac/.test(ig.platform),windows:/Win/.test(ig.platform),linux:/Linux|X11/.test(ig.platform),ie:cg,ie_version:ag?og.documentMode||6:lg?+lg[1]:sg?+sg[1]:0,gecko:hg,gecko_version:hg?+(/Firefox\/(\d+)/.exec(ig.userAgent)||[0,0])[1]:0,chrome:!!ug,chrome_version:ug?+ug[1]:0,ios:pg,android:/Android\b/.test(ig.userAgent),webkit:dg,webkit_version:dg?+(/\bAppleWebKit\/(\d+)/.exec(ig.userAgent)||[0,0])[1]:0,safari:fg,safari_version:fg?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ig.userAgent)||[0,0])[1]:0,tabSize:null!=og.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function gg(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const vg=Object.create(null);function bg(e,t,n){if(e==t)return!0;e||(e=vg),t||(t=vg);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let o of r)if(o!=n&&(-1==i.indexOf(o)||e[o]!==t[o]))return!1;return!0}function yg(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,"style"==i?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function wg(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}class xg{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var kg=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(kg||(kg={}));class Sg extends Cm{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Eg(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Ng(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:i,end:o}=Og(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new Ng(e,t,n,r,e.widget||null,!0)}static line(e){return new Cg(e)}static set(e,t=!1){return Mm.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Sg.none=Mm.empty;class Eg extends Sg{constructor(e){let{start:t,end:n}=Og(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?gg(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||vg}eq(e){return this==e||e instanceof Eg&&this.tagName==e.tagName&&bg(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Eg.prototype.point=!1;class Cg extends Sg{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Cg&&this.spec.class==e.spec.class&&bg(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Cg.prototype.mapMode=kp.TrackBefore,Cg.prototype.point=!0;class Ng extends Sg{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?kp.TrackBefore:kp.TrackAfter:kp.TrackDel}get type(){return this.startSide!=this.endSide?kg.WidgetRange:this.startSide<=0?kg.WidgetBefore:kg.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ng&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function Og(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!=n?n:t,end:null!=r?r:t}}function Ag(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}Ng.prototype.point=!0;class Tg extends Cm{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof Tg&&this.tagName==e.tagName&&bg(this.attributes,e.attributes)}static create(e){return new Tg(e.tagName,e.attributes||vg)}static set(e,t=!1){return Mm.of(e,t)}}function Mg(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Rg(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function Dg(e,t){if(!t.anchorNode)return!1;try{return Rg(e,t.anchorNode)}catch(e){return!1}}function Pg(e){return 3==e.nodeType?$g(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Lg(e,t,n,r){return!!n&&(_g(e,t,n,r,-1)||_g(e,t,n,r,1))}function Bg(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function Ig(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function _g(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:jg(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Bg(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?jg(e):0}}}function jg(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Fg(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Wg(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function zg(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}Tg.prototype.startSide=Tg.prototype.endSide=-1;class Hg{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?jg(t):0),n,Math.min(e.focusOffset,n?jg(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Vg,qg=null;function Ug(e){if(e.setActive)return e.setActive();if(qg)return e.focus(qg);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==qg?{get preventScroll(){return qg={preventScroll:!0},!0}}:void 0),!qg){qg=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}function $g(e,t,n=t){let r=Vg||(Vg=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Kg(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function Yg(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Gg(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r>0)return{node:n,offset:r};if(1==n.nodeType&&r>0){if("false"==n.contentEditable)return null;n=n.childNodes[r-1],r=jg(n)}else{if(!n.parentNode||Ig(n))return null;r=Bg(n),n=n.parentNode}}}function Xg(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r<n.nodeValue.length)return{node:n,offset:r};if(1==n.nodeType&&r<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[r],r=0}else{if(!n.parentNode||Ig(n))return null;r=Bg(n)+1,n=n.parentNode}}}mg.safari&&mg.safari_version>=26&&(qg=!1);class Jg{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Jg(e.parentNode,Bg(e),t)}static after(e,t){return new Jg(e.parentNode,Bg(e)+1,t)}}var Qg=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Qg||(Qg={}));const Zg=Qg.LTR,ev=Qg.RTL;function tv(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const nv=tv("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),rv=tv("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),iv=Object.create(null),ov=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);iv[t]=n,iv[n]=-t}function sv(e){return e<=247?nv[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?rv[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const av=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class lv{get dir(){return this.level%2?ev:Zg}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}function cv(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!cv(r.inner,i.inner))return!1}return!0}const hv=[];function uv(e,t,n,r,i,o,s){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==o.length||l<o[c].from){let e=hv[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?r:r+1,f=l;e:for(;;)if(c<o.length&&f==o[c].from){if(h)break e;let p=o[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(hv[e]==a)break e;break}e=o[t++].to}if(c++,u)u.push(p);else{p.from>l&&s.push(new lv(l,p.from,d)),dv(e,p.direction==Zg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}f=p.to}else{if(f==n||(t?hv[f]!=a:hv[f]==a))break;f++}u?uv(e,l,f,r+1,i,u,s):l<f&&s.push(new lv(l,f,d)),l=f}else for(let l=n,c=o.length;l>t;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=hv[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?r:r+1,f=l;e:for(;;)if(c&&f==o[c-1].to){if(h)break e;let p=o[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(hv[e-1]==a)break e;break}e=o[--n].from}if(u)u.push(p);else{p.to<l&&s.push(new lv(p.to,l,d)),dv(e,p.direction==Zg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}f=p.from}else{if(f==t||(n?hv[f-1]!=a:hv[f-1]==a))break;f--}u?uv(e,f,l,r+1,i,u,s):f<l&&s.push(new lv(f,l,d)),l=f}}function dv(e,t,n,r,i,o,s){let a=t%2?2:1;!function(e,t,n,r,i){for(let o=0;o<=r.length;o++){let s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i;for(let t=s,n=l,r=l;t<a;t++){let i=sv(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),hv[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=hv[e];if(128==i)e<a-1&&t==hv[e+1]&&24&t?i=hv[e]=t:hv[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==hv[i];)i++;let o=e&&8==t||i<n&&8==hv[i]?1==r?1:8:256;for(let t=e;t<i;t++)hv[t]=o;e=i-1}else 8==i&&1==r&&(hv[e]=1);t=i,7&i&&(r=i)}}}(e,i,o,r,a),function(e,t,n,r,i){let o=1==i?2:1;for(let s=0,a=0,l=0;s<=r.length;s++){let c=s?r[s-1].to:t,h=s<r.length?r[s].from:n;for(let t,n,r,s=c;s<h;s++)if(n=iv[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(ov[e+1]==-n){let t=ov[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(hv[s]=hv[ov[e]]=n),a=e;break}}else{if(189==ov.length)break;ov[a++]=s,ov[a++]=t,ov[a++]=l}else if(2==(r=hv[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=ov[t+2];if(2&n)break;if(e)ov[t+2]|=2;else{if(4&n)break;ov[t+2]|=4}}}}}(e,i,o,r,a),function(e,t,n,r){for(let i=0,o=r;i<=n.length;i++){let s=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=s;l<a;){let s=hv[l];if(256==s){let s=l+1;for(;;)if(s==a){if(i==n.length)break;s=n[i++].to,a=i<n.length?n[i].from:t}else{if(256!=hv[s])break;s++}let c=1==o,h=c==(1==(s<t?hv[s]:r))?c?1:2:r;for(let t=s,r=i,o=r?n[r-1].to:e;t>l;)t==o&&(t=n[--r].from,o=r?n[r-1].to:e),hv[--t]=h;l=s}else o=s,l++}}}(i,o,r,a),uv(e,i,o,t,n,r,s)}function fv(e){return[new lv(0,e,0)]}let pv="";function mv(e,t,n,r,i){var o;let s=r.head-e.from,a=lv.find(t,s,null!==(o=r.bidiLevel)&&void 0!==o?o:-1,r.assoc),l=t[a],c=l.side(i,n);if(s==c){let e=a+=i?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!i,n),c=l.side(i,n)}let h=vp(e.text,s,l.forward(i,n));(h<l.from||h>l.to)&&(h=c),pv=e.text.slice(Math.min(s,h),Math.max(s,h));let u=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return u&&h==c&&u.level+(i?0:1)<l.level?Dp.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):Dp.cursor(h+e.from,l.forward(i,n)?-1:1,l.level)}function gv(e,t,n){for(let r=t;r<n;r++){let t=sv(e.charCodeAt(r));if(1==t)return Zg;if(2==t||4==t)return ev}return Zg}const vv=Bp.define(),bv=Bp.define(),yv=Bp.define(),wv=Bp.define(),xv=Bp.define(),kv=Bp.define(),Sv=Bp.define(),Ev=Bp.define(),Cv=Bp.define(),Nv=Bp.define({combine:e=>e.some(e=>e)}),Ov=Bp.define({combine:e=>e.some(e=>e)}),Av=Bp.define();class Tv{constructor(e,t="nearest",n="nearest",r=5,i=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=o}map(e){return e.empty?this:new Tv(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 Tv(Dp.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Mv=um.define({map:(e,t)=>e.map(t)}),Rv=um.define();function Dv(e,t,n){let r=e.facet(wv);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const Pv=Bp.define({combine:e=>!e.length||e[0]});let Lv=0;const Bv=Bp.define({combine:e=>e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})});class Iv{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Bv.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Bv.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new Iv(Lv++,e,n,r,e=>{let t=[];return o&&t.push(Wv.of(t=>{let n=t.plugin(e);return n?o(n):Sg.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return Iv.define((t,n)=>new e(t,n),t)}}class _v{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 e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Dv(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Dv(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Dv(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jv=Bp.define(),Fv=Bp.define(),Wv=Bp.define(),zv=Bp.define(),Hv=Bp.define(),Vv=Bp.define(),qv=Bp.define();function Uv(e,t){let n=e.state.facet(qv);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return Mm.spans(r,t.from,t.to,{point(){},span(e,n,r,o){let s=e-t.from,a=n-t.from,l=i;for(let e=r.length-1;e>=0;e--,o--){let n,i=r[e].spec.bidiIsolate;if(null==i&&(i=gv(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==i)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:i,inner:[]};l.push(e),l=e.inner}}}}),i}const $v=Bp.define();function Kv(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet($v)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(r=Math.max(r,s.top)),null!=s.bottom&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}const Yv=Bp.define();class Gv{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new Gv(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let r=0,i=0,o=0;;){let s=r<e.length?e[r].fromB:1e9,a=i<t.length?t[i]:1e9,l=Math.min(s,a);if(1e9==l)break;let c=l+o,h=l,u=c;for(;;)if(i<t.length&&t[i]<=h){let n=t[i+1];i+=2,h=Math.max(h,n);for(let t=r;t<e.length&&e[t].fromB<=h;t++)o=e[t].toA-e[t].toB;u=Math.max(u,n+o)}else{if(!(r<e.length&&e[r].fromB<=h))break;{let t=e[r++];h=Math.max(h,t.toB),u=Math.max(u,t.toA),o=t.toA-t.toB}}n.push(new Gv(c,u,l,h))}return n}}class Xv{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ep.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new Gv(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new Xv(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const Jv=[];class Qv{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Jv}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,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;null==t[r]&&e.removeAttribute(r)}for(let n in t){let r=t[n];"style"==n?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Bg(this.dom),r=this.length?e>0:t>0;return new Jg(this.parent.dom,n+(r?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof tb)return e;return null}static get(e){return e.cmTile}}class Zv extends Qv{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(2&this.flags)return;super.sync(e);let t,n=this.dom,r=null,i=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=r?r.nextSibling:n.firstChild,i&&t!=s.dom&&(i.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=eb(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=eb(t);this.length=o}}function eb(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class tb extends Zv{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Qv.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let o=n.children[r++];if(o instanceof nb)t.push(r),n=o,r=0;else{let t=i+o.length,n=e(o,i);if(void 0!==n)return n;i=t+o.breakAfter}}}resolveBlock(e,t){let n,r,i=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,i=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!r||!s.isWidget()&&r.isWidget())&&(r=s,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:i}:{tile:r,offset:o}}}class nb extends Zv{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new nb(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class rb extends Zv{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new rb(t||document.createElement("div"),e);return t&&n||(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,o=null,s=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let u=a.children[c],d=h+u.length;d>=l&&(u.isComposite()?e(u,l-h):(!o||o.isHidden&&(t>0||n&&ib(o,u)))&&(d>l||32&u.flags)?(o=u,s=l-h):(h<l||16&u.flags&&!u.isHidden)&&(r=u,i=l-h)),h=d}}(this,e);let a=(t<0?r:o)||r||o;return a?{tile:a,offset:a==r?i:s}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Pg(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Jg(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,16&e.flags?1:32&e.flags?-1:t);let i=n.tile.parent,o=!1;for(let e of i.children){if(o)return new Jg(e.dom,0);e==n.tile&&(o=!0)}}return new Jg(this.dom,0)}}function ib(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class ob extends Zv{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new ob(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class sb extends Qv{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,o=0;0==e&&t<0||e==n&&t>=0?mg.chrome||mg.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=$g(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return mg.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?Fg(a,o<0):a||null}static of(e,t){let n=new sb(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class ab extends Qv{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Fg(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?0==i:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return Fg(n,!r)}}get overrideDOMText(){if(!this.length)return ap.empty;let{root:e}=this;if(!e)return ap.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,i){return i||(i=e.toDOM(t),e.editable||(i.contentEditable="false")),new ab(i,n,e,r)}}class lb extends Qv{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ap.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class cb{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++}else{let a=r.children[i],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(s.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a)):(o=!!l,i++,e-=a.length)}else if(i==r.length)o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++;else{if(!e)break;{let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}}return this.tile=r,this.index=i,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class hb{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class ub{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var i;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(!s||!s.isText()||8&s.flags)o.append(r||sb.of(e,null===(i=this.cache.find(sb))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new sb(s.dom,s.text+e)).parent=o}this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?bb(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof ob&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(bb(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=Qv.get(n.dom);e&&e.setDOM(bb(n.dom))}let e=ob.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=Qv.get(e.text);i&&this.cache.reused.set(i,2);let o=new sb(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);r||this.flushBuffer();let i=this.ensureMarks(t,n);r||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).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){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=vb);let r=rb.start(e,t||(null===(n=this.cache.find(rb))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let o,s=e[i];if(t>0&&(o=r.lastChild)&&o instanceof ob&&o.mark.eq(s))r=o,t--;else{let e=ob.of(s,null===(n=this.cache.find(ob,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);r.append(e),r=e,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&gb(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||mg.ios&&gb(this.curLine,!0))||this.curLine.append(this.cache.findWidget(wb,0,32)||new ab(wb.toDOM(),0,wb,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new hb(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof nb&&r.wrapper.eq(n.wrapper))t=r;else{let r=nb.of(n.wrapper,null===(e=this.cache.find(nb,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(lb,void 0,1);return n&&(n.flags=t),n||new lb(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class db{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:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw new Error("Ran out of text content when drawing inline views");this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const fb=[ab,rb,sb,ob,lb,nb,tb];for(let e=0;e<fb.length;e++)fb[e].bucket=e;class pb{constructor(e){this.view=e,this.buckets=fb.map(()=>[]),this.index=fb.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],o=this.index[r];for(let e=i.length-1;e>=0;e--){let s=(e+o)%i.length,a=i[s];if((!t||t(a))&&!this.reused.has(a))return i.splice(s,1),s<o&&this.index[r]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}let s=r[i];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new ab(s.dom,t,e,-498&s.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class mb{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new pb(e),this.text=new db(e.state.doc),this.builder=new ub(this.cache,new tb(e,e.contentDOM),Mm.iter(n)),this.cache.reused.set(t,2),this.old=new cb(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){let e=a-r;this.preserve(e,!o,!s),r=a,i+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof ob&&t.push(r.mark)}return t}(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t<e.length?ab.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&o.flags?(o.flags&=-2,this.builder.addBlockWidget(o)):(this.builder.ensureLine(null),this.builder.addInlineWidget(o,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)):this.builder.addText(e.text,r,i,this.cache.reuse(e)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof lb)this.cache.add(e);else{if(!(e instanceof ob))return!1;this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof ob&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof ob&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,o=Mm.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof Ng){if(this.disallowBlockEffectsFor[l]){if(o.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=s.length,a>s.length)r.continueWidget(t-e);else{let i=o.widget||(o.block?yb.block:yb.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(o),c=this.cache.findWidget(i,t-e,l)||ab.of(i,this.view,t-e,l);o.block?(o.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(c)):(r.ensureLine(n),r.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,r=t.spec.class;if(!n&&!r)return e;e||(e={class:"cm-line"});n&&gg(n,e);r&&(e.class+=" "+r);return e}(n,o);t>e&&this.text.skip(t-e)},span:(e,t,i,o)=>{for(let s=e;s<t;){let e=this.text.next(Math.min(512,t-s));null==e?(r.addLineStartIfNotCovered(n),r.addBreak(),s++):(r.ensureLine(n),r.addText(e,i,o),s+=e.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>i,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=Qv.get(r);if(r==this.view.contentDOM)break;e instanceof ob?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(ob.of(new Eg({tagName:r.nodeName.toLowerCase(),attributes:wg(r)}),r)):n=new rb(r,vb)}return{line:n,marks:t}}}function gb(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}const vb={class:"cm-line"};function bb(e){let t=Qv.get(e);return t&&t.setDOM(e.cloneNode()),e}class yb extends xg{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}}yb.inline=new yb("span"),yb.block=new yb("div");const wb=new class extends xg{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class xb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Sg.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 tb(e,e.contentDOM),this.updateInner([new Gv(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?r=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(r=e.state.selection.main.head));let i=r>-1?function(e,t,n){let r=Sb(e,n);if(!r)return null;let{node:i,from:o,to:s}=r,a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new Gv(l.mapPos(o),l.mapPos(s),o,s),text:i}}(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:r}=this.hasComposition;n=new Gv(t,r,e.changes.mapPos(t,-1),e.changes.mapPos(r,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(mg.ie||mg.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let r=new Eb;return Mm.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=Gv.extendWithRanges(n,a));let l=function(e,t,n){let r=new Cb;return Mm.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=Gv.extendWithRanges(n,l)),i&&!n.some(e=>e.fromA<=i.range.fromA&&e.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new mb(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=r.run(e,t),kb(n,r.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 r=mg.chrome||mg.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),!r||!r.written&&n.selectionRange.focusNode==r.node&&this.tile.dom.contains(r.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof Nb&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(Rv)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(Pv)||n.tabIndex>-1)&&Dg(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),mg.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new Jg(e,0),s=!0}var h;let u=this.view.observer.selectionRange;!s&&u.focusNode&&(Lg(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Lg(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{mg.android&&mg.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=Mg(this.view.root);if(e)if(c.empty){if(mg.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?Gg:Xg)(a.node,a.offset);t&&(a=new Jg(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Jg(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Jg(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Lg(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Mg(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let r=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r;{let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=0==jg(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==r&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!Qv.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r,i=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,i=e-l,o=c<e),c>=e&&!r&&(r=t,s=e-l,a=l>e),l>e&&r)return!0}}),n||r?(o&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(i,t):r.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Nb?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let r of t.children){if(r.length>=n){let t=e(r,n);if(t)return t}if((n-=r.length)<0)break}else if(t.isText()&&n<t.length){let e=vp(t.text,n);if(e==n)return null;let r=$g(t.dom,n,e).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,o=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==Qg.LTR,l=0,c=(e,h,u)=>{for(let d=0;d<e.children.length&&!(h>r);d++){let r=e.children[d],f=h+r.length,p=r.dom.getBoundingClientRect(),{height:m}=p;if(u&&!d&&(l+=p.top-u.top),r instanceof nb)f>n&&c(r,h,p);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,o)){let e=r.dom.lastChild,t=e?Pg(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>s&&(s=n,this.minWidth=i,this.minWidthFrom=h,this.minWidthTo=f)}}u&&d==e.children.length-1&&(l+=u.bottom-p.bottom),h=f+r.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?Qg.RTL:Qg.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=Pg(r.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,r,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let e=Pg(i.firstChild)[0];t=i.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:t,i.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){let r=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Sg.replace({widget:new Nb(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return Sg.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Wv).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(Hv).map((e,t)=>{let r="function"==typeof e;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(Mm.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(zv).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(Av))try{if(t(this.view,e.range,e))return!0}catch(e){Dv(this.view.state,e,"scroll handler")}let t,{range:n}=e,r=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!r)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,t.left),top:Math.min(r.top,t.top),right:Math.max(r.right,t.right),bottom:Math.max(r.bottom,t.bottom)});let i=Kv(this.view),o={left:r.left-i.left,top:r.top-i.top,right:r.right+i.right,bottom:r.bottom+i.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,r,i,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,f=1,p=1;if(d)e=Wg(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:f,scaleY:p}=zg(h,t)),e={left:t.left,right:t.left+h.clientWidth*f,top:t.top,bottom:t.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==i)t.top<e.top?(g=t.top-(e.top+s),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+s)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+s,n<0&&t.top-g<e.top&&(g=t.top-(e.top+s)));else{let r=t.bottom-t.top,o=e.bottom-e.top;g=("center"==i&&r<=o?t.top+r/2-o/2:"start"==i||"center"==i&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==r?t.left<e.left?(m=t.left-(e.left+o),n>0&&t.right>e.right+m&&(m=t.right-e.right+o)):t.right>e.right&&(m=t.right-e.right+o,n<0&&t.left<e.left+m&&(m=t.left-(e.left+o))):m=("center"==r?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==r==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,m||g)if(d)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=h.scrollTop;h.scrollTop+=g/p,n=(h.scrollTop-e)*p}if(m){let t=h.scrollLeft;h.scrollLeft+=m/f,e=(h.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(r="nearest"),n&&Math.abs(n-g)<1&&(i="nearest")}if(d)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Qg.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){kb(this.tile)}}function kb(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)kb(n,t)}}function Sb(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Gg(n.focusNode,n.focusOffset),i=Xg(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=Qv.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=Qv.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let Eb=class{constructor(){this.changes=[]}compareRange(e,t){Ag(e,t,this.changes)}comparePoint(e,t){Ag(e,t,this.changes)}boundChange(e){Ag(e,e,this.changes)}};class Cb{constructor(){this.changes=[]}compareRange(e,t){Ag(e,t,this.changes)}comparePoint(){}boundChange(e){Ag(e,e,this.changes)}}class Nb extends xg{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 Ob(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;e&&(i.type!=kg.Text||e.type==i.type&&!(n<0?i.from<t:i.to>t))||(e=i)}}return e||r}return r}function Ab(e,t,n,r){let i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from);for(let a=t,l=null;;){let t=mv(i,o,s,a,n),c=pv;if(!t){if(i.number==(n?e.state.doc.lines:1))return a;c="\n",i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!r)return t;l=r(c)}a=t}}function Tb(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,o)=>{if(t>e&&t<i){let o=r||n||(t-e<i-t?-1:1);t=o<0?e:i,r=o}});if(!r)return t}}function Mb(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],o=null;if(i.empty){let t=Tb(e,i.from,0);t!=i.from&&(o=Dp.cursor(t,-1))}else{let t=Tb(e,i.from,-1),n=Tb(e,i.to,1);t==i.from&&n==i.to||(o=Dp.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?Dp.create(n,t.mainIndex):t}function Rb(e,t,n){let r=Tb(e.state.facet(Vv).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:Dp.cursor(r,r<n.from?1:-1)}class Db{constructor(e,t){this.pos=e,this.assoc=t}}function Pb(e,t,n,r){let i,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-s;for(;;){if(c<0)return new Db(0,1);if(c>e.viewState.docHeight)return new Db(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==kg.Text){let t=e.docView.coordsAt(r<0?i.from:i.to,r);if(t&&(r<0?t.top<=c+s:t.bottom>=c+s))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?i.bottom+t:i.top-t}if(e.viewport.from>=i.to||e.viewport.to<=i.from){if(n)return null;if(i.type==kg.Text){let t=function(e,t,n,r,i){let o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((i-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+Vm(s,o,e.state.tabSize)}(e,o,i,a,l);return new Db(t,t==i.from?1:-1)}}if(i.type!=kg.Text)return c<(i.top+i.bottom)/2?new Db(i.from,1):new Db(i.to,-1);let h=e.docView.lineAt(i.from,2);return h&&h.length==i.length||(h=e.docView.lineAt(i.from,-2)),Lb(e,h,i.from,a,l)}function Lb(e,t,n,r,i){let o=-1,s=null,a=1e9,l=1e9,c=i,h=i,u=(e,t)=>{for(let n=0;n<e.length;n++){let u=e[n];if(u.top==u.bottom)continue;let d=u.left>r?u.left-r:u.right<r?r-u.right:0,f=u.top>i?u.top-i:u.bottom<i?i-u.bottom:0;u.top<=h&&u.bottom>=c&&(c=Math.min(u.top,c),h=Math.max(u.bottom,h),f=0),(o<0||(f-l||d-a)<0)&&(o>=0&&l&&a<d&&s.top<=h-2&&s.bottom>=c+2?l=0:(o=t,a=d,l=f,s=u))}};if(t.isText()){for(let e=0;e<t.length;){let n=vp(t.text,e);if(u($g(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(Bb(e,o+n)==Qg.LTR)?new Db(n+vp(t.text,o),-1):new Db(n+o,1)}{if(!t.length)return new Db(n,1);for(let e=0;e<t.children.length;e++){let n=t.children[e];if(!(48&n.flags)&&(u((1==n.dom.nodeType?n.dom:$g(n.dom,0,n.length)).getClientRects(),e),!a&&!l))break}let c=t.children[o],h=t.posBefore(c,n);return c.isComposite()||c.isText()?Lb(e,c,h,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(Bb(e,o+n)==Qg.LTR)?new Db(h+c.length,-1):new Db(h,1)}}function Bb(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[lv.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const Ib="";class _b{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Sm.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ib}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=Qv.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=Qv.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:Ig(r))||Ig(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!Fb(o,t)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(i=r.exec(t))&&(o=i.index,s=i[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=Qv.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(jb(e,n.node,n.offset)?t:0))}}function jb(e,t,n){for(;;){if(!t||n<jg(t))return!1;if(t==e)return!0;n=Bg(t)+1,t=t.parentNode}}function Fb(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=Qv.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class Wb{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class zb{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Hb(e.docView.tile,t,n,0))){let t=i||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new Wb(n,r)),i==n&&o==r||t.push(new Wb(i,o)));return t}(e),n=new _b(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?Dp.single(n+t,r+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!Rg(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!Rg(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((mg.ios||mg.chrome)&&e.state.selection.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),o=s.from-t,a=s.to-i;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&i!=e.state.doc.length||(n=0,r=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(Dp.range(r,n)):this.newSel=Dp.single(r,n)}}}function Hb(e,t,n,r){if(e.isComposite()){let i=-1,o=-1,s=-1,a=-1;for(let l=0,c=r,h=r;l<e.children.length;l++){let r=e.children[l],u=c+r.length;if(c<t&&u>n)return Hb(r,t,n,c);if(u>=t&&-1==i&&(i=l,o=c),c>n&&r.dom.parentNode==e.dom){s=l,a=h;break}h=u,c=u+r.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Vb(e,t){let n,{newSel:r}=t,i=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:r,to:s}=t.bounds,a=i.from,l=null;(8===o||mg.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=Ub(e.state.doc.sliceString(r,s,Ib),t.text,a-r,l);c&&(mg.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==Ib+Ib&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:ap.of(t.text.slice(c.from,c.toB).split(Ib))})}else r&&(!e.hasFocus&&e.state.facet(Pv)||$b(r,i))&&(r=null);if(!n&&!r)return!1;if(!n&&t.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,i.to)}:(mg.mac||mg.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=Dp.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:ap.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,i.to))}:e.state.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:e.state.toText(e.inputState.insertingText)}:mg.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=Dp.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:ap.of([" "])}),n)return qb(e,n,r,o);if(r&&!$b(r,i)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(r=Mb(e.state.facet(Vv).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function qb(e,t,n,r=-1){if(mg.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(mg.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&" "==e.state.sliceDoc(t.from,i.from))&&1==t.insert.length&&2==t.insert.lines&&Kg(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>i.head)&&Kg(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&Kg(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let n=t.from<o.from?-1:1,r=n<0?o.from:o.to,a=Tb(i.facet(Vv).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:Dp.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?i.sliceDoc(o.from,t.from):"",s=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=i.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&Sb(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(o.head);let u=o.to-t.to;r=i.changeByRange(n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let r=n.to-u,h=r-c.length;if(e.state.sliceDoc(h,r)!=c||r>=l.from&&h<=l.to)return{range:n};let d=i.changes({from:h,to:r,insert:t.insert}),f=n.to-o.to;return{changes:d,range:a?Dp.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(d)}})}else r={changes:s,selection:a&&i.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return i.update(r,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(kv).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function Ub(e,t,n,r){let i=Math.min(e.length,t.length),o=0;for(;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==r){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function $b(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Kb{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,mg.safari&&e.contentDOM.addEventListener("input",()=>null),mg.gecko&&function(e){vy.has(e)||(vy.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,r=t.target;r!=e.contentDOM;r=r.parentNode)if(!r||11==r.nodeType||(n=Qv.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Gb(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if("scroll"!=e){let i=!t[e].handlers.length,o=n[e];o&&i!=!o.handlers.length&&(r.removeEventListener(e,this.handleEvent),o=null),o||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)"scroll"==e||t[e]||r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&Qb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),mg.android&&mg.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!mg.ios||e.synthetic||e.altKey||e.metaKey||!((t=Xb.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Jb.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Kg(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(mg.safari&&!mg.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}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 Yb(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){Dv(n.state,e)}}}function Gb(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(Yb(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(Yb(t.value,r))}}for(let e in ty)n(e).handlers.push(ty[e]);for(let e in ny)n(e).observers.push(ny[e]);return t}const Xb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Jb="dthko",Qb=[16,17,18,20,91,92,224,225];function Zb(e){return.7*Math.max(0,e)+8}class ey{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,r=e.ownerDocument;for(let i=e.parentNode;i&&!(i==r.body||t&&n);)if(1==i.nodeType)!n&&i.scrollHeight>i.clientHeight&&(n=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(Vv).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Sm.allowMultipleSelections)&&function(e,t){let n=e.state.facet(vv);return n.length?n[0](t):mg.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Mg(e.root);if(!r||0==r.rangeCount)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=uy(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let r=0,i=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Kv(this.view);e.clientX-c.left<=o+6?r=-Zb(o-e.clientX):e.clientX+c.right>=a-6&&(r=Zb(e.clientX-a)),e.clientY-c.top<=s+6?i=-Zb(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=Zb(e.clientY-l)),this.setScrollSpeed(r,i)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=Mb(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const ty=Object.create(null),ny=Object.create(null),ry=mg.ie&&mg.ie_version<15||mg.ios&&mg.webkit_version<604;function iy(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function oy(e,t){t=iy(e.state,Ev,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=fy&&r.selection.ranges.every(e=>e.empty)&&fy==o.toString();if(a){let e=-1;n=r.changeByRange(n=>{let a=r.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=r.toText((s?o.line(i++).text:t)+r.lineBreak);return{changes:{from:a.from,insert:l},range:Dp.cursor(n.from+l.length)}})}else n=s?r.changeByRange(e=>{let t=o.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:Dp.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function sy(e,t,n,r){if(1==r)return Dp.cursor(t,n);if(2==r)return function(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(0==i.length)return Dp.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=vp(i.text,o,!1):a=vp(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=vp(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=vp(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return Dp.range(s+i.from,a+i.from)}(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:i.from,s=r?r.posAtEnd:i.to;return s<e.state.doc.length&&s==i.to&&s++,Dp.range(o,s)}}ny.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},ty.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),ny.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},ny.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},ty.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(yv))if(n=r(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=uy(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,o,s){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=sy(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=sy(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?Dp.range(i,o):Dp.range(o,i)}return o?i.replaceRange(i.main.extend(c.from,c.to)):s&&1==r&&i.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return Dp.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(i,l.pos))?a:s?i.addRange(c):Dp.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new ey(e,t,n,r)),r&&e.observer.ignore(()=>{Ug(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),!1===i.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const ay=mg.ie&&mg.ie_version<=11;let ly=null,cy=0,hy=0;function uy(e){if(!ay)return e.detail;let t=ly,n=hy;return ly=e,hy=Date.now(),cy=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(cy+1)%3:1}function dy(e,t,n,r){if(!(n=iy(e.state,Ev,n)))return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=r&&o&&function(e,t){let n=e.state.facet(bv);return n.length?n[0](t):mg.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}ty.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=Dp.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",iy(e.state,Cv,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},ty.dragend=e=>(e.inputState.draggedContent=null,!1),ty.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,o=()=>{++i==n.length&&dy(e,t,r.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return dy(e,t,n,!0),!0}return!1},ty.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=ry?null:t.clipboardData;return n?(oy(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),oy(e,n.value)},50)}(e),!1)};let fy=null;ty.copy=ty.cut=(e,t)=>{let n=Mg(e.root);if(n&&!Dg(e.contentDOM,n))return!1;let{text:r,ranges:i,linewise:o}=function(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let o=e.doc.lineAt(r);o.number>i&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),i=o.number}r=!0}return{text:iy(e,Cv,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;fy=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=ry?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}(e,r),!1)};const py=lm.define();function my(e,t){let n=[];for(let r of e.facet(Sv)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:py.of(!0)}):null}function gy(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=my(e.state,t);n?e.dispatch(n):e.update([])}},10)}ny.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),gy(e)},ny.blur=e=>{e.observer.clearSelectionRange(),gy(e)},ny.compositionstart=ny.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},ny.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,mg.chrome&&mg.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},ny.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},ty.beforeinput=(e,t)=>{var n,r;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let r=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),i=t.getTargetRanges();if(r&&i.length){let t=i[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return qb(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(mg.chrome&&mg.android&&(i=Xb.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){let t=(null===(r=window.visualViewport)||void 0===r?void 0:r.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return mg.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),mg.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>ny.compositionend(e,t),20),!1};const vy=new Set;const by=["pre-wrap","normal","pre-line","break-spaces"];let yy=!1;function wy(){yy=!1}class xy{constructor(e){this.lineWrapping=e,this.doc=ap.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return by.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(10*r)]||(t=!0,this.heightSamples[Math.floor(10*r)]=!0)}return t}refresh(e,t,n,r,i,o){let s=by.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class ky{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Sy{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return"number"==typeof this._content?kg.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ng?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Sy(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Ey=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(Ey||(Ey={}));const Cy=.001;class Ny{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Cy&&(yy=!0),this.height=e)}replace(e,t,n){return Ny.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,o=n.doc;for(let s=r.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=r[s],u=i.lineAt(a,Ey.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:i.lineAt(l,Ey.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;s>0&&u.from<=r[s-1].toA;)a=r[s-1].fromA,c=r[s-1].fromB,s--,a<u.from&&(u=i.lineAt(a,Ey.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let f=Ly.build(n.setDoc(o),e,c,h);i=Oy(i,i.replace(a,l,f))}return i.updateHeight(n,0)}static empty(){return new My(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,r=0,i=0;for(;;)if(t==n)if(r>2*i){let i=e[t-1];i.break?e.splice(--t,1,i.left,null,i.right):e.splice(--t,1,i.left,i.right),n+=1+i.break,r-=i.size}else{if(!(i>2*r))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,i-=t.size}}else if(r<i){let n=e[t++];n&&(r+=n.size)}else{let t=e[--n];t&&(i+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new Dy(Ny.of(e.slice(0,t)),o,Ny.of(e.slice(n)))}}function Oy(e,t){return e==t?e:(e.constructor!=t.constructor&&(yy=!0),t)}Ny.prototype.size=1;const Ay=Sg.replace({});class Ty extends Ny{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Sy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Sy(r,0,n,this.spaceAbove,Ay):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}forEachLine(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,Ey.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class My extends Ty{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new Sy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return 1==n.length&&(r instanceof My||r instanceof Ry&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof Ry?r=new My(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Ny.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||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 Ry extends Ny{constructor(e){super(e,0)}heightMetrics(e,t){let n,r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:r,lastLine:i,perLine:n,perChar:s}}blockAt(e,t,n,r){let{firstLine:i,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(i),l=s+o.length*a,c=Math.max(n,e-l/2);return new Sy(o.from,o.length,c,l,0)}{let r=Math.max(0,Math.min(o-i,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(i+r);return new Sy(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==Ey.ByHeight)return this.blockAt(e,n,r,i);if(t==Ey.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new Sy(t,r-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,i),l=n.doc.lineAt(e),c=s+l.length*a,h=l.number-o,u=r+s*h+a*(l.from-i-h);return new Sy(l.from,l.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,n,r,i,o){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,i);for(let c=e,h=r;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;h+=a*n+l*(e-i-n)}let r=a+l*t.length;o(new Sy(t.from,t.length,h,r,0)),h+=r,c=t.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let e=n[n.length-1];e instanceof Ry?n[n.length-1]=new Ry(e.length+r):n.push(null,new Ry(r-1))}if(e>0){let t=n[0];t instanceof Ry?n[0]=new Ry(e+t.length):n.unshift(new Ry(e-1),null)}return Ny.of(n)}decomposeLeft(e,t){t.push(new Ry(e-1),null)}decomposeRight(e,t){t.push(null,new Ry(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let i=t+this.length;if(r&&r.from<=t+this.length&&r.more){let n=[],o=Math.max(t,r.from),s=-1;for(r.from>t&&n.push(new Ry(r.from-t-1).updateHeight(e,t));o<=i&&r.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let i=r.heights[r.index++],a=0;i<0&&(a=-i,i=r.heights[r.index++]),-1==s?s=i:Math.abs(i-s)>=Cy&&(s=-2);let l=new My(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new Ry(i-o).updateHeight(e,o));let a=Ny.of(n);return(s<0||Math.abs(a.height-this.height)>=Cy||Math.abs(s-this.heightMetrics(e,t).perLine)>=Cy)&&(yy=!0),Oy(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Dy extends Ny{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,a=t==Ey.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==Ey.ByPosNoHeight?Ey.ByPosNoHeight:Ey.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,o){let s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,Ey.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let e of n)i.push(e);if(e>0&&Py(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),Py(i,e)}return Ny.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ny.of(this.break?[e,null,t]:[e,t]):(this.left=Oy(this.left,e),this.right=Oy(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:o}=this,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Py(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof Ry&&(r=e[t+1])instanceof Ry&&e.splice(t-1,3,new Ry(n.length+1+r.length))}class Ly{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof My?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new My(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Ty(o,r,n)):(o||i||r>=5)&&this.addLineDeco(r,i,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new My(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Ry(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof My)return e;let t=new My(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof My||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new My(0,-1,0));let n=e;for(let e of this.nodes)e instanceof My&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new Ly(n,e);return Mm.spans(t,n,r,i,0),i.finish(n)}}class By{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Ag(e,t,this.changes,5)}}function Iy(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(1==t.nodeType){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=r.overflow){let r=n.getBoundingClientRect();o=Math.max(o,r.left),s=Math.min(s,r.right),a=Math.max(a,r.top),l=Math.min(t==e.parentNode?i.innerHeight:l,r.bottom)}t="absolute"==r.position||"fixed"==r.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function _y(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class jy{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return Sg.replace({widget:new Fy(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Fy extends xg{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Wy{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=qy,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Qg.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Fv).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new xy(t),this.stateDeco=Uy(e),this.heightMap=Ny.empty().applyChanges(this.stateDeco,ap.empty,this.heightOracle.setDoc(e.doc),[new Gv(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Sg.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new zy(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?qy:new $y(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(Ky(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Uy(this.state);let r=e.changedRanges,i=Gv.extendWithRanges(r,function(e,t,n){let r=new By;return Mm.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:Ep.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);wy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||yy)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ov)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Qg.RTL:Qg.LTR;let o=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=zg(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Yg(e.scrollDOM);let f=(this.printing?_y:Iy)(t,this.paddingTop),p=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;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&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&r.refresh(i,n,s,a,Math.max(5,v/s),t),o&&(e.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),wy();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?Ny.empty().applyChanges(this.stateDeco,ap.empty,this.heightOracle,[new Gv(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new ky(n.from,i))}yy&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new zy(r.lineAt(o-1e3*n,Ey.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),Ey.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=r.lineAt(e,Ey.ByPos,i,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new zy(r.lineAt(n-500,Ey.ByHeight,i,0,0).from,r.lineAt(n+o+500,Ey.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new zy(this.heightMap.lineAt(n,Ey.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Ey.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,Ey.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,Ey.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=s+Math.max(10,Math.min(n,250)))&&r>o-2e3&&i<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new jy(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=Qg.LTR&&!n)return[];let s=[],a=(r,o,l,c)=>{if(o-r<i)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>r&&e<o)return a(r,e-10,l,c),void a(e+10,o,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-o)<i&&!u.some(t=>e.from<t&&e.to>t));if(!d){if(o<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=o&&e.to>=o)){let e=t.moveToLineBoundary(Dp.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);d=new jy(r,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=kg.Text)return;let i=function(e,t,n){let r=[],i=e,o=0;Mm.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),o+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),o+=t-i);return{total:o,ranges:r}}(t.from,t.to,this.stateDeco);if(i.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=r/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let r=Vy(i,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=r-s,n=r+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=Hy(i,e),l=Hy(i,n)}else{let n=i.total*this.heightOracle.charWidth,o=r*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let e=Vy(i,c),t=((f-d)/2+o)/n;h=e-t,u=e+t}else h=(d-o)/n,u=(f+o)/n;s=Hy(i,h),l=Hy(i,u)}s>t.from&&a(t.from,s,t,i),l<t.to&&a(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,r){let i=Vy(r,n)-Vy(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){jy.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Sg.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];Mm.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(8&r);t++){let i=this.visibleRanges[t],o=n[t];i.from==o.from&&i.to==o.to||(r|=4,e&&e.mapPos(i.from,-1)==o.from&&e.mapPos(i.to,1)==o.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Ky(this.heightMap.lineAt(e,Ey.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Ky(this.heightMap.lineAt(this.scaler.fromDOM(e),Ey.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Ky(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 zy{constructor(e,t){this.from=e,this.to=t}}function Hy({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],o=i-n;if(r<=o)return n+r;r-=o}}function Vy(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}const qy={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function Uy(e){let t=e.facet(Wv).filter(e=>"function"!=typeof e),n=e.facet(Hv).filter(e=>"function"!=typeof e);return n.length&&t.push(Mm.join(n)),t}class $y{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,Ey.ByPos,e,0,0).top,s=t.lineAt(i,Ey.ByPos,e,0,0).bottom;return r+=s-o,{from:n,to:i,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=o+(e.top-i)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(e){return e instanceof $y&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to))}}function Ky(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Sy(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Ky(e,t)):e._content)}const Yy=Bp.define({combine:e=>e.join(" ")}),Gy=Bp.define({combine:e=>e.indexOf(!0)>-1}),Xy=Km.newName(),Jy=Km.newName(),Qy=Km.newName(),Zy={"&light":"."+Jy,"&dark":"."+Qy};function ew(e,t,n){return new Km(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const tw=ew("."+Xy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Zy),nw={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},rw=mg.ie&&mg.ie_version<=11;class iw{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Hg,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(mg.ie&&mg.ie_version<=11||mg.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!mg.android||!1===e.constructor.EDIT_CONTEXT||mg.chrome&&mg.chrome_version<126||(this.editContext=new aw(e),e.state.facet(Pv)&&(e.contentDOM.editContext=this.editContext.editContext)),rw&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.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){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Pv)?n.root.activeElement!=this.dom:!Dg(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(mg.ie&&mg.ie_version<=11||mg.android&&mg.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Lg(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Mg(e.root);if(!t)return!1;let n=mg.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return sw(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?sw(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=Dg(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,jg(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=jg(n))}else{if(n==e)return!0;r=Bg(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,nw),rw&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),rw&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Kg(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Dg(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new zb(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=Vb(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!$b(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=ow(t,e.previousSibling||e.target.previousSibling,-1),r=ow(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Pv)!=e.state.facet(Pv)&&(e.view.contentDOM.editContext=e.state.facet(Pv)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.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 ow(e,t,n){for(;t;){let r=Qv.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function sw(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return Lg(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class aw{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&i<this.from?s=i:a==this.to&&i>this.to&&(a=i);let c=Ub(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=Dp.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void($b(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let h={from:c.from+s,to:c.toA+s,insert:ap.of(n.text.slice(c.from,c.toB).split("\n"))};if((mg.mac||mg.android)&&h.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:s,to:a,insert:ap.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);qb(e,h,Dp.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(i<o){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(r)?1:2}px`;n.push(Sg.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:Rv.of(Sg.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=Mg(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,a,l)=>{if(n)return;let c=l.length-(o-i);if(r&&o>=r.to){if(r.from==i&&r.to==o&&r.insert.eq(l))return r=this.pendingContextChange=null,t+=c,void(this.to+=c);r=null,this.revertPending(e.state)}if(i+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.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)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==r||this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class lw{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Wy(e.state||Sm.create(e)),e.scrollTo&&e.scrollTo.is(Mv)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Bv).map(e=>new _v(e));for(let e of this.plugins)e.update(this);this.observer=new iw(this),this.inputState=new Kb(this),this.inputState.ensureHandlers(this.plugins),this.docView=new xb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof dm?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,r=!1,i=this.state;for(let t of e){if(t.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=t.state}if(this.destroyed)return void(this.viewState.state=i);let o=this.hasFocus,s=0,a=null;e.some(e=>e.annotation(py))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=my(i,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(Sm.phrases)!=this.state.facet(Sm.phrases))return this.setState(i);t=Xv.create(this,i,e),t.flags|=s;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new Tv(e.empty?e:Dp.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(Mv)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=uw.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Yv)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(Yy)!=t.state.facet(Yy)&&(this.viewState.mustMeasureContent=!0),(n||r||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(xv))try{e(t)}catch(e){Dv(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Vb(this,c)&&l.force&&Kg(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Wy(e),this.plugins=e.facet(Bv).map(e=>new _v(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new xb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Bv),n=e.state.facet(Bv);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new _v(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){Dv(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(Yg(n))i=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5)break;let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return Dv(this.state,e),hw}}),c=Xv.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=hw)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){Dv(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(e>1||e<-1){r+=e,n.scrollTop=r/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(xv))e(t)}get themeClasses(){return Xy+" "+(this.state.facet(Gy)?Qy:Jy)+" "+this.state.facet(Yy)}updateAttrs(){let e=dw(this,jv,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Pv)?"true":"false",class:"cm-content",style:`${mg.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),dw(this,Fv,t);let n=this.observer.ignore(()=>{let n=yg(this.contentDOM,this.contentAttrs,t),r=yg(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(lw.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(Yv);let e=this.state.facet(lw.cspNonce);Km.mount(this.root,this.styleModules.concat(tw).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&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(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Rb(this,e,Ab(this,e,t,n))}moveByGroup(e,t){return Rb(this,e,Ab(this,e,t,t=>function(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==ym.Space&&(i=t),i==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return Dp.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,r){let i=Ob(e,t.head,t.assoc||-1),o=r&&i.type==kg.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),s=e.posAtCoords({x:n==(r==Qg.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return Dp.cursor(s,n?-1:1)}return Dp.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return Rb(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return Dp.cursor(i,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||-1),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(i);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-t.from))),s=(o<0?t.top:t.bottom)+h}let u=Pb(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return Dp.cursor(u.pos,u.assoc,void 0,a)}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=Pb(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Pb(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r);return Fg(n,i[lv.find(i,e-r.from,-1,t)].dir==Qg.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Nv)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>cw)return fv(e.length);let t,n=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==n&&(r.fresh||cv(r.isolates,t=Uv(this,e))))return r.order;t||(t=Uv(this,e));let r=function(e,t,n){if(!e)return[new lv(0,0,t==ev?1:0)];if(t==Zg&&!n.length&&!av.test(e))return fv(e.length);if(n.length)for(;e.length>hv.length;)hv[hv.length]=256;let r=[],i=t==Zg?0:1;return dv(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new uw(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||mg.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ug(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Mv.of(new Tv("number"==typeof e?Dp.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Mv.of(new Tv(Dp.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Iv.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Iv.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Km.newName(),r=[Yy.of(n),Yv.of(ew(`.${n}`,e))];return t&&t.dark&&r.push(Gy.of(!0)),r}static baseTheme(e){return Yp.lowest(Yv.of(ew("."+Xy,e,Zy)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&Qv.get(n)||Qv.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}lw.styleModule=Yv,lw.inputHandler=kv,lw.clipboardInputFilter=Ev,lw.clipboardOutputFilter=Cv,lw.scrollHandler=Av,lw.focusChangeEffect=Sv,lw.perLineTextDirection=Nv,lw.exceptionSink=wv,lw.updateListener=xv,lw.editable=Pv,lw.mouseSelectionStyle=yv,lw.dragMovesSelection=bv,lw.clickAddsSelectionRange=vv,lw.decorations=Wv,lw.blockWrappers=zv,lw.outerDecorations=Hv,lw.atomicRanges=Vv,lw.bidiIsolatedRanges=qv,lw.scrollMargins=$v,lw.darkTheme=Gy,lw.cspNonce=Bp.define({combine:e=>e.length?e[0]:""}),lw.contentAttributes=Fv,lw.editorAttributes=jv,lw.lineWrapping=lw.contentAttributes.of({class:"cm-lineWrapping"}),lw.announce=um.define();const cw=4096,hw={};class uw{constructor(e,t,n,r,i,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:Qg.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir!=r||t.touchesRange(o.from,o.to)||n.push(new uw(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function dw(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],o="function"==typeof t?t(e):t;o&&gg(o,n)}return n}const fw=mg.mac?"mac":mg.windows?"win":mg.linux?"linux":"key";function pw(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const mw=Yp.default(lw.domEventHandlers({keydown:(e,t)=>kw(bw(t.state),e,t,"editor")})),gw=Bp.define({enables:mw}),vw=new WeakMap;function bw(e){let t=e.facet(gw),n=vw.get(t);return n||vw.set(t,n=function(e,t=fw){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(null==n)r[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},o=(e,r,o,s,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),u=r.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let r,i,o,s,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?s=!0:i=!0}}return r&&(a="Alt-"+a),i&&(a="Ctrl-"+a),s&&(a="Meta-"+a),o&&(a="Shift-"+a),a}(e,t));for(let t=1;t<u.length;t++){let n=u.slice(0,t).join(" ");i(n,!0),h[n]||(h[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=yw={view:t,prefix:n,scope:e};return setTimeout(()=>{yw==r&&(yw=null)},ww),!0}]})}let d=u.join(" ");i(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),s&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,xw))}let i=r[t]||r.key;if(i)for(let t of e)o(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&o(t,"Shift-"+i,r.shift,r.preventDefault,r.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let yw=null;const ww=4e3;let xw=null;function kw(e,t,n,r){xw=t;let i=function(e){var t=!(Qm&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Zm&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Jm:Xm)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),o=wp(bp(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;yw&&yw.view==n&&yw.scope==r&&(s=yw.prefix+" ",Qb.indexOf(t.keyCode)<0&&(l=!0,yw=null));let h,u,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[r];return p&&(f(p[s+pw(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||mg.windows&&t.ctrlKey&&t.altKey||mg.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(h=Xm[t.keyCode])||h==i?o&&t.shiftKey&&f(p[s+pw(i,t,!0)])&&(a=!0):(f(p[s+pw(h,t,!0)])||t.shiftKey&&(u=Jm[t.keyCode])!=i&&u!=h&&f(p[s+pw(u,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),xw=null,a}class Sw{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let i=Ew(e);return[new Sw(t,r.left-i.left,r.top-i.top,null,r.bottom-r.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),o=e.textDirection==Qg.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=Ew(e),c=s.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=Ob(e,r,1),p=Ob(e,i,-1),m=f.type==kg.Text?f:null,g=p.type==kg.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=Cw(e,r,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=Cw(e,i,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return b(y(n.from,n.to,m));{let t=m?y(n.from,null,m):w(f,!1),r=g?y(null,n.to,g):w(p,!0),i=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(v(u,t.bottom,d,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==kg.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),b(t).concat(i).concat(b(r))}function v(e,n,r,i){return new Sw(t,e-l.left,n-l.top,r-e,i-n)}function b({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(v(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,s=-1e9,a=[];function l(t,n,l,c,h){let f=e.coordsAtPos(t,t==r.to?-2:2),p=e.coordsAtPos(l,l==r.from?2:-2);f&&p&&(i=Math.min(f.top,p.top,i),s=Math.max(f.bottom,p.bottom,s),h==Qg.LTR?a.push(o&&n?u:f.left,o&&c?d:p.right):a.push(!o&&c?u:p.left,!o&&n?d:f.right))}let c=null!=t?t:r.from,h=null!=n?n:r.to;for(let r of e.visibleRanges)if(r.to>c&&r.from<h)for(let i=Math.max(r.from,c),o=Math.min(r.to,h);;){let r=e.state.doc.lineAt(i);for(let s of e.bidiSpans(r)){let e=s.from+r.from,a=s.to+r.from;if(e>=o)break;a>i&&l(Math.max(e,i),null==t&&e<=c,Math.min(a,o),null==n&&a>=h,s.dir)}if(i=r.to+1,i>=o)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:i,bottom:s,horizontal:a}}function w(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function Ew(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Qg.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Cw(e,t,n,r){let i=e.coordsAtPos(t,2*n);if(!i)return r;let o=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return null==a||null==l?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}class Nw{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Ow)!=e.state.facet(Ow)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(Ow);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;e==this.scaleX&&t==this.scaleY||(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{return n=e,r=this.drawn[t],!(n.constructor==r.constructor&&n.eq(r));var n,r})){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,mg.safari&&mg.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Ow=Bp.define();function Aw(e){return[Iv.define(t=>new Nw(t,e)),Ow.of(e)]}const Tw=Bp.define({combine:e=>Em(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function Mw(e){return e.startState.facet(Tw)!=e.state.facet(Tw)}const Rw=Aw({above:!0,markers(e){let{state:t}=e,n=t.facet(Tw),r=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty||n.drawRangeCursor){let t=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=i.empty?i:Dp.cursor(i.head,i.head>i.anchor?-1:1);for(let i of Sw.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=Mw(e);return n&&Dw(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){Dw(t.state,e)},class:"cm-cursorLayer"});function Dw(e,t){t.style.animationDuration=e.facet(Tw).cursorBlinkRate+"ms"}const Pw=Aw({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:Sw.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||Mw(e),class:"cm-selectionLayer"}),Lw=Yp.highest(lw.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Bw=um.define({map:(e,t)=>null==e?null:t.mapPos(e)}),Iw=Hp.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(Bw)?t.value:e,e))}),_w=Iv.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(Iw);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(Iw)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Iw),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(Iw)!=e&&this.view.dispatch({effects:Bw.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function jw(e,t,n,r,i){t.lastIndex=0;for(let o,s=e.iterRange(n,r),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}class Fw{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:i,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,r,i)=>{let o=n(e,t,r);o&&i(r,r+e[0].length,o)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n)}this.boundary=i,this.maxLength=o}createDeco(e){let t=new Rm,n=t.add.bind(t);for(let{from:t,to:r}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:o}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=o:r.push({from:i,to:o});return r}(e,this.maxLength))jw(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,o,s)=>{s>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),r=Math.max(s,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let o=Math.max(i.from,n),s=Math.min(i.to,r);if(s>=o){let n=e.state.doc.lineAt(o),r=n.to<s?e.state.doc.lineAt(s):n,a=Math.max(i.from,n.from),l=Math.min(i.to,r.to);if(this.boundary){for(;o>n.from;o--)if(this.boundary.test(n.text[o-1-n.from])){a=o;break}for(;s<r.to;s++)if(this.boundary.test(r.text[s-r.from])){l=s;break}}let c,h=[],u=(e,t,n)=>h.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.index<l-n.from;)this.addMatch(c,e,c.index+n.from,u);else jw(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:h})}}return t}}const Ww=null!=/x/.unicode?"gu":"g",zw=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",Ww),Hw={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Vw=null;const qw=Bp.define({combine(e){let t=Em(e,{render:null,specialChars:zw,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Vw&&"undefined"!=typeof document&&document.body){let t=document.body.style;Vw=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Vw||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Ww)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Ww)),t}});let Uw=null;class $w extends xg{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(Hw[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}}class Kw extends xg{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const Yw=Sg.line({class:"cm-activeLine"}),Gw=Iv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Yw.range(i.from)),t=i.from)}return Sg.set(n)}},{decorations:e=>e.decorations});class Xw extends xg{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Pg(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Fg(t[0],"rtl"!=n.direction),i=parseInt(n.lineHeight);return r.bottom-r.top>1.5*i?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}}const Jw=2e3;function Qw(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>Jw?-1:i==r.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):Hm(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function Zw(e,t){let n=Qw(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,o){let s=Qw(e,t);if(!s)return r;let a=function(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>Jw||n.off>Jw||t.col<0||n.col<0){let s=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=a&&o.push(Dp.range(n.from+s,n.to+a))}}else{let s=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=Vm(n.text,s,e.tabSize,!0);if(r<0)o.push(Dp.cursor(n.to));else{let t=Vm(n.text,a,e.tabSize);o.push(Dp.range(n.from+r,n.from+t))}}}return o}(e.state,n,s);return a.length?o?Dp.create(a.concat(r.ranges)):Dp.create(a):r}}:null}const ex={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},tx={style:"cursor: crosshair"};const nx="-10000px";class rx{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let o=[],s=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],a=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(a=e)}if(a<0)o[n]=this.createTooltipView(r,n?o[n-1]:null),s&&(s[n]=!!r.above);else{let r=o[n]=this.tooltipViews[a];s&&(s[n]=t[a]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)o.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(s.forEach((e,n)=>t[n]=e),t.length=s.length),this.input=r,this.tooltips=i,this.tooltipViews=o,!0}}function ix(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const ox=Bp.define({combine:e=>{var t,n,r;return{position:mg.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(r=e.find(e=>e.tooltipSpace))||void 0===r?void 0:r.tooltipSpace)||ix}}}),sx=new WeakMap,ax=Iv.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(ox);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new rx(e,ux,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(ox);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.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 e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=nx,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 e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(mg.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Kv(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((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(ox).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:o}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=e.pos[a],d=e.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(n.top,r.top)||u.top>=Math.min(n.bottom,r.bottom)||u.right<Math.max(n.left,r.left)-.1||u.left>Math.min(n.right,r.right)+.1)){h.style.top=nx;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=sx.get(c))&&void 0!==t?t:d.bottom-d.top,v=c.offset||hx,b=this.view.textDirection==Qg.LTR,y=d.width>r.right-r.left?b?r.left:r.right-d.width:b?Math.max(r.left,Math.min(u.left-(f?14:0)+v.x,r.right-m)):Math.min(Math.max(r.left,u.left-m+(f?14:0)-v.x),r.right-m),w=this.above[a];!l.strictSide&&(w?u.top-g-p-v.y<r.top:u.bottom+g+p+v.y>r.bottom)&&w==r.bottom-u.bottom>u.top-r.top&&(w=this.above[a]=!w);let x=(w?u.top-r.top:r.bottom-u.bottom)-p;if(x<g&&!1!==c.resize){if(x<this.view.defaultLineHeight){h.style.top=nx;continue}sx.set(c,g),h.style.height=(g=x)/o+"px"}else h.style.height&&(h.style.height="");let k=w?u.top-g-p-v.y:u.bottom+p+v.y,S=y+m;if(!0!==c.overlap)for(let e of s)e.left<S&&e.right>y&&e.top<k+g&&e.bottom>k&&(k=w?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(h.style.top=(k-e.parent.top)/o+"px",lx(h,(y-e.parent.left)/i)):(h.style.top=k/o+"px",lx(h,y/i)),f){let e=u.left+(b?v.x:-v.x)-(y+14-7);f.style.left=e/i+"px"}!0!==c.overlap&&s.push({left:y,top:k,right:S,bottom:k+g}),h.classList.toggle("cm-tooltip-above",w),h.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=nx}},{eventObservers:{scroll(){this.maybeMeasure()}}});function lx(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const cx=lw.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:"14px",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"}}}),hx={x:0,y:0},ux=Bp.define({enables:[ax,cx]}),dx=Bp.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class fx{static create(e){return new fx(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new rx(e,dx,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(void 0!==r)if(void 0===t)t=r;else if(t!==r)return}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const px=ux.compute([dx],e=>{let t=e.facet(dx);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:fx.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class mx{constructor(e,t,n,r,i){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),null==r)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),s=o&&o.dir==Qg.RTL?-1:1;i=t.x<n.left?-s:s}let o=this.source(e,r,i);if(null==o?void 0:o.then){let t=this.pending={pos:r};o.then(n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>Dv(e.state,t,"hover tooltip"))}else!o||Array.isArray(o)&&!o.length||e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(ax),t=e?e.manager.tooltips.findIndex(e=>e.create==fx.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;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:r,tooltip:i}=this;if(r.length&&i&&!function(e,t){let n,{left:r,right:i,top:o,bottom:s}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();o=Math.min(e.top,o),s=Math.max(e.bottom,s)}return t.clientX>=r-gx&&t.clientX<=i+gx&&t.clientY>=o-gx&&t.clientY<=s+gx}(i.dom,e)||this.pending){let{pos:i}=r[0]||this.pending,o=null!==(n=null===(t=r[0])||void 0===t?void 0:t.end)&&void 0!==n?n:i;(i==o?this.view.posAtCoords(this.lastMove)==i:function(e,t,n,r,i){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let a=e.posAtCoords({x:r,y:i},!1);return a>=t&&a<=n}(this.view,i,o,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const gx=4;function vx(e,t={}){let n=um.define(),r=Hp.define({create:()=>[],update(e,r){if(e.length&&(t.hideOnChange&&(r.docChanged||r.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(r,e))),r.docChanged)){let t=[];for(let n of e){let e=r.changes.mapPos(n.pos,-1,kp.TrackDel);if(null!=e){let i=Object.assign(Object.create(null),n);i.pos=e,null!=i.end&&(i.end=r.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of r.effects)t.is(n)&&(e=t.value),t.is(yx)&&(e=[]);return e},provide:e=>dx.from(e)});return{active:r,extension:[r,Iv.define(i=>new mx(i,e,r,n,t.hoverTime||300)),px]}}function bx(e,t){let n=e.plugin(ax);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const yx=um.define(),wx=Bp.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function xx(e,t){let n=e.plugin(kx),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const kx=Iv.fromClass(class{constructor(e){this.input=e.state.facet(Cx),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(wx);this.top=new Sx(e,!0,t.topContainer),this.bottom=new Sx(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(wx);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Sx(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Sx(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Cx);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],o=[],s=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),s.push(t)):(t=this.panels[a],t.update&&t.update(e)),r.push(t),(t.top?i:o).push(t)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(o);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>lw.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Sx{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Ex(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Ex(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 Ex(e){let t=e.nextSibling;return e.remove(),t}const Cx=Bp.define({enables:kx});function Nx(e,t){let n,r=new Promise(e=>n=e),i=e=>function(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=ng("form"),t.input){let e=ng("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),r.appendChild(ng("label",(t.label||"")+": ",e))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(ng("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i="FORM"==r.nodeName?[r]:r.querySelectorAll("form");for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),s(null)):13==e.keyCode&&(e.preventDefault(),s(t))}),t.addEventListener("submit",e=>{e.preventDefault(),s(t)})}let o=ng("div",r,ng("button",{onclick:()=>s(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(o.className=t.class);function s(t){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(t)}return o.classList.add("cm-dialog"),{dom:o,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?r.querySelector(t.focus):r.querySelector("input")||r.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(Ox,!1)?e.dispatch({effects:Ax.of(i)}):e.dispatch({effects:um.appendConfig.of(Ox.init(()=>[i]))});let o=Tx.of(i);return{close:o,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(Ox).indexOf(i)>-1&&e.dispatch({effects:o})}),t))}}const Ox=Hp.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(Ax)?e=[n.value].concat(e):n.is(Tx)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>Cx.computeN([e],t=>t.field(e))}),Ax=um.define(),Tx=um.define();class Mx extends Cm{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Mx.prototype.elementClass="",Mx.prototype.toDOM=void 0,Mx.prototype.mapMode=kp.TrackBefore,Mx.prototype.startSide=Mx.prototype.endSide=-1,Mx.prototype.point=!0;const Rx=Bp.define(),Dx=Bp.define(),Px={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Mm.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Lx=Bp.define();function Bx(e){return[_x(),Lx.of({...Px,...e})]}const Ix=Bp.define({combine:e=>e.some(e=>e)});function _x(e){let t=[jx];return e&&!1===e.fixed&&t.push(Ix.of(!0)),t}const jx=Iv.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(Lx).map(t=>new Hx(e,t)),this.fixed=!e.state.facet(Ix);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<.8*(n.to-n.from))}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ix)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=Mm.iter(this.view.state.facet(Rx),this.view.viewport.from),r=[],i=this.gutters.map(e=>new zx(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let o of e.type)if(o.type==kg.Text&&t){Wx(n,r,o.from);for(let e of i)e.line(this.view,o,r);t=!1}else if(o.widget)for(let e of i)e.widget(this.view,o)}else if(e.type==kg.Text){Wx(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Lx),n=e.state.facet(Lx),r=e.docChanged||e.heightChanged||e.viewportChanged||!Mm.eq(e.startState.facet(Rx),e.state.facet(Rx),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Hx(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>lw.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Qg.LTR?{left:r,right:i}:{right:r,left:i}})});function Fx(e){return Array.isArray(e)?e:[e]}function Wx(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class zx{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Mm.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Vx(e,o,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,o,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Wx(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let o=this.gutter;(0!=r.length||o.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(Dx)){let i=n(e,t.widget,t);i&&(r||(r=[])).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Hx{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i,o=r.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let e=o.getBoundingClientRect();i=(e.top+e.bottom)/2}else i=r.clientY;let s=e.lineBlockAtHeight(i-e.documentTop);t.domEventHandlers[n](e,s,r)&&r.preventDefault()});this.markers=Fx(t.markers(e)),t.initialSpacer&&(this.spacer=new Vx(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Fx(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!Mm.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Vx{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let i=0,o=0;;){let s=o,a=i<t.length?t[i++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=o;e<this.markers.length;e++)if(this.markers[e].compare(a)){s=e,l=!0;break}}else s=this.markers.length;for(;o<s;){let e=this.markers[o++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}const qx=Bp.define(),Ux=Bp.define(),$x=Bp.define({combine:e=>Em(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})});class Kx extends Mx{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Yx(e,t){return e.state.facet($x).formatNumber(t,e.state)}const Gx=Lx.compute([$x],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(qx),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new Kx(Yx(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Ux)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet($x)!=e.state.facet($x),initialSpacer:e=>new Kx(Yx(e,Xx(e.state.doc.lines))),updateSpacer(e,t){let n=Yx(t.view,Xx(t.view.state.doc.lines));return n==e.number?e:new Kx(n)},domEventHandlers:e.facet($x).domEventHandlers,side:"before"}));function Xx(e){let t=9;for(;t<e;)t=10*t+9;return t}const Jx=new class extends Mx{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Qx=Rx.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Jx.range(i)))}return Mm.of(t)});const Zx=1024;let ek=0;class tk{constructor(e,t){this.from=e,this.to=t}}class nk{constructor(e={}){this.id=ek++,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"function"!=typeof e&&(e=ok.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}nk.closedBy=new nk({deserialize:e=>e.split(" ")}),nk.openedBy=new nk({deserialize:e=>e.split(" ")}),nk.group=new nk({deserialize:e=>e.split(" ")}),nk.isolate=new nk({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),nk.contextHash=new nk({perNode:!0}),nk.lookAhead=new nk({perNode:!0}),nk.mounted=new nk({perNode:!0});class rk{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[nk.mounted.id]}}const ik=Object.create(null);class ok{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):ik,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new ok(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(nk.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(nk.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}ok.none=new ok("",Object.create(null),0,8);class sk{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let t of e){let e=t(n);if(e){r||(r=Object.assign({},n.props));let t=e[1],i=e[0];i.combine&&i.id in r&&(t=i.combine(r[i.id],t)),r[i.id]=t}}t.push(r?new ok(n.name,r,n.id,n.flags):n)}return new sk(t)}}const ak=new WeakMap,lk=new WeakMap;var ck;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(ck||(ck={}));class hk{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=rk.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Sk(this.topNode,e)}cursorAt(e,t=0,n=0){let r=ak.get(this)||this.topNode,i=new Sk(r);return i.moveTo(e,t),ak.set(this,i._tree),i}get topNode(){return new gk(this,0,0,null)}resolve(e,t=0){let n=pk(ak.get(this)||this.topNode,e,t,!1);return ak.set(this,n),n}resolveInner(e,t=0){let n=pk(lk.get(this)||this.topNode,e,t,!0);return lk.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof gk?r:r.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(i||(i=[r])).push(o.resolve(t,n)),e=o}else{let o=rk.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new gk(o.tree,o.overlay[0].from+e.from,-1,e);(i||(i=[r])).push(pk(s,t,n,!1))}}return i?xk(i):r}(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&ck.IncludeAnonymous)>0;for(let e=this.cursor(o|ck.IncludeAnonymous);;){let o=!1;if(e.from<=i&&e.to>=r&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ok(ok.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new hk(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new hk(ok.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=Zx,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new uk(n,n.length):n,l=r.types,c=0,h=0;function u(e,t,n,b,y,w){let{id:x,start:k,end:S,size:E}=a,C=h,N=c;if(E<0){if(a.next(),-1==E){let t=o[x];return n.push(t),void b.push(k-e)}if(-3==E)return void(c=x);if(-4==E)return void(h=x);throw new RangeError(`Unrecognized record size: ${E}`)}let O,A,T=l[x],M=k-e;if(S-k<=i&&(A=g(a.pos-t,y))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,i=t.length;for(;a.pos>n;)i=v(A.start,t,i);O=new dk(t,S-A.start,r),M=A.start-e}else{let e=a.pos-E;a.next();let t=[],n=[],r=x>=s?x:-1,o=0,l=S;for(;a.pos>e;)r>=0&&a.id==r&&a.size>=0?(a.end<=l-i&&(p(t,n,k,o,a.end,l,r,C,N),o=t.length,l=a.end),a.next()):w>2500?d(k,e,t,n):u(k,e,t,n,r,w+1);if(r>=0&&o>0&&o<t.length&&p(t,n,k,o,k,l,r,C,N),t.reverse(),n.reverse(),r>-1&&o>0){let e=f(T,N);O=Ok(T,t,n,0,t.length,0,S-k,e,e)}else O=m(T,t,n,S-k,C-S,N)}n.push(O),b.push(M)}function d(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:r}=a;if(r>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-i),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),i=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-i,t[n++]=s[e+2]-i,t[n++]=n;n.push(new dk(t,s[2]-i,r)),o.push(i-e)}}function f(e,t){return(n,r,i)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof hk){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(nk.lookAhead))&&(a=r[l]+o.length+s)}return m(e,n,r,i,a,t)}}function p(e,t,n,i,o,s,a,l,c){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(m(r.types[a],h,u,s-o,l-s,c)),t.push(o-n)}function m(e,t,n,r,i,o,s){if(o){let e=[nk.contextHash,o];s=s?[e].concat(s):[e]}if(i>25){let e=[nk.lookAhead,i];s=s?[e].concat(s):[e]}return new hk(e,t,n,r,s)}function g(e,t){let n=a.fork(),r=0,o=0,l=0,c=n.end-i,h={size:0,start:0,skip:0};e:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){h.size=r,h.start=o,h.skip=l,l+=4,r+=4,n.next();continue}let a=n.pos-e;if(e<0||a<i||n.start<c)break;let u=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=d,r+=e,l+=u}return(t<0||r==e)&&(h.size=r,h.start=o,h.skip=l),h.size>4?h:void 0}function v(e,t,n){let{id:r,start:i,end:o,size:l}=a;if(a.next(),l>=0&&r<s){let s=n;if(l>4){let r=a.pos-(l-4);for(;a.pos>r;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==l?c=r:-4==l&&(h=r);return n}let b=[],y=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,b,y,-1,0);let w=null!==(t=e.length)&&void 0!==t?t:b.length?y[0]+b[0].length:0;return new hk(l[e.topID],b.reverse(),y.reverse(),w)}(e)}}hk.empty=new hk(ok.none,[],[],0);class uk{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new uk(this.buffer,this.index)}}class dk{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return ok.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(fk(i,r,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){i[a++]=r[s++],i[a++]=r[s++]-n;let t=i[a++]=r[s++]-n;i[a++]=r[s++]-e,o=Math.max(o,t)}return new dk(i,o,this.set)}}function fk(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function pk(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof gk&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:ck.IgnoreOverlays;if(r)for(let r=e,s=r.parent;s;r=s,s=r.parent)r instanceof gk&&r.index<0&&(null===(i=s.enter(t,n,o))||void 0===i?void 0:i.from)!=r.from&&(e=s);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class mk{cursor(e=0){return new Sk(this,e)}getChild(e,t=null,n=null){let r=vk(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return vk(this,e,t,n)}resolve(e,t=0){return pk(this,e,t,!1)}resolveInner(e,t=0){return pk(this,e,t,!0)}matchContext(e){return bk(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class gk extends mk{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,i=0){var o;for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let c=a[e],h=l[e]+s.from;if(i&ck.EnterBracketed&&c instanceof hk&&null===(null===(o=rk.get(c))||void 0===o?void 0:o.overlay)&&(h>=n||h+c.length<=n)||fk(r,n,h,h+c.length))if(c instanceof dk){if(i&ck.ExcludeBuffers)continue;let o=c.findChild(0,c.buffer.length,t,n-h,r);if(o>-1)return new wk(new yk(s,c,e,h),null,o)}else if(i&ck.IncludeAnonymous||!c.type.isAnonymous||Ek(c)){let o;if(!(i&ck.IgnoreMounts)&&(o=rk.get(c))&&!o.overlay)return new gk(o.tree,h,e,s);let a=new gk(c,h,e,s);return i&ck.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r,i)}}if(i&ck.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&ck.IgnoreOverlays)&&(r=rk.get(this._tree))&&r.overlay){let i=e-this.from,o=n&ck.EnterBracketed&&r.bracketed;for(let{from:e,to:n}of r.overlay)if((t>0||o?e<=i:e<i)&&(t<0||o?n>=i:n>i))return new gk(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 vk(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function bk(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class yk{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class wk extends mk{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new wk(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&ck.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new wk(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new wk(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new wk(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new hk(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function xk(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof gk&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new kk(i,n)}class kk{constructor(e,t){this.heads=e,this.node=t}get next(){return xk(this.heads)}}class Sk{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~ck.EnterBracketed,e instanceof gk)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof gk?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&ck.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ck.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ck.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));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&ck.IncludeAnonymous||e instanceof dk||!e.type.isAnonymous||Ek(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new wk(this.buffer,t,this.stack[e]);return this.bufferNode=new wk(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return bk(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return bk(this._tree,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Ek(e){return e.children.some(e=>e instanceof dk||!e.type.isAnonymous||Ek(e))}const Ck=new WeakMap;function Nk(e,t){if(!e.isAnonymous||t instanceof dk||t.type!=e)return 1;let n=Ck.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof hk)){n=1;break}n+=Nk(e,r)}Ck.set(t,n)}return n}function Ok(e,t,n,r,i,o,s,a,l){let c=0;for(let n=r;n<i;n++)c+=Nk(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,r,i,s,a){for(let c=i;c<s;){let i=c,f=r[c],p=Nk(e,n[c]);for(c++;c<s;c++){let t=Nk(e,n[c]);if(p+t>=h)break;p+=t}if(c==i+1){if(p>h){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+a);continue}u.push(n[i])}else{let t=r[c-1]+n[c-1].length-f;u.push(Ok(e,n,r,i,c,f,t,null,l))}d.push(f+a-o)}}(t,n,r,i,0),(a||l)(u,d,s)}class Ak{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new Ak(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let t=o;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new Ak(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&r.push(t),o.to>h)break;o=i<e.length?e[i++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return r}}class Tk{startParse(e,t,n){return"string"==typeof e&&(e=new Mk(e)),n=n?n.length?n.map(e=>new tk(e.from,e.to)):[new tk(0,0)]:[new tk(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class Mk{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new nk({perNode:!0});let Rk=0;class Dk{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Rk++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof Dk&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let r=new Dk(n,[],null,[]);if(r.set.push(r),t)for(let e of t.set)r.set.push(e);return r}static defineModifier(e){let t=new Lk(e);return e=>e.modified.indexOf(t)>-1?e:Lk.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let Pk=0;class Lk{constructor(e){this.name=e,this.instances=[],this.id=Pk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every((e,t)=>e==i[t]));var r,i});if(n)return n;let r=[],i=new Dk(e.name,r,e,t);for(let e of t)e.instances.push(i);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)r.push(Lk.get(t,e));return i}}function Bk(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new _k(r,i,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return Ik.add(t)}const Ik=new nk({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let o=new _k(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}});class _k{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function jk(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function Fk(e,t,n,r=0,i=e.length){let o=new Wk(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}_k.empty=new _k([],2,null);class Wk{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(o)));let l=r,c=function(e){let t=e.type.prop(Ik);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||_k.empty,h=function(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}(i,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(t,s),l),c.opaque)return;let u=e.tree&&e.tree.prop(nk.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter(e=>!e.scope||e.scope(u.tree.type)),h=e.firstChild();for(let d=0,f=s;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+s:a,g=Math.max(t,f),v=Math.min(n,m);if(g<v&&h)for(;e.from<v&&(this.highlightRange(e,g,v,r,i),this.startSpan(Math.min(v,e.to),l),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;f=p.to+s,f>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,f),"",c),this.startSpan(Math.min(n,f),l))}h&&e.parent()}else if(e.firstChild()){u&&(r="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const zk=Dk.define,Hk=zk(),Vk=zk(),qk=zk(Vk),Uk=zk(Vk),$k=zk(),Kk=zk($k),Yk=zk($k),Gk=zk(),Xk=zk(Gk),Jk=zk(),Qk=zk(),Zk=zk(),eS=zk(Zk),tS=zk(),nS={comment:Hk,lineComment:zk(Hk),blockComment:zk(Hk),docComment:zk(Hk),name:Vk,variableName:zk(Vk),typeName:qk,tagName:zk(qk),propertyName:Uk,attributeName:zk(Uk),className:zk(Vk),labelName:zk(Vk),namespace:zk(Vk),macroName:zk(Vk),literal:$k,string:Kk,docString:zk(Kk),character:zk(Kk),attributeValue:zk(Kk),number:Yk,integer:zk(Yk),float:zk(Yk),bool:zk($k),regexp:zk($k),escape:zk($k),color:zk($k),url:zk($k),keyword:Jk,self:zk(Jk),null:zk(Jk),atom:zk(Jk),unit:zk(Jk),modifier:zk(Jk),operatorKeyword:zk(Jk),controlKeyword:zk(Jk),definitionKeyword:zk(Jk),moduleKeyword:zk(Jk),operator:Qk,derefOperator:zk(Qk),arithmeticOperator:zk(Qk),logicOperator:zk(Qk),bitwiseOperator:zk(Qk),compareOperator:zk(Qk),updateOperator:zk(Qk),definitionOperator:zk(Qk),typeOperator:zk(Qk),controlOperator:zk(Qk),punctuation:Zk,separator:zk(Zk),bracket:eS,angleBracket:zk(eS),squareBracket:zk(eS),paren:zk(eS),brace:zk(eS),content:Gk,heading:Xk,heading1:zk(Xk),heading2:zk(Xk),heading3:zk(Xk),heading4:zk(Xk),heading5:zk(Xk),heading6:zk(Xk),contentSeparator:zk(Gk),list:zk(Gk),quote:zk(Gk),emphasis:zk(Gk),strong:zk(Gk),link:zk(Gk),monospace:zk(Gk),strikethrough:zk(Gk),inserted:zk(),deleted:zk(),changed:zk(),invalid:zk(),meta:tS,documentMeta:zk(tS),annotation:zk(tS),processingInstruction:zk(tS),definition:Dk.defineModifier("definition"),constant:Dk.defineModifier("constant"),function:Dk.defineModifier("function"),standard:Dk.defineModifier("standard"),local:Dk.defineModifier("local"),special:Dk.defineModifier("special")};for(let e in nS){let t=nS[e];t instanceof Dk&&(t.name=e)}var rS;jk([{tag:nS.link,class:"tok-link"},{tag:nS.heading,class:"tok-heading"},{tag:nS.emphasis,class:"tok-emphasis"},{tag:nS.strong,class:"tok-strong"},{tag:nS.keyword,class:"tok-keyword"},{tag:nS.atom,class:"tok-atom"},{tag:nS.bool,class:"tok-bool"},{tag:nS.url,class:"tok-url"},{tag:nS.labelName,class:"tok-labelName"},{tag:nS.inserted,class:"tok-inserted"},{tag:nS.deleted,class:"tok-deleted"},{tag:nS.literal,class:"tok-literal"},{tag:nS.string,class:"tok-string"},{tag:nS.number,class:"tok-number"},{tag:[nS.regexp,nS.escape,nS.special(nS.string)],class:"tok-string2"},{tag:nS.variableName,class:"tok-variableName"},{tag:nS.local(nS.variableName),class:"tok-variableName tok-local"},{tag:nS.definition(nS.variableName),class:"tok-variableName tok-definition"},{tag:nS.special(nS.variableName),class:"tok-variableName2"},{tag:nS.definition(nS.propertyName),class:"tok-propertyName tok-definition"},{tag:nS.typeName,class:"tok-typeName"},{tag:nS.namespace,class:"tok-namespace"},{tag:nS.className,class:"tok-className"},{tag:nS.macroName,class:"tok-macroName"},{tag:nS.propertyName,class:"tok-propertyName"},{tag:nS.operator,class:"tok-operator"},{tag:nS.comment,class:"tok-comment"},{tag:nS.meta,class:"tok-meta"},{tag:nS.invalid,class:"tok-invalid"},{tag:nS.punctuation,class:"tok-punctuation"}]);const iS=new nk;const oS=new nk;class sS{constructor(e,t,n=[],r=""){this.data=e,this.name=r,Sm.prototype.hasOwnProperty("tree")||Object.defineProperty(Sm.prototype,"tree",{get(){return cS(this)}}),this.parser=t,this.extension=[bS.of(this),Sm.languageData.of((e,t,n)=>{let r=aS(e,t,n),i=r.type.prop(iS);if(!i)return[];let o=e.facet(i),s=r.type.prop(oS);if(s){let i=r.resolve(t-r.from,n);for(let t of s)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o})].concat(n)}isActiveAt(e,t,n=-1){return aS(e,t,n).type.prop(iS)==this.data}findRegions(e){let t=e.facet(bS);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(iS)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(nk.mounted);if(i){if(i.tree.prop(iS)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof hk&&r(i,e.positions[n]+t)}};return r(cS(e),0),n}get allowsNesting(){return!0}}function aS(e,t,n){let r=e.facet(bS),i=cS(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,ck.ExcludeBuffers|ck.EnterBracketed))e.type.isTop&&(i=e);return i}sS.setState=um.define();class lS extends sS{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,Bp.define({combine:n?e=>e.concat(n):void 0}));var n;return new lS(t,e.parser.configure({props:[iS.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new lS(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function cS(e){let t=e.field(sS.state,!1);return t?t.tree:hk.empty}class hS{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let uS=null;class dS{constructor(e,t,n=[],r,i,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new dS(e,t,[],hk.empty,0,n,[],null)}startParse(){return this.parser.startParse(new hS(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=hk.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(Ak.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ak.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=uS;uS=this;try{return e()}finally{uS=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=fS(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:i,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i})),n=Ak.applyChanges(n,t),r=hk.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&s.push({from:n,to:r})}}}return new dS(this.parser,t,n,r,i,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=fS(this.fragments,n,r),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Tk{createParse(t,n,r){let i=r[0].from,o=r[r.length-1].to,s={parsedPos:i,advance(){let t=uS;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new hk(ok.none,[],[],o-i)},stoppedAt:null,stopAt(){}};return s}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return uS}}function fS(e,t,n){return Ak.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class pS{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new pS(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=dS.create(e.facet(bS).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new pS(n)}}sS.state=Hp.define({create:pS.init,update(e,t){for(let e of t.effects)if(e.is(sS.setState))return e.value;return t.startState.facet(bS)!=t.state.facet(bS)?pS.init(t.state):e.apply(t)}});let mS=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(mS=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const gS="undefined"!=typeof navigator&&(null===(rS=navigator.scheduling)||void 0===rS?void 0:rS.isInputPending)?()=>navigator.scheduling.isInputPending():null,vS=Iv.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(sS.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(sS.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=mS(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(sS.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!gS?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,a=i.context.work(()=>gS&&gS()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:sS.setState.of(new pS(i.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Dv(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),bS=Bp.define({combine:e=>e.length?e[0]:null,enables:e=>[sS.state,vS,lw.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class yS{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const wS=Bp.define(),xS=Bp.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function kS(e){let t=e.facet(xS);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function SS(e,t){let n="",r=e.tabSize,i=e.facet(xS)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let e=0;e<t;e++)n+=i;return n}function ES(e,t){e instanceof Sm&&(e=new CS(e));for(let n of e.state.facet(wS)){let r=n(e,t);if(void 0!==r)return r}let n=cS(e.state);return n.length>=t?function(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return OS(r,e,n)}(e,n,t):null}class CS{constructor(e,t={}){this.state=e,this.options=t,this.unit=kS(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Hm(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const NS=new nk;function OS(e,t,n){for(let r=e;r;r=r.next){let e=AS(r.node);if(e)return e(MS.create(t,n,r))}return 0}function AS(e){let t=e.type.prop(NS);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(nk.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=s)return null;let e=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?TS:null}function TS(){return 0}class MS extends CS{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new MS(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(RS(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return OS(this.context.next,this.base,this.pos)}}function RS(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function DS({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const PS=Bp.define(),LS=new nk;function BS(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function IS(e,t,n){for(let r of e.facet(PS)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=cS(e);if(r.length<n)return null;let i=null;for(let o=r.resolveStack(n,1);o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<t)break;let a=s.type.prop(LS);if(a&&(s.to<r.length-50||r.length==e.doc.length||!BS(s))){let r=a(s,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function _S(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const jS=um.define({map:_S}),FS=um.define({map:_S});function WS(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const zS=Hp.define({create:()=>Sg.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=HS(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(jS)&&!qS(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(GS),i=r?Sg.replace({widget:new ZS(r(t.state,n.value))}):QS;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(FS)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=HS(e,t.selection.main.head)),e},provide:e=>lw.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(QS.range(r,i))}return Sg.set(t,!0)}});function HS(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function VS(e,t,n){var r;let i=null;return null===(r=e.field(zS,!1))||void 0===r||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function qS(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function US(e,t){return e.field(zS,!1)?t:t.concat(um.appendConfig.of(XS()))}function $S(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return lw.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const KS=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of WS(e)){let n=IS(e.state,t.from,t.to);if(n)return e.dispatch({effects:US(e.state,[jS.of(n),$S(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(zS,!1))return!1;let t=[];for(let n of WS(e)){let r=VS(e.state,n.from,n.to);r&&t.push(FS.of(r),$S(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=IS(t,i.from,i.to);o&&n.push(jS.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:US(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(zS,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(FS.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],YS={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},GS=Bp.define({combine:e=>Em(e,YS)});function XS(e){let t=[zS,nE];return e&&t.push(GS.of(e)),t}function JS(e,t){let{state:n}=e,r=n.facet(GS),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=VS(e.state,n.from,n.to);r&&e.dispatch({effects:FS.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const QS=Sg.replace({widget:new class extends xg{toDOM(e){return JS(e,null)}}});class ZS extends xg{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return JS(e,this.value)}}const eE={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class tE extends Mx{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}const nE=lw.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class rE{constructor(e,t){let n;function r(e){let t=Km.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof sS?e=>e.prop(iS)==o.data:o?e=>e==o:void 0,this.style=jk(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Km(n):null,this.themeType=t.themeType}static define(e,t){return new rE(e,t||{})}}const iE=Bp.define(),oE=Bp.define({combine:e=>e.length?[e[0]]:null});function sE(e){let t=e.facet(iE);return t.length?t:e.facet(oE)}function aE(e,t){let n,r=[cE];return e instanceof rE&&(e.module&&r.push(lw.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(oE.of(e)):n?r.push(iE.computeN([lw.darkTheme],t=>t.facet(lw.darkTheme)==("dark"==n)?[e]:[])):r.push(iE.of(e)),r}class lE{constructor(e){this.markCache=Object.create(null),this.tree=cS(e.state),this.decorations=this.buildDeco(e,sE(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=cS(e.state),n=sE(e.state),r=n!=sE(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return Sg.none;let n=new Rm;for(let{from:r,to:i}of e.visibleRanges)Fk(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=Sg.mark({class:r})))},r,i);return n.finish()}}const cE=Yp.high(Iv.fromClass(lE,{decorations:e=>e.decorations})),hE=rE.define([{tag:nS.meta,color:"#404740"},{tag:nS.link,textDecoration:"underline"},{tag:nS.heading,textDecoration:"underline",fontWeight:"bold"},{tag:nS.emphasis,fontStyle:"italic"},{tag:nS.strong,fontWeight:"bold"},{tag:nS.strikethrough,textDecoration:"line-through"},{tag:nS.keyword,color:"#708"},{tag:[nS.atom,nS.bool,nS.url,nS.contentSeparator,nS.labelName],color:"#219"},{tag:[nS.literal,nS.inserted],color:"#164"},{tag:[nS.string,nS.deleted],color:"#a11"},{tag:[nS.regexp,nS.escape,nS.special(nS.string)],color:"#e40"},{tag:nS.definition(nS.variableName),color:"#00f"},{tag:nS.local(nS.variableName),color:"#30a"},{tag:[nS.typeName,nS.namespace],color:"#085"},{tag:nS.className,color:"#167"},{tag:[nS.special(nS.variableName),nS.macroName],color:"#256"},{tag:nS.definition(nS.propertyName),color:"#00c"},{tag:nS.comment,color:"#940"},{tag:nS.invalid,color:"#f00"}]),uE=lw.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),dE="()[]{}",fE=Bp.define({combine:e=>Em(e,{afterCursor:!0,brackets:dE,maxScanDistance:1e4,renderMatch:gE})}),pE=Sg.mark({class:"cm-matchingBracket"}),mE=Sg.mark({class:"cm-nonmatchingBracket"});function gE(e){let t=[],n=e.matched?pE:mE;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const vE=Hp.define({create:()=>Sg.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(fE);for(let e of t.state.selection.ranges){if(!e.empty)continue;let i=kE(t.state,e.head,-1,r)||e.head>0&&kE(t.state,e.head-1,1,r)||r.afterCursor&&(kE(t.state,e.head,1,r)||e.head<t.state.doc.length&&kE(t.state,e.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,t.state)))}return Sg.set(n,!0)},provide:e=>lw.decorations.from(e)}),bE=[vE,uE];const yE=new nk;function wE(e,t,n){let r=e.prop(t<0?nk.openedBy:nk.closedBy);if(r)return r;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function xE(e){let t=e.type.prop(yE);return t?t(e.node):e}function kE(e,t,n,r={}){let i=r.maxScanDistance||1e4,o=r.brackets||dE,s=cS(e),a=s.resolveInner(t,n);for(let r=a;r;r=r.parent){let i=wE(r.type,n,o);if(i&&r.from<r.to){let s=xE(r);if(s&&(n>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return SE(e,t,n,r,s,i,o)}}return function(e,t,n,r,i,o,s){let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!h.next().done&&e<=o;){let o=h.value;n<0&&(e+=o.length);let a=t+e*n;for(let e=n>0?0:o.length-1,t=n>0?o.length:-1;e!=t;e+=n){let t=s.indexOf(o[e]);if(!(t<0||r.resolveInner(a+e,1).type!=i))if(t%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}n>0&&(e+=o.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,i,o)}function SE(e,t,n,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},c=0,h=null==a?void 0:a.cursor();if(h&&(n<0?h.childBefore(r.from):h.childAfter(r.to)))do{if(n<0?h.to<=r.from:h.from>=r.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let e=xE(h);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(wE(h.type,n,s))c++;else if(wE(h.type,-n,s)){if(0==c){let e=xE(h);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const EE=Object.create(null),CE=[ok.none],NE=[],OE=Object.create(null),AE=Object.create(null);for(let[e,t]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"]])AE[e]=ME(EE,t);function TE(e,t){NE.indexOf(e)>-1||NE.push(e)}function ME(e,t){let n=[];for(let r of t.split(" ")){let t=[];for(let n of r.split(".")){let r=e[n]||nS[n];r?"function"==typeof r?t.length?t=t.map(r):TE(n):t.length?TE(n):t=Array.isArray(r)?r:[r]:TE(n)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(e=>e.id),o=OE[i];if(o)return o.id;let s=OE[i]=ok.define({id:CE.length,name:r,props:[Bk({[r]:n})]});return CE.push(s),s.id}Qg.RTL,Qg.LTR;function RE(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const DE=RE(jE,0),PE=RE(_E,0),LE=RE((e,t)=>_E(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t)),0);function BE(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const IE=50;function _E(e,t,n=t.selection.ranges){let r=n.map(e=>BE(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>function(e,{open:t,close:n},r,i){let o,s,a=e.sliceDoc(r-IE,r),l=e.sliceDoc(i,i+IE),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-t.length,u)==t&&l.slice(h,h+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-r<=2*IE?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+IE),s=e.sliceDoc(i-IE,i));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(s)[0].length,p=s.length-f-n.length;return o.slice(d,d+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:i-f-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,r[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function jE(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:e,to:o}of n){let n=r.length,s=1e9,a=BE(t,e).line;if(a){for(let n=e;n<=o;){let l=t.doc.lineAt(n);if(l.from>i&&(e==o||o>l.from)){i=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,n=l.text.slice(e,e+a.length)==a?e:-1;e<l.text.length&&e<s&&(s=e),r.push({line:l,comment:n,token:a,indent:e,empty:t,single:!1})}n=l.to+1}if(s<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=s);r.length==n+1&&(r[n].single=!0)}}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:o,single:s}of r)!s&&o||e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const FE=lm.define(),WE=lm.define(),zE=Bp.define(),HE=Bp.define({combine:e=>Em(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),VE=Hp.define({create:()=>oC.empty,update(e,t){let n=t.state.facet(HE),r=t.annotation(FE);if(r){let i=GE.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?XE(s,s.length,n.minDepth,i):eC(s,t.startState.selection),new oC(0==o?r.rest:s,0==o?s:r.rest)}let i=t.annotation(WE);if("full"!=i&&"before"!=i||(e=e.isolate()),!1===t.annotation(dm.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=GE.fromTransaction(t),s=t.annotation(dm.time),a=t.annotation(dm.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),"full"!=i&&"after"!=i||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new oC(e.done.map(GE.fromJSON),e.undone.map(GE.fromJSON))});function qE(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(VE,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const UE=qE(0,!1),$E=qE(1,!1),KE=qE(0,!0),YE=qE(1,!0);class GE{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new GE(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new GE(e.changes&&Ep.fromJSON(e.changes),[],e.mapped&&Sp.fromJSON(e.mapped),e.startSelection&&Dp.fromJSON(e.startSelection),e.selectionsAfter.map(Dp.fromJSON))}static fromTransaction(e,t){let n=QE;for(let t of e.startState.facet(zE)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new GE(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,QE)}static selection(e){return new GE(void 0,QE,void 0,void 0,e)}}function XE(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function JE(e,t){return e.length?t.length?e.concat(t):e:t}const QE=[],ZE=200;function eC(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ZE));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),XE(e,e.length-1,1e9,n.setSelAfter(r)))}return[GE.selection([t])]}function tC(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function nC(e,t){if(!e.length)return e;let n=e.length,r=QE;for(;n;){let i=rC(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[GE.selection(r)]:QE}function rC(e,t,n){let r=JE(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):QE,n);if(!e.changes)return GE.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new GE(i,um.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const iC=/^(input\.type|delete)($|\.)/;class oC{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new oC(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||iC.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,function(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,o)=>{for(let e=0;e<n.length;){let t=n[e++],s=n[e++];o>=t&&i<=s&&(r=!0)}}),r}(s.changes,e.changes))||"input.type.compose"==n)?XE(o,o.length-1,r.minDepth,new GE(e.changes.compose(s.changes),JE(um.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,QE)):XE(o,o.length,r.minDepth,e),new oC(o,QE,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:QE;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter((e,t)=>e.empty!=s.ranges[t].empty).length)?this:new oC(eC(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new oC(nC(this.done,e),nC(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1],o=i.selectionsAfter[0]||t.selection;if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:FE.of({side:e,rest:tC(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?QE:r.slice(0,r.length-1);return i.mapped&&(n=nC(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:FE.of({side:e,rest:n,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}oC.empty=new oC(QE,QE);const sC=[{key:"Mod-z",run:UE,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:$E,preventDefault:!0},{linux:"Ctrl-Shift-z",run:$E,preventDefault:!0},{key:"Mod-u",run:KE,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:YE,preventDefault:!0}];function aC(e,t){return Dp.create(e.ranges.map(t),e.mainIndex)}function lC(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function cC({state:e,dispatch:t},n){let r=aC(e.selection,n);return!r.eq(e.selection,!0)&&(t(lC(e,r)),!0)}function hC(e,t){return Dp.cursor(t?e.to:e.from)}function uC(e,t){return cC(e,n=>n.empty?e.moveByChar(n,t):hC(n,t))}function dC(e){return e.textDirectionAt(e.state.selection.main.head)==Qg.LTR}const fC=e=>uC(e,!dC(e)),pC=e=>uC(e,dC(e));function mC(e,t){return cC(e,n=>n.empty?e.moveByGroup(n,t):hC(n,t))}function gC(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function vC(e,t,n){let r,i,o=cS(e).resolveInner(t.head),s=n?nk.closedBy:nk.openedBy;for(let r=t.head;;){let t=n?o.childAfter(r):o.childBefore(r);if(!t)break;gC(e,t,s)?o=t:r=n?t.to:t.from}return i=o.type.prop(s)&&(r=n?kE(e,o.from,1):kE(e,o.to,-1))&&r.matched?n?r.end.to:r.end.from:n?o.to:o.from,Dp.cursor(i,n?-1:1)}function bC(e,t){return cC(e,n=>{if(!n.empty)return hC(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const yC=e=>bC(e,!1),wC=e=>bC(e,!0);function xC(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){for(let t of e.state.facet(lw.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(r=Math.max(null==n?void 0:n.top,r)),(null==n?void 0:n.bottom)&&(i=Math.max(null==n?void 0:n.bottom,i))}t=e.scrollDOM.clientHeight-r-i}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:i,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function kC(e,t){let n,r=xC(e),{state:i}=e,o=aC(i.selection,n=>n.empty?e.moveVertically(n,t,r.height):hC(n,t));if(o.eq(i.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(i.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),a=s.top+r.marginTop,l=s.bottom-r.marginBottom;t&&t.top>a&&t.bottom<l&&(n=lw.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(lC(i,o),{effects:n}),!0}const SC=e=>kC(e,!1),EC=e=>kC(e,!0);function CC(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=Dp.cursor(r.from+n))}return i}function NC(e,t){let n=aC(e.state.selection,e=>{let n=t(e);return Dp.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(lC(e.state,n)),!0)}function OC(e,t){return NC(e,n=>e.moveByChar(n,t))}const AC=e=>OC(e,!dC(e)),TC=e=>OC(e,dC(e));function MC(e,t){return NC(e,n=>e.moveByGroup(n,t))}function RC(e,t){return NC(e,n=>e.moveVertically(n,t))}const DC=e=>RC(e,!1),PC=e=>RC(e,!0);function LC(e,t){return NC(e,n=>e.moveVertically(n,t,xC(e).height))}const BC=e=>LC(e,!1),IC=e=>LC(e,!0),_C=({state:e,dispatch:t})=>(t(lC(e,{anchor:0})),!0),jC=({state:e,dispatch:t})=>(t(lC(e,{anchor:e.doc.length})),!0),FC=({state:e,dispatch:t})=>(t(lC(e,{anchor:e.selection.main.anchor,head:0})),!0),WC=({state:e,dispatch:t})=>(t(lC(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function zC(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let o=n.doc.lineAt(r.head);if(t?o.to<e.state.doc.length:o.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<o.from||r.head>o.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(lC(n,Dp.create(i,i.length-1))),!0)}function HC(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:o}=r;if(i==o){let s=t(r);s<i?(n="delete.backward",s=VC(e,s,!1)):s>i&&(n="delete.forward",s=VC(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=VC(e,i,!1),o=VC(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:Dp.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?lw.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function VC(e,t,n){if(e instanceof lw)for(let r of e.state.facet(lw.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}const qC=(e,t,n)=>HC(e,r=>{let i,o,s=r.from,{state:a}=e,l=a.doc.lineAt(s);if(n&&!t&&s>l.from&&s<l.from+200&&!/[^ \t]/.test(i=l.text.slice(0,s-l.from))){if("\t"==i[i.length-1])return s-1;let e=Hm(i,a.tabSize)%kS(a)||kS(a);for(let t=0;t<e&&" "==i[i.length-1-t];t++)s--;o=s}else o=vp(l.text,s-l.from,t,t)+l.from,o==s&&l.number!=(t?a.doc.lines:1)?o+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,s-l.from))&&(o=vp(l.text,o-l.from,!1,!1)+l.from);return o}),UC=e=>qC(e,!1,!0),$C=e=>qC(e,!0,!1),KC=(e,t)=>HC(e,n=>{let r=n.head,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let e=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let a=vp(o.text,r-o.from,t)+o.from,l=o.text.slice(Math.min(r,a)-o.from,Math.max(r,a)-o.from),c=s(l);if(null!=e&&c!=e)break;" "==l&&r==n.head||(e=c),r=a}return r}),YC=e=>KC(e,!1);function GC(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function XC(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of GC(e)){if(n?t.to==e.doc.length:0==t.from)continue;let o=e.doc.lineAt(n?t.to+1:t.from-1),s=o.length+1;if(n){r.push({from:t.to,to:o.to},{from:t.from,insert:o.text+e.lineBreak});for(let n of t.ranges)i.push(Dp.range(Math.min(e.doc.length,n.anchor+s),Math.min(e.doc.length,n.head+s)))}else{r.push({from:o.from,to:t.from},{from:t.to,insert:e.lineBreak+o.text});for(let e of t.ranges)i.push(Dp.range(e.anchor-s,e.head-s))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:Dp.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function JC(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of GC(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const QC=eN(!1),ZC=eN(!0);function eN(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,o=t.doc.lineAt(r),s=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=cS(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(nk.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(i.to,o.from))?{from:i.to,to:o.from}:null}(t,r);e&&(r=i=(i<=o.to?o:t.doc.lineAt(i)).to);let a=new CS(t,{simulateBreak:r,simulateDoubleBreak:!!s}),l=ES(a,r);for(null==l&&(l=Hm(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));i<o.to&&/\s/.test(o.text[i-o.from]);)i++;s?({from:r,to:i}=s):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",SS(t,l)];return s&&c.push(SS(t,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:ap.of(c)},range:Dp.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function tN(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let s=e.doc.lineAt(o);s.number>n&&(r.empty||r.to>s.from)&&(t(s,i,r),n=s.number),o=s.to+1}let o=e.changes(i);return{changes:i,range:Dp.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const nN=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(tN(e,(t,n)=>{n.push({from:t.from,insert:e.facet(xS)})}),{userEvent:"input.indent"})),!0),rN=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(tN(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Hm(r,e.tabSize),o=0,s=SS(e,Math.max(0,i-kS(e)));for(;o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:s.slice(o)})}),{userEvent:"delete.dedent"})),!0),iN=[{key:"Ctrl-b",run:fC,shift:AC,preventDefault:!0},{key:"Ctrl-f",run:pC,shift:TC},{key:"Ctrl-p",run:yC,shift:DC},{key:"Ctrl-n",run:wC,shift:PC},{key:"Ctrl-a",run:e=>cC(e,t=>Dp.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>NC(e,t=>Dp.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>cC(e,t=>Dp.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>NC(e,t=>Dp.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:$C},{key:"Ctrl-h",run:UC},{key:"Ctrl-k",run:e=>HC(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:YC},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:ap.of(["",""])},range:Dp.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:vp(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:vp(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(i,n))},range:Dp.cursor(o)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:EC}],oN=[{key:"ArrowLeft",run:fC,shift:AC,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>mC(e,!dC(e)),shift:e=>MC(e,!dC(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>cC(e,t=>CC(e,t,!dC(e))),shift:e=>NC(e,t=>CC(e,t,!dC(e))),preventDefault:!0},{key:"ArrowRight",run:pC,shift:TC,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>mC(e,dC(e)),shift:e=>MC(e,dC(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>cC(e,t=>CC(e,t,dC(e))),shift:e=>NC(e,t=>CC(e,t,dC(e))),preventDefault:!0},{key:"ArrowUp",run:yC,shift:DC,preventDefault:!0},{mac:"Cmd-ArrowUp",run:_C,shift:FC},{mac:"Ctrl-ArrowUp",run:SC,shift:BC},{key:"ArrowDown",run:wC,shift:PC,preventDefault:!0},{mac:"Cmd-ArrowDown",run:jC,shift:WC},{mac:"Ctrl-ArrowDown",run:EC,shift:IC},{key:"PageUp",run:SC,shift:BC},{key:"PageDown",run:EC,shift:IC},{key:"Home",run:e=>cC(e,t=>CC(e,t,!1)),shift:e=>NC(e,t=>CC(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:_C,shift:FC},{key:"End",run:e=>cC(e,t=>CC(e,t,!0)),shift:e=>NC(e,t=>CC(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:jC,shift:WC},{key:"Enter",run:QC,shift:QC},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:UC,shift:UC,preventDefault:!0},{key:"Delete",run:$C,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:YC,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>KC(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>HC(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>HC(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(iN.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sN=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>cC(e,t=>vC(e.state,t,!dC(e))),shift:e=>NC(e,t=>vC(e.state,t,!dC(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>cC(e,t=>vC(e.state,t,dC(e))),shift:e=>NC(e,t=>vC(e.state,t,dC(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>XC(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>JC(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>XC(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>JC(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>zC(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>zC(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Dp.create([n.main]):n.main.empty||(r=Dp.create([Dp.cursor(n.main.head)])),!!r&&(t(lC(e,r)),!0)}},{key:"Mod-Enter",run:ZC},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=GC(e).map(({from:t,to:n})=>Dp.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Dp.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=aC(e.selection,t=>{let n=cS(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return Dp.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(lC(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:rN},{key:"Mod-]",run:nN},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new CS(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=tN(e,(t,i,o)=>{let s=ES(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=SS(e,s);(a!=l||o.from<t.from+a.length)&&(n[t.from]=s,i.push({from:t.from,to:t.from+a.length,insert:l}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(GC(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=aC(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,n){let r=!1,i=aC(e.selection,t=>{let i=kE(e,t.head,-1)||kE(e,t.head,1)||t.head>0&&kE(e,t.head-1,1)||t.head<e.doc.length&&kE(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let o=i.start.from==t.head?i.end.to:i.end.from;return n?Dp.range(t.anchor,o):Dp.cursor(o)});return!!r&&(t(lC(e,i)),!0)}(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=BE(e.state,n.from);return r.line?DE(e):!!r.block&&LE(e)}},{key:"Alt-A",run:PE},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(oN),aN={key:"Tab",run:nN,shift:rN},lN="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class cN{constructor(e,t,n=0,r=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(lN(e)):lN,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return bp(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=yp(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=wp(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let o=r.charCodeAt(e),s=this.match(o,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(s)return this.value=s,this;break}i==n&&e<t.length&&t.charCodeAt(e)==o&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,o=!0)),o||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(cN.prototype[Symbol.iterator]=function(){return this});const hN={from:-1,to:-1,match:/.*/.exec("")},uN="gm"+(null==/x/.unicode?"":"u");class dN{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=hN,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new mN(e,t,n,r,i);this.re=new RegExp(t,uN+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=gN(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=gN(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const fN=new WeakMap;class pN{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=fN.get(e);if(!r||r.from>=n||r.to<=t){let r=new pN(t,e.sliceString(t,n));return fN.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),fN.set(e,new pN(o,i)),new pN(t,i.slice(t-o,n-o))}}class mN{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=hN,this.matchPos=gN(e,r),this.re=new RegExp(t,uN+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=pN.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=gN(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=pN.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function gN(e,t){if(t>=e.length)return t;let n,r=e.lineAt(t);for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(dN.prototype[Symbol.iterator]=mN.prototype[Symbol.iterator]=function(){return this});const vN={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},bN=Bp.define({combine:e=>Em(e,vN,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const yN=Sg.mark({class:"cm-selectionMatch"}),wN=Sg.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function xN(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==ym.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==ym.Word)}const kN=Iv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(bN),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Sg.none;let i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return Sg.none;let e=n.wordAt(o.head);if(!e)return Sg.none;s=n.charCategorizer(o.head),i=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return Sg.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!xN(s,n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==ym.Word&&e(t.sliceDoc(r-1,r))==ym.Word}(s,n,o.from,o.to))return Sg.none}else if(i=n.sliceDoc(o.from,o.to),!i)return Sg.none}let a=[];for(let r of e.visibleRanges){let e=new cN(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!s||xN(s,n,r,i))&&(o.empty&&r<=o.from&&i>=o.to?a.push(wN.range(r,i)):(r>=o.to||i<=o.from)&&a.push(yN.range(r,i)),a.length>t.maxMatches))return Sg.none}}return Sg.set(a)}},{decorations:e=>e.decorations}),SN=lw.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const EN=Bp.define({combine:e=>Em(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ZN(e),scrollToMatch:e=>lw.scrollIntoView(e)})});class CN{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,uN),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new DN(this):new AN(this)}getCursor(e,t=0,n){let r=e.doc?e:Sm.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?TN(this,r,t,n):ON(this,r,t,n)}}class NN{constructor(e){this.spec=e}}function ON(e,t,n,r){let i;return e.wholeWord&&(i=function(e,t){return(n,r,i,o)=>((o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),!(t(MN(i,n-o))==ym.Word&&t(RN(i,n-o))==ym.Word||t(RN(i,r-o))==ym.Word&&t(MN(i,r-o))==ym.Word))}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=function(e,t,n){return(r,i,o,s)=>{if(n&&!n(r,i,o,s))return!1;let a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}(e.test,t,i)),new cN(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}class AN extends NN{constructor(e){super(e)}nextMatch(e,t,n){let r=ON(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=ON(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=ON(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!r||r.from==t&&r.to==n?null:r}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=ON(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ON(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function TN(e,t,n,r){let i;var o;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),i=(e,t,n)=>!n[0].length||(o(MN(n.input,n.index))!=ym.Word||o(RN(n.input,n.index))!=ym.Word)&&(o(RN(n.input,n.index+n[0].length))!=ym.Word||o(MN(n.input,n.index+n[0].length))!=ym.Word)),e.test&&(i=function(e,t,n){return(r,i,o)=>(!n||n(r,i,o))&&e(o[0],t,r,i)}(e.test,t,i)),new dN(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function MN(e,t){return e.slice(vp(e,t,!1),t)}function RN(e,t){return e.slice(t,vp(e,t))}class DN extends NN{nextMatch(e,t,n){let r=TN(this.spec,e,n,e.doc.length).next();return r.done&&(r=TN(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),o=TN(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=TN(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=TN(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const PN=um.define(),LN=um.define(),BN=Hp.define({create:e=>new IN(KN(e).create(),null),update(e,t){for(let n of t.effects)n.is(PN)?e=new IN(n.value.create(),e.panel):n.is(LN)&&(e=new IN(e.query,n.value?$N:null));return e},provide:e=>Cx.from(e,e=>e.panel)});class IN{constructor(e,t){this.query=e,this.panel=t}}const _N=Sg.mark({class:"cm-searchMatch"}),jN=Sg.mark({class:"cm-searchMatch cm-searchMatch-selected"}),FN=Iv.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(BN))}update(e){let t=e.state.field(BN);(t!=e.startState.field(BN)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Sg.none;let{view:n}=this,r=new Rm;for(let t=0,i=n.visibleRanges,o=i.length;t<o;t++){let{from:s,to:a}=i[t];for(;t<o-1&&a>i[t+1].from-500;)a=i[++t].to;e.highlight(n.state,s,a,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?jN:_N)})}return r.finish()}},{decorations:e=>e.decorations});function WN(e){return t=>{let n=t.state.field(BN,!1);return n&&n.query.spec.valid?e(t,n):XN(t)}}const zN=WN((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Dp.single(r.from,r.to),o=e.state.facet(EN);return e.dispatch({selection:i,effects:[rO(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),GN(e),!0}),HN=WN((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=Dp.single(i.from,i.to),s=e.state.facet(EN);return e.dispatch({selection:o,effects:[rO(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),GN(e),!0}),VN=WN((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:Dp.create(n.map(e=>Dp.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),qN=WN((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s,a,l=o,c=[],h=[];l.from==r&&l.to==i&&(a=n.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=t.nextMatch(n,l.from,l.to),h.push(lw.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let u=e.state.changes(c);return l&&(s=Dp.single(l.from,l.to).map(u),h.push(rO(e,l)),h.push(n.facet(EN).scrollToMatch(s.main,e))),e.dispatch({changes:u,selection:s,effects:h,userEvent:"input.replace"}),!0}),UN=WN((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:lw.announce.of(r),userEvent:"input.replace.all"}),!0});function $N(e){return e.state.facet(EN).createPanel(e)}function KN(e,t){var n,r,i,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(EN);return new CN({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null==t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function YN(e){let t=xx(e,$N);return t&&t.dom.querySelector("[main-field]")}function GN(e){let t=YN(e);t&&t==e.root.activeElement&&t.select()}const XN=e=>{let t=e.state.field(BN,!1);if(t&&t.panel){let n=YN(e);if(n&&n!=e.root.activeElement){let r=KN(e.state,t.query.spec);r.valid&&e.dispatch({effects:PN.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[LN.of(!0),t?PN.of(KN(e.state,t.query.spec)):um.appendConfig.of(oO)]});return!0},JN=e=>{let t=e.state.field(BN,!1);if(!t||!t.panel)return!1;let n=xx(e,$N);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:LN.of(!1)}),!0},QN=[{key:"Mod-f",run:XN,scope:"editor search-panel"},{key:"F3",run:zN,shift:HN,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:zN,shift:HN,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:JN,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let t=new cN(e.doc,e.sliceDoc(r,i));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(s=o.length),o.push(Dp.range(t.value.from,t.value.to))}return t(e.update({selection:Dp.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=Nx(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i)return void e.dispatch({effects:r});let o=t.doc.lineAt(t.selection.main.head),[,s,a,l,c]=i,h=l?+l.slice(1):0,u=a?+a:o.number;if(a&&c){let e=u/100;s&&(e=e*("-"==s?-1:1)+o.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else a&&s&&(u=u*("-"==s?-1:1)+o.number);let d=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),f=Dp.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[r,lw.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=Dp.create(n.ranges.map(t=>e.wordAt(t.head)||Dp.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new cN(e.doc,t,r[r.length-1].to);;){if(i.next(),!i.done){if(n&&r.some(e=>e.from==i.value.from))continue;if(o){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}if(n)return null;i=new cN(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}}(e,r);return!!i&&(t(e.update({selection:e.selection.addRange(Dp.range(i.from,i.to),!1),effects:lw.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class ZN{constructor(e){this.view=e;let t=this.query=e.state.field(BN).query.spec;function n(e,t,n){return ng("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=ng("input",{value:t.search,placeholder:eO(e,"Find"),"aria-label":eO(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ng("input",{value:t.replace,placeholder:eO(e,"Replace"),"aria-label":eO(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ng("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ng("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ng("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=ng("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>zN(e),[eO(e,"next")]),n("prev",()=>HN(e),[eO(e,"previous")]),n("select",()=>VN(e),[eO(e,"all")]),ng("label",null,[this.caseField,eO(e,"match case")]),ng("label",null,[this.reField,eO(e,"regexp")]),ng("label",null,[this.wordField,eO(e,"by word")]),...e.state.readOnly?[]:[ng("br"),this.replaceField,n("replace",()=>qN(e),[eO(e,"replace")]),n("replaceAll",()=>UN(e),[eO(e,"replace all")])],ng("button",{name:"close",onclick:()=>JN(e),"aria-label":eO(e,"close"),type:"button"},["×"])])}commit(){let e=new CN({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:PN.of(e)}))}keydown(e){var t,n,r;t=this.view,n=e,r="search-panel",kw(bw(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?HN:zN)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),qN(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(PN)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(EN).top}}function eO(e,t){return e.state.phrase(t)}const tO=30,nO=/[\s\.,:;?!]/;function rO(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-tO),s=Math.min(i,n+tO),a=e.state.sliceDoc(o,s);if(o!=r.from)for(let e=0;e<tO;e++)if(!nO.test(a[e+1])&&nO.test(a[e])){a=a.slice(e);break}if(s!=i)for(let e=a.length-1;e>a.length-tO;e--)if(!nO.test(a[e-1])&&nO.test(a[e])){a=a.slice(0,e);break}return lw.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}const iO=lw.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),oO=[BN,Yp.low(FN),iO];class sO{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=cS(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(uO(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function aO(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function lO(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=aO(t)+aO(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class cO{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function hO(e){return e.selection.main.from}function uO(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const dO=lm.define();function fO(e,t,n,r){let{main:i}=e.selection,o=n-i.from,s=r-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};let l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:Dp.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const pO=new WeakMap;function mO(e){if(!Array.isArray(e))return e;let t=pO.get(e);return t||pO.set(e,t=lO(e)),t}const gO=um.define(),vO=um.define();class bO{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=bp(e,t),r=wp(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(bp(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(1==t.length){let r=bp(e,0),i=wp(r),o=i==e.length?0:-100;if(r==t[0]);else{if(r!=n[0])return null;o+=-200}return this.ret(o,[0,i])}let s=e.indexOf(this.pattern);if(0==s)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&l<a;){let o=bp(e,i);o!=t[l]&&o!=n[l]||(r[l++]=i),i+=wp(o)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let r=0,l=Math.min(e.length,200),v=0;r<l&&h<a;){let l=bp(e,r);s<0&&(c<a&&l==t[c]&&(i[c++]=r),d<a&&(l==t[d]||l==n[d]?(0==d&&(f=r),p=r+1,d++):d=0));let b,y=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(b=yp(l))!=b.toLowerCase()?1:b!=b.toUpperCase()?2:0;(!r||1==y&&m||0==v&&0!=y)&&(t[h]==l||n[h]==l&&(u=!0)?o[h++]=r:o.length&&(g=!1)),v=y,r+=wp(l)}return h==a&&0==o[0]&&g?this.result((u?-200:0)-100,o,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),o,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?wp(bp(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}}class yO{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const wO=Bp.define({combine:e=>Em(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:kO,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>xO(e(n),t(n)),optionClass:(e,t)=>n=>xO(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function xO(e,t){return e?t?e+" "+t:e:t}function kO(e,t,n,r,i,o){let s,a,l=e.textDirection==Qg.RTL,c=l,h=!1,u="top",d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))s=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=m||e>t.top?s=n.bottom-t.top:(u="bottom",s=t.bottom-n.top)}return{style:`${u}: ${s/((t.bottom-t.top)/o.offsetHeight)}px; max-width: ${a/((t.right-t.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}function SO(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class EO{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(wO);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement("span");i.className="cm-completionLabel";let o=e.displayLabel||e.label,s=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>s&&i.appendChild(document.createTextNode(o.slice(s,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(t,n))),a.className="cm-completionMatchedText",s=n}return s<o.length&&i.appendChild(document.createTextNode(o.slice(s))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=SO(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:r}=e.state.field(t).open;for(let t,i=n.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(t=/-(\d+)$/.exec(i.id))&&+t[1]<r.length)return this.applyCompletion(e,r[+t[1]]),void n.preventDefault()}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(wO).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:vO.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:i,selected:o,disabled:s}=n.open;r.open&&r.open.options==i||(this.range=SO(i.length,o,e.state.facet(wO).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),s!=(null===(t=r.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=SO(t.options.length,t.selected,this.view.state.facet(wO).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o="string"==typeof i?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>Dv(this.view.state,e,"completion info")):(this.addInfoPane(o,r),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):r--;return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(wO).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",e=>{e.target==r&&e.preventDefault()});let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:a}=e[o],{section:l}=s;if(l){let e="string"==typeof l?l:l.name;if(e!=i&&(o>n.from||0==n.from))if(i=e,"string"!=typeof l&&l.header)r.appendChild(l.header(l));else{r.appendChild(document.createElement("completion-section")).textContent=e}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(s);h&&(c.className=h);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function CO(e,t){return n=>new EO(n,e,t)}function NO(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class OO{constructor(e,t,n,r,i,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new OO(this.options,RO(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,i,o){if(r&&!o&&e.some(e=>e.isPending))return r.setDisabled();let s=function(e,t){let n=[],r=null,i=null,o=e=>{n.push(e);let{section:t}=e.completion;if(t){r||(r=[]);let e="string"==typeof t?t:t.name;r.some(t=>t.name==e)||r.push("string"==typeof t?{name:e}:t)}},s=t.facet(wO);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(!1===r.result.filter)for(let t of r.result.options)o(new cO(t,r.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(r.from,r.to),l=s.filterStrict?new yO(a):new bO(a);for(let t of r.result.options)if(n=l.match(t.label)){let s=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(o(new cO(t,r.source,s,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;i||(i=Object.create(null)),i[e]=Math.max(a,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,o=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?i[t.name]-i[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(o))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=s.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?a.push(e):NO(e.completion)>NO(l)&&(a[a.length-1]=e),l=e.completion}return a}(e,t);if(!s.length)return r&&e.some(e=>e.isPending)?r.setDisabled():null;let a=t.facet(wO).selectOnOpen?0:-1;if(r&&r.selected!=a&&-1!=r.selected){let e=r.options[r.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){a=t;break}}return new OO(s,RO(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:WO,above:i.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new OO(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new OO(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class AO{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new AO(DO,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(wO),r=(n.override||t.languageDataAt("autocomplete",hO(t)).map(mO)).map(t=>(this.active.find(e=>e.source==t)||new LO(t,this.active.some(e=>0!=e.state)?1:0)).update(e,n));r.length==this.active.length&&r.every((e,t)=>e==this.active[t])&&(r=this.active);let i=this.open,o=e.effects.some(e=>e.is(IO));i&&e.docChanged&&(i=i.map(e.changes)),e.selection||r.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)||o?i=OO.build(r,t,this.id,i,n,o):i&&i.disabled&&!r.some(e=>e.isPending)&&(i=null),!i&&r.every(e=>!e.isPending)&&r.some(e=>e.hasResult())&&(r=r.map(e=>e.hasResult()?new LO(e.source,0):e));for(let t of e.effects)t.is(_O)&&(i=i&&i.setSelected(t.value,this.id));return r==this.active&&i==this.open?this:new AO(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?TO:MO}}const TO={"aria-autocomplete":"list"},MO={};function RO(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const DO=[];function PO(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(dO);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class LO{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=PO(e,t),r=this;(8&n||16&n&&this.touches(e))&&(r=new LO(r.source,0)),4&n&&0==r.state&&(r=new LO(this.source,1)),r=r.updateFor(e,n);for(let t of e.effects)if(t.is(gO))r=new LO(r.source,1,t.value);else if(t.is(vO))r=new LO(r.source,0);else if(t.is(IO))for(let e of t.value)e.source==r.source&&(r=e);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(hO(e.state))}}class BO extends LO{constructor(e,t,n,r,i,o){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=hO(e.state);if(s>o||!r||2&t&&(hO(e.startState)==this.from||s<this.limit))return new LO(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):uO(e,!0).test(i)}(r.validFor,e.state,i,o)?new BO(this.source,this.explicit,a,r,i,o):r.update&&(r=r.update(r,i,o,new sO(e.state,s,!1)))?new BO(this.source,this.explicit,a,r,r.from,null!==(n=r.to)&&void 0!==n?n:hO(e.state)):new LO(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new BO(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new LO(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const IO=um.define({map:(e,t)=>e.map(e=>e.map(t))}),_O=um.define(),jO=Hp.define({create:()=>AO.start(),update:(e,t)=>e.update(t),provide:e=>[ux.from(e,e=>e.tooltip),lw.contentAttributes.from(e,e=>e.attrs)]});function FO(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(jO).active.find(e=>e.source==t.source);return r instanceof BO&&("string"==typeof n?e.dispatch({...fO(e.state,n,r.from,r.to),annotations:dO.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}const WO=CO(jO,FO);function zO(e,t="option"){return n=>{let r=n.state.field(jO,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(wO).interactionDelay)return!1;let i,o=1;"page"==t&&(i=bx(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+o*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:_O.of(a)}),!0}}const HO=e=>!!e.state.field(jO,!1)&&(e.dispatch({effects:gO.of(!0)}),!0);class VO{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const qO=Iv.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(jO).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(jO),n=e.state.facet(wO);if(!e.selectionSet&&!e.docChanged&&e.startState.field(jO)==t)return;let r=e.transactions.some(e=>{let t=PO(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){Dv(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(gO)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(jO);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(wO).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=hO(t),r=new sO(t,n,e.explicit,this.view),i=new VO(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(e=>{i.context.aborted||(i.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:vO.of(null)}),Dv(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(wO).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(wO),r=this.view.state.field(jO);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(void 0===o.done)continue;if(this.running.splice(i--,1),o.done){let r=hO(o.updates.length?o.updates[0].startState:this.view.state),i=Math.min(r,o.done.from+(o.active.explicit?0:1)),s=new BO(o.active.source,o.active.explicit,i,o.done,o.done.from,null!==(e=o.done.to)&&void 0!==e?e:r);for(let e of o.updates)s=s.update(e,n);if(s.hasResult()){t.push(s);continue}}let s=r.active.find(e=>e.source==o.active.source);if(s&&s.isPending)if(null==o.done){let e=new LO(o.active.source,0);for(let t of o.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:IO.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(jO,!1);if(t&&t.tooltip&&this.view.state.facet(wO).closeOnBlur){let n=t.open&&bx(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:vO.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:gO.of(!1)}),20),this.composing=0}}}),UO="object"==typeof navigator&&/Win/.test(navigator.platform),$O=Yp.highest(lw.domEventHandlers({keydown(e,t){let n=t.state.field(jO,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!UO||!e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&FO(t,r),!1}})),KO=lw.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),YO={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},GO=um.define({map(e,t){let n=t.mapPos(e,-1,kp.TrackAfter);return null==n?void 0:n}}),XO=new class extends Cm{};XO.startSide=1,XO.endSide=-1;const JO=Hp.define({create:()=>Mm.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(GO)&&(e=e.update({add:[XO.range(n.value,n.value+1)]}));return e}});const QO="()[]{}<>«»»«[]{}";function ZO(e){for(let t=0;t<16;t+=2)if(QO.charCodeAt(t)==e)return QO.charAt(t+1);return yp(e<128?e:e+1)}function eA(e,t){return e.languageDataAt("closeBrackets",t)[0]||YO}const tA="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),nA=lw.inputHandler.of((e,t,n,r)=>{if((tA?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||2==r.length&&1==wp(bp(r,0))||t!=i.from||n!=i.to)return!1;let o=function(e,t){let n=eA(e,e.selection.main.head),r=n.brackets||YO.brackets;for(let i of r){let o=ZO(bp(i,0));if(t==i)return o==i?lA(e,i,r.indexOf(i+i+i)>-1,n):sA(e,i,o,n.before||YO.before);if(t==o&&iA(e,e.selection.main.from))return aA(e,i,o)}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),rA=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=eA(e,e.selection.main.head).brackets||YO.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return wp(bp(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let i of n)if(i==r&&oA(e.doc,t.head)==ZO(bp(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Dp.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function iA(e,t){let n=!1;return e.field(JO).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function oA(e,t){let n=e.sliceString(t,t+2);return n.slice(0,wp(bp(n,0)))}function sA(e,t,n,r){let i=null,o=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:GO.of(o.to+t.length),range:Dp.range(o.anchor+t.length,o.head+t.length)};let s=oA(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:GO.of(o.head+t.length),range:Dp.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function aA(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&oA(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Dp.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function lA(e,t,n,r){let i=r.stringPrefixes||YO.stringPrefixes,o=null,s=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:GO.of(r.to+t.length),range:Dp.range(r.anchor+t.length,r.head+t.length)};let s,a=r.head,l=oA(e.doc,a);if(l==t){if(cA(e,a))return{changes:{insert:t+t,from:a},effects:GO.of(a+t.length),range:Dp.cursor(a+t.length)};if(iA(e,a)){let r=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+r.length,insert:r},range:Dp.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=hA(e,a-2*t.length,i))>-1&&cA(e,s))return{changes:{insert:t+t+t+t,from:a},effects:GO.of(a+t.length),range:Dp.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=ym.Word&&hA(e,a,i)>-1&&!function(e,t,n,r){let i=cS(e).resolveInner(t,-1),o=r.reduce((e,t)=>Math.max(e,t.length),0);for(let s=0;s<5;s++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),a=s.indexOf(n);if(!a||a>-1&&r.indexOf(s.slice(0,a))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=i.to==t&&i.parent;if(!l)break;i=l}return!1}(e,a,t,i))return{changes:{insert:t+t,from:a},effects:GO.of(a+t.length),range:Dp.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function cA(e,t){let n=cS(e).resolveInner(t+1);return n.parent&&n.from==t}function hA(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ym.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=ym.Word)return n}return-1}const uA=[{key:"Ctrl-Space",run:HO},{mac:"Alt-`",run:HO},{mac:"Alt-i",run:HO},{key:"Escape",run:e=>{let t=e.state.field(jO,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:vO.of(null)}),!0)}},{key:"ArrowDown",run:zO(!0)},{key:"ArrowUp",run:zO(!1)},{key:"PageDown",run:zO(!0,"page")},{key:"PageUp",run:zO(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(jO,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(wO).interactionDelay)&&FO(e,t.open.options[t.open.selected])}}],dA=Yp.highest(gw.computeN([wO],e=>e.facet(wO).defaultKeymap?[uA]:[]));class fA{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class pA{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(NA).markerFilter;r&&(e=r(e,n));let i=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Rm,s=[],a=0,l=n.doc.iter(),c=0,h=n.doc.length;for(let e=0;;){let t,n,r=e==i.length?null:i[e];if(!r&&!s.length)break;if(s.length)t=a,n=s.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if(t=r.from,t>h)break;n=r.to,s.push(r),e++}for(;e<i.length;){let r=i[e];if(r.from!=t||!(r.to>r.from||r.to==t)){n=Math.min(r.from,n);break}s.push(r),e++,n=Math.min(r.to,n)}n=Math.min(n,h);let u=!1;if(s.some(e=>e.from==t&&(e.to==n||n==h))&&(u=t==n,!u&&n-t<10)){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let d=IA(s);if(u)o.add(t,t,Sg.widget({widget:new MA(d),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,Sg.mark({class:"cm-lintRange cm-lintRange-"+d+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>n)}))}if(a=n,a==h)break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1)}let u=o.finish();return new pA(u,t,mA(u))}}function mA(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(r){if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new fA(r.from,n,r.diagnostic)}else r=new fA(e,n,t||i.diagnostics[0])}),r}function gA(e,t){return e.field(wA,!1)?t:t.concat(um.appendConfig.of(_A))}const vA=um.define(),bA=um.define(),yA=um.define(),wA=Hp.define({create:()=>new pA(Sg.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=mA(n,e.selected.diagnostic,i)||mA(n,null,i)}!n.size&&i&&t.state.facet(NA).autoPanel&&(i=null),e=new pA(n,i,r)}for(let n of t.effects)if(n.is(vA)){let r=t.state.facet(NA).autoPanel?n.value.length?DA.open:null:e.panel;e=pA.init(n.value,r,t.state)}else n.is(bA)?e=new pA(e.diagnostics,n.value?DA.open:null,e.selected):n.is(yA)&&(e=new pA(e.diagnostics,e.panel,n.value));return e},provide:e=>[Cx.from(e,e=>e.panel),lw.decorations.from(e,e=>e.diagnostics)]}),xA=Sg.mark({class:"cm-lintRange cm-lintRange-active"});function kA(e,t,n){let r,{diagnostics:i}=e.state.field(wA),o=-1,s=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),(e,i,{spec:a})=>{if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=a.diagnostics,o=e,s=i,!1});let a=e.state.facet(NA).tooltipFilter;return r&&a&&(r=a(r,e.state)),r?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:SA(e,r)})}:null}function SA(e,t){return ng("ul",{class:"cm-tooltip-lint"},t.map(t=>TA(e,t,!1)))}const EA=e=>{let t=e.state.field(wA,!1);return!(!t||!t.panel)&&(e.dispatch({effects:bA.of(!1)}),!0)},CA=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(wA,!1);t&&t.panel||e.dispatch({effects:gA(e.state,[bA.of(!0)])});let n=xx(e,DA.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(wA,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!(!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],NA=Bp.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...Em(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:OA,tooltipFilter:OA,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})})});function OA(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function AA(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue e}}t.push("")}return t}function TA(e,t,n){var r;let i=n?AA(t.actions):[];return ng("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ng("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(r=t.actions)||void 0===r?void 0:r.map((n,r)=>{let o=!1,s=r=>{if(r.preventDefault(),o)return;o=!0;let i=mA(e.state.field(wA).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,l=i[r]?a.indexOf(i[r]):-1,c=l<0?a:[a.slice(0,l),ng("u",a.slice(l,l+1)),a.slice(l+1)];return ng("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:s,onmousedown:s,"aria-label":` Action: ${a}${l<0?"":` (access key "${i[r]})"`}.`},c)}),t.source&&ng("div",{class:"cm-diagnosticSource"},t.source))}class MA extends xg{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ng("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class RA{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=TA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class DA{constructor(e){this.view=e,this.items=[];this.list=ng("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)EA(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],r=AA(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=mA(this.view.state.field(wA).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=ng("div",{class:"cm-panel-lint"},this.list,ng("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>EA(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(wA).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(wA),n=0,r=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(e,s,{spec:a})=>{for(let e of a.diagnostics){if(o.has(e))continue;o.add(e);let s,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(s=new RA(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[a],a>n&&(this.items.splice(n,a-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),i=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new RA(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=mA(this.view.state.field(wA).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:yA.of(t)})}static open(e){return new DA(e)}}function PA(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const LA=lw.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:PA("#d11")},".cm-lintRange-warning":{backgroundImage:PA("orange")},".cm-lintRange-info":{backgroundImage:PA("#999")},".cm-lintRange-hint":{backgroundImage:PA("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function BA(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function IA(e){let t="hint",n=1;for(let r of e){let e=BA(r.severity);e>n&&(n=e,t=r.severity)}return t}const _A=[wA,lw.decorations.compute([wA],e=>{let{selected:t,panel:n}=e.field(wA);return t&&n&&t.from!=t.to?Sg.set([xA.range(t.from,t.to)]):Sg.none}),vx(kA,{hideOn:function(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(NA).hideOn(e,n,r);if(null!=i)return i;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(vA))&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),LA];var jA=function(e){void 0===e&&(e={});var{crosshairCursor:t=!1}=e,n=[];!1!==e.closeBracketsKeymap&&(n=n.concat(rA)),!1!==e.defaultKeymap&&(n=n.concat(sN)),!1!==e.searchKeymap&&(n=n.concat(QN)),!1!==e.historyKeymap&&(n=n.concat(sC)),!1!==e.foldKeymap&&(n=n.concat(KS)),!1!==e.completionKeymap&&(n=n.concat(uA)),!1!==e.lintKeymap&&(n=n.concat(CA));var r=[];return!1!==e.lineNumbers&&r.push(function(e={}){return[$x.of(e),_x(),Gx]}()),!1!==e.highlightActiveLineGutter&&r.push(Qx),!1!==e.highlightSpecialChars&&r.push(function(e={}){return[qw.of(e),Uw||(Uw=Iv.fromClass(class{constructor(e){this.view=e,this.decorations=Sg.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(qw)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Fw({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=bp(t[0],0);if(9==o){let e=i.lineAt(r),t=n.state.tabSize,o=Hm(e.text,t,r-e.from);return Sg.replace({widget:new Kw((t-o%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Sg.replace({widget:new $w(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(qw);e.startState.facet(qw)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}()),!1!==e.history&&r.push(function(e={}){return[VE,HE.of(e),lw.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?UE:"historyRedo"==e.inputType?$E:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(e={}){let t={...eE,...e},n=new tE(t,!0),r=new tE(t,!1),i=Iv.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(bS)!=e.state.facet(bS)||e.startState.field(zS,!1)!=e.state.field(zS,!1)||cS(e.startState)!=cS(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new Rm;for(let i of e.viewportLineBlocks){let o=VS(e.state,i.from,i.to)?r:IS(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[i,Bx({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||Mm.empty},initialSpacer:()=>new tE(t,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=VS(e.state,t.from,t.to);if(r)return e.dispatch({effects:FS.of(r)}),!0;let i=IS(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:jS.of(i)}),!0)}}}),XS()]}()),!1!==e.drawSelection&&r.push(function(e={}){return[Tw.of(e),Rw,Pw,Lw,Ov.of(!0)]}()),!1!==e.dropCursor&&r.push([Iw,_w]),!1!==e.allowMultipleSelections&&r.push(Sm.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(Sm.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+200)return e;let o=n.sliceString(i.from,r);if(!t.some(e=>e.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=ES(s,t.from);if(null==n)continue;let r=/^\s*/.exec(t.text)[0],i=SS(s,n);r!=i&&l.push({from:t.from,to:t.from+r.length,insert:i})}return l.length?[e,{changes:l,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&r.push(aE(hE,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(e={}){return[fE.of(e),bE]}()),!1!==e.closeBrackets&&r.push([nA,JO]),!1!==e.autocompletion&&r.push(function(e={}){return[$O,jO,wO.of(e),qO,dA,KO]}()),!1!==e.rectangularSelection&&r.push(function(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return lw.mouseSelectionStyle.of((e,n)=>t(n)?Zw(e,n):null)}()),!1!==t&&r.push(function(e={}){let[t,n]=ex[e.key||"Alt"],r=Iv.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,lw.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?tx:null})]}()),!1!==e.highlightActiveLine&&r.push(Gw),!1!==e.highlightSelectionMatches&&r.push(function(e){let t=[SN,kN];return e&&t.push(bN.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&r.push(xS.of(" ".repeat(e.tabSize))),r.concat([gw.of(n.flat())]).filter(Boolean)};const FA="#e06c75",WA="#abb2bf",zA="#7d8799",HA="#d19a66",VA="#2c313a",qA="#282c34",UA="#353a42",$A="#528bff",KA=[lw.theme({"&":{color:WA,backgroundColor:qA},".cm-content":{caretColor:$A},".cm-cursor, .cm-dropCursor":{borderLeftColor:$A},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:WA},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:qA,color:zA,border:"none"},".cm-activeLineGutter":{backgroundColor:VA},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:UA},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:UA,borderBottomColor:UA},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:VA,color:WA}}},{dark:!0}),aE(rE.define([{tag:nS.keyword,color:"#c678dd"},{tag:[nS.name,nS.deleted,nS.character,nS.propertyName,nS.macroName],color:FA},{tag:[nS.function(nS.variableName),nS.labelName],color:"#61afef"},{tag:[nS.color,nS.constant(nS.name),nS.standard(nS.name)],color:HA},{tag:[nS.definition(nS.name),nS.separator],color:WA},{tag:[nS.typeName,nS.className,nS.number,nS.changed,nS.annotation,nS.modifier,nS.self,nS.namespace],color:"#e5c07b"},{tag:[nS.operator,nS.operatorKeyword,nS.url,nS.escape,nS.regexp,nS.link,nS.special(nS.string)],color:"#56b6c2"},{tag:[nS.meta,nS.comment],color:zA},{tag:nS.strong,fontWeight:"bold"},{tag:nS.emphasis,fontStyle:"italic"},{tag:nS.strikethrough,textDecoration:"line-through"},{tag:nS.link,color:zA,textDecoration:"underline"},{tag:nS.heading,fontWeight:"bold",color:FA},{tag:[nS.atom,nS.bool,nS.special(nS.variableName)],color:HA},{tag:[nS.processingInstruction,nS.string,nS.inserted],color:"#98c379"},{tag:nS.invalid,color:"#ffffff"}]))];var YA=lw.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),GA=function(e){void 0===e&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,a=[];switch(t&&a.unshift(gw.of([aN])),s&&("boolean"==typeof s?a.unshift(jA()):a.unshift(jA(s))),o&&a.unshift(function(e){let t=Iv.fromClass(class{constructor(t){this.view=t,this.placeholder=e?Sg.set([Sg.widget({widget:new Xw(e),side:1}).range(0)]):Sg.none}get decorations(){return this.view.state.doc.length?Sg.none:this.placeholder}},{decorations:e=>e.decorations});return"string"==typeof e?[t,lw.contentAttributes.of({"aria-placeholder":e})]:t}(o)),i){case"light":a.push(YA);break;case"dark":a.push(KA);break;case"none":break;default:a.push(i)}return!1===n&&a.push(lw.editable.of(!1)),r&&a.push(Sm.readOnly.of(!0)),[...a]};class XA{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class JA{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}}var QA=null,ZA=lm.define(),eT=[];function tT(e){var{value:t,selection:n,onChange:r,onStatistics:s,onCreateEditor:l,onUpdate:c,extensions:h=eT,autoFocus:u,theme:d="light",height:f=null,minHeight:p=null,maxHeight:m=null,width:g=null,minWidth:v=null,maxWidth:b=null,placeholder:y="",editable:w=!0,readOnly:x=!1,indentWithTab:k=!0,basicSetup:S=!0,root:E,initialState:C}=e,[N,O]=i(),[A,T]=i(),[M,R]=i(),D=i(()=>({current:null}))[0],P=i(()=>({current:null}))[0],L=lw.theme({"&":{height:f,minHeight:p,maxHeight:m,width:g,minWidth:v,maxWidth:b},"& .cm-scroller":{height:"100% !important"}}),B=lw.updateListener.of(e=>{if(e.docChanged&&"function"==typeof r&&!e.transactions.some(e=>e.annotation(ZA))){D.current?D.current.reset():(D.current=new XA(()=>{if(P.current){var e=P.current;P.current=null,e()}D.current=null},200),("undefined"==typeof window?new JA:(QA||(QA=new JA),QA)).add(D.current));var t=e.state.doc.toString();r(t,e)}s&&s((e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}))(e))}),I=[B,L,...GA({theme:d,editable:w,readOnly:x,placeholder:y,indentWithTab:k,basicSetup:S})];return c&&"function"==typeof c&&I.push(lw.updateListener.of(c)),I=I.concat(h),o(()=>{if(N&&!M){var e={doc:t,selection:n,extensions:I},r=C?Sm.fromJSON(C.json,e,C.fields):Sm.create(e);if(R(r),!A){var i=new lw({state:r,parent:N,root:E});T(i),l&&l(i,r)}}return()=>{A&&(R(void 0),T(void 0))}},[N,M]),a(()=>{e.container&&O(e.container)},[e.container]),a(()=>()=>{A&&(A.destroy(),T(void 0)),D.current&&(D.current.cancel(),D.current=null)},[A]),a(()=>{u&&A&&A.focus()},[u,A]),a(()=>{A&&A.dispatch({effects:um.reconfigure.of(I)})},[d,h,f,p,m,g,v,b,y,w,x,k,S,r,c]),a(()=>{if(void 0!==t){var e=A?A.state.doc.toString():"";if(A&&t!==e){var n=()=>{A&&t!==A.state.doc.toString()&&A.dispatch({changes:{from:0,to:A.state.doc.toString().length,insert:t||""},annotations:[ZA.of(!0)]})};D.current&&!D.current.isDone?P.current=n:n()}}},[t,A]),{state:M,setState:R,view:A,setView:T,container:N,setContainer:O}}var nT=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],rT=n((e,t)=>{var{className:n,value:r="",selection:i,extensions:o=[],onChange:s,onStatistics:a,onCreateEditor:d,onUpdate:f,autoFocus:p,theme:m="light",height:g,minHeight:v,maxHeight:b,width:y,minWidth:w,maxWidth:x,basicSetup:k,placeholder:S,indentWithTab:E,editable:C,readOnly:N,root:O,initialState:A}=e,T=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,nT),M=l(null),{state:R,view:D,container:P,setContainer:L}=tT({root:O,value:r,autoFocus:p,theme:m,height:g,minHeight:v,maxHeight:b,width:y,minWidth:w,maxWidth:x,basicSetup:k,placeholder:S,indentWithTab:E,editable:C,readOnly:N,selection:i,onChange:s,onStatistics:a,onCreateEditor:d,onUpdate:f,extensions:o,initialState:A});c(t,()=>({editor:M.current,state:R,view:D}),[M,P,R,D]);var B=h(e=>{M.current=e,L(e)},[L]);if("string"!=typeof r)throw new Error("value must be typeof string but got "+typeof r);return u("div",Gf({ref:B,className:("string"==typeof m?"cm-theme-"+m:"cm-theme")+(n?" "+n:"")},T))});rT.displayName="CodeMirror";class iT{constructor(e,t,n,r,i,o,s,a,l,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=o,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new iT(e,[],t,n,n,0,[],0,r?new oT(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,r=65535&e,{parser:i}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),s=i.dynamicPrecedence(r);if(s&&(this.score+=s),0==n)return this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(r,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[r])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(r<i.minRepeatTerm||131072&e){let e=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,e,u+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=i.getGoto(e,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,n,r=4,i=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(0==r&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&0==e.buffer[r-4]&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t)return void(e.buffer[r-2]=n)}}if(i&&this.pos!=n){let i=this.buffer.length;if(i>0&&(0!=this.buffer[i-4]||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}else this.buffer.push(e,t,n,r)}shift(e,t,n,r){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:o}=this.p;this.pos=r;let s=o.stateFlag(i,1);!s&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(i,s?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){65536&e?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new iT(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new sT(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r,i=0;i<t.length;i+=2)(r=t[i+1])!=this.state&&this.p.parser.hasAction(r,e)&&n.push(t[i],r);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>1&t&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=65535&t,i=this.stack.length-3*n;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-i;if(n>1){let r=65535&t,i=this.stack.length-3*n;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(null!=e)return e}})};return n(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(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new oT(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class oT{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class sT{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class aT{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new aT(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(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,0==this.index&&this.maybeNext()}fork(){return new aT(this.stack,this.pos,this.index)}}function lT(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let r=0,i=0;r<e.length;){let o=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(126==t){o=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),o+=i,n)break;o*=46}n?n[i++]=o:n=new t(o)}return n}class cT{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const hT=new cT;class uT{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=hT,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t,n,r=this.chunkOff+e;if(r>=0&&r<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(r);else{let r=this.resolveOffset(e,1);if(null==r)return-1;if(t=r,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,r=this.range;for(;r.to<=t;)r=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=hT,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class dT{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,r,i,o){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;0!=(a&e[s]);){let n=e[s+1];for(let r=s+3;r<n;r+=2)if((e[r+1]&a)>0){let n=e[r];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||pT(n,t.token.value,i,o))){t.acceptToken(n);break}}let r=t.next,c=0,h=e[s+2];if(!(t.next<0&&h>c&&65535==e[n+3*h-3])){for(;c<h;){let i=c+h>>1,o=n+i+(i<<1),a=e[o],l=e[o+1]||65536;if(r<a)h=i;else{if(!(r>=l)){s=e[o+2],t.advance();continue e}c=i+1}}break}s=e[n+3*h-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}function fT(e,t,n){for(let r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function pT(e,t,n,r){let i=fT(n,r,t);return i<0||fT(n,r,e)<i}dT.prototype.contextual=dT.prototype.fallback=dT.prototype.extend=!1,dT.prototype.fallback=dT.prototype.extend=!1;const mT="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let gT=null;function vT(e,t,n){let r=e.cursor(ck.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}class bT{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?vT(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?vT(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof hk){if(o==e){if(o<this.safeFrom)return null;let e=o+i.length;if(e<=this.safeTo){let t=i.prop(nk.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}}class yT{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new cT)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let r=0;r<i.length;r++){if(!(1<<r&o))continue;let l=i[r],c=this.tokens[r];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=o||c.context!=s)&&(this.updateCachedToken(c,l,e),c.mask=o,c.context=s),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let r=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new cT,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new cT,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){1&i?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let e=0;e<2;e++)for(let a=o.stateSlot(i,e?2:1);;a+=3){if(65535==s[a]){if(1!=s[a+1]){0==r&&2==s[a+1]&&(r=this.putAction(ET(s,a+2),t,n,r));break}a=ET(s,a+2)}s[a]==t&&(r=this.putAction(ET(s,a+1),t,n,r))}return r}}class wT{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new uT(t,r),this.tokens=new yT(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[iT.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>4*e.bufferLength?new bT(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,r=this.minStackPos,i=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<n.length;o++){let s=n[o];for(;;){if(this.tokens.mainToken=null,s.pos>r)i.push(s);else{if(this.advanceStack(s,i,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!i.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return this.stackToTree(t);if(this.parser.strict)throw new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,i);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(i.length>e)for(i.sort((e,t)=>t.score-e.score);i.length>e;)i.pop();i.some(e=>e.reducePos>r)&&this.recovering--}else if(i.length>1){e:for(let e=0;e<i.length-1;e++){let t=i[e];for(let n=e+1;n<i.length;n++){let r=i[n];if(t.sameState(r)||t.buffer.length>500&&r.buffer.length>500){if(!((t.score-r.score||t.buffer.length-r.buffer.length)>0)){i.splice(e--,1);continue e}i.splice(n--,1)}}}i.length>12&&(i.sort((e,t)=>t.score-e.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let e=1;e<i.length;e++)i[e].pos<this.minStackPos&&(this.minStackPos=i[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this;mT&&this.stackID(e);if(null!=this.stoppedAt&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(nk.contextHash)||0)==n))return e.useNode(o,r),!0;if(!(o instanceof hk)||0==o.children.length||o.positions[0]>0)break;let s=o.children[0];if(!(s instanceof hk&&0==o.positions[0]))break;o=s}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let i=0;i<s.length;){let o=s[i++],a=s[i++],l=s[i++],c=i==s.length||!n,h=c?e:e.split(),u=this.tokens.mainToken;if(h.apply(o,a,u?u.start:h.pos,l),c)return!0;h.pos>r?t.push(h):n.push(h)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return xT(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=t[o<<1],l=t[1+(o<<1)],c=mT?this.stackID(s)+" -> ":"";if(s.deadEnd){if(i)continue;if(i=!0,s.restart(),this.advanceFully(s,n))continue}let h=s.split(),u=c;for(let e=0;e<10&&h.forceReduce();e++){if(this.advanceFully(h,n))break;mT&&(u=this.stackID(h)+" -> ")}for(let e of s.recoverByInsert(a))this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),xT(s,n)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),hk.build({buffer:aT.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(gT||(gT=new WeakMap)).get(e);return t||gT.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function xT(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class kT{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class ST extends Tk{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=nk[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let o=t[n+-r];for(let s=-r;s>0;s--)i(t[n++],e,o);n++}}}this.nodeSet=new sk(t.map((t,i)=>ok.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:0==i,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Zx;let o=lT(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(CT),this.states=lT(e.states,Uint32Array),this.data=lT(e.stateData),this.goto=lT(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new dT(o,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new wT(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],o=1&t,s=r[i++];if(o&&n)return s;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return s;if(o)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i,o=this.stateSlot(e,r?2:1);;o+=3){if(65535==(i=n[o])){if(1!=n[o+1]){if(2==n[o+1])return ET(n,o+2);break}i=n[o=ET(n,o+2)]}if(i==t||0==i)return ET(n,o+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==r;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=ET(this.data,n+2)}r=t(ET(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=ET(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(ST.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let i=e.specializers.find(e=>e.from==n.external);if(!i)return n;let o=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[r]=CT(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(" ")){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,i=this.dialects[t[e]];65535!=(n=this.data[i++]);)(r||(r=new Uint8Array(this.maxTerm+1)))[n]=1;return new kT(e,n,r)}static deserialize(e){return new ST(e)}}function ET(e,t){return e[t]|e[t+1]<<16}function CT(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}const NT=Bk({String:nS.string,Number:nS.number,"True False":nS.bool,PropertyName:nS.propertyName,Null:nS.null,", :":nS.separator,"[ ]":nS.squareBracket,"{ }":nS.brace}),OT=ST.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:[NT],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}),AT=lS.define({name:"json",parser:OT.configure({props:[NS.add({Object:DS({except:/^\s*\}/}),Array:DS({except:/^\s*\]/})}),LS.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function TT(e){return MT.apply(this,arguments)}function MT(){return MT=w(S().m(function e(t){var n,r;return S().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(!(null===(n=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===n?void 0:n.writeText)){e.n=3;break}return e.n=2,navigator.clipboard.writeText(t);case 2:return e.a(2);case 3:(r=document.createElement("textarea")).value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r);case 4:return e.a(2)}},e)})),MT.apply(this,arguments)}function RT(t){var n=t.value,r=t.title;if(null==n||""===n)return e.createElement("span",null,"-");var i,o=Kf(n),s=o.ok,a=o.pretty,l=o.compact,c=l.length>80?l.slice(0,80)+"…":l;return e.createElement(wf,null,e.createElement(xf,{asChild:!0},e.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),e.createElement(Ef,{className:"max-w-3xl"},e.createElement(Cf,null,e.createElement(Of,null,r||"JSON")),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(vt,{variant:"outline",size:"sm",onClick:(i=w(S().m(function e(){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,TT(a);case 1:Ga.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,Ga.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return i.apply(this,arguments)})},"复制")),e.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!s&&e.createElement("div",{className:"text-xs text-destructive"},o.ok?"":o.message)))}function DT(t){t.id;var n=t.value;t.required;var r,i=t.disabled,o=t.onChange,s=C(e.useState(null),2),a=s[0],l=s[1];return e.createElement("div",{className:"space-y-2"},e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(vt,{type:"button",variant:"outline",size:"sm",disabled:!!i,onClick:function(){if(!i){var e=(n||"").trim();if(e){var t=Yf(e,2);t.ok?(o(t.formatted),l(null)):l(t.message)}}}},"格式化"),e.createElement(vt,{type:"button",variant:"outline",size:"sm",onClick:(r=w(S().m(function e(){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,TT(n||"");case 1:Ga.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,Ga.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),e.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},e.createElement(rT,{className:"w-full max-w-full",editable:!i,value:n||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new yS(AT),lw.lineWrapping],onChange:function(e){i||(o(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=Kf(t);n.ok?l(null):l(n.message)}(e))}})),a&&e.createElement("div",{className:"text-xs text-destructive"},a))}var PT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",{className:"relative w-full overflow-x-auto"},e.createElement("table",Object.assign({ref:n,className:et("w-full min-w-max caption-bottom text-sm",r)},i)))});PT.displayName="Table";var LT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("thead",Object.assign({ref:n,className:et("[&_tr]:border-b",r)},i))});LT.displayName="TableHeader";var BT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("tbody",Object.assign({ref:n,className:et("[&_tr:last-child]:border-0",r)},i))});BT.displayName="TableBody";var IT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("tfoot",Object.assign({ref:n,className:et("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r)},i))});IT.displayName="TableFooter";var _T=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("tr",Object.assign({ref:n,className:et("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r)},i))});_T.displayName="TableRow";var jT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("th",Object.assign({ref:n,className:et("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});jT.displayName="TableHead";var FT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("td",Object.assign({ref:n,className:et("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});FT.displayName="TableCell";var WT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("caption",Object.assign({ref:n,className:et("mt-4 text-sm text-muted-foreground",r)},i))});WT.displayName="TableCaption";var zT=mt("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function HT(t){var n=t.className,r=t.variant,i=oe(t,["className","variant"]);return e.createElement("div",Object.assign({className:et(zT({variant:r}),n)},i))}function VT(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function qT(e){return"integer"===e||"float"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"大于"},{value:"gte",label:"大于等于"},{value:"lt",label:"小于"},{value:"lte",label:"小于等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]:"boolean"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"isNull",label:"为空(NULL)"}]:"date"===e||"datetime"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"晚于/大于"},{value:"gte",label:"晚于等于/大于等于"},{value:"lt",label:"早于/小于"},{value:"lte",label:"早于等于/小于等于"},{value:"isNull",label:"为空(NULL)"}]:[{value:"contains",label:"包含"},{value:"startsWith",label:"开头是"},{value:"endsWith",label:"结尾是"},{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]}function UT(e){var n,r,o=s(function(){var t=[];t.push.apply(t,N([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=x(e.fields||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if((null==i?void 0:i.name)&&("json"!==i.type&&"jsonb"!==i.type))if("relation"===i.type&&i.relation){var o=i.relation.foreignKey||"".concat(i.relation.target,"_id");t.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else t.push({column:i.name,label:i.comment||i.name,type:i.type})}}catch(e){r.e(e)}finally{r.f()}var s=new Set;return t.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[e.fields]),l=s(function(){return new Map(o.map(function(e){return[e.column,e]}))},[o]),c=s(function(){return new Map(o.map(function(e){return[e.column,e.type]}))},[o]),h=C(i([]),2),u=h[0],d=h[1];a(function(){d(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:VT(),column:e.column,operator:"isNull",value:""};if(("ilike"===e.operator||"like"===e.operator)&&"string"==typeof e.value){var n=e.value;if(n.startsWith("%")&&n.endsWith("%")&&n.length>=2)return{id:VT(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:VT(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:VT(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:VT(),column:e.column,operator:"in",value:r.join(",")}}return{id:VT(),column:e.column,operator:["eq","neq","gt","gte","lt","lte"].includes(e.operator)?e.operator:"eq",value:void 0===e.value||null===e.value?"":String(e.value)}})}(e.value||[],c))},[JSON.stringify(e.value),o.length]);var f=function(e,t){d(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var o=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var s=qT((null===(r=l.get(t.column))||void 0===r?void 0:r.type)||"string");o.operator=(null===(i=s[0])||void 0===i?void 0:i.value)||"eq",o.value=""}return t.operator&&"isNull"===t.operator&&(o.value=""),o})})};return t.createElement("div",{className:"space-y-3"},t.createElement("div",{className:"flex items-center justify-between gap-3"},t.createElement(Ta,{className:"text-base font-medium flex items-center gap-2"},t.createElement(z,{className:"h-4 w-4"}),"动态筛选"),t.createElement("div",{className:"flex items-center gap-2"},(null===(n=e.value)||void 0===n?void 0:n.length)>0&&t.createElement(HT,{variant:"secondary"},"已应用 ",e.value.length," 条"),t.createElement(vt,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=o[0];if(e){var t=qT(e.type);d(function(n){var r;return[].concat(N(n),[{id:VT(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},t.createElement(G,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===u.length?t.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):t.createElement("div",{className:"space-y-2"},u.map(function(e){var n=l.get(e.column),r=(null==n?void 0:n.type)||"string",i=qT(r),s="isNull"!==e.operator;return t.createElement("div",{key:e.id,className:"grid grid-cols-12 gap-2 items-center"},t.createElement("div",{className:"col-span-5"},t.createElement($d,{value:e.column,onValueChange:function(t){return f(e.id,{column:t})}},t.createElement(Yd,{className:"h-10"},t.createElement(Kd,{placeholder:"字段"})),t.createElement(Jd,null,o.map(function(e){return t.createElement(Zd,{key:e.column,value:e.column},e.label," (",e.column,")")})))),t.createElement("div",{className:"col-span-3"},t.createElement($d,{value:e.operator,onValueChange:function(t){return f(e.id,{operator:t})}},t.createElement(Yd,{className:"h-10"},t.createElement(Kd,{placeholder:"操作符"})),t.createElement(Jd,null,i.map(function(e){return t.createElement(Zd,{key:e.value,value:e.value},e.label)})))),t.createElement("div",{className:"col-span-3"},s?"boolean"===r?t.createElement($d,{value:e.value,onValueChange:function(t){return f(e.id,{value:t})}},t.createElement(Yd,{className:"h-10"},t.createElement(Kd,{placeholder:"值"})),t.createElement(Jd,null,t.createElement(Zd,{value:"true"},"true"),t.createElement(Zd,{value:"false"},"false"))):t.createElement(bt,{className:"h-10",placeholder:"in"===e.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:e.value,onChange:function(t){return f(e.id,{value:t.target.value})}}):t.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),t.createElement("div",{className:"col-span-1 flex justify-end"},t.createElement(vt,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return t=e.id,void d(function(e){return e.filter(function(e){return e.id!==t})});var t}},t.createElement(re,{className:"h-4 w-4"}))))})),t.createElement("div",{className:"flex items-center justify-end gap-2"},t.createElement(vt,{type:"button",variant:"outline",onClick:function(){d([]),e.onChange([])},disabled:0===u.length&&0===((null===(r=e.value)||void 0===r?void 0:r.length)||0)},"清空"),t.createElement(vt,{type:"button",onClick:function(){var t=function(e,t){var n,r,i=[],o=x(e);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.get(s.column);if(a&&s.operator)if("isNull"!==s.operator){var l=null!==(n=s.value)&&void 0!==n?n:"",c=String(l).trim();if(c)if("contains"!==s.operator)if("startsWith"!==s.operator)if("endsWith"!==s.operator)if("in"!==s.operator)i.push({column:a.column,operator:s.operator,value:c});else{var h=c.split(",").map(function(e){return e.trim()}).filter(Boolean);i.push({column:a.column,operator:"in",value:h})}else i.push({column:a.column,operator:"ilike",value:"%".concat(c)});else i.push({column:a.column,operator:"ilike",value:"".concat(c,"%")});else i.push({column:a.column,operator:"ilike",value:"%".concat(c,"%")})}else i.push({column:a.column,operator:"is",value:null})}}catch(e){o.e(e)}finally{o.f()}return i}(u,l);e.onChange(t)},disabled:0===u.length},"应用")))}function $T(){var e,n=C(i([]),2),r=n[0],o=n[1],s=C(i(null),2),l=s[0],c=s[1],h=C(i([]),2),u=h[0],d=h[1],f=C(i(!1),2),p=f[0],m=f[1],g=C(i(!1),2),b=g[0],y=g[1],x=C(i(null),2),E=x[0],N=x[1],O=C(i({}),2),A=O[0],T=O[1],M=C(i(1),2),R=M[0],D=M[1],P=C(i(10),2),L=P[0];P[1];var _=C(i(0),2),j=_[0],F=_[1],W=C(i(""),2),H=W[0],V=W[1],U=C(i(!1),2),$=U[0],K=U[1],Y=C(i(null),2),J=Y[0],Z=Y[1],te=C(i(!0),2),ne=te[0],re=te[1],ie=C(i([]),2),oe=ie[0],se=ie[1],ae=C(i(!1),2),le=ae[0],ce=ae[1],he=function(e){return Array.isArray(e)?e:Array.isArray(null==e?void 0:e.models)?e.models:Array.isArray(null==e?void 0:e.data)?e.data:Array.isArray(null==e?void 0:e.items)?e.items:[]},ue=function(e){var t;if(e&&Array.isArray(e.data)){var n="number"==typeof e.total?e.total:"number"==typeof(null===(t=e.pagination)||void 0===t?void 0:t.total)?e.pagination.total:e.data.length;return{rows:e.data,total:n}}if(e&&Array.isArray(e.rows)){var r="number"==typeof e.total?e.total:e.rows.length;return{rows:e.rows,total:r}}return Array.isArray(e)?{rows:e,total:e.length}:{rows:[],total:0}},de=function(e){return!e||!e.readOnly&&!1!==e.editable};a(function(){fe()},[]),a(function(){l&&pe()},[l,R,L,H,oe]);var fe=function(){var e=w(S().m(function e(){var t;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return re(!0),e.p=1,e.n=2,bh();case 2:t=e.v,o(he(t.data)),e.n=4;break;case 3:e.p=3,e.v,Ga.error("加载模型列表失败");case 4:return e.p=4,re(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),pe=function(){var e=w(S().m(function e(){var t,n,r;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:return m(!0),e.p=2,t={page:R,limit:L},H&&(t.search=H),oe.length>0&&(t.filters=oe),e.n=3,Oh(l.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return Ga.error(n.message||"加载数据失败"),d([]),F(0),e.a(2);case 4:r=ue(n.data),d(r.rows),F(r.total),e.n=6;break;case 5:e.p=5,e.v,Ga.error("加载数据失败"),d([]),F(0);case 6:return e.p=6,m(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),me=function(){var e=w(S().m(function e(t){var n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return Z(t.id),e.p=2,e.n=3,Rh(null==l?void 0:l.table_name,t.id);case 3:(n=e.v).success?(Ga.success("删除成功"),pe()):Ga.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Ga.error("删除失败");case 5:return e.p=5,Z(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ge=function(){var e=w(S().m(function e(){var t,n,r,i,o;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:if(K(!0),e.p=2,t={},l.json_schema.fields.forEach(function(e){if("id"!==e.name&&de(e)){var n=A[e.name];if("date"!==e.type&&"datetime"!==e.type||(n=n?new Date(n).toISOString():null),"json"===e.type||"jsonb"===e.type){var r=(n||"").toString().trim();if(r){var i=Kf(r);if(!i.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(i.message));n=i.value}else n=null}t[e.name]=n}}),!E){e.n=4;break}return e.n=3,Mh(l.table_name,Object.assign(Object.assign({},t),{id:E.id}));case 3:(n=e.v).success?(Ga.success("更新成功"),y(!1),pe()):Ga.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,Th(l.table_name,t);case 5:(r=e.v).success?(Ga.success("创建成功"),y(!1),pe()):Ga.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",Ga.error(i);case 8:return e.p=8,K(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}();return t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),t.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),t.createElement(Ma,{className:"border-2 shadow-lg"},t.createElement(Ra,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(Da,null,"数据管理"),t.createElement(Pa,null,"选择数据模型进行查看和管理")),l&&t.createElement(vt,{onClick:function(){N(null),T({}),y(!0)},className:"w-full md:w-auto"},t.createElement(G,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(La,{className:"space-y-6 pt-6"},t.createElement("div",{className:"flex flex-col md:flex-row gap-4"},t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(Ta,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},t.createElement(z,{className:"h-4 w-4"}),"选择数据模型"),t.createElement($d,{value:(null===(e=null==l?void 0:l.id)||void 0===e?void 0:e.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});c(t||null),D(1),V(""),se([])},disabled:ne},t.createElement(Yd,{className:"h-11"},ne?t.createElement("div",{className:"flex items-center gap-2"},t.createElement(q,{className:"h-4 w-4 animate-spin"}),t.createElement("span",null,"加载中...")):t.createElement(Kd,{placeholder:"请选择模型"})),t.createElement(Jd,null,r.map(function(e){return t.createElement(Zd,{key:e.id,value:e.id.toString()},e.name," (",e.table_name,")")})))),l&&t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(Ta,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},t.createElement(X,{className:"h-4 w-4"}),"搜索"),t.createElement("div",{className:"relative"},t.createElement(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(bt,{id:"search",placeholder:"搜索数据...",value:H,onChange:function(e){return V(e.target.value)},className:"pl-10 h-11"})))),l&&t.createElement(t.Fragment,null,t.createElement("div",{className:"flex items-center justify-end"},t.createElement(vt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return ce(!0)}},t.createElement(z,{className:"h-4 w-4 mr-2"}),"筛选",oe.length>0?"(".concat(oe.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},j)," 条数据"),t.createElement(HT,{variant:"outline"},l.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement("div",{className:"overflow-x-auto"},t.createElement(PT,null,t.createElement(LT,null,t.createElement(_T,{className:"bg-muted/50"},t.createElement(jT,{className:"font-semibold w-20"},"ID"),l.json_schema.fields.map(function(e){return t.createElement(jT,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(jT,{className:"font-semibold"},"创建时间"),t.createElement(jT,{className:"font-semibold"},"更新时间"),t.createElement(jT,{className:"font-semibold w-32 text-center"},"操作"))),t.createElement(BT,null,p?Array.from({length:3}).map(function(e,n){return t.createElement(_T,{key:n},t.createElement(FT,{colSpan:l.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(q,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===u.length?t.createElement(_T,null,t.createElement(FT,{colSpan:l.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(X,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):u.map(function(e,n){return t.createElement(_T,{key:e.id,className:n%2==0?"bg-muted/20":""},t.createElement(FT,{className:"font-mono font-medium"},e.id),l.json_schema.fields.map(function(n){return t.createElement(FT,{key:n.name},function(e,n){return"boolean"===e.type?t.createElement(HT,{variant:n?"default":"secondary"},n?"是":"否"):"date"===e.type||"datetime"===e.type?n?v(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===e.type&&n&&n.length>50?t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===e.type||"jsonb"===e.type?t.createElement(RT,{value:n,title:e.comment||e.name}):n||"-"}(n,e[n.name]))}),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,null,t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return function(e){N(e);var t={};null==l||l.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?v(r).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(r=null==r||""===r?"":"string"==typeof r?r:JSON.stringify(r,null,2)),t[n.name]=r}}),T(t),y(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(Q,{className:"h-4 w-4"})),t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return me(e)},disabled:J===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},J===e.id?t.createElement(q,{className:"h-4 w-4 animate-spin"}):t.createElement(ee,{className:"h-4 w-4"})))))}))))),j>L&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},R)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(j/L))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return D(Math.max(1,R-1))},disabled:1===R||p},t.createElement(B,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return D(Math.min(Math.ceil(j/L),R+1))},disabled:R>=Math.ceil(j/L)||p},"下一页",t.createElement(I,{className:"h-4 w-4 ml-1"}))))))),l&&t.createElement(wf,{open:le,onOpenChange:ce},t.createElement(Ef,{className:"max-w-3xl"},t.createElement(Cf,null,t.createElement(Of,{className:"text-xl"},"筛选"),t.createElement(Tf,{className:"text-sm"},l.name," - ",l.table_name)),t.createElement("div",{className:"py-2"},t.createElement(UT,{fields:l.json_schema.fields,value:oe,onChange:function(e){se(e),D(1)}})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return ce(!1)}},"关闭")))),t.createElement(wf,{open:b,onOpenChange:y},t.createElement(Ef,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(Cf,null,t.createElement(Of,{className:"text-2xl"},E?"编辑数据":"新建数据"),t.createElement(Tf,{className:"text-base"},null==l?void 0:l.name," - ",null==l?void 0:l.table_name)),t.createElement("div",{className:"space-y-4 py-4"},null==l?void 0:l.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=de(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(bf,{id:e.name,checked:A[e.name]||!1,disabled:!n,onCheckedChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t)))}}),t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"date",value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"datetime-local",value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(yf,{id:e.name,rows:4,value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(DT,{id:e.name,value:A[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"number",value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));default:return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return y(!1)},disabled:$},"取消"),t.createElement(vt,{onClick:ge,disabled:$},$?t.createElement(t.Fragment,null,t.createElement(q,{className:"h-4 w-4 mr-2 animate-spin"}),E?"更新中...":"创建中..."):E?"更新":"创建"))))))}function KT(e){return/^https?:\/\//i.test(e)}function YT(e){var n=e.url;return t.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},t.createElement(sa,null,t.createElement(aa,{asChild:!0},t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-muted",title:"点击打开原图"},t.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement(la,{side:"right",className:"p-2"},t.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function GT(e){var n=e.model,r=C(i([]),2),o=r[0],l=r[1],c=C(i(!1),2),h=c[0],u=c[1],d=C(i(!1),2),f=d[0],p=d[1],m=C(i(!1),2),g=m[0],b=m[1],y=C(i(null),2),x=y[0],E=y[1],N=C(i({}),2),O=N[0],A=N[1],T=C(i(1),2),M=T[0],R=T[1],D=C(i(10),2),P=D[0];D[1];var L=C(i(0),2),_=L[0],j=L[1],W=C(i(""),2),H=W[0],V=W[1],U=C(i(!1),2),$=U[0],K=U[1],Y=C(i(null),2),J=Y[0],Z=Y[1],te=C(i({}),2),ne=te[0],re=te[1],ie=C(i([]),2),oe=ie[0],se=ie[1],ae=s(function(){return oe.length?JSON.stringify(oe):""},[oe]),le=function(e){return!e.readOnly&&!1!==e.editable};a(function(){n&&he()},[null==n?void 0:n.table_name,M,P,H,ae]);var ce=function(){var e=w(S().m(function e(t){var n,r,i,o,s;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if("relation"===t.type&&t.relation){e.n=1;break}return e.a(2);case 1:if(n=t.relation,r=n.target,i=n.displayField,o="".concat(r,"_").concat(i||"name"),!ne[o]){e.n=2;break}return e.a(2);case 2:return e.p=2,e.n=3,Ah(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&re(function(e){return Object.assign(Object.assign({},e),k({},o,s.data))}),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}();a(function(){f&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return ce(e)})},[f,n]);var he=function(){var e=w(S().m(function e(){var t,r,i,o;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return u(!0),e.p=2,i={page:M,limit:P},H&&(i.search=H),oe.length>0&&(i.filters=oe),e.n=3,Oh(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return Ga.error(o.message||"加载数据失败"),l([]),j(0),e.a(2);case 4:l((null===(t=o.data)||void 0===t?void 0:t.data)||[]),j((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,Ga.error("加载数据失败"),l([]),j(0);case 6:return e.p=6,u(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),ue=function(){var e=w(S().m(function e(t){var r;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return Z(t.id),e.p=2,e.n=3,Rh(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(Ga.success("删除成功"),he()):Ga.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Ga.error("删除失败");case 5:return e.p=5,Z(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),de=function(){var e=w(S().m(function e(){var t,r,i,o,s,a;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if(K(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&le(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=O[n]}else{var r=O[e.name];if("date"!==e.type&&"datetime"!==e.type||(r=r?new Date(r).toISOString():null),"json"===e.type||"jsonb"===e.type){var i=(r||"").toString().trim();if(i){var o=Kf(i);if(!o.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(o.message));r=o.value}else r=null}t[e.name]=r}}),!x){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:x.id}),e.n=3,Mh(n.table_name,r);case 3:(i=e.v).success?(Ga.success("更新成功"),p(!1),he()):Ga.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,Th(n.table_name,t);case 5:(o=e.v).success?(Ga.success("创建成功"),p(!1),he()):Ga.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",Ga.error(s);case 8:return e.p=8,K(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),fe=function(e,n,r){if("string"==typeof n){var i=n.trim();if(i&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!KT(n))return!1;var r=(null===(t=n.split("#")[0])||void 0===t?void 0:t.split("?")[0])||n;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(r)}(i))return t.createElement(YT,{url:i});if(i&&KT(i))return t.createElement("a",{href:i,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:i},i)}if("boolean"===e.type)return t.createElement(HT,{variant:n?"default":"secondary"},n?"是":"否");if("date"===e.type||"datetime"===e.type)return n?v(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===e.type&&n&&n.length>50)return t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===e.type||"jsonb"===e.type)return t.createElement(RT,{value:n,title:e.comment||e.name});if("relation"===e.type&&e.relation&&r){var o=e.relation.displayField,s=void 0===o?"name":o,a=r["".concat(e.name,"_data")];if(a)return t.createElement(HT,{variant:"outline"},a[s]||"ID: ".concat(a.id));var l=r[e.relation.foreignKey||"".concat(e.relation.target,"_id")];return l?"ID: ".concat(l):"-"}return n||"-"};return n?t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"container mx-auto px-6 py-4 space-y-4"},t.createElement("div",{className:"space-y-1"},t.createElement("div",{className:"flex items-center gap-3"},t.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},t.createElement(F,{className:"h-4 w-4"})),t.createElement("div",null,t.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),t.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),t.createElement(Ma,{className:"border-2 shadow-lg"},t.createElement(Ra,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(Da,null,"数据管理"),t.createElement(Pa,null,"查看和管理 ",n.name," 的数据")),t.createElement(vt,{onClick:function(){E(null),A({}),p(!0)},className:"w-full md:w-auto"},t.createElement(G,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(La,{className:"space-y-4 pt-4"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},t.createElement("div",{className:"flex-1"},t.createElement(Ta,{htmlFor:"search",className:"sr-only"},"搜索"),t.createElement("div",{className:"relative"},t.createElement(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(bt,{id:"search",placeholder:"搜索数据...",value:H,onChange:function(e){return V(e.target.value)},className:"pl-10 h-10"}))),t.createElement(vt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return b(!0)}},t.createElement(z,{className:"h-4 w-4 mr-2"}),"筛选",oe.length>0?"(".concat(oe.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},_)," 条数据"),t.createElement(HT,{variant:"outline"},n.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement(PT,null,t.createElement(LT,null,t.createElement(_T,{className:"bg-muted/50"},t.createElement(jT,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(e){return t.createElement(jT,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(jT,{className:"font-semibold"},"创建时间"),t.createElement(jT,{className:"font-semibold"},"更新时间"),t.createElement(jT,{className:et("font-semibold w-32 text-center sticky right-0 z-20 bg-muted/50 border-l","shadow-[-8px_0_12px_-10px_rgba(0,0,0,0.25)]")},"操作"))),t.createElement(BT,null,h?Array.from({length:3}).map(function(e,r){return t.createElement(_T,{key:r},t.createElement(FT,{colSpan:n.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(q,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?t.createElement(_T,null,t.createElement(FT,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(X,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):o.map(function(e,r){return t.createElement(_T,{key:e.id,className:r%2==0?"bg-muted/20":""},t.createElement(FT,{className:"font-mono font-medium"},e.id),n.json_schema.fields.map(function(n){return t.createElement(FT,{key:n.name},fe(n,e[n.name],e))}),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,{className:et("sticky right-0 z-10 border-l","shadow-[-8px_0_12px_-10px_rgba(0,0,0,0.18)]",r%2==0?"bg-muted/20":"bg-background")},t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return function(e){E(e);var t={};null==n||n.json_schema.fields.forEach(function(n){if("id"!==n.name)if("relation"===n.type&&n.relation){var r=n.relation.foreignKey||"".concat(n.relation.target,"_id");t[r]=e[r]}else{var i=e[n.name];"date"!==n.type&&"datetime"!==n.type||(i=i?v(i).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(i=null==i||""===i?"":"string"==typeof i?i:JSON.stringify(i,null,2)),t[n.name]=i}}),A(t),p(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(Q,{className:"h-4 w-4"})),t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return ue(e)},disabled:J===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},J===e.id?t.createElement(q,{className:"h-4 w-4 animate-spin"}):t.createElement(ee,{className:"h-4 w-4"})))))})))),_>P&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},M)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(_/P))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return R(Math.max(1,M-1))},disabled:1===M||h},t.createElement(B,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return R(Math.min(Math.ceil(_/P),M+1))},disabled:M>=Math.ceil(_/P)||h},"下一页",t.createElement(I,{className:"h-4 w-4 ml-1"})))))),t.createElement(wf,{open:g,onOpenChange:b},t.createElement(Ef,{className:"max-w-3xl"},t.createElement(Cf,null,t.createElement(Of,{className:"text-xl"},"筛选"),t.createElement(Tf,{className:"text-sm"},n.name," - ",n.table_name)),t.createElement("div",{className:"py-2"},t.createElement(UT,{fields:n.json_schema.fields,value:oe,onChange:function(e){se(e),R(1)}})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return b(!1)}},"关闭")))),t.createElement(wf,{open:f,onOpenChange:p},t.createElement(Ef,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(Cf,null,t.createElement(Of,{className:"text-2xl"},x?"编辑数据":"新建数据"),t.createElement(Tf,{className:"text-base"},n.name," - ",n.table_name)),t.createElement("div",{className:"space-y-4 py-4"},n.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=le(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(bf,{id:e.name,checked:O[e.name]||!1,disabled:!n,onCheckedChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t)))}}),t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"date",value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"datetime-local",value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(yf,{id:e.name,rows:4,value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(DT,{id:e.name,value:O[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"number",value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"relation":if(!e.relation)return null;var r=e.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=ne[a]||[],c=e.relation.foreignKey||"".concat(i,"_id"),h=void 0!==O[c]&&null!==O[c]?String(O[c]):"",u=l.find(function(e){return String(e.id)===h});return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement($d,{value:h,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;A(Object.assign(Object.assign({},O),k({},c,n?t:e)))}},t.createElement(Yd,{className:"h-11"},t.createElement(Kd,{placeholder:"请选择".concat(e.comment||e.name)},u?u.label:h?"ID: ".concat(h):"请选择".concat(e.comment||e.name))),t.createElement(Jd,null,0===l.length?t.createElement(Zd,{value:"_loading",disabled:!0},"加载中..."):l.map(function(e){return t.createElement(Zd,{key:e.id,value:String(e.id)},e.label)}))));default:return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return p(!1)},disabled:$},"取消"),t.createElement(vt,{onClick:de,disabled:$},$?t.createElement(t.Fragment,null,t.createElement(q,{className:"h-4 w-4 mr-2 animate-spin"}),x?"更新中...":"创建中..."):x?"更新":"创建")))))):t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"container mx-auto px-6 py-4"},t.createElement(Ma,{className:"border-2"},t.createElement(La,{className:"py-16 text-center"},t.createElement(F,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),t.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function XT(e){var n=e.model;return t.createElement(GT,{key:n.id,model:n})}function JT(e){return e.models.map(function(e){return{path:"/data/list-".concat(e.id),name:e.name,icon:t.createElement(Z),component:function(){return t.createElement(XT,{model:e})}}})}var QT=function(e){return[{path:"/login",name:"登录",icon:t.createElement($),component:Dh},{name:"数据管理",icon:t.createElement(j),path:"/data",component:$T,routes:N(JT(e))}]},ZT=J,eM=te,tM=K;function nM(e){var n=e.inputModels,r=e.skipAuth,o=void 0!==r&&r,l=C(i("/data"),2),c=l[0],h=l[1],u=C(i([]),2);u[0],u[1];var d=C(i(!1),2),f=d[0],p=d[1],m=C(i(null),2),g=m[0],v=m[1],b=C(i(!0),2),y=b[0],k=b[1],E=s(function(){return QT({models:n.models})},[n.models]);a(function(){if(o)return p(!0),v(null),k(!1),void("/login"===c&&h("/data"));var e=function(){var e=w(S().m(function e(){var t,n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,Ch()){e.n=1;break}return p(!1),h("/login"),k(!1),e.a(2);case 1:return e.p=1,e.n=2,kh();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=Nh())){e.n=4;break}v(t),e.n=6;break;case 4:return e.n=5,Sh();case 5:(n=e.v).success&&n.data&&(v(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:p(!0),"/login"===c&&h("/data"),e.n=8;break;case 7:e.p=7,e.v,Eh(),p(!1),v(null),h("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,p(!1),v(null),h("/login");case 10:return e.p=10,k(!1),e.f(10);case 11:return e.a(2)}},e,null,[[1,7],[0,9,10,11]])}));return function(){return e.apply(this,arguments)}}();e()},[o]);var N=function(e,t){v(t),p(!0),h("/data"),Ga.success("欢迎回来,".concat(t.username,"!"))},O=function(e,t){var n,r=x(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.path===t)return i;if(i.routes){var o=O(i.routes,t);if(o)return o}}}catch(e){r.e(e)}finally{r.f()}return null};if(y)return t.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},t.createElement("div",{className:"space-y-4"},t.createElement(tt,{className:"h-12 w-48"}),t.createElement(tt,{className:"h-4 w-64"})));if(!f)return t.createElement(Dh,{onLoginSuccess:N});var A=E.filter(function(e){return"/login"!==e.path}),T=function(e){if(!e)return F;if(t.isValidElement(e)){var n=e.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return H;if(r.includes("Table"))return Z;if(r.includes("Database"))return F;if(r.includes("File"))return W}}return F},M=A.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:T(e.icon),path:e.path}}):[{title:e.name,icon:T(e.icon),path:e.path}]});return t.createElement(ua,null,t.createElement(da,{variant:"inset"},t.createElement(ma,{className:"border-b border-sidebar-border"},t.createElement("div",{className:"flex items-center gap-2 px-2 py-1"},t.createElement("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-primary"},t.createElement(ZT,{className:"w-4 h-4 text-primary-foreground"})),t.createElement("span",{className:"font-semibold text-lg"},"WE0-CMS"))),t.createElement(va,null,t.createElement(ba,null,t.createElement(ya,null,"Navigation"),t.createElement(wa,null,t.createElement(xa,null,M.map(function(e){return t.createElement(ka,{key:e.path},t.createElement(Ea,{onClick:function(){return h(e.path)},isActive:(n=e.path,c===n||c.startsWith(n+"/")),tooltip:e.title},t.createElement(e.icon,{className:"w-4 h-4"}),t.createElement("span",null,e.title)));var n}))))),t.createElement(ga,{className:"border-t border-sidebar-border"},t.createElement(xa,null,!o&&g&&t.createElement(t.Fragment,null,t.createElement(ka,null,t.createElement(Ea,{tooltip:g.username||"User"},t.createElement(eM,{className:"w-4 h-4"}),t.createElement("span",{className:"truncate"},g.username))),t.createElement(ka,null,t.createElement(Ea,{onClick:function(){window.confirm("确定要登出系统吗?")&&(Eh(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),p(!1),v(null),h("/login"),Ga.success("已成功登出"))},tooltip:"Logout"},t.createElement(tM,{className:"w-4 h-4"}),t.createElement("span",null,"Logout"))))))),t.createElement(pa,null,t.createElement("header",{className:"flex h-14 items-center gap-4 border-b bg-background px-6"},t.createElement(fa,null),t.createElement("h1",{className:"text-lg font-semibold"},function(){if("/login"===c)return"Login";var e=O(E,c);return(null==e?void 0:e.name)||"数据管理"}())),t.createElement("main",{className:"flex-1 p-6"},function(){if(!o&&"/login"===c)return t.createElement(Dh,{onLoginSuccess:N});if(o&&"/login"===c)return t.createElement($T,null);var e=O(E,c);if(e){var n=e.component;return t.createElement(n,null)}return t.createElement($T,null)}())))}export{nM as CmsLayoutShadcn,QT as cmsRoutes,nM as default,vh as setSessionId};
|
|
15
|
+
*/const T=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),M=(e,t)=>{const i=n(({color:n="currentColor",size:i=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:a="",children:l,...c},h)=>r("svg",{ref:h,...A,width:i,height:i,stroke:n,strokeWidth:s?24*Number(o)/Number(i):o,className:["lucide",`lucide-${T(e)}`,a].join(" "),...c},[...t.map(([e,t])=>r(e,t)),...Array.isArray(l)?l:[l]]));return i.displayName=`${e}`,i},R=M("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),D=M("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),P=M("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),L=M("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),B=M("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),I=M("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),_=M("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),j=M("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),F=M("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),W=M("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),z=M("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),H=M("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),V=M("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),q=M("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),U=M("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),$=M("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]),K=M("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),Y=M("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),G=M("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),X=M("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),J=M("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Q=M("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]]),Z=M("Table",[["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"}]]),ee=M("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),te=M("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),ne=M("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),re=M("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var ie=function(){return ie=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ie.apply(this,arguments)};function oe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function se(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=se(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ae(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=se(e))&&(r&&(r+=" "),r+=t);return r}"function"==typeof SuppressedError&&SuppressedError;const le=e=>{const t=de(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),ce(n,t)||ue(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},ce=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?ce(e.slice(1),r):void 0;if(i)return i;if(0===t.validators.length)return;const o=e.join("-");return t.validators.find(({validator:e})=>e(o))?.classGroupId},he=/^\[(.+)\]$/,ue=e=>{if(he.test(e)){const t=he.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},de=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return ge(Object.entries(e.classGroups),n).forEach(([e,n])=>{fe(n,r,e,t)}),r},fe=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:pe(t,e)).classGroupId=n)}if("function"==typeof e)return me(e)?void fe(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{fe(i,pe(t,e),n,r)})})},pe=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},me=e=>e.isThemeGetter,ge=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,ve=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(i(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},be=e=>{const{separator:t,experimentalParseClassName:n}=e,r=1===t.length,i=t[0],o=t.length,s=e=>{const n=[];let s,a=0,l=0;for(let c=0;c<e.length;c++){let h=e[c];if(0===a){if(h===i&&(r||e.slice(c,c+o)===t)){n.push(e.slice(l,c)),l=c+o;continue}if("/"===h){s=c;continue}}"["===h?a++:"]"===h&&a--}const c=0===n.length?e:e.substring(l),h=c.startsWith("!");return{modifiers:n,hasImportantModifier:h,baseClassName:h?c.substring(1):c,maybePostfixModifierPosition:s&&s>l?s-l:void 0}};return n?e=>n({className:e,parseClassName:s}):s},ye=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(e=>{"["===e[0]?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},we=/\s+/;function xe(){let e,t,n=0,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=ke(e))&&(r&&(r+=" "),r+=t);return r}const ke=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=ke(e[r]))&&(n&&(n+=" "),n+=t);return n};function Se(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:ve(e.cacheSize),parseClassName:be(e),...le(e)}))(l),r=n.cache.get,i=n.cache.set,o=s,s(a)};function s(e){const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,o=[],s=e.trim().split(we);let a="";for(let e=s.length-1;e>=0;e-=1){const t=s[e],{modifiers:l,hasImportantModifier:c,baseClassName:h,maybePostfixModifierPosition:u}=n(t);let d=Boolean(u),f=r(d?h.substring(0,u):h);if(!f){if(!d){a=t+(a.length>0?" "+a:a);continue}if(f=r(h),!f){a=t+(a.length>0?" "+a:a);continue}d=!1}const p=ye(l).join(":"),m=c?p+"!":p,g=m+f;if(o.includes(g))continue;o.push(g);const v=i(f,d);for(let e=0;e<v.length;++e){const t=v[e];o.push(m+t)}a=t+(a.length>0?" "+a:a)}return a})(e,n);return i(e,o),o}return function(){return o(xe.apply(null,arguments))}}const Ee=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},Ce=/^\[(?:([a-z-]+):)?(.+)\]$/i,Ne=/^\d+\/\d+$/,Oe=new Set(["px","full","screen"]),Ae=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Te=/\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$/,Me=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Re=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,De=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pe=e=>Be(e)||Oe.has(e)||Ne.test(e),Le=e=>Ye(e,"length",Ge),Be=e=>Boolean(e)&&!Number.isNaN(Number(e)),Ie=e=>Ye(e,"number",Be),_e=e=>Boolean(e)&&Number.isInteger(Number(e)),je=e=>e.endsWith("%")&&Be(e.slice(0,-1)),Fe=e=>Ce.test(e),We=e=>Ae.test(e),ze=new Set(["length","size","percentage"]),He=e=>Ye(e,ze,Xe),Ve=e=>Ye(e,"position",Xe),qe=new Set(["image","url"]),Ue=e=>Ye(e,qe,Qe),$e=e=>Ye(e,"",Je),Ke=()=>!0,Ye=(e,t,n)=>{const r=Ce.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},Ge=e=>Te.test(e)&&!Me.test(e),Xe=()=>!1,Je=e=>Re.test(e),Qe=e=>De.test(e),Ze=Se(()=>{const e=Ee("colors"),t=Ee("spacing"),n=Ee("blur"),r=Ee("brightness"),i=Ee("borderColor"),o=Ee("borderRadius"),s=Ee("borderSpacing"),a=Ee("borderWidth"),l=Ee("contrast"),c=Ee("grayscale"),h=Ee("hueRotate"),u=Ee("invert"),d=Ee("gap"),f=Ee("gradientColorStops"),p=Ee("gradientColorStopPositions"),m=Ee("inset"),g=Ee("margin"),v=Ee("opacity"),b=Ee("padding"),y=Ee("saturate"),w=Ee("scale"),x=Ee("sepia"),k=Ee("skew"),S=Ee("space"),E=Ee("translate"),C=()=>["auto",Fe,t],N=()=>[Fe,t],O=()=>["",Pe,Le],A=()=>["auto",Be,Fe],T=()=>["","0",Fe],M=()=>[Be,Fe];return{cacheSize:500,separator:":",theme:{colors:[Ke],spacing:[Pe,Le],blur:["none","",We,Fe],brightness:M(),borderColor:[e],borderRadius:["none","","full",We,Fe],borderSpacing:N(),borderWidth:O(),contrast:M(),grayscale:T(),hueRotate:M(),invert:T(),gap:N(),gradientColorStops:[e],gradientColorStopPositions:[je,Le],inset:C(),margin:C(),opacity:M(),padding:N(),saturate:M(),scale:M(),sepia:T(),skew:M(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",Fe]}],container:["container"],columns:[{columns:[We]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"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:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Fe]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],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",_e,Fe]}],basis:[{basis:C()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Fe]}],grow:[{grow:T()}],shrink:[{shrink:T()}],order:[{order:["first","last","none",_e,Fe]}],"grid-cols":[{"grid-cols":[Ke]}],"col-start-end":[{col:["auto",{span:["full",_e,Fe]},Fe]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[Ke]}],"row-start-end":[{row:["auto",{span:[_e,Fe]},Fe]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Fe]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Fe]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Fe,t]}],"min-w":[{"min-w":[Fe,t,"min","max","fit"]}],"max-w":[{"max-w":[Fe,t,"none","full","min","max","fit","prose",{screen:[We]},We]}],h:[{h:[Fe,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Fe,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Fe,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Fe,t,"auto","min","max","fit"]}],"font-size":[{text:["base",We,Le]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ie]}],"font-family":[{font:[Ke]}],"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",Fe]}],"line-clamp":[{"line-clamp":["none",Be,Ie]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Pe,Fe]}],"list-image":[{"list-image":["none",Fe]}],"list-style-type":[{list:["none","disc","decimal",Fe]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Pe,Le]}],"underline-offset":[{"underline-offset":["auto",Pe,Fe]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Fe]}],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",Fe]}],"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:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Ve]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",He]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Ue]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"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:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[Pe,Fe]}],"outline-w":[{outline:[Pe,Le]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:O()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Pe,Le]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",We,$e]}],"shadow-color":[{shadow:[Ke]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",We,Fe]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[u]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Fe]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",Fe]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",Fe]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[_e,Fe]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Fe]}],accent:[{accent:["auto",e]}],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",Fe]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"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",Fe]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Pe,Le,Ie]}],stroke:[{stroke:[e,"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"]}}});function et(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ze(ae(t))}function tt(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("animate-pulse rounded-md bg-muted",n)},r))}function nt(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function rt(...e){return t=>{let n=!1;const r=e.map(e=>{const r=nt(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():nt(e[t],null)}}}}function it(...t){return e.useCallback(rt(...t),t)}var ot=Symbol.for("react.lazy"),st=e[" use ".trim().toString()];function at(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===ot&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function lt(t){const n=ht(t),r=e.forwardRef((t,r)=>{let{children:i,...o}=t;at(i)&&"function"==typeof st&&(i=st(i._payload));const s=e.Children.toArray(i),a=s.find(dt);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}var ct=lt("Slot");function ht(t){const n=e.forwardRef((t,n)=>{let{children:r,...i}=t;if(at(r)&&"function"==typeof st&&(r=st(r._payload)),e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var ut=Symbol("radix.slottable");function dt(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===ut}const ft=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,pt=ae,mt=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return pt(e,null==n?void 0:n.class,null==n?void 0:n.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(e=>{const t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;const s=ft(t)||ft(r);return i[e][s]}),a=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{}),l=null==t||null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:n,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...o,...a}[t]):{...o,...a}[t]===n})?[...e,n,r]:e},[]);return pt(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var gt=mt("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),vt=e.forwardRef(function(t,n){var r=t.className,i=t.variant,o=t.size,s=t.asChild,a=void 0!==s&&s,l=oe(t,["className","variant","size","asChild"]),c=a?ct:"button";return e.createElement(c,Object.assign({className:et(gt({variant:i,size:o,className:r})),ref:n},l))});vt.displayName="Button";var bt=e.forwardRef(function(t,n){var r=t.className,i=t.type,o=oe(t,["className","type"]);return e.createElement("input",Object.assign({type:i,className:et("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:n},o))});bt.displayName="Input";var yt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=lt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),wt="horizontal",xt=["horizontal","vertical"],kt=e.forwardRef((e,t)=>{const{decorative:n,orientation:r=wt,...i}=e,o=function(e){return xt.includes(e)}(r)?r:wt,s=n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"};return u(yt.div,{"data-orientation":o,...s,...i,ref:t})});kt.displayName="Separator";var St=kt,Et=e.forwardRef(function(t,n){var r=t.className,i=t.orientation,o=void 0===i?"horizontal":i,s=t.decorative,a=void 0===s||s,l=oe(t,["className","orientation","decorative"]);return e.createElement(St,Object.assign({ref:n,decorative:a,orientation:o,className:et("shrink-0 bg-border","horizontal"===o?"h-[1px] w-full":"h-full w-[1px]",r)},l))});function Ct(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Nt(t,n=[]){let r=[];const i=()=>{const n=r.map(t=>e.createContext(t));return function(r){const i=r?.[t]||n;return e.useMemo(()=>({[`__scope${t}`]:{...r,[t]:i}}),[r,i])}};return i.scopeName=t,[function(n,i){const o=e.createContext(i),s=r.length;r=[...r,i];const a=n=>{const{scope:r,children:i,...a}=n,l=r?.[t]?.[s]||o,c=e.useMemo(()=>a,Object.values(a));return u(l.Provider,{value:c,children:i})};return a.displayName=n+"Provider",[a,function(r,a){const l=a?.[t]?.[s]||o,c=e.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},Ot(i,...n)]}function Ot(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const i=r.reduce((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]}),{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return r.scopeName=n.scopeName,r}Et.displayName=St.displayName;var At=globalThis?.document?e.useLayoutEffect:()=>{},Tt=e[" useId ".trim().toString()]||(()=>{}),Mt=0;function Rt(t){const[n,r]=e.useState(Tt());return At(()=>{t||r(e=>e??String(Mt++))},[t]),t||(n?`radix-${n}`:"")}var Dt=e[" useInsertionEffect ".trim().toString()]||At;function Pt({prop:t,defaultProp:n,onChange:r=()=>{},caller:i}){const[o,s,a]=function({defaultProp:t,onChange:n}){const[r,i]=e.useState(t),o=e.useRef(r),s=e.useRef(n);return Dt(()=>{s.current=n},[n]),e.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,i,s]}({defaultProp:n,onChange:r}),l=void 0!==t,c=l?t:o;{const n=e.useRef(void 0!==t);e.useEffect(()=>{const e=n.current;if(e!==l){}n.current=l},[l,i])}const h=e.useCallback(e=>{if(l){const n=function(e){return"function"==typeof e}(e)?e(t):e;n!==t&&a.current?.(n)}else s(e)},[l,t,s,a]);return[c,h]}function Lt(t){const n=Bt(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(_t);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function Bt(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var It=Symbol("radix.slottable");function _t(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===It}var jt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=Lt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});function Ft(t){const n=e.useRef(t);return e.useEffect(()=>{n.current=t}),e.useMemo(()=>(...e)=>n.current?.(...e),[])}function Wt(t,n=globalThis?.document){const r=Ft(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&r(e)};return n.addEventListener("keydown",e,{capture:!0}),()=>n.removeEventListener("keydown",e,{capture:!0})},[r,n])}var zt,Ht="dismissableLayer.update",Vt="dismissableLayer.pointerDownOutside",qt="dismissableLayer.focusOutside",Ut=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),$t=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,h=e.useContext(Ut),[d,f]=e.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=it(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){Yt(Vt,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){Yt(qt,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Wt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(zt=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),Kt(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=zt)}},[d,p,r,h]),e.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),Kt())},[d,h]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(Ht,e),()=>document.removeEventListener(Ht,e)},[]),u(jt.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Ct(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Ct(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ct(t.onPointerDownCapture,S.onPointerDownCapture)})});$t.displayName="DismissableLayer";function Kt(){const e=new CustomEvent(Ht);document.dispatchEvent(e)}function Yt(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(Ut),i=e.useRef(null),o=it(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),u(jt.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var Gt="focusScope.autoFocusOnMount",Xt="focusScope.autoFocusOnUnmount",Jt={bubbles:!1,cancelable:!0},Qt=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),h=Ft(o),d=Ft(s),f=e.useRef(null),p=it(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?f.current=t:nn(f.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||nn(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&nn(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){rn.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(Gt,Jt);l.addEventListener(Gt,h),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(nn(r,{select:t}),document.activeElement!==n)return}((e=Zt(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&nn(l))}return()=>{l.removeEventListener(Gt,h),setTimeout(()=>{const e=new CustomEvent(Xt,Jt);l.addEventListener(Xt,d),l.dispatchEvent(e),e.defaultPrevented||nn(t??document.body,{select:!0}),l.removeEventListener(Xt,d),rn.remove(m)},0)}}var e},[l,h,d,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Zt(e),n=en(t,e),r=en(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&nn(o,{select:!0})):(e.preventDefault(),r&&nn(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return u(jt.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function Zt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function en(e,t){for(const n of e)if(!tn(n,{upTo:t}))return n}function tn(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function nn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Qt.displayName="FocusScope";var rn=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=on(e,t),e.unshift(t)},remove(t){e=on(e,t),e[0]?.resume()}}}();function on(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var sn=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);At(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?m.createPortal(u(jt.div,{...i,ref:n}),a):null});sn.displayName="Portal";var an=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=ln(i.current);s.current="mounted"===l?e:"none"},[l]),At(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=ln(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),At(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=ln(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=ln(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=it(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function ln(e){return e?.animationName||"none"}an.displayName="Presence";var cn=0;function hn(){e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??un()),document.body.insertAdjacentElement("beforeend",e[1]??un()),cn++,()=>{1===cn&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),cn--}},[])}function un(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var dn="right-scroll-bar-position",fn="width-before-scroll-bar";function pn(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var mn="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,gn=new WeakMap;function vn(e,t){var n,r,o,s=(n=t||null,r=function(t){return e.forEach(function(e){return pn(e,t)})},(o=i(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return mn(function(){var t=gn.get(s);if(t){var n=new Set(t),r=new Set(e),i=s.current;n.forEach(function(e){r.has(e)||pn(e,null)}),r.forEach(function(e){n.has(e)||pn(e,i)})}gn.set(s,e)},[e]),s}function bn(e){return e}var yn=function(t){var n=t.sideCar,r=oe(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=n.read();if(!i)throw new Error("Sidecar medium not found");return e.createElement(i,ie({},r))};yn.isSideCarExport=!0;var wn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=bn);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var o=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(o)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=ie({async:!0,ssr:!1},e),t}(),xn=function(){},kn=e.forwardRef(function(t,n){var r=e.useRef(null),i=e.useState({onScrollCapture:xn,onWheelCapture:xn,onTouchMoveCapture:xn}),o=i[0],s=i[1],a=t.forwardProps,l=t.children,c=t.className,h=t.removeScrollBar,u=t.enabled,d=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,b=t.as,y=void 0===b?"div":b,w=t.gapMode,x=oe(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=vn([r,n]),E=ie(ie({},x),o);return e.createElement(e.Fragment,null,u&&e.createElement(k,{sideCar:wn,removeScrollBar:h,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:r,gapMode:w}),a?e.cloneElement(e.Children.only(l),ie(ie({},E),{ref:S})):e.createElement(y,ie({},E,{className:c,ref:S}),l))});kn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},kn.classNames={fullWidth:fn,zeroRight:dn};function Sn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var En=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=Sn())&&(i=n,(r=t).styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cn=function(){var t,n=(t=En(),function(n,r){e.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&r])});return function(e){var t=e.styles,r=e.dynamic;return n(t,r),null}},Nn={left:0,top:0,right:0,gap:0},On=function(e){return parseInt(e||"",10)||0},An=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Nn;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],i=t["padding"===e?"paddingRight":"marginRight"];return[On(n),On(r),On(i)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Tn=Cn(),Mn="data-scroll-locked",Rn=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(a,"px ").concat(r,";\n }\n body[").concat(Mn,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(a,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(dn," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(fn," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(dn," .").concat(dn," {\n right: 0 ").concat(r,";\n }\n \n .").concat(fn," .").concat(fn," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(Mn,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},Dn=function(){var e=parseInt(document.body.getAttribute(Mn)||"0",10);return isFinite(e)?e:0},Pn=function(t){var n=t.noRelative,r=t.noImportant,i=t.gapMode,o=void 0===i?"margin":i;e.useEffect(function(){return document.body.setAttribute(Mn,(Dn()+1).toString()),function(){var e=Dn()-1;e<=0?document.body.removeAttribute(Mn):document.body.setAttribute(Mn,e.toString())}},[]);var s=e.useMemo(function(){return An(o)},[o]);return e.createElement(Tn,{styles:Rn(s,!n,o,r?"":"!important")})},Ln=!1;if("undefined"!=typeof window)try{var Bn=Object.defineProperty({},"passive",{get:function(){return Ln=!0,!0}});window.addEventListener("test",Bn,Bn),window.removeEventListener("test",Bn,Bn)}catch(e){Ln=!1}var In=!!Ln&&{passive:!1},_n=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},jn=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),Fn(e,r)){var i=Wn(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Fn=function(e,t){return"v"===e?function(e){return _n(e,"overflowY")}(t):function(e){return _n(e,"overflowX")}(t)},Wn=function(e,t){return"v"===e?function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]}(t):function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t)},zn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Hn=function(e){return[e.deltaX,e.deltaY]},Vn=function(e){return e&&"current"in e?e.current:e},qn=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Un=0,$n=[];function Kn(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Yn,Gn=(Yn=function(t){var n=e.useRef([]),r=e.useRef([0,0]),i=e.useRef(),o=e.useState(Un++)[0],s=e.useState(Cn)[0],a=e.useRef(t);e.useEffect(function(){a.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var e=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(Vn),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var n,o=zn(e),s=r.current,l="deltaX"in e?e.deltaX:s[0]-o[0],c="deltaY"in e?e.deltaY:s[1]-o[1],h=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===h.type)return!1;var d=window.getSelection(),f=d&&d.anchorNode;if(f&&(f===h||f.contains(h)))return!1;var p=jn(u,h);if(!p)return!0;if(p?n=u:(n="v"===u?"h":"v",p=jn(u,h)),!p)return!1;if(!i.current&&"changedTouches"in e&&(l||c)&&(i.current=n),!n)return!0;var m=i.current||n;return function(e,t,n,r,i){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),c=!1,h=s>0,u=0,d=0;do{if(!a)break;var f=Wn(e,a),p=f[0],m=f[1]-f[2]-o*p;(p||m)&&Fn(e,a)&&(u+=m,d+=p);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(h&&(i&&Math.abs(u)<1||!i&&s>u)||!h&&(i&&Math.abs(d)<1||!i&&-s>d))&&(c=!0),c}(m,t,e,"h"===m?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if($n.length&&$n[$n.length-1]===s){var r="deltaY"in t?Hn(t):zn(t),i=n.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&(n=e.delta,i=r,n[0]===i[0]&&n[1]===i[1]);var n,i})[0];if(i&&i.should)t.cancelable&&t.preventDefault();else if(!i){var o=(a.current.shards||[]).map(Vn).filter(Boolean).filter(function(e){return e.contains(t.target)});(o.length>0?l(t,o[0]):!a.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),h=e.useCallback(function(e,t,r,i){var o={name:e,delta:t,target:r,should:i,shadowParent:Kn(r)};n.current.push(o),setTimeout(function(){n.current=n.current.filter(function(e){return e!==o})},1)},[]),u=e.useCallback(function(e){r.current=zn(e),i.current=void 0},[]),d=e.useCallback(function(e){h(e.type,Hn(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){h(e.type,zn(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return $n.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,In),document.addEventListener("touchmove",c,In),document.addEventListener("touchstart",u,In),function(){$n=$n.filter(function(e){return e!==s}),document.removeEventListener("wheel",c,In),document.removeEventListener("touchmove",c,In),document.removeEventListener("touchstart",u,In)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(s,{styles:qn(o)}):null,p?e.createElement(Pn,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},wn.useMedium(Yn),yn),Xn=e.forwardRef(function(t,n){return e.createElement(kn,ie({},t,{ref:n,sideCar:Gn}))});Xn.classNames=kn.classNames;var Jn=Xn,Qn=new WeakMap,Zn=new WeakMap,er={},tr=0,nr=function(e){return e&&(e.host||nr(e.parentNode))},rr=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=nr(t);return n&&e.contains(n)?n:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);er[n]||(er[n]=new WeakMap);var o=er[n],s=[],a=new Set,l=new Set(i),c=function(e){e&&!a.has(e)&&(a.add(e),c(e.parentNode))};i.forEach(c);var h=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(a.has(e))h(e);else try{var t=e.getAttribute(r),i=null!==t&&"false"!==t,l=(Qn.get(e)||0)+1,c=(o.get(e)||0)+1;Qn.set(e,l),o.set(e,c),s.push(e),1===l&&i&&Zn.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return h(t),a.clear(),tr++,function(){s.forEach(function(e){var t=Qn.get(e)-1,i=o.get(e)-1;Qn.set(e,t),o.set(e,i),t||(Zn.has(e)||e.removeAttribute(r),Zn.delete(e)),i||e.removeAttribute(n)}),--tr||(Qn=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,er={})}},ir=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),rr(r,i,n,"aria-hidden")):function(){return null}},or="Dialog",[sr,ar]=Nt(or),[lr,cr]=sr(or),hr=t=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=t,l=e.useRef(null),c=e.useRef(null),[h,d]=Pt({prop:i,defaultProp:o??!1,onChange:s,caller:or});return u(lr,{scope:n,triggerRef:l,contentRef:c,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:h,onOpenChange:d,onOpenToggle:e.useCallback(()=>d(e=>!e),[d]),modal:a,children:r})};hr.displayName=or;var ur="DialogTrigger",dr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(ur,n),o=it(t,i.triggerRef);return u(jt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Dr(i.open),...r,ref:o,onClick:Ct(e.onClick,i.onOpenToggle)})});dr.displayName=ur;var fr="DialogPortal",[pr,mr]=sr(fr,{forceMount:void 0}),gr=t=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=t,s=cr(fr,n);return u(pr,{scope:n,forceMount:r,children:e.Children.map(i,e=>u(an,{present:r||s.open,children:u(sn,{asChild:!0,container:o,children:e})}))})};gr.displayName=fr;var vr="DialogOverlay",br=e.forwardRef((e,t)=>{const n=mr(vr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=cr(vr,e.__scopeDialog);return o.modal?u(an,{present:r||o.open,children:u(wr,{...i,ref:t})}):null});br.displayName=vr;var yr=Lt("DialogOverlay.RemoveScroll"),wr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(vr,n);return u(Jn,{as:yr,allowPinchZoom:!0,shards:[i.contentRef],children:u(jt.div,{"data-state":Dr(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),xr="DialogContent",kr=e.forwardRef((e,t)=>{const n=mr(xr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=cr(xr,e.__scopeDialog);return u(an,{present:r||o.open,children:o.modal?u(Sr,{...i,ref:t}):u(Er,{...i,ref:t})})});kr.displayName=xr;var Sr=e.forwardRef((t,n)=>{const r=cr(xr,t.__scopeDialog),i=e.useRef(null),o=it(n,r.contentRef,i);return e.useEffect(()=>{const e=i.current;if(e)return ir(e)},[]),u(Cr,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ct(t.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Ct(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:Ct(t.onFocusOutside,e=>e.preventDefault())})}),Er=e.forwardRef((t,n)=>{const r=cr(xr,t.__scopeDialog),i=e.useRef(!1),o=e.useRef(!1);return u(Cr,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(i.current||r.triggerRef.current?.focus(),e.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(i.current=!0,"pointerdown"===e.detail.originalEvent.type&&(o.current=!0));const n=e.target,s=r.triggerRef.current?.contains(n);s&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&o.current&&e.preventDefault()}})}),Cr=e.forwardRef((t,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=t,l=cr(xr,r),c=e.useRef(null),h=it(n,c);return hn(),d(f,{children:[u(Qt,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u($t,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Dr(l.open),...a,ref:h,onDismiss:()=>l.onOpenChange(!1)})}),d(f,{children:[u(Ir,{titleId:l.titleId}),u(_r,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Nr="DialogTitle",Or=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(Nr,n);return u(jt.h2,{id:i.titleId,...r,ref:t})});Or.displayName=Nr;var Ar="DialogDescription",Tr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(Ar,n);return u(jt.p,{id:i.descriptionId,...r,ref:t})});Tr.displayName=Ar;var Mr="DialogClose",Rr=e.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(Mr,n);return u(jt.button,{type:"button",...r,ref:t,onClick:Ct(e.onClick,()=>i.onOpenChange(!1))})});function Dr(e){return e?"open":"closed"}Rr.displayName=Mr;var Pr="DialogTitleWarning",[Lr,Br]=function(t,n){const r=e.createContext(n),i=t=>{const{children:n,...i}=t,o=e.useMemo(()=>i,Object.values(i));return u(r.Provider,{value:o,children:n})};return i.displayName=t+"Provider",[i,function(i){const o=e.useContext(r);if(o)return o;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${t}\``)}]}(Pr,{contentName:xr,titleName:Nr,docsSlug:"dialog"}),Ir=({titleId:t})=>{const n=Br(Pr),r=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)}},[r,t]),null},_r=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Br("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(n&&e){document.getElementById(n)}},[r,t,n]),null},jr=hr,Fr=dr,Wr=gr,zr=br,Hr=kr,Vr=Or,qr=Tr,Ur=Rr,$r=jr,Kr=Wr,Yr=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(zr,Object.assign({className:et("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i,{ref:n}))});Yr.displayName=zr.displayName;var Gr=mt("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Xr=e.forwardRef(function(t,n){var r=t.side,i=void 0===r?"right":r,o=t.className,s=t.children,a=oe(t,["side","className","children"]);return e.createElement(Kr,null,e.createElement(Yr,null),e.createElement(Hr,Object.assign({ref:n,className:et(Gr({side:i}),o)},a),s,e.createElement(Ur,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"},e.createElement(re,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});Xr.displayName=Hr.displayName;var Jr=function(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col space-y-2 text-center sm:text-left",n)},r))};Jr.displayName="SheetHeader";var Qr=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Vr,Object.assign({ref:n,className:et("text-lg font-semibold text-foreground",r)},i))});Qr.displayName=Vr.displayName;var Zr=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(qr,Object.assign({ref:n,className:et("text-sm text-muted-foreground",r)},i))});function ei(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}Zr.displayName=qr.displayName;var ti=Symbol("radix.slottable");function ni(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===ti}var ri=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=function(t){const n=ei(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(ni);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});var ii,oi="dismissableLayer.update",si="dismissableLayer.pointerDownOutside",ai="dismissableLayer.focusOutside",li=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ci=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,h=e.useContext(li),[d,f]=e.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=it(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){ui(si,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){ui(ai,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Wt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(ii=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),hi(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=ii)}},[d,p,r,h]),e.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),hi())},[d,h]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(oi,e),()=>document.removeEventListener(oi,e)},[]),u(ri.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Ct(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Ct(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ct(t.onPointerDownCapture,S.onPointerDownCapture)})});ci.displayName="DismissableLayer";function hi(){const e=new CustomEvent(oi);document.dispatchEvent(e)}function ui(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(li),i=e.useRef(null),o=it(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),u(ri.div,{...t,ref:o})}).displayName="DismissableLayerBranch";const di=["top","right","bottom","left"],fi=Math.min,pi=Math.max,mi=Math.round,gi=Math.floor,vi=e=>({x:e,y:e}),bi={left:"right",right:"left",bottom:"top",top:"bottom"},yi={start:"end",end:"start"};function wi(e,t,n){return pi(e,fi(t,n))}function xi(e,t){return"function"==typeof e?e(t):e}function ki(e){return e.split("-")[0]}function Si(e){return e.split("-")[1]}function Ei(e){return"x"===e?"y":"x"}function Ci(e){return"y"===e?"height":"width"}const Ni=new Set(["top","bottom"]);function Oi(e){return Ni.has(ki(e))?"y":"x"}function Ai(e){return Ei(Oi(e))}function Ti(e){return e.replace(/start|end/g,e=>yi[e])}const Mi=["left","right"],Ri=["right","left"],Di=["top","bottom"],Pi=["bottom","top"];function Li(e,t,n,r){const i=Si(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?Ri:Mi:t?Mi:Ri;case"left":case"right":return t?Di:Pi;default:return[]}}(ki(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(Ti)))),o}function Bi(e){return e.replace(/left|right|bottom|top/g,e=>bi[e])}function Ii(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function _i(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ji(e,t,n){let{reference:r,floating:i}=e;const o=Oi(t),s=Ai(t),a=Ci(s),l=ki(t),c="y"===o,h=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let f;switch(l){case"top":f={x:h,y:r.y-i.height};break;case"bottom":f={x:h,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-i.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Si(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function Fi(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:d=!1,padding:f=0}=xi(t,e),p=Ii(f),m=a[d?"floating"===u?"reference":"floating":u],g=_i(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:h,strategy:l})),v="floating"===u?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,b=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),y=await(null==o.isElement?void 0:o.isElement(b))&&await(null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},w=_i(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(g.top-w.top+p.top)/y.y,bottom:(w.bottom-g.bottom+p.bottom)/y.y,left:(g.left-w.left+p.left)/y.x,right:(w.right-g.right+p.right)/y.x}}function Wi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function zi(e){return di.some(t=>e[t]>=0)}const Hi=new Set(["left","top"]);function Vi(){return"undefined"!=typeof window}function qi(e){return Ki(e)?(e.nodeName||"").toLowerCase():"#document"}function Ui(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function $i(e){var t;return null==(t=(Ki(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Ki(e){return!!Vi()&&(e instanceof Node||e instanceof Ui(e).Node)}function Yi(e){return!!Vi()&&(e instanceof Element||e instanceof Ui(e).Element)}function Gi(e){return!!Vi()&&(e instanceof HTMLElement||e instanceof Ui(e).HTMLElement)}function Xi(e){return!(!Vi()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Ui(e).ShadowRoot)}const Ji=new Set(["inline","contents"]);function Qi(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=ho(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ji.has(i)}const Zi=new Set(["table","td","th"]);function eo(e){return Zi.has(qi(e))}const to=[":popover-open",":modal"];function no(e){return to.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const ro=["transform","translate","scale","rotate","perspective"],io=["transform","translate","scale","rotate","perspective","filter"],oo=["paint","layout","strict","content"];function so(e){const t=ao(),n=Yi(e)?ho(e):e;return ro.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||io.some(e=>(n.willChange||"").includes(e))||oo.some(e=>(n.contain||"").includes(e))}function ao(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const lo=new Set(["html","body","#document"]);function co(e){return lo.has(qi(e))}function ho(e){return Ui(e).getComputedStyle(e)}function uo(e){return Yi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function fo(e){if("html"===qi(e))return e;const t=e.assignedSlot||e.parentNode||Xi(e)&&e.host||$i(e);return Xi(t)?t.host:t}function po(e){const t=fo(e);return co(t)?e.ownerDocument?e.ownerDocument.body:e.body:Gi(t)&&Qi(t)?t:po(t)}function mo(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=po(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Ui(i);if(o){const e=go(s);return t.concat(s,s.visualViewport||[],Qi(i)?i:[],e&&n?mo(e):[])}return t.concat(i,mo(i,[],n))}function go(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vo(e){const t=ho(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Gi(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=mi(n)!==o||mi(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function bo(e){return Yi(e)?e:e.contextElement}function yo(e){const t=bo(e);if(!Gi(t))return vi(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=vo(t);let s=(o?mi(n.width):n.width)/r,a=(o?mi(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const wo=vi(0);function xo(e){const t=Ui(e);return ao()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:wo}function ko(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=bo(e);let s=vi(1);t&&(r?Yi(r)&&(s=yo(r)):s=yo(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Ui(e))&&t}(o,n,r)?xo(o):vi(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,h=i.width/s.x,u=i.height/s.y;if(o){const e=Ui(o),t=r&&Yi(r)?Ui(r):r;let n=e,i=go(n);for(;i&&r&&t!==n;){const e=yo(i),t=i.getBoundingClientRect(),r=ho(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,h*=e.x,u*=e.y,l+=o,c+=s,n=Ui(i),i=go(n)}}return _i({width:h,height:u,x:l,y:c})}function So(e,t){const n=uo(e).scrollLeft;return t?t.left+n:ko($i(e)).left+n}function Eo(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-So(e,n),y:n.top+t.scrollTop}}const Co=new Set(["absolute","fixed"]);function No(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Ui(e),r=$i(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=ao();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}const c=So(r);if(c<=0){const e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,s=Math.abs(r.clientWidth-t.clientWidth-i);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=$i(e),n=uo(e),r=e.ownerDocument.body,i=pi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=pi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+So(e);const a=-n.scrollTop;return"rtl"===ho(r).direction&&(s+=pi(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}($i(e));else if(Yi(t))r=function(e,t){const n=ko(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Gi(e)?yo(e):vi(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=xo(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _i(r)}function Oo(e,t){const n=fo(e);return!(n===t||!Yi(n)||co(n))&&("fixed"===ho(n).position||Oo(n,t))}function Ao(e,t,n){const r=Gi(t),i=$i(t),o="fixed"===n,s=ko(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=vi(0);function c(){l.x=So(i)}if(r||!r&&!o)if(("body"!==qi(t)||Qi(i))&&(a=uo(t)),r){const e=ko(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const h=!i||r||o?vi(0):Eo(i,a);return{x:s.left+a.scrollLeft-l.x-h.x,y:s.top+a.scrollTop-l.y-h.y,width:s.width,height:s.height}}function To(e){return"static"===ho(e).position}function Mo(e,t){if(!Gi(e)||"fixed"===ho(e).position)return null;if(t)return t(e);let n=e.offsetParent;return $i(e)===n&&(n=n.ownerDocument.body),n}function Ro(e,t){const n=Ui(e);if(no(e))return n;if(!Gi(e)){let t=fo(e);for(;t&&!co(t);){if(Yi(t)&&!To(t))return t;t=fo(t)}return n}let r=Mo(e,t);for(;r&&eo(r)&&To(r);)r=Mo(r,t);return r&&co(r)&&To(r)&&!so(r)?n:r||function(e){let t=fo(e);for(;Gi(t)&&!co(t);){if(so(t))return t;if(no(t))return null;t=fo(t)}return null}(e)||n}const Do={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=$i(r),a=!!t&&no(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=vi(1);const h=vi(0),u=Gi(r);if((u||!u&&!o)&&(("body"!==qi(r)||Qi(s))&&(l=uo(r)),Gi(r))){const e=ko(r);c=yo(r),h.x=e.x+r.clientLeft,h.y=e.y+r.clientTop}const d=!s||u||o?vi(0):Eo(s,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+h.x+d.x,y:n.y*c.y-l.scrollTop*c.y+h.y+d.y}},getDocumentElement:$i,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?no(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=mo(e,[],!1).filter(e=>Yi(e)&&"body"!==qi(e)),i=null;const o="fixed"===ho(e).position;let s=o?fo(e):e;for(;Yi(s)&&!co(s);){const t=ho(s),n=so(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&Co.has(i.position)||Qi(s)&&!n&&Oo(e,s))?r=r.filter(e=>e!==s):i=t,s=fo(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((e,n)=>{const r=No(t,n,i);return e.top=pi(r.top,e.top),e.right=fi(r.right,e.right),e.bottom=fi(r.bottom,e.bottom),e.left=pi(r.left,e.left),e},No(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Ro,getElementRects:async function(e){const t=this.getOffsetParent||Ro,n=this.getDimensions,r=await n(e.floating);return{reference:Ao(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=vo(e);return{width:t,height:n}},getScale:yo,isElement:Yi,isRTL:function(e){return"rtl"===ho(e).direction}};function Po(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Lo(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=bo(e),h=i||o?[...c?mo(c):[],...mo(t)]:[];h.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)});const u=c&&a?function(e,t){let n,r=null;const i=$i(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:h,top:u,width:d,height:f}=c;if(a||t(),!d||!f)return;const p={rootMargin:-gi(u)+"px "+-gi(i.clientWidth-(h+d))+"px "+-gi(i.clientHeight-(u+f))+"px "+-gi(h)+"px",threshold:pi(0,fi(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==r||Po(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let d,f=-1,p=null;s&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m=l?ko(e):null;return l&&function t(){const r=ko(e);m&&!Po(m,r)&&n();m=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;h.forEach(e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)}),null==u||u(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}const Bo=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=ki(n),a=Si(n),l="y"===Oi(n),c=Hi.has(s)?-1:1,h=o&&l?-1:1,u=xi(t,e);let{mainAxis:d,crossAxis:f,alignmentAxis:p}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof p&&(f="end"===a?-1*p:p),l?{x:f*h,y:d*c}:{x:d*c,y:f*h}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Io=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=xi(e,t),c={x:n,y:r},h=await Fi(t,l),u=Oi(ki(i)),d=Ei(u);let f=c[d],p=c[u];if(o){const e="y"===d?"bottom":"right";f=wi(f+h["y"===d?"top":"left"],f,f-h[e])}if(s){const e="y"===u?"bottom":"right";p=wi(p+h["y"===u?"top":"left"],p,p-h[e])}const m=a.fn({...t,[d]:f,[u]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[d]:o,[u]:s}}}}}},_o=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=xi(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=ki(i),b=Oi(a),y=ki(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),x=d||(y||!m?[Bi(a)]:function(e){const t=Bi(e);return[Ti(e),t,Ti(t)]}(a)),k="none"!==p;!d&&k&&x.push(...Li(a,m,p,w));const S=[a,...x],E=await Fi(t,g),C=[];let N=(null==(r=o.flip)?void 0:r.overflows)||[];if(h&&C.push(E[v]),u){const e=function(e,t,n){void 0===n&&(n=!1);const r=Si(e),i=Ai(e),o=Ci(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Bi(s)),[s,Bi(s)]}(i,s,w);C.push(E[e[0]],E[e[1]])}if(N=[...N,{placement:i,overflows:C}],!C.every(e=>e<=0)){var O,A;const e=((null==(O=o.flip)?void 0:O.index)||0)+1,t=S[e];if(t){if(!("alignment"===u&&b!==Oi(t))||N.every(e=>Oi(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:N},reset:{placement:t}}}let n=null==(A=N.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:A.placement;if(!n)switch(f){case"bestFit":{var T;const e=null==(T=N.filter(e=>{if(k){const t=Oi(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:T[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},jo=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:s,elements:a}=t,{apply:l=()=>{},...c}=xi(e,t),h=await Fi(t,c),u=ki(i),d=Si(i),f="y"===Oi(i),{width:p,height:m}=o.floating;let g,v;"top"===u||"bottom"===u?(g=u,v=d===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(v=u,g="end"===d?"top":"bottom");const b=m-h.top-h.bottom,y=p-h.left-h.right,w=fi(m-h[g],b),x=fi(p-h[v],y),k=!t.middlewareData.shift;let S=w,E=x;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(E=y),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(S=b),k&&!d){const e=pi(h.left,0),t=pi(h.right,0),n=pi(h.top,0),r=pi(h.bottom,0);f?E=p-2*(0!==e||0!==t?e+t:pi(h.left,h.right)):S=m-2*(0!==n||0!==r?n+r:pi(h.top,h.bottom))}await l({...t,availableWidth:E,availableHeight:S});const C=await s.getDimensions(a.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}},Fo=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=xi(e,t);switch(r){case"referenceHidden":{const e=Wi(await Fi(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:zi(e)}}}case"escaped":{const e=Wi(await Fi(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:zi(e)}}}default:return{}}}}},Wo=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:h=0}=xi(e,t)||{};if(null==c)return{};const u=Ii(h),d={x:n,y:r},f=Ai(i),p=Ci(f),m=await s.getDimensions(c),g="y"===f,v=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",w=o.reference[p]+o.reference[f]-d[f]-o.floating[p],x=d[f]-o.reference[f],k=await(null==s.getOffsetParent?void 0:s.getOffsetParent(c));let S=k?k[y]:0;S&&await(null==s.isElement?void 0:s.isElement(k))||(S=a.floating[y]||o.floating[p]);const E=w/2-x/2,C=S/2-m[p]/2-1,N=fi(u[v],C),O=fi(u[b],C),A=N,T=S-m[p]-O,M=S/2-m[p]/2+E,R=wi(A,M,T),D=!l.arrow&&null!=Si(i)&&M!==R&&o.reference[p]/2-(M<A?N:O)-m[p]/2<0,P=D?M<A?M-A:M-T:0;return{[f]:d[f]+P,data:{[f]:R,centerOffset:M-R-P,...D&&{alignmentOffset:P}},reset:D}}}),zo=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=xi(e,t),h={x:n,y:r},u=Oi(i),d=Ei(u);let f=h[d],p=h[u];const m=xi(a,t),g="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const e="y"===d?"height":"width",t=o.reference[d]-o.floating[e]+g.mainAxis,n=o.reference[d]+o.reference[e]-g.mainAxis;f<t?f=t:f>n&&(f=n)}if(c){var v,b;const e="y"===d?"width":"height",t=Hi.has(ki(i)),n=o.reference[u]-o.floating[e]+(t&&(null==(v=s.offset)?void 0:v[u])||0)+(t?0:g.crossAxis),r=o.reference[u]+o.reference[e]+(t?0:(null==(b=s.offset)?void 0:b[u])||0)-(t?g.crossAxis:0);p<n?p=n:p>r&&(p=r)}return{[d]:f,[u]:p}}}},Ho=(e,t,n)=>{const r=new Map,i={platform:Do,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:u}=ji(c,r,l),d=r,f={},p=0;for(let n=0;n<a.length;n++){const{name:o,fn:m}=a[n],{x:g,y:v,data:b,reset:y}=await m({x:h,y:u,initialPlacement:r,placement:d,strategy:i,middlewareData:f,rects:c,platform:s,elements:{reference:e,floating:t}});h=null!=g?g:h,u=null!=v?v:u,f={...f,[o]:{...f[o],...b}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await s.getElementRects({reference:e,floating:t,strategy:i}):y.rects),({x:h,y:u}=ji(c,d,l))),n=-1)}return{x:h,y:u,placement:d,strategy:i,middlewareData:f}})(e,t,{...i,platform:o})};var Vo="undefined"!=typeof document?o:function(){};function qo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!==r--;)if(!qo(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;0!==r--;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!==r--;){const n=i[r];if(("_owner"!==n||!e.$$typeof)&&!qo(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Uo(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $o(e,t){const n=Uo(e);return Math.round(t*n)/n}function Ko(t){const n=e.useRef(t);return Vo(()=>{n.current=t}),n}function Yo(t){void 0===t&&(t={});const{placement:n="bottom",strategy:r="absolute",middleware:i=[],platform:o,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:h}=t,[u,d]=e.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[f,m]=e.useState(i);qo(f,i)||m(i);const[g,v]=e.useState(null),[b,y]=e.useState(null),w=e.useCallback(e=>{e!==E.current&&(E.current=e,v(e))},[]),x=e.useCallback(e=>{e!==C.current&&(C.current=e,y(e))},[]),k=s||g,S=a||b,E=e.useRef(null),C=e.useRef(null),N=e.useRef(u),O=null!=c,A=Ko(c),T=Ko(o),M=Ko(h),R=e.useCallback(()=>{if(!E.current||!C.current)return;const e={placement:n,strategy:r,middleware:f};T.current&&(e.platform=T.current),Ho(E.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==M.current};D.current&&!qo(N.current,t)&&(N.current=t,p.flushSync(()=>{d(t)}))})},[f,n,r,T,M]);Vo(()=>{!1===h&&N.current.isPositioned&&(N.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[h]);const D=e.useRef(!1);Vo(()=>(D.current=!0,()=>{D.current=!1}),[]),Vo(()=>{if(k&&(E.current=k),S&&(C.current=S),k&&S){if(A.current)return A.current(k,S,R);R()}},[k,S,R,A,O]);const P=e.useMemo(()=>({reference:E,floating:C,setReference:w,setFloating:x}),[w,x]),L=e.useMemo(()=>({reference:k,floating:S}),[k,S]),B=e.useMemo(()=>{const e={position:r,left:0,top:0};if(!L.floating)return e;const t=$o(L.floating,u.x),n=$o(L.floating,u.y);return l?{...e,transform:"translate("+t+"px, "+n+"px)",...Uo(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}},[r,l,L.floating,u.x,u.y]);return e.useMemo(()=>({...u,update:R,refs:P,elements:L,floatingStyles:B}),[u,R,P,L,B])}const Go=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}="function"==typeof e?e(t):e;return n&&(i=n,{}.hasOwnProperty.call(i,"current"))?null!=n.current?Wo({element:n.current,padding:r}).fn(t):{}:n?Wo({element:n,padding:r}).fn(t):{};var i}}),Xo=(e,t)=>({...Bo(e),options:[e,t]}),Jo=(e,t)=>({...Io(e),options:[e,t]}),Qo=(e,t)=>({...zo(e),options:[e,t]}),Zo=(e,t)=>({..._o(e),options:[e,t]}),es=(e,t)=>({...jo(e),options:[e,t]}),ts=(e,t)=>({...Fo(e),options:[e,t]}),ns=(e,t)=>({...Go(e),options:[e,t]});var rs=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return u(ri.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u("polygon",{points:"0,0 30,0 15,10"})})});rs.displayName="Arrow";var is=rs;function os(t){const[n,r]=e.useState(void 0);return At(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const n=e[0];let i,o;if("borderBoxSize"in n){const e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=t.offsetWidth,o=t.offsetHeight;r({width:i,height:o})});return e.observe(t,{box:"border-box"}),()=>e.unobserve(t)}r(void 0)},[t]),n}var ss="Popper",[as,ls]=Nt(ss),[cs,hs]=as(ss),us=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return u(cs,{scope:n,anchor:i,onAnchorChange:o,children:r})};us.displayName=ss;var ds="PopperAnchor",fs=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=hs(ds,r),a=e.useRef(null),l=it(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:u(ri.div,{...o,ref:l})});fs.displayName=ds;var ps="PopperContent",[ms,gs]=as(ps),vs=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:h=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=t,b=hs(ps,r),[y,w]=e.useState(null),x=it(n,e=>w(e)),[k,S]=e.useState(null),E=os(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==s?"-"+s:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(h)?h:[h],M=T.length>0,R={padding:A,boundary:T.filter(xs),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=Yo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>Lo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Xo({mainAxis:o+N,alignmentAxis:a}),c&&Jo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Qo():void 0,...R}),c&&Zo({...R}),es({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&ns({element:k,padding:l}),ks({arrowWidth:C,arrowHeight:N}),p&&ts({strategy:"referenceHidden",...R})]}),[_,j]=Ss(L),F=Ft(g);At(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=e.useState();return At(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),u("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:u(ms,{scope:r,placedSide:_,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:u(ri.div,{"data-side":_,"data-align":j,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});vs.displayName=ps;var bs="PopperArrow",ys={top:"bottom",right:"left",bottom:"top",left:"right"},ws=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=gs(bs,n),o=ys[i.placedSide];return u("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:u(is,{...r,ref:t,style:{...r.style,display:"block"}})})});function xs(e){return null!==e}ws.displayName=bs;var ks=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=Ss(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function Ss(e){const[t,n="center"]=e.split("-");return[t,n]}var Es=us,Cs=fs,Ns=vs,Os=ws;var As=t=>{const{present:n,children:r}=t,i=function(t){const[n,r]=e.useState(),i=e.useRef(null),o=e.useRef(t),s=e.useRef("none"),a=t?"mounted":"unmounted",[l,c]=function(t,n){return e.useReducer((e,t)=>n[e][t]??e,t)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Ts(i.current);s.current="mounted"===l?e:"none"},[l]),At(()=>{const e=i.current,n=o.current;if(n!==t){const r=s.current,i=Ts(e);if(t)c("MOUNT");else if("none"===i||"none"===e?.display)c("UNMOUNT");else{c(n&&r!==i?"ANIMATION_OUT":"UNMOUNT")}o.current=t}},[t,c]),At(()=>{if(n){let e;const t=n.ownerDocument.defaultView??window,r=r=>{const s=Ts(i.current).includes(CSS.escape(r.animationName));if(r.target===n&&s&&(c("ANIMATION_END"),!o.current)){const r=n.style.animationFillMode;n.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===n.style.animationFillMode&&(n.style.animationFillMode=r)})}},a=e=>{e.target===n&&(s.current=Ts(i.current))};return n.addEventListener("animationstart",a),n.addEventListener("animationcancel",r),n.addEventListener("animationend",r),()=>{t.clearTimeout(e),n.removeEventListener("animationstart",a),n.removeEventListener("animationcancel",r),n.removeEventListener("animationend",r)}}c("ANIMATION_END")},[n,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{i.current=e?getComputedStyle(e):null,r(e)},[])}}(n),o="function"==typeof r?r({present:i.isPresent}):e.Children.only(r),s=it(i.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof r||i.isPresent?e.cloneElement(o,{ref:s}):null};function Ts(e){return e?.animationName||"none"}As.displayName="Presence";var Ms=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Rs=e.forwardRef((e,t)=>u(ri.span,{...e,ref:t,style:{...Ms,...e.style}}));Rs.displayName="VisuallyHidden";var Ds=Rs,[Ps,Ls]=Nt("Tooltip",[ls]),Bs=ls(),Is="TooltipProvider",_s=700,js="tooltip.open",[Fs,Ws]=Ps(Is),zs=t=>{const{__scopeTooltip:n,delayDuration:r=_s,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:s}=t,a=e.useRef(!0),l=e.useRef(!1),c=e.useRef(0);return e.useEffect(()=>{const e=c.current;return()=>window.clearTimeout(e)},[]),u(Fs,{scope:n,isOpenDelayedRef:a,delayDuration:r,onOpen:e.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:e.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:e.useCallback(e=>{l.current=e},[]),disableHoverableContent:o,children:s})};zs.displayName=Is;var Hs="Tooltip",[Vs,qs]=Ps(Hs),Us=t=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=t,c=Ws(Hs,t.__scopeTooltip),h=Bs(n),[d,f]=e.useState(null),p=Rt(),m=e.useRef(0),g=a??c.disableHoverableContent,v=l??c.delayDuration,b=e.useRef(!1),[y,w]=Pt({prop:i,defaultProp:o??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(js))):c.onClose(),s?.(e)},caller:Hs}),x=e.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),k=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,w(!0)},[w]),S=e.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),E=e.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,w(!0),m.current=0},v)},[v,w]);return e.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),u(Es,{...h,children:u(Vs,{scope:n,contentId:p,open:y,stateAttribute:x,trigger:d,onTriggerChange:f,onTriggerEnter:e.useCallback(()=>{c.isOpenDelayedRef.current?E():k()},[c.isOpenDelayedRef,E,k]),onTriggerLeave:e.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:k,onClose:S,disableHoverableContent:g,children:r})})};Us.displayName=Hs;var $s="TooltipTrigger",Ks=e.forwardRef((t,n)=>{const{__scopeTooltip:r,...i}=t,o=qs($s,r),s=Ws($s,r),a=Bs(r),l=it(n,e.useRef(null),o.onTriggerChange),c=e.useRef(!1),h=e.useRef(!1),d=e.useCallback(()=>c.current=!1,[]);return e.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),u(Cs,{asChild:!0,...a,children:u(ri.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:l,onPointerMove:Ct(t.onPointerMove,e=>{"touch"!==e.pointerType&&(h.current||s.isPointerInTransitRef.current||(o.onTriggerEnter(),h.current=!0))}),onPointerLeave:Ct(t.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Ct(t.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Ct(t.onFocus,()=>{c.current||o.onOpen()}),onBlur:Ct(t.onBlur,o.onClose),onClick:Ct(t.onClick,o.onClose)})})});Ks.displayName=$s;var[Ys,Gs]=Ps("TooltipPortal",{forceMount:void 0}),Xs="TooltipContent",Js=e.forwardRef((e,t)=>{const n=Gs(Xs,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,s=qs(Xs,e.__scopeTooltip);return u(As,{present:r||s.open,children:s.disableHoverableContent?u(na,{side:i,...o,ref:t}):u(Qs,{side:i,...o,ref:t})})}),Qs=e.forwardRef((t,n)=>{const r=qs(Xs,t.__scopeTooltip),i=Ws(Xs,t.__scopeTooltip),o=e.useRef(null),s=it(n,o),[a,l]=e.useState(null),{trigger:c,onClose:h}=r,d=o.current,{onPointerInTransitChange:f}=i,p=e.useCallback(()=>{l(null),f(!1)},[f]),m=e.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect()),o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,i),s=function(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}(t.getBoundingClientRect()),a=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...s]);l(a),f(!0)},[f]);return e.useEffect(()=>()=>p(),[p]),e.useEffect(()=>{if(c&&d){const e=e=>m(e,d),t=e=>m(e,c);return c.addEventListener("pointerleave",e),d.addEventListener("pointerleave",t),()=>{c.removeEventListener("pointerleave",e),d.removeEventListener("pointerleave",t)}}},[c,d,m,p]),e.useEffect(()=>{if(a){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||d?.contains(t),i=!function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,h=a.x,u=a.y;c>r!=u>r&&n<(h-l)*(r-c)/(u-c)+l&&(i=!i)}return i}(n,a);r?p():i&&(p(),h())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,d,a,h,p]),u(na,{...t,ref:s})}),[Zs,ea]=Ps(Hs,{isInside:!1}),ta=function(e){const t=({children:e})=>u(f,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=ti,t}("TooltipContent"),na=e.forwardRef((t,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=t,c=qs(Xs,r),h=Bs(r),{onClose:f}=c;return e.useEffect(()=>(document.addEventListener(js,f),()=>document.removeEventListener(js,f)),[f]),e.useEffect(()=>{if(c.trigger){const e=e=>{const t=e.target;t?.contains(c.trigger)&&f()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,f]),u(ci,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:f,children:d(Ns,{"data-state":c.stateAttribute,...h,...l,ref:n,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u(ta,{children:i}),u(Zs,{scope:r,isInside:!0,children:u(Ds,{id:c.contentId,role:"tooltip",children:o||i})})]})})});Js.displayName=Xs;var ra="TooltipArrow";e.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Bs(n);return ea(ra,n).isInside?null:u(Os,{...i,...r,ref:t})}).displayName=ra;var ia=Js,oa=zs,sa=Us,aa=Ks,la=e.forwardRef(function(t,n){var r=t.className,i=t.sideOffset,o=void 0===i?4:i,s=oe(t,["className","sideOffset"]);return e.createElement(ia,Object.assign({ref:n,sideOffset:o,className:et("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",r)},s))});la.displayName=ia.displayName;var ca=e.createContext(null);function ha(){var t=e.useContext(ca);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function ua(t){var n=t.defaultOpen,r=void 0===n||n,i=t.open,o=t.onOpenChange,s=t.className,a=t.style,l=t.children,c=oe(t,["defaultOpen","open","onOpenChange","className","style","children"]),h=function(){var t=C(e.useState(void 0),2),n=t[0],r=t[1];return e.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){r(window.innerWidth<768)};return e.addEventListener("change",t),r(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!n}(),u=C(e.useState(!1),2),d=u[0],f=u[1],p=C(e.useState(r),2),m=p[0],g=p[1],v=null!=i?i:m,b=e.useCallback(function(e){var t="function"==typeof e?e(v):e;o?o(t):g(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[o,v]),y=e.useCallback(function(){return h?f(function(e){return!e}):b(function(e){return!e})},[h,b,f]);e.useEffect(function(){var e=function(e){"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[y]);var w=v?"expanded":"collapsed",x=e.useMemo(function(){return{state:w,open:v,setOpen:b,isMobile:h,openMobile:d,setOpenMobile:f,toggleSidebar:y}},[w,v,b,h,d,f,y]);return e.createElement(ca.Provider,{value:x},e.createElement(oa,{delayDuration:0},e.createElement("div",Object.assign({style:Object.assign({"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"},a),className:et("group/sidebar-wrapper flex min-h-svh w-full",s)},c),l)))}function da(t){var n=t.side,r=void 0===n?"left":n,i=t.variant,o=void 0===i?"sidebar":i,s=t.collapsible,a=void 0===s?"offcanvas":s,l=t.className,c=t.children,h=oe(t,["side","variant","collapsible","className","children"]),u=ha(),d=u.isMobile,f=u.state,p=u.openMobile,m=u.setOpenMobile;return"none"===a?e.createElement("div",Object.assign({className:et("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},h),c):d?e.createElement($r,Object.assign({open:p,onOpenChange:m},h),e.createElement(Xr,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:r},e.createElement(Jr,{className:"sr-only"},e.createElement(Qr,null,"Sidebar"),e.createElement(Zr,null,"Displays the mobile sidebar.")),e.createElement("div",{className:"flex h-full w-full flex-col"},c))):e.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":f,"data-collapsible":"collapsed"===f?a:"","data-variant":o,"data-side":r},e.createElement("div",{className:et("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===o||"inset"===o?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),e.createElement("div",Object.assign({className:et("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex","left"===r?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===o||"inset"===o?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",l)},h),e.createElement("div",{className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"},c)))}function fa(t){var n=t.className,r=t.onClick,i=oe(t,["className","onClick"]),o=ha().toggleSidebar;return e.createElement(vt,Object.assign({variant:"ghost",size:"icon",className:et("h-7 w-7",n),onClick:function(e){null==r||r(e),o()}},i),e.createElement(Y,null),e.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function pa(t){var n=t.className,r=oe(t,["className"]);return e.createElement("main",Object.assign({className:et("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",n)},r))}function ma(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col gap-2 p-2",n)},r))}function ga(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col gap-2 p-2",n)},r))}function va(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",n)},r))}function ba(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("relative flex w-full min-w-0 flex-col p-2",n)},r))}function ya(t){var n=t.className,r=t.asChild,i=void 0!==r&&r,o=oe(t,["className","asChild"]),s=i?ct:"div";return e.createElement(s,Object.assign({className:et("text-sidebar-foreground/70 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",n)},o))}function wa(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("w-full text-sm",n)},r))}function xa(t){var n=t.className,r=oe(t,["className"]);return e.createElement("ul",Object.assign({className:et("flex w-full min-w-0 flex-col gap-1",n)},r))}function ka(t){var n=t.className,r=oe(t,["className"]);return e.createElement("li",Object.assign({className:et("group/menu-item relative",n)},r))}var Sa=mt("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Ea(t){var n=t.asChild,r=void 0!==n&&n,i=t.isActive,o=void 0!==i&&i,s=t.variant,a=void 0===s?"default":s,l=t.size,c=void 0===l?"default":l,h=t.tooltip,u=t.className,d=oe(t,["asChild","isActive","variant","size","tooltip","className"]),f=r?ct:"button",p=ha(),m=p.isMobile,g=p.state,v=e.createElement(f,Object.assign({"data-size":c,"data-active":o,className:et(Sa({variant:a,size:c}),u)},d));return h?("string"==typeof h&&(h={children:h}),e.createElement(sa,null,e.createElement(aa,{asChild:!0},v),e.createElement(la,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},h)))):v}var Ca=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=lt(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),Na=e.forwardRef((e,t)=>u(Ca.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Na.displayName="Label";var Oa=Na,Aa=mt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ta=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Oa,Object.assign({ref:n,className:et(Aa(),r)},i))});Ta.displayName=Oa.displayName;var Ma=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("rounded-lg border bg-card text-card-foreground shadow-sm",r)},i))});Ma.displayName="Card";var Ra=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("flex flex-col space-y-1.5 p-6",r)},i))});Ra.displayName="CardHeader";var Da=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("text-2xl font-semibold leading-none tracking-tight",r)},i))});Da.displayName="CardTitle";var Pa=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("text-sm text-muted-foreground",r)},i))});Pa.displayName="CardDescription";var La=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("p-6 pt-0",r)},i))});La.displayName="CardContent";var Ba=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",Object.assign({ref:n,className:et("flex items-center p-6 pt-0",r)},i))});Ba.displayName="CardFooter";var Ia={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},_a=new Set;function ja(){_a.forEach(function(e){return e(Ia.items.slice())})}function Fa(e){switch(e){case"success":return t.createElement(D,null);case"error":return t.createElement(ne,null);case"warning":return t.createElement(R,null);case"loading":return t.createElement(q,{className:"animate-spin"});default:return t.createElement(V,null)}}function Wa(e){var t,n,r;qa();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=Ia.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:Ia.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:Fa(e.type),className:e.className,createdAt:i};return s>=0?Ia.items[s]=Object.assign({},Ia.items[s],a):(Ia.items.length>=Ia.config.maxCount&&Ia.items.shift(),Ia.items.push(a)),ja(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){za(o)},1e3*a.duration),{close:function(){return za(o)}}}function za(e){var t;if(void 0===e)return Ia.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),Ia.items=[],void ja();var n=Ia.items.findIndex(function(t){return t.key===e});if(n>=0){var r=C(Ia.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),ja()}}var Ha=null,Va=null;function qa(){"undefined"!=typeof window&&(Va||((Va=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(Va)),Ha||(Ha=g(Va)).render(t.createElement(Ua,null)))}function Ua(){var e=function(){var e=C(i(Ia.items),2),t=e[0],n=e[1];return a(function(){var e=n;return _a.add(e),function(){_a.delete(e)}},[]),t}(),n=Ia.config.top;return t.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},t.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},e.map(function(e){var n,r,i=function(e){switch(e){case"success":return{container:"border-green-200 bg-green-50/90 text-green-800 border-l-4 border-l-green-500",icon:"text-green-500",text:"text-green-800"};case"error":return{container:"border-red-200 bg-red-50/90 text-red-800 border-l-4 border-l-red-500",icon:"text-red-500",text:"text-red-800"};case"warning":return{container:"border-yellow-200 bg-yellow-50/90 text-yellow-800 border-l-4 border-l-yellow-500",icon:"text-yellow-500",text:"text-yellow-800"};default:return{container:"border-blue-200 bg-blue-50/90 text-blue-800 border-l-4 border-l-blue-500",icon:"text-blue-500",text:"text-blue-800"}}}(e.type);return t.createElement("div",{key:e.key,className:"pointer-events-auto flex w-full items-center gap-2 rounded-md border px-3 py-2 backdrop-blur ".concat(i.container," ").concat(null!==(n=e.className)&&void 0!==n?n:"")},t.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=e.icon)&&void 0!==r?r:Fa(e.type)),t.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof e.content?t.createElement("span",{className:"break-words align-middle"},e.content):e.content))})))}function $a(e,n,r,i){if(t.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:e,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:e})}var Ka,Ya,Ga=(Ya={open:function(e){var t;return Wa(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return Wa($a("info",e,t,n))},success:function(e,t,n){return Wa($a("success",e,t,n))},error:function(e,t,n){return Wa($a("error",e,t,n))},warning:function(e,t,n){return Wa($a("warning",e,t,n))},loading:function(e,t,n){return Wa($a("loading",e,null!=t?t:0,n))},destroy:function(e){return za(e)},config:function(e){return t=e,Ia.config=Object.assign({},Ia.config,t),void ja();var t},useMessage:function(){var e=s(function(){return"undefined"!=typeof window&&qa(),t.createElement(t.Fragment,null)},[]);return[Ka.current,e]}},(Ka={}).current=Ya,Ya);function Xa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ja}=Object.prototype,{getPrototypeOf:Qa}=Object,{iterator:Za,toStringTag:el}=Symbol,tl=(nl=Object.create(null),e=>{const t=Ja.call(e);return nl[t]||(nl[t]=t.slice(8,-1).toLowerCase())});var nl;const rl=e=>(e=e.toLowerCase(),t=>tl(t)===e),il=e=>t=>typeof t===e,{isArray:ol}=Array,sl=il("undefined");function al(e){return null!==e&&!sl(e)&&null!==e.constructor&&!sl(e.constructor)&&hl(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ll=rl("ArrayBuffer");const cl=il("string"),hl=il("function"),ul=il("number"),dl=e=>null!==e&&"object"==typeof e,fl=e=>{if("object"!==tl(e))return!1;const t=Qa(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||el in e||Za in e)},pl=rl("Date"),ml=rl("File"),gl=rl("Blob"),vl=rl("FileList"),bl=rl("URLSearchParams"),[yl,wl,xl,kl]=["ReadableStream","Request","Response","Headers"].map(rl);function Sl(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),ol(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(al(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(r=0;r<o;r++)s=i[r],t.call(null,e[s],s,e)}}function El(e,t){if(al(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,i=n.length;for(;i-- >0;)if(r=n[i],t===r.toLowerCase())return r;return null}const Cl="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Nl=e=>!sl(e)&&e!==Cl;const Ol=(Al="undefined"!=typeof Uint8Array&&Qa(Uint8Array),e=>Al&&e instanceof Al);var Al;const Tl=rl("HTMLFormElement"),Ml=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Rl=rl("RegExp"),Dl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Sl(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)};const Pl=rl("AsyncFunction"),Ll=(Bl="function"==typeof setImmediate,Il=hl(Cl.postMessage),Bl?setImmediate:Il?(_l=`axios@${Math.random()}`,jl=[],Cl.addEventListener("message",({source:e,data:t})=>{e===Cl&&t===_l&&jl.length&&jl.shift()()},!1),e=>{jl.push(e),Cl.postMessage(_l,"*")}):e=>setTimeout(e));var Bl,Il,_l,jl;const Fl="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Cl):"undefined"!=typeof process&&process.nextTick||Ll;var Wl={isArray:ol,isArrayBuffer:ll,isBuffer:al,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||hl(e.append)&&("formdata"===(t=tl(e))||"object"===t&&hl(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&ll(e.buffer),t},isString:cl,isNumber:ul,isBoolean:e=>!0===e||!1===e,isObject:dl,isPlainObject:fl,isEmptyObject:e=>{if(!dl(e)||al(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:yl,isRequest:wl,isResponse:xl,isHeaders:kl,isUndefined:sl,isDate:pl,isFile:ml,isBlob:gl,isRegExp:Rl,isFunction:hl,isStream:e=>dl(e)&&hl(e.pipe),isURLSearchParams:bl,isTypedArray:Ol,isFileList:vl,forEach:Sl,merge:function e(){const{caseless:t,skipUndefined:n}=Nl(this)&&this||{},r={},i=(i,o)=>{const s=t&&El(r,o)||o;fl(r[s])&&fl(i)?r[s]=e(r[s],i):fl(i)?r[s]=e({},i):ol(i)?r[s]=i.slice():n&&sl(i)||(r[s]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Sl(arguments[e],i);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(Sl(t,(t,r)=>{n&&hl(t)?e[r]=Xa(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,o,s;const a={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&Qa(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:tl,kindOfTest:rl,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(ol(e))return e;let t=e.length;if(!ul(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Za]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Tl,hasOwnProperty:Ml,hasOwnProp:Ml,reduceDescriptors:Dl,freezeMethods:e=>{Dl(e,(t,n)=>{if(hl(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];hl(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return ol(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:El,global:Cl,isContextDefined:Nl,isSpecCompliantForm:function(e){return!!(e&&hl(e.append)&&"FormData"===e[el]&&e[Za])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(dl(e)){if(t.indexOf(e)>=0)return;if(al(e))return e;if(!("toJSON"in e)){t[r]=e;const i=ol(e)?[]:{};return Sl(e,(e,t)=>{const o=n(e,r+1);!sl(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:Pl,isThenable:e=>e&&(dl(e)||hl(e))&&hl(e.then)&&hl(e.catch),setImmediate:Ll,asap:Fl,isIterable:e=>null!=e&&hl(e[Za])};function zl(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}Wl.inherits(zl,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Wl.toJSONObject(this.config),code:this.code,status:this.status}}});const Hl=zl.prototype,Vl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Vl[e]={value:e}}),Object.defineProperties(zl,Vl),Object.defineProperty(Hl,"isAxiosError",{value:!0}),zl.from=(e,t,n,r,i,o)=>{const s=Object.create(Hl);Wl.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return zl.call(s,a,l,n,r,i),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",o&&Object.assign(s,o),s};function ql(e){return Wl.isPlainObject(e)||Wl.isArray(e)}function Ul(e){return Wl.endsWith(e,"[]")?e.slice(0,-2):e}function $l(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ul(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Kl=Wl.toFlatObject(Wl,{},null,function(e){return/^is[A-Z]/.test(e)});function Yl(e,t,n){if(!Wl.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Wl.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Wl.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Wl.isSpecCompliantForm(t);if(!Wl.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Wl.isDate(e))return e.toISOString();if(Wl.isBoolean(e))return e.toString();if(!a&&Wl.isBlob(e))throw new zl("Blob is not supported. Use a Buffer instead.");return Wl.isArrayBuffer(e)||Wl.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,i){let a=e;if(e&&!i&&"object"==typeof e)if(Wl.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Wl.isArray(e)&&function(e){return Wl.isArray(e)&&!e.some(ql)}(e)||(Wl.isFileList(e)||Wl.endsWith(n,"[]"))&&(a=Wl.toArray(e)))return n=Ul(n),a.forEach(function(e,r){!Wl.isUndefined(e)&&null!==e&&t.append(!0===s?$l([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!ql(e)||(t.append($l(i,n,o),l(e)),!1)}const h=[],u=Object.assign(Kl,{defaultVisitor:c,convertValue:l,isVisitable:ql});if(!Wl.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Wl.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+r.join("."));h.push(n),Wl.forEach(n,function(n,o){!0===(!(Wl.isUndefined(n)||null===n)&&i.call(t,n,Wl.isString(o)?o.trim():o,r,u))&&e(n,r?r.concat(o):[o])}),h.pop()}}(e),t}function Gl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Xl(e,t){this._pairs=[],e&&Yl(e,this,t)}const Jl=Xl.prototype;function Ql(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Zl(e,t,n){if(!t)return e;const r=n&&n.encode||Ql;Wl.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(o=i?i(t,n):Wl.isURLSearchParams(t)?t.toString():new Xl(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}Jl.append=function(e,t){this._pairs.push([e,t])},Jl.toString=function(e){const t=e?function(t){return e.call(this,t,Gl)}:Gl;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ec=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Wl.forEach(this.handlers,function(t){null!==t&&e(t)})}},tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},nc={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Xl,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const rc="undefined"!=typeof window&&"undefined"!=typeof document,ic="object"==typeof navigator&&navigator||void 0,oc=rc&&(!ic||["ReactNative","NativeScript","NS"].indexOf(ic.product)<0),sc="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ac=rc&&window.location.href||"http://localhost";var lc={...Object.freeze({__proto__:null,hasBrowserEnv:rc,hasStandardBrowserEnv:oc,hasStandardBrowserWebWorkerEnv:sc,navigator:ic,origin:ac}),...nc};function cc(e){function t(e,n,r,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;if(o=!o&&Wl.isArray(r)?r.length:o,a)return Wl.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s;r[o]&&Wl.isObject(r[o])||(r[o]=[]);return t(e,n,r[o],i)&&Wl.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],t[o]=e[o];return t}(r[o])),!s}if(Wl.isFormData(e)&&Wl.isFunction(e.entries)){const n={};return Wl.forEachEntry(e,(e,r)=>{t(function(e){return Wl.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const hc={transitional:tc,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=Wl.isObject(e);i&&Wl.isHTMLForm(e)&&(e=new FormData(e));if(Wl.isFormData(e))return r?JSON.stringify(cc(e)):e;if(Wl.isArrayBuffer(e)||Wl.isBuffer(e)||Wl.isStream(e)||Wl.isFile(e)||Wl.isBlob(e)||Wl.isReadableStream(e))return e;if(Wl.isArrayBufferView(e))return e.buffer;if(Wl.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Yl(e,new lc.classes.URLSearchParams,{visitor:function(e,t,n,r){return lc.isNode&&Wl.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Wl.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Yl(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e,t,n){if(Wl.isString(e))try{return(t||JSON.parse)(e),Wl.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||hc.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Wl.isResponse(e)||Wl.isReadableStream(e))return e;if(e&&Wl.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw zl.from(e,zl.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lc.classes.FormData,Blob:lc.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Wl.forEach(["delete","get","head","post","put","patch"],e=>{hc.headers[e]={}});var uc=hc;const dc=Wl.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const fc=Symbol("internals");function pc(e){return e&&String(e).trim().toLowerCase()}function mc(e){return!1===e||null==e?e:Wl.isArray(e)?e.map(mc):String(e)}function gc(e,t,n,r,i){return Wl.isFunction(r)?r.call(this,t,n):(i&&(t=n),Wl.isString(t)?Wl.isString(r)?-1!==t.indexOf(r):Wl.isRegExp(r)?r.test(t):void 0:void 0)}class vc{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=pc(t);if(!i)throw new Error("header name must be a non-empty string");const o=Wl.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=mc(e))}const o=(e,t)=>Wl.forEach(e,(e,n)=>i(e,n,t));if(Wl.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Wl.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&dc[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Wl.isObject(e)&&Wl.isIterable(e)){let n,r,i={};for(const t of e){if(!Wl.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[r=t[0]]=(n=i[r])?Wl.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=pc(e)){const n=Wl.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Wl.isFunction(t))return t.call(this,e,n);if(Wl.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=pc(e)){const n=Wl.findKey(this,e);return!(!n||void 0===this[n]||t&&!gc(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=pc(e)){const i=Wl.findKey(n,e);!i||t&&!gc(0,n[i],i,t)||(delete n[i],r=!0)}}return Wl.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!gc(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return Wl.forEach(this,(r,i)=>{const o=Wl.findKey(n,i);if(o)return t[o]=mc(r),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();s!==i&&delete t[i],t[s]=mc(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Wl.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Wl.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[fc]=this[fc]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=pc(e);t[r]||(!function(e,t){const n=Wl.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return Wl.isArray(e)?e.forEach(r):r(e),this}}vc.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Wl.reduceDescriptors(vc.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Wl.freezeMethods(vc);var bc=vc;function yc(e,t){const n=this||uc,r=t||n,i=bc.from(r.headers);let o=r.data;return Wl.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function wc(e){return!(!e||!e.__CANCEL__)}function xc(e,t,n){zl.call(this,null==e?"canceled":e,zl.ERR_CANCELED,t,n),this.name="CanceledError"}function kc(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new zl("Request failed with status code "+n.status,[zl.ERR_BAD_REQUEST,zl.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Wl.inherits(xc,zl,{__CANCEL__:!0});const Sc=(e,t,n=3)=>{let r=0;const i=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=r[s];i||(i=l),n[o]=a,r[o]=l;let h=s,u=0;for(;h!==o;)u+=n[h++],h%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const d=c&&l-c;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(e,t){let n,r,i=0,o=1e3/t;const s=(t,o=Date.now())=>{i=o,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=o?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},o-a)))},()=>n&&s(n)]}(n=>{const o=n.loaded,s=n.lengthComputable?n.total:void 0,a=o-r,l=i(a);r=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&o<=s?(s-o)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},Ec=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Cc=e=>(...t)=>Wl.asap(()=>e(...t));var Nc=lc.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,lc.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(lc.origin),lc.navigator&&/(msie|trident)/i.test(lc.navigator.userAgent)):()=>!0,Oc=lc.hasStandardBrowserEnv?{write(e,t,n,r,i,o,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Wl.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Wl.isString(r)&&a.push(`path=${r}`),Wl.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),Wl.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function Ac(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Tc=e=>e instanceof bc?{...e}:e;function Mc(e,t){t=t||{};const n={};function r(e,t,n,r){return Wl.isPlainObject(e)&&Wl.isPlainObject(t)?Wl.merge.call({caseless:r},e,t):Wl.isPlainObject(t)?Wl.merge({},t):Wl.isArray(t)?t.slice():t}function i(e,t,n,i){return Wl.isUndefined(t)?Wl.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!Wl.isUndefined(t))return r(void 0,t)}function s(e,t){return Wl.isUndefined(t)?Wl.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>i(Tc(e),Tc(t),0,!0)};return Wl.forEach(Object.keys({...e,...t}),function(r){const o=l[r]||i,s=o(e[r],t[r],r);Wl.isUndefined(s)&&o!==a||(n[r]=s)}),n}var Rc=e=>{const t=Mc({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=bc.from(s),t.url=Zl(Ac(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Wl.isFormData(n))if(lc.hasStandardBrowserEnv||lc.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Wl.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(lc.hasStandardBrowserEnv&&(r&&Wl.isFunction(r)&&(r=r(t)),r||!1!==r&&Nc(t.url))){const e=i&&o&&Oc.read(o);e&&s.set(i,e)}return t};var Dc="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Rc(e);let i=r.data;const o=bc.from(r.headers).normalize();let s,a,l,c,h,{responseType:u,onUploadProgress:d,onDownloadProgress:f}=r;function p(){c&&c(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=bc.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());kc(function(e){t(e),p()},function(e){n(e),p()},{data:u&&"text"!==u&&"json"!==u?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new zl("Request aborted",zl.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=new zl(t&&t.message?t.message:"Network Error",zl.ERR_NETWORK,e,m);r.event=t||null,n(r),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||tc;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new zl(t,i.clarifyTimeoutError?zl.ETIMEDOUT:zl.ECONNABORTED,e,m)),m=null},void 0===i&&o.setContentType(null),"setRequestHeader"in m&&Wl.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Wl.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),u&&"json"!==u&&(m.responseType=r.responseType),f&&([l,h]=Sc(f,!0),m.addEventListener("progress",l)),d&&m.upload&&([a,c]=Sc(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new xc(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);v&&-1===lc.protocols.indexOf(v)?n(new zl("Unsupported protocol "+v+":",zl.ERR_BAD_REQUEST,e)):m.send(i||null)})};var Pc=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const i=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof zl?t:new xc(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new zl(`timeout ${t} of ms exceeded`,zl.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:a}=r;return a.unsubscribe=()=>Wl.asap(s),a}};const Lc=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,i=0;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},Bc=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Ic=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of Bc(e))yield*Lc(n,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return a(),void e.close();let o=r.byteLength;if(n){let e=s+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},{isFunction:_c}=Wl,jc=(({Request:e,Response:t})=>({Request:e,Response:t}))(Wl.global),{ReadableStream:Fc,TextEncoder:Wc}=Wl.global,zc=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Hc=e=>{e=Wl.merge.call({skipUndefined:!0},jc,e);const{fetch:t,Request:n,Response:r}=e,i=t?_c(t):"function"==typeof fetch,o=_c(n),s=_c(r);if(!i)return!1;const a=i&&_c(Fc),l=i&&("function"==typeof Wc?(c=new Wc,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const h=o&&a&&zc(()=>{let e=!1;const t=new n(lc.origin,{body:new Fc,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),u=s&&a&&zc(()=>Wl.isReadableStream(new r("").body)),d={stream:u&&(e=>e.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new zl(`Response type '${e}' is not supported`,zl.ERR_NOT_SUPPORT,n)})});const f=async(e,t)=>{const r=Wl.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Wl.isBlob(e))return e.size;if(Wl.isSpecCompliantForm(e)){const t=new n(lc.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Wl.isArrayBufferView(e)||Wl.isArrayBuffer(e)?e.byteLength:(Wl.isURLSearchParams(e)&&(e+=""),Wl.isString(e)?(await l(e)).byteLength:void 0)})(t):r};return async e=>{let{url:i,method:s,data:a,signal:l,cancelToken:c,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:v,headers:b,withCredentials:y="same-origin",fetchOptions:w}=Rc(e),x=t||fetch;v=v?(v+"").toLowerCase():"text";let k=Pc([l,c&&c.toAbortSignal()],p),S=null;const E=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let C;try{if(g&&h&&"get"!==s&&"head"!==s&&0!==(C=await f(b,a))){let e,t=new n(i,{method:"POST",body:a,duplex:"half"});if(Wl.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=Ec(C,Sc(Cc(g)));a=Ic(t.body,65536,e,n)}}Wl.isString(y)||(y=y?"include":"omit");const t=o&&"credentials"in n.prototype,l={...w,signal:k,method:s.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?y:void 0};S=o&&new n(i,l);let c=await(o?x(S,w):x(i,l));const p=u&&("stream"===v||"response"===v);if(u&&(m||p&&E)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=c[t]});const t=Wl.toFiniteNumber(c.headers.get("content-length")),[n,i]=m&&Ec(t,Sc(Cc(m),!0))||[];c=new r(Ic(c.body,65536,n,()=>{i&&i(),E&&E()}),e)}v=v||"text";let N=await d[Wl.findKey(d,v)||"text"](c,e);return!p&&E&&E(),await new Promise((t,n)=>{kc(t,n,{data:N,headers:bc.from(c.headers),status:c.status,statusText:c.statusText,config:e,request:S})})}catch(t){if(E&&E(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new zl("Network Error",zl.ERR_NETWORK,e,S),{cause:t.cause||t});throw zl.from(t,t&&t.code,e,S)}}},Vc=new Map,qc=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:i}=t,o=[r,i,n];let s,a,l=o.length,c=Vc;for(;l--;)s=o[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:Hc(t)),c=a;return a};qc();const Uc={http:null,xhr:Dc,fetch:{get:qc}};Wl.forEach(Uc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const $c=e=>`- ${e}`,Kc=e=>Wl.isFunction(e)||null===e||!1===e;var Yc={getAdapter:function(e,t){e=Wl.isArray(e)?e:[e];const{length:n}=e;let r,i;const o={};for(let s=0;s<n;s++){let n;if(r=e[s],i=r,!Kc(r)&&(i=Uc[(n=String(r)).toLowerCase()],void 0===i))throw new zl(`Unknown adapter '${n}'`);if(i&&(Wl.isFunction(i)||(i=i.get(t))))break;o[n||"#"+s]=i}if(!i){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new zl("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map($c).join("\n"):" "+$c(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i},adapters:Uc};function Gc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xc(null,e)}function Xc(e){Gc(e),e.headers=bc.from(e.headers),e.data=yc.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Yc.getAdapter(e.adapter||uc.adapter,e)(e).then(function(t){return Gc(e),t.data=yc.call(e,e.transformResponse,t),t.headers=bc.from(t.headers),t},function(t){return wc(t)||(Gc(e),t&&t.response&&(t.response.data=yc.call(e,e.transformResponse,t.response),t.response.headers=bc.from(t.response.headers))),Promise.reject(t)})}const Jc="1.13.2",Qc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Qc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Zc={};Qc.transitional=function(e,t,n){return(r,i,o)=>{if(!1===e)throw new zl(function(e,t){return"[Axios v"+Jc+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),zl.ERR_DEPRECATED);return t&&!Zc[i]&&(Zc[i]=!0),!e||e(r,i,o)}},Qc.spelling=function(e){return(e,t)=>!0};var eh={assertOptions:function(e,t,n){if("object"!=typeof e)throw new zl("options must be an object",zl.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],s=t[o];if(s){const t=e[o],n=void 0===t||s(t,o,e);if(!0!==n)throw new zl("option "+o+" must be "+n,zl.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new zl("Unknown option "+o,zl.ERR_BAD_OPTION)}},validators:Qc};const th=eh.validators;class nh{constructor(e){this.defaults=e||{},this.interceptors={request:new ec,response:new ec}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Mc(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&eh.assertOptions(n,{silentJSONParsing:th.transitional(th.boolean),forcedJSONParsing:th.transitional(th.boolean),clarifyTimeoutError:th.transitional(th.boolean)},!1),null!=r&&(Wl.isFunction(r)?t.paramsSerializer={serialize:r}:eh.assertOptions(r,{encode:th.function,serialize:th.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),eh.assertOptions(t,{baseUrl:th.spelling("baseURL"),withXsrfToken:th.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&Wl.merge(i.common,i[t.method]);i&&Wl.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=bc.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let h,u=0;if(!a){const e=[Xc.bind(this),void 0];for(e.unshift(...s),e.push(...l),h=e.length,c=Promise.resolve(t);u<h;)c=c.then(e[u++],e[u++]);return c}h=s.length;let d=t;for(;u<h;){const e=s[u++],t=s[u++];try{d=e(d)}catch(e){t.call(this,e);break}}try{c=Xc.call(this,d)}catch(e){return Promise.reject(e)}for(u=0,h=l.length;u<h;)c=c.then(l[u++],l[u++]);return c}getUri(e){return Zl(Ac((e=Mc(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Wl.forEach(["delete","get","head","options"],function(e){nh.prototype[e]=function(t,n){return this.request(Mc(n||{},{method:e,url:t,data:(n||{}).data}))}}),Wl.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(Mc(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}nh.prototype[e]=t(),nh.prototype[e+"Form"]=t(!0)});var rh=nh;class ih{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new xc(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ih(function(t){e=t}),cancel:e}}}var oh=ih;const sh={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(sh).forEach(([e,t])=>{sh[t]=e});var ah=sh;const lh=function e(t){const n=new rh(t),r=Xa(rh.prototype.request,n);return Wl.extend(r,rh.prototype,n,{allOwnKeys:!0}),Wl.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Mc(t,n))},r}(uc);lh.Axios=rh,lh.CanceledError=xc,lh.CancelToken=oh,lh.isCancel=wc,lh.VERSION=Jc,lh.toFormData=Yl,lh.AxiosError=zl,lh.Cancel=lh.CanceledError,lh.all=function(e){return Promise.all(e)},lh.spread=function(e){return function(t){return e.apply(null,t)}},lh.isAxiosError=function(e){return Wl.isObject(e)&&!0===e.isAxiosError},lh.mergeConfig=Mc,lh.AxiosHeaders=bc,lh.formToJSON=e=>cc(Wl.isHTMLForm(e)?new FormData(e):e),lh.getAdapter=Yc.getAdapter,lh.HttpStatusCode=ah,lh.default=lh;var ch=lh.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),hh=new Map;ch.interceptors.request.use(function(e){e.url&&e.url.startsWith("http")&&(e.baseURL="");var t=localStorage.getItem("cms_token");t&&(e.headers.Authorization="Bearer ".concat(t));var n=localStorage.getItem("cms_session_id");return n&&(e.headers["X-Session-Id"]=n),e},function(e){return Promise.reject(e)}),ch.interceptors.response.use(function(e){return e},function(e){var t="请求错误",n=!1;if(e.response){var r=e.response.status,i=e.response.data;401===r?"登录已过期,请重新登录"===(null==i?void 0:i.message)?(t="登录已过期,请重新登录",n=!0):"认证信息无效"===(null==i?void 0:i.message)?(t="认证信息无效,请重新登录",n=!0):(t="认证失败,请登录",n=!0):t=(null==i?void 0:i.message)||"HTTP ".concat(r,": ").concat(e.response.statusText)}else t=e.request?"网络连接失败,请检查网络状态":e.message||"请求错误";return n?(localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),"/login"!==window.location.pathname&&"/"!==window.location.pathname&&(Ga.error(t),setTimeout(function(){window.location.reload()},1e3))):Ga.error(t),Promise.reject(e)});var uh,dh=function(e,t,n){var r=e;if(t){var i=new URLSearchParams(t).toString();r=r+(r.includes("?")?"&":"?")+i}var o="GET ".concat(r),s=hh.get(o);if(s)return s;var a=ch.get(r,n).then(function(e){return e.data}).finally(function(){hh.delete(o)});return hh.set(o,a),a},fh=function(e,t,n){return ch.post(e,t,n).then(function(e){return e.data})},ph=function(e,t,n){return ch.put(e,t,n).then(function(e){return e.data})},mh=function(e,t){return ch.delete(e,t).then(function(e){return e.data})};try{var gh=localStorage.getItem("cms_session_id")||void 0;uh=gh}catch(rS){}function vh(e){uh=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}}var bh=function(){return dh("/models")},yh=function(){return dh("/auth/signup/status/".concat(uh?uh+"_":"","cms_users"))},wh=function(e){return fh("/auth/signup/".concat(uh?uh+"_":"","cms_users"),e)},xh=function(e){return fh("/auth/login/".concat(uh?uh+"_":"","cms_users"),e)},kh=function(){return fh("/auth/verify/".concat(uh?uh+"_":"","cms_users"))},Sh=function(){return dh("/auth/user/".concat(uh?uh+"_":"","cms_users"))},Eh=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},Ch=function(){return localStorage.getItem("cms_token")},Nh=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},Oh=function(e,t){var n=t?Object.assign({},t):void 0;return(null==n?void 0:n.filters)&&Array.isArray(n.filters)&&(n.filters=JSON.stringify(n.filters)),dh("/data/".concat(uh?uh+"_":"").concat(e),n)},Ah=function(e,t){return dh("/relation/".concat(uh?uh+"_":"").concat(e,"/options"),t)},Th=function(e,t){return fh("/data/".concat(uh?uh+"_":"").concat(e),t)},Mh=function(e,t){return ph("/data/".concat(uh?uh+"_":"").concat(e),t)},Rh=function(e,t){return mh("/data/".concat(uh?uh+"_":"").concat(e,"?id=").concat(t))};function Dh(e){var n=e.onLoginSuccess,r=C(i(""),2),o=r[0],s=r[1],l=C(i(""),2),c=l[0],h=l[1],u=C(i(!1),2),d=u[0],f=u[1],p=C(i("login"),2),m=p[0],g=p[1];a(function(){var e=Ch();if(e){var t=function(){var t=w(S().m(function t(){var r;return S().w(function(t){for(;;)switch(t.p=t.n){case 0:return f(!0),t.p=1,t.n=2,kh();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,Sh();case 4:if(!(r=t.v).success||!r.data){t.n=5;break}localStorage.setItem("cms_user",JSON.stringify(r.data)),null==n||n(e,r.data),t.n=6;break;case 5:throw new Error("获取用户信息失败");case 6:t.n=8;break;case 7:t.p=7,t.v,Eh();case 8:return t.p=8,f(!1),t.f(8);case 9:return t.a(2)}},t,null,[[1,7,8,9]])}));return function(){return t.apply(this,arguments)}}();t()}},[n]),a(function(){if(!Ch()){var e=function(){var e=w(S().m(function e(){var t,n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return f(!0),e.p=1,e.n=2,yh();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?g("signup"):g("login"),e.n=4;break;case 3:e.p=3,e.v,g("login");case 4:return e.p=4,f(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}();e()}},[]);var v=function(){var e=w(S().m(function e(t){var r,i,s,a,l;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),o&&c){e.n=1;break}return Ga.error("请完善登录信息"),e.a(2);case 1:if(f(!0),e.p=2,"signup"!==m){e.n=4;break}return e.n=3,wh({username:o,password:c});case 3:a=e.v,e.n=6;break;case 4:return e.n=5,xh({username:o,password:c});case 5:a=e.v;case 6:if((s=a).success&&(null===(r=s.data)||void 0===r?void 0:r.token)){e.n=7;break}return Ga.error(s.message||"登录失败"),"signup"===m&&(null===(i=s.message)||void 0===i?void 0:i.includes("已存在管理员"))&&g("login"),e.a(2);case 7:localStorage.setItem("cms_token",s.data.token),localStorage.setItem("cms_user",JSON.stringify(s.data.user)),null==n||n(s.data.token,s.data.user),e.n=9;break;case 8:e.p=8,l=e.v,Ga.error("登陆失败,".concat(l.message||"网络错误,请稍后重试"));case 9:return e.p=9,f(!1),e.f(9);case 10:return e.a(2)}},e,null,[[2,8,9,10]])}));return function(t){return e.apply(this,arguments)}}();return t.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},t.createElement("div",{className:"pointer-events-none absolute inset-0"},t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),t.createElement("div",{className:"absolute inset-0 bg-[radial-gradient(1200px_600px_at_-10%_-10%,rgba(59,130,246,0.12),transparent),radial-gradient(900px_500px_at_110%_20%,rgba(147,51,234,0.10),transparent),radial-gradient(700px_400px_at_60%_120%,rgba(99,102,241,0.10),transparent)]"}),t.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(115deg,rgba(255,255,255,0.6)_0%,rgba(255,255,255,0.15)_32%,transparent_32%,transparent_68%,rgba(255,255,255,0.15)_68%,rgba(255,255,255,0.6)_100%)]"})),t.createElement("div",{className:"flex-1 relative flex items-center justify-center"},t.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},t.createElement("div",{className:"mb-12"},t.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},t.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},"CMS 管理后台")),t.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"内容管理平台"),t.createElement("p",{className:"mt-6 text-2xl text-gray-600"},"一站式管理、协作与发布")),t.createElement("div",{className:"mt-8 flex items-center text-gray-500 gap-6"},t.createElement("span",{className:"flex items-center gap-2"},t.createElement("span",{className:"h-2 w-2 rounded-full bg-blue-500"}),"多角色权限"),t.createElement("span",{className:"flex items-center gap-2"},t.createElement("span",{className:"h-2 w-2 rounded-full bg-violet-500"}),"结构化内容"),t.createElement("span",{className:"flex items-center gap-2"},t.createElement("span",{className:"h-2 w-2 rounded-full bg-indigo-500"}),"可扩展 API")))),t.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},t.createElement("div",{className:"w-full max-w-sm"},d?t.createElement(Ma,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(La,{className:"p-8"},t.createElement("div",{className:"space-y-4"},t.createElement(tt,{className:"h-12 w-48"}),t.createElement(tt,{className:"h-4 w-64"}),t.createElement(tt,{className:"h-10 w-full"}),t.createElement(tt,{className:"h-10 w-full"})))):t.createElement(Ma,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},t.createElement(Ra,{className:"p-8 pb-6"},t.createElement(Da,{className:"text-center text-2xl mb-2 text-gray-800"},"signup"===m?"创建管理员账号":"欢迎使用 CMS 管理后台"),t.createElement(Pa,{className:"text-center text-gray-500"},"signup"===m?"首次进入需要先创建一个管理员账号":"请输入账号和密码登录")),t.createElement(La,{className:"p-8 pt-0"},t.createElement("form",{onSubmit:v,className:"space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement(Ta,{htmlFor:"username"},"账号/邮箱"),t.createElement("div",{className:"relative"},t.createElement(te,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(bt,{id:"username",type:"text",placeholder:"邮箱",value:o,onChange:function(e){return s(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:2}))),t.createElement("div",{className:"space-y-2"},t.createElement(Ta,{htmlFor:"password"},"密码"),t.createElement("div",{className:"relative"},t.createElement(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),t.createElement(bt,{id:"password",type:"password",placeholder:"密码",value:c,onChange:function(e){return h(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:6}))),t.createElement(vt,{type:"submit",className:"w-full h-12 rounded-xl transition-all duration-200 font-semibold text-base shadow-lg hover:brightness-[1.03] active:scale-[0.99]",style:{backgroundImage:"linear-gradient(135deg, rgba(236, 248, 255, 0.78) 0%, rgba(221, 238, 255, 0.78) 100%)",color:"rgba(0, 0, 0, 0.7)",border:"none",boxShadow:"0 6px 24px rgba(37, 99, 235, 0.12)"},disabled:d},t.createElement($,{className:"h-4 w-4 mr-2"}),d?"signup"===m?"创建中...":"登录中...":"signup"===m?"创建账号并进入":"登录"),t.createElement("div",{className:"text-center text-sm text-gray-500"},"signup"===m?t.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return g("login")},disabled:d},"已有账号?去登录"):t.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return g("signup")},disabled:d},"首次使用?创建管理员"))))))))}function Ph(e,[t,n]){return Math.min(n,Math.max(t,e))}function Lh(t){const n=Bh(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(_h);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}function Bh(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var Ih=Symbol("radix.slottable");function _h(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Ih}var jh=e.createContext(void 0);var Fh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=Lh(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{});var Wh,zh="dismissableLayer.update",Hh="dismissableLayer.pointerDownOutside",Vh="dismissableLayer.focusOutside",qh=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Uh=e.forwardRef((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=t,h=e.useContext(qh),[d,f]=e.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=it(n,e=>f(e)),v=Array.from(h.layers),[b]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=h.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1),o=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){let t=function(){Kh(Hh,r,i,{discrete:!0})};const i={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",o.current),o.current=t,n.addEventListener("click",o.current,{once:!0})):t()}else n.removeEventListener("click",o.current);i.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",o.current)}},[n,r]),{onPointerDownCapture:()=>i.current=!0}}(e=>{const t=e.target,n=[...h.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},p),E=function(t,n=globalThis?.document){const r=Ft(t),i=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!i.current){Kh(Vh,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,r]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{const t=e.target;[...h.branches].some(e=>e.contains(t))||(s?.(e),a?.(e),e.defaultPrevented||l?.())},p);return Wt(e=>{w===h.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},p),e.useEffect(()=>{if(d)return r&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(Wh=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(d)),h.layers.add(d),$h(),()=>{r&&1===h.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Wh)}},[d,p,r,h]),e.useEffect(()=>()=>{d&&(h.layers.delete(d),h.layersWithOutsidePointerEventsDisabled.delete(d),$h())},[d,h]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(zh,e),()=>document.removeEventListener(zh,e)},[]),u(Fh.div,{...c,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...t.style},onFocusCapture:Ct(t.onFocusCapture,E.onFocusCapture),onBlurCapture:Ct(t.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ct(t.onPointerDownCapture,S.onPointerDownCapture)})});Uh.displayName="DismissableLayer";function $h(){const e=new CustomEvent(zh);document.dispatchEvent(e)}function Kh(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}e.forwardRef((t,n)=>{const r=e.useContext(qh),i=e.useRef(null),o=it(n,i);return e.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),u(Fh.div,{...t,ref:o})}).displayName="DismissableLayerBranch";var Yh="focusScope.autoFocusOnMount",Gh="focusScope.autoFocusOnUnmount",Xh={bubbles:!1,cancelable:!0},Jh=e.forwardRef((t,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=t,[l,c]=e.useState(null),h=Ft(o),d=Ft(s),f=e.useRef(null),p=it(n,e=>c(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(i){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?f.current=t:tu(f.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||tu(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&tu(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,l,m.paused]),e.useEffect(()=>{if(l){nu.add(m);const t=document.activeElement;if(!l.contains(t)){const n=new CustomEvent(Yh,Xh);l.addEventListener(Yh,h),l.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(tu(r,{select:t}),document.activeElement!==n)return}((e=Qh(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&tu(l))}return()=>{l.removeEventListener(Yh,h),setTimeout(()=>{const e=new CustomEvent(Gh,Xh);l.addEventListener(Gh,d),l.dispatchEvent(e),e.defaultPrevented||tu(t??document.body,{select:!0}),l.removeEventListener(Gh,d),nu.remove(m)},0)}}var e},[l,h,d,m]);const g=e.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Qh(e),n=Zh(t,e),r=Zh(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&tu(o,{select:!0})):(e.preventDefault(),r&&tu(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return u(Fh.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});function Qh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Zh(e,t){for(const n of e)if(!eu(n,{upTo:t}))return n}function eu(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function tu(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Jh.displayName="FocusScope";var nu=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=ru(e,t),e.unshift(t)},remove(t){e=ru(e,t),e[0]?.resume()}}}();function ru(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var iu=e.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return u(Fh.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u("polygon",{points:"0,0 30,0 15,10"})})});iu.displayName="Arrow";var ou=iu,su="Popper",[au,lu]=Nt(su),[cu,hu]=au(su),uu=t=>{const{__scopePopper:n,children:r}=t,[i,o]=e.useState(null);return u(cu,{scope:n,anchor:i,onAnchorChange:o,children:r})};uu.displayName=su;var du="PopperAnchor",fu=e.forwardRef((t,n)=>{const{__scopePopper:r,virtualRef:i,...o}=t,s=hu(du,r),a=e.useRef(null),l=it(n,a),c=e.useRef(null);return e.useEffect(()=>{const e=c.current;c.current=i?.current||a.current,e!==c.current&&s.onAnchorChange(c.current)}),i?null:u(Fh.div,{...o,ref:l})});fu.displayName=du;var pu="PopperContent",[mu,gu]=au(pu),vu=e.forwardRef((t,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:h=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=t,b=hu(pu,r),[y,w]=e.useState(null),x=it(n,e=>w(e)),[k,S]=e.useState(null),E=os(k),C=E?.width??0,N=E?.height??0,O=i+("center"!==s?"-"+s:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(h)?h:[h],M=T.length>0,R={padding:A,boundary:T.filter(xu),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=Yo({strategy:"fixed",placement:O,whileElementsMounted:(...e)=>Lo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Xo({mainAxis:o+N,alignmentAxis:a}),c&&Jo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Qo():void 0,...R}),c&&Zo({...R}),es({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&ns({element:k,padding:l}),ku({arrowWidth:C,arrowHeight:N}),p&&ts({strategy:"referenceHidden",...R})]}),[_,j]=Su(L),F=Ft(g);At(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=e.useState();return At(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),u("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:u(mu,{scope:r,placedSide:_,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:u(Fh.div,{"data-side":_,"data-align":j,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});vu.displayName=pu;var bu="PopperArrow",yu={top:"bottom",right:"left",bottom:"top",left:"right"},wu=e.forwardRef(function(e,t){const{__scopePopper:n,...r}=e,i=gu(bu,n),o=yu[i.placedSide];return u("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:u(ou,{...r,ref:t,style:{...r.style,display:"block"}})})});function xu(e){return null!==e}wu.displayName=bu;var ku=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=Su(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function Su(e){const[t,n="center"]=e.split("-");return[t,n]}var Eu=uu,Cu=fu,Nu=vu,Ou=wu,Au=e.forwardRef((t,n)=>{const{container:r,...i}=t,[o,s]=e.useState(!1);At(()=>s(!0),[]);const a=r||o&&globalThis?.document?.body;return a?m.createPortal(u(Fh.div,{...i,ref:n}),a):null});function Tu(t){const n=e.useRef({value:t,previous:t});return e.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}Au.displayName="Portal";var Mu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});e.forwardRef((e,t)=>u(Fh.span,{...e,ref:t,style:{...Mu,...e.style}})).displayName="VisuallyHidden";var Ru=[" ","Enter","ArrowUp","ArrowDown"],Du=[" ","Enter"],Pu="Select",[Lu,Bu,Iu]=function(e){const n=e+"CollectionProvider",[r,i]=Nt(n),[o,s]=r(n,{collectionRef:{current:null},itemMap:new Map}),a=e=>{const{scope:n,children:r}=e,i=t.useRef(null),s=t.useRef(new Map).current;return u(o,{scope:n,itemMap:s,collectionRef:i,children:r})};a.displayName=n;const l=e+"CollectionSlot",c=Lh(l),h=t.forwardRef((e,t)=>{const{scope:n,children:r}=e,i=it(t,s(l,n).collectionRef);return u(c,{ref:i,children:r})});h.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Lh(d),m=t.forwardRef((e,n)=>{const{scope:r,children:i,...o}=e,a=t.useRef(null),l=it(n,a),c=s(d,r);return t.useEffect(()=>(c.itemMap.set(a,{ref:a,...o}),()=>{c.itemMap.delete(a)})),u(p,{[f]:"",ref:l,children:i})});return m.displayName=d,[{Provider:a,Slot:h,ItemSlot:m},function(n){const r=s(e+"CollectionConsumer",n);return t.useCallback(()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},i]}(Pu),[_u,ju]=Nt(Pu,[Iu,lu]),Fu=lu(),[Wu,zu]=_u(Pu),[Hu,Vu]=_u(Pu),qu=t=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:s,value:a,defaultValue:l,onValueChange:c,dir:h,name:f,autoComplete:p,disabled:m,required:g,form:v}=t,b=Fu(n),[y,w]=e.useState(null),[x,k]=e.useState(null),[S,E]=e.useState(!1),C=function(t){const n=e.useContext(jh);return t||n||"ltr"}(h),[N,O]=Pt({prop:i,defaultProp:o??!1,onChange:s,caller:Pu}),[A,T]=Pt({prop:a,defaultProp:l,onChange:c,caller:Pu}),M=e.useRef(null),R=!y||(v||!!y.closest("form")),[D,P]=e.useState(new Set),L=Array.from(D).map(e=>e.props.value).join(";");return u(Eu,{...b,children:d(Wu,{required:g,scope:n,trigger:y,onTriggerChange:w,valueNode:x,onValueNodeChange:k,valueNodeHasChildren:S,onValueNodeHasChildrenChange:E,contentId:Rt(),value:A,onValueChange:T,open:N,onOpenChange:O,dir:C,triggerPointerDownPosRef:M,disabled:m,children:[u(Lu.Provider,{scope:n,children:u(Hu,{scope:t.__scopeSelect,onNativeOptionAdd:e.useCallback(e=>{P(t=>new Set(t).add(e))},[]),onNativeOptionRemove:e.useCallback(e=>{P(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),R?d(Md,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:p,value:A,onChange:e=>T(e.target.value),disabled:m,form:v,children:[void 0===A?u("option",{value:""}):null,Array.from(D)]},L):null]})})};qu.displayName=Pu;var Uu="SelectTrigger",$u=e.forwardRef((t,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=t,s=Fu(r),a=zu(Uu,r),l=a.disabled||i,c=it(n,a.onTriggerChange),h=Bu(r),d=e.useRef("touch"),[f,p,m]=Dd(e=>{const t=h().filter(e=>!e.disabled),n=t.find(e=>e.value===a.value),r=Pd(t,e,n);void 0!==r&&a.onValueChange(r.value)}),g=e=>{l||(a.onOpenChange(!0),m()),e&&(a.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return u(Cu,{asChild:!0,...s,children:u(Fh.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Rd(a.value)?"":void 0,...o,ref:c,onClick:Ct(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==d.current&&g(e)}),onPointerDown:Ct(o.onPointerDown,e=>{d.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(g(e),e.preventDefault())}),onKeyDown:Ct(o.onKeyDown,e=>{const t=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||Ru.includes(e.key)&&(g(),e.preventDefault())})})})});$u.displayName=Uu;var Ku="SelectValue",Yu=e.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=zu(Ku,n),{onValueNodeHasChildrenChange:c}=l,h=void 0!==o,d=it(t,l.onValueNodeChange);return At(()=>{c(h)},[c,h]),u(Fh.span,{...a,ref:d,style:{pointerEvents:"none"},children:Rd(l.value)?u(f,{children:s}):o})});Yu.displayName=Ku;var Gu=e.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return u(Fh.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});Gu.displayName="SelectIcon";var Xu=e=>u(Au,{asChild:!0,...e});Xu.displayName="SelectPortal";var Ju="SelectContent",Qu=e.forwardRef((t,n)=>{const r=zu(Ju,t.__scopeSelect),[i,o]=e.useState();if(At(()=>{o(new DocumentFragment)},[]),!r.open){const e=i;return e?p.createPortal(u(ed,{scope:t.__scopeSelect,children:u(Lu.Slot,{scope:t.__scopeSelect,children:u("div",{children:t.children})})}),e):null}return u(rd,{...t,ref:n})});Qu.displayName=Ju;var Zu=10,[ed,td]=_u(Ju),nd=Lh("SelectContent.RemoveScroll"),rd=e.forwardRef((t,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:l,sideOffset:c,align:h,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b,...y}=t,w=zu(Ju,r),[x,k]=e.useState(null),[S,E]=e.useState(null),C=it(n,e=>k(e)),[N,O]=e.useState(null),[A,T]=e.useState(null),M=Bu(r),[R,D]=e.useState(!1),P=e.useRef(!1);e.useEffect(()=>{if(x)return ir(x)},[x]),hn();const L=e.useCallback(e=>{const[t,...n]=M().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(const n of e){if(n===i)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i)return}},[M,S]),B=e.useCallback(()=>L([N,x]),[L,N,x]);e.useEffect(()=>{R&&B()},[R,B]);const{onOpenChange:I,triggerPointerDownPosRef:_}=w;e.useEffect(()=>{if(x){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(_.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(_.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():x.contains(n.target)||I(!1),document.removeEventListener("pointermove",t),_.current=null};return null!==_.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[x,I,_]),e.useEffect(()=>{const e=()=>I(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[I]);const[j,F]=Dd(e=>{const t=M().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=Pd(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),W=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&(O(e),r&&(P.current=!0))},[w.value]),z=e.useCallback(()=>x?.focus(),[x]),H=e.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&T(e)},[w.value]),V="popper"===i?od:id,q=V===od?{side:l,sideOffset:c,align:h,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b}:{};return u(ed,{scope:r,content:x,viewport:S,onViewportChange:E,itemRefCallback:W,selectedItem:N,onItemLeave:z,itemTextRefCallback:H,focusSelectedItem:B,selectedItemText:A,position:i,isPositioned:R,searchRef:j,children:u(Jn,{as:nd,allowPinchZoom:!0,children:u(Jh,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Ct(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:u(Uh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u(V,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:e=>e.preventDefault(),...y,...q,onPlaced:()=>D(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:Ct(y.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||F(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=M().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});rd.displayName="SelectContentImpl";var id=e.forwardRef((t,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=t,s=zu(Ju,r),a=td(Ju,r),[l,c]=e.useState(null),[h,d]=e.useState(null),f=it(n,e=>d(e)),p=Bu(r),m=e.useRef(!1),g=e.useRef(!0),{viewport:v,selectedItem:b,selectedItemText:y,focusSelectedItem:w}=a,x=e.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&h&&v&&b&&y){const e=s.trigger.getBoundingClientRect(),t=h.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),r=y.getBoundingClientRect();if("rtl"!==s.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,c=Math.max(a,t.width),h=window.innerWidth-Zu,u=Ph(o,[Zu,Math.max(Zu,h-c)]);l.style.minWidth=a+"px",l.style.left=u+"px"}else{const i=t.right-r.right,o=window.innerWidth-n.right-i,s=window.innerWidth-e.right-o,a=e.width+s,c=Math.max(a,t.width),h=window.innerWidth-Zu,u=Ph(o,[Zu,Math.max(Zu,h-c)]);l.style.minWidth=a+"px",l.style.right=u+"px"}const o=p(),a=window.innerHeight-2*Zu,c=v.scrollHeight,u=window.getComputedStyle(h),d=parseInt(u.borderTopWidth,10),f=parseInt(u.paddingTop,10),g=parseInt(u.borderBottomWidth,10),w=d+f+c+parseInt(u.paddingBottom,10)+g,x=Math.min(5*b.offsetHeight,w),k=window.getComputedStyle(v),S=parseInt(k.paddingTop,10),E=parseInt(k.paddingBottom,10),C=e.top+e.height/2-Zu,N=a-C,O=b.offsetHeight/2,A=d+f+(b.offsetTop+O),T=w-A;if(A<=C){const e=o.length>0&&b===o[o.length-1].ref.current;l.style.bottom="0px";const t=h.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(N,O+(e?E:0)+t+g);l.style.height=n+"px"}else{const e=o.length>0&&b===o[0].ref.current;l.style.top="0px";const t=Math.max(C,d+v.offsetTop+(e?S:0)+O)+T;l.style.height=t+"px",v.scrollTop=A-C+v.offsetTop}l.style.margin=`${Zu}px 0`,l.style.minHeight=x+"px",l.style.maxHeight=a+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,l,h,v,b,y,s.dir,i]);At(()=>x(),[x]);const[k,S]=e.useState();At(()=>{h&&S(window.getComputedStyle(h).zIndex)},[h]);const E=e.useCallback(e=>{e&&!0===g.current&&(x(),w?.(),g.current=!1)},[x,w]);return u(sd,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:u("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u(Fh.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});id.displayName="SelectItemAlignedPosition";var od=e.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Zu,...o}=e,s=Fu(n);return u(Nu,{...s,...o,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});od.displayName="SelectPopperPosition";var[sd,ad]=_u(Ju,{}),ld="SelectViewport",cd=e.forwardRef((t,n)=>{const{__scopeSelect:r,nonce:i,...o}=t,s=td(ld,r),a=ad(ld,r),l=it(n,s.onViewportChange),c=e.useRef(0);return d(f,{children:[u("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),u(Lu.Slot,{scope:r,children:u(Fh.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ct(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=a;if(r?.current&&n){const e=Math.abs(c.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*Zu,i=parseFloat(n.style.minHeight),o=parseFloat(n.style.height),s=Math.max(i,o);if(s<r){const i=s+e,o=Math.min(r,i),a=i-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=a>0?a:0,n.style.justifyContent="flex-end")}}}c.current=t.scrollTop})})})]})});cd.displayName=ld;var hd="SelectGroup",[ud,dd]=_u(hd);e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Rt();return u(ud,{scope:n,id:i,children:u(Fh.div,{role:"group","aria-labelledby":i,...r,ref:t})})}).displayName=hd;var fd="SelectLabel",pd=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=dd(fd,n);return u(Fh.div,{id:i.id,...r,ref:t})});pd.displayName=fd;var md="SelectItem",[gd,vd]=_u(md),bd=e.forwardRef((t,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:s,...a}=t,l=zu(md,r),c=td(md,r),h=l.value===i,[d,f]=e.useState(s??""),[p,m]=e.useState(!1),g=it(n,e=>c.itemRefCallback?.(e,i,o)),v=Rt(),b=e.useRef("touch"),y=()=>{o||(l.onValueChange(i),l.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u(gd,{scope:r,value:i,disabled:o,textId:v,isSelected:h,onItemTextChange:e.useCallback(e=>{f(t=>t||(e?.textContent??"").trim())},[]),children:u(Lu.ItemSlot,{scope:r,value:i,disabled:o,textValue:d,children:u(Fh.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":h&&p,"data-state":h?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:Ct(a.onFocus,()=>m(!0)),onBlur:Ct(a.onBlur,()=>m(!1)),onClick:Ct(a.onClick,()=>{"mouse"!==b.current&&y()}),onPointerUp:Ct(a.onPointerUp,()=>{"mouse"===b.current&&y()}),onPointerDown:Ct(a.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:Ct(a.onPointerMove,e=>{b.current=e.pointerType,o?c.onItemLeave?.():"mouse"===b.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ct(a.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Ct(a.onKeyDown,e=>{""!==c.searchRef?.current&&" "===e.key||(Du.includes(e.key)&&y()," "===e.key&&e.preventDefault())})})})})});bd.displayName=md;var yd="SelectItemText",wd=e.forwardRef((t,n)=>{const{__scopeSelect:r,className:i,style:o,...s}=t,a=zu(yd,r),l=td(yd,r),c=vd(yd,r),h=Vu(yd,r),[m,g]=e.useState(null),v=it(n,e=>g(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),b=m?.textContent,y=e.useMemo(()=>u("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:w,onNativeOptionRemove:x}=h;return At(()=>(w(y),()=>x(y)),[w,x,y]),d(f,{children:[u(Fh.span,{id:c.textId,...s,ref:v}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?p.createPortal(s.children,a.valueNode):null]})});wd.displayName=yd;var xd="SelectItemIndicator",kd=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return vd(xd,n).isSelected?u(Fh.span,{"aria-hidden":!0,...r,ref:t}):null});kd.displayName=xd;var Sd="SelectScrollUpButton",Ed=e.forwardRef((t,n)=>{const r=td(Sd,t.__scopeSelect),i=ad(Sd,t.__scopeSelect),[o,s]=e.useState(!1),a=it(n,i.onScrollButtonChange);return At(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;s(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?u(Od,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});Ed.displayName=Sd;var Cd="SelectScrollDownButton",Nd=e.forwardRef((t,n)=>{const r=td(Cd,t.__scopeSelect),i=ad(Cd,t.__scopeSelect),[o,s]=e.useState(!1),a=it(n,i.onScrollButtonChange);return At(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;s(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?u(Od,{...t,ref:a,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});Nd.displayName=Cd;var Od=e.forwardRef((t,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=t,s=td("SelectScrollButton",r),a=e.useRef(null),l=Bu(r),c=e.useCallback(()=>{null!==a.current&&(window.clearInterval(a.current),a.current=null)},[]);return e.useEffect(()=>()=>c(),[c]),At(()=>{const e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),u(Fh.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:Ct(o.onPointerDown,()=>{null===a.current&&(a.current=window.setInterval(i,50))}),onPointerMove:Ct(o.onPointerMove,()=>{s.onItemLeave?.(),null===a.current&&(a.current=window.setInterval(i,50))}),onPointerLeave:Ct(o.onPointerLeave,()=>{c()})})}),Ad=e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u(Fh.div,{"aria-hidden":!0,...r,ref:t})});Ad.displayName="SelectSeparator";var Td="SelectArrow";e.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Fu(n),o=zu(Td,n),s=td(Td,n);return o.open&&"popper"===s.position?u(Ou,{...i,...r,ref:t}):null}).displayName=Td;var Md=e.forwardRef(({__scopeSelect:t,value:n,...r},i)=>{const o=e.useRef(null),s=it(i,o),a=Tu(n);return e.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(a!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[a,n]),u(Fh.select,{...r,style:{...Mu,...r.style},ref:s,defaultValue:n})});function Rd(e){return""===e||void 0===e}function Dd(t){const n=Ft(t),r=e.useRef(""),i=e.useRef(0),o=e.useCallback(e=>{const t=r.current+e;n(t),function e(t){r.current=t,window.clearTimeout(i.current),""!==t&&(i.current=window.setTimeout(()=>e(""),1e3))}(t)},[n]),s=e.useCallback(()=>{r.current="",window.clearTimeout(i.current)},[]);return e.useEffect(()=>()=>window.clearTimeout(i.current),[]),[r,o,s]}function Pd(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=(s=e,a=Math.max(i,0),s.map((e,t)=>s[(a+t)%s.length]));var s,a;1===r.length&&(o=o.filter(e=>e!==n));const l=o.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}Md.displayName="SelectBubbleInput";var Ld=$u,Bd=Gu,Id=Xu,_d=Qu,jd=cd,Fd=pd,Wd=bd,zd=wd,Hd=kd,Vd=Ed,qd=Nd,Ud=Ad,$d=qu,Kd=Yu,Yd=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=oe(t,["className","children"]);return e.createElement(Ld,Object.assign({ref:n,className:et("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",r)},o),i,e.createElement(Bd,{asChild:!0},e.createElement(L,{className:"h-4 w-4 opacity-50"})))});Yd.displayName=Ld.displayName;var Gd=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Vd,Object.assign({ref:n,className:et("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(_,{className:"h-4 w-4"}))});Gd.displayName=Vd.displayName;var Xd=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(qd,Object.assign({ref:n,className:et("flex cursor-default items-center justify-center py-1",r)},i),e.createElement(L,{className:"h-4 w-4"}))});Xd.displayName=qd.displayName;var Jd=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=t.position,s=void 0===o?"popper":o,a=oe(t,["className","children","position"]);return e.createElement(Id,null,e.createElement(_d,Object.assign({ref:n,className:et("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",r),position:s},a),e.createElement(Gd,null),e.createElement(jd,{className:et("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},i),e.createElement(Xd,null)))});Jd.displayName=_d.displayName;var Qd=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Fd,Object.assign({ref:n,className:et("py-1.5 pl-8 pr-2 text-sm font-semibold",r)},i))});Qd.displayName=Fd.displayName;var Zd=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=oe(t,["className","children"]);return e.createElement(Wd,Object.assign({ref:n,className:et("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(Hd,null,e.createElement(P,{className:"h-4 w-4"}))),e.createElement(zd,null,i))});Zd.displayName=Wd.displayName;var ef=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Ud,Object.assign({ref:n,className:et("-mx-1 my-1 h-px bg-muted",r)},i))});function tf(t){const n=e.forwardRef((t,n)=>{const{children:r,...i}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(i,r.props);return r.type!==e.Fragment&&(o.ref=n?rt(n,t):t),e.cloneElement(r,o)}return e.Children.count(r)>1?e.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}ef.displayName=Ud.displayName;var nf=Symbol("radix.slottable");function rf(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===nf}var of=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=function(t){const n=tf(t),r=e.forwardRef((t,r)=>{const{children:i,...o}=t,s=e.Children.toArray(i),a=s.find(rf);if(a){const t=a.props.children,i=s.map(n=>n===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n);return u(n,{...o,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return u(n,{...o,ref:r,children:i})});return r.displayName=`${t}.Slot`,r}(`Primitive.${n}`),i=e.forwardRef((e,t)=>{const{asChild:i,...o}=e,s=i?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),u(s,{...o,ref:t})});return i.displayName=`Primitive.${n}`,{...t,[n]:i}},{}),sf="Switch",[af,lf]=Nt(sf),[cf,hf]=af(sf),uf=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:s,required:a,disabled:l,value:c="on",onCheckedChange:h,form:f,...p}=t,[m,g]=e.useState(null),v=it(n,e=>g(e)),b=e.useRef(!1),y=!m||(f||!!m.closest("form")),[w,x]=Pt({prop:o,defaultProp:s??!1,onChange:h,caller:sf});return d(cf,{scope:r,checked:w,disabled:l,children:[u(of.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":mf(w),"data-disabled":l?"":void 0,disabled:l,value:c,...p,ref:v,onClick:Ct(t.onClick,e=>{x(e=>!e),y&&(b.current=e.isPropagationStopped(),b.current||e.stopPropagation())})}),y&&u(pf,{control:m,bubbles:!b.current,name:i,value:c,checked:w,required:a,disabled:l,form:f,style:{transform:"translateX(-100%)"}})]})});uf.displayName=sf;var df="SwitchThumb",ff=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=hf(df,n);return u(of.span,{"data-state":mf(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});ff.displayName=df;var pf=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:i=!0,...o},s)=>{const a=e.useRef(null),l=it(a,s),c=Tu(r),h=os(n);return e.useEffect(()=>{const e=a.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(c!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[c,r,i]),u("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:l,style:{...o.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function mf(e){return e?"checked":"unchecked"}pf.displayName="SwitchBubbleInput";var gf=uf,vf=ff,bf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(gf,Object.assign({className:et("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",r)},i,{ref:n}),e.createElement(vf,{className:et("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}))});bf.displayName=gf.displayName;var yf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("textarea",Object.assign({className:et("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:n},i))});yf.displayName="Textarea";var wf=jr,xf=Fr,kf=Wr,Sf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(zr,Object.assign({ref:n,className:et("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r)},i))});Sf.displayName=zr.displayName;var Ef=e.forwardRef(function(t,n){var r=t.className,i=t.children,o=oe(t,["className","children"]);return e.createElement(kf,null,e.createElement(Sf,null),e.createElement(Hr,Object.assign({ref:n,className:et("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",r)},o),i,e.createElement(Ur,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"},e.createElement(re,{className:"h-4 w-4"}),e.createElement("span",{className:"sr-only"},"Close"))))});Ef.displayName=Hr.displayName;var Cf=function(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col space-y-1.5 text-center sm:text-left",n)},r))};Cf.displayName="DialogHeader";var Nf=function(t){var n=t.className,r=oe(t,["className"]);return e.createElement("div",Object.assign({className:et("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n)},r))};Nf.displayName="DialogFooter";var Of=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(Vr,Object.assign({ref:n,className:et("text-lg font-semibold leading-none tracking-tight",r)},i))});Of.displayName=Vr.displayName;var Af,Tf=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement(qr,Object.assign({ref:n,className:et("text-sm text-muted-foreground",r)},i))});function Mf(e,t=!1){const n=e.length;let r=0,i="",o=0,s=16,a=0,l=0,c=0,h=0,u=0;function d(t,n){let i=0,o=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)o=16*o+t-48;else if(t>=65&&t<=70)o=16*o+t-65+10;else{if(!(t>=97&&t<=102))break;o=16*o+t-97+10}r++,i++}return i<t&&(o=-1),o}function f(){if(i="",u=0,o=r,l=a,h=c,r>=n)return o=n,s=17;let t=e.charCodeAt(r);if(Rf(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(Rf(t));return s=15}if(Df(t))return r++,i+=String.fromCharCode(t),13===t&&10===e.charCodeAt(r)&&(r++,i+="\n"),a++,c=r,s=14;switch(t){case 123:return r++,s=1;case 125:return r++,s=2;case 91:return r++,s=3;case 93:return r++,s=4;case 58:return r++,s=6;case 44:return r++,s=5;case 34:return r++,i=function(){let t="",i=r;for(;;){if(r>=n){t+=e.substring(i,r),u=2;break}const o=e.charCodeAt(r);if(34===o){t+=e.substring(i,r),r++;break}if(92!==o){if(o>=0&&o<=31){if(Df(o)){t+=e.substring(i,r),u=2;break}u=6}r++}else{if(t+=e.substring(i,r),r++,r>=n){u=2;break}switch(e.charCodeAt(r++)){case 34:t+='"';break;case 92:t+="\\";break;case 47:t+="/";break;case 98:t+="\b";break;case 102:t+="\f";break;case 110:t+="\n";break;case 114:t+="\r";break;case 116:t+="\t";break;case 117:const e=d(4,!0);e>=0?t+=String.fromCharCode(e):u=4;break;default:u=5}i=r}}return t}(),s=10;case 47:const l=r-1;if(47===e.charCodeAt(r+1)){for(r+=2;r<n&&!Df(e.charCodeAt(r));)r++;return i=e.substring(l,r),s=12}if(42===e.charCodeAt(r+1)){r+=2;const t=n-1;let o=!1;for(;r<t;){const t=e.charCodeAt(r);if(42===t&&47===e.charCodeAt(r+1)){r+=2,o=!0;break}r++,Df(t)&&(13===t&&10===e.charCodeAt(r)&&r++,a++,c=r)}return o||(r++,u=1),i=e.substring(l,r),s=13}return i+=String.fromCharCode(t),r++,s=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!Pf(e.charCodeAt(r)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=function(){let t=r;if(48===e.charCodeAt(r))r++;else for(r++;r<e.length&&Pf(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(r++,!(r<e.length&&Pf(e.charCodeAt(r))))return u=3,e.substring(t,r);for(r++;r<e.length&&Pf(e.charCodeAt(r));)r++}let n=r;if(r<e.length&&(69===e.charCodeAt(r)||101===e.charCodeAt(r)))if(r++,(r<e.length&&43===e.charCodeAt(r)||45===e.charCodeAt(r))&&r++,r<e.length&&Pf(e.charCodeAt(r))){for(r++;r<e.length&&Pf(e.charCodeAt(r));)r++;n=r}else u=3;return e.substring(t,n)}(),s=11;default:for(;r<n&&p(t);)r++,t=e.charCodeAt(r);if(o!==r){switch(i=e.substring(o,r),i){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return i+=String.fromCharCode(t),r++,s=16}}function p(e){if(Rf(e)||Df(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}return{setPosition:function(e){r=e,i="",o=0,s=16,u=0},getPosition:()=>r,scan:t?function(){let e;do{e=f()}while(e>=12&&e<=15);return e}:f,getToken:()=>s,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>r-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-h,getTokenError:()=>u}}function Rf(e){return 32===e||9===e}function Df(e){return 10===e||13===e}function Pf(e){return e>=48&&e<=57}Tf.displayName=qr.displayName,function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"}(Af||(Af={}));const Lf=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),Bf=200,If={" ":{"\n":new Array(Bf).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":new Array(Bf).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(Bf).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))},"\t":{"\n":new Array(Bf).fill(0).map((e,t)=>"\n"+"\t".repeat(t)),"\r":new Array(Bf).fill(0).map((e,t)=>"\r"+"\t".repeat(t)),"\r\n":new Array(Bf).fill(0).map((e,t)=>"\r\n"+"\t".repeat(t))}},_f=["\n","\r","\r\n"];function jf(e,t,n){let r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!Wf(e,o-1);)o--;let l=a;for(;l<e.length&&!Wf(e,l);)l++;i=e.substring(o,l),r=function(e,t){let n=0,r=0;const i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===Lf[1])r++;else{if("\t"!==t)break;r+=i}n++}return Math.floor(r/i)}(i,n)}else i=e,r=0,o=0,s=0,a=e.length;const l=function(e,t){for(let e=0;e<t.length;e++){const n=t.charAt(e);if("\r"===n)return e+1<t.length&&"\n"===t.charAt(e+1)?"\r\n":"\r";if("\n"===n)return"\n"}return e&&e.eol||"\n"}(n,e),c=_f.includes(l);let h,u=0,d=0;h=n.insertSpaces?Lf[n.tabSize||4]??Ff(Lf[1],n.tabSize||4):"\t";const f="\t"===h?"\t":" ";let p=Mf(i,!1),m=!1;function g(){if(u>1)return Ff(l,u)+Ff(h,r+d);const e=h.length*(r+d);return!c||e>If[f][l].length?l+Ff(h,r+d):e<=0?l:If[f][l][e]}function v(){let e=p.scan();for(u=0;15===e||14===e;)14===e&&n.keepLines?u+=1:14===e&&(u=1),e=p.scan();return m=16===e||0!==p.getTokenError(),e}const b=[];function y(n,r,i){m||t&&!(r<a&&i>s)||e.substring(r,i)===n||b.push({offset:r,length:i-r,content:n})}let w=v();if(n.keepLines&&u>0&&y(Ff(l,u),0,0),17!==w){let e=p.getTokenOffset()+o;y(h.length*r<20&&n.insertSpaces?Lf[h.length*r]:Ff(h,r),o,e)}for(;17!==w;){let e=p.getTokenOffset()+p.getTokenLength()+o,t=v(),r="",i=!1;for(;0===u&&(12===t||13===t);){let n=p.getTokenOffset()+o;y(Lf[1],e,n),e=p.getTokenOffset()+p.getTokenLength()+o,i=12===t,r=i?g():"",t=v()}if(2===t)1!==w&&d--,n.keepLines&&u>0||!n.keepLines&&1!==w?r=g():n.keepLines&&(r=Lf[1]);else if(4===t)3!==w&&d--,n.keepLines&&u>0||!n.keepLines&&3!==w?r=g():n.keepLines&&(r=Lf[1]);else{switch(w){case 3:case 1:d++,r=n.keepLines&&u>0||!n.keepLines?g():Lf[1];break;case 5:r=n.keepLines&&u>0||!n.keepLines?g():Lf[1];break;case 12:r=g();break;case 13:u>0?r=g():i||(r=Lf[1]);break;case 6:n.keepLines&&u>0?r=g():i||(r=Lf[1]);break;case 10:n.keepLines&&u>0?r=g():6!==t||i||(r="");break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&u>0?r=g():12!==t&&13!==t||i?5!==t&&17!==t&&(m=!0):r=Lf[1];break;case 16:m=!0}u>0&&(12===t||13===t)&&(r=g())}17===t&&(r=n.keepLines&&u>0?g():n.insertFinalNewline?l:"");y(r,e,p.getTokenOffset()+o),w=t}return b}function Ff(e,t){let n="";for(let r=0;r<t;r++)n+=e;return n}function Wf(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}var zf,Hf,Vf;!function(e){e.DEFAULT={allowTrailingComma:!1}}(zf||(zf={})),function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"}(Hf||(Hf={})),function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"}(Vf||(Vf={}));const qf=function(e,t=[],n=zf.DEFAULT){let r=null,i=[];const o=[];function s(e){Array.isArray(i)?i.push(e):null!==r&&(i[r]=e)}const a={onObjectBegin:()=>{const e={};s(e),o.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{const e=[];s(e),o.push(i),i=e,r=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:s,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}};return function(e,t,n=zf.DEFAULT){const r=Mf(e,!1),i=[];let o=0;function s(e){return e?()=>0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(e){return e?()=>{if(o>0)o++;else{!1===e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())&&(o=1)}}:()=>!0}function h(e){return e?()=>{o>0&&o--,0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const u=c(t.onObjectBegin),d=l(t.onObjectProperty),f=h(t.onObjectEnd),p=c(t.onArrayBegin),m=h(t.onArrayEnd),g=l(t.onLiteralValue),v=a(t.onSeparator),b=s(t.onComment),y=a(t.onError),w=n&&n.disallowComments,x=n&&n.allowTrailingComma;function k(){for(;;){const e=r.scan();switch(r.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:w||S(11);break;case 2:S(12);break;case 6:S(16)}switch(e){case 12:case 13:w?S(10):b();break;case 16:S(1);break;case 15:case 14:break;default:return e}}}function S(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;17!==e;){if(-1!==t.indexOf(e)){k();break}if(-1!==n.indexOf(e))break;e=k()}}}function E(e){const t=r.getTokenValue();return e?g(t):(d(t),i.push(t)),k(),!0}function C(){switch(r.getToken()){case 11:const e=r.getTokenValue();let t=Number(e);isNaN(t)&&(S(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return k(),!0}function N(){return 10!==r.getToken()?(S(3,[],[2,5]),!1):(E(!1),6===r.getToken()?(v(":"),k(),T()||S(4,[],[2,5])):S(5,[],[2,5]),i.pop(),!0)}function O(){u(),k();let e=!1;for(;2!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(e||S(4,[],[]),v(","),k(),2===r.getToken()&&x)break}else e&&S(6,[],[]);N()||S(4,[],[2,5]),e=!0}return f(),2!==r.getToken()?S(7,[2],[]):k(),!0}function A(){p(),k();let e=!0,t=!1;for(;4!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(t||S(4,[],[]),v(","),k(),4===r.getToken()&&x)break}else t&&S(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,T()||S(4,[],[4,5]),t=!0}return m(),e||i.pop(),4!==r.getToken()?S(8,[4],[]):k(),!0}function T(){switch(r.getToken()){case 3:return A();case 1:return O();case 10:return E(!0);default:return C()}}if(k(),17===r.getToken())return!!n.allowEmptyContent||(S(4,[],[]),!1);if(!T())return S(4,[],[]),!1;17!==r.getToken()&&S(9,[],[])}(e,a,n),i[0]};var Uf;function $f(e,t){if(!t.length)return"JSON 格式不正确";var n=t[0],r=function(e,t){for(var n=1,r=1,i=Math.max(0,Math.min(t,e.length)),o=0;o<i;o++){"\n"===e.charAt(o)?(n++,r=1):r++}return{line:n,col:r}}(e,n.offset),i=r.line,o=r.col,s=function(e){switch(e){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}(n.error);return"JSON 格式不正确(".concat(s,",行 ").concat(i," 列 ").concat(o,")")}function Kf(e){if(null==e||""===e)return{ok:!0,value:null,pretty:"null",compact:"null"};try{if("string"!=typeof e)return{ok:!0,value:e,pretty:JSON.stringify(e,null,2),compact:JSON.stringify(e)};var t=e,n=[],r=qf(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:$f(t,n),pretty:t,compact:t}:{ok:!0,value:r,pretty:JSON.stringify(r,null,2),compact:JSON.stringify(r)}}catch(t){var i="string"==typeof e?e:String(e);return{ok:!1,message:"JSON 格式不正确",pretty:i,compact:i}}}function Yf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(qf(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:$f(n,r)};for(var i=function(e,t,n){return jf(e,t,n)}(n,void 0,{insertSpaces:!0,tabSize:t}),o=n,s=i.length-1;s>=0;s--){var a=i[s];o=o.slice(0,a.offset)+a.content+o.slice(a.offset+a.length)}return{ok:!0,formatted:o}}function Gf(){return Gf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gf.apply(null,arguments)}!function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"}(Uf||(Uf={}));let Xf=[],Jf=[];function Qf(e){if(e<768)return!1;for(let t=0,n=Xf.length;;){let r=t+n>>1;if(e<Xf[r])n=r;else{if(!(e>=Jf[r]))return!0;t=r+1}if(t==n)return!1}}function Zf(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Jf:Xf).push(n+=e[t])})();function ep(e,t,n=!0,r=!0){return(n?tp:np)(e,t,r)}function tp(e,t,n){if(t==e.length)return t;t&&ip(e.charCodeAt(t))&&op(e.charCodeAt(t-1))&&t--;let r=rp(e,t);for(t+=sp(r);t<e.length;){let i=rp(e,t);if(8205==r||8205==i||n&&Qf(i))t+=sp(i),r=i;else{if(!Zf(i))break;{let n=0,r=t-2;for(;r>=0&&Zf(rp(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function np(e,t,n){for(;t>0;){let r=tp(e,t-2,n);if(r<t)return r;t--}return 0}function rp(e,t){let n=e.charCodeAt(t);if(!op(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ip(r)?r-56320+(n-55296<<10)+65536:n}function ip(e){return e>=56320&&e<57344}function op(e){return e>=55296&&e<56320}function sp(e){return e<65536?1:2}class ap{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=gp(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),cp.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=gp(this,e,t);let n=[];return this.decompose(e,t,n,0),cp.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new dp(this),i=new dp(e);for(let e=t,o=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(o+=r.value.length,r.done||o>=n)return!0}}iter(e=1){return new dp(this,e)}iterRange(e,t=this.length){return new fp(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new pp(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new lp(e):cp.from(lp.split(e,[])):ap.empty}}class lp extends ap{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new mp(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new lp(up(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=hp(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new lp(t,e.length+i.length));else{let e=t.length>>1;n.push(new lp(t.slice(0,e)),new lp(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof lp))return super.replace(e,t,n);[e,t]=gp(this,e,t);let r=hp(this.text,hp(n.text,up(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new lp(r,i):cp.from(lp.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=gp(this,e,t);let r="";for(let i=0,o=0;i<=t&&o<this.text.length;o++){let s=this.text[o],a=i+s.length;i>e&&o&&(r+=n),e<a&&t>i&&(r+=s.slice(Math.max(0,e-i),t-i)),i=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new lp(n,r)),n=[],r=-1);return r>-1&&t.push(new lp(n,r)),t}}class cp extends ap{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}decompose(e,t,n,r){for(let i=0,o=0;o<=t&&i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e<=a&&t>=o){let i=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!i?n.push(s):s.decompose(e-o,t-o,n,i)}o=a+1}}replace(e,t,n){if([e,t]=gp(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let o=this.children[r],s=i+o.length;if(e>=i&&t<=s){let a=o.replace(e-i,t-i,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let i=this.children.slice();return i[r]=a,new cp(i,this.length-(t-e)+n.length)}return super.replace(i,s,a)}i=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=gp(this,e,t);let r="";for(let i=0,o=0;i<this.children.length&&o<=t;i++){let s=this.children[i],a=o+s.length;o>e&&i&&(r+=n),e<a&&t>o&&(r+=s.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof cp))return 0;let n=0,[r,i,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==o||i==s)return n;let a=this.children[r],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new lp(n,t)}let r=Math.max(32,n>>5),i=r<<1,o=r>>1,s=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>i&&e instanceof cp)for(let t of e.children)h(t);else e.lines>o&&(a>o||!a)?(u(),s.push(e)):e instanceof lp&&a&&(t=c[c.length-1])instanceof lp&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new lp(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>r&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(s.push(1==c.length?c[0]:cp.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==s.length?s[0]:new cp(s,t)}}function hp(e,t,n=0,r=1e9){for(let i=0,o=0,s=!0;o<e.length&&i<=r;o++){let a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function up(e,t,n){return hp(e,[""],t,n)}ap.empty=new lp([""],0);class dp{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof lp?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof lp?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof lp){let i=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[o+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof lp?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class fp{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new dp(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),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 pp{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(ap.prototype[Symbol.iterator]=function(){return this.iter()},dp.prototype[Symbol.iterator]=fp.prototype[Symbol.iterator]=pp.prototype[Symbol.iterator]=function(){return this});class mp{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function gp(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function vp(e,t,n=!0,r=!0){return ep(e,t,n,r)}function bp(e,t){let n=e.charCodeAt(t);if(!(r=n,r>=55296&&r<56320&&t+1!=e.length))return n;var r;let i=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(i)?i-56320+(n-55296<<10)+65536:n}function yp(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function wp(e){return e<65536?1:2}const xp=/\r\n?|\n/;var kp=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(kp||(kp={}));class Sp{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,i),r+=i):r+=o,n+=i}}iterChangedRanges(e,t=!1){Op(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new Sp(e)}composeDesc(e){return this.empty?e:e.empty?this:Tp(this,e)}mapDesc(e,t=!1){return e.empty?this:Ap(this,e,t)}mapPos(e,t=-1,n=kp.Simple){let r=0,i=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=r+s;if(a<0){if(l>e)return i+(e-r);i+=s}else{if(n!=kp.Simple&&l>=e&&(n==kp.TrackDel&&r<e&&l>e||n==kp.TrackBefore&&r<e||n==kp.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=r+this.sections[n++];if(this.sections[n++]>=0&&r<=t&&i>=e)return!(r<e&&i>t)||"cover";r=i}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Sp(e)}static create(e){return new Sp(e)}}class Ep extends Sp{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Op(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Ap(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let o=t[r],s=t[r+1];if(s>=0){t[r]=s,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(ap.empty);n.push(o?e.slice(i,i+o):ap.empty)}i+=o}return new Ep(t,n)}compose(e){return this.empty?e:e.empty?this:Tp(this,e,!0)}map(e,t=!1){return e.empty?this:Ap(this,e,t,!0)}iterChanges(e,t=!1){Op(this,e,t)}get desc(){return Sp.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new Mp(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==i.len;){if(i.done)break e;let e=Math.min(i.len,a-s);Cp(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;Cp(t,e,o),o>0&&Np(n,t,i.text),i.forward(e),s+=e}let l=e[o++];for(;s<l;){if(i.done)break e;let e=Math.min(i.len,l-s);Cp(t,e,-1),Cp(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new Ep(t,n),filtered:Sp.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],o=0,s=null;function a(e=!1){if(!e&&!r.length)return;o<t&&Cp(r,t-o,-1);let n=new Ep(r,i);s=s?s.compose(n.map(s)):n,r=[],i=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof Ep){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=c?"string"==typeof c?ap.of(c.split(n||xp)):c:ap.empty,u=h.length;if(e==s&&0==u)return;e<o&&a(),e>o&&Cp(r,e-o,-1),Cp(r,s-e,u),Np(i,r,h),o=s}}(e),a(!s),s}static empty(e){return new Ep(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else{if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(ap.empty);n[r]=ap.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new Ep(t,n)}static createSet(e,t){return new Ep(e,t)}}function Cp(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Np(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(ap.empty);e.push(n)}}function Op(e,t,n){let r=e.inserted;for(let i=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{let c=i,h=o,u=ap.empty;for(;c+=a,h+=l,l&&r&&(u=u.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,h,u),i=c,o=h}}}function Ap(e,t,n,r=!1){let i=[],o=r?[]:null,s=new Mp(e),a=new Mp(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);Cp(i,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(Cp(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(Cp(i,0,s.ins),o&&Np(o,i,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?Ep.createSet(i,o):Sp.create(i);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}Cp(i,t,e<s.i?s.ins:0),o&&e<s.i&&Np(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function Tp(e,t,n=!1){let r=[],i=n?[]:null,o=new Mp(e),s=new Mp(t);for(let e=!1;;){if(o.done&&s.done)return i?Ep.createSet(r,i):Sp.create(r);if(0==o.ins)Cp(r,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=r.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;Cp(r,t,n,e),i&&n&&Np(i,r,s.text)}else-1==s.ins?(Cp(r,o.off?0:o.len,t,e),i&&Np(i,r,o.textBit(t))):(Cp(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&Np(i,r,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||r.length>n),o.forward2(t),s.forward(t)}}else Cp(r,0,s.ins,e),i&&Np(i,r,s.text),s.next()}}class Mp{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ap.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ap.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Rp{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new Rp(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return Dp.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Dp.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Dp.range(e.anchor,e.head)}static create(e,t,n){return new Rp(e,t,n)}}class Dp{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:Dp.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new Dp([this.main],0)}addRange(e,t=!0){return Dp.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,Dp.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Dp(e.ranges.map(e=>Rp.fromJSON(e)),e.main)}static single(e,t=e){return new Dp([Dp.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return Dp.normalized(e.slice(),t);n=i.to}return new Dp(e,t)}static cursor(e,t=0,n,r){return Rp.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:16777215)<<6)}static range(e,t,n,r){let i=(null!=n?n:16777215)<<6|(null==r?7:Math.min(6,r));return t<e?Rp.create(t,e,48|i):Rp.create(e,t,(t>e?8:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let o=i.from,s=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?Dp.range(s,o):Dp.range(o,s))}}return new Dp(e,t)}}function Pp(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let Lp=0;class Bp{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Lp++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new Bp(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:Ip),!!e.static,e.enables)}of(e){return new _p([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _p(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _p(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function Ip(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class _p{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Lp++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||Fp(e,c)){let t=n(e);if(s?!jp(t,e.values[o],r):!r(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=em(t,l);if(this.dependencies.every(n=>n instanceof Bp?t.facet(n)===e.facet(n):!(n instanceof Hp)||t.field(n,!1)==e.field(n,!1))||(s?jp(a=n(e),i,r):r(a=n(e),i)))return e.values[o]=i,0}else a=n(e);return e.values[o]=a,1}}}}function jp(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Fp(e,t){let n=!1;for(let r of t)1&Zp(e,r)&&(n=!0);return n}function Wp(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),o=r.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<r.length;t++){let o=em(e,r[t]);if(2==i[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of r)Zp(e,t);return e.values[s]=a(e),1},update(e,n){if(!Fp(e,o))return 0;let r=a(e);return t.compare(r,e.values[s])?0:(e.values[s]=r,1)},reconfigure(e,i){let o=Fp(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&Ip(n,l))return e.values[s]=c,0;let h=a(e);return t.compare(h,c)?(e.values[s]=c,0):(e.values[s]=h,1)}}}const zp=Bp.define({static:!0});class Hp{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new Hp(Lp++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(zp).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r,i=e.facet(zp),o=n.facet(zp);return(r=i.find(e=>e.field==this))&&r!=o.find(e=>e.field==this)?(e.values[t]=r.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,zp.of({field:this,create:e})]}get extension(){return this}}const Vp=4,qp=3,Up=2,$p=1;function Kp(e){return t=>new Gp(t,e)}const Yp={highest:Kp(0),high:Kp($p),default:Kp(Up),low:Kp(qp),lowest:Kp(Vp)};class Gp{constructor(e,t){this.inner=e,this.prec=t}}class Xp{of(e){return new Jp(this,e)}reconfigure(e){return Xp.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Jp{constructor(e,t){this.compartment=e,this.inner=t}}class Qp{constructor(e,t,n,r,i,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],i=Object.create(null),o=new Map;for(let n of function(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(e,s){let a=i.get(e);if(null!=a){if(a<=s)return;let t=r[a].indexOf(e);t>-1&&r[a].splice(t,1),e instanceof Jp&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Jp){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),o(r,s)}else if(e instanceof Gp)o(e.inner,e.prec);else if(e instanceof Hp)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof _p)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Up);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,Up),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof Hp?r.push(n):(i[n.facet.id]||(i[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of r)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in i){let t=i[e],r=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[r.id]=a.length<<1|1,Ip(o,t))a.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));a.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[r.id]=l.length<<1,l.push(e=>Wp(e,r,t))}}let h=l.map(e=>e(s));return new Qp(e,o,h,s,a,i)}}function Zp(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function em(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const tm=Bp.define(),nm=Bp.define({combine:e=>e.some(e=>e),static:!0}),rm=Bp.define({combine:e=>e.length?e[0]:void 0,static:!0}),im=Bp.define(),om=Bp.define(),sm=Bp.define(),am=Bp.define({combine:e=>!!e.length&&e[0]});class lm{constructor(e,t){this.type=e,this.value=t}static define(){return new cm}}class cm{of(e){return new lm(this,e)}}class hm{constructor(e){this.map=e}of(e){return new um(this,e)}}class um{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new um(this.type,t)}is(e){return this.type==e}static define(e={}){return new hm(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}um.reconfigure=um.define(),um.appendConfig=um.define();class dm{constructor(e,t,n,r,i,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Pp(n,t.newLength),i.some(e=>e.type==dm.time)||(this.annotations=i.concat(dm.time.of(Date.now())))}static create(e,t,n,r,i,o){return new dm(e,t,n,r,i,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(dm.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function fm(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else{if(!(i<t.length))return n;o=t[i++],s=t[i++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function pm(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=Ep.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):null===(r=e.selection)||void 0===r?void 0:r.map(i),effects:um.mapEffects(e.effects,i).concat(um.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function mm(e,t,n){let r=t.selection,i=bm(t.annotations);return t.userEvent&&(i=i.concat(dm.userEvent.of(t.userEvent))),{changes:t.changes instanceof Ep?t.changes:Ep.of(t.changes||[],n,e.facet(rm)),selection:r&&(r instanceof Dp?r:Dp.single(r.anchor,r.head)),effects:bm(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function gm(e,t,n){let r=mm(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let i=1;i<t.length;i++){!1===t[i].filter&&(n=!1);let o=!!t[i].sequential;r=pm(r,mm(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=dm.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(sm),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=pm(r,mm(t,o,e.changes.newLength),!0))}return r==e?e:dm.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let r of t.facet(im)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:fm(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=Ep.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=dm.create(t,r,e.selection&&e.selection.map(i),um.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(om);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof dm?i:Array.isArray(i)&&1==i.length&&i[0]instanceof dm?i[0]:gm(t,bm(i),!1)}return e}(i):i)}dm.time=lm.define(),dm.userEvent=lm.define(),dm.addToHistory=lm.define(),dm.remote=lm.define();const vm=[];function bm(e){return null==e?vm:Array.isArray(e)?e:[e]}var ym=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(ym||(ym={}));const wm=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let xm;try{xm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function km(e){return t=>{if(!/\S/.test(t))return ym.Space;if(function(e){if(xm)return xm.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||wm.test(n)))return!0}return!1}(t))return ym.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ym.Word;return ym.Other}}class Sm{constructor(e,t,n,r,i,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Zp(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Zp(this,n),em(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return gm(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(Xp.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(um.reconfigure)?(n=null,r=t.value):t.is(um.appendConfig)&&(n=null,r=bm(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=Qp.resolve(r,i,this);let e=new Sm(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(nm)?e.newSelection:e.newSelection.asSingle();new Sm(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Dp.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=bm(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(l);let c=r.mapDesc(a,!0);i.push(s.range.map(c)),r=r.compose(l),o=um.mapEffects(o,l).concat(um.mapEffects(bm(s.effects),c))}return{changes:r,selection:Dp.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ep?e:Ep.of(e,this.doc.length,this.facet(Sm.lineSeparator))}toText(e){return ap.of(e.split(this.facet(Sm.lineSeparator)||xp))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(Zp(this,t),em(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Hp&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],o=e[t];r.push(i.init(e=>i.spec.fromJSON(o,e)))}return Sm.create({doc:e.doc,selection:Dp.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Qp.resolve(e.extensions||[],new Map),n=e.doc instanceof ap?e.doc:ap.of((e.doc||"").split(t.staticFacet(Sm.lineSeparator)||xp)),r=e.selection?e.selection instanceof Dp?e.selection:Dp.single(e.selection.anchor,e.selection.head):Dp.single(0);return Pp(r,n.length),t.staticFacet(nm)||(r=r.asSingle()),new Sm(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(Sm.tabSize)}get lineBreak(){return this.facet(Sm.lineSeparator)||"\n"}get readOnly(){return this.facet(am)}phrase(e,...t){for(let t of this.facet(Sm.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(tm))for(let o of i(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return km(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=vp(t,o,!1);if(i(t.slice(e,o))!=ym.Word)break;o=e}for(;s<r;){let e=vp(t,s);if(i(t.slice(s,e))!=ym.Word)break;s=e}return o==s?null:Dp.range(o+n,s+n)}}function Em(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],o=r[e];if(void 0===o)r[e]=i;else if(o===i||void 0===i);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);r[e]=n[e](o,i)}}for(let e in t)void 0===r[e]&&(r[e]=t[e]);return r}Sm.allowMultipleSelections=nm,Sm.tabSize=Bp.define({combine:e=>e.length?e[0]:4}),Sm.lineSeparator=rm,Sm.readOnly=am,Sm.phrases=Bp.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),Sm.languageData=tm,Sm.changeFilter=im,Sm.transactionFilter=om,Sm.transactionExtender=sm,Xp.reconfigure=um.define();class Cm{eq(e){return this==e}range(e,t=e){return Om.create(e,t,this)}}function Nm(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}Cm.prototype.startSide=Cm.prototype.endSide=0,Cm.prototype.point=!1,Cm.prototype.mapMode=kp.TrackDel;let Om=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function Am(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Tm{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let o=r,s=i.length;;){if(o==s)return o;let r=o+s>>1,a=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==o)return a>=0?o:s;a>=0?s=r:o=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);i<o;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),r.push(l-o),i.push(c-o))}return{mapped:n.length?new Tm(r,i,n,s):null,pos:o}}}class Mm{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new Mm(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(Am)),this.isEmpty)return t.length?Mm.of(t):this;let s=new Pm(this,null,-1).goto(0),a=0,l=[],c=new Rm;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(s.chunkIndex)||i<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||r>s.to||i<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(Om.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?Mm.empty:this.nextLayer.update({add:l,filter:o,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],s=this.chunk[i],a=e.touchesRange(o,o+s.length);if(!1===a)r=Math.max(r,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:i,pos:a}=s.map(o,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(a))}}let i=this.nextLayer.map(e);return 0==t.length?i:new Mm(n,t,i||Mm.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],o=this.chunk[r];if(t>=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return Lm.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Lm.from(e).goto(t)}static compare(e,t,n,r,i=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),a=Dm(o,s,n),l=new Im(o,a,i),c=new Im(s,a,i);n.iterGaps((e,t,n)=>_m(l,e,c,t,n,r)),n.empty&&0==n.length&&_m(l,0,c,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=999999999);let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=o.length)return!1;if(!i.length)return!0;let s=Dm(i,o),a=new Im(i,s,0).goto(n),l=new Im(o,s,0).goto(n);for(;;){if(a.to!=l.to||!jm(a.active,l.active)||a.point&&(!l.point||!Nm(a.point,l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}static spans(e,t,n,r,i=-1){let o=new Im(e,null,i).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),i=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);r.point(s,e,o.point,n,i,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(r.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new Rm;for(let r of e instanceof Om?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(Am(t,r)>0)return e.slice().sort(Am);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return Mm.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=Mm.empty;r=r.nextLayer)t=new Mm(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}Mm.empty=new Mm([],[],null,-1),Mm.empty.nextLayer=Mm.empty;class Rm{finishChunk(e){this.chunks.push(new Tm(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Rm)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(Mm.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Mm.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Dm(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=r.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||i.add(e.chunk[t])}return i}class Pm{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Lm{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let o=e[i];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new Pm(o,t,n,i));return 1==r.length?r[0]:new Lm(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Bm(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Bm(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)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(),Bm(this.heap,0)}}}function Bm(e,t){for(let n=e[t];;){let r=1+(t<<1);if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class Im{constructor(e,t,n){this.minPoint=n,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=Lm.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Fm(this.active,e),Fm(this.activeTo,e),Fm(this.activeRank,e),this.minActive=zm(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Wm(this.active,t,n),Wm(this.activeTo,t,r),Wm(this.activeRank,t,i),e&&Wm(e,t,this.cursor.from),this.minActive=zm(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Fm(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function _m(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t,c=!!o.boundChange;for(let t=!1;;){let r=e.to+l-n.to,i=r||e.endSide-n.endSide,h=i<0?e.to+l:n.to,u=Math.min(h,s);if(e.point||n.point?(e.point&&n.point&&Nm(e.point,n.point)&&jm(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,u,e.point,n.point),t=!1):(t&&o.boundChange(a),u>a&&!jm(e.active,n.active)&&o.compareRange(a,u,e.active,n.active),c&&u<s&&(r||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>s)break;a=h,i<=0&&e.next(),i>=0&&n.next()}}function jm(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!Nm(e[n],t[n]))return!1;return!0}function Fm(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Wm(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function zm(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Hm(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=vp(e,i));return r}function Vm(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=9==e.charCodeAt(r)?n-i%n:1,r=vp(e,r)}return!0===r?-1:e.length}const qm="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Um="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),$m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Km{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=$m[qm]||1;return $m[qm]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[Um],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Gm(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let Ym=new Map;class Gm{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Ym.get(n);if(t)return e[Um]=t;this.sheet=new r.CSSStyleSheet,Ym.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Um]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Xm={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Jm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Qm="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zm="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),eg=0;eg<10;eg++)Xm[48+eg]=Xm[96+eg]=String(eg);for(eg=1;eg<=24;eg++)Xm[eg+111]="F"+eg;for(eg=65;eg<=90;eg++)Xm[eg]=String.fromCharCode(eg+32),Jm[eg]=String.fromCharCode(eg);for(var tg in Xm)Jm.hasOwnProperty(tg)||(Jm[tg]=Xm[tg]);function ng(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)rg(e,arguments[t]);return e}function rg(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)rg(e,t[n])}}let ig="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},og="undefined"!=typeof document?document:{documentElement:{style:{}}};const sg=/Edge\/(\d+)/.exec(ig.userAgent),ag=/MSIE \d/.test(ig.userAgent),lg=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ig.userAgent),cg=!!(ag||lg||sg),hg=!cg&&/gecko\/(\d+)/i.test(ig.userAgent),ug=!cg&&/Chrome\/(\d+)/.exec(ig.userAgent),dg="webkitFontSmoothing"in og.documentElement.style,fg=!cg&&/Apple Computer/.test(ig.vendor),pg=fg&&(/Mobile\/\w+/.test(ig.userAgent)||ig.maxTouchPoints>2);var mg={mac:pg||/Mac/.test(ig.platform),windows:/Win/.test(ig.platform),linux:/Linux|X11/.test(ig.platform),ie:cg,ie_version:ag?og.documentMode||6:lg?+lg[1]:sg?+sg[1]:0,gecko:hg,gecko_version:hg?+(/Firefox\/(\d+)/.exec(ig.userAgent)||[0,0])[1]:0,chrome:!!ug,chrome_version:ug?+ug[1]:0,ios:pg,android:/Android\b/.test(ig.userAgent),webkit:dg,webkit_version:dg?+(/\bAppleWebKit\/(\d+)/.exec(ig.userAgent)||[0,0])[1]:0,safari:fg,safari_version:fg?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ig.userAgent)||[0,0])[1]:0,tabSize:null!=og.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function gg(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const vg=Object.create(null);function bg(e,t,n){if(e==t)return!0;e||(e=vg),t||(t=vg);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let o of r)if(o!=n&&(-1==i.indexOf(o)||e[o]!==t[o]))return!1;return!0}function yg(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,"style"==i?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function wg(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}class xg{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var kg=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(kg||(kg={}));class Sg extends Cm{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Eg(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Ng(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:i,end:o}=Og(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new Ng(e,t,n,r,e.widget||null,!0)}static line(e){return new Cg(e)}static set(e,t=!1){return Mm.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Sg.none=Mm.empty;class Eg extends Sg{constructor(e){let{start:t,end:n}=Og(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?gg(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||vg}eq(e){return this==e||e instanceof Eg&&this.tagName==e.tagName&&bg(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Eg.prototype.point=!1;class Cg extends Sg{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Cg&&this.spec.class==e.spec.class&&bg(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Cg.prototype.mapMode=kp.TrackBefore,Cg.prototype.point=!0;class Ng extends Sg{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?kp.TrackBefore:kp.TrackAfter:kp.TrackDel}get type(){return this.startSide!=this.endSide?kg.WidgetRange:this.startSide<=0?kg.WidgetBefore:kg.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ng&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function Og(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!=n?n:t,end:null!=r?r:t}}function Ag(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}Ng.prototype.point=!0;class Tg extends Cm{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof Tg&&this.tagName==e.tagName&&bg(this.attributes,e.attributes)}static create(e){return new Tg(e.tagName,e.attributes||vg)}static set(e,t=!1){return Mm.of(e,t)}}function Mg(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Rg(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function Dg(e,t){if(!t.anchorNode)return!1;try{return Rg(e,t.anchorNode)}catch(e){return!1}}function Pg(e){return 3==e.nodeType?$g(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Lg(e,t,n,r){return!!n&&(_g(e,t,n,r,-1)||_g(e,t,n,r,1))}function Bg(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function Ig(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function _g(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:jg(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Bg(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?jg(e):0}}}function jg(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Fg(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Wg(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function zg(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}Tg.prototype.startSide=Tg.prototype.endSide=-1;class Hg{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?jg(t):0),n,Math.min(e.focusOffset,n?jg(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Vg,qg=null;function Ug(e){if(e.setActive)return e.setActive();if(qg)return e.focus(qg);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==qg?{get preventScroll(){return qg={preventScroll:!0},!0}}:void 0),!qg){qg=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}function $g(e,t,n=t){let r=Vg||(Vg=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Kg(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function Yg(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Gg(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r>0)return{node:n,offset:r};if(1==n.nodeType&&r>0){if("false"==n.contentEditable)return null;n=n.childNodes[r-1],r=jg(n)}else{if(!n.parentNode||Ig(n))return null;r=Bg(n),n=n.parentNode}}}function Xg(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r<n.nodeValue.length)return{node:n,offset:r};if(1==n.nodeType&&r<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[r],r=0}else{if(!n.parentNode||Ig(n))return null;r=Bg(n)+1,n=n.parentNode}}}mg.safari&&mg.safari_version>=26&&(qg=!1);class Jg{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Jg(e.parentNode,Bg(e),t)}static after(e,t){return new Jg(e.parentNode,Bg(e)+1,t)}}var Qg=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Qg||(Qg={}));const Zg=Qg.LTR,ev=Qg.RTL;function tv(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const nv=tv("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),rv=tv("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),iv=Object.create(null),ov=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);iv[t]=n,iv[n]=-t}function sv(e){return e<=247?nv[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?rv[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const av=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class lv{get dir(){return this.level%2?ev:Zg}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}function cv(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!cv(r.inner,i.inner))return!1}return!0}const hv=[];function uv(e,t,n,r,i,o,s){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==o.length||l<o[c].from){let e=hv[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?r:r+1,f=l;e:for(;;)if(c<o.length&&f==o[c].from){if(h)break e;let p=o[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(hv[e]==a)break e;break}e=o[t++].to}if(c++,u)u.push(p);else{p.from>l&&s.push(new lv(l,p.from,d)),dv(e,p.direction==Zg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}f=p.to}else{if(f==n||(t?hv[f]!=a:hv[f]==a))break;f++}u?uv(e,l,f,r+1,i,u,s):l<f&&s.push(new lv(l,f,d)),l=f}else for(let l=n,c=o.length;l>t;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=hv[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?r:r+1,f=l;e:for(;;)if(c&&f==o[c-1].to){if(h)break e;let p=o[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(hv[e-1]==a)break e;break}e=o[--n].from}if(u)u.push(p);else{p.to<l&&s.push(new lv(p.to,l,d)),dv(e,p.direction==Zg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}f=p.from}else{if(f==t||(n?hv[f-1]!=a:hv[f-1]==a))break;f--}u?uv(e,f,l,r+1,i,u,s):f<l&&s.push(new lv(f,l,d)),l=f}}function dv(e,t,n,r,i,o,s){let a=t%2?2:1;!function(e,t,n,r,i){for(let o=0;o<=r.length;o++){let s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i;for(let t=s,n=l,r=l;t<a;t++){let i=sv(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),hv[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=hv[e];if(128==i)e<a-1&&t==hv[e+1]&&24&t?i=hv[e]=t:hv[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==hv[i];)i++;let o=e&&8==t||i<n&&8==hv[i]?1==r?1:8:256;for(let t=e;t<i;t++)hv[t]=o;e=i-1}else 8==i&&1==r&&(hv[e]=1);t=i,7&i&&(r=i)}}}(e,i,o,r,a),function(e,t,n,r,i){let o=1==i?2:1;for(let s=0,a=0,l=0;s<=r.length;s++){let c=s?r[s-1].to:t,h=s<r.length?r[s].from:n;for(let t,n,r,s=c;s<h;s++)if(n=iv[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(ov[e+1]==-n){let t=ov[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(hv[s]=hv[ov[e]]=n),a=e;break}}else{if(189==ov.length)break;ov[a++]=s,ov[a++]=t,ov[a++]=l}else if(2==(r=hv[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=ov[t+2];if(2&n)break;if(e)ov[t+2]|=2;else{if(4&n)break;ov[t+2]|=4}}}}}(e,i,o,r,a),function(e,t,n,r){for(let i=0,o=r;i<=n.length;i++){let s=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=s;l<a;){let s=hv[l];if(256==s){let s=l+1;for(;;)if(s==a){if(i==n.length)break;s=n[i++].to,a=i<n.length?n[i].from:t}else{if(256!=hv[s])break;s++}let c=1==o,h=c==(1==(s<t?hv[s]:r))?c?1:2:r;for(let t=s,r=i,o=r?n[r-1].to:e;t>l;)t==o&&(t=n[--r].from,o=r?n[r-1].to:e),hv[--t]=h;l=s}else o=s,l++}}}(i,o,r,a),uv(e,i,o,t,n,r,s)}function fv(e){return[new lv(0,e,0)]}let pv="";function mv(e,t,n,r,i){var o;let s=r.head-e.from,a=lv.find(t,s,null!==(o=r.bidiLevel)&&void 0!==o?o:-1,r.assoc),l=t[a],c=l.side(i,n);if(s==c){let e=a+=i?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!i,n),c=l.side(i,n)}let h=vp(e.text,s,l.forward(i,n));(h<l.from||h>l.to)&&(h=c),pv=e.text.slice(Math.min(s,h),Math.max(s,h));let u=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return u&&h==c&&u.level+(i?0:1)<l.level?Dp.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):Dp.cursor(h+e.from,l.forward(i,n)?-1:1,l.level)}function gv(e,t,n){for(let r=t;r<n;r++){let t=sv(e.charCodeAt(r));if(1==t)return Zg;if(2==t||4==t)return ev}return Zg}const vv=Bp.define(),bv=Bp.define(),yv=Bp.define(),wv=Bp.define(),xv=Bp.define(),kv=Bp.define(),Sv=Bp.define(),Ev=Bp.define(),Cv=Bp.define(),Nv=Bp.define({combine:e=>e.some(e=>e)}),Ov=Bp.define({combine:e=>e.some(e=>e)}),Av=Bp.define();class Tv{constructor(e,t="nearest",n="nearest",r=5,i=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=o}map(e){return e.empty?this:new Tv(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 Tv(Dp.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Mv=um.define({map:(e,t)=>e.map(t)}),Rv=um.define();function Dv(e,t,n){let r=e.facet(wv);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const Pv=Bp.define({combine:e=>!e.length||e[0]});let Lv=0;const Bv=Bp.define({combine:e=>e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})});class Iv{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Bv.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Bv.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new Iv(Lv++,e,n,r,e=>{let t=[];return o&&t.push(Wv.of(t=>{let n=t.plugin(e);return n?o(n):Sg.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return Iv.define((t,n)=>new e(t,n),t)}}class _v{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 e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Dv(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Dv(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Dv(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jv=Bp.define(),Fv=Bp.define(),Wv=Bp.define(),zv=Bp.define(),Hv=Bp.define(),Vv=Bp.define(),qv=Bp.define();function Uv(e,t){let n=e.state.facet(qv);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return Mm.spans(r,t.from,t.to,{point(){},span(e,n,r,o){let s=e-t.from,a=n-t.from,l=i;for(let e=r.length-1;e>=0;e--,o--){let n,i=r[e].spec.bidiIsolate;if(null==i&&(i=gv(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==i)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:i,inner:[]};l.push(e),l=e.inner}}}}),i}const $v=Bp.define();function Kv(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet($v)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(r=Math.max(r,s.top)),null!=s.bottom&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}const Yv=Bp.define();class Gv{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new Gv(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let r=0,i=0,o=0;;){let s=r<e.length?e[r].fromB:1e9,a=i<t.length?t[i]:1e9,l=Math.min(s,a);if(1e9==l)break;let c=l+o,h=l,u=c;for(;;)if(i<t.length&&t[i]<=h){let n=t[i+1];i+=2,h=Math.max(h,n);for(let t=r;t<e.length&&e[t].fromB<=h;t++)o=e[t].toA-e[t].toB;u=Math.max(u,n+o)}else{if(!(r<e.length&&e[r].fromB<=h))break;{let t=e[r++];h=Math.max(h,t.toB),u=Math.max(u,t.toA),o=t.toA-t.toB}}n.push(new Gv(c,u,l,h))}return n}}class Xv{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ep.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new Gv(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new Xv(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const Jv=[];class Qv{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Jv}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,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;null==t[r]&&e.removeAttribute(r)}for(let n in t){let r=t[n];"style"==n?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Bg(this.dom),r=this.length?e>0:t>0;return new Jg(this.parent.dom,n+(r?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof tb)return e;return null}static get(e){return e.cmTile}}class Zv extends Qv{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(2&this.flags)return;super.sync(e);let t,n=this.dom,r=null,i=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=r?r.nextSibling:n.firstChild,i&&t!=s.dom&&(i.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=eb(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=eb(t);this.length=o}}function eb(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class tb extends Zv{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Qv.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let o=n.children[r++];if(o instanceof nb)t.push(r),n=o,r=0;else{let t=i+o.length,n=e(o,i);if(void 0!==n)return n;i=t+o.breakAfter}}}resolveBlock(e,t){let n,r,i=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,i=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!r||!s.isWidget()&&r.isWidget())&&(r=s,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:i}:{tile:r,offset:o}}}class nb extends Zv{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new nb(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class rb extends Zv{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new rb(t||document.createElement("div"),e);return t&&n||(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,o=null,s=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let u=a.children[c],d=h+u.length;d>=l&&(u.isComposite()?e(u,l-h):(!o||o.isHidden&&(t>0||n&&ib(o,u)))&&(d>l||32&u.flags)?(o=u,s=l-h):(h<l||16&u.flags&&!u.isHidden)&&(r=u,i=l-h)),h=d}}(this,e);let a=(t<0?r:o)||r||o;return a?{tile:a,offset:a==r?i:s}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Pg(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Jg(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,16&e.flags?1:32&e.flags?-1:t);let i=n.tile.parent,o=!1;for(let e of i.children){if(o)return new Jg(e.dom,0);e==n.tile&&(o=!0)}}return new Jg(this.dom,0)}}function ib(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class ob extends Zv{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new ob(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class sb extends Qv{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,o=0;0==e&&t<0||e==n&&t>=0?mg.chrome||mg.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=$g(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return mg.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?Fg(a,o<0):a||null}static of(e,t){let n=new sb(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class ab extends Qv{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Fg(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?0==i:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return Fg(n,!r)}}get overrideDOMText(){if(!this.length)return ap.empty;let{root:e}=this;if(!e)return ap.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,i){return i||(i=e.toDOM(t),e.editable||(i.contentEditable="false")),new ab(i,n,e,r)}}class lb extends Qv{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ap.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class cb{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++}else{let a=r.children[i],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(s.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a)):(o=!!l,i++,e-=a.length)}else if(i==r.length)o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++;else{if(!e)break;{let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}}return this.tile=r,this.index=i,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class hb{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class ub{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var i;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(!s||!s.isText()||8&s.flags)o.append(r||sb.of(e,null===(i=this.cache.find(sb))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new sb(s.dom,s.text+e)).parent=o}this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?bb(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof ob&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(bb(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=Qv.get(n.dom);e&&e.setDOM(bb(n.dom))}let e=ob.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=Qv.get(e.text);i&&this.cache.reused.set(i,2);let o=new sb(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);r||this.flushBuffer();let i=this.ensureMarks(t,n);r||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).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){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=vb);let r=rb.start(e,t||(null===(n=this.cache.find(rb))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let o,s=e[i];if(t>0&&(o=r.lastChild)&&o instanceof ob&&o.mark.eq(s))r=o,t--;else{let e=ob.of(s,null===(n=this.cache.find(ob,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);r.append(e),r=e,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&gb(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||mg.ios&&gb(this.curLine,!0))||this.curLine.append(this.cache.findWidget(wb,0,32)||new ab(wb.toDOM(),0,wb,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new hb(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof nb&&r.wrapper.eq(n.wrapper))t=r;else{let r=nb.of(n.wrapper,null===(e=this.cache.find(nb,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(lb,void 0,1);return n&&(n.flags=t),n||new lb(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class db{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:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw new Error("Ran out of text content when drawing inline views");this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const fb=[ab,rb,sb,ob,lb,nb,tb];for(let e=0;e<fb.length;e++)fb[e].bucket=e;class pb{constructor(e){this.view=e,this.buckets=fb.map(()=>[]),this.index=fb.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],o=this.index[r];for(let e=i.length-1;e>=0;e--){let s=(e+o)%i.length,a=i[s];if((!t||t(a))&&!this.reused.has(a))return i.splice(s,1),s<o&&this.index[r]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}let s=r[i];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new ab(s.dom,t,e,-498&s.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class mb{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new pb(e),this.text=new db(e.state.doc),this.builder=new ub(this.cache,new tb(e,e.contentDOM),Mm.iter(n)),this.cache.reused.set(t,2),this.old=new cb(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){let e=a-r;this.preserve(e,!o,!s),r=a,i+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof ob&&t.push(r.mark)}return t}(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t<e.length?ab.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&o.flags?(o.flags&=-2,this.builder.addBlockWidget(o)):(this.builder.ensureLine(null),this.builder.addInlineWidget(o,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)):this.builder.addText(e.text,r,i,this.cache.reuse(e)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof lb)this.cache.add(e);else{if(!(e instanceof ob))return!1;this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof ob&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof ob&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,o=Mm.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof Ng){if(this.disallowBlockEffectsFor[l]){if(o.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=s.length,a>s.length)r.continueWidget(t-e);else{let i=o.widget||(o.block?yb.block:yb.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(o),c=this.cache.findWidget(i,t-e,l)||ab.of(i,this.view,t-e,l);o.block?(o.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(c)):(r.ensureLine(n),r.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,r=t.spec.class;if(!n&&!r)return e;e||(e={class:"cm-line"});n&&gg(n,e);r&&(e.class+=" "+r);return e}(n,o);t>e&&this.text.skip(t-e)},span:(e,t,i,o)=>{for(let s=e;s<t;){let e=this.text.next(Math.min(512,t-s));null==e?(r.addLineStartIfNotCovered(n),r.addBreak(),s++):(r.ensureLine(n),r.addText(e,i,o),s+=e.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>i,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=Qv.get(r);if(r==this.view.contentDOM)break;e instanceof ob?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(ob.of(new Eg({tagName:r.nodeName.toLowerCase(),attributes:wg(r)}),r)):n=new rb(r,vb)}return{line:n,marks:t}}}function gb(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}const vb={class:"cm-line"};function bb(e){let t=Qv.get(e);return t&&t.setDOM(e.cloneNode()),e}class yb extends xg{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}}yb.inline=new yb("span"),yb.block=new yb("div");const wb=new class extends xg{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class xb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Sg.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 tb(e,e.contentDOM),this.updateInner([new Gv(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?r=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(r=e.state.selection.main.head));let i=r>-1?function(e,t,n){let r=Sb(e,n);if(!r)return null;let{node:i,from:o,to:s}=r,a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new Gv(l.mapPos(o),l.mapPos(s),o,s),text:i}}(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:r}=this.hasComposition;n=new Gv(t,r,e.changes.mapPos(t,-1),e.changes.mapPos(r,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(mg.ie||mg.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let r=new Eb;return Mm.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=Gv.extendWithRanges(n,a));let l=function(e,t,n){let r=new Cb;return Mm.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=Gv.extendWithRanges(n,l)),i&&!n.some(e=>e.fromA<=i.range.fromA&&e.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new mb(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=r.run(e,t),kb(n,r.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 r=mg.chrome||mg.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),!r||!r.written&&n.selectionRange.focusNode==r.node&&this.tile.dom.contains(r.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof Nb&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(Rv)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(Pv)||n.tabIndex>-1)&&Dg(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),mg.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new Jg(e,0),s=!0}var h;let u=this.view.observer.selectionRange;!s&&u.focusNode&&(Lg(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Lg(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{mg.android&&mg.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=Mg(this.view.root);if(e)if(c.empty){if(mg.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?Gg:Xg)(a.node,a.offset);t&&(a=new Jg(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Jg(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Jg(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Lg(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Mg(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let r=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r;{let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=0==jg(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==r&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!Qv.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r,i=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,i=e-l,o=c<e),c>=e&&!r&&(r=t,s=e-l,a=l>e),l>e&&r)return!0}}),n||r?(o&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(i,t):r.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Nb?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let r of t.children){if(r.length>=n){let t=e(r,n);if(t)return t}if((n-=r.length)<0)break}else if(t.isText()&&n<t.length){let e=vp(t.text,n);if(e==n)return null;let r=$g(t.dom,n,e).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,o=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==Qg.LTR,l=0,c=(e,h,u)=>{for(let d=0;d<e.children.length&&!(h>r);d++){let r=e.children[d],f=h+r.length,p=r.dom.getBoundingClientRect(),{height:m}=p;if(u&&!d&&(l+=p.top-u.top),r instanceof nb)f>n&&c(r,h,p);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,o)){let e=r.dom.lastChild,t=e?Pg(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>s&&(s=n,this.minWidth=i,this.minWidthFrom=h,this.minWidthTo=f)}}u&&d==e.children.length-1&&(l+=u.bottom-p.bottom),h=f+r.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?Qg.RTL:Qg.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=Pg(r.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,r,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let e=Pg(i.firstChild)[0];t=i.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:t,i.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){let r=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Sg.replace({widget:new Nb(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return Sg.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Wv).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(Hv).map((e,t)=>{let r="function"==typeof e;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(Mm.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(zv).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(Av))try{if(t(this.view,e.range,e))return!0}catch(e){Dv(this.view.state,e,"scroll handler")}let t,{range:n}=e,r=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!r)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,t.left),top:Math.min(r.top,t.top),right:Math.max(r.right,t.right),bottom:Math.max(r.bottom,t.bottom)});let i=Kv(this.view),o={left:r.left-i.left,top:r.top-i.top,right:r.right+i.right,bottom:r.bottom+i.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,r,i,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,f=1,p=1;if(d)e=Wg(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:f,scaleY:p}=zg(h,t)),e={left:t.left,right:t.left+h.clientWidth*f,top:t.top,bottom:t.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==i)t.top<e.top?(g=t.top-(e.top+s),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+s)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+s,n<0&&t.top-g<e.top&&(g=t.top-(e.top+s)));else{let r=t.bottom-t.top,o=e.bottom-e.top;g=("center"==i&&r<=o?t.top+r/2-o/2:"start"==i||"center"==i&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==r?t.left<e.left?(m=t.left-(e.left+o),n>0&&t.right>e.right+m&&(m=t.right-e.right+o)):t.right>e.right&&(m=t.right-e.right+o,n<0&&t.left<e.left+m&&(m=t.left-(e.left+o))):m=("center"==r?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==r==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,m||g)if(d)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=h.scrollTop;h.scrollTop+=g/p,n=(h.scrollTop-e)*p}if(m){let t=h.scrollLeft;h.scrollLeft+=m/f,e=(h.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(r="nearest"),n&&Math.abs(n-g)<1&&(i="nearest")}if(d)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Qg.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){kb(this.tile)}}function kb(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)kb(n,t)}}function Sb(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Gg(n.focusNode,n.focusOffset),i=Xg(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=Qv.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=Qv.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let Eb=class{constructor(){this.changes=[]}compareRange(e,t){Ag(e,t,this.changes)}comparePoint(e,t){Ag(e,t,this.changes)}boundChange(e){Ag(e,e,this.changes)}};class Cb{constructor(){this.changes=[]}compareRange(e,t){Ag(e,t,this.changes)}comparePoint(){}boundChange(e){Ag(e,e,this.changes)}}class Nb extends xg{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 Ob(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;e&&(i.type!=kg.Text||e.type==i.type&&!(n<0?i.from<t:i.to>t))||(e=i)}}return e||r}return r}function Ab(e,t,n,r){let i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from);for(let a=t,l=null;;){let t=mv(i,o,s,a,n),c=pv;if(!t){if(i.number==(n?e.state.doc.lines:1))return a;c="\n",i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!r)return t;l=r(c)}a=t}}function Tb(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,o)=>{if(t>e&&t<i){let o=r||n||(t-e<i-t?-1:1);t=o<0?e:i,r=o}});if(!r)return t}}function Mb(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],o=null;if(i.empty){let t=Tb(e,i.from,0);t!=i.from&&(o=Dp.cursor(t,-1))}else{let t=Tb(e,i.from,-1),n=Tb(e,i.to,1);t==i.from&&n==i.to||(o=Dp.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?Dp.create(n,t.mainIndex):t}function Rb(e,t,n){let r=Tb(e.state.facet(Vv).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:Dp.cursor(r,r<n.from?1:-1)}class Db{constructor(e,t){this.pos=e,this.assoc=t}}function Pb(e,t,n,r){let i,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-s;for(;;){if(c<0)return new Db(0,1);if(c>e.viewState.docHeight)return new Db(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==kg.Text){let t=e.docView.coordsAt(r<0?i.from:i.to,r);if(t&&(r<0?t.top<=c+s:t.bottom>=c+s))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?i.bottom+t:i.top-t}if(e.viewport.from>=i.to||e.viewport.to<=i.from){if(n)return null;if(i.type==kg.Text){let t=function(e,t,n,r,i){let o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((i-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+Vm(s,o,e.state.tabSize)}(e,o,i,a,l);return new Db(t,t==i.from?1:-1)}}if(i.type!=kg.Text)return c<(i.top+i.bottom)/2?new Db(i.from,1):new Db(i.to,-1);let h=e.docView.lineAt(i.from,2);return h&&h.length==i.length||(h=e.docView.lineAt(i.from,-2)),Lb(e,h,i.from,a,l)}function Lb(e,t,n,r,i){let o=-1,s=null,a=1e9,l=1e9,c=i,h=i,u=(e,t)=>{for(let n=0;n<e.length;n++){let u=e[n];if(u.top==u.bottom)continue;let d=u.left>r?u.left-r:u.right<r?r-u.right:0,f=u.top>i?u.top-i:u.bottom<i?i-u.bottom:0;u.top<=h&&u.bottom>=c&&(c=Math.min(u.top,c),h=Math.max(u.bottom,h),f=0),(o<0||(f-l||d-a)<0)&&(o>=0&&l&&a<d&&s.top<=h-2&&s.bottom>=c+2?l=0:(o=t,a=d,l=f,s=u))}};if(t.isText()){for(let e=0;e<t.length;){let n=vp(t.text,e);if(u($g(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(Bb(e,o+n)==Qg.LTR)?new Db(n+vp(t.text,o),-1):new Db(n+o,1)}{if(!t.length)return new Db(n,1);for(let e=0;e<t.children.length;e++){let n=t.children[e];if(!(48&n.flags)&&(u((1==n.dom.nodeType?n.dom:$g(n.dom,0,n.length)).getClientRects(),e),!a&&!l))break}let c=t.children[o],h=t.posBefore(c,n);return c.isComposite()||c.isText()?Lb(e,c,h,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(Bb(e,o+n)==Qg.LTR)?new Db(h+c.length,-1):new Db(h,1)}}function Bb(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[lv.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const Ib="";class _b{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Sm.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ib}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=Qv.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=Qv.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:Ig(r))||Ig(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!Fb(o,t)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(i=r.exec(t))&&(o=i.index,s=i[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=Qv.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(jb(e,n.node,n.offset)?t:0))}}function jb(e,t,n){for(;;){if(!t||n<jg(t))return!1;if(t==e)return!0;n=Bg(t)+1,t=t.parentNode}}function Fb(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=Qv.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class Wb{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class zb{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Hb(e.docView.tile,t,n,0))){let t=i||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new Wb(n,r)),i==n&&o==r||t.push(new Wb(i,o)));return t}(e),n=new _b(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?Dp.single(n+t,r+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!Rg(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!Rg(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((mg.ios||mg.chrome)&&e.state.selection.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),o=s.from-t,a=s.to-i;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&i!=e.state.doc.length||(n=0,r=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(Dp.range(r,n)):this.newSel=Dp.single(r,n)}}}function Hb(e,t,n,r){if(e.isComposite()){let i=-1,o=-1,s=-1,a=-1;for(let l=0,c=r,h=r;l<e.children.length;l++){let r=e.children[l],u=c+r.length;if(c<t&&u>n)return Hb(r,t,n,c);if(u>=t&&-1==i&&(i=l,o=c),c>n&&r.dom.parentNode==e.dom){s=l,a=h;break}h=u,c=u+r.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Vb(e,t){let n,{newSel:r}=t,i=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:r,to:s}=t.bounds,a=i.from,l=null;(8===o||mg.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=Ub(e.state.doc.sliceString(r,s,Ib),t.text,a-r,l);c&&(mg.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==Ib+Ib&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:ap.of(t.text.slice(c.from,c.toB).split(Ib))})}else r&&(!e.hasFocus&&e.state.facet(Pv)||$b(r,i))&&(r=null);if(!n&&!r)return!1;if(!n&&t.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,i.to)}:(mg.mac||mg.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=Dp.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:ap.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,i.to))}:e.state.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:e.state.toText(e.inputState.insertingText)}:mg.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=Dp.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:ap.of([" "])}),n)return qb(e,n,r,o);if(r&&!$b(r,i)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(r=Mb(e.state.facet(Vv).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function qb(e,t,n,r=-1){if(mg.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(mg.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&" "==e.state.sliceDoc(t.from,i.from))&&1==t.insert.length&&2==t.insert.lines&&Kg(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>i.head)&&Kg(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&Kg(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let n=t.from<o.from?-1:1,r=n<0?o.from:o.to,a=Tb(i.facet(Vv).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:Dp.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?i.sliceDoc(o.from,t.from):"",s=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=i.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&Sb(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(o.head);let u=o.to-t.to;r=i.changeByRange(n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let r=n.to-u,h=r-c.length;if(e.state.sliceDoc(h,r)!=c||r>=l.from&&h<=l.to)return{range:n};let d=i.changes({from:h,to:r,insert:t.insert}),f=n.to-o.to;return{changes:d,range:a?Dp.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(d)}})}else r={changes:s,selection:a&&i.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return i.update(r,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(kv).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function Ub(e,t,n,r){let i=Math.min(e.length,t.length),o=0;for(;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==r){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function $b(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Kb{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,mg.safari&&e.contentDOM.addEventListener("input",()=>null),mg.gecko&&function(e){vy.has(e)||(vy.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,r=t.target;r!=e.contentDOM;r=r.parentNode)if(!r||11==r.nodeType||(n=Qv.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Gb(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if("scroll"!=e){let i=!t[e].handlers.length,o=n[e];o&&i!=!o.handlers.length&&(r.removeEventListener(e,this.handleEvent),o=null),o||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)"scroll"==e||t[e]||r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&Qb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),mg.android&&mg.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!mg.ios||e.synthetic||e.altKey||e.metaKey||!((t=Xb.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Jb.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Kg(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(mg.safari&&!mg.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}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 Yb(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){Dv(n.state,e)}}}function Gb(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(Yb(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(Yb(t.value,r))}}for(let e in ty)n(e).handlers.push(ty[e]);for(let e in ny)n(e).observers.push(ny[e]);return t}const Xb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Jb="dthko",Qb=[16,17,18,20,91,92,224,225];function Zb(e){return.7*Math.max(0,e)+8}class ey{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,r=e.ownerDocument;for(let i=e.parentNode;i&&!(i==r.body||t&&n);)if(1==i.nodeType)!n&&i.scrollHeight>i.clientHeight&&(n=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(Vv).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Sm.allowMultipleSelections)&&function(e,t){let n=e.state.facet(vv);return n.length?n[0](t):mg.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Mg(e.root);if(!r||0==r.rangeCount)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=uy(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let r=0,i=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Kv(this.view);e.clientX-c.left<=o+6?r=-Zb(o-e.clientX):e.clientX+c.right>=a-6&&(r=Zb(e.clientX-a)),e.clientY-c.top<=s+6?i=-Zb(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=Zb(e.clientY-l)),this.setScrollSpeed(r,i)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=Mb(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const ty=Object.create(null),ny=Object.create(null),ry=mg.ie&&mg.ie_version<15||mg.ios&&mg.webkit_version<604;function iy(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function oy(e,t){t=iy(e.state,Ev,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=fy&&r.selection.ranges.every(e=>e.empty)&&fy==o.toString();if(a){let e=-1;n=r.changeByRange(n=>{let a=r.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=r.toText((s?o.line(i++).text:t)+r.lineBreak);return{changes:{from:a.from,insert:l},range:Dp.cursor(n.from+l.length)}})}else n=s?r.changeByRange(e=>{let t=o.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:Dp.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function sy(e,t,n,r){if(1==r)return Dp.cursor(t,n);if(2==r)return function(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(0==i.length)return Dp.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=vp(i.text,o,!1):a=vp(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=vp(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=vp(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return Dp.range(s+i.from,a+i.from)}(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:i.from,s=r?r.posAtEnd:i.to;return s<e.state.doc.length&&s==i.to&&s++,Dp.range(o,s)}}ny.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},ty.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),ny.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},ny.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},ty.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(yv))if(n=r(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=uy(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,o,s){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=sy(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=sy(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?Dp.range(i,o):Dp.range(o,i)}return o?i.replaceRange(i.main.extend(c.from,c.to)):s&&1==r&&i.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return Dp.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(i,l.pos))?a:s?i.addRange(c):Dp.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new ey(e,t,n,r)),r&&e.observer.ignore(()=>{Ug(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),!1===i.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const ay=mg.ie&&mg.ie_version<=11;let ly=null,cy=0,hy=0;function uy(e){if(!ay)return e.detail;let t=ly,n=hy;return ly=e,hy=Date.now(),cy=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(cy+1)%3:1}function dy(e,t,n,r){if(!(n=iy(e.state,Ev,n)))return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=r&&o&&function(e,t){let n=e.state.facet(bv);return n.length?n[0](t):mg.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}ty.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=Dp.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",iy(e.state,Cv,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},ty.dragend=e=>(e.inputState.draggedContent=null,!1),ty.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,o=()=>{++i==n.length&&dy(e,t,r.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return dy(e,t,n,!0),!0}return!1},ty.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=ry?null:t.clipboardData;return n?(oy(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),oy(e,n.value)},50)}(e),!1)};let fy=null;ty.copy=ty.cut=(e,t)=>{let n=Mg(e.root);if(n&&!Dg(e.contentDOM,n))return!1;let{text:r,ranges:i,linewise:o}=function(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let o=e.doc.lineAt(r);o.number>i&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),i=o.number}r=!0}return{text:iy(e,Cv,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;fy=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=ry?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}(e,r),!1)};const py=lm.define();function my(e,t){let n=[];for(let r of e.facet(Sv)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:py.of(!0)}):null}function gy(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=my(e.state,t);n?e.dispatch(n):e.update([])}},10)}ny.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),gy(e)},ny.blur=e=>{e.observer.clearSelectionRange(),gy(e)},ny.compositionstart=ny.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},ny.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,mg.chrome&&mg.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},ny.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},ty.beforeinput=(e,t)=>{var n,r;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let r=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),i=t.getTargetRanges();if(r&&i.length){let t=i[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return qb(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(mg.chrome&&mg.android&&(i=Xb.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){let t=(null===(r=window.visualViewport)||void 0===r?void 0:r.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return mg.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),mg.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>ny.compositionend(e,t),20),!1};const vy=new Set;const by=["pre-wrap","normal","pre-line","break-spaces"];let yy=!1;function wy(){yy=!1}class xy{constructor(e){this.lineWrapping=e,this.doc=ap.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return by.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(10*r)]||(t=!0,this.heightSamples[Math.floor(10*r)]=!0)}return t}refresh(e,t,n,r,i,o){let s=by.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class ky{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Sy{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return"number"==typeof this._content?kg.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ng?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Sy(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Ey=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(Ey||(Ey={}));const Cy=.001;class Ny{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Cy&&(yy=!0),this.height=e)}replace(e,t,n){return Ny.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,o=n.doc;for(let s=r.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=r[s],u=i.lineAt(a,Ey.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:i.lineAt(l,Ey.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;s>0&&u.from<=r[s-1].toA;)a=r[s-1].fromA,c=r[s-1].fromB,s--,a<u.from&&(u=i.lineAt(a,Ey.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let f=Ly.build(n.setDoc(o),e,c,h);i=Oy(i,i.replace(a,l,f))}return i.updateHeight(n,0)}static empty(){return new My(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,r=0,i=0;for(;;)if(t==n)if(r>2*i){let i=e[t-1];i.break?e.splice(--t,1,i.left,null,i.right):e.splice(--t,1,i.left,i.right),n+=1+i.break,r-=i.size}else{if(!(i>2*r))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,i-=t.size}}else if(r<i){let n=e[t++];n&&(r+=n.size)}else{let t=e[--n];t&&(i+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new Dy(Ny.of(e.slice(0,t)),o,Ny.of(e.slice(n)))}}function Oy(e,t){return e==t?e:(e.constructor!=t.constructor&&(yy=!0),t)}Ny.prototype.size=1;const Ay=Sg.replace({});class Ty extends Ny{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Sy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Sy(r,0,n,this.spaceAbove,Ay):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}forEachLine(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,Ey.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class My extends Ty{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new Sy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return 1==n.length&&(r instanceof My||r instanceof Ry&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof Ry?r=new My(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Ny.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||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 Ry extends Ny{constructor(e){super(e,0)}heightMetrics(e,t){let n,r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:r,lastLine:i,perLine:n,perChar:s}}blockAt(e,t,n,r){let{firstLine:i,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(i),l=s+o.length*a,c=Math.max(n,e-l/2);return new Sy(o.from,o.length,c,l,0)}{let r=Math.max(0,Math.min(o-i,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(i+r);return new Sy(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==Ey.ByHeight)return this.blockAt(e,n,r,i);if(t==Ey.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new Sy(t,r-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,i),l=n.doc.lineAt(e),c=s+l.length*a,h=l.number-o,u=r+s*h+a*(l.from-i-h);return new Sy(l.from,l.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,n,r,i,o){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,i);for(let c=e,h=r;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;h+=a*n+l*(e-i-n)}let r=a+l*t.length;o(new Sy(t.from,t.length,h,r,0)),h+=r,c=t.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let e=n[n.length-1];e instanceof Ry?n[n.length-1]=new Ry(e.length+r):n.push(null,new Ry(r-1))}if(e>0){let t=n[0];t instanceof Ry?n[0]=new Ry(e+t.length):n.unshift(new Ry(e-1),null)}return Ny.of(n)}decomposeLeft(e,t){t.push(new Ry(e-1),null)}decomposeRight(e,t){t.push(null,new Ry(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let i=t+this.length;if(r&&r.from<=t+this.length&&r.more){let n=[],o=Math.max(t,r.from),s=-1;for(r.from>t&&n.push(new Ry(r.from-t-1).updateHeight(e,t));o<=i&&r.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let i=r.heights[r.index++],a=0;i<0&&(a=-i,i=r.heights[r.index++]),-1==s?s=i:Math.abs(i-s)>=Cy&&(s=-2);let l=new My(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new Ry(i-o).updateHeight(e,o));let a=Ny.of(n);return(s<0||Math.abs(a.height-this.height)>=Cy||Math.abs(s-this.heightMetrics(e,t).perLine)>=Cy)&&(yy=!0),Oy(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Dy extends Ny{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,a=t==Ey.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==Ey.ByPosNoHeight?Ey.ByPosNoHeight:Ey.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,o){let s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,Ey.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let e of n)i.push(e);if(e>0&&Py(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),Py(i,e)}return Ny.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ny.of(this.break?[e,null,t]:[e,t]):(this.left=Oy(this.left,e),this.right=Oy(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:o}=this,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Py(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof Ry&&(r=e[t+1])instanceof Ry&&e.splice(t-1,3,new Ry(n.length+1+r.length))}class Ly{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof My?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new My(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Ty(o,r,n)):(o||i||r>=5)&&this.addLineDeco(r,i,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new My(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Ry(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof My)return e;let t=new My(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof My||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new My(0,-1,0));let n=e;for(let e of this.nodes)e instanceof My&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new Ly(n,e);return Mm.spans(t,n,r,i,0),i.finish(n)}}class By{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Ag(e,t,this.changes,5)}}function Iy(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(1==t.nodeType){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=r.overflow){let r=n.getBoundingClientRect();o=Math.max(o,r.left),s=Math.min(s,r.right),a=Math.max(a,r.top),l=Math.min(t==e.parentNode?i.innerHeight:l,r.bottom)}t="absolute"==r.position||"fixed"==r.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function _y(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class jy{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return Sg.replace({widget:new Fy(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Fy extends xg{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Wy{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=qy,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Qg.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Fv).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new xy(t),this.stateDeco=Uy(e),this.heightMap=Ny.empty().applyChanges(this.stateDeco,ap.empty,this.heightOracle.setDoc(e.doc),[new Gv(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Sg.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new zy(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?qy:new $y(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(Ky(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Uy(this.state);let r=e.changedRanges,i=Gv.extendWithRanges(r,function(e,t,n){let r=new By;return Mm.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:Ep.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);wy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||yy)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ov)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Qg.RTL:Qg.LTR;let o=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=zg(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Yg(e.scrollDOM);let f=(this.printing?_y:Iy)(t,this.paddingTop),p=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;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&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&r.refresh(i,n,s,a,Math.max(5,v/s),t),o&&(e.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),wy();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?Ny.empty().applyChanges(this.stateDeco,ap.empty,this.heightOracle,[new Gv(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new ky(n.from,i))}yy&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new zy(r.lineAt(o-1e3*n,Ey.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),Ey.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=r.lineAt(e,Ey.ByPos,i,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new zy(r.lineAt(n-500,Ey.ByHeight,i,0,0).from,r.lineAt(n+o+500,Ey.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new zy(this.heightMap.lineAt(n,Ey.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Ey.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,Ey.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,Ey.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=s+Math.max(10,Math.min(n,250)))&&r>o-2e3&&i<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new jy(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=Qg.LTR&&!n)return[];let s=[],a=(r,o,l,c)=>{if(o-r<i)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>r&&e<o)return a(r,e-10,l,c),void a(e+10,o,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-o)<i&&!u.some(t=>e.from<t&&e.to>t));if(!d){if(o<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=o&&e.to>=o)){let e=t.moveToLineBoundary(Dp.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);d=new jy(r,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=kg.Text)return;let i=function(e,t,n){let r=[],i=e,o=0;Mm.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),o+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),o+=t-i);return{total:o,ranges:r}}(t.from,t.to,this.stateDeco);if(i.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=r/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let r=Vy(i,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=r-s,n=r+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=Hy(i,e),l=Hy(i,n)}else{let n=i.total*this.heightOracle.charWidth,o=r*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let e=Vy(i,c),t=((f-d)/2+o)/n;h=e-t,u=e+t}else h=(d-o)/n,u=(f+o)/n;s=Hy(i,h),l=Hy(i,u)}s>t.from&&a(t.from,s,t,i),l<t.to&&a(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,r){let i=Vy(r,n)-Vy(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){jy.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Sg.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];Mm.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(8&r);t++){let i=this.visibleRanges[t],o=n[t];i.from==o.from&&i.to==o.to||(r|=4,e&&e.mapPos(i.from,-1)==o.from&&e.mapPos(i.to,1)==o.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Ky(this.heightMap.lineAt(e,Ey.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Ky(this.heightMap.lineAt(this.scaler.fromDOM(e),Ey.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Ky(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 zy{constructor(e,t){this.from=e,this.to=t}}function Hy({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],o=i-n;if(r<=o)return n+r;r-=o}}function Vy(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}const qy={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function Uy(e){let t=e.facet(Wv).filter(e=>"function"!=typeof e),n=e.facet(Hv).filter(e=>"function"!=typeof e);return n.length&&t.push(Mm.join(n)),t}class $y{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,Ey.ByPos,e,0,0).top,s=t.lineAt(i,Ey.ByPos,e,0,0).bottom;return r+=s-o,{from:n,to:i,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=o+(e.top-i)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(e){return e instanceof $y&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to))}}function Ky(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Sy(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Ky(e,t)):e._content)}const Yy=Bp.define({combine:e=>e.join(" ")}),Gy=Bp.define({combine:e=>e.indexOf(!0)>-1}),Xy=Km.newName(),Jy=Km.newName(),Qy=Km.newName(),Zy={"&light":"."+Jy,"&dark":"."+Qy};function ew(e,t,n){return new Km(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const tw=ew("."+Xy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Zy),nw={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},rw=mg.ie&&mg.ie_version<=11;class iw{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Hg,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(mg.ie&&mg.ie_version<=11||mg.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!mg.android||!1===e.constructor.EDIT_CONTEXT||mg.chrome&&mg.chrome_version<126||(this.editContext=new aw(e),e.state.facet(Pv)&&(e.contentDOM.editContext=this.editContext.editContext)),rw&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.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){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Pv)?n.root.activeElement!=this.dom:!Dg(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(mg.ie&&mg.ie_version<=11||mg.android&&mg.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Lg(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Mg(e.root);if(!t)return!1;let n=mg.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return sw(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?sw(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=Dg(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,jg(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=jg(n))}else{if(n==e)return!0;r=Bg(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,nw),rw&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),rw&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Kg(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Dg(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new zb(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=Vb(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!$b(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=ow(t,e.previousSibling||e.target.previousSibling,-1),r=ow(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Pv)!=e.state.facet(Pv)&&(e.view.contentDOM.editContext=e.state.facet(Pv)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.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 ow(e,t,n){for(;t;){let r=Qv.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function sw(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return Lg(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class aw{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&i<this.from?s=i:a==this.to&&i>this.to&&(a=i);let c=Ub(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=Dp.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void($b(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let h={from:c.from+s,to:c.toA+s,insert:ap.of(n.text.slice(c.from,c.toB).split("\n"))};if((mg.mac||mg.android)&&h.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:s,to:a,insert:ap.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);qb(e,h,Dp.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(i<o){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(r)?1:2}px`;n.push(Sg.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:Rv.of(Sg.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=Mg(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,a,l)=>{if(n)return;let c=l.length-(o-i);if(r&&o>=r.to){if(r.from==i&&r.to==o&&r.insert.eq(l))return r=this.pendingContextChange=null,t+=c,void(this.to+=c);r=null,this.revertPending(e.state)}if(i+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.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)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==r||this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class lw{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Wy(e.state||Sm.create(e)),e.scrollTo&&e.scrollTo.is(Mv)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Bv).map(e=>new _v(e));for(let e of this.plugins)e.update(this);this.observer=new iw(this),this.inputState=new Kb(this),this.inputState.ensureHandlers(this.plugins),this.docView=new xb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof dm?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,r=!1,i=this.state;for(let t of e){if(t.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=t.state}if(this.destroyed)return void(this.viewState.state=i);let o=this.hasFocus,s=0,a=null;e.some(e=>e.annotation(py))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=my(i,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(Sm.phrases)!=this.state.facet(Sm.phrases))return this.setState(i);t=Xv.create(this,i,e),t.flags|=s;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new Tv(e.empty?e:Dp.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(Mv)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=uw.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Yv)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(Yy)!=t.state.facet(Yy)&&(this.viewState.mustMeasureContent=!0),(n||r||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(xv))try{e(t)}catch(e){Dv(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Vb(this,c)&&l.force&&Kg(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Wy(e),this.plugins=e.facet(Bv).map(e=>new _v(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new xb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Bv),n=e.state.facet(Bv);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new _v(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){Dv(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(Yg(n))i=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5)break;let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return Dv(this.state,e),hw}}),c=Xv.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=hw)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){Dv(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(e>1||e<-1){r+=e,n.scrollTop=r/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(xv))e(t)}get themeClasses(){return Xy+" "+(this.state.facet(Gy)?Qy:Jy)+" "+this.state.facet(Yy)}updateAttrs(){let e=dw(this,jv,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Pv)?"true":"false",class:"cm-content",style:`${mg.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),dw(this,Fv,t);let n=this.observer.ignore(()=>{let n=yg(this.contentDOM,this.contentAttrs,t),r=yg(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(lw.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(Yv);let e=this.state.facet(lw.cspNonce);Km.mount(this.root,this.styleModules.concat(tw).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&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(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Rb(this,e,Ab(this,e,t,n))}moveByGroup(e,t){return Rb(this,e,Ab(this,e,t,t=>function(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==ym.Space&&(i=t),i==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return Dp.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,r){let i=Ob(e,t.head,t.assoc||-1),o=r&&i.type==kg.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),s=e.posAtCoords({x:n==(r==Qg.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return Dp.cursor(s,n?-1:1)}return Dp.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return Rb(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return Dp.cursor(i,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||-1),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(i);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-t.from))),s=(o<0?t.top:t.bottom)+h}let u=Pb(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return Dp.cursor(u.pos,u.assoc,void 0,a)}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=Pb(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Pb(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r);return Fg(n,i[lv.find(i,e-r.from,-1,t)].dir==Qg.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Nv)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>cw)return fv(e.length);let t,n=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==n&&(r.fresh||cv(r.isolates,t=Uv(this,e))))return r.order;t||(t=Uv(this,e));let r=function(e,t,n){if(!e)return[new lv(0,0,t==ev?1:0)];if(t==Zg&&!n.length&&!av.test(e))return fv(e.length);if(n.length)for(;e.length>hv.length;)hv[hv.length]=256;let r=[],i=t==Zg?0:1;return dv(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new uw(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||mg.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ug(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Mv.of(new Tv("number"==typeof e?Dp.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Mv.of(new Tv(Dp.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Iv.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Iv.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Km.newName(),r=[Yy.of(n),Yv.of(ew(`.${n}`,e))];return t&&t.dark&&r.push(Gy.of(!0)),r}static baseTheme(e){return Yp.lowest(Yv.of(ew("."+Xy,e,Zy)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&Qv.get(n)||Qv.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}lw.styleModule=Yv,lw.inputHandler=kv,lw.clipboardInputFilter=Ev,lw.clipboardOutputFilter=Cv,lw.scrollHandler=Av,lw.focusChangeEffect=Sv,lw.perLineTextDirection=Nv,lw.exceptionSink=wv,lw.updateListener=xv,lw.editable=Pv,lw.mouseSelectionStyle=yv,lw.dragMovesSelection=bv,lw.clickAddsSelectionRange=vv,lw.decorations=Wv,lw.blockWrappers=zv,lw.outerDecorations=Hv,lw.atomicRanges=Vv,lw.bidiIsolatedRanges=qv,lw.scrollMargins=$v,lw.darkTheme=Gy,lw.cspNonce=Bp.define({combine:e=>e.length?e[0]:""}),lw.contentAttributes=Fv,lw.editorAttributes=jv,lw.lineWrapping=lw.contentAttributes.of({class:"cm-lineWrapping"}),lw.announce=um.define();const cw=4096,hw={};class uw{constructor(e,t,n,r,i,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:Qg.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir!=r||t.touchesRange(o.from,o.to)||n.push(new uw(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function dw(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],o="function"==typeof t?t(e):t;o&&gg(o,n)}return n}const fw=mg.mac?"mac":mg.windows?"win":mg.linux?"linux":"key";function pw(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const mw=Yp.default(lw.domEventHandlers({keydown:(e,t)=>kw(bw(t.state),e,t,"editor")})),gw=Bp.define({enables:mw}),vw=new WeakMap;function bw(e){let t=e.facet(gw),n=vw.get(t);return n||vw.set(t,n=function(e,t=fw){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(null==n)r[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},o=(e,r,o,s,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),u=r.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let r,i,o,s,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?s=!0:i=!0}}return r&&(a="Alt-"+a),i&&(a="Ctrl-"+a),s&&(a="Meta-"+a),o&&(a="Shift-"+a),a}(e,t));for(let t=1;t<u.length;t++){let n=u.slice(0,t).join(" ");i(n,!0),h[n]||(h[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=yw={view:t,prefix:n,scope:e};return setTimeout(()=>{yw==r&&(yw=null)},ww),!0}]})}let d=u.join(" ");i(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),s&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,xw))}let i=r[t]||r.key;if(i)for(let t of e)o(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&o(t,"Shift-"+i,r.shift,r.preventDefault,r.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let yw=null;const ww=4e3;let xw=null;function kw(e,t,n,r){xw=t;let i=function(e){var t=!(Qm&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Zm&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Jm:Xm)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),o=wp(bp(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;yw&&yw.view==n&&yw.scope==r&&(s=yw.prefix+" ",Qb.indexOf(t.keyCode)<0&&(l=!0,yw=null));let h,u,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[r];return p&&(f(p[s+pw(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||mg.windows&&t.ctrlKey&&t.altKey||mg.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(h=Xm[t.keyCode])||h==i?o&&t.shiftKey&&f(p[s+pw(i,t,!0)])&&(a=!0):(f(p[s+pw(h,t,!0)])||t.shiftKey&&(u=Jm[t.keyCode])!=i&&u!=h&&f(p[s+pw(u,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),xw=null,a}class Sw{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let i=Ew(e);return[new Sw(t,r.left-i.left,r.top-i.top,null,r.bottom-r.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),o=e.textDirection==Qg.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=Ew(e),c=s.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=Ob(e,r,1),p=Ob(e,i,-1),m=f.type==kg.Text?f:null,g=p.type==kg.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=Cw(e,r,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=Cw(e,i,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return b(y(n.from,n.to,m));{let t=m?y(n.from,null,m):w(f,!1),r=g?y(null,n.to,g):w(p,!0),i=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(v(u,t.bottom,d,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==kg.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),b(t).concat(i).concat(b(r))}function v(e,n,r,i){return new Sw(t,e-l.left,n-l.top,r-e,i-n)}function b({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(v(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,s=-1e9,a=[];function l(t,n,l,c,h){let f=e.coordsAtPos(t,t==r.to?-2:2),p=e.coordsAtPos(l,l==r.from?2:-2);f&&p&&(i=Math.min(f.top,p.top,i),s=Math.max(f.bottom,p.bottom,s),h==Qg.LTR?a.push(o&&n?u:f.left,o&&c?d:p.right):a.push(!o&&c?u:p.left,!o&&n?d:f.right))}let c=null!=t?t:r.from,h=null!=n?n:r.to;for(let r of e.visibleRanges)if(r.to>c&&r.from<h)for(let i=Math.max(r.from,c),o=Math.min(r.to,h);;){let r=e.state.doc.lineAt(i);for(let s of e.bidiSpans(r)){let e=s.from+r.from,a=s.to+r.from;if(e>=o)break;a>i&&l(Math.max(e,i),null==t&&e<=c,Math.min(a,o),null==n&&a>=h,s.dir)}if(i=r.to+1,i>=o)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:i,bottom:s,horizontal:a}}function w(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function Ew(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Qg.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Cw(e,t,n,r){let i=e.coordsAtPos(t,2*n);if(!i)return r;let o=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return null==a||null==l?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}class Nw{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Ow)!=e.state.facet(Ow)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(Ow);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;e==this.scaleX&&t==this.scaleY||(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{return n=e,r=this.drawn[t],!(n.constructor==r.constructor&&n.eq(r));var n,r})){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,mg.safari&&mg.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Ow=Bp.define();function Aw(e){return[Iv.define(t=>new Nw(t,e)),Ow.of(e)]}const Tw=Bp.define({combine:e=>Em(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function Mw(e){return e.startState.facet(Tw)!=e.state.facet(Tw)}const Rw=Aw({above:!0,markers(e){let{state:t}=e,n=t.facet(Tw),r=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty||n.drawRangeCursor){let t=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=i.empty?i:Dp.cursor(i.head,i.head>i.anchor?-1:1);for(let i of Sw.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=Mw(e);return n&&Dw(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){Dw(t.state,e)},class:"cm-cursorLayer"});function Dw(e,t){t.style.animationDuration=e.facet(Tw).cursorBlinkRate+"ms"}const Pw=Aw({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:Sw.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||Mw(e),class:"cm-selectionLayer"}),Lw=Yp.highest(lw.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Bw=um.define({map:(e,t)=>null==e?null:t.mapPos(e)}),Iw=Hp.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(Bw)?t.value:e,e))}),_w=Iv.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(Iw);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(Iw)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Iw),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(Iw)!=e&&this.view.dispatch({effects:Bw.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function jw(e,t,n,r,i){t.lastIndex=0;for(let o,s=e.iterRange(n,r),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}class Fw{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:i,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,r,i)=>{let o=n(e,t,r);o&&i(r,r+e[0].length,o)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n)}this.boundary=i,this.maxLength=o}createDeco(e){let t=new Rm,n=t.add.bind(t);for(let{from:t,to:r}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:o}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=o:r.push({from:i,to:o});return r}(e,this.maxLength))jw(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,o,s)=>{s>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),r=Math.max(s,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let o=Math.max(i.from,n),s=Math.min(i.to,r);if(s>=o){let n=e.state.doc.lineAt(o),r=n.to<s?e.state.doc.lineAt(s):n,a=Math.max(i.from,n.from),l=Math.min(i.to,r.to);if(this.boundary){for(;o>n.from;o--)if(this.boundary.test(n.text[o-1-n.from])){a=o;break}for(;s<r.to;s++)if(this.boundary.test(r.text[s-r.from])){l=s;break}}let c,h=[],u=(e,t,n)=>h.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.index<l-n.from;)this.addMatch(c,e,c.index+n.from,u);else jw(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:h})}}return t}}const Ww=null!=/x/.unicode?"gu":"g",zw=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",Ww),Hw={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Vw=null;const qw=Bp.define({combine(e){let t=Em(e,{render:null,specialChars:zw,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Vw&&"undefined"!=typeof document&&document.body){let t=document.body.style;Vw=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Vw||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Ww)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Ww)),t}});let Uw=null;class $w extends xg{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(Hw[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}}class Kw extends xg{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const Yw=Sg.line({class:"cm-activeLine"}),Gw=Iv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Yw.range(i.from)),t=i.from)}return Sg.set(n)}},{decorations:e=>e.decorations});class Xw extends xg{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Pg(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Fg(t[0],"rtl"!=n.direction),i=parseInt(n.lineHeight);return r.bottom-r.top>1.5*i?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}}const Jw=2e3;function Qw(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>Jw?-1:i==r.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):Hm(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function Zw(e,t){let n=Qw(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,o){let s=Qw(e,t);if(!s)return r;let a=function(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>Jw||n.off>Jw||t.col<0||n.col<0){let s=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=a&&o.push(Dp.range(n.from+s,n.to+a))}}else{let s=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=Vm(n.text,s,e.tabSize,!0);if(r<0)o.push(Dp.cursor(n.to));else{let t=Vm(n.text,a,e.tabSize);o.push(Dp.range(n.from+r,n.from+t))}}}return o}(e.state,n,s);return a.length?o?Dp.create(a.concat(r.ranges)):Dp.create(a):r}}:null}const ex={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},tx={style:"cursor: crosshair"};const nx="-10000px";class rx{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let o=[],s=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],a=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(a=e)}if(a<0)o[n]=this.createTooltipView(r,n?o[n-1]:null),s&&(s[n]=!!r.above);else{let r=o[n]=this.tooltipViews[a];s&&(s[n]=t[a]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)o.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(s.forEach((e,n)=>t[n]=e),t.length=s.length),this.input=r,this.tooltips=i,this.tooltipViews=o,!0}}function ix(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const ox=Bp.define({combine:e=>{var t,n,r;return{position:mg.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(r=e.find(e=>e.tooltipSpace))||void 0===r?void 0:r.tooltipSpace)||ix}}}),sx=new WeakMap,ax=Iv.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(ox);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new rx(e,ux,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(ox);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.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 e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=nx,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 e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(mg.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Kv(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((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(ox).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:o}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=e.pos[a],d=e.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(n.top,r.top)||u.top>=Math.min(n.bottom,r.bottom)||u.right<Math.max(n.left,r.left)-.1||u.left>Math.min(n.right,r.right)+.1)){h.style.top=nx;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=sx.get(c))&&void 0!==t?t:d.bottom-d.top,v=c.offset||hx,b=this.view.textDirection==Qg.LTR,y=d.width>r.right-r.left?b?r.left:r.right-d.width:b?Math.max(r.left,Math.min(u.left-(f?14:0)+v.x,r.right-m)):Math.min(Math.max(r.left,u.left-m+(f?14:0)-v.x),r.right-m),w=this.above[a];!l.strictSide&&(w?u.top-g-p-v.y<r.top:u.bottom+g+p+v.y>r.bottom)&&w==r.bottom-u.bottom>u.top-r.top&&(w=this.above[a]=!w);let x=(w?u.top-r.top:r.bottom-u.bottom)-p;if(x<g&&!1!==c.resize){if(x<this.view.defaultLineHeight){h.style.top=nx;continue}sx.set(c,g),h.style.height=(g=x)/o+"px"}else h.style.height&&(h.style.height="");let k=w?u.top-g-p-v.y:u.bottom+p+v.y,S=y+m;if(!0!==c.overlap)for(let e of s)e.left<S&&e.right>y&&e.top<k+g&&e.bottom>k&&(k=w?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(h.style.top=(k-e.parent.top)/o+"px",lx(h,(y-e.parent.left)/i)):(h.style.top=k/o+"px",lx(h,y/i)),f){let e=u.left+(b?v.x:-v.x)-(y+14-7);f.style.left=e/i+"px"}!0!==c.overlap&&s.push({left:y,top:k,right:S,bottom:k+g}),h.classList.toggle("cm-tooltip-above",w),h.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=nx}},{eventObservers:{scroll(){this.maybeMeasure()}}});function lx(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const cx=lw.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:"14px",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"}}}),hx={x:0,y:0},ux=Bp.define({enables:[ax,cx]}),dx=Bp.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class fx{static create(e){return new fx(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new rx(e,dx,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(void 0!==r)if(void 0===t)t=r;else if(t!==r)return}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const px=ux.compute([dx],e=>{let t=e.facet(dx);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:fx.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class mx{constructor(e,t,n,r,i){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),null==r)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),s=o&&o.dir==Qg.RTL?-1:1;i=t.x<n.left?-s:s}let o=this.source(e,r,i);if(null==o?void 0:o.then){let t=this.pending={pos:r};o.then(n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>Dv(e.state,t,"hover tooltip"))}else!o||Array.isArray(o)&&!o.length||e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(ax),t=e?e.manager.tooltips.findIndex(e=>e.create==fx.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;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:r,tooltip:i}=this;if(r.length&&i&&!function(e,t){let n,{left:r,right:i,top:o,bottom:s}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();o=Math.min(e.top,o),s=Math.max(e.bottom,s)}return t.clientX>=r-gx&&t.clientX<=i+gx&&t.clientY>=o-gx&&t.clientY<=s+gx}(i.dom,e)||this.pending){let{pos:i}=r[0]||this.pending,o=null!==(n=null===(t=r[0])||void 0===t?void 0:t.end)&&void 0!==n?n:i;(i==o?this.view.posAtCoords(this.lastMove)==i:function(e,t,n,r,i){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let a=e.posAtCoords({x:r,y:i},!1);return a>=t&&a<=n}(this.view,i,o,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const gx=4;function vx(e,t={}){let n=um.define(),r=Hp.define({create:()=>[],update(e,r){if(e.length&&(t.hideOnChange&&(r.docChanged||r.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(r,e))),r.docChanged)){let t=[];for(let n of e){let e=r.changes.mapPos(n.pos,-1,kp.TrackDel);if(null!=e){let i=Object.assign(Object.create(null),n);i.pos=e,null!=i.end&&(i.end=r.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of r.effects)t.is(n)&&(e=t.value),t.is(yx)&&(e=[]);return e},provide:e=>dx.from(e)});return{active:r,extension:[r,Iv.define(i=>new mx(i,e,r,n,t.hoverTime||300)),px]}}function bx(e,t){let n=e.plugin(ax);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const yx=um.define(),wx=Bp.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function xx(e,t){let n=e.plugin(kx),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const kx=Iv.fromClass(class{constructor(e){this.input=e.state.facet(Cx),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(wx);this.top=new Sx(e,!0,t.topContainer),this.bottom=new Sx(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(wx);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Sx(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Sx(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Cx);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],o=[],s=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),s.push(t)):(t=this.panels[a],t.update&&t.update(e)),r.push(t),(t.top?i:o).push(t)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(o);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>lw.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Sx{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Ex(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Ex(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 Ex(e){let t=e.nextSibling;return e.remove(),t}const Cx=Bp.define({enables:kx});function Nx(e,t){let n,r=new Promise(e=>n=e),i=e=>function(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=ng("form"),t.input){let e=ng("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),r.appendChild(ng("label",(t.label||"")+": ",e))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(ng("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i="FORM"==r.nodeName?[r]:r.querySelectorAll("form");for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),s(null)):13==e.keyCode&&(e.preventDefault(),s(t))}),t.addEventListener("submit",e=>{e.preventDefault(),s(t)})}let o=ng("div",r,ng("button",{onclick:()=>s(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(o.className=t.class);function s(t){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(t)}return o.classList.add("cm-dialog"),{dom:o,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?r.querySelector(t.focus):r.querySelector("input")||r.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(Ox,!1)?e.dispatch({effects:Ax.of(i)}):e.dispatch({effects:um.appendConfig.of(Ox.init(()=>[i]))});let o=Tx.of(i);return{close:o,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(Ox).indexOf(i)>-1&&e.dispatch({effects:o})}),t))}}const Ox=Hp.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(Ax)?e=[n.value].concat(e):n.is(Tx)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>Cx.computeN([e],t=>t.field(e))}),Ax=um.define(),Tx=um.define();class Mx extends Cm{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Mx.prototype.elementClass="",Mx.prototype.toDOM=void 0,Mx.prototype.mapMode=kp.TrackBefore,Mx.prototype.startSide=Mx.prototype.endSide=-1,Mx.prototype.point=!0;const Rx=Bp.define(),Dx=Bp.define(),Px={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Mm.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Lx=Bp.define();function Bx(e){return[_x(),Lx.of({...Px,...e})]}const Ix=Bp.define({combine:e=>e.some(e=>e)});function _x(e){let t=[jx];return e&&!1===e.fixed&&t.push(Ix.of(!0)),t}const jx=Iv.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(Lx).map(t=>new Hx(e,t)),this.fixed=!e.state.facet(Ix);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<.8*(n.to-n.from))}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ix)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=Mm.iter(this.view.state.facet(Rx),this.view.viewport.from),r=[],i=this.gutters.map(e=>new zx(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let o of e.type)if(o.type==kg.Text&&t){Wx(n,r,o.from);for(let e of i)e.line(this.view,o,r);t=!1}else if(o.widget)for(let e of i)e.widget(this.view,o)}else if(e.type==kg.Text){Wx(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Lx),n=e.state.facet(Lx),r=e.docChanged||e.heightChanged||e.viewportChanged||!Mm.eq(e.startState.facet(Rx),e.state.facet(Rx),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Hx(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>lw.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Qg.LTR?{left:r,right:i}:{right:r,left:i}})});function Fx(e){return Array.isArray(e)?e:[e]}function Wx(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class zx{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Mm.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Vx(e,o,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,o,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Wx(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let o=this.gutter;(0!=r.length||o.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(Dx)){let i=n(e,t.widget,t);i&&(r||(r=[])).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Hx{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i,o=r.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let e=o.getBoundingClientRect();i=(e.top+e.bottom)/2}else i=r.clientY;let s=e.lineBlockAtHeight(i-e.documentTop);t.domEventHandlers[n](e,s,r)&&r.preventDefault()});this.markers=Fx(t.markers(e)),t.initialSpacer&&(this.spacer=new Vx(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Fx(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!Mm.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Vx{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let i=0,o=0;;){let s=o,a=i<t.length?t[i++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=o;e<this.markers.length;e++)if(this.markers[e].compare(a)){s=e,l=!0;break}}else s=this.markers.length;for(;o<s;){let e=this.markers[o++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}const qx=Bp.define(),Ux=Bp.define(),$x=Bp.define({combine:e=>Em(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})});class Kx extends Mx{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Yx(e,t){return e.state.facet($x).formatNumber(t,e.state)}const Gx=Lx.compute([$x],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(qx),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new Kx(Yx(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Ux)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet($x)!=e.state.facet($x),initialSpacer:e=>new Kx(Yx(e,Xx(e.state.doc.lines))),updateSpacer(e,t){let n=Yx(t.view,Xx(t.view.state.doc.lines));return n==e.number?e:new Kx(n)},domEventHandlers:e.facet($x).domEventHandlers,side:"before"}));function Xx(e){let t=9;for(;t<e;)t=10*t+9;return t}const Jx=new class extends Mx{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Qx=Rx.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Jx.range(i)))}return Mm.of(t)});const Zx=1024;let ek=0;class tk{constructor(e,t){this.from=e,this.to=t}}class nk{constructor(e={}){this.id=ek++,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"function"!=typeof e&&(e=ok.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}nk.closedBy=new nk({deserialize:e=>e.split(" ")}),nk.openedBy=new nk({deserialize:e=>e.split(" ")}),nk.group=new nk({deserialize:e=>e.split(" ")}),nk.isolate=new nk({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),nk.contextHash=new nk({perNode:!0}),nk.lookAhead=new nk({perNode:!0}),nk.mounted=new nk({perNode:!0});class rk{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[nk.mounted.id]}}const ik=Object.create(null);class ok{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):ik,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new ok(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(nk.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(nk.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}ok.none=new ok("",Object.create(null),0,8);class sk{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let t of e){let e=t(n);if(e){r||(r=Object.assign({},n.props));let t=e[1],i=e[0];i.combine&&i.id in r&&(t=i.combine(r[i.id],t)),r[i.id]=t}}t.push(r?new ok(n.name,r,n.id,n.flags):n)}return new sk(t)}}const ak=new WeakMap,lk=new WeakMap;var ck;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(ck||(ck={}));class hk{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=rk.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Sk(this.topNode,e)}cursorAt(e,t=0,n=0){let r=ak.get(this)||this.topNode,i=new Sk(r);return i.moveTo(e,t),ak.set(this,i._tree),i}get topNode(){return new gk(this,0,0,null)}resolve(e,t=0){let n=pk(ak.get(this)||this.topNode,e,t,!1);return ak.set(this,n),n}resolveInner(e,t=0){let n=pk(lk.get(this)||this.topNode,e,t,!0);return lk.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof gk?r:r.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(i||(i=[r])).push(o.resolve(t,n)),e=o}else{let o=rk.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new gk(o.tree,o.overlay[0].from+e.from,-1,e);(i||(i=[r])).push(pk(s,t,n,!1))}}return i?xk(i):r}(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&ck.IncludeAnonymous)>0;for(let e=this.cursor(o|ck.IncludeAnonymous);;){let o=!1;if(e.from<=i&&e.to>=r&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ok(ok.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new hk(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new hk(ok.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=Zx,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new uk(n,n.length):n,l=r.types,c=0,h=0;function u(e,t,n,b,y,w){let{id:x,start:k,end:S,size:E}=a,C=h,N=c;if(E<0){if(a.next(),-1==E){let t=o[x];return n.push(t),void b.push(k-e)}if(-3==E)return void(c=x);if(-4==E)return void(h=x);throw new RangeError(`Unrecognized record size: ${E}`)}let O,A,T=l[x],M=k-e;if(S-k<=i&&(A=g(a.pos-t,y))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,i=t.length;for(;a.pos>n;)i=v(A.start,t,i);O=new dk(t,S-A.start,r),M=A.start-e}else{let e=a.pos-E;a.next();let t=[],n=[],r=x>=s?x:-1,o=0,l=S;for(;a.pos>e;)r>=0&&a.id==r&&a.size>=0?(a.end<=l-i&&(p(t,n,k,o,a.end,l,r,C,N),o=t.length,l=a.end),a.next()):w>2500?d(k,e,t,n):u(k,e,t,n,r,w+1);if(r>=0&&o>0&&o<t.length&&p(t,n,k,o,k,l,r,C,N),t.reverse(),n.reverse(),r>-1&&o>0){let e=f(T,N);O=Ok(T,t,n,0,t.length,0,S-k,e,e)}else O=m(T,t,n,S-k,C-S,N)}n.push(O),b.push(M)}function d(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:r}=a;if(r>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-i),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),i=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-i,t[n++]=s[e+2]-i,t[n++]=n;n.push(new dk(t,s[2]-i,r)),o.push(i-e)}}function f(e,t){return(n,r,i)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof hk){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(nk.lookAhead))&&(a=r[l]+o.length+s)}return m(e,n,r,i,a,t)}}function p(e,t,n,i,o,s,a,l,c){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(m(r.types[a],h,u,s-o,l-s,c)),t.push(o-n)}function m(e,t,n,r,i,o,s){if(o){let e=[nk.contextHash,o];s=s?[e].concat(s):[e]}if(i>25){let e=[nk.lookAhead,i];s=s?[e].concat(s):[e]}return new hk(e,t,n,r,s)}function g(e,t){let n=a.fork(),r=0,o=0,l=0,c=n.end-i,h={size:0,start:0,skip:0};e:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){h.size=r,h.start=o,h.skip=l,l+=4,r+=4,n.next();continue}let a=n.pos-e;if(e<0||a<i||n.start<c)break;let u=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=d,r+=e,l+=u}return(t<0||r==e)&&(h.size=r,h.start=o,h.skip=l),h.size>4?h:void 0}function v(e,t,n){let{id:r,start:i,end:o,size:l}=a;if(a.next(),l>=0&&r<s){let s=n;if(l>4){let r=a.pos-(l-4);for(;a.pos>r;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==l?c=r:-4==l&&(h=r);return n}let b=[],y=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,b,y,-1,0);let w=null!==(t=e.length)&&void 0!==t?t:b.length?y[0]+b[0].length:0;return new hk(l[e.topID],b.reverse(),y.reverse(),w)}(e)}}hk.empty=new hk(ok.none,[],[],0);class uk{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new uk(this.buffer,this.index)}}class dk{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return ok.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(fk(i,r,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){i[a++]=r[s++],i[a++]=r[s++]-n;let t=i[a++]=r[s++]-n;i[a++]=r[s++]-e,o=Math.max(o,t)}return new dk(i,o,this.set)}}function fk(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function pk(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof gk&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:ck.IgnoreOverlays;if(r)for(let r=e,s=r.parent;s;r=s,s=r.parent)r instanceof gk&&r.index<0&&(null===(i=s.enter(t,n,o))||void 0===i?void 0:i.from)!=r.from&&(e=s);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class mk{cursor(e=0){return new Sk(this,e)}getChild(e,t=null,n=null){let r=vk(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return vk(this,e,t,n)}resolve(e,t=0){return pk(this,e,t,!1)}resolveInner(e,t=0){return pk(this,e,t,!0)}matchContext(e){return bk(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class gk extends mk{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,i=0){var o;for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let c=a[e],h=l[e]+s.from;if(i&ck.EnterBracketed&&c instanceof hk&&null===(null===(o=rk.get(c))||void 0===o?void 0:o.overlay)&&(h>=n||h+c.length<=n)||fk(r,n,h,h+c.length))if(c instanceof dk){if(i&ck.ExcludeBuffers)continue;let o=c.findChild(0,c.buffer.length,t,n-h,r);if(o>-1)return new wk(new yk(s,c,e,h),null,o)}else if(i&ck.IncludeAnonymous||!c.type.isAnonymous||Ek(c)){let o;if(!(i&ck.IgnoreMounts)&&(o=rk.get(c))&&!o.overlay)return new gk(o.tree,h,e,s);let a=new gk(c,h,e,s);return i&ck.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r,i)}}if(i&ck.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&ck.IgnoreOverlays)&&(r=rk.get(this._tree))&&r.overlay){let i=e-this.from,o=n&ck.EnterBracketed&&r.bracketed;for(let{from:e,to:n}of r.overlay)if((t>0||o?e<=i:e<i)&&(t<0||o?n>=i:n>i))return new gk(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 vk(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function bk(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class yk{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class wk extends mk{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new wk(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&ck.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new wk(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new wk(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new wk(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new hk(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function xk(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof gk&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new kk(i,n)}class kk{constructor(e,t){this.heads=e,this.node=t}get next(){return xk(this.heads)}}class Sk{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~ck.EnterBracketed,e instanceof gk)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof gk?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&ck.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ck.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ck.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));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&ck.IncludeAnonymous||e instanceof dk||!e.type.isAnonymous||Ek(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new wk(this.buffer,t,this.stack[e]);return this.bufferNode=new wk(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return bk(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return bk(this._tree,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Ek(e){return e.children.some(e=>e instanceof dk||!e.type.isAnonymous||Ek(e))}const Ck=new WeakMap;function Nk(e,t){if(!e.isAnonymous||t instanceof dk||t.type!=e)return 1;let n=Ck.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof hk)){n=1;break}n+=Nk(e,r)}Ck.set(t,n)}return n}function Ok(e,t,n,r,i,o,s,a,l){let c=0;for(let n=r;n<i;n++)c+=Nk(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,r,i,s,a){for(let c=i;c<s;){let i=c,f=r[c],p=Nk(e,n[c]);for(c++;c<s;c++){let t=Nk(e,n[c]);if(p+t>=h)break;p+=t}if(c==i+1){if(p>h){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+a);continue}u.push(n[i])}else{let t=r[c-1]+n[c-1].length-f;u.push(Ok(e,n,r,i,c,f,t,null,l))}d.push(f+a-o)}}(t,n,r,i,0),(a||l)(u,d,s)}class Ak{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new Ak(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let t=o;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new Ak(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&r.push(t),o.to>h)break;o=i<e.length?e[i++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return r}}class Tk{startParse(e,t,n){return"string"==typeof e&&(e=new Mk(e)),n=n?n.length?n.map(e=>new tk(e.from,e.to)):[new tk(0,0)]:[new tk(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class Mk{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new nk({perNode:!0});let Rk=0;class Dk{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Rk++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof Dk&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let r=new Dk(n,[],null,[]);if(r.set.push(r),t)for(let e of t.set)r.set.push(e);return r}static defineModifier(e){let t=new Lk(e);return e=>e.modified.indexOf(t)>-1?e:Lk.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let Pk=0;class Lk{constructor(e){this.name=e,this.instances=[],this.id=Pk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every((e,t)=>e==i[t]));var r,i});if(n)return n;let r=[],i=new Dk(e.name,r,e,t);for(let e of t)e.instances.push(i);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)r.push(Lk.get(t,e));return i}}function Bk(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new _k(r,i,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return Ik.add(t)}const Ik=new nk({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let o=new _k(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}});class _k{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function jk(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function Fk(e,t,n,r=0,i=e.length){let o=new Wk(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}_k.empty=new _k([],2,null);class Wk{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(o)));let l=r,c=function(e){let t=e.type.prop(Ik);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||_k.empty,h=function(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}(i,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(t,s),l),c.opaque)return;let u=e.tree&&e.tree.prop(nk.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter(e=>!e.scope||e.scope(u.tree.type)),h=e.firstChild();for(let d=0,f=s;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+s:a,g=Math.max(t,f),v=Math.min(n,m);if(g<v&&h)for(;e.from<v&&(this.highlightRange(e,g,v,r,i),this.startSpan(Math.min(v,e.to),l),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;f=p.to+s,f>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,f),"",c),this.startSpan(Math.min(n,f),l))}h&&e.parent()}else if(e.firstChild()){u&&(r="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const zk=Dk.define,Hk=zk(),Vk=zk(),qk=zk(Vk),Uk=zk(Vk),$k=zk(),Kk=zk($k),Yk=zk($k),Gk=zk(),Xk=zk(Gk),Jk=zk(),Qk=zk(),Zk=zk(),eS=zk(Zk),tS=zk(),nS={comment:Hk,lineComment:zk(Hk),blockComment:zk(Hk),docComment:zk(Hk),name:Vk,variableName:zk(Vk),typeName:qk,tagName:zk(qk),propertyName:Uk,attributeName:zk(Uk),className:zk(Vk),labelName:zk(Vk),namespace:zk(Vk),macroName:zk(Vk),literal:$k,string:Kk,docString:zk(Kk),character:zk(Kk),attributeValue:zk(Kk),number:Yk,integer:zk(Yk),float:zk(Yk),bool:zk($k),regexp:zk($k),escape:zk($k),color:zk($k),url:zk($k),keyword:Jk,self:zk(Jk),null:zk(Jk),atom:zk(Jk),unit:zk(Jk),modifier:zk(Jk),operatorKeyword:zk(Jk),controlKeyword:zk(Jk),definitionKeyword:zk(Jk),moduleKeyword:zk(Jk),operator:Qk,derefOperator:zk(Qk),arithmeticOperator:zk(Qk),logicOperator:zk(Qk),bitwiseOperator:zk(Qk),compareOperator:zk(Qk),updateOperator:zk(Qk),definitionOperator:zk(Qk),typeOperator:zk(Qk),controlOperator:zk(Qk),punctuation:Zk,separator:zk(Zk),bracket:eS,angleBracket:zk(eS),squareBracket:zk(eS),paren:zk(eS),brace:zk(eS),content:Gk,heading:Xk,heading1:zk(Xk),heading2:zk(Xk),heading3:zk(Xk),heading4:zk(Xk),heading5:zk(Xk),heading6:zk(Xk),contentSeparator:zk(Gk),list:zk(Gk),quote:zk(Gk),emphasis:zk(Gk),strong:zk(Gk),link:zk(Gk),monospace:zk(Gk),strikethrough:zk(Gk),inserted:zk(),deleted:zk(),changed:zk(),invalid:zk(),meta:tS,documentMeta:zk(tS),annotation:zk(tS),processingInstruction:zk(tS),definition:Dk.defineModifier("definition"),constant:Dk.defineModifier("constant"),function:Dk.defineModifier("function"),standard:Dk.defineModifier("standard"),local:Dk.defineModifier("local"),special:Dk.defineModifier("special")};for(let e in nS){let t=nS[e];t instanceof Dk&&(t.name=e)}var rS;jk([{tag:nS.link,class:"tok-link"},{tag:nS.heading,class:"tok-heading"},{tag:nS.emphasis,class:"tok-emphasis"},{tag:nS.strong,class:"tok-strong"},{tag:nS.keyword,class:"tok-keyword"},{tag:nS.atom,class:"tok-atom"},{tag:nS.bool,class:"tok-bool"},{tag:nS.url,class:"tok-url"},{tag:nS.labelName,class:"tok-labelName"},{tag:nS.inserted,class:"tok-inserted"},{tag:nS.deleted,class:"tok-deleted"},{tag:nS.literal,class:"tok-literal"},{tag:nS.string,class:"tok-string"},{tag:nS.number,class:"tok-number"},{tag:[nS.regexp,nS.escape,nS.special(nS.string)],class:"tok-string2"},{tag:nS.variableName,class:"tok-variableName"},{tag:nS.local(nS.variableName),class:"tok-variableName tok-local"},{tag:nS.definition(nS.variableName),class:"tok-variableName tok-definition"},{tag:nS.special(nS.variableName),class:"tok-variableName2"},{tag:nS.definition(nS.propertyName),class:"tok-propertyName tok-definition"},{tag:nS.typeName,class:"tok-typeName"},{tag:nS.namespace,class:"tok-namespace"},{tag:nS.className,class:"tok-className"},{tag:nS.macroName,class:"tok-macroName"},{tag:nS.propertyName,class:"tok-propertyName"},{tag:nS.operator,class:"tok-operator"},{tag:nS.comment,class:"tok-comment"},{tag:nS.meta,class:"tok-meta"},{tag:nS.invalid,class:"tok-invalid"},{tag:nS.punctuation,class:"tok-punctuation"}]);const iS=new nk;const oS=new nk;class sS{constructor(e,t,n=[],r=""){this.data=e,this.name=r,Sm.prototype.hasOwnProperty("tree")||Object.defineProperty(Sm.prototype,"tree",{get(){return cS(this)}}),this.parser=t,this.extension=[bS.of(this),Sm.languageData.of((e,t,n)=>{let r=aS(e,t,n),i=r.type.prop(iS);if(!i)return[];let o=e.facet(i),s=r.type.prop(oS);if(s){let i=r.resolve(t-r.from,n);for(let t of s)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o})].concat(n)}isActiveAt(e,t,n=-1){return aS(e,t,n).type.prop(iS)==this.data}findRegions(e){let t=e.facet(bS);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(iS)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(nk.mounted);if(i){if(i.tree.prop(iS)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof hk&&r(i,e.positions[n]+t)}};return r(cS(e),0),n}get allowsNesting(){return!0}}function aS(e,t,n){let r=e.facet(bS),i=cS(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,ck.ExcludeBuffers|ck.EnterBracketed))e.type.isTop&&(i=e);return i}sS.setState=um.define();class lS extends sS{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,Bp.define({combine:n?e=>e.concat(n):void 0}));var n;return new lS(t,e.parser.configure({props:[iS.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new lS(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function cS(e){let t=e.field(sS.state,!1);return t?t.tree:hk.empty}class hS{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let uS=null;class dS{constructor(e,t,n=[],r,i,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new dS(e,t,[],hk.empty,0,n,[],null)}startParse(){return this.parser.startParse(new hS(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=hk.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(Ak.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ak.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=uS;uS=this;try{return e()}finally{uS=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=fS(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:i,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i})),n=Ak.applyChanges(n,t),r=hk.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&s.push({from:n,to:r})}}}return new dS(this.parser,t,n,r,i,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=fS(this.fragments,n,r),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Tk{createParse(t,n,r){let i=r[0].from,o=r[r.length-1].to,s={parsedPos:i,advance(){let t=uS;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new hk(ok.none,[],[],o-i)},stoppedAt:null,stopAt(){}};return s}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return uS}}function fS(e,t,n){return Ak.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class pS{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new pS(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=dS.create(e.facet(bS).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new pS(n)}}sS.state=Hp.define({create:pS.init,update(e,t){for(let e of t.effects)if(e.is(sS.setState))return e.value;return t.startState.facet(bS)!=t.state.facet(bS)?pS.init(t.state):e.apply(t)}});let mS=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(mS=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const gS="undefined"!=typeof navigator&&(null===(rS=navigator.scheduling)||void 0===rS?void 0:rS.isInputPending)?()=>navigator.scheduling.isInputPending():null,vS=Iv.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(sS.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(sS.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=mS(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(sS.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!gS?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,a=i.context.work(()=>gS&&gS()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:sS.setState.of(new pS(i.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Dv(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),bS=Bp.define({combine:e=>e.length?e[0]:null,enables:e=>[sS.state,vS,lw.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class yS{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const wS=Bp.define(),xS=Bp.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function kS(e){let t=e.facet(xS);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function SS(e,t){let n="",r=e.tabSize,i=e.facet(xS)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let e=0;e<t;e++)n+=i;return n}function ES(e,t){e instanceof Sm&&(e=new CS(e));for(let n of e.state.facet(wS)){let r=n(e,t);if(void 0!==r)return r}let n=cS(e.state);return n.length>=t?function(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return OS(r,e,n)}(e,n,t):null}class CS{constructor(e,t={}){this.state=e,this.options=t,this.unit=kS(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Hm(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const NS=new nk;function OS(e,t,n){for(let r=e;r;r=r.next){let e=AS(r.node);if(e)return e(MS.create(t,n,r))}return 0}function AS(e){let t=e.type.prop(NS);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(nk.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=s)return null;let e=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?TS:null}function TS(){return 0}class MS extends CS{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new MS(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(RS(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return OS(this.context.next,this.base,this.pos)}}function RS(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function DS({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const PS=Bp.define(),LS=new nk;function BS(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function IS(e,t,n){for(let r of e.facet(PS)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=cS(e);if(r.length<n)return null;let i=null;for(let o=r.resolveStack(n,1);o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<t)break;let a=s.type.prop(LS);if(a&&(s.to<r.length-50||r.length==e.doc.length||!BS(s))){let r=a(s,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function _S(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const jS=um.define({map:_S}),FS=um.define({map:_S});function WS(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const zS=Hp.define({create:()=>Sg.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=HS(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(jS)&&!qS(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(GS),i=r?Sg.replace({widget:new ZS(r(t.state,n.value))}):QS;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(FS)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=HS(e,t.selection.main.head)),e},provide:e=>lw.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(QS.range(r,i))}return Sg.set(t,!0)}});function HS(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function VS(e,t,n){var r;let i=null;return null===(r=e.field(zS,!1))||void 0===r||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function qS(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function US(e,t){return e.field(zS,!1)?t:t.concat(um.appendConfig.of(XS()))}function $S(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return lw.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const KS=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of WS(e)){let n=IS(e.state,t.from,t.to);if(n)return e.dispatch({effects:US(e.state,[jS.of(n),$S(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(zS,!1))return!1;let t=[];for(let n of WS(e)){let r=VS(e.state,n.from,n.to);r&&t.push(FS.of(r),$S(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=IS(t,i.from,i.to);o&&n.push(jS.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:US(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(zS,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(FS.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],YS={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},GS=Bp.define({combine:e=>Em(e,YS)});function XS(e){let t=[zS,nE];return e&&t.push(GS.of(e)),t}function JS(e,t){let{state:n}=e,r=n.facet(GS),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=VS(e.state,n.from,n.to);r&&e.dispatch({effects:FS.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const QS=Sg.replace({widget:new class extends xg{toDOM(e){return JS(e,null)}}});class ZS extends xg{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return JS(e,this.value)}}const eE={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class tE extends Mx{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}const nE=lw.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class rE{constructor(e,t){let n;function r(e){let t=Km.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof sS?e=>e.prop(iS)==o.data:o?e=>e==o:void 0,this.style=jk(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Km(n):null,this.themeType=t.themeType}static define(e,t){return new rE(e,t||{})}}const iE=Bp.define(),oE=Bp.define({combine:e=>e.length?[e[0]]:null});function sE(e){let t=e.facet(iE);return t.length?t:e.facet(oE)}function aE(e,t){let n,r=[cE];return e instanceof rE&&(e.module&&r.push(lw.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(oE.of(e)):n?r.push(iE.computeN([lw.darkTheme],t=>t.facet(lw.darkTheme)==("dark"==n)?[e]:[])):r.push(iE.of(e)),r}class lE{constructor(e){this.markCache=Object.create(null),this.tree=cS(e.state),this.decorations=this.buildDeco(e,sE(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=cS(e.state),n=sE(e.state),r=n!=sE(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return Sg.none;let n=new Rm;for(let{from:r,to:i}of e.visibleRanges)Fk(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=Sg.mark({class:r})))},r,i);return n.finish()}}const cE=Yp.high(Iv.fromClass(lE,{decorations:e=>e.decorations})),hE=rE.define([{tag:nS.meta,color:"#404740"},{tag:nS.link,textDecoration:"underline"},{tag:nS.heading,textDecoration:"underline",fontWeight:"bold"},{tag:nS.emphasis,fontStyle:"italic"},{tag:nS.strong,fontWeight:"bold"},{tag:nS.strikethrough,textDecoration:"line-through"},{tag:nS.keyword,color:"#708"},{tag:[nS.atom,nS.bool,nS.url,nS.contentSeparator,nS.labelName],color:"#219"},{tag:[nS.literal,nS.inserted],color:"#164"},{tag:[nS.string,nS.deleted],color:"#a11"},{tag:[nS.regexp,nS.escape,nS.special(nS.string)],color:"#e40"},{tag:nS.definition(nS.variableName),color:"#00f"},{tag:nS.local(nS.variableName),color:"#30a"},{tag:[nS.typeName,nS.namespace],color:"#085"},{tag:nS.className,color:"#167"},{tag:[nS.special(nS.variableName),nS.macroName],color:"#256"},{tag:nS.definition(nS.propertyName),color:"#00c"},{tag:nS.comment,color:"#940"},{tag:nS.invalid,color:"#f00"}]),uE=lw.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),dE="()[]{}",fE=Bp.define({combine:e=>Em(e,{afterCursor:!0,brackets:dE,maxScanDistance:1e4,renderMatch:gE})}),pE=Sg.mark({class:"cm-matchingBracket"}),mE=Sg.mark({class:"cm-nonmatchingBracket"});function gE(e){let t=[],n=e.matched?pE:mE;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const vE=Hp.define({create:()=>Sg.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(fE);for(let e of t.state.selection.ranges){if(!e.empty)continue;let i=kE(t.state,e.head,-1,r)||e.head>0&&kE(t.state,e.head-1,1,r)||r.afterCursor&&(kE(t.state,e.head,1,r)||e.head<t.state.doc.length&&kE(t.state,e.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,t.state)))}return Sg.set(n,!0)},provide:e=>lw.decorations.from(e)}),bE=[vE,uE];const yE=new nk;function wE(e,t,n){let r=e.prop(t<0?nk.openedBy:nk.closedBy);if(r)return r;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function xE(e){let t=e.type.prop(yE);return t?t(e.node):e}function kE(e,t,n,r={}){let i=r.maxScanDistance||1e4,o=r.brackets||dE,s=cS(e),a=s.resolveInner(t,n);for(let r=a;r;r=r.parent){let i=wE(r.type,n,o);if(i&&r.from<r.to){let s=xE(r);if(s&&(n>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return SE(e,t,n,r,s,i,o)}}return function(e,t,n,r,i,o,s){let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!h.next().done&&e<=o;){let o=h.value;n<0&&(e+=o.length);let a=t+e*n;for(let e=n>0?0:o.length-1,t=n>0?o.length:-1;e!=t;e+=n){let t=s.indexOf(o[e]);if(!(t<0||r.resolveInner(a+e,1).type!=i))if(t%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}n>0&&(e+=o.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,i,o)}function SE(e,t,n,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},c=0,h=null==a?void 0:a.cursor();if(h&&(n<0?h.childBefore(r.from):h.childAfter(r.to)))do{if(n<0?h.to<=r.from:h.from>=r.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let e=xE(h);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(wE(h.type,n,s))c++;else if(wE(h.type,-n,s)){if(0==c){let e=xE(h);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const EE=Object.create(null),CE=[ok.none],NE=[],OE=Object.create(null),AE=Object.create(null);for(let[e,t]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"]])AE[e]=ME(EE,t);function TE(e,t){NE.indexOf(e)>-1||NE.push(e)}function ME(e,t){let n=[];for(let r of t.split(" ")){let t=[];for(let n of r.split(".")){let r=e[n]||nS[n];r?"function"==typeof r?t.length?t=t.map(r):TE(n):t.length?TE(n):t=Array.isArray(r)?r:[r]:TE(n)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(e=>e.id),o=OE[i];if(o)return o.id;let s=OE[i]=ok.define({id:CE.length,name:r,props:[Bk({[r]:n})]});return CE.push(s),s.id}Qg.RTL,Qg.LTR;function RE(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const DE=RE(jE,0),PE=RE(_E,0),LE=RE((e,t)=>_E(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t)),0);function BE(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const IE=50;function _E(e,t,n=t.selection.ranges){let r=n.map(e=>BE(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>function(e,{open:t,close:n},r,i){let o,s,a=e.sliceDoc(r-IE,r),l=e.sliceDoc(i,i+IE),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-t.length,u)==t&&l.slice(h,h+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-r<=2*IE?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+IE),s=e.sliceDoc(i-IE,i));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(s)[0].length,p=s.length-f-n.length;return o.slice(d,d+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:i-f-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,r[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function jE(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:e,to:o}of n){let n=r.length,s=1e9,a=BE(t,e).line;if(a){for(let n=e;n<=o;){let l=t.doc.lineAt(n);if(l.from>i&&(e==o||o>l.from)){i=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,n=l.text.slice(e,e+a.length)==a?e:-1;e<l.text.length&&e<s&&(s=e),r.push({line:l,comment:n,token:a,indent:e,empty:t,single:!1})}n=l.to+1}if(s<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=s);r.length==n+1&&(r[n].single=!0)}}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:o,single:s}of r)!s&&o||e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const FE=lm.define(),WE=lm.define(),zE=Bp.define(),HE=Bp.define({combine:e=>Em(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),VE=Hp.define({create:()=>oC.empty,update(e,t){let n=t.state.facet(HE),r=t.annotation(FE);if(r){let i=GE.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?XE(s,s.length,n.minDepth,i):eC(s,t.startState.selection),new oC(0==o?r.rest:s,0==o?s:r.rest)}let i=t.annotation(WE);if("full"!=i&&"before"!=i||(e=e.isolate()),!1===t.annotation(dm.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=GE.fromTransaction(t),s=t.annotation(dm.time),a=t.annotation(dm.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),"full"!=i&&"after"!=i||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new oC(e.done.map(GE.fromJSON),e.undone.map(GE.fromJSON))});function qE(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(VE,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const UE=qE(0,!1),$E=qE(1,!1),KE=qE(0,!0),YE=qE(1,!0);class GE{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new GE(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new GE(e.changes&&Ep.fromJSON(e.changes),[],e.mapped&&Sp.fromJSON(e.mapped),e.startSelection&&Dp.fromJSON(e.startSelection),e.selectionsAfter.map(Dp.fromJSON))}static fromTransaction(e,t){let n=QE;for(let t of e.startState.facet(zE)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new GE(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,QE)}static selection(e){return new GE(void 0,QE,void 0,void 0,e)}}function XE(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function JE(e,t){return e.length?t.length?e.concat(t):e:t}const QE=[],ZE=200;function eC(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ZE));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),XE(e,e.length-1,1e9,n.setSelAfter(r)))}return[GE.selection([t])]}function tC(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function nC(e,t){if(!e.length)return e;let n=e.length,r=QE;for(;n;){let i=rC(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[GE.selection(r)]:QE}function rC(e,t,n){let r=JE(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):QE,n);if(!e.changes)return GE.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new GE(i,um.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const iC=/^(input\.type|delete)($|\.)/;class oC{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new oC(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||iC.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,function(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,o)=>{for(let e=0;e<n.length;){let t=n[e++],s=n[e++];o>=t&&i<=s&&(r=!0)}}),r}(s.changes,e.changes))||"input.type.compose"==n)?XE(o,o.length-1,r.minDepth,new GE(e.changes.compose(s.changes),JE(um.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,QE)):XE(o,o.length,r.minDepth,e),new oC(o,QE,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:QE;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter((e,t)=>e.empty!=s.ranges[t].empty).length)?this:new oC(eC(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new oC(nC(this.done,e),nC(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1],o=i.selectionsAfter[0]||t.selection;if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:FE.of({side:e,rest:tC(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?QE:r.slice(0,r.length-1);return i.mapped&&(n=nC(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:FE.of({side:e,rest:n,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}oC.empty=new oC(QE,QE);const sC=[{key:"Mod-z",run:UE,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:$E,preventDefault:!0},{linux:"Ctrl-Shift-z",run:$E,preventDefault:!0},{key:"Mod-u",run:KE,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:YE,preventDefault:!0}];function aC(e,t){return Dp.create(e.ranges.map(t),e.mainIndex)}function lC(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function cC({state:e,dispatch:t},n){let r=aC(e.selection,n);return!r.eq(e.selection,!0)&&(t(lC(e,r)),!0)}function hC(e,t){return Dp.cursor(t?e.to:e.from)}function uC(e,t){return cC(e,n=>n.empty?e.moveByChar(n,t):hC(n,t))}function dC(e){return e.textDirectionAt(e.state.selection.main.head)==Qg.LTR}const fC=e=>uC(e,!dC(e)),pC=e=>uC(e,dC(e));function mC(e,t){return cC(e,n=>n.empty?e.moveByGroup(n,t):hC(n,t))}function gC(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function vC(e,t,n){let r,i,o=cS(e).resolveInner(t.head),s=n?nk.closedBy:nk.openedBy;for(let r=t.head;;){let t=n?o.childAfter(r):o.childBefore(r);if(!t)break;gC(e,t,s)?o=t:r=n?t.to:t.from}return i=o.type.prop(s)&&(r=n?kE(e,o.from,1):kE(e,o.to,-1))&&r.matched?n?r.end.to:r.end.from:n?o.to:o.from,Dp.cursor(i,n?-1:1)}function bC(e,t){return cC(e,n=>{if(!n.empty)return hC(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const yC=e=>bC(e,!1),wC=e=>bC(e,!0);function xC(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){for(let t of e.state.facet(lw.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(r=Math.max(null==n?void 0:n.top,r)),(null==n?void 0:n.bottom)&&(i=Math.max(null==n?void 0:n.bottom,i))}t=e.scrollDOM.clientHeight-r-i}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:i,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function kC(e,t){let n,r=xC(e),{state:i}=e,o=aC(i.selection,n=>n.empty?e.moveVertically(n,t,r.height):hC(n,t));if(o.eq(i.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(i.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),a=s.top+r.marginTop,l=s.bottom-r.marginBottom;t&&t.top>a&&t.bottom<l&&(n=lw.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(lC(i,o),{effects:n}),!0}const SC=e=>kC(e,!1),EC=e=>kC(e,!0);function CC(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=Dp.cursor(r.from+n))}return i}function NC(e,t){let n=aC(e.state.selection,e=>{let n=t(e);return Dp.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(lC(e.state,n)),!0)}function OC(e,t){return NC(e,n=>e.moveByChar(n,t))}const AC=e=>OC(e,!dC(e)),TC=e=>OC(e,dC(e));function MC(e,t){return NC(e,n=>e.moveByGroup(n,t))}function RC(e,t){return NC(e,n=>e.moveVertically(n,t))}const DC=e=>RC(e,!1),PC=e=>RC(e,!0);function LC(e,t){return NC(e,n=>e.moveVertically(n,t,xC(e).height))}const BC=e=>LC(e,!1),IC=e=>LC(e,!0),_C=({state:e,dispatch:t})=>(t(lC(e,{anchor:0})),!0),jC=({state:e,dispatch:t})=>(t(lC(e,{anchor:e.doc.length})),!0),FC=({state:e,dispatch:t})=>(t(lC(e,{anchor:e.selection.main.anchor,head:0})),!0),WC=({state:e,dispatch:t})=>(t(lC(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function zC(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let o=n.doc.lineAt(r.head);if(t?o.to<e.state.doc.length:o.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<o.from||r.head>o.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(lC(n,Dp.create(i,i.length-1))),!0)}function HC(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:o}=r;if(i==o){let s=t(r);s<i?(n="delete.backward",s=VC(e,s,!1)):s>i&&(n="delete.forward",s=VC(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=VC(e,i,!1),o=VC(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:Dp.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?lw.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function VC(e,t,n){if(e instanceof lw)for(let r of e.state.facet(lw.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}const qC=(e,t,n)=>HC(e,r=>{let i,o,s=r.from,{state:a}=e,l=a.doc.lineAt(s);if(n&&!t&&s>l.from&&s<l.from+200&&!/[^ \t]/.test(i=l.text.slice(0,s-l.from))){if("\t"==i[i.length-1])return s-1;let e=Hm(i,a.tabSize)%kS(a)||kS(a);for(let t=0;t<e&&" "==i[i.length-1-t];t++)s--;o=s}else o=vp(l.text,s-l.from,t,t)+l.from,o==s&&l.number!=(t?a.doc.lines:1)?o+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,s-l.from))&&(o=vp(l.text,o-l.from,!1,!1)+l.from);return o}),UC=e=>qC(e,!1,!0),$C=e=>qC(e,!0,!1),KC=(e,t)=>HC(e,n=>{let r=n.head,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let e=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let a=vp(o.text,r-o.from,t)+o.from,l=o.text.slice(Math.min(r,a)-o.from,Math.max(r,a)-o.from),c=s(l);if(null!=e&&c!=e)break;" "==l&&r==n.head||(e=c),r=a}return r}),YC=e=>KC(e,!1);function GC(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function XC(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of GC(e)){if(n?t.to==e.doc.length:0==t.from)continue;let o=e.doc.lineAt(n?t.to+1:t.from-1),s=o.length+1;if(n){r.push({from:t.to,to:o.to},{from:t.from,insert:o.text+e.lineBreak});for(let n of t.ranges)i.push(Dp.range(Math.min(e.doc.length,n.anchor+s),Math.min(e.doc.length,n.head+s)))}else{r.push({from:o.from,to:t.from},{from:t.to,insert:e.lineBreak+o.text});for(let e of t.ranges)i.push(Dp.range(e.anchor-s,e.head-s))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:Dp.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function JC(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of GC(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const QC=eN(!1),ZC=eN(!0);function eN(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,o=t.doc.lineAt(r),s=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=cS(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(nk.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(i.to,o.from))?{from:i.to,to:o.from}:null}(t,r);e&&(r=i=(i<=o.to?o:t.doc.lineAt(i)).to);let a=new CS(t,{simulateBreak:r,simulateDoubleBreak:!!s}),l=ES(a,r);for(null==l&&(l=Hm(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));i<o.to&&/\s/.test(o.text[i-o.from]);)i++;s?({from:r,to:i}=s):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",SS(t,l)];return s&&c.push(SS(t,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:ap.of(c)},range:Dp.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function tN(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let s=e.doc.lineAt(o);s.number>n&&(r.empty||r.to>s.from)&&(t(s,i,r),n=s.number),o=s.to+1}let o=e.changes(i);return{changes:i,range:Dp.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const nN=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(tN(e,(t,n)=>{n.push({from:t.from,insert:e.facet(xS)})}),{userEvent:"input.indent"})),!0),rN=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(tN(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Hm(r,e.tabSize),o=0,s=SS(e,Math.max(0,i-kS(e)));for(;o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:s.slice(o)})}),{userEvent:"delete.dedent"})),!0),iN=[{key:"Ctrl-b",run:fC,shift:AC,preventDefault:!0},{key:"Ctrl-f",run:pC,shift:TC},{key:"Ctrl-p",run:yC,shift:DC},{key:"Ctrl-n",run:wC,shift:PC},{key:"Ctrl-a",run:e=>cC(e,t=>Dp.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>NC(e,t=>Dp.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>cC(e,t=>Dp.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>NC(e,t=>Dp.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:$C},{key:"Ctrl-h",run:UC},{key:"Ctrl-k",run:e=>HC(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:YC},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:ap.of(["",""])},range:Dp.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:vp(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:vp(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(i,n))},range:Dp.cursor(o)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:EC}],oN=[{key:"ArrowLeft",run:fC,shift:AC,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>mC(e,!dC(e)),shift:e=>MC(e,!dC(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>cC(e,t=>CC(e,t,!dC(e))),shift:e=>NC(e,t=>CC(e,t,!dC(e))),preventDefault:!0},{key:"ArrowRight",run:pC,shift:TC,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>mC(e,dC(e)),shift:e=>MC(e,dC(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>cC(e,t=>CC(e,t,dC(e))),shift:e=>NC(e,t=>CC(e,t,dC(e))),preventDefault:!0},{key:"ArrowUp",run:yC,shift:DC,preventDefault:!0},{mac:"Cmd-ArrowUp",run:_C,shift:FC},{mac:"Ctrl-ArrowUp",run:SC,shift:BC},{key:"ArrowDown",run:wC,shift:PC,preventDefault:!0},{mac:"Cmd-ArrowDown",run:jC,shift:WC},{mac:"Ctrl-ArrowDown",run:EC,shift:IC},{key:"PageUp",run:SC,shift:BC},{key:"PageDown",run:EC,shift:IC},{key:"Home",run:e=>cC(e,t=>CC(e,t,!1)),shift:e=>NC(e,t=>CC(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:_C,shift:FC},{key:"End",run:e=>cC(e,t=>CC(e,t,!0)),shift:e=>NC(e,t=>CC(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:jC,shift:WC},{key:"Enter",run:QC,shift:QC},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:UC,shift:UC,preventDefault:!0},{key:"Delete",run:$C,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:YC,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>KC(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>HC(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>HC(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(iN.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sN=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>cC(e,t=>vC(e.state,t,!dC(e))),shift:e=>NC(e,t=>vC(e.state,t,!dC(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>cC(e,t=>vC(e.state,t,dC(e))),shift:e=>NC(e,t=>vC(e.state,t,dC(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>XC(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>JC(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>XC(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>JC(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>zC(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>zC(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Dp.create([n.main]):n.main.empty||(r=Dp.create([Dp.cursor(n.main.head)])),!!r&&(t(lC(e,r)),!0)}},{key:"Mod-Enter",run:ZC},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=GC(e).map(({from:t,to:n})=>Dp.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Dp.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=aC(e.selection,t=>{let n=cS(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return Dp.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(lC(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:rN},{key:"Mod-]",run:nN},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new CS(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=tN(e,(t,i,o)=>{let s=ES(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=SS(e,s);(a!=l||o.from<t.from+a.length)&&(n[t.from]=s,i.push({from:t.from,to:t.from+a.length,insert:l}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(GC(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=aC(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,n){let r=!1,i=aC(e.selection,t=>{let i=kE(e,t.head,-1)||kE(e,t.head,1)||t.head>0&&kE(e,t.head-1,1)||t.head<e.doc.length&&kE(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let o=i.start.from==t.head?i.end.to:i.end.from;return n?Dp.range(t.anchor,o):Dp.cursor(o)});return!!r&&(t(lC(e,i)),!0)}(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=BE(e.state,n.from);return r.line?DE(e):!!r.block&&LE(e)}},{key:"Alt-A",run:PE},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(oN),aN={key:"Tab",run:nN,shift:rN},lN="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class cN{constructor(e,t,n=0,r=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(lN(e)):lN,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return bp(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=yp(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=wp(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let o=r.charCodeAt(e),s=this.match(o,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(s)return this.value=s,this;break}i==n&&e<t.length&&t.charCodeAt(e)==o&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,o=!0)),o||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(cN.prototype[Symbol.iterator]=function(){return this});const hN={from:-1,to:-1,match:/.*/.exec("")},uN="gm"+(null==/x/.unicode?"":"u");class dN{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=hN,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new mN(e,t,n,r,i);this.re=new RegExp(t,uN+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=gN(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=gN(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const fN=new WeakMap;class pN{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=fN.get(e);if(!r||r.from>=n||r.to<=t){let r=new pN(t,e.sliceString(t,n));return fN.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),fN.set(e,new pN(o,i)),new pN(t,i.slice(t-o,n-o))}}class mN{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=hN,this.matchPos=gN(e,r),this.re=new RegExp(t,uN+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=pN.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=gN(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=pN.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function gN(e,t){if(t>=e.length)return t;let n,r=e.lineAt(t);for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(dN.prototype[Symbol.iterator]=mN.prototype[Symbol.iterator]=function(){return this});const vN={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},bN=Bp.define({combine:e=>Em(e,vN,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const yN=Sg.mark({class:"cm-selectionMatch"}),wN=Sg.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function xN(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==ym.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==ym.Word)}const kN=Iv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(bN),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Sg.none;let i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return Sg.none;let e=n.wordAt(o.head);if(!e)return Sg.none;s=n.charCategorizer(o.head),i=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return Sg.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!xN(s,n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==ym.Word&&e(t.sliceDoc(r-1,r))==ym.Word}(s,n,o.from,o.to))return Sg.none}else if(i=n.sliceDoc(o.from,o.to),!i)return Sg.none}let a=[];for(let r of e.visibleRanges){let e=new cN(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!s||xN(s,n,r,i))&&(o.empty&&r<=o.from&&i>=o.to?a.push(wN.range(r,i)):(r>=o.to||i<=o.from)&&a.push(yN.range(r,i)),a.length>t.maxMatches))return Sg.none}}return Sg.set(a)}},{decorations:e=>e.decorations}),SN=lw.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const EN=Bp.define({combine:e=>Em(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ZN(e),scrollToMatch:e=>lw.scrollIntoView(e)})});class CN{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,uN),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new DN(this):new AN(this)}getCursor(e,t=0,n){let r=e.doc?e:Sm.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?TN(this,r,t,n):ON(this,r,t,n)}}class NN{constructor(e){this.spec=e}}function ON(e,t,n,r){let i;return e.wholeWord&&(i=function(e,t){return(n,r,i,o)=>((o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),!(t(MN(i,n-o))==ym.Word&&t(RN(i,n-o))==ym.Word||t(RN(i,r-o))==ym.Word&&t(MN(i,r-o))==ym.Word))}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=function(e,t,n){return(r,i,o,s)=>{if(n&&!n(r,i,o,s))return!1;let a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}(e.test,t,i)),new cN(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}class AN extends NN{constructor(e){super(e)}nextMatch(e,t,n){let r=ON(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=ON(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=ON(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!r||r.from==t&&r.to==n?null:r}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=ON(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ON(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function TN(e,t,n,r){let i;var o;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),i=(e,t,n)=>!n[0].length||(o(MN(n.input,n.index))!=ym.Word||o(RN(n.input,n.index))!=ym.Word)&&(o(RN(n.input,n.index+n[0].length))!=ym.Word||o(MN(n.input,n.index+n[0].length))!=ym.Word)),e.test&&(i=function(e,t,n){return(r,i,o)=>(!n||n(r,i,o))&&e(o[0],t,r,i)}(e.test,t,i)),new dN(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function MN(e,t){return e.slice(vp(e,t,!1),t)}function RN(e,t){return e.slice(t,vp(e,t))}class DN extends NN{nextMatch(e,t,n){let r=TN(this.spec,e,n,e.doc.length).next();return r.done&&(r=TN(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),o=TN(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=TN(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=TN(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const PN=um.define(),LN=um.define(),BN=Hp.define({create:e=>new IN(KN(e).create(),null),update(e,t){for(let n of t.effects)n.is(PN)?e=new IN(n.value.create(),e.panel):n.is(LN)&&(e=new IN(e.query,n.value?$N:null));return e},provide:e=>Cx.from(e,e=>e.panel)});class IN{constructor(e,t){this.query=e,this.panel=t}}const _N=Sg.mark({class:"cm-searchMatch"}),jN=Sg.mark({class:"cm-searchMatch cm-searchMatch-selected"}),FN=Iv.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(BN))}update(e){let t=e.state.field(BN);(t!=e.startState.field(BN)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Sg.none;let{view:n}=this,r=new Rm;for(let t=0,i=n.visibleRanges,o=i.length;t<o;t++){let{from:s,to:a}=i[t];for(;t<o-1&&a>i[t+1].from-500;)a=i[++t].to;e.highlight(n.state,s,a,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?jN:_N)})}return r.finish()}},{decorations:e=>e.decorations});function WN(e){return t=>{let n=t.state.field(BN,!1);return n&&n.query.spec.valid?e(t,n):XN(t)}}const zN=WN((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Dp.single(r.from,r.to),o=e.state.facet(EN);return e.dispatch({selection:i,effects:[rO(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),GN(e),!0}),HN=WN((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=Dp.single(i.from,i.to),s=e.state.facet(EN);return e.dispatch({selection:o,effects:[rO(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),GN(e),!0}),VN=WN((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:Dp.create(n.map(e=>Dp.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),qN=WN((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s,a,l=o,c=[],h=[];l.from==r&&l.to==i&&(a=n.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=t.nextMatch(n,l.from,l.to),h.push(lw.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let u=e.state.changes(c);return l&&(s=Dp.single(l.from,l.to).map(u),h.push(rO(e,l)),h.push(n.facet(EN).scrollToMatch(s.main,e))),e.dispatch({changes:u,selection:s,effects:h,userEvent:"input.replace"}),!0}),UN=WN((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:lw.announce.of(r),userEvent:"input.replace.all"}),!0});function $N(e){return e.state.facet(EN).createPanel(e)}function KN(e,t){var n,r,i,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(EN);return new CN({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null==t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function YN(e){let t=xx(e,$N);return t&&t.dom.querySelector("[main-field]")}function GN(e){let t=YN(e);t&&t==e.root.activeElement&&t.select()}const XN=e=>{let t=e.state.field(BN,!1);if(t&&t.panel){let n=YN(e);if(n&&n!=e.root.activeElement){let r=KN(e.state,t.query.spec);r.valid&&e.dispatch({effects:PN.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[LN.of(!0),t?PN.of(KN(e.state,t.query.spec)):um.appendConfig.of(oO)]});return!0},JN=e=>{let t=e.state.field(BN,!1);if(!t||!t.panel)return!1;let n=xx(e,$N);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:LN.of(!1)}),!0},QN=[{key:"Mod-f",run:XN,scope:"editor search-panel"},{key:"F3",run:zN,shift:HN,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:zN,shift:HN,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:JN,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let t=new cN(e.doc,e.sliceDoc(r,i));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(s=o.length),o.push(Dp.range(t.value.from,t.value.to))}return t(e.update({selection:Dp.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=Nx(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i)return void e.dispatch({effects:r});let o=t.doc.lineAt(t.selection.main.head),[,s,a,l,c]=i,h=l?+l.slice(1):0,u=a?+a:o.number;if(a&&c){let e=u/100;s&&(e=e*("-"==s?-1:1)+o.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else a&&s&&(u=u*("-"==s?-1:1)+o.number);let d=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),f=Dp.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[r,lw.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=Dp.create(n.ranges.map(t=>e.wordAt(t.head)||Dp.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new cN(e.doc,t,r[r.length-1].to);;){if(i.next(),!i.done){if(n&&r.some(e=>e.from==i.value.from))continue;if(o){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}if(n)return null;i=new cN(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}}(e,r);return!!i&&(t(e.update({selection:e.selection.addRange(Dp.range(i.from,i.to),!1),effects:lw.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class ZN{constructor(e){this.view=e;let t=this.query=e.state.field(BN).query.spec;function n(e,t,n){return ng("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=ng("input",{value:t.search,placeholder:eO(e,"Find"),"aria-label":eO(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ng("input",{value:t.replace,placeholder:eO(e,"Replace"),"aria-label":eO(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ng("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ng("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ng("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=ng("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>zN(e),[eO(e,"next")]),n("prev",()=>HN(e),[eO(e,"previous")]),n("select",()=>VN(e),[eO(e,"all")]),ng("label",null,[this.caseField,eO(e,"match case")]),ng("label",null,[this.reField,eO(e,"regexp")]),ng("label",null,[this.wordField,eO(e,"by word")]),...e.state.readOnly?[]:[ng("br"),this.replaceField,n("replace",()=>qN(e),[eO(e,"replace")]),n("replaceAll",()=>UN(e),[eO(e,"replace all")])],ng("button",{name:"close",onclick:()=>JN(e),"aria-label":eO(e,"close"),type:"button"},["×"])])}commit(){let e=new CN({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:PN.of(e)}))}keydown(e){var t,n,r;t=this.view,n=e,r="search-panel",kw(bw(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?HN:zN)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),qN(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(PN)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(EN).top}}function eO(e,t){return e.state.phrase(t)}const tO=30,nO=/[\s\.,:;?!]/;function rO(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-tO),s=Math.min(i,n+tO),a=e.state.sliceDoc(o,s);if(o!=r.from)for(let e=0;e<tO;e++)if(!nO.test(a[e+1])&&nO.test(a[e])){a=a.slice(e);break}if(s!=i)for(let e=a.length-1;e>a.length-tO;e--)if(!nO.test(a[e-1])&&nO.test(a[e])){a=a.slice(0,e);break}return lw.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}const iO=lw.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),oO=[BN,Yp.low(FN),iO];class sO{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=cS(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(uO(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function aO(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function lO(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=aO(t)+aO(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class cO{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function hO(e){return e.selection.main.from}function uO(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const dO=lm.define();function fO(e,t,n,r){let{main:i}=e.selection,o=n-i.from,s=r-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};let l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:Dp.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const pO=new WeakMap;function mO(e){if(!Array.isArray(e))return e;let t=pO.get(e);return t||pO.set(e,t=lO(e)),t}const gO=um.define(),vO=um.define();class bO{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=bp(e,t),r=wp(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(bp(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(1==t.length){let r=bp(e,0),i=wp(r),o=i==e.length?0:-100;if(r==t[0]);else{if(r!=n[0])return null;o+=-200}return this.ret(o,[0,i])}let s=e.indexOf(this.pattern);if(0==s)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&l<a;){let o=bp(e,i);o!=t[l]&&o!=n[l]||(r[l++]=i),i+=wp(o)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let r=0,l=Math.min(e.length,200),v=0;r<l&&h<a;){let l=bp(e,r);s<0&&(c<a&&l==t[c]&&(i[c++]=r),d<a&&(l==t[d]||l==n[d]?(0==d&&(f=r),p=r+1,d++):d=0));let b,y=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(b=yp(l))!=b.toLowerCase()?1:b!=b.toUpperCase()?2:0;(!r||1==y&&m||0==v&&0!=y)&&(t[h]==l||n[h]==l&&(u=!0)?o[h++]=r:o.length&&(g=!1)),v=y,r+=wp(l)}return h==a&&0==o[0]&&g?this.result((u?-200:0)-100,o,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),o,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?wp(bp(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}}class yO{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const wO=Bp.define({combine:e=>Em(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:kO,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>xO(e(n),t(n)),optionClass:(e,t)=>n=>xO(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function xO(e,t){return e?t?e+" "+t:e:t}function kO(e,t,n,r,i,o){let s,a,l=e.textDirection==Qg.RTL,c=l,h=!1,u="top",d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))s=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=m||e>t.top?s=n.bottom-t.top:(u="bottom",s=t.bottom-n.top)}return{style:`${u}: ${s/((t.bottom-t.top)/o.offsetHeight)}px; max-width: ${a/((t.right-t.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}function SO(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class EO{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(wO);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement("span");i.className="cm-completionLabel";let o=e.displayLabel||e.label,s=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>s&&i.appendChild(document.createTextNode(o.slice(s,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(t,n))),a.className="cm-completionMatchedText",s=n}return s<o.length&&i.appendChild(document.createTextNode(o.slice(s))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=SO(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:r}=e.state.field(t).open;for(let t,i=n.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(t=/-(\d+)$/.exec(i.id))&&+t[1]<r.length)return this.applyCompletion(e,r[+t[1]]),void n.preventDefault()}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(wO).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:vO.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:i,selected:o,disabled:s}=n.open;r.open&&r.open.options==i||(this.range=SO(i.length,o,e.state.facet(wO).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),s!=(null===(t=r.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=SO(t.options.length,t.selected,this.view.state.facet(wO).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o="string"==typeof i?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>Dv(this.view.state,e,"completion info")):(this.addInfoPane(o,r),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):r--;return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(wO).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",e=>{e.target==r&&e.preventDefault()});let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:a}=e[o],{section:l}=s;if(l){let e="string"==typeof l?l:l.name;if(e!=i&&(o>n.from||0==n.from))if(i=e,"string"!=typeof l&&l.header)r.appendChild(l.header(l));else{r.appendChild(document.createElement("completion-section")).textContent=e}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(s);h&&(c.className=h);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function CO(e,t){return n=>new EO(n,e,t)}function NO(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class OO{constructor(e,t,n,r,i,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new OO(this.options,RO(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,i,o){if(r&&!o&&e.some(e=>e.isPending))return r.setDisabled();let s=function(e,t){let n=[],r=null,i=null,o=e=>{n.push(e);let{section:t}=e.completion;if(t){r||(r=[]);let e="string"==typeof t?t:t.name;r.some(t=>t.name==e)||r.push("string"==typeof t?{name:e}:t)}},s=t.facet(wO);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(!1===r.result.filter)for(let t of r.result.options)o(new cO(t,r.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(r.from,r.to),l=s.filterStrict?new yO(a):new bO(a);for(let t of r.result.options)if(n=l.match(t.label)){let s=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(o(new cO(t,r.source,s,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;i||(i=Object.create(null)),i[e]=Math.max(a,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,o=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?i[t.name]-i[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(o))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=s.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?a.push(e):NO(e.completion)>NO(l)&&(a[a.length-1]=e),l=e.completion}return a}(e,t);if(!s.length)return r&&e.some(e=>e.isPending)?r.setDisabled():null;let a=t.facet(wO).selectOnOpen?0:-1;if(r&&r.selected!=a&&-1!=r.selected){let e=r.options[r.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){a=t;break}}return new OO(s,RO(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:WO,above:i.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new OO(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new OO(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class AO{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new AO(DO,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(wO),r=(n.override||t.languageDataAt("autocomplete",hO(t)).map(mO)).map(t=>(this.active.find(e=>e.source==t)||new LO(t,this.active.some(e=>0!=e.state)?1:0)).update(e,n));r.length==this.active.length&&r.every((e,t)=>e==this.active[t])&&(r=this.active);let i=this.open,o=e.effects.some(e=>e.is(IO));i&&e.docChanged&&(i=i.map(e.changes)),e.selection||r.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)||o?i=OO.build(r,t,this.id,i,n,o):i&&i.disabled&&!r.some(e=>e.isPending)&&(i=null),!i&&r.every(e=>!e.isPending)&&r.some(e=>e.hasResult())&&(r=r.map(e=>e.hasResult()?new LO(e.source,0):e));for(let t of e.effects)t.is(_O)&&(i=i&&i.setSelected(t.value,this.id));return r==this.active&&i==this.open?this:new AO(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?TO:MO}}const TO={"aria-autocomplete":"list"},MO={};function RO(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const DO=[];function PO(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(dO);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class LO{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=PO(e,t),r=this;(8&n||16&n&&this.touches(e))&&(r=new LO(r.source,0)),4&n&&0==r.state&&(r=new LO(this.source,1)),r=r.updateFor(e,n);for(let t of e.effects)if(t.is(gO))r=new LO(r.source,1,t.value);else if(t.is(vO))r=new LO(r.source,0);else if(t.is(IO))for(let e of t.value)e.source==r.source&&(r=e);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(hO(e.state))}}class BO extends LO{constructor(e,t,n,r,i,o){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=hO(e.state);if(s>o||!r||2&t&&(hO(e.startState)==this.from||s<this.limit))return new LO(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):uO(e,!0).test(i)}(r.validFor,e.state,i,o)?new BO(this.source,this.explicit,a,r,i,o):r.update&&(r=r.update(r,i,o,new sO(e.state,s,!1)))?new BO(this.source,this.explicit,a,r,r.from,null!==(n=r.to)&&void 0!==n?n:hO(e.state)):new LO(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new BO(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new LO(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const IO=um.define({map:(e,t)=>e.map(e=>e.map(t))}),_O=um.define(),jO=Hp.define({create:()=>AO.start(),update:(e,t)=>e.update(t),provide:e=>[ux.from(e,e=>e.tooltip),lw.contentAttributes.from(e,e=>e.attrs)]});function FO(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(jO).active.find(e=>e.source==t.source);return r instanceof BO&&("string"==typeof n?e.dispatch({...fO(e.state,n,r.from,r.to),annotations:dO.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}const WO=CO(jO,FO);function zO(e,t="option"){return n=>{let r=n.state.field(jO,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(wO).interactionDelay)return!1;let i,o=1;"page"==t&&(i=bx(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+o*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:_O.of(a)}),!0}}const HO=e=>!!e.state.field(jO,!1)&&(e.dispatch({effects:gO.of(!0)}),!0);class VO{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const qO=Iv.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(jO).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(jO),n=e.state.facet(wO);if(!e.selectionSet&&!e.docChanged&&e.startState.field(jO)==t)return;let r=e.transactions.some(e=>{let t=PO(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){Dv(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(gO)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(jO);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(wO).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=hO(t),r=new sO(t,n,e.explicit,this.view),i=new VO(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(e=>{i.context.aborted||(i.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:vO.of(null)}),Dv(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(wO).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(wO),r=this.view.state.field(jO);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(void 0===o.done)continue;if(this.running.splice(i--,1),o.done){let r=hO(o.updates.length?o.updates[0].startState:this.view.state),i=Math.min(r,o.done.from+(o.active.explicit?0:1)),s=new BO(o.active.source,o.active.explicit,i,o.done,o.done.from,null!==(e=o.done.to)&&void 0!==e?e:r);for(let e of o.updates)s=s.update(e,n);if(s.hasResult()){t.push(s);continue}}let s=r.active.find(e=>e.source==o.active.source);if(s&&s.isPending)if(null==o.done){let e=new LO(o.active.source,0);for(let t of o.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:IO.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(jO,!1);if(t&&t.tooltip&&this.view.state.facet(wO).closeOnBlur){let n=t.open&&bx(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:vO.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:gO.of(!1)}),20),this.composing=0}}}),UO="object"==typeof navigator&&/Win/.test(navigator.platform),$O=Yp.highest(lw.domEventHandlers({keydown(e,t){let n=t.state.field(jO,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!UO||!e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&FO(t,r),!1}})),KO=lw.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),YO={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},GO=um.define({map(e,t){let n=t.mapPos(e,-1,kp.TrackAfter);return null==n?void 0:n}}),XO=new class extends Cm{};XO.startSide=1,XO.endSide=-1;const JO=Hp.define({create:()=>Mm.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(GO)&&(e=e.update({add:[XO.range(n.value,n.value+1)]}));return e}});const QO="()[]{}<>«»»«[]{}";function ZO(e){for(let t=0;t<16;t+=2)if(QO.charCodeAt(t)==e)return QO.charAt(t+1);return yp(e<128?e:e+1)}function eA(e,t){return e.languageDataAt("closeBrackets",t)[0]||YO}const tA="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),nA=lw.inputHandler.of((e,t,n,r)=>{if((tA?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||2==r.length&&1==wp(bp(r,0))||t!=i.from||n!=i.to)return!1;let o=function(e,t){let n=eA(e,e.selection.main.head),r=n.brackets||YO.brackets;for(let i of r){let o=ZO(bp(i,0));if(t==i)return o==i?lA(e,i,r.indexOf(i+i+i)>-1,n):sA(e,i,o,n.before||YO.before);if(t==o&&iA(e,e.selection.main.from))return aA(e,i,o)}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),rA=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=eA(e,e.selection.main.head).brackets||YO.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return wp(bp(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let i of n)if(i==r&&oA(e.doc,t.head)==ZO(bp(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Dp.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function iA(e,t){let n=!1;return e.field(JO).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function oA(e,t){let n=e.sliceString(t,t+2);return n.slice(0,wp(bp(n,0)))}function sA(e,t,n,r){let i=null,o=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:GO.of(o.to+t.length),range:Dp.range(o.anchor+t.length,o.head+t.length)};let s=oA(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:GO.of(o.head+t.length),range:Dp.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function aA(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&oA(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Dp.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function lA(e,t,n,r){let i=r.stringPrefixes||YO.stringPrefixes,o=null,s=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:GO.of(r.to+t.length),range:Dp.range(r.anchor+t.length,r.head+t.length)};let s,a=r.head,l=oA(e.doc,a);if(l==t){if(cA(e,a))return{changes:{insert:t+t,from:a},effects:GO.of(a+t.length),range:Dp.cursor(a+t.length)};if(iA(e,a)){let r=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+r.length,insert:r},range:Dp.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=hA(e,a-2*t.length,i))>-1&&cA(e,s))return{changes:{insert:t+t+t+t,from:a},effects:GO.of(a+t.length),range:Dp.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=ym.Word&&hA(e,a,i)>-1&&!function(e,t,n,r){let i=cS(e).resolveInner(t,-1),o=r.reduce((e,t)=>Math.max(e,t.length),0);for(let s=0;s<5;s++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),a=s.indexOf(n);if(!a||a>-1&&r.indexOf(s.slice(0,a))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=i.to==t&&i.parent;if(!l)break;i=l}return!1}(e,a,t,i))return{changes:{insert:t+t,from:a},effects:GO.of(a+t.length),range:Dp.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function cA(e,t){let n=cS(e).resolveInner(t+1);return n.parent&&n.from==t}function hA(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ym.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=ym.Word)return n}return-1}const uA=[{key:"Ctrl-Space",run:HO},{mac:"Alt-`",run:HO},{mac:"Alt-i",run:HO},{key:"Escape",run:e=>{let t=e.state.field(jO,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:vO.of(null)}),!0)}},{key:"ArrowDown",run:zO(!0)},{key:"ArrowUp",run:zO(!1)},{key:"PageDown",run:zO(!0,"page")},{key:"PageUp",run:zO(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(jO,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(wO).interactionDelay)&&FO(e,t.open.options[t.open.selected])}}],dA=Yp.highest(gw.computeN([wO],e=>e.facet(wO).defaultKeymap?[uA]:[]));class fA{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class pA{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(NA).markerFilter;r&&(e=r(e,n));let i=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Rm,s=[],a=0,l=n.doc.iter(),c=0,h=n.doc.length;for(let e=0;;){let t,n,r=e==i.length?null:i[e];if(!r&&!s.length)break;if(s.length)t=a,n=s.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if(t=r.from,t>h)break;n=r.to,s.push(r),e++}for(;e<i.length;){let r=i[e];if(r.from!=t||!(r.to>r.from||r.to==t)){n=Math.min(r.from,n);break}s.push(r),e++,n=Math.min(r.to,n)}n=Math.min(n,h);let u=!1;if(s.some(e=>e.from==t&&(e.to==n||n==h))&&(u=t==n,!u&&n-t<10)){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let d=IA(s);if(u)o.add(t,t,Sg.widget({widget:new MA(d),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,Sg.mark({class:"cm-lintRange cm-lintRange-"+d+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>n)}))}if(a=n,a==h)break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1)}let u=o.finish();return new pA(u,t,mA(u))}}function mA(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(r){if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new fA(r.from,n,r.diagnostic)}else r=new fA(e,n,t||i.diagnostics[0])}),r}function gA(e,t){return e.field(wA,!1)?t:t.concat(um.appendConfig.of(_A))}const vA=um.define(),bA=um.define(),yA=um.define(),wA=Hp.define({create:()=>new pA(Sg.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=mA(n,e.selected.diagnostic,i)||mA(n,null,i)}!n.size&&i&&t.state.facet(NA).autoPanel&&(i=null),e=new pA(n,i,r)}for(let n of t.effects)if(n.is(vA)){let r=t.state.facet(NA).autoPanel?n.value.length?DA.open:null:e.panel;e=pA.init(n.value,r,t.state)}else n.is(bA)?e=new pA(e.diagnostics,n.value?DA.open:null,e.selected):n.is(yA)&&(e=new pA(e.diagnostics,e.panel,n.value));return e},provide:e=>[Cx.from(e,e=>e.panel),lw.decorations.from(e,e=>e.diagnostics)]}),xA=Sg.mark({class:"cm-lintRange cm-lintRange-active"});function kA(e,t,n){let r,{diagnostics:i}=e.state.field(wA),o=-1,s=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),(e,i,{spec:a})=>{if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=a.diagnostics,o=e,s=i,!1});let a=e.state.facet(NA).tooltipFilter;return r&&a&&(r=a(r,e.state)),r?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:SA(e,r)})}:null}function SA(e,t){return ng("ul",{class:"cm-tooltip-lint"},t.map(t=>TA(e,t,!1)))}const EA=e=>{let t=e.state.field(wA,!1);return!(!t||!t.panel)&&(e.dispatch({effects:bA.of(!1)}),!0)},CA=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(wA,!1);t&&t.panel||e.dispatch({effects:gA(e.state,[bA.of(!0)])});let n=xx(e,DA.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(wA,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!(!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],NA=Bp.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...Em(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:OA,tooltipFilter:OA,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})})});function OA(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function AA(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue e}}t.push("")}return t}function TA(e,t,n){var r;let i=n?AA(t.actions):[];return ng("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ng("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(r=t.actions)||void 0===r?void 0:r.map((n,r)=>{let o=!1,s=r=>{if(r.preventDefault(),o)return;o=!0;let i=mA(e.state.field(wA).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,l=i[r]?a.indexOf(i[r]):-1,c=l<0?a:[a.slice(0,l),ng("u",a.slice(l,l+1)),a.slice(l+1)];return ng("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:s,onmousedown:s,"aria-label":` Action: ${a}${l<0?"":` (access key "${i[r]})"`}.`},c)}),t.source&&ng("div",{class:"cm-diagnosticSource"},t.source))}class MA extends xg{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ng("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class RA{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=TA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class DA{constructor(e){this.view=e,this.items=[];this.list=ng("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)EA(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],r=AA(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=mA(this.view.state.field(wA).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=ng("div",{class:"cm-panel-lint"},this.list,ng("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>EA(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(wA).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(wA),n=0,r=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(e,s,{spec:a})=>{for(let e of a.diagnostics){if(o.has(e))continue;o.add(e);let s,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(s=new RA(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[a],a>n&&(this.items.splice(n,a-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),i=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new RA(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=mA(this.view.state.field(wA).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:yA.of(t)})}static open(e){return new DA(e)}}function PA(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const LA=lw.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:PA("#d11")},".cm-lintRange-warning":{backgroundImage:PA("orange")},".cm-lintRange-info":{backgroundImage:PA("#999")},".cm-lintRange-hint":{backgroundImage:PA("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function BA(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function IA(e){let t="hint",n=1;for(let r of e){let e=BA(r.severity);e>n&&(n=e,t=r.severity)}return t}const _A=[wA,lw.decorations.compute([wA],e=>{let{selected:t,panel:n}=e.field(wA);return t&&n&&t.from!=t.to?Sg.set([xA.range(t.from,t.to)]):Sg.none}),vx(kA,{hideOn:function(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(NA).hideOn(e,n,r);if(null!=i)return i;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(vA))&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),LA];var jA=function(e){void 0===e&&(e={});var{crosshairCursor:t=!1}=e,n=[];!1!==e.closeBracketsKeymap&&(n=n.concat(rA)),!1!==e.defaultKeymap&&(n=n.concat(sN)),!1!==e.searchKeymap&&(n=n.concat(QN)),!1!==e.historyKeymap&&(n=n.concat(sC)),!1!==e.foldKeymap&&(n=n.concat(KS)),!1!==e.completionKeymap&&(n=n.concat(uA)),!1!==e.lintKeymap&&(n=n.concat(CA));var r=[];return!1!==e.lineNumbers&&r.push(function(e={}){return[$x.of(e),_x(),Gx]}()),!1!==e.highlightActiveLineGutter&&r.push(Qx),!1!==e.highlightSpecialChars&&r.push(function(e={}){return[qw.of(e),Uw||(Uw=Iv.fromClass(class{constructor(e){this.view=e,this.decorations=Sg.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(qw)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Fw({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=bp(t[0],0);if(9==o){let e=i.lineAt(r),t=n.state.tabSize,o=Hm(e.text,t,r-e.from);return Sg.replace({widget:new Kw((t-o%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Sg.replace({widget:new $w(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(qw);e.startState.facet(qw)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}()),!1!==e.history&&r.push(function(e={}){return[VE,HE.of(e),lw.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?UE:"historyRedo"==e.inputType?$E:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(e={}){let t={...eE,...e},n=new tE(t,!0),r=new tE(t,!1),i=Iv.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(bS)!=e.state.facet(bS)||e.startState.field(zS,!1)!=e.state.field(zS,!1)||cS(e.startState)!=cS(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new Rm;for(let i of e.viewportLineBlocks){let o=VS(e.state,i.from,i.to)?r:IS(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[i,Bx({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||Mm.empty},initialSpacer:()=>new tE(t,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=VS(e.state,t.from,t.to);if(r)return e.dispatch({effects:FS.of(r)}),!0;let i=IS(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:jS.of(i)}),!0)}}}),XS()]}()),!1!==e.drawSelection&&r.push(function(e={}){return[Tw.of(e),Rw,Pw,Lw,Ov.of(!0)]}()),!1!==e.dropCursor&&r.push([Iw,_w]),!1!==e.allowMultipleSelections&&r.push(Sm.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(Sm.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+200)return e;let o=n.sliceString(i.from,r);if(!t.some(e=>e.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=ES(s,t.from);if(null==n)continue;let r=/^\s*/.exec(t.text)[0],i=SS(s,n);r!=i&&l.push({from:t.from,to:t.from+r.length,insert:i})}return l.length?[e,{changes:l,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&r.push(aE(hE,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(e={}){return[fE.of(e),bE]}()),!1!==e.closeBrackets&&r.push([nA,JO]),!1!==e.autocompletion&&r.push(function(e={}){return[$O,jO,wO.of(e),qO,dA,KO]}()),!1!==e.rectangularSelection&&r.push(function(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return lw.mouseSelectionStyle.of((e,n)=>t(n)?Zw(e,n):null)}()),!1!==t&&r.push(function(e={}){let[t,n]=ex[e.key||"Alt"],r=Iv.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,lw.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?tx:null})]}()),!1!==e.highlightActiveLine&&r.push(Gw),!1!==e.highlightSelectionMatches&&r.push(function(e){let t=[SN,kN];return e&&t.push(bN.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&r.push(xS.of(" ".repeat(e.tabSize))),r.concat([gw.of(n.flat())]).filter(Boolean)};const FA="#e06c75",WA="#abb2bf",zA="#7d8799",HA="#d19a66",VA="#2c313a",qA="#282c34",UA="#353a42",$A="#528bff",KA=[lw.theme({"&":{color:WA,backgroundColor:qA},".cm-content":{caretColor:$A},".cm-cursor, .cm-dropCursor":{borderLeftColor:$A},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:WA},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:qA,color:zA,border:"none"},".cm-activeLineGutter":{backgroundColor:VA},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:UA},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:UA,borderBottomColor:UA},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:VA,color:WA}}},{dark:!0}),aE(rE.define([{tag:nS.keyword,color:"#c678dd"},{tag:[nS.name,nS.deleted,nS.character,nS.propertyName,nS.macroName],color:FA},{tag:[nS.function(nS.variableName),nS.labelName],color:"#61afef"},{tag:[nS.color,nS.constant(nS.name),nS.standard(nS.name)],color:HA},{tag:[nS.definition(nS.name),nS.separator],color:WA},{tag:[nS.typeName,nS.className,nS.number,nS.changed,nS.annotation,nS.modifier,nS.self,nS.namespace],color:"#e5c07b"},{tag:[nS.operator,nS.operatorKeyword,nS.url,nS.escape,nS.regexp,nS.link,nS.special(nS.string)],color:"#56b6c2"},{tag:[nS.meta,nS.comment],color:zA},{tag:nS.strong,fontWeight:"bold"},{tag:nS.emphasis,fontStyle:"italic"},{tag:nS.strikethrough,textDecoration:"line-through"},{tag:nS.link,color:zA,textDecoration:"underline"},{tag:nS.heading,fontWeight:"bold",color:FA},{tag:[nS.atom,nS.bool,nS.special(nS.variableName)],color:HA},{tag:[nS.processingInstruction,nS.string,nS.inserted],color:"#98c379"},{tag:nS.invalid,color:"#ffffff"}]))];var YA=lw.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),GA=function(e){void 0===e&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,a=[];switch(t&&a.unshift(gw.of([aN])),s&&("boolean"==typeof s?a.unshift(jA()):a.unshift(jA(s))),o&&a.unshift(function(e){let t=Iv.fromClass(class{constructor(t){this.view=t,this.placeholder=e?Sg.set([Sg.widget({widget:new Xw(e),side:1}).range(0)]):Sg.none}get decorations(){return this.view.state.doc.length?Sg.none:this.placeholder}},{decorations:e=>e.decorations});return"string"==typeof e?[t,lw.contentAttributes.of({"aria-placeholder":e})]:t}(o)),i){case"light":a.push(YA);break;case"dark":a.push(KA);break;case"none":break;default:a.push(i)}return!1===n&&a.push(lw.editable.of(!1)),r&&a.push(Sm.readOnly.of(!0)),[...a]};class XA{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class JA{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}}var QA=null,ZA=lm.define(),eT=[];function tT(e){var{value:t,selection:n,onChange:r,onStatistics:s,onCreateEditor:l,onUpdate:c,extensions:h=eT,autoFocus:u,theme:d="light",height:f=null,minHeight:p=null,maxHeight:m=null,width:g=null,minWidth:v=null,maxWidth:b=null,placeholder:y="",editable:w=!0,readOnly:x=!1,indentWithTab:k=!0,basicSetup:S=!0,root:E,initialState:C}=e,[N,O]=i(),[A,T]=i(),[M,R]=i(),D=i(()=>({current:null}))[0],P=i(()=>({current:null}))[0],L=lw.theme({"&":{height:f,minHeight:p,maxHeight:m,width:g,minWidth:v,maxWidth:b},"& .cm-scroller":{height:"100% !important"}}),B=lw.updateListener.of(e=>{if(e.docChanged&&"function"==typeof r&&!e.transactions.some(e=>e.annotation(ZA))){D.current?D.current.reset():(D.current=new XA(()=>{if(P.current){var e=P.current;P.current=null,e()}D.current=null},200),("undefined"==typeof window?new JA:(QA||(QA=new JA),QA)).add(D.current));var t=e.state.doc.toString();r(t,e)}s&&s((e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}))(e))}),I=[B,L,...GA({theme:d,editable:w,readOnly:x,placeholder:y,indentWithTab:k,basicSetup:S})];return c&&"function"==typeof c&&I.push(lw.updateListener.of(c)),I=I.concat(h),o(()=>{if(N&&!M){var e={doc:t,selection:n,extensions:I},r=C?Sm.fromJSON(C.json,e,C.fields):Sm.create(e);if(R(r),!A){var i=new lw({state:r,parent:N,root:E});T(i),l&&l(i,r)}}return()=>{A&&(R(void 0),T(void 0))}},[N,M]),a(()=>{e.container&&O(e.container)},[e.container]),a(()=>()=>{A&&(A.destroy(),T(void 0)),D.current&&(D.current.cancel(),D.current=null)},[A]),a(()=>{u&&A&&A.focus()},[u,A]),a(()=>{A&&A.dispatch({effects:um.reconfigure.of(I)})},[d,h,f,p,m,g,v,b,y,w,x,k,S,r,c]),a(()=>{if(void 0!==t){var e=A?A.state.doc.toString():"";if(A&&t!==e){var n=()=>{A&&t!==A.state.doc.toString()&&A.dispatch({changes:{from:0,to:A.state.doc.toString().length,insert:t||""},annotations:[ZA.of(!0)]})};D.current&&!D.current.isDone?P.current=n:n()}}},[t,A]),{state:M,setState:R,view:A,setView:T,container:N,setContainer:O}}var nT=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],rT=n((e,t)=>{var{className:n,value:r="",selection:i,extensions:o=[],onChange:s,onStatistics:a,onCreateEditor:d,onUpdate:f,autoFocus:p,theme:m="light",height:g,minHeight:v,maxHeight:b,width:y,minWidth:w,maxWidth:x,basicSetup:k,placeholder:S,indentWithTab:E,editable:C,readOnly:N,root:O,initialState:A}=e,T=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,nT),M=l(null),{state:R,view:D,container:P,setContainer:L}=tT({root:O,value:r,autoFocus:p,theme:m,height:g,minHeight:v,maxHeight:b,width:y,minWidth:w,maxWidth:x,basicSetup:k,placeholder:S,indentWithTab:E,editable:C,readOnly:N,selection:i,onChange:s,onStatistics:a,onCreateEditor:d,onUpdate:f,extensions:o,initialState:A});c(t,()=>({editor:M.current,state:R,view:D}),[M,P,R,D]);var B=h(e=>{M.current=e,L(e)},[L]);if("string"!=typeof r)throw new Error("value must be typeof string but got "+typeof r);return u("div",Gf({ref:B,className:("string"==typeof m?"cm-theme-"+m:"cm-theme")+(n?" "+n:"")},T))});rT.displayName="CodeMirror";class iT{constructor(e,t,n,r,i,o,s,a,l,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=o,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new iT(e,[],t,n,n,0,[],0,r?new oT(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,r=65535&e,{parser:i}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),s=i.dynamicPrecedence(r);if(s&&(this.score+=s),0==n)return this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(r,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[r])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(r<i.minRepeatTerm||131072&e){let e=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,e,u+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=i.getGoto(e,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,n,r=4,i=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(0==r&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&0==e.buffer[r-4]&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t)return void(e.buffer[r-2]=n)}}if(i&&this.pos!=n){let i=this.buffer.length;if(i>0&&(0!=this.buffer[i-4]||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}else this.buffer.push(e,t,n,r)}shift(e,t,n,r){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:o}=this.p;this.pos=r;let s=o.stateFlag(i,1);!s&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(i,s?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){65536&e?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new iT(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new sT(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r,i=0;i<t.length;i+=2)(r=t[i+1])!=this.state&&this.p.parser.hasAction(r,e)&&n.push(t[i],r);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>1&t&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=65535&t,i=this.stack.length-3*n;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-i;if(n>1){let r=65535&t,i=this.stack.length-3*n;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(null!=e)return e}})};return n(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(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new oT(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class oT{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class sT{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class aT{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new aT(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(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,0==this.index&&this.maybeNext()}fork(){return new aT(this.stack,this.pos,this.index)}}function lT(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let r=0,i=0;r<e.length;){let o=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(126==t){o=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),o+=i,n)break;o*=46}n?n[i++]=o:n=new t(o)}return n}class cT{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const hT=new cT;class uT{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=hT,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t,n,r=this.chunkOff+e;if(r>=0&&r<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(r);else{let r=this.resolveOffset(e,1);if(null==r)return-1;if(t=r,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,r=this.range;for(;r.to<=t;)r=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=hT,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class dT{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,r,i,o){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;0!=(a&e[s]);){let n=e[s+1];for(let r=s+3;r<n;r+=2)if((e[r+1]&a)>0){let n=e[r];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||pT(n,t.token.value,i,o))){t.acceptToken(n);break}}let r=t.next,c=0,h=e[s+2];if(!(t.next<0&&h>c&&65535==e[n+3*h-3])){for(;c<h;){let i=c+h>>1,o=n+i+(i<<1),a=e[o],l=e[o+1]||65536;if(r<a)h=i;else{if(!(r>=l)){s=e[o+2],t.advance();continue e}c=i+1}}break}s=e[n+3*h-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}function fT(e,t,n){for(let r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function pT(e,t,n,r){let i=fT(n,r,t);return i<0||fT(n,r,e)<i}dT.prototype.contextual=dT.prototype.fallback=dT.prototype.extend=!1,dT.prototype.fallback=dT.prototype.extend=!1;const mT="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let gT=null;function vT(e,t,n){let r=e.cursor(ck.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}class bT{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?vT(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?vT(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof hk){if(o==e){if(o<this.safeFrom)return null;let e=o+i.length;if(e<=this.safeTo){let t=i.prop(nk.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}}class yT{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new cT)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let r=0;r<i.length;r++){if(!(1<<r&o))continue;let l=i[r],c=this.tokens[r];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=o||c.context!=s)&&(this.updateCachedToken(c,l,e),c.mask=o,c.context=s),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let r=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new cT,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new cT,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){1&i?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let e=0;e<2;e++)for(let a=o.stateSlot(i,e?2:1);;a+=3){if(65535==s[a]){if(1!=s[a+1]){0==r&&2==s[a+1]&&(r=this.putAction(ET(s,a+2),t,n,r));break}a=ET(s,a+2)}s[a]==t&&(r=this.putAction(ET(s,a+1),t,n,r))}return r}}class wT{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new uT(t,r),this.tokens=new yT(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[iT.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>4*e.bufferLength?new bT(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,r=this.minStackPos,i=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<n.length;o++){let s=n[o];for(;;){if(this.tokens.mainToken=null,s.pos>r)i.push(s);else{if(this.advanceStack(s,i,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!i.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return this.stackToTree(t);if(this.parser.strict)throw new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,i);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(i.length>e)for(i.sort((e,t)=>t.score-e.score);i.length>e;)i.pop();i.some(e=>e.reducePos>r)&&this.recovering--}else if(i.length>1){e:for(let e=0;e<i.length-1;e++){let t=i[e];for(let n=e+1;n<i.length;n++){let r=i[n];if(t.sameState(r)||t.buffer.length>500&&r.buffer.length>500){if(!((t.score-r.score||t.buffer.length-r.buffer.length)>0)){i.splice(e--,1);continue e}i.splice(n--,1)}}}i.length>12&&(i.sort((e,t)=>t.score-e.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let e=1;e<i.length;e++)i[e].pos<this.minStackPos&&(this.minStackPos=i[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this;mT&&this.stackID(e);if(null!=this.stoppedAt&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(nk.contextHash)||0)==n))return e.useNode(o,r),!0;if(!(o instanceof hk)||0==o.children.length||o.positions[0]>0)break;let s=o.children[0];if(!(s instanceof hk&&0==o.positions[0]))break;o=s}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let i=0;i<s.length;){let o=s[i++],a=s[i++],l=s[i++],c=i==s.length||!n,h=c?e:e.split(),u=this.tokens.mainToken;if(h.apply(o,a,u?u.start:h.pos,l),c)return!0;h.pos>r?t.push(h):n.push(h)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return xT(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=t[o<<1],l=t[1+(o<<1)],c=mT?this.stackID(s)+" -> ":"";if(s.deadEnd){if(i)continue;if(i=!0,s.restart(),this.advanceFully(s,n))continue}let h=s.split(),u=c;for(let e=0;e<10&&h.forceReduce();e++){if(this.advanceFully(h,n))break;mT&&(u=this.stackID(h)+" -> ")}for(let e of s.recoverByInsert(a))this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),xT(s,n)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),hk.build({buffer:aT.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(gT||(gT=new WeakMap)).get(e);return t||gT.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function xT(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class kT{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class ST extends Tk{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=nk[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let o=t[n+-r];for(let s=-r;s>0;s--)i(t[n++],e,o);n++}}}this.nodeSet=new sk(t.map((t,i)=>ok.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:0==i,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Zx;let o=lT(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(CT),this.states=lT(e.states,Uint32Array),this.data=lT(e.stateData),this.goto=lT(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new dT(o,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new wT(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],o=1&t,s=r[i++];if(o&&n)return s;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return s;if(o)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i,o=this.stateSlot(e,r?2:1);;o+=3){if(65535==(i=n[o])){if(1!=n[o+1]){if(2==n[o+1])return ET(n,o+2);break}i=n[o=ET(n,o+2)]}if(i==t||0==i)return ET(n,o+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==r;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=ET(this.data,n+2)}r=t(ET(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=ET(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(ST.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let i=e.specializers.find(e=>e.from==n.external);if(!i)return n;let o=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[r]=CT(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(" ")){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,i=this.dialects[t[e]];65535!=(n=this.data[i++]);)(r||(r=new Uint8Array(this.maxTerm+1)))[n]=1;return new kT(e,n,r)}static deserialize(e){return new ST(e)}}function ET(e,t){return e[t]|e[t+1]<<16}function CT(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}const NT=Bk({String:nS.string,Number:nS.number,"True False":nS.bool,PropertyName:nS.propertyName,Null:nS.null,", :":nS.separator,"[ ]":nS.squareBracket,"{ }":nS.brace}),OT=ST.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:[NT],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}),AT=lS.define({name:"json",parser:OT.configure({props:[NS.add({Object:DS({except:/^\s*\}/}),Array:DS({except:/^\s*\]/})}),LS.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function TT(e){return MT.apply(this,arguments)}function MT(){return MT=w(S().m(function e(t){var n,r;return S().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(!(null===(n=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===n?void 0:n.writeText)){e.n=3;break}return e.n=2,navigator.clipboard.writeText(t);case 2:return e.a(2);case 3:(r=document.createElement("textarea")).value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r);case 4:return e.a(2)}},e)})),MT.apply(this,arguments)}function RT(t){var n=t.value,r=t.title;if(null==n||""===n)return e.createElement("span",null,"-");var i,o=Kf(n),s=o.ok,a=o.pretty,l=o.compact,c=l.length>80?l.slice(0,80)+"…":l;return e.createElement(wf,null,e.createElement(xf,{asChild:!0},e.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),e.createElement(Ef,{className:"max-w-3xl"},e.createElement(Cf,null,e.createElement(Of,null,r||"JSON")),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(vt,{variant:"outline",size:"sm",onClick:(i=w(S().m(function e(){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,TT(a);case 1:Ga.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,Ga.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return i.apply(this,arguments)})},"复制")),e.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!s&&e.createElement("div",{className:"text-xs text-destructive"},o.ok?"":o.message)))}function DT(t){t.id;var n=t.value;t.required;var r,i=t.disabled,o=t.onChange,s=C(e.useState(null),2),a=s[0],l=s[1];return e.createElement("div",{className:"space-y-2"},e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(vt,{type:"button",variant:"outline",size:"sm",disabled:!!i,onClick:function(){if(!i){var e=(n||"").trim();if(e){var t=Yf(e,2);t.ok?(o(t.formatted),l(null)):l(t.message)}}}},"格式化"),e.createElement(vt,{type:"button",variant:"outline",size:"sm",onClick:(r=w(S().m(function e(){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,TT(n||"");case 1:Ga.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,Ga.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),e.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},e.createElement(rT,{className:"w-full max-w-full",editable:!i,value:n||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new yS(AT),lw.lineWrapping],onChange:function(e){i||(o(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=Kf(t);n.ok?l(null):l(n.message)}(e))}})),a&&e.createElement("div",{className:"text-xs text-destructive"},a))}var PT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("div",{className:"relative w-full overflow-x-auto"},e.createElement("table",Object.assign({ref:n,className:et("w-full min-w-max caption-bottom text-sm",r)},i)))});PT.displayName="Table";var LT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("thead",Object.assign({ref:n,className:et("[&_tr]:border-b",r)},i))});LT.displayName="TableHeader";var BT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("tbody",Object.assign({ref:n,className:et("[&_tr:last-child]:border-0",r)},i))});BT.displayName="TableBody";var IT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("tfoot",Object.assign({ref:n,className:et("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r)},i))});IT.displayName="TableFooter";var _T=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("tr",Object.assign({ref:n,className:et("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r)},i))});_T.displayName="TableRow";var jT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("th",Object.assign({ref:n,className:et("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});jT.displayName="TableHead";var FT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("td",Object.assign({ref:n,className:et("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",r)},i))});FT.displayName="TableCell";var WT=e.forwardRef(function(t,n){var r=t.className,i=oe(t,["className"]);return e.createElement("caption",Object.assign({ref:n,className:et("mt-4 text-sm text-muted-foreground",r)},i))});WT.displayName="TableCaption";var zT=mt("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function HT(t){var n=t.className,r=t.variant,i=oe(t,["className","variant"]);return e.createElement("div",Object.assign({className:et(zT({variant:r}),n)},i))}function VT(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function qT(e){return"integer"===e||"float"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"大于"},{value:"gte",label:"大于等于"},{value:"lt",label:"小于"},{value:"lte",label:"小于等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]:"boolean"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"isNull",label:"为空(NULL)"}]:"date"===e||"datetime"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"晚于/大于"},{value:"gte",label:"晚于等于/大于等于"},{value:"lt",label:"早于/小于"},{value:"lte",label:"早于等于/小于等于"},{value:"isNull",label:"为空(NULL)"}]:[{value:"contains",label:"包含"},{value:"startsWith",label:"开头是"},{value:"endsWith",label:"结尾是"},{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]}function UT(e){var n,r,o=s(function(){var t=[];t.push.apply(t,N([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=x(e.fields||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if((null==i?void 0:i.name)&&("json"!==i.type&&"jsonb"!==i.type))if("relation"===i.type&&i.relation){var o=i.relation.foreignKey||"".concat(i.relation.target,"_id");t.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else t.push({column:i.name,label:i.comment||i.name,type:i.type})}}catch(e){r.e(e)}finally{r.f()}var s=new Set;return t.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[e.fields]),l=s(function(){return new Map(o.map(function(e){return[e.column,e]}))},[o]),c=s(function(){return new Map(o.map(function(e){return[e.column,e.type]}))},[o]),h=C(i([]),2),u=h[0],d=h[1];a(function(){d(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:VT(),column:e.column,operator:"isNull",value:""};if(("ilike"===e.operator||"like"===e.operator)&&"string"==typeof e.value){var n=e.value;if(n.startsWith("%")&&n.endsWith("%")&&n.length>=2)return{id:VT(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:VT(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:VT(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:VT(),column:e.column,operator:"in",value:r.join(",")}}return{id:VT(),column:e.column,operator:["eq","neq","gt","gte","lt","lte"].includes(e.operator)?e.operator:"eq",value:void 0===e.value||null===e.value?"":String(e.value)}})}(e.value||[],c))},[JSON.stringify(e.value),o.length]);var f=function(e,t){d(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var o=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var s=qT((null===(r=l.get(t.column))||void 0===r?void 0:r.type)||"string");o.operator=(null===(i=s[0])||void 0===i?void 0:i.value)||"eq",o.value=""}return t.operator&&"isNull"===t.operator&&(o.value=""),o})})};return t.createElement("div",{className:"space-y-3"},t.createElement("div",{className:"flex items-center justify-between gap-3"},t.createElement(Ta,{className:"text-base font-medium flex items-center gap-2"},t.createElement(z,{className:"h-4 w-4"}),"动态筛选"),t.createElement("div",{className:"flex items-center gap-2"},(null===(n=e.value)||void 0===n?void 0:n.length)>0&&t.createElement(HT,{variant:"secondary"},"已应用 ",e.value.length," 条"),t.createElement(vt,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=o[0];if(e){var t=qT(e.type);d(function(n){var r;return[].concat(N(n),[{id:VT(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},t.createElement(G,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===u.length?t.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):t.createElement("div",{className:"space-y-2"},u.map(function(e){var n=l.get(e.column),r=(null==n?void 0:n.type)||"string",i=qT(r),s="isNull"!==e.operator;return t.createElement("div",{key:e.id,className:"grid grid-cols-12 gap-2 items-center"},t.createElement("div",{className:"col-span-5"},t.createElement($d,{value:e.column,onValueChange:function(t){return f(e.id,{column:t})}},t.createElement(Yd,{className:"h-10"},t.createElement(Kd,{placeholder:"字段"})),t.createElement(Jd,null,o.map(function(e){return t.createElement(Zd,{key:e.column,value:e.column},e.label," (",e.column,")")})))),t.createElement("div",{className:"col-span-3"},t.createElement($d,{value:e.operator,onValueChange:function(t){return f(e.id,{operator:t})}},t.createElement(Yd,{className:"h-10"},t.createElement(Kd,{placeholder:"操作符"})),t.createElement(Jd,null,i.map(function(e){return t.createElement(Zd,{key:e.value,value:e.value},e.label)})))),t.createElement("div",{className:"col-span-3"},s?"boolean"===r?t.createElement($d,{value:e.value,onValueChange:function(t){return f(e.id,{value:t})}},t.createElement(Yd,{className:"h-10"},t.createElement(Kd,{placeholder:"值"})),t.createElement(Jd,null,t.createElement(Zd,{value:"true"},"true"),t.createElement(Zd,{value:"false"},"false"))):t.createElement(bt,{className:"h-10",placeholder:"in"===e.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:e.value,onChange:function(t){return f(e.id,{value:t.target.value})}}):t.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),t.createElement("div",{className:"col-span-1 flex justify-end"},t.createElement(vt,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return t=e.id,void d(function(e){return e.filter(function(e){return e.id!==t})});var t}},t.createElement(re,{className:"h-4 w-4"}))))})),t.createElement("div",{className:"flex items-center justify-end gap-2"},t.createElement(vt,{type:"button",variant:"outline",onClick:function(){d([]),e.onChange([])},disabled:0===u.length&&0===((null===(r=e.value)||void 0===r?void 0:r.length)||0)},"清空"),t.createElement(vt,{type:"button",onClick:function(){var t=function(e,t){var n,r,i=[],o=x(e);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.get(s.column);if(a&&s.operator)if("isNull"!==s.operator){var l=null!==(n=s.value)&&void 0!==n?n:"",c=String(l).trim();if(c)if("contains"!==s.operator)if("startsWith"!==s.operator)if("endsWith"!==s.operator)if("in"!==s.operator)i.push({column:a.column,operator:s.operator,value:c});else{var h=c.split(",").map(function(e){return e.trim()}).filter(Boolean);i.push({column:a.column,operator:"in",value:h})}else i.push({column:a.column,operator:"ilike",value:"%".concat(c)});else i.push({column:a.column,operator:"ilike",value:"".concat(c,"%")});else i.push({column:a.column,operator:"ilike",value:"%".concat(c,"%")})}else i.push({column:a.column,operator:"is",value:null})}}catch(e){o.e(e)}finally{o.f()}return i}(u,l);e.onChange(t)},disabled:0===u.length},"应用")))}function $T(){var e,n=C(i([]),2),r=n[0],o=n[1],s=C(i(null),2),l=s[0],c=s[1],h=C(i([]),2),u=h[0],d=h[1],f=C(i(!1),2),p=f[0],m=f[1],g=C(i(!1),2),b=g[0],y=g[1],x=C(i(null),2),E=x[0],N=x[1],O=C(i({}),2),A=O[0],T=O[1],M=C(i(1),2),R=M[0],D=M[1],P=C(i(10),2),L=P[0];P[1];var _=C(i(0),2),j=_[0],F=_[1],W=C(i(""),2),H=W[0],V=W[1],U=C(i(!1),2),$=U[0],K=U[1],Y=C(i(null),2),J=Y[0],Z=Y[1],te=C(i(!0),2),ne=te[0],re=te[1],ie=C(i([]),2),oe=ie[0],se=ie[1],ae=C(i(!1),2),le=ae[0],ce=ae[1],he=function(e){return Array.isArray(e)?e:Array.isArray(null==e?void 0:e.models)?e.models:Array.isArray(null==e?void 0:e.data)?e.data:Array.isArray(null==e?void 0:e.items)?e.items:[]},ue=function(e){var t;if(e&&Array.isArray(e.data)){var n="number"==typeof e.total?e.total:"number"==typeof(null===(t=e.pagination)||void 0===t?void 0:t.total)?e.pagination.total:e.data.length;return{rows:e.data,total:n}}if(e&&Array.isArray(e.rows)){var r="number"==typeof e.total?e.total:e.rows.length;return{rows:e.rows,total:r}}return Array.isArray(e)?{rows:e,total:e.length}:{rows:[],total:0}},de=function(e){return!e||!e.readOnly&&!1!==e.editable};a(function(){fe()},[]),a(function(){l&&pe()},[l,R,L,H,oe]);var fe=function(){var e=w(S().m(function e(){var t;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return re(!0),e.p=1,e.n=2,bh();case 2:t=e.v,o(he(t.data)),e.n=4;break;case 3:e.p=3,e.v,Ga.error("加载模型列表失败");case 4:return e.p=4,re(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),pe=function(){var e=w(S().m(function e(){var t,n,r;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:return m(!0),e.p=2,t={page:R,limit:L},H&&(t.search=H),oe.length>0&&(t.filters=oe),e.n=3,Oh(l.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return Ga.error(n.message||"加载数据失败"),d([]),F(0),e.a(2);case 4:r=ue(n.data),d(r.rows),F(r.total),e.n=6;break;case 5:e.p=5,e.v,Ga.error("加载数据失败"),d([]),F(0);case 6:return e.p=6,m(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),me=function(){var e=w(S().m(function e(t){var n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return Z(t.id),e.p=2,e.n=3,Rh(null==l?void 0:l.table_name,t.id);case 3:(n=e.v).success?(Ga.success("删除成功"),pe()):Ga.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Ga.error("删除失败");case 5:return e.p=5,Z(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ge=function(){var e=w(S().m(function e(){var t,n,r,i,o;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(l){e.n=1;break}return e.a(2);case 1:if(K(!0),e.p=2,t={},l.json_schema.fields.forEach(function(e){if("id"!==e.name&&de(e)){var n=A[e.name];if("date"!==e.type&&"datetime"!==e.type||(n=n?new Date(n).toISOString():null),"json"===e.type||"jsonb"===e.type){var r=(n||"").toString().trim();if(r){var i=Kf(r);if(!i.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(i.message));n=i.value}else n=null}t[e.name]=n}}),!E){e.n=4;break}return e.n=3,Mh(l.table_name,Object.assign(Object.assign({},t),{id:E.id}));case 3:(n=e.v).success?(Ga.success("更新成功"),y(!1),pe()):Ga.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,Th(l.table_name,t);case 5:(r=e.v).success?(Ga.success("创建成功"),y(!1),pe()):Ga.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",Ga.error(i);case 8:return e.p=8,K(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}();return t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},t.createElement("div",{className:"space-y-2"},t.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),t.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),t.createElement(Ma,{className:"border-2 shadow-lg"},t.createElement(Ra,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(Da,null,"数据管理"),t.createElement(Pa,null,"选择数据模型进行查看和管理")),l&&t.createElement(vt,{onClick:function(){N(null),T({}),y(!0)},className:"w-full md:w-auto"},t.createElement(G,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(La,{className:"space-y-6 pt-6"},t.createElement("div",{className:"flex flex-col md:flex-row gap-4"},t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(Ta,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},t.createElement(z,{className:"h-4 w-4"}),"选择数据模型"),t.createElement($d,{value:(null===(e=null==l?void 0:l.id)||void 0===e?void 0:e.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});c(t||null),D(1),V(""),se([])},disabled:ne},t.createElement(Yd,{className:"h-11"},ne?t.createElement("div",{className:"flex items-center gap-2"},t.createElement(q,{className:"h-4 w-4 animate-spin"}),t.createElement("span",null,"加载中...")):t.createElement(Kd,{placeholder:"请选择模型"})),t.createElement(Jd,null,r.map(function(e){return t.createElement(Zd,{key:e.id,value:e.id.toString()},e.name," (",e.table_name,")")})))),l&&t.createElement("div",{className:"flex-1 space-y-2"},t.createElement(Ta,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},t.createElement(X,{className:"h-4 w-4"}),"搜索"),t.createElement("div",{className:"relative"},t.createElement(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(bt,{id:"search",placeholder:"搜索数据...",value:H,onChange:function(e){return V(e.target.value)},className:"pl-10 h-11"})))),l&&t.createElement(t.Fragment,null,t.createElement("div",{className:"flex items-center justify-end"},t.createElement(vt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return ce(!0)}},t.createElement(z,{className:"h-4 w-4 mr-2"}),"筛选",oe.length>0?"(".concat(oe.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},j)," 条数据"),t.createElement(HT,{variant:"outline"},l.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement("div",{className:"overflow-x-auto"},t.createElement(PT,null,t.createElement(LT,null,t.createElement(_T,{className:"bg-muted/50"},t.createElement(jT,{className:"font-semibold w-20"},"ID"),l.json_schema.fields.map(function(e){return t.createElement(jT,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(jT,{className:"font-semibold"},"创建时间"),t.createElement(jT,{className:"font-semibold"},"更新时间"),t.createElement(jT,{className:"font-semibold w-32 text-center"},"操作"))),t.createElement(BT,null,p?Array.from({length:3}).map(function(e,n){return t.createElement(_T,{key:n},t.createElement(FT,{colSpan:l.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(q,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===u.length?t.createElement(_T,null,t.createElement(FT,{colSpan:l.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(X,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):u.map(function(e,n){return t.createElement(_T,{key:e.id,className:n%2==0?"bg-muted/20":""},t.createElement(FT,{className:"font-mono font-medium"},e.id),l.json_schema.fields.map(function(n){return t.createElement(FT,{key:n.name},function(e,n){return"boolean"===e.type?t.createElement(HT,{variant:n?"default":"secondary"},n?"是":"否"):"date"===e.type||"datetime"===e.type?n?v(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===e.type&&n&&n.length>50?t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===e.type||"jsonb"===e.type?t.createElement(RT,{value:n,title:e.comment||e.name}):n||"-"}(n,e[n.name]))}),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,null,t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return function(e){N(e);var t={};null==l||l.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?v(r).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(r=null==r||""===r?"":"string"==typeof r?r:JSON.stringify(r,null,2)),t[n.name]=r}}),T(t),y(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(Q,{className:"h-4 w-4"})),t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return me(e)},disabled:J===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},J===e.id?t.createElement(q,{className:"h-4 w-4 animate-spin"}):t.createElement(ee,{className:"h-4 w-4"})))))}))))),j>L&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},R)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(j/L))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return D(Math.max(1,R-1))},disabled:1===R||p},t.createElement(B,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return D(Math.min(Math.ceil(j/L),R+1))},disabled:R>=Math.ceil(j/L)||p},"下一页",t.createElement(I,{className:"h-4 w-4 ml-1"}))))))),l&&t.createElement(wf,{open:le,onOpenChange:ce},t.createElement(Ef,{className:"max-w-3xl"},t.createElement(Cf,null,t.createElement(Of,{className:"text-xl"},"筛选"),t.createElement(Tf,{className:"text-sm"},l.name," - ",l.table_name)),t.createElement("div",{className:"py-2"},t.createElement(UT,{fields:l.json_schema.fields,value:oe,onChange:function(e){se(e),D(1)}})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return ce(!1)}},"关闭")))),t.createElement(wf,{open:b,onOpenChange:y},t.createElement(Ef,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(Cf,null,t.createElement(Of,{className:"text-2xl"},E?"编辑数据":"新建数据"),t.createElement(Tf,{className:"text-base"},null==l?void 0:l.name," - ",null==l?void 0:l.table_name)),t.createElement("div",{className:"space-y-4 py-4"},null==l?void 0:l.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=de(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(bf,{id:e.name,checked:A[e.name]||!1,disabled:!n,onCheckedChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t)))}}),t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"date",value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"datetime-local",value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(yf,{id:e.name,rows:4,value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(DT,{id:e.name,value:A[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"number",value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));default:return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:A[e.name]||"",disabled:!n,onChange:function(t){return T(Object.assign(Object.assign({},A),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return y(!1)},disabled:$},"取消"),t.createElement(vt,{onClick:ge,disabled:$},$?t.createElement(t.Fragment,null,t.createElement(q,{className:"h-4 w-4 mr-2 animate-spin"}),E?"更新中...":"创建中..."):E?"更新":"创建"))))))}function KT(e){return/^https?:\/\//i.test(e)}function YT(e){var n=e.url;return t.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},t.createElement(sa,null,t.createElement(aa,{asChild:!0},t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-muted",title:"点击打开原图"},t.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement(la,{side:"right",className:"p-2"},t.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),t.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function GT(e){var n=e.model,r=C(i([]),2),o=r[0],l=r[1],c=C(i(!1),2),h=c[0],u=c[1],d=C(i(!1),2),f=d[0],p=d[1],m=C(i(!1),2),g=m[0],b=m[1],y=C(i(null),2),x=y[0],E=y[1],N=C(i({}),2),O=N[0],A=N[1],T=C(i(1),2),M=T[0],R=T[1],D=C(i(10),2),P=D[0];D[1];var L=C(i(0),2),_=L[0],j=L[1],W=C(i(""),2),H=W[0],V=W[1],U=C(i(!1),2),$=U[0],K=U[1],Y=C(i(null),2),J=Y[0],Z=Y[1],te=C(i({}),2),ne=te[0],re=te[1],ie=C(i([]),2),oe=ie[0],se=ie[1],ae=s(function(){return oe.length?JSON.stringify(oe):""},[oe]),le=function(e){return!e.readOnly&&!1!==e.editable};a(function(){n&&he()},[null==n?void 0:n.table_name,M,P,H,ae]);var ce=function(){var e=w(S().m(function e(t){var n,r,i,o,s;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if("relation"===t.type&&t.relation){e.n=1;break}return e.a(2);case 1:if(n=t.relation,r=n.target,i=n.displayField,o="".concat(r,"_").concat(i||"name"),!ne[o]){e.n=2;break}return e.a(2);case 2:return e.p=2,e.n=3,Ah(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&re(function(e){return Object.assign(Object.assign({},e),k({},o,s.data))}),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}();a(function(){f&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return ce(e)})},[f,n]);var he=function(){var e=w(S().m(function e(){var t,r,i,o;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return u(!0),e.p=2,i={page:M,limit:P},H&&(i.search=H),oe.length>0&&(i.filters=oe),e.n=3,Oh(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return Ga.error(o.message||"加载数据失败"),l([]),j(0),e.a(2);case 4:l((null===(t=o.data)||void 0===t?void 0:t.data)||[]),j((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,Ga.error("加载数据失败"),l([]),j(0);case 6:return e.p=6,u(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),ue=function(){var e=w(S().m(function e(t){var r;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return Z(t.id),e.p=2,e.n=3,Rh(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(Ga.success("删除成功"),he()):Ga.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Ga.error("删除失败");case 5:return e.p=5,Z(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),de=function(){var e=w(S().m(function e(){var t,r,i,o,s,a;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if(K(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&le(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=O[n]}else{var r=O[e.name];if("date"!==e.type&&"datetime"!==e.type||(r=r?new Date(r).toISOString():null),"json"===e.type||"jsonb"===e.type){var i=(r||"").toString().trim();if(i){var o=Kf(i);if(!o.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(o.message));r=o.value}else r=null}t[e.name]=r}}),!x){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:x.id}),e.n=3,Mh(n.table_name,r);case 3:(i=e.v).success?(Ga.success("更新成功"),p(!1),he()):Ga.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,Th(n.table_name,t);case 5:(o=e.v).success?(Ga.success("创建成功"),p(!1),he()):Ga.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",Ga.error(s);case 8:return e.p=8,K(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),fe=function(e,n,r){if("string"==typeof n){var i=n.trim();if(i&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!KT(n))return!1;var r=(null===(t=n.split("#")[0])||void 0===t?void 0:t.split("?")[0])||n;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(r)}(i))return t.createElement(YT,{url:i});if(i&&KT(i))return t.createElement("a",{href:i,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:i},i)}if("boolean"===e.type)return t.createElement(HT,{variant:n?"default":"secondary"},n?"是":"否");if("date"===e.type||"datetime"===e.type)return n?v(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===e.type&&n&&n.length>50)return t.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===e.type||"jsonb"===e.type)return t.createElement(RT,{value:n,title:e.comment||e.name});if("relation"===e.type&&e.relation&&r){var o=e.relation.displayField,s=void 0===o?"name":o,a=r["".concat(e.name,"_data")];if(a)return t.createElement(HT,{variant:"outline"},a[s]||"ID: ".concat(a.id));var l=r[e.relation.foreignKey||"".concat(e.relation.target,"_id")];return l?"ID: ".concat(l):"-"}return n||"-"};return n?t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"w-full py-4 space-y-4"},t.createElement("div",{className:"space-y-1"},t.createElement("div",{className:"flex items-center gap-3"},t.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},t.createElement(F,{className:"h-4 w-4"})),t.createElement("div",null,t.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),t.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),t.createElement(Ma,{className:"border-2 shadow-lg"},t.createElement(Ra,{className:"bg-muted/30"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},t.createElement("div",null,t.createElement(Da,null,"数据管理"),t.createElement(Pa,null,"查看和管理 ",n.name," 的数据")),t.createElement(vt,{onClick:function(){E(null),A({}),p(!0)},className:"w-full md:w-auto"},t.createElement(G,{className:"h-4 w-4 mr-2"}),"新建数据"))),t.createElement(La,{className:"space-y-4 pt-4"},t.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},t.createElement("div",{className:"flex-1"},t.createElement(Ta,{htmlFor:"search",className:"sr-only"},"搜索"),t.createElement("div",{className:"relative"},t.createElement(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.createElement(bt,{id:"search",placeholder:"搜索数据...",value:H,onChange:function(e){return V(e.target.value)},className:"pl-10 h-10"}))),t.createElement(vt,{type:"button",variant:"outline",className:"h-10",onClick:function(){return b(!0)}},t.createElement(z,{className:"h-4 w-4 mr-2"}),"筛选",oe.length>0?"(".concat(oe.length,")"):"")),t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",t.createElement("span",{className:"font-semibold text-foreground"},_)," 条数据"),t.createElement(HT,{variant:"outline"},n.name)),t.createElement("div",{className:"rounded-lg border overflow-hidden"},t.createElement(PT,null,t.createElement(LT,null,t.createElement(_T,{className:"bg-muted/50"},t.createElement(jT,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(e){return t.createElement(jT,{key:e.name,className:"font-semibold"},e.comment||e.name)}),t.createElement(jT,{className:"font-semibold"},"创建时间"),t.createElement(jT,{className:"font-semibold"},"更新时间"),t.createElement(jT,{className:et("font-semibold w-32 text-center sticky right-0 z-30 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.35)]")},"操作"))),t.createElement(BT,null,h?Array.from({length:3}).map(function(e,r){return t.createElement(_T,{key:r},t.createElement(FT,{colSpan:n.json_schema.fields.length+4},t.createElement("div",{className:"flex items-center gap-2 py-4"},t.createElement(q,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?t.createElement(_T,null,t.createElement(FT,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},t.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},t.createElement(X,{className:"h-8 w-8"}),t.createElement("p",null,"暂无数据")))):o.map(function(e,r){return t.createElement(_T,{key:e.id,className:et("group",r%2==0?"bg-muted/20":"")},t.createElement(FT,{className:"font-mono font-medium max-w-[220px] truncate",title:String(e.id)},e.id),n.json_schema.fields.map(function(n){return t.createElement(FT,{key:n.name},fe(n,e[n.name],e))}),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.created_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,{className:"text-sm text-muted-foreground"},v(e.updated_at).format("YYYY-MM-DD HH:mm")),t.createElement(FT,{className:et("sticky right-0 z-20 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.25)]","group-hover:bg-muted/50")},t.createElement("div",{className:"flex items-center justify-center gap-2"},t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return function(e){E(e);var t={};null==n||n.json_schema.fields.forEach(function(n){if("id"!==n.name)if("relation"===n.type&&n.relation){var r=n.relation.foreignKey||"".concat(n.relation.target,"_id");t[r]=e[r]}else{var i=e[n.name];"date"!==n.type&&"datetime"!==n.type||(i=i?v(i).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(i=null==i||""===i?"":"string"==typeof i?i:JSON.stringify(i,null,2)),t[n.name]=i}}),A(t),p(!0)}(e)},className:"h-8 w-8 p-0"},t.createElement(Q,{className:"h-4 w-4"})),t.createElement(vt,{variant:"ghost",size:"sm",onClick:function(){return ue(e)},disabled:J===e.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},J===e.id?t.createElement(q,{className:"h-4 w-4 animate-spin"}):t.createElement(ee,{className:"h-4 w-4"})))))})))),_>P&&t.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},t.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",t.createElement("span",{className:"font-semibold text-foreground"},M)," 页, 共 ",t.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(_/P))," 页"),t.createElement("div",{className:"flex gap-2"},t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return R(Math.max(1,M-1))},disabled:1===M||h},t.createElement(B,{className:"h-4 w-4 mr-1"}),"上一页"),t.createElement(vt,{variant:"outline",size:"sm",onClick:function(){return R(Math.min(Math.ceil(_/P),M+1))},disabled:M>=Math.ceil(_/P)||h},"下一页",t.createElement(I,{className:"h-4 w-4 ml-1"})))))),t.createElement(wf,{open:g,onOpenChange:b},t.createElement(Ef,{className:"max-w-3xl"},t.createElement(Cf,null,t.createElement(Of,{className:"text-xl"},"筛选"),t.createElement(Tf,{className:"text-sm"},n.name," - ",n.table_name)),t.createElement("div",{className:"py-2"},t.createElement(UT,{fields:n.json_schema.fields,value:oe,onChange:function(e){se(e),R(1)}})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return b(!1)}},"关闭")))),t.createElement(wf,{open:f,onOpenChange:p},t.createElement(Ef,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},t.createElement(Cf,null,t.createElement(Of,{className:"text-2xl"},x?"编辑数据":"新建数据"),t.createElement(Tf,{className:"text-base"},n.name," - ",n.table_name)),t.createElement("div",{className:"space-y-4 py-4"},n.json_schema.fields.map(function(e){return function(e){if("id"===e.name)return null;var n=le(e);switch(e.type){case"boolean":return t.createElement("div",{key:e.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},t.createElement(bf,{id:e.name,checked:O[e.name]||!1,disabled:!n,onCheckedChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t)))}}),t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium cursor-pointer"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"date",value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"datetime":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"datetime-local",value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"text":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(yf,{id:e.name,rows:4,value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"resize-none"}));case"json":case"jsonb":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(DT,{id:e.name,value:O[e.name]||"",required:e.required,disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t)))}}));case"integer":case"float":return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"number",value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}));case"relation":if(!e.relation)return null;var r=e.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=ne[a]||[],c=e.relation.foreignKey||"".concat(i,"_id"),h=void 0!==O[c]&&null!==O[c]?String(O[c]):"",u=l.find(function(e){return String(e.id)===h});return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement($d,{value:h,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;A(Object.assign(Object.assign({},O),k({},c,n?t:e)))}},t.createElement(Yd,{className:"h-11"},t.createElement(Kd,{placeholder:"请选择".concat(e.comment||e.name)},u?u.label:h?"ID: ".concat(h):"请选择".concat(e.comment||e.name))),t.createElement(Jd,null,0===l.length?t.createElement(Zd,{value:"_loading",disabled:!0},"加载中..."):l.map(function(e){return t.createElement(Zd,{key:e.id,value:String(e.id)},e.label)}))));default:return t.createElement("div",{key:e.name,className:"space-y-2"},t.createElement(Ta,{htmlFor:e.name,className:"text-base font-medium"},e.comment||e.name,e.required&&t.createElement("span",{className:"text-destructive ml-1"},"*")),t.createElement(bt,{id:e.name,type:"email"===e.type?"email":"text",maxLength:e.maxLength,value:O[e.name]||"",disabled:!n,onChange:function(t){return A(Object.assign(Object.assign({},O),k({},e.name,t.target.value)))},required:e.required,className:"h-11"}))}}(e)})),t.createElement(Nf,{className:"gap-2"},t.createElement(vt,{variant:"outline",onClick:function(){return p(!1)},disabled:$},"取消"),t.createElement(vt,{onClick:de,disabled:$},$?t.createElement(t.Fragment,null,t.createElement(q,{className:"h-4 w-4 mr-2 animate-spin"}),x?"更新中...":"创建中..."):x?"更新":"创建")))))):t.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},t.createElement("div",{className:"w-full py-4"},t.createElement(Ma,{className:"border-2"},t.createElement(La,{className:"py-16 text-center"},t.createElement(F,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),t.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function XT(e){var n=e.model;return t.createElement(GT,{key:n.id,model:n})}function JT(e){return e.models.map(function(e){return{path:"/data/list-".concat(e.id),name:e.name,icon:t.createElement(Z),component:function(){return t.createElement(XT,{model:e})}}})}var QT=function(e){return[{path:"/login",name:"登录",icon:t.createElement($),component:Dh},{name:"数据管理",icon:t.createElement(j),path:"/data",component:$T,routes:N(JT(e))}]},ZT=J,eM=te,tM=K;function nM(e){var n=e.inputModels,r=e.skipAuth,o=void 0!==r&&r,l=C(i("/data"),2),c=l[0],h=l[1],u=C(i([]),2);u[0],u[1];var d=C(i(!1),2),f=d[0],p=d[1],m=C(i(null),2),g=m[0],v=m[1],b=C(i(!0),2),y=b[0],k=b[1],E=s(function(){return QT({models:n.models})},[n.models]);a(function(){if(o)return p(!0),v(null),k(!1),void("/login"===c&&h("/data"));var e=function(){var e=w(S().m(function e(){var t,n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,Ch()){e.n=1;break}return p(!1),h("/login"),k(!1),e.a(2);case 1:return e.p=1,e.n=2,kh();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=Nh())){e.n=4;break}v(t),e.n=6;break;case 4:return e.n=5,Sh();case 5:(n=e.v).success&&n.data&&(v(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:p(!0),"/login"===c&&h("/data"),e.n=8;break;case 7:e.p=7,e.v,Eh(),p(!1),v(null),h("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,p(!1),v(null),h("/login");case 10:return e.p=10,k(!1),e.f(10);case 11:return e.a(2)}},e,null,[[1,7],[0,9,10,11]])}));return function(){return e.apply(this,arguments)}}();e()},[o]);var N=function(e,t){v(t),p(!0),h("/data"),Ga.success("欢迎回来,".concat(t.username,"!"))},O=function(e,t){var n,r=x(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.path===t)return i;if(i.routes){var o=O(i.routes,t);if(o)return o}}}catch(e){r.e(e)}finally{r.f()}return null};if(y)return t.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},t.createElement("div",{className:"space-y-4"},t.createElement(tt,{className:"h-12 w-48"}),t.createElement(tt,{className:"h-4 w-64"})));if(!f)return t.createElement(Dh,{onLoginSuccess:N});var A=E.filter(function(e){return"/login"!==e.path}),T=function(e){if(!e)return F;if(t.isValidElement(e)){var n=e.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return H;if(r.includes("Table"))return Z;if(r.includes("Database"))return F;if(r.includes("File"))return W}}return F},M=A.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:T(e.icon),path:e.path}}):[{title:e.name,icon:T(e.icon),path:e.path}]});return t.createElement(ua,null,t.createElement(da,{variant:"inset"},t.createElement(ma,{className:"border-b border-sidebar-border"},t.createElement("div",{className:"flex items-center gap-2 px-2 py-1"},t.createElement("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-primary"},t.createElement(ZT,{className:"w-4 h-4 text-primary-foreground"})),t.createElement("span",{className:"font-semibold text-lg"},"WE0-CMS"))),t.createElement(va,null,t.createElement(ba,null,t.createElement(ya,null,"Navigation"),t.createElement(wa,null,t.createElement(xa,null,M.map(function(e){return t.createElement(ka,{key:e.path},t.createElement(Ea,{onClick:function(){return h(e.path)},isActive:(n=e.path,c===n||c.startsWith(n+"/")),tooltip:e.title},t.createElement(e.icon,{className:"w-4 h-4"}),t.createElement("span",null,e.title)));var n}))))),t.createElement(ga,{className:"border-t border-sidebar-border"},t.createElement(xa,null,!o&&g&&t.createElement(t.Fragment,null,t.createElement(ka,null,t.createElement(Ea,{tooltip:g.username||"User"},t.createElement(eM,{className:"w-4 h-4"}),t.createElement("span",{className:"truncate"},g.username))),t.createElement(ka,null,t.createElement(Ea,{onClick:function(){window.confirm("确定要登出系统吗?")&&(Eh(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),p(!1),v(null),h("/login"),Ga.success("已成功登出"))},tooltip:"Logout"},t.createElement(tM,{className:"w-4 h-4"}),t.createElement("span",null,"Logout"))))))),t.createElement(pa,null,t.createElement("header",{className:"flex h-14 items-center gap-4 border-b bg-background px-6"},t.createElement(fa,null),t.createElement("h1",{className:"text-lg font-semibold"},function(){if("/login"===c)return"Login";var e=O(E,c);return(null==e?void 0:e.name)||"数据管理"}())),t.createElement("main",{className:"flex-1 p-6"},function(){if(!o&&"/login"===c)return t.createElement(Dh,{onLoginSuccess:N});if(o&&"/login"===c)return t.createElement($T,null);var e=O(E,c);if(e){var n=e.component;return t.createElement(n,null)}return t.createElement($T,null)}())))}export{nM as CmsLayoutShadcn,QT as cmsRoutes,nM as default,vh as setSessionId};
|
|
16
16
|
//# sourceMappingURL=index.esm.js.map
|