unleash-server 4.18.6 → 4.18.7
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/lib/create-config.js +1 -0
- package/dist/lib/create-config.js.map +1 -1
- package/dist/lib/routes/backstage.js +8 -0
- package/dist/lib/routes/backstage.js.map +1 -1
- package/dist/lib/types/option.d.ts +1 -0
- package/dist/lib/util/load-index-html.js +2 -1
- package/dist/lib/util/load-index-html.js.map +1 -1
- package/dist/lib/util/rewriteHTML.d.ts +1 -1
- package/dist/lib/util/rewriteHTML.js +2 -1
- package/dist/lib/util/rewriteHTML.js.map +1 -1
- package/dist/server-dev.js +1 -0
- package/dist/server-dev.js.map +1 -1
- package/frontend/build/index.html +2 -1
- package/frontend/build/static/{FeatureMetricsChart.5f300759.js → FeatureMetricsChart.3d538f46.js} +1 -1
- package/frontend/build/static/{Playground.dc6fedbc.js → Playground.50b68fc1.js} +2 -2
- package/frontend/build/static/index.5704f77b.js +434 -0
- package/frontend/package.json +7 -7
- package/package.json +7 -7
- package/frontend/build/static/index.2a5842ca.js +0 -434
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as ri,j as p,r as I,u as ke,C as z,B as ms,s as re,a as j,T as ie,b as Ef,d as Rt,e as Ca,f as L,g as If,S as Nf,h as Ff,i as Vf,k as Wf,F as $e,I as Hf,l as Ao,m as Oi,n as Aa,P as Ma,o as Vi,p as zf,A as wn,q as Wi,t as $f,v as Oa,w as jf,x as qf,y as Ur,z as Qs,D as cn,E as Js,G as Uf,H as Gf,J as Kf,K as Qf,L as Jf,M as Yf,N as Xf,O as Da,Q as Zf,R as Ys,U as Mo,V as _f,W as eu,X as tu,Y as gs,Z as iu,_ as nu,$ as su,a0 as ru,a1 as ou,a2 as Ta,a3 as lu,a4 as kn,a5 as au,a6 as hu,a7 as cu,a8 as fu,a9 as Pa,aa as Oo,ab as Do,ac as wi,ad as Xs,ae as uu,af as Zs,ag as du,ah as Ra,ai as pu,aj as mu,ak as gu,al as yu,am as bu}from"./index.2a5842ca.js";const Xn=ri(p("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z"}),"CancelOutlined"),xu=ri(p("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"CheckCircleOutline"),wu=ri(p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined"),ku=ri(p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error"),vu=ri(p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"}),"Help"),Su=ri(p("path",{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"}),"WarningOutlined"),Cu=n=>I.exports.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",...n},I.exports.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84818 0.184159C8.56367 -0.0789547 8.1234 -0.0575747 7.86482 0.231912C7.60623 0.521399 7.62724 0.96937 7.91175 1.23248C9.48292 2.68551 10.6076 4.74934 10.6076 7C10.6076 9.25066 9.48292 11.3145 7.91175 12.7675C7.62724 13.0306 7.60623 13.4786 7.86482 13.7681C8.1234 14.0576 8.56367 14.079 8.84818 13.8158C10.6396 12.1592 11.9998 9.73702 11.9998 7C11.9998 4.26298 10.6396 1.84083 8.84818 0.184159ZM6.04105 2.23302C6.29109 1.93586 6.73054 1.90121 7.02259 2.15563C8.33146 3.29586 9.35426 5.02309 9.35426 6.99995C9.35426 8.97682 8.33145 10.7039 7.02259 11.8441C6.73054 12.0986 6.29109 12.0639 6.04105 11.7668C5.79101 11.4696 5.82506 11.0225 6.11711 10.768C7.19425 9.82969 7.96199 8.46967 7.96199 6.99995C7.96199 5.53021 7.19423 4.17007 6.11711 3.23173C5.82506 2.97731 5.79101 2.53017 6.04105 2.23302ZM6.56908 7.00015C6.56908 8.56492 5.3224 9.83342 3.78454 9.83342C2.24668 9.83342 1 8.56492 1 7.00015C1 5.43539 2.24668 4.16689 3.78454 4.16689C5.3224 4.16689 6.56908 5.43539 6.56908 7.00015Z",fill:"currentColor"})),Au=n=>I.exports.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",...n},I.exports.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84835 0.184159C8.56384 -0.0789547 8.12358 -0.0575747 7.86499 0.231912C7.6064 0.521399 7.62741 0.96937 7.91192 1.23248C9.4831 2.68551 10.6078 4.74934 10.6078 7C10.6078 7.40738 10.5709 7.80863 10.5012 8.20125L11.6597 9.35972C11.8783 8.60937 12 7.81877 12 7C12 4.26298 10.6397 1.84083 8.84835 0.184159ZM9.35443 6.99995L9.35418 7.0542L7.63252 5.33255C7.30901 4.52372 6.76993 3.80029 6.11728 3.23173C5.82523 2.97731 5.79118 2.53017 6.04122 2.23302C6.29127 1.93586 6.73072 1.90121 7.02276 2.15563C8.33164 3.29586 9.35443 5.02309 9.35443 6.99995ZM7.57827 8.79752L6.48307 7.70233C6.17606 8.92745 5.08437 9.83342 3.78471 9.83342C2.24685 9.83342 1.00017 8.56492 1.00017 7.00015C1.00017 5.69492 1.8676 4.59583 3.04789 4.26714L0.458225 1.67748C0.172794 1.39205 0.178843 0.923223 0.471736 0.63033C0.764629 0.337437 1.23345 0.331388 1.51889 0.616819L13.2132 12.3111C13.4986 12.5965 13.4926 13.0654 13.1997 13.3583C12.9068 13.6511 12.4379 13.6572 12.1525 13.3718L10.556 11.7753C10.0694 12.539 9.48623 13.2259 8.84835 13.8158C8.56384 14.079 8.12358 14.0576 7.86499 13.7681C7.6064 13.4786 7.62741 13.0306 7.91192 12.7675C8.54021 12.1865 9.0971 11.5078 9.53922 10.7585L8.62356 9.84281C8.20906 10.6195 7.64861 11.2989 7.02276 11.8441C6.73072 12.0986 6.29127 12.0639 6.04122 11.7668C5.79118 11.4696 5.82523 11.0225 6.11728 10.768C6.73471 10.2302 7.25048 9.55374 7.57827 8.79752Z",fill:"currentColor"})),vn=({enabled:n,label:e,showIcon:t=!0})=>{const i=ke(),s=p(z,{condition:n==="unknown"||n==="unevaluated",show:p(Su,{color:"warning",fontSize:"inherit"}),elseShow:p(z,{condition:typeof n=="boolean"&&Boolean(n),show:p(Cu,{color:i.palette.success.main,strokeWidth:"0.25"}),elseShow:p(Au,{color:i.palette.error.main,strokeWidth:"0.25"})})});return p(z,{condition:n==="unknown"||n==="unevaluated",show:p(ms,{icon:t?s:void 0,color:"warning",children:e}),elseShow:p(z,{condition:typeof n=="boolean"&&Boolean(n),show:p(ms,{color:"success",icon:t?s:void 0,children:e}),elseShow:p(ms,{color:"error",icon:t?s:void 0,children:e})})})},Mu=re(j)(({theme:n})=>({display:"flex",alignItems:"center",padding:n.spacing(1,2)})),Ou=re(j)(()=>({marginRight:"auto"})),Du=({feature:n})=>{const[e,t]=(()=>{var i;return n!=null&&n.isEnabled?[!0,"True"]:((i=n==null?void 0:n.strategies)==null?void 0:i.result)==="unknown"?["unknown","Unknown"]:[!1,"False"]})();return p(Mu,{children:p(Ou,{"data-loading":!0,children:p(vn,{enabled:e,label:t,showIcon:e!=="unknown"})})})},Tu=re("div")(({theme:n})=>({padding:n.spacing(4),maxWidth:"400px"})),ys=re(ie)(({theme:n})=>({marginBottom:n.spacing(2)})),Pu=re(wu)(({theme:n})=>({color:n.palette.success.main})),Ru=({variants:n,selectedVariant:e})=>{const t=ke(),i=I.exports.useMemo(()=>n.map(c=>({name:c.name,weight:`${Ef(c.weight)}%`,selected:c.name===e})),[n,e]),s=I.exports.useMemo(()=>({sortBy:[{id:"name",desc:!1}]}),[]),{getTableProps:r,getTableBodyProps:o,headerGroups:l,rows:a,prepareRow:h}=Rt.exports.useTable({initialState:s,columns:Bu,data:i,sortTypes:Ca,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0},Rt.exports.useGlobalFilter,Rt.exports.useSortBy);return L(Tu,{children:[p(ys,{variant:"subtitle2",children:"Variant Information"}),p(ys,{variant:"body2",children:"The following table shows the variants defined on this feature toggle and the variant result based on your context configuration."}),p(ys,{variant:"body2",children:'If you include "userId" or "sessionId" in your context, the variant will be the same every time because unleash uses these properties to ensure that the user receives the same experience.'}),L(If,{...r(),rowHeight:"dense",children:[p(Nf,{headerGroups:l}),p(Ff,{...o(),children:a.map(c=>{let f={};return c.original.selected||(f.color=t.palette.text.secondary),h(c),p(Vf,{hover:!0,...c.getRowProps(),children:c.cells.map(u=>p(Wf,{...u.getCellProps(),style:f,children:u.render("Cell")}))})})})]})]})},Bu=[{id:"Icon",Cell:({row:{original:{selected:n}}})=>p($e,{children:p(z,{condition:n,show:p(Hf,{icon:p(Pu,{})})})}),maxWidth:25,disableGlobalFilter:!0},{Header:"Name",accessor:"name",searchable:!0,Cell:({row:{original:{name:n}}})=>p(Ao,{children:n}),maxWidth:175,width:175},{Header:"Weight",accessor:"weight",sortType:"alphanumeric",searchable:!0,maxWidth:75,Cell:({row:{original:{weight:n}}})=>p(Ao,{children:n})}],Lu=re("div")(()=>({maxWidth:"100%",display:"flex",alignItems:"center",wordBreak:"break-all"})),Eu=({variant:n,variants:e,feature:t,isEnabled:i})=>{const s=ke(),[r,o]=I.exports.useState(null),l=c=>o(c.currentTarget),a=()=>o(null),h=Boolean(r);return L(Lu,{children:[n,p(z,{condition:Boolean(e)&&e.length>0&&i,show:L($e,{children:[p(Oi,{onClick:l,children:p(Aa,{})}),p(Ma,{open:h,id:`${t}-result-variants`,PaperProps:{sx:{borderRadius:`${s.shape.borderRadiusLarge}px`}},onClose:a,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:-320},children:p(Ru,{variants:e,selectedVariant:n})})]})})]})},Iu=Vi()(n=>({popoverPaper:{display:"flex",flexDirection:"column",padding:n.spacing(6),width:728,maxWidth:"100%",height:"auto",overflowY:"auto",backgroundColor:n.palette.tertiary.light,borderRadius:n.shape.borderRadiusLarge}})),Nu=Vi()(n=>({titleRowWrapper:{display:"flex",justifyContent:"space-between",width:"100%"},titleRow:{display:"inline-flex",alignItems:"center",gap:n.spacing(1.5),marginTop:n.spacing(1.5)},alertRow:{margin:n.spacing(1,0)},descriptionRow:{margin:n.spacing(1,.5)},name:{fontWeight:600,padding:n.spacing(.5)},icon:{textAlign:"right"}})),Ba=["default","applicationHostname","flexibleRollout","gradualRolloutRandom","gradualRolloutSessionId","gradualRolloutUserId","remoteAddress","userWithId"];function La(n){return n===void 0?!0:Object.values(n).every(e=>e&&typeof e=="object"?La(e):e===null)}const To=n=>{var e,t;return(t=(e=n.strategies)==null?void 0:e.data)==null?void 0:t.find(i=>!Ba.includes(i.name))},Fu=n=>{var e,t;return!((t=(e=n.strategies)==null?void 0:e.data)!=null&&t.find(i=>Ba.includes(i.name)))},Vu=({feature:n,input:e,onClose:t})=>{var f;const{classes:i}=Nu(),s=ke(),[r,o,l]=(()=>n.isEnabled?[`This feature toggle is True in ${e==null?void 0:e.environment} because `,"at least one strategy is True",s.palette.success.main]:n.isEnabledInCurrentEnvironment?Fu(n)?[`This feature toggle is Unknown in ${e==null?void 0:e.environment} because `,"no strategies could be fully evaluated",s.palette.warning.main]:To(n)?[`This feature toggle is Unknown in ${e==null?void 0:e.environment} because `,"not all strategies could be fully evaluated",s.palette.warning.main]:[`This feature toggle is False in ${e==null?void 0:e.environment} because `,"all strategies are either False or could not be fully evaluated",s.palette.error.main]:[`This feature toggle is False in ${e==null?void 0:e.environment} because `,"the environment is disabled",s.palette.error.main])(),a=La(e==null?void 0:e.context)?"You did not provide a value for your context field in step 2 of the configuration":void 0,h=To(n)?"This feature uses custom strategies. Custom strategies can't be evaluated, so they will be marked accordingly.":void 0,c=t&&(u=>{u.stopPropagation(),t()});return L($e,{children:[L("div",{className:i.titleRowWrapper,children:[L("div",{className:i.titleRow,children:[p(ie,{variant:"subtitle1",className:i.name,children:n.name}),p(z,{condition:((f=n==null?void 0:n.strategies)==null?void 0:f.result)!=="unknown",show:()=>p(vn,{enabled:n.isEnabled,label:n.isEnabled?"True":"False"}),elseShow:()=>p(vn,{enabled:"unknown",label:"Unknown",showIcon:!1})})]}),p(Oi,{onClick:c,className:i.icon,children:p(zf,{})})]}),L("div",{className:i.descriptionRow,children:[p(ie,{variant:"body1",component:"span",children:r}),p(ie,{variant:"subtitle1",color:l,component:"span",children:o}),p(ie,{variant:"body1",component:"span",children:"."})]}),p(z,{condition:Boolean(a),show:p("div",{className:i.alertRow,children:p(wn,{color:"info",children:a})})}),p(z,{condition:Boolean(h),show:p("div",{className:i.alertRow,children:p(wn,{severity:"warning",color:"info",children:h})})})]})},Ea=Vi()(n=>({valueContainer:{display:"flex",alignItems:"center",gap:"1ch"},valueSeparator:{color:n.palette.grey[700]},summary:{width:"auto",height:"auto",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`}})),Wu=re("div")(({theme:n})=>({display:"flex",alignItems:"center",marginTop:n.spacing(1),color:n.palette.error.main})),Hu=({constraint:n,input:e})=>L(Wu,{children:[p(Xn,{style:{marginRight:"0.25rem"}}),p(ie,{variant:"body2",children:(()=>{const i=e==null?void 0:e.context[n.contextName];return i?`Constraint not met \u2013 the value in the context: { ${i} } is not ${n.operator} ${n.contextName}`:`Constraint not met \u2013 no value was specified for ${n.contextName}`})()})]}),zu=re(xu)(({theme:n})=>({color:n.palette.success.main})),$u=re("div")(({theme:n})=>({display:"flex",alignItems:"center",marginTop:n.spacing(1),color:n.palette.success.main})),ju=()=>L($u,{children:[p(zu,{style:{marginRight:"0.25rem"}}),p(ie,{variant:"body2",children:"Constraint met by value in context"})]}),qu=re("div")(()=>({width:"100%",display:"flex",flexDirection:"column"})),Ia=({constraints:n,input:e})=>n?p(qu,{children:n==null?void 0:n.map((t,i)=>L(I.exports.Fragment,{children:[p(z,{condition:i>0,show:p(Wi,{text:"AND"})}),p($f,{constraint:t,compact:!0,renderAfter:p(z,{condition:t.result,show:p(ju,{}),elseShow:p(Hu,{input:e,constraint:t})})})]},Oa(t)))}):null,Uu=re("div")(({theme:n})=>({color:n.palette.error.main,display:"inline-flex",justifyContent:"center",marginLeft:"auto",gap:n.spacing(1)})),Gu=({segments:n,input:e})=>n?p($e,{children:n.map((t,i)=>L(I.exports.Fragment,{children:[p(jf,{segment:t,constraintList:p(Ia,{constraints:t.constraints,input:e}),headerContent:p(z,{condition:!Boolean(t.result),show:L(Uu,{children:[p(ie,{variant:"subtitle2",sx:{pt:.25},children:"segment is false"}),p("span",{children:p(Xn,{})})]})}),isExpanded:!0}),p(z,{condition:i>=0&&n.length>1&&i!==n.length-1,show:p(Wi,{text:"AND"})})]},t.id))}):null,Ku=Vi()(n=>({container:{width:"100%",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:n.spacing(2)},disabled:{backgroundColor:n.palette.neutral.light,opacity:"90%"},chip:{margin:"0.25rem"},column:{flexDirection:"column"},paragraph:{display:"inline",margin:"0.25rem 0",maxWidth:"95%",textAlign:"center",wordBreak:"break-word"}})),bs=({value:n,text:e,input:t,showReason:i=!1})=>{const{classes:s}=Ku(),r=ke(),o=t==="no value"?"error":"neutral",l=`value does not match any ${e}`;return L("div",{className:qf(s.container,i?s.disabled:""),children:[p(ie,{variant:"subtitle1",color:r.palette[o].main,children:`${t}`}),L("div",{className:s.column,children:[p(z,{condition:Boolean(i),show:p(ie,{variant:"subtitle1",color:r.palette.error.main,children:l})}),p(z,{condition:n.length===0,show:L("p",{children:["No ",e,"s added yet."]}),elseShow:L("div",{children:[L("p",{className:s.paragraph,children:[n.length," ",n.length>1?`${e}s`:e," will get access."]}),n.map(a=>p(Ur,{label:p(Qs,{maxWidth:"300",text:a.toString(),maxLength:50}),className:s.chip},a))]})})]}),p(z,{condition:Boolean(i),show:p(Xn,{color:"error"}),elseShow:p("div",{})})]})},at=n=>{switch(n.toUpperCase()){case"USERIDS":return"userId";case"IPS":return"remoteAddress";default:return n}},Qu=({parameters:n,constraints:e,input:t})=>{const{classes:i}=Ea();return p($e,{children:Object.keys(n).map(s=>{var r,o,l,a,h,c,f,u;switch(s){case"rollout":case"Rollout":const d=Js(n[s]);return L(j,{className:i.summary,sx:{display:"flex",alignItems:"center"},children:[p(j,{sx:{mr:"1rem"},children:p(Uf,{percentage:d,size:"2rem"})}),L("div",{children:[p(Ur,{color:"success",variant:"outlined",size:"small",label:`${d}%`})," ","of your base"," ",e.length>0?"who match constraints":""," ","is included."]})]},s);case"userIds":case"UserIds":const m=cn(n[s]);return p(bs,{value:m,text:"user",input:Boolean((r=t==null?void 0:t.context)==null?void 0:r[at(s)])?(o=t==null?void 0:t.context)==null?void 0:o[at(s)]:"no value",showReason:Boolean((l=t==null?void 0:t.context)==null?void 0:l[at(s)])?!m.includes((a=t==null?void 0:t.context)==null?void 0:a[at(s)]):void 0},s);case"hostNames":case"HostNames":const y=cn(n[s]);return p(bs,{value:y,text:"host",input:"no value",showReason:void 0},s);case"IPs":const x=cn(n[s]);return p(bs,{value:x,text:"IP",input:Boolean((h=t==null?void 0:t.context)==null?void 0:h[at(s)])?(c=t==null?void 0:t.context)==null?void 0:c[at(s)]:"no value",showReason:Boolean((f=t==null?void 0:t.context)==null?void 0:f[at(s)])?!x.includes((u=t==null?void 0:t.context)==null?void 0:u[at(s)]):void 0},s);case"stickiness":case"groupId":return null;default:return null}})})},Ju=re(j)(({theme:n})=>({width:"100%",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`,display:"flex",flexDirection:"row",alignItems:"center",gap:2})),hi=({text:n,input:e=null,isRequired:t=!1})=>{const i=ke(),s=e===null?"error":"neutral",r=t&&e===null;return L(Ju,{children:[p(ie,{variant:"subtitle1",color:i.palette[s].main,sx:{minWidth:118},children:`${e===null?"no value":e}`}),p(j,{sx:{flexGrow:1,flexDirection:"column"},children:p(j,{sx:{flexGrow:1},children:p(z,{condition:Boolean(r),show:L($e,{children:[p(ie,{component:"span",color:i.palette.error.main,children:" required parameter "}),p(Qs,{maxWidth:"300",text:n,maxLength:50}),p(ie,{component:"span",color:i.palette.error.main,children:" is not set "})]}),elseShow:L($e,{children:[p(ie,{component:"span",color:"text.disabled",children:" set on parameter "}),p(Qs,{maxWidth:"300",text:n,maxLength:50})]})})})}),p(z,{condition:Boolean(r),show:p(Xn,{color:"error"}),elseShow:p("div",{})})]})},Yu=({strategyName:n,parameters:e})=>{const{strategies:t}=Gf(),i=t.find(r=>r.name===n);if(!(i!=null&&i.editable))return null;const s=i==null?void 0:i.parameters.map(r=>{const o=e[r.name],l=r.required;switch(r==null?void 0:r.type){case"list":const a=cn(o);return p(hi,{isRequired:l,text:r.name,input:(a==null?void 0:a.length)>0?a.join(", "):null});case"percentage":const h=Js(o),c=!(o===void 0||o===""||h<0||h>100);return p(hi,{text:r.name,isRequired:l,input:c?`${h}%`:void 0});case"boolean":const f=["true","false"].includes(o)?o:void 0;return p(hi,{isRequired:l,text:r.name,input:o!==void 0?f:void 0});case"string":const u=Kf(o);return p(hi,{text:r.name,isRequired:l,input:u!==void 0?u:void 0});case"number":const d=!(o===void 0||o===""),m=Js(o);return p(hi,{text:r.name,isRequired:l,input:d?`${m}`:void 0});case"default":return null}return null});return p($e,{children:s.map((r,o)=>L(I.exports.Fragment,{children:[p(z,{condition:o>0,show:p(Wi,{text:"AND"})}),r]},o))})},Xu=re("div")(({theme:n})=>({padding:n.spacing(0)})),Zu=({strategyResult:n,input:e})=>{const{name:t,constraints:i,segments:s,parameters:r}=n,{uiConfig:o}=Qf(),{classes:l}=Ea(),a=Boolean(o.flags.SE)&&Boolean(s&&s.length>0),h=Boolean(i&&(i==null?void 0:i.length)>0),c=t!=="default"&&Object.keys(Jf).includes(t),f=Object.keys(r).length>0&&n.result.evaluationStatus==="incomplete";if(!r)return null;const u=[a&&p(Gu,{segments:s,input:e}),h&&p(Ia,{constraints:i,input:e}),c&&p(Qu,{parameters:r,constraints:i,input:e}),f&&p(Yu,{strategyName:t,parameters:r}),t==="default"&&L(j,{sx:{width:"100%"},className:l.summary,children:["The standard strategy is"," ",p(Ur,{variant:"outlined",size:"small",color:"success",label:"ON"})," ","for all users."]})].filter(Boolean);return p(Xu,{children:u.map((d,m)=>L(I.exports.Fragment,{children:[p(z,{condition:m>0,show:p(Wi,{text:"AND"})}),d]},m))})},_u=Vi()(n=>({header:{display:"flex",padding:n.spacing(2,2),justifyContent:"space-between"},headerName:{padding:n.spacing(.5,2),display:"flex",gap:n.spacing(1),alignItems:"center",borderBottom:`1px solid ${n.palette.divider}`,fontWeight:n.typography.fontWeightMedium},icon:{fill:n.palette.inactiveIcon},resultChip:{marginLeft:"auto"},body:{padding:n.spacing(2),justifyItems:"center"},innerContainer:{[n.breakpoints.down(400)]:{padding:"0.5rem"},width:"100%",flexShrink:0,paddingBottom:"1rem",borderRadius:n.shape.borderRadiusMedium,background:n.palette.background.default},successBorder:{borderColor:n.palette.success.main}})),ed=({strategy:n,input:e,index:t})=>{const{result:i}=n,{classes:s}=_u(),r=ke(),o=i.evaluationStatus==="incomplete"?"Unevaluated":i.enabled?"True":"False";return p(Yf,{className:i.enabled&&i.evaluationStatus==="complete"?s.successBorder:void 0,strategy:{...n,id:`${Oa(n)}`},orderNumber:t+1,actions:p(vn,{showIcon:!1,enabled:i.enabled,label:o}),children:p(Zu,{strategyResult:n,input:e,percentageFill:r.palette.tertiary.light})})},td=re("div")(({theme:n})=>({display:"flex",padding:"0, 4px",flexDirection:"column",borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.warning.border}`})),id=re("div")(({theme:n})=>({padding:n.spacing(1,.5)})),nd=re(wn)(({theme:n})=>({border:"0!important",borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:`1px solid ${n.palette.warning.border}!important`})),Na=({strategies:n,input:e})=>p(z,{condition:n.length>0,show:L($e,{children:[p(ie,{variant:"subtitle1",sx:{mt:2,ml:1,mb:2,color:"text.secondary"},children:`Strategies (${n==null?void 0:n.length})`}),p(j,{sx:{width:"100%"},children:n==null?void 0:n.map((t,i)=>L(I.exports.Fragment,{children:[p(z,{condition:i>0,show:p(Wi,{text:"OR"})}),p(ed,{strategy:t,index:i,input:e},t.id)]},t.id))})]})}),sd=({strategies:n,input:e})=>L(td,{sx:{pb:1,mt:2},children:[L(nd,{severity:"info",color:"warning",children:["If environment was enabled, then this feature toggle would be"," ",n!=null&&n.result?"TRUE":"FALSE"," with strategies evaluated like so:"," "]}),p(id,{sx:{p:2.5},children:p(Na,{strategies:(n==null?void 0:n.data)||[],input:e})})]}),rd=({feature:n,input:e})=>{var t,i,s,r;return L($e,{children:[p(z,{condition:((i=(t=n==null?void 0:n.strategies)==null?void 0:t.data)==null?void 0:i.length)===0,show:p(wn,{severity:"warning",sx:{mt:2},children:"There are no strategies added to this feature toggle in selected environment."})}),p(z,{condition:!n.isEnabledInCurrentEnvironment&&Boolean((s=n==null?void 0:n.strategies)==null?void 0:s.data),show:p(sd,{strategies:n==null?void 0:n.strategies,input:e}),elseShow:p(Na,{strategies:((r=n==null?void 0:n.strategies)==null?void 0:r.data)||[],input:e})})]})},od=re("div")(({theme:n})=>({alignItems:"flex-end",color:n.palette.tertiary.main})),ld=({feature:n,input:e})=>{const[t,i]=I.exports.useState(!1),{classes:s}=Iu(),r=I.exports.useRef(null),o=()=>{i(!t)};return n?L(od,{children:[p(Oi,{onClick:o,children:p(Aa,{ref:r})}),L(Ma,{open:t,onClose:()=>i(!1),anchorEl:r.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},classes:{paper:s.popoverPaper},children:[p(Vu,{feature:n,input:e,onClose:()=>i(!1)}),p(rd,{feature:n,input:e})]})]}):null},ad={id:"name"},{value:Po,setValue:hd}=Xf("PlaygroundResultsTable:v1",ad),cd=({features:n,input:e,loading:t})=>{const[i,s]=Da(),r=Zf(t),[o,l]=I.exports.useState(i.get("search")||""),a=ke(),h=Ys(a.breakpoints.down("sm")),c=Ys(a.breakpoints.down("md")),f=I.exports.useMemo(()=>[{Header:"Name",accessor:"name",searchable:!0,minWidth:160,Cell:({value:k,row:{original:O}})=>p(Mo,{title:k,to:`/projects/${O==null?void 0:O.projectId}/features/${k}`})},{Header:"Project ID",accessor:"projectId",sortType:"alphanumeric",filterName:"projectId",searchable:!0,maxWidth:170,Cell:({value:k})=>p(Mo,{title:k,to:`/projects/${k}`})},{Header:"Variant",id:"variant",accessor:"variant.name",sortType:"alphanumeric",filterName:"variant",searchable:!0,maxWidth:200,Cell:({value:k,row:{original:{variant:O,feature:F,variants:T,isEnabled:E}}})=>p(Eu,{variant:O!=null&&O.enabled?k:"",variants:T,feature:F,isEnabled:E})},{id:"isEnabled",Header:"isEnabled",filterName:"isEnabled",accessor:k=>{var O;return k!=null&&k.isEnabled?"true":((O=k==null?void 0:k.strategies)==null?void 0:O.result)==="unknown"?"unknown":"false"},Cell:({row:k})=>p(Du,{feature:k.original}),sortType:"playgroundResultState",maxWidth:120,sortInverted:!0},{Header:"",maxWidth:70,id:"info",Cell:({row:k})=>p(ld,{feature:k.original,input:e})}],[e]),{data:u,getSearchText:d,getSearchContext:m}=_f(f,o,n||[]),y=I.exports.useMemo(()=>t?Array(5).fill({name:"Feature name",projectId:"FeatureProject",variant:{name:"FeatureVariant",variants:[]},enabled:!0}):u,[u,t]),[x]=I.exports.useState(()=>({sortBy:[{id:i.get("sort")||Po.id,desc:i.has("order")?i.get("order")==="desc":Po.desc}]})),{headerGroups:b,rows:v,state:{sortBy:M},prepareRow:S,setHiddenColumns:C}=Rt.exports.useTable({initialState:x,columns:f,data:y,sortTypes:Ca,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:eu}},Rt.exports.useGlobalFilter,Rt.exports.useFlexLayout,Rt.exports.useSortBy);return I.exports.useEffect(()=>{const k=[];c&&k.push("projectId"),h&&k.push("variant"),C(k)},[C,h,c]),I.exports.useEffect(()=>{if(t)return;const k=Object.fromEntries(i);k.sort=M[0].id,M[0].desc?k.order="desc":k.order&&delete k.order,o?k.search=o:delete k.search,s(k,{replace:!0}),hd({id:M[0].id,desc:M[0].desc||!1})},[t,M,o]),L($e,{children:[L(j,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[p(ie,{variant:"subtitle1",sx:{ml:1},children:n!==void 0&&!t?`Results (${v.length<y.length?`${v.length} of ${y.length}`:y.length})`:"Results"}),p(tu,{initialValue:o,onChange:l,hasFilters:!0,getSearchContext:m,disabled:t,containerStyles:{marginLeft:"1rem",maxWidth:"400px"}})]}),p(z,{condition:!t&&!y,show:()=>p(gs,{children:y===void 0?"None of the feature toggles were evaluated yet.":"No results found."}),elseShow:()=>L(j,{ref:r,children:[p(iu,{value:d(o),children:p(nu,{rows:v,headerGroups:b,prepareRow:S})}),p(z,{condition:y.length===0&&(o==null?void 0:o.length)>0,show:L(gs,{children:["No feature toggles found matching \u201C",o,"\u201D"]})}),p(z,{condition:y&&y.length===0&&!o,show:p(gs,{children:"No features toggles to display"})})]})})]})},fd=()=>{const{makeRequest:n,createRequest:e,errors:t,loading:i}=su({propagateErrors:!0}),s="api/admin/playground";return{evaluatePlayground:async o=>{const a=e(s,{method:"POST",body:JSON.stringify(o)});try{return(await n(a.caller,a.id)).json()}catch(h){throw h}},errors:t,loading:i}},ud=re("div")(({style:n,theme:e})=>({width:"25px",height:"25px",borderRadius:"50%",color:e.palette.text.tertiaryContrast,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",...n})),Zn=({style:n,children:e,type:t})=>{const i=ke(),s={backgroundColor:i.palette.primary.main};return t==="secondary"&&(s.backgroundColor=i.palette.tertiary.dark),p(ud,{style:{...s,...n},children:e})},dd=n=>!n||n.length===0||n.length===1&&n[0]==="*"?"*":n,pd=n=>{const e=Fa(n);return e.length>0?e[0]:""},Fa=n=>n.filter(({enabled:e})=>Boolean(e)).sort((e,t)=>e.sortOrder-t.sortOrder).map(({name:e})=>e),md=(n,e)=>n?"100%":e&&!n?"65%":"50%";function _s(n,e,t){var i,s,r,o,l;e==null&&(e=100);function a(){var c=Date.now()-o;c<e&&c>=0?i=setTimeout(a,e-c):(i=null,t||(l=n.apply(r,s),r=s=null))}var h=function(){r=this,s=arguments,o=Date.now();var c=t&&!i;return i||(i=setTimeout(a,e)),c&&(l=n.apply(r,s),r=s=null),l};return h.clear=function(){i&&(clearTimeout(i),i=null)},h.flush=function(){i&&(l=n.apply(r,s),r=s=null,clearTimeout(i),i=null)},h}_s.debounce=_s;var gd=_s;function er(){return er=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},er.apply(this,arguments)}function yd(n,e){if(n==null)return{};var t={},i=Object.keys(n),s,r;for(r=0;r<i.length;r++)s=i[r],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}class U{constructor(){}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,i){let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Je.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),Je.from(i,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),i=this.length-this.scanIdentical(e,-1),s=new ki(this),r=new ki(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new ki(this,e)}iterRange(e,t=this.length){return new Va(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Wa(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?U.empty:e.length<=32?new ne(e):Je.from(ne.split(e,[]))}}class ne extends U{constructor(e,t=bd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new xd(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new ne(Ro(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=fn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new ne(l,o.length+r.length));else{let a=l.length>>1;i.push(new ne(l.slice(0,a)),new ne(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof ne))return super.replace(e,t,i);let s=fn(this.text,fn(i.text,Ro(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new ne(s,r):Je.from(ne.split(s,[]),r)}sliceString(e,t=this.length,i=`
|
|
1
|
+
import{c as ri,j as p,r as I,u as ke,C as z,B as ms,s as re,a as j,T as ie,b as Ef,d as Rt,e as Ca,f as L,g as If,S as Nf,h as Ff,i as Vf,k as Wf,F as $e,I as Hf,l as Ao,m as Oi,n as Aa,P as Ma,o as Vi,p as zf,A as wn,q as Wi,t as $f,v as Oa,w as jf,x as qf,y as Ur,z as Qs,D as cn,E as Js,G as Uf,H as Gf,J as Kf,K as Qf,L as Jf,M as Yf,N as Xf,O as Da,Q as Zf,R as Ys,U as Mo,V as _f,W as eu,X as tu,Y as gs,Z as iu,_ as nu,$ as su,a0 as ru,a1 as ou,a2 as Ta,a3 as lu,a4 as kn,a5 as au,a6 as hu,a7 as cu,a8 as fu,a9 as Pa,aa as Oo,ab as Do,ac as wi,ad as Xs,ae as uu,af as Zs,ag as du,ah as Ra,ai as pu,aj as mu,ak as gu,al as yu,am as bu}from"./index.5704f77b.js";const Xn=ri(p("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z"}),"CancelOutlined"),xu=ri(p("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"CheckCircleOutline"),wu=ri(p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined"),ku=ri(p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error"),vu=ri(p("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"}),"Help"),Su=ri(p("path",{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"}),"WarningOutlined"),Cu=n=>I.exports.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",...n},I.exports.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84818 0.184159C8.56367 -0.0789547 8.1234 -0.0575747 7.86482 0.231912C7.60623 0.521399 7.62724 0.96937 7.91175 1.23248C9.48292 2.68551 10.6076 4.74934 10.6076 7C10.6076 9.25066 9.48292 11.3145 7.91175 12.7675C7.62724 13.0306 7.60623 13.4786 7.86482 13.7681C8.1234 14.0576 8.56367 14.079 8.84818 13.8158C10.6396 12.1592 11.9998 9.73702 11.9998 7C11.9998 4.26298 10.6396 1.84083 8.84818 0.184159ZM6.04105 2.23302C6.29109 1.93586 6.73054 1.90121 7.02259 2.15563C8.33146 3.29586 9.35426 5.02309 9.35426 6.99995C9.35426 8.97682 8.33145 10.7039 7.02259 11.8441C6.73054 12.0986 6.29109 12.0639 6.04105 11.7668C5.79101 11.4696 5.82506 11.0225 6.11711 10.768C7.19425 9.82969 7.96199 8.46967 7.96199 6.99995C7.96199 5.53021 7.19423 4.17007 6.11711 3.23173C5.82506 2.97731 5.79101 2.53017 6.04105 2.23302ZM6.56908 7.00015C6.56908 8.56492 5.3224 9.83342 3.78454 9.83342C2.24668 9.83342 1 8.56492 1 7.00015C1 5.43539 2.24668 4.16689 3.78454 4.16689C5.3224 4.16689 6.56908 5.43539 6.56908 7.00015Z",fill:"currentColor"})),Au=n=>I.exports.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",...n},I.exports.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84835 0.184159C8.56384 -0.0789547 8.12358 -0.0575747 7.86499 0.231912C7.6064 0.521399 7.62741 0.96937 7.91192 1.23248C9.4831 2.68551 10.6078 4.74934 10.6078 7C10.6078 7.40738 10.5709 7.80863 10.5012 8.20125L11.6597 9.35972C11.8783 8.60937 12 7.81877 12 7C12 4.26298 10.6397 1.84083 8.84835 0.184159ZM9.35443 6.99995L9.35418 7.0542L7.63252 5.33255C7.30901 4.52372 6.76993 3.80029 6.11728 3.23173C5.82523 2.97731 5.79118 2.53017 6.04122 2.23302C6.29127 1.93586 6.73072 1.90121 7.02276 2.15563C8.33164 3.29586 9.35443 5.02309 9.35443 6.99995ZM7.57827 8.79752L6.48307 7.70233C6.17606 8.92745 5.08437 9.83342 3.78471 9.83342C2.24685 9.83342 1.00017 8.56492 1.00017 7.00015C1.00017 5.69492 1.8676 4.59583 3.04789 4.26714L0.458225 1.67748C0.172794 1.39205 0.178843 0.923223 0.471736 0.63033C0.764629 0.337437 1.23345 0.331388 1.51889 0.616819L13.2132 12.3111C13.4986 12.5965 13.4926 13.0654 13.1997 13.3583C12.9068 13.6511 12.4379 13.6572 12.1525 13.3718L10.556 11.7753C10.0694 12.539 9.48623 13.2259 8.84835 13.8158C8.56384 14.079 8.12358 14.0576 7.86499 13.7681C7.6064 13.4786 7.62741 13.0306 7.91192 12.7675C8.54021 12.1865 9.0971 11.5078 9.53922 10.7585L8.62356 9.84281C8.20906 10.6195 7.64861 11.2989 7.02276 11.8441C6.73072 12.0986 6.29127 12.0639 6.04122 11.7668C5.79118 11.4696 5.82523 11.0225 6.11728 10.768C6.73471 10.2302 7.25048 9.55374 7.57827 8.79752Z",fill:"currentColor"})),vn=({enabled:n,label:e,showIcon:t=!0})=>{const i=ke(),s=p(z,{condition:n==="unknown"||n==="unevaluated",show:p(Su,{color:"warning",fontSize:"inherit"}),elseShow:p(z,{condition:typeof n=="boolean"&&Boolean(n),show:p(Cu,{color:i.palette.success.main,strokeWidth:"0.25"}),elseShow:p(Au,{color:i.palette.error.main,strokeWidth:"0.25"})})});return p(z,{condition:n==="unknown"||n==="unevaluated",show:p(ms,{icon:t?s:void 0,color:"warning",children:e}),elseShow:p(z,{condition:typeof n=="boolean"&&Boolean(n),show:p(ms,{color:"success",icon:t?s:void 0,children:e}),elseShow:p(ms,{color:"error",icon:t?s:void 0,children:e})})})},Mu=re(j)(({theme:n})=>({display:"flex",alignItems:"center",padding:n.spacing(1,2)})),Ou=re(j)(()=>({marginRight:"auto"})),Du=({feature:n})=>{const[e,t]=(()=>{var i;return n!=null&&n.isEnabled?[!0,"True"]:((i=n==null?void 0:n.strategies)==null?void 0:i.result)==="unknown"?["unknown","Unknown"]:[!1,"False"]})();return p(Mu,{children:p(Ou,{"data-loading":!0,children:p(vn,{enabled:e,label:t,showIcon:e!=="unknown"})})})},Tu=re("div")(({theme:n})=>({padding:n.spacing(4),maxWidth:"400px"})),ys=re(ie)(({theme:n})=>({marginBottom:n.spacing(2)})),Pu=re(wu)(({theme:n})=>({color:n.palette.success.main})),Ru=({variants:n,selectedVariant:e})=>{const t=ke(),i=I.exports.useMemo(()=>n.map(c=>({name:c.name,weight:`${Ef(c.weight)}%`,selected:c.name===e})),[n,e]),s=I.exports.useMemo(()=>({sortBy:[{id:"name",desc:!1}]}),[]),{getTableProps:r,getTableBodyProps:o,headerGroups:l,rows:a,prepareRow:h}=Rt.exports.useTable({initialState:s,columns:Bu,data:i,sortTypes:Ca,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0},Rt.exports.useGlobalFilter,Rt.exports.useSortBy);return L(Tu,{children:[p(ys,{variant:"subtitle2",children:"Variant Information"}),p(ys,{variant:"body2",children:"The following table shows the variants defined on this feature toggle and the variant result based on your context configuration."}),p(ys,{variant:"body2",children:'If you include "userId" or "sessionId" in your context, the variant will be the same every time because unleash uses these properties to ensure that the user receives the same experience.'}),L(If,{...r(),rowHeight:"dense",children:[p(Nf,{headerGroups:l}),p(Ff,{...o(),children:a.map(c=>{let f={};return c.original.selected||(f.color=t.palette.text.secondary),h(c),p(Vf,{hover:!0,...c.getRowProps(),children:c.cells.map(u=>p(Wf,{...u.getCellProps(),style:f,children:u.render("Cell")}))})})})]})]})},Bu=[{id:"Icon",Cell:({row:{original:{selected:n}}})=>p($e,{children:p(z,{condition:n,show:p(Hf,{icon:p(Pu,{})})})}),maxWidth:25,disableGlobalFilter:!0},{Header:"Name",accessor:"name",searchable:!0,Cell:({row:{original:{name:n}}})=>p(Ao,{children:n}),maxWidth:175,width:175},{Header:"Weight",accessor:"weight",sortType:"alphanumeric",searchable:!0,maxWidth:75,Cell:({row:{original:{weight:n}}})=>p(Ao,{children:n})}],Lu=re("div")(()=>({maxWidth:"100%",display:"flex",alignItems:"center",wordBreak:"break-all"})),Eu=({variant:n,variants:e,feature:t,isEnabled:i})=>{const s=ke(),[r,o]=I.exports.useState(null),l=c=>o(c.currentTarget),a=()=>o(null),h=Boolean(r);return L(Lu,{children:[n,p(z,{condition:Boolean(e)&&e.length>0&&i,show:L($e,{children:[p(Oi,{onClick:l,children:p(Aa,{})}),p(Ma,{open:h,id:`${t}-result-variants`,PaperProps:{sx:{borderRadius:`${s.shape.borderRadiusLarge}px`}},onClose:a,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:-320},children:p(Ru,{variants:e,selectedVariant:n})})]})})]})},Iu=Vi()(n=>({popoverPaper:{display:"flex",flexDirection:"column",padding:n.spacing(6),width:728,maxWidth:"100%",height:"auto",overflowY:"auto",backgroundColor:n.palette.tertiary.light,borderRadius:n.shape.borderRadiusLarge}})),Nu=Vi()(n=>({titleRowWrapper:{display:"flex",justifyContent:"space-between",width:"100%"},titleRow:{display:"inline-flex",alignItems:"center",gap:n.spacing(1.5),marginTop:n.spacing(1.5)},alertRow:{margin:n.spacing(1,0)},descriptionRow:{margin:n.spacing(1,.5)},name:{fontWeight:600,padding:n.spacing(.5)},icon:{textAlign:"right"}})),Ba=["default","applicationHostname","flexibleRollout","gradualRolloutRandom","gradualRolloutSessionId","gradualRolloutUserId","remoteAddress","userWithId"];function La(n){return n===void 0?!0:Object.values(n).every(e=>e&&typeof e=="object"?La(e):e===null)}const To=n=>{var e,t;return(t=(e=n.strategies)==null?void 0:e.data)==null?void 0:t.find(i=>!Ba.includes(i.name))},Fu=n=>{var e,t;return!((t=(e=n.strategies)==null?void 0:e.data)!=null&&t.find(i=>Ba.includes(i.name)))},Vu=({feature:n,input:e,onClose:t})=>{var f;const{classes:i}=Nu(),s=ke(),[r,o,l]=(()=>n.isEnabled?[`This feature toggle is True in ${e==null?void 0:e.environment} because `,"at least one strategy is True",s.palette.success.main]:n.isEnabledInCurrentEnvironment?Fu(n)?[`This feature toggle is Unknown in ${e==null?void 0:e.environment} because `,"no strategies could be fully evaluated",s.palette.warning.main]:To(n)?[`This feature toggle is Unknown in ${e==null?void 0:e.environment} because `,"not all strategies could be fully evaluated",s.palette.warning.main]:[`This feature toggle is False in ${e==null?void 0:e.environment} because `,"all strategies are either False or could not be fully evaluated",s.palette.error.main]:[`This feature toggle is False in ${e==null?void 0:e.environment} because `,"the environment is disabled",s.palette.error.main])(),a=La(e==null?void 0:e.context)?"You did not provide a value for your context field in step 2 of the configuration":void 0,h=To(n)?"This feature uses custom strategies. Custom strategies can't be evaluated, so they will be marked accordingly.":void 0,c=t&&(u=>{u.stopPropagation(),t()});return L($e,{children:[L("div",{className:i.titleRowWrapper,children:[L("div",{className:i.titleRow,children:[p(ie,{variant:"subtitle1",className:i.name,children:n.name}),p(z,{condition:((f=n==null?void 0:n.strategies)==null?void 0:f.result)!=="unknown",show:()=>p(vn,{enabled:n.isEnabled,label:n.isEnabled?"True":"False"}),elseShow:()=>p(vn,{enabled:"unknown",label:"Unknown",showIcon:!1})})]}),p(Oi,{onClick:c,className:i.icon,children:p(zf,{})})]}),L("div",{className:i.descriptionRow,children:[p(ie,{variant:"body1",component:"span",children:r}),p(ie,{variant:"subtitle1",color:l,component:"span",children:o}),p(ie,{variant:"body1",component:"span",children:"."})]}),p(z,{condition:Boolean(a),show:p("div",{className:i.alertRow,children:p(wn,{color:"info",children:a})})}),p(z,{condition:Boolean(h),show:p("div",{className:i.alertRow,children:p(wn,{severity:"warning",color:"info",children:h})})})]})},Ea=Vi()(n=>({valueContainer:{display:"flex",alignItems:"center",gap:"1ch"},valueSeparator:{color:n.palette.grey[700]},summary:{width:"auto",height:"auto",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`}})),Wu=re("div")(({theme:n})=>({display:"flex",alignItems:"center",marginTop:n.spacing(1),color:n.palette.error.main})),Hu=({constraint:n,input:e})=>L(Wu,{children:[p(Xn,{style:{marginRight:"0.25rem"}}),p(ie,{variant:"body2",children:(()=>{const i=e==null?void 0:e.context[n.contextName];return i?`Constraint not met \u2013 the value in the context: { ${i} } is not ${n.operator} ${n.contextName}`:`Constraint not met \u2013 no value was specified for ${n.contextName}`})()})]}),zu=re(xu)(({theme:n})=>({color:n.palette.success.main})),$u=re("div")(({theme:n})=>({display:"flex",alignItems:"center",marginTop:n.spacing(1),color:n.palette.success.main})),ju=()=>L($u,{children:[p(zu,{style:{marginRight:"0.25rem"}}),p(ie,{variant:"body2",children:"Constraint met by value in context"})]}),qu=re("div")(()=>({width:"100%",display:"flex",flexDirection:"column"})),Ia=({constraints:n,input:e})=>n?p(qu,{children:n==null?void 0:n.map((t,i)=>L(I.exports.Fragment,{children:[p(z,{condition:i>0,show:p(Wi,{text:"AND"})}),p($f,{constraint:t,compact:!0,renderAfter:p(z,{condition:t.result,show:p(ju,{}),elseShow:p(Hu,{input:e,constraint:t})})})]},Oa(t)))}):null,Uu=re("div")(({theme:n})=>({color:n.palette.error.main,display:"inline-flex",justifyContent:"center",marginLeft:"auto",gap:n.spacing(1)})),Gu=({segments:n,input:e})=>n?p($e,{children:n.map((t,i)=>L(I.exports.Fragment,{children:[p(jf,{segment:t,constraintList:p(Ia,{constraints:t.constraints,input:e}),headerContent:p(z,{condition:!Boolean(t.result),show:L(Uu,{children:[p(ie,{variant:"subtitle2",sx:{pt:.25},children:"segment is false"}),p("span",{children:p(Xn,{})})]})}),isExpanded:!0}),p(z,{condition:i>=0&&n.length>1&&i!==n.length-1,show:p(Wi,{text:"AND"})})]},t.id))}):null,Ku=Vi()(n=>({container:{width:"100%",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:n.spacing(2)},disabled:{backgroundColor:n.palette.neutral.light,opacity:"90%"},chip:{margin:"0.25rem"},column:{flexDirection:"column"},paragraph:{display:"inline",margin:"0.25rem 0",maxWidth:"95%",textAlign:"center",wordBreak:"break-word"}})),bs=({value:n,text:e,input:t,showReason:i=!1})=>{const{classes:s}=Ku(),r=ke(),o=t==="no value"?"error":"neutral",l=`value does not match any ${e}`;return L("div",{className:qf(s.container,i?s.disabled:""),children:[p(ie,{variant:"subtitle1",color:r.palette[o].main,children:`${t}`}),L("div",{className:s.column,children:[p(z,{condition:Boolean(i),show:p(ie,{variant:"subtitle1",color:r.palette.error.main,children:l})}),p(z,{condition:n.length===0,show:L("p",{children:["No ",e,"s added yet."]}),elseShow:L("div",{children:[L("p",{className:s.paragraph,children:[n.length," ",n.length>1?`${e}s`:e," will get access."]}),n.map(a=>p(Ur,{label:p(Qs,{maxWidth:"300",text:a.toString(),maxLength:50}),className:s.chip},a))]})})]}),p(z,{condition:Boolean(i),show:p(Xn,{color:"error"}),elseShow:p("div",{})})]})},at=n=>{switch(n.toUpperCase()){case"USERIDS":return"userId";case"IPS":return"remoteAddress";default:return n}},Qu=({parameters:n,constraints:e,input:t})=>{const{classes:i}=Ea();return p($e,{children:Object.keys(n).map(s=>{var r,o,l,a,h,c,f,u;switch(s){case"rollout":case"Rollout":const d=Js(n[s]);return L(j,{className:i.summary,sx:{display:"flex",alignItems:"center"},children:[p(j,{sx:{mr:"1rem"},children:p(Uf,{percentage:d,size:"2rem"})}),L("div",{children:[p(Ur,{color:"success",variant:"outlined",size:"small",label:`${d}%`})," ","of your base"," ",e.length>0?"who match constraints":""," ","is included."]})]},s);case"userIds":case"UserIds":const m=cn(n[s]);return p(bs,{value:m,text:"user",input:Boolean((r=t==null?void 0:t.context)==null?void 0:r[at(s)])?(o=t==null?void 0:t.context)==null?void 0:o[at(s)]:"no value",showReason:Boolean((l=t==null?void 0:t.context)==null?void 0:l[at(s)])?!m.includes((a=t==null?void 0:t.context)==null?void 0:a[at(s)]):void 0},s);case"hostNames":case"HostNames":const y=cn(n[s]);return p(bs,{value:y,text:"host",input:"no value",showReason:void 0},s);case"IPs":const x=cn(n[s]);return p(bs,{value:x,text:"IP",input:Boolean((h=t==null?void 0:t.context)==null?void 0:h[at(s)])?(c=t==null?void 0:t.context)==null?void 0:c[at(s)]:"no value",showReason:Boolean((f=t==null?void 0:t.context)==null?void 0:f[at(s)])?!x.includes((u=t==null?void 0:t.context)==null?void 0:u[at(s)]):void 0},s);case"stickiness":case"groupId":return null;default:return null}})})},Ju=re(j)(({theme:n})=>({width:"100%",padding:n.spacing(2,3),borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.dividerAlternative}`,display:"flex",flexDirection:"row",alignItems:"center",gap:2})),hi=({text:n,input:e=null,isRequired:t=!1})=>{const i=ke(),s=e===null?"error":"neutral",r=t&&e===null;return L(Ju,{children:[p(ie,{variant:"subtitle1",color:i.palette[s].main,sx:{minWidth:118},children:`${e===null?"no value":e}`}),p(j,{sx:{flexGrow:1,flexDirection:"column"},children:p(j,{sx:{flexGrow:1},children:p(z,{condition:Boolean(r),show:L($e,{children:[p(ie,{component:"span",color:i.palette.error.main,children:" required parameter "}),p(Qs,{maxWidth:"300",text:n,maxLength:50}),p(ie,{component:"span",color:i.palette.error.main,children:" is not set "})]}),elseShow:L($e,{children:[p(ie,{component:"span",color:"text.disabled",children:" set on parameter "}),p(Qs,{maxWidth:"300",text:n,maxLength:50})]})})})}),p(z,{condition:Boolean(r),show:p(Xn,{color:"error"}),elseShow:p("div",{})})]})},Yu=({strategyName:n,parameters:e})=>{const{strategies:t}=Gf(),i=t.find(r=>r.name===n);if(!(i!=null&&i.editable))return null;const s=i==null?void 0:i.parameters.map(r=>{const o=e[r.name],l=r.required;switch(r==null?void 0:r.type){case"list":const a=cn(o);return p(hi,{isRequired:l,text:r.name,input:(a==null?void 0:a.length)>0?a.join(", "):null});case"percentage":const h=Js(o),c=!(o===void 0||o===""||h<0||h>100);return p(hi,{text:r.name,isRequired:l,input:c?`${h}%`:void 0});case"boolean":const f=["true","false"].includes(o)?o:void 0;return p(hi,{isRequired:l,text:r.name,input:o!==void 0?f:void 0});case"string":const u=Kf(o);return p(hi,{text:r.name,isRequired:l,input:u!==void 0?u:void 0});case"number":const d=!(o===void 0||o===""),m=Js(o);return p(hi,{text:r.name,isRequired:l,input:d?`${m}`:void 0});case"default":return null}return null});return p($e,{children:s.map((r,o)=>L(I.exports.Fragment,{children:[p(z,{condition:o>0,show:p(Wi,{text:"AND"})}),r]},o))})},Xu=re("div")(({theme:n})=>({padding:n.spacing(0)})),Zu=({strategyResult:n,input:e})=>{const{name:t,constraints:i,segments:s,parameters:r}=n,{uiConfig:o}=Qf(),{classes:l}=Ea(),a=Boolean(o.flags.SE)&&Boolean(s&&s.length>0),h=Boolean(i&&(i==null?void 0:i.length)>0),c=t!=="default"&&Object.keys(Jf).includes(t),f=Object.keys(r).length>0&&n.result.evaluationStatus==="incomplete";if(!r)return null;const u=[a&&p(Gu,{segments:s,input:e}),h&&p(Ia,{constraints:i,input:e}),c&&p(Qu,{parameters:r,constraints:i,input:e}),f&&p(Yu,{strategyName:t,parameters:r}),t==="default"&&L(j,{sx:{width:"100%"},className:l.summary,children:["The standard strategy is"," ",p(Ur,{variant:"outlined",size:"small",color:"success",label:"ON"})," ","for all users."]})].filter(Boolean);return p(Xu,{children:u.map((d,m)=>L(I.exports.Fragment,{children:[p(z,{condition:m>0,show:p(Wi,{text:"AND"})}),d]},m))})},_u=Vi()(n=>({header:{display:"flex",padding:n.spacing(2,2),justifyContent:"space-between"},headerName:{padding:n.spacing(.5,2),display:"flex",gap:n.spacing(1),alignItems:"center",borderBottom:`1px solid ${n.palette.divider}`,fontWeight:n.typography.fontWeightMedium},icon:{fill:n.palette.inactiveIcon},resultChip:{marginLeft:"auto"},body:{padding:n.spacing(2),justifyItems:"center"},innerContainer:{[n.breakpoints.down(400)]:{padding:"0.5rem"},width:"100%",flexShrink:0,paddingBottom:"1rem",borderRadius:n.shape.borderRadiusMedium,background:n.palette.background.default},successBorder:{borderColor:n.palette.success.main}})),ed=({strategy:n,input:e,index:t})=>{const{result:i}=n,{classes:s}=_u(),r=ke(),o=i.evaluationStatus==="incomplete"?"Unevaluated":i.enabled?"True":"False";return p(Yf,{className:i.enabled&&i.evaluationStatus==="complete"?s.successBorder:void 0,strategy:{...n,id:`${Oa(n)}`},orderNumber:t+1,actions:p(vn,{showIcon:!1,enabled:i.enabled,label:o}),children:p(Zu,{strategyResult:n,input:e,percentageFill:r.palette.tertiary.light})})},td=re("div")(({theme:n})=>({display:"flex",padding:"0, 4px",flexDirection:"column",borderRadius:n.shape.borderRadiusMedium,border:`1px solid ${n.palette.warning.border}`})),id=re("div")(({theme:n})=>({padding:n.spacing(1,.5)})),nd=re(wn)(({theme:n})=>({border:"0!important",borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:`1px solid ${n.palette.warning.border}!important`})),Na=({strategies:n,input:e})=>p(z,{condition:n.length>0,show:L($e,{children:[p(ie,{variant:"subtitle1",sx:{mt:2,ml:1,mb:2,color:"text.secondary"},children:`Strategies (${n==null?void 0:n.length})`}),p(j,{sx:{width:"100%"},children:n==null?void 0:n.map((t,i)=>L(I.exports.Fragment,{children:[p(z,{condition:i>0,show:p(Wi,{text:"OR"})}),p(ed,{strategy:t,index:i,input:e},t.id)]},t.id))})]})}),sd=({strategies:n,input:e})=>L(td,{sx:{pb:1,mt:2},children:[L(nd,{severity:"info",color:"warning",children:["If environment was enabled, then this feature toggle would be"," ",n!=null&&n.result?"TRUE":"FALSE"," with strategies evaluated like so:"," "]}),p(id,{sx:{p:2.5},children:p(Na,{strategies:(n==null?void 0:n.data)||[],input:e})})]}),rd=({feature:n,input:e})=>{var t,i,s,r;return L($e,{children:[p(z,{condition:((i=(t=n==null?void 0:n.strategies)==null?void 0:t.data)==null?void 0:i.length)===0,show:p(wn,{severity:"warning",sx:{mt:2},children:"There are no strategies added to this feature toggle in selected environment."})}),p(z,{condition:!n.isEnabledInCurrentEnvironment&&Boolean((s=n==null?void 0:n.strategies)==null?void 0:s.data),show:p(sd,{strategies:n==null?void 0:n.strategies,input:e}),elseShow:p(Na,{strategies:((r=n==null?void 0:n.strategies)==null?void 0:r.data)||[],input:e})})]})},od=re("div")(({theme:n})=>({alignItems:"flex-end",color:n.palette.tertiary.main})),ld=({feature:n,input:e})=>{const[t,i]=I.exports.useState(!1),{classes:s}=Iu(),r=I.exports.useRef(null),o=()=>{i(!t)};return n?L(od,{children:[p(Oi,{onClick:o,children:p(Aa,{ref:r})}),L(Ma,{open:t,onClose:()=>i(!1),anchorEl:r.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},classes:{paper:s.popoverPaper},children:[p(Vu,{feature:n,input:e,onClose:()=>i(!1)}),p(rd,{feature:n,input:e})]})]}):null},ad={id:"name"},{value:Po,setValue:hd}=Xf("PlaygroundResultsTable:v1",ad),cd=({features:n,input:e,loading:t})=>{const[i,s]=Da(),r=Zf(t),[o,l]=I.exports.useState(i.get("search")||""),a=ke(),h=Ys(a.breakpoints.down("sm")),c=Ys(a.breakpoints.down("md")),f=I.exports.useMemo(()=>[{Header:"Name",accessor:"name",searchable:!0,minWidth:160,Cell:({value:k,row:{original:O}})=>p(Mo,{title:k,to:`/projects/${O==null?void 0:O.projectId}/features/${k}`})},{Header:"Project ID",accessor:"projectId",sortType:"alphanumeric",filterName:"projectId",searchable:!0,maxWidth:170,Cell:({value:k})=>p(Mo,{title:k,to:`/projects/${k}`})},{Header:"Variant",id:"variant",accessor:"variant.name",sortType:"alphanumeric",filterName:"variant",searchable:!0,maxWidth:200,Cell:({value:k,row:{original:{variant:O,feature:F,variants:T,isEnabled:E}}})=>p(Eu,{variant:O!=null&&O.enabled?k:"",variants:T,feature:F,isEnabled:E})},{id:"isEnabled",Header:"isEnabled",filterName:"isEnabled",accessor:k=>{var O;return k!=null&&k.isEnabled?"true":((O=k==null?void 0:k.strategies)==null?void 0:O.result)==="unknown"?"unknown":"false"},Cell:({row:k})=>p(Du,{feature:k.original}),sortType:"playgroundResultState",maxWidth:120,sortInverted:!0},{Header:"",maxWidth:70,id:"info",Cell:({row:k})=>p(ld,{feature:k.original,input:e})}],[e]),{data:u,getSearchText:d,getSearchContext:m}=_f(f,o,n||[]),y=I.exports.useMemo(()=>t?Array(5).fill({name:"Feature name",projectId:"FeatureProject",variant:{name:"FeatureVariant",variants:[]},enabled:!0}):u,[u,t]),[x]=I.exports.useState(()=>({sortBy:[{id:i.get("sort")||Po.id,desc:i.has("order")?i.get("order")==="desc":Po.desc}]})),{headerGroups:b,rows:v,state:{sortBy:M},prepareRow:S,setHiddenColumns:C}=Rt.exports.useTable({initialState:x,columns:f,data:y,sortTypes:Ca,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:eu}},Rt.exports.useGlobalFilter,Rt.exports.useFlexLayout,Rt.exports.useSortBy);return I.exports.useEffect(()=>{const k=[];c&&k.push("projectId"),h&&k.push("variant"),C(k)},[C,h,c]),I.exports.useEffect(()=>{if(t)return;const k=Object.fromEntries(i);k.sort=M[0].id,M[0].desc?k.order="desc":k.order&&delete k.order,o?k.search=o:delete k.search,s(k,{replace:!0}),hd({id:M[0].id,desc:M[0].desc||!1})},[t,M,o]),L($e,{children:[L(j,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[p(ie,{variant:"subtitle1",sx:{ml:1},children:n!==void 0&&!t?`Results (${v.length<y.length?`${v.length} of ${y.length}`:y.length})`:"Results"}),p(tu,{initialValue:o,onChange:l,hasFilters:!0,getSearchContext:m,disabled:t,containerStyles:{marginLeft:"1rem",maxWidth:"400px"}})]}),p(z,{condition:!t&&!y,show:()=>p(gs,{children:y===void 0?"None of the feature toggles were evaluated yet.":"No results found."}),elseShow:()=>L(j,{ref:r,children:[p(iu,{value:d(o),children:p(nu,{rows:v,headerGroups:b,prepareRow:S})}),p(z,{condition:y.length===0&&(o==null?void 0:o.length)>0,show:L(gs,{children:["No feature toggles found matching \u201C",o,"\u201D"]})}),p(z,{condition:y&&y.length===0&&!o,show:p(gs,{children:"No features toggles to display"})})]})})]})},fd=()=>{const{makeRequest:n,createRequest:e,errors:t,loading:i}=su({propagateErrors:!0}),s="api/admin/playground";return{evaluatePlayground:async o=>{const a=e(s,{method:"POST",body:JSON.stringify(o)});try{return(await n(a.caller,a.id)).json()}catch(h){throw h}},errors:t,loading:i}},ud=re("div")(({style:n,theme:e})=>({width:"25px",height:"25px",borderRadius:"50%",color:e.palette.text.tertiaryContrast,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",...n})),Zn=({style:n,children:e,type:t})=>{const i=ke(),s={backgroundColor:i.palette.primary.main};return t==="secondary"&&(s.backgroundColor=i.palette.tertiary.dark),p(ud,{style:{...s,...n},children:e})},dd=n=>!n||n.length===0||n.length===1&&n[0]==="*"?"*":n,pd=n=>{const e=Fa(n);return e.length>0?e[0]:""},Fa=n=>n.filter(({enabled:e})=>Boolean(e)).sort((e,t)=>e.sortOrder-t.sortOrder).map(({name:e})=>e),md=(n,e)=>n?"100%":e&&!n?"65%":"50%";function _s(n,e,t){var i,s,r,o,l;e==null&&(e=100);function a(){var c=Date.now()-o;c<e&&c>=0?i=setTimeout(a,e-c):(i=null,t||(l=n.apply(r,s),r=s=null))}var h=function(){r=this,s=arguments,o=Date.now();var c=t&&!i;return i||(i=setTimeout(a,e)),c&&(l=n.apply(r,s),r=s=null),l};return h.clear=function(){i&&(clearTimeout(i),i=null)},h.flush=function(){i&&(l=n.apply(r,s),r=s=null,clearTimeout(i),i=null)},h}_s.debounce=_s;var gd=_s;function er(){return er=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},er.apply(this,arguments)}function yd(n,e){if(n==null)return{};var t={},i=Object.keys(n),s,r;for(r=0;r<i.length;r++)s=i[r],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}class U{constructor(){}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,i){let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Je.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),Je.from(i,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),i=this.length-this.scanIdentical(e,-1),s=new ki(this),r=new ki(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new ki(this,e)}iterRange(e,t=this.length){return new Va(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Wa(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?U.empty:e.length<=32?new ne(e):Je.from(ne.split(e,[]))}}class ne extends U{constructor(e,t=bd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new xd(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new ne(Ro(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=fn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new ne(l,o.length+r.length));else{let a=l.length>>1;i.push(new ne(l.slice(0,a)),new ne(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof ne))return super.replace(e,t,i);let s=fn(this.text,fn(i.text,Ro(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new ne(s,r):Je.from(ne.split(s,[]),r)}sliceString(e,t=this.length,i=`
|
|
2
2
|
`){let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=i),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new ne(i,s)),i=[],s=-1);return s>-1&&t.push(new ne(i,s)),t}}class Je extends U{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if(i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>5-1&&a.lines>h>>5+1){let c=this.children.slice();return c[s]=a,new Je(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=i),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Je))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let m of e)m.flatten(d);return new ne(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let m;if(d.lines>r&&d instanceof Je)for(let y of d.children)f(y);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof ne&&a&&(m=c[c.length-1])instanceof ne&&d.lines+m.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new ne(m.text.concat(d.text),m.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Je.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Je(l,t)}}U.empty=new ne([""],0);function bd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function fn(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r<n.length&&s<=i;r++){let l=n[r],a=s+l.length;a>=t&&(a>i&&(l=l.slice(0,i-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function Ro(n,e,t){return fn(n,[""],e,t)}class ki{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 ne?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof ne?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(s instanceof ne){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ne?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Va{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ki(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}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 i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Wa{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(U.prototype[Symbol.iterator]=function(){return this.iter()},ki.prototype[Symbol.iterator]=Va.prototype[Symbol.iterator]=Wa.prototype[Symbol.iterator]=function(){return this});class xd{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}let Kt="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(n=>n?parseInt(n,36):1);for(let n=1;n<Kt.length;n++)Kt[n]+=Kt[n-1];function wd(n){for(let e=1;e<Kt.length;e+=2)if(Kt[e]>n)return Kt[e-1]<=n;return!1}function Bo(n){return n>=127462&&n<=127487}const Lo=8205;function Le(n,e,t=!0,i=!0){return(t?Ha:kd)(n,e,i)}function Ha(n,e,t){if(e==n.length)return e;e&&za(n.charCodeAt(e))&&$a(n.charCodeAt(e-1))&&e--;let i=ue(n,e);for(e+=Re(i);e<n.length;){let s=ue(n,e);if(i==Lo||s==Lo||t&&wd(s))e+=Re(s),i=s;else if(Bo(s)){let r=0,o=e-2;for(;o>=0&&Bo(ue(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function kd(n,e,t){for(;e>0;){let i=Ha(n,e-2,t);if(i<e)return i;e--}return 0}function za(n){return n>=56320&&n<57344}function $a(n){return n>=55296&&n<56320}function ue(n,e){let t=n.charCodeAt(e);if(!$a(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return za(i)?(t-55296<<10)+(i-56320)+65536:t}function Gr(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Re(n){return n<65536?1:2}const tr=/\r\n?|\n/;var Se=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Se||(Se={}));class Ze{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 i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){ir(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new Ze(e)}composeDesc(e){return this.empty?e:e.empty?this:ja(this,e)}mapDesc(e,t=!1){return e.empty?this:nr(this,e,t)}mapPos(e,t=-1,i=Se.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=Se.Simple&&h>=e&&(i==Se.TrackDel&&s<e&&h>e||i==Se.TrackBefore&&s<e||i==Se.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ze(e)}static create(e){return new Ze(e)}}class ae extends Ze{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 ir(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return nr(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(U.empty);i.push(o?e.slice(r,r+o):U.empty)}r+=o}return new ae(t,i)}compose(e){return this.empty?e:e.empty?this:ja(this,e,!0)}map(e,t=!1){return e.empty?this:nr(this,e,t,!0)}iterChanges(e,t=!1){ir(this,e,t)}get desc(){return Ze.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new Di(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);xe(s,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;xe(t,c,f),f>0&&dt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);xe(t,c,-1),xe(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new ae(t,i),filtered:Ze.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&xe(s,t-o,-1);let f=new ae(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ae){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let m=d?typeof d=="string"?U.of(d.split(i||tr)):d:U.empty,y=m.length;if(f==u&&y==0)return;f<o&&a(),f>o&&xe(s,f-o,-1),xe(s,u-f,y),dt(r,s,m),o=u}}return h(e),a(!l),l}static empty(e){return new ae(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(U.empty);i[s]=U.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new ae(t,i)}static createSet(e,t){return new ae(e,t)}}function xe(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function dt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(U.empty);n.push(t)}}function ir(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,c=r,f=U.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function nr(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Di(n),l=new Di(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);xe(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(xe(s,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(xe(s,0,o.ins),r&&dt(r,s,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;xe(s,h,a<o.i?o.ins:0),r&&a<o.i&&dt(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?ae.createSet(s,r):Ze.create(s);throw new Error("Mismatched change set lengths")}}function ja(n,e,t=!1){let i=[],s=t?[]:null,r=new Di(n),o=new Di(e);for(let l=!1;;){if(r.done&&o.done)return s?ae.createSet(i,s):Ze.create(i);if(r.ins==0)xe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)xe(i,0,o.ins,l),s&&dt(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;xe(i,a,c,l),s&&c&&dt(s,i,o.text)}else o.ins==-1?(xe(i,r.off?0:r.len,a,l),s&&dt(s,i,r.textBit(a))):(xe(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&dt(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Di{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?U.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?U.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Bt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Bt(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return w.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return w.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return w.range(e.anchor,e.head)}static create(e,t,i){return new Bt(e,t,i)}}class w{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:w.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new w([this.main],0)}addRange(e,t=!0){return w.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,w.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new w(e.ranges.map(t=>Bt.fromJSON(t)),e.main)}static single(e,t=e){return new w([w.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return w.normalized(e.slice(),t);i=r.to}return new w(e,t)}static cursor(e,t=0,i,s){return Bt.create(e,e,(t==0?0:t<0?4:8)|(i==null?3:Math.min(2,i))|(s!=null?s:33554431)<<5)}static range(e,t,i){let s=(i!=null?i:33554431)<<5;return t<e?Bt.create(t,e,16|s|8):Bt.create(e,t,s|(t>e?4:0))}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?w.range(a,l):w.range(l,a))}}return new w(e,t)}}function qa(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Kr=0;class R{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Kr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}static define(e={}){return new R(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Qr),!!e.static,e.enables)}of(e){return new un([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Qr(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class un{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Kr++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||sr(f,c)){let d=i(f);if(l?!Eo(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,m=u.config.address[r];if(m!=null){let y=Cn(u,m);if(this.dependencies.every(x=>x instanceof R?u.facet(x)===f.facet(x):x instanceof ge?u.field(x,!1)==f.field(x,!1):!0)||(l?Eo(d=i(f),y,s):s(d=i(f),y)))return f.values[o]=y,0}else d=i(f);return f.values[o]=d,1}}}}function Eo(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function sr(n,e){let t=!1;for(let i of e)vi(n,i)&1&&(t=!0);return t}function vd(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Cn(a,i[c]);if(s[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)vi(a,h);return a.values[o]=l(a),1},update(a,h){if(!sr(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=sr(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Qr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Io=R.define({static:!0});class ge{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new ge(Kr++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Io).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,Io.of({field:this,create:e})]}get extension(){return this}}const Tt={lowest:4,low:3,default:2,high:1,highest:0};function ci(n){return e=>new Ua(e,n)}const oi={highest:ci(Tt.highest),high:ci(Tt.high),default:ci(Tt.default),low:ci(Tt.low),lowest:ci(Tt.lowest)};class Ua{constructor(e,t){this.inner=e,this.prec=t}}class _n{of(e){return new rr(this,e)}reconfigure(e){return _n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class rr{constructor(e,t){this.compartment=e,this.inner=t}}class Sn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Sd(e,t,o))u instanceof ge?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],m=d[0].facet,y=c&&c[u]||[];if(d.every(x=>x.type==0))if(l[m.id]=a.length<<1|1,Qr(y,d))a.push(i.facet(m));else{let x=m.combine(d.map(b=>b.value));a.push(i&&m.compare(x,i.facet(m))?i.facet(m):x)}else{for(let x of d)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=h.length<<1,h.push(b=>x.dynamicSlot(b)));l[m.id]=h.length<<1,h.push(x=>vd(x,m,d))}}let f=h.map(u=>u(l));return new Sn(e,o,f,l,a,r)}}function Sd(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof rr&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof rr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Ua)r(o.inner,o.prec);else if(o instanceof ge)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof un)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Tt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,Tt.default),i.reduce((o,l)=>o.concat(l))}function vi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Cn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const Ga=R.define(),Ka=R.define({combine:n=>n.some(e=>e),static:!0}),Qa=R.define({combine:n=>n.length?n[0]:void 0,static:!0}),Ja=R.define(),Ya=R.define(),Xa=R.define(),Za=R.define({combine:n=>n.length?n[0]:!1});class Wt{constructor(e,t){this.type=e,this.value=t}static define(){return new Cd}}class Cd{of(e){return new Wt(this,e)}}class Ad{constructor(e){this.map=e}of(e){return new N(this,e)}}class N{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new N(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ad(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}N.reconfigure=N.define();N.appendConfig=N.define();class he{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&qa(i,t.newLength),r.some(l=>l.type==he.time)||(this.annotations=r.concat(he.time.of(Date.now())))}static create(e,t,i,s,r,o){return new he(e,t,i,s,r,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(he.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}he.time=Wt.define();he.userEvent=Wt.define();he.addToHistory=Wt.define();he.remote=Wt.define();function Md(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function _a(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=ae.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:N.mapEffects(n.effects,s).concat(N.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function or(n,e,t){let i=e.selection,s=Qt(e.annotations);return e.userEvent&&(s=s.concat(he.userEvent.of(e.userEvent))),{changes:e.changes instanceof ae?e.changes:ae.of(e.changes||[],t,n.facet(Qa)),selection:i&&(i instanceof w?i:w.single(i.anchor,i.head)),effects:Qt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function eh(n,e,t){let i=or(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=_a(i,or(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=he.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Dd(t?Od(s):s)}function Od(n){let e=n.startState,t=!0;for(let s of e.facet(Ja)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Md(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=ae.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=he.create(e,s,n.selection&&n.selection.map(r),N.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(Ya);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof he?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof he?n=r[0]:n=eh(e,Qt(r),!1)}return n}function Dd(n){let e=n.startState,t=e.facet(Xa),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=_a(i,or(e,r,n.changes.newLength),!0))}return i==n?n:he.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Td=[];function Qt(n){return n==null?Td:Array.isArray(n)?n:[n]}var Ce=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Ce||(Ce={}));const Pd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let lr;try{lr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Rd(n){if(lr)return lr.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||Pd.test(t)))return!0}return!1}function Bd(n){return e=>{if(!/\S/.test(e))return Ce.Space;if(Rd(e))return Ce.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return Ce.Word;return Ce.Other}}class H{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)vi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return vi(this,i),Cn(this,i)}update(...e){return eh(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let o of e.effects)o.is(_n.reconfigure)?(t&&(s=new Map,t.compartments.forEach((l,a)=>s.set(a,l)),t=null),s.set(o.value.compartment,o.value.extension)):o.is(N.reconfigure)?(t=null,i=o.value):o.is(N.appendConfig)&&(t=null,i=Qt(i).concat(o.value));let r;t?r=e.startState.values.slice():(t=Sn.resolve(i,s,this),r=new H(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new H(t,e.newDoc,e.newSelection,r,(o,l)=>l.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:w.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=Qt(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=s.mapDesc(h,!0);r.push(a.range.map(f)),s=s.compose(c),o=N.mapEffects(o,c).concat(N.mapEffects(Qt(a.effects),f))}return{changes:s,selection:w.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ae?e:ae.of(e,this.doc.length,this.facet(H.lineSeparator))}toText(e){return U.of(e.split(this.facet(H.lineSeparator)||tr))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(vi(this,t),Cn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof ge&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return H.create({doc:e.doc,selection:w.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Sn.resolve(e.extensions||[],new Map),i=e.doc instanceof U?e.doc:U.of((e.doc||"").split(t.staticFacet(H.lineSeparator)||tr)),s=e.selection?e.selection instanceof w?e.selection:w.single(e.selection.anchor,e.selection.head):w.single(0);return qa(s,i.length),t.staticFacet(Ka)||(s=s.asSingle()),new H(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(H.tabSize)}get lineBreak(){return this.facet(H.lineSeparator)||`
|
|
@@ -7,4 +7,4 @@ import{c as ri,j as p,r as I,u as ke,C as z,B as ms,s as re,a as j,T as ie,b as
|
|
|
7
7
|
`;this.styleTag.textContent=r}}}var vt={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:"'",229:"q"},Xt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},zo=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Id=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),Nd=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),$o=typeof navigator<"u"&&/Mac/.test(navigator.platform),Fd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Vd=zo&&($o||+zo[1]<57)||Nd&&$o;for(var de=0;de<10;de++)vt[48+de]=vt[96+de]=String(de);for(var de=1;de<=24;de++)vt[de+111]="F"+de;for(var de=65;de<=90;de++)vt[de]=String.fromCharCode(de+32),Xt[de]=String.fromCharCode(de);for(var ws in vt)Xt.hasOwnProperty(ws)||(Xt[ws]=vt[ws]);function Wd(n){var e=Vd&&(n.ctrlKey||n.altKey||n.metaKey)||(Id||Fd)&&n.shiftKey&&n.key&&n.key.length==1,t=!e&&n.key||(n.shiftKey?Xt:vt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function An(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Zt(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Hd(){let n=document.activeElement;for(;n&&n.shadowRoot;)n=n.shadowRoot.activeElement;return n}function dr(n,e){if(!e.anchorNode)return!1;try{return Zt(n,e.anchorNode)}catch{return!1}}function Ri(n){return n.nodeType==3?_t(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Mn(n,e,t,i){return t?jo(n,e,t,i,-1)||jo(n,e,t,i,1):!1}function pr(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function jo(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:On(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=pr(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?On(n):0}else return!1}}function On(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}const ih={left:0,right:0,top:0,bottom:0};function es(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function zd(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function $d(n,e,t,i,s,r,o,l){let a=n.ownerDocument,h=a.defaultView;for(let c=n;c;)if(c.nodeType==1){let f,u=c==a.body;if(u)f=zd(h);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.parentNode;continue}let y=c.getBoundingClientRect();f={left:y.left,right:y.left+c.clientWidth,top:y.top,bottom:y.top+c.clientHeight}}let d=0,m=0;if(s=="nearest")e.top<f.top?(m=-(f.top-e.top+o),t>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+m+o)):e.bottom>f.bottom&&(m=e.bottom-f.bottom+o,t<0&&e.top-m<f.top&&(m=-(f.top+m-e.top+o)));else{let y=e.bottom-e.top,x=f.bottom-f.top;m=(s=="center"&&y<=x?e.top+y/2-x/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-x+o)-f.top}if(i=="nearest"?e.left<f.left?(d=-(f.left-e.left+r),t>0&&e.right>f.right+d&&(d=e.right-f.right+d+r)):e.right>f.right&&(d=e.right-f.right+r,t<0&&e.left<f.left+d&&(d=-(f.left+d-e.left+r))):d=(i=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:i=="start"==l?e.left-r:e.right-(f.right-f.left)+r)-f.left,d||m)if(u)h.scrollBy(d,m);else{if(m){let y=c.scrollTop;c.scrollTop+=m,m=c.scrollTop-y}if(d){let y=c.scrollLeft;c.scrollLeft+=d,d=c.scrollLeft-y}e={left:e.left-d,top:e.top-m,right:e.right-d,bottom:e.bottom-m}}if(u)break;c=c.assignedSlot||c.parentNode,i=s="nearest"}else if(c.nodeType==11)c=c.host;else break}class jd{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){this.set(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}let $t=null;function nh(n){if(n.setActive)return n.setActive();if($t)return n.focus($t);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus($t==null?{get preventScroll(){return $t={preventScroll:!0},!0}}:void 0),!$t){$t=!1;for(let t=0;t<e.length;){let i=e[t++],s=e[t++],r=e[t++];i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=r&&(i.scrollLeft=r)}}}let qo;function _t(n,e,t=e){let i=qo||(qo=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Si(n,e,t){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0},s=new KeyboardEvent("keydown",i);s.synthetic=!0,n.dispatchEvent(s);let r=new KeyboardEvent("keyup",i);return r.synthetic=!0,n.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function qd(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function sh(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}class me{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new me(e.parentNode,pr(e),t)}static after(e,t){return new me(e.parentNode,pr(e)+1,t)}}const Yr=[];class X{constructor(){this.parent=null,this.dom=null,this.dirty=2}get editorView(){if(!this.parent)throw new Error("Accessing view in orphan content view");return this.parent.editorView}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}coordsAt(e,t){return null}sync(e){if(this.dirty&2){let t=this.dom,i=null,s;for(let r of this.children){if(r.dirty){if(!r.dom&&(s=i?i.nextSibling:t.firstChild)){let o=X.get(s);(!o||!o.parent&&o.constructor==r.constructor)&&r.reuseDOM(s)}r.sync(e),r.dirty=0}if(s=i?i.nextSibling:t.firstChild,e&&!e.written&&e.node==t&&s!=r.dom&&(e.written=!0),r.dom.parentNode==t)for(;s&&s!=r.dom;)s=Uo(s);else t.insertBefore(r.dom,s);i=r.dom}for(s=i?i.nextSibling:t.firstChild,s&&e&&e.node==t&&(e.written=!0);s;)s=Uo(s)}else if(this.dirty&1)for(let t of this.children)t.dirty&&(t.sync(e),t.dirty=0)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let s=On(e)==0?0:t==0?-1:1;for(;;){let r=e.parentNode;if(r==this.dom)break;s==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?s=-1:s=1),e=r}s<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!X.get(i);)i=i.nextSibling;if(!i)return this.length;for(let s=0,r=0;;s++){let o=this.children[s];if(o.dom==i)return r;r+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let s=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<this.children.length;a++){let f=this.children[a],u=h+f.length;if(h<e&&u>t)return f.domBoundsAround(e,t,h);if(u>=e&&s==-1&&(s=a,r=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:r,to:l<0?i+this.length:l,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.dirty|=2),t.dirty&1)return;t.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Yr){this.markDirty();for(let s=e;s<t;s++){let r=this.children[s];r.parent==this&&r.destroy()}this.children.splice(e,t-e,...i);for(let s=0;s<i.length;s++)i[s].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new rh(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}merge(e,t,i,s,r,o){return!1}become(e){return!1}getSide(){return 0}destroy(){this.parent=null}}X.prototype.breakAfter=0;function Uo(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class rh{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function oh(n,e,t,i,s,r,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=r.length?r[r.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&r.length<2&&c.merge(t,s,r.length?f:null,t==0,l,a))){if(i<h.length){let d=h[i];d&&s<d.length?(e==i&&(d=d.split(s),s=0),!u&&f&&d.merge(0,s,f,!0,0,a)?r[r.length-1]=d:(s&&d.merge(0,s,null,!1,0,a),r.push(d))):d!=null&&d.breakAfter&&(f?f.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,t>0&&(!o&&r.length&&c.merge(t,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<i&&r.length;)if(h[i-1].become(r[r.length-1]))i--,r.pop(),a=r.length?0:l;else if(h[e].become(r[0]))e++,r.shift(),l=r.length?0:a;else break;!r.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||r.length)&&n.replaceChildren(e,i,r)}}function lh(n,e,t,i,s,r){let o=n.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:h,off:c}=o.findPos(e,-1),f=e-t;for(let u of i)f+=u.length;n.length+=f,oh(n,h,c,l,a,i,0,s,r)}let Be=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},mr=typeof document<"u"?document:{documentElement:{style:{}}};const gr=/Edge\/(\d+)/.exec(Be.userAgent),ah=/MSIE \d/.test(Be.userAgent),yr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Be.userAgent),ts=!!(ah||yr||gr),Go=!ts&&/gecko\/(\d+)/i.test(Be.userAgent),ks=!ts&&/Chrome\/(\d+)/.exec(Be.userAgent),Ko="webkitFontSmoothing"in mr.documentElement.style,hh=!ts&&/Apple Computer/.test(Be.vendor),Qo=hh&&(/Mobile\/\w+/.test(Be.userAgent)||Be.maxTouchPoints>2);var P={mac:Qo||/Mac/.test(Be.platform),windows:/Win/.test(Be.platform),linux:/Linux|X11/.test(Be.platform),ie:ts,ie_version:ah?mr.documentMode||6:yr?+yr[1]:gr?+gr[1]:0,gecko:Go,gecko_version:Go?+(/Firefox\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,chrome:!!ks,chrome_version:ks?+ks[1]:0,ios:Qo,android:/Android\b/.test(Be.userAgent),webkit:Ko,safari:hh,webkit_version:Ko?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:mr.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Ud=256;class St extends X{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return i&&(!(i instanceof St)||this.length-(t-e)+i.length>Ud)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new St(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new me(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return br(this.dom,e,t)}}class _e extends X{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let s of t)s.setParent(this)}setAttrs(e){if(sh(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e){this.dom?this.dirty&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e)}merge(e,t,i,s,r,o){return i&&(!(i instanceof _e&&i.mark.eq(this.mark))||e&&r<=0||t<this.length&&o<=0)?!1:(lh(this,e,t,i?i.children:[],r-1,o-1),this.markDirty(),!0)}split(e){let t=[],i=0,s=-1,r=0;for(let l of this.children){let a=i+l.length;a>e&&t.push(i<e?l.split(e-i):l),s<0&&i>=e&&(s=r),i=a,r++}let o=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new _e(this.mark,t,o)}domAtPos(e){return uh(this.dom,this.children,e)}coordsAt(e,t){return ph(this,e,t)}}function br(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let s=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?P.chrome||P.gecko||(e?(s--,o=1):r<i&&(r++,o=-1)):t<0?s--:r<i&&r++;let l=_t(n,s,r).getClientRects();if(!l.length)return ih;let a=l[(o?o<0:t>=0)?0:l.length-1];return P.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?es(a,o<0):a||null}class pt extends X{constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}static create(e,t,i){return new(e.customView||pt)(e,t,i)}split(e){let t=pt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(){(!this.dom||!this.widget.updateDOM(this.dom))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,s,r,o){return i&&(!(i instanceof pt)||!this.widget.compare(i.widget)||e>0&&r<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e.length==this.length&&e instanceof pt&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.eq(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return U.empty;let e=this;for(;e.parent;)e=e.parent;let t=e.editorView,i=t&&t.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):U.empty}domAtPos(e){return e==0?me.before(this.dom):me.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.dom.getClientRects(),s=null;if(!i.length)return ih;for(let r=e>0?i.length-1:0;s=i[r],!(e>0?r==0:r==i.length-1||s.top<s.bottom);r+=e>0?-1:1);return e==0&&t>0||e==this.length&&t<=0?s:es(s,e==0)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ch extends pt{domAtPos(e){let{topView:t,text:i}=this.widget;return t?xr(e,0,t,i,(s,r)=>s.domAtPos(r),s=>new me(i,Math.min(s,i.nodeValue.length))):new me(i,Math.min(e,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,t){let{topView:i,text:s}=this.widget;return i?fh(e,t,i,s):Math.min(t,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,t){let{topView:i,text:s}=this.widget;return i?xr(e,t,i,s,(r,o,l)=>r.coordsAt(o,l),(r,o)=>br(s,r,o)):br(s,e,t)}destroy(){var e;super.destroy(),(e=this.widget.topView)===null||e===void 0||e.destroy()}get isEditable(){return!0}}function xr(n,e,t,i,s,r){if(t instanceof _e){for(let o of t.children){let l=Zt(o.dom,i),a=l?i.nodeValue.length:o.length;if(n<a||n==a&&o.getSide()<=0)return l?xr(n,e,o,i,s,r):s(o,n,e);n-=a}return s(t,t.length,-1)}else return t.dom==i?r(n,e):s(t,n,e)}function fh(n,e,t,i){if(t instanceof _e)for(let s of t.children){let r=0,o=Zt(s.dom,i);if(Zt(s.dom,n))return r+(o?fh(n,e,s,i):s.localPosFromDOM(n,e));r+=o?i.nodeValue.length:s.length}else if(t.dom==i)return Math.min(e,i.nodeValue.length);return t.localPosFromDOM(n,e)}class ei extends X{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof ei&&e.side==this.side}split(){return new ei(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return me.before(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){let t=this.dom.getBoundingClientRect(),i=Gd(this,this.side>0?-1:1);return i&&i.top<t.bottom&&i.bottom>t.top?{left:t.left,right:t.right,top:i.top,bottom:i.bottom}:t}get overrideDOMText(){return U.empty}}St.prototype.children=pt.prototype.children=ei.prototype.children=Yr;function Gd(n,e){let t=n.parent,i=t?t.children.indexOf(n):-1;for(;t&&i>=0;)if(e<0?i>0:i<t.children.length){let s=t.children[i+e];if(s instanceof St){let r=s.coordsAt(e<0?s.length:0,e);if(r)return r}i+=e}else if(t instanceof _e&&t.parent)i=t.parent.children.indexOf(t)+(e<0?0:1),t=t.parent;else{let s=t.dom.lastChild;if(s&&s.nodeName=="BR")return s.getClientRects()[0];break}}function uh(n,e,t){let i=0;for(let s=0;i<e.length;i++){let r=e[i],o=s+r.length;if(!(o==s&&r.getSide()<=0)){if(t>s&&t<o&&r.dom.parentNode==n)return r.domAtPos(t-s);if(t<=s)break;s=o}}for(;i>0;i--){let s=e[i-1].dom;if(s.parentNode==n)return me.after(s)}return new me(n,0)}function dh(n,e,t){let i,{children:s}=n;t>0&&e instanceof _e&&s.length&&(i=s[s.length-1])instanceof _e&&i.mark.eq(e.mark)?dh(i,e.children[0],t-1):(s.push(e),e.setParent(n)),n.length+=e.length}function ph(n,e,t){for(let r=0,o=0;o<n.children.length;o++){let l=n.children[o],a=r+l.length,h;if((t<=0||a==n.length||l.getSide()>0?a>=e:a>e)&&(e<a||o+1==n.children.length||(h=n.children[o+1]).length||h.getSide()>0)){let c=0;if(a==r){if(l.getSide()<=0)continue;c=t=-l.getSide()}let f=l.coordsAt(Math.max(0,e-r),t);return c&&f?es(f,t<0):f}r=a}let i=n.dom.lastChild;if(!i)return n.dom.getBoundingClientRect();let s=Ri(i);return s[s.length-1]||null}function wr(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}function Xr(n,e){if(n==e)return!0;if(!n||!e)return!1;let t=Object.keys(n),i=Object.keys(e);if(t.length!=i.length)return!1;for(let s of t)if(i.indexOf(s)==-1||n[s]!==e[s])return!1;return!0}function kr(n,e,t){let i=null;if(e)for(let s in e)t&&s in t||n.removeAttribute(i=s);if(t)for(let s in t)e&&e[s]==t[s]||n.setAttribute(i=s,t[s]);return!!i}class lt{eq(e){return!1}updateDOM(e){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}ignoreEvent(e){return!0}get customView(){return null}destroy(e){}}var K=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(K||(K={}));class B extends Nt{constructor(e,t,i,s){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(e){return new is(e)}static widget(e){let t=e.side||0,i=!!e.block;return t+=i?t>0?3e8:-4e8:t>0?1e8:-1e8,new Ft(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=mh(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ft(e,i,s,t,e.widget||null,!0)}static line(e){return new zi(e)}static set(e,t=!1){return G.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}B.none=G.empty;class is extends B{constructor(e){let{start:t,end:i}=mh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof is&&this.tagName==e.tagName&&this.class==e.class&&Xr(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)}}is.prototype.point=!1;class zi extends B{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof zi&&Xr(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)}}zi.prototype.mapMode=Se.TrackBefore;zi.prototype.point=!0;class Ft extends B{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?Se.TrackBefore:Se.TrackAfter:Se.TrackDel}get type(){return this.startSide<this.endSide?K.WidgetRange:this.startSide<=0?K.WidgetBefore:K.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(e){return e instanceof Ft&&Kd(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ft.prototype.point=!0;function mh(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function Kd(n,e){return n==e||!!(n&&e&&n.compare(e))}function vr(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class Ae extends X{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,s,r,o){if(i){if(!(i instanceof Ae))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),lh(this,e,t,i?i.children:[],r,o),!0}split(e){let t=new Ae;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:s}=this.childPos(e);s&&(t.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let r=i;r<this.children.length;r++)t.append(this.children[r],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){!this.dom||(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Xr(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){dh(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=wr(t,this.attrs||{})),i&&(this.attrs=wr({class:i},this.attrs||{}))}domAtPos(e){return uh(this.dom,this.children,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.dirty|=6)}sync(e){var t;this.dom?this.dirty&4&&(sh(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(kr(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e);let i=this.dom.lastChild;for(;i&&X.get(i)instanceof _e;)i=i.lastChild;if(!i||!this.length||i.nodeName!="BR"&&((t=X.get(i))===null||t===void 0?void 0:t.isEditable)==!1&&(!P.ios||!this.children.some(s=>s instanceof St))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0;for(let t of this.children){if(!(t instanceof St))return null;let i=Ri(t.dom);if(i.length!=1)return null;e+=i[0].width}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length}}coordsAt(e,t){return ph(this,e,t)}become(e){return!1}get type(){return K.Text}static find(e,t){for(let i=0,s=0;i<e.children.length;i++){let r=e.children[i],o=s+r.length;if(o>=t){if(r instanceof Ae)return r;if(o>t)break}s=o+r.breakAfter}return null}}class Et extends X{constructor(e,t,i){super(),this.widget=e,this.length=t,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,s,r,o){return i&&(!(i instanceof Et)||!this.widget.compare(i.widget)||e>0&&r<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?me.before(this.dom):me.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new Et(this.widget,t,this.type);return i.breakAfter=this.breakAfter,i}get children(){return Yr}sync(){(!this.dom||!this.widget.updateDOM(this.dom))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):U.empty}domBoundsAround(){return null}become(e){return e instanceof Et&&e.type==this.type&&e.widget.constructor==this.widget.constructor?(e.widget.eq(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Zr{constructor(e,t,i,s){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!e.breakAfter&&!(e instanceof Et&&e.type==K.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ae),this.atCursorPos=!0),this.curLine}flushBuffer(e){this.pendingBuffer&&(this.curLine.append(Qi(new ei(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer([]),this.curLine=null,this.content.push(e)}finish(e){e?this.pendingBuffer=0:this.flushBuffer([]),this.posCovered()||this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,e--;continue}else this.text=r,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(0,i)),this.getLine().append(Qi(new St(this.text.slice(this.textOff,this.textOff+s)),t),i),this.atCursorPos=!0,this.textOff+=s,e-=s,i=0}}span(e,t,i,s){this.buildText(t-e,i,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,i,s,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Ft){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Ft)if(i.block){let{type:a}=i;a==K.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Et(i.widget||new Jo("div"),l,a))}else{let a=pt.create(i.widget||new Jo("span"),l,i.startSide),h=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e<t||i.startSide>0),c=!a.isEditable&&(e<t||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&(this.pendingBuffer=0),this.flushBuffer(s),h&&(f.append(Qi(new ei(1),s),r),r=s.length+Math.max(0,r-s.length)),f.append(Qi(a,s),r),this.atCursorPos=c,this.pendingBuffer=c?e<t?1:2:0}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,i,s,r){let o=new Zr(e,t,i,r);return o.openEnd=G.spans(s,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Qi(n,e){for(let t of e)n=new _e(t,[n],n.length);return n}class Jo extends lt{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}}const gh=R.define(),yh=R.define(),bh=R.define(),xh=R.define(),Sr=R.define(),wh=R.define(),kh=R.define({combine:n=>n.some(e=>e)});class Dn{constructor(e,t="nearest",i="nearest",s=5,r=5){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r}map(e){return e.empty?this:new Dn(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const Yo=N.define({map:(n,e)=>n.map(e)});function Ie(n,e,t){let i=n.facet(xh);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const ns=R.define({combine:n=>n.length?n[0]:!0});let Qd=0;const mi=R.define();class se{constructor(e,t,i,s){this.id=e,this.create=t,this.domEventHandlers=i,this.extension=s(this)}static define(e,t){const{eventHandlers:i,provide:s,decorations:r}=t||{};return new se(Qd++,e,i,o=>{let l=[mi.of(o)];return r&&l.push(Bi.of(a=>{let h=a.plugin(o);return h?r(h):B.none})),s&&l.push(s(o)),l})}static fromClass(e,t){return se.define(i=>new e(i),t)}}class vs{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Ie(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ie(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Ie(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const vh=R.define(),Sh=R.define(),Bi=R.define(),Ch=R.define(),Ah=R.define(),gi=R.define();class nt{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new nt(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,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let s=0,r=0,o=0,l=0;;s++){let a=s==e.length?null:e[s],h=o-l,c=a?a.fromB:1e9;for(;r<t.length&&t[r]<c;){let f=t[r],u=t[r+1],d=Math.max(l,f),m=Math.min(c,u);if(d<=m&&new nt(d+h,m+h,d,m).addToSet(i),u>c)break;r+=2}if(!a)return i;new nt(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}}class Tn{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ae.empty(this.startState.doc.length);for(let o of i)this.changes=this.changes.compose(o.changes);let s=[];this.changes.iterChangedRanges((o,l,a,h)=>s.push(new nt(o,l,a,h))),this.changedRanges=s;let r=e.hasFocus;r!=e.inputState.notifiedFocused&&(e.inputState.notifiedFocused=r,this.flags|=1)}static create(e,t,i){return new Tn(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}var ee=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(ee||(ee={}));const Cr=ee.LTR,Jd=ee.RTL;function Mh(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}const Yd=Mh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Xd=Mh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ar=Object.create(null),qe=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);Ar[e]=t,Ar[t]=-e}function Zd(n){return n<=247?Yd[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Xd[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8203||n==8204?256:1}const _d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;class Jt{constructor(e,t,i){this.from=e,this.to=t,this.level=i}get dir(){return this.level%2?Jd:Cr}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,i,s){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(r<0||(s!=0?s<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}const _=[];function ep(n,e){let t=n.length,i=e==Cr?1:2,s=e==Cr?2:1;if(!n||i==1&&!_d.test(n))return Oh(t);for(let o=0,l=i,a=i;o<t;o++){let h=Zd(n.charCodeAt(o));h==512?h=l:h==8&&a==4&&(h=16),_[o]=h==4?2:h,h&7&&(a=h),l=h}for(let o=0,l=i,a=i;o<t;o++){let h=_[o];if(h==128)o<t-1&&l==_[o+1]&&l&24?h=_[o]=l:_[o]=256;else if(h==64){let c=o+1;for(;c<t&&_[c]==64;)c++;let f=o&&l==8||c<t&&_[c]==8?a==1?1:8:256;for(let u=o;u<c;u++)_[u]=f;o=c-1}else h==8&&a==1&&(_[o]=1);l=h,h&7&&(a=h)}for(let o=0,l=0,a=0,h,c,f;o<t;o++)if(c=Ar[h=n.charCodeAt(o)])if(c<0){for(let u=l-3;u>=0;u-=3)if(qe[u+1]==-c){let d=qe[u+2],m=d&2?i:d&4?d&1?s:i:0;m&&(_[o]=_[qe[u]]=m),l=u;break}}else{if(qe.length==189)break;qe[l++]=o,qe[l++]=h,qe[l++]=a}else if((f=_[o])==2||f==1){let u=f==i;a=u?0:1;for(let d=l-3;d>=0;d-=3){let m=qe[d+2];if(m&2)break;if(u)qe[d+2]|=2;else{if(m&4)break;qe[d+2]|=4}}}for(let o=0;o<t;o++)if(_[o]==256){let l=o+1;for(;l<t&&_[l]==256;)l++;let a=(o?_[o-1]:i)==1,h=(l<t?_[l]:i)==1,c=a==h?a?1:2:i;for(let f=o;f<l;f++)_[f]=c;o=l-1}let r=[];if(i==1)for(let o=0;o<t;){let l=o,a=_[o++]!=1;for(;o<t&&a==(_[o]!=1);)o++;if(a)for(let h=o;h>l;){let c=h,f=_[--h]!=2;for(;h>l&&f==(_[h-1]!=2);)h--;r.push(new Jt(h,c,f?2:1))}else r.push(new Jt(l,o,0))}else for(let o=0;o<t;){let l=o,a=_[o++]==2;for(;o<t&&a==(_[o]==2);)o++;r.push(new Jt(l,o,a?1:2))}return r}function Oh(n){return[new Jt(0,n,0)]}let Dh="";function tp(n,e,t,i,s){var r;let o=i.head-n.from,l=-1;if(o==0){if(!s||!n.length)return null;e[0].level!=t&&(o=e[0].side(!1,t),l=0)}else if(o==n.length){if(s)return null;let u=e[e.length-1];u.level!=t&&(o=u.side(!0,t),l=e.length-1)}l<0&&(l=Jt.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc));let a=e[l];o==a.side(s,t)&&(a=e[l+=s?1:-1],o=a.side(!s,t));let h=s==(a.dir==t),c=Le(n.text,o,h);if(Dh=n.text.slice(Math.min(o,c),Math.max(o,c)),c!=a.side(s,t))return w.cursor(c+n.from,h?-1:1,a.level);let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return!f&&a.level!=t?w.cursor(s?n.to:n.from,s?-1:1,t):f&&f.level<a.level?w.cursor(f.side(!s,t)+n.from,s?1:-1,f.level):w.cursor(c+n.from,s?-1:1,a.level)}const mt="\uFFFF";class Th{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(H.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=mt}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s),this.readNode(s);let r=s.nextSibling;if(r==t)break;let o=X.get(s),l=X.get(r);(o&&l?o.breakAfter:(o?o.breakAfter:Xo(s))||Xo(r)&&(s.nodeName!="BR"||s.cmIgnore))&&this.lineBreak(),s=r}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=X.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+Math.min(t,i.offset))}}function Xo(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}class Zo{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class _o extends X{constructor(e){super(),this.view=e,this.compositionDeco=B.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ae],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new nt(0,0,0,e.state.doc.length)],0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:o,toA:l})=>l<this.minWidthFrom||o>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.view.inputState.composing<0?this.compositionDeco=B.none:(e.transactions.length||this.dirty)&&(this.compositionDeco=np(this.view,e.changes)),(P.ie||P.chrome)&&!this.compositionDeco.size&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,s=this.updateDeco(),r=lp(i,s,e.changes);return t=nt.extendWithRanges(t,r),this.dirty==0&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=P.chrome||P.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(r),this.dirty=0,r&&(r.written||i.selectionRange.focusNode!=r.node)&&(this.forceSelection=!0),this.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.children)r instanceof Et&&r.widget instanceof el&&s.push(r.dom);i.updateGaps(s)}updateChildren(e,t){let i=this.childCursor(t);for(let s=e.length-1;;s--){let r=s>=0?e[s]:null;if(!r)break;let{fromA:o,toA:l,fromB:a,toB:h}=r,{content:c,breakAtStart:f,openStart:u,openEnd:d}=Zr.build(this.view.state.doc,a,h,this.decorations,this.dynamicDecorationMap),{i:m,off:y}=i.findPos(l,1),{i:x,off:b}=i.findPos(o,-1);oh(this,x,b,m,y,c,f,u,d)}}updateSelection(e=!1,t=!1){if((e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange(),!(t||this.mayControlSelection())||P.ios&&this.view.inputState.rapidCompositionStart)return;let i=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,r=this.domAtPos(s.anchor),o=s.empty?r:this.domAtPos(s.head);if(P.gecko&&s.empty&&ip(r)){let a=document.createTextNode("");this.view.observer.ignore(()=>r.node.insertBefore(a,r.node.childNodes[r.offset]||null)),r=o=new me(a,0),i=!0}let l=this.view.observer.selectionRange;(i||!l.focusNode||!Mn(r.node,r.offset,l.anchorNode,l.anchorOffset)||!Mn(o.node,o.offset,l.focusNode,l.focusOffset))&&(this.view.observer.ignore(()=>{P.android&&P.chrome&&this.dom.contains(l.focusNode)&&ap(l.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let a=An(this.root);if(a)if(s.empty){if(P.gecko){let h=rp(r.node,r.offset);if(h&&h!=3){let c=Rh(r.node,r.offset,h==1?1:-1);c&&(r=new me(c,h==1?0:c.nodeValue.length))}}a.collapse(r.node,r.offset),s.bidiLevel!=null&&l.cursorBidiLevel!=null&&(l.cursorBidiLevel=s.bidiLevel)}else if(a.extend)a.collapse(r.node,r.offset),a.extend(o.node,o.offset);else{let h=document.createRange();s.anchor>s.head&&([r,o]=[o,r]),h.setEnd(o.node,o.offset),h.setStart(r.node,r.offset),a.removeAllRanges(),a.addRange(h)}}),this.view.observer.setSelectionRange(r,o)),this.impreciseAnchor=r.precise?null:new me(l.anchorNode,l.anchorOffset),this.impreciseHead=o.precise?null:new me(l.focusNode,l.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let e=this.view.state.selection.main,t=An(this.root);if(!t||!e.empty||!e.assoc||!t.modify)return;let i=Ae.find(this,e.head);if(!i)return;let s=i.posAtStart;if(e.head==s||e.head==s+i.length)return;let r=this.coordsAt(e.head,-1),o=this.coordsAt(e.head,1);if(!r||!o||r.bottom>o.top)return;let l=this.domAtPos(e.head+e.assoc);t.collapse(l.node,l.offset),t.modify("move",e.assoc<0?"forward":"backward","lineboundary")}mayControlSelection(){let e=this.root.activeElement;return e==this.dom||dr(this.dom,this.view.observer.selectionRange)&&!(e&&this.dom.contains(e))}nearest(e){for(let t=e;t;){let i=X.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let s=this.children[t];if(i<s.length||s instanceof Ae)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){for(let i=this.length,s=this.children.length-1;;s--){let r=this.children[s],o=i-r.breakAfter-r.length;if(e>o||e==o&&r.type!=K.WidgetBefore&&r.type!=K.WidgetAfter&&(!s||t==2||this.children[s-1].breakAfter||this.children[s-1].type==K.WidgetBefore&&t>-2))return r.coordsAt(e-o,t);i=o}}measureVisibleLineHeights(e){let t=[],{from:i,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ee.LTR;for(let h=0,c=0;c<this.children.length;c++){let f=this.children[c],u=h+f.length;if(u>s)break;if(h>=i){let d=f.dom.getBoundingClientRect();if(t.push(d.height),o){let m=f.dom.lastChild,y=m?Ri(m):[];if(y.length){let x=y[y.length-1],b=a?x.right-d.left:d.right-x.left;b>l&&(l=b,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?ee.RTL:ee.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ae){let r=s.measureTextSize();if(r)return r}let e=document.createElement("div"),t,i;return e.className="cm-line",e.style.width="99999px",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=Ri(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,e.remove()}),{lineHeight:t,charWidth:i}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new rh(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.length;if(o>i){let l=t.lineBlockAt(o).bottom-t.lineBlockAt(i).top;e.push(B.replace({widget:new el(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return B.set(e)}updateDeco(){let e=this.view.state.facet(Bi).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=0,o=0,l=0,a=0;for(let c of this.view.state.facet(Ah).map(f=>f(this.view)))if(c){let{left:f,right:u,top:d,bottom:m}=c;f!=null&&(r=Math.max(r,f)),u!=null&&(o=Math.max(o,u)),d!=null&&(l=Math.max(l,d)),m!=null&&(a=Math.max(a,m))}let h={left:i.left-r,top:i.top-l,right:i.right+o,bottom:i.bottom+a};$d(this.view.scrollDOM,h,t.head<t.anchor?-1:1,e.x,e.y,e.xMargin,e.yMargin,this.view.textDirection==ee.LTR)}}function ip(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}class el extends lt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function Ph(n){let e=n.observer.selectionRange,t=e.focusNode&&Rh(e.focusNode,e.focusOffset,0);if(!t)return null;let i=n.docView.nearest(t);if(!i)return null;if(i instanceof Ae){let s=t;for(;s.parentNode!=i.dom;)s=s.parentNode;let r=s.previousSibling;for(;r&&!X.get(r);)r=r.previousSibling;let o=r?X.get(r).posAtEnd:i.posAtStart;return{from:o,to:o,node:s,text:t}}else{for(;;){let{parent:r}=i;if(!r)return null;if(r instanceof Ae)break;i=r}let s=i.posAtStart;return{from:s,to:s+i.length,node:i.dom,text:t}}}function np(n,e){let t=Ph(n);if(!t)return B.none;let{from:i,to:s,node:r,text:o}=t,l=e.mapPos(i,1),a=Math.max(l,e.mapPos(s,-1)),{state:h}=n,c=r.nodeType==3?r.nodeValue:new Th([],h).readRange(r.firstChild,null).text;if(a-l<c.length)if(h.doc.sliceString(l,Math.min(h.doc.length,l+c.length),mt)==c)a=l+c.length;else if(h.doc.sliceString(Math.max(0,a-c.length),a,mt)==c)l=a-c.length;else return B.none;else if(h.doc.sliceString(l,a,mt)!=c)return B.none;let f=X.get(r);return f instanceof ch?f=f.widget.topView:f&&(f.parent=null),B.set(B.replace({widget:new sp(r,o,f),inclusive:!0}).range(l,a))}class sp extends lt{constructor(e,t,i){super(),this.top=e,this.text=t,this.topView=i}eq(e){return this.top==e.top&&this.text==e.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return ch}}function Rh(n,e,t){for(;;){if(n.nodeType==3)return n;if(n.nodeType==1&&e>0&&t<=0)n=n.childNodes[e-1],e=On(n);else if(n.nodeType==1&&e<n.childNodes.length&&t>=0)n=n.childNodes[e],e=0;else return null}}function rp(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}class op{constructor(){this.changes=[]}compareRange(e,t){vr(e,t,this.changes)}comparePoint(e,t){vr(e,t,this.changes)}}function lp(n,e,t){let i=new op;return G.compare(n,e,t,i),i.changes}function ap(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function hp(n,e,t=1){let i=n.charCategorizer(e),s=n.doc.lineAt(e),r=e-s.from;if(s.length==0)return w.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=Le(s.text,r,!1):l=Le(s.text,r);let a=i(s.text.slice(o,l));for(;o>0;){let h=Le(s.text,o,!1);if(i(s.text.slice(h,o))!=a)break;o=h}for(;l<s.length;){let h=Le(s.text,l);if(i(s.text.slice(l,h))!=a)break;l=h}return w.range(o+s.from,l+s.from)}function cp(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function fp(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function Ss(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function tl(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function il(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function Mr(n,e,t){let i,s,r,o,l,a,h,c;for(let d=n.firstChild;d;d=d.nextSibling){let m=Ri(d);for(let y=0;y<m.length;y++){let x=m[y];s&&Ss(s,x)&&(x=tl(il(x,s.bottom),s.top));let b=cp(e,x),v=fp(t,x);if(b==0&&v==0)return d.nodeType==3?nl(d,e,t):Mr(d,e,t);(!i||o>v||o==v&&r>b)&&(i=d,s=x,r=b,o=v),b==0?t>x.bottom&&(!h||h.bottom<x.bottom)?(l=d,h=x):t<x.top&&(!c||c.top>x.top)&&(a=d,c=x):h&&Ss(h,x)?h=il(h,x.bottom):c&&Ss(c,x)&&(c=tl(c,x.top))}}if(h&&h.bottom>=t?(i=l,s=h):c&&c.top<=t&&(i=a,s=c),!i)return{node:n,offset:0};let f=Math.max(s.left,Math.min(s.right,e));if(i.nodeType==3)return nl(i,f,t);if(!r&&i.contentEditable=="true")return Mr(i,f,t);let u=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(s.left+s.right)/2?1:0);return{node:n,offset:u}}function nl(n,e,t){let i=n.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<i;l++){let a=_t(n,l,l+1).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(c.top==c.bottom)continue;o||(o=e-c.left);let f=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f<r){let u=e>=(c.left+c.right)/2,d=u;if((P.chrome||P.gecko)&&_t(n,l).getBoundingClientRect().left==c.right&&(d=!u),f<=0)return{node:n,offset:l+(d?1:0)};s=l+(d?1:0),r=f}}}return{node:n,offset:s>-1?s:o>0?n.nodeValue.length:0}}function Bh(n,{x:e,y:t},i,s=-1){var r;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,a,{docHeight:h}=n.viewState,c=t-l;if(c<0)return 0;if(c>h)return n.state.doc.length;for(let b=n.defaultLineHeight/2,v=!1;a=n.elementAtHeight(c),a.type!=K.Text;)for(;c=s>0?a.bottom+b:a.top-b,!(c>=0&&c<=h);){if(v)return i?null:0;v=!0,s=-s}t=l+c;let f=a.from;if(f<n.viewport.from)return n.viewport.from==0?0:i?null:sl(n,o,a,e,t);if(f>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:i?null:sl(n,o,a,e,t);let u=n.dom.ownerDocument,d=n.root.elementFromPoint?n.root:u,m=d.elementFromPoint(e,t);m&&!n.contentDOM.contains(m)&&(m=null),m||(e=Math.max(o.left+1,Math.min(o.right-1,e)),m=d.elementFromPoint(e,t),m&&!n.contentDOM.contains(m)&&(m=null));let y,x=-1;if(m&&((r=n.docView.nearest(m))===null||r===void 0?void 0:r.isEditable)!=!1){if(u.caretPositionFromPoint){let b=u.caretPositionFromPoint(e,t);b&&({offsetNode:y,offset:x}=b)}else if(u.caretRangeFromPoint){let b=u.caretRangeFromPoint(e,t);b&&({startContainer:y,startOffset:x}=b,(P.safari&&up(y,x,e)||P.chrome&&dp(y,x,e))&&(y=void 0))}}if(!y||!n.docView.dom.contains(y)){let b=Ae.find(n.docView,f);if(!b)return c>a.top+a.height/2?a.to:a.from;({node:y,offset:x}=Mr(b.dom,e,t))}return n.docView.posFromDOM(y,x)}function sl(n,e,t,i,s){let r=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=Math.floor((s-t.top)/n.defaultLineHeight);r+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+cr(o,r,n.state.tabSize)}function up(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let s=n.nextSibling;s;s=s.nextSibling)if(s.nodeType!=1||s.nodeName!="BR")return!1;return _t(n,i-1,i).getBoundingClientRect().left>t}function dp(n,e,t){if(e!=0)return!1;for(let s=n;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let i=n.nodeType==1?n.getBoundingClientRect():_t(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function pp(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=!i||!n.lineWrapping?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let a=n.dom.getBoundingClientRect(),h=n.textDirectionAt(s.from),c=n.posAtCoords({x:t==(h==ee.LTR)?a.right-1:a.left+1,y:(r.top+r.bottom)/2});if(c!=null)return w.cursor(c,t?-1:1)}let o=Ae.find(n.docView,e.head),l=o?t?o.posAtEnd:o.posAtStart:t?s.to:s.from;return w.cursor(l,t?-1:1)}function rl(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=e,a=null;;){let h=tp(s,r,o,l,t),c=Dh;if(!h){if(s.number==(t?n.state.doc.lines:1))return l;c=`
|
|
8
8
|
`,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),h=w.cursor(t?s.from:s.to)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function mp(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==Ce.Space&&(s=o),s==o}}function gp(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return w.cursor(s,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let d=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-d.from))),l=(r<0?d.top:d.bottom)+c}let f=a.left+o,u=i!=null?i:n.defaultLineHeight>>1;for(let d=0;;d+=10){let m=l+(u+d)*r,y=Bh(n,{x:f,y:m},!1,r);if(m<a.top||m>a.bottom||(r<0?y<s:y>s))return w.cursor(y,e.assoc,void 0,o)}}function Cs(n,e,t){let i=n.state.facet(Ch).map(s=>s(n));for(;;){let s=!1;for(let r of i)r.between(t.from-1,t.from+1,(o,l,a)=>{t.from>o&&t.from<l&&(t=e.from>t.from?w.cursor(o,1):w.cursor(l,-1),s=!0)});if(!s)return t}}class yp{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;for(let t in ce){let i=ce[t];e.contentDOM.addEventListener(t,s=>{!ol(e,s)||this.ignoreDuringComposition(s)||t=="keydown"&&this.keydown(e,s)||(this.mustFlushObserver(s)&&e.observer.forceFlush(),this.runCustomHandlers(t,e,s)?s.preventDefault():i(e,s))}),this.registeredEvents.push(t)}P.chrome&&P.chrome_version>=102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,P.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var i;let s;this.customHandlers=[];for(let r of t)if(s=(i=r.update(e).spec)===null||i===void 0?void 0:i.domEventHandlers){this.customHandlers.push({plugin:r.value,handlers:s});for(let o in s)this.registeredEvents.indexOf(o)<0&&o!="scroll"&&(this.registeredEvents.push(o),e.contentDOM.addEventListener(o,l=>{!ol(e,l)||this.runCustomHandlers(o,e,l)&&l.preventDefault()}))}}runCustomHandlers(e,t,i){for(let s of this.customHandlers){let r=s.handlers[e];if(r)try{if(r.call(s.plugin,i,t)||i.defaultPrevented)return!0}catch(o){Ie(t.state,o)}}return!1}runScrollHandlers(e,t){for(let i of this.customHandlers){let s=i.handlers.scroll;if(s)try{s.call(i.plugin,t,e)}catch(r){Ie(e.state,r)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(P.android&&P.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let i;return P.ios&&(i=Lh.find(s=>s.keyCode==t.keyCode))&&!(t.ctrlKey||t.altKey||t.metaKey)&&!t.synthetic?(this.pendingIOSKey=i,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Si(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:P.safari&&Date.now()-this.compositionEndedAt<100?(this.compositionEndedAt=0,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229||e.type=="compositionend"&&!P.ios}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const Lh=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Eh=[16,17,18,20,91,92,224,225];class bp{constructor(e,t,i,s){this.view=e,this.style=i,this.mustSelect=s,this.lastEvent=t;let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(H.allowMultipleSelections)&&xp(e,t),this.dragMove=wp(e,t),this.dragging=kp(e,t)&&_r(t)==1?null:!1,this.dragging===!1&&(t.preventDefault(),this.select(t))}move(e){if(e.buttons==0)return this.destroy();this.dragging===!1&&this.select(this.lastEvent=e)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(e){let t=this.style.get(e,this.extend,this.multiple);(this.mustSelect||!t.eq(this.view.state.selection)||t.main.assoc!=this.view.state.selection.main.assoc)&&this.view.dispatch({selection:t,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function xp(n,e){let t=n.state.facet(gh);return t.length?t[0](e):P.mac?e.metaKey:e.ctrlKey}function wp(n,e){let t=n.state.facet(yh);return t.length?t[0](e):P.mac?!e.altKey:!e.ctrlKey}function kp(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=An(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function ol(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=X.get(t))&&i.ignoreEvent(e))return!1;return!0}const ce=Object.create(null),Ih=P.ie&&P.ie_version<15||P.ios&&P.webkit_version<604;function vp(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Nh(n,t.value)},50)}function Nh(n,e){let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Or!=null&&t.selection.ranges.every(a=>a.empty)&&Or==r.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:w.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:w.cursor(a.from+h.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ce.keydown=(n,e)=>{n.inputState.setSelectionOrigin("select"),e.keyCode==27?n.inputState.lastEscPress=Date.now():Eh.indexOf(e.keyCode)<0&&(n.inputState.lastEscPress=0)};let Fh=0;ce.touchstart=(n,e)=>{Fh=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};ce.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ce.mousedown=(n,e)=>{if(n.observer.flush(),Fh>Date.now()-2e3&&_r(e)==1)return;let t=null;for(let i of n.state.facet(bh))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Ap(n,e)),t){let i=n.root.activeElement!=n.contentDOM;i&&n.observer.ignore(()=>nh(n.contentDOM)),n.inputState.startMouseSelection(new bp(n,e,t,i))}};function ll(n,e,t,i){if(i==1)return w.cursor(e,t);if(i==2)return hp(n.state,e,t);{let s=Ae.find(n.docView,e),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<n.state.doc.length&&l==r.to&&l++,w.range(o,l)}}let Vh=(n,e)=>n>=e.top&&n<=e.bottom,al=(n,e,t)=>Vh(e,t)&&n>=t.left&&n<=t.right;function Sp(n,e,t,i){let s=Ae.find(n.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&al(t,i,o))return-1;let l=s.coordsAt(r,1);return l&&al(t,i,l)?1:o&&Vh(i,o)?-1:1}function hl(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Sp(n,t,e.clientX,e.clientY)}}const Cp=P.ie&&P.ie_version<=11;let cl=null,fl=0,ul=0;function _r(n){if(!Cp)return n.detail;let e=cl,t=ul;return cl=n,ul=Date.now(),fl=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(fl+1)%3:1}function Ap(n,e){let t=hl(n,e),i=_r(e),s=n.state.selection,r=t,o=e;return{update(l){l.docChanged&&(t&&(t.pos=l.changes.mapPos(t.pos)),s=s.map(l.changes),o=null)},get(l,a,h){let c;if(o&&l.clientX==o.clientX&&l.clientY==o.clientY?c=r:(c=r=hl(n,l),o=l),!c||!t)return s;let f=ll(n,c.pos,c.bias,i);if(t.pos!=c.pos&&!a){let u=ll(n,t.pos,t.bias,i),d=Math.min(u.from,f.from),m=Math.max(u.to,f.to);f=d<f.from?w.range(d,m):w.range(m,d)}return a?s.replaceRange(s.main.extend(f.from,f.to)):h&&s.ranges.length>1&&s.ranges.some(u=>u.eq(f))?Mp(s,f):h?s.addRange(f):w.create([f])}}}function Mp(n,e){for(let t=0;;t++)if(n.ranges[t].eq(e))return w.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}ce.dragstart=(n,e)=>{let{selection:{main:t}}=n.state,{mouseSelection:i}=n.inputState;i&&(i.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function dl(n,e,t,i){if(!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=n.inputState,o=i&&r&&r.dragging&&r.dragMove?{from:r.dragging.from,to:r.dragging.to}:null,l={from:s,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}ce.drop=(n,e)=>{if(!e.dataTransfer)return;if(n.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let i=Array(t.length),s=0,r=()=>{++s==t.length&&dl(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}}else dl(n,e,e.dataTransfer.getData("Text"),!0)};ce.paste=(n,e)=>{if(n.state.readOnly)return e.preventDefault();n.observer.flush();let t=Ih?null:e.clipboardData;t?(Nh(n,t.getData("text/plain")),e.preventDefault()):vp(n)};function Op(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Dp(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}let Or=null;ce.copy=ce.cut=(n,e)=>{let{text:t,ranges:i,linewise:s}=Dp(n.state);if(!t&&!s)return;Or=s?t:null;let r=Ih?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",t)):Op(n,t),e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"})};function Wh(n){setTimeout(()=>{n.hasFocus!=n.inputState.notifiedFocused&&n.update([])},10)}ce.focus=Wh;ce.blur=n=>{n.observer.clearSelectionRange(),Wh(n)};function Hh(n,e){if(n.docView.compositionDeco.size){n.inputState.rapidCompositionStart=e;try{n.update([])}finally{n.inputState.rapidCompositionStart=!1}}}ce.compositionstart=ce.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0,n.docView.compositionDeco.size&&(n.observer.flush(),Hh(n,!0)))};ce.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionFirstChange=null,setTimeout(()=>{n.inputState.composing<0&&Hh(n,!1)},50)};ce.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};ce.beforeinput=(n,e)=>{var t;let i;if(P.chrome&&P.android&&(i=Lh.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}};const pl=["pre-wrap","normal","pre-line","break-spaces"];class Tp{constructor(){this.doc=U.empty,this.lineWrapping=!1,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return pl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let s=e[i];s<0?i++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,i,s,r){let o=pl.indexOf(e)>-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=i,this.lineLength=s,l){this.heightSamples={};for(let a=0;a<r.length;a++){let h=r[a];h<0?a++:this.heightSamples[Math.floor(h*10)]=!0}}return l}}class Pp{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class gt{constructor(e,t,i,s,r){this.from=e,this.length=t,this.top=i,this.height=s,this.type=r}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(e){let t=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(e.type)?e.type:[e]);return new gt(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Q=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(Q||(Q={}));const dn=.001;class De{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>dn&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return De.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this;for(let o=s.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=s[o],f=r.lineAt(l,Q.ByPosNoHeight,t,0,0),u=f.to>=a?f:r.lineAt(a,Q.ByPosNoHeight,t,0,0);for(c+=u.to-a,a=u.to;o>0&&f.from<=s[o-1].toA;)l=s[o-1].fromA,h=s[o-1].fromB,o--,l<f.from&&(f=r.lineAt(l,Q.ByPosNoHeight,t,0,0));h+=f.from-l,l=f.from;let d=eo.build(i,e,h,c);r=r.replace(l,a,d)}return r.updateHeight(i,0)}static empty(){return new Pe(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,s=0,r=0;for(;;)if(t==i)if(s>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,s-=l.size}else if(r>s*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(s<r){let l=e[t++];l&&(s+=l.size)}else{let l=e[--i];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Rp(De.of(e.slice(0,t)),o,De.of(e.slice(i)))}}De.prototype.size=1;class zh extends De{constructor(e,t,i){super(e,t),this.type=i}blockAt(e,t,i,s){return new gt(s,this.length,i,this.height,this.type)}lineAt(e,t,i,s,r){return this.blockAt(0,i,s,r)}forEachLine(e,t,i,s,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,i,s,r))}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(e,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Pe extends zh{constructor(e,t){super(e,t,K.Text),this.collapsed=0,this.widgetHeight=0}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof Pe||s instanceof fe&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof fe?s=new Pe(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):De.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setHeight(e,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class fe extends De{constructor(e){super(e,0)}lines(e,t){let i=e.lineAt(t).number,s=e.lineAt(t+this.length).number;return{firstLine:i,lastLine:s,lineHeight:this.height/(s-i+1)}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,lineHeight:l}=this.lines(t,s),a=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:h,length:c}=t.line(r+a);return new gt(h,c,i+l*a,l,K.Text)}lineAt(e,t,i,s,r){if(t==Q.ByHeight)return this.blockAt(e,i,s,r);if(t==Q.ByPosNoHeight){let{from:f,to:u}=i.lineAt(e);return new gt(f,u-f,0,0,K.Text)}let{firstLine:o,lineHeight:l}=this.lines(i,r),{from:a,length:h,number:c}=i.lineAt(e);return new gt(a,h,s+l*(c-o),l,K.Text)}forEachLine(e,t,i,s,r,o){let{firstLine:l,lineHeight:a}=this.lines(i,r);for(let h=Math.max(e,r),c=Math.min(r+this.length,t);h<=c;){let f=i.lineAt(h);h==e&&(s+=a*(f.number-l)),o(new gt(f.from,f.length,s,a,K.Text)),s+=a,h=f.to+1}}replace(e,t,i){let s=this.length-t;if(s>0){let r=i[i.length-1];r instanceof fe?i[i.length-1]=new fe(r.length+s):i.push(null,new fe(s-1))}if(e>0){let r=i[0];r instanceof fe?i[0]=new fe(e+r.length):i.unshift(new fe(e-1),null)}return De.of(i)}decomposeLeft(e,t){t.push(new fe(e-1),null)}decomposeRight(e,t){t.push(null,new fe(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1,h=e.heightChanged;for(s.from>t&&o.push(new fe(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let u=s.heights[s.index++];a==-1?a=u:Math.abs(u-a)>=dn&&(a=-2);let d=new Pe(f,u);d.outdated=!1,o.push(d),l+=f+1}l<=r&&o.push(null,new fe(r-l).updateHeight(e,l));let c=De.of(o);return e.heightChanged=h||a<0||Math.abs(c.height-this.height)>=dn||Math.abs(a-this.lines(e.doc,t).lineHeight)>=dn,c}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Rp extends De{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,i,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==Q.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,s,r):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==Q.ByPosNoHeight?Q.ByPosNoHeight:Q.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,s,r).join(h)}forEachLine(e,t,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,s,r,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,Q.ByPos,i,s,r);e<h.from&&this.left.forEachLine(e,h.from-1,i,s,r,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&ml(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),ml(r,l)}return De.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?De.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=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,i=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,i,s):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ml(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof fe&&(i=n[e+1])instanceof fe&&n.splice(e-1,3,new fe(t.length+1+i.length))}const Bp=5;class eo{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 i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Pe?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Pe(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0;s<0&&(s=this.oracle.lineHeight);let r=t-e;i.block?this.addBlock(new zh(r,s,i.type)):(r||s>=Bp)&&this.addLineDeco(s,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Pe(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new fe(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Pe)return e;let t=new Pe(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine(),e.type==K.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,e.type!=K.WidgetBefore&&(this.covering=e)}addLineDeco(e,t){let i=this.ensureLine();i.length+=t,i.collapsed+=t,i.widgetHeight=Math.max(i.widgetHeight,e),this.writtenTo=this.pos=this.pos+t}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Pe)&&!this.isCovered?this.nodes.push(new Pe(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let s of this.nodes)s instanceof Pe&&s.updateHeight(this.oracle,i),i+=s?s.length:1;return this.nodes}static build(e,t,i,s){let r=new eo(i,e);return G.spans(t,i,s,r,0),r.finish(i)}}function Lp(n,e,t){let i=new Ep;return G.compare(n,e,t,i,0),i.changes}class Ep{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,s){(e<t||i&&i.heightRelevant||s&&s.heightRelevant)&&vr(e,t,this.changes,5)}}function Ip(n,e){let t=n.getBoundingClientRect(),i=Math.max(0,t.left),s=Math.min(innerWidth,t.right),r=Math.max(0,t.top),o=Math.min(innerHeight,t.bottom),l=n.ownerDocument.body;for(let a=n.parentNode;a&&a!=l;)if(a.nodeType==1){let h=a,c=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&c.overflow!="visible"){let f=h.getBoundingClientRect();i=Math.max(i,f.left),s=Math.min(s,f.right),r=Math.max(r,f.top),o=Math.min(o,f.bottom)}a=c.position=="absolute"||c.position=="fixed"?h.offsetParent:h.parentNode}else if(a.nodeType==11)a=a.host;else break;return{left:i-t.left,right:Math.max(i,s)-t.left,top:r-(t.top+e),bottom:Math.max(r,o)-(t.top+e)}}function Np(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class As{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let s=e[i],r=t[i];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e){return B.replace({widget:new Fp(this.size,e)}).range(this.from,this.to)}}class Fp extends lt{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 gl{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.heightOracle=new Tp,this.scaler=xl,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ee.RTL,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.stateDeco=e.facet(Bi).filter(t=>typeof t!="function"),this.heightMap=De.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle.setDoc(e.doc),[new nt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=B.set(this.lineGaps.map(t=>t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Ji(r,o))}}this.viewports=e.sort((i,s)=>i.from-s.from),this.scaler=this.heightMap.height<=7e6?xl:new Hp(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:yi(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Bi).filter(h=>typeof h!="function");let s=e.changedRanges,r=nt.extendWithRanges(s,Lp(i,this.stateDeco,e?e.changes:ae.empty(this.state.doc.length))),o=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(e.flags|=2);let l=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<l.from||t.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let a=!e.changes.empty||e.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),a&&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(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ee.RTL:ee.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=o||this.mustMeasureContent||this.contentDOMHeight!=t.clientHeight;this.contentDOMHeight=t.clientHeight,this.mustMeasureContent=!1;let a=0,h=0,c=parseInt(i.paddingTop)||0,f=parseInt(i.paddingBottom)||0;(this.paddingTop!=c||this.paddingBottom!=f)&&(this.paddingTop=c,this.paddingBottom=f,a|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,a|=8);let u=(this.printing?Np:Ip)(t,this.paddingTop),d=u.top-this.pixelViewport.top,m=u.bottom-this.pixelViewport.bottom;this.pixelViewport=u;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(l=!0)),!this.inView)return 0;let x=t.clientWidth;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=x,this.editorHeight=e.scrollDOM.clientHeight,a|=8),l){let v=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(v)&&(o=!0),o||s.lineWrapping&&Math.abs(x-this.contentDOMWidth)>s.charWidth){let{lineHeight:M,charWidth:S}=e.docView.measureTextSize();o=s.refresh(r,M,S,x/S,v),o&&(e.docView.minWidth=0,a|=8)}d>0&&m>0?h=Math.max(d,m):d<0&&m<0&&(h=Math.min(d,m)),s.heightChanged=!1;for(let M of this.viewports){let S=M.from==this.viewport.from?v:e.docView.measureVisibleLineHeights(M);this.heightMap=this.heightMap.updateHeight(s,0,o,new Pp(M.from,S))}s.heightChanged&&(a|=2)}let b=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(a&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.state.doc,{visibleTop:o,visibleBottom:l}=this,a=new Ji(s.lineAt(o-i*1e3,Q.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,Q.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=s.lineAt(h,Q.ByPos,r,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Ji(s.lineAt(u-1e3/2,Q.ByHeight,r,0,0).from,s.lineAt(u+c+1e3/2,Q.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new Ji(this.heightMap.lineAt(i,Q.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(s,Q.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,Q.ByPos,this.state.doc,0,0),{bottom:r}=this.heightMap.lineAt(t,Q.ByPos,this.state.doc,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let s of e)t.touchesRange(s.from,s.to)||i.push(new As(t.mapPos(s.from),t.mapPos(s.to),s.size));return i}ensureLineGaps(e){let t=[];if(this.defaultTextDirection!=ee.LTR)return t;for(let i of this.viewportLines){if(i.length<4e3)continue;let s=Vp(i.from,i.to,this.stateDeco);if(s.total<4e3)continue;let r,o;if(this.heightOracle.lineWrapping){let h=2e3/this.heightOracle.lineLength*this.heightOracle.lineHeight;r=Yi(s,(this.visibleTop-i.top-h)/i.height),o=Yi(s,(this.visibleBottom-i.top+h)/i.height)}else{let h=s.total*this.heightOracle.charWidth,c=2e3*this.heightOracle.charWidth;r=Yi(s,(this.pixelViewport.left-c)/h),o=Yi(s,(this.pixelViewport.right+c)/h)}let l=[];r>i.from&&l.push({from:i.from,to:r}),o<i.to&&l.push({from:o,to:i.to});let a=this.state.selection.main;a.from>=i.from&&a.from<=i.to&&bl(l,a.from-10,a.from+10),!a.empty&&a.to>=i.from&&a.to<=i.to&&bl(l,a.to-10,a.to+10);for(let{from:h,to:c}of l)c-h>1e3&&t.push(Wp(e,f=>f.from>=i.from&&f.to<=i.to&&Math.abs(f.from-h)<1e3&&Math.abs(f.to-c)<1e3)||new As(h,c,this.gapSize(i,h,c,s)))}return t}gapSize(e,t,i,s){let r=yl(s,i)-yl(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){As.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=B.set(e.map(t=>t.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];G.spans(e,this.viewport.from,this.viewport.to,{span(s,r){t.push({from:s,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((s,r)=>s.from!=t[r].from||s.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||yi(this.heightMap.lineAt(e,Q.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(e){return yi(this.heightMap.lineAt(this.scaler.fromDOM(e),Q.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(e){return yi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ji{constructor(e,t){this.from=e,this.to=t}}function Vp(n,e,t){let i=[],s=n,r=0;return G.spans(t,n,e,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s<e&&(i.push({from:s,to:e}),r+=e-s),{total:r,ranges:i}}function Yi({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(i<=l)return r+i;i-=l}}function yl(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function bl(n,e,t){for(let i=0;i<n.length;i++){let s=n[i];if(s.from<t&&s.to>e){let r=[];s.from<e&&r.push({from:s.from,to:e}),s.to>t&&r.push({from:t,to:s.to}),n.splice(i,1,...r),i+=r.length-1}}}function Wp(n,e){for(let t of n)if(e(t))return t}const xl={toDOM(n){return n},fromDOM(n){return n},scale:1};class Hp{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,Q.ByPos,e,0,0).top,c=t.lineAt(a,Q.ByPos,e,0,0).bottom;return s+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,s=r.domBottom}}}function yi(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new gt(n.from,n.length,t,i-t,Array.isArray(n.type)?n.type.map(s=>yi(s,e)):n.type)}const Xi=R.define({combine:n=>n.join(" ")}),Dr=R.define({combine:n=>n.indexOf(!0)>-1}),Tr=kt.newName(),$h=kt.newName(),jh=kt.newName(),qh={"&light":"."+$h,"&dark":"."+jh};function Pr(n,e,t){return new kt(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const zp=Pr("."+Tr,{"&.cm-editor":{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},".cm-content":{margin:0,flexGrow:2,flexShrink:0,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",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 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .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":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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},"&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-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".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"}},qh),$p={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ms=P.ie&&P.ie_version<=11;class jp{constructor(e,t,i){this.view=e,this.onChange=t,this.onScrollChanged=i,this.active=!1,this.selectionRange=new jd,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(s=>{for(let r of s)this.queue.push(r);(P.ie&&P.ie_version<=11||P.ios&&e.composing)&&s.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),Ms&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),window.addEventListener("resize",this.onResize=this.onResize.bind(this)),typeof ResizeObserver=="function"&&(this.resize=new ResizeObserver(()=>{this.view.docView.lastUpdate<Date.now()-75&&this.onResize()}),this.resize.observe(e.scrollDOM)),window.addEventListener("beforeprint",this.onPrint=this.onPrint.bind(this)),this.start(),window.addEventListener("scroll",this.onScroll=this.onScroll.bind(this)),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(s=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),s.length>0&&s[s.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(s=>{s.length>0&&s[s.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){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,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:t}=this,i=this.selectionRange;if(t.state.facet(ns)?t.root.activeElement!=this.dom:!dr(t.dom,i))return;let s=i.anchorNode&&t.docView.nearest(i.anchorNode);s&&s.ignoreEvent(e)||((P.ie&&P.ie_version<=11||P.android&&P.chrome)&&!t.state.selection.main.empty&&i.focusNode&&Mn(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1))}readSelectionRange(){let{root:e}=this.view,t=P.safari&&e.nodeType==11&&Hd()==this.view.contentDOM&&qp(this.view)||An(e);return!t||this.selectionRange.eq(t)?!1:(this.selectionRange.setRange(t),this.selectionChanged=!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 i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,$p),Ms&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){!this.active||(this.active=!1,this.observer.disconnect(),Ms&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){this.delayedAndroidKey||requestAnimationFrame(()=>{let i=this.delayedAndroidKey;this.delayedAndroidKey=null,this.delayedFlush=-1,this.flush()||Si(this.view.contentDOM,i.key,i.keyCode)}),(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t})}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=window.setTimeout(()=>{this.delayedFlush=-1,this.flush()},20))}forceFlush(){this.delayedFlush>=0&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}processRecords(){let e=this.queue;for(let r of this.observer.takeRecords())e.push(r);e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);!o||(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return;e&&this.readSelectionRange();let{from:t,to:i,typeOver:s}=this.processRecords(),r=this.selectionChanged&&dr(this.dom,this.selectionRange);if(t<0&&!r)return;this.selectionChanged=!1;let o=this.view.state,l=this.onChange(t,i,s);return this.view.state==o&&this.view.update([]),l}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.dirty|=4),e.type=="childList"){let i=wl(t,e.previousSibling||e.target.previousSibling,-1),s=wl(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resize)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("beforeprint",this.onPrint),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}}function wl(n,e,t){for(;e;){let i=X.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function qp(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),document.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return Mn(l.node,l.offset,r,o)&&([i,s,r,o]=[r,o,i,s]),{anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:o}}function Up(n,e,t,i){let s,r,o=n.state.selection.main;if(e>-1){let l=n.docView.domBoundsAround(e,t,0);if(!l||n.state.readOnly)return!1;let{from:a,to:h}=l,c=n.docView.impreciseHead||n.docView.impreciseAnchor?[]:Kp(n),f=new Th(c,n.state);f.readRange(l.startDOM,l.endDOM);let u=o.from,d=null;(n.inputState.lastKeyCode===8&&n.inputState.lastKeyTime>Date.now()-100||P.android&&f.text.length<h-a)&&(u=o.to,d="end");let m=Gp(n.state.doc.sliceString(a,h,mt),f.text,u-a,d);m&&(P.chrome&&n.inputState.lastKeyCode==13&&m.toB==m.from+2&&f.text.slice(m.from,m.toB)==mt+mt&&m.toB--,s={from:a+m.from,to:a+m.toA,insert:U.of(f.text.slice(m.from,m.toB).split(mt))}),r=Qp(c,a)}else if(n.hasFocus||!n.state.facet(ns)){let l=n.observer.selectionRange,{impreciseHead:a,impreciseAnchor:h}=n.docView,c=a&&a.node==l.focusNode&&a.offset==l.focusOffset||!Zt(n.contentDOM,l.focusNode)?n.state.selection.main.head:n.docView.posFromDOM(l.focusNode,l.focusOffset),f=h&&h.node==l.anchorNode&&h.offset==l.anchorOffset||!Zt(n.contentDOM,l.anchorNode)?n.state.selection.main.anchor:n.docView.posFromDOM(l.anchorNode,l.anchorOffset);(c!=o.head||f!=o.anchor)&&(r=w.single(f,c))}if(!s&&!r)return!1;if(!s&&i&&!o.empty&&r&&r.main.empty?s={from:o.from,to:o.to,insert:n.state.doc.slice(o.from,o.to)}:s&&s.from>=o.from&&s.to<=o.to&&(s.from!=o.from||s.to!=o.to)&&o.to-o.from-(s.to-s.from)<=4?s={from:o.from,to:o.to,insert:n.state.doc.slice(o.from,s.from).append(s.insert).append(n.state.doc.slice(s.to,o.to))}:(P.mac||P.android)&&s&&s.from==s.to&&s.from==o.head-1&&s.insert.toString()=="."&&(s={from:o.from,to:o.to,insert:U.of([" "])}),s){let l=n.state;if(P.ios&&n.inputState.flushIOSKey(n)||P.android&&(s.from==o.from&&s.to==o.to&&s.insert.length==1&&s.insert.lines==2&&Si(n.contentDOM,"Enter",13)||s.from==o.from-1&&s.to==o.to&&s.insert.length==0&&Si(n.contentDOM,"Backspace",8)||s.from==o.from&&s.to==o.to+1&&s.insert.length==0&&Si(n.contentDOM,"Delete",46)))return!0;let a=s.insert.toString();if(n.state.facet(wh).some(f=>f(n,s.from,s.to,a)))return!0;n.inputState.composing>=0&&n.inputState.composing++;let h;if(s.from>=o.from&&s.to<=o.to&&s.to-s.from>=(o.to-o.from)/3&&(!r||r.main.empty&&r.main.from==s.from+s.insert.length)&&n.inputState.composing<0){let f=o.from<s.from?l.sliceDoc(o.from,s.from):"",u=o.to>s.to?l.sliceDoc(s.to,o.to):"";h=l.replaceSelection(n.state.toText(f+s.insert.sliceString(0,void 0,n.state.lineBreak)+u))}else{let f=l.changes(s),u=r&&!l.selection.main.eq(r.main)&&r.main.to<=f.newLength?r.main:void 0;if(l.selection.ranges.length>1&&n.inputState.composing>=0&&s.to<=o.to&&s.to>=o.to-10){let d=n.state.sliceDoc(s.from,s.to),m=Ph(n)||n.state.doc.lineAt(o.head),y=o.to-s.to,x=o.to-o.from;h=l.changeByRange(b=>{if(b.from==o.from&&b.to==o.to)return{changes:f,range:u||b.map(f)};let v=b.to-y,M=v-d.length;if(b.to-b.from!=x||n.state.sliceDoc(M,v)!=d||m&&b.to>=m.from&&b.from<=m.to)return{range:b};let S=l.changes({from:M,to:v,insert:s.insert}),C=b.to-o.to;return{changes:S,range:u?w.range(Math.max(0,u.anchor+C),Math.max(0,u.head+C)):b.map(S)}})}else h={changes:f,selection:u&&l.selection.replaceRange(u)}}let c="input.type";return n.composing&&(c+=".compose",n.inputState.compositionFirstChange&&(c+=".start",n.inputState.compositionFirstChange=!1)),n.dispatch(h,{scrollIntoView:!0,userEvent:c}),!0}else if(r&&!r.main.eq(o)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin),n.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function Gp(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r<s&&n.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&n.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Kp(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new Zo(t,i)),(s!=t||r!=i)&&e.push(new Zo(s,r))),e}function Qp(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?w.single(t+e,i+e):null}class D{constructor(e={}){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.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this.root=e.root||qd(e.parent)||document,this.viewState=new gl(e.state||H.create(e)),this.plugins=this.state.facet(mi).map(t=>new vs(t));for(let t of this.plugins)t.update(this);this.observer=new jp(this,(t,i,s)=>Up(this,t,i,s),t=>{this.inputState.runScrollHandlers(this,t),this.observer.intersecting&&this.measure()}),this.inputState=new yp(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new _o(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}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.composing>0}get compositionStarted(){return this.inputState.composing>=0}dispatch(...e){this._dispatch(e.length==1&&e[0]instanceof he?e[0]:this.state.update(...e))}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,s,r=this.state;for(let l of e){if(l.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=l.state}if(this.destroyed){this.viewState.state=r;return}if(this.observer.clear(),r.facet(H.phrases)!=this.state.facet(H.phrases))return this.setState(r);s=Tn.create(this,r,e);let o=this.viewState.scrollTarget;try{this.updateState=2;for(let l of e){if(o&&(o=o.map(l.changes)),l.scrollIntoView){let{main:a}=l.state.selection;o=new Dn(a.empty?a:w.cursor(a.head,a.head>a.anchor?-1:1))}for(let a of l.effects)a.is(Yo)&&(o=a.value)}this.viewState.update(s,o),this.bidiCache=Pn.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(gi)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(l=>l.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Xi)!=s.state.facet(Xi)&&(this.viewState.mustMeasureContent=!0),(t||i||o||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!s.empty)for(let l of this.state.facet(Sr))l(s)}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new gl(e),this.plugins=e.facet(mi).map(i=>new vs(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView=new _o(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(mi),i=e.state.facet(mi);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new vs(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this)}measure(e=!0){if(this.destroyed)return;this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.flush();let t=null;try{for(let i=0;;i++){this.updateState=1;let s=this.viewport,r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(i>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let o=[];r&4||([this.measureRequests,o]=[o,this.measureRequests]);let l=o.map(f=>{try{return f.read(this)}catch(u){return Ie(this.state,u),kl}}),a=Tn.create(this,this.state,[]),h=!1,c=!1;a.flags|=r,t?t.flags|=r:t=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),h=this.docView.update(a));for(let f=0;f<o.length;f++)if(l[f]!=kl)try{let u=o[f];u.write&&u.write(l[f],this)}catch(u){Ie(this.state,u)}if(this.viewState.scrollTarget&&(this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,c=!0),h&&this.docView.updateSelection(!0),this.viewport.from==s.from&&this.viewport.to==s.to&&!c&&this.measureRequests.length==0)break}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let i of this.state.facet(Sr))i(t)}get themeClasses(){return Tr+" "+(this.state.facet(Dr)?jh:$h)+" "+this.state.facet(Xi)}updateAttrs(){let e=vl(this,vh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ns)?"true":"false",class:"cm-content",style:`${P.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),vl(this,Sh,t);let i=this.observer.ignore(()=>{let s=kr(this.contentDOM,this.contentAttrs,t),r=kr(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is(D.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(gi),kt.mount(this.root,this.styleModules.concat(zp).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=requestAnimationFrame(()=>this.measure())),e){if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.spec==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}}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,i){return Cs(this,e,rl(this,e,t,i))}moveByGroup(e,t){return Cs(this,e,rl(this,e,t,i=>mp(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return pp(this,e,t,i)}moveVertically(e,t,i){return Cs(this,e,gp(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Bh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[Jt.find(r,e-s.from,-1,t)];return es(i,o.dir==ee.LTR==t>0)}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(kh)||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>Jp)return Oh(e.length);let t=this.textDirectionAt(e.from);for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t)return s.order;let i=ep(e.text,t);return this.bidiCache.push(new Pn(e.from,e.to,t,i)),i}get hasFocus(){var e;return(document.hasFocus()||P.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{nh(this.contentDOM),this.docView.updateSelection()})}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Yo.of(new Dn(typeof e=="number"?w.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return se.define(()=>({}),{eventHandlers:e})}static theme(e,t){let i=kt.newName(),s=[Xi.of(i),gi.of(Pr(`.${i}`,e))];return t&&t.dark&&s.push(Dr.of(!0)),s}static baseTheme(e){return oi.lowest(gi.of(Pr("."+Tr,e,qh)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&X.get(i)||X.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}D.styleModule=gi;D.inputHandler=wh;D.perLineTextDirection=kh;D.exceptionSink=xh;D.updateListener=Sr;D.editable=ns;D.mouseSelectionStyle=bh;D.dragMovesSelection=yh;D.clickAddsSelectionRange=gh;D.decorations=Bi;D.atomicRanges=Ch;D.scrollMargins=Ah;D.darkTheme=Dr;D.contentAttributes=Sh;D.editorAttributes=vh;D.lineWrapping=D.contentAttributes.of({class:"cm-lineWrapping"});D.announce=N.define();const Jp=4096,kl={};class Pn{constructor(e,t,i,s){this.from=e,this.to=t,this.dir=i,this.order=s}static update(e,t){if(t.empty)return e;let i=[],s=e.length?e[e.length-1].dir:ee.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==s&&!t.touchesRange(o.from,o.to)&&i.push(new Pn(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.order))}return i}}function vl(n,e,t){for(let i=n.state.facet(e),s=i.length-1;s>=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&wr(o,t)}return t}const Yp=P.mac?"mac":P.windows?"win":P.linux?"linux":"key";function Xp(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;a<t.length-1;++a){const h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))s=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return s&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Zi(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}const Zp=oi.default(D.domEventHandlers({keydown(n,e){return Gh(Uh(e.state),n,e,"editor")}})),ss=R.define({enables:Zp}),Sl=new WeakMap;function Uh(n){let e=n.facet(ss),t=Sl.get(e);return t||Sl.set(e,t=tm(e.reduce((i,s)=>i.concat(s),[]))),t}function _p(n,e,t){return Gh(Uh(n.state),e,n,t)}let ut=null;const em=4e3;function tm(n,e=Yp){let t=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h)=>{let c=t[o]||(t[o]=Object.create(null)),f=l.split(/ (?!$)/).map(m=>Xp(m,e));for(let m=1;m<f.length;m++){let y=f.slice(0,m).join(" ");s(y,!0),c[y]||(c[y]={preventDefault:!0,commands:[x=>{let b=ut={view:x,prefix:y,scope:o};return setTimeout(()=>{ut==b&&(ut=null)},em),!0}]})}let u=f.join(" ");s(u,!1);let d=c[u]||(c[u]={preventDefault:!1,commands:[]});d.commands.push(a),h&&(d.preventDefault=!0)};for(let o of n){let l=o[e]||o.key;if(!!l)for(let a of o.scope?o.scope.split(" "):["editor"])r(a,l,o.run,o.preventDefault),o.shift&&r(a,"Shift-"+l,o.shift,o.preventDefault)}return t}function Gh(n,e,t,i){let s=Wd(e),r=ue(s,0),o=Re(r)==s.length&&s!=" ",l="",a=!1;ut&&ut.view==t&&ut.scope==i&&(l=ut.prefix+" ",(a=Eh.indexOf(e.keyCode)<0)&&(ut=null));let h=u=>{if(u){for(let d of u.commands)if(d(t))return!0;u.preventDefault&&(a=!0)}return!1},c=n[i],f;if(c){if(h(c[l+Zi(s,e,!o)]))return!0;if(o&&(e.shiftKey||e.altKey||e.metaKey||r>127)&&(f=vt[e.keyCode])&&f!=s){if(h(c[l+Zi(f,e,!0)]))return!0;if(e.shiftKey&&Xt[e.keyCode]!=f&&h(c[l+Zi(Xt[e.keyCode],e,!1)]))return!0}else if(o&&e.shiftKey&&h(c[l+Zi(s,e,!0)]))return!0}return a}const Kh=!P.ios,bi=R.define({combine(n){return ot(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function im(n={}){return[bi.of(n),nm,sm]}class Qh{constructor(e,t,i,s,r){this.left=e,this.top=t,this.width=i,this.height=s,this.className=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width>=0&&(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}}const nm=se.fromClass(class{constructor(n){this.view=n,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=n.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=n.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),n.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(bi).cursorBlinkRate+"ms"}update(n){let e=n.startState.facet(bi)!=n.state.facet(bi);(e||n.selectionSet||n.geometryChanged||n.viewportChanged)&&this.view.requestMeasure(this.measureReq),n.transactions.some(t=>t.scrollIntoView)&&(this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:n}=this.view,e=n.facet(bi),t=n.selection.ranges.map(s=>s.empty?[]:rm(this.view,s)).reduce((s,r)=>s.concat(r)),i=[];for(let s of n.selection.ranges){let r=s==n.selection.main;if(s.empty?!r||Kh:e.drawRangeCursor){let o=om(this.view,s,r);o&&i.push(o)}}return{rangePieces:t,cursors:i}}drawSel({rangePieces:n,cursors:e}){if(n.length!=this.rangePieces.length||n.some((t,i)=>!t.eq(this.rangePieces[i]))){this.selectionLayer.textContent="";for(let t of n)this.selectionLayer.appendChild(t.draw());this.rangePieces=n}if(e.length!=this.cursors.length||e.some((t,i)=>!t.eq(this.cursors[i]))){let t=this.cursorLayer.children;if(t.length!==e.length){this.cursorLayer.textContent="";for(const i of e)this.cursorLayer.appendChild(i.draw())}else e.forEach((i,s)=>i.adjust(t[s]));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),Jh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Kh&&(Jh[".cm-line"].caretColor="transparent !important");const sm=oi.highest(D.theme(Jh));function Yh(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==ee.LTR?e.left:e.right-n.scrollDOM.clientWidth)-n.scrollDOM.scrollLeft,top:e.top-n.scrollDOM.scrollTop}}function Cl(n,e,t){let i=w.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:K.Text}}function Al(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==K.Text))return i}return t}function rm(n,e){if(e.to<=n.viewport.from||e.from>=n.viewport.to)return[];let t=Math.max(e.from,n.viewport.from),i=Math.min(e.to,n.viewport.to),s=n.textDirection==ee.LTR,r=n.contentDOM,o=r.getBoundingClientRect(),l=Yh(n),a=window.getComputedStyle(r.firstChild),h=o.left+parseInt(a.paddingLeft)+Math.min(0,parseInt(a.textIndent)),c=o.right-parseInt(a.paddingRight),f=Al(n,t),u=Al(n,i),d=f.type==K.Text?f:null,m=u.type==K.Text?u:null;if(n.lineWrapping&&(d&&(d=Cl(n,t,d)),m&&(m=Cl(n,i,m))),d&&m&&d.from==m.from)return x(b(e.from,e.to,d));{let M=d?b(e.from,null,d):v(f,!1),S=m?b(null,e.to,m):v(u,!0),C=[];return(d||f).to<(m||u).from-1?C.push(y(h,M.bottom,c,S.top)):M.bottom<S.top&&n.elementAtHeight((M.bottom+S.top)/2).type==K.Text&&(M.bottom=S.top=(M.bottom+S.top)/2),x(M).concat(C).concat(x(S))}function y(M,S,C,k){return new Qh(M-l.left,S-l.top-.01,C-M,k-S+.01,"cm-selectionBackground")}function x({top:M,bottom:S,horizontal:C}){let k=[];for(let O=0;O<C.length;O+=2)k.push(y(C[O],M,C[O+1],S));return k}function b(M,S,C){let k=1e9,O=-1e9,F=[];function T(q,J,ye,oe,$){let te=n.coordsAtPos(q,q==C.to?-2:2),Z=n.coordsAtPos(ye,ye==C.from?2:-2);k=Math.min(te.top,Z.top,k),O=Math.max(te.bottom,Z.bottom,O),$==ee.LTR?F.push(s&&J?h:te.left,s&&oe?c:Z.right):F.push(!s&&oe?h:Z.left,!s&&J?c:te.right)}let E=M!=null?M:C.from,W=S!=null?S:C.to;for(let q of n.visibleRanges)if(q.to>E&&q.from<W)for(let J=Math.max(q.from,E),ye=Math.min(q.to,W);;){let oe=n.state.doc.lineAt(J);for(let $ of n.bidiSpans(oe)){let te=$.from+oe.from,Z=$.to+oe.from;if(te>=ye)break;Z>J&&T(Math.max(te,J),M==null&&te<=E,Math.min(Z,ye),S==null&&Z>=W,$.dir)}if(J=oe.to+1,J>=ye)break}return F.length==0&&T(E,M==null,W,S==null,n.textDirection),{top:k,bottom:O,horizontal:F}}function v(M,S){let C=o.top+(S?M.top:M.bottom);return{top:C,bottom:C,horizontal:[]}}}function om(n,e,t){let i=n.coordsAtPos(e.head,e.assoc||1);if(!i)return null;let s=Yh(n);return new Qh(i.left-s.left,i.top-s.top,-1,i.bottom-i.top,t?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}const Xh=N.define({map(n,e){return n==null?null:e.mapPos(n)}}),xi=ge.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Xh)?i.value:t,n)}}),lm=se.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(xi);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(xi)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let n=this.view.state.field(xi),e=n!=null&&this.view.coordsAtPos(n);if(!e)return null;let t=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-t.left+this.view.scrollDOM.scrollLeft,top:e.top-t.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(n){this.cursor&&(n?(this.cursor.style.left=n.left+"px",this.cursor.style.top=n.top+"px",this.cursor.style.height=n.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(xi)!=n&&this.view.dispatch({effects:Xh.of(n)})}},{eventHandlers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function am(){return[xi,lm]}function Ml(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,o+l.index+l[0].length,l)}function hm(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class cm{constructor(e){let{regexp:t,decoration:i,boundary:s,maxLength:r=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=t,this.getDeco=typeof i=="function"?i:()=>i,this.boundary=s,this.maxLength=r}createDeco(e){let t=new wt;for(let{from:i,to:s}of hm(e,this.maxLength))Ml(e.state.doc,this.regexp,i,s,(r,o,l)=>t.add(r,o,this.getDeco(l,e,r)));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),s=Math.max(a,s))}),e.viewportChanged||s-i>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,s);if(l>o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(r.from,a.from),f=Math.min(r.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],d;if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.index<f-a.from;){let m=d.index+a.from;u.push(this.getDeco(d,e,m).range(m,m+d[0].length))}else Ml(e.state.doc,this.regexp,c,f,(m,y,x)=>u.push(this.getDeco(x,e,m).range(m,y)));t=t.update({filterFrom:c,filterTo:f,filter:(m,y)=>m<c||y>f,add:u})}}return t}}const Rr=/x/.unicode!=null?"gu":"g",fm=new RegExp(`[\0-\b
|
|
9
9
|
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\uFEFF\uFFF9-\uFFFC]`,Rr),um={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",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Os=null;function dm(){var n;if(Os==null&&typeof document<"u"&&document.body){let e=document.body.style;Os=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Os||!1}const pn=R.define({combine(n){let e=ot(n,{render:null,specialChars:fm,addSpecialChars:null});return(e.replaceTabs=!dm())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Rr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Rr)),e}});function pm(n={}){return[pn.of(n),mm()]}let Ol=null;function mm(){return Ol||(Ol=se.fromClass(class{constructor(n){this.view=n,this.decorations=B.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(pn)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new cm({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=ue(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=Hi(o.text,l,i-o.from);return B.replace({widget:new xm((l-a%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[r]||(this.decorationCache[r]=B.replace({widget:new bm(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(pn);n.startState.facet(pn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const gm="\u2022";function ym(n){return n>=32?gm:n==10?"\u2424":String.fromCharCode(9216+n)}class bm extends lt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=ym(this.code),i=e.state.phrase("Control character")+" "+(um[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class xm extends lt{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function wm(){return vm}const km=B.line({class:"cm-activeLine"}),vm=se.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){if(!i.empty)return B.none;let s=n.lineBlockAt(i.head);s.from>e&&(t.push(km.range(s.from)),e=s.from)}return B.set(t)}},{decorations:n=>n.decorations});class Sm extends lt{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}ignoreEvent(){return!1}}function Cm(n){return se.fromClass(class{constructor(e){this.view=e,this.placeholder=B.set([B.widget({widget:new Sm(n),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?B.none:this.placeholder}},{decorations:e=>e.decorations})}const Br=2e3;function Am(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Br||t.off>Br||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let h=n.doc.line(a);h.length<=l&&r.push(w.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let h=n.doc.line(a),c=cr(h.text,o,n.tabSize,!0);if(c>-1){let f=cr(h.text,l,n.tabSize);r.push(w.range(h.from+c,h.from+f))}}}return r}function Mm(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Dl(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>Br?-1:s==i.length?Mm(n,e.clientX):Hi(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Om(n,e){let t=Dl(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=Dl(n,s);if(!l)return i;let a=Am(n.state,t,l);return a.length?o?w.create(a.concat(i.ranges)):w.create(a):i}}:null}function Dm(n){let e=(n==null?void 0:n.eventFilter)||(t=>t.altKey&&t.button==0);return D.mouseSelectionStyle.of((t,i)=>e(i)?Om(t,i):null)}const Tm={Alt:[18,n=>n.altKey],Control:[17,n=>n.ctrlKey],Shift:[16,n=>n.shiftKey],Meta:[91,n=>n.metaKey]},Pm={style:"cursor: crosshair"};function Rm(n={}){let[e,t]=Tm[n.key||"Alt"],i=se.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventHandlers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)}}});return[i,D.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?Pm:null})]}const Ds="-10000px";class Zh{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(s=>s),this.tooltipViews=this.tooltips.map(i)}update(e){let t=e.state.facet(this.facet),i=t.filter(r=>r);if(t===this.input){for(let r of this.tooltipViews)r.update&&r.update(e);return!1}let s=[];for(let r=0;r<i.length;r++){let o=i[r],l=-1;if(!!o){for(let a=0;a<this.tooltips.length;a++){let h=this.tooltips[a];h&&h.create==o.create&&(l=a)}if(l<0)s[r]=this.createTooltipView(o);else{let a=s[r]=this.tooltipViews[l];a.update&&a.update(e)}}}for(let r of this.tooltipViews)s.indexOf(r)<0&&r.dom.remove();return this.input=t,this.tooltips=i,this.tooltipViews=s,!0}}function Bm(){return{top:0,left:0,bottom:innerHeight,right:innerWidth}}const Ts=R.define({combine:n=>{var e,t,i;return{position:P.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Bm}}}),_h=se.fromClass(class{constructor(n){var e;this.view=n,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let t=n.state.facet(Ts);this.position=t.position,this.parent=t.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new Zh(n,to,i=>this.createTooltip(i)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(i=>{Date.now()>this.lastTransaction-50&&i.length>0&&i[i.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),(e=n.dom.ownerDocument.defaultView)===null||e===void 0||e.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Ts);if(i.position!=this.position){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Ds,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;(n=this.view.dom.ownerDocument.defaultView)===null||n===void 0||n.removeEventListener("resize",this.measureSoon);for(let{dom:t}of this.manager.tooltipViews)t.remove();(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect();return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Ts).tooltipSpace(this.view)}}writeMeasure(n){let{editor:e,space:t}=n,i=[];for(let s=0;s<this.manager.tooltips.length;s++){let r=this.manager.tooltips[s],o=this.manager.tooltipViews[s],{dom:l}=o,a=n.pos[s],h=n.size[s];if(!a||a.bottom<=Math.max(e.top,t.top)||a.top>=Math.min(e.bottom,t.bottom)||a.right<Math.max(e.left,t.left)-.1||a.left>Math.min(e.right,t.right)+.1){l.style.top=Ds;continue}let c=r.arrow?o.dom.querySelector(".cm-tooltip-arrow"):null,f=c?7:0,u=h.right-h.left,d=h.bottom-h.top,m=o.offset||Em,y=this.view.textDirection==ee.LTR,x=h.width>t.right-t.left?y?t.left:t.right-h.width:y?Math.min(a.left-(c?14:0)+m.x,t.right-u):Math.max(t.left,a.left-u+(c?14:0)-m.x),b=!!r.above;!r.strictSide&&(b?a.top-(h.bottom-h.top)-m.y<t.top:a.bottom+(h.bottom-h.top)+m.y>t.bottom)&&b==t.bottom-a.bottom>a.top-t.top&&(b=!b);let v=b?a.top-d-f-m.y:a.bottom+f+m.y,M=x+u;if(o.overlap!==!0)for(let S of i)S.left<M&&S.right>x&&S.top<v+d&&S.bottom>v&&(v=b?S.top-d-2-f:S.bottom+f+2);this.position=="absolute"?(l.style.top=v-n.parent.top+"px",l.style.left=x-n.parent.left+"px"):(l.style.top=v+"px",l.style.left=x+"px"),c&&(c.style.left=`${a.left+(y?m.x:-m.x)-(x+14-7)}px`),o.overlap!==!0&&i.push({left:x,top:v,right:M,bottom:v+d}),l.classList.toggle("cm-tooltip-above",b),l.classList.toggle("cm-tooltip-below",!b),o.positioned&&o.positioned()}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Ds}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),Lm=D.baseTheme({".cm-tooltip":{zIndex:100},"&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:`${7}px`,width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:`${7}px solid transparent`,borderRight:`${7}px solid transparent`},".cm-tooltip-above &":{bottom:`-${7}px`,"&:before":{borderTop:`${7}px solid #bbb`},"&:after":{borderTop:`${7}px solid #f5f5f5`,bottom:"1px"}},".cm-tooltip-below &":{top:`-${7}px`,"&:before":{borderBottom:`${7}px solid #bbb`},"&:after":{borderBottom:`${7}px solid #f5f5f5`,top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Em={x:0,y:0},to=R.define({enables:[_h,Lm]}),Rn=R.define();class io{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Zh(e,Rn,t=>this.createHostedView(t))}static create(e){return new io(e)}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned()}update(e){this.manager.update(e)}}const Im=to.compute([Rn],n=>{let e=n.facet(Rn).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.filter(t=>t.end!=null).map(t=>t.end)),create:io.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Nm{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,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)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{lastMove:e}=this,t=this.view.contentDOM.contains(e.target)?this.view.posAtCoords(e):null;if(t==null)return;let i=this.view.coordsAtPos(t);if(i==null||e.y<i.top||e.y>i.bottom||e.x<i.left-this.view.defaultCharacterWidth||e.x>i.right+this.view.defaultCharacterWidth)return;let s=this.view.bidiSpans(this.view.state.doc.lineAt(t)).find(l=>l.from<=t&&l.to>=t),r=s&&s.dir==ee.RTL?-1:1,o=this.source(this.view,t,e.x<i.left?-r:r);if(o!=null&&o.then){let l=this.pending={pos:t};o.then(a=>{this.pending==l&&(this.pending=null,a&&this.view.dispatch({effects:this.setHover.of(a)}))},a=>Ie(this.view.state,a,"hover tooltip"))}else o&&this.view.dispatch({effects:this.setHover.of(o)})}mousemove(e){var t;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 i=this.active;if(i&&!Fm(this.lastMove.target)||this.pending){let{pos:s}=i||this.pending,r=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==r?this.view.posAtCoords(this.lastMove)!=s:!Vm(this.view,s,r,e.clientX,e.clientY,6))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function Fm(n){for(let e=n;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip"))return!0;return!1}function Vm(n,e,t,i,s,r){let o=document.createRange(),l=n.domAtPos(e),a=n.domAtPos(t);o.setEnd(a.node,a.offset),o.setStart(l.node,l.offset);let h=o.getClientRects();o.detach();for(let c=0;c<h.length;c++){let f=h[c];if(Math.max(f.top-s,s-f.bottom,f.left-i,i-f.right)<=r)return!0}return!1}function Wm(n,e={}){let t=N.define(),i=ge.define({create(){return null},update(s,r){if(s&&(e.hideOnChange&&(r.docChanged||r.selection)||e.hideOn&&e.hideOn(r,s)))return null;if(s&&r.docChanged){let o=r.changes.mapPos(s.pos,-1,Se.TrackDel);if(o==null)return null;let l=Object.assign(Object.create(null),s);l.pos=o,s.end!=null&&(l.end=r.changes.mapPos(s.end)),s=l}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(zm)&&(s=null);return s},provide:s=>Rn.from(s)});return[i,se.define(s=>new Nm(s,n,i,t,e.hoverTime||300)),Im]}function Hm(n,e){let t=n.plugin(_h);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const zm=N.define(),Tl=R.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Li(n,e){let t=n.plugin(ec),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const ec=se.fromClass(class{constructor(n){this.input=n.state.facet(Ei),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Tl);this.top=new _i(n,!0,e.topContainer),this.bottom=new _i(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(Tl);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new _i(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new _i(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Ei);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),s.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>D.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class _i{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Pl(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Pl(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 Pl(n){let e=n.nextSibling;return n.remove(),e}const Ei=R.define({enables:ec});class rt extends Nt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}rt.prototype.elementClass="";rt.prototype.toDOM=void 0;rt.prototype.mapMode=Se.TrackBefore;rt.prototype.startSide=rt.prototype.endSide=-1;rt.prototype.point=!0;const mn=R.define(),$m={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>G.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Ci=R.define();function jm(n){return[tc(),Ci.of(Object.assign(Object.assign({},$m),n))]}const Lr=R.define({combine:n=>n.some(e=>e)});function tc(n){let e=[qm];return n&&n.fixed===!1&&e.push(Lr.of(!0)),e}const qm=se.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=n.state.facet(Ci).map(e=>new Bl(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(Lr),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(Lr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=G.iter(this.view.state.facet(mn),this.view.viewport.from),i=[],s=this.gutters.map(r=>new Um(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks){let o;if(Array.isArray(r.type)){for(let l of r.type)if(l.type==K.Text){o=l;break}}else o=r.type==K.Text?r:void 0;if(!!o){i.length&&(i=[]),ic(t,i,r.from);for(let l of s)l.line(this.view,o,i)}}for(let r of s)r.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(Ci),t=n.state.facet(Ci),i=n.docChanged||n.heightChanged||n.viewportChanged||!G.eq(n.startState.facet(mn),n.state.facet(mn),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new Bl(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>D.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==ee.LTR?{left:t.dom.offsetWidth}:{right:t.dom.offsetWidth}})});function Rl(n){return Array.isArray(n)?n:[n]}function ic(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class Um{constructor(e,t,i){this.gutter=e,this.height=i,this.localMarkers=[],this.i=0,this.cursor=G.iter(e.markers,t.from)}line(e,t,i){this.localMarkers.length&&(this.localMarkers=[]),ic(this.cursor,this.localMarkers,t.from);let s=i.length?this.localMarkers.concat(i):this.localMarkers,r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;if(s.length==0&&!o.config.renderEmptyElements)return;let l=t.top-this.height;if(this.i==o.elements.length){let a=new nc(e,t.height,l,s);o.elements.push(a),o.dom.appendChild(a.dom)}else o.elements[this.i].update(e,t.height,l,s);this.height=t.bottom,this.i++}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Bl{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 i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=e.lineBlockAtHeight(s.clientY-e.documentTop);t.domEventHandlers[i](e,r,s)&&s.preventDefault()});this.markers=Rl(t.markers(e)),t.initialSpacer&&(this.spacer=new nc(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=Rl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!G.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class nc{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.dom.style.height=(this.height=t)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Gm(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(s);let f=s.nextSibling;s.remove(),s=f}}if(!a)break;a.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function Gm(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const Km=R.define(),Ut=R.define({combine(n){return ot(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let s in t){let r=i[s],o=t[s];i[s]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class Ps extends rt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Rs(n,e){return n.state.facet(Ut).formatNumber(e,n.state)}const Qm=Ci.compute([Ut],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Km)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new Ps(Rs(e,e.state.doc.lineAt(t.from).number))},lineMarkerChange:e=>e.startState.facet(Ut)!=e.state.facet(Ut),initialSpacer(e){return new Ps(Rs(e,Ll(e.state.doc.lines)))},updateSpacer(e,t){let i=Rs(t.view,Ll(t.view.state.doc.lines));return i==e.number?e:new Ps(i)},domEventHandlers:n.facet(Ut).domEventHandlers}));function Jm(n={}){return[Ut.of(n),tc(),Qm]}function Ll(n){let e=9;for(;e<n;)e=e*10+9;return e}const Ym=new class extends rt{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Xm=mn.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges)if(i.empty){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(Ym.range(s)))}return G.of(e)});function Zm(){return Xm}const sc=1024;let _m=0;class Bs{constructor(e,t){this.from=e,this.to=t}}class V{constructor(e={}){this.id=_m++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Te.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}V.closedBy=new V({deserialize:n=>n.split(" ")});V.openedBy=new V({deserialize:n=>n.split(" ")});V.group=new V({deserialize:n=>n.split(" ")});V.contextHash=new V({perNode:!0});V.lookAhead=new V({perNode:!0});V.mounted=new V({perNode:!0});const eg=Object.create(null);class Te{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):eg,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new Te(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(V.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(V.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}Te.none=new Te("",Object.create(null),0,8);class no{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 i of this.types){let s=null;for(let r of e){let o=r(i);o&&(s||(s=Object.assign({},i.props)),s[o[0].id]=o[1])}t.push(s?new Te(i.name,s,i.id,i.flags):i)}return new no(t)}}const en=new WeakMap,El=new WeakMap;var pe;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(pe||(pe={}));class le{constructor(e,t,i,s,r){if(this.type=e,this.children=t,this.positions=i,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=this.prop(V.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let s=i.toString();s&&(t&&(t+=","),t+=s)}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 En(this.topNode,e)}cursorAt(e,t=0,i=0){let s=en.get(this)||this.topNode,r=new En(s);return r.moveTo(e,t),en.set(this,r._tree),r}get topNode(){return new st(this,0,0,null)}resolve(e,t=0){let i=ti(en.get(this)||this.topNode,e,t,!1);return en.set(this,i),i}resolveInner(e,t=0){let i=ti(El.get(this)||this.topNode,e,t,!0);return El.set(this,i),i}iterate(e){let{enter:t,leave:i,from:s=0,to:r=this.length}=e;for(let o=this.cursor((e.mode||0)|pe.IncludeAnonymous);;){let l=!1;if(o.from<=r&&o.to>=s&&(o.type.isAnonymous||t(o)!==!1)){if(o.firstChild())continue;l=!0}for(;l&&i&&!o.type.isAnonymous&&i(o),!o.nextSibling();){if(!o.parent())return;l=!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:oo(Te.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new le(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new le(Te.none,t,i,s)))}static build(e){return ig(e)}}le.empty=new le(Te.none,[],[],0);class so{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 so(this.buffer,this.index)}}class Ht{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Te.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],i=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,i==e)return r;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,i,s,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(rc(r,s,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i,s){let r=this.buffer,o=new Uint16Array(t-e);for(let l=e,a=0;l<t;)o[a++]=r[l++],o[a++]=r[l++]-i,o[a++]=r[l++]-i,o[a++]=r[l++]-e;return new Ht(o,s-i,this.set)}}function rc(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function oc(n,e){let t=n.childBefore(e);for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(n=t,t=i.prevSibling):t=i}return n}function ti(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof st&&n.index<0?null:n.parent;if(!o)return n;n=o}let r=i?0:pe.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof st&&o.index<0&&((s=l.enter(e,t,r))===null||s===void 0?void 0:s.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,r);if(!o)return n;n=o}}class st{constructor(e,t,i,s){this._tree=e,this.from=t,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(!!rc(s,i,f,f+c.length)){if(c instanceof Ht){if(r&pe.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,s);if(u>-1)return new yt(new tg(o,c,e,f),null,u)}else if(r&pe.IncludeAnonymous||!c.type.isAnonymous||ro(c)){let u;if(!(r&pe.IgnoreMounts)&&c.props&&(u=c.prop(V.mounted))&&!u.overlay)return new st(u.tree,f,e,o);let d=new st(c,f,e,o);return r&pe.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?c.children.length-1:0,t,i,s)}}}if(r&pe.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let s;if(!(i&pe.IgnoreOverlays)&&(s=this._tree.prop(V.mounted))&&s.overlay){let r=e-this.from;for(let{from:o,to:l}of s.overlay)if((t>0?o<=r:o<r)&&(t<0?l>=r:l>r))return new st(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new En(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return ti(this,e,t,!1)}resolveInner(e,t=0){return ti(this,e,t,!0)}enterUnfinishedNodesBefore(e){return oc(this,e)}getChild(e,t=null,i=null){let s=Bn(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return Bn(this,e,t,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Ln(this,e)}}function Bn(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(;!s.type.is(t);)if(!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function Ln(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class tg{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class yt{constructor(e,t,i){this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}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]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new yt(this.context,this,r)}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)}enter(e,t,i=0){if(i&pe.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new yt(this.context,this,r)}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 yt(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 yt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new En(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1],l=i.buffer[this.index+2];e.push(i.slice(s,r,o,l)),t.push(0)}return new le(this.type,e,t,this.to-this.from)}resolve(e,t=0){return ti(this,e,t,!1)}resolveInner(e,t=0){return ti(this,e,t,!0)}enterUnfinishedNodesBefore(e){return oc(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,i=null){let s=Bn(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return Bn(this,e,t,i)}get node(){return this}matchContext(e){return Ln(this,e)}}class En{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof st)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof st?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}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,i=this.mode){return this.buffer?i&pe.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&pe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&pe.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:i}=s)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&pe.IncludeAnonymous||l instanceof Ht||!l.type.isAnonymous||ro(l))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,i=0;if(e&&e.context==this.buffer){e:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}}for(let s=i;s<this.stack.length;s++)t=new yt(this.buffer,t,this.stack[s]);return this.bufferNode=new yt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;s&&t&&t(this),s=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,s=!0}}}matchContext(e){if(!this.buffer)return Ln(this.node,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return Ln(this.node,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function ro(n){return n.children.some(e=>e instanceof Ht||!e.type.isAnonymous||ro(e))}function ig(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=sc,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new so(t,t.length):t,a=i.types,h=0,c=0;function f(S,C,k,O,F){let{id:T,start:E,end:W,size:q}=l,J=c;for(;q<0;)if(l.next(),q==-1){let Z=r[T];k.push(Z),O.push(E-S);return}else if(q==-3){h=T;return}else if(q==-4){c=T;return}else throw new RangeError(`Unrecognized record size: ${q}`);let ye=a[T],oe,$,te=E-S;if(W-E<=s&&($=y(l.pos-C,F))){let Z=new Uint16Array($.size-$.skip),be=l.pos-$.size,tt=Z.length;for(;l.pos>be;)tt=x($.start,Z,tt);oe=new Ht(Z,W-$.start,i),te=$.start-S}else{let Z=l.pos-q;l.next();let be=[],tt=[],Ot=T>=o?T:-1,zt=0,qi=W;for(;l.pos>Z;)Ot>=0&&l.id==Ot&&l.size>=0?(l.end<=qi-s&&(d(be,tt,E,zt,l.end,qi,Ot,J),zt=be.length,qi=l.end),l.next()):f(E,Z,be,tt,Ot);if(Ot>=0&&zt>0&&zt<be.length&&d(be,tt,E,zt,E,qi,Ot,J),be.reverse(),tt.reverse(),Ot>-1&&zt>0){let Co=u(ye);oe=oo(ye,be,tt,0,be.length,0,W-E,Co,Co)}else oe=m(ye,be,tt,W-E,J-W)}k.push(oe),O.push(te)}function u(S){return(C,k,O)=>{let F=0,T=C.length-1,E,W;if(T>=0&&(E=C[T])instanceof le){if(!T&&E.type==S&&E.length==O)return E;(W=E.prop(V.lookAhead))&&(F=k[T]+E.length+W)}return m(S,C,k,O,F)}}function d(S,C,k,O,F,T,E,W){let q=[],J=[];for(;S.length>O;)q.push(S.pop()),J.push(C.pop()+k-F);S.push(m(i.types[E],q,J,T-F,W-T)),C.push(F-k)}function m(S,C,k,O,F=0,T){if(h){let E=[V.contextHash,h];T=T?[E].concat(T):[E]}if(F>25){let E=[V.lookAhead,F];T=T?[E].concat(T):[E]}return new le(S,C,k,O,T)}function y(S,C){let k=l.fork(),O=0,F=0,T=0,E=k.end-s,W={size:0,start:0,skip:0};e:for(let q=k.pos-S;k.pos>q;){let J=k.size;if(k.id==C&&J>=0){W.size=O,W.start=F,W.skip=T,T+=4,O+=4,k.next();continue}let ye=k.pos-J;if(J<0||ye<q||k.start<E)break;let oe=k.id>=o?4:0,$=k.start;for(k.next();k.pos>ye;){if(k.size<0)if(k.size==-3)oe+=4;else break e;else k.id>=o&&(oe+=4);k.next()}F=$,O+=J,T+=oe}return(C<0||O==S)&&(W.size=O,W.start=F,W.skip=T),W.size>4?W:void 0}function x(S,C,k){let{id:O,start:F,end:T,size:E}=l;if(l.next(),E>=0&&O<o){let W=k;if(E>4){let q=l.pos-(E-4);for(;l.pos>q;)k=x(S,C,k)}C[--k]=W,C[--k]=T-S,C[--k]=F-S,C[--k]=O}else E==-3?h=O:E==-4&&(c=O);return k}let b=[],v=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,b,v,-1);let M=(e=n.length)!==null&&e!==void 0?e:b.length?v[0]+b[0].length:0;return new le(a[n.topID],b.reverse(),v.reverse(),M)}const Il=new WeakMap;function gn(n,e){if(!n.isAnonymous||e instanceof Ht||e.type!=n)return 1;let t=Il.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof le)){t=1;break}t+=gn(n,i)}Il.set(e,t)}return t}function oo(n,e,t,i,s,r,o,l,a){let h=0;for(let m=i;m<s;m++)h+=gn(n,e[m]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(m,y,x,b,v){for(let M=x;M<b;){let S=M,C=y[M],k=gn(n,m[M]);for(M++;M<b;M++){let O=gn(n,m[M]);if(k+O>=c)break;k+=O}if(M==S+1){if(k>c){let O=m[S];d(O.children,O.positions,0,O.children.length,y[S]+v);continue}f.push(m[S])}else{let O=y[M-1]+m[M-1].length-C;f.push(oo(n,m,y,S,M,C,O,null,a))}u.push(C+v-r)}}return d(e,t,i,s,0),(l||a)(f,u,o)}class It{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new It(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,m=Math.min(u.to,f)-h;u=d>=m?null:new It(d,m,u.tree,u.offset+h,l>0,!!c)}if(u&&s.push(u),o.to>f)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return s}}class lc{startParse(e,t,i){return typeof e=="string"&&(e=new ng(e)),i=i?i.length?i.map(s=>new Bs(s.from,s.to)):[new Bs(0,0)]:[new Bs(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}}class ng{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 V({perNode:!0});let sg=0;class Qe{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=sg++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new Qe([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new In;return t=>t.modified.indexOf(e)>-1?t:In.get(t.base||t,t.modified.concat(e).sort((i,s)=>i.id-s.id))}}let rg=0;class In{constructor(){this.instances=[],this.id=rg++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&og(t,l.modified));if(i)return i;let s=[],r=new Qe(s,e,t);for(let l of t)l.instances.push(r);let o=ac(t);for(let l of e.set)for(let a of o)s.push(In.get(l,a));return r}}function og(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function ac(n){let e=[n];for(let t=0;t<n.length;t++)for(let i of ac(n.slice(0,t).concat(n.slice(t+1))))e.push(i);return e}function hc(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let f=0;;){if(l=="..."&&f>0&&f+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==s.length)break;let d=s[f++];if(f==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let c=new lg(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return cc.add(e)}const cc=new V;class lg{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}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 fc(n,e){let t=Object.create(null);for(let r of n)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:i,all:s=null}=e||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function ag(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function hg(n,e,t,i=0,s=n.length){let r=new cg(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class cg{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,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,i,s,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,c=o.prop(cc),f=!1;for(;c;){if(!c.context||e.matchContext(c.context)){let d=ag(r,c.tags);d&&(h&&(h+=" "),h+=d,c.mode==1?s+=(s?" ":"")+d:c.mode==0&&(f=!0));break}c=c.next}if(this.startSpan(e.from,h),f)return;let u=e.tree&&e.tree.prop(V.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),m=this.highlighters.filter(x=>!x.scope||x.scope(u.tree.type)),y=e.firstChild();for(let x=0,b=l;;x++){let v=x<u.overlay.length?u.overlay[x]:null,M=v?v.from+l:a,S=Math.max(t,b),C=Math.min(i,M);if(S<C&&y)for(;e.from<C&&(this.highlightRange(e,S,C,s,r),this.startSpan(Math.min(i,e.to),h),!(e.to>=M||!e.nextSibling())););if(!v||M>i)break;b=v.to+l,b>t&&(this.highlightRange(d.cursor(),Math.max(t,v.from+l),Math.min(i,b),s,m),this.startSpan(b,h))}y&&e.parent()}else if(e.firstChild()){do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}const A=Qe.define,tn=A(),ct=A(),Nl=A(ct),Fl=A(ct),ft=A(),nn=A(ft),Ls=A(ft),Ke=A(),Dt=A(Ke),Ue=A(),Ge=A(),Er=A(),ui=A(Er),sn=A(),g={comment:tn,lineComment:A(tn),blockComment:A(tn),docComment:A(tn),name:ct,variableName:A(ct),typeName:Nl,tagName:A(Nl),propertyName:Fl,attributeName:A(Fl),className:A(ct),labelName:A(ct),namespace:A(ct),macroName:A(ct),literal:ft,string:nn,docString:A(nn),character:A(nn),attributeValue:A(nn),number:Ls,integer:A(Ls),float:A(Ls),bool:A(ft),regexp:A(ft),escape:A(ft),color:A(ft),url:A(ft),keyword:Ue,self:A(Ue),null:A(Ue),atom:A(Ue),unit:A(Ue),modifier:A(Ue),operatorKeyword:A(Ue),controlKeyword:A(Ue),definitionKeyword:A(Ue),moduleKeyword:A(Ue),operator:Ge,derefOperator:A(Ge),arithmeticOperator:A(Ge),logicOperator:A(Ge),bitwiseOperator:A(Ge),compareOperator:A(Ge),updateOperator:A(Ge),definitionOperator:A(Ge),typeOperator:A(Ge),controlOperator:A(Ge),punctuation:Er,separator:A(Er),bracket:ui,angleBracket:A(ui),squareBracket:A(ui),paren:A(ui),brace:A(ui),content:Ke,heading:Dt,heading1:A(Dt),heading2:A(Dt),heading3:A(Dt),heading4:A(Dt),heading5:A(Dt),heading6:A(Dt),contentSeparator:A(Ke),list:A(Ke),quote:A(Ke),emphasis:A(Ke),strong:A(Ke),link:A(Ke),monospace:A(Ke),strikethrough:A(Ke),inserted:A(),deleted:A(),changed:A(),invalid:A(),meta:sn,documentMeta:A(sn),annotation:A(sn),processingInstruction:A(sn),definition:Qe.defineModifier(),constant:Qe.defineModifier(),function:Qe.defineModifier(),standard:Qe.defineModifier(),local:Qe.defineModifier(),special:Qe.defineModifier()};fc([{tag:g.link,class:"tok-link"},{tag:g.heading,class:"tok-heading"},{tag:g.emphasis,class:"tok-emphasis"},{tag:g.strong,class:"tok-strong"},{tag:g.keyword,class:"tok-keyword"},{tag:g.atom,class:"tok-atom"},{tag:g.bool,class:"tok-bool"},{tag:g.url,class:"tok-url"},{tag:g.labelName,class:"tok-labelName"},{tag:g.inserted,class:"tok-inserted"},{tag:g.deleted,class:"tok-deleted"},{tag:g.literal,class:"tok-literal"},{tag:g.string,class:"tok-string"},{tag:g.number,class:"tok-number"},{tag:[g.regexp,g.escape,g.special(g.string)],class:"tok-string2"},{tag:g.variableName,class:"tok-variableName"},{tag:g.local(g.variableName),class:"tok-variableName tok-local"},{tag:g.definition(g.variableName),class:"tok-variableName tok-definition"},{tag:g.special(g.variableName),class:"tok-variableName2"},{tag:g.definition(g.propertyName),class:"tok-propertyName tok-definition"},{tag:g.typeName,class:"tok-typeName"},{tag:g.namespace,class:"tok-namespace"},{tag:g.className,class:"tok-className"},{tag:g.macroName,class:"tok-macroName"},{tag:g.propertyName,class:"tok-propertyName"},{tag:g.operator,class:"tok-operator"},{tag:g.comment,class:"tok-comment"},{tag:g.meta,class:"tok-meta"},{tag:g.invalid,class:"tok-invalid"},{tag:g.punctuation,class:"tok-punctuation"}]);var Es;const Ii=new V;function fg(n){return R.define({combine:n?e=>e.concat(n):void 0})}class ze{constructor(e,t,i=[]){this.data=e,H.prototype.hasOwnProperty("tree")||Object.defineProperty(H.prototype,"tree",{get(){return we(this)}}),this.parser=t,this.extension=[Ct.of(this),H.languageData.of((s,r,o)=>s.facet(Vl(s,r,o)))].concat(i)}isActiveAt(e,t,i=-1){return Vl(e,t,i)==this.data}findRegions(e){let t=e.facet(Ct);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Ii)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(V.mounted);if(l){if(l.tree.prop(Ii)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof le&&s(h,r.positions[a]+o)}};return s(we(e),0),i}get allowsNesting(){return!0}}ze.setState=N.define();function Vl(n,e,t){let i=n.facet(Ct);if(!i)return null;let s=i.data;if(i.allowsNesting)for(let r=we(n).topNode;r;r=r.enter(e,t,pe.ExcludeBuffers))s=r.type.prop(Ii)||s;return s}class Nn extends ze{constructor(e,t){super(e,t),this.parser=t}static define(e){let t=fg(e.languageData);return new Nn(t,e.parser.configure({props:[Ii.add(i=>i.isTop?t:void 0)]}))}configure(e){return new Nn(this.data,this.parser.configure(e))}get allowsNesting(){return this.parser.hasWrappers()}}function we(n){let e=n.field(ze.state,!1);return e?e.tree:le.empty}class ug{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}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 i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let di=null;class Fn{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Fn(e,t,[],le.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ug(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=le.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(It.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(It.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=di;di=this;try{return e()}finally{di=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Wl(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=It.applyChanges(i,a),s=le.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new Fn(this.parser,t,i,s,r,o,l,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 i=0;i<this.skipped.length;i++){let{from:s,to:r}=this.skipped[i];s<e.to&&r>e.from&&(this.fragments=Wl(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends lc{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=di;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new le(Te.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return di}}function Wl(n,e,t){return It.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ii{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),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ii(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Fn.create(e.facet(Ct).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ii(i)}}ze.state=ge.define({create:ii.init,update(n,e){for(let t of e.effects)if(t.is(ze.setState))return t.value;return e.startState.facet(Ct)!=e.state.facet(Ct)?ii.init(e.state):n.apply(e)}});let uc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(uc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Is=typeof navigator<"u"&&((Es=navigator.scheduling)===null||Es===void 0?void 0:Es.isInputPending)?()=>navigator.scheduling.isInputPending():null,dg=se.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(ze.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(ze.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=uc(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:i,viewport:{to:s}}=this.view,r=i.field(ze.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Is?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work(()=>Is&&Is()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:ze.setState.of(new ii(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ie(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ct=R.define({combine(n){return n.length?n[0]:null},enables:[ze.state,dg]});class pg{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const mg=R.define(),rs=R.define({combine:n=>{if(!n.length)return" ";if(!/^(?: +|\t+)$/.test(n[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return n[0]}});function Vn(n){let e=n.facet(rs);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Ni(n,e){let t="",i=n.tabSize;if(n.facet(rs).charCodeAt(0)==9)for(;e>=i;)t+=" ",e-=i;for(let s=0;s<e;s++)t+=" ";return t}function lo(n,e){n instanceof H&&(n=new os(n));for(let i of n.state.facet(mg)){let s=i(n,e);if(s!=null)return s}let t=we(n.state);return t?gg(n,t,e):null}class os{constructor(e,t={}){this.state=e,this.options=t,this.unit=Vn(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(e,t);return i.slice(e-s,Math.min(i.length,e+100-s))}column(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.countColumn(i,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Hi(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const dc=new V;function gg(n,e,t){return pc(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,n)}function yg(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function bg(n){let e=n.type.prop(dc);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(V.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>vg(o,!0,1,void 0,r&&!yg(o)?s.from:void 0)}return n.parent==null?xg:null}function pc(n,e,t){for(;n;n=n.parent){let i=bg(n);if(i)return i(ao.create(t,e,n))}return null}function xg(){return 0}class ao extends os{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.node=i}static create(e,t,i){return new ao(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let t=this.node.resolve(e.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(wg(t,this.node))break;e=this.state.doc.lineAt(t.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?pc(e,this.pos,this.base):0}}function wg(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function kg(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.from<o?t:null;l=a.to}}function vg(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?kg(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}function Hl({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Sg=200;function Cg(){return H.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+Sg)return n;let r=t.sliceString(s.from,i);if(!e.some(h=>h.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=lo(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=Ni(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const Ag=R.define(),mc=new V;function Mg(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function Og(n,e,t){let i=we(n);if(i.length<t)return null;let s=i.resolveInner(t),r=null;for(let o=s;o;o=o.parent){if(o.to<=t||o.from>t)continue;if(r&&o.from<e)break;let l=o.type.prop(mc);if(l&&(o.to<i.length-50||i.length==n.doc.length||!Dg(o))){let a=l(o,n);a&&a.from<=t&&a.from>=e&&a.to>t&&(r=a)}}return r}function Dg(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Wn(n,e,t){for(let i of n.facet(Ag)){let s=i(n,e,t);if(s)return s}return Og(n,e,t)}function gc(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const ls=N.define({map:gc}),$i=N.define({map:gc});function yc(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Vt=ge.define({create(){return B.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)t.is(ls)&&!Tg(n,t.value.from,t.value.to)?n=n.update({add:[zl.range(t.value.from,t.value.to)]}):t.is($i)&&(n=n.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(s,r)=>{s<i&&r>i&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(s,r)=>r<=i||s>=i}))}return n},provide:n=>D.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],s=n[t++];if(typeof i!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(zl.range(i,s))}return B.set(e,!0)}});function Hn(n,e,t){var i;let s=null;return(i=n.field(Vt,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Tg(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function bc(n,e){return n.field(Vt,!1)?e:e.concat(N.appendConfig.of(kc()))}const Pg=n=>{for(let e of yc(n)){let t=Wn(n.state,e.from,e.to);if(t)return n.dispatch({effects:bc(n.state,[ls.of(t),xc(n,t)])}),!0}return!1},Rg=n=>{if(!n.state.field(Vt,!1))return!1;let e=[];for(let t of yc(n)){let i=Hn(n.state,t.from,t.to);i&&e.push($i.of(i),xc(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function xc(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return D.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const Bg=n=>{let{state:e}=n,t=[];for(let i=0;i<e.doc.length;){let s=n.lineBlockAt(i),r=Wn(e,s.from,s.to);r&&t.push(ls.of(r)),i=(r?n.lineBlockAt(r.to):s).to+1}return t.length&&n.dispatch({effects:bc(n.state,t)}),!!t.length},Lg=n=>{let e=n.state.field(Vt,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push($i.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},Eg=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Pg},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Rg},{key:"Ctrl-Alt-[",run:Bg},{key:"Ctrl-Alt-]",run:Lg}],Ig={placeholderDOM:null,placeholderText:"\u2026"},wc=R.define({combine(n){return ot(n,Ig)}});function kc(n){let e=[Vt,Vg];return n&&e.push(wc.of(n)),e}const zl=B.replace({widget:new class extends lt{toDOM(n){let{state:e}=n,t=e.facet(wc),i=r=>{let o=n.lineBlockAt(n.posAtDOM(r.target)),l=Hn(n.state,o.from,o.to);l&&n.dispatch({effects:$i.of(l)}),r.preventDefault()};if(t.placeholderDOM)return t.placeholderDOM(n,i);let s=document.createElement("span");return s.textContent=t.placeholderText,s.setAttribute("aria-label",e.phrase("folded code")),s.title=e.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}}}),Ng={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Ns extends rt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Fg(n={}){let e=Object.assign(Object.assign({},Ng),n),t=new Ns(e,!0),i=new Ns(e,!1),s=se.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Ct)!=o.state.facet(Ct)||o.startState.field(Vt,!1)!=o.state.field(Vt,!1)||we(o.startState)!=we(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new wt;for(let a of o.viewportLineBlocks){let h=Hn(o.state,a.from,a.to)?i:Wn(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[s,jm({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||G.empty},initialSpacer(){return new Ns(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=Hn(o.state,l.from,l.to);if(h)return o.dispatch({effects:$i.of(h)}),!0;let c=Wn(o.state,l.from,l.to);return c?(o.dispatch({effects:ls.of(c)}),!0):!1}})}),kc()]}const Vg=D.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 li{constructor(e,t){let i;function s(l){let a=kt.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof ze?l=>l.prop(Ii)==o.data:o?l=>l==o:void 0,this.style=fc(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new kt(i):null,this.themeType=t.themeType}static define(e,t){return new li(e,t||{})}}const Ir=R.define(),vc=R.define({combine(n){return n.length?[n[0]]:null}});function Fs(n){let e=n.facet(Ir);return e.length?e:n.facet(vc)}function ho(n,e){let t=[Hg],i;return n instanceof li&&(n.module&&t.push(D.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(vc.of(n)):i?t.push(Ir.computeN([D.darkTheme],s=>s.facet(D.darkTheme)==(i=="dark")?[n]:[])):t.push(Ir.of(n)),t}class Wg{constructor(e){this.markCache=Object.create(null),this.tree=we(e.state),this.decorations=this.buildDeco(e,Fs(e.state))}update(e){let t=we(e.state),i=Fs(e.state),s=i!=Fs(e.startState);t.length<e.view.viewport.to&&!s&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i))}buildDeco(e,t){if(!t||!this.tree.length)return B.none;let i=new wt;for(let{from:s,to:r}of e.visibleRanges)hg(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=B.mark({class:a})))},s,r);return i.finish()}}const Hg=oi.high(se.fromClass(Wg,{decorations:n=>n.decorations})),zg=li.define([{tag:g.meta,color:"#7a757a"},{tag:g.link,textDecoration:"underline"},{tag:g.heading,textDecoration:"underline",fontWeight:"bold"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strong,fontWeight:"bold"},{tag:g.strikethrough,textDecoration:"line-through"},{tag:g.keyword,color:"#708"},{tag:[g.atom,g.bool,g.url,g.contentSeparator,g.labelName],color:"#219"},{tag:[g.literal,g.inserted],color:"#164"},{tag:[g.string,g.deleted],color:"#a11"},{tag:[g.regexp,g.escape,g.special(g.string)],color:"#e40"},{tag:g.definition(g.variableName),color:"#00f"},{tag:g.local(g.variableName),color:"#30a"},{tag:[g.typeName,g.namespace],color:"#085"},{tag:g.className,color:"#167"},{tag:[g.special(g.variableName),g.macroName],color:"#256"},{tag:g.definition(g.propertyName),color:"#00c"},{tag:g.comment,color:"#940"},{tag:g.invalid,color:"#f00"}]),$g=D.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Sc=1e4,Cc="()[]{}",Ac=R.define({combine(n){return ot(n,{afterCursor:!0,brackets:Cc,maxScanDistance:Sc,renderMatch:Ug})}}),jg=B.mark({class:"cm-matchingBracket"}),qg=B.mark({class:"cm-nonmatchingBracket"});function Ug(n){let e=[],t=n.matched?jg:qg;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const Gg=ge.define({create(){return B.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Ac);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=Ye(e.state,s.head,-1,i)||s.head>0&&Ye(e.state,s.head-1,1,i)||i.afterCursor&&(Ye(e.state,s.head,1,i)||s.head<e.state.doc.length&&Ye(e.state,s.head+1,-1,i));r&&(t=t.concat(i.renderMatch(r,e.state)))}return B.set(t,!0)},provide:n=>D.decorations.from(n)}),Kg=[Gg,$g];function Qg(n={}){return[Ac.of(n),Kg]}function Nr(n,e,t){let i=n.prop(e<0?V.openedBy:V.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function Ye(n,e,t,i={}){let s=i.maxScanDistance||Sc,r=i.brackets||Cc,o=we(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=Nr(a.type,t,r);if(h&&a.from<a.to)return Jg(n,e,t,a,h,r)}return Yg(n,e,t,o,l.type,s,r)}function Jg(n,e,t,i,s,r){let o=i.parent,l={from:i.from,to:i.to},a=0,h=o==null?void 0:o.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(a==0&&s.indexOf(h.type.name)>-1&&h.from<h.to)return{start:l,end:{from:h.from,to:h.to},matched:!0};if(Nr(h.type,t,r))a++;else if(Nr(h.type,-t,r)&&(a--,a==0))return{start:l,end:h.from==h.to?void 0:{from:h.from,to:h.to},matched:!1}}while(t<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}function Yg(n,e,t,i,s,r,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let m=e+u*t;for(let y=t>0?0:d.length-1,x=t>0?d.length:-1;y!=x;y+=t){let b=o.indexOf(d[y]);if(!(b<0||i.resolveInner(m+y,1).type!=s))if(b%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:m+y,to:m+y+1},matched:b>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}const Xg=Object.create(null),$l=[Te.none],jl=[],Zg=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Zg[n]=_g(Xg,e);function Vs(n,e){jl.indexOf(n)>-1||(jl.push(n),console.warn(e))}function _g(n,e){let t=null;for(let r of e.split(".")){let o=n[r]||g[r];o?typeof o=="function"?t?t=o(t):Vs(r,`Modifier ${r} used at start of tag`):t?Vs(r,`Tag ${r} used as modifier`):t=o:Vs(r,`Unknown highlighting tag ${r}`)}if(!t)return 0;let i=e.replace(/ /g,"_"),s=Te.define({id:$l.length,name:i,props:[hc({[i]:t})]});return $l.push(s),s.id}const e0=n=>{let e=fo(n.state);return e.line?t0(n):e.block?n0(n):!1};function co(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const t0=co(o0,0),i0=co(Mc,0),n0=co((n,e)=>Mc(n,e,r0(e)),0);function fo(n,e=n.selection.main.head){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const pi=50;function s0(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-pi,i),o=n.sliceDoc(s,s+pi),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,f;s-i<=2*pi?c=f=n.sliceDoc(i,s):(c=n.sliceDoc(i,i+pi),f=n.sliceDoc(s-pi,s));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,m=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(m,m+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(m-1))?1:0}}:null}function r0(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to),r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from,to:s.to})}return e}function Mc(n,e,t=e.selection.ranges){let i=t.map(r=>fo(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>s0(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:h,close:c}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:r}}return null}function o0(n,e,t=e.selection.ranges){let i=[],s=-1;for(let{from:r,to:o}of t){let l=i.length,a=1e9;for(let h=r;h<=o;){let c=e.doc.lineAt(h);if(c.from>s&&(r==o||o>c.from)){s=c.from;let f=fo(e,h).line;if(!f)continue;let u=/^\s*/.exec(c.text)[0].length,d=u==c.length,m=c.text.slice(u,u+f.length)==f?u:-1;u<c.text.length&&u<a&&(a=u),i.push({line:c,comment:m,token:f,indent:u,empty:d,single:!1})}h=c.to+1}if(a<1e9)for(let h=l;h<i.length;h++)i[h].indent<i[h].line.text.length&&(i[h].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}const Fr=Wt.define(),l0=Wt.define(),a0=R.define(),Oc=R.define({combine(n){return ot(n,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}});function h0(n){let e=0;return n.iterChangedRanges((t,i)=>e=i),e}const Dc=ge.define({create(){return Xe.empty},update(n,e){let t=e.state.facet(Oc),i=e.annotation(Fr);if(i){let a=e.docChanged?w.single(h0(e.changes)):void 0,h=Oe.fromTransaction(e,a),c=i.side,f=c==0?n.undone:n.done;return h?f=zn(f,f.length,t.minDepth,h):f=Rc(f,e.startState.selection),new Xe(c==0?i.rest:f,c==0?f:i.rest)}let s=e.annotation(l0);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(he.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=Oe.fromTransaction(e),o=e.annotation(he.time),l=e.annotation(he.userEvent);return r?n=n.addChanges(r,o,l,t.newGroupDelay,t.minDepth):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Xe(n.done.map(Oe.fromJSON),n.undone.map(Oe.fromJSON))}});function c0(n={}){return[Dc,Oc.of(n),D.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Tc:e.inputType=="historyRedo"?Vr:null;return i?(e.preventDefault(),i(t)):!1}})]}function as(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(Dc,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const Tc=as(0,!1),Vr=as(1,!1),f0=as(0,!0),u0=as(1,!0);class Oe{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new Oe(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Oe(e.changes&&ae.fromJSON(e.changes),[],e.mapped&&Ze.fromJSON(e.mapped),e.startSelection&&w.fromJSON(e.startSelection),e.selectionsAfter.map(w.fromJSON))}static fromTransaction(e,t){let i=Ve;for(let s of e.startState.facet(a0)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new Oe(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ve)}static selection(e){return new Oe(void 0,Ve,void 0,void 0,e)}}function zn(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function d0(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function p0(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Pc(n,e){return n.length?e.length?n.concat(e):n:e}const Ve=[],m0=200;function Rc(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-m0));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),zn(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Oe.selection([e])]}function g0(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Ws(n,e){if(!n.length)return n;let t=n.length,i=Ve;for(;t;){let s=y0(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[Oe.selection(i)]:Ve}function y0(n,e,t){let i=Pc(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ve,t);if(!n.changes)return Oe.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new Oe(s,N.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const b0=/^(input\.type|delete)($|\.)/;class Xe{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new Xe(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||b0.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<s&&d0(l.changes,e.changes)||i=="input.type.compose")?o=zn(o,o.length-1,r,new Oe(e.changes.compose(l.changes),Pc(e.effects,l.effects),l.mapped,l.startSelection,Ve)):o=zn(o,o.length,r,e),new Xe(o,Ve,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ve;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&p0(r[r.length-1],e)?this:new Xe(Rc(this.done,e),this.undone,t,i)}addMapping(e){return new Xe(Ws(this.done,e),Ws(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1];if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Fr.of({side:e,rest:g0(s)}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let o=s.length==1?Ve:s.slice(0,s.length-1);return r.mapped&&(o=Ws(o,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Fr.of({side:e,rest:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Xe.empty=new Xe(Ve,Ve);const x0=[{key:"Mod-z",run:Tc,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Vr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Vr,preventDefault:!0},{key:"Mod-u",run:f0,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:u0,preventDefault:!0}];function ai(n,e){return w.create(n.ranges.map(e),n.mainIndex)}function et(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function je({state:n,dispatch:e},t){let i=ai(n.selection,t);return i.eq(n.selection)?!1:(e(et(n,i)),!0)}function hs(n,e){return w.cursor(e?n.to:n.from)}function Bc(n,e){return je(n,t=>t.empty?n.moveByChar(t,e):hs(t,e))}function ve(n){return n.textDirectionAt(n.state.selection.main.head)==ee.LTR}const Lc=n=>Bc(n,!ve(n)),Ec=n=>Bc(n,ve(n));function Ic(n,e){return je(n,t=>t.empty?n.moveByGroup(t,e):hs(t,e))}const w0=n=>Ic(n,!ve(n)),k0=n=>Ic(n,ve(n));function v0(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function cs(n,e,t){let i=we(n).resolveInner(e.head),s=t?V.closedBy:V.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;v0(n,h,s)?i=h:a=t?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=t?Ye(n,i.from,1):Ye(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,w.cursor(l,t?-1:1)}const S0=n=>je(n,e=>cs(n.state,e,!ve(n))),C0=n=>je(n,e=>cs(n.state,e,ve(n)));function Nc(n,e){return je(n,t=>{if(!t.empty)return hs(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const Fc=n=>Nc(n,!1),Vc=n=>Nc(n,!0);function Wc(n){return Math.max(n.defaultLineHeight,Math.min(n.dom.clientHeight,innerHeight)-5)}function Hc(n,e){let{state:t}=n,i=ai(t.selection,l=>l.empty?n.moveVertically(l,e,Wc(n)):hs(l,e));if(i.eq(t.selection))return!1;let s=n.coordsAtPos(t.selection.main.head),r=n.scrollDOM.getBoundingClientRect(),o;return s&&s.top>r.top&&s.bottom<r.bottom&&s.top-r.top<=n.scrollDOM.scrollHeight-n.scrollDOM.scrollTop-n.scrollDOM.clientHeight&&(o=D.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-r.top})),n.dispatch(et(t,i),{effects:o}),!0}const ql=n=>Hc(n,!1),Wr=n=>Hc(n,!0);function Mt(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=w.cursor(i.from+r))}return s}const A0=n=>je(n,e=>Mt(n,e,!0)),M0=n=>je(n,e=>Mt(n,e,!1)),O0=n=>je(n,e=>Mt(n,e,!ve(n))),D0=n=>je(n,e=>Mt(n,e,ve(n))),T0=n=>je(n,e=>w.cursor(n.lineBlockAt(e.head).from,1)),P0=n=>je(n,e=>w.cursor(n.lineBlockAt(e.head).to,-1));function R0(n,e,t){let i=!1,s=ai(n.selection,r=>{let o=Ye(n,r.head,-1)||Ye(n,r.head,1)||r.head>0&&Ye(n,r.head-1,1)||r.head<n.doc.length&&Ye(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return t?w.range(r.anchor,l):w.cursor(l)});return i?(e(et(n,s)),!0):!1}const B0=({state:n,dispatch:e})=>R0(n,e,!1);function We(n,e){let t=ai(n.state.selection,i=>{let s=e(i);return w.range(i.anchor,s.head,s.goalColumn)});return t.eq(n.state.selection)?!1:(n.dispatch(et(n.state,t)),!0)}function zc(n,e){return We(n,t=>n.moveByChar(t,e))}const $c=n=>zc(n,!ve(n)),jc=n=>zc(n,ve(n));function qc(n,e){return We(n,t=>n.moveByGroup(t,e))}const L0=n=>qc(n,!ve(n)),E0=n=>qc(n,ve(n)),I0=n=>We(n,e=>cs(n.state,e,!ve(n))),N0=n=>We(n,e=>cs(n.state,e,ve(n)));function Uc(n,e){return We(n,t=>n.moveVertically(t,e))}const Gc=n=>Uc(n,!1),Kc=n=>Uc(n,!0);function Qc(n,e){return We(n,t=>n.moveVertically(t,e,Wc(n)))}const Ul=n=>Qc(n,!1),Gl=n=>Qc(n,!0),F0=n=>We(n,e=>Mt(n,e,!0)),V0=n=>We(n,e=>Mt(n,e,!1)),W0=n=>We(n,e=>Mt(n,e,!ve(n))),H0=n=>We(n,e=>Mt(n,e,ve(n))),z0=n=>We(n,e=>w.cursor(n.lineBlockAt(e.head).from)),$0=n=>We(n,e=>w.cursor(n.lineBlockAt(e.head).to)),Kl=({state:n,dispatch:e})=>(e(et(n,{anchor:0})),!0),Ql=({state:n,dispatch:e})=>(e(et(n,{anchor:n.doc.length})),!0),Jl=({state:n,dispatch:e})=>(e(et(n,{anchor:n.selection.main.anchor,head:0})),!0),Yl=({state:n,dispatch:e})=>(e(et(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),j0=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),q0=({state:n,dispatch:e})=>{let t=us(n).map(({from:i,to:s})=>w.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:w.create(t),userEvent:"select"})),!0},U0=({state:n,dispatch:e})=>{let t=ai(n.selection,i=>{var s;let r=we(n).resolveInner(i.head,1);for(;!(r.from<i.from&&r.to>=i.to||r.to>i.to&&r.from<=i.from||!(!((s=r.parent)===null||s===void 0)&&s.parent));)r=r.parent;return w.range(r.to,r.from)});return e(et(n,t)),!0},G0=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=w.create([t.main]):t.main.empty||(i=w.create([w.cursor(t.main.head)])),i?(e(et(n,i)),!0):!1};function fs(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(o);a<o?(t="delete.backward",a=rn(n,a,!1)):a>o&&(t="delete.forward",a=rn(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=rn(n,o,!1),l=rn(n,o,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:w.cursor(o)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?D.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function rn(n,e,t){if(n instanceof D)for(let i of n.state.facet(D.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const Jc=(n,e)=>fs(n,t=>{let{state:i}=n,s=i.doc.lineAt(t),r,o;if(!e&&t>s.from&&t<s.from+200&&!/[^ \t]/.test(r=s.text.slice(0,t-s.from))){if(r[r.length-1]==" ")return t-1;let l=Hi(r,i.tabSize),a=l%Vn(i)||Vn(i);for(let h=0;h<a&&r[r.length-1-h]==" ";h++)t--;o=t}else o=Le(s.text,t-s.from,e,e)+s.from,o==t&&s.number!=(e?i.doc.lines:1)&&(o+=e?1:-1);return o}),Hr=n=>Jc(n,!1),Yc=n=>Jc(n,!0),Xc=(n,e)=>fs(n,t=>{let i=t,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=Le(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t)&&(l=c),i=a}return i}),Zc=n=>Xc(n,!1),K0=n=>Xc(n,!0),_c=n=>fs(n,e=>{let t=n.lineBlockAt(e).to;return e<t?t:Math.min(n.state.doc.length,e+1)}),Q0=n=>fs(n,e=>{let t=n.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)}),J0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:U.of(["",""])},range:w.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Y0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:Le(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:Le(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:w.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function us(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function ef(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of us(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(w.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(w.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:w.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const X0=({state:n,dispatch:e})=>ef(n,e,!1),Z0=({state:n,dispatch:e})=>ef(n,e,!0);function tf(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of us(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const _0=({state:n,dispatch:e})=>tf(n,e,!1),e1=({state:n,dispatch:e})=>tf(n,e,!0),t1=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(us(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),i=ai(e.selection,s=>n.moveVertically(s,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function i1(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=we(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(V.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from?{from:i.to,to:s.from}:null}const n1=nf(!1),s1=nf(!0);function nf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&i1(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new os(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=lo(h,r);for(c==null&&(c=/^\s*/.exec(e.doc.lineAt(r).text)[0].length);o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",Ni(e,c)];return a&&f.push(Ni(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:U.of(f)},range:w.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function uo(n,e){let t=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:w.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const r1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new os(n,{overrideIndentation:r=>{let o=t[r];return o==null?-1:o}}),s=uo(n,(r,o,l)=>{let a=lo(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=Ni(n,a);(h!=c||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:c}))});return s.changes.empty||e(n.update(s,{userEvent:"indent"})),!0},sf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(uo(n,(t,i)=>{i.push({from:t.from,insert:n.facet(rs)})}),{userEvent:"input.indent"})),!0),rf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(uo(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Hi(s,n.tabSize),o=0,l=Ni(n,Math.max(0,r-Vn(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),o1=[{key:"Ctrl-b",run:Lc,shift:$c,preventDefault:!0},{key:"Ctrl-f",run:Ec,shift:jc},{key:"Ctrl-p",run:Fc,shift:Gc},{key:"Ctrl-n",run:Vc,shift:Kc},{key:"Ctrl-a",run:T0,shift:z0},{key:"Ctrl-e",run:P0,shift:$0},{key:"Ctrl-d",run:Yc},{key:"Ctrl-h",run:Hr},{key:"Ctrl-k",run:_c},{key:"Ctrl-Alt-h",run:Zc},{key:"Ctrl-o",run:J0},{key:"Ctrl-t",run:Y0},{key:"Ctrl-v",run:Wr}],l1=[{key:"ArrowLeft",run:Lc,shift:$c,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:w0,shift:L0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:O0,shift:W0,preventDefault:!0},{key:"ArrowRight",run:Ec,shift:jc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:k0,shift:E0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:D0,shift:H0,preventDefault:!0},{key:"ArrowUp",run:Fc,shift:Gc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Kl,shift:Jl},{mac:"Ctrl-ArrowUp",run:ql,shift:Ul},{key:"ArrowDown",run:Vc,shift:Kc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ql,shift:Yl},{mac:"Ctrl-ArrowDown",run:Wr,shift:Gl},{key:"PageUp",run:ql,shift:Ul},{key:"PageDown",run:Wr,shift:Gl},{key:"Home",run:M0,shift:V0,preventDefault:!0},{key:"Mod-Home",run:Kl,shift:Jl},{key:"End",run:A0,shift:F0,preventDefault:!0},{key:"Mod-End",run:Ql,shift:Yl},{key:"Enter",run:n1},{key:"Mod-a",run:j0},{key:"Backspace",run:Hr,shift:Hr},{key:"Delete",run:Yc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Zc},{key:"Mod-Delete",mac:"Alt-Delete",run:K0},{mac:"Mod-Backspace",run:Q0},{mac:"Mod-Delete",run:_c}].concat(o1.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),a1=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:S0,shift:I0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:C0,shift:N0},{key:"Alt-ArrowUp",run:X0},{key:"Shift-Alt-ArrowUp",run:_0},{key:"Alt-ArrowDown",run:Z0},{key:"Shift-Alt-ArrowDown",run:e1},{key:"Escape",run:G0},{key:"Mod-Enter",run:s1},{key:"Alt-l",mac:"Ctrl-l",run:q0},{key:"Mod-i",run:U0,preventDefault:!0},{key:"Mod-[",run:rf},{key:"Mod-]",run:sf},{key:"Mod-Alt-\\",run:r1},{key:"Shift-Mod-k",run:t1},{key:"Shift-Mod-\\",run:B0},{key:"Mod-/",run:e0},{key:"Alt-A",run:i0}].concat(l1),h1={key:"Tab",run:sf,shift:rf};function Y(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e<arguments.length;e++)of(n,arguments[e]);return n}function of(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)of(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}const Xl=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class ni{constructor(e,t,i=0,s=e.length,r){this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?o=>r(Xl(o)):Xl,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 ue(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=Gr(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Re(e);let s=this.normalize(t);for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o);if(a)return this.value=a,this;if(r==s.length-1)break;o==i&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t){let i=null;for(let s=0;s<this.matches.length;s+=2){let r=this.matches[s],o=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?i={from:this.matches[s+1],to:t+1}:(this.matches[s]++,o=!0)),o||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:t+1}:this.matches.push(1,t)),i}}typeof Symbol<"u"&&(ni.prototype[Symbol.iterator]=function(){return this});const lf={from:-1,to:-1,match:/.*/.exec("")},po="gm"+(/x/.unicode==null?"":"u");class af{constructor(e,t,i,s=0,r=e.length){if(this.to=r,this.curLine="",this.done=!1,this.value=lf,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hf(e,t,i,s,r);this.re=new RegExp(t,po+(i!=null&&i.ignoreCase?"i":"")),this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=s,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 i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=s+(i==s?1:0),i==this.curLine.length&&this.nextLine(),i<s||i>this.value.to)return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Hs=new WeakMap;class Yt{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=Hs.get(e);if(!s||s.from>=i||s.to<=t){let l=new Yt(t,e.sliceString(t,i));return Hs.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),Hs.set(e,new Yt(o,r)),new Yt(t,r.slice(t-o,i-o))}}class hf{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=lf,this.matchPos=s,this.re=new RegExp(t,po+(i!=null&&i.ignoreCase?"i":"")),this.flat=Yt.get(e,s,this.chunkEnd(s+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&&this.flat.to<this.to&&t.index+t[0].length>this.flat.text.length-10&&(t=null),t){let i=this.flat.from+t.index,s=i+t[0].length;return this.value={from:i,to:s,match:t},this.matchPos=s+(i==s?1:0),this}else{if(this.flat.to==this.to)return this.done=!0,this;this.flat=Yt.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}}typeof Symbol<"u"&&(af.prototype[Symbol.iterator]=hf.prototype[Symbol.iterator]=function(){return this});function c1(n){try{return new RegExp(n,po),!0}catch{return!1}}function zr(n){let e=Y("input",{class:"cm-textfield",name:"line"}),t=Y("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:$n.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),i())},onsubmit:s=>{s.preventDefault(),i()}},Y("label",n.state.phrase("Go to line"),": ",e)," ",Y("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function i(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!s)return;let{state:r}=n,o=r.doc.lineAt(r.selection.main.head),[,l,a,h,c]=s,f=h?+h.slice(1):0,u=a?+a:o.number;if(a&&c){let m=u/100;l&&(m=m*(l=="-"?-1:1)+o.number/r.doc.lines),u=Math.round(r.doc.lines*m)}else a&&l&&(u=u*(l=="-"?-1:1)+o.number);let d=r.doc.line(Math.max(1,Math.min(r.doc.lines,u)));n.dispatch({effects:$n.of(!1),selection:w.cursor(d.from+Math.max(0,Math.min(f,d.length))),scrollIntoView:!0}),n.focus()}return{dom:t}}const $n=N.define(),Zl=ge.define({create(){return!0},update(n,e){for(let t of e.effects)t.is($n)&&(n=t.value);return n},provide:n=>Ei.from(n,e=>e?zr:null)}),f1=n=>{let e=Li(n,zr);if(!e){let t=[$n.of(!0)];n.state.field(Zl,!1)==null&&t.push(N.appendConfig.of([Zl,u1])),n.dispatch({effects:t}),e=Li(n,zr)}return e&&e.dom.querySelector("input").focus(),!0},u1=D.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),d1={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},cf=R.define({combine(n){return ot(n,d1,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function p1(n){let e=[x1,b1];return n&&e.push(cf.of(n)),e}const m1=B.mark({class:"cm-selectionMatch"}),g1=B.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function _l(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=Ce.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=Ce.Word)}function y1(n,e,t,i){return n(e.sliceDoc(t,t+1))==Ce.Word&&n(e.sliceDoc(i-1,i))==Ce.Word}const b1=se.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(cf),{state:t}=n,i=t.selection;if(i.ranges.length>1)return B.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return B.none;let a=t.wordAt(s.head);if(!a)return B.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return B.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(_l(o,t,s.from,s.to)&&y1(o,t,s.from,s.to)))return B.none}else if(r=t.sliceDoc(s.from,s.to).trim(),!r)return B.none}let l=[];for(let a of n.visibleRanges){let h=new ni(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||_l(o,t,c,f))&&(s.empty&&c<=s.from&&f>=s.to?l.push(g1.range(c,f)):(c>=s.to||f<=s.from)&&l.push(m1.range(c,f)),l.length>e.maxMatches))return B.none}}return B.set(l)}},{decorations:n=>n.decorations}),x1=D.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),w1=({state:n,dispatch:e})=>{let{selection:t}=n,i=w.create(t.ranges.map(s=>n.wordAt(s.head)||w.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function k1(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new ni(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new ni(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const v1=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return w1({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=k1(n,i);return s?(e(n.update({selection:n.selection.addRange(w.range(s.from,s.to),!1),effects:D.scrollIntoView(s.to)})),!0):!1},mo=R.define({combine(n){var e;return{top:n.reduce((t,i)=>t!=null?t:i.top,void 0)||!1,caseSensitive:n.reduce((t,i)=>t!=null?t:i.caseSensitive,void 0)||!1,createPanel:((e=n.find(t=>t.createPanel))===null||e===void 0?void 0:e.createPanel)||(t=>new B1(t))}}});class ff{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||c1(this.search)),this.unquoted=e.literal?this.search:this.search.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
10
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp}create(){return this.regexp?new C1(this):new S1(this)}getCursor(e,t=0,i=e.length){return this.regexp?qt(this,e,t,i):jt(this,e,t,i)}}class uf{constructor(e){this.spec=e}}function jt(n,e,t,i){return new ni(e,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase())}class S1 extends uf{constructor(e){super(e)}nextMatch(e,t,i){let s=jt(this.spec,e,i,e.length).nextOverlapping();return s.done&&(s=jt(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=jt(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.length)}getReplacement(e){return this.spec.replace}matchAll(e,t){let i=jt(this.spec,e,0,e.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=jt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function qt(n,e,t,i){return new af(e,n.search,n.caseSensitive?void 0:{ignoreCase:!0},t,i)}class C1 extends uf{nextMatch(e,t,i){let s=qt(this.spec,e,i,e.length).next();return s.done&&(s=qt(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=qt(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.length)}getReplacement(e){return this.spec.replace.replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=qt(this.spec,e,0,e.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=qt(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Fi=N.define(),go=N.define(),bt=ge.define({create(n){return new zs($r(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Fi)?n=new zs(t.value.create(),n.panel):t.is(go)&&(n=new zs(n.query,t.value?yo:null));return n},provide:n=>Ei.from(n,e=>e.panel)});class zs{constructor(e,t){this.query=e,this.panel=t}}const A1=B.mark({class:"cm-searchMatch"}),M1=B.mark({class:"cm-searchMatch cm-searchMatch-selected"}),O1=se.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(bt))}update(n){let e=n.state.field(bt);(e!=n.startState.field(bt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return B.none;let{view:t}=this,i=new wt;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state.doc,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?M1:A1)})}return i.finish()}},{decorations:n=>n.decorations});function ji(n){return e=>{let t=e.state.field(bt,!1);return t&&t.query.spec.valid?n(e,t):df(e)}}const jn=ji((n,{query:e})=>{let{from:t,to:i}=n.state.selection.main,s=e.nextMatch(n.state.doc,t,i);return!s||s.from==t&&s.to==i?!1:(n.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:bo(n,s),userEvent:"select.search"}),!0)}),qn=ji((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main,r=e.prevMatch(t.doc,i,s);return r?(n.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:bo(n,r),userEvent:"select.search"}),!0):!1}),D1=ji((n,{query:e})=>{let t=e.matchAll(n.state.doc,1e3);return!t||!t.length?!1:(n.dispatch({selection:w.create(t.map(i=>w.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),T1=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new ni(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(w.range(l.value.from,l.value.to))}return e(n.update({selection:w.create(r,o),userEvent:"select.search.matches"})),!0},ea=ji((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t.doc,i,i);if(!r)return!1;let o=[],l,a,h=[];if(r.from==i&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t.doc,r.from,r.to),h.push(D.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),r){let c=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l={anchor:r.from-c,head:r.to-c},h.push(bo(n,r))}return n.dispatch({changes:o,selection:l,scrollIntoView:!!l,effects:h,userEvent:"input.replace"}),!0}),P1=ji((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state.doc,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:D.announce.of(i),userEvent:"input.replace.all"}),!0});function yo(n){return n.state.facet(mo).createPanel(n)}function $r(n,e){var t;let i=n.selection.main,s=i.empty||i.to>i.from+100?"":n.sliceDoc(i.from,i.to),r=(t=e==null?void 0:e.caseSensitive)!==null&&t!==void 0?t:n.facet(mo).caseSensitive;return e&&!s?e:new ff({search:s.replace(/\n/g,"\\n"),caseSensitive:r})}const df=n=>{let e=n.state.field(bt,!1);if(e&&e.panel){let t=Li(n,yo);if(!t)return!1;let i=t.dom.querySelector("[main-field]");if(i&&i!=n.root.activeElement){let s=$r(n.state,e.query.spec);s.valid&&n.dispatch({effects:Fi.of(s)}),i.focus(),i.select()}}else n.dispatch({effects:[go.of(!0),e?Fi.of($r(n.state,e.query.spec)):N.appendConfig.of(E1)]});return!0},pf=n=>{let e=n.state.field(bt,!1);if(!e||!e.panel)return!1;let t=Li(n,yo);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:go.of(!1)}),!0},R1=[{key:"Mod-f",run:df,scope:"editor search-panel"},{key:"F3",run:jn,shift:qn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:jn,shift:qn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:pf,scope:"editor search-panel"},{key:"Mod-Shift-l",run:T1},{key:"Alt-g",run:f1},{key:"Mod-d",run:v1,preventDefault:!0}];class B1{constructor(e){this.view=e;let t=this.query=e.state.field(bt).query.spec;this.commit=this.commit.bind(this),this.searchField=Y("input",{value:t.search,placeholder:Ne(e,"Find"),"aria-label":Ne(e,"Find"),class:"cm-textfield",name:"search","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Y("input",{value:t.replace,placeholder:Ne(e,"Replace"),"aria-label":Ne(e,"Replace"),class:"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit}),this.caseField=Y("input",{type:"checkbox",name:"case",checked:t.caseSensitive,onchange:this.commit}),this.reField=Y("input",{type:"checkbox",name:"re",checked:t.regexp,onchange:this.commit});function i(s,r,o){return Y("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=Y("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>jn(e),[Ne(e,"next")]),i("prev",()=>qn(e),[Ne(e,"previous")]),i("select",()=>D1(e),[Ne(e,"all")]),Y("label",null,[this.caseField,Ne(e,"match case")]),Y("label",null,[this.reField,Ne(e,"regexp")]),...e.state.readOnly?[]:[Y("br"),this.replaceField,i("replace",()=>ea(e),[Ne(e,"replace")]),i("replaceAll",()=>P1(e),[Ne(e,"replace all")]),Y("button",{name:"close",onclick:()=>pf(e),"aria-label":Ne(e,"close"),type:"button"},["\xD7"])]])}commit(){let e=new ff({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Fi.of(e)}))}keydown(e){_p(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?qn:jn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ea(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Fi)&&!i.value.eq(this.query)&&this.setQuery(i.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}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(mo).top}}function Ne(n,e){return n.state.phrase(e)}const on=30,ln=/[\s\.,:;?!]/;function bo(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-on),o=Math.min(s,t+on),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<on;a++)if(!ln.test(l[a+1])&&ln.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-on;a--)if(!ln.test(l[a-1])&&ln.test(l[a])){l=l.slice(0,a);break}}return D.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const L1=D.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"}}),E1=[bt,oi.lowest(O1),L1];class mf{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=we(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),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(gf(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function ta(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function I1(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=ta(e)+ta(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function N1(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:I1(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class ia{constructor(e,t,i){this.completion=e,this.source=t,this.match=i}}function xt(n){return n.selection.main.head}function gf(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}function F1(n,e,t,i){return Object.assign(Object.assign({},n.changeByRange(s=>{if(s==n.selection.main)return{changes:{from:t,to:i,insert:e},range:w.cursor(t+e.length)};let r=i-t;return!s.empty||r&&n.sliceDoc(s.from-r,s.from)!=n.sliceDoc(t,i)?{range:s}:{changes:{from:s.from-r,to:s.from,insert:e},range:w.cursor(s.from-r+e.length)}})),{userEvent:"input.complete"})}function yf(n,e){const t=e.completion.apply||e.completion.label;let i=e.source;typeof t=="string"?n.dispatch(F1(n.state,t,i.from,i.to)):t(n,e.completion,i.from,i.to)}const na=new WeakMap;function V1(n){if(!Array.isArray(n))return n;let e=na.get(n);return e||na.set(n,e=N1(n)),e}class W1{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t<e.length;){let i=ue(e,t),s=Re(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(ue(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}match(e){if(this.pattern.length==0)return[0];if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let v=ue(e,0);return v==t[0]?[0,0,Re(v)]:v==i[0]?[-200,0,Re(v)]:null}let l=e.indexOf(this.pattern);if(l==0)return[0,0,this.pattern.length];let a=t.length,h=0;if(l<0){for(let v=0,M=Math.min(e.length,200);v<M&&h<a;){let S=ue(e,v);(S==t[h]||S==i[h])&&(s[h++]=v),v+=Re(S)}if(h<a)return null}let c=0,f=0,u=!1,d=0,m=-1,y=-1,x=/[a-z]/.test(e),b=!0;for(let v=0,M=Math.min(e.length,200),S=0;v<M&&f<a;){let C=ue(e,v);l<0&&(c<a&&C==t[c]&&(r[c++]=v),d<a&&(C==t[d]||C==i[d]?(d==0&&(m=v),y=v+1,d++):d=0));let k,O=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(k=Gr(C))!=k.toLowerCase()?1:k!=k.toUpperCase()?2:0;(!v||O==1&&x||S==0&&O!=0)&&(t[f]==C||i[f]==C&&(u=!0)?o[f++]=v:o.length&&(b=!1)),S=O,v+=Re(C)}return f==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,e):d==a&&m==0?[-200-e.length,0,y]:l>-1?[-700-e.length,l,l+this.pattern.length]:d==a?[-200+-700-e.length,m,y]:f==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[e-i.length],r=1;for(let o of t){let l=o+(this.astral?Re(ue(i,o)):1);r>1&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return s}}const At=R.define({combine(n){return ot(n,{activateOnTyping:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[]},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,optionClass:(e,t)=>i=>H1(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function H1(n,e){return n?e?n+" "+e:n:e}function z1(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s){let r=document.createElement("span");r.className="cm-completionLabel";let{label:o}=t,l=0;for(let a=1;a<s.length;){let h=s[a++],c=s[a++];h>l&&r.appendChild(document.createTextNode(o.slice(l,h)));let f=r.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(h,c))),f.className="cm-completionMatchedText",l=c}return l<o.length&&r.appendChild(document.createTextNode(o.slice(l))),r},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function sa(n,e,t){if(n<=t)return{from:0,to:n};if(e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class $1{constructor(e,t){this.view=e,this.stateField=t,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:l=>this.positionInfo(l),key:this};let i=e.state.field(t),{options:s,selected:r}=i.open,o=e.state.facet(At);this.optionContent=z1(o),this.optionClass=o.optionClass,this.range=sa(s.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",l=>{for(let a=l.target,h;a&&a!=this.dom;a=a.parentNode)if(a.nodeName=="LI"&&(h=/-(\d+)$/.exec(a.id))&&+h[1]<s.length){yf(e,s[+h[1]]),l.preventDefault();return}}),this.list=this.dom.appendChild(this.createListBox(s,i.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})}mount(){this.updateSel()}update(e){e.state.field(this.stateField)!=e.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=sa(t.options.length,t.selected,this.view.state.facet(At).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})),this.updateSelectedOption(t.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o)}).catch(o=>Ie(this.view.state,o,"completion info")):this.addInfoPane(r)}}addInfoPane(e){let t=this.info=document.createElement("div");t.className="cm-tooltip cm-completionInfo",t.appendChild(e),this.dom.appendChild(t),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&q1(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect();if(s.top>Math.min(innerHeight,t.bottom)-10||s.bottom<Math.max(0,t.top)+10)return null;let r=Math.max(0,Math.min(s.top,innerHeight-i.height))-t.top,o=this.view.textDirection==ee.RTL,l=t.left,a=innerWidth-t.right;return o&&l<Math.min(i.width,a)?o=!1:!o&&a<Math.min(i.width,l)&&(o=!0),{top:r,left:o}}positionInfo(e){this.info&&(this.info.style.top=(e?e.top:-1e6)+"px",e&&(this.info.classList.toggle("cm-completionInfo-left",e.left),this.info.classList.toggle("cm-completionInfo-right",!e.left)))}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let r=i.from;r<i.to;r++){let{completion:o,match:l}=e[r];const a=s.appendChild(document.createElement("li"));a.id=t+"-"+r,a.setAttribute("role","option");let h=this.optionClass(o);h&&(a.className=h);for(let c of this.optionContent){let f=c(o,this.view.state,l);f&&a.appendChild(f)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}}function j1(n){return e=>new $1(e,n)}function q1(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect();i.top<t.top?n.scrollTop-=t.top-i.top:i.bottom>t.bottom&&(n.scrollTop+=i.bottom-t.bottom)}function ra(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function U1(n,e){let t=[],i=0;for(let o of n)if(o.hasResult())if(o.result.filter===!1){let l=o.result.getMatch;for(let a of o.result.options){let h=[1e9-i++];if(l)for(let c of l(a))h.push(c);t.push(new ia(a,o,h))}}else{let l=new W1(e.sliceDoc(o.from,o.to)),a;for(let h of o.result.options)(a=l.match(h.label))&&(h.boost!=null&&(a[0]+=h.boost),t.push(new ia(h,o,a)))}let s=[],r=null;for(let o of t.sort(J1))!r||r.label!=o.completion.label||r.detail!=o.completion.detail||r.type!=null&&o.completion.type!=null&&r.type!=o.completion.type||r.apply!=o.completion.apply?s.push(o):ra(o.completion)>ra(r)&&(s[s.length-1]=o),r=o.completion;return s}class Ai{constructor(e,t,i,s,r){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ai(this.options,oa(t,e),this.tooltip,this.timestamp,e)}static build(e,t,i,s,r){let o=U1(e,t);if(!o.length)return null;let l=0;if(s&&s.selected){let a=s.options[s.selected].completion;for(let h=0;h<o.length;h++)if(o[h].completion==a){l=h;break}}return new Ai(o,oa(i,l),{pos:e.reduce((a,h)=>h.hasResult()?Math.min(a,h.from):a,1e8),create:j1(Fe),above:r.aboveCursor},s?s.timestamp:Date.now(),l)}map(e){return new Ai(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}}class Un{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Un(Q1,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(At),r=(i.override||t.languageDataAt("autocomplete",xt(t)).map(V1)).map(l=>(this.active.find(h=>h.source==l)||new Me(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!G1(r,this.active)?Ai.build(r,t,this.id,this.open,i):this.open&&e.docChanged?this.open.map(e.changes):this.open;!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new Me(l.source,0):l));for(let l of e.effects)l.is(xf)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new Un(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:K1}}function G1(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult;)t++;for(;i<e.length&&!e[i].hasResult;)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const K1={"aria-autocomplete":"list"};function oa(n,e){return{"aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":n+"-"+e,"aria-controls":n}}const Q1=[];function J1(n,e){let t=e.match[0]-n.match[0];return t||n.completion.label.localeCompare(e.completion.label)}function jr(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class Me{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=jr(e),s=this;i?s=s.handleUserEvent(e,i,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new Me(s.source,0));for(let r of e.effects)if(r.is(xo))s=new Me(s.source,1,r.value?xt(e.state):-1);else if(r.is(Gn))s=new Me(s.source,0);else if(r.is(bf))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new Me(this.source,1)}handleChange(e){return e.changes.touchesRange(xt(e.startState))?new Me(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Me(this.source,this.state,e.mapPos(this.explicitPos))}}class Mi extends Me{constructor(e,t,i,s,r){super(e,2,t),this.result=i,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,i){var s;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=xt(e.state);if((this.explicitPos<0?l<=r:l<this.from)||l>o||t=="delete"&&xt(e.startState)==this.from)return new Me(this.source,t=="input"&&i.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),h;return Y1(this.result.validFor,e.state,r,o)?new Mi(this.source,a,this.result,r,o):this.result.update&&(h=this.result.update(this.result,r,o,new mf(e.state,l,a>=0)))?new Mi(this.source,a,h,h.from,(s=h.to)!==null&&s!==void 0?s:xt(e.state)):new Me(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Me(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Mi(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function Y1(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):gf(n,!0).test(s)}const xo=N.define(),Gn=N.define(),bf=N.define({map(n,e){return n.map(t=>t.map(e))}}),xf=N.define(),Fe=ge.define({create(){return Un.start()},update(n,e){return n.update(e)},provide:n=>[to.from(n,e=>e.tooltip),D.contentAttributes.from(n,e=>e.attrs)]}),wf=75;function an(n,e="option"){return t=>{let i=t.state.field(Fe,!1);if(!i||!i.open||Date.now()-i.open.timestamp<wf)return!1;let s=1,r;e=="page"&&(r=Hm(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let o=i.open.selected+s*(n?1:-1),{length:l}=i.open.options;return o<0?o=e=="page"?0:l-1:o>=l&&(o=e=="page"?l-1:0),t.dispatch({effects:xf.of(o)}),!0}}const X1=n=>{let e=n.state.field(Fe,!1);return n.state.readOnly||!e||!e.open||Date.now()-e.open.timestamp<wf?!1:(yf(n,e.open.options[e.open.selected]),!0)},Z1=n=>n.state.field(Fe,!1)?(n.dispatch({effects:xo.of(!0)}),!0):!1,_1=n=>{let e=n.state.field(Fe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Gn.of(null)}),!0)};class ey{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const la=50,ty=50,iy=1e3,ny=se.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of n.state.field(Fe).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Fe);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Fe)==e)return;let t=n.transactions.some(i=>(i.selection||i.docChanged)&&!jr(i));for(let i=0;i<this.running.length;i++){let s=this.running[i];if(t||s.updates.length+n.transactions.length>ty&&Date.now()-s.time>iy){for(let r of s.context.abortListeners)try{r()}catch(o){Ie(this.view.state,o)}s.context.abortListeners=null,this.running.splice(i--,1)}else s.updates.push(...n.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(i=>i.state==1&&!this.running.some(s=>s.active.source==i.source))?setTimeout(()=>this.startUpdate(),la):-1,this.composing!=0)for(let i of n.transactions)jr(i)=="input"?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:n}=this.view,e=n.field(Fe);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=xt(e),i=new mf(e,t,n.explicitPos==t),s=new ey(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Gn.of(null)}),Ie(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),la))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(At);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=new Mi(s.active.source,s.active.explicitPos,s.done,s.done.from,(n=s.done.to)!==null&&n!==void 0?n:xt(s.updates.length?s.updates[0].startState:this.view.state));for(let l of s.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let r=this.view.state.field(Fe).active.find(o=>o.source==s.active.source);if(r&&r.state==1)if(s.done==null){let o=new Me(s.active.source,0);for(let l of s.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:bf.of(e)})}},{eventHandlers:{blur(){let n=this.view.state.field(Fe,!1);n&&n.tooltip&&this.view.state.facet(At).closeOnBlur&&this.view.dispatch({effects:Gn.of(null)})},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:xo.of(!1)}),20),this.composing=0}}}),sy=D.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",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",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"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Kn={brackets:["(","[","{","'",'"'],before:")]}:;>"},Lt=N.define({map(n,e){let t=e.mapPos(n,-1,Se.TrackAfter);return t==null?void 0:t}}),wo=N.define({map(n,e){return e.mapPos(n)}}),ko=new class extends Nt{};ko.startSide=1;ko.endSide=-1;const kf=ge.define({create(){return G.empty},update(n,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,i=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(i,-1)&&(n=G.empty)}n=n.map(e.changes);for(let t of e.effects)t.is(Lt)?n=n.update({add:[ko.range(t.value,t.value+1)]}):t.is(wo)&&(n=n.update({filter:i=>i!=t.value}));return n}});function ry(){return[ly,kf]}const $s="()[]{}<>";function vf(n){for(let e=0;e<$s.length;e+=2)if($s.charCodeAt(e)==n)return $s.charAt(e+1);return Gr(n<128?n:n+1)}function Sf(n,e){return n.languageDataAt("closeBrackets",e)[0]||Kn}const oy=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ly=D.inputHandler.of((n,e,t,i)=>{if((oy?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Re(ue(i,0))==1||e!=s.from||t!=s.to)return!1;let r=cy(n.state,i);return r?(n.dispatch(r),!0):!1}),ay=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Sf(n,n.selection.main.head).brackets||Kn.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=fy(n.doc,o.head);for(let a of i)if(a==l&&ds(n.doc,o.head)==vf(ue(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:w.cursor(o.head-a.length),userEvent:"delete.backward"}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0})),!s},hy=[{key:"Backspace",run:ay}];function cy(n,e){let t=Sf(n,n.selection.main.head),i=t.brackets||Kn.brackets;for(let s of i){let r=vf(ue(s,0));if(e==s)return r==s?py(n,s,i.indexOf(s+s+s)>-1):uy(n,s,r,t.before||Kn.before);if(e==r&&Cf(n,n.selection.main.from))return dy(n,s,r)}return null}function Cf(n,e){let t=!1;return n.field(kf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function ds(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Re(ue(t,0)))}function fy(n,e){let t=n.sliceString(e-2,e);return Re(ue(t,0))==t.length?t:t.slice(1)}function uy(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Lt.of(o.to+e.length),range:w.range(o.anchor+e.length,o.head+e.length)};let l=ds(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Lt.of(o.head+e.length),range:w.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function dy(n,e,t){let i=null,s=n.selection.ranges.map(r=>r.empty&&ds(n.doc,r.head)==t?w.cursor(r.head+t.length):i=r);return i?null:n.update({selection:w.create(s,n.selection.mainIndex),scrollIntoView:!0,effects:n.selection.ranges.map(({from:r})=>wo.of(r))})}function py(n,e,t){let i=null,s=n.changeByRange(r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:e,from:r.to}],effects:Lt.of(r.to+e.length),range:w.range(r.anchor+e.length,r.head+e.length)};let o=r.head,l=ds(n.doc,o);if(l==e){if(aa(n,o))return{changes:{insert:e+e,from:o},effects:Lt.of(o+e.length),range:w.cursor(o+e.length)};if(Cf(n,o)){let a=t&&n.sliceDoc(o,o+e.length*3)==e+e+e;return{range:w.cursor(o+e.length*(a?3:1)),effects:wo.of(o)}}}else{if(t&&n.sliceDoc(o-2*e.length,o)==e+e&&aa(n,o-2*e.length))return{changes:{insert:e+e+e+e,from:o},effects:Lt.of(o+e.length),range:w.cursor(o+e.length)};if(n.charCategorizer(o)(l)!=Ce.Word){let a=n.sliceDoc(o-1,o);if(a!=e&&n.charCategorizer(o)(a)!=Ce.Word&&!my(n,o,e))return{changes:{insert:e+e,from:o},effects:Lt.of(o+e.length),range:w.cursor(o+e.length)}}}return{range:i=r}});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function aa(n,e){let t=we(n).resolveInner(e+1);return t.parent&&t.from==e}function my(n,e,t){let i=we(n).resolveInner(e,-1);for(let s=0;s<5;s++){if(n.sliceDoc(i.from,i.from+t.length)==t){let o=i.firstChild;for(;o&&o.from==i.from&&o.to-o.from>t.length;){if(n.sliceDoc(o.to-t.length,o.to)==t)return!1;o=o.firstChild}return!0}let r=i.to==e&&i.parent;if(!r)break;i=r}return!1}function gy(n={}){return[Fe,At.of(n),ny,yy,sy]}const Af=[{key:"Ctrl-Space",run:Z1},{key:"Escape",run:_1},{key:"ArrowDown",run:an(!0)},{key:"ArrowUp",run:an(!1)},{key:"PageDown",run:an(!0,"page")},{key:"PageUp",run:an(!1,"page")},{key:"Enter",run:X1}],yy=oi.highest(ss.computeN([At],n=>n.facet(At).defaultKeymap?[Af]:[]));class by{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Pt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet(Gt).markerFilter;r&&(s=r(s));let o=B.set(s.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?B.widget({widget:new Dy(l),diagnostic:l}).range(l.from):B.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity},diagnostic:l}).range(l.from,l.to)),!0);return new Pt(o,t,si(o))}}function si(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new by(s,r,o.diagnostic),!1}),i}function xy(n,e){return!!(n.effects.some(t=>t.is(vo))||n.changes.touchesRange(e.pos))}function Mf(n,e){return n.field(Ee,!1)?e:e.concat(N.appendConfig.of([Ee,D.decorations.compute([Ee],t=>{let{selected:i,panel:s}=t.field(Ee);return!i||!s||i.from==i.to?B.none:B.set([ky.range(i.from,i.to)])}),Wm(vy,{hideOn:xy}),Py]))}function wy(n,e){return{effects:Mf(n,[vo.of(e)])}}const vo=N.define(),So=N.define(),Of=N.define(),Ee=ge.define({create(){return new Pt(B.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=si(t,n.selected.diagnostic,s)||si(t,null,s)}n=new Pt(t,n.panel,i)}for(let t of e.effects)t.is(vo)?n=Pt.init(t.value,n.panel,e.state):t.is(So)?n=new Pt(n.diagnostics,t.value?ps.open:null,n.selected):t.is(Of)&&(n=new Pt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Ei.from(n,e=>e.panel),D.decorations.from(n,e=>e.diagnostics)]}),ky=B.mark({class:"cm-lintRange cm-lintRange-active"});function vy(n,e,t){let{diagnostics:i}=n.state.field(Ee),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0))&&(s.push(c.diagnostic),r=Math.min(a,r),o=Math.max(h,o))});let l=n.state.facet(Gt).tooltipFilter;return l&&(s=l(s)),s.length?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:Sy(n,s)}}}:null}function Sy(n,e){return Y("ul",{class:"cm-tooltip-lint"},e.map(t=>Tf(n,t,!1)))}const Cy=n=>{let e=n.state.field(Ee,!1);(!e||!e.panel)&&n.dispatch({effects:Mf(n.state,[So.of(!0)])});let t=Li(n,ps.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},ha=n=>{let e=n.state.field(Ee,!1);return!e||!e.panel?!1:(n.dispatch({effects:So.of(!1)}),!0)},Ay=n=>{let e=n.state.field(Ee,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},My=[{key:"Mod-Shift-m",run:Cy},{key:"F8",run:Ay}],Oy=se.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(Gt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(n<this.lintTime-10)setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(Gt);Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let s=i.reduce((r,o)=>r.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(wy(this.view.state,s))},i=>{Ie(this.view.state,i)})}}update(n){let e=n.state.facet(Gt);(n.docChanged||e!=n.startState.facet(Gt))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),Gt=R.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},ot(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null}))},enables:Oy});function Df(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Tf(n,e,t){var i;let s=t?Df(e.actions):[];return Y("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Y("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=f=>{f.preventDefault();let u=si(n.state.field(Ee).diagnostics,e);u&&r.apply(n,u.from,u.to)},{name:a}=r,h=s[o]?a.indexOf(s[o]):-1,c=h<0?a:[a.slice(0,h),Y("u",a.slice(h,h+1)),a.slice(h+1)];return Y("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${a}${h<0?"":` (access key "${s[o]})"`}.`},c)}),e.source&&Y("div",{class:"cm-diagnosticSource"},e.source))}class Dy extends lt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return Y("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class ca{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Tf(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ps{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)ha(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Df(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=si(this.view.state.field(Ee).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=Y("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=Y("div",{class:"cm-panel-lint"},this.list,Y("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>ha(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Ee).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(Ee),i=0,s=!1,r=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new ca(this.view,a.diagnostic),this.items.splice(i,0,c),s=!0):(c=this.items[h],h>i&&(this.items.splice(i,h-i),s=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),r=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new ca(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{o.top<l.top?this.list.scrollTop-=l.top-o.top:o.bottom>l.bottom&&(this.list.scrollTop+=o.bottom-l.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ee),i=si(t.diagnostics,this.items[e].diagnostic);!i||this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Of.of(i)})}static open(e){return new ps(e)}}function Ty(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function js(n){return Ty(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Py=D.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-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:js("#d11")},".cm-lintRange-warning":{backgroundImage:js("orange")},".cm-lintRange-info":{backgroundImage:js("#999")},".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-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}}});var fa=function(e){e===void 0&&(e={});var t=[];e.closeBracketsKeymap!==!1&&(t=t.concat(hy)),e.defaultKeymap!==!1&&(t=t.concat(a1)),e.searchKeymap!==!1&&(t=t.concat(R1)),e.historyKeymap!==!1&&(t=t.concat(x0)),e.foldKeymap!==!1&&(t=t.concat(Eg)),e.completionKeymap!==!1&&(t=t.concat(Af)),e.lintKeymap!==!1&&(t=t.concat(My));var i=[];return e.lineNumbers!==!1&&i.push(Jm()),e.highlightActiveLineGutter!==!1&&i.push(Zm()),e.highlightSpecialChars!==!1&&i.push(pm()),e.history!==!1&&i.push(c0()),e.foldGutter!==!1&&i.push(Fg()),e.drawSelection!==!1&&i.push(im()),e.dropCursor!==!1&&i.push(am()),e.allowMultipleSelections!==!1&&i.push(H.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(Cg()),e.syntaxHighlighting!==!1&&i.push(ho(zg,{fallback:!0})),e.bracketMatching!==!1&&i.push(Qg()),e.closeBrackets!==!1&&i.push(ry()),e.autocompletion!==!1&&i.push(gy()),e.rectangularSelection!==!1&&i.push(Dm()),e.crosshairCursor!==!1&&i.push(Rm()),e.highlightActiveLine!==!1&&i.push(wm()),e.highlightSelectionMatches!==!1&&i.push(p1()),e.tabSize&&typeof e.tabSize=="number"&&i.push(rs.of(" ".repeat(e.tabSize))),i.concat([ss.of(t.flat())]).filter(Boolean)};const Ry="#e5c07b",ua="#e06c75",By="#56b6c2",Ly="#ffffff",yn="#abb2bf",qr="#7d8799",Ey="#61afef",Iy="#98c379",da="#d19a66",Ny="#c678dd",Fy="#21252b",qs="#2c313a",pa="#282c34",Us="#353a42",Vy="#3E4451",ma="#528bff",Wy=D.theme({"&":{color:yn,backgroundColor:pa},".cm-content":{caretColor:ma},".cm-cursor, .cm-dropCursor":{borderLeftColor:ma},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Vy},".cm-panels":{backgroundColor:Fy,color:yn},".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:qs},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{backgroundColor:pa,color:qr,border:"none"},".cm-activeLineGutter":{backgroundColor:qs},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Us},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Us,borderBottomColor:Us},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:qs,color:yn}}},{dark:!0}),Hy=li.define([{tag:g.keyword,color:Ny},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:ua},{tag:[g.function(g.variableName),g.labelName],color:Ey},{tag:[g.color,g.constant(g.name),g.standard(g.name)],color:da},{tag:[g.definition(g.name),g.separator],color:yn},{tag:[g.typeName,g.className,g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:Ry},{tag:[g.operator,g.operatorKeyword,g.url,g.escape,g.regexp,g.link,g.special(g.string)],color:By},{tag:[g.meta,g.comment],color:qr},{tag:g.strong,fontWeight:"bold"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strikethrough,textDecoration:"line-through"},{tag:g.link,color:qr,textDecoration:"underline"},{tag:g.heading,fontWeight:"bold",color:ua},{tag:[g.atom,g.bool,g.special(g.variableName)],color:da},{tag:[g.processingInstruction,g.string,g.inserted],color:Iy},{tag:g.invalid,color:Ly}]),zy=[Wy,ho(Hy)];var $y=n=>({line:n.state.doc.lineAt(n.state.selection.main.from),lineCount:n.state.doc.lines,lineBreak:n.state.lineBreak,length:n.state.doc.length,readOnly:n.state.readOnly,tabSize:n.state.tabSize,selection:n.state.selection,selectionAsSingle:n.state.selection.asSingle().main,ranges:n.state.selection.ranges,selectionCode:n.state.sliceDoc(n.state.selection.main.from,n.state.selection.main.to),selections:n.state.selection.ranges.map(e=>n.state.sliceDoc(e.from,e.to)),selectedText:n.state.selection.ranges.some(e=>!e.empty)});function jy(n){var{value:e,selection:t,onChange:i,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=[],autoFocus:a,theme:h="light",height:c="",minHeight:f="",maxHeight:u="",placeholder:d="",width:m="",minWidth:y="",maxWidth:x="",editable:b=!0,readOnly:v=!1,indentWithTab:M=!0,basicSetup:S=!0,root:C,initialState:k}=n,[O,F]=I.exports.useState(),[T,E]=I.exports.useState(),[W,q]=I.exports.useState(),J=D.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ye=D.theme({"&":{height:c,minHeight:f,maxHeight:u,width:m,minWidth:y,maxWidth:x}}),oe=D.updateListener.of(te=>{if(te.docChanged&&typeof i=="function"){var Z=te.state.doc,be=Z.toString();i(be,te)}s&&s($y(te))}),$=[oe,ye];switch(M&&$.unshift(ss.of([h1])),S&&(typeof S=="boolean"?$.unshift(fa()):$.unshift(fa(S))),d&&$.unshift(Cm(d)),h){case"light":$.push(J);break;case"dark":$.push(zy);break;default:$.push(h);break}return b===!1&&$.push(D.editable.of(!1)),v&&$.push(H.readOnly.of(!0)),o&&typeof o=="function"&&$.push(D.updateListener.of(o)),$=$.concat(l),I.exports.useEffect(()=>{if(O&&!W){var te={doc:e,selection:t,extensions:$},Z=k?H.fromJSON(k.json,te,k.fields):H.create(te);if(q(Z),!T){var be=new D({state:Z,parent:O,root:C});E(be),r&&r(be,Z)}}return()=>{T&&(q(void 0),E(void 0))}},[O,W]),I.exports.useEffect(()=>F(n.container),[n.container]),I.exports.useEffect(()=>()=>{T&&(T.destroy(),E(void 0))},[T]),I.exports.useEffect(()=>{a&&T&&T.focus()},[a,T]),I.exports.useEffect(()=>{T&&T.dispatch({effects:N.reconfigure.of($)})},[h,l,c,f,u,m,y,x,d,b,v,M,S,i,o]),I.exports.useEffect(()=>{var te=T?T.state.doc.toString():"";T&&e!==te&&T.dispatch({changes:{from:0,to:te.length,insert:e||""}})},[e,T]),{state:W,setState:q,view:T,setView:E,container:O,setContainer:F}}var qy=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Pf=I.exports.forwardRef((n,e)=>{var{className:t,value:i="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,autoFocus:c,theme:f="light",height:u,minHeight:d,maxHeight:m,width:y,minWidth:x,maxWidth:b,basicSetup:v,placeholder:M,indentWithTab:S,editable:C,readOnly:k,root:O,initialState:F}=n,T=yd(n,qy),E=I.exports.useRef(null),{state:W,view:q,container:J,setContainer:ye}=jy({container:E.current,root:O,value:i,autoFocus:c,theme:f,height:u,minHeight:d,maxHeight:m,width:y,minWidth:x,maxWidth:b,basicSetup:v,placeholder:M,indentWithTab:S,editable:C,readOnly:k,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,extensions:r,initialState:F});if(I.exports.useImperativeHandle(e,()=>({editor:E.current,state:W,view:q}),[E,J,W,q]),typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var oe=typeof f=="string"?"cm-theme-"+f:"cm-theme";return p("div",er({ref:E,className:""+oe+(t?" "+t:"")},T))});Pf.displayName="CodeMirror";class Qn{constructor(e,t,i,s,r,o,l,a,h,c=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new Qn(e,[],t,i,i,0,[],0,s?new ga(s,s.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){let t=e>>19,i=e&65535,{parser:s}=this.p,r=s.dynamicPrecedence(i);if(r&&(this.score+=r),t==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),l=this.stack[o-2],a=this.stack[o-1],h=this.bufferBase+this.buffer.length-a;if(i<s.minRepeatTerm||e&131072){let c=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,l,c,h+4,!0)}if(e&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=s.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,l)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i){let s=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(r,1)||(this.reducePos=i)),this.pushState(r,s),this.shiftContext(t,s),t<=o.maxNode&&this.buffer.push(t,s,i,4)}else this.pos=i,this.shiftContext(t,s),t<=this.p.parser.maxNode&&this.buffer.push(t,s,i,4)}apply(e,t,i){e&65536?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,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 i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new Qn(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Uy(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if((i&65536)==0)return!0;if(i==0)return!1;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let s=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[r],o);if(this.stack.length<120)for(let r=0;s.length<4<<1&&r<t.length;r+=2){let o=t[r+1];s.some((l,a)=>a&1&&l==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s<t.length&&i.length<4;s+=2){let r=t[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],this.pos),o.score-=200,i.push(o)}return i}forceReduce(){let e=this.p.parser.stateSlot(this.state,5);if((e&65536)==0)return!1;let{parser:t}=this.p;if(!t.validAction(this.state,e)){let i=e>>19,s=e&65535,r=this.stack.length-i*3;if(r<0||t.getGoto(this.stack[r],s,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.reducePos,this.reducePos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.reducePos,this.reducePos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new ga(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class ga{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var ya;(function(n){n[n.Insert=200]="Insert",n[n.Delete=190]="Delete",n[n.Reduce=100]="Reduce",n[n.MaxNext=4]="MaxNext",n[n.MaxInsertStackDepth=300]="MaxInsertStackDepth",n[n.DampenInsertStackDepth=120]="DampenInsertStackDepth"})(ya||(ya={}));class Uy{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class Jn{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Jn(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Jn(this.stack,this.pos,this.index)}}class bn{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const ba=new bn;class Gy{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=ba,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 i=this.range,s=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!s)return null;let o=this.ranges[--s];r-=i.from-o.to,i=o}for(;t<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}peek(e){let t=this.chunkOff+e,i,s;if(t>=0&&t<this.chunk.length)i=this.pos+e,s=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}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=ba,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 i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class xn{constructor(e,t){this.data=e,this.id=t}token(e,t){Ky(this.data,e,t,this.id)}}xn.prototype.contextual=xn.prototype.fallback=xn.prototype.extend=!1;function Ky(n,e,t,i){let s=0,r=1<<i,{parser:o}=t.p,{dialect:l}=o;e:for(;(r&n[s])!=0;){let a=n[s+1];for(let u=s+3;u<a;u+=2)if((n[u+1]&r)>0){let d=n[u];if(l.allows(d)&&(e.token.value==-1||e.token.value==d||o.overrides(d,e.token.value))){e.acceptToken(d);break}}let h=e.next,c=0,f=n[s+2];if(e.next<0&&f>c&&n[a+f*3-3]==65535){s=n[a+f*3-1];continue e}for(;c<f;){let u=c+f>>1,d=a+u+(u<<1),m=n[d],y=n[d+1];if(h<m)f=u;else if(h>=y)c=u+1;else{s=n[d+2],e.advance();continue e}}break}}function hn(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i<n.length;){let r=0;for(;;){let o=n.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}const He=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let Gs=null;var xa;(function(n){n[n.Margin=25]="Margin"})(xa||(xa={}));function wa(n,e,t){let i=n.cursor(pe.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class Qy{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?wa(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?wa(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 i=this.trees[t],s=this.index[t];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],o=this.start[t]+i.positions[s];if(o>e)return this.nextStart=o,null;if(r instanceof le){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(V.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class Jy{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new bn)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let c=r[h],f=this.tokens[h];if(!(i&&!c.fallback)&&((c.contextual||f.start!=e.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,c,e),f.mask=o,f.context=l),f.lookAhead>f.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!c.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new bn,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new bn,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){if(t.token(this.stream.reset(i.pos,e),i),e.value>-1){let{parser:s}=i.p;for(let r=0;r<s.specialized.length;r++)if(s.specialized[r]==e.value){let o=s.specializers[r](this.stream.read(e.start,e.end),i);if(o>=0&&i.p.parser.dialect.allows(o>>1)){(o&1)==0?e.value=o>>1:e.extended=o>>1;break}}}else e.value=0,e.end=Math.min(i.p.stream.end,i.pos+1)}putAction(e,t,i,s){for(let r=0;r<s;r+=3)if(this.actions[r]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=i,s}addActions(e,t,i,s){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=it(l,h+2);else{s==0&&l[h+1]==2&&(s=this.putAction(it(l,h+2),t,i,s));break}l[h]==t&&(s=this.putAction(it(l,h+1),t,i,s))}return s}}var ka;(function(n){n[n.Distance=5]="Distance",n[n.MaxRemainingPerStep=3]="MaxRemainingPerStep",n[n.MinBufferLengthPrune=500]="MinBufferLengthPrune",n[n.ForceReduceLimit=10]="ForceReduceLimit",n[n.CutDepth=15e3]="CutDepth",n[n.CutTo=9e3]="CutTo"})(ka||(ka={}));class Yy{constructor(e,t,i,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.stream=new Gy(t,s),this.tokens=new Jy(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[Qn.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>e.bufferLength*4?new Qy(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&Zy(s);if(o)return this.stackToTree(o);if(this.parser.strict)throw He&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let s=e.pos,{parser:r}=this,o=He?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let f=this.fragments.nodeAt(s);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(V.contextHash)||0)==c))return e.useNode(f,u),He&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof le)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof le&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),He&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;h<a.length;){let c=a[h++],f=a[h++],u=a[h++],d=h==a.length||!i,m=d?e:e.split();if(m.apply(c,f,u),He&&console.log(o+this.stackID(m)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(f)} @ ${s}${m==e?"":", split"})`),d)return!0;m.pos>s?t.push(m):i.push(m)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return va(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],h=t[(o<<1)+1],c=He?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),He&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=c;for(let d=0;f.forceReduce()&&d<10&&(He&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)He&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))He&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),He&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),va(l,i)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),le.build({buffer:Jn.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=(Gs||(Gs=new WeakMap)).get(e);return t||Gs.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function va(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}class Xy{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class Yn extends lc{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (${14})`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),s=[];for(let l=0;l<t.length;l++)s.push([]);function r(l,a,h){s[l].push([a,a.deserialize(String(h))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=V[a]);for(let h=1;h<l.length;){let c=l[h++];if(c>=0)r(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)r(l[h++],a,f);h++}}}this.nodeSet=new no(t.map((l,a)=>Te.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=sc;let o=hn(e.tokenData);if(this.context=e.context,this.specialized=new Uint16Array(e.specialized?e.specialized.length:0),this.specializers=[],e.specialized)for(let l=0;l<e.specialized.length;l++)this.specialized[l]=e.specialized[l].term,this.specializers[l]=e.specialized[l].get;this.states=hn(e.states,Uint32Array),this.data=hn(e.stateData),this.goto=hn(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new xn(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let s=new Yy(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(s[r]==e)return a;if(l)return-1}}hasAction(e,t){let i=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(e,s?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=it(i,r+2)];else{if(i[r+1]==2)return it(i,r+2);break}if(o==t||o==0)return it(i,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=it(this.data,i+2);else return!1;if(t==it(this.data,i+1))return!0}}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=it(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}overrides(e,t){let i=Sa(this.data,this.tokenPrecTable,t);return i<0||Sa(this.data,this.tokenPrecTable,e)<i}configure(e){let t=Object.assign(Object.create(Yn.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.map(i=>{let s=e.specializers.find(r=>r.from==i);return s?s.to:i})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;r<t.length;r++)if(!i[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new Xy(e,i,s)}static deserialize(e){return new Yn(e)}}function it(n,e){return n[e]|n[e+1]<<16}function Sa(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function Zy(n){let e=null;for(let t of n){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}const _y=hc({String:g.string,Number:g.number,"True False":g.bool,PropertyName:g.propertyName,Null:g.null,",":g.separator,"[ ]":g.squareBracket,"{ }":g.brace}),eb=Yn.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"\u26A0 JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[_y],skippedNodes:[0],repeatNodeCount:2,tokenData:"(p~RaXY!WYZ!W]^!Wpq!Wrs!]|}$i}!O$n!Q!R$w!R![&V![!]&h!}#O&m#P#Q&r#Y#Z&w#b#c'f#h#i'}#o#p(f#q#r(k~!]Oc~~!`Upq!]qr!]rs!rs#O!]#O#P!w#P~!]~!wOe~~!zXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#g~#jR!Q![#s!c!i#s#T#Z#s~#vR!Q![$P!c!i$P#T#Z$P~$SR!Q![$]!c!i$]#T#Z$]~$`R!Q![!]!c!i!]#T#Z!]~$nOh~~$qQ!Q!R$w!R![&V~$|RT~!O!P%V!g!h%k#X#Y%k~%YP!Q![%]~%bRT~!Q![%]!g!h%k#X#Y%k~%nR{|%w}!O%w!Q![%}~%zP!Q![%}~&SPT~!Q![%}~&[ST~!O!P%V!Q![&V!g!h%k#X#Y%k~&mOg~~&rO]~~&wO[~~&zP#T#U&}~'QP#`#a'T~'WP#g#h'Z~'^P#X#Y'a~'fOR~~'iP#i#j'l~'oP#`#a'r~'uP#`#a'x~'}OS~~(QP#f#g(T~(WP#i#j(Z~(^P#X#Y(a~(fOQ~~(kOW~~(pOV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),tb=Nn.define({name:"json",parser:eb.configure({props:[dc.add({Object:Hl({except:/^\s*\}/}),Array:Hl({except:/^\s*\]/})}),mc.add({"Object Array":Mg})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function ib(){return new pg(tb)}var Rf=n=>{var{theme:e,settings:t,styles:i}=n,s={"&":{backgroundColor:t.background,color:t.foreground},".cm-gutters":{}};t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var r={};t.gutterActiveForeground&&(r.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},r.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=r,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={backgroundColor:t.selection}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var o=D.theme(s,{dark:e==="dark"}),l=li.define(i),a=[o,ho(l)];return a},nb=Rf({theme:"light",settings:{background:"#faf8f5",foreground:"#b29762",caret:"#93abdc",selection:"#e3dcce",selectionMatch:"#e3dcce",gutterBackground:"#faf8f5",gutterForeground:"#cdc4b1",lineHighlight:"#EFEFEF"},styles:[{tag:[g.comment,g.bracket],color:"#b6ad9a"},{tag:[g.atom,g.number,g.keyword,g.link,g.attributeName,g.quote],color:"#063289"},{tag:[g.emphasis,g.heading,g.tagName,g.propertyName,g.variableName],color:"#2d2006"},{tag:[g.typeName,g.url,g.string],color:"#896724"},{tag:[g.operator,g.string],color:"#1659df"},{tag:[g.propertyName],color:"#b29762"},{tag:[g.unit,g.punctuation],color:"#063289"}]}),sb=Rf({theme:"dark",settings:{background:"#2a2734",foreground:"#6c6783",caret:"#ffad5c",selection:"rgba(255, 255, 255, 0.1)",gutterBackground:"#2a2734",gutterForeground:"#545167",lineHighlight:"#36334280"},styles:[{tag:[g.comment,g.bracket],color:"#6c6783"},{tag:[g.atom,g.number,g.keyword,g.link,g.attributeName,g.quote],color:"#ffcc99"},{tag:[g.emphasis,g.heading,g.tagName,g.propertyName,g.className,g.variableName],color:"#eeebff"},{tag:[g.typeName,g.url],color:"#7a63ee"},{tag:g.operator,color:"#ffad5c"},{tag:g.string,color:"#ffb870"},{tag:[g.propertyName],color:"#9a86fd"},{tag:[g.unit,g.punctuation],color:"#e09142"}]});const rb=re("aside")(({theme:n})=>({height:"50px",backgroundColor:n.palette.neutral.light,borderTopRightRadius:n.shape.borderRadiusMedium,borderTopLeftRadius:n.shape.borderRadiusMedium,padding:n.spacing(1,2),color:n.palette.text.primary,display:"flex",justifyContent:"space-between",alignItems:"center",border:`1px solid ${n.palette.lightBorder}`,borderBottom:"none"})),Bf=re("div")(({theme:n,style:e})=>({width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.5s ease-in-out",borderRadius:"50%",opacity:.8,...e})),ob=re("div")(({theme:n})=>({fontSize:"0.9rem",color:n.palette.error.main,marginRight:n.spacing(1)})),lb=()=>{const n=ke();return p(Bf,{style:{color:n.palette.text.tertiaryContrast,backgroundColor:n.palette.success.main},children:p(ou,{sx:{width:"20px",height:"20px"}})})},ab=()=>{const n=ke();return p(Bf,{style:{color:n.palette.text.tertiaryContrast,backgroundColor:n.palette.error.main},children:p(ku,{})})},hb=({context:n,setContext:e,error:t})=>{const{themeMode:i}=I.exports.useContext(ru),s=ke(),r=I.exports.useCallback(o=>{e(o)},[e]);return L(j,{sx:{width:"100%"},children:[L(rb,{children:["JSON",p(z,{condition:Boolean(t),show:L(j,{sx:o=>({display:"flex",alignItems:"center"}),children:[p(ob,{children:t}),p(ab,{})]}),elseShow:p(lb,{})})]}),p(Pf,{value:n,height:"200px",theme:i==="dark"?sb:nb,extensions:[ib()],onChange:r,style:{border:`1px solid ${s.palette.lightBorder}`,borderTop:"none",borderBottomLeftRadius:s.shape.borderRadiusMedium,borderBottomRightRadius:s.shape.borderRadiusMedium},placeholder:JSON.stringify({currentTime:"2022-07-04T14:13:03.929Z",appName:"playground",userId:"test",remoteAddress:"127.0.0.1"},null,2)})]})},cb=({context:n,setContext:e})=>{const t=ke(),{setToastData:i}=Ta(),{context:s}=lu(),r=s.sort((b,v)=>b.sortOrder-v.sortOrder).map(({name:b})=>b),[o,l]=I.exports.useState(),[a,h]=I.exports.useState(!1),[c,f]=I.exports.useState(""),[u,d]=I.exports.useState(""),m=I.exports.useMemo(()=>gd.debounce(b=>{if(!b)return l(void 0);try{const v=JSON.parse(b);h(v[c]!==void 0)}catch(v){return l(kn(v))}return l(void 0)},250),[l,c,h]);I.exports.useEffect(()=>{m(n)},[m,n]);const y=()=>{try{const b=JSON.parse(n||"{}");e(JSON.stringify({...b,[c]:u},null,2));const v=s.find(M=>M.name===c);if((v==null?void 0:v.legalValues)&&v.legalValues.length>0||c==="currentTime")return;d("")}catch(b){i({type:"error",title:`Error parsing context: ${kn(b)}`})}},x=()=>{if(c==="currentTime"){const v=Oo(u),M=new Date,S=v?Do(v.toISOString()):Do(M.toISOString());return p(wi,{id:"date",label:"Date",size:"small",type:"datetime-local",value:S,sx:{width:200,maxWidth:"100%"},onChange:C=>{const k=Oo(C.target.value),O=k==null?void 0:k.toISOString();O&&d(O)},InputLabelProps:{shrink:!0},required:!0})}const b=s.find(v=>v.name===c);if(b&&b.legalValues&&b.legalValues.length>0){const v=b.legalValues.map(({value:M})=>M);return p(Xs,{disablePortal:!0,id:"context-legal-values",size:"small",onChange:(M,S)=>{if(typeof S=="string")return d(S)},options:v,sx:{width:200,maxWidth:"100%"},renderInput:M=>p(wi,{...M,label:"Value"})})}return p(wi,{label:"Value",id:"context-value",sx:{width:200,maxWidth:"100%"},size:"small",value:u,onChange:v=>d(v.target.value||"")})};return L(j,{children:[L(j,{sx:{display:"flex",alignItems:"center",mb:2},children:[p(Zn,{type:"secondary",children:"2"}),p(ie,{variant:"body2",color:t.palette.text.secondary,sx:{ml:1},children:"Unleash context"})]}),L(j,{sx:{display:"flex",gap:2,flexWrap:"wrap",mb:2},children:[L(au,{children:[p(hu,{id:"context-field-label",size:"small",children:"Context field"}),p(cu,{label:"Context field",labelId:"context-field-label",id:"context-field",value:c,onChange:b=>{if(f(b.target.value||""),b.target.value==="currentTime")return d(new Date().toISOString());d("")},variant:"outlined",size:"small",sx:{width:200,maxWidth:"100%"},children:r.map(b=>p(fu,{value:b,children:b},b))})]}),x(),p(Pa,{variant:"outlined",disabled:!c||Boolean(o),onClick:y,sx:{width:"95px"},children:`${a?"Replace":"Add"} `})]}),p(hb,{context:n,setContext:e,error:o})]})},ht={label:"ALL",id:"*"},fb=({environment:n,projects:e,setProjects:t,setEnvironment:i,environmentOptions:s})=>{const r=ke(),{projects:o=[]}=uu(),l=[ht,...o.map(({name:c,id:f})=>({label:c,id:f}))],a=(c,f,u)=>{const d=f;return u==="clear"||d===null?t([ht.id]):Array.isArray(d)?d.length===0?t([ht.id]):d.find(({id:m})=>m===ht.id)!==void 0?t([ht.id]):t(d.map(({id:m})=>m)):d.id===ht.id?t([ht.id]):t([d.id])},h=e.length===0||e.length===1&&e[0]==="*";return L(j,{sx:{pb:2},children:[L(j,{sx:{display:"flex",alignItems:"center",mb:2},children:[p(Zn,{type:"secondary",children:"1"}),p(ie,{variant:"body2",color:r.palette.text.secondary,sx:{ml:1},children:"Access configuration"})]}),L(j,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[p(Xs,{disablePortal:!0,id:"environment",options:s,sx:{width:200,maxWidth:"100%"},renderInput:c=>p(wi,{...c,label:"Environment",required:!0}),value:n,onChange:(c,f)=>i(f||""),size:"small"}),p(Xs,{disablePortal:!0,id:"projects",multiple:!h,options:l,sx:{width:200,maxWidth:"100%"},renderInput:c=>p(wi,{...c,label:"Projects"}),size:"small",value:h?ht:l.filter(({id:c})=>e.includes(c)),onChange:a})]})]})},ub=({environments:n,environment:e,onSubmit:t,projects:i,setProjects:s,setEnvironment:r,context:o,setContext:l})=>{const a=ke();return L(j,{component:"form",onSubmit:t,sx:{display:"flex",flexDirection:"column"},children:[p(fb,{environment:e,projects:i,setEnvironment:r,setProjects:s,environmentOptions:Fa(n)}),p(Zs,{variant:"fullWidth",sx:{mb:2,borderColor:a.palette.dividerAlternative,borderStyle:"dashed"}}),p(cb,{context:o,setContext:l}),p(Zs,{variant:"fullWidth",sx:{mt:3,mb:2,borderColor:a.palette.dividerAlternative}}),L(j,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p(Zn,{type:"secondary",children:"3"}),p(Pa,{variant:"contained",size:"large",type:"submit",sx:{marginLeft:"auto"},children:"Try configuration"})]})]})},Ks=({headerText:n,bodyText:e,sectionNumber:t})=>p(j,{sx:{display:"flex",alignItems:"flex-start",mt:2,flexDirection:"column"},children:L(j,{sx:{display:"flex"},children:[p(j,{children:p(Zn,{children:t})}),L(j,{sx:{ml:2,display:"flex",flexDirection:"column"},children:[p(ie,{variant:"body1",sx:{fontWeight:"bold"},children:n}),p(z,{condition:Boolean(e),show:p(ie,{variant:"body1",sx:{mt:1},children:e})})]})]})}),Lf=()=>L(j,{sx:{ml:4},children:[p(ie,{variant:"body1",children:"Unleash playground is for helping you to undestand how unleash works, how feature toggles are evaluated and for you to easily debug your feature toggles."}),p(Zs,{sx:{mt:2,mb:2}}),p(ie,{variant:"body1",sx:{mb:1},children:"What you need to do is:"}),p(Ks,{headerText:"Select in which environment you want to test your feature toggle configuration",bodyText:"You can also specify specific projects, or check toggles in all projects.",sectionNumber:"1"}),p(Ks,{headerText:"Select a context field that you'd like to check",bodyText:"You can configure as many context fields as you want. You can also leave the context empty to test against an empty context.",sectionNumber:"2"}),p(Ks,{headerText:"Submit the form to try the configuration",bodyText:"The results of evaluating your feature toggles will appear after you submit the form. Then view the results.",sectionNumber:"3"})]}),db=()=>{const[n,e]=I.exports.useState(null),t=o=>e(o.currentTarget),i=()=>e(null),s=Boolean(n),r="playground-guidance-popper";return L(j,{children:[p(Oi,{onClick:t,"aria-describedby":r,children:p(vu,{})}),p(du,{id:r,open:s,anchorEl:n,sx:o=>({zIndex:o.zIndex.tooltip}),children:L(Ra,{sx:o=>({padding:o.spacing(8,4),maxWidth:"500px",borderRadius:`${o.shape.borderRadiusExtraLarge}px`}),children:[p(Oi,{onClick:i,sx:{position:"absolute",right:25,top:15},children:p(pu,{})}),p(Lf,{})]})})]})},gb=()=>{const{environments:n}=mu(),e=ke(),t=Ys(e.breakpoints.down("lg")),[i,s]=I.exports.useState(""),[r,o]=I.exports.useState([]),[l,a]=I.exports.useState(),[h,c]=I.exports.useState(),{setToastData:f}=Ta(),[u,d]=Da(),{evaluatePlayground:m,loading:y}=fd();I.exports.useEffect(()=>{s(pd(n))},[n]),I.exports.useEffect(()=>{try{const C=u.get("environment");C&&s(C);let k,O=u.get("projects");O&&(k=O.split(","),o(k));let F=u.get("context");F&&(F=decodeURI(F),a(F)),(async()=>{C&&F&&await x(C,k||"*",F)})()}catch(C){f({type:"error",title:`Failed to parse URL parameters: ${kn(C)}`})}},[]);const x=async(C,k,O,F)=>{try{const T=JSON.parse(O||"{}"),E=await m({environment:C,projects:dd(k),context:{appName:"playground",...T}});F&&typeof F=="function"&&F(),c(E)}catch(T){f({type:"error",title:`Error parsing context: ${kn(T)}`})}},b=async C=>{C.preventDefault(),await x(i,r,l,v)},v=()=>{u.set("context",encodeURI(l||"")),u.set("environment",i),Array.isArray(r)&&r.length>0&&!(r.length===1&&r[0]==="*")?u.set("projects",r.join(",")):u.delete("projects"),d(u)},M=h&&!t?"35%":"auto",S=md(t,h);return p(gu,{header:p(yu,{title:"Unleash playground",actions:p(db,{})}),disableLoading:!0,bodyClass:"no-padding",children:L(j,{sx:{display:"flex",flexDirection:t?"column":"row"},children:[p(j,{sx:{background:e.palette.playgroundBackground,borderBottomLeftRadius:e.shape.borderRadiusMedium},children:p(Ra,{elevation:0,sx:{px:4,py:3,mb:4,mt:2,background:e.palette.playgroundBackground,transition:"width 0.4s ease",minWidth:t?"auto":"500px",width:M,position:"sticky",top:0},children:p(ub,{onSubmit:b,context:l,setContext:a,environments:n,projects:r,environment:i,setProjects:o,setEnvironment:s})})}),p(j,{sx:C=>({width:S,transition:"width 0.4s ease",padding:C.spacing(4,2)}),children:p(z,{condition:y,show:p(bu,{}),elseShow:p(z,{condition:Boolean(h),show:p(cd,{loading:y,features:h==null?void 0:h.features,input:h==null?void 0:h.input}),elseShow:p(Lf,{})})})})]})})};export{gb as Playground,gb as default};
|
|
10
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp}create(){return this.regexp?new C1(this):new S1(this)}getCursor(e,t=0,i=e.length){return this.regexp?qt(this,e,t,i):jt(this,e,t,i)}}class uf{constructor(e){this.spec=e}}function jt(n,e,t,i){return new ni(e,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase())}class S1 extends uf{constructor(e){super(e)}nextMatch(e,t,i){let s=jt(this.spec,e,i,e.length).nextOverlapping();return s.done&&(s=jt(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=jt(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.length)}getReplacement(e){return this.spec.replace}matchAll(e,t){let i=jt(this.spec,e,0,e.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=jt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function qt(n,e,t,i){return new af(e,n.search,n.caseSensitive?void 0:{ignoreCase:!0},t,i)}class C1 extends uf{nextMatch(e,t,i){let s=qt(this.spec,e,i,e.length).next();return s.done&&(s=qt(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=qt(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.length)}getReplacement(e){return this.spec.replace.replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=qt(this.spec,e,0,e.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=qt(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Fi=N.define(),go=N.define(),bt=ge.define({create(n){return new zs($r(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Fi)?n=new zs(t.value.create(),n.panel):t.is(go)&&(n=new zs(n.query,t.value?yo:null));return n},provide:n=>Ei.from(n,e=>e.panel)});class zs{constructor(e,t){this.query=e,this.panel=t}}const A1=B.mark({class:"cm-searchMatch"}),M1=B.mark({class:"cm-searchMatch cm-searchMatch-selected"}),O1=se.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(bt))}update(n){let e=n.state.field(bt);(e!=n.startState.field(bt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return B.none;let{view:t}=this,i=new wt;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state.doc,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?M1:A1)})}return i.finish()}},{decorations:n=>n.decorations});function ji(n){return e=>{let t=e.state.field(bt,!1);return t&&t.query.spec.valid?n(e,t):df(e)}}const jn=ji((n,{query:e})=>{let{from:t,to:i}=n.state.selection.main,s=e.nextMatch(n.state.doc,t,i);return!s||s.from==t&&s.to==i?!1:(n.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:bo(n,s),userEvent:"select.search"}),!0)}),qn=ji((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main,r=e.prevMatch(t.doc,i,s);return r?(n.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:bo(n,r),userEvent:"select.search"}),!0):!1}),D1=ji((n,{query:e})=>{let t=e.matchAll(n.state.doc,1e3);return!t||!t.length?!1:(n.dispatch({selection:w.create(t.map(i=>w.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),T1=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new ni(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(w.range(l.value.from,l.value.to))}return e(n.update({selection:w.create(r,o),userEvent:"select.search.matches"})),!0},ea=ji((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t.doc,i,i);if(!r)return!1;let o=[],l,a,h=[];if(r.from==i&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t.doc,r.from,r.to),h.push(D.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),r){let c=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l={anchor:r.from-c,head:r.to-c},h.push(bo(n,r))}return n.dispatch({changes:o,selection:l,scrollIntoView:!!l,effects:h,userEvent:"input.replace"}),!0}),P1=ji((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state.doc,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:D.announce.of(i),userEvent:"input.replace.all"}),!0});function yo(n){return n.state.facet(mo).createPanel(n)}function $r(n,e){var t;let i=n.selection.main,s=i.empty||i.to>i.from+100?"":n.sliceDoc(i.from,i.to),r=(t=e==null?void 0:e.caseSensitive)!==null&&t!==void 0?t:n.facet(mo).caseSensitive;return e&&!s?e:new ff({search:s.replace(/\n/g,"\\n"),caseSensitive:r})}const df=n=>{let e=n.state.field(bt,!1);if(e&&e.panel){let t=Li(n,yo);if(!t)return!1;let i=t.dom.querySelector("[main-field]");if(i&&i!=n.root.activeElement){let s=$r(n.state,e.query.spec);s.valid&&n.dispatch({effects:Fi.of(s)}),i.focus(),i.select()}}else n.dispatch({effects:[go.of(!0),e?Fi.of($r(n.state,e.query.spec)):N.appendConfig.of(E1)]});return!0},pf=n=>{let e=n.state.field(bt,!1);if(!e||!e.panel)return!1;let t=Li(n,yo);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:go.of(!1)}),!0},R1=[{key:"Mod-f",run:df,scope:"editor search-panel"},{key:"F3",run:jn,shift:qn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:jn,shift:qn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:pf,scope:"editor search-panel"},{key:"Mod-Shift-l",run:T1},{key:"Alt-g",run:f1},{key:"Mod-d",run:v1,preventDefault:!0}];class B1{constructor(e){this.view=e;let t=this.query=e.state.field(bt).query.spec;this.commit=this.commit.bind(this),this.searchField=Y("input",{value:t.search,placeholder:Ne(e,"Find"),"aria-label":Ne(e,"Find"),class:"cm-textfield",name:"search","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Y("input",{value:t.replace,placeholder:Ne(e,"Replace"),"aria-label":Ne(e,"Replace"),class:"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit}),this.caseField=Y("input",{type:"checkbox",name:"case",checked:t.caseSensitive,onchange:this.commit}),this.reField=Y("input",{type:"checkbox",name:"re",checked:t.regexp,onchange:this.commit});function i(s,r,o){return Y("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=Y("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>jn(e),[Ne(e,"next")]),i("prev",()=>qn(e),[Ne(e,"previous")]),i("select",()=>D1(e),[Ne(e,"all")]),Y("label",null,[this.caseField,Ne(e,"match case")]),Y("label",null,[this.reField,Ne(e,"regexp")]),...e.state.readOnly?[]:[Y("br"),this.replaceField,i("replace",()=>ea(e),[Ne(e,"replace")]),i("replaceAll",()=>P1(e),[Ne(e,"replace all")]),Y("button",{name:"close",onclick:()=>pf(e),"aria-label":Ne(e,"close"),type:"button"},["\xD7"])]])}commit(){let e=new ff({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Fi.of(e)}))}keydown(e){_p(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?qn:jn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ea(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Fi)&&!i.value.eq(this.query)&&this.setQuery(i.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}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(mo).top}}function Ne(n,e){return n.state.phrase(e)}const on=30,ln=/[\s\.,:;?!]/;function bo(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-on),o=Math.min(s,t+on),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<on;a++)if(!ln.test(l[a+1])&&ln.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-on;a--)if(!ln.test(l[a-1])&&ln.test(l[a])){l=l.slice(0,a);break}}return D.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const L1=D.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"}}),E1=[bt,oi.lowest(O1),L1];class mf{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=we(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),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(gf(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function ta(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function I1(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=ta(e)+ta(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function N1(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:I1(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class ia{constructor(e,t,i){this.completion=e,this.source=t,this.match=i}}function xt(n){return n.selection.main.head}function gf(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}function F1(n,e,t,i){return Object.assign(Object.assign({},n.changeByRange(s=>{if(s==n.selection.main)return{changes:{from:t,to:i,insert:e},range:w.cursor(t+e.length)};let r=i-t;return!s.empty||r&&n.sliceDoc(s.from-r,s.from)!=n.sliceDoc(t,i)?{range:s}:{changes:{from:s.from-r,to:s.from,insert:e},range:w.cursor(s.from-r+e.length)}})),{userEvent:"input.complete"})}function yf(n,e){const t=e.completion.apply||e.completion.label;let i=e.source;typeof t=="string"?n.dispatch(F1(n.state,t,i.from,i.to)):t(n,e.completion,i.from,i.to)}const na=new WeakMap;function V1(n){if(!Array.isArray(n))return n;let e=na.get(n);return e||na.set(n,e=N1(n)),e}class W1{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t<e.length;){let i=ue(e,t),s=Re(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(ue(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}match(e){if(this.pattern.length==0)return[0];if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let v=ue(e,0);return v==t[0]?[0,0,Re(v)]:v==i[0]?[-200,0,Re(v)]:null}let l=e.indexOf(this.pattern);if(l==0)return[0,0,this.pattern.length];let a=t.length,h=0;if(l<0){for(let v=0,M=Math.min(e.length,200);v<M&&h<a;){let S=ue(e,v);(S==t[h]||S==i[h])&&(s[h++]=v),v+=Re(S)}if(h<a)return null}let c=0,f=0,u=!1,d=0,m=-1,y=-1,x=/[a-z]/.test(e),b=!0;for(let v=0,M=Math.min(e.length,200),S=0;v<M&&f<a;){let C=ue(e,v);l<0&&(c<a&&C==t[c]&&(r[c++]=v),d<a&&(C==t[d]||C==i[d]?(d==0&&(m=v),y=v+1,d++):d=0));let k,O=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(k=Gr(C))!=k.toLowerCase()?1:k!=k.toUpperCase()?2:0;(!v||O==1&&x||S==0&&O!=0)&&(t[f]==C||i[f]==C&&(u=!0)?o[f++]=v:o.length&&(b=!1)),S=O,v+=Re(C)}return f==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,e):d==a&&m==0?[-200-e.length,0,y]:l>-1?[-700-e.length,l,l+this.pattern.length]:d==a?[-200+-700-e.length,m,y]:f==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[e-i.length],r=1;for(let o of t){let l=o+(this.astral?Re(ue(i,o)):1);r>1&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return s}}const At=R.define({combine(n){return ot(n,{activateOnTyping:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[]},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,optionClass:(e,t)=>i=>H1(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function H1(n,e){return n?e?n+" "+e:n:e}function z1(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s){let r=document.createElement("span");r.className="cm-completionLabel";let{label:o}=t,l=0;for(let a=1;a<s.length;){let h=s[a++],c=s[a++];h>l&&r.appendChild(document.createTextNode(o.slice(l,h)));let f=r.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(h,c))),f.className="cm-completionMatchedText",l=c}return l<o.length&&r.appendChild(document.createTextNode(o.slice(l))),r},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function sa(n,e,t){if(n<=t)return{from:0,to:n};if(e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class $1{constructor(e,t){this.view=e,this.stateField=t,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:l=>this.positionInfo(l),key:this};let i=e.state.field(t),{options:s,selected:r}=i.open,o=e.state.facet(At);this.optionContent=z1(o),this.optionClass=o.optionClass,this.range=sa(s.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",l=>{for(let a=l.target,h;a&&a!=this.dom;a=a.parentNode)if(a.nodeName=="LI"&&(h=/-(\d+)$/.exec(a.id))&&+h[1]<s.length){yf(e,s[+h[1]]),l.preventDefault();return}}),this.list=this.dom.appendChild(this.createListBox(s,i.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})}mount(){this.updateSel()}update(e){e.state.field(this.stateField)!=e.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=sa(t.options.length,t.selected,this.view.state.facet(At).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})),this.updateSelectedOption(t.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o)}).catch(o=>Ie(this.view.state,o,"completion info")):this.addInfoPane(r)}}addInfoPane(e){let t=this.info=document.createElement("div");t.className="cm-tooltip cm-completionInfo",t.appendChild(e),this.dom.appendChild(t),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&q1(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect();if(s.top>Math.min(innerHeight,t.bottom)-10||s.bottom<Math.max(0,t.top)+10)return null;let r=Math.max(0,Math.min(s.top,innerHeight-i.height))-t.top,o=this.view.textDirection==ee.RTL,l=t.left,a=innerWidth-t.right;return o&&l<Math.min(i.width,a)?o=!1:!o&&a<Math.min(i.width,l)&&(o=!0),{top:r,left:o}}positionInfo(e){this.info&&(this.info.style.top=(e?e.top:-1e6)+"px",e&&(this.info.classList.toggle("cm-completionInfo-left",e.left),this.info.classList.toggle("cm-completionInfo-right",!e.left)))}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let r=i.from;r<i.to;r++){let{completion:o,match:l}=e[r];const a=s.appendChild(document.createElement("li"));a.id=t+"-"+r,a.setAttribute("role","option");let h=this.optionClass(o);h&&(a.className=h);for(let c of this.optionContent){let f=c(o,this.view.state,l);f&&a.appendChild(f)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}}function j1(n){return e=>new $1(e,n)}function q1(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect();i.top<t.top?n.scrollTop-=t.top-i.top:i.bottom>t.bottom&&(n.scrollTop+=i.bottom-t.bottom)}function ra(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function U1(n,e){let t=[],i=0;for(let o of n)if(o.hasResult())if(o.result.filter===!1){let l=o.result.getMatch;for(let a of o.result.options){let h=[1e9-i++];if(l)for(let c of l(a))h.push(c);t.push(new ia(a,o,h))}}else{let l=new W1(e.sliceDoc(o.from,o.to)),a;for(let h of o.result.options)(a=l.match(h.label))&&(h.boost!=null&&(a[0]+=h.boost),t.push(new ia(h,o,a)))}let s=[],r=null;for(let o of t.sort(J1))!r||r.label!=o.completion.label||r.detail!=o.completion.detail||r.type!=null&&o.completion.type!=null&&r.type!=o.completion.type||r.apply!=o.completion.apply?s.push(o):ra(o.completion)>ra(r)&&(s[s.length-1]=o),r=o.completion;return s}class Ai{constructor(e,t,i,s,r){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ai(this.options,oa(t,e),this.tooltip,this.timestamp,e)}static build(e,t,i,s,r){let o=U1(e,t);if(!o.length)return null;let l=0;if(s&&s.selected){let a=s.options[s.selected].completion;for(let h=0;h<o.length;h++)if(o[h].completion==a){l=h;break}}return new Ai(o,oa(i,l),{pos:e.reduce((a,h)=>h.hasResult()?Math.min(a,h.from):a,1e8),create:j1(Fe),above:r.aboveCursor},s?s.timestamp:Date.now(),l)}map(e){return new Ai(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}}class Un{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Un(Q1,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(At),r=(i.override||t.languageDataAt("autocomplete",xt(t)).map(V1)).map(l=>(this.active.find(h=>h.source==l)||new Me(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!G1(r,this.active)?Ai.build(r,t,this.id,this.open,i):this.open&&e.docChanged?this.open.map(e.changes):this.open;!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new Me(l.source,0):l));for(let l of e.effects)l.is(xf)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new Un(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:K1}}function G1(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult;)t++;for(;i<e.length&&!e[i].hasResult;)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const K1={"aria-autocomplete":"list"};function oa(n,e){return{"aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":n+"-"+e,"aria-controls":n}}const Q1=[];function J1(n,e){let t=e.match[0]-n.match[0];return t||n.completion.label.localeCompare(e.completion.label)}function jr(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class Me{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=jr(e),s=this;i?s=s.handleUserEvent(e,i,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new Me(s.source,0));for(let r of e.effects)if(r.is(xo))s=new Me(s.source,1,r.value?xt(e.state):-1);else if(r.is(Gn))s=new Me(s.source,0);else if(r.is(bf))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new Me(this.source,1)}handleChange(e){return e.changes.touchesRange(xt(e.startState))?new Me(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Me(this.source,this.state,e.mapPos(this.explicitPos))}}class Mi extends Me{constructor(e,t,i,s,r){super(e,2,t),this.result=i,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,i){var s;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=xt(e.state);if((this.explicitPos<0?l<=r:l<this.from)||l>o||t=="delete"&&xt(e.startState)==this.from)return new Me(this.source,t=="input"&&i.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),h;return Y1(this.result.validFor,e.state,r,o)?new Mi(this.source,a,this.result,r,o):this.result.update&&(h=this.result.update(this.result,r,o,new mf(e.state,l,a>=0)))?new Mi(this.source,a,h,h.from,(s=h.to)!==null&&s!==void 0?s:xt(e.state)):new Me(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Me(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Mi(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function Y1(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):gf(n,!0).test(s)}const xo=N.define(),Gn=N.define(),bf=N.define({map(n,e){return n.map(t=>t.map(e))}}),xf=N.define(),Fe=ge.define({create(){return Un.start()},update(n,e){return n.update(e)},provide:n=>[to.from(n,e=>e.tooltip),D.contentAttributes.from(n,e=>e.attrs)]}),wf=75;function an(n,e="option"){return t=>{let i=t.state.field(Fe,!1);if(!i||!i.open||Date.now()-i.open.timestamp<wf)return!1;let s=1,r;e=="page"&&(r=Hm(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let o=i.open.selected+s*(n?1:-1),{length:l}=i.open.options;return o<0?o=e=="page"?0:l-1:o>=l&&(o=e=="page"?l-1:0),t.dispatch({effects:xf.of(o)}),!0}}const X1=n=>{let e=n.state.field(Fe,!1);return n.state.readOnly||!e||!e.open||Date.now()-e.open.timestamp<wf?!1:(yf(n,e.open.options[e.open.selected]),!0)},Z1=n=>n.state.field(Fe,!1)?(n.dispatch({effects:xo.of(!0)}),!0):!1,_1=n=>{let e=n.state.field(Fe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Gn.of(null)}),!0)};class ey{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const la=50,ty=50,iy=1e3,ny=se.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of n.state.field(Fe).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Fe);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Fe)==e)return;let t=n.transactions.some(i=>(i.selection||i.docChanged)&&!jr(i));for(let i=0;i<this.running.length;i++){let s=this.running[i];if(t||s.updates.length+n.transactions.length>ty&&Date.now()-s.time>iy){for(let r of s.context.abortListeners)try{r()}catch(o){Ie(this.view.state,o)}s.context.abortListeners=null,this.running.splice(i--,1)}else s.updates.push(...n.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(i=>i.state==1&&!this.running.some(s=>s.active.source==i.source))?setTimeout(()=>this.startUpdate(),la):-1,this.composing!=0)for(let i of n.transactions)jr(i)=="input"?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:n}=this.view,e=n.field(Fe);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=xt(e),i=new mf(e,t,n.explicitPos==t),s=new ey(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Gn.of(null)}),Ie(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),la))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(At);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=new Mi(s.active.source,s.active.explicitPos,s.done,s.done.from,(n=s.done.to)!==null&&n!==void 0?n:xt(s.updates.length?s.updates[0].startState:this.view.state));for(let l of s.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let r=this.view.state.field(Fe).active.find(o=>o.source==s.active.source);if(r&&r.state==1)if(s.done==null){let o=new Me(s.active.source,0);for(let l of s.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:bf.of(e)})}},{eventHandlers:{blur(){let n=this.view.state.field(Fe,!1);n&&n.tooltip&&this.view.state.facet(At).closeOnBlur&&this.view.dispatch({effects:Gn.of(null)})},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:xo.of(!1)}),20),this.composing=0}}}),sy=D.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",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",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"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Kn={brackets:["(","[","{","'",'"'],before:")]}:;>"},Lt=N.define({map(n,e){let t=e.mapPos(n,-1,Se.TrackAfter);return t==null?void 0:t}}),wo=N.define({map(n,e){return e.mapPos(n)}}),ko=new class extends Nt{};ko.startSide=1;ko.endSide=-1;const kf=ge.define({create(){return G.empty},update(n,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,i=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(i,-1)&&(n=G.empty)}n=n.map(e.changes);for(let t of e.effects)t.is(Lt)?n=n.update({add:[ko.range(t.value,t.value+1)]}):t.is(wo)&&(n=n.update({filter:i=>i!=t.value}));return n}});function ry(){return[ly,kf]}const $s="()[]{}<>";function vf(n){for(let e=0;e<$s.length;e+=2)if($s.charCodeAt(e)==n)return $s.charAt(e+1);return Gr(n<128?n:n+1)}function Sf(n,e){return n.languageDataAt("closeBrackets",e)[0]||Kn}const oy=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ly=D.inputHandler.of((n,e,t,i)=>{if((oy?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Re(ue(i,0))==1||e!=s.from||t!=s.to)return!1;let r=cy(n.state,i);return r?(n.dispatch(r),!0):!1}),ay=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Sf(n,n.selection.main.head).brackets||Kn.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=fy(n.doc,o.head);for(let a of i)if(a==l&&ds(n.doc,o.head)==vf(ue(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:w.cursor(o.head-a.length),userEvent:"delete.backward"}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0})),!s},hy=[{key:"Backspace",run:ay}];function cy(n,e){let t=Sf(n,n.selection.main.head),i=t.brackets||Kn.brackets;for(let s of i){let r=vf(ue(s,0));if(e==s)return r==s?py(n,s,i.indexOf(s+s+s)>-1):uy(n,s,r,t.before||Kn.before);if(e==r&&Cf(n,n.selection.main.from))return dy(n,s,r)}return null}function Cf(n,e){let t=!1;return n.field(kf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function ds(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Re(ue(t,0)))}function fy(n,e){let t=n.sliceString(e-2,e);return Re(ue(t,0))==t.length?t:t.slice(1)}function uy(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Lt.of(o.to+e.length),range:w.range(o.anchor+e.length,o.head+e.length)};let l=ds(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Lt.of(o.head+e.length),range:w.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function dy(n,e,t){let i=null,s=n.selection.ranges.map(r=>r.empty&&ds(n.doc,r.head)==t?w.cursor(r.head+t.length):i=r);return i?null:n.update({selection:w.create(s,n.selection.mainIndex),scrollIntoView:!0,effects:n.selection.ranges.map(({from:r})=>wo.of(r))})}function py(n,e,t){let i=null,s=n.changeByRange(r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:e,from:r.to}],effects:Lt.of(r.to+e.length),range:w.range(r.anchor+e.length,r.head+e.length)};let o=r.head,l=ds(n.doc,o);if(l==e){if(aa(n,o))return{changes:{insert:e+e,from:o},effects:Lt.of(o+e.length),range:w.cursor(o+e.length)};if(Cf(n,o)){let a=t&&n.sliceDoc(o,o+e.length*3)==e+e+e;return{range:w.cursor(o+e.length*(a?3:1)),effects:wo.of(o)}}}else{if(t&&n.sliceDoc(o-2*e.length,o)==e+e&&aa(n,o-2*e.length))return{changes:{insert:e+e+e+e,from:o},effects:Lt.of(o+e.length),range:w.cursor(o+e.length)};if(n.charCategorizer(o)(l)!=Ce.Word){let a=n.sliceDoc(o-1,o);if(a!=e&&n.charCategorizer(o)(a)!=Ce.Word&&!my(n,o,e))return{changes:{insert:e+e,from:o},effects:Lt.of(o+e.length),range:w.cursor(o+e.length)}}}return{range:i=r}});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function aa(n,e){let t=we(n).resolveInner(e+1);return t.parent&&t.from==e}function my(n,e,t){let i=we(n).resolveInner(e,-1);for(let s=0;s<5;s++){if(n.sliceDoc(i.from,i.from+t.length)==t){let o=i.firstChild;for(;o&&o.from==i.from&&o.to-o.from>t.length;){if(n.sliceDoc(o.to-t.length,o.to)==t)return!1;o=o.firstChild}return!0}let r=i.to==e&&i.parent;if(!r)break;i=r}return!1}function gy(n={}){return[Fe,At.of(n),ny,yy,sy]}const Af=[{key:"Ctrl-Space",run:Z1},{key:"Escape",run:_1},{key:"ArrowDown",run:an(!0)},{key:"ArrowUp",run:an(!1)},{key:"PageDown",run:an(!0,"page")},{key:"PageUp",run:an(!1,"page")},{key:"Enter",run:X1}],yy=oi.highest(ss.computeN([At],n=>n.facet(At).defaultKeymap?[Af]:[]));class by{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Pt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet(Gt).markerFilter;r&&(s=r(s));let o=B.set(s.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?B.widget({widget:new Dy(l),diagnostic:l}).range(l.from):B.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity},diagnostic:l}).range(l.from,l.to)),!0);return new Pt(o,t,si(o))}}function si(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new by(s,r,o.diagnostic),!1}),i}function xy(n,e){return!!(n.effects.some(t=>t.is(vo))||n.changes.touchesRange(e.pos))}function Mf(n,e){return n.field(Ee,!1)?e:e.concat(N.appendConfig.of([Ee,D.decorations.compute([Ee],t=>{let{selected:i,panel:s}=t.field(Ee);return!i||!s||i.from==i.to?B.none:B.set([ky.range(i.from,i.to)])}),Wm(vy,{hideOn:xy}),Py]))}function wy(n,e){return{effects:Mf(n,[vo.of(e)])}}const vo=N.define(),So=N.define(),Of=N.define(),Ee=ge.define({create(){return new Pt(B.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=si(t,n.selected.diagnostic,s)||si(t,null,s)}n=new Pt(t,n.panel,i)}for(let t of e.effects)t.is(vo)?n=Pt.init(t.value,n.panel,e.state):t.is(So)?n=new Pt(n.diagnostics,t.value?ps.open:null,n.selected):t.is(Of)&&(n=new Pt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Ei.from(n,e=>e.panel),D.decorations.from(n,e=>e.diagnostics)]}),ky=B.mark({class:"cm-lintRange cm-lintRange-active"});function vy(n,e,t){let{diagnostics:i}=n.state.field(Ee),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0))&&(s.push(c.diagnostic),r=Math.min(a,r),o=Math.max(h,o))});let l=n.state.facet(Gt).tooltipFilter;return l&&(s=l(s)),s.length?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:Sy(n,s)}}}:null}function Sy(n,e){return Y("ul",{class:"cm-tooltip-lint"},e.map(t=>Tf(n,t,!1)))}const Cy=n=>{let e=n.state.field(Ee,!1);(!e||!e.panel)&&n.dispatch({effects:Mf(n.state,[So.of(!0)])});let t=Li(n,ps.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},ha=n=>{let e=n.state.field(Ee,!1);return!e||!e.panel?!1:(n.dispatch({effects:So.of(!1)}),!0)},Ay=n=>{let e=n.state.field(Ee,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},My=[{key:"Mod-Shift-m",run:Cy},{key:"F8",run:Ay}],Oy=se.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(Gt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(n<this.lintTime-10)setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(Gt);Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let s=i.reduce((r,o)=>r.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(wy(this.view.state,s))},i=>{Ie(this.view.state,i)})}}update(n){let e=n.state.facet(Gt);(n.docChanged||e!=n.startState.facet(Gt))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),Gt=R.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},ot(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null}))},enables:Oy});function Df(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Tf(n,e,t){var i;let s=t?Df(e.actions):[];return Y("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Y("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=f=>{f.preventDefault();let u=si(n.state.field(Ee).diagnostics,e);u&&r.apply(n,u.from,u.to)},{name:a}=r,h=s[o]?a.indexOf(s[o]):-1,c=h<0?a:[a.slice(0,h),Y("u",a.slice(h,h+1)),a.slice(h+1)];return Y("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${a}${h<0?"":` (access key "${s[o]})"`}.`},c)}),e.source&&Y("div",{class:"cm-diagnosticSource"},e.source))}class Dy extends lt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return Y("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class ca{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Tf(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ps{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)ha(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Df(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=si(this.view.state.field(Ee).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=Y("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=Y("div",{class:"cm-panel-lint"},this.list,Y("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>ha(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Ee).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(Ee),i=0,s=!1,r=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new ca(this.view,a.diagnostic),this.items.splice(i,0,c),s=!0):(c=this.items[h],h>i&&(this.items.splice(i,h-i),s=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),r=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new ca(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{o.top<l.top?this.list.scrollTop-=l.top-o.top:o.bottom>l.bottom&&(this.list.scrollTop+=o.bottom-l.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ee),i=si(t.diagnostics,this.items[e].diagnostic);!i||this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Of.of(i)})}static open(e){return new ps(e)}}function Ty(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function js(n){return Ty(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Py=D.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-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:js("#d11")},".cm-lintRange-warning":{backgroundImage:js("orange")},".cm-lintRange-info":{backgroundImage:js("#999")},".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-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}}});var fa=function(e){e===void 0&&(e={});var t=[];e.closeBracketsKeymap!==!1&&(t=t.concat(hy)),e.defaultKeymap!==!1&&(t=t.concat(a1)),e.searchKeymap!==!1&&(t=t.concat(R1)),e.historyKeymap!==!1&&(t=t.concat(x0)),e.foldKeymap!==!1&&(t=t.concat(Eg)),e.completionKeymap!==!1&&(t=t.concat(Af)),e.lintKeymap!==!1&&(t=t.concat(My));var i=[];return e.lineNumbers!==!1&&i.push(Jm()),e.highlightActiveLineGutter!==!1&&i.push(Zm()),e.highlightSpecialChars!==!1&&i.push(pm()),e.history!==!1&&i.push(c0()),e.foldGutter!==!1&&i.push(Fg()),e.drawSelection!==!1&&i.push(im()),e.dropCursor!==!1&&i.push(am()),e.allowMultipleSelections!==!1&&i.push(H.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(Cg()),e.syntaxHighlighting!==!1&&i.push(ho(zg,{fallback:!0})),e.bracketMatching!==!1&&i.push(Qg()),e.closeBrackets!==!1&&i.push(ry()),e.autocompletion!==!1&&i.push(gy()),e.rectangularSelection!==!1&&i.push(Dm()),e.crosshairCursor!==!1&&i.push(Rm()),e.highlightActiveLine!==!1&&i.push(wm()),e.highlightSelectionMatches!==!1&&i.push(p1()),e.tabSize&&typeof e.tabSize=="number"&&i.push(rs.of(" ".repeat(e.tabSize))),i.concat([ss.of(t.flat())]).filter(Boolean)};const Ry="#e5c07b",ua="#e06c75",By="#56b6c2",Ly="#ffffff",yn="#abb2bf",qr="#7d8799",Ey="#61afef",Iy="#98c379",da="#d19a66",Ny="#c678dd",Fy="#21252b",qs="#2c313a",pa="#282c34",Us="#353a42",Vy="#3E4451",ma="#528bff",Wy=D.theme({"&":{color:yn,backgroundColor:pa},".cm-content":{caretColor:ma},".cm-cursor, .cm-dropCursor":{borderLeftColor:ma},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Vy},".cm-panels":{backgroundColor:Fy,color:yn},".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:qs},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{backgroundColor:pa,color:qr,border:"none"},".cm-activeLineGutter":{backgroundColor:qs},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Us},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Us,borderBottomColor:Us},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:qs,color:yn}}},{dark:!0}),Hy=li.define([{tag:g.keyword,color:Ny},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:ua},{tag:[g.function(g.variableName),g.labelName],color:Ey},{tag:[g.color,g.constant(g.name),g.standard(g.name)],color:da},{tag:[g.definition(g.name),g.separator],color:yn},{tag:[g.typeName,g.className,g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:Ry},{tag:[g.operator,g.operatorKeyword,g.url,g.escape,g.regexp,g.link,g.special(g.string)],color:By},{tag:[g.meta,g.comment],color:qr},{tag:g.strong,fontWeight:"bold"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strikethrough,textDecoration:"line-through"},{tag:g.link,color:qr,textDecoration:"underline"},{tag:g.heading,fontWeight:"bold",color:ua},{tag:[g.atom,g.bool,g.special(g.variableName)],color:da},{tag:[g.processingInstruction,g.string,g.inserted],color:Iy},{tag:g.invalid,color:Ly}]),zy=[Wy,ho(Hy)];var $y=n=>({line:n.state.doc.lineAt(n.state.selection.main.from),lineCount:n.state.doc.lines,lineBreak:n.state.lineBreak,length:n.state.doc.length,readOnly:n.state.readOnly,tabSize:n.state.tabSize,selection:n.state.selection,selectionAsSingle:n.state.selection.asSingle().main,ranges:n.state.selection.ranges,selectionCode:n.state.sliceDoc(n.state.selection.main.from,n.state.selection.main.to),selections:n.state.selection.ranges.map(e=>n.state.sliceDoc(e.from,e.to)),selectedText:n.state.selection.ranges.some(e=>!e.empty)});function jy(n){var{value:e,selection:t,onChange:i,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=[],autoFocus:a,theme:h="light",height:c="",minHeight:f="",maxHeight:u="",placeholder:d="",width:m="",minWidth:y="",maxWidth:x="",editable:b=!0,readOnly:v=!1,indentWithTab:M=!0,basicSetup:S=!0,root:C,initialState:k}=n,[O,F]=I.exports.useState(),[T,E]=I.exports.useState(),[W,q]=I.exports.useState(),J=D.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ye=D.theme({"&":{height:c,minHeight:f,maxHeight:u,width:m,minWidth:y,maxWidth:x}}),oe=D.updateListener.of(te=>{if(te.docChanged&&typeof i=="function"){var Z=te.state.doc,be=Z.toString();i(be,te)}s&&s($y(te))}),$=[oe,ye];switch(M&&$.unshift(ss.of([h1])),S&&(typeof S=="boolean"?$.unshift(fa()):$.unshift(fa(S))),d&&$.unshift(Cm(d)),h){case"light":$.push(J);break;case"dark":$.push(zy);break;default:$.push(h);break}return b===!1&&$.push(D.editable.of(!1)),v&&$.push(H.readOnly.of(!0)),o&&typeof o=="function"&&$.push(D.updateListener.of(o)),$=$.concat(l),I.exports.useEffect(()=>{if(O&&!W){var te={doc:e,selection:t,extensions:$},Z=k?H.fromJSON(k.json,te,k.fields):H.create(te);if(q(Z),!T){var be=new D({state:Z,parent:O,root:C});E(be),r&&r(be,Z)}}return()=>{T&&(q(void 0),E(void 0))}},[O,W]),I.exports.useEffect(()=>F(n.container),[n.container]),I.exports.useEffect(()=>()=>{T&&(T.destroy(),E(void 0))},[T]),I.exports.useEffect(()=>{a&&T&&T.focus()},[a,T]),I.exports.useEffect(()=>{T&&T.dispatch({effects:N.reconfigure.of($)})},[h,l,c,f,u,m,y,x,d,b,v,M,S,i,o]),I.exports.useEffect(()=>{var te=T?T.state.doc.toString():"";T&&e!==te&&T.dispatch({changes:{from:0,to:te.length,insert:e||""}})},[e,T]),{state:W,setState:q,view:T,setView:E,container:O,setContainer:F}}var qy=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Pf=I.exports.forwardRef((n,e)=>{var{className:t,value:i="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,autoFocus:c,theme:f="light",height:u,minHeight:d,maxHeight:m,width:y,minWidth:x,maxWidth:b,basicSetup:v,placeholder:M,indentWithTab:S,editable:C,readOnly:k,root:O,initialState:F}=n,T=yd(n,qy),E=I.exports.useRef(null),{state:W,view:q,container:J,setContainer:ye}=jy({container:E.current,root:O,value:i,autoFocus:c,theme:f,height:u,minHeight:d,maxHeight:m,width:y,minWidth:x,maxWidth:b,basicSetup:v,placeholder:M,indentWithTab:S,editable:C,readOnly:k,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,extensions:r,initialState:F});if(I.exports.useImperativeHandle(e,()=>({editor:E.current,state:W,view:q}),[E,J,W,q]),typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var oe=typeof f=="string"?"cm-theme-"+f:"cm-theme";return p("div",er({ref:E,className:""+oe+(t?" "+t:"")},T))});Pf.displayName="CodeMirror";class Qn{constructor(e,t,i,s,r,o,l,a,h,c=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new Qn(e,[],t,i,i,0,[],0,s?new ga(s,s.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){let t=e>>19,i=e&65535,{parser:s}=this.p,r=s.dynamicPrecedence(i);if(r&&(this.score+=r),t==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),l=this.stack[o-2],a=this.stack[o-1],h=this.bufferBase+this.buffer.length-a;if(i<s.minRepeatTerm||e&131072){let c=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,l,c,h+4,!0)}if(e&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=s.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,l)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i){let s=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(r,1)||(this.reducePos=i)),this.pushState(r,s),this.shiftContext(t,s),t<=o.maxNode&&this.buffer.push(t,s,i,4)}else this.pos=i,this.shiftContext(t,s),t<=this.p.parser.maxNode&&this.buffer.push(t,s,i,4)}apply(e,t,i){e&65536?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,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 i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new Qn(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Uy(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if((i&65536)==0)return!0;if(i==0)return!1;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let s=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[r],o);if(this.stack.length<120)for(let r=0;s.length<4<<1&&r<t.length;r+=2){let o=t[r+1];s.some((l,a)=>a&1&&l==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s<t.length&&i.length<4;s+=2){let r=t[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],this.pos),o.score-=200,i.push(o)}return i}forceReduce(){let e=this.p.parser.stateSlot(this.state,5);if((e&65536)==0)return!1;let{parser:t}=this.p;if(!t.validAction(this.state,e)){let i=e>>19,s=e&65535,r=this.stack.length-i*3;if(r<0||t.getGoto(this.stack[r],s,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.reducePos,this.reducePos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.reducePos,this.reducePos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new ga(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class ga{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var ya;(function(n){n[n.Insert=200]="Insert",n[n.Delete=190]="Delete",n[n.Reduce=100]="Reduce",n[n.MaxNext=4]="MaxNext",n[n.MaxInsertStackDepth=300]="MaxInsertStackDepth",n[n.DampenInsertStackDepth=120]="DampenInsertStackDepth"})(ya||(ya={}));class Uy{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class Jn{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Jn(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Jn(this.stack,this.pos,this.index)}}class bn{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const ba=new bn;class Gy{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=ba,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 i=this.range,s=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!s)return null;let o=this.ranges[--s];r-=i.from-o.to,i=o}for(;t<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}peek(e){let t=this.chunkOff+e,i,s;if(t>=0&&t<this.chunk.length)i=this.pos+e,s=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}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=ba,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 i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class xn{constructor(e,t){this.data=e,this.id=t}token(e,t){Ky(this.data,e,t,this.id)}}xn.prototype.contextual=xn.prototype.fallback=xn.prototype.extend=!1;function Ky(n,e,t,i){let s=0,r=1<<i,{parser:o}=t.p,{dialect:l}=o;e:for(;(r&n[s])!=0;){let a=n[s+1];for(let u=s+3;u<a;u+=2)if((n[u+1]&r)>0){let d=n[u];if(l.allows(d)&&(e.token.value==-1||e.token.value==d||o.overrides(d,e.token.value))){e.acceptToken(d);break}}let h=e.next,c=0,f=n[s+2];if(e.next<0&&f>c&&n[a+f*3-3]==65535){s=n[a+f*3-1];continue e}for(;c<f;){let u=c+f>>1,d=a+u+(u<<1),m=n[d],y=n[d+1];if(h<m)f=u;else if(h>=y)c=u+1;else{s=n[d+2],e.advance();continue e}}break}}function hn(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i<n.length;){let r=0;for(;;){let o=n.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}const He=typeof process<"u"&&process.env&&/\bparse\b/.test({}.LOG);let Gs=null;var xa;(function(n){n[n.Margin=25]="Margin"})(xa||(xa={}));function wa(n,e,t){let i=n.cursor(pe.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class Qy{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?wa(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?wa(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 i=this.trees[t],s=this.index[t];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],o=this.start[t]+i.positions[s];if(o>e)return this.nextStart=o,null;if(r instanceof le){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(V.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class Jy{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new bn)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let c=r[h],f=this.tokens[h];if(!(i&&!c.fallback)&&((c.contextual||f.start!=e.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,c,e),f.mask=o,f.context=l),f.lookAhead>f.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!c.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new bn,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new bn,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){if(t.token(this.stream.reset(i.pos,e),i),e.value>-1){let{parser:s}=i.p;for(let r=0;r<s.specialized.length;r++)if(s.specialized[r]==e.value){let o=s.specializers[r](this.stream.read(e.start,e.end),i);if(o>=0&&i.p.parser.dialect.allows(o>>1)){(o&1)==0?e.value=o>>1:e.extended=o>>1;break}}}else e.value=0,e.end=Math.min(i.p.stream.end,i.pos+1)}putAction(e,t,i,s){for(let r=0;r<s;r+=3)if(this.actions[r]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=i,s}addActions(e,t,i,s){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=it(l,h+2);else{s==0&&l[h+1]==2&&(s=this.putAction(it(l,h+2),t,i,s));break}l[h]==t&&(s=this.putAction(it(l,h+1),t,i,s))}return s}}var ka;(function(n){n[n.Distance=5]="Distance",n[n.MaxRemainingPerStep=3]="MaxRemainingPerStep",n[n.MinBufferLengthPrune=500]="MinBufferLengthPrune",n[n.ForceReduceLimit=10]="ForceReduceLimit",n[n.CutDepth=15e3]="CutDepth",n[n.CutTo=9e3]="CutTo"})(ka||(ka={}));class Yy{constructor(e,t,i,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.stream=new Gy(t,s),this.tokens=new Jy(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[Qn.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>e.bufferLength*4?new Qy(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&Zy(s);if(o)return this.stackToTree(o);if(this.parser.strict)throw He&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let s=e.pos,{parser:r}=this,o=He?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let f=this.fragments.nodeAt(s);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(V.contextHash)||0)==c))return e.useNode(f,u),He&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof le)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof le&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),He&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;h<a.length;){let c=a[h++],f=a[h++],u=a[h++],d=h==a.length||!i,m=d?e:e.split();if(m.apply(c,f,u),He&&console.log(o+this.stackID(m)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(f)} @ ${s}${m==e?"":", split"})`),d)return!0;m.pos>s?t.push(m):i.push(m)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return va(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],h=t[(o<<1)+1],c=He?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),He&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=c;for(let d=0;f.forceReduce()&&d<10&&(He&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)He&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))He&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),He&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),va(l,i)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),le.build({buffer:Jn.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=(Gs||(Gs=new WeakMap)).get(e);return t||Gs.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function va(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}class Xy{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class Yn extends lc{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (${14})`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),s=[];for(let l=0;l<t.length;l++)s.push([]);function r(l,a,h){s[l].push([a,a.deserialize(String(h))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=V[a]);for(let h=1;h<l.length;){let c=l[h++];if(c>=0)r(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)r(l[h++],a,f);h++}}}this.nodeSet=new no(t.map((l,a)=>Te.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=sc;let o=hn(e.tokenData);if(this.context=e.context,this.specialized=new Uint16Array(e.specialized?e.specialized.length:0),this.specializers=[],e.specialized)for(let l=0;l<e.specialized.length;l++)this.specialized[l]=e.specialized[l].term,this.specializers[l]=e.specialized[l].get;this.states=hn(e.states,Uint32Array),this.data=hn(e.stateData),this.goto=hn(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new xn(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let s=new Yy(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(s[r]==e)return a;if(l)return-1}}hasAction(e,t){let i=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(e,s?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=it(i,r+2)];else{if(i[r+1]==2)return it(i,r+2);break}if(o==t||o==0)return it(i,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=it(this.data,i+2);else return!1;if(t==it(this.data,i+1))return!0}}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=it(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}overrides(e,t){let i=Sa(this.data,this.tokenPrecTable,t);return i<0||Sa(this.data,this.tokenPrecTable,e)<i}configure(e){let t=Object.assign(Object.create(Yn.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.map(i=>{let s=e.specializers.find(r=>r.from==i);return s?s.to:i})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;r<t.length;r++)if(!i[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new Xy(e,i,s)}static deserialize(e){return new Yn(e)}}function it(n,e){return n[e]|n[e+1]<<16}function Sa(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function Zy(n){let e=null;for(let t of n){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}const _y=hc({String:g.string,Number:g.number,"True False":g.bool,PropertyName:g.propertyName,Null:g.null,",":g.separator,"[ ]":g.squareBracket,"{ }":g.brace}),eb=Yn.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"\u26A0 JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[_y],skippedNodes:[0],repeatNodeCount:2,tokenData:"(p~RaXY!WYZ!W]^!Wpq!Wrs!]|}$i}!O$n!Q!R$w!R![&V![!]&h!}#O&m#P#Q&r#Y#Z&w#b#c'f#h#i'}#o#p(f#q#r(k~!]Oc~~!`Upq!]qr!]rs!rs#O!]#O#P!w#P~!]~!wOe~~!zXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#g~#jR!Q![#s!c!i#s#T#Z#s~#vR!Q![$P!c!i$P#T#Z$P~$SR!Q![$]!c!i$]#T#Z$]~$`R!Q![!]!c!i!]#T#Z!]~$nOh~~$qQ!Q!R$w!R![&V~$|RT~!O!P%V!g!h%k#X#Y%k~%YP!Q![%]~%bRT~!Q![%]!g!h%k#X#Y%k~%nR{|%w}!O%w!Q![%}~%zP!Q![%}~&SPT~!Q![%}~&[ST~!O!P%V!Q![&V!g!h%k#X#Y%k~&mOg~~&rO]~~&wO[~~&zP#T#U&}~'QP#`#a'T~'WP#g#h'Z~'^P#X#Y'a~'fOR~~'iP#i#j'l~'oP#`#a'r~'uP#`#a'x~'}OS~~(QP#f#g(T~(WP#i#j(Z~(^P#X#Y(a~(fOQ~~(kOW~~(pOV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),tb=Nn.define({name:"json",parser:eb.configure({props:[dc.add({Object:Hl({except:/^\s*\}/}),Array:Hl({except:/^\s*\]/})}),mc.add({"Object Array":Mg})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function ib(){return new pg(tb)}var Rf=n=>{var{theme:e,settings:t,styles:i}=n,s={"&":{backgroundColor:t.background,color:t.foreground},".cm-gutters":{}};t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var r={};t.gutterActiveForeground&&(r.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},r.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=r,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={backgroundColor:t.selection}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var o=D.theme(s,{dark:e==="dark"}),l=li.define(i),a=[o,ho(l)];return a},nb=Rf({theme:"light",settings:{background:"#faf8f5",foreground:"#b29762",caret:"#93abdc",selection:"#e3dcce",selectionMatch:"#e3dcce",gutterBackground:"#faf8f5",gutterForeground:"#cdc4b1",lineHighlight:"#EFEFEF"},styles:[{tag:[g.comment,g.bracket],color:"#b6ad9a"},{tag:[g.atom,g.number,g.keyword,g.link,g.attributeName,g.quote],color:"#063289"},{tag:[g.emphasis,g.heading,g.tagName,g.propertyName,g.variableName],color:"#2d2006"},{tag:[g.typeName,g.url,g.string],color:"#896724"},{tag:[g.operator,g.string],color:"#1659df"},{tag:[g.propertyName],color:"#b29762"},{tag:[g.unit,g.punctuation],color:"#063289"}]}),sb=Rf({theme:"dark",settings:{background:"#2a2734",foreground:"#6c6783",caret:"#ffad5c",selection:"rgba(255, 255, 255, 0.1)",gutterBackground:"#2a2734",gutterForeground:"#545167",lineHighlight:"#36334280"},styles:[{tag:[g.comment,g.bracket],color:"#6c6783"},{tag:[g.atom,g.number,g.keyword,g.link,g.attributeName,g.quote],color:"#ffcc99"},{tag:[g.emphasis,g.heading,g.tagName,g.propertyName,g.className,g.variableName],color:"#eeebff"},{tag:[g.typeName,g.url],color:"#7a63ee"},{tag:g.operator,color:"#ffad5c"},{tag:g.string,color:"#ffb870"},{tag:[g.propertyName],color:"#9a86fd"},{tag:[g.unit,g.punctuation],color:"#e09142"}]});const rb=re("aside")(({theme:n})=>({height:"50px",backgroundColor:n.palette.neutral.light,borderTopRightRadius:n.shape.borderRadiusMedium,borderTopLeftRadius:n.shape.borderRadiusMedium,padding:n.spacing(1,2),color:n.palette.text.primary,display:"flex",justifyContent:"space-between",alignItems:"center",border:`1px solid ${n.palette.lightBorder}`,borderBottom:"none"})),Bf=re("div")(({theme:n,style:e})=>({width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.5s ease-in-out",borderRadius:"50%",opacity:.8,...e})),ob=re("div")(({theme:n})=>({fontSize:"0.9rem",color:n.palette.error.main,marginRight:n.spacing(1)})),lb=()=>{const n=ke();return p(Bf,{style:{color:n.palette.text.tertiaryContrast,backgroundColor:n.palette.success.main},children:p(ou,{sx:{width:"20px",height:"20px"}})})},ab=()=>{const n=ke();return p(Bf,{style:{color:n.palette.text.tertiaryContrast,backgroundColor:n.palette.error.main},children:p(ku,{})})},hb=({context:n,setContext:e,error:t})=>{const{themeMode:i}=I.exports.useContext(ru),s=ke(),r=I.exports.useCallback(o=>{e(o)},[e]);return L(j,{sx:{width:"100%"},children:[L(rb,{children:["JSON",p(z,{condition:Boolean(t),show:L(j,{sx:o=>({display:"flex",alignItems:"center"}),children:[p(ob,{children:t}),p(ab,{})]}),elseShow:p(lb,{})})]}),p(Pf,{value:n,height:"200px",theme:i==="dark"?sb:nb,extensions:[ib()],onChange:r,style:{border:`1px solid ${s.palette.lightBorder}`,borderTop:"none",borderBottomLeftRadius:s.shape.borderRadiusMedium,borderBottomRightRadius:s.shape.borderRadiusMedium},placeholder:JSON.stringify({currentTime:"2022-07-04T14:13:03.929Z",appName:"playground",userId:"test",remoteAddress:"127.0.0.1"},null,2)})]})},cb=({context:n,setContext:e})=>{const t=ke(),{setToastData:i}=Ta(),{context:s}=lu(),r=s.sort((b,v)=>b.sortOrder-v.sortOrder).map(({name:b})=>b),[o,l]=I.exports.useState(),[a,h]=I.exports.useState(!1),[c,f]=I.exports.useState(""),[u,d]=I.exports.useState(""),m=I.exports.useMemo(()=>gd.debounce(b=>{if(!b)return l(void 0);try{const v=JSON.parse(b);h(v[c]!==void 0)}catch(v){return l(kn(v))}return l(void 0)},250),[l,c,h]);I.exports.useEffect(()=>{m(n)},[m,n]);const y=()=>{try{const b=JSON.parse(n||"{}");e(JSON.stringify({...b,[c]:u},null,2));const v=s.find(M=>M.name===c);if((v==null?void 0:v.legalValues)&&v.legalValues.length>0||c==="currentTime")return;d("")}catch(b){i({type:"error",title:`Error parsing context: ${kn(b)}`})}},x=()=>{if(c==="currentTime"){const v=Oo(u),M=new Date,S=v?Do(v.toISOString()):Do(M.toISOString());return p(wi,{id:"date",label:"Date",size:"small",type:"datetime-local",value:S,sx:{width:200,maxWidth:"100%"},onChange:C=>{const k=Oo(C.target.value),O=k==null?void 0:k.toISOString();O&&d(O)},InputLabelProps:{shrink:!0},required:!0})}const b=s.find(v=>v.name===c);if(b&&b.legalValues&&b.legalValues.length>0){const v=b.legalValues.map(({value:M})=>M);return p(Xs,{disablePortal:!0,id:"context-legal-values",size:"small",onChange:(M,S)=>{if(typeof S=="string")return d(S)},options:v,sx:{width:200,maxWidth:"100%"},renderInput:M=>p(wi,{...M,label:"Value"})})}return p(wi,{label:"Value",id:"context-value",sx:{width:200,maxWidth:"100%"},size:"small",value:u,onChange:v=>d(v.target.value||"")})};return L(j,{children:[L(j,{sx:{display:"flex",alignItems:"center",mb:2},children:[p(Zn,{type:"secondary",children:"2"}),p(ie,{variant:"body2",color:t.palette.text.secondary,sx:{ml:1},children:"Unleash context"})]}),L(j,{sx:{display:"flex",gap:2,flexWrap:"wrap",mb:2},children:[L(au,{children:[p(hu,{id:"context-field-label",size:"small",children:"Context field"}),p(cu,{label:"Context field",labelId:"context-field-label",id:"context-field",value:c,onChange:b=>{if(f(b.target.value||""),b.target.value==="currentTime")return d(new Date().toISOString());d("")},variant:"outlined",size:"small",sx:{width:200,maxWidth:"100%"},children:r.map(b=>p(fu,{value:b,children:b},b))})]}),x(),p(Pa,{variant:"outlined",disabled:!c||Boolean(o),onClick:y,sx:{width:"95px"},children:`${a?"Replace":"Add"} `})]}),p(hb,{context:n,setContext:e,error:o})]})},ht={label:"ALL",id:"*"},fb=({environment:n,projects:e,setProjects:t,setEnvironment:i,environmentOptions:s})=>{const r=ke(),{projects:o=[]}=uu(),l=[ht,...o.map(({name:c,id:f})=>({label:c,id:f}))],a=(c,f,u)=>{const d=f;return u==="clear"||d===null?t([ht.id]):Array.isArray(d)?d.length===0?t([ht.id]):d.find(({id:m})=>m===ht.id)!==void 0?t([ht.id]):t(d.map(({id:m})=>m)):d.id===ht.id?t([ht.id]):t([d.id])},h=e.length===0||e.length===1&&e[0]==="*";return L(j,{sx:{pb:2},children:[L(j,{sx:{display:"flex",alignItems:"center",mb:2},children:[p(Zn,{type:"secondary",children:"1"}),p(ie,{variant:"body2",color:r.palette.text.secondary,sx:{ml:1},children:"Access configuration"})]}),L(j,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[p(Xs,{disablePortal:!0,id:"environment",options:s,sx:{width:200,maxWidth:"100%"},renderInput:c=>p(wi,{...c,label:"Environment",required:!0}),value:n,onChange:(c,f)=>i(f||""),size:"small"}),p(Xs,{disablePortal:!0,id:"projects",multiple:!h,options:l,sx:{width:200,maxWidth:"100%"},renderInput:c=>p(wi,{...c,label:"Projects"}),size:"small",value:h?ht:l.filter(({id:c})=>e.includes(c)),onChange:a})]})]})},ub=({environments:n,environment:e,onSubmit:t,projects:i,setProjects:s,setEnvironment:r,context:o,setContext:l})=>{const a=ke();return L(j,{component:"form",onSubmit:t,sx:{display:"flex",flexDirection:"column"},children:[p(fb,{environment:e,projects:i,setEnvironment:r,setProjects:s,environmentOptions:Fa(n)}),p(Zs,{variant:"fullWidth",sx:{mb:2,borderColor:a.palette.dividerAlternative,borderStyle:"dashed"}}),p(cb,{context:o,setContext:l}),p(Zs,{variant:"fullWidth",sx:{mt:3,mb:2,borderColor:a.palette.dividerAlternative}}),L(j,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p(Zn,{type:"secondary",children:"3"}),p(Pa,{variant:"contained",size:"large",type:"submit",sx:{marginLeft:"auto"},children:"Try configuration"})]})]})},Ks=({headerText:n,bodyText:e,sectionNumber:t})=>p(j,{sx:{display:"flex",alignItems:"flex-start",mt:2,flexDirection:"column"},children:L(j,{sx:{display:"flex"},children:[p(j,{children:p(Zn,{children:t})}),L(j,{sx:{ml:2,display:"flex",flexDirection:"column"},children:[p(ie,{variant:"body1",sx:{fontWeight:"bold"},children:n}),p(z,{condition:Boolean(e),show:p(ie,{variant:"body1",sx:{mt:1},children:e})})]})]})}),Lf=()=>L(j,{sx:{ml:4},children:[p(ie,{variant:"body1",children:"Unleash playground is for helping you to undestand how unleash works, how feature toggles are evaluated and for you to easily debug your feature toggles."}),p(Zs,{sx:{mt:2,mb:2}}),p(ie,{variant:"body1",sx:{mb:1},children:"What you need to do is:"}),p(Ks,{headerText:"Select in which environment you want to test your feature toggle configuration",bodyText:"You can also specify specific projects, or check toggles in all projects.",sectionNumber:"1"}),p(Ks,{headerText:"Select a context field that you'd like to check",bodyText:"You can configure as many context fields as you want. You can also leave the context empty to test against an empty context.",sectionNumber:"2"}),p(Ks,{headerText:"Submit the form to try the configuration",bodyText:"The results of evaluating your feature toggles will appear after you submit the form. Then view the results.",sectionNumber:"3"})]}),db=()=>{const[n,e]=I.exports.useState(null),t=o=>e(o.currentTarget),i=()=>e(null),s=Boolean(n),r="playground-guidance-popper";return L(j,{children:[p(Oi,{onClick:t,"aria-describedby":r,children:p(vu,{})}),p(du,{id:r,open:s,anchorEl:n,sx:o=>({zIndex:o.zIndex.tooltip}),children:L(Ra,{sx:o=>({padding:o.spacing(8,4),maxWidth:"500px",borderRadius:`${o.shape.borderRadiusExtraLarge}px`}),children:[p(Oi,{onClick:i,sx:{position:"absolute",right:25,top:15},children:p(pu,{})}),p(Lf,{})]})})]})},gb=()=>{const{environments:n}=mu(),e=ke(),t=Ys(e.breakpoints.down("lg")),[i,s]=I.exports.useState(""),[r,o]=I.exports.useState([]),[l,a]=I.exports.useState(),[h,c]=I.exports.useState(),{setToastData:f}=Ta(),[u,d]=Da(),{evaluatePlayground:m,loading:y}=fd();I.exports.useEffect(()=>{s(pd(n))},[n]),I.exports.useEffect(()=>{try{const C=u.get("environment");C&&s(C);let k,O=u.get("projects");O&&(k=O.split(","),o(k));let F=u.get("context");F&&(F=decodeURI(F),a(F)),(async()=>{C&&F&&await x(C,k||"*",F)})()}catch(C){f({type:"error",title:`Failed to parse URL parameters: ${kn(C)}`})}},[]);const x=async(C,k,O,F)=>{try{const T=JSON.parse(O||"{}"),E=await m({environment:C,projects:dd(k),context:{appName:"playground",...T}});F&&typeof F=="function"&&F(),c(E)}catch(T){f({type:"error",title:`Error parsing context: ${kn(T)}`})}},b=async C=>{C.preventDefault(),await x(i,r,l,v)},v=()=>{u.set("context",encodeURI(l||"")),u.set("environment",i),Array.isArray(r)&&r.length>0&&!(r.length===1&&r[0]==="*")?u.set("projects",r.join(",")):u.delete("projects"),d(u)},M=h&&!t?"35%":"auto",S=md(t,h);return p(gu,{header:p(yu,{title:"Unleash playground",actions:p(db,{})}),disableLoading:!0,bodyClass:"no-padding",children:L(j,{sx:{display:"flex",flexDirection:t?"column":"row"},children:[p(j,{sx:{background:e.palette.playgroundBackground,borderBottomLeftRadius:e.shape.borderRadiusMedium},children:p(Ra,{elevation:0,sx:{px:4,py:3,mb:4,mt:2,background:e.palette.playgroundBackground,transition:"width 0.4s ease",minWidth:t?"auto":"500px",width:M,position:"sticky",top:0},children:p(ub,{onSubmit:b,context:l,setContext:a,environments:n,projects:r,environment:i,setProjects:o,setEnvironment:s})})}),p(j,{sx:C=>({width:S,transition:"width 0.4s ease",padding:C.spacing(4,2)}),children:p(z,{condition:y,show:p(bu,{}),elseShow:p(z,{condition:Boolean(h),show:p(cd,{loading:y,features:h==null?void 0:h.features,input:h==null?void 0:h.input}),elseShow:p(Lf,{})})})})]})})};export{gb as Playground,gb as default};
|